[vtkusers] Overriding QVTKWidget interactor style
Elvis Stansvik
elvis.stansvik at orexplore.com
Tue Feb 21 10:37:08 EST 2017
2017-02-21 16:13 GMT+01:00 Mwoua <david.levy at leddartech.com>:
> Hello,
> im new to VTK and I can't find a way to override the interactor style to
> remap keyboard event. I'm using the point cloud library viewer, but I think
> my issue is related to the QVTKWidget.
>
> Here is my code :
>
> boost::shared_ptr<pcl::visualization::PCLVisualizer> mViewer;
> QVTKWidget *mVTKWidget;
>
> // Set up the QVTK window
> mViewer =
> boost::make_shared<pcl::visualization::PCLVisualizer>("viewer", false);
> mVTKWidget->SetRenderWindow (mViewer->getRenderWindow ());
> auto lInteractor = mVTKWidget->GetInteractor ();
> auto lInteractorStyle = CustomInteractor::New();
> lInteractor->SetInteractorStyle(lInteractorStyle);
> mViewer->setupInteractor (lInteractor, mVTKWidget->GetRenderWindow ());
^ this line will reset the interactor to the default style, so it'll
overwrite what you set earlier. Use this overload instead [2]:
void pcl::visualization::PCLVisualizer::setupInteractor (
vtkRenderWindowInteractor * iren, vtkRenderWindow * win,
vtkInteractorStyle * style )
E.g:
mViewer->setupInteractor (lInteractor, mVTKWidget->GetRenderWindow
(), lInteractorStyle);
With that, I don't think you need to do
lInteractor->SetInteractorStyle(lInteractorStyle). It will be done for
you by setupInteractor [3].
Hope that helps,
Elvis
[1] http://docs.pointclouds.org/trunk/classpcl_1_1visualization_1_1_p_c_l_visualizer.html#a9f2ab0047663bcd23e48cf39b74145de
[2] http://docs.pointclouds.org/trunk/classpcl_1_1visualization_1_1_p_c_l_visualizer.html#a26b785bcbdf1aaec1db1e1cfa15aa5f4
[3] https://github.com/PointCloudLibrary/pcl/blob/master/visualization/src/pcl_visualizer.cpp#L377
>
> mVTKWidget->update ();
>
> And my custom interactor just to try things :
> class CustomInteractor : public
> pcl::visualization::PCLVisualizerInteractorStyle
> {
> void OnChar() override {}
> void OnKeyDown ()override {}
> void OnKeyUp ()override {}
> };
>
>
> PCLVisualizerInteractorStyle inherits from vtkInteractorStyleRubberBandPick.
>
> I might be missing something easy, but im out of idea.
>
> Thanks
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Overriding-QVTKWidget-interactor-style-tp5742264.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list