Medical Imaging Interaction Toolkit  2025.12.02
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 
67 {
68  Q_OBJECT
69 
70 public:
71  QmitkSlicesInterpolator(QWidget *parent = nullptr, const char *name = nullptr);
72 
76  void Initialize(mitk::ToolManager *toolManager, const QList<QmitkRenderWindow*>& windows);
77 
82  void Uninitialize();
83 
85 
91  void SetDataStorage(mitk::DataStorage::Pointer storage);
92 
99 
101 
106 
111 
117  void OnTimeChanged(itk::Object *sender, const itk::EventObject &);
118 
124  void OnSliceChanged(itk::Object *sender, const itk::EventObject &);
125 
126 
127  void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &);
128 
132  void OnInterpolationInfoChanged(const itk::EventObject &);
133 
137  void OnInterpolationAborted(const itk::EventObject &);
138 
142  void OnSurfaceInterpolationInfoChanged(const itk::EventObject &);
143 
144 
145 private:
149  void Show3DInterpolationResult(bool);
150 
155  void OnActiveLabelChanged(mitk::Label::PixelType);
156 
157 signals:
158 
161 
162 public slots:
163 
164  virtual void setEnabled(bool);
169 
171 
176 
177 protected slots:
178 
183 
184  /*
185  Opens popup to ask about which orientation should be interpolated
186  */
188 
189  /*
190  Reaction to button clicks
191  */
193 
200 
201  /*
202  * Will trigger interpolation for all slices in given orientation (called from popup menu of
203  * OnAcceptAllInterpolationsClicked)
204  */
205  void OnAcceptAllPopupActivated(QAction *action);
206 
211 
213 
215 
216  // Enhancement for 3D interpolation
220  void OnShowMarkers(bool);
221 
223 
231 
233 
235 
237 
238 protected:
239 
240  typedef std::map<QAction*, mitk::SliceNavigationController*> ActionToSliceDimensionMapType;
241  const ActionToSliceDimensionMapType CreateActionToSlicer(const QList<QmitkRenderWindow*>& windows);
243 
245 
254  bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e,
255  mitk::SliceNavigationController *sliceNavigationController);
256 
264 
270 
272 
273 private:
274  void InitializeWindow(QmitkRenderWindow* window);
275  void HideAllInterpolationControls();
276  void Show2DInterpolationControls(bool show);
277  void Show3DInterpolationControls(bool show);
278  void CheckSupportedImageDimension();
279  void WaitForFutures();
280  void NodeRemoved(const mitk::DataNode* node);
281 
282  mitk::SegmentationInterpolationController::Pointer m_Interpolator;
283  mitk::SurfaceInterpolationController::Pointer m_SurfaceInterpolator;
284 
285  mitk::ToolManager::Pointer m_ToolManager;
286  bool m_Initialized;
287 
288  unsigned int m_ControllerToTimeObserverTag;
289  QHash<mitk::SliceNavigationController *, int> m_ControllerToSliceObserverTag;
290  QHash<mitk::SliceNavigationController *, int> m_ControllerToDeleteObserverTag;
291 
292  unsigned int InterpolationInfoChangedObserverTag;
293  unsigned int SurfaceInterpolationInfoChangedObserverTag;
294  unsigned int InterpolationAbortedObserverTag;
295 
296  QGroupBox *m_GroupBoxEnableExclusiveInterpolationMode;
297  QComboBox *m_CmbInterpolation;
298  QPushButton *m_BtnApply2D;
299  QPushButton *m_BtnApplyForAllSlices2D;
300  QPushButton *m_BtnApply3D;
301 
302  QCheckBox *m_ChkShowPositionNodes;
303  QPushButton *m_BtnReinit3DInterpolation;
304 
305  mitk::DataNode::Pointer m_FeedbackNode;
306  mitk::DataNode::Pointer m_InterpolatedSurfaceNode;
307 
308  mitk::MultiLabelSegmentation *m_Segmentation;
309 
311  unsigned int m_LastSliceIndex;
312 
313  mitk::TimePointType m_TimePoint;
314 
315  bool m_2DInterpolationEnabled;
316  bool m_3DInterpolationEnabled;
317 
318  unsigned int m_numTimesLabelSetConnectionAdded;
319 
320  mitk::DataStorage::Pointer m_DataStorage;
321 
322  QFuture<void> m_Future;
323  QFutureWatcher<void> m_Watcher;
324 
325  QFuture<void> m_ModifyFuture;
326  QFutureWatcher<void> m_ModifyWatcher;
327 
328  QTimer *m_Timer;
329 
330  QFuture<void> m_PlaneFuture;
331  QFutureWatcher<void> m_PlaneWatcher;
332 
333  mitk::Label::PixelType m_CurrentActiveLabelValue;
334 
335  bool m_FirstRun;
336 };
337 
338 #endif
#define MITKSEGMENTATIONUI_EXPORT
MITK implementation of the QVTKWidget.
GUI for slices interpolation.
void OnAccept3DInterpolationClicked()
ActionToSliceDimensionMapType m_ActionToSlicerMap
void Interpolate(mitk::PlaneGeometry *plane)
void SetDataStorage(mitk::DataStorage::Pointer storage)
Set the Data Storage object.
~QmitkSlicesInterpolator() override
void OnInterpolationMethodChanged(int index)
void OnReinit3DInterpolation()
Reaction to reinit 3D Interpolation. Re-reads the plane geometries of the image that should have gene...
void EnableInterpolation(bool)
void OnSliceChanged(itk::Object *sender, const itk::EventObject &)
Reacts to the slice changed event.
bool TranslateAndInterpolateChangedSlice(const mitk::TimeGeometry *timeGeometry)
const ActionToSliceDimensionMapType CreateActionToSlicer(const QList< QmitkRenderWindow * > &windows)
void OnAcceptAllInterpolationsClicked()
mitk::DataStorage * GetDataStorage()
Get the Data Storage object.
void FinishInterpolation(mitk::SliceNavigationController *slicer=nullptr)
void On3DInterpolationActivated(bool)
void On3DInterpolationEnabled(bool)
void OnInterpolationActivated(bool)
virtual void setEnabled(bool)
std::map< QAction *, mitk::SliceNavigationController * > ActionToSliceDimensionMapType
void OnSurfaceInterpolationFinished()
Function triggers when the surface interpolation thread completes running. It is responsible for retr...
void OnInterpolationAborted(const itk::EventObject &)
void OnAcceptAllPopupActivated(QAction *action)
void SetActiveLabelValue(mitk::MultiLabelSegmentation::LabelValueType labelValue)
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)
void OnTimeChanged(itk::Object *sender, const itk::EventObject &)
Reacts to the time changed event.
void Enable3DInterpolation(bool)
void On2DInterpolationEnabled(bool)
void OnInterpolationInfoChanged(const itk::EventObject &)
void StartUpdateInterpolationTimer()
void OnToolManagerReferenceDataModified()
void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &)
bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e, mitk::SliceNavigationController *sliceNavigationController)
void AcceptAllInterpolations(mitk::SliceNavigationController *slicer)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
Data management class that handles 'was created by' relations.
unsigned short PixelType
Definition: mitkLabel.h:94
MultiLabelSegmentation class for handling labels and layers in a segmentation session.
mitk::Label::PixelType LabelValueType
Describes a two-dimensional, rectangular plane.
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