Computer Assisted Medical Intervention Tool Kit  version 5.2
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-2024 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 
35 namespace camitk {
36 class 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 
85 class CAMITK_API ViewerExtension : public QObject {
86 
87 protected:
90 
91 public:
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 
123 protected:
127  bool registerViewer(Viewer*);
128 
131 
133  void setManagedMetaObject(const QMetaObject*);
134 
135 private:
137  QString dynamicLibraryFileName;
138 
140  QTranslator* translator;
141 
143  const QMetaObject* managedMetaObject;
144 };
145 
146 }
147 // -------------------- declare the interface for QPluginLoader --------------------
148 Q_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 ...
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)
Viewer is an abstract class that is the base class for all viewers.
Definition: Viewer.h:181
Definition: Action.cpp:36