[vtkusers] modify a text in the renderer with the mose move event

David Doria daviddoria+vtk at gmail.com
Wed Nov 18 12:35:30 EST 2009


On Wed, Nov 18, 2009 at 11:30 AM, RimAY <rim.ayari at gmail.com> wrote:
>
> Thanks for your reply,
>
> this is the function that i used:
>
> def print_text(renwinInteractor, event):
>    x1, y1 = renwinInteractor.GetEventPosition()
>    picker = vtk.vtkPointPicker()
>    picker.PickFromListOn()
>    picker.AddPickList(actorVTK)
>    picker.SetTolerance(0.01)
>    picker.Pick(x1, y1, 0, renderer)
>    pickPos = picker.GetPickPosition()
>    cellId = picker.GetPointId()
>
>    interactor.ShowCursor()
>    interactor.LightFollowCameraOn()
>
>    if cellId==-1:
>        return 0
>    else:
>        Tactorx = vtkTextActor()
>        cx = str(x1)
>        Tactorx.SetInput(cx)
>        Tactorx.SetDisplayPosition(70,175)
>        Tactorx.GetTextProperty().SetJustificationToCentered()
>        renderer.AddActor(Tactorx)
>        Tactorx.Modified()
> interactor.AddObserver('MouseMoveEvent', print_text)
>
> interactor is the vtkRenderWindowInteractor() and actorVTK is a vtkActor():
>
> readerVTK.SetFileName("vtp file")
> mapperVTK.SetInput(readerVTK.GetOutput())
> actorVTK.SetMapper(mapperVTK)
>
> Thanks


That is still not compilable.

Thanks,

David



More information about the vtkusers mailing list