MCPcopy Create free account
hub / github.com/MITK/MITK / DecideInteraction

Method DecideInteraction

Modules/Gizmo/src/mitkGizmoInteractor.cpp:111–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111void mitk::GizmoInteractor::DecideInteraction(StateMachineAction *, InteractionEvent *interactionEvent)
112{
113 assert(m_PickedHandle != Gizmo::NoHandle);
114
115 auto positionEvent = dynamic_cast<const InteractionPositionEvent *>(interactionEvent);
116 if (positionEvent == nullptr)
117 {
118 return;
119 }
120
121 // if something relevant was picked, we calculate a number of
122 // important points and axes for the upcoming geometry manipulations
123
124 // note initial state
125 m_InitialClickPosition2D = positionEvent->GetPointerPositionOnScreen();
126 m_InitialClickPosition3D = positionEvent->GetPositionInWorld();
127
128 auto renderer = positionEvent->GetSender()->GetVtkRenderer();
129 renderer->SetWorldPoint(m_InitialClickPosition3D[0], m_InitialClickPosition3D[1], m_InitialClickPosition3D[2], 0);
130 renderer->WorldToDisplay();
131 m_InitialClickPosition2DZ = renderer->GetDisplayPoint()[2];
132
133 m_InitialGizmoCenter3D = m_Gizmo->GetCenter();
134 positionEvent->GetSender()->WorldToDisplay(m_InitialGizmoCenter3D, m_InitialGizmoCenter2D);
135
136 m_InitialManipulatedObjectGeometry = m_ManipulatedObjectGeometry->Clone();
137
138 switch ( m_PickedHandle ) {
139 case Gizmo::MoveAlongAxisX:
140 case Gizmo::RotateAroundAxisX:
141 case Gizmo::ScaleX:
142 m_AxisOfMovement = m_InitialManipulatedObjectGeometry->GetAxisVector(0);
143 break;
144 case Gizmo::MoveAlongAxisY:
145 case Gizmo::RotateAroundAxisY:
146 case Gizmo::ScaleY:
147 m_AxisOfMovement = m_InitialManipulatedObjectGeometry->GetAxisVector(1);
148 break;
149 case Gizmo::MoveAlongAxisZ:
150 case Gizmo::RotateAroundAxisZ:
151 case Gizmo::ScaleZ:
152 m_AxisOfMovement = m_InitialManipulatedObjectGeometry->GetAxisVector(2);
153 break;
154 default:
155 break;
156 }
157 m_AxisOfMovement.Normalize();
158 m_AxisOfRotation = m_AxisOfMovement;
159
160 // for translation: test whether the user clicked into the "object's real" axis direction
161 // or into the other one
162 Vector3D intendedAxis = m_InitialClickPosition3D - m_InitialGizmoCenter3D;
163
164 if ( intendedAxis * m_AxisOfMovement < 0 ) {
165 m_AxisOfMovement *= -1.0;
166 }
167
168 // for rotation: test whether the axis of rotation is more looking in the direction

Callers

nothing calls this directly

Calls 13

GetPositionInWorldMethod · 0.80
GetSenderMethod · 0.80
WorldToDisplayMethod · 0.80
GetCenterMethod · 0.80
GetAxisVectorMethod · 0.80
NormalizeMethod · 0.80
QueueEventMethod · 0.80
NewFunction · 0.50
GetVtkRendererMethod · 0.45
CloneMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected