Medical Imaging Interaction Toolkit  2021.10.99-1c4db16f
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_Included
14 #define QmitkSlicesInterpolator_h_Included
15 
16 #include "mitkDataNode.h"
17 #include "mitkDataStorage.h"
21 #include "mitkToolManager.h"
23 
26 
27 #include <QWidget>
28 #include <map>
29 
30 #include <QCheckBox>
31 #include <QComboBox>
32 #include <QFrame>
33 #include <QGroupBox>
34 #include <QRadioButton>
35 
37 #include "vtkProperty.h"
38 
39 // For running 3D interpolation in background
40 #include <QFuture>
41 #include <QFutureWatcher>
42 #include <QTimer>
43 #include <QtConcurrentRun>
44 
45 namespace mitk
46 {
47  class PlaneGeometry;
48  class SliceNavigationController;
49 }
50 
51 class QPushButton;
52 
73 {
74  Q_OBJECT
75 
76 public:
77  QmitkSlicesInterpolator(QWidget *parent = nullptr, const char *name = nullptr);
78 
82  void Initialize(mitk::ToolManager *toolManager, const QList<mitk::SliceNavigationController *> &controllers);
83 
84  void Uninitialize();
85 
86  ~QmitkSlicesInterpolator() override;
87 
88  void SetDataStorage(mitk::DataStorage::Pointer storage);
89  mitk::DataStorage *GetDataStorage();
90 
94  void OnToolManagerWorkingDataModified();
95 
99  void OnToolManagerReferenceDataModified();
100 
101  void OnTimeChanged(itk::Object *sender, const itk::EventObject &);
102 
103  void OnSliceChanged(itk::Object *sender, const itk::EventObject &);
104 
105  void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &);
106 
110  void OnInterpolationInfoChanged(const itk::EventObject &);
111 
115  void OnInterpolationAborted(const itk::EventObject &);
116 
120  void OnSurfaceInterpolationInfoChanged(const itk::EventObject &);
121 
125  void Show3DInterpolationResult(bool);
126 
127 signals:
128 
129  void SignalRememberContourPositions(bool);
130  void SignalShowMarkerNodes(bool);
131 
132 public slots:
133 
134  virtual void setEnabled(bool);
138  void EnableInterpolation(bool);
139 
140  void Enable3DInterpolation(bool);
141 
145  void FinishInterpolation(mitk::SliceNavigationController *slicer = nullptr);
146 
147 protected slots:
148 
152  void OnAcceptInterpolationClicked();
153 
154  /*
155  Opens popup to ask about which orientation should be interpolated
156  */
157  void OnAcceptAllInterpolationsClicked();
158 
159  /*
160  Reaction to button clicks
161  */
162  void OnAccept3DInterpolationClicked();
163 
164  void OnReinit3DInterpolation();
165 
166  void OnSuggestPlaneClicked();
167 
168  /*
169  * Will trigger interpolation for all slices in given orientation (called from popup menu of
170  * OnAcceptAllInterpolationsClicked)
171  */
172  void OnAcceptAllPopupActivated(QAction *action);
173 
177  void OnInterpolationActivated(bool);
178 
179  void On3DInterpolationActivated(bool);
180 
181  void OnInterpolationMethodChanged(int index);
182 
183  // Enhancement for 3D interpolation
184  void On2DInterpolationEnabled(bool);
185  void On3DInterpolationEnabled(bool);
186  void OnInterpolationDisabled(bool);
187  void OnShowMarkers(bool);
188 
189  void Run3DInterpolation();
190 
191  void RunPlaneSuggestion();
192 
193  void OnSurfaceInterpolationFinished();
194 
195  void StartUpdateInterpolationTimer();
196 
197  void StopUpdateInterpolationTimer();
198 
199  void ChangeSurfaceColor();
200 
201 protected:
202  const std::map<QAction *, mitk::SliceNavigationController *> createActionToSliceDimension();
203  std::map<QAction *, mitk::SliceNavigationController *> ACTION_TO_SLICEDIMENSION;
204 
205  void AcceptAllInterpolations(mitk::SliceNavigationController *slicer);
206 
215  bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e, mitk::SliceNavigationController *slicer);
216 
222  void Interpolate(mitk::PlaneGeometry *plane, mitk::TimePointType timePoint, mitk::SliceNavigationController *slicer);
223 
224  // void InterpolateSurface();
225 
230  void UpdateVisibleSuggestion();
231 
232  void SetCurrentContourListID();
233 
234 private:
235  void HideAllInterpolationControls();
236  void Show2DInterpolationControls(bool show);
237  void Show3DInterpolationControls(bool show);
238  void CheckSupportedImageDimension();
239  void WaitForFutures();
240  void NodeRemoved(const mitk::DataNode* node);
241 
242  mitk::SegmentationInterpolationController::Pointer m_Interpolator;
243  mitk::SurfaceInterpolationController::Pointer m_SurfaceInterpolator;
244 
247 
248  mitk::ToolManager::Pointer m_ToolManager;
249  bool m_Initialized;
250 
251  QHash<mitk::SliceNavigationController *, int> m_ControllerToTimeObserverTag;
252  QHash<mitk::SliceNavigationController *, int> m_ControllerToSliceObserverTag;
253  QHash<mitk::SliceNavigationController *, int> m_ControllerToDeleteObserverTag;
254 
255  unsigned int InterpolationInfoChangedObserverTag;
256  unsigned int SurfaceInterpolationInfoChangedObserverTag;
257  unsigned int InterpolationAbortedObserverTag;
258 
259  QGroupBox *m_GroupBoxEnableExclusiveInterpolationMode;
260  QComboBox *m_CmbInterpolation;
261  QPushButton *m_BtnApply2D;
262  QPushButton *m_BtnApplyForAllSlices2D;
263  QPushButton *m_BtnApply3D;
264 
265  // T28261
266  // QPushButton *m_BtnSuggestPlane;
267 
268  QCheckBox *m_ChkShowPositionNodes;
269  QPushButton *m_BtnReinit3DInterpolation;
270 
271  mitk::DataNode::Pointer m_FeedbackNode;
272  mitk::DataNode::Pointer m_InterpolatedSurfaceNode;
273  mitk::DataNode::Pointer m_3DContourNode;
274 
275  mitk::Image *m_Segmentation;
276 
278  unsigned int m_LastSliceIndex;
279 
280  QHash<mitk::SliceNavigationController *, mitk::TimePointType> m_TimePoints;
281 
282  bool m_2DInterpolationEnabled;
283  bool m_3DInterpolationEnabled;
284  // unsigned int m_CurrentListID;
285 
286  mitk::DataStorage::Pointer m_DataStorage;
287 
288  QFuture<void> m_Future;
289  QFutureWatcher<void> m_Watcher;
290  QTimer *m_Timer;
291 
292  QFuture<void> m_PlaneFuture;
293  QFutureWatcher<void> m_PlaneWatcher;
294 
295  bool m_FirstRun;
296 };
297 
298 #endif
GUI for slices interpolation.
Data management class that handles &#39;was created by&#39; relations.
itk::SmartPointer< Self > Pointer
DataCollection - Class to facilitate loading/accessing structured data.
Controls the selection of the slice the associated BaseRenderer will display.
Image class for storing images.
Definition: mitkImage.h:69
std::map< QAction *, mitk::SliceNavigationController * > ACTION_TO_SLICEDIMENSION
mitk::ScalarType TimePointType
Describes a two-dimensional, rectangular plane.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57
#define MITKSEGMENTATIONUI_EXPORT
Manages and coordinates instances of mitk::Tool.