Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkMxNMultiWidget.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 QmitkMxNMultiWidget_h
14 #define QmitkMxNMultiWidget_h
15 
16 #include <MitkQtWidgetsExports.h>
17 
18 // qt widgets module
22 
23 #include <nlohmann/json.hpp>
24 
25 #include <map>
26 #include <set>
27 #include <string>
28 #include <utility>
29 #include <vector>
30 
31 class QSplitter;
32 
45 {
46  Q_OBJECT
47 
48 public:
49 
50  QmitkMxNMultiWidget(QWidget* parent = nullptr,
51  Qt::WindowFlags f = {},
52  const QString& multiWidgetName = "mxn");
53 
55 
56  void InitializeMultiWidget() override;
57 
58  void Synchronize(bool synchronized) override;
59 
60  QmitkRenderWindow* GetRenderWindow(const QString& widgetName) const override;
61  QmitkRenderWindow* GetRenderWindow(const mitk::AnatomicalPlane& orientation) const override;
62 
63  void SetActiveRenderWindowWidget(RenderWindowWidgetPointer activeRenderWindowWidget) override;
64 
74  void InitializeViews(const mitk::TimeGeometry* geometry, bool resetCamera) override;
75 
83  void SetInteractionReferenceGeometry(const mitk::TimeGeometry* referenceGeometry) override;
84 
90  bool HasCoupledRenderWindows() const override;
91 
92  void SetSelectedPosition(const mitk::Point3D& newPosition, const QString& widgetName) override;
93  const mitk::Point3D GetSelectedPosition(const QString& widgetName) const override;
94 
95  void SetCrosshairVisibility(bool visible) override;
96  bool GetCrosshairVisibility() const override;
97  void SetCrosshairGap(unsigned int gapSize) override;
98 
99  void ResetCrosshair() override;
100 
101  void SetWidgetPlaneMode(int userMode) override;
102 
104 
107 
108  using GroupSyncIndexType = int;
109 
134  void AddSynchronizationGroup(const GroupSyncIndexType index, const std::string& name = std::string());
135 
158 
168 
198 
217 
235  {
236  QString id; // canonical fully-qualified window id
237  QString displayName; // optional human-readable label, empty when absent
238  QString viewDirection; // "axial" | "sagittal" | "coronal" | "original"
239  QString selectionGroup; // links.selection group label
240  };
241 
266  std::vector<WindowDescriptor> ListWindowDescriptors() const;
267 
300  void ApplyLayout(const nlohmann::json& doc);
301 
302 public Q_SLOTS:
303 
304  // mouse events
305  void wheelEvent(QWheelEvent* e) override;
306  void mousePressEvent(QMouseEvent* e) override;
307  void moveEvent(QMoveEvent* e) override;
308 
325  void LoadLayout(const nlohmann::json* jsonData);
326 
340  void SaveLayout(std::ostream* outStream);
341 
343 
350 
351 Q_SIGNALS:
352 
353  void WheelMoved(QWheelEvent *);
354  void Moved();
358 
359 protected:
360 
373 
375  std::size_t GetSyncGroupCount() const;
376 
377 private:
378 
379  void SetLayoutImpl() override;
380  void SetInteractionSchemeImpl() override { }
381 
396  void ValidateIdsForThisEditor(const nlohmann::json& doc) const;
397 
408  QmitkAbstractMultiWidget::RenderWindowWidgetPointer CreateRenderWindowWidget();
409 
410  QmitkAbstractMultiWidget::RenderWindowWidgetPointer GetWindowFromIndex(size_t index);
411 
423  nlohmann::json SerializeSplitter(const QSplitter* splitter,
424  const std::map<GroupSyncIndexType, std::string>& groupNames) const;
425 
441  WindowDescriptor MakeWindowDescriptor(const QmitkRenderWindowWidget* cell) const;
442 
451  QSplitter* BuildSplitterFromJsonV2(const nlohmann::json& splitNode,
452  const std::map<std::string, GroupSyncIndexType>& nameToInt,
453  QSplitter* parentSplitter);
454 
485  void SeedAndNormalizeGroups(
486  const std::vector<std::pair<std::string, std::string>>& seedingOrder,
487  const std::map<std::string, GroupSyncIndexType>& nameToInt);
488 
496  void TearDownAllCells();
497 
506  void RollBackToSingleDefaultCell();
507 
508  std::map < GroupSyncIndexType, std::unique_ptr<QmitkSynchronizedWidgetConnector> > m_SynchronizedWidgetConnectors;
509 
524  std::map<GroupSyncIndexType, std::string> m_GroupNameByIndex;
525 
531  std::string m_LayoutName;
532 
533  bool m_CrosshairVisibility;
534 
535 };
536 
537 #endif
#define MITKQTWIDGETS_EXPORT
Abstract base widget for displaying multiple render windows at once.
std::shared_ptr< QmitkRenderWindowWidget > RenderWindowWidgetPointer
Convenience type alias for a shared pointer to a render window widget.
QList< mitk::DataNode::Pointer > NodeList
The 'QmitkMxNMultiWidget' is a 'QmitkAbstractMultiWidget' that is used to display multiple render win...
void SetDataBasedLayout(const QmitkAbstractNodeSelectionWidget::NodeList &nodes)
nlohmann::json SerializeLayout() const
Serialize the current layout tree to a v2.0 JSON document (always strict mode).
void UpdateUtilityWidgetViewPlanes()
void SetWidgetPlaneMode(int userMode) override
Sets the widget plane mode (e.g., rotation, swivel).
QmitkSynchronizedWidgetConnector * GetSyncGroupConnector(const GroupSyncIndexType index) const
Look up the connector backing the synchronization group with the given index. Returns nullptr if no g...
void Synchronize(bool synchronized) override
Enable or disable synchronization of display action events.
void SetSelectedPosition(const mitk::Point3D &newPosition, const QString &widgetName) override
Sets the selected position in the specified render window.
void SetSynchronizationGroup(QmitkSynchronizedNodeSelectionWidget *synchronizedWidget, const GroupSyncIndexType index)
Move a synchronized node selection widget to the group with the given index.
void SetCrosshairGap(unsigned int gapSize) override
Sets the gap size of the crosshair.
bool GetCrosshairVisibility() const override
Returns whether the crosshair is currently visible.
void LoadLayout(const nlohmann::json *jsonData)
Slot wrapper around 'ApplyLayout'. Loads a v2.0 layout document (replaces the current cell tree).
void SyncGroupAdded(const GroupSyncIndexType index)
GroupSyncIndexType NextFreeSyncGroupIndex() const
Returns the smallest positive index not already used by an existing synchronization group.
void WheelMoved(QWheelEvent *)
void moveEvent(QMoveEvent *e) override
void InitializeMultiWidget() override
Initialize the multi widget. Must be implemented by subclasses.
void SaveLayout(std::ostream *outStream)
Slot wrapper around 'SerializeLayout'. Writes the current layout as a v2.0 JSON document (pretty-prin...
QmitkMxNMultiWidget(QWidget *parent=nullptr, Qt::WindowFlags f={}, const QString &multiWidgetName="mxn")
mitk::SliceNavigationController * GetTimeNavigationController()
std::size_t GetSyncGroupCount() const
Number of currently registered synchronization groups.
void InitializeViews(const mitk::TimeGeometry *geometry, bool resetCamera) override
Initialize the active render windows of the MxNMultiWidget to the given geometry.
bool HasCoupledRenderWindows() const override
Returns true if the render windows are coupled; false if not.
void AddSynchronizationGroup(const GroupSyncIndexType index, const std::string &name=std::string())
Create a new selection synchronization group with the given index.
QmitkRenderWindow * GetRenderWindow(const mitk::AnatomicalPlane &orientation) const override
Returns the render window that shows the given anatomical orientation.
void wheelEvent(QWheelEvent *e) override
const mitk::Point3D GetSelectedPosition(const QString &widgetName) const override
Returns the selected position in the specified render window.
void mousePressEvent(QMouseEvent *e) override
void SetCrosshairVisibility(bool visible) override
Sets the crosshair visibility.
std::vector< WindowDescriptor > ListWindowDescriptors() const
List all cell leaves in the current layout tree, in pre-order traversal order.
void SetInteractionReferenceGeometry(const mitk::TimeGeometry *referenceGeometry) override
Forward the given time geometry to all base renderers, so that they can store it as their interaction...
void ApplyLayout(const nlohmann::json &doc)
Apply a v2.0 JSON document.
void OnCreateNewSyncGroupRequested(QmitkSynchronizedNodeSelectionWidget *synchronizedWidget)
Slot connected to 'QmitkRenderWindowUtilityWidget::CreateNewSyncGroupRequested'. Allocates the next f...
QmitkRenderWindow * GetRenderWindow(const QString &widgetName) const override
Returns the render window with the given widget name.
RenderWindowWidgetPointer CreateRenderWindowWidget(const QString &id)
Construct a render-window widget with a caller-supplied id.
void ResetCrosshair() override
Resets the crosshair to the default position.
void SetActiveRenderWindowWidget(RenderWindowWidgetPointer activeRenderWindowWidget) override
Sets the active render window widget.
The 'QmitkRenderWindowWidget' is a QFrame that holds a render window and some associates properties,...
MITK implementation of the QVTKWidget.
Node selection widget with renderer-specific functionality and synchronization support.
This class connects different 'QmitkSynchronizedNodeSelectionWidget', such that they can synchronize ...
Controls the selection of the slice the associated BaseRenderer will display.
nlohmann::json json
AnatomicalPlane
Enumeration of standard anatomical image planes.
Plain-data summary of one cell leaf in the layout tree.