Computer Assited Medical Intervention Tool Kit  version 5.0
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-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, 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() = 0;
97
99 virtual QString getDescription() = 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();
118
121 Viewer* getNewInstance(QString name);
122
123protected:
127 bool registerViewer(Viewer*);
128
131
133 void setManagedMetaObject(const QMetaObject*);
134
135private:
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:49
This class describes what is a generic Action extension.
Definition: ViewerExtension.h:85
virtual void init()=0
this method should just call registerNewViewer(MyViewer) for any MyViewer class you need to register ...
QTranslator * translator
Provide internationalization support for text output.
Definition: ViewerExtension.h:140
const QMetaObject * managedMetaObject
static meta object of the viewer class managed by this extension
Definition: ViewerExtension.h:143
ViewerList viewers
the list of viewers
Definition: ViewerExtension.h:130
virtual QString getDescription()=0
returns the viewer extension small description (to be overriden in the derived class)
virtual QString getName()=0
returns the viewer extension name (to be overriden in the derived class)
QString dynamicLibraryFileName
the shared lib (.so, .dll or .dylib) used to instantiate the ComponentExtension subclass instance
Definition: ViewerExtension.h:137
Viewer is an abstract class that is the base class for all viewers.
Definition: Viewer.h:180
Definition: Action.cpp:35
QList< Viewer * > ViewerList
A list of Viewer.
Definition: CamiTKAPI.h:139