Computer Assited Medical Intervention Tool Kit  version 5.0
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-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 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 
42 class vtkObject;
43 namespace camitk {
44 class MainWindow;
45 class ActionExtension;
46 class ViewerExtension;
47 class Action;
48 class Viewer;
49 class HistoryItem;
50 class ComponentExtension;
51 class Property;
52 class PropertyObject;
53 
82 class CAMITK_API Application : public QApplication {
83  Q_OBJECT
84 
85 public:
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 
211  friend class Component;
212 
217  static const ComponentList& getTopLevelComponents();
218 
223  static const ComponentList& getAllComponents();
224 
226  static bool isAlive(Component*);
227 
229  static bool hasModified();
230 
232 
237 
241  static const ComponentList& getSelectedComponents();
242 
246  static void clearSelectedComponents();
248 
251 
253  static Action* getAction(QString);
254 
256  static const ActionList getActions();
257 
259  static ActionList getActions(Component*);
260 
262  static ActionList getActions(ComponentList);
263 
265  static ActionList getActions(ComponentList, QString);
266 
270  static int registerAllActions(ActionExtension*);
271 
275  static int unregisterAllActions(ActionExtension*);
276 
280  static void setTriggeredAction(Action* action);
281 
283  static Action* getTriggeredAction();
285 
288 
290  static Viewer* getViewer(QString name);
291 
295  static Viewer* getNewViewer(QString name, QString className);
296 
298  static const ViewerList getViewers();
299 
301  static ViewerList getViewers(Component*);
302 
304  static bool registerViewer(Viewer*);
305 
310  static int registerAllViewers(ViewerExtension*);
311 
315  static int unregisterAllViewers(ViewerExtension*);
317 
321 
332  void setMainWindow(MainWindow* mw);
333 
338  static MainWindow* getMainWindow();
339 
341  static void refresh();
342 
349  static void showStatusBarMessage(QString msg, int timeout = 0);
350 
354  static void resetProgressBar();
355 
361  static void setProgressBarValue(int);
362 
375  static void vtkProgressFunction(vtkObject* caller, long unsigned int, void*, void*);
377 
380 
385  static void addHistoryItem(HistoryItem item);
386 
390  static HistoryItem removeLastHistoryItem();
391 
396  static void saveHistoryAsSXML();
397 
399 
402 
405  static QString getSelectedLanguage();
407 
410 
416  static PropertyObject* getPropertyObject();
418 
419 private slots:
420  void quitting();
421 
422 private:
424  static QString name;
425 
428 
430  static int argc;
431 
433  static char** argv;
434 
436 
440  static QList<QFileInfo> recentDocuments;
441 
443  static QDir lastUsedDirectory;
444 
446  static int maxRecentDocuments;
447 
449  static QTranslator* translator;
451 
454 
461  static ComponentList& getTopLevelComponentList();
462 
470  static ComponentList& getAllComponentList();
471 
479  static ComponentList& getSelectedComponentList();
480 
493  static void setSelected(Component* component, bool isSelected);
494 
501  static void addComponent(Component*);
502 
509  static void removeComponent(Component*);
510 
512 
515 
517  static QSettings settings;
518 
520  static void applyPropertyValues();
522 
525 
536  static QStack<HistoryItem>& getHistory();
537 
539 
542 
552  static QMap<QString, Action*>& getActionMap();
553 
555  static ActionList sort(ActionSet);
557 
559  static ViewerList sort(ViewerSet);
561 
564 
576  static QMap<QString, Viewer*>& getViewerMap();
577 
578  static ViewerExtension* getViewerExtension(Viewer* viewer);
579 
581 
584 
587  static void createProperties();
588 
600 
602  static void initResources();
603 
604 protected:
609  bool eventFilter(QObject* object, QEvent* event) override;
610 };
611 
612 
613 
614 }
615 
616 #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
static QList< QFileInfo > recentDocuments
Definition: Application.h:440
static Action * currentAction
Definition: Application.h:435
static char ** argv
argv given from command line
Definition: Application.h:433
static MainWindow * mainWindow
the main window of the CamiTK application
Definition: Application.h:427
static int argc
argc given from command line
Definition: Application.h:430
static QString name
name of the CamiTK application (used to differentiate settings between CamiTK applications)
Definition: Application.h:424
static PropertyObject * propertyObject
A simple QObject that holds the CamiTK level properties of the application.
Definition: Application.h:598
static QSettings settings
global settings for CamiTK application
Definition: Application.h:517
static QDir lastUsedDirectory
last used directory
Definition: Application.h:443
static int maxRecentDocuments
max number of recent document (default 10)
Definition: Application.h:446
static QTranslator * translator
Provide internationalization support for text output.
Definition: Application.h:449
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