[vtkusers] Overriding QVTKWidget interactor style

Róbert Špir spir.robert at gmail.com
Tue Feb 21 10:38:43 EST 2017


Hi,
my code is

//QVTK window
modularInteractorStyle = vtkSmartPointer<ModularInteractorStyle>::New();
viewer= boost::shared_ptr<pcl::visualization::PCLVisualizer>(new
pcl::visualization::PCLVisualizer("Point Cloud Viewer",false));
this->viewer->initCameraParameters();
ui->qvtkWidget->SetRenderWindow(viewer->getRenderWindow());
viewer->setupInteractor(ui->qvtkWidget->GetInteractor(),
ui->qvtkWidget->GetRenderWindow(), modularInteractorStyle);


and then my derived class from PCLVisualizerInteractorStyle is

class ModularInteractorStyle : public
pcl::visualization::PCLVisualizerInteractorStyle {
...
void OnLeftButtonDown();
void OnKeyDown();
void OnKeyUp();
void OnMouseMove();
void OnLeftButtonUp();
void OnMouseWheelForward();
void OnMouseWheelBackward();
...

and everything works.

Robert


-----Original Message-----
From: vtkusers [mailto:vtkusers-bounces at vtk.org] On Behalf Of Mwoua
Sent: Tuesday, February 21, 2017 4:13 PM
To: vtkusers at vtk.org
Subject: [vtkusers] Overriding QVTKWidget interactor style

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 ());

    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-tp57
42264.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