Medical Imaging Interaction Toolkit  2023.12.00
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 (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 mitkGizmoInteractor_h
14 #define mitkGizmoInteractor_h
15 
16 #include "mitkGizmo.h"
17 
18 // MITK includes
19 #include <mitkDataInteractor.h>
20 #include <mitkDataNode.h>
21 #include <mitkGeometry3D.h>
22 
23 // VTK includes
24 #include <vtkCellPicker.h>
25 #include <vtkSmartPointer.h>
26 
27 // System includes
28 #include <memory>
29 
30 #include "MitkGizmoExports.h"
31 
32 namespace mitk
33 {
34  class InteractionPositionEvent;
35 
53  {
54  public:
56  itkFactorylessNewMacro(Self);
57  itkCloneMacro(Self);
58 
62  void SetGizmoNode(DataNode *node);
63 
66  void SetManipulatedObjectNode(DataNode *node);
67 
68  private:
70  ~GizmoInteractor() override;
71 
73  void ConnectActionsAndFunctions() override;
74 
77  bool HasPickedHandle(const InteractionEvent *);
78 
81  void DecideInteraction(StateMachineAction *, InteractionEvent *interactionEvent);
82 
85  void MoveAlongAxis(StateMachineAction *, InteractionEvent *interactionEvent);
86 
89  void ScaleEqually(StateMachineAction *, InteractionEvent *interactionEvent);
90 
93  void RotateAroundAxis(StateMachineAction *, InteractionEvent *interactionEvent);
94 
97  void MoveFreely(StateMachineAction *, InteractionEvent *interactionEvent);
98 
100  void FeedUndoStack(StateMachineAction *, InteractionEvent *interactionEvent);
101 
103  void ApplyTranslationToManipulatedObject(const Vector3D &projectedMovement);
104 
106  void ApplyEqualScalingToManipulatedObject(double scalingFactor);
107 
109  void ApplyRotationToManipulatedObject(double angle_deg);
110 
112  Gizmo::HandleType PickFrom2D(const InteractionPositionEvent *positionEvent);
113 
116  Gizmo::HandleType PickFrom3D(const InteractionPositionEvent *positionEvent);
117 
118  void UpdateHandleHighlight();
119 
121  Gizmo::Pointer m_Gizmo;
122 
124  BaseGeometry::Pointer m_ManipulatedObjectGeometry;
125 
127  std::map<BaseRenderer *, vtkSmartPointer<vtkCellPicker>> m_Picker;
128 
130  Gizmo::HandleType m_PickedHandle = Gizmo::NoHandle;
131 
133  Gizmo::HandleType m_HighlightedHandle = Gizmo::NoHandle;
134 
136  double m_ColorForHighlight[4];
137 
139  double m_ColorReplacedByHighlight[4];
140 
141  Point2D m_InitialClickPosition2D; //< Initial screen click position
142  double m_InitialClickPosition2DZ; //< Z value of the initial screen click position
143  Point3D m_InitialClickPosition3D; //< Initial 3D click position
144 
145  Point2D m_InitialGizmoCenter2D; //< Initial position of the gizmo's center in screen coordinates
146  Point3D m_InitialGizmoCenter3D; //< Initial 3D position of the gizmo's center
147 
148  Vector3D m_AxisOfMovement; //< Axis along which we move when translating
149  Vector3D m_AxisOfRotation; //< Axis around which we turn when rotating
150 
151  std::unique_ptr<Operation> m_FinalDoOperation; //< Operation for the undo-stack
152  std::unique_ptr<Operation> m_FinalUndoOperation; //< Operation for the undo-stack
153 
155  BaseGeometry::Pointer m_InitialManipulatedObjectGeometry;
156  };
157 }
158 #endif
mitk::InteractionEvent
Definition: mitkInteractionEvent.h:26
mitk::Gizmo::HandleType
HandleType
Names for the different parts of the gizmo.
Definition: mitkGizmo.h:61
mitk::Gizmo::NoHandle
@ NoHandle
Definition: mitkGizmo.h:73
mitk::GizmoInteractor
Definition: mitkGizmoInteractor.h:52
MitkGizmoExports.h
itk::SmartPointer< Self >
mitkGeometry3D.h
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::Vector< ScalarType, 3 >
mitk::Point< ScalarType, 2 >
mitkDataInteractor.h
mitkGizmo.h
mitkDataNode.h
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::DataInteractor
Base class from with interactors that handle DataNodes are to be derived.
Definition: mitkDataInteractor.h:48
MITKGIZMO_EXPORT
#define MITKGIZMO_EXPORT
Definition: MitkGizmoExports.h:15
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
mitk::Surface::Pointer
itk::SmartPointer< Self > Pointer
Definition: mitkSurface.h:33