[vtkusers] How to move points interactively, vtkHandleWidget

Karthik Krishnan karthik.krishnan at kitware.com
Fri Oct 17 10:28:30 EDT 2008


On Fri, Oct 17, 2008 at 10:24 AM, Dirk Fressmann
<dirk.fressmann at dynamore.de> wrote:
>
> 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

Did you take a look at the VTKTests.

Specifically the following two tests are the examples you are
looking for:

  TestSphereHandleWidget.cxx
  TestHandleWidget.cxx


> 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
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



-- 
Karthik Krishnan
R&D Engineer,
Kitware Inc.
Ph: 518 371 3971 x119
Fax: 518 371 3971



More information about the vtkusers mailing list