[vtkusers] ContourWidget + qvtkWidget [QVTKInteractor]

agatte agatakrason at gmail.com
Sat Feb 8 17:05:17 EST 2014


Hello,

I have a big problem concening QVTKinteractor.

I followed examples from VTK wiki :
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PolygonalSurfaceContourLineInterpolator
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt/RenderWindowUISingleInheritance

I am trying to add vtkContourWidget to  qvtkWidget.

I always receive an error message concerning : QVTKInteractor can not
control event loop.
I don't know why it doesn't work ?

What I am doing wrong ?

Could You look at my code ?
Could You advice me something ?

 *ui->qvtkWidget->GetRenderWindow()->AddRenderer(renderer);
  ui->qvtkWidget->GetRenderWindow()->Render();
  contourWidget->EnabledOn();
  ui->qvtkWidget->GetInteractor()->Start(); // ????
  contourWidget->On();
 *
// Constructor
RenderWindowUISingleInheritance::RenderWindowUISingleInheritance() 
{
  this->ui = new Ui_RenderWindowUISingleInheritance;
  this->ui->setupUi(this);
 
  vtkSmartPointer<vtkSphereSource> sphereSource =
vtkSmartPointer<vtkSphereSource>::New();
  sphereSource->SetRadius(5);
  sphereSource->Update();
 
  vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInputConnection(sphereSource->GetOutputPort());
 
  vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);
 
  // Create the RenderWindow, Renderer
  vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
  renderer->AddActor(actor);
 
  // Here comes the contour widget
  vtkSmartPointer<vtkContourWidget> contourWidget =
vtkSmartPointer<vtkContourWidget>::New();
  contourWidget->SetInteractor(ui->qvtkWidget->GetInteractor());

  vtkSmartPointer<vtkOrientedGlyphContourRepresentation> rep =
vtkOrientedGlyphContourRepresentation::SafeDownCast(
  contourWidget->GetRepresentation());
  rep->GetLinesProperty()->SetColor(1, 0.2, 0);
  rep->GetLinesProperty()->SetLineWidth(1.0);
 
  vtkSmartPointer<vtkPolygonalSurfacePointPlacer> pointPlacer =
vtkSmartPointer<vtkPolygonalSurfacePointPlacer>::New();
  pointPlacer->AddProp(actor);
  pointPlacer->GetPolys()->AddItem( sphereSource->GetOutput());
  rep->SetPointPlacer(pointPlacer);
 
  vtkSmartPointer<vtkPolygonalSurfaceContourLineInterpolator> interpolator =
vtkSmartPointer<vtkPolygonalSurfaceContourLineInterpolator>::New();
  interpolator->GetPolys()->AddItem(  sphereSource->GetOutput() );
  rep->SetLineInterpolator(interpolator);

  ui->qvtkWidget->GetRenderWindow()->AddRenderer(renderer);
  ui->qvtkWidget->GetRenderWindow()->Render();
  contourWidget->EnabledOn();
  ui->qvtkWidget->GetInteractor()->Start(); // ????
  contourWidget->On();

  // Set up action signals and slots
  connect(this->ui->actionExit, SIGNAL(triggered()), this,
SLOT(slotExit()));
 
}


I  would appreciate for any help please.



--
View this message in context: http://vtk.1045678.n5.nabble.com/ContourWidget-qvtkWidget-QVTKInteractor-tp5725818.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list