16 #include <vtkRenderer.h>
17 #include <vtkRenderWindow.h>
18 #include <vtkObjectFactory.h>
19 #include <vtkOBBTree.h>
20 #include <vtkCamera.h>
28 pcl::visualization::PCLVisualizerInteractorStyle(),
31 ResetPixelDistance(0),
32 pointsHolder_(new
pcl::PointCloud<
pcl::PointXYZRGB>),
38 this->MotionFactor = 5;
43 if (this->CurrentRenderer ==
NULL)
48 vtkRenderWindowInteractor *rwi = this->Interactor;
50 int dx = rwi->GetEventPosition()[0] - rwi->GetLastEventPosition()[0];
51 int dy =
orthoMode_?0:rwi->GetEventPosition()[1] - rwi->GetLastEventPosition()[1];
53 int *
size = this->CurrentRenderer->GetRenderWindow()->GetSize();
55 double delta_elevation = -20.0 /
size[1];
56 double delta_azimuth = -20.0 /
size[0];
58 double rxf = dx * delta_azimuth * this->MotionFactor;
59 double ryf = dy * delta_elevation * this->MotionFactor;
61 vtkCamera *
camera = this->CurrentRenderer->GetActiveCamera();
67 camera->OrthogonalizeViewUp();
74 if (this->AutoAdjustCameraClippingRange)
76 this->CurrentRenderer->ResetCameraClippingRange();
79 if (rwi->GetLightFollowCamera())
81 this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
89 if (this->CurrentRenderer ==
NULL)
94 vtkCamera *
camera = CurrentRenderer->GetActiveCamera ();
96 camera->SetParallelProjection (enabled);
102 camera->SetViewUp(1, 0, 0);
104 CurrentRenderer->SetActiveCamera (
camera);
110 if(this->CurrentRenderer &&
111 this->CurrentRenderer->GetLayer() == 1 &&
112 this->GetInteractor()->GetShiftKey() &&
this->GetInteractor()->GetControlKey() &&
120 this->GetInteractor()->GetEventPosition(pickPosition);
121 int result = this->Interactor->GetPicker()->Pick(pickPosition[0], pickPosition[1],
123 this->CurrentRenderer);
127 this->Interactor->GetPicker()->GetPickPosition(picked);
129 UDEBUG(
"Control move! Picked value: %f %f %f", picked[0], picked[1], picked[2]);
131 float textSize = 0.05;
147 double pickedNormal[3];
148 cellPicker->GetPickNormal(pickedNormal);
149 double lineP0[3] = {picked[0], picked[1], picked[2]};
150 double lineP1[3] = {picked[0]+pickedNormal[0]*
length, picked[1]+pickedNormal[1]*
length, picked[2]+pickedNormal[2]*
length};
157 double previous[3] = {picked[0], picked[1], picked[2]};
158 for(
int i = 0;
i < intersectPoints->GetNumberOfPoints();
i++ )
176 Transform(previous[0]+
v[0], previous[1]+
v[1],previous[2]+
v[2], 0, 0, 0),
180 Transform(previous[0], previous[1], previous[2], 0, 0, 0),
197 PCLVisualizerInteractorStyle::OnMouseMove();
204 if(this->CurrentRenderer && this->CurrentRenderer->GetLayer() == 1)
208 this->GetInteractor()->GetEventPosition(pickPosition);
210 int ydist = pickPosition[1] - this->PreviousPosition[1];
212 this->PreviousPosition[0] = pickPosition[0];
213 this->PreviousPosition[1] = pickPosition[1];
215 int moveDistance = (
int)
sqrt((
double)(xdist*xdist + ydist*ydist));
226 int result = this->Interactor->GetPicker()->Pick(pickPosition[0], pickPosition[1],
228 this->CurrentRenderer);
229 if(
result && this->GetInteractor()->GetControlKey()==0)
232 this->Interactor->GetPicker()->GetPickPosition(picked);
233 UDEBUG(
"Double clicked! Picked value: %f %f %f", picked[0], picked[1], picked[2]);
234 vtkCamera *
camera = this->CurrentRenderer->GetActiveCamera();
239 camera->GetFocalPoint(focal[0], focal[1], focal[2]);
241 camera->SetFocalPoint (picked[0], picked[1], picked[2]);
242 camera->OrthogonalizeViewUp();
244 if (this->AutoAdjustCameraClippingRange)
246 this->CurrentRenderer->ResetCameraClippingRange();
249 if (this->Interactor->GetLightFollowCamera())
251 this->CurrentRenderer->UpdateLightsGeometryToFollowCamera();
269 else if(this->GetInteractor()->GetControlKey() &&
viewer_)
271 int result = this->Interactor->GetPicker()->Pick(pickPosition[0], pickPosition[1],
273 this->CurrentRenderer);
277 this->Interactor->GetPicker()->GetPickPosition(picked);
279 UDEBUG(
"Shift clicked! Picked value: %f %f %f", picked[0], picked[1], picked[2]);
281 float textSize = 0.05;
300 Transform(picked[0], picked[1], picked[2], 0, 0, 0),
333 PCLVisualizerInteractorStyle::OnLeftButtonDown();