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

RimAY rim.ayari at gmail.com
Wed Nov 18 11:30:42 EST 2009


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


David Doria-2 wrote:
> 
> On Wed, Nov 18, 2009 at 2:25 AM, RimAY <rim.ayari at gmail.com> wrote:
>>
>> Dear All ,
>> Can someone give me an idea how can i change a text in the renderer with
>> the
>> mouse move event.
>> I try with vtktextactor this is the part of my code:
>>
>> Tactorx = vtkTextActor()
>> Tactorx.SetInput(cx)
>> Tactorx.SetDisplayPosition(70,170)
>> Tactorx.GetTextProperty().SetJustificationToCentered()
>> renderer.AddActor(Tactorx)
>> Tactorx.Modified()
>>
>> cx change its value with the mose move, i get the new value above the
>> ancien
>> one, the result is an illegible text :(
>>
>> Thanks a lot
> 
> Can you provide the smallest compilable example of your problem?
> 
> Thanks,
> 
> David
> _______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 

-- 
View this message in context: http://old.nabble.com/modify-a-text-in-the-renderer-with-the-mose-move-event-tp26403090p26408427.html
Sent from the VTK - Users mailing list archive at Nabble.com.




More information about the vtkusers mailing list