Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 OnSurfaceInterpolationInfoChanged(const itk::EventObject &);
116 
120  void Show3DInterpolationResult(bool);
121 
122 signals:
123 
124  void SignalRememberContourPositions(bool);
125  void SignalShowMarkerNodes(bool);
126 
127 public slots:
128 
129  virtual void setEnabled(bool);
133  void EnableInterpolation(bool);
134 
135  void Enable3DInterpolation(bool);
136 
140  void FinishInterpolation(mitk::SliceNavigationController *slicer = nullptr);
141 
142 protected slots:
143 
147  void OnAcceptInterpolationClicked();
148 
149  /*
150  Opens popup to ask about which orientation should be interpolated
151  */
152  void OnAcceptAllInterpolationsClicked();
153 
154  /*
155  Reaction to button clicks
156  */
157  void OnAccept3DInterpolationClicked();
158 
159  void OnReinit3DInterpolation();
160 
161  void OnSuggestPlaneClicked();
162 
163  /*
164  * Will trigger interpolation for all slices in given orientation (called from popup menu of
165  * OnAcceptAllInterpolationsClicked)
166  */
167  void OnAcceptAllPopupActivated(QAction *action);
168 
172  void OnInterpolationActivated(bool);
173 
174  void On3DInterpolationActivated(bool);
175 
176  void OnInterpolationMethodChanged(int index);
177 
178  // Enhancement for 3D interpolation
179  void On2DInterpolationEnabled(bool);
180  void On3DInterpolationEnabled(bool);
181  void OnInterpolationDisabled(bool);
182  void OnShowMarkers(bool);
183 
184  void Run3DInterpolation();
185 
186  void RunPlaneSuggestion();
187 
188  void OnSurfaceInterpolationFinished();
189 
190  void StartUpdateInterpolationTimer();
191 
192  void StopUpdateInterpolationTimer();
193 
194  void ChangeSurfaceColor();
195 
196 protected:
197  const std::map<QAction *, mitk::SliceNavigationController *> createActionToSliceDimension();
198  std::map<QAction *, mitk::SliceNavigationController *> ACTION_TO_SLICEDIMENSION;
199 
200  void AcceptAllInterpolations(mitk::SliceNavigationController *slicer);
201 
210  bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e, mitk::SliceNavigationController *slicer);
211 
217  void Interpolate(mitk::PlaneGeometry *plane, unsigned int timeStep, mitk::SliceNavigationController *slicer);
218 
219  // void InterpolateSurface();
220 
225  void UpdateVisibleSuggestion();
226 
227  void SetCurrentContourListID();
228 
229 private:
230  void HideAllInterpolationControls();
231  void Show2DInterpolationControls(bool show);
232  void Show3DInterpolationControls(bool show);
233  void CheckSupportedImageDimension();
234  void WaitForFutures();
235  void NodeRemoved(const mitk::DataNode* node);
236 
237  mitk::SegmentationInterpolationController::Pointer m_Interpolator;
238  mitk::SurfaceInterpolationController::Pointer m_SurfaceInterpolator;
239 
242 
243  mitk::ToolManager::Pointer m_ToolManager;
244  bool m_Initialized;
245 
246  QHash<mitk::SliceNavigationController *, int> m_ControllerToTimeObserverTag;
247  QHash<mitk::SliceNavigationController *, int> m_ControllerToSliceObserverTag;
248  QHash<mitk::SliceNavigationController *, int> m_ControllerToDeleteObserverTag;
249 
250  unsigned int InterpolationInfoChangedObserverTag;
251  unsigned int SurfaceInterpolationInfoChangedObserverTag;
252 
253  QGroupBox *m_GroupBoxEnableExclusiveInterpolationMode;
254  QComboBox *m_CmbInterpolation;
255  QPushButton *m_BtnApply2D;
256  QPushButton *m_BtnApplyForAllSlices2D;
257  QPushButton *m_BtnApply3D;
258 
259  QPushButton *m_BtnSuggestPlane;
260 
261  QCheckBox *m_ChkShowPositionNodes;
262  QPushButton *m_BtnReinit3DInterpolation;
263 
264  mitk::DataNode::Pointer m_FeedbackNode;
265  mitk::DataNode::Pointer m_InterpolatedSurfaceNode;
266  mitk::DataNode::Pointer m_3DContourNode;
267 
268  mitk::Image *m_Segmentation;
269 
271  unsigned int m_LastSliceIndex;
272 
273  QHash<mitk::SliceNavigationController *, unsigned int> m_TimeStep;
274 
275  bool m_2DInterpolationEnabled;
276  bool m_3DInterpolationEnabled;
277  // unsigned int m_CurrentListID;
278 
280 
281  QFuture<void> m_Future;
282  QFutureWatcher<void> m_Watcher;
283  QTimer *m_Timer;
284 
285  QFuture<void> m_PlaneFuture;
286  QFutureWatcher<void> m_PlaneWatcher;
287 
288  bool m_FirstRun;
289 };
290 
291 #endif
GUI for slices interpolation.
Data management class that handles &#39;was created by&#39; relations.
DataCollection - Class to facilitate loading/accessing structured data.
Controls the selection of the slice the associated BaseRenderer will display.
mitk::DataStorage::Pointer m_DataStorage
Image class for storing images.
Definition: mitkImage.h:72
std::map< QAction *, mitk::SliceNavigationController * > ACTION_TO_SLICEDIMENSION
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.