Computer Assited Medical Intervention Tool Kit  version 4.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-2016 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 
32 // -- QT stuff
33 #include <QApplication>
34 #include <QSettings>
35 #include <QDir>
36 #include <QFileInfo>
37 #include <QStack>
38 #include <QList>
39 #include <QTranslator>
40 
41 class vtkObject;
42 namespace camitk {
43 class MainWindow;
44 class ActionExtension;
45 class Action;
46 class HistoryItem;
47 class ComponentExtension;
48 class Property;
49 class PropertyObject;
50 
62 class CAMITK_API Application : public QApplication {
63  Q_OBJECT
64 
65 public:
66 
68  SAME_TRANSFORMATION, // Child has the same frame as its parent (parent frame = world).
69  NO_TRANSFORMATION, // Child has no frame and parent frame = world.
70  SUBFRAME // Child has no frame but its parent is set as its parent frame.
71  };
72 
74 
75 
76 
95  Application(QString name, int & argc, char ** argv, bool autoloadExtension = true, bool registerFileExtension = false);
96 
98  virtual ~Application();
99 
102 
105  static QString getName();
106 
122  static QSettings & getSettings();
123 
136  static int exec();
137 
140  static const QDir getLastUsedDirectory();
141 
143  static void setLastUsedDirectory(QDir);
144 
148  static void addRecentDocument(QFileInfo);
149 
151  static const QList<QFileInfo> getRecentDocuments();
152 
154  static const int getMaxRecentDocuments();
155 
157 
160 
165  static Component * open(const QString &);
166 
171  static Component * openDirectory(const QString & dirName, const QString & pluginName);
172 
177  static bool close(Component *component);
178 
184  static bool save(Component * component);
185 
187  friend class Component;
188 
193  static const ComponentList & getTopLevelComponents();
194 
199  static const ComponentList & getAllComponents();
200 
202  static bool isAlive(Component *);
203 
205  static bool hasModified();
206 
208 
213 
217  static const ComponentList & getSelectedComponents();
218 
222  static void clearSelectedComponents();
223 
225 
228 
230  static Action * getAction(QString );
231 
233  static const ActionList getActions();
234 
236  static ActionList getActions(Component *);
237 
239  static ActionList getActions(ComponentList );
240 
242  static ActionList getActions(ComponentList , QString );
243 
247  static int registerAllActions(ActionExtension *);
248 
252  static int unregisterAllActions(ActionExtension *);
254 
257 
269  void setMainWindow(MainWindow * mw);
270 
272  static MainWindow * getMainWindow();
273 
275  static void refresh();
276 
283  static void showStatusBarMessage(QString msg, int timeout=0);
284 
288  static void resetProgressBar();
289 
295  static void setProgressBarValue(int);
296 
309  static void vtkProgressFunction(vtkObject* caller, long unsigned int eventId, void* clientData, void* callData);
311 
314 
319  static void addHistoryItem(HistoryItem item);
320 
324  static HistoryItem removeLastHistoryItem();
325 
330  static void saveHistoryAsSXML();
331 
333 
336 
339  static QString getSelectedLanguage();
341 
344 
347  PropertyObject* getPropertyObject();
348 
353  return autoloadLastOpenedComponentsProperty;
354  }
355 
360  return defaultTargetedComponentProperty;
361  }
363 
364 
367 
370  static TargetPositionningMethods getDefaultTargetPositionningMethod();
371 
375  static void setDefaultTargetPositionningMethod(TargetPositionningMethods method);
377 
378 private slots:
379  void quitting();
380 
381 private:
383  static QString name;
384 
387 
389  static QSettings settings;
390 
392  int argc;
393 
395  char ** argv;
396 
400  static QList<QFileInfo> recentDocuments;
401 
403  static QDir lastUsedDirectory;
404 
406  static int maxRecentDocuments;
407 
409  QTranslator* translator;
411 
414 
421  static ComponentList & getTopLevelComponentList();
422 
430  static ComponentList & getAllComponentList();
431 
439  static ComponentList & getSelectedComponentList();
440 
453  static void setSelected(Component *component, bool isSelected);
454 
461  static void addComponent(Component *);
462 
469  static void removeComponent(Component *);
470 
472 
473 
478 
485  static QStack<HistoryItem> & getHistory();
486 
488 
491 
498  static QMap<QString,Action*> & getActionMap();
499 
501  static ActionList sort(ActionSet);
503 
505  void initResources();
506 
509 
512  void createProperties();
513 
518 
523 
535 
536 
537 };
538 
539 
540 
541 }
542 
544 
545 #endif // CAMITKAPPLICATION_H
The generic/default application.
Definition: Application.h:62
static int maxRecentDocuments
max number of recent document (default 10)
Definition: Application.h:406
static MainWindow * mainWindow
the main window of the CamiTK application
Definition: Application.h:386
int argc
argc given from command line
Definition: Application.h:392
Action class is an abstract class that enables you to build a action (generally on a component)...
Definition: Action.h:208
Property * getAutoloadLastOpenedComponentsProperty()
Get the CamiTK property associated with auto loading last opened component when the application start...
Definition: Application.h:352
QTranslator * translator
Provide internationalization support for text output.
Definition: Application.h:409
This Class is the base class for your application.
Definition: MainWindow.h:62
Definition: Action.cpp:40
CAMITK_API QList< Action * > ActionList
A list of Action.
Definition: CamiTKAPI.h:95
CAMITK_API QSet< Action * > ActionSet
A set of Action.
Definition: CamiTKAPI.h:92
Definition: Application.h:68
Property * autoloadLastOpenedComponentsProperty
The CamiTK property to open the last components the application opened during its last session...
Definition: Application.h:522
static QSettings settings
global settings for CamiTK application
Definition: Application.h:389
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:299
static QList< QFileInfo > recentDocuments
Definition: Application.h:400
CAMITK_API QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:86
#define CAMITK_API
Definition: CamiTKAPI.h:49
This class describes a property object.
Definition: PropertyObject.h:50
This class describes what is a generic Action extension.
Definition: ActionExtension.h:61
Property * getDefaultTargetedComponentProperty()
Get the CamiTK property associated with the new component frame policy.
Definition: Application.h:359
HistoryItem class describes the entry of an action used in a pipeline, in the history.
Definition: HistoryItem.h:61
Definition: Application.h:69
static QString name
name of the CamiTK application (used to differentiate settings between CamiTK applications) ...
Definition: Application.h:383
char ** argv
argv given from command line
Definition: Application.h:395
TargetPositionningMethods
Definition: Application.h:67
This properties and methods helps registering an applied action in the history of the application...
static QDir lastUsedDirectory
last used directory
Definition: Application.h:403
Definition: canvas_typed/mainwindow.h:69
Property * defaultTargetedComponentProperty
The CamiTK property for selecting the frame policy.
Definition: Application.h:517
PropertyObject * propertyObject
A simple QObject that holds the CamiTK level properties of the application.
Definition: Application.h:533
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:260