Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef QmitkSlicesInterpolator_h_Included
18 #define QmitkSlicesInterpolator_h_Included
19 
20 #include "mitkDataNode.h"
21 #include "mitkDataStorage.h"
25 #include "mitkToolManager.h"
26 #include "mitkWeakPointer.h"
28 
31 
32 #include <QWidget>
33 #include <map>
34 
35 #include <QCheckBox>
36 #include <QComboBox>
37 #include <QFrame>
38 #include <QGroupBox>
39 #include <QRadioButton>
40 
42 #include "vtkProperty.h"
43 
44 // For running 3D interpolation in background
45 #include <QFuture>
46 #include <QFutureWatcher>
47 #include <QTimer>
48 #include <QtConcurrentRun>
49 
50 namespace mitk
51 {
52  class PlaneGeometry;
53  class SliceNavigationController;
54 }
55 
56 class QPushButton;
57 
81 {
82  Q_OBJECT
83 
84 public:
85  QmitkSlicesInterpolator(QWidget *parent = 0, const char *name = 0);
86 
90  void Initialize(mitk::ToolManager *toolManager, const QList<mitk::SliceNavigationController *> &controllers);
91 
92  void Uninitialize();
93 
94  virtual ~QmitkSlicesInterpolator();
95 
96  void SetDataStorage(mitk::DataStorage::Pointer storage);
98 
102  void OnToolManagerWorkingDataModified();
103 
107  void OnToolManagerReferenceDataModified();
108 
109  void OnTimeChanged(itk::Object *sender, const itk::EventObject &);
110 
111  void OnSliceChanged(itk::Object *sender, const itk::EventObject &);
112 
113  void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &);
114 
118  void OnInterpolationInfoChanged(const itk::EventObject &);
119 
123  void OnSurfaceInterpolationInfoChanged(const itk::EventObject &);
124 
128  void Show3DInterpolationResult(bool);
129 
130 signals:
131 
132  void SignalRememberContourPositions(bool);
133  void SignalShowMarkerNodes(bool);
134 
135 public slots:
136 
137  virtual void setEnabled(bool);
141  void EnableInterpolation(bool);
142 
143  void Enable3DInterpolation(bool);
144 
148  void FinishInterpolation(mitk::SliceNavigationController *slicer = NULL);
149 
150 protected slots:
151 
155  void OnAcceptInterpolationClicked();
156 
157  /*
158  Opens popup to ask about which orientation should be interpolated
159  */
160  void OnAcceptAllInterpolationsClicked();
161 
162  /*
163  Reaction to button clicks
164  */
165  void OnAccept3DInterpolationClicked();
166 
167  void OnReinit3DInterpolation();
168 
169  void OnSuggestPlaneClicked();
170 
171  /*
172  * Will trigger interpolation for all slices in given orientation (called from popup menu of
173  * OnAcceptAllInterpolationsClicked)
174  */
175  void OnAcceptAllPopupActivated(QAction *action);
176 
180  void OnInterpolationActivated(bool);
181 
182  void On3DInterpolationActivated(bool);
183 
184  void OnInterpolationMethodChanged(int index);
185 
186  // Enhancement for 3D interpolation
187  void On2DInterpolationEnabled(bool);
188  void On3DInterpolationEnabled(bool);
189  void OnInterpolationDisabled(bool);
190  void OnShowMarkers(bool);
191 
192  void Run3DInterpolation();
193 
194  void RunPlaneSuggestion();
195 
196  void OnSurfaceInterpolationFinished();
197 
198  void StartUpdateInterpolationTimer();
199 
200  void StopUpdateInterpolationTimer();
201 
202  void ChangeSurfaceColor();
203 
204 protected:
205  const std::map<QAction *, mitk::SliceNavigationController *> createActionToSliceDimension();
206  std::map<QAction *, mitk::SliceNavigationController *> ACTION_TO_SLICEDIMENSION;
207 
208  void AcceptAllInterpolations(mitk::SliceNavigationController *slicer);
209 
218  bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e, mitk::SliceNavigationController *slicer);
219 
225  void Interpolate(mitk::PlaneGeometry *plane, unsigned int timeStep, mitk::SliceNavigationController *slicer);
226 
227  // void InterpolateSurface();
228 
233  void UpdateVisibleSuggestion();
234 
235  void SetCurrentContourListID();
236 
237 private:
238  void HideAllInterpolationControls();
239  void Show2DInterpolationControls(bool show);
240  void Show3DInterpolationControls(bool show);
241  void CheckSupportedImageDimension();
242  void WaitForFutures();
243  void NodeRemoved(const mitk::DataNode* node);
244 
246  mitk::SurfaceInterpolationController::Pointer m_SurfaceInterpolator;
247 
250 
251  mitk::ToolManager::Pointer m_ToolManager;
252  bool m_Initialized;
253 
254  QHash<mitk::SliceNavigationController *, int> m_ControllerToTimeObserverTag;
255  QHash<mitk::SliceNavigationController *, int> m_ControllerToSliceObserverTag;
256  QHash<mitk::SliceNavigationController *, int> m_ControllerToDeleteObserverTag;
257 
258  unsigned int InterpolationInfoChangedObserverTag;
259  unsigned int SurfaceInterpolationInfoChangedObserverTag;
260 
261  QGroupBox *m_GroupBoxEnableExclusiveInterpolationMode;
262  QComboBox *m_CmbInterpolation;
263  QPushButton *m_BtnApply2D;
264  QPushButton *m_BtnApplyForAllSlices2D;
265  QPushButton *m_BtnApply3D;
266 
267  QPushButton *m_BtnSuggestPlane;
268 
269  QCheckBox *m_ChkShowPositionNodes;
270  QPushButton *m_BtnReinit3DInterpolation;
271 
272  mitk::DataNode::Pointer m_FeedbackNode;
273  mitk::DataNode::Pointer m_InterpolatedSurfaceNode;
274  mitk::DataNode::Pointer m_3DContourNode;
275 
276  mitk::Image *m_Segmentation;
277 
279  unsigned int m_LastSliceIndex;
280 
281  QHash<mitk::SliceNavigationController *, unsigned int> m_TimeStep;
282 
283  bool m_2DInterpolationEnabled;
284  bool m_3DInterpolationEnabled;
285  // unsigned int m_CurrentListID;
286 
288 
289  QFuture<void> m_Future;
290  QFutureWatcher<void> m_Watcher;
291  QTimer *m_Timer;
292 
293  QFuture<void> m_PlaneFuture;
294  QFutureWatcher<void> m_PlaneWatcher;
295 
296  bool m_FirstRun;
297 };
298 
299 #endif
GUI for slices interpolation.
Data management class that handles 'was created by' relations.
itk::SmartPointer< Self > Pointer
DataCollection - Class to facilitate loading/accessing structured data.
static mitk::DataStorage::Pointer GetDataStorage()
Controls the selection of the slice the associated BaseRenderer will display.
mitk::DataStorage::Pointer m_DataStorage
Image class for storing images.
Definition: mitkImage.h:76
std::map< QAction *, mitk::SliceNavigationController * > ACTION_TO_SLICEDIMENSION
Describes a two-dimensional, rectangular plane.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
#define MITKSEGMENTATIONUI_EXPORT
Manages and coordinates instances of mitk::Tool.