Computer Assited Medical Intervention Tool Kit  version 4.1
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
camitk::ComponentExtension Class Referenceabstract

This class describes what is a generic Component extension. More...

#include <ComponentExtension.h>

Inherits QObject.

Inherited by camitk::ImageAcquisitionComponentExtension, camitk::ImageComponentExtension, camitk::MeshComponentExtension, DicomComponentExtension, and MMLComponentExtension.

Public Member Functions

 ~ComponentExtension () override=default
 protected destructor, More...
 
ComponentExtension plugin interface methods

get the plugin name

virtual QString getName () const =0
 
virtual QString getDescription () const =0
 get the plugin description More...
 
virtual QStringList getFileExtensions () const =0
 get the list of managed extensions (each file with an extension in the list can be loaded by this Component) More...
 
virtual Componentopen (const QString &)=0
 get a new instance from data stored in a file (this is the most important method to redefine in your subclass) More...
 
virtual bool save (Component *component) const
 save a given Component (does not have to be top-level) into one of the currently managed format (check the component QFileInfo(component->getFileName()).completeSuffix(). More...
 
virtual bool hasDataDirectory () const
 return true if this component manages directory instead of individual files (e.g. Dicom series are stored in directories, not files) More...
 
QString getLocation () const
 get the file path (location of the .dll/.so/.dylib) of this plugin More...
 
void setLocation (const QString loc)
 set the file path (once loaded as a dynamic library) More...
 
void initResources ()
 Load, for the selected langage (asked to the Application), the associated .qm file. More...
 

Protected Member Functions

 ComponentExtension ()
 protected constructor, More...
 

Private Attributes

bool autoload
 the autoload state More...
 
QString dynamicLibraryFileName
 the shared lib (.so, .dll or .dylib) used to instanciate the ComponentExtension subclass instance More...
 

Detailed Description

This class describes what is a generic Component extension.

To add a ComponentExtension to CamiTK core, write a new class that inherits from this class.

There are two types of component extension: the classical one manages (mime type) file extension, the other one manages all files in a given directory (e.g. Dicom images). For the latter you have to redefine hasDataDirectory().

The following methods HAVE to be redefined in your subclass:

The following methods can be redefined:

Constructor & Destructor Documentation

◆ ComponentExtension()

camitk::ComponentExtension::ComponentExtension ( )
protected

protected constructor,

Note
never directly instanciate a ComponentExtension, use loadExtension(...) instead!

References autoload.

◆ ~ComponentExtension()

camitk::ComponentExtension::~ComponentExtension ( )
overridedefault

protected destructor,

Note
never directly delete a ComponentExtension, use UnloadExtension(...) instead!

Member Function Documentation

◆ getDescription()

virtual QString camitk::ComponentExtension::getDescription ( ) const
pure virtual

◆ getFileExtensions()

virtual QStringList camitk::ComponentExtension::getFileExtensions ( ) const
pure virtual

◆ getLocation()

QString camitk::ComponentExtension::getLocation ( ) const
inline

◆ getName()

virtual QString camitk::ComponentExtension::getName ( ) const
pure virtual

◆ hasDataDirectory()

virtual bool camitk::ComponentExtension::hasDataDirectory ( ) const
inlinevirtual

return true if this component manages directory instead of individual files (e.g. Dicom series are stored in directories, not files)

Reimplemented in DicomComponentExtension.

Referenced by camitk::ExtensionManager::loadExtension().

◆ initResources()

void camitk::ComponentExtension::initResources ( )

Load, for the selected langage (asked to the Application), the associated .qm file.

References CAMITK_INFO, getLocation(), and camitk::Application::getSelectedLanguage().

Referenced by camitk::ExtensionManager::loadExtension().

◆ open()

virtual Component* camitk::ComponentExtension::open ( const QString &  )
pure virtual

get a new instance from data stored in a file (this is the most important method to redefine in your subclass)

This method may throw an AbortException if a problem occurs.

Note
The parameter is a filename with an absolute path (from Qt's QFileInfo::absoluteFilePath method): On Unix (including Mac OS) this will always begin with the root, '/', directory. On Windows this will always begin 'D:/' where D is a drive letter, except for network shares that are not mapped to a drive letter, in which case the path will begin '//sharename/'

Implemented in DicomComponentExtension, VRMLComponentExtension, camitk::ImageComponentExtension, camitk::MeshComponentExtension, MMLComponentExtension, PMLComponentExtension, MshExtension, ItkImageComponentExtension, ObjExtension, OffExtension, StlExtension, VtkImageComponentExtension, and VtkMeshComponentExtension.

Referenced by MMLComponentExtension::MMLComponentExtension(), camitk::Application::open(), and camitk::Application::openDirectory().

◆ save()

bool camitk::ComponentExtension::save ( Component component) const
virtual

save a given Component (does not have to be top-level) into one of the currently managed format (check the component QFileInfo(component->getFileName()).completeSuffix().

Redefine this method to extract all needed data/information from the Geometry or BitMap representation in order to export a given component to one of the file extension managed by this component extension. It is advised to call component->setModified(false) when the saving has been performed successfully (this will reset the modification flag: component will not need to be saved prior to close).

Note
this will enable to export to one of the managed filename extension at the CamiTK level (i.e. if you write this method, any compatible component can be saved to your managed format!
this method is called by CamiTK only if the filename extension is managed by this component extension. There should be no need to check it in the method.

The default behaviour is a "not implemented yet" message box.

Returns
false if the operation was not performed properly or not performed at all.

Reimplemented in DicomComponentExtension, VRMLComponentExtension, MshExtension, MMLComponentExtension, PMLComponentExtension, ItkImageComponentExtension, OffExtension, StlExtension, VtkImageComponentExtension, VtkMeshComponentExtension, and ObjExtension.

References CAMITK_WARNING, camitk::Component::getFileName(), getName(), and camitk::Component::getName().

Referenced by MMLComponentExtension::MMLComponentExtension(), and MMLComponentExtension::save().

◆ setLocation()

void camitk::ComponentExtension::setLocation ( const QString  loc)
inline

set the file path (once loaded as a dynamic library)

Referenced by camitk::ExtensionManager::loadExtension().

Member Data Documentation

◆ autoload

bool camitk::ComponentExtension::autoload
private

the autoload state

Referenced by ComponentExtension().

◆ dynamicLibraryFileName

QString camitk::ComponentExtension::dynamicLibraryFileName
private

the shared lib (.so, .dll or .dylib) used to instanciate the ComponentExtension subclass instance


The documentation for this class was generated from the following files: