Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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-2013 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 
38 class vtkObject;
39 namespace camitk {
40 class MainWindow;
41 class ActionExtension;
42 class Action;
43 
51 class CAMITK_API Application : public QApplication {
52  Q_OBJECT
53 
54 public:
55 
70  Application(QString name, int & argc, char ** argv, bool autoloadExtension = true);
71 
73  virtual ~Application();
74 
77 
78 
80  static QString getName();
81 
97  static QSettings & getSettings();
98 
111  static int exec();
112 
115  static const QDir getLastUsedDirectory();
116 
118  static void setLastUsedDirectory(QDir);
119 
123  static void addRecentDocument(QFileInfo);
124 
126  static const QList<QFileInfo> getRecentDocuments();
127 
129  static const int getMaxRecentDocuments();
130 
132 
135 
136 
138  static Component * open(const QString &);
139 
144  static Component * openDirectory(const QString & dirName, const QString & pluginName);
145 
150  static bool close(Component *component);
151 
157  static bool save(Component * component);
158 
160  friend class Component;
161 
166  static const ComponentList & getTopLevelComponents();
167 
172  static const ComponentList & getAllComponents();
173 
175  static bool isAlive(Component *);
176 
178  static bool hasModified();
179 
181 
186 
190  static const ComponentList & getSelectedComponents();
191 
195  static void clearSelectedComponents();
196 
198 
201 
203  static Action * getAction(QString );
204 
206  static const ActionList getActions();
207 
209  static ActionList getActions(Component *);
210 
212  static ActionList getActions(ComponentList );
213 
215  static ActionList getActions(ComponentList , QString );
216 
220  static int registerAllActions(ActionExtension *);
222 
225 
226 
237  void setMainWindow(MainWindow * mw);
238 
240  static MainWindow * getMainWindow();
241 
243  static void refresh();
244 
251  static void showStatusBarMessage(QString msg, int timeout=0);
252 
256  static void resetProgressBar();
257 
263  static void setProgressBarValue(int);
264 
277  static void vtkProgressFunction(vtkObject* caller, long unsigned int eventId, void* clientData, void* callData);
279 
280 
281 private slots:
282  void quitting();
283 
284 private:
286  static QString name;
287 
290 
292  static QSettings settings;
293 
295  int argc;
296 
298  char ** argv;
299 
303  static QList<QFileInfo> recentDocuments;
304 
306  static QDir lastUsedDirectory;
307 
309  static int maxRecentDocuments;
311 
314 
321  static ComponentList & getTopLevelComponentList();
322 
330  static ComponentList & getAllComponentList();
331 
339  static ComponentList & getSelectedComponentList();
340 
353  static void setSelected(Component *component, bool isSelected);
354 
361  static void addComponent(Component *);
362 
369  static void removeComponent(Component *);
370 
372 
375 
382  static QMap<QString,Action*> & getActionMap();
383 
385  static ActionList sort(ActionSet);
387 
388 
389 };
390 
391 
392 
393 }
394 
395 #endif // CAMITKAPPLICATION_H