Medical Imaging Interaction Toolkit  2023.12.99-63768887
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 
25 
26 #include <QWidget>
27 #include <map>
28 
29 #include <QCheckBox>
30 #include <QComboBox>
31 #include <QFrame>
32 #include <QGroupBox>
33 #include <QRadioButton>
34 
36 #include "vtkProperty.h"
37 
38 // For running 3D interpolation in background
39 #include <QFuture>
40 #include <QFutureWatcher>
41 #include <QTimer>
42 #include <QtConcurrentRun>
43 
44 namespace mitk
45 {
46  class PlaneGeometry;
47  class SliceNavigationController;
48  class TimeNavigationController;
49 }
50 
51 class QPushButton;
52 class QmitkRenderWindow;
53 
70 {
71  Q_OBJECT
72 
73 public:
74  QmitkSlicesInterpolator(QWidget *parent = nullptr, const char *name = nullptr);
75 
79  void Initialize(mitk::ToolManager *toolManager, const QList<QmitkRenderWindow*>& windows);
80 
85  void Uninitialize();
86 
87  ~QmitkSlicesInterpolator() override;
88 
94  void SetDataStorage(mitk::DataStorage::Pointer storage);
95 
101  mitk::DataStorage *GetDataStorage();
102 
103  void SetActiveLabelValue(mitk::LabelSetImage::LabelValueType labelValue);
104 
108  void OnToolManagerWorkingDataModified();
109 
113  void OnToolManagerReferenceDataModified();
114 
120  void OnTimeChanged(itk::Object *sender, const itk::EventObject &);
121 
127  void OnSliceChanged(itk::Object *sender, const itk::EventObject &);
128 
129 
130  void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &);
131 
135  void OnInterpolationInfoChanged(const itk::EventObject &);
136 
140  void OnInterpolationAborted(const itk::EventObject &);
141 
145  void OnSurfaceInterpolationInfoChanged(const itk::EventObject &);
146 
147 
148 private:
152  void Show3DInterpolationResult(bool);
153 
158  void OnActiveLabelChanged(mitk::Label::PixelType);
159 
160 signals:
161 
162  void SignalRememberContourPositions(bool);
163  void SignalShowMarkerNodes(bool);
164 
165 public slots:
166 
167  virtual void setEnabled(bool);
171  void EnableInterpolation(bool);
172 
173  void Enable3DInterpolation(bool);
174 
178  void FinishInterpolation(mitk::SliceNavigationController *slicer = nullptr);
179 
180 protected slots:
181 
185  void OnAcceptInterpolationClicked();
186 
187  /*
188  Opens popup to ask about which orientation should be interpolated
189  */
190  void OnAcceptAllInterpolationsClicked();
191 
192  /*
193  Reaction to button clicks
194  */
195  void OnAccept3DInterpolationClicked();
196 
202  void OnReinit3DInterpolation();
203 
204  /*
205  * Will trigger interpolation for all slices in given orientation (called from popup menu of
206  * OnAcceptAllInterpolationsClicked)
207  */
208  void OnAcceptAllPopupActivated(QAction *action);
209 
213  void OnInterpolationActivated(bool);
214 
215  void On3DInterpolationActivated(bool);
216 
217  void OnInterpolationMethodChanged(int index);
218 
219  // Enhancement for 3D interpolation
220  void On2DInterpolationEnabled(bool);
221  void On3DInterpolationEnabled(bool);
222  void OnInterpolationDisabled(bool);
223  void OnShowMarkers(bool);
224 
225  void Run3DInterpolation();
226 
233  void OnSurfaceInterpolationFinished();
234 
235  void StartUpdateInterpolationTimer();
236 
237  void StopUpdateInterpolationTimer();
238 
239  void ChangeSurfaceColor();
240 
241 protected:
242 
243  typedef std::map<QAction*, mitk::SliceNavigationController*> ActionToSliceDimensionMapType;
244  const ActionToSliceDimensionMapType CreateActionToSlicer(const QList<QmitkRenderWindow*>& windows);
246 
247  void AcceptAllInterpolations(mitk::SliceNavigationController *slicer);
248 
257  bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e,
258  mitk::SliceNavigationController *sliceNavigationController);
259 
260  bool TranslateAndInterpolateChangedSlice(const mitk::TimeGeometry* timeGeometry);
266  void Interpolate(mitk::PlaneGeometry *plane);
267 
272  void UpdateVisibleSuggestion();
273 
274  void SetCurrentContourListID();
275 
276 private:
277  void InitializeWindow(QmitkRenderWindow* window);
278  void HideAllInterpolationControls();
279  void Show2DInterpolationControls(bool show);
280  void Show3DInterpolationControls(bool show);
281  void CheckSupportedImageDimension();
282  void WaitForFutures();
283  void NodeRemoved(const mitk::DataNode* node);
284 
285  mitk::SegmentationInterpolationController::Pointer m_Interpolator;
286  mitk::SurfaceInterpolationController::Pointer m_SurfaceInterpolator;
287 
290 
291  mitk::ToolManager::Pointer m_ToolManager;
292  bool m_Initialized;
293 
294  unsigned int m_ControllerToTimeObserverTag;
295  QHash<mitk::SliceNavigationController *, int> m_ControllerToSliceObserverTag;
296  QHash<mitk::SliceNavigationController *, int> m_ControllerToDeleteObserverTag;
297 
298  unsigned int InterpolationInfoChangedObserverTag;
299  unsigned int SurfaceInterpolationInfoChangedObserverTag;
300  unsigned int InterpolationAbortedObserverTag;
301 
302  QGroupBox *m_GroupBoxEnableExclusiveInterpolationMode;
303  QComboBox *m_CmbInterpolation;
304  QPushButton *m_BtnApply2D;
305  QPushButton *m_BtnApplyForAllSlices2D;
306  QPushButton *m_BtnApply3D;
307 
308  QCheckBox *m_ChkShowPositionNodes;
309  QPushButton *m_BtnReinit3DInterpolation;
310 
311  mitk::DataNode::Pointer m_FeedbackNode;
312  mitk::DataNode::Pointer m_InterpolatedSurfaceNode;
313 
314  mitk::Image *m_Segmentation;
315 
317  unsigned int m_LastSliceIndex;
318 
319  mitk::TimePointType m_TimePoint;
320 
321  bool m_2DInterpolationEnabled;
322  bool m_3DInterpolationEnabled;
323 
324  unsigned int m_numTimesLabelSetConnectionAdded;
325 
326  mitk::DataStorage::Pointer m_DataStorage;
327 
328  QFuture<void> m_Future;
329  QFutureWatcher<void> m_Watcher;
330 
331  QFuture<void> m_ModifyFuture;
332  QFutureWatcher<void> m_ModifyWatcher;
333 
334  QTimer *m_Timer;
335 
336  QFuture<void> m_PlaneFuture;
337  QFutureWatcher<void> m_PlaneWatcher;
338 
339  mitk::Label::PixelType m_CurrentActiveLabelValue;
340 
341  bool m_FirstRun;
342 };
343 
344 #endif
MITKSEGMENTATIONUI_EXPORT
#define MITKSEGMENTATIONUI_EXPORT
Definition: MitkSegmentationUIExports.h:15
mitk::TimeGeometry
Definition: mitkTimeGeometry.h:43
mitkVtkRepresentationProperty.h
mitkSurfaceInterpolationController.h
mitkPointCloudScoringFilter.h
mitk::PlaneGeometry
Describes a two-dimensional, rectangular plane.
Definition: mitkPlaneGeometry.h:78
mitkDataStorage.h
mitkFeatureBasedEdgeDetectionFilter.h
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
QmitkSlicesInterpolator::ActionToSliceDimensionMapType
std::map< QAction *, mitk::SliceNavigationController * > ActionToSliceDimensionMapType
Definition: QmitkSlicesInterpolator.h:243
itk::SmartPointer< Self >
QmitkRenderWindow
MITK implementation of the QVTKWidget.
Definition: QmitkRenderWindow.h:38
QmitkSlicesInterpolator
GUI for slices interpolation.
Definition: QmitkSlicesInterpolator.h:69
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:80
mitkSegmentationInterpolationController.h
mitk::DataStorage
Data management class that handles 'was created by' relations.
Definition: mitkDataStorage.h:43
mitkDataNode.h
MitkSegmentationUIExports.h
mitk::BaseDataSource::Pointer
itk::SmartPointer< Self > Pointer
Definition: mitkBaseDataSource.h:74
QmitkSlicesInterpolator::m_ActionToSlicerMap
ActionToSliceDimensionMapType m_ActionToSlicerMap
Definition: QmitkSlicesInterpolator.h:245
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