Medical Imaging Interaction Toolkit  2023.12.00
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 
55 {
59 };
60 
81 {
82  Q_OBJECT
83 
84 public:
85  QmitkSlicesInterpolator(QWidget *parent = nullptr, const char *name = nullptr);
86 
90  void Initialize(mitk::ToolManager *toolManager, const QList<QmitkRenderWindow*>& windows);
91 
96  void Uninitialize();
97 
98  ~QmitkSlicesInterpolator() override;
99 
105  void SetDataStorage(mitk::DataStorage::Pointer storage);
106 
112  mitk::DataStorage *GetDataStorage();
113 
114 
118  void OnToolManagerWorkingDataModified();
119 
123  void OnToolManagerReferenceDataModified();
124 
130  void OnTimeChanged(itk::Object *sender, const itk::EventObject &);
131 
137  void OnSliceChanged(itk::Object *sender, const itk::EventObject &);
138 
139 
140  void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &);
141 
145  void OnInterpolationInfoChanged(const itk::EventObject &);
146 
150  void OnInterpolationAborted(const itk::EventObject &);
151 
155  void OnSurfaceInterpolationInfoChanged(const itk::EventObject &);
156 
157 
158 private:
162  void Show3DInterpolationResult(bool);
163 
168  void OnActiveLabelChanged(mitk::Label::PixelType);
169 
174  void OnLayerChanged();
175 
180  void OnRemoveLabel(mitk::Label::PixelType removedLabelValue);
181 
186  void OnModifyLabelChanged(const itk::Object *caller,
187  const itk::EventObject & /*event*/);
188 
194  void OnAddLabelSetConnection();
195 
202  void OnAddLabelSetConnection(unsigned int layerID);
203 
208  void OnRemoveLabelSetConnection();
209 
216  void MergeContours(unsigned int timeStep, unsigned int layerID);
217 
218 
223  void PrepareInputsFor3DInterpolation();
224 
225 signals:
226 
227  void SignalRememberContourPositions(bool);
228  void SignalShowMarkerNodes(bool);
229 
230 public slots:
231 
232  virtual void setEnabled(bool);
236  void EnableInterpolation(bool);
237 
238  void Enable3DInterpolation(bool);
239 
243  void FinishInterpolation(mitk::SliceNavigationController *slicer = nullptr);
244 
245 protected slots:
246 
250  void OnAcceptInterpolationClicked();
251 
252  /*
253  Opens popup to ask about which orientation should be interpolated
254  */
255  void OnAcceptAllInterpolationsClicked();
256 
257  /*
258  Reaction to button clicks
259  */
260  void OnAccept3DInterpolationClicked();
261 
267  void OnReinit3DInterpolation();
268 
269  /*
270  * Will trigger interpolation for all slices in given orientation (called from popup menu of
271  * OnAcceptAllInterpolationsClicked)
272  */
273  void OnAcceptAllPopupActivated(QAction *action);
274 
278  void OnInterpolationActivated(bool);
279 
280  void On3DInterpolationActivated(bool);
281 
282  void OnInterpolationMethodChanged(int index);
283 
284  // Enhancement for 3D interpolation
285  void On2DInterpolationEnabled(bool);
286  void On3DInterpolationEnabled(bool);
287  void OnInterpolationDisabled(bool);
288  void OnShowMarkers(bool);
289 
290  void Run3DInterpolation();
291 
298  void OnSurfaceInterpolationFinished();
299 
300  void StartUpdateInterpolationTimer();
301 
302  void StopUpdateInterpolationTimer();
303 
304  void ChangeSurfaceColor();
305 
313  void OnRemoveLabelSetConnection(mitk::LabelSetImage* labelSetImage, unsigned int layerID);
314 
315 protected:
316 
317  typedef std::map<QAction*, mitk::SliceNavigationController*> ActionToSliceDimensionMapType;
318  const ActionToSliceDimensionMapType CreateActionToSlicer(const QList<QmitkRenderWindow*>& windows);
320 
321  void AcceptAllInterpolations(mitk::SliceNavigationController *slicer);
322 
331  bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e,
332  mitk::SliceNavigationController *sliceNavigationController);
333 
334  bool TranslateAndInterpolateChangedSlice(const mitk::TimeGeometry* timeGeometry);
340  void Interpolate(mitk::PlaneGeometry *plane);
341 
346  void UpdateVisibleSuggestion();
347 
348  void SetCurrentContourListID();
349 
350 private:
351  void InitializeWindow(QmitkRenderWindow* window);
352  void HideAllInterpolationControls();
353  void Show2DInterpolationControls(bool show);
354  void Show3DInterpolationControls(bool show);
355  void CheckSupportedImageDimension();
356  void WaitForFutures();
357  void NodeRemoved(const mitk::DataNode* node);
358  void ClearSegmentationObservers();
359 
360  mitk::SegmentationInterpolationController::Pointer m_Interpolator;
361  mitk::SurfaceInterpolationController::Pointer m_SurfaceInterpolator;
362 
365 
366  mitk::ToolManager::Pointer m_ToolManager;
367  bool m_Initialized;
368 
369  unsigned int m_ControllerToTimeObserverTag;
370  QHash<mitk::SliceNavigationController *, int> m_ControllerToSliceObserverTag;
371  QHash<mitk::SliceNavigationController *, int> m_ControllerToDeleteObserverTag;
372 
373  std::map<mitk::LabelSetImage *, unsigned long> m_SegmentationObserverTags;
374 
375  unsigned int InterpolationInfoChangedObserverTag;
376  unsigned int SurfaceInterpolationInfoChangedObserverTag;
377  unsigned int InterpolationAbortedObserverTag;
378 
379  QGroupBox *m_GroupBoxEnableExclusiveInterpolationMode;
380  QComboBox *m_CmbInterpolation;
381  QPushButton *m_BtnApply2D;
382  QPushButton *m_BtnApplyForAllSlices2D;
383  QPushButton *m_BtnApply3D;
384 
385  // T28261
386  // QPushButton *m_BtnSuggestPlane;
387 
388  QCheckBox *m_ChkShowPositionNodes;
389  QPushButton *m_BtnReinit3DInterpolation;
390 
391  mitk::DataNode::Pointer m_FeedbackNode;
392  mitk::DataNode::Pointer m_InterpolatedSurfaceNode;
393  mitk::DataNode::Pointer m_3DContourNode;
394 
395  mitk::Image *m_Segmentation;
396 
398  unsigned int m_LastSliceIndex;
399 
400  mitk::TimePointType m_TimePoint;
401 
402  bool m_2DInterpolationEnabled;
403  bool m_3DInterpolationEnabled;
404 
405  unsigned int m_numTimesLabelSetConnectionAdded;
406 
407  mitk::DataStorage::Pointer m_DataStorage;
408 
409  QFuture<void> m_Future;
410  QFutureWatcher<void> m_Watcher;
411 
412  QFuture<void> m_ModifyFuture;
413  QFutureWatcher<void> m_ModifyWatcher;
414 
415  QTimer *m_Timer;
416 
417  QFuture<void> m_PlaneFuture;
418  QFutureWatcher<void> m_PlaneWatcher;
419 
420  mitk::Label::PixelType m_PreviousActiveLabelValue;
421  mitk::Label::PixelType m_CurrentActiveLabelValue;
422 
423  unsigned int m_PreviousLayerIndex;
424  unsigned int m_CurrentLayerIndex;
425  bool m_FirstRun;
426 };
427 
428 #endif
MITKSEGMENTATIONUI_EXPORT
#define MITKSEGMENTATIONUI_EXPORT
Definition: MitkSegmentationUIExports.h:15
mitk::TimeGeometry
Definition: mitkTimeGeometry.h:43
mitkVtkRepresentationProperty.h
Erase
@ Erase
Definition: QmitkSlicesInterpolator.h:57
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:317
itk::SmartPointer< Self >
QmitkRenderWindow
MITK implementation of the QVTKWidget.
Definition: QmitkRenderWindow.h:38
QmitkSlicesInterpolator
GUI for slices interpolation.
Definition: QmitkSlicesInterpolator.h:80
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
Null
@ Null
Definition: QmitkSlicesInterpolator.h:56
mitkSegmentationInterpolationController.h
Merge
@ Merge
Definition: QmitkSlicesInterpolator.h:58
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:319
ModifyLabelActionTrigerred
ModifyLabelActionTrigerred
Definition: QmitkSlicesInterpolator.h:54
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
LabelSetImage class for handling labels and layers in a segmentation session.
Definition: mitkLabelSetImage.h:29