Computer Assited Medical Intervention Tool Kit  version 3.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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 #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 
60 class CAMITK_API Application : public QApplication {
61  Q_OBJECT
62 
63 public:
64 
84  Application(QString name, int & argc, char ** argv, bool autoloadExtension = true, bool registerFileExtension = false);
85 
87  virtual ~Application();
88 
91 
94  static QString getName();
95 
111  static QSettings & getSettings();
112 
125  static int exec();
126 
129  static const QDir getLastUsedDirectory();
130 
132  static void setLastUsedDirectory(QDir);
133 
137  static void addRecentDocument(QFileInfo);
138 
140  static const QList<QFileInfo> getRecentDocuments();
141 
143  static const int getMaxRecentDocuments();
144 
146 
149 
154  static Component * open(const QString &);
155 
160  static Component * openDirectory(const QString & dirName, const QString & pluginName);
161 
166  static bool close(Component *component);
167 
173  static bool save(Component * component);
174 
176  friend class Component;
177 
182  static const ComponentList & getTopLevelComponents();
183 
188  static const ComponentList & getAllComponents();
189 
191  static bool isAlive(Component *);
192 
194  static bool hasModified();
195 
197 
202 
206  static const ComponentList & getSelectedComponents();
207 
211  static void clearSelectedComponents();
212 
214 
217 
219  static Action * getAction(QString );
220 
222  static const ActionList getActions();
223 
225  static ActionList getActions(Component *);
226 
228  static ActionList getActions(ComponentList );
229 
231  static ActionList getActions(ComponentList , QString );
232 
236  static int registerAllActions(ActionExtension *);
238 
241 
253  void setMainWindow(MainWindow * mw);
254 
256  static MainWindow * getMainWindow();
257 
259  static void refresh();
260 
267  static void showStatusBarMessage(QString msg, int timeout=0);
268 
272  static void resetProgressBar();
273 
279  static void setProgressBarValue(int);
280 
293  static void vtkProgressFunction(vtkObject* caller, long unsigned int eventId, void* clientData, void* callData);
295 
298 
303  static void addHistoryItem(HistoryItem item);
304 
308  static HistoryItem removeLastHistoryItem();
309 
314  static void saveHistoryAsSXML();
315 
317 
320 
321 
325  static QString getSelectedLanguage();
327 
328 
329 
330 
331 private slots:
332  void quitting();
333 
334 private:
336  static QString name;
337 
340 
342  static QSettings settings;
343 
345  int argc;
346 
348  char ** argv;
349 
353  static QList<QFileInfo> recentDocuments;
354 
356  static QDir lastUsedDirectory;
357 
359  static int maxRecentDocuments;
360 
362  QTranslator* translator;
364 
367 
374  static ComponentList & getTopLevelComponentList();
375 
383  static ComponentList & getAllComponentList();
384 
392  static ComponentList & getSelectedComponentList();
393 
406  static void setSelected(Component *component, bool isSelected);
407 
414  static void addComponent(Component *);
415 
422  static void removeComponent(Component *);
423 
425 
426 
431 
438  static QStack<HistoryItem> & getHistory();
439 
441 
444 
451  static QMap<QString,Action*> & getActionMap();
452 
454  static ActionList sort(ActionSet);
456 
458  void initResources();
459 
460 
461 };
462 
463 }
464 
465 #endif // CAMITKAPPLICATION_H
The generic/default application.
Definition: Application.h:60
static int maxRecentDocuments
max number of recent document (default 10)
Definition: Application.h:359
static MainWindow * mainWindow
the main window of the CamiTK application
Definition: Application.h:339
int argc
argc given from command line
Definition: Application.h:345
Action class is an abstract class that enables you to build a action (generally on a component)...
Definition: Action.h:184
string name
Definition: select.cpp:111
QTranslator * translator
Provide internationalization support for text output.
Definition: Application.h:362
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
static QSettings settings
global settings for CamiTK application
Definition: Application.h:342
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:353
CAMITK_API QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:86
#define CAMITK_API
Definition: CamiTKAPI.h:49
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:336
char ** argv
argv given from command line
Definition: Application.h:348
This properties and methods helps registering an applied action in the history of the application...
static QDir lastUsedDirectory
last used directory
Definition: Application.h:356
Definition: canvas_typed/mainwindow.h:69