Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency with other GUIs #70

Open
alxbilger opened this issue Mar 3, 2023 · 0 comments
Open

Inconsistency with other GUIs #70

alxbilger opened this issue Mar 3, 2023 · 0 comments

Comments

@alxbilger
Copy link
Contributor

I was trying to run SOFA from a Python interpreter (no runSofa). The usual way is the following code:

import Sofa
import Sofa.Gui
root = Sofa.Core.Node("root") # Generate the root node     
scene_lib.createScene(root, config) # Create the scene graph
Sofa.Simulation.init(root) # Initialization of the scene graph

Sofa.Gui.GUIManager.Init("myscene", "imgui")
Sofa.Gui.GUIManager.createGUI(root, __file__)
Sofa.Gui.GUIManager.SetDimension(1080, 1080)
Sofa.Gui.GUIManager.MainLoop(root)

But nothing happens and no GUI appears. The script ends without error.
I added the following message: #69, to find out that the root node is not given to the GUI. Hence the GUI cannot run.

In other GUIs, the root node is given to the GUI in the Sofa.Gui.GUIManager.createGUI function, via setScene. But in ImGuiGUI::CreateGUI, setScene is not called. I tried to add it, but it has side effects and it is too early for them, leading to a crash.

A workaround is to explicitly call setScene in the python script:

import Sofa
import Sofa.Gui
root = Sofa.Core.Node("root") # Generate the root node     
scene_lib.createScene(root, config) # Create the scene graph
Sofa.Simulation.init(root) # Initialization of the scene graph

Sofa.Gui.GUIManager.Init("myscene", "imgui")
Sofa.Gui.GUIManager.createGUI(root, __file__)
Sofa.Gui.GUIManager.SetDimension(1080, 1080)
Sofa.Gui.GUIManager.SetScene(root, __file__) #  <----------------------------  HERE
Sofa.Gui.GUIManager.MainLoop(root)

It would be nice to have consistency with the other GUIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant