pivy SoRayPickAction

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

pivy SoRayPickAction

Post by looo »

In the coin documentation for SoRayPickAction it is recommended to get the scene with view.getSceneManager().getSceneGraph() to have the camera-node in the path of a SoRayPickAction. I haven't found something like this in freecad. Is there a way to get the camera of the view into the traversing path?
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: pivy SoRayPickAction

Post by ickby »

Hello,

This depends on your free cad version. If you are on stable you can use the method getscnegraph() of the view3DInventorViewer to get the scene including the camera. On current master there was a change yesterday that changed this. Now the getscenegraph() method returns only the geometry scene. If you want the one with the camera you need to call getSoRenderManager().getscenegraph() on the View3DInventorViewer
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pivy SoRayPickAction

Post by looo »

Thanks, I have compiled a newer version and the SoRenderManager is working. But now another problem occurs: For the raypick I will need the ViewportRegion. Any idea where I can find it?

OS: Debian GNU/Linux unstable (sid)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.4075 (Git)
Branch: master
Hash: dfd2eb33273dd7dfb802f3cde2bd384206903685
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: pivy SoRayPickAction

Post by ickby »

GetSoRenderManager()->getViewportRegion() should work
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pivy SoRayPickAction

Post by looo »

My freecad crashed with this command. (GUI.ActiveDocument.ActiveView.getViewer(). getSoRenderManager().getViewportRegion()) Previously I had to import soqt to get the viewportregion. Maybe there is something similuar with the new system?
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: pivy SoRayPickAction

Post by ickby »

does getViewer() return a valid object? and returns getSoRenderManager a valid object?

SoQt is not needed anymore, you will need to import coin, but I suppose that you did so already?
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: pivy SoRayPickAction

Post by wmayer »

What was your exact Python code to get the viewport with the old soqt stuff?
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pivy SoRayPickAction

Post by looo »

does getViewer() return a valid object? and returns getSoRenderManager a valid object?
the crash is happening when doing this comand: RenderManager.getViewportRegion(). No problem with the getViewer() and getSoRenderManager().
SoQt is not needed anymore, you will need to import coin, but I suppose that you did so already?
I tried both (with coin imported and withoout) but always get the crash afer doing the getViewportRegion() command and moving the mouse over the scene.
What was your exact Python code to get the viewport with the old soqt stuff
I haven't got it anymore. I will try to reproduce on another machine and post here.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pivy SoRayPickAction

Post by looo »

here is the way how I get the Viewportregion in older freecad version:

from pivy.gui import soqt
view = Gui.ActiveDocument.ActiveView
viewer = view.getViewer()
viewportregion = viewer.getViewportRegion()

Version info:

OS: Ubuntu 14.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.3989 (Git)
Branch: master
Hash: 7318a1d443c34c29b16aa44c89b371123ffc6f9f
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
SoQt version: 1.6.0a
OCC version: 6.7.1
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: pivy SoRayPickAction

Post by looo »

same error with daily build in ubuntu. after getting the viewport and moving the mouse freecad crashes.
Post Reply