Medical Imaging Interaction Toolkit  2018.4.99-b20efe7f
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  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);
61  itkCloneMacro(Self);
62 
64  void SetPrecision(ScalarType precision);
65 
67  void SetMinimumPointDistance(ScalarType minimumDistance);
68 
69  protected:
71  ~PlanarFigureInteractor() override;
72 
73  void ConnectActionsAndFunctions() override;
74 
76  bool CheckFigurePlaced(const InteractionEvent *interactionEvent);
77 
78  bool CheckFigureHovering(const InteractionEvent *interactionEvent);
79 
80  bool CheckControlPointHovering(const InteractionEvent *interactionEvent);
81 
82  bool CheckSelection(const InteractionEvent *interactionEvent);
83 
84  bool CheckPointValidity(const InteractionEvent *interactionEvent);
85 
86  bool CheckFigureFinished(const InteractionEvent *interactionEvent);
87 
88  bool CheckResetOnPointSelect(const InteractionEvent *interactionEvent);
89 
90  bool CheckFigureOnRenderingGeometry(const InteractionEvent *interactionEvent);
91 
92  bool CheckMinimalFigureFinished(const InteractionEvent *interactionEvent);
93 
94  bool CheckFigureIsExtendable(const InteractionEvent *interactionEvent);
95 
96  bool CheckFigureIsDeletable(const InteractionEvent *interactionEvent);
97 
98  bool CheckFigureIsEditable(const InteractionEvent *interactionEvent);
99 
101 
102  void FinalizeFigure(StateMachineAction *, InteractionEvent *interactionEvent);
103 
104  void MoveCurrentPoint(StateMachineAction *, InteractionEvent *interactionEvent);
105 
106  void DeselectPoint(StateMachineAction *, InteractionEvent *interactionEvent);
107 
108  void AddPoint(StateMachineAction *, InteractionEvent *interactionEvent);
109 
110  void AddInitialPoint(StateMachineAction *, InteractionEvent *interactionEvent);
111 
112  void StartHovering(StateMachineAction *, InteractionEvent *interactionEvent);
113 
114  void EndHovering(StateMachineAction *, InteractionEvent *interactionEvent);
115 
116  void DeleteFigure(StateMachineAction *, InteractionEvent *interactionEvent);
117 
118  void PerformPointResetOnSelect(StateMachineAction *, InteractionEvent *interactionEvent);
119 
120  void SetPreviewPointPosition(StateMachineAction *, InteractionEvent *interactionEvent);
121 
122  void HidePreviewPoint(StateMachineAction *, InteractionEvent *interactionEvent);
123 
124  void HideControlPoints(StateMachineAction *, InteractionEvent *interactionEvent);
125 
126  void RemoveSelectedPoint(StateMachineAction *, InteractionEvent *interactionEvent);
127 
128  void RequestContextMenu(StateMachineAction *, InteractionEvent *interactionEvent);
129 
130  void SelectFigure(StateMachineAction *, InteractionEvent *interactionEvent);
131 
132  void SelectPoint(StateMachineAction *, InteractionEvent *interactionEvent);
133 
134  void EndInteraction(StateMachineAction *, InteractionEvent *interactionEvent);
135 
136  bool FilterEvents(InteractionEvent *interactionEvent, DataNode *) override;
137 
141  bool IsMousePositionAcceptableAsNewControlPoint(const mitk::InteractionPositionEvent *positionEvent,
142  const PlanarFigure *);
143 
144  bool TransformPositionEventToPoint2D(const InteractionPositionEvent *positionEvent,
145  const PlaneGeometry *planarFigureGeometry,
146  Point2D &point2D);
147 
148  bool TransformObjectToDisplay(const mitk::Point2D &point2D,
149  mitk::Point2D &displayPoint,
150  const mitk::PlaneGeometry *objectGeometry,
151  const mitk::PlaneGeometry *rendererGeometry,
152  const mitk::BaseRenderer *renderer) const;
153 
159  bool IsPointNearLine(const mitk::Point2D &point,
160  const mitk::Point2D &startPoint,
161  const mitk::Point2D &endPoint,
162  mitk::Point2D &projectedPoint) const;
163 
166  int IsPositionOverFigure(const InteractionPositionEvent *positionEvent,
167  PlanarFigure *planarFigure,
168  const PlaneGeometry *planarFigureGeometry,
169  const PlaneGeometry *rendererGeometry,
170  Point2D &pointProjectedOntoLine) const;
171 
175  int IsPositionInsideMarker(const InteractionPositionEvent *positionEvent,
176  const PlanarFigure *planarFigure,
177  const PlaneGeometry *planarFigureGeometry,
178  const PlaneGeometry *rendererGeometry,
179  const BaseRenderer *renderer) const;
180 
181  void LogPrintPlanarFigureQuantities(const PlanarFigure *planarFigure);
182 
183  void ConfigurationChanged() override;
184 
185  private:
187  ScalarType m_Precision;
188 
190  ScalarType m_MinimumPointDistance;
191 
193  bool m_IsHovering;
194  };
195 }
196 
197 #endif // MITKPLANARFIGUREINTERACTOR_H
Interaction with mitk::PlanarFigure objects via control-points.
Super class for all position events.
itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent)
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
#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:57