Override PCLVisualizerInteractorStyle mouse click
-
I m creating my application in Qt. I have integrated a 3D PCL
viewer in a QVTWidget plugin. I want to change the standard functions of user input like left mouse click on the viewer window.Following are the class details:
class SiLS : public QMainWindow, pcl::visualization::PCLVisualizerInteractorStyle { Q_OBJECT public: SiLS(QWidget *parent = nullptr); ~SiLS(); void OnLeftButtonDown() override { std::cout << "Pressed left mouse button." << std::endl; } private slots: private: Ui::SiLS *ui; protected: pcl::visualization::PCLVisualizer::Ptr viewer; }; SiLS::SiLS(QWidget *parent) : QMainWindow(parent) , ui(new Ui::SiLS) { ui->setupUi(this); // Set up the QVTK window viewer.reset (new pcl::visualization::PCLVisualizer ("viewer", false)); ui->BEV_Display->SetRenderWindow(viewer->getRenderWindow()); viewer->setupInteractor(ui->BEV_Display->GetInteractor(), ui->BEV_Display->GetRenderWindow(), SiLS::New()); ui->BEV_Display->update(); } SiLS::~SiLS() { delete ui; }
-
But after left clicking inside the window I m not getting the print statement in output.
-
After closing the application window I m getting following errors:
ERROR: In /home/suraj/VTK/VTK-7.1.1/Common/Core/vtkObject.cxx, line 156 vtkObject (0x7ffda4148b80): Trying to delete object with non-zero reference count. Generic Warning: In /home/suraj/VTK/VTK-7.1.1/Common/Core/vtkObjectBase.cxx, line 93 Trying to delete object with non-zero reference count.
Is there anything I m missing?
-
-
Hi,
@surajj4837 said in Override PCLVisualizerInteractorStyle mouse click:
class SiLS : public QMainWindow, pcl::visualization::PCLVisualizerInteractorStyle
Why the double inheritance ?
-
This might be one of the mistakes. I want to override the left click function of PCLVisualizer, which is member of SiLS class (which is the only class I have created). So I inherited the PCLVisualizerInteractorStyle which has the virtual function of left click.
-
C++ does not work like that. Create a proper subclass and then use that one for the member variable.