[vtkusers] location of movable component

Podariu, Silviu spodariu at unmc.edu
Thu Dec 19 21:07:11 EST 2013

Thank you Jorge,

I have been trying to convert the Tcl to Python; still working on it...  :)


From: Jorge Perez [josp.jorge at gmail.com]
Sent: Monday, December 16, 2013 3:46 AM
To: Podariu, Silviu
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] location of movable component

Hi, you can use vtkHandleWidget


below is a simple example in Tcl, the position is printed in standard output.

package require vtk
package require vtkinteraction

# this proc will be invoked during widget interaction
proc OnInteraction { r } {
  set pos [$r GetWorldPosition]
  puts "pos = $pos"

vtkTkRenderWidget .tkrw
::vtk::bind_tk_render_widget .tkrw

set renWin [.tkrw GetRenderWindow]

vtkRenderer ren
ren SetBackground 0.0 0.4 0.5

$renWin AddRenderer ren

# create the widget representation
vtkFixedSizeHandleRepresentation3D rep
rep SetHandleSizeInPixels 10
[rep GetProperty] SetColor 1 0 0
rep SetWorldPosition 0 0 0

# create the widget
vtkHandleWidget widget
widget SetInteractor [$renWin GetInteractor]
widget SetDefaultRenderer ren
widget SetRepresentation rep
# add the interaction observer
widget AddObserver InteractionEvent {OnInteraction rep}
after idle {widget On}

pack .tkrw -fill both -expand yes

2013/12/13 Podariu, Silviu <spodariu at unmc.edu<mailto:spodariu at unmc.edu>>


Is there a way of adding a little component in space ( point, sphere, cube ), which can be moved interactively ( with the mouse/arrows/keys ) and whose location at any time can be displayed in the terminal ( or on the renderer window itself )?


The information in this e-mail may be privileged and confidential, intended only for the use of the addressee(s) above. Any unauthorized use or disclosure of this information is prohibited. If you have received this e-mail by mistake, please delete it and immediately contact the sender.

Powered by www.kitware.com<http://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:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131220/59a7515e/attachment.htm>

More information about the vtkusers mailing list