|
Computer Assited Medical Intervention Tool Kit
version 5.0
|
|
Go to the documentation of this file.
26 #ifndef CAMITKAPPLICATION_H
27 #define CAMITKAPPLICATION_H
34 #include <QApplication>
40 #include <QTranslator>
45 class ActionExtension;
46 class ViewerExtension;
50 class ComponentExtension;
94 Q_ENUM(TargetPositionningPolicy)
116 Application(QString name,
int& argc,
char** argv,
bool autoloadExtension =
true,
bool registerFileExtension =
false);
126 bool notify(QObject*, QEvent*)
override;
129 static QString getName();
146 static QSettings& getSettings();
164 static const QDir getLastUsedDirectory();
167 static void setLastUsedDirectory(QDir);
172 static void addRecentDocument(QFileInfo);
175 static const QList<QFileInfo> getRecentDocuments();
178 static const int getMaxRecentDocuments();
195 static Component* openDirectory(
const QString& dirName,
const QString& pluginName);
229 static bool hasModified();
246 static void clearSelectedComponents();
253 static Action* getAction(QString);
280 static void setTriggeredAction(
Action* action);
283 static Action* getTriggeredAction();
290 static Viewer* getViewer(QString name);
295 static Viewer* getNewViewer(QString name, QString className);
304 static bool registerViewer(
Viewer*);
349 static void showStatusBarMessage(QString msg,
int timeout = 0);
354 static void resetProgressBar();
361 static void setProgressBarValue(
int);
375 static void vtkProgressFunction(vtkObject* caller,
long unsigned int,
void*,
void*);
396 static void saveHistoryAsSXML();
405 static QString getSelectedLanguage();
493 static void setSelected(
Component* component,
bool isSelected);
520 static void applyPropertyValues();
536 static QStack<HistoryItem>& getHistory();
552 static QMap<QString, Action*>& getActionMap();
576 static QMap<QString, Viewer*>& getViewerMap();
587 static void createProperties();
602 static void initResources();
609 bool eventFilter(QObject*
object, QEvent* event)
override;
616 #endif // CAMITKAPPLICATION_H
static void resetProgressBar()
Resets the progress bar if it exists.
Definition: Application.cpp:361
static char ** argv
argv given from command line
Definition: Application.h:433
static void createProperties()
Create all the application properties and add them to the qApp.
Definition: Application.cpp:1472
virtual void setTimeStampInformation(bool showTimeStamp)=0
By default a logger should always show the time-stamp in the form of "yyyy-MM-dd HH:mm:ss....
virtual void setLogLevel(LogLevel level)=0
Sets Current verbosity level of the log.
virtual Component * open(const QString &)=0
get a new instance from data stored in a file (this is the most important method to redefine in your ...
static const ViewerList getViewers()
get all the viewers registered in the application (note: the returned ViewerList is garanteed to be s...
Definition: Application.cpp:980
Component * getParentComponent()
get the parent component
Definition: sdk/libraries/core/component/Component.cpp:209
void quitting()
}@
Definition: Application.cpp:208
virtual void setDebugInformation(bool)=0
Allows the logger to add debug information to the log message.
static bool save(Component *component)
save a component to its file (as given by component->getFileName()).
Definition: Application.cpp:667
virtual bool setLogToFile(bool writeToFile)=0
Ask the logger to write to the log file.
#define CAMITK_WARNING_ALT(MSG)
Definition: Log.h:267
bool isTopLevel() const
return true if this component is a top-level component
Definition: sdk/libraries/core/component/Component.cpp:203
QList< HistoryComponent > getInputHistoryComponents()
Get the input components of the history item action.
Definition: HistoryItem.cpp:70
static const ActionList getActions()
get all the actions registered in the application (note: the returned ActionList is garanteed to be s...
Definition: Application.cpp:737
static void initResources()
Init the application resources by loading the language associated .qml file.
Definition: Application.cpp:1451
virtual void redirectToConsole(bool)
use or not the application console (redirect or not standard out/err streams)
Definition: MainWindow.cpp:393
QList< HistoryComponent > getOutputHistoryComponents()
Get the output components of the history item action.
Definition: HistoryItem.cpp:80
static ComponentList & getSelectedComponentList()
get the currently selected Components.
Definition: Application.cpp:1071
static ComponentList & getTopLevelComponentList()
get the current application wide list of instantiated top-level Components.
Definition: Application.cpp:1057
QStringList getHierarchy() const override
Definition: sdk/libraries/core/component/Component.cpp:480
static ComponentList & getAllComponentList()
get the current application wide list of all Components.
Definition: Application.cpp:1064
static QStack< HistoryItem > & getHistory()
get the history of actions stored.
Definition: Application.cpp:1125
@ SUCCESS
everything went according to plan
Definition: Action.h:248
static QString getSelectedLanguage()
Returns for the current CamiTK application, the selected language (stored in its ....
Definition: Application.cpp:1437
static QSettings & getSettings()
Get the Core wide settings.
Definition: Application.cpp:309
const QString getFileName() const
get the file name where the data have to be stored/were stored
Definition: sdk/libraries/core/component/Component.cpp:461
static QMap< QString, Viewer * > & getViewerMap()
As viewers are mainly sort/compared/process by name, an internal QMap associates all the registered v...
Definition: Application.cpp:875
static QStringList getFileExtensions()
get the list of all the suffixes managed by registered component extensions (all possible file suffix...
Definition: ExtensionManager.cpp:480
void initIcons()
Definition: Application.cpp:53
void setMainWindow(MainWindow *mw)
set the main window.
Definition: Application.cpp:251
static void addRecentDocument(QFileInfo)
Add a document to the list of recent documents (e.g.
Definition: Application.cpp:402
static void autoload()
Autoload component and action extensions.
Definition: ExtensionManager.cpp:68
static const ComponentList & getAllComponents()
get the current application wide list of all Components.
Definition: Application.cpp:1083
static void refresh()
refresh the main window (this will call the refresh method of all viewers)
Definition: Application.cpp:333
static void clearSelectedComponents()
clear all the selection, i.e call setSelected(false) for all the previously selected components and c...
Definition: Application.cpp:1106
static void removeComponent(Component *)
unregister a Component.
Definition: Application.cpp:1050
static bool close(Component *component)
Close a Component: if it has been changed, ask the user for more information, then if everything is o...
Definition: Application.cpp:629
bool viewerLessThan(const camitk::Viewer *v1, const camitk::Viewer *v2)
Definition: Application.cpp:784
void saveToSettings(const QString &settingGroupName)
save setting in the given group name using all the property values
Definition: PropertyObject.cpp:239
static PropertyObject * propertyObject
A simple QObject that holds the CamiTK level properties of the application.
Definition: Application.h:598
#define CAMITK_INFO(MSG)
Log for info verbosity (the second most verbose one) The msg will appear only if the user asked for I...
Definition: Log.h:261
static void setProgressBarValue(int)
set the progress bar value, value should be in [0..100].
Definition: Application.cpp:374
@ NONE
No message is logged.
Definition: InterfaceLogger.h:61
This class describes what is a generic Component extension. To add a ComponentExtension to CamiTK cor...
Definition: ComponentExtension.h:83
const ViewerList & getViewers()
get the list of viewer instances registered by this extension
Definition: ViewerExtension.cpp:190
void loadFromSettings(const QString &settingGroupName)
initializes all property values from setting values found in the given group name
Definition: PropertyObject.cpp:142
@ ERROR
Only error messages are logged.
Definition: InterfaceLogger.h:62
static const QDir getLastUsedDirectory()
Get the last used directory (e.g.
Definition: Application.cpp:436
static const int getMaxRecentDocuments()
get the maximal number of recent documents stored
Definition: Application.cpp:451
static ActionList sort(ActionSet)
sort an ActionSet by action's name
Definition: Application.cpp:791
static void unloadAllViewerExtensions()
unload all viewer extensions and delete instantiated actions
Definition: ExtensionManager.cpp:527
static int registerAllViewers(ViewerExtension *)
register all viewers from the given ViewerExtension
Definition: Application.cpp:918
static int unregisterAllActions(ActionExtension *)
unregister all actions from the given ActionExtension
Definition: Application.cpp:766
QString getName() const
get the name of the action
Definition: Action.h:338
HistoryComponent class describes the component information (name, type) stored in the history.
Definition: HistoryComponent.h:82
static QString name
name of the CamiTK application (used to differentiate settings between CamiTK applications)
Definition: Application.h:424
static void addHistoryItem(HistoryItem item)
Add the history item to the application history.
Definition: Application.cpp:1132
Application(QString name, int &argc, char **argv, bool autoloadExtension=true, bool registerFileExtension=false)
Initializes the window system and constructs a CamiTK application object with argc command line argum...
Definition: Application.cpp:73
QList< Action * > ActionList
A list of Action.
Definition: CamiTKAPI.h:136
static const ComponentList & getSelectedComponents()
get the currently selected Components.
Definition: Application.cpp:1088
static QDir lastUsedDirectory
last used directory
Definition: Application.h:443
bool actionLessThan(const camitk::Action *a1, const camitk::Action *a2)
Definition: Application.cpp:778
QString getExtensionName() const
the name of the extension in the family in which this action is associated
Definition: Action.cpp:156
static int maxRecentDocuments
max number of recent document (default 10)
Definition: Application.h:446
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:303
QSet< Viewer * > ViewerSet
A set of Viewer.
Definition: CamiTKAPI.h:133
static ComponentExtension * getComponentExtension(QString)
get the plugin corresponding to a given extension or name.
Definition: ExtensionManager.cpp:440
static const QString getCurrentWorkingDir()
get the current working directory (during dev, this should be the build directory,...
Definition: Core.cpp:423
static const QString getTestDataDir()
Get a valid camitk test data directory name.
Definition: Core.cpp:361
QString getFamily() const
the name of the family in which this action is associated
Definition: Action.h:353
static Action * currentAction
Definition: Application.h:435
QString getName() const
get the name of the viewer
Definition: Viewer.h:200
Action class is an abstract class that enables you to build a action (generally on a component)....
Definition: Action.h:231
virtual QString getName()=0
returns the viewer extension name (to be overriden in the derived class)
static InterfaceLogger * getLogger()
get the current application logger
Definition: Log.cpp:73
static ComponentExtension * getDataDirectoryComponentExtension(QString)
get the plugin corresponding to a given data directory component extension's name.
Definition: ExtensionManager.cpp:428
Definition: canvas_typed/mainwindow.h:69
static Viewer * getViewer(QString name)
get the pointer to a registered viewer given its name
Definition: Application.cpp:882
static const QList< ViewerExtension * > getViewerExtensionsList()
Get the list of registered ViewerExtension.
Definition: ExtensionManager.cpp:536
static void showStatusBarMessage(QString msg, int timeout=0)
Set a message to the status bar.
Definition: Application.cpp:345
QString getDescription() const
the description of the action
Definition: Action.h:343
The generic/default application. Once this class is intanciated in the main, everything is setup....
Definition: Application.h:82
QSet< Action * > ActionSet
A set of Action.
Definition: CamiTKAPI.h:130
HistoryItem class describes the entry of an action used in a pipeline, in the history.
Definition: HistoryItem.h:84
static Component * openDirectory(const QString &dirName, const QString &pluginName)
load a directory and returns the corresponding Component (returns nullptr if an error occurs)
Definition: Application.cpp:555
Exception class to handle abortion in component instantiation. Particularly useful to handle construc...
Definition: AbortException.h:66
static void setLastUsedDirectory(QDir)
set (force) the last used directory
Definition: Application.cpp:441
#define CAMITK_ERROR(MSG)
Log for error verbosity (the minimum verbosity) Will always appear.
Definition: Log.h:276
static void vtkProgressFunction(vtkObject *caller, long unsigned int, void *, void *)
Observer function to be called by vtkFilters and to update progress bar Example of use:
Definition: Application.cpp:387
void show()
inherited from QWidget, just to refresh all viewers
Definition: MainWindow.cpp:425
static Component * open(const QString &)
load the filename and returns the corresponding top level Component (returns nullptr if an error occu...
Definition: Application.cpp:456
static bool registerViewer(Viewer *)
register a viewer in the viewer list (therefore allowing it to be refreshed by the main window automa...
Definition: Application.cpp:887
QStringList getComponents()
get the list of Component class manages by this viewer (default is set to "Component",...
Definition: Viewer.cpp:99
virtual void setSelected(const bool b, const bool recursive=true)
Update the selection flag.
Definition: sdk/libraries/core/component/Component.cpp:445
virtual bool save(Component *component) const
save a given Component (does not have to be top-level) into one of the currently managed format (chec...
Definition: ComponentExtension.cpp:63
@ INFO
information, warning and error messages are logged
Definition: InterfaceLogger.h:64
static void saveHistoryAsSXML()
Save the history as an SCXML file, stored using.
Definition: Application.cpp:1142
~Application() override
destructor
Definition: Application.cpp:190
QString getName() const override
get the name to be displayed
Definition: sdk/libraries/core/component/Component.h:907
static void setTriggeredAction(Action *action)
set the currently triggered action This is used by Action::trigger(..) to refresh all the viewer (the...
Definition: Application.cpp:1115
LogLevel
Definition: InterfaceLogger.h:60
static MainWindow * getMainWindow()
get the main window
Definition: Application.cpp:297
const char * what() const noexcept
get the detailed reason from the exception
Definition: AbortException.h:99
@ SAME_TRANSFORMATION
New component has no parent frame (parent frame is set to nullptr), and its frame is copied from its ...
Definition: Application.h:89
static PropertyObject * getPropertyObject()
Get the property object of the application.
Definition: Application.cpp:1531
QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:127
static const QStringList getComponentDirectories()
get all the component directories.
Definition: Core.cpp:351
static MainWindow * mainWindow
the main window of the CamiTK application
Definition: Application.h:427
@ IMAGE_COMPONENT
this Component represents a volumic image and its subcomponents can be displayed as slices.
Definition: HistoryComponent.h:120
static void applyPropertyValues()
Apply all the property values to update the model (e.g., use the logLevel to modify the actual log le...
Definition: Application.cpp:1556
Viewer * getNewInstance(QString name)
factory: create a new viewer instance and register it
Definition: ViewerExtension.cpp:161
static QTranslator * translator
Provide internationalization support for text output.
Definition: Application.h:449
QProgressBar * getProgressBar()
similar as statusBar() from QMainWindow but for the progress bar
Definition: MainWindow.cpp:388
@ WARNING
Only Warning and Error messages are logged.
Definition: InterfaceLogger.h:63
virtual void setMessageBoxLevel(LogLevel level)=0
Set the lowest log level that will open modal message box for messages instead of (silently/undisrupt...
static bool isAlive(Component *)
does this Component still exists?
Definition: Application.cpp:1022
static Action * getAction(QString)
get a registered action given its name
Definition: Application.cpp:809
static QString getName()
get the application name
Definition: Application.cpp:203
This class is the base class for your application. It sets up the main window and creates a menubar,...
Definition: MainWindow.h:89
bool notify(QObject *, QEvent *) override
reimplemented from QApplication to catch all exception from external libs used in CEP (e....
Definition: Application.cpp:223
QStringList getTag() const
the name of the tag called this action
Definition: Action.h:361
static QMap< QString, Action * > & getActionMap()
As actions are mainly sort/compared/process by name, an internal QMap associates all the contains all...
Definition: Application.cpp:730
This class describes what is a generic Action extension. To add a ActionExtension to CamiTK core,...
Definition: ActionExtension.h:80
Viewer is an abstract class that is the base class for all viewers.
Definition: Viewer.h:180
static int registerAllActions(ActionExtension *)
register all actions from the given ActionExtension
Definition: Application.cpp:742
QList< Viewer * > ViewerList
A list of Viewer.
Definition: CamiTKAPI.h:139
static Viewer * getNewViewer(QString name, QString className)
instantiate a new viewer of the given name and given class name (Viewer inheriting class).
Definition: Application.cpp:960
bool eventFilter(QObject *object, QEvent *event) override
Event filter of this class instance to watch its properties instances.
Definition: Application.cpp:1536
static bool hasModified()
Return true if at least one of the opened components has been modified, false otherwise.
Definition: Application.cpp:1027
@ MESH_COMPONENT
this Component represent a 3D mesh, it has a 3D representation which can be displayed in the 3D viewe...
Definition: HistoryComponent.h:121
static const QList< QFileInfo > getRecentDocuments()
Get the list of recent documents.
Definition: Application.cpp:446
virtual void setLogToStandardOutput(bool writeToStdOut)=0
Allows the logger to write on std::cout.
#define CAMITK_INFO_ALT(MSG)
Definition: Log.h:262
TargetPositionningPolicy
Definition: Application.h:88
static QString getLevelAsString(InterfaceLogger::LogLevel level)
get the enum value as a text
Definition: Log.cpp:82
static void addComponent(Component *)
register a new component either in the full component list, or in the full list and in the top-level ...
Definition: Application.cpp:1039
#define CAMITK_ERROR_ALT(MSG)
Definition: Log.h:277
QString getDescription() const
get the name of the viewer
Definition: Viewer.h:205
const ActionList & getActions()
get the list of actions registered y this extension
Definition: ActionExtension.cpp:122
static const ComponentList & getTopLevelComponents()
get the current application wide list of instantiated top-level Components.
Definition: Application.cpp:1078
@ TRACE
all types of messages are logged
Definition: InterfaceLogger.h:65
static int exec()
Overriden from QApplication: Enters the main event loop and waits until exit() is called,...
Definition: Application.cpp:314
static HistoryItem removeLastHistoryItem()
Remove the last pushed actions in the history of the current pipeline.
Definition: Application.cpp:1137
void refresh()
refresh the display
QString getName()
Get the name of the corresponding action in the pipeline.
Definition: HistoryItem.cpp:59
static const char * version
Definition: Core.h:208
static void unloadAllActionExtensions()
unload all action extensions and delete instantiated actions
Definition: ExtensionManager.cpp:511
@ OTHER
this Component has no defined representation.
Definition: HistoryComponent.h:122
This class describes what is a generic Action extension. To add a ActionExtension to CamiTK core,...
Definition: ViewerExtension.h:108
Type getType() const
Get the Type of the Component associated to this item.
Definition: HistoryComponent.cpp:53
static QList< QFileInfo > recentDocuments
Definition: Application.h:440
virtual bool addProperty(Property *)
Tag a new CamiTK property to this object.
Definition: PropertyObject.cpp:76
static QSettings settings
global settings for CamiTK application
Definition: Application.h:517
static void registerFileExtension(QString fileExtension)
Register the file extension with the current application for opening This function is called by regis...
Definition: ExtensionManager.cpp:567
virtual void aboutToShow()
this method is automatically called by Application before the first time show() is called.
Definition: MainWindow.cpp:438
static int argc
argc given from command line
Definition: Application.h:430
static int unregisterAllViewers(ViewerExtension *)
unregister all viewers from the given ViewerExtension
Definition: Application.cpp:985
static Action * getTriggeredAction()
get the currently triggered action
Definition: Application.cpp:1120
QString getName() const
Get the the name of the Component associated to this item.
Definition: HistoryComponent.cpp:48
static ViewerExtension * getViewerExtension(Viewer *viewer)
Definition: Application.cpp:997
This class describes a property object.
Definition: PropertyObject.h:94
static void setSelected(Component *component, bool isSelected)
insert/remove one specific Component to the selection (at the end).
Definition: Application.cpp:1093
QString getComponent() const
the name of the component class that can be used by this action
Definition: Action.h:348
virtual void refresh()
Definition: MainWindow.cpp:357
virtual QString getName() const =0
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:302
virtual bool getModified() const
set the modified flag
Definition: sdk/libraries/core/component/Component.h:948
#define CAMITK_WARNING_IF_ALT(COND, MSG)
Definition: Log.h:320
@ NO_TRANSFORMATION
New component has no parent frame (parent frame is therefore set to nullptr) and transform is Id.
Definition: Application.h:90
#define CAMITK_API
Definition: CamiTKAPI.h:49
Definition: Action.cpp:35