Computer Assisted Medical Intervention Tool Kit  version 5.2
 
Loading...
Searching...
No Matches
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-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 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
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
199 static bool loadWorkspace(const QString& filepath);
200
205 static bool close(Component* component);
206
212 static bool save(Component* component);
213
218 static bool saveWorkspace(const QString& filepath);
219
224 static const ComponentList& getTopLevelComponents();
225
230 static const ComponentList& getAllComponents();
231
233 static bool isAlive(Component*);
234
236 static bool hasModified();
237
239
244
248 static const ComponentList& getSelectedComponents();
249
253 static void clearSelectedComponents();
255
258
260 static Action* getAction(QString);
261
263 static const ActionList getActions();
264
266 static ActionList getActions(Component*);
267
269 static ActionList getActions(ComponentList);
270
272 static ActionList getActions(ComponentList, QString);
273
277 static int registerAllActions(ActionExtension*);
278
282 static int unregisterAllActions(ActionExtension*);
283
287 static void setTriggeredAction(Action* action);
288
290 static Action* getTriggeredAction();
292
295
297 static Viewer* getViewer(QString name);
298
302 static Viewer* getNewViewer(QString name, QString className);
303
305 static const ViewerList getViewers();
306
308 static ViewerList getViewers(Component*);
309
311 static bool registerViewer(Viewer*);
312
317 static int registerAllViewers(ViewerExtension*);
318
322 static int unregisterAllViewers(ViewerExtension*);
324
328
339 void setMainWindow(MainWindow* mw);
340
345 static MainWindow* getMainWindow();
346
348 static void refresh();
349
356 static void showStatusBarMessage(QString msg, int timeout = 0);
357
361 static void resetProgressBar();
362
368 static void setProgressBarValue(int);
369
382 static void vtkProgressFunction(vtkObject* caller, long unsigned int, void*, void*);
384
387
392 static void addHistoryItem(HistoryItem item);
393
397 static HistoryItem removeLastHistoryItem();
398
403 static void saveHistoryAsSXML();
404
406
409
412 static QString getSelectedLanguage();
414
417
423 static PropertyObject* getPropertyObject();
425
429 friend class Component;
430 friend class PersistenceManager;
432
433private slots:
434 void quitting();
435
436private:
438 static QString name;
439
441 static MainWindow* mainWindow;
442
444 static int argc;
445
447 static char** argv;
448
449 static Action* currentAction;
450
454 static QList<QFileInfo> recentDocuments;
455
457 static QDir lastUsedDirectory;
458
460 static int maxRecentDocuments;
461
463 static QTranslator* translator;
465
468
475 static ComponentList& getTopLevelComponentList();
476
484 static ComponentList& getAllComponentList();
485
493 static ComponentList& getSelectedComponentList();
494
507 static void setSelected(Component* component, bool isSelected);
508
515 static void addComponent(Component*);
516
523 static void removeComponent(Component*);
524
526
529
531 static QSettings settings;
532
534 static void applyPropertyValues();
535
537 static void applyMainWindowPropertyValues();
538
540
543
554 static QStack<HistoryItem>& getHistory();
555
557
560
570 static QMap<QString, Action*>& getActionMap();
571
573 static ActionList sort(ActionSet);
575
578
590 static QMap<QString, Viewer*>& getViewerMap();
591
593 static ViewerExtension* getViewerExtension(Viewer* viewer);
594
596 static ViewerList sort(ViewerSet);
598
601
604 static void createProperties();
605
615 static PropertyObject* propertyObject;
617
619 static void initResources();
620
621protected:
626 bool eventFilter(QObject* object, QEvent* event) override;
627};
628
629
630
631}
632
633#endif // CAMITKAPPLICATION_H
#define CAMITK_API
Definition CamiTKAPI.h:49
Definition canvas_typed/mainwindow.h:69
Definition PersistenceManager.h:34
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:209
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:303
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
Definition PersistenceManager.h:43
This class describes a property object.
Definition PropertyObject.h:72
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:181
Definition Action.cpp:36
QSet< Action * > ActionSet
A set of Action.
Definition CamiTKAPI.h:130
QSet< Viewer * > ViewerSet
A set of Viewer.
Definition CamiTKAPI.h:133
void refresh()
refresh the display