Computer Assited Medical Intervention Tool Kit  version 3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-2014 UJF-Grenoble 1, 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 
40 class vtkObject;
41 namespace camitk {
42 class MainWindow;
43 class ActionExtension;
44 class Action;
45 class HistoryItem;
46 
58 class CAMITK_API Application : public QApplication {
59  Q_OBJECT
60 
61 public:
62 
82  Application(QString name, int & argc, char ** argv, bool autoloadExtension = true, bool registerFileExtension = false);
83 
85  virtual ~Application();
86 
89 
92  static QString getName();
93 
109  static QSettings & getSettings();
110 
123  static int exec();
124 
127  static const QDir getLastUsedDirectory();
128 
130  static void setLastUsedDirectory(QDir);
131 
135  static void addRecentDocument(QFileInfo);
136 
138  static const QList<QFileInfo> getRecentDocuments();
139 
141  static const int getMaxRecentDocuments();
142 
144 
147 
150  static Component * open(const QString &);
151 
156  static Component * openDirectory(const QString & dirName, const QString & pluginName);
157 
162  static bool close(Component *component);
163 
169  static bool save(Component * component);
170 
172  friend class Component;
173 
178  static const ComponentList & getTopLevelComponents();
179 
184  static const ComponentList & getAllComponents();
185 
187  static bool isAlive(Component *);
188 
190  static bool hasModified();
191 
193 
198 
202  static const ComponentList & getSelectedComponents();
203 
207  static void clearSelectedComponents();
208 
210 
213 
215  static Action * getAction(QString );
216 
218  static const ActionList getActions();
219 
221  static ActionList getActions(Component *);
222 
224  static ActionList getActions(ComponentList );
225 
227  static ActionList getActions(ComponentList , QString );
228 
232  static int registerAllActions(ActionExtension *);
234 
237 
249  void setMainWindow(MainWindow * mw);
250 
252  static MainWindow * getMainWindow();
253 
255  static void refresh();
256 
263  static void showStatusBarMessage(QString msg, int timeout=0);
264 
268  static void resetProgressBar();
269 
275  static void setProgressBarValue(int);
276 
289  static void vtkProgressFunction(vtkObject* caller, long unsigned int eventId, void* clientData, void* callData);
291 
294 
299  static void addHistoryItem(HistoryItem item);
300 
304  static HistoryItem removeLastHistoryItem();
305 
310  static void saveHistoryAsSXML();
311 
313 
314 
315 
316 
317 private slots:
318  void quitting();
319 
320 private:
322  static QString name;
323 
326 
328  static QSettings settings;
329 
331  int argc;
332 
334  char ** argv;
335 
339  static QList<QFileInfo> recentDocuments;
340 
342  static QDir lastUsedDirectory;
343 
345  static int maxRecentDocuments;
347 
350 
357  static ComponentList & getTopLevelComponentList();
358 
366  static ComponentList & getAllComponentList();
367 
375  static ComponentList & getSelectedComponentList();
376 
389  static void setSelected(Component *component, bool isSelected);
390 
397  static void addComponent(Component *);
398 
405  static void removeComponent(Component *);
406 
408 
409 
414 
421  static QStack<HistoryItem> & getHistory();
422 
424 
427 
434  static QMap<QString,Action*> & getActionMap();
435 
437  static ActionList sort(ActionSet);
439 
440 };
441 
442 }
443 
444 #endif // CAMITKAPPLICATION_H
The generic/default application.
Definition: Application.h:58
static int maxRecentDocuments
max number of recent document (default 10)
Definition: Application.h:345
static MainWindow * mainWindow
the main window of the CamiTK application
Definition: Application.h:325
int argc
argc given from command line
Definition: Application.h:331
Action class is an abstract class that enables you to build a action (generally on a component)...
Definition: Action.h:184
This Class is the base class for your application.
Definition: MainWindow.h:62
CAMITK_API QList< Action * > ActionList
A list of Action.
Definition: CamiTKAPI.h:96
CAMITK_API QSet< Action * > ActionSet
A set of Action.
Definition: CamiTKAPI.h:93
static QSettings settings
global settings for CamiTK application
Definition: Application.h:328
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:292
CAMITK_API QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:87
#define CAMITK_API
Definition: CamiTKAPI.h:49
static QList< QFileInfo > recentDocuments
Definition: Application.h:339
Definition: ExtensionWindow.h:40
This class describes what is a generic Action extension.
Definition: ActionExtension.h:61
HistoryItem class describes the entry of an action used in a pipeline, in the history.
Definition: HistoryItem.h:61
static QString name
name of the CamiTK application (used to differentiate settings between CamiTK applications) ...
Definition: Application.h:322
char ** argv
argv given from command line
Definition: Application.h:334
This properties and methods helps registering an applied action in the history of the application...
static QDir lastUsedDirectory
last used directory
Definition: Application.h:342
Definition: ExtensionWindow.h:39
Definition: canvas_typed/mainwindow.h:70