MCPcopy Create free account
hub / github.com/Kitware/VTK / Rotate

Method Rotate

Interaction/Style/vtkInteractorStyleTrackballActor.cxx:204–292  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

202
203//------------------------------------------------------------------------------
204void vtkInteractorStyleTrackballActor::Rotate()
205{
206 if (this->CurrentRenderer == nullptr || this->InteractionProp == nullptr)
207 {
208 return;
209 }
210
211 vtkRenderWindowInteractor* rwi = this->Interactor;
212 vtkCamera* cam = this->CurrentRenderer->GetActiveCamera();
213
214 // First get the origin of the assembly
215 double* obj_center = this->InteractionProp->GetCenter();
216
217 // GetLength gets the length of the diagonal of the bounding box
218 double boundRadius = this->InteractionProp->GetLength() * 0.5;
219
220 // Get the view up and view right vectors
221 double view_up[3], view_look[3], view_right[3];
222
223 cam->OrthogonalizeViewUp();
224 cam->ComputeViewPlaneNormal();
225 cam->GetViewUp(view_up);
226 vtkMath::Normalize(view_up);
227 cam->GetViewPlaneNormal(view_look);
228 vtkMath::Cross(view_up, view_look, view_right);
229 vtkMath::Normalize(view_right);
230
231 // Get the furtherest point from object position+origin
232 double outsidept[3];
233
234 outsidept[0] = obj_center[0] + view_right[0] * boundRadius;
235 outsidept[1] = obj_center[1] + view_right[1] * boundRadius;
236 outsidept[2] = obj_center[2] + view_right[2] * boundRadius;
237
238 // Convert them to display coord
239 double disp_obj_center[3];
240
241 this->ComputeWorldToDisplay(obj_center[0], obj_center[1], obj_center[2], disp_obj_center);
242
243 this->ComputeWorldToDisplay(outsidept[0], outsidept[1], outsidept[2], outsidept);
244
245 double radius = sqrt(vtkMath::Distance2BetweenPoints(disp_obj_center, outsidept));
246 double nxf = (rwi->GetEventPosition()[0] - disp_obj_center[0]) / radius;
247
248 double nyf = (rwi->GetEventPosition()[1] - disp_obj_center[1]) / radius;
249
250 double oxf = (rwi->GetLastEventPosition()[0] - disp_obj_center[0]) / radius;
251
252 double oyf = (rwi->GetLastEventPosition()[1] - disp_obj_center[1]) / radius;
253
254 if (((nxf * nxf + nyf * nyf) <= 1.0) && ((oxf * oxf + oyf * oyf) <= 1.0))
255 {
256 double newXAngle = vtkMath::DegreesFromRadians(asin(nxf));
257 double newYAngle = vtkMath::DegreesFromRadians(asin(nyf));
258 double oldXAngle = vtkMath::DegreesFromRadians(asin(oxf));
259 double oldYAngle = vtkMath::DegreesFromRadians(asin(oyf));
260
261 double scale[3];

Callers 1

OnMouseMoveMethod · 0.95

Calls 14

Prop3DTransformMethod · 0.95
GetActiveCameraMethod · 0.80
OrthogonalizeViewUpMethod · 0.80
GetViewUpMethod · 0.80
ComputeWorldToDisplayMethod · 0.80
RenderMethod · 0.65
NormalizeFunction · 0.50
CrossFunction · 0.50
sqrtFunction · 0.50
asinFunction · 0.50
GetCenterMethod · 0.45

Tested by

no test coverage detected