Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
Coding

General Information

Conceptually MITK is mainly geared to ITK (The Insight Toolkit). Thus, most of the ITK coding concepts can be transferred to MITK.

The ITK coding concepts can be found in the free ITK software guide, downloadable at ITKs homepage.

The main ITK concepts which one should look into before using MITK are:

  • SmartPointers
  • Pipelining and Filters

Coding Style

MITK provides coding style guidelines. When implementing code which should be added to the project, these guidelines should be followed in order to keep a unified coding style all over MITK. The style is geared to a common c++ coding style combined with some extension of used libraries, e.g. the use of itk smart pointers. The MITK style guide is provided on the page The MITK Style Guide and Technical Notes . If you are new to coding with MITK please also consider that MITK is using different pre defined macros, which might look confusing. An overview on these macros is given in section Macros in MITK.

Macros in MITK

MITK uses different macros to simplify implementation, but these macros might look confusing at first. Some of these macros are derived from ITK, others are defined in MITK itself. The most important macros are defined in the file mitkCommon.h, but there are some other headers which also define macros, e.g. mitkTestingMacros.h and mitkExceptionMacros.h.

In the following the most important macros are shown for overview, more details are available in the corresponding header files.

//These macros come from ITK:
itkNewMacro(Class);//this macro creates the constructor for smart pointers
//it calls the default c++ constructor of the class
//the default constructor should be declared protected
itkFactorylessNewMacro(Class); //like the itkNewMacro macro but does not use object factories
itkGetMacro(Name,Class); //these macros create getters and setters
itkSetMacro(Name,Class); //automatically, but you need the corresponding
itkGetConstMacro(Name,Class); //member variable m_Name in your class
itkSetConstMacro(Name,Class);
//The following macros are defined in MITK itself:
mitkClassMacro(Class,Superclass); //macro is needed in every header of a MITK class
mitkNewMacro1Param(Class,ParamType); //like the ITK new macro, but with one parameter
//you need a constructor with one parameter as well
//the same macro exists for 2,3 and 4 parameters
mitkExceptionClassMacro(Class,Superclass); //special macro for MITK exception classes