Picking always returns ViewBox

133 views
Skip to first unread message

Pradeep J

unread,
Aug 17, 2015, 6:01:53 AM8/17/15
to vispy
Trying out vispy as I am in need of a scenegraph implementation.
I expected the below code to return the SphereVisual/XYZAxisVisual when I click on it, but I always get a ViewBox instead.

c = scene.SceneCanvas(keys='interactive', show=True)

view
= c.central_widget.add_view()
view
.camera = 'arcball'

scene
.Sphere(radius=0.5, parent=view.scene)
scene
.visuals.XYZAxis(parent=view.scene)

@c.connect
def on_mouse_press(event):
   
print c.visual_at(event.pos)


always prints:

<ViewBox at 0x55518f0>

I am guessing this some newbie mistake on my part, what is the right way to use visual_at() for picking visuals?

Thanks.


Luke Campagnola

unread,
Aug 22, 2015, 10:23:41 AM8/22/15
to Vispy list
Most visuals are not interactive by default; you need to set `visual.interactive = True` for each visual that you want to be pickable. However, in this case it seems to fail even when I do that for the sphere. Can you open an issue for this?

--
You received this message because you are subscribed to the Google Groups "vispy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vispy+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pradeep J

unread,
Aug 23, 2015, 8:48:11 PM8/23/15
to vispy
Thanks Luke, I'll file an issue.

Evan

unread,
Nov 27, 2015, 5:05:57 PM11/27/15
to vispy
A workaround is to temporarily make the view not interactive :

@c.connect
def on_mouse_press(event):
   view.interactive = False
   
print c.visual_at(event.pos)
   view.interactive = True


Best regards,

Evan
Reply all
Reply to author
Forward
0 new messages