ImFusion SDK 4.3
Workspace Class Reference

#include <ImFusion/GUI/Workspace.h>

Workspaces allow for restoring a session or automate the execution of a series of data loading and algorithms in a similar fashion as scripting. More...

+ Inheritance diagram for Workspace:

Detailed Description

Workspaces allow for restoring a session or automate the execution of a series of data loading and algorithms in a similar fashion as scripting.

This class serves as encapsulation of the individual aspects of workspaces. The workspace state can either be retrieved from an ApplicationController and/or loaded from a workspace file (a XML-serialized form of a workspace). An existing workspace can then be run/executed in an ApplicationController and/or saved to a workspace file.

Workspaces can store the following information:

  • A set of algorithms, each described by:
    • The Algorithm factory name
    • The algorithm Configuration and optionally the corresponding AlgorithmController configuration (if any)
    • A list of input Data (if any), each described by a UID
    • A list of output Data (if any), each described by a UID
    • An executed flag describing whether the algorithm shall be executed or only opened
  • A set of metadata blocks for of datasets, each described by:
    • A unique ID (uid) used for cross-referencing within a workspace
    • An optional name/title that shall be shown in the DataModel
    • An optional transformation matrix
    • Optional Properties (only for images)
  • A set of DataLink instances that link datasets.
  • A set of annotations, each described by:
    • An optional parent dataset (described by a UID) under which the annotation is stored in the AnnotationModel
    • An optional reference dataset storing annotation data in case of meshes, point clouds, etc.
    • Properties storing the configuration
  • Optional Display settings
See also
Workspaces API, WorkspaceConversionFunction, Placeholders in Workspace Files

Public Types

enum class  Mode { Replay = 0 , Snapshot = 1 }
 Save mode of a workspace file describing how algorithms and intermediate data are handled/stored. More...
 
enum  { WORKSPACE_VERSION = 34 }
 Current version number of written workspace files.
 

Public Member Functions

void recordAlgorithm (const Algorithm &algorithm, const AlgorithmController *controller, bool executed, const DataList &inputData, const DataList &outputData, bool keepControllerOpen=false, bool canUseReplayWorkspace=true)
 Add an algorithm to be recorded by this workspace.
 
void markAlgorithmAsRemoved (const Algorithm *alg)
 Marks an algorithm as removed.
 
bool updateAlgorithmDescription (const Algorithm *alg)
 Update the description of a recorded algorithm.
 
void recordSelectionChange (MainWindowBase &mwb, SharedImageSet &sis)
 Convenience method to record a SelectionChangeAlgorithm for the given image if needed.
 
void retrieveState (ApplicationController &appCtrl)
 Retrieve workspace state from the current state of the given ApplicationController.
 
bool execute (ApplicationController &appCtrl)
 Execute the workspace in the given ApplicationController.
 
bool loadFromFile (const std::string &filename)
 Load a workspace state from a file.
 
bool saveToFile (const std::string &filename, Mode mode)
 Save the workspace state to an .iws file.
 
bool saveToFile (const std::string &filename)
 Save the workspace state to an .iws file. Uses p_saveMode to determine the mode.
 
bool exportAsPython (const std::string &filename)
 Export the workspace algorithms as python script.
 
void clear ()
 Clear the current workspace state.
 
bool isComposed () const
 Returns whether the algorithm 'Run Workspace' is in the current workspace.
 
void registerData (Data &data, const std::string &uid)
 Register a data under a given uid.
 
void setFallbackDataModel (const DataModel *dm)
 
void setSelectedDataComponents (const std::set< std::string > &selectedComps)
 Sets the list of DataComponent IDs that will be written to the workspace file on export.
 
const std::set< std::string > & selectedDataComponents () const
 Retrieves the list of DataComponent IDs that will be written to the workspace file on export.
 
bool canUseReplayWorkspace () const
 Returns whether all algorithms in the history can be replayed (determined by the flag passed in recordAlgorithm)
 
- Public Member Functions inherited from SignalReceiver
 SignalReceiver ()=default
 Default constructor.
 
 SignalReceiver (const SignalReceiver &other)
 Copy constructor, does not copy any existing signal connections from other.
 
SignalReceiveroperator= (SignalReceiver rhs)
 Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs.
 
virtual ~SignalReceiver ()
 Virtual destructor disconnects from all connected signals.
 
- Public Member Functions inherited from Configurable
virtual void configure (const Properties *p)
 Configure this object instance by de-serializing the given Properties.
 
virtual void configuration (Properties *p) const
 Serialize the current object configuration into the given Properties object.
 
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
 
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
 
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 
 Configurable (const Configurable &rhs)
 
 Configurable (Configurable &&rhs) noexcept
 
Configurableoperator= (const Configurable &)
 
Configurableoperator= (Configurable &&) noexcept
 

Static Public Member Functions

static std::vector< std::map< std::string, std::string > > loadPlaceholderBatchFile (const std::string &filename, const std::vector< std::string > &placeholderKeys)
 Loads a set of placeholders from a file for batch processing.
 

Public Attributes

Parameter< Modep_saveMode {"saveMode", Mode::Replay, this}
 
Parameter< bool > p_removeDefaultProperties {"removeDefaultProperties", true, this}
 
Parameter< bool > p_removeEmptyProperties {"removeEmptyProperties", true, this}
 
Parameter< bool > p_saveAbsolutePaths {"saveAbsolutePaths", false, this}
 
Parameter< bool > p_saveDisplayState {"saveDisplayState", true, this}
 
Parameter< bool > p_composeWorkspacesInSaving {"composeWorkspacesInSaving", true, this}
 
- Public Attributes inherited from Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.
 

Additional Inherited Members

- Protected Member Functions inherited from SignalReceiver
void disconnectAll ()
 Disconnects all existing connections.
 
- Protected Attributes inherited from Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.
 

Member Enumeration Documentation

◆ Mode

enum class Mode
strong

Save mode of a workspace file describing how algorithms and intermediate data are handled/stored.

Enumerator
Replay 

Do not save intermediate data generated by algorithms explicitly.

Instead, the complete algorithm history is stored in the workspace.

Snapshot 

Write the entire data model to a separate file.

Only store open algorithms in workspace that have not yet been executed.

Member Function Documentation

◆ recordAlgorithm()

void recordAlgorithm ( const Algorithm & algorithm,
const AlgorithmController * controller,
bool executed,
const DataList & inputData,
const DataList & outputData,
bool keepControllerOpen = false,
bool canUseReplayWorkspace = true )

Add an algorithm to be recorded by this workspace.

Parameters
algorithmAlgorithm to record
controllerOptional AlgorithmController whose configuration should be recorded as well
executedFlag whether this algorithm has been executed
outputDataList of input data of the algorithm
outputDataList of output data of the algorithm
keepControllerOpenFlag whether to create the controller even if execute is true
canUseReplayWorkspaceFlag whether a replay algorithm would be able to reproduce the algorithm exeuction exactly

◆ retrieveState()

void retrieveState ( ApplicationController & appCtrl)

Retrieve workspace state from the current state of the given ApplicationController.

Note
All Data referenced in the workspace (e.g. by algorithms or annotations) should have been introduced already as part of the outputData in recordAlgorithm(). If a dataset referenced in the ApplicationController state that is yet unknown by the workspace, subsequent replay of the workspace might not properly restore the dataset.

◆ execute()

bool execute ( ApplicationController & appCtrl)

Execute the workspace in the given ApplicationController.

Note
Placeholders values are taken and/or queried from the ApplicationController interface.

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