Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef MITKPLANARFIGUREINTERACTOR_H_HEADER_INCLUDED
18 #define MITKPLANARFIGUREINTERACTOR_H_HEADER_INCLUDED
19 
21 
22 #include "mitkCommon.h"
23 #include "mitkDataInteractor.h"
24 #include "mitkNumericTypes.h"
25 
26 #pragma GCC visibility push(default)
27 #include <itkEventObject.h>
28 #pragma GCC visibility pop
29 
30 namespace mitk
31 {
32  class DataNode;
33  class PlaneGeometry;
34  class PlanarFigure;
35  class PositionEvent;
36  class BaseRenderer;
37  class InteractionPositionEvent;
38  class StateMachineAction;
39 
40 #pragma GCC visibility push(default)
41 
42  // Define events for PlanarFigure interaction notifications
43  itkEventMacro(PlanarFigureEvent, itk::AnyEvent);
44  itkEventMacro(StartPlacementPlanarFigureEvent, PlanarFigureEvent);
45  itkEventMacro(EndPlacementPlanarFigureEvent, PlanarFigureEvent);
46  itkEventMacro(SelectPlanarFigureEvent, PlanarFigureEvent);
47  itkEventMacro(StartInteractionPlanarFigureEvent, PlanarFigureEvent);
48  itkEventMacro(EndInteractionPlanarFigureEvent, PlanarFigureEvent);
49  itkEventMacro(StartHoverPlanarFigureEvent, PlanarFigureEvent);
50  itkEventMacro(EndHoverPlanarFigureEvent, PlanarFigureEvent);
51  itkEventMacro(ContextMenuPlanarFigureEvent, PlanarFigureEvent);
52 
53 #pragma GCC visibility pop
54 
61  {
62  public:
64  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
65 
66 
67  void SetPrecision(ScalarType precision);
68 
70  void SetMinimumPointDistance(ScalarType minimumDistance);
71 
72  protected:
74  virtual ~PlanarFigureInteractor();
75 
76  virtual void ConnectActionsAndFunctions() override;
77 
79  bool CheckFigurePlaced(const InteractionEvent *interactionEvent);
80 
81  bool CheckFigureHovering(const InteractionEvent *interactionEvent);
82 
83  bool CheckControlPointHovering(const InteractionEvent *interactionEvent);
84 
85  bool CheckSelection(const InteractionEvent *interactionEvent);
86 
87  bool CheckPointValidity(const InteractionEvent *interactionEvent);
88 
89  bool CheckFigureFinished(const InteractionEvent *interactionEvent);
90 
91  bool CheckResetOnPointSelect(const InteractionEvent *interactionEvent);
92 
93  bool CheckFigureOnRenderingGeometry(const InteractionEvent *interactionEvent);
94 
95  bool CheckMinimalFigureFinished(const InteractionEvent *interactionEvent);
96 
97  bool CheckFigureIsExtendable(const InteractionEvent *interactionEvent);
98 
99  bool CheckFigureIsDeletable(const InteractionEvent *interactionEvent);
100 
101  bool CheckFigureIsEditable(const InteractionEvent *interactionEvent);
102 
104 
105  void FinalizeFigure(StateMachineAction *, InteractionEvent *interactionEvent);
106 
107  void MoveCurrentPoint(StateMachineAction *, InteractionEvent *interactionEvent);
108 
109  void DeselectPoint(StateMachineAction *, InteractionEvent *interactionEvent);
110 
111  void AddPoint(StateMachineAction *, InteractionEvent *interactionEvent);
112 
113  void AddInitialPoint(StateMachineAction *, InteractionEvent *interactionEvent);
114 
115  void StartHovering(StateMachineAction *, InteractionEvent *interactionEvent);
116 
117  void EndHovering(StateMachineAction *, InteractionEvent *interactionEvent);
118 
119  void DeleteFigure(StateMachineAction *, InteractionEvent *interactionEvent);
120 
121  void PerformPointResetOnSelect(StateMachineAction *, InteractionEvent *interactionEvent);
122 
123  void SetPreviewPointPosition(StateMachineAction *, InteractionEvent *interactionEvent);
124 
125  void HidePreviewPoint(StateMachineAction *, InteractionEvent *interactionEvent);
126 
127  void HideControlPoints(StateMachineAction *, InteractionEvent *interactionEvent);
128 
129  void RemoveSelectedPoint(StateMachineAction *, InteractionEvent *interactionEvent);
130 
131  void RequestContextMenu(StateMachineAction *, InteractionEvent *interactionEvent);
132 
133  void SelectFigure(StateMachineAction *, InteractionEvent *interactionEvent);
134 
135  void SelectPoint(StateMachineAction *, InteractionEvent *interactionEvent);
136 
137  void EndInteraction(StateMachineAction *, InteractionEvent *interactionEvent);
138 
139  bool FilterEvents(InteractionEvent *interactionEvent, DataNode *) override;
140 
144  bool IsMousePositionAcceptableAsNewControlPoint(const mitk::InteractionPositionEvent *positionEvent,
145  const PlanarFigure *);
146 
147  bool TransformPositionEventToPoint2D(const InteractionPositionEvent *positionEvent,
148  const PlaneGeometry *planarFigureGeometry,
149  Point2D &point2D);
150 
151  bool TransformObjectToDisplay(const mitk::Point2D &point2D,
152  mitk::Point2D &displayPoint,
153  const mitk::PlaneGeometry *objectGeometry,
154  const mitk::PlaneGeometry *rendererGeometry,
155  const mitk::BaseRenderer *renderer) const;
156 
162  bool IsPointNearLine(const mitk::Point2D &point,
163  const mitk::Point2D &startPoint,
164  const mitk::Point2D &endPoint,
165  mitk::Point2D &projectedPoint) const;
166 
169  int IsPositionOverFigure(const InteractionPositionEvent *positionEvent,
170  PlanarFigure *planarFigure,
171  const PlaneGeometry *planarFigureGeometry,
172  const PlaneGeometry *rendererGeometry,
173  Point2D &pointProjectedOntoLine) const;
174 
178  int IsPositionInsideMarker(const InteractionPositionEvent *positionEvent,
179  const PlanarFigure *planarFigure,
180  const PlaneGeometry *planarFigureGeometry,
181  const PlaneGeometry *rendererGeometry,
182  const BaseRenderer *renderer) const;
183 
184  void LogPrintPlanarFigureQuantities(const PlanarFigure *planarFigure);
185 
186  virtual void ConfigurationChanged() override;
187 
188  private:
190  ScalarType m_Precision;
191 
193  ScalarType m_MinimumPointDistance;
194 
196  bool m_IsHovering;
197 
198  bool m_LastPointWasValid;
199 
200  // mitk::PlanarFigure::Pointer m_PlanarFigure;
201  };
202 }
203 
204 #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...
virtual void ConnectActionsAndFunctions() override
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:44
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:66