Computer Assisted Medical Intervention Tool Kit version 6.0
 
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-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 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;
53class SplashScreen;
54
83class CAMITK_API Application : public QApplication {
84 Q_OBJECT
85
86public:
87
110 Application(QString name, int& argc, char** argv, bool autoloadExtension = true, bool registerFileExtension = false, bool useSplashScreen = false);
111
113 ~Application() override;
114
118
120 bool notify(QObject*, QEvent*) override;
121
123 static QString getName();
124
140 static QSettings& getSettings();
141
154 static int exec();
155
157 static void restart(QString reason);
158
161 static const QDir getLastUsedDirectory();
162
164 static void setLastUsedDirectory(QDir);
165
169 static void addRecentDocument(QString);
170
172 static const QList<QFileInfo> getRecentDocuments();
173
175 static const int getMaxRecentDocuments();
176
178
182
188 static Component* open(const QString& fileName, bool blockRefresh = false);
189
194 static Component* openDirectory(const QString& dirName, const QString& pluginName);
195
198 static bool loadWorkspace(const QString& filepath);
199
205 static bool close(Component* component, bool blockRefresh = false);
206
212 static bool save(Component* component);
213
218 static bool saveWorkspace(const QString& filepath);
219
227 static QString getUniqueComponentName(QString name, const ComponentList& components = getTopLevelComponents());
228
233 static const ComponentList& getTopLevelComponents();
234
239 static const ComponentList& getAllComponents();
240
242 static bool isAlive(Component*);
243
245 static bool isAlive(Action*);
246
248 static bool hasModified();
249
251
256
260 static const ComponentList& getSelectedComponents();
261
265 static void clearSelectedComponents();
267
270
272 static Action* getAction(QString);
273
275 static const ActionList getActions();
276
278 static ActionList getActions(Component*);
279
281 static ActionList getActions(ComponentList);
282
284 static ActionList getActions(ComponentList, QString);
285
289 static int registerAllActions(ActionExtension*);
290
294 static int unregisterAllActions(ActionExtension*);
295
299 static void setTriggeredAction(Action* action);
300
302 static Action* getTriggeredAction();
304
307
309 static Viewer* getViewer(QString name);
310
314 static Viewer* getNewViewer(QString name, QString className);
315
317 static const ViewerList getViewers();
318
320 static const ViewerList getViewers(Component*);
321
323 static bool registerViewer(Viewer*);
324
329 static int registerAllViewers(ViewerExtension*);
330
334 static int unregisterAllViewers(ViewerExtension*);
336
340
352 void setMainWindow(MainWindow* mw, bool redirect = true);
353
358 static MainWindow* getMainWindow();
359
361 static void refresh();
362
369 static void showStatusBarMessage(QString msg, int timeout = 0);
370
374 static void resetProgressBar();
375
381 static void setProgressBarValue(int);
382
395 static void vtkProgressFunction(vtkObject* caller, long unsigned int, void*, void*);
397
400
405 static void addHistoryItem(HistoryItem item);
406
410 static HistoryItem removeLastHistoryItem();
411
416 static void saveHistoryAsSCXML();
417
419
422
425 static QString getSelectedLanguage();
427
430
436 static PropertyObject* getPropertyObject();
438
439
443 friend class Component;
444 friend class PersistenceManager;
446
447private slots:
448 void quitting();
449
450private:
452 static QString name;
453
455 static MainWindow* mainWindow;
456
458 static SplashScreen* splashScreen;
459
461 static int argc;
462
464 static char** argv;
465
466 static Action* currentAction;
467
471 static QList<QFileInfo> recentDocuments;
472
474 static QDir lastUsedDirectory;
475
477 static int maxRecentDocuments;
478
480 static QTranslator* translator;
482
485
492 static ComponentList& getTopLevelComponentList();
493
501 static ComponentList& getAllComponentList();
502
510 static ComponentList& getSelectedComponentList();
511
524 static void setSelected(Component* component, bool isSelected);
525
532 static void addComponent(Component*);
533
540 static void removeComponent(Component*);
541
543
546
548 static QSettings settings;
549
551 static void applyPropertyValues();
552
554 static void applyMainWindowPropertyValues();
555
557
560
571 static QStack<HistoryItem>& getHistory();
572
574
577
587 static QMap<QString, Action*>& getActionMap();
588
590 static ActionList sort(ActionSet);
592
595
607 static QMap<QString, Viewer*>& getViewerMap();
608
610 static ViewerExtension* getViewerExtension(Viewer* viewer);
611
613 static ViewerList sort(ViewerSet);
615
618
621 static void createProperties();
622
632 static PropertyObject* propertyObject;
634
636 static void initResources();
637
638protected:
643 bool eventFilter(QObject* object, QEvent* event) override;
644};
645
646
647
648}
649
650#endif // CAMITKAPPLICATION_H
#define CAMITK_API
Definition CamiTKAPI.h:66
Definition canvas_typed/mainwindow.h:69
Definition PersistenceManager.h:30
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 an algorithm that wor...
Definition Action.h:215
The generic/default application.
Definition Application.h:83
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition sdk/libraries/core/component/Component.h:304
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:68
This class describes a property object.
Definition PropertyObject.h:72
CamiTK application splash screen.
Definition SplashScreen.h:44
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:182
Definition action.py:1
Definition Action.cpp:40
QSet< Action * > ActionSet
A set of Action.
Definition CamiTKAPI.h:164
QSet< Viewer * > ViewerSet
A set of Viewer.
Definition CamiTKAPI.h:167