[vtkusers] location of movable component

Jorge Perez josp.jorge at gmail.com
Mon Dec 16 04:46:06 EST 2013

Hi, you can use vtkHandleWidget


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

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>

> Hello,
> 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 )?
> Thanks,
> Silviu
> 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
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131216/c128183e/attachment.htm>

More information about the vtkusers mailing list