Documentation/4.5/Developers/Modules

From Slicer Wiki
Revision as of 17:33, 21 November 2019 by Unknown user (talk) (Text replacement - "slicerWiki/index.php" to "wiki")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Home < Documentation < 4.5 < Developers < Modules


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


Slicer supports three types of modules. While the developer has to choose between one of the three 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 the Extension Wizard
  2. Read Compiling slicer modules outside of the slicer source tree.
  3. Learn from 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 the Extension Wizard
  2. Read Compiling slicer modules outside of the slicer source tree.
  3. Learn from existing modules

Scripted Modules

Scripted modules are written in Python.

An extensive tutorial and reference page was created for the Slicer/Python breakout session at the NA-MIC 2014 Summer Project Week. Please read through this and many of your questions will be answered.

Several tutorials for developers are available from the Slicer Training page: http://wiki.slicer.org/wiki/Documentation/Nightly/Training#Tutorials_for_software_developers

  • Python Console
  • Full access to the API: VTK, Qt, MRML and Slicer,SimpleITK are fully wrapped
  • Recommended for fast prototyping and custom workflow development
  • Where to start?
  1. Read the Slicer/Python breakout session at the NA-MIC 2014 Summer Project Week tutorial.
  2. Create initial skeleton using the Extension Wizard
  3. Python scripted module design - beyond basics (role of widget, logic, MRML classes, using MRML node for storing module parameters, etc.)
  4. Learn from 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