Computer Assited Medical Intervention Tool Kit  version 4.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-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
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 Action;
47 class HistoryItem;
48 class ComponentExtension;
49 class Property;
50 class PropertyObject;
51 
63 class CAMITK_API Application : public QApplication {
64  Q_OBJECT
65 
66 public:
67 
72  SUBFRAME
73  };
74 
76 
77 
97  Application(QString name, int& argc, char** argv, bool autoloadExtension = true, bool registerFileExtension = false);
98 
100  ~Application() override;
101 
104 
107  bool notify(QObject*, QEvent*) override;
108 
110  static QString getName();
111 
127  static QSettings& getSettings();
128 
141  static int exec();
142 
145  static const QDir getLastUsedDirectory();
146 
148  static void setLastUsedDirectory(QDir);
149 
153  static void addRecentDocument(QFileInfo);
154 
156  static const QList<QFileInfo> getRecentDocuments();
157 
159  static const int getMaxRecentDocuments();
160 
162 
165 
170  static Component* open(const QString&);
171 
176  static Component* openDirectory(const QString& dirName, const QString& pluginName);
177 
182  static bool close(Component* component);
183 
189  static bool save(Component* component);
190 
192  friend class Component;
193 
198  static const ComponentList& getTopLevelComponents();
199 
204  static const ComponentList& getAllComponents();
205 
207  static bool isAlive(Component*);
208 
210  static bool hasModified();
211 
213 
218 
222  static const ComponentList& getSelectedComponents();
223 
227  static void clearSelectedComponents();
228 
230 
233 
235  static Action* getAction(QString);
236 
238  static const ActionList getActions();
239 
241  static ActionList getActions(Component*);
242 
244  static ActionList getActions(ComponentList);
245 
247  static ActionList getActions(ComponentList, QString);
248 
252  static int registerAllActions(ActionExtension*);
253 
257  static int unregisterAllActions(ActionExtension*);
259 
262 
274  void setMainWindow(MainWindow* mw);
275 
277  static MainWindow* getMainWindow();
278 
280  static void refresh();
281 
288  static void showStatusBarMessage(QString msg, int timeout = 0);
289 
293  static void resetProgressBar();
294 
300  static void setProgressBarValue(int);
301 
314  static void vtkProgressFunction(vtkObject* caller, long unsigned int, void*, void*);
316 
319 
324  static void addHistoryItem(HistoryItem item);
325 
329  static HistoryItem removeLastHistoryItem();
330 
335  static void saveHistoryAsSXML();
336 
338 
341 
344  static QString getSelectedLanguage();
346 
349 
355  static PropertyObject* getPropertyObject();
357 
358 private slots:
359  void quitting();
360 
361 private:
363  static QString name;
364 
367 
369  static int argc;
370 
372  static char** argv;
373 
377  static QList<QFileInfo> recentDocuments;
378 
380  static QDir lastUsedDirectory;
381 
383  static int maxRecentDocuments;
384 
386  static QTranslator* translator;
388 
391 
398  static ComponentList& getTopLevelComponentList();
399 
407  static ComponentList& getAllComponentList();
408 
416  static ComponentList& getSelectedComponentList();
417 
430  static void setSelected(Component* component, bool isSelected);
431 
438  static void addComponent(Component*);
439 
446  static void removeComponent(Component*);
447 
449 
452 
454  static QSettings settings;
455 
457  static void applyPropertyValues();
459 
464 
471  static QStack<HistoryItem>& getHistory();
472 
474 
477 
484  static QMap<QString, Action*>& getActionMap();
485 
487  static ActionList sort(ActionSet);
489 
491  static void initResources();
492 
493 
496 
499  static void createProperties();
500 
512 
513 protected:
518  bool eventFilter(QObject* object, QEvent* event) override;
519 };
520 
521 
522 
523 }
524 
526 
527 #endif // CAMITKAPPLICATION_H
The generic/default application.
Definition: Application.h:63
static int maxRecentDocuments
max number of recent document (default 10)
Definition: Application.h:383
static MainWindow * mainWindow
the main window of the CamiTK application
Definition: Application.h:366
static int argc
argc given from command line
Definition: Application.h:369
Action class is an abstract class that enables you to build a action (generally on a component)...
Definition: Action.h:207
TargetPositionningPolicy
: Policy to determine how a newly instanciated component&#39;s frame should be initialized regarding of i...
Definition: Application.h:69
New component has no parent frame (parent frame is set to nullptr), and its frame is copied from its ...
Definition: Application.h:70
This Class is the base class for your application.
Definition: MainWindow.h:62
Definition: Action.cpp:36
static QSettings settings
global settings for CamiTK application
Definition: Application.h:454
static PropertyObject * propertyObject
A simple QObject that holds the CamiTK level properties of the application.
Definition: Application.h:510
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:298
static QList< QFileInfo > recentDocuments
Definition: Application.h:377
#define CAMITK_API
Definition: CamiTKAPI.h:49
This class describes a property object.
Definition: PropertyObject.h:71
This class describes what is a generic Action extension.
Definition: ActionExtension.h:59
HistoryItem class describes the entry of an action used in a pipeline, in the history.
Definition: HistoryItem.h:61
QList< Action * > ActionList
A list of Action.
Definition: CamiTKAPI.h:95
static char ** argv
argv given from command line
Definition: Application.h:372
QSet< Action * > ActionSet
A set of Action.
Definition: CamiTKAPI.h:92
static QString name
name of the CamiTK application (used to differentiate settings between CamiTK applications) ...
Definition: Application.h:363
New component has no parent frame (parent frame is therefore set to nullptr) and transform is Id...
Definition: Application.h:71
QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:89
static QTranslator * translator
Provide internationalization support for text output.
Definition: Application.h:386
This properties and methods helps registering an applied action in the history of the application...
static QDir lastUsedDirectory
last used directory
Definition: Application.h:380
Definition: canvas_typed/mainwindow.h:69