[vtkusers] Question ? ContourWidget Qt+VTK
agatte
agatakrason at gmail.com
Wed Jan 22 15:06:03 EST 2014
Hi,
I am trying to make contour Widget.
I followed PolygonalSurfacePointPlacer and RenderWindowUISingleInheritance
example from VTK wiki :
http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/vtkPolygonalSurfacePointPlacer
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Qt/RenderWindowUISingleInheritance
I can not clicked on sphere. It doesn't work.
I have a problem with interactor and qvtkwidget.
Could You look at my code ?
I received an error concerning :
ERROR: In ..\..\..\GUISupport\Qt\QVTKInteractor.cxx, line 147
QVTKInteractor (0B18A530): QVTKInteractor cannot control the event loop.
// 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);
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
renderer->AddActor(actor);
vtkSmartPointer<vtkContourWidget> contourWidget =
vtkSmartPointer<vtkContourWidget>::New();
contourWidget->SetInteractor(this->ui->qvtkWidget->GetInteractor());
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();
* this->ui->qvtkWidget->GetRenderWindow()->Render(); // ??
this->ui->qvtkWidget->GetInteractor()->Initialize(); // ??
this->ui->qvtkWidget->GetInteractor()->Start(); // Here ?? *
// 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/Question-ContourWidget-Qt-VTK-tp5725546.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list