Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkAbstractMultiWidget.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef QmitkAbstractMultiWidget_h
14 #define QmitkAbstractMultiWidget_h
15 
16 // mitk qt widgets module
17 #include <MitkQtWidgetsExports.h>
18 
19 // mitk core
20 #include <mitkBaseRenderer.h>
23 #include <mitkPoint.h>
24 
25 // qt
26 #include <QWidget>
27 
28 // c++
29 #include <map>
30 #include <memory>
31 
33 class QmitkRenderWindow;
35 
36 namespace mitk
37 {
38  class DataStorage;
39  class InteractionEventHandler;
40 }
41 
61 {
62  Q_OBJECT
63 
64 public:
65 
67  using RenderWindowWidgetPointer = std::shared_ptr<QmitkRenderWindowWidget>;
69  using RenderWindowWidgetMap = std::map<QString, std::shared_ptr<QmitkRenderWindowWidget>>;
71  using RenderWindowHash = QHash<QString, QmitkRenderWindow*>;
72 
73  QmitkAbstractMultiWidget(QWidget* parent = 0,
74  Qt::WindowFlags f = {},
75  const QString& multiWidgetName = "multiwidget");
76 
78 
80  virtual void InitializeMultiWidget() = 0;
82  virtual void MultiWidgetOpened() { }
84  virtual void MultiWidgetClosed() { }
85 
90  virtual void SetDataStorage(mitk::DataStorage* dataStorage);
96 
108  int GetRowCount() const;
115  int GetColumnCount() const;
121  virtual void SetLayout(int row, int column);
122 
124  virtual void Synchronize(bool) { };
130 
140  void SetDisplayActionEventHandler(std::unique_ptr<mitk::DisplayActionEventHandler> displayActionEventHandler);
146 
165  RenderWindowWidgetPointer GetRenderWindowWidget(const QString& widgetName) const;
180  QmitkRenderWindow* GetRenderWindow(int row, int column) const;
186  virtual QmitkRenderWindow* GetRenderWindow(const QString& widgetName) const;
192  virtual QmitkRenderWindow* GetRenderWindow(const mitk::AnatomicalPlane& orientation) const = 0;
193 
198  virtual void SetActiveRenderWindowWidget(RenderWindowWidgetPointer activeRenderWindowWidget);
205 
207  QString GetMultiWidgetName() const;
214  virtual QString GetNameFromIndex(int row, int column) const;
239  virtual QString GetNameFromIndex(size_t index) const;
240 
242  unsigned int GetNumberOfRenderWindowWidgets() const;
243 
248  void RequestUpdate(const QString& widgetName);
255  void ForceImmediateUpdate(const QString& widgetName);
258 
270  virtual void InitializeViews(const mitk::TimeGeometry* geometry, bool resetCamera) = 0;
271 
280  virtual void SetInteractionReferenceGeometry(const mitk::TimeGeometry* referenceGeometry) = 0;
281 
288  virtual bool HasCoupledRenderWindows() const = 0;
289 
295  virtual void SetSelectedPosition(const mitk::Point3D& newPosition, const QString& widgetName) = 0;
301  virtual const mitk::Point3D GetSelectedPosition(const QString& widgetName) const = 0;
302 
307  virtual void SetCrosshairVisibility(bool visible) = 0;
309  virtual bool GetCrosshairVisibility() const = 0;
314  virtual void SetCrosshairGap(unsigned int gapSize) = 0;
315 
317  virtual void ResetCrosshair() = 0;
318 
323  virtual void SetWidgetPlaneMode(int mode) = 0;
324 
329  virtual void ActivateMenuWidget(bool state);
331  virtual bool IsMenuWidgetEnabled() const;
332 
335 
336 signals:
337 
339 
340 private slots:
341 
342  void OnFocusChanged(itk::Object*, const itk::EventObject& event);
343 
344 protected:
345 
351  virtual void AddRenderWindowWidget(const QString& widgetName, RenderWindowWidgetPointer renderWindowWidget);
361  virtual void RemoveRenderWindowWidget();
368  virtual void RemoveRenderWindowWidget(const QString& widgetName);
369 
382 
383 private:
384 
388  virtual void SetLayoutImpl() = 0;
392  virtual void SetInteractionSchemeImpl() = 0;
393 
394  struct Impl;
395  std::unique_ptr<Impl> m_Impl;
396 
397 };
398 
399 #endif
#define MITKQTWIDGETS_EXPORT
Abstract base widget for displaying multiple render windows at once.
void RequestUpdate(const QString &widgetName)
Requests an update of the render window with the given name.
virtual void RemoveRenderWindowWidget()
Removes the last render window widget by reverse map order.
virtual bool IsMenuWidgetEnabled() const
Returns whether the render window menu widget is enabled.
RenderWindowHash GetRenderWindows() const
Returns a hash of all render windows keyed by name.
mitk::InteractionEventHandler * GetInteractionEventHandler()
Returns the interaction event handler.
virtual QString GetNameFromIndex(int row, int column) const
Returns the widget name for the given row and column.
virtual void MultiWidgetClosed()
Called when the multi widget is closed. Default implementation does nothing.
virtual void SetLayout(int row, int column)
Sets the layout to the given number of rows and columns.
int GetRowCount() const
Returns the row count of the last SetLayout(r, c) call, or 0 if a non-grid layout has been loaded sin...
void SetDisplayActionEventHandler(std::unique_ptr< mitk::DisplayActionEventHandler > displayActionEventHandler)
Sets the display action event handler.
RenderWindowWidgetPointer GetRenderWindowWidget(const QmitkRenderWindow *renderWindow) const
Returns the render window widget that owns the given render window.
RenderWindowWidgetMap Get3DRenderWindowWidgets() const
Returns all 3D render window widgets.
QmitkAbstractMultiWidget(QWidget *parent=0, Qt::WindowFlags f={}, const QString &multiWidgetName="multiwidget")
std::map< QString, std::shared_ptr< QmitkRenderWindowWidget > > RenderWindowWidgetMap
Convenience type alias for a map of render window widgets keyed by name.
virtual void SetDataStorage(mitk::DataStorage *dataStorage)
Sets the data storage for all render window widgets.
QmitkMultiWidgetLayoutManager * GetMultiWidgetLayoutManager() const
Returns the layout manager for this multi widget.
QString GetMultiWidgetName() const
Returns the name of this multi widget.
virtual void SetInteractionScheme(mitk::InteractionSchemeSwitcher::InteractionScheme scheme)
Sets the interaction scheme for the multi widget.
virtual void InitializeMultiWidget()=0
Initialize the multi widget. Must be implemented by subclasses.
virtual bool GetCrosshairVisibility() const =0
Returns whether the crosshair is currently visible.
void ForceImmediateUpdateAll()
Forces an immediate update of all render windows.
virtual void AddRenderWindowWidget(const QString &widgetName, RenderWindowWidgetPointer renderWindowWidget)
Adds a render window widget with the given name.
RenderWindowWidgetPointer GetFirstRenderWindowWidget() const
Returns the first render window widget.
virtual void InitializeViews(const mitk::TimeGeometry *geometry, bool resetCamera)=0
Initialize the render windows of the concrete multi widget to the given geometry.
void ResetGridState()
Reset the grid-layout sentinel: row/column counts to 0 and the active render-window pointer to nullpt...
virtual void Synchronize(bool)
Enable or disable synchronization of display action events.
unsigned int GetNumberOfRenderWindowWidgets() const
Returns the number of render window widgets.
virtual void RemoveRenderWindowWidget(const QString &widgetName)
Removes the render window widget registered under the given qualified name. No-op if no such widget i...
RenderWindowWidgetPointer GetRenderWindowWidget(const QString &widgetName) const
Returns the render window widget with the given name.
void RequestUpdateAll()
Requests an update of all render windows.
virtual void ResetCrosshair()=0
Resets the crosshair to the default position.
virtual void SetCrosshairGap(unsigned int gapSize)=0
Sets the gap size of the crosshair.
int GetColumnCount() const
Returns the column count of the last SetLayout(r, c) call, or 0 if a non-grid layout has been loaded ...
std::shared_ptr< QmitkRenderWindowWidget > RenderWindowWidgetPointer
Convenience type alias for a shared pointer to a render window widget.
virtual void SetSelectedPosition(const mitk::Point3D &newPosition, const QString &widgetName)=0
Sets the selected position in the specified render window.
virtual void SetInteractionReferenceGeometry(const mitk::TimeGeometry *referenceGeometry)=0
Define the reference geometry for interaction within a render window.
mitk::DisplayActionEventHandler * GetDisplayActionEventHandler()
Returns the display action event handler.
virtual void MultiWidgetOpened()
Called when the multi widget is opened. Default implementation does nothing.
virtual QString GetNameFromIndex(size_t index) const
Returns the qualified widget name for the given linear index.
virtual QmitkRenderWindow * GetRenderWindow(const QString &widgetName) const
Returns the render window with the given widget name.
QmitkRenderWindow * GetRenderWindow(int row, int column) const
Returns the render window at the given row and column.
virtual QmitkRenderWindow * GetRenderWindow(const mitk::AnatomicalPlane &orientation) const =0
Returns the render window that shows the given anatomical orientation.
RenderWindowWidgetPointer GetRenderWindowWidget(int row, int column) const
Returns the render window widget at the given row and column.
virtual void SetCrosshairVisibility(bool visible)=0
Sets the crosshair visibility.
virtual bool HasCoupledRenderWindows() const =0
Returns true if the render windows are coupled; false if not.
mitk::DataStorage * GetDataStorage() const
Returns the current data storage.
virtual void ActivateMenuWidget(bool state)
Activates or deactivates the render window menu widget.
RenderWindowWidgetPointer GetActiveRenderWindowWidget() const
Returns the currently active render window widget.
virtual void SetWidgetPlaneMode(int mode)=0
Sets the widget plane mode (e.g., rotation, swivel).
virtual const mitk::Point3D GetSelectedPosition(const QString &widgetName) const =0
Returns the selected position in the specified render window.
QHash< QString, QmitkRenderWindow * > RenderWindowHash
Convenience type alias for a hash of render windows keyed by name.
void ForceImmediateUpdate(const QString &widgetName)
Forces an immediate update of the render window with the given name.
RenderWindowWidgetMap GetRenderWindowWidgets() const
Returns all render window widgets.
RenderWindowWidgetMap Get2DRenderWindowWidgets() const
Returns all 2D render window widgets.
virtual void SetActiveRenderWindowWidget(RenderWindowWidgetPointer activeRenderWindowWidget)
Sets the active render window widget.
RenderWindowWidgetPointer GetLastRenderWindowWidget() const
Returns the last render window widget.
virtual ~QmitkAbstractMultiWidget()
The layout manager provides different layout-functions that can modify the layout of an QmitkAbstract...
The 'QmitkRenderWindowWidget' is a QFrame that holds a render window and some associates properties,...
MITK implementation of the QVTKWidget.
Abstract data management class that organizes DataNode objects in a directed acyclic graph.
Simplifies connecting display action event observers to a DisplayActionEventBroadcast.
Base class for all objects that handle mitk::InteractionEvents.
Find image slices visible on a given plane.
AnatomicalPlane
Enumeration of standard anatomical image planes.