pclVislizer with vtk and Qt

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

pclVislizer with vtk and Qt

Tamim
Hello all,

I'm new to pcl and Qt as well so I don't know if this is a simple question.

I've been trying to combine between pclVisulizer , vtkBoxWidget2 and
QVTKWidget

The goal is to add a box widget to the QVTKWidget using pclVisulizer

So far, the main part of the code is something like this :

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

  ui->setupUi(this);

  ui->slider_frame->setEnabled(false);
  ui->slider_tracklet->setEnabled(false);

  // add qvtkwidget to main window
  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);

  double pos[6]={20,60,20,80,20,90};
  vtkSmartPointer<vtkBoxWidget2> box=vtkSmartPointer<vtkBoxWidget2>::New();

  auto shapeActorMap = pclVisualizer->getShapeActorMap();
      auto cubeIt = shapeActorMap->find("cube");
      if (cubeIt == shapeActorMap->end())
      {
        throw std::runtime_error("could not find cube");
      }

  vtkSmartPointer<vtkActor> cube = vtkActor::SafeDownCast(cubeIt->second);

  box->SetInteractor(pclVisualizer->getRenderWindow()->GetInteractor());
  box->GetRepresentation()->SetPlaceFactor(1);
  box->GetRepresentation()->PlaceWidget(cube->GetBounds());
  box->On();



and its running without any errors...but also, the box is not showing.
(I've tried : update(),render(),start(), updatecamera(),spin(),spinOnce()
functions but no result)

I've tried to add a cube and add the box to bound it with the following
code(although I didn't understand all of it ) and some editing of the above
one :

pclVisualizer->addCube({0, 0, 0}, {0, 0, 0, 1}, 10, 10, 10);
auto shapeActorMap = pclVisualizer->getShapeActorMap();
    auto cubeIt = shapeActorMap->find("cube");
    if (cubeIt == shapeActorMap->end())
    {
      throw std::runtime_error("could not find cube");
    }

    vtkSmartPointer<vtkActor> cube = vtkActor::SafeDownCast(cubeIt->second);

   box->GetRepresentation()->PlaceWidget(cube->GetBounds());

The cube is displayed but the boxWidget is not


Also, as I understood,the pclVisulizer has an internal RenderWindow....does
this window has it's own
interactor or I have to add the interactor from vtk myslef ?

I'm using Qt 5.7  with pcl 1.8.1

any help or explanation to anything would be great !
Thanks a lot  




--
Sent from: http://www.pcl-users.org/
_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users
Reply | Threaded
Open this post in threaded view
|

Re: pclVislizer with vtk and Qt

Sérgio Agostinho


On 17-01-2018 09:52, Tamim wrote:
>
> Also, as I understood,the pclVisulizer has an internal RenderWindow....does
> this window has it's own
> interactor or I have to add the interactor from vtk myslef ?
It can have or not. The PCLVisualizer allows you to specify if you want
to create one upon construction an there are methods to pass your own if
you want.

Cheers



_______________________________________________
[hidden email] / http://pointclouds.org
http://pointclouds.org/mailman/listinfo/pcl-users

signature.asc (836 bytes) Download Attachment