Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkGizmoInteractor.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 mitkGizmoInteractor_h
18 #define mitkGizmoInteractor_h
19 
20 #include "mitkGizmo.h"
21 
22 // MITK includes
23 #include <mitkDataInteractor.h>
24 #include <mitkDataNode.h>
25 #include <mitkGeometry3D.h>
26 
27 // VTK includes
28 #include <vtkCellPicker.h>
29 #include <vtkSmartPointer.h>
30 
31 // System includes
32 #include <memory>
33 
34 #include "MitkGizmoExports.h"
35 
36 namespace mitk
37 {
38  class InteractionPositionEvent;
39 
57  {
58  public:
60  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
61 
62 
63  void SetGizmoNode(DataNode *node);
66 
69  void SetManipulatedObjectNode(DataNode *node);
70 
71  private:
73  virtual ~GizmoInteractor();
74 
76  virtual void ConnectActionsAndFunctions() override;
77 
80  bool HasPickedHandle(const InteractionEvent *);
81 
84  void DecideInteraction(StateMachineAction *, InteractionEvent *interactionEvent);
85 
88  void MoveAlongAxis(StateMachineAction *, InteractionEvent *interactionEvent);
89 
92  void ScaleEqually(StateMachineAction *, InteractionEvent *interactionEvent);
93 
96  void RotateAroundAxis(StateMachineAction *, InteractionEvent *interactionEvent);
97 
100  void MoveFreely(StateMachineAction *, InteractionEvent *interactionEvent);
101 
103  void FeedUndoStack(StateMachineAction *, InteractionEvent *interactionEvent);
104 
106  void ApplyTranslationToManipulatedObject(const Vector3D &projectedMovement);
107 
109  void ApplyEqualScalingToManipulatedObject(double scalingFactor);
110 
112  void ApplyRotationToManipulatedObject(double angle_deg);
113 
115  Gizmo::HandleType PickFrom2D(const InteractionPositionEvent *positionEvent);
116 
119  Gizmo::HandleType PickFrom3D(const InteractionPositionEvent *positionEvent);
120 
122  Gizmo::Pointer m_Gizmo;
123 
125  BaseGeometry::Pointer m_ManipulatedObjectGeometry;
126 
128  std::map<BaseRenderer *, vtkSmartPointer<vtkCellPicker>> m_Picker;
129 
131  Gizmo::HandleType m_PickedHandle;
132 
133  Point2D m_InitialClickPosition2D; //< Initial screen click position
134  double m_InitialClickPosition2DZ; //< Z value of the initial screen click position
135  Point3D m_InitialClickPosition3D; //< Initial 3D click position
136 
137  Point2D m_InitialGizmoCenter2D; //< Initial position of the gizmo's center in screen coordinates
138  Point3D m_InitialGizmoCenter3D; //< Initial 3D position of the gizmo's center
139 
140  Vector3D m_AxisOfMovement; //< Axis along which we move when translating
141  Vector3D m_AxisOfRotation; //< Axis around which we turn when rotating
142 
143  std::unique_ptr<Operation> m_FinalDoOperation; //< Operation for the undo-stack
144  std::unique_ptr<Operation> m_FinalUndoOperation; //< Operation for the undo-stack
145 
147  BaseGeometry::Pointer m_InitialManipulatedObjectGeometry;
148  };
149 }
150 #endif
#define MITKGIZMO_EXPORT
Super class for all position events.
DataCollection - Class to facilitate loading/accessing structured data.
itk::SmartPointer< Self > Pointer
Definition: mitkSurface.h:37
Base class from with interactors that handle DataNodes are to be derived.
HandleType
Names for the different parts of the gizmo.
Definition: mitkGizmo.h:65
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
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66