Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkSlicesInterpolator.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 QmitkSlicesInterpolator_h
14 #define QmitkSlicesInterpolator_h
15 
16 #include <mitkDataNode.h>
17 #include <mitkDataStorage.h>
20 #include <mitkToolManager.h>
22 
23 #include <QWidget>
24 #include <map>
25 
26 #include <QCheckBox>
27 #include <QComboBox>
28 #include <QFrame>
29 #include <QGroupBox>
30 #include <QRadioButton>
31 
33 #include <vtkProperty.h>
34 
35 // For running 3D interpolation in background
36 #include <QFuture>
37 #include <QFutureWatcher>
38 #include <QTimer>
39 #include <QtConcurrentRun>
40 
41 namespace mitk
42 {
43  class PlaneGeometry;
44  class SliceNavigationController;
45  class TimeNavigationController;
46 }
47 
48 class QPushButton;
49 class QmitkRenderWindow;
50 
66 {
67  Q_OBJECT
68 
69 public:
70  QmitkSlicesInterpolator(QWidget *parent = nullptr, const char *name = nullptr);
71 
75  void Initialize(mitk::ToolManager *toolManager, const QList<QmitkRenderWindow*>& windows);
76 
78  void Uninitialize();
79 
81 
83  void SetDataStorage(mitk::DataStorage::Pointer storage);
84 
87 
90 
95 
100 
102  void OnTimeChanged(itk::Object *sender, const itk::EventObject &);
103 
105  void OnSliceChanged(itk::Object *sender, const itk::EventObject &);
106 
107 
109  void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &);
110 
114  void OnInterpolationInfoChanged(const itk::EventObject &);
115 
119  void OnInterpolationAborted(const itk::EventObject &);
120 
124  void OnSurfaceInterpolationInfoChanged(const itk::EventObject &);
125 
126 
127 private:
129  void Show3DInterpolationResult(bool);
130 
132  void OnActiveLabelChanged(mitk::Label::PixelType);
133 
134 signals:
135 
138 
139 public slots:
140 
141  virtual void setEnabled(bool);
146 
149 
154 
155 protected slots:
156 
161 
162  /*
163  Opens popup to ask about which orientation should be interpolated
164  */
166 
167  /*
168  Reaction to button clicks
169  */
171 
174 
175  /*
176  * Will trigger interpolation for all slices in given orientation (called from popup menu of
177  * OnAcceptAllInterpolationsClicked)
178  */
179  void OnAcceptAllPopupActivated(QAction *action);
180 
185 
188 
191 
199  void OnShowMarkers(bool);
200 
203 
211 
214 
217 
220 
221 protected:
222 
223  typedef std::map<QAction*, mitk::SliceNavigationController*> ActionToSliceDimensionMapType;
224  const ActionToSliceDimensionMapType CreateActionToSlicer(const QList<QmitkRenderWindow*>& windows);
226 
228 
234 
243  bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e,
244  mitk::SliceNavigationController *sliceNavigationController);
245 
253 
259 
261 
262 private:
263  void InitializeWindow(QmitkRenderWindow* window);
264  void HideAllInterpolationControls();
265  void Show2DInterpolationControls(bool show);
266  void Show3DInterpolationControls(bool show);
267  void CheckSupportedImageDimension();
268  void WaitForFutures();
269  void NodeRemoved(const mitk::DataNode* node);
270 
271  mitk::SegmentationInterpolationController::Pointer m_Interpolator;
272  mitk::SurfaceInterpolationController::Pointer m_SurfaceInterpolator;
273 
274  mitk::ToolManager::Pointer m_ToolManager;
275  bool m_Initialized;
276 
277  unsigned int m_ControllerToTimeObserverTag;
278  QHash<mitk::SliceNavigationController *, int> m_ControllerToSliceObserverTag;
279  QHash<mitk::SliceNavigationController *, int> m_ControllerToDeleteObserverTag;
280 
281  unsigned int InterpolationInfoChangedObserverTag;
282  unsigned int SurfaceInterpolationInfoChangedObserverTag;
283  unsigned int InterpolationAbortedObserverTag;
284 
285  QGroupBox *m_GroupBoxEnableExclusiveInterpolationMode;
286  QComboBox *m_CmbInterpolation;
287  QPushButton *m_BtnApply2D;
288  QPushButton *m_BtnApplyForAllSlices2D;
289  QPushButton *m_BtnApply3D;
290 
291  QCheckBox *m_ChkShowPositionNodes;
292  QPushButton *m_BtnReinit3DInterpolation;
293 
294  mitk::DataNode::Pointer m_FeedbackNode;
295  mitk::DataNode::Pointer m_InterpolatedSurfaceNode;
296 
297  mitk::MultiLabelSegmentation *m_Segmentation;
298 
300  unsigned int m_LastSliceIndex;
301 
302  mitk::TimePointType m_TimePoint;
303 
304  bool m_2DInterpolationEnabled;
305  bool m_3DInterpolationEnabled;
306 
307  unsigned int m_numTimesLabelSetConnectionAdded;
308 
309  mitk::DataStorage::Pointer m_DataStorage;
310 
311  QFuture<void> m_Future;
312  QFutureWatcher<void> m_Watcher;
313 
314  QFuture<void> m_ModifyFuture;
315  QFutureWatcher<void> m_ModifyWatcher;
316 
317  QTimer *m_Timer;
318 
319  QFuture<void> m_PlaneFuture;
320  QFutureWatcher<void> m_PlaneWatcher;
321 
322  mitk::Label::PixelType m_CurrentActiveLabelValue;
323 
324  bool m_FirstRun;
325 };
326 
327 #endif
#define MITKSEGMENTATIONUI_EXPORT
MITK implementation of the QVTKWidget.
GUI for slices interpolation.
void OnShowMarkers(bool)
Called when the "show position markers" checkbox is toggled.
void Uninitialize()
Releases resources and disconnects from the tool manager and render windows.
void OnAccept3DInterpolationClicked()
ActionToSliceDimensionMapType m_ActionToSlicerMap
void Interpolate(mitk::PlaneGeometry *plane)
void StopUpdateInterpolationTimer()
Stops the interpolation update timer.
void SetDataStorage(mitk::DataStorage::Pointer storage)
Sets the data storage used for interpolation feedback nodes.
~QmitkSlicesInterpolator() override
void OnInterpolationMethodChanged(int index)
Called when the interpolation method combo box selection changes.
void OnReinit3DInterpolation()
Reinitializes 3D interpolation by re-reading the plane geometries of the segmentation image.
void EnableInterpolation(bool)
void ChangeSurfaceColor()
Updates the surface color to match the active label color.
void OnSliceChanged(itk::Object *sender, const itk::EventObject &)
Reacts to the slice changed event. Public for itk::Command callbacks.
bool TranslateAndInterpolateChangedSlice(const mitk::TimeGeometry *timeGeometry)
const ActionToSliceDimensionMapType CreateActionToSlicer(const QList< QmitkRenderWindow * > &windows)
void OnAcceptAllInterpolationsClicked()
void AcceptAllInterpolationsWithErrorHandling(mitk::SliceNavigationController *slicer)
mitk::DataStorage * GetDataStorage()
Returns the current data storage.
void Run3DInterpolation()
Triggers 3D surface interpolation in a background thread.
void FinishInterpolation(mitk::SliceNavigationController *slicer=nullptr)
void On3DInterpolationActivated(bool)
Called when 3D interpolation is activated or deactivated.
void On3DInterpolationEnabled(bool)
Called when the 3D interpolation radio button is toggled.
void OnInterpolationActivated(bool)
virtual void setEnabled(bool)
std::map< QAction *, mitk::SliceNavigationController * > ActionToSliceDimensionMapType
void OnSurfaceInterpolationFinished()
Called when the surface interpolation thread completes.
void OnInterpolationAborted(const itk::EventObject &)
void OnAcceptAllPopupActivated(QAction *action)
void SetActiveLabelValue(mitk::MultiLabelSegmentation::LabelValueType labelValue)
Sets the active label value for which interpolation is performed.
void OnToolManagerWorkingDataModified()
void OnSurfaceInterpolationInfoChanged(const itk::EventObject &)
QmitkSlicesInterpolator(QWidget *parent=nullptr, const char *name=nullptr)
void Initialize(mitk::ToolManager *toolManager, const QList< QmitkRenderWindow * > &windows)
void SignalShowMarkerNodes(bool)
void SignalRememberContourPositions(bool)
void OnInterpolationDisabled(bool)
Called when the "no interpolation" radio button is toggled.
void OnTimeChanged(itk::Object *sender, const itk::EventObject &)
Reacts to the time changed event. Public for itk::Command callbacks.
void Enable3DInterpolation(bool)
Enables or disables 3D surface interpolation.
void On2DInterpolationEnabled(bool)
Called when the 2D interpolation radio button is toggled.
void OnInterpolationInfoChanged(const itk::EventObject &)
void StartUpdateInterpolationTimer()
Starts the timer that periodically triggers interpolation updates.
void OnToolManagerReferenceDataModified()
void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &)
Handles deletion of a SliceNavigationController. Public for itk::Command callbacks.
bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e, mitk::SliceNavigationController *sliceNavigationController)
void AcceptAllInterpolations(mitk::SliceNavigationController *slicer)
Central node class of the MITK data tree, associating a data object with properties and mappers.
Definition: mitkDataNode.h:72
Abstract data management class that organizes DataNode objects in a directed acyclic graph.
unsigned short PixelType
Pixel type used for label values (unsigned short).
Definition: mitkLabel.h:106
MultiLabelSegmentation class for handling labels and layers in a segmentation session.
mitk::Label::PixelType LabelValueType
Describes the geometry of a plane object.
Controls the selection of the slice the associated BaseRenderer will display.
Manages and coordinates instances of mitk::Tool.
Find image slices visible on a given plane.
mitk::ScalarType TimePointType
Type for time point values in milliseconds (ms).