Open crasbe opened 6 years ago
Using a custom interactor style via setupInteractor from PCLVisualizer does not work either, because the only interactors which can be loaded have to inherit from PCLVisualizerInteractorStyle.
Quick work around so you don't get blocked. The idea is that your custom interactor should inherit from PCLVisualizerInteractorStyle
. With this approach you can define an interactor whose sole purpose is to expose "OnChar, OnKeyDown, OnKeyUp, OnMouseMove, OnLeftButtonDown, OnLeftButtonUp, OnMiddleButtonDown, OnMiddleButtonUp, OnRightButtonDown, OnRightButtonUp, OnMouseWheelForward, OnMouseWheelBackward, OnTimer, zoomIn and zoomOut" into a public scope.
I'm not sure how useful the On...
functions are for the user code. Internally they typically query Interactor
about the position of the event. The user code can not set the position, so why triggering the handlers? Having said that, I nevertheless support making the functions consistent with the base class, i.e. marking them public
.
Your Environment
Context
The member functions OnChar, OnKeyDown, OnKeyUp, OnMouseMove, OnLeftButtonDown, OnLeftButtonUp, OnMiddleButtonDown, OnMiddleButtonUp, OnRightButtonDown, OnRightButtonUp, OnMouseWheelForward, OnMouseWheelBackward, OnTimer, zoomIn and zoomOut are protected in PCLVisualizerInteractorStyle.
In my case, I want to control the QVTKWidget by buttons in a QT GUI including a zoom feature which could conveniently be implemented by accessing zoomIn and zoomOut.
PCLVisualizerInteractorStyle inherits from vtkInteractorStyleRubberBandPick, where the member functions above are public, so for me there is no apparent reason why they should be protected. Using a custom interactor style via setupInteractor from PCLVisualizer does not work either, because the only interactors which can be loaded have to inherit from PCLVisualizerInteractorStyle.
Reimplementing the behaviour of zoomIn and zoomOut by accessing the interactor style via getInteractorStyle() is not possible as well because void vtkInteractorStyleTrackballCamera::Dolly(double factor) from VTK is a protected function as well.
Expected Behavior
The member functions listed above should be public to be able to access them from user programs which try to alter the behaviour of the PCLVisualizer. There is no apparent reason why they should be protected, because they cannot leak any information or could be used in a malicious way.
The described behaviour has not been changed in master.
Possible Solution
Make "OnChar, OnKeyDown, OnKeyUp, OnMouseMove, OnLeftButtonDown, OnLeftButtonUp, OnMiddleButtonDown, OnMiddleButtonUp, OnRightButtonDown, OnRightButtonUp, OnMouseWheelForward, OnMouseWheelBackward, OnTimer, zoomIn and zoomOut" public instead of protected.