ImFusion SDK 4.3
ApplicationController Class Reference

#include <ImFusion/GUI/ApplicationController.h>

The basic ApplicationController provides essential interfaces of the SDK but no graphical user interface. More...

+ Inheritance diagram for ApplicationController:

Detailed Description

The basic ApplicationController provides essential interfaces of the SDK but no graphical user interface.

Depending on the constructor arguments, instantiating this class can also take care of proper initialization (e.g. factories, OpenGL contexts, etc.) of the ImFusion SDK. In this case you do not need to call Framework::init() explicitly.

While it is technically possible to have multiple ApplicationController instances at the same time, such setups are discouraged and may be considered undefined/unsupported behavior.

See also
What is the correct way to initialize the ImFusionLib and its plugins?

Public Member Functions

 ApplicationController (std::unique_ptr< DataModel > dataModel, std::optional< Framework::InitConfig > sdkInitConfig)
 Instantiate and initialize the ApplicationController interface.
 
void load (int argc, char **argv)
 Load configuration file and optional further parameters.
 
void loadAll (const std::vector< std::string > &fileNames)
 Loads all files passed as arguments.
 
virtual bool loadWorkspace (const Filesystem::Path &filename, const std::optional< std::map< std::string, std::string > > &=std::nullopt)
 Loads a workspace file from the path denoted by filename.
 
virtual Progressprogress ()
 Returns the optional Progress instance that can be used to report progress updates.
 
virtual bool open (const std::string &filename, DataList *outDataList=nullptr)
 Opens a generic file and adds it to the DataModel.
 
virtual void closeAll ()
 Closes all data, algorithms and annotations.
 
virtual void addAlgorithm (std::unique_ptr< Algorithm > a, const Properties *config=nullptr)
 Adds an algorithm.
 
virtual void removeAlgorithm (Algorithm *a, bool del=true)
 Removes the algorithm and deletes it if del is true.
 
virtual void clearAlgorithms ()
 Removes all algorithm and deletes it if del is true.
 
virtual void executeAlgorithms ()
 Executes all algorithms. TODO: delete algorithms afterwards?
 
virtual void addAlgorithmToHistory (const Algorithm &a, bool allowReplayWorkspaces=true)
 Adds an already executed algorithm to the history.
 
void registerAlgorithm (const Algorithm &alg)
 Registers the algorithm.
 
void updateRegisteredAlgorithm (const Algorithm &alg)
 Update the description of a recorded algorithm.
 
void ignoreDataInHistory (Data &data)
 Ignore the given Data in the algorithm history/workspace.
 
void ignoreAnnotationInHistory (InteractiveObject &annotation)
 Ignore the given Annotation in the algorithm history/workspace.
 
const WorkspacealgorithmHistory () const
 Return the workspace instance modeling list of executed algorithms and their input/output data.
 
std::vector< Algorithm * > algorithms () const
 Returns the list of all algorithms.
 
virtual std::vector< Algorithm * > dependingAlgorithms (const Data *data) const
 Returns the algorithms that depend on data.
 
virtual std::vector< Algorithm * > dependingAlgorithms (const DataList &data) const
 Returns the algorithms that depend on exactly the provided data list.
 
virtual AlgorithmgetAlgorithm (const std::string &id) const
 Returns the first algorithm with the given id or nullptr if not existing.
 
template<typename T>
T * getAlgorithm (const std::string &id="") const
 Returns the first algorithm of the given type, optionally with id filtering.
 
virtual std::vector< std::map< std::string, std::string > > askWorkspacePlaceholders (const std::vector< std::string > &placeholderKeys)
 Asks the user the value of some placeholders and returns the input of the user.
 
virtual void addPlaceholder (const std::string &name, const std::string &value)
 Adds a placeholder value to m_placeholders (or overwrites it if it already exists)
 
virtual std::map< std::string, std::stringplaceholders () const
 Gets the currently set placeholders.
 
virtual void setPlaceholders (const std::map< std::string, std::string > &placeholders)
 Sets the placeholders.
 
virtual bool saveWorkspace (const Filesystem::Path &filename, std::optional< std::set< std::string > > selectedDataComps=std::nullopt)
 Save current workspace to a iws file Selected data components passed as parameter are also saved.
 
virtual DataModeldataModel ()
 
virtual const DataModeldataModel () const
 
void loadPlugins (const std::vector< std::string > &pluginFolders=std::vector< std::string >())
 Load and register/initializes all ImFusion plugins from the specified folders.
 
virtual bool canBeDeleted (const Data *data)
 Check whether data can be deleted or loaded algorithms depend on it.
 

Public Attributes

Signal< const Algorithm * > signalAlgorithmRemoved
 Signal emitted just before an Algorithm is removed.
 

Protected Member Functions

virtual void configureAlgorithm (Algorithm *)
 Called before an Algorithm is executed, allows for custom configuration.
 
virtual bool open (const std::string &algorithm, const std::string &name, DataList *outDataList, bool addToRecentFiles=true, const Properties *p=nullptr, std::string *pathOut=nullptr)
 Open a specific file type.
 
virtual bool prepareData (Data *data) const
 Prepares data for processing and display.
 
virtual AlgorithmControllergetAlgorithmController (const Algorithm *) const
 Returns the controller of the algorithm or nullptr if not existing (default implementation).
 
bool checkDicomMagicByte (const Filesystem::Path &filename) const
 Checks the given file whether it contains the DICOM magic byte ("DICM" at bytes 128 ff.).
 
virtual bool openWithIoAlgorithms (const std::vector< std::string > &algs, const std::string &filename, DataList *dataOut)
 Uses the first of the given algs to open filename, store them in the DataModel and optionally put them in dataOut.
 

Protected Attributes

std::unique_ptr< DataModelm_dataModel
 
std::unique_ptr< Workspacem_algorithmHistory
 History of executed algorithms and their input/output data.
 
std::map< std::string, std::stringm_placeholders
 Placeholders as extra command line arguments.
 
std::vector< std::unique_ptr< Algorithm > > m_algorithms
 List of all active Algorithms.
 
std::vector< Propertiesm_algorithmTemplates
 List of templates that newly instantiated algorithms should be configured from.
 
DataList m_untrackedData
 Data that has been added to the data model but is not yet assigned to an output of an algorithm.
 
std::vector< Data * > m_ignoredData
 Data that has been explicitly marked to be ignored in workspaces.
 
std::vector< InteractiveObject * > m_ignoredAnnotations
 Annotations that have been explicitly marked to be ignored in workspaces.
 
bool m_prepareShiftOnly = true
 Only shift intensities during prepareData.
 
bool m_prepareNoShiftScale = false
 Do not shift or scale intensities during prepareData, overrides m_prepareShiftOnly.
 
bool m_prepareDownsample = false
 Downsample data during prepareData.
 

Static Protected Attributes

static std::string m_logFileLocation
 Path to the log file (empty if not set)
 

Constructor & Destructor Documentation

◆ ApplicationController()

Instantiate and initialize the ApplicationController interface.

Parameters
dataModelDataModel to use for storing Data, must not be null.
sdkInitConfigFlag and parameters whether to call Framework::init() during construction. Leave the Optional empty in case you have manually initialized the framework already.
See also
Framework::init(), LicenseManagerSDK

Member Function Documentation

◆ load()

void load ( int argc,
char ** argv )

Load configuration file and optional further parameters.

Deprecated
"Use instead one of the member functions `loadAll`, `loadWorkspace`, `loadImf`."

◆ loadWorkspace()

virtual bool loadWorkspace ( const Filesystem::Path & filename,
const std::optional< std::map< std::string, std::string > > & = std::nullopt )
virtual

Loads a workspace file from the path denoted by filename.

Loads the properties from the file and calls loadWorkspace(const Properties*).

◆ progress()

virtual Progress * progress ( )
inlinevirtual

Returns the optional Progress instance that can be used to report progress updates.

Reimplemented in ConsoleController, and MainWindowBase.

◆ open() [1/2]

virtual bool open ( const std::string & filename,
DataList * outDataList = nullptr )
virtual

Opens a generic file and adds it to the DataModel.

The algorithm used to open the file is decided on the extension. You can provide an optional outDataList parameter to receive the list of loaded data. Returns true on success, false otherwise.

Reimplemented in MainWindowBase.

◆ closeAll()

virtual void closeAll ( )
virtual

Closes all data, algorithms and annotations.

Reimplemented in MainWindowBase.

◆ addAlgorithm()

virtual void addAlgorithm ( std::unique_ptr< Algorithm > a,
const Properties * config = nullptr )
virtual

Adds an algorithm.

Subclasses overriding this method may change or even delete the pointer. The optional config is used to configure the algorithm before it is added to the list of algorithms.

Reimplemented in MainWindowBase.

◆ removeAlgorithm()

virtual void removeAlgorithm ( Algorithm * a,
bool del = true )
virtual

Removes the algorithm and deletes it if del is true.

Reimplemented in MainWindowBase.

◆ registerAlgorithm()

void registerAlgorithm ( const Algorithm & alg)

Registers the algorithm.

Current untracked data (m_untrackedData) is marked as output of alg.

◆ ignoreDataInHistory()

void ignoreDataInHistory ( Data & data)

Ignore the given Data in the algorithm history/workspace.

AlgorithmControllers that add temporary data to the DataModel should call this function to mark the data as its side-product. This will avoid potentially corrupt workspaces due to wrong tracking of data origin.

◆ ignoreAnnotationInHistory()

void ignoreAnnotationInHistory ( InteractiveObject & annotation)

Ignore the given Annotation in the algorithm history/workspace.

AlgorithmControllers that add temporary annotations to the AnnotationModel should call this function to mark the data as its side-product. This will avoid potentially corrupt workspaces due to wrong tracking of data origin.

◆ getAlgorithm()

template<typename T>
T * getAlgorithm ( const std::string & id = "") const

Returns the first algorithm of the given type, optionally with id filtering.

Returns nullptr if not existing

◆ askWorkspacePlaceholders()

virtual std::vector< std::map< std::string, std::string > > askWorkspacePlaceholders ( const std::vector< std::string > & placeholderKeys)
virtual

Asks the user the value of some placeholders and returns the input of the user.

Reimplemented in ConsoleController, and MainWindowBase.

◆ loadPlugins()

void loadPlugins ( const std::vector< std::string > & pluginFolders = std::vectorstd::string >())

Load and register/initializes all ImFusion plugins from the specified folders.

If pluginFolders is empty, the following default search paths are used:

Windows platforms:

  • IMFUSION_PLUGIN_PATH environment variable
  • <executable-path>/plugins
  • <ImFusionLib.dll-path>/plugins

Unix platforms:

  • IMFUSION_PLUGIN_PATH environment variable
  • <ImFusionLib.so-path>/../lib/ImFusionLib/plugins

Plugin names defined in the environment variable IMFUSION_PLUGIN_BLACKLIST as a semi-colon-separated list (e.g. "Foo.dll;Bar.dll") will not be loaded by this function. This mechanism can also be used to explicitly ignore libraries that might conflict with or crash the application.

Will additionally call ImFusionPlugin::setApplicationController() on every loaded plugin.

◆ canBeDeleted()

virtual bool canBeDeleted ( const Data * data)
virtual

Check whether data can be deleted or loaded algorithms depend on it.

Reimplemented in MainWindowBase.

◆ configureAlgorithm()

virtual void configureAlgorithm ( Algorithm * )
inlineprotectedvirtual

Called before an Algorithm is executed, allows for custom configuration.

Reimplemented in MainWindowBase.

◆ open() [2/2]

virtual bool open ( const std::string & algorithm,
const std::string & name,
DataList * outDataList,
bool addToRecentFiles = true,
const Properties * p = nullptr,
std::string * pathOut = nullptr )
protectedvirtual

Open a specific file type.

Reimplemented in MainWindowBase.

◆ prepareData()

virtual bool prepareData ( Data * data) const
protectedvirtual

Prepares data for processing and display.

Callback of DataModel::setPrepareCallback

◆ getAlgorithmController()

virtual AlgorithmController * getAlgorithmController ( const Algorithm * ) const
inlineprotectedvirtual

Returns the controller of the algorithm or nullptr if not existing (default implementation).

Reimplemented in MainWindowBase.

◆ openWithIoAlgorithms()

virtual bool openWithIoAlgorithms ( const std::vector< std::string > & algs,
const std::string & filename,
DataList * dataOut )
protectedvirtual

Uses the first of the given algs to open filename, store them in the DataModel and optionally put them in dataOut.

Reimplemented in MainWindowBase.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close