Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
mitkSegTool2D.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 mitkSegTool2D_h
14 #define mitkSegTool2D_h
15 
16 #include <mitkCommon.h>
17 #include <mitkImage.h>
18 #include <mitkTool.h>
20 
22 
23 #include <mitkInteractionConst.h>
26 
27 #include <mitkDiffSliceOperation.h>
28 
29 #include <usModuleResource.h>
30 
31 namespace mitk
32 {
33  class BaseRenderer;
34 
57  {
58  public:
60 
71  static bool DetermineAffectedImageSlice(const Image *image,
72  const PlaneGeometry *plane,
73  int &affectedDimension,
74  int &affectedSlice);
75 
85  static void UpdateAllSurfaceInterpolations(const LabelSetImage* workingImage,
86  TimeStepType timeStep,
87  const PlaneGeometry *plane,
88  bool detectIntersection);
89 
100  static Image::Pointer GetAffectedImageSliceAs2DImage(const InteractionPositionEvent* positionEvent, const Image* image, unsigned int component = 0);
101 
113  static Image::Pointer GetAffectedImageSliceAs2DImage(const PlaneGeometry* planeGeometry,
114  const Image* image,
115  TimeStepType timeStep,
116  unsigned int component = 0);
117  static Image::Pointer GetAffectedImageSliceAs2DImageByTimePoint(const PlaneGeometry* planeGeometry,
118  const Image* image,
119  TimePointType timePoint,
120  unsigned int component = 0);
121 
124  static void WriteBackSegmentationResult(const DataNode* workingNode, const PlaneGeometry* planeGeometry, const Image* segmentationResult, TimeStepType timeStep);
125 
128  static void WriteSliceToVolume(Image* workingImage, const PlaneGeometry* planeGeometry, const Image* slice, TimeStepType timeStep, bool allowUndo);
129 
130  void SetShowMarkerNodes(bool);
131 
136  void SetEnable3DInterpolation(bool);
137 
138  void Activated() override;
139  void Deactivated() override;
140 
141  itkSetMacro(IsTimePointChangeAware, bool);
142  itkGetMacro(IsTimePointChangeAware, bool);
143  itkBooleanMacro(IsTimePointChangeAware);
144 
145  protected:
146  SegTool2D(); // purposely hidden
147  SegTool2D(const char *, const us::Module *interactorModule = nullptr); // purposely hidden
148  ~SegTool2D() override;
149 
153  DataNode* GetWorkingDataNode() const;
154  Image* GetWorkingData() const;
155 
156  DataNode* GetReferenceDataNode() const;
157  Image* GetReferenceData() const;
158 
162  virtual void OnTimePointChanged();
163 
165  {
167  const mitk::PlaneGeometry *plane = nullptr;
168  mitk::TimeStepType timestep = 0;
169  unsigned int slicePosition;
170 
171  SliceInformation() = default;
172  SliceInformation(const mitk::Image* aSlice, const mitk::PlaneGeometry* aPlane, mitk::TimeStepType aTimestep);
173  };
174 
185  static void UpdateSurfaceInterpolation(const std::vector<SliceInformation>& sliceInfos,
186  const Image* workingImage,
187  bool detectIntersection,
188  mitk::Label::PixelType activeLabelValue, bool silent = false);
189 
190 
197  bool FilterEvents(InteractionEvent *interactionEvent, DataNode *dataNode) override;
198 
205  Image::Pointer GetAffectedWorkingSlice(const InteractionPositionEvent *) const;
206 
213  Image::Pointer GetAffectedReferenceSlice(const InteractionPositionEvent *) const;
215  Image::Pointer GetAffectedReferenceSlice(const PlaneGeometry* planeGeometry, TimeStepType timeStep) const;
216 
219  void WriteBackSegmentationResult(const InteractionPositionEvent *, const Image* segmentationResult);
220 
223  void WriteBackSegmentationResult(const PlaneGeometry *planeGeometry, const Image* segmentationResult, TimeStepType timeStep);
224 
227  void WriteBackSegmentationResults(const std::vector<SliceInformation> &sliceList, bool writeSliceToVolume = true);
228 
238  static void WriteBackSegmentationResults(const DataNode* workingNode, const std::vector<SliceInformation>& sliceList, bool writeSliceToVolume = true);
239 
249  static void WriteSliceToVolume(Image* workingImage, const SliceInformation &sliceInfo, bool allowUndo);
250 
256  int AddContourmarker(const PlaneGeometry* planeGeometry, unsigned int sliceIndex);
257 
258  void InteractiveSegmentationBugMessage(const std::string &message) const;
259 
262  static bool IsPositionEventInsideImageRegion(InteractionPositionEvent* positionEvent, const BaseData* data);
263 
264  BaseRenderer *m_LastEventSender = nullptr;
265  unsigned int m_LastEventSlice = 0;
266 
267  itkGetMacro(LastTimePointTriggered, TimePointType);
268 
269  void PushCursor();
270  void PushCursor(us::ModuleResource cursorResource);
271  void PopCursor(bool popFirstCursor = false);
272  void PopAllCursors();
273 
274  private:
278  void OnTimePointChangedInternal();
279 
280  static void RemoveContourFromInterpolator(const SliceInformation& sliceInfo, LabelSetImage::LabelValueType labelValue);
281 
282  // The prefix of the contourmarkername. Suffix is a consecutive number
283  const std::string m_Contourmarkername;
284 
285  bool m_ShowMarkerNodes = false;
286  static bool m_SurfaceInterpolationEnabled;
287 
288  bool m_IsTimePointChangeAware = true;
289 
290  TimePointType m_LastTimePointTriggered = 0.;
291 
292  unsigned int m_NumPushedCursors = 0;
293  };
294 
295 } // namespace
296 
297 #endif
mitkTool.h
mitkInteractionConst.h
Constants for most interaction classes, due to the generic StateMachines.
mitk::InteractionEvent
Definition: mitkInteractionEvent.h:26
mitkImage.h
mitk::PlaneGeometry
Describes a two-dimensional, rectangular plane.
Definition: mitkPlaneGeometry.h:78
mitk::SegTool2D::SliceInformation::slice
mitk::Image::ConstPointer slice
Definition: mitkSegTool2D.h:166
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
mitkRestorePlanePositionOperation.h
mitk::SegTool2D::SliceInformation::slicePosition
unsigned int slicePosition
Definition: mitkSegTool2D.h:169
itk::SmartPointer< Self >
mitkPlanePositionManager.h
mitk::Label::PixelType
unsigned short PixelType
Definition: mitkLabel.h:34
mitk::Tool
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:83
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::SegTool2D::SliceInformation
Definition: mitkSegTool2D.h:164
mitk::SegTool2D
Abstract base class for segmentation tools.
Definition: mitkSegTool2D.h:56
mitk::InteractionPositionEvent
Super class for all position events.
Definition: mitkInteractionPositionEvent.h:36
mitkInteractionPositionEvent.h
mitkDiffSliceOperation.h
us::Module
Definition: usModule.h:78
mitkCommon.h
MITKSEGMENTATION_EXPORT
#define MITKSEGMENTATION_EXPORT
Definition: MitkSegmentationExports.h:15
mitk::BaseData
Base of all data objects.
Definition: mitkBaseData.h:42
us::ModuleResource
Definition: usModuleResource.h:55
mitk::TimeStepType
std::size_t TimeStepType
Definition: mitkTimeGeometry.h:27
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::BaseRenderer
Definition: mitkBaseRenderer.h:56
mitk::TimePointType
mitk::ScalarType TimePointType
Definition: mitkTimeGeometry.h:26
MitkSegmentationExports.h
usModuleResource.h
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
mitk::LabelSetImage
LabelSetImage class for handling labels and layers in a segmentation session.
Definition: mitkLabelSetImage.h:43
mitk::LabelSetImage::LabelValueType
mitk::Label::PixelType LabelValueType
Definition: mitkLabelSetImage.h:75