[vtkusers] How to move points interactively, vtkHandleWidget

Karthik Krishnan karthik.krishnan at kitware.com
Mon Oct 20 11:40:05 EDT 2008


Assuming you know that points ID, set the point's world position
according to the API in vtkUnstructuredGrid in response to interaction
changes from the handle widget.

On Mon, Oct 20, 2008 at 5:39 AM, Dirk Fressmann
<dirk.fressmann at dynamore.de> wrote:
>
> I still have to move a single node from the vtkPoints class (used by
> vtkUnstructuredGrid), according to widgetRep->GetWorldPosition(). I guess I
> have to define a filter vtkTransformFilter, but how can I add a single node,
> which actually is not an object?
>
> Thanks in advance
> Dirk
>
>
>
> Karthik Krishnan wrote:
>>
>> You can get it from the representation...
>> as in    widgetRep->GetWorldPosition( pos );
>>
>> Dirk Fressmann wrote:
>>>
>>> Oh thanks that helped :-) I figured out how to use it and got the sphere
>>> on the screen. But how do I get the new position (after translation) in
>>> world coordinates?
>>>
>>> Thanks in advance
>>> Cheers Dirk
>>>
>>>
>>>
>>> Karthik Krishnan wrote:
>>>>
>>>> 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
>>>>>
>>>>
>>>>
>>>>
>>>
>>
>
> --
> DYNAmore - Gesellschaft fuer Ingenieurdienstleistungen mbH
> Dirk Fressmann, Dr.-Ing.
> Industriestrasse 2
> D-70565 Stuttgart-Vaihingen
> --------------------------------------------------------------------
> Tel             +49 (0)711 - 45 96 00 - 23
> Fax             +49 (0)711 - 45 96 00 - 29
> E-Mail          dirk.fressmann at dynamore.de
> Internet        www.dynamore.de
> _______________________________________________
> 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