![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GUI/ApplicationController.h>
The basic ApplicationController provides essential interfaces of the SDK but no graphical user interface. More...
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.
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 Progress * | progress () |
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 Workspace & | algorithmHistory () 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 Algorithm * | getAlgorithm (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::string > | placeholders () 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 DataModel * | dataModel () |
virtual const DataModel * | dataModel () 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 AlgorithmController * | getAlgorithmController (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< DataModel > | m_dataModel |
std::unique_ptr< Workspace > | m_algorithmHistory |
History of executed algorithms and their input/output data. | |
std::map< std::string, std::string > | m_placeholders |
Placeholders as extra command line arguments. | |
std::vector< std::unique_ptr< Algorithm > > | m_algorithms |
List of all active Algorithms. | |
std::vector< Properties > | m_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) | |
ApplicationController | ( | std::unique_ptr< DataModel > | dataModel, |
std::optional< Framework::InitConfig > | sdkInitConfig ) |
Instantiate and initialize the ApplicationController interface.
dataModel | DataModel to use for storing Data, must not be null. |
sdkInitConfig | Flag and parameters whether to call Framework::init() during construction. Leave the Optional empty in case you have manually initialized the framework already. |
void load | ( | int | argc, |
char ** | argv ) |
Load configuration file and optional further parameters.
|
virtual |
Loads a workspace file from the path denoted by filename.
Loads the properties from the file and calls loadWorkspace(const Properties*).
|
inlinevirtual |
Returns the optional Progress instance that can be used to report progress updates.
Reimplemented in ConsoleController, and MainWindowBase.
|
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.
|
virtual |
Closes all data, algorithms and annotations.
Reimplemented in MainWindowBase.
|
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.
|
virtual |
Removes the algorithm and deletes it if del is true.
Reimplemented in MainWindowBase.
void registerAlgorithm | ( | const Algorithm & | alg | ) |
Registers the algorithm.
Current untracked data (m_untrackedData) is marked as output of alg.
void ignoreDataInHistory | ( | Data & | data | ) |
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.
T * getAlgorithm | ( | const std::string & | id = "" | ) | const |
Returns the first algorithm of the given type, optionally with id filtering.
Returns nullptr if not existing
|
virtual |
Asks the user the value of some placeholders and returns the input of the user.
Reimplemented in ConsoleController, and MainWindowBase.
void loadPlugins | ( | const std::vector< std::string > & | pluginFolders = std::vector< std::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 variableUnix platforms:
IMFUSION_PLUGIN_PATH
environment variablePlugin 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.
|
virtual |
Check whether data can be deleted or loaded algorithms depend on it.
Reimplemented in MainWindowBase.
|
inlineprotectedvirtual |
Called before an Algorithm is executed, allows for custom configuration.
Reimplemented in MainWindowBase.
|
protectedvirtual |
Open a specific file type.
Reimplemented in MainWindowBase.
|
protectedvirtual |
Prepares data for processing and display.
Callback of DataModel::setPrepareCallback
|
inlineprotectedvirtual |
Returns the controller of the algorithm or nullptr if not existing (default implementation).
Reimplemented in MainWindowBase.
|
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.