12
NA-MIC National Alliance for Medical Image Computing http://na-mic.org Slicer / ITK / VTK Development Tools Steve Pieper, PhD

NA-MIC National Alliance for Medical Image Computing Slicer / ITK / VTK Development Tools Steve Pieper, PhD

Embed Size (px)

Citation preview

Page 1: NA-MIC National Alliance for Medical Image Computing  Slicer / ITK / VTK Development Tools Steve Pieper, PhD

NA-MICNational Alliance for Medical Image Computing http://na-mic.org

Slicer / ITK / VTK Development Tools

Steve Pieper, PhD

Page 2: NA-MIC National Alliance for Medical Image Computing  Slicer / ITK / VTK Development Tools Steve Pieper, PhD

National Alliance for Medical Image Computing http://na-mic.org

Overall Goals

• Understanding the Big Picture:– Code browsing with ctags– Source Navigator

• Debugging:– tkcon– Using the native debuggers– itkFilterWatcher

Page 3: NA-MIC National Alliance for Medical Image Computing  Slicer / ITK / VTK Development Tools Steve Pieper, PhD

National Alliance for Medical Image Computing http://na-mic.org

Ctags

• Exuberant CTAGS– Ctags.sf.net

• Provides detailed tag files for emacs and vi

• Run in top level directory with– ctags –r .

Page 4: NA-MIC National Alliance for Medical Image Computing  Slicer / ITK / VTK Development Tools Steve Pieper, PhD

National Alliance for Medical Image Computing http://na-mic.org

Source Navigator

• http://sourcenav.sourceforge.net/– Linux source code to compile– Windows binaries

Page 5: NA-MIC National Alliance for Medical Image Computing  Slicer / ITK / VTK Development Tools Steve Pieper, PhD

National Alliance for Medical Image Computing http://na-mic.org

Source Navigator

• Multi-directory class browser (see whole project)

• Hierarchy Display

• View all code– Jump to definitions and declarations– See comments and code

• Grep UI

Page 6: NA-MIC National Alliance for Medical Image Computing  Slicer / ITK / VTK Development Tools Steve Pieper, PhD

National Alliance for Medical Image Computing http://na-mic.org

Native Tools

• CMake creates makefiles and .SLN files that can be used outside of CMake for debugging– Resolve linker or option issues

• Can attach to running process with gdb or visual studio– Debug the C++ code

Page 7: NA-MIC National Alliance for Medical Image Computing  Slicer / ITK / VTK Development Tools Steve Pieper, PhD

National Alliance for Medical Image Computing http://na-mic.org

Visual Studio Slicer Debugging

• Start Slicer

• Tools->Debug Processes– Attach to wish84.exe, Slicer 2.4– Run program until it crashes– Browse to Source directory and set

breakpoints

Page 8: NA-MIC National Alliance for Medical Image Computing  Slicer / ITK / VTK Development Tools Steve Pieper, PhD

National Alliance for Medical Image Computing http://na-mic.org

gdb Debugging

• Start slicer

• Use ps to find process id of ‘parent’ vtk thread

• Use gdb command ‘attach <pid>’

Page 9: NA-MIC National Alliance for Medical Image Computing  Slicer / ITK / VTK Development Tools Steve Pieper, PhD

National Alliance for Medical Image Computing http://na-mic.org

Tkcon

• Very smart console written in Tk– Identifier completion

• Files• Variables• Class instances• UI Windows

– Command line editing like readline

• Create VTK class instances and experiment

• Write and test tcl code interactively

Page 10: NA-MIC National Alliance for Medical Image Computing  Slicer / ITK / VTK Development Tools Steve Pieper, PhD

National Alliance for Medical Image Computing http://na-mic.org

Interactive VTK Commands

• <instance> ListMethods– Tells all instances currently known to

the interpreter

• <instance> Print– Calls the PrintSelf method

• <instance> ListMethods– Tell what methods are available in the

interpreter

Page 11: NA-MIC National Alliance for Medical Image Computing  Slicer / ITK / VTK Development Tools Steve Pieper, PhD

National Alliance for Medical Image Computing http://na-mic.org

itk::FilterWatcher

• Uses itk Observer mechanism to register callbacks for common events– StartEvent– ProgressEvent– EndEvent

• Prints total running time

Page 12: NA-MIC National Alliance for Medical Image Computing  Slicer / ITK / VTK Development Tools Steve Pieper, PhD

National Alliance for Medical Image Computing http://na-mic.org

Most useful debugging tool

• Print statements in the code!– Just remember to remove them when

you are done debugging…– Be sure to flush them– Or, use the –verbose option in slicer

to control debugging flags