[vtkusers] QVTKInteractor Can not control event loop
agatte
agatakrason at gmail.com
Sat Feb 1 05:57:39 EST 2014
Hello !
I am trying to add contourwidget (pointplacer) to qvtkWidget.
I received an error concering *QVTKInteractor cannot control the event
loop.*
I don't know what is wrong in my code.
I followed examples from VTK wiki (PolygonalSurfacePointPlacer, vtk+qt).
// 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);
vtkSmartPointer<vtkRenderWindowInteractor> interactor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor = ui->qvtkWidget->GetInteractor();
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);
vtkSmartPointer<vtkRenderWindow> renwin =
vtkSmartPointer<vtkRenderWindow>::New();
renwin->AddRenderer(renderer);
ui->qvtkWidget->SetRenderWindow(renwin);
// renwin->SetInteractor(ui->qvtkWidget->GetInteractor());
//ui->qvtkWidget->GetInteractor()->SetRenderWindow(renwin);
interactor->SetRenderWindow(renwin);
contourWidget->EnabledOn();
renderer->ResetCamera();
renwin->SetInteractor(interactor);
// ui->qvtkWidget->GetRenderWindow()->Render();
// ui->qvtkWidget->GetInteractor()->Initialize();
// ui->qvtkWidget->GetInteractor()->Start();
renwin->Render();
interactor->Initialize();
interactor->Start();
}
I would appreciate for any help please.
agatte
--
View this message in context: http://vtk.1045678.n5.nabble.com/QVTKInteractor-Can-not-control-event-loop-tp5725741.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list