160 likes | 304 Views
Slicer Custom Modules. Steve Pieper, PhD. Overall Goals. Allow Independent Development of Run-Time Loadable Modules Enforce code independence Allow modules delivered under different licenses Support development outside of main cvs prior to code sharing
E N D
Slicer Custom Modules Steve Pieper, PhD
Overall Goals • Allow Independent Development of Run-Time Loadable Modules • Enforce code independence • Allow modules delivered under different licenses • Support development outside of main cvs prior to code sharing • The SLICER_MODULES environment variable • Space-separated list of directories containing slicer module directory trees • Used by cmaker, launch, and tarup • Allows you to keep your own code in a distinct cvs repository/working directory
What is a Module? • C++ code (optional) • VTK Subclasses • ITK Subclasses • Extra Helper code (GSL, OpenGL, etc) • Tcl code • Application Logic • User Interface Code
Directory Organization • Modules/vtk<ModuleName> • cxx • CMakeListsLocal.txt lists the source files plus custom build directives • tcl • <ModuleName>.tcl has standard slicer entry points • builds • Platform specific binary directories • Wrapping • Standard tcl/java/python wrapping support • data • Additional files your module needs (will be included in distribution by tarup.tcl)
Modules in Slicer CVS vtkCISGFile/ vtkITK/ vtkCorCTA/ vtkIbrowser/ BIRNDUP/ vtkCustomModule/ vtkImageSmooth/ vtkDTMRI/ vtkLevelSets/ LDMMViewer/ vtkEMLocalSegment/ vtkMIRIADSegment/ MultiVolumeReader/ vtkEMPrivateSegment/ vtkMorphometrics/ vtkFMRIEngine/ vtkRealignResample/ iSlicer/ vtkFSLReader/ vtkRigidIntensityRegistration/ vtkAffineSegment/ vtkFastMarching/ vtkSubVolume/ vtkAnalyze/ vtkFluxDiffusion/ vtkTensorUtil/ vtkBXH/ vtkFreeSurferReaders/ vtkVolumeTextureMapping/
vtkCustomModule • A support script to help manage the many files that need to be created/customized when making a vtk loadable library source tree • Modules/vtkCustomModule/README.txt describes the step-by-step process
Module Making Steps • Copy vtkCustomModule to vtk<ModuleName> and cd to that dir • Remove all CVS subdirs • (e.g. with rm -r `find . -name CVS` ) • Run ./vtkNameModule • Your <ModuleName> will be propagated to the various files
Module Making Steps (cont) • Add your source files to cxx directory • Add references to files in CMakeListsLocal.txt (copy from SAMPLE) SET(LOCAL_MODULE_SRCS vtkMultiInputsSimpleImageToImageFilter.cxx vtkActivationVolumeGenerator.cxx vtkActivationDetector.cxx vtkCDF.cxx )
Module Making Steps (cont) • Set any classes not to be wrapped SET ( LOCAL_NO_WRAP_SRCS GeneralLinearModel.cxx ) • Set any Abstract classes SET_SOURCE_FILES_PROPERTIES ( vtkMultiInputsSimpleImageToImageFilter.cxx ABSTRACT )
Module Making Steps (cont) • If your code subclasses Slicer classes, uncomment the include directories lines and add other modules you depend on if needed: INCLUDE_DIRECTORIES( ${VTKSLICERBASE_SOURCE_DIR}/cxx ${VTKSLICERBASE_BUILD_DIR} ${VTKTENSORUTIL_SOURCE_DIR}/cxx ${VTKTENSORUTIL_BUILD_DIR} ) … LINK_LIBRARIES (${VTKSLICERBASE_BUILD_LIB} ${VTKTENSORUTIL_BUILD_LIB} ${VTKTENSORUTIL_BUILD_TCL_LIB})
Module Cxx Code • To ensure Windows dll files will be built correctly, be sure your .h files have the following code: #include <vtkModuleNameConfigure.h> and class VTK_MODULENAME_EXPORT vtkTest : ...
Module Tcl Files • vtkNameModule will create a tcl/ModuleName.tcl file for you with a default UI • Comments in that file tell how to customize your interface for your application
Module Tcl Wrapping • In the Wrapping/Tcl/vtk<ModuleName>/vtk<ModuleName>.tcl file: • Source all tcl files your module needs • If your module depends on another module, include, for example: package require vtkTensorUtil
What you get for this work • Cross-platform build and automatic detection at run time • Spot in the slicer “More:” menu and in the Hierarchical “Modules” menu on the main toolbar • Ability to interact with slicer scene
ITK Based Modules • Depend on vtkITK Module for build • To allow subclassing the vtkITKImageToImageFilters • Write vtkITK wrapper class (Raul will describe in the next section) • Just use the filter as if it were a vtk class if {[info command vtkITKBSplineImageFilter] == ""} { DevErrorWindow "DTMRI\nERROR: vtkITKBSplineImageFilter does not exist, cannot use bspline filter“ return } DTMRIMakeVTKObject vtkITKBSplineImageFilter bspline($i)
Resources • www.slicer.org • www.na-mic.org/Wiki • www.na-mic.org/Bug • www.na-mic.org/Testing • slicer-devel@bwh.harvard.edu • slicer-users@bwh.harvard.edu