17 #include "vtkCamera.h"
20 #include "vtkObjectFactory.h"
21 #include "vtkRenderWindow.h"
22 #include "vtkRenderWindowInteractor.h"
23 #include "vtkRenderer.h"
50 if (ren ==
NULL || !this->GetGUIHelper())
55 vtkCamera* camera = ren->GetActiveCamera();
57 camera->GetPosition(pos);
58 camera->GetFocalPoint(fp);
60 if (camera->GetParallelProjection())
62 camera->OrthogonalizeViewUp();
63 double* up = camera->GetViewUp();
64 double* vpn = camera->GetViewPlaneNormal();
67 camera->GetViewUp(up);
68 camera->GetViewPlaneNormal(vpn);
72 int*
size = ren->GetSize();
73 double dx = (double)(
x - rwi->GetLastEventPosition()[0]) / (
double)(
size[1]);
74 double dy = (double)(rwi->GetLastEventPosition()[1] -
y) / (
double)(
size[1]);
76 scale = camera->GetParallelScale();
80 tmp = (right[0] * dx + up[0] * dy);
83 tmp = (right[1] * dx + up[1] * dy);
86 tmp = (right[2] * dx + up[2] * dy);
89 camera->SetPosition(pos);
90 camera->SetFocalPoint(fp);
94 double depth, worldPt[4], lastWorldPt[4];
95 double bounds[6], center[3];
96 if (this->GetGUIHelper()->GetActiveSourceBounds(bounds))
99 for (idx = 0; idx < 3; idx++)
101 center[idx] = (bounds[idx * 2] + bounds[idx * 2 + 1]) / 2.0;
103 ren->SetWorldPoint(center[0], center[1], center[2], 1.0);
107 if (this->GetGUIHelper()->GetCenterOfRotation(center))
109 ren->SetWorldPoint(center[0], center[1], center[2], 1.0);
113 ren->WorldToDisplay();
114 depth = ren->GetDisplayPoint()[2];
116 ren->SetDisplayPoint(
x,
y, depth);
117 ren->DisplayToWorld();
118 ren->GetWorldPoint(worldPt);
121 worldPt[0] /= worldPt[3];
122 worldPt[1] /= worldPt[3];
123 worldPt[2] /= worldPt[3];
127 ren->SetDisplayPoint(rwi->GetLastEventPosition()[0], rwi->GetLastEventPosition()[1], depth);
128 ren->DisplayToWorld();
129 ren->GetWorldPoint(lastWorldPt);
132 lastWorldPt[0] /= lastWorldPt[3];
133 lastWorldPt[1] /= lastWorldPt[3];
134 lastWorldPt[2] /= lastWorldPt[3];
135 lastWorldPt[3] = 1.0;
138 pos[0] += lastWorldPt[0] - worldPt[0];
139 pos[1] += lastWorldPt[1] - worldPt[1];
140 pos[2] += lastWorldPt[2] - worldPt[2];
142 fp[0] += lastWorldPt[0] - worldPt[0];
143 fp[1] += lastWorldPt[1] - worldPt[1];
144 fp[2] += lastWorldPt[2] - worldPt[2];
146 camera->SetPosition(pos);
147 camera->SetFocalPoint(fp);
155 this->Superclass::PrintSelf(os, indent);
void OnButtonDown(int x, int y, vtkRenderer *ren, vtkRenderWindowInteractor *iren) override
void OnButtonUp(int x, int y, vtkRenderer *ren, vtkRenderWindowInteractor *iren) override
void OnMouseMove(int x, int y, vtkRenderer *ren, vtkRenderWindowInteractor *iren) override
void PrintSelf(ostream &os, vtkIndent indent) override
~vtkPVTrackballPan() override
CLOUDVIEWER_HOST_DEVICE float Cross(const Point &a, const Point &b)
vtkStandardNewMacro(vtkPVTrackballPan)