Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
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 
84  ~QmitkSlicesInterpolator() override;
85 
91  void SetDataStorage(mitk::DataStorage::Pointer storage);
92 
98  mitk::DataStorage *GetDataStorage();
99 
100  void SetActiveLabelValue(mitk::LabelSetImage::LabelValueType labelValue);
101 
105  void OnToolManagerWorkingDataModified();
106 
110  void OnToolManagerReferenceDataModified();
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 
159  void SignalRememberContourPositions(bool);
160  void SignalShowMarkerNodes(bool);
161 
162 public slots:
163 
164  virtual void setEnabled(bool);
168  void EnableInterpolation(bool);
169 
170  void Enable3DInterpolation(bool);
171 
175  void FinishInterpolation(mitk::SliceNavigationController *slicer = nullptr);
176 
177 protected slots:
178 
182  void OnAcceptInterpolationClicked();
183 
184  /*
185  Opens popup to ask about which orientation should be interpolated
186  */
187  void OnAcceptAllInterpolationsClicked();
188 
189  /*
190  Reaction to button clicks
191  */
192  void OnAccept3DInterpolationClicked();
193 
199  void OnReinit3DInterpolation();
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 
210  void OnInterpolationActivated(bool);
211 
212  void On3DInterpolationActivated(bool);
213 
214  void OnInterpolationMethodChanged(int index);
215 
216  // Enhancement for 3D interpolation
217  void On2DInterpolationEnabled(bool);
218  void On3DInterpolationEnabled(bool);
219  void OnInterpolationDisabled(bool);
220  void OnShowMarkers(bool);
221 
222  void Run3DInterpolation();
223 
230  void OnSurfaceInterpolationFinished();
231 
232  void StartUpdateInterpolationTimer();
233 
234  void StopUpdateInterpolationTimer();
235 
236  void ChangeSurfaceColor();
237 
238 protected:
239 
240  typedef std::map<QAction*, mitk::SliceNavigationController*> ActionToSliceDimensionMapType;
241  const ActionToSliceDimensionMapType CreateActionToSlicer(const QList<QmitkRenderWindow*>& windows);
243 
244  void AcceptAllInterpolations(mitk::SliceNavigationController *slicer);
245 
254  bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e,
255  mitk::SliceNavigationController *sliceNavigationController);
256 
257  bool TranslateAndInterpolateChangedSlice(const mitk::TimeGeometry* timeGeometry);
263  void Interpolate(mitk::PlaneGeometry *plane);
264 
269  void UpdateVisibleSuggestion();
270 
271  void SetCurrentContourListID();
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::Image *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
MITKSEGMENTATIONUI_EXPORT
#define MITKSEGMENTATIONUI_EXPORT
Definition: MitkSegmentationUIExports.h:15
mitk::TimeGeometry
Definition: mitkTimeGeometry.h:45
mitkVtkRepresentationProperty.h
mitkSurfaceInterpolationController.h
mitk::PlaneGeometry
Describes a two-dimensional, rectangular plane.
Definition: mitkPlaneGeometry.h:78
mitkDataStorage.h
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
QmitkSlicesInterpolator::ActionToSliceDimensionMapType
std::map< QAction *, mitk::SliceNavigationController * > ActionToSliceDimensionMapType
Definition: QmitkSlicesInterpolator.h:240
itk::SmartPointer< Self >
QmitkRenderWindow
MITK implementation of the QVTKWidget.
Definition: QmitkRenderWindow.h:38
QmitkSlicesInterpolator
GUI for slices interpolation.
Definition: QmitkSlicesInterpolator.h:66
mitk::Label::PixelType
unsigned short PixelType
Definition: mitkLabel.h:34
mitk::SliceNavigationController
Controls the selection of the slice the associated BaseRenderer will display.
Definition: mitkSliceNavigationController.h:130
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::ToolManager
Manages and coordinates instances of mitk::Tool.
Definition: mitkToolManager.h:78
mitkSegmentationInterpolationController.h
mitk::DataStorage
Data management class that handles 'was created by' relations.
Definition: mitkDataStorage.h:43
mitkDataNode.h
MitkSegmentationUIExports.h
QmitkSlicesInterpolator::m_ActionToSlicerMap
ActionToSliceDimensionMapType m_ActionToSlicerMap
Definition: QmitkSlicesInterpolator.h:242
mitk::TimePointType
mitk::ScalarType TimePointType
Definition: mitkTimeGeometry.h:26
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
mitkToolManager.h
mitk::LabelSetImage::LabelValueType
mitk::Label::PixelType LabelValueType
Definition: mitkLabelSetImage.h:75