[vtkusers] vtk widgets start on specified point
Vincent LEFORT
vincent.lefort at aquilab.com
Thu Feb 2 10:05:26 EST 2012
Hello,
I'm trying to use vtk widgets (vtkDistanceWidget, vtkAngleWidget,...) in a software.
I have a vtkInteractorStyle on my vtkRenderWindowInteractor and I try to make a vtkDistanceWidget inside my vtkInteractorStyle and define the first point to a specified X and Y value.
The code :
vtkPointHandleRepresentation2D* pointHandle = vtkPointHandleRepresentation2D::New();
pointHandle->GetProperty()->SetColor(1,0,1);
vtkDistanceRepresentation2D* representation = vtkDistanceRepresentation2D::New();
representation->SetTolerance(15);
representation->SetHandleRepresentation(pointHandle) ;
representation->InstantiateHandleRepresentation();
distanceWidgetMem = vtkDistanceWidget::New();
distanceWidgetMem->SetInteractor(interactor) ;
distanceWidgetMem->SetRepresentation(representation);
distanceWidgetMem->CreateDefaultRepresentation();
distanceWidgetMem->On();
With this code, the next time i will press on left button, the widget will be shown and run as wanted. But I wanted to set the first point to my X, Y directly.
One method is to call (after the On) :
interactor->SetEventInformation(event.newX,event.newY);
interactor->InvokeEvent(vtkCommand::LeftButtonPressEvent);
But it's not a very good solution to fake an event and call this event twice...
Thanks.
Vincent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120202/a3b699f3/attachment.htm>
More information about the vtkusers
mailing list