Computer Assited Medical Intervention Tool Kit  version 5.0
camitk::Application Class Reference

The generic/default application. Once this class is intanciated in the main, everything is setup. The constructor can take the command line arguments. It can also be asked not to load the extensions automatically,see Application(). More...

#include <Application.h>

+ Inheritance diagram for camitk::Application:
+ Collaboration diagram for camitk::Application:

Public Types

enum  TargetPositionningPolicy { SAME_TRANSFORMATION, NO_TRANSFORMATION, SUBFRAME }
 

Public Member Functions

 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 arguments in argv. More...
 
 ~Application () override
 destructor More...
 

Static Public Member Functions

Selection management
static const ComponentListgetSelectedComponents ()
 get the currently selected Components. More...
 
static void clearSelectedComponents ()
 clear all the selection, i.e call setSelected(false) for all the previously selected components and clear the list. More...
 
Action instances management
static ActiongetAction (QString)
 get a registered action given its name More...
 
static const ActionList getActions ()
 get all the actions registered in the application (note: the returned ActionList is garanteed to be sorted by action name and to contain no duplicates) More...
 
static ActionList getActions (Component *)
 get all the actions that can be applied on a given component (note: the returned ActionList is garanteed to be sorted by action name and to contain no duplicates) More...
 
static ActionList getActions (ComponentList)
 Get all the actions that can be applied on any components of the given list of components (note: the returned ActionList is garanteed to be sorted by action name and to contain no duplicates) More...
 
static ActionList getActions (ComponentList, QString)
 get all the actions that of a given tag (note: the returned ActionList is guaranteed to be sorted by action name and to contain no duplicates) More...
 
static int registerAllActions (ActionExtension *)
 register all actions from the given ActionExtension More...
 
static int unregisterAllActions (ActionExtension *)
 unregister all actions from the given ActionExtension More...
 
static void setTriggeredAction (Action *action)
 set the currently triggered action This is used by Action::trigger(..) to refresh all the viewer (the viewers interested by the fact an action was triggered can then update what they need to) More...
 
static ActiongetTriggeredAction ()
 get the currently triggered action More...
 
Application resources management
static QString getSelectedLanguage ()
 Returns for the current CamiTK application, the selected language (stored in its .ini configuration file) More...
 

Protected Member Functions

bool eventFilter (QObject *object, QEvent *event) override
 Event filter of this class instance to watch its properties instances. More...
 

Static Private Member Functions

static void initResources ()
 Init the application resources by loading the language associated .qml file. More...
 
static ViewerList sort (ViewerSet)
 sort an ViewerSet by viewer's name More...
 
Components management
static ComponentListgetTopLevelComponentList ()
 get the current application wide list of instantiated top-level Components. More...
 
static ComponentListgetAllComponentList ()
 get the current application wide list of all Components. More...
 
static ComponentListgetSelectedComponentList ()
 get the currently selected Components. More...
 
static void setSelected (Component *component, bool isSelected)
 insert/remove one specific Component to the selection (at the end). More...
 
static void addComponent (Component *)
 register a new component either in the full component list, or in the full list and in the top-level list. More...
 
static void removeComponent (Component *)
 unregister a Component. More...
 
Actions management
static QMap< QString, Action * > & getActionMap ()
 As actions are mainly sort/compared/process by name, an internal QMap associates all the contains all the registered actions with their name (key) This is the private (intern) method. More...
 
static ActionList sort (ActionSet)
 sort an ActionSet by action's name More...
 

Static Private Attributes

Recent document management

list of all the remembered recent documents (last opened is last inserted!)

static QList< QFileInfo > recentDocuments
 
static QDir lastUsedDirectory
 last used directory More...
 
static int maxRecentDocuments = 0
 max number of recent document (default 10) More...
 
static QTranslator * translator = nullptr
 Provide internationalization support for text output. More...
 

Application specific

bool notify (QObject *, QEvent *) override
 reimplemented from QApplication to catch all exception from external libs used in CEP (e.g. from ITK) and avoid crashes... More...
 
static QString getName ()
 get the application name More...
 
static QSettings & getSettings ()
 Get the Core wide settings. More...
 
static int exec ()
 Overriden from QApplication: Enters the main event loop and waits until exit() is called, then returns the value that was set to exit() (which is 0 if exit() is called via quit()). More...
 
static const QDir getLastUsedDirectory ()
 Get the last used directory (e.g. More...
 
static void setLastUsedDirectory (QDir)
 set (force) the last used directory More...
 
static void addRecentDocument (QFileInfo)
 Add a document to the list of recent documents (e.g. More...
 
static const QList< QFileInfo > getRecentDocuments ()
 Get the list of recent documents. More...
 
static const int getMaxRecentDocuments ()
 get the maximal number of recent documents stored More...
 

Component instances management

class Component
 class Component is a friend class: only the class Component can access to the private members addComponent(..) and removeComponent(..) More...
 
static Componentopen (const QString &)
 load the filename and returns the corresponding top level Component (returns nullptr if an error occurs) More...
 
static ComponentopenDirectory (const QString &dirName, const QString &pluginName)
 load a directory and returns the corresponding Component (returns nullptr if an error occurs) More...
 
static bool close (Component *component)
 Close a Component: if it has been changed, ask the user for more information, then if everything is ok, delete it. More...
 
static bool save (Component *component)
 save a component to its file (as given by component->getFileName()). More...
 
static const ComponentListgetTopLevelComponents ()
 get the current application wide list of instantiated top-level Components. More...
 
static const ComponentListgetAllComponents ()
 get the current application wide list of all Components. More...
 
static bool isAlive (Component *)
 does this Component still exists? More...
 
static bool hasModified ()
 Return true if at least one of the opened components has been modified, false otherwise. More...
 

viewer management

static ViewergetViewer (QString name)
 get the pointer to a registered viewer given its name More...
 
static ViewergetNewViewer (QString name, QString className)
 instantiate a new viewer of the given name and given class name (Viewer inheriting class). More...
 
static const ViewerList getViewers ()
 get all the viewers registered in the application (note: the returned ViewerList is garanteed to be sorted by viewer name and to not contain any duplicate) More...
 
static ViewerList getViewers (Component *)
 get all the actions that can be applied on a given component (note: the returned ActionList is garanteed to be sorted by action name and to contain no duplicates) More...
 
static bool registerViewer (Viewer *)
 register a viewer in the viewer list (therefore allowing it to be refreshed by the main window automatically More...
 
static int registerAllViewers (ViewerExtension *)
 register all viewers from the given ViewerExtension More...
 
static int unregisterAllViewers (ViewerExtension *)
 unregister all viewers from the given ViewerExtension More...
 
static QMap< QString, Viewer * > & getViewerMap ()
 As viewers are mainly sort/compared/process by name, an internal QMap associates all the registered viewers with their name (key). More...
 
static ViewerExtensiongetViewerExtension (Viewer *viewer)
 

Main Window management

void setMainWindow (MainWindow *mw)
 set the main window. More...
 
static MainWindowgetMainWindow ()
 get the main window More...
 
static void refresh ()
 refresh the main window (this will call the refresh method of all viewers) More...
 
static void showStatusBarMessage (QString msg, int timeout=0)
 Set a message to the status bar. More...
 
static void resetProgressBar ()
 Resets the progress bar if it exists. More...
 
static void setProgressBarValue (int)
 set the progress bar value, value should be in [0..100]. More...
 
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: More...
 

Actions pipeline history

static void addHistoryItem (HistoryItem item)
 Add the history item to the application history. More...
 
static HistoryItem removeLastHistoryItem ()
 Remove the last pushed actions in the history of the current pipeline. More...
 
static void saveHistoryAsSXML ()
 Save the history as an SCXML file, stored using. More...
 
static QStack< HistoryItem > & getHistory ()
 get the history of actions stored. More...
 

Property management

static QString name = Core::version
 name of the CamiTK application (used to differentiate settings between CamiTK applications) More...
 
static MainWindowmainWindow = nullptr
 the main window of the CamiTK application More...
 
static int argc = 0
 argc given from command line More...
 
static char ** argv = nullptr
 argv given from command line More...
 
static ActioncurrentAction = nullptr
 
static PropertyObjectpropertyObject = nullptr
 A simple QObject that holds the CamiTK level properties of the application. More...
 
static PropertyObjectgetPropertyObject ()
 Get the property object of the application. More...
 
void quitting ()
 }@ More...
 
static void createProperties ()
 Create all the application properties and add them to the qApp. More...
 

Application settings

static QSettings settings
 global settings for CamiTK application More...
 
static void applyPropertyValues ()
 Apply all the property values to update the model (e.g., use the logLevel to modify the actual log level of the application logger) More...
 

Detailed Description

The generic/default application. Once this class is intanciated in the main, everything is setup. The constructor can take the command line arguments. It can also be asked not to load the extensions automatically,see Application().

If you do not have a specific MainWindow extension, then the default CamiTK MainWindow is used, see setMainWindow().

This class manages all application-level instances, structures and all. This explains the number of static methods in this class.

It manages:

  • the registered/loaded action extensions and all the actions
  • the registered/loaded component extensions and all the component instances
  • the registered/loaded viewer extensions and all the viewer instances
  • the refresh mechanism
  • the current selection (selected components)
  • the recently opened documents
  • the application language/internationalization settings
  • the opening/closing/saving of components
  • the main window
  • the history of applied actions (including saving it as a CamitK SCXML document)
  • some application level settings

Member Enumeration Documentation

◆ TargetPositionningPolicy

: Policy to determine how a newly instantiated component's frame should be initialized regarding of its parent's component.

Enumerator
SAME_TRANSFORMATION 

New component has no parent frame (parent frame is set to nullptr), and its frame is copied from its parent. This is the default.

NO_TRANSFORMATION 

New component has no parent frame (parent frame is therefore set to nullptr) and transform is Id.

SUBFRAME 

New component's parent frame is its parent component.

Constructor & Destructor Documentation

◆ Application()

camitk::Application::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 arguments in argv.

The first parameter is the name of the application (used as a identifier in the settings, for example)

The second and third parameters comes from the command line (see QApplication API documentation). This constructor inits all the CamiTK context:

  • application wide settings
  • autoload (or not, depending on the last parameter) of the extension
Note
that you have to call init before doing anything!
Parameters
namethe name of the application, it will be used to save specific configuration for example.
argcthe number of command line arguments
argvthe values of the command line arguments
autoloadExtensionif true, all the plugins are loaded
registerFileExtensionif true, the application will prompt the user at first run if he wants to register file formats handled by loaded components with this application for opening.
Note
registerFileExtension is only valid on Windows platform.

References argc, argv, camitk::ExtensionManager::autoload(), CAMITK_INFO, createProperties(), eventFilter(), camitk::ExtensionManager::getFileExtensions(), getName(), camitk::Core::getTestDataDir(), initIcons(), initResources(), lastUsedDirectory, camitk::PropertyObject::loadFromSettings(), mainWindow, maxRecentDocuments, name, propertyObject, quitting(), recentDocuments, camitk::ExtensionManager::registerFileExtension(), settings, and translator.

+ Here is the call graph for this function:

◆ ~Application()

camitk::Application::~Application ( )
override

destructor

References CAMITK_INFO, and propertyObject.

Member Function Documentation

◆ addComponent()

void camitk::Application::addComponent ( Component comp)
staticprivate

register a new component either in the full component list, or in the full list and in the top-level list.

Note
do not call this method from anywhere BUT the Component class destructor; Component is a friend class.

References getAllComponentList(), camitk::Component::getParentComponent(), and getTopLevelComponentList().

+ Here is the call graph for this function:

◆ addHistoryItem()

void camitk::Application::addHistoryItem ( HistoryItem  item)
static

Add the history item to the application history.

The item is added to the history stack of actions used in a pipeline

See also
removeLastHistoryItem() To pop back an action from the history use
Parameters
itemthe item to add to the history

References getHistory().

+ Here is the call graph for this function:

◆ addRecentDocument()

void camitk::Application::addRecentDocument ( QFileInfo  filename)
static

Add a document to the list of recent documents (e.g.

when a document was opened) and update lastUsedDirectory

References lastUsedDirectory, maxRecentDocuments, name, recentDocuments, and settings.

Referenced by open().

+ Here is the caller graph for this function:

◆ applyPropertyValues()

void camitk::Application::applyPropertyValues ( )
staticprivate

Apply all the property values to update the model (e.g., use the logLevel to modify the actual log level of the application logger)

References camitk::InterfaceLogger::ERROR, camitk::Log::getLogger(), camitk::InterfaceLogger::INFO, camitk::InterfaceLogger::NONE, propertyObject, camitk::InterfaceLogger::setDebugInformation(), camitk::InterfaceLogger::setLogLevel(), camitk::InterfaceLogger::setLogToFile(), camitk::InterfaceLogger::setLogToStandardOutput(), camitk::InterfaceLogger::setMessageBoxLevel(), camitk::InterfaceLogger::setTimeStampInformation(), camitk::InterfaceLogger::TRACE, and camitk::InterfaceLogger::WARNING.

Referenced by eventFilter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearSelectedComponents()

void camitk::Application::clearSelectedComponents ( )
static

clear all the selection, i.e call setSelected(false) for all the previously selected components and clear the list.

References getSelectedComponentList(), and camitk::Component::setSelected().

+ Here is the call graph for this function:

◆ close()

bool camitk::Application::close ( Component component)
static

Close a Component: if it has been changed, ask the user for more information, then if everything is ok, delete it.

Parameters
componentthe Component to close.
Returns
true if the closing was made, false if the user cancelled the operation or a saving problem occurs

References camitk::Component::getModified(), camitk::Component::getName(), refresh(), save(), and showStatusBarMessage().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createProperties()

void camitk::Application::createProperties ( )
staticprivate

Create all the application properties and add them to the qApp.

References camitk::PropertyObject::addProperty(), camitk::InterfaceLogger::ERROR, camitk::Log::getLevelAsString(), camitk::Log::getLogger(), getName(), camitk::InterfaceLogger::INFO, camitk::InterfaceLogger::NONE, propertyObject, SAME_TRANSFORMATION, camitk::InterfaceLogger::TRACE, and camitk::InterfaceLogger::WARNING.

Referenced by Application().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eventFilter()

bool camitk::Application::eventFilter ( QObject *  object,
QEvent *  event 
)
overrideprotected

Event filter of this class instance to watch its properties instances.

Each time a property has dynamically changed, this method is called.

References applyPropertyValues(), getName(), propertyObject, and camitk::PropertyObject::saveToSettings().

Referenced by Application().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exec()

int camitk::Application::exec ( )
static

Overriden from QApplication: Enters the main event loop and waits until exit() is called, then returns the value that was set to exit() (which is 0 if exit() is called via quit()).

It is necessary to call this function to start event handling. The main event loop receives events from the window system and dispatches these to the application widgets.

Generally, no user interaction can take place before calling exec(). As a special case, modal widgets like QMessageBox can be used before calling exec(), because modal widgets call exec() to start a local event loop.

To make your application perform idle processing, i.e., executing a special function whenever there are no pending events, use a QTimer with 0 timeout. More advanced idle processing schemes can be achieved using processEvents().

References camitk::MainWindow::aboutToShow(), CAMITK_ERROR_ALT, mainWindow, setMainWindow(), and camitk::MainWindow::show().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAction()

Action * camitk::Application::getAction ( QString  name)
static

get a registered action given its name

References getActionMap(), and name.

Referenced by registerAllActions(), save(), and saveHistoryAsSXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActionMap()

QMap< QString, Action * > & camitk::Application::getActionMap ( )
staticprivate

As actions are mainly sort/compared/process by name, an internal QMap associates all the contains all the registered actions with their name (key) This is the private (intern) method.

The action extension map is updated by loadExtension, unloadExtension and autoloadExtensions.

This method follows the "construct on first use" idiom/design-pattern. It therefore avoids the infamous "static initialization order fiasco", see http://www.parashift.com/c++-faq/ctors.html

Referenced by getAction(), getActions(), registerAllActions(), and unregisterAllActions().

+ Here is the caller graph for this function:

◆ getActions() [1/4]

const ActionList camitk::Application::getActions ( )
static

get all the actions registered in the application (note: the returned ActionList is garanteed to be sorted by action name and to contain no duplicates)

References getActionMap().

Referenced by getActions(), and main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActions() [2/4]

ActionList camitk::Application::getActions ( Component component)
static

get all the actions that can be applied on a given component (note: the returned ActionList is garanteed to be sorted by action name and to contain no duplicates)

References getActions(), camitk::Action::getComponent(), camitk::Component::getHierarchy(), and sort().

+ Here is the call graph for this function:

◆ getActions() [3/4]

ActionList camitk::Application::getActions ( ComponentList  cList)
static

Get all the actions that can be applied on any components of the given list of components (note: the returned ActionList is garanteed to be sorted by action name and to contain no duplicates)

References getActions(), and sort().

+ Here is the call graph for this function:

◆ getActions() [4/4]

ActionList camitk::Application::getActions ( ComponentList  selComp,
QString  tag 
)
static

get all the actions that of a given tag (note: the returned ActionList is guaranteed to be sorted by action name and to contain no duplicates)

References camitk::actionLessThan(), getActions(), and camitk::Action::getTag().

+ Here is the call graph for this function:

◆ getAllComponentList()

ComponentList & camitk::Application::getAllComponentList ( )
staticprivate

get the current application wide list of all Components.

This is the private (intern) method. This holds all the components at any level (full component list), top-level or under. This method follows the "construct on first use" idiom/design-pattern. It therefore avoids the infamous "static initialization order fiasco", see http://www.parashift.com/c++-faq/ctors.html

Referenced by addComponent(), getAllComponents(), and removeComponent().

+ Here is the caller graph for this function:

◆ getAllComponents()

const ComponentList & camitk::Application::getAllComponents ( )
static

get the current application wide list of all Components.

This is the public method (return a const, the component list is private and cannot be modified externally).

References getAllComponentList().

Referenced by isAlive(), camitk::Action::preProcess(), and refresh().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHistory()

QStack< HistoryItem > & camitk::Application::getHistory ( )
staticprivate

get the history of actions stored.

This methods returns the singleton stack of actions stored in a pipeline as their are applied during the execution of the application.

This is the private (intern) method. This history is updated (push(), pop()) by addHistoryItem() and removeHistoryItem() This method follows the "construct on first use" idiom/design-pattern. It therefore avoids the infamous "static initialization order fiasco", see http://www.parashift.com/c++-faq/ctors.html

Referenced by addHistoryItem(), removeLastHistoryItem(), and saveHistoryAsSXML().

+ Here is the caller graph for this function:

◆ getLastUsedDirectory()

const QDir camitk::Application::getLastUsedDirectory ( )
static

Get the last used directory (e.g.

the directory of the last opened document)

References lastUsedDirectory.

◆ getMainWindow()

MainWindow * camitk::Application::getMainWindow ( )
static

get the main window

Note
if there is no MainWindow when this method is first called, then this method makes sure there is a MainWindow by and force the creation of a default MainWindow (direct instance of the MainWindow class)

References mainWindow, and setMainWindow().

+ Here is the call graph for this function:

◆ getMaxRecentDocuments()

const int camitk::Application::getMaxRecentDocuments ( )
static

get the maximal number of recent documents stored

References maxRecentDocuments.

◆ getName()

QString camitk::Application::getName ( )
static

get the application name

References name.

Referenced by ActionStateMachine::ActionStateMachine(), Application(), createProperties(), eventFilter(), getSelectedLanguage(), and initResources().

+ Here is the caller graph for this function:

◆ getNewViewer()

Viewer * camitk::Application::getNewViewer ( QString  name,
QString  className 
)
static

instantiate a new viewer of the given name and given class name (Viewer inheriting class).

Note
this method does not register the viewer automatically. Please call registerViewer(..) to add it to the list of registered viewers.

References CAMITK_ERROR_ALT, camitk::ViewerExtension::getNewInstance(), camitk::ExtensionManager::getViewerExtensionsList(), and name.

+ Here is the call graph for this function:

◆ getPropertyObject()

PropertyObject * camitk::Application::getPropertyObject ( )
static

Get the property object of the application.

Note that everytime a property is changed, the Application is notified, update its settings and take the new property values into account.

See also
eventFilter()

References propertyObject.

Referenced by camitk::Action::setAutoUpdateProperties().

+ Here is the caller graph for this function:

◆ getRecentDocuments()

const QList< QFileInfo > camitk::Application::getRecentDocuments ( )
static

Get the list of recent documents.

References recentDocuments.

◆ getSelectedComponentList()

ComponentList & camitk::Application::getSelectedComponentList ( )
staticprivate

get the currently selected Components.

This is the private (intern) method. the current selection (selected Components can at any level). This method follows the "construct on first use" idiom/design-pattern. It therefore avoids the infamous "static initialization order fiasco", see http://www.parashift.com/c++-faq/ctors.html

Referenced by clearSelectedComponents(), getSelectedComponents(), removeComponent(), and setSelected().

+ Here is the caller graph for this function:

◆ getSelectedComponents()

const ComponentList & camitk::Application::getSelectedComponents ( )
static

get the currently selected Components.

This is the public method (return a const, the selected component list is private and cannot be modified externally).

References getSelectedComponentList().

+ Here is the call graph for this function:

◆ getSelectedLanguage()

QString camitk::Application::getSelectedLanguage ( )
static

Returns for the current CamiTK application, the selected language (stored in its .ini configuration file)

References getName(), getSettings(), and settings.

Referenced by initResources().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSettings()

QSettings & camitk::Application::getSettings ( )
static

Get the Core wide settings.

This is the preferred methods for accessing and writing the settings for your specific needs, although you can use any kind of settings you like, using this allow you to store all settings in one place for all Core needs. This settings are stored in the user scope, using the INI format (i.e. no registers !), the organisation name is TIMC-IMAG and the application name is equal to Core::version. Check the QSettings API documentation to know exactly where is the settings file or call Application::getSettings().fileName()

The recommanded method is to use one section for each Core area. Use the beginGroup("my area")/endGroup() to define specific settings area.

Note
for each beginGroup you use, you HAVE TO use an endGroup(), otherwise the settings state integrity is not guaranteed!

References settings.

Referenced by getSelectedLanguage().

+ Here is the caller graph for this function:

◆ getTopLevelComponentList()

ComponentList & camitk::Application::getTopLevelComponentList ( )
staticprivate

get the current application wide list of instantiated top-level Components.

This is the private (intern) method. The top-level component list is updated by the Component class top-level constructor. This method follows the "construct on first use" idiom/design-pattern. It therefore avoids the infamous "static initialization order fiasco", see http://www.parashift.com/c++-faq/ctors.html

Referenced by addComponent(), getTopLevelComponents(), and removeComponent().

+ Here is the caller graph for this function:

◆ getTopLevelComponents()

const ComponentList & camitk::Application::getTopLevelComponents ( )
static

get the current application wide list of instantiated top-level Components.

This is the public method (return a const, the top-level component list is private and cannot be modified externally).

References getTopLevelComponentList().

Referenced by hasModified().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTriggeredAction()

Action * camitk::Application::getTriggeredAction ( )
static

get the currently triggered action

References currentAction.

◆ getViewer()

Viewer * camitk::Application::getViewer ( QString  name)
static

get the pointer to a registered viewer given its name

References getViewerMap(), and name.

Referenced by VRMLComponentExtension::save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getViewerExtension()

ViewerExtension * camitk::Application::getViewerExtension ( Viewer viewer)
staticprivate

References camitk::Viewer::getName(), camitk::ExtensionManager::getViewerExtensionsList(), and getViewers().

Referenced by registerViewer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getViewerMap()

QMap< QString, Viewer * > & camitk::Application::getViewerMap ( )
staticprivate

As viewers are mainly sort/compared/process by name, an internal QMap associates all the registered viewers with their name (key).

This is the private (intern) method.

This is the private (intern) method.

The viewer extension map is updated by loadExtension, unloadExtension and autoloadExtensions.

This method follows the "construct on first use" idiom/design-pattern. It therefore avoids the infamous "static initialization order fiasco", see http://www.parashift.com/c++-faq/ctors.html

Referenced by getViewer(), getViewers(), registerViewer(), and unregisterAllViewers().

+ Here is the caller graph for this function:

◆ getViewers() [1/2]

const ViewerList camitk::Application::getViewers ( )
static

get all the viewers registered in the application (note: the returned ViewerList is garanteed to be sorted by viewer name and to not contain any duplicate)

References getViewerMap().

Referenced by getViewerExtension(), and getViewers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getViewers() [2/2]

ViewerList camitk::Application::getViewers ( Component component)
static

get all the actions that can be applied on a given component (note: the returned ActionList is garanteed to be sorted by action name and to contain no duplicates)

References camitk::Viewer::getComponents(), camitk::Component::getHierarchy(), getViewers(), and sort().

+ Here is the call graph for this function:

◆ hasModified()

bool camitk::Application::hasModified ( )
static

Return true if at least one of the opened components has been modified, false otherwise.

References getTopLevelComponents().

+ Here is the call graph for this function:

◆ initResources()

void camitk::Application::initResources ( )
staticprivate

Init the application resources by loading the language associated .qml file.

References CAMITK_WARNING_ALT, getName(), getSelectedLanguage(), and translator.

Referenced by Application().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAlive()

bool camitk::Application::isAlive ( Component comp)
static

does this Component still exists?

References getAllComponents().

+ Here is the call graph for this function:

◆ notify()

bool camitk::Application::notify ( QObject *  receiver,
QEvent *  event 
)
override

reimplemented from QApplication to catch all exception from external libs used in CEP (e.g. from ITK) and avoid crashes...

References CAMITK_ERROR.

◆ open()

Component * camitk::Application::open ( const QString &  fileName)
static

load the filename and returns the corresponding top level Component (returns nullptr if an error occurs)

Note
this method opens the filename and created the associated TOP LEVEL component If you wish to open a subcomponent (not top level then), prefer directly calling its public constructor.

References addRecentDocument(), CAMITK_ERROR_ALT, CAMITK_WARNING_IF_ALT, camitk::Core::getComponentDirectories(), camitk::ExtensionManager::getComponentExtension(), camitk::ComponentExtension::getName(), camitk::Component::isTopLevel(), camitk::ComponentExtension::open(), refresh(), resetProgressBar(), showStatusBarMessage(), and camitk::AbortException::what().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ openDirectory()

Component * camitk::Application::openDirectory ( const QString &  dirName,
const QString &  pluginName 
)
static

load a directory and returns the corresponding Component (returns nullptr if an error occurs)

Parameters
dirNamethe name of the directory to open
pluginNamethe name of the plugin to use

References CAMITK_ERROR_ALT, camitk::Core::getComponentDirectories(), camitk::ExtensionManager::getDataDirectoryComponentExtension(), camitk::ComponentExtension::getName(), camitk::ComponentExtension::open(), refresh(), resetProgressBar(), showStatusBarMessage(), and camitk::AbortException::what().

+ Here is the call graph for this function:

◆ quitting

void camitk::Application::quitting ( )
privateslot

}@

References translator, camitk::ExtensionManager::unloadAllActionExtensions(), and camitk::ExtensionManager::unloadAllViewerExtensions().

Referenced by Application().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ refresh()

void camitk::Application::refresh ( )
static

refresh the main window (this will call the refresh method of all viewers)

References getAllComponents(), mainWindow, and camitk::MainWindow::refresh().

Referenced by close(), open(), and openDirectory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ registerAllActions()

int camitk::Application::registerAllActions ( ActionExtension ext)
static

register all actions from the given ActionExtension

Returns
the number of actions effectively registered (in case an action's name is already registered it won't be a second time)

References CAMITK_ERROR_ALT, getAction(), getActionMap(), camitk::ActionExtension::getActions(), camitk::Action::getDescription(), camitk::Action::getExtensionName(), camitk::Action::getFamily(), and camitk::Action::getName().

+ Here is the call graph for this function:

◆ registerAllViewers()

int camitk::Application::registerAllViewers ( ViewerExtension ext)
static

register all viewers from the given ViewerExtension

Returns
the number of viewers effectively registered (in case a viewer's name is already registered by another viewer extension, it won't be registered a second time)

References camitk::ViewerExtension::getViewers(), and registerViewer().

Referenced by ActionStateMachine::ActionStateMachine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ registerViewer()

bool camitk::Application::registerViewer ( Viewer viewer)
static

register a viewer in the viewer list (therefore allowing it to be refreshed by the main window automatically

References CAMITK_ERROR_ALT, camitk::Viewer::getDescription(), camitk::ViewerExtension::getName(), camitk::Viewer::getName(), getViewerExtension(), and getViewerMap().

Referenced by registerAllViewers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeComponent()

void camitk::Application::removeComponent ( Component comp)
staticprivate

unregister a Component.

This method remove top-level component and other level component

Note
do not call this method from anywhere BUT the Component class destructor Component is a friend class.

References getAllComponentList(), getSelectedComponentList(), and getTopLevelComponentList().

+ Here is the call graph for this function:

◆ removeLastHistoryItem()

HistoryItem camitk::Application::removeLastHistoryItem ( )
static

Remove the last pushed actions in the history of the current pipeline.

See also
addHistoryItem() To push back the item use

References getHistory().

+ Here is the call graph for this function:

◆ resetProgressBar()

void camitk::Application::resetProgressBar ( )
static

Resets the progress bar if it exists.

See example of use for ProgressFunction for more detailed explanation.

References camitk::MainWindow::getProgressBar(), and mainWindow.

Referenced by PMLComponentExtension::open(), open(), and openDirectory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

bool camitk::Application::save ( Component component)
static

save a component to its file (as given by component->getFileName()).

Note
the component's file name has to be set prior to call this method.

This method look for the proper loaded ComponentExtension, and call its save(Component*) method

References CAMITK_ERROR_ALT, getAction(), camitk::Core::getComponentDirectories(), camitk::ExtensionManager::getComponentExtension(), camitk::Component::getFileName(), camitk::Component::getName(), camitk::ComponentExtension::save(), setLastUsedDirectory(), showStatusBarMessage(), and camitk::Action::SUCCESS.

Referenced by close(), and main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveHistoryAsSXML()

void camitk::Application::saveHistoryAsSXML ( )
static

◆ setLastUsedDirectory()

void camitk::Application::setLastUsedDirectory ( QDir  last)
static

set (force) the last used directory

References lastUsedDirectory.

Referenced by save().

+ Here is the caller graph for this function:

◆ setMainWindow()

void camitk::Application::setMainWindow ( MainWindow mw)

set the main window.

You need to call this method in order to use a customized CamiTK MainWindow instead of the default one. This method has to be called after init().

It allows you to set the main window using your application extension instance.

Note
Application takes ownership of the MainWindow pointer and deletes it at the appropriate time.
Parameters
mwThe instance of main window you want to use for your application (if NULL a new instance of the MainWindow class is created)

References CAMITK_ERROR, mainWindow, name, and camitk::MainWindow::redirectToConsole().

Referenced by exec(), getMainWindow(), and ActionStateMachine::initMainWindow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setProgressBarValue()

void camitk::Application::setProgressBarValue ( int  value)
static

set the progress bar value, value should be in [0..100].

Attempting to change the current value to one outside the minimum-maximum range has no effect on the current value.

Consider using vtkProgressFunction()

References camitk::MainWindow::getProgressBar(), and mainWindow.

+ Here is the call graph for this function:

◆ setSelected()

void camitk::Application::setSelected ( Component component,
bool  isSelected 
)
staticprivate

insert/remove one specific Component to the selection (at the end).

The selected component list is a QList, because the selection order is important (QList is order, QSet is not). But it does not make any sense to have two times the same Component instance so if isSelected is true we have to "manually" check that it is not already in the list

Note
do not call this method from anywhere BUT the Component setSelected method; Component is a friend class.
Parameters
componentthe component to insert/remove from the selection
isSelectedif true then insert if not already in the selection, otherwise remove

References getSelectedComponentList().

+ Here is the call graph for this function:

◆ setTriggeredAction()

void camitk::Application::setTriggeredAction ( Action action)
static

set the currently triggered action This is used by Action::trigger(..) to refresh all the viewer (the viewers interested by the fact an action was triggered can then update what they need to)

References currentAction.

◆ showStatusBarMessage()

void camitk::Application::showStatusBarMessage ( QString  msg,
int  timeout = 0 
)
static

Set a message to the status bar.

By default there is no timeout (default), i.e. the given message remains displayed until this method is called again (or the status bar is cleared otherwise).

Parameters
msgthe message to display in the status bar.
timeoutnumber of milli-seconds (timeout) before the status bar is cleared (default = 0, i.e. until next call)

References CAMITK_INFO_ALT, and mainWindow.

Referenced by close(), PMLComponentExtension::open(), open(), openDirectory(), and save().

+ Here is the caller graph for this function:

◆ sort() [1/2]

ActionList camitk::Application::sort ( ActionSet  actionSet)
staticprivate

sort an ActionSet by action's name

References camitk::actionLessThan().

Referenced by getActions(), and getViewers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sort() [2/2]

ViewerList camitk::Application::sort ( ViewerSet  viewerSet)
staticprivate

sort an ViewerSet by viewer's name

References camitk::viewerLessThan().

+ Here is the call graph for this function:

◆ unregisterAllActions()

int camitk::Application::unregisterAllActions ( ActionExtension ext)
static

unregister all actions from the given ActionExtension

Returns
the number of actions effectively unregistered

References getActionMap(), camitk::ActionExtension::getActions(), and camitk::Action::getName().

+ Here is the call graph for this function:

◆ unregisterAllViewers()

int camitk::Application::unregisterAllViewers ( ViewerExtension ext)
static

unregister all viewers from the given ViewerExtension

Returns
the number of viewer effectively unregistered

References camitk::Viewer::getName(), getViewerMap(), and camitk::ViewerExtension::getViewers().

Referenced by camitk::ExtensionManager::unloadAllViewerExtensions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vtkProgressFunction()

void camitk::Application::vtkProgressFunction ( vtkObject *  caller,
long unsigned int  ,
void *  ,
void *   
)
static

Observer function to be called by vtkFilters and to update progress bar Example of use:

Application::showStatusBarMessage("Applying my vtk filter");
vtkSmartPointer<vtkCallbackCommand> progressCallback = vtkSmartPointer<vtkCallbackCommand>::New();
progressCallback->SetCallback(&Application::vtkProgressFunction);
myVtkFilter->AddObserver(vtkCommand::ProgressEvent, progressCallback);

References camitk::MainWindow::getProgressBar(), and mainWindow.

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ Component

friend class Component
friend

class Component is a friend class: only the class Component can access to the private members addComponent(..) and removeComponent(..)

Member Data Documentation

◆ argc

int camitk::Application::argc = 0
staticprivate

argc given from command line

Referenced by Application().

◆ argv

char ** camitk::Application::argv = nullptr
staticprivate

argv given from command line

Referenced by Application().

◆ currentAction

Action * camitk::Application::currentAction = nullptr
staticprivate

◆ lastUsedDirectory

QDir camitk::Application::lastUsedDirectory
staticprivate

◆ mainWindow

MainWindow * camitk::Application::mainWindow = nullptr
staticprivate

◆ maxRecentDocuments

int camitk::Application::maxRecentDocuments = 0
staticprivate

max number of recent document (default 10)

Referenced by addRecentDocument(), Application(), and getMaxRecentDocuments().

◆ name

QString camitk::Application::name = Core::version
staticprivate

name of the CamiTK application (used to differentiate settings between CamiTK applications)

Referenced by addRecentDocument(), Application(), getAction(), getName(), getNewViewer(), getViewer(), and setMainWindow().

◆ propertyObject

PropertyObject * camitk::Application::propertyObject = nullptr
staticprivate

A simple QObject that holds the CamiTK level properties of the application.

Note
Use the accessor getPropertyObject() to access this object
See also
PropertyObject

Referenced by Application(), applyPropertyValues(), createProperties(), eventFilter(), getPropertyObject(), and ~Application().

◆ recentDocuments

QList< QFileInfo > camitk::Application::recentDocuments
staticprivate

◆ settings

QSettings camitk::Application::settings
staticprivate

global settings for CamiTK application

Referenced by addRecentDocument(), Application(), getSelectedLanguage(), and getSettings().

◆ translator

QTranslator * camitk::Application::translator = nullptr
staticprivate

Provide internationalization support for text output.

Referenced by Application(), initResources(), and quitting().


The documentation for this class was generated from the following files:
camitk::Application::resetProgressBar
static void resetProgressBar()
Resets the progress bar if it exists.
Definition: Application.cpp:361
camitk::Application::showStatusBarMessage
static void showStatusBarMessage(QString msg, int timeout=0)
Set a message to the status bar.
Definition: Application.cpp:345
camitk::Application::vtkProgressFunction
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