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

Method TranslateObject

Modules/DataTypesExt/src/mitkClippingPlaneInteractor3D.cpp:153–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151}
152
153void mitk::ClippingPlaneInteractor3D::TranslateObject(StateMachineAction *, InteractionEvent *interactionEvent)
154{
155 auto *positionEvent = dynamic_cast<InteractionPositionEvent *>(interactionEvent);
156 if (positionEvent == nullptr)
157 return;
158
159 double currentWorldPoint[4];
160 mitk::Point2D currentDisplayPoint = positionEvent->GetPointerPositionOnScreen();
161 vtkInteractorObserver::ComputeDisplayToWorld(interactionEvent->GetSender()->GetVtkRenderer(),
162 currentDisplayPoint[0],
163 currentDisplayPoint[1],
164 0.0, // m_InitialInteractionPickedPoint[2],
165 currentWorldPoint);
166
167 Vector3D interactionMove;
168 interactionMove[0] = currentWorldPoint[0] - m_InitialPickedWorldPoint[0];
169 interactionMove[1] = currentWorldPoint[1] - m_InitialPickedWorldPoint[1];
170 interactionMove[2] = currentWorldPoint[2] - m_InitialPickedWorldPoint[2];
171
172 Point3D origin = m_OriginalGeometry->GetOrigin();
173
174 // Get the timestep to also support 3D+t
175 int timeStep = interactionEvent->GetSender()->GetTimeStep(this->GetDataNode()->GetData());
176
177 // If data is an mitk::Surface, extract it
178 Surface::Pointer surface = dynamic_cast<Surface *>(this->GetDataNode()->GetData());
179 vtkPolyData *polyData = nullptr;
180 if (surface.IsNotNull())
181 {
182 polyData = surface->GetVtkPolyData(timeStep);
183
184 // Extract surface normal from surface (if existent, otherwise use default)
185 vtkPointData *pointData = polyData->GetPointData();
186 if (pointData != nullptr)
187 {
188 vtkDataArray *normal = polyData->GetPointData()->GetVectors("planeNormal");
189 if (normal != nullptr)
190 {
191 m_ObjectNormal[0] = normal->GetComponent(0, 0);
192 m_ObjectNormal[1] = normal->GetComponent(0, 1);
193 m_ObjectNormal[2] = normal->GetComponent(0, 2);
194 }
195 }
196 }
197
198 Vector3D transformedObjectNormal;
199 this->GetDataNode()->GetData()->GetGeometry(timeStep)->IndexToWorld(m_ObjectNormal, transformedObjectNormal);
200
201 this->GetDataNode()->GetData()->GetGeometry(timeStep)->SetOrigin(
202 origin + transformedObjectNormal * (interactionMove * transformedObjectNormal));
203
204 RenderingManager::GetInstance()->RequestUpdateAll();
205}
206
207void mitk::ClippingPlaneInteractor3D::RotateObject(StateMachineAction *, InteractionEvent *interactionEvent)
208{

Callers

nothing calls this directly

Calls 13

GetSenderMethod · 0.80
IsNotNullMethod · 0.80
GetGeometryMethod · 0.80
GetVtkRendererMethod · 0.45
GetOriginMethod · 0.45
GetTimeStepMethod · 0.45
GetDataMethod · 0.45
GetDataNodeMethod · 0.45
GetVtkPolyDataMethod · 0.45
IndexToWorldMethod · 0.45
SetOriginMethod · 0.45

Tested by

no test coverage detected