Medical Imaging Interaction Toolkit
2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
|
First, create a folder for your module within /Modules e.g. 'NewModule'. You need to add the new folder to the ModuleList.cmake file in the Module directory as well. Open /Modules/ModuleList.cmake, append the folder to the MITK_MODULES list.
A simple example module is provided in the MITK/Examples/FirstSteps/NewModule directory, it includes a new data type (more information at How to create a new custom data type) and adds a MiniApp for that data type (more information at How to create a MiniApp command line tool).
Within the module we recommend using a Unix like directory structure. This helps others finding their way around your code. Depending on your use case you might not need every directory.
Subsequently a quick description of what each directory contains.
This directory should not directly contain files. Instead it contains further directories each of which is its own module.
These modules provide functionality which should be available at application start, but will not be included by other modules. Examples would be a module registering readers/writers or providing an interface for specific hardware.
For an example of an autoload module take a look at NewModule/autoload/IO.
This directory contains all cmdapps (command line tools) related to your module. For more information see How to create a MiniApp command line tool.
This directory contains the documentation for your module.
This directory contains all header files which might be included by other modules.
This directory contains resources needed by your module, such as xmls, images or similar.
This directory contains source and header files which should not be included by other modules. Further subdivision can help keeping it organized. (e.g. src/DataManagement src/Algorithms)
This directory contains all tests for your module.
Within your module create a CMakeLists.txt using the MITK_CREATE_MODULE macro:
An example:
If you do not choose a module name, one will be generated based on the folder name (In this case the resulting name will be MitkNewModule). This name has to be unique across the entire project in order to avoid collisions. It should only contain Letters (both upper- and lowercase), no numbers, no underscores etc.
An example of an autoload module that sets its own name is:
the resulting name is MitkNewModuleIO.
Next, create a new file and name it files.cmake, containing the files of your module.
An example:
If you do not add a source file here it will not be compiled, unless it is included elsewhere.
Providing tests for your code is a very good way to save yourself a lot of debugging time and ensure consistency. An example of a small test environment is provided in the NewModule example.
Again you need a CMakeLists.txt, e.g.:
a files.cmake, e.g.:
and an actual test, e.g.:
For more information regarding tests please refer to Testing.
That's it! Enjoy your new module!