ImFusion SDK 4.3
MainWindowBase Class Referenceabstract

#include <ImFusion/GUI/MainWindowBase.h>

Extends ApplicationController with additional interfaces for graphical user interfaces. More...

+ Inheritance diagram for MainWindowBase:

Detailed Description

Extends ApplicationController with additional interfaces for graphical user interfaces.

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.

Public Types

enum class  PostLoadAction {
  None = 0 , SelectData = 1 << 0 , ShowViews = 1 << 1 , StoreOriginalMatrix = 1 << 2 ,
  CreateDataController = 1 << 3 , All = 0xFF
}
 Bitflag enumeration of available actions that the default implementation of postLoad() performs. More...
 

Public Slots

virtual void onVisibleDataChanged (const DataList &before, const DataList &now)
 This method is called when the selection in the DataWidget changes. The base implementation only hands all image data to the DisplayWidget.
 
virtual void onDataDeleting (Data *data)
 This is called when data in the DataWidget is about to be deleted.
 
virtual void onDataDeleted ()
 This is called when data in the DataWidget has been deleted.
 

Signals

void settingsChanged ()
 Emitted when the settings are changed by the user e.g.
 

Public Member Functions

 MainWindowBase (std::optional< Framework::InitConfig > sdkInitConfig, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::Widget)
 Instantiate and initialize the MainWindowBase interface.
 
 ~MainWindowBase () override
 Destructor.
 
Progressprogress () override
 Returns m_progressDialog.
 
void setupWidgets ()
 Initializes any widget of MainWindowBase and adds them to the ui. Must be called after the ui has been initialized.
 
virtual void resetViews ()
 Resets views of MainWindowBase.
 
virtual void resetLayout ()
 Resets layout of MainWindowBase.
 
void readSettings ()
 Load and restore window position and size settings.
 
void writeSettings ()
 Write window position and size settings.
 
virtual void loadStyleSheet ()
 Reads the default style and loads it.
 
virtual QBoxLayout * algorithmDock () const =0
 
virtual QBoxLayout * secondaryAlgorithmDock () const
 Returns an optional secondary algorithm dock.
 
virtual QBoxLayout * scrollBarLayout () const =0
 
virtual QToolBar * toolbar () const
 
virtual DataControllerBarcontrollerBar () const
 
virtual DisplayWidgetMultidisplay () const =0
 
virtual LogViewerWidgetlogWidget () const
 
virtual QWidget * collapseDockButton () const
 
virtual QWidget * mainWidget () const
 
virtual const DataItemModeldataItemModel () const
 
virtual const QItemSelectionModel * dataSelectionModel () const
 
virtual const AnnotationModelannotationModel () const
 
virtual DataItemModeldataItemModel ()
 
virtual QItemSelectionModel * dataSelectionModel ()
 
virtual DataFilterModeldataItemFilterModel ()
 
virtual AnnotationModelannotationModel ()
 
std::vector< InteractiveObject * > selectedAnnotations (const Data *dataset, bool includeGlobal=true) const
 Return the currently selected annotations for a given data set or all annotation if data set is zero.
 
DataList selectedData () const
 Return the currently selected data.
 
void selectData (const Data *data)
 Select a single data sets.
 
void selectData (const DataList &selection)
 Select one or multiple data sets.
 
void updateSelected ()
 Update the currently selected data in terms of description and scroll bar.
 
AlgorithmControllergetAlgorithmController (const Algorithm *a) const override
 Returns the controller of the algorithm or nullptr if not existing.
 
virtual AlgorithmControllergetAlgorithmController (const std::string &id) const
 Returns the controller of the first algorithm with the given id or nullptr if not existing.
 
virtual DataControllergetDataController (const std::string &name) const
 Returns the data controller with the given name or nullptr if not existing.
 
virtual ControllerDecoratorgetControllerDecorator (const Controller *controller)
 Returns the container widget hosting the corresponding Controller or nullptr if not existing.
 
virtual ControllerDecoratoraddController (Controller *controller)
 Registers a Controller instance with the MainWindowBase so that it can be shown in the GUI.
 
virtual void removeController (Controller *controller)
 Removes a previously registered Controller from this MainWindowBase so that it is no longer shown in the GUI.
 
template<typename T>
T * getDataController () const
 Returns the data controller of the given type or nullptr if not existing.
 
bool canBeDeleted (const Data *data) override
 Check whether data can be deleted or loaded algorithms depend on it.
 
void showAnnotationWidget (bool visible=true)
 Shows / hides the annotation editor.
 
void expandAnnotationWidget (bool visible=true)
 Expands / collapses the annotation editor.
 
void showDataWidget (bool visible=true)
 Expands / collapses the data widget.
 
void initIOPlugins (QMenu *importMenu)
 Add I/O plugins to import and export menu.
 
void reset (bool keepTester=false)
 Reset application. Set keepTester to true when running GUI unit tests.
 
void processEvents ()
 Process pending GUI events.
 
void dragEnterEvent (QDragEnterEvent *event) override
 Accepts drops with mime type "text/uri-list".
 
void dropEvent (QDropEvent *event) override
 For mime type "text/uri-list", the mime text is used as a filename and the file is opened as data.
 
std::vector< std::map< std::string, std::string > > askWorkspacePlaceholders (const std::vector< std::string > &placeholderKeys) override
 Asks the user the value of some placeholders and returns the input of the user.
 
virtual void setStatusText (const QString &)
 Sets the text of the status bar.
 
void closeAll () override
 Closes all data, algorithms and annotations.
 
Flags< PostLoadActionpostLoadActions () const
 Returns the set of actions to perform in default implementation of postLoad().
 
void setPostLoadActions (Flags< PostLoadAction > value)
 Sets the set of actions to perform in default implementation of postLoad().
 
void addAlgorithm (std::unique_ptr< Algorithm > a, const Properties *config=nullptr) override
 Adds a the given algorithm and creates a controller if available.
 
void removeAlgorithm (Algorithm *a, bool del=true) override
 Same as removeAlgorithm(a, del, true)
 
virtual void removeAlgorithm (Algorithm *a, bool del, bool delCtrl, bool executed=false)
 Removes the given algorithm and its associated controller.
 
void removeAlgorithmLater (Algorithm *a, bool del, bool delCtrl, bool executed=false)
 Schedules a call to removeAlgorithm() with the same arguments using the Qt event loop.
 
virtual void setLogoPixmap (std::unique_ptr< QPixmap > logoPixmap)
 Set a logo for customized branding. This functionality is disabled by default unless it is explicity enabled for an installer.
 
virtual void onObjectDeleting (InteractiveObject *obj)
 This is called when data in the DataWidget is about to be deleted.
 
void onPaste ()
 
virtual void applySettings ()
 Apply updated settings.
 
void importData ()
 Import data using I/O algorithm.
 
void addRecentFile (const QString &algorithm, const QString &fileName, const Properties *p)
 Add file to recently opened files.
 
AnnotationWidgetannotationWidget ()
 
DataWidgetdataWidget ()
 
ViewLayoutWidgetviewsWidget ()
 
SelectionWidgetselectionWidget ()
 
virtual bool open (const std::string &filename, DataList *outDataList=nullptr)
 Opens a generic file and adds it to the DataModel.
 
- Public Member Functions inherited from ApplicationController
 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 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 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.
 
- 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.
 

Static Public Member Functions

static void loadStyleSheet (QApplication &app, QString style)
 Loads a specified style sheet.
 
static void loadStyleSheet (QApplication &app)
 Loads the default style sheet.
 
static QString readDefaultStyleQssFiles ()
 Reads the default style qss files and returns their content (files are concatenated).
 
static void reloadStyleSheet ()
 Reloads default style sheet.
 

Protected Slots

bool prepareData (Data *data) const override
 Calls ApplicationController::prepareData and additionally checks if an image can be uploaded with OpenGL.
 
virtual void postLoad (Data *data)
 This method is called after data has been loaded.
 
void toggleFullscreen (bool flag)
 Toggles between fullscreen and default/maximized window mode.
 
virtual void onSelectionModelChanged (const QItemSelection &selected, const QItemSelection &deselected)
 Slot called when the MainWindow's data selection model has changed.
 
virtual void onScreenChanged (QScreen *newScreen)
 Slot called when the hosting QWindow's screen has changed.
 
void processDroppedFiles (const QStringList filenames)
 Slot called after a drop event has been accepted (as to not block the source program by loading data in the drop event itself)
 

Protected Member Functions

bool openFile (const QString *additionalFilters=0, QString *filename=0, QString *selectedFilter=0)
 Shows file selection dialog for open and opens file if the format is known.
 
bool saveFileAs (const QString *additionalFilters=0, QString *filename=0, QString *selectedFilter=0)
 Shows file selection dialog for save and saves file if the format is known.
 
bool openWithIoAlgorithms (const std::vector< std::string > &algs, const std::string &filename, DataList *dataOut) override
 Asks the user which of the algs to use to open filename, loads file into the DataModel and stores the result in dataOut.
 
bool eventFilter (QObject *target, QEvent *event) override
 Filters close events of algorithm controllers and data controllers.
 
void closeEvent (QCloseEvent *event) override
 Removes all algorithms before closing.
 
void configureAlgorithm (Algorithm *a) override
 Called before an Algorithm is executed, allows for custom configuration.
 
bool open (const std::string &algorithm, const std::string &name, DataList *data, bool addToRecentFiles=true, const Properties *p=nullptr, std::string *effectivePath=nullptr) override
 Open a specific file type.
 
void deleteControllerIfOwned (Controller *controller)
 Deletes controller and related instances if it is owned by this instance (only applies to AlgorithmControllers and DataControllers).
 
- Protected Member Functions inherited from ApplicationController
virtual bool prepareData (Data *data) const
 Prepares data for processing and display.
 
bool checkDicomMagicByte (const Filesystem::Path &filename) const
 Checks the given file whether it contains the DICOM magic byte ("DICM" at bytes 128 ff.).
 
- Protected Member Functions inherited from SignalReceiver
void disconnectAll ()
 Disconnects all existing connections.
 

Protected Attributes

std::map< Algorithm *, std::unique_ptr< AlgorithmController > > m_algorithmController
 AlgorithmControllers per Algorithm.
 
std::map< std::string, std::unique_ptr< DataController > > m_dataControllers
 DataControllers per factory ID.
 
std::map< Controller *, std::unique_ptr< DefaultControllerDecorator > > m_controllers
 List of all known Controllers and their container widgets.
 
std::unique_ptr< ProgressDialogm_progressDialog
 Progress dialog widget.
 
std::unique_ptr< DataItemModelm_dataItemModel
 DataItemModel wrapping the ApplicationController's dataModel()
 
DataWidgetm_dataWidget = nullptr
 Displays the DataModel and provides selection.
 
AnnotationWidgetm_annotationWidget = nullptr
 widget to edit annotations
 
SelectionWidgetm_selWidget = nullptr
 selection widget
 
ViewLayoutWidgetm_layoutWidget = nullptr
 widget controls for the view layout
 
RecentFilesMenum_recentFilesMenu = nullptr
 menu for recent files
 
QMap< QString, QAction * > m_actions
 Contains all menu actions.
 
Flags< PostLoadActionm_postLoadActions = PostLoadAction::All
 Set of actions to perform in default implementation of postLoad()
 
- Protected Attributes inherited from ApplicationController
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.
 

Additional Inherited Members

- Public Attributes inherited from ApplicationController
Signal< const Algorithm * > signalAlgorithmRemoved
 Signal emitted just before an Algorithm is removed.
 
- Static Protected Attributes inherited from ApplicationController
static std::string m_logFileLocation
 Path to the log file (empty if not set)
 

Member Enumeration Documentation

◆ PostLoadAction

enum class PostLoadAction
strong

Bitflag enumeration of available actions that the default implementation of postLoad() performs.

Enumerator
None 

Don't perform any actions in postLoad()

SelectData 

Change the selection of the DataWidget to the newly added Data.

ShowViews 

Make views that can show the added Data visible in case they are not.

StoreOriginalMatrix 

Store the Data's original pose matrix in its TransformationStashDataComponent.

CreateDataController 

Create and show a DataController for the added Data if possible.

All 

Perform all actions in postLoad()

Constructor & Destructor Documentation

◆ MainWindowBase()

MainWindowBase ( std::optional< Framework::InitConfig > sdkInitConfig,
QWidget * parent = nullptr,
Qt::WindowFlags flags = Qt::Widget )

Instantiate and initialize the MainWindowBase interface.

Parameters
sdkInitConfigFlag and parameters whether to call Framework::init() during construction. Leave the Optional empty in case you have initialized the SDK already manually.
Note
If you provide a custom OpenGL context make sure to use a GlContextQt so that it is compatible with DisplayWidget.
Parameters
parentOptional parent QWidget.
flagsQt window flags

Member Function Documentation

◆ progress()

Progress * progress ( )
overridevirtual

Returns m_progressDialog.

Reimplemented from ApplicationController.

◆ loadStyleSheet() [1/3]

static void loadStyleSheet ( QApplication & app,
QString style )
static

Loads a specified style sheet.

This function can be used to initially set the style before the main window is created to ensure that a splash/loading, login or license dialog is styled correctly. In this case you should call MainWindowBase::loadStyleSheet(*qApp,CustomMainWindow::readCustomStyle()) where readCustomStyle is a static function reading the custom style (instead of readDefaultStyleQssFiles).

◆ loadStyleSheet() [2/3]

static void loadStyleSheet ( QApplication & app)
static

Loads the default style sheet.

Deprecated
"Use `loadStyleSheet(QApplication& app, QString& style)` to specify the style content or use the non-static version to ensure loading of the correct style"

◆ loadStyleSheet() [3/3]

virtual void loadStyleSheet ( )
virtual

Reads the default style and loads it.

This method internally calls readDefaultStyleQssFiles.

Override this method if you want to provide a custom style in a derived class. Example in custom main window class:

class CustomMainWindow : public MainWindowBase
{
// ...
QString readCustomStyle()
{
// get file from ressource
QFile stylesheet(":/style/customStyle.qss");
if (stylesheet.open(QIODevice::ReadOnly))
return stylesheet.readAll();
else
return QString();
}
void loadStyleSheet() override
{
MainWindowBase::loadStyleSheet(*qApp, MiniNavSystem::readCustomStyle());
}
}
virtual void loadStyleSheet()
Reads the default style and loads it.
MainWindowBase(std::optional< Framework::InitConfig > sdkInitConfig, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::Widget)
Instantiate and initialize the MainWindowBase interface.

◆ reloadStyleSheet()

static void reloadStyleSheet ( )
static

Reloads default style sheet.

Deprecated
"Directly use `loadStyleSheet` instead"

◆ getAlgorithmController()

AlgorithmController * getAlgorithmController ( const Algorithm * a) const
overridevirtual

Returns the controller of the algorithm or nullptr if not existing.

Reimplemented from ApplicationController.

◆ addController()

virtual ControllerDecorator * addController ( Controller * controller)
virtual

Registers a Controller instance with the MainWindowBase so that it can be shown in the GUI.

The default implementation will decorate it using a standard DefaultControllerDecorator. Subclasses may override this function to use a custom UI.

◆ removeController()

virtual void removeController ( Controller * controller)
virtual

Removes a previously registered Controller from this MainWindowBase so that it is no longer shown in the GUI.

The default implementation will remove the ControllerDecorator used for decoration. Furthermore, it will delete controller if deleteControllerIfOwned is true and controller is owned by this MainWindowBase instance (only applies to AlgorithmControllers and DataControllers that were originally created through MainWindowBase and not added from the outside).

◆ canBeDeleted()

bool canBeDeleted ( const Data * data)
overridevirtual

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

Reimplemented from ApplicationController.

◆ askWorkspacePlaceholders()

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

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

Reimplemented from ApplicationController.

◆ closeAll()

void closeAll ( )
overridevirtual

Closes all data, algorithms and annotations.

Reimplemented from ApplicationController.

◆ addAlgorithm()

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

Adds a the given algorithm and creates a controller if available.

If no controller is available, the algorithm is instantly executed and deletes afterwards (a will be set to 0). If config contains a sub-property "Controller", it will be used to configure the controller. The controller is always initialized after the algorithm was configured and added.

Reimplemented from ApplicationController.

◆ removeAlgorithm() [1/2]

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

Same as removeAlgorithm(a, del, true)

Reimplemented from ApplicationController.

◆ removeAlgorithm() [2/2]

virtual void removeAlgorithm ( Algorithm * a,
bool del,
bool delCtrl,
bool executed = false )
virtual

Removes the given algorithm and its associated controller.

If del is true, the algorithm is also deleted (a will be invalid afterwards!). If delCtrl is true, the controller is deleted, too. If executed is true, the algorithm configuration is stored in the history of executed algorithms.

◆ settingsChanged

void settingsChanged ( )
signal

Emitted when the settings are changed by the user e.g.

through the SettingsDialog. It is not emitted when the settings change through any other means. You should not rely on this signal ever being called.

◆ postLoad

virtual void postLoad ( Data * data)
protectedvirtualslot

This method is called after data has been loaded.

The default implementation will perform all actions as specified in postLoadActions().

◆ onScreenChanged

virtual void onScreenChanged ( QScreen * newScreen)
protectedvirtualslot

Slot called when the hosting QWindow's screen has changed.

Will re-evaluate the new screen's DPI and notify the renderer backend etc.

◆ openFile()

bool openFile ( const QString * additionalFilters = 0,
QString * filename = 0,
QString * selectedFilter = 0 )
protected

Shows file selection dialog for open and opens file if the format is known.

The caller can add additional filters to the file open dialog. If an unknown filter is selected the method returns it in selectedFilter.

◆ saveFileAs()

bool saveFileAs ( const QString * additionalFilters = 0,
QString * filename = 0,
QString * selectedFilter = 0 )
protected

Shows file selection dialog for save and saves file if the format is known.

The caller can add additional filters to the file save dialog. If an unknown filter is selected the method returns it in selectedFilter.

◆ openWithIoAlgorithms()

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

Asks the user which of the algs to use to open filename, loads file into the DataModel and stores the result in dataOut.

Reimplemented from ApplicationController.

◆ eventFilter()

bool eventFilter ( QObject * target,
QEvent * event )
overrideprotected

Filters close events of algorithm controllers and data controllers.

On close event for a data controller, the controller is removed and deleted. For algorithm controllers which are QWidget the controller and its algorithm is removed and deleted. For controllers which are QDialog, reject() slot will be raised. They must handle deleting themselves and their algorithms either by overriding the reject() slot or in their run() method considering that the default reject slot() causes the exec() method to return 0. AlgorithmController::closeAlgorithm method can be called to remove the algorithm and its controller.

◆ configureAlgorithm()

void configureAlgorithm ( Algorithm * a)
overrideprotectedvirtual

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

Reimplemented from ApplicationController.

◆ open() [1/2]

bool open ( const std::string & algorithm,
const std::string & name,
DataList * data,
bool addToRecentFiles = true,
const Properties * p = nullptr,
std::string * effectivePath = nullptr )
overrideprotectedvirtual

Open a specific file type.

Reimplemented from ApplicationController.

◆ open() [2/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 from ApplicationController.


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