0

I'm new to pcl and Qt I want to add vtkBoxWidget2 to pclVisulaizer in Qt :

So far, the main parts of the code looks something like this :

pclVisualizer(new pcl::visualization::PCLVisualizer("PCL Visualizer", 
 false));

  // position of the vtkBoxWidget2
  double pos_a[6]={0,10,0,10,0,10};

  vtkSmartPointer<vtkBoxWidget2>box=vtkSmartPointer<vtkBoxWidget2>::New();

  // Set up user interface
  ui->setupUi(this);

  // add qvtkwidget to main windows
  qvtkWidget_pclViewer = new QVTKWidget;

  ui->splitterVertical->addWidget(qvtkWidget_pclViewer);
  qvtkWidget_pclViewer->SetRenderWindow(pclVisualizer->getRenderWindow());
  pclVisualizer->setupInteractor(qvtkWidget_pclViewer->GetInteractor(), 
  qvtkWidget_pclViewer->GetRenderWindow());

  pclVisualizer->setBackgroundColor(0, 0, 0);
  pclVisualizer->addCoordinateSystem(1.0);


  box->SetInteractor(qvtkWidget_pclViewer->GetInteractor());
  box->GetRepresentation()->SetPlaceFactor(1);
  box->GetRepresentation()->PlaceWidget(pos_a);
  box->On();
  qvtkWidget_pclViewer->update();

the code is running and I can see the coordinates I created but the box is not showing at all

any help would be appreciated

Tamim Boubou
  • 75
  • 11
  • I am not sure if this is related to your problem. But anyway,The `vtkBoxWidget2` object you are storing in the smart pointer `box` gets destructed as soon as the function you are posting (most likely a `QWidget`'s constructor) returns. Maybe you meant to store `box` as a member variable instead? (the same way you are dealing with `pclVisualizer`) – Mike Jan 18 '18 at 20:33
  • tried your suggestion but didn't work either ....thanks anyway @Mike – Tamim Boubou Jan 22 '18 at 08:08

0 Answers0