Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
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_HEADER_INCLUDED
14 #define MITKPLANARFIGUREINTERACTOR_H_HEADER_INCLUDED
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  itkEventMacro(PlanarFigureEvent, itk::AnyEvent);
40  itkEventMacro(StartPlacementPlanarFigureEvent, PlanarFigureEvent);
41  itkEventMacro(EndPlacementPlanarFigureEvent, PlanarFigureEvent);
42  itkEventMacro(SelectPlanarFigureEvent, PlanarFigureEvent);
43  itkEventMacro(StartInteractionPlanarFigureEvent, PlanarFigureEvent);
44  itkEventMacro(EndInteractionPlanarFigureEvent, PlanarFigureEvent);
45  itkEventMacro(StartHoverPlanarFigureEvent, PlanarFigureEvent);
46  itkEventMacro(EndHoverPlanarFigureEvent, PlanarFigureEvent);
47  itkEventMacro(ContextMenuPlanarFigureEvent, PlanarFigureEvent);
48 
49 #pragma GCC visibility pop
50 
57  {
58  public:
60  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
61 
62 
63  void SetPrecision(ScalarType precision);
64 
66  void SetMinimumPointDistance(ScalarType minimumDistance);
67 
68  protected:
70  ~PlanarFigureInteractor() override;
71 
72  void ConnectActionsAndFunctions() override;
73 
75  bool CheckFigurePlaced(const InteractionEvent *interactionEvent);
76 
77  bool CheckFigureHovering(const InteractionEvent *interactionEvent);
78 
79  bool CheckControlPointHovering(const InteractionEvent *interactionEvent);
80 
81  bool CheckSelection(const InteractionEvent *interactionEvent);
82 
83  bool CheckPointValidity(const InteractionEvent *interactionEvent);
84 
85  bool CheckFigureFinished(const InteractionEvent *interactionEvent);
86 
87  bool CheckResetOnPointSelect(const InteractionEvent *interactionEvent);
88 
89  bool CheckFigureOnRenderingGeometry(const InteractionEvent *interactionEvent);
90 
91  bool CheckMinimalFigureFinished(const InteractionEvent *interactionEvent);
92 
93  bool CheckFigureIsExtendable(const InteractionEvent *interactionEvent);
94 
95  bool CheckFigureIsDeletable(const InteractionEvent *interactionEvent);
96 
97  bool CheckFigureIsEditable(const InteractionEvent *interactionEvent);
98 
100 
101  void FinalizeFigure(StateMachineAction *, InteractionEvent *interactionEvent);
102 
103  void MoveCurrentPoint(StateMachineAction *, InteractionEvent *interactionEvent);
104 
105  void DeselectPoint(StateMachineAction *, InteractionEvent *interactionEvent);
106 
107  void AddPoint(StateMachineAction *, InteractionEvent *interactionEvent);
108 
109  void AddInitialPoint(StateMachineAction *, InteractionEvent *interactionEvent);
110 
111  void StartHovering(StateMachineAction *, InteractionEvent *interactionEvent);
112 
113  void EndHovering(StateMachineAction *, InteractionEvent *interactionEvent);
114 
115  void DeleteFigure(StateMachineAction *, InteractionEvent *interactionEvent);
116 
117  void PerformPointResetOnSelect(StateMachineAction *, InteractionEvent *interactionEvent);
118 
119  void SetPreviewPointPosition(StateMachineAction *, InteractionEvent *interactionEvent);
120 
121  void HidePreviewPoint(StateMachineAction *, InteractionEvent *interactionEvent);
122 
123  void HideControlPoints(StateMachineAction *, InteractionEvent *interactionEvent);
124 
125  void RemoveSelectedPoint(StateMachineAction *, InteractionEvent *interactionEvent);
126 
127  void RequestContextMenu(StateMachineAction *, InteractionEvent *interactionEvent);
128 
129  void SelectFigure(StateMachineAction *, InteractionEvent *interactionEvent);
130 
131  void SelectPoint(StateMachineAction *, InteractionEvent *interactionEvent);
132 
133  void EndInteraction(StateMachineAction *, InteractionEvent *interactionEvent);
134 
135  bool FilterEvents(InteractionEvent *interactionEvent, DataNode *) override;
136 
140  bool IsMousePositionAcceptableAsNewControlPoint(const mitk::InteractionPositionEvent *positionEvent,
141  const PlanarFigure *);
142 
143  bool TransformPositionEventToPoint2D(const InteractionPositionEvent *positionEvent,
144  const PlaneGeometry *planarFigureGeometry,
145  Point2D &point2D);
146 
147  bool TransformObjectToDisplay(const mitk::Point2D &point2D,
148  mitk::Point2D &displayPoint,
149  const mitk::PlaneGeometry *objectGeometry,
150  const mitk::PlaneGeometry *rendererGeometry,
151  const mitk::BaseRenderer *renderer) const;
152 
158  bool IsPointNearLine(const mitk::Point2D &point,
159  const mitk::Point2D &startPoint,
160  const mitk::Point2D &endPoint,
161  mitk::Point2D &projectedPoint) const;
162 
165  int IsPositionOverFigure(const InteractionPositionEvent *positionEvent,
166  PlanarFigure *planarFigure,
167  const PlaneGeometry *planarFigureGeometry,
168  const PlaneGeometry *rendererGeometry,
169  Point2D &pointProjectedOntoLine) const;
170 
174  int IsPositionInsideMarker(const InteractionPositionEvent *positionEvent,
175  const PlanarFigure *planarFigure,
176  const PlaneGeometry *planarFigureGeometry,
177  const PlaneGeometry *rendererGeometry,
178  const BaseRenderer *renderer) const;
179 
180  void LogPrintPlanarFigureQuantities(const PlanarFigure *planarFigure);
181 
182  void ConfigurationChanged() override;
183 
184  private:
186  ScalarType m_Precision;
187 
189  ScalarType m_MinimumPointDistance;
190 
192  bool m_IsHovering;
193 
194  bool m_LastPointWasValid;
195 
196  // mitk::PlanarFigure::Pointer m_PlanarFigure;
197  };
198 }
199 
200 #endif // MITKPLANARFIGUREINTERACTOR_H_HEADER_INCLUDED
Interaction with mitk::PlanarFigure objects via control-points.
Super class for all position events.
double ScalarType
Organizes the rendering process.
DataCollection - Class to facilitate loading/accessing structured data.
Base class from with interactors that handle DataNodes are to be derived.
Represents an action, that is executed after a certain event (in statemachine-mechanism) TODO: implem...
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
itkEventMacro(ContourModelEvent, itk::AnyEvent)
#define MITKPLANARFIGURE_EXPORT
Base-class for geometric planar (2D) figures, such as lines, circles, rectangles, polygons...
Describes a two-dimensional, rectangular plane.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64