Get vtkRenderWindowInteractor Pointer from PCLVisualizer

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Get vtkRenderWindowInteractor Pointer from PCLVisualizer

ravijoshi
I am trying to get vtkRenderWindowInteractor pointer from PCLVisualizer.
Please see the code snippet below-

---------------------------------------
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new
pcl::PointCloud<pcl::PointXYZRGB>);
pcl::io::loadPCDFile("file.pcd", *cloud);

pcl::visualization::PCLVisualizer pc_viewer("Point Cloud Viewer");
pc_viewer.addPointCloud(cloud, "raw_cloud");
pc_viewer.initCameraParameters();
pc_viewer.getCameraParameters(argc, argv);

vtkSmartPointer<vtkRenderWindowInteractor> iren = pc_viewer.interactor_;
---------------------------------------
The above code throws following error-

/usr/include/pcl-1.7/pcl/visualization/pcl_visualizer.h:1685:52: error:
‘vtkSmartPointer<vtkRenderWindowInteractor>
pcl::visualization::PCLVisualizer::interactor_’ is protected
         vtkSmartPointer<vtkRenderWindowInteractor> interactor_;
---------------------------------------
Since, I am trying to access protected member, which is prohibited, the
above error is obvious. Can someone please tell me the way to get
vtkRenderWindowInteractor pointer from PCLVisualizer ? Something like below-

vtkRenderWindowInteractor* iren =
reinterpret_cast<pcl::visualization::PCLVisualizer*>(pc_viewer)->GetWindowInteractor();

Thank you very much!



--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: Get vtkRenderWindowInteractor Pointer from PCLVisualizer

ravijoshi
vtkRenderWindowInteractor* iren =
pc_viewer.getRenderWindow()->GetInteractor();

Worked well!



--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users