Difference between revisions of "Documentation/4.1/Developers/Modules"

From Slicer Wiki
Jump to: navigation, search
m (Text replacement - "slicerWiki/index.php" to "wiki")
 
(23 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
<noinclude>{{documentation/versioncheck}}</noinclude>
 
Slicer supports 3 types of modules. While the developer has to choose between one of the 3 types to implement its module, the end user won't notice the difference as they all share the same look & feel. The choice for a given type of module is usually based on the type of inputs/parameters for a given module.
 
Slicer supports 3 types of modules. While the developer has to choose between one of the 3 types to implement its module, the end user won't notice the difference as they all share the same look & feel. The choice for a given type of module is usually based on the type of inputs/parameters for a given module.
 +
 
= Command Line Interface (CLI) =
 
= Command Line Interface (CLI) =
CLIs are standalone executables with a limited input/output arguments complexity (simple argument types, no user interactions...). They are typically implemented using ITK.
+
CLIs are standalone executables with a limited input/output arguments complexity (simple argument types, no user interactions...). They are typically implemented using [http://www.itk.org ITK].
The recommended way to write your own CLI is to base your work on an [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ existing module] using the [[Documentation/{{documentation/version}}/Developers/ModuleWizard|module wizard]].
 
 
* Shared lib or executable
 
* Shared lib or executable
* GUI automatically generated
+
* UI automatically generated
 +
* Where to start ?
 +
# Create initial skeleton using [[Documentation/{{documentation/version}}/Developers/ModuleWizard|module wizard]]
 +
# Read [[Documentation/{{documentation/version}}/Developers/Build_Module|Compiling slicer modules outside of the slicer source tree.]]
 +
# Learn from existing [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/CLI/ existing modules]
 
* Links:
 
* Links:
 
** [[Slicer3:Execution_Model_Documentation|Slicer3 execution model]] (Slicer4 is very similar)
 
** [[Slicer3:Execution_Model_Documentation|Slicer3 execution model]] (Slicer4 is very similar)
Line 10: Line 15:
  
 
= Loadable Modules =
 
= Loadable Modules =
Loadable modules are C++ plugins that are built against Slicer. They define custom GUIs for their specific behavior as they have full control over the application.
+
Loadable modules are [http://en.wikipedia.org/wiki/C%2B%2B C++] plugins that are built against Slicer. They define custom GUIs for their specific behavior as they have full control over the application.
 
* C++ shared library
 
* C++ shared library
* Full control over the GUI (Qt) and Slicer internals (MRML, logics, display managers...)
+
* Full control over the UI (based on [http://qt.nokia.com/products/ Qt]) and Slicer internals (MRML, logics, display managers...)
 
* Optimized for heavy computations
 
* Optimized for heavy computations
 +
* Where to start ?
 +
# Create initial skeleton using [[Documentation/{{documentation/version}}/Developers/ModuleWizard|module wizard]]
 +
# Read [[Documentation/{{documentation/version}}/Developers/Build_Module|Compiling slicer modules outside of the slicer source tree.]]
 +
# Learn from existing [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Loadable/ existing modules]
 
* Links:
 
* Links:
 
**[http://www.na-mic.org/Wiki/index.php/File:LoadableModules.pptx Loadable modules] (presentation of 2012 NAMIC AHM)
 
**[http://www.na-mic.org/Wiki/index.php/File:LoadableModules.pptx Loadable modules] (presentation of 2012 NAMIC AHM)
Line 19: Line 28:
  
 
= Scripted Modules =
 
= Scripted Modules =
Scripted modules are written in Python and typically but not necessarily use the high level API of Slicer and toolkits.   
+
Scripted modules are written in [http://www.python.org/ Python] and typically but not necessarily use the high level API of Slicer and toolkits.   
 
* Python Console
 
* Python Console
* Full access to the API: VTK, ITK, MRML, Qt and Slicer are fully wrapped
+
* Full access to the API: [http://www.vtk.org VTK], [http://www.itk.org ITK], MRML, [http://qt.nokia.com/products/ Qt] and Slicer are fully wrapped
 
* Recommended for fast prototyping
 
* Recommended for fast prototyping
 +
* Where to start ?
 +
# Create initial skeleton using [[Documentation/{{documentation/version}}/Developers/ModuleWizard|module wizard]]
 +
# Read [[Documentation/{{documentation/version}}/Developers/Build_Module|Compiling slicer modules outside of the slicer source tree.]]
 +
# Learn from existing [http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/Modules/Scripted/ existing modules]
 
* Links:
 
* Links:
** [http://www.slicer.org/slicerWiki/index.php/Documentation/{{documentation/version}}/Developers/Python_scripting|Python Scripting]
+
** [http://www.slicer.org/wiki/Documentation/{{documentation/version}}/Developers/Python_scripting Python Scripting]
** See the [[Documentation/{{documentation/version}}/Training#Slicer4_Programming_Tutorial|Python Scripting Tutorial]]
+
** [[Documentation/{{documentation/version}}/Training#Slicer4_Programming_Tutorial|Python Scripting Tutorial]]
  
 
=Module Factory=
 
=Module Factory=

Latest revision as of 17:02, 21 November 2019

Home < Documentation < 4.1 < Developers < Modules


For the latest Slicer documentation, visit the read-the-docs.


Slicer supports 3 types of modules. While the developer has to choose between one of the 3 types to implement its module, the end user won't notice the difference as they all share the same look & feel. The choice for a given type of module is usually based on the type of inputs/parameters for a given module.

Command Line Interface (CLI)

CLIs are standalone executables with a limited input/output arguments complexity (simple argument types, no user interactions...). They are typically implemented using ITK.

  • Shared lib or executable
  • UI automatically generated
  • Where to start ?
  1. Create initial skeleton using module wizard
  2. Read Compiling slicer modules outside of the slicer source tree.
  3. Learn from existing existing modules

Loadable Modules

Loadable modules are C++ plugins that are built against Slicer. They define custom GUIs for their specific behavior as they have full control over the application.

  • C++ shared library
  • Full control over the UI (based on Qt) and Slicer internals (MRML, logics, display managers...)
  • Optimized for heavy computations
  • Where to start ?
  1. Create initial skeleton using module wizard
  2. Read Compiling slicer modules outside of the slicer source tree.
  3. Learn from existing existing modules

Scripted Modules

Scripted modules are written in Python and typically but not necessarily use the high level API of Slicer and toolkits.

  • Python Console
  • Full access to the API: VTK, ITK, MRML, Qt and Slicer are fully wrapped
  • Recommended for fast prototyping
  • Where to start ?
  1. Create initial skeleton using module wizard
  2. Read Compiling slicer modules outside of the slicer source tree.
  3. Learn from existing existing modules

Module Factory

Loading modules into slicer happens in multiple steps:

  • module factories must be registered into the factory manager
  • directories where the modules to load are located must be passed to the factory manager
  • Optionally specify module names to ignore
  • scan the directories and test which file is a module and register it (not instantiated yet)
  • Instantiate all the register modules
  • Connect each module with the scene and the application

More details can be found in the online doc

ToDo

  • Transform all core modules into Loadable modules.
    • the factory manager only support file based modules, core modules are not file based (linked into the core factory itself)
  • Move factory registration in qSlicerApplication (or a general application library) to support module discovery/loading without needing to instantiate Slicer.
    • Currently can't be moved into qSlicerApplication as the CLI factories that are in QTCLI depend on QTGUI
    • QtTesting is also limited with the QTCLI dependency on QtGUI (->qSlicerApplication would need to access QtTesting code from QtCli)
    • Proposed architecture
Base
  Application -> classes that are useful to build an application (mix of qSlicerCoreApplication, qSlicerApplication, Main.cxx...)
  Core -> formally QtCore
  Modules -> contains the factories and module specific code
     Loadable
     CLI
     Scripted
  Scripted -> all that is python specific
     Cxx
     Python
  Widgets -> formally QtGUI
  • Add category hierarchy in the Settings module panel
  • Register factory settings/command-options(e.g. disable-loadable-modules) when registering module factories
    • To have the settings panel be generic but have the code proper of each registered factory somewhere else
  • Add mechanism for modules to register dialogs (toolbars that open dialogs), e.g. the sceneview module needs to register the sceneView dialog into an icon.
  • Ignore modules from the launcher command line.
  • cloning" of module panels at run time. See "here and here