Computer Assited Medical Intervention Tool Kit  version 3.2
 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-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 #include <QStack>
38 
39 class vtkObject;
40 namespace camitk {
41 class MainWindow;
42 class ActionExtension;
43 class Action;
44 class HistoryItem;
45 
53 class CAMITK_API Application : public QApplication {
54  Q_OBJECT
55 
56 public:
57 
77  Application(QString name, int & argc, char ** argv, bool autoloadExtension = true, bool registerFileExtension = false);
78 
80  virtual ~Application();
81 
84 
87  static QString getName();
88 
104  static QSettings & getSettings();
105 
118  static int exec();
119 
122  static const QDir getLastUsedDirectory();
123 
125  static void setLastUsedDirectory(QDir);
126 
130  static void addRecentDocument(QFileInfo);
131 
133  static const QList<QFileInfo> getRecentDocuments();
134 
136  static const int getMaxRecentDocuments();
137 
139 
142 
145  static Component * open(const QString &);
146 
151  static Component * openDirectory(const QString & dirName, const QString & pluginName);
152 
157  static bool close(Component *component);
158 
164  static bool save(Component * component);
165 
167  friend class Component;
168 
173  static const ComponentList & getTopLevelComponents();
174 
179  static const ComponentList & getAllComponents();
180 
182  static bool isAlive(Component *);
183 
185  static bool hasModified();
186 
188 
193 
197  static const ComponentList & getSelectedComponents();
198 
202  static void clearSelectedComponents();
203 
205 
208 
210  static Action * getAction(QString );
211 
213  static const ActionList getActions();
214 
216  static ActionList getActions(Component *);
217 
219  static ActionList getActions(ComponentList );
220 
222  static ActionList getActions(ComponentList , QString );
223 
227  static int registerAllActions(ActionExtension *);
229 
232 
244  void setMainWindow(MainWindow * mw);
245 
247  static MainWindow * getMainWindow();
248 
250  static void refresh();
251 
258  static void showStatusBarMessage(QString msg, int timeout=0);
259 
263  static void resetProgressBar();
264 
270  static void setProgressBarValue(int);
271 
284  static void vtkProgressFunction(vtkObject* caller, long unsigned int eventId, void* clientData, void* callData);
286 
289 
294  static void addHistoryItem(HistoryItem item);
295 
299  static HistoryItem removeLastHistoryItem();
300 
302 
303 
304 
305 
306 private slots:
307  void quitting();
308 
309 private:
311  static QString name;
312 
315 
317  static QSettings settings;
318 
320  int argc;
321 
323  char ** argv;
324 
328  static QList<QFileInfo> recentDocuments;
329 
331  static QDir lastUsedDirectory;
332 
334  static int maxRecentDocuments;
336 
339 
346  static ComponentList & getTopLevelComponentList();
347 
355  static ComponentList & getAllComponentList();
356 
364  static ComponentList & getSelectedComponentList();
365 
378  static void setSelected(Component *component, bool isSelected);
379 
386  static void addComponent(Component *);
387 
394  static void removeComponent(Component *);
395 
397 
398 
403 
410  static QStack<HistoryItem> & getHistory();
411 
413 
416 
423  static QMap<QString,Action*> & getActionMap();
424 
426  static ActionList sort(ActionSet);
428 
429 };
430 
431 }
432 
433 #endif // CAMITKAPPLICATION_H