Medical Imaging Interaction Toolkit  2026.06.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 
62  {
63  public:
65  itkFactorylessNewMacro(Self);
66  itkCloneMacro(Self);
67 
79  void SetGizmoNode(DataNode *node);
80 
94 
95  private:
97  ~GizmoInteractor() override;
98 
100  void ConnectActionsAndFunctions() override;
101 
104  bool HasPickedHandle(const InteractionEvent *);
105 
108  void DecideInteraction(StateMachineAction *, InteractionEvent *interactionEvent);
109 
112  void MoveAlongAxis(StateMachineAction *, InteractionEvent *interactionEvent);
113 
116  void ScaleEqually(StateMachineAction *, InteractionEvent *interactionEvent);
117 
120  void RotateAroundAxis(StateMachineAction *, InteractionEvent *interactionEvent);
121 
124  void MoveFreely(StateMachineAction *, InteractionEvent *interactionEvent);
125 
127  void FeedUndoStack(StateMachineAction *, InteractionEvent *interactionEvent);
128 
130  void ApplyTranslationToManipulatedObject(const Vector3D &projectedMovement);
131 
133  void ApplyEqualScalingToManipulatedObject(double scalingFactor);
134 
136  void ApplyRotationToManipulatedObject(double angle_deg);
137 
139  Gizmo::HandleType PickFrom2D(const InteractionPositionEvent *positionEvent);
140 
143  Gizmo::HandleType PickFrom3D(const InteractionPositionEvent *positionEvent);
144 
145  void UpdateHandleHighlight();
146 
148  Gizmo::Pointer m_Gizmo;
149 
151  BaseGeometry::Pointer m_ManipulatedObjectGeometry;
152 
154  std::map<BaseRenderer *, vtkSmartPointer<vtkCellPicker>> m_Picker;
155 
157  Gizmo::HandleType m_PickedHandle = Gizmo::NoHandle;
158 
160  Gizmo::HandleType m_HighlightedHandle = Gizmo::NoHandle;
161 
163  double m_ColorForHighlight[4];
164 
166  double m_ColorReplacedByHighlight[4];
167 
168  Point2D m_InitialClickPosition2D; //< Initial screen click position
169  double m_InitialClickPosition2DZ; //< Z value of the initial screen click position
170  Point3D m_InitialClickPosition3D; //< Initial 3D click position
171 
172  Point2D m_InitialGizmoCenter2D; //< Initial position of the gizmo's center in screen coordinates
173  Point3D m_InitialGizmoCenter3D; //< Initial 3D position of the gizmo's center
174 
175  Vector3D m_AxisOfMovement; //< Axis along which we move when translating
176  Vector3D m_AxisOfRotation; //< Axis around which we turn when rotating
177 
178  std::unique_ptr<Operation> m_FinalDoOperation; //< Operation for the undo-stack
179  std::unique_ptr<Operation> m_FinalUndoOperation; //< Operation for the undo-stack
180 
182  BaseGeometry::Pointer m_InitialManipulatedObjectGeometry;
183  };
184 }
185 #endif
#define MITKGIZMO_EXPORT
Base class for interactors that operate on DataNodes.
Central node class of the MITK data tree, associating a data object with properties and mappers.
Definition: mitkDataNode.h:72
Data interactor for manipulating object geometry via a Gizmo widget.
mitkClassMacro(GizmoInteractor, DataInteractor)
void SetManipulatedObjectNode(DataNode *node)
Set the DataNode whose geometry shall be manipulated.
void SetGizmoNode(DataNode *node)
Set the DataNode that holds the Gizmo for visual feedback.
HandleType
Enumeration of interactive handle types for the gizmo.
Definition: mitkGizmo.h:77
@ NoHandle
Indicates that no handle was picked.
Definition: mitkGizmo.h:88
Base class for all interaction events in MITK.
Super class for all position-aware interaction events.
Represents an action that is executed after a certain event in the state machine mechanism.
Find image slices visible on a given plane.