Medical Imaging Interaction Toolkit  2023.04.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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"
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 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  const std::map<QAction *, mitk::SliceNavigationController *> createActionToSlicer(const QList<QmitkRenderWindow*>& windows);
317  std::map<QAction *, mitk::SliceNavigationController *> m_ActionToSlicer;
318 
319  void AcceptAllInterpolations(mitk::SliceNavigationController *slicer);
320 
329  bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e, mitk::SliceNavigationController *slicer);
330 
336  void Interpolate(mitk::PlaneGeometry *plane, mitk::TimePointType timePoint, mitk::SliceNavigationController *slicer);
337 
338  // void InterpolateSurface();
339 
344  void UpdateVisibleSuggestion();
345 
346  void SetCurrentContourListID();
347 
348 private:
349  void InitializeWindow(QmitkRenderWindow* window);
350  void HideAllInterpolationControls();
351  void Show2DInterpolationControls(bool show);
352  void Show3DInterpolationControls(bool show);
353  void CheckSupportedImageDimension();
354  void WaitForFutures();
355  void NodeRemoved(const mitk::DataNode* node);
356  void ClearSegmentationObservers();
357 
358  mitk::SegmentationInterpolationController::Pointer m_Interpolator;
359  mitk::SurfaceInterpolationController::Pointer m_SurfaceInterpolator;
360 
363 
364  mitk::ToolManager::Pointer m_ToolManager;
365  bool m_Initialized;
366 
367  QHash<mitk::SliceNavigationController *, int> m_ControllerToTimeObserverTag;
368  QHash<mitk::SliceNavigationController *, int> m_ControllerToSliceObserverTag;
369  QHash<mitk::SliceNavigationController *, int> m_ControllerToDeleteObserverTag;
370 
371  std::map<mitk::LabelSetImage *, unsigned long> m_SegmentationObserverTags;
372 
373  unsigned int InterpolationInfoChangedObserverTag;
374  unsigned int SurfaceInterpolationInfoChangedObserverTag;
375  unsigned int InterpolationAbortedObserverTag;
376 
377  QGroupBox *m_GroupBoxEnableExclusiveInterpolationMode;
378  QComboBox *m_CmbInterpolation;
379  QPushButton *m_BtnApply2D;
380  QPushButton *m_BtnApplyForAllSlices2D;
381  QPushButton *m_BtnApply3D;
382 
383  // T28261
384  // QPushButton *m_BtnSuggestPlane;
385 
386  QCheckBox *m_ChkShowPositionNodes;
387  QPushButton *m_BtnReinit3DInterpolation;
388 
389  mitk::DataNode::Pointer m_FeedbackNode;
390  mitk::DataNode::Pointer m_InterpolatedSurfaceNode;
391  mitk::DataNode::Pointer m_3DContourNode;
392 
393  mitk::Image *m_Segmentation;
394 
396  unsigned int m_LastSliceIndex;
397 
398  QHash<mitk::SliceNavigationController *, mitk::TimePointType> m_TimePoints;
399 
400  bool m_2DInterpolationEnabled;
401  bool m_3DInterpolationEnabled;
402 
403  unsigned int m_numTimesLabelSetConnectionAdded;
404 
405  mitk::DataStorage::Pointer m_DataStorage;
406 
407  QFuture<void> m_Future;
408  QFutureWatcher<void> m_Watcher;
409 
410  QFuture<void> m_ModifyFuture;
411  QFutureWatcher<void> m_ModifyWatcher;
412 
413  QTimer *m_Timer;
414 
415  QFuture<void> m_PlaneFuture;
416  QFutureWatcher<void> m_PlaneWatcher;
417 
418  mitk::Label::PixelType m_PreviousActiveLabelValue;
419  mitk::Label::PixelType m_CurrentActiveLabelValue;
420 
421  unsigned int m_PreviousLayerIndex;
422  unsigned int m_CurrentLayerIndex;
423  bool m_FirstRun;
424 };
425 
426 #endif
MITKSEGMENTATIONUI_EXPORT
#define MITKSEGMENTATIONUI_EXPORT
Definition: MitkSegmentationUIExports.h:15
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
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:33
mitk::SliceNavigationController
Controls the selection of the slice the associated BaseRenderer will display.
Definition: mitkSliceNavigationController.h:132
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition: RenderingTests.dox:1
mitk::ToolManager
Manages and coordinates instances of mitk::Tool.
Definition: mitkToolManager.h:80
QmitkSlicesInterpolator::m_ActionToSlicer
std::map< QAction *, mitk::SliceNavigationController * > m_ActionToSlicer
Definition: QmitkSlicesInterpolator.h:317
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
mitkSliceNavigationController.h
MitkSegmentationUIExports.h
mitk::BaseDataSource::Pointer
itk::SmartPointer< Self > Pointer
Definition: mitkBaseDataSource.h:74
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