[vtkusers] [Help please] QVTKInteractor

agatte agatakrason at gmail.com
Sat Jan 25 15:34:31 EST 2014


Hi all vtk - Users,

I have a problem w QVTKInteractor. 
I  received an error : QVTKInteractor cannot control the event loop

I don't know exactly what's  wrong in my code.
I followed qt example from VTK wiki .
I am trying to add widget.

Could someone look at this code  please ?

// Constructor
RenderWindowUISingleInheritance::RenderWindowUISingleInheritance() 
{
  this->ui = new Ui_RenderWindowUISingleInheritance;
  this->ui->setupUi(this);

     vtkSmartPointer<vtkXMLPolyDataReader> readerIcon
=vtkSmartPointer<vtkXMLPolyDataReader>::New();
     readerIcon->SetFileName("Bunny.vtp");
 
    vtkSmartPointer<vtkDataSetMapper> iconMapper =
vtkSmartPointer<vtkDataSetMapper>::New();
    iconMapper->SetInputConnection(readerIcon->GetOutputPort());
 
    vtkSmartPointer<vtkActor> iconActor = vtkSmartPointer<vtkActor>::New();
    iconActor->SetMapper(iconMapper);

	 vtkSmartPointer<vtkRenderWindowInteractor> interactor =
this->ui->qvtkWidget->GetInteractor();

	vtkSmartPointer<vtkOrientationMarkerWidget> iconWidget =
vtkSmartPointer<vtkOrientationMarkerWidget>::New();
	iconWidget->SetInteractor(interactor);
    iconWidget->SetOutlineColor( 0.9300, 0.5700, 0.1300 );
    iconWidget->SetOrientationMarker( iconActor );
    iconWidget->SetViewport( 0.0, 0.0, 0.2, 0.2 );
    iconWidget->SetEnabled( 1 );
    iconWidget->InteractiveOn();
 
  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);
 
  vtkSmartPointer<vtkContourWidget> contourWidget = 
vtkSmartPointer<vtkContourWidget>::New();
  contourWidget->SetInteractor(interactor);
 
  vtkSmartPointer<MyCallback> callback = vtkSmartPointer<MyCallback>::New();
  callback->SetSphereSource(sphereSource);
  contourWidget->AddObserver(vtkCommand::InteractionEvent,callback);
 
  vtkOrientedGlyphContourRepresentation* rep =
vtkOrientedGlyphContourRepresentation::SafeDownCast(
  contourWidget->GetRepresentation());
 
  vtkSmartPointer<vtkPolygonalSurfacePointPlacer> pointPlacer =
vtkSmartPointer<vtkPolygonalSurfacePointPlacer>::New();
  pointPlacer->AddProp(actor);
  pointPlacer->GetPolys()->AddItem(sphereSource->GetOutput());
 
  rep->GetLinesProperty()->SetColor(1, 0, 0);
  rep->GetLinesProperty()->SetLineWidth(3.0);
  rep->SetPointPlacer(pointPlacer);

  this->ui->qvtkWidget->GetRenderWindow()->AddRenderer(renderer);

  contourWidget->EnabledOn();
  renderer->ResetCamera();
 
  interactor->Initialize();
  interactor->Start();

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


I would appreciate for any help/advice please.

agatte



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


More information about the vtkusers mailing list