Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
mitkPlanarFigureInteractor.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 mitkPlanarFigureInteractor_h
14 #define mitkPlanarFigureInteractor_h
15 
17 
18 #include "mitkCommon.h"
19 #include "mitkDataInteractor.h"
20 #include "mitkNumericTypes.h"
21 
22 #pragma GCC visibility push(default)
23 #include <itkEventObject.h>
24 #pragma GCC visibility pop
25 
26 namespace mitk
27 {
28  class DataNode;
29  class PlaneGeometry;
30  class PlanarFigure;
31  class PositionEvent;
32  class BaseRenderer;
33  class InteractionPositionEvent;
34  class StateMachineAction;
35 
36 #pragma GCC visibility push(default)
37 
38  // Define events for PlanarFigure interaction notifications
39  itkEventMacroDeclaration(PlanarFigureEvent, itk::AnyEvent);
40  itkEventMacroDeclaration(StartPlacementPlanarFigureEvent, PlanarFigureEvent);
41  itkEventMacroDeclaration(EndPlacementPlanarFigureEvent, PlanarFigureEvent);
42  itkEventMacroDeclaration(SelectPlanarFigureEvent, PlanarFigureEvent);
43  itkEventMacroDeclaration(StartInteractionPlanarFigureEvent, PlanarFigureEvent);
44  itkEventMacroDeclaration(EndInteractionPlanarFigureEvent, PlanarFigureEvent);
45  itkEventMacroDeclaration(StartHoverPlanarFigureEvent, PlanarFigureEvent);
46  itkEventMacroDeclaration(EndHoverPlanarFigureEvent, PlanarFigureEvent);
47  itkEventMacroDeclaration(ContextMenuPlanarFigureEvent, PlanarFigureEvent);
48  itkEventMacroDeclaration(PointMovedPlanarFigureEvent, PlanarFigureEvent);
49 
50 #pragma GCC visibility pop
51 
58  {
59  public:
61  itkFactorylessNewMacro(Self);
62  itkCloneMacro(Self);
63 
65  void SetPrecision(ScalarType precision);
66 
68  void SetMinimumPointDistance(ScalarType minimumDistance);
69 
70  protected:
72  ~PlanarFigureInteractor() override;
73 
74  void ConnectActionsAndFunctions() override;
75 
77  bool CheckFigurePlaced(const InteractionEvent *interactionEvent);
78 
79  bool CheckFigureHovering(const InteractionEvent *interactionEvent);
80 
81  bool CheckControlPointHovering(const InteractionEvent *interactionEvent);
82 
83  bool CheckSelection(const InteractionEvent *interactionEvent);
84 
85  bool CheckPointValidity(const InteractionEvent *interactionEvent);
86 
87  bool CheckFigureFinished(const InteractionEvent *interactionEvent);
88 
89  bool CheckResetOnPointSelect(const InteractionEvent *interactionEvent);
90 
91  bool CheckFigureOnRenderingGeometry(const InteractionEvent *interactionEvent);
92 
93  bool CheckMinimalFigureFinished(const InteractionEvent *interactionEvent);
94 
95  bool CheckFigureIsExtendable(const InteractionEvent *interactionEvent);
96 
97  bool CheckFigureIsDeletable(const InteractionEvent *interactionEvent);
98 
99  bool CheckFigureIsEditable(const InteractionEvent *interactionEvent);
100 
102 
103  void FinalizeFigure(StateMachineAction *, InteractionEvent *interactionEvent);
104 
105  void MoveCurrentPoint(StateMachineAction *, InteractionEvent *interactionEvent);
106 
107  void DeselectPoint(StateMachineAction *, InteractionEvent *interactionEvent);
108 
109  void AddPoint(StateMachineAction *, InteractionEvent *interactionEvent);
110 
111  void AddInitialPoint(StateMachineAction *, InteractionEvent *interactionEvent);
112 
113  void StartHovering(StateMachineAction *, InteractionEvent *interactionEvent);
114 
115  void EndHovering(StateMachineAction *, InteractionEvent *interactionEvent);
116 
117  void DeleteFigure(StateMachineAction *, InteractionEvent *interactionEvent);
118 
119  void PerformPointResetOnSelect(StateMachineAction *, InteractionEvent *interactionEvent);
120 
121  void SetPreviewPointPosition(StateMachineAction *, InteractionEvent *interactionEvent);
122 
123  void HidePreviewPoint(StateMachineAction *, InteractionEvent *interactionEvent);
124 
125  void HideControlPoints(StateMachineAction *, InteractionEvent *interactionEvent);
126 
127  void RemoveSelectedPoint(StateMachineAction *, InteractionEvent *interactionEvent);
128 
129  void RequestContextMenu(StateMachineAction *, InteractionEvent *interactionEvent);
130 
131  void SelectFigure(StateMachineAction *, InteractionEvent *interactionEvent);
132 
133  void SelectPoint(StateMachineAction *, InteractionEvent *interactionEvent);
134 
135  void EndInteraction(StateMachineAction *, InteractionEvent *interactionEvent);
136 
137  bool FilterEvents(InteractionEvent *interactionEvent, DataNode *) override;
138 
142  bool IsMousePositionAcceptableAsNewControlPoint(const mitk::InteractionPositionEvent *positionEvent,
143  const PlanarFigure *);
144 
145  bool TransformPositionEventToPoint2D(const InteractionPositionEvent *positionEvent,
146  const PlaneGeometry *planarFigureGeometry,
147  Point2D &point2D);
148 
149  bool TransformObjectToDisplay(const mitk::Point2D &point2D,
150  mitk::Point2D &displayPoint,
151  const mitk::PlaneGeometry *objectGeometry,
152  const mitk::PlaneGeometry *rendererGeometry,
153  const mitk::BaseRenderer *renderer) const;
154 
160  bool IsPointNearLine(const mitk::Point2D &point,
161  const mitk::Point2D &startPoint,
162  const mitk::Point2D &endPoint,
163  mitk::Point2D &projectedPoint) const;
164 
167  int IsPositionOverFigure(const InteractionPositionEvent *positionEvent,
168  PlanarFigure *planarFigure,
169  const PlaneGeometry *planarFigureGeometry,
170  const PlaneGeometry *rendererGeometry,
171  Point2D &pointProjectedOntoLine) const;
172 
176  int IsPositionInsideMarker(const InteractionPositionEvent *positionEvent,
177  const PlanarFigure *planarFigure,
178  const PlaneGeometry *planarFigureGeometry,
179  const PlaneGeometry *rendererGeometry,
180  const BaseRenderer *renderer) const;
181 
182  void LogPrintPlanarFigureQuantities(const PlanarFigure *planarFigure);
183 
184  void ConfigurationChanged() override;
185 
186  private:
188  ScalarType m_Precision;
189 
191  ScalarType m_MinimumPointDistance;
192 
194  bool m_IsHovering;
195  };
196 }
197 
198 #endif
mitk::InteractionEvent
Definition: mitkInteractionEvent.h:26
MitkPlanarFigureExports.h
mitk::PlaneGeometry
Describes a two-dimensional, rectangular plane.
Definition: mitkPlaneGeometry.h:78
mitk::PlanarFigure
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons,...
Definition: mitkPlanarFigure.h:50
MITKPLANARFIGURE_EXPORT
#define MITKPLANARFIGURE_EXPORT
Definition: MitkPlanarFigureExports.h:15
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::InteractionPositionEvent
Super class for all position events.
Definition: mitkInteractionPositionEvent.h:36
mitk::Point< ScalarType, 2 >
mitkNumericTypes.h
mitkCommon.h
mitkDataInteractor.h
mitk::PlanarFigureInteractor
Interaction with mitk::PlanarFigure objects via control-points.
Definition: mitkPlanarFigureInteractor.h:57
mitk::StateMachineAction
Represents an action, that is executed after a certain event (in statemachine-mechanism) TODO: implem...
Definition: mitkStateMachineAction.h:30
mitkClassMacro
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:36
mitk::BaseRenderer
Definition: mitkBaseRenderer.h:56
mitk::DataInteractor
Base class from with interactors that handle DataNodes are to be derived.
Definition: mitkDataInteractor.h:48
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
mitk::itkEventMacroDeclaration
itkEventMacroDeclaration(BoundingShapeInteractionEvent, itk::AnyEvent)
mitk::ScalarType
double ScalarType
Definition: mitkNumericConstants.h:20