Computer Assisted Medical Intervention Tool Kit  version 6.0
Loading...
Searching...
No Matches
ViewerExtension.h
Go to the documentation of this file.
1/*****************************************************************************
2* $CAMITK_LICENCE_BEGIN$
3*
4* CamiTK - Computer Assisted Medical Intervention ToolKit
5* (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
6*
7* Visit http://camitk.imag.fr for more information
8*
9* This file is part of CamiTK.
10*
11* CamiTK is free software: you can redistribute it and/or modify
12* it under the terms of the GNU Lesser General Public License version 3
13* only, as published by the Free Software Foundation.
14*
15* CamiTK is distributed in the hope that it will be useful,
16* but WITHOUT ANY WARRANTY; without even the implied warranty of
17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18* GNU Lesser General Public License version 3 for more details.
19*
20* You should have received a copy of the GNU Lesser General Public License
21* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22*
23* $CAMITK_LICENCE_END$
24****************************************************************************/
25
26#ifndef VIEWER_EXTENSION_H
27#define VIEWER_EXTENSION_H
28
29#include "CamiTKAPI.h"
30
31// -- QT stuff
32#include <QRegularExpression>
33#include <QTranslator>
34
35namespace camitk {
36class Viewer;
37
43#define registerDefaultViewer(className) setManagedMetaObject(&className::staticMetaObject); \
44 registerViewer(new className(QString(#className).replace(QRegularExpression("([^A-Z\\s])([A-Z])"),"\\1 \\2").replace(QRegularExpression("([A-Z]+)([A-Z][a-z])"),"\\1 \\2")));
45
47#define registerNewViewer(className, instanceName) setManagedMetaObject(&className::staticMetaObject); \
48 registerViewer(new className(QString(instanceName)))
49
85class CAMITK_API ViewerExtension : public QObject {
86
87protected:
90
91public:
93 ~ViewerExtension() override;
94
96 virtual QString getName() const = 0;
97
99 virtual QString getDescription() const = 0;
100
102 virtual void init() = 0;
103
105 const ViewerList& getViewers();
106
108 void setLocation(const QString loc);
109
111 QString getLocation() const;
112
114 void initResources();
115
117 QString getViewerClassName() const;
118
121 Viewer* getNewInstance(QString name);
122
123protected:
127 bool registerViewer(Viewer*);
128
131
133 void setManagedMetaObject(const QMetaObject*);
134
135private:
137 QString dynamicLibraryFileName;
138
140 QTranslator* translator;
141
143 const QMetaObject* managedMetaObject;
144};
145
146}
147// -------------------- declare the interface for QPluginLoader --------------------
148Q_DECLARE_INTERFACE(camitk::ViewerExtension, "TIMC-IMAG. Viewer Extension/2.1") //TODO use variable from CMake?
149
150#endif //VIEWER_EXTENSION_H
151
#define CAMITK_API
Definition CamiTKAPI.h:66
This class describes what is a generic Action extension.
Definition ViewerExtension.h:85
QString getViewerClassName() const
get the class name of the viewer managed by this extension
Definition ViewerExtension.cpp:89
QString getLocation() const
get the file path (location of the .dll/.so/.dylib) of this plugin
Definition ViewerExtension.cpp:84
virtual void init()=0
this method should just call registerNewViewer(MyViewer) for any MyViewer class you need to register ...
virtual QString getDescription() const =0
returns the viewer extension small description (to be overriden in the derived class)
const ViewerList & getViewers()
get the list of viewer instances registered by this extension
Definition ViewerExtension.cpp:167
void initResources()
Load, for the selected langage (asked to the Application), the associated .qm file.
Definition ViewerExtension.cpp:57
bool registerViewer(Viewer *)
register an viewer instance The first call will also register the managed viewer class name in viewer...
Definition ViewerExtension.cpp:107
virtual QString getName() const =0
returns the viewer extension name (to be overriden in the derived class)
ViewerExtension()
constructor
Definition ViewerExtension.cpp:38
void setManagedMetaObject(const QMetaObject *)
The first time this method is called, it sets the static meta object.
Definition ViewerExtension.cpp:99
Viewer * getNewInstance(QString name)
factory: create a new viewer instance and register it
Definition ViewerExtension.cpp:138
ViewerList viewers
the list of viewers
Definition ViewerExtension.h:130
void setLocation(const QString loc)
set the file path (once loaded as a dynamic library) = where this extension was loaded
Definition ViewerExtension.cpp:79
Viewer is an abstract class that is the base class for all viewers.
Definition Viewer.h:182
Definition Action.cpp:40
QList< Viewer * > ViewerList
A list of Viewer.
Definition CamiTKAPI.h:173