- Create a directory called 'dti' (or the name of your plugin) in
the 'plugin' directory, copy the milxQtPluginInterface and rename it to
'milxQtDiffusionTensorPlugin' or equivalent.
- Open the file in you favourite editor and find/replace
'PluginInterface' with 'DiffusionTensorPlugin'. You may want to deal
with the guard block separately ensuring the use of capitals. Make sure
to add the include for milxQtPluginInterface
and remove the empty constructor and destructor (including the QThread
reference) with milxQtPluginInterface.
- Change the sub-classing to inherit from
milxQtPluginInterface,
something like changing from 'milxQtPluginInterface : public QThread'
to 'milxQtDiffusionTensorPlugin : public milxQtPluginInterface'. Also,
remove the '= 0' of all members except the ones in the 'public slots',
which can be replaced with empty {}. Lastly, remove all the non-virtual
members, signals and the private members as they are inheritted now.
- Change the plugin factory code near the bottom of the header to
something like (ensuring the removal of the Q_DECLARE_INTERFACE line):
class MILXQT_PLUGIN_EXPORT milxQtDiffusionTensorPluginFactory: public QObject,
public milxQtPluginFactory
{
Q_OBJECT
Q_INTERFACES(milxQtPluginFactory)
public:
milxQtPluginInterface* newPlugin(QObject *theParent = 0)
{ return new milxQtDiffusionTensorPlugin(theParent); }
};
Only two places required changing the 'DeNoise' string with
DiffusionTensor. That concludes the header changes.
- Copy the CMakeLists.txt from the denoise plugin and replace
'deNoise' with 'DTI' or equivalent. Remember that the plugin header and
source files are called 'milxQtDiffusionTensorPlugin'.
The name is important here as it must match the name you will give
later in the plugin source file. Remove references to other headers and
source files, you will eventually add your own here. We can also remove
the VTK or ITK references here until we need them later. However, Qt
references are required so don't remove them.
- Lastly, we need the plugin source file. You can copy and modify
the denoise version or create your own. The former is less error prone
and when doing the latter ensure that all virtual members are
implemented even if their stubs. To modify the denoise source, rename
and find/replace as we did before for the header file.
- Ensure that the export plugin (last) line looks like:
Q_EXPORT_PLUGIN2(DTIPlugin, milxQtDiffusionTensorPluginFactory);
Notice that the first argument is the same name as the plugin in the
CMakeLists.txt file. The second argument is the plugin factory class
found in the header. For the moment, we will comment out the
'createConnections', 'run()' and 'milxQtDeNoisePlugin::pluginWindow'
members fully, and comment the code inside the constructor,
'modelResult()' member, 'isPluginWindow()' member and the
'milxQtDiffusionTensorPlugin::loadExtension()' member.
- Ensure that all virtual members have an implementation in either
the source file or the header file. You may need to copy some inline
implementations from the denoise plugin header file too, such as
the'hasOpenSupport()' member etc.
- Finally, add the build sub-directory directive in the plugin
CMakeLists.txt file as
if(BUILD_DTI_PLUGIN)
add_subdirectory(dti)
endif(BUILD_DTI_PLUGIN)
Enable the option in the SMILI CMakeLists.txt file as
OPTION(BUILD_DTI_PLUGIN "Build the Diffusion Tensor plugin for MILX Qt Viewer" OFF)
- The plugin should now compile and build. The plugin will be
loaded by sMILX upon startup. It should output something like the
following in the Log window:
Attempting to Load libDTIPlugin.so
Instanced ...
- Now simply sub-class milxQtImage and/or milxQtModel and implement
functions commented in step 7 as in the denoise plugin to complete your
plugin.