 |
Computer Assited Medical Intervention Tool Kit
version 4.1
|
Go to the documentation of this file.
26 #ifndef CAMITKAPPLICATION_H
27 #define CAMITKAPPLICATION_H
34 #include <QApplication>
40 #include <QTranslator>
45 class ActionExtension;
48 class ComponentExtension;
63 class CAMITK_API Application :
public QApplication {
75 Q_ENUMS(TargetPositionningPolicy)
97 Application(QString name,
int& argc,
char** argv,
bool autoloadExtension =
true,
bool registerFileExtension =
false);
107 bool notify(QObject*, QEvent*)
override;
110 static QString getName();
127 static QSettings& getSettings();
145 static const QDir getLastUsedDirectory();
148 static void setLastUsedDirectory(QDir);
153 static void addRecentDocument(QFileInfo);
156 static const QList<QFileInfo> getRecentDocuments();
159 static const int getMaxRecentDocuments();
176 static Component* openDirectory(
const QString& dirName,
const QString& pluginName);
210 static bool hasModified();
227 static void clearSelectedComponents();
235 static Action* getAction(QString);
288 static void showStatusBarMessage(QString msg,
int timeout = 0);
293 static void resetProgressBar();
300 static void setProgressBarValue(
int);
314 static void vtkProgressFunction(vtkObject* caller,
long unsigned int,
void*,
void*);
335 static void saveHistoryAsSXML();
344 static QString getSelectedLanguage();
377 static QList<QFileInfo> recentDocuments;
380 static QDir lastUsedDirectory;
383 static int maxRecentDocuments;
386 static QTranslator* translator;
430 static void setSelected(
Component* component,
bool isSelected);
454 static QSettings settings;
457 static void applyPropertyValues();
471 static QStack<HistoryItem>& getHistory();
484 static QMap<QString, Action*>& getActionMap();
491 static void initResources();
499 static void createProperties();
518 bool eventFilter(QObject*
object, QEvent* event)
override;
527 #endif // CAMITKAPPLICATION_H
static void resetProgressBar()
Resets the progress bar if it exists.
Definition: Application.cpp:338
static char ** argv
argv given from command line
Definition: Application.h:371
static void createProperties()
Create all the application properties and add them to the qApp.
Definition: Application.cpp:1267
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 ...
virtual Component * getParentComponent()
get the parent component
Definition: sdk/libraries/core/component/Component.cpp:260
void quitting()
}@
Definition: Application.cpp:206
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:641
virtual bool setLogToFile(bool writeToFile)=0
Ask the logger to write to the log file.
#define CAMITK_WARNING_ALT(MSG)
Definition: Log.h:262
bool isTopLevel() const
return true if this component is a top-level component
Definition: sdk/libraries/core/component/Component.cpp:235
QList< HistoryComponent > getInputHistoryComponents()
Get the input components of the history item action.
Definition: HistoryItem.cpp:68
static const ActionList getActions()
get all the actions registered in the application (note: the returned ActionList is garanteed to be s...
Definition: Application.cpp:706
static void initResources()
Init the application resources by loading the language associated .qm file.
Definition: Application.cpp:1246
virtual void redirectToConsole(bool)
use or not the application console (redirect or not standard out/err streams)
Definition: MainWindow.cpp:323
QList< HistoryComponent > getOutputHistoryComponents()
Get the output components of the history item action.
Definition: HistoryItem.cpp:78
static ComponentList & getSelectedComponentList()
get the currently selected Components.
Definition: Application.cpp:877
static ComponentList & getTopLevelComponentList()
get the current application wide list of instantiated top-level Components.
Definition: Application.cpp:863
QStringList getHierarchy() const override
Definition: sdk/libraries/core/component/Component.cpp:173
static ComponentList & getAllComponentList()
get the current application wide list of all Components.
Definition: Application.cpp:870
static QStack< HistoryItem > & getHistory()
get the singleton stack of actions stored in a pipeline This is the private (intern) method.
Definition: Application.cpp:921
everything went according to plan
Definition: Action.h:245
static QString getSelectedLanguage()
Returns for the current CamiTK application, the selected language (stored in its ....
Definition: Application.cpp:1232
static QSettings & getSettings()
Get the Core wide settings.
Definition: Application.cpp:300
const QString getFileName() const
get the file name where the data have to be stored/were stored
Definition: sdk/libraries/core/component/Component.cpp:572
static QStringList getFileExtensions()
get the list of all the suffixes managed by registered component extensions (all possible file suffix...
Definition: ExtensionManager.cpp:365
void initIcons()
Definition: Application.cpp:52
void setMainWindow(MainWindow *mw)
set the main window.
Definition: Application.cpp:245
static void addRecentDocument(QFileInfo)
Add a document to the list of recent documents (e.g.
Definition: Application.cpp:379
static void autoload()
Autoload component and action extensions.
Definition: ExtensionManager.cpp:65
static const ComponentList & getAllComponents()
get the current application wide list of all Components.
Definition: Application.cpp:889
static void refresh()
refresh the main window (this will call the refresh method of all viewers)
Definition: Application.cpp:317
static void clearSelectedComponents()
clear all the selection, i.e call setSelected(false) for all the previously selected components and c...
Definition: Application.cpp:912
static void removeComponent(Component *)
unregister a Component.
Definition: Application.cpp:856
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:603
void saveToSettings(const QString &settingGroupName)
save setting in the given group name using all the property values
Definition: PropertyObject.cpp:238
static PropertyObject * propertyObject
A simple QObject that holds the CamiTK level properties of the application.
Definition: Application.h:509
#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:256
static void setProgressBarValue(int)
set the progress bar value, value should be in [0..100].
Definition: Application.cpp:351
No message is logged.
Definition: InterfaceLogger.h:60
This class describes what is a generic Component extension. To add a ComponentExtension to CamiTK cor...
Definition: ComponentExtension.h:78
void loadFromSettings(const QString &settingGroupName)
initializes all property values from setting values found in the given group name
Definition: PropertyObject.cpp:141
Only error messages are logged.
Definition: InterfaceLogger.h:61
static const QDir getLastUsedDirectory()
Get the last used directory (e.g.
Definition: Application.cpp:413
static const int getMaxRecentDocuments()
get the maximal number of recent documents stored
Definition: Application.cpp:428
static ActionList sort(ActionSet)
sort an ActionSet by action's name
Definition: Application.cpp:753
static int unregisterAllActions(ActionExtension *)
unregister all actions from the given ActionExtension
Definition: Application.cpp:735
QString getName() const
get the name of the action
Definition: Action.h:332
HistoryComponent class describes the component information (name, type) stored in the history.
Definition: HistoryComponent.h:80
static QString name
name of the CamiTK application (used to differentiate settings between CamiTK applications)
Definition: Application.h:362
static void addHistoryItem(HistoryItem item)
Add the history item to the application history.
Definition: Application.cpp:928
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:71
QList< Action * > ActionList
A list of Action.
Definition: CamiTKAPI.h:94
static const ComponentList & getSelectedComponents()
get the currently selected Components.
Definition: Application.cpp:894
static QDir lastUsedDirectory
last used directory
Definition: Application.h:379
bool actionLessThan(const camitk::Action *a1, const camitk::Action *a2)
Definition: Application.cpp:747
QString getExtensionName() const
the name of the extension in the family in which this action is associated
Definition: Action.cpp:148
static int maxRecentDocuments
max number of recent document (default 10)
Definition: Application.h:382
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:312
static ComponentExtension * getComponentExtension(QString)
get the plugin corresponding to a given extension or name.
Definition: ExtensionManager.cpp:325
static const QString getCurrentWorkingDir()
get the current working directory (during dev, this should be the build directory,...
Definition: Core.cpp:358
static const QString getTestDataDir()
Get a valid camitk test data directory name.
Definition: Core.cpp:297
QString getFamily() const
the name of the family in which this action is associated
Definition: Action.h:347
Action class is an abstract class that enables you to build a action (generally on a component)....
Definition: Action.h:228
static InterfaceLogger * getLogger()
get the current application logger
Definition: Log.cpp:71
static ComponentExtension * getDataDirectoryComponentExtension(QString)
get the plugin corresponding to a given data directory component extension's name.
Definition: ExtensionManager.cpp:313
Definition: canvas_typed/mainwindow.h:68
static void showStatusBarMessage(QString msg, int timeout=0)
Set a message to the status bar.
Definition: Application.cpp:322
QString getDescription() const
the description of the action
Definition: Action.h:337
The generic/default application. Once this class is intanciated in the main, everything is setup....
Definition: Application.h:62
virtual ApplyStatus apply()=0
This method is called when the action has to be applied on the target list (get the target lists usin...
QSet< Action * > ActionSet
A set of Action.
Definition: CamiTKAPI.h:91
HistoryItem class describes the entry of an action used in a pipeline, in the history.
Definition: HistoryItem.h:82
static Component * openDirectory(const QString &dirName, const QString &pluginName)
load a directory and returns the corresponding Component (return NULL if an error occurs)
Definition: Application.cpp:531
Exception class to handle abortion in component instantiation. Particularly useful to handle construc...
Definition: AbortException.h:64
static void setLastUsedDirectory(QDir)
set (force) the last used directory
Definition: Application.cpp:418
#define CAMITK_ERROR(MSG)
Log for error verbosity (the minimum verbosity) Will always appear.
Definition: Log.h:271
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:364
void show()
inherited from QWidget, just to refresh all viewers
Definition: MainWindow.cpp:355
static Component * open(const QString &)
load the filename and returns the corresponding top level Component (return NULL if an error occurs)
Definition: Application.cpp:433
virtual void setSelected(const bool b, const bool recursive=true)
Update the selection flag.
Definition: sdk/libraries/core/component/Component.cpp:557
information, warning and error messages are logged
Definition: InterfaceLogger.h:63
static void saveHistoryAsSXML()
Save the history as an SCXML file, stored using.
Definition: Application.cpp:938
~Application() override
destructor
Definition: Application.cpp:188
QString getName() const override
get the name to be displayed
Definition: sdk/libraries/core/component/Component.h:848
LogLevel
Definition: InterfaceLogger.h:59
static MainWindow * getMainWindow()
get the main window
Definition: Application.cpp:291
const char * what() const noexcept
get the detailed reason from the exception
Definition: AbortException.h:96
New component has no parent frame (parent frame is set to nullptr), and its frame is copied from its ...
Definition: Application.h:69
static PropertyObject * getPropertyObject()
Get the property object of the application.
Definition: Application.cpp:1325
QList< Component * > ComponentList
A list of Component.
Definition: CamiTKAPI.h:88
static const QStringList getComponentDirectories()
get all the component directories.
Definition: Core.cpp:292
static MainWindow * mainWindow
the main window of the CamiTK application
Definition: Application.h:365
this Component represents a volumic image and its subcomponents can be displayed as slices.
Definition: HistoryComponent.h:117
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:1350
static QTranslator * translator
Provide internationalization support for text output.
Definition: Application.h:385
Q_ENUMS(ControlMode CameraOrientation)
RendererWidget implements all support methods to use camiTK with Qt interface.
QProgressBar * getProgressBar()
similar as statusBar() from QMainWindow but for the progress bar
Definition: MainWindow.cpp:317
Only Warning and Error messages are logged.
Definition: InterfaceLogger.h:62
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:828
static Action * getAction(QString)
get a registered action given its name
Definition: Application.cpp:762
static QString getName()
get the application name
Definition: Application.cpp:201
This Class is the base class for your application. It sets up the main window and providing a menubar...
Definition: MainWindow.h:83
bool notify(QObject *, QEvent *) override
reimplemented from QApplication to catch all exception from external libs used in CEP (e....
Definition: Application.cpp:219
QStringList getTag() const
the name of the tag called this action
Definition: Action.h:355
static QMap< QString, Action * > & getActionMap()
all the registered actions, this is a QMap as actions are mainly sort/compared/process by name (key).
Definition: Application.cpp:699
This class describes what is a generic Action extension. To add a ActionExtension to CamiTK core,...
Definition: ActionExtension.h:80
static int registerAllActions(ActionExtension *)
register all actions from the given ActionExtension
Definition: Application.cpp:711
bool eventFilter(QObject *object, QEvent *event) override
Event filter of this class instance to watch its properties instances.
Definition: Application.cpp:1330
static bool hasModified()
Return true if at least one of the opened components has been modified, false otherwise.
Definition: Application.cpp:833
this Component represent a 3D mesh, it has a 3D representation which can be displayed in the 3D viewe...
Definition: HistoryComponent.h:118
static const QList< QFileInfo > getRecentDocuments()
Get the list of recent documents.
Definition: Application.cpp:423
virtual void setLogToStandardOutput(bool writeToStdOut)=0
Allows the logger to write on std::cout.
#define CAMITK_INFO_ALT(MSG)
Definition: Log.h:257
TargetPositionningPolicy
Definition: Application.h:68
static QString getLevelAsString(InterfaceLogger::LogLevel level)
get the enum value as a text
Definition: Log.cpp:80
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:845
#define CAMITK_ERROR_ALT(MSG)
Definition: Log.h:272
const ActionList & getActions()
get the list of actions registered y this extension
Definition: ActionExtension.cpp:103
static const ComponentList & getTopLevelComponents()
get the current application wide list of instantiated top-level Components.
Definition: Application.cpp:884
all types of messages are logged
Definition: InterfaceLogger.h:64
static int exec()
Overriden from QApplication: Enters the main event loop and waits until exit() is called,...
Definition: Application.cpp:305
static HistoryItem removeLastHistoryItem()
Remove the last pushed actions in the history of the current pipeline.
Definition: Application.cpp:933
void refresh()
refresh the display
QString getName()
Get the name of the corresponding action in the pipeline.
Definition: HistoryItem.cpp:57
static const char * version
Definition: Core.h:170
static void unloadAllActionExtensions()
unload all action extensions and delete instantiated actions
Definition: ExtensionManager.cpp:396
this Component has no defined representation.
Definition: HistoryComponent.h:119
Type getType() const
Get the Type of the Component associated to this item.
Definition: HistoryComponent.cpp:52
static QList< QFileInfo > recentDocuments
Definition: Application.h:376
virtual bool addProperty(Property *)
Tag a new CamiTK property to this object.
Definition: PropertyObject.cpp:75
static QSettings settings
global settings for CamiTK application
Definition: Application.h:453
static void registerFileExtension(QString fileExtension)
Register the file extension with the current application for opening This function is called by regis...
Definition: ExtensionManager.cpp:405
virtual void aboutToShow()
this method is automatically called by Application before the first time show() is called.
Definition: MainWindow.cpp:367
static int argc
argc given from command line
Definition: Application.h:368
QString getName() const
Get the the name of the Component associated to this item.
Definition: HistoryComponent.cpp:47
This class describes a property object.
Definition: PropertyObject.h:92
static void setSelected(Component *component, bool isSelected)
insert/remove one specific Component to the selection (at the end).
Definition: Application.cpp:899
QString getComponent() const
the name of the component class that can be used by this action
Definition: Action.h:342
virtual void refresh()
Definition: MainWindow.cpp:302
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:297
virtual bool getModified() const
set the modified flag
Definition: sdk/libraries/core/component/Component.h:886
#define CAMITK_WARNING_IF_ALT(COND, MSG)
Definition: Log.h:315
#define CAMITK_API
Definition: CamiTKAPI.h:48
Definition: Action.cpp:36