Computer Assisted Medical Intervention Tool Kit  version 5.1
Application.h
Go to the documentation of this file.
1/*****************************************************************************
2 * $CAMITK_LICENCE_BEGIN$
3 *
4 * CamiTK - Computer Assisted Medical Intervention ToolKit
5 * (c) 2001-2023 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 CAMITKAPPLICATION_H
27#define CAMITKAPPLICATION_H
28
29// -- Core stuff
30#include "CamiTKAPI.h"
31#include "InterfaceLogger.h"
32
33// -- QT stuff
34#include <QApplication>
35#include <QSettings>
36#include <QDir>
37#include <QFileInfo>
38#include <QStack>
39#include <QList>
40#include <QTranslator>
41
42class vtkObject;
43namespace camitk {
44class MainWindow;
45class ActionExtension;
46class ViewerExtension;
47class Action;
48class Viewer;
49class HistoryItem;
50class ComponentExtension;
51class Property;
52class PropertyObject;
53
82class CAMITK_API Application : public QApplication {
83 Q_OBJECT
84
85public:
86
91 SUBFRAME
92 };
93
94 Q_ENUM(TargetPositionningPolicy)
95
96
116 Application(QString name, int& argc, char** argv, bool autoloadExtension = true, bool registerFileExtension = false);
117
119 ~Application() override;
120
124
126 bool notify(QObject*, QEvent*) override;
127
129 static QString getName();
130
146 static QSettings& getSettings();
147
160 static int exec();
161
164 static const QDir getLastUsedDirectory();
165
167 static void setLastUsedDirectory(QDir);
168
172 static void addRecentDocument(QFileInfo);
173
175 static const QList<QFileInfo> getRecentDocuments();
176
178 static const int getMaxRecentDocuments();
179
181
185
189 static Component* open(const QString&);
190
195 static Component* openDirectory(const QString& dirName, const QString& pluginName);
196
201 static bool close(Component* component);
202
208 static bool save(Component* component);
209
214 static const ComponentList& getTopLevelComponents();
215
220 static const ComponentList& getAllComponents();
221
223 static bool isAlive(Component*);
224
226 static bool hasModified();
227
229
234
238 static const ComponentList& getSelectedComponents();
239
243 static void clearSelectedComponents();
245
248
250 static Action* getAction(QString);
251
253 static const ActionList getActions();
254
256 static ActionList getActions(Component*);
257
259 static ActionList getActions(ComponentList);
260
262 static ActionList getActions(ComponentList, QString);
263
267 static int registerAllActions(ActionExtension*);
268
272 static int unregisterAllActions(ActionExtension*);
273
277 static void setTriggeredAction(Action* action);
278
280 static Action* getTriggeredAction();
282
285
287 static Viewer* getViewer(QString name);
288
292 static Viewer* getNewViewer(QString name, QString className);
293
295 static const ViewerList getViewers();
296
298 static ViewerList getViewers(Component*);
299
301 static bool registerViewer(Viewer*);
302
307 static int registerAllViewers(ViewerExtension*);
308
312 static int unregisterAllViewers(ViewerExtension*);
314
318
329 void setMainWindow(MainWindow* mw);
330
335 static MainWindow* getMainWindow();
336
338 static void refresh();
339
346 static void showStatusBarMessage(QString msg, int timeout = 0);
347
351 static void resetProgressBar();
352
358 static void setProgressBarValue(int);
359
372 static void vtkProgressFunction(vtkObject* caller, long unsigned int, void*, void*);
374
377
382 static void addHistoryItem(HistoryItem item);
383
387 static HistoryItem removeLastHistoryItem();
388
393 static void saveHistoryAsSXML();
394
396
399
402 static QString getSelectedLanguage();
404
407
413 static PropertyObject* getPropertyObject();
415
419 friend class Component;
421
422private slots:
423 void quitting();
424
425private:
427 static QString name;
428
430 static MainWindow* mainWindow;
431
433 static int argc;
434
436 static char** argv;
437
438 static Action* currentAction;
439
443 static QList<QFileInfo> recentDocuments;
444
446 static QDir lastUsedDirectory;
447
449 static int maxRecentDocuments;
450
452 static QTranslator* translator;
454
457
464 static ComponentList& getTopLevelComponentList();
465
473 static ComponentList& getAllComponentList();
474
482 static ComponentList& getSelectedComponentList();
483
496 static void setSelected(Component* component, bool isSelected);
497
504 static void addComponent(Component*);
505
512 static void removeComponent(Component*);
513
515
518
520 static QSettings settings;
521
523 static void applyPropertyValues();
525
528
539 static QStack<HistoryItem>& getHistory();
540
542
545
555 static QMap<QString, Action*>& getActionMap();
556
558 static ActionList sort(ActionSet);
560
563
575 static QMap<QString, Viewer*>& getViewerMap();
576
578 static ViewerExtension* getViewerExtension(Viewer* viewer);
579
581 static ViewerList sort(ViewerSet);
583
586
589 static void createProperties();
590
600 static PropertyObject* propertyObject;
602
604 static void initResources();
605
606protected:
611 bool eventFilter(QObject* object, QEvent* event) override;
612};
613
614
615
616}
617
618#endif // CAMITKAPPLICATION_H
#define CAMITK_API
Definition: CamiTKAPI.h:49
Definition: canvas_typed/mainwindow.h:69
This class describes what is a generic Action extension.
Definition: ActionExtension.h:57
Action class is an abstract class that enables you to build a action (generally on a component).
Definition: Action.h:208
The generic/default application.
Definition: Application.h:82
TargetPositionningPolicy
: Policy to determine how a newly instantiated component's frame should be initialized regarding of i...
Definition: Application.h:88
@ SAME_TRANSFORMATION
New component has no parent frame (parent frame is set to nullptr), and its frame is copied from its ...
Definition: Application.h:89
@ NO_TRANSFORMATION
New component has no parent frame (parent frame is therefore set to nullptr) and transform is Id.
Definition: Application.h:90
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:302
HistoryItem class describes the entry of an action used in a pipeline, in the history.
Definition: HistoryItem.h:61
This class is the base class for your application.
Definition: MainWindow.h:66
This class describes a property object.
Definition: PropertyObject.h:71
This class describes what is a generic Action extension.
Definition: ViewerExtension.h:85
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
QSet< Action * > ActionSet
A set of Action.
Definition: CamiTKAPI.h:130
QList< Action * > ActionList
A list of Action.
Definition: CamiTKAPI.h:136
QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:127
QSet< Viewer * > ViewerSet
A set of Viewer.
Definition: CamiTKAPI.h:133
void refresh()
refresh the display