[vtkusers] How to move points interactively, vtkHandleWidget

Dirk Fressmann dirk.fressmann at dynamore.de
Fri Oct 17 10:24:17 EDT 2008


Hey Guys,

I have a vtkUnstructuredGrid defined and want to be able to mousepick 
certain nodes to move them in space. I found two possibilities:
- vtkPointWidget
- vtkHandleWidget/vtkPointHandleRepresentation3D or 
vtkSphererHandleRepresentation.

Especially since I want to highlight those points, which can be moved by 
the user, I think the latter one is the best method. Unfortunately I 
can't find any information or examples about this and I don't see any 
effects if I do something like this (python)

vtkHandleRepr = vtk.vtkSphereHandleRepresentation()
vtkHandleRepr.SetWorldPosition([0.0,0.0,0.0])
vtkHandleRepr.SetHandleSize(5.0)
vtkHandleRepr.SetSphereRadius(5)
vtkHandleRepr.ActiveRepresentationOn()
vtkHandleRepr.SetRenderer(ren)

vtkHandle = vtk.vtkHandleWidget()
vtkHandle.SetRepresentation(vtkHandleRepr)
vtkHandle.SetInteractor(iren)

# callback function
def _testit(object,event):
     print "hello"
vtkHandle.AddObserver("LeftButtonPressEvent", _testit)

or c++

   vtkSphereHandleRepresentation *handleRep =
     vtkSphereHandleRepresentation::New();
   double pos[3] = {0.0, 0.0, 0.0};
   handleRep->SetWorldPosition(pos);
   handleRep->SetPlaceFactor(2.5);
   handleRep->SetSphereRadius(5.0);
   handleRep->PlaceWidget(vtkActor[1]->GetBounds());
   handleRep->ActiveRepresentationOn();

   vtkHandleWidget *handleWidget = vtkHandleWidget::New();
   handleWidget->SetInteractor(iren);
   handleWidget->SetRepresentation(handleRep);

where there should be at least a sphere at position (0,0,0).
Anyone any ideas or experiences with this?

Cheers Dirk



More information about the vtkusers mailing list