Draft: improved IsActive behavior (#14103)

Related issue: #14061.
This commit is contained in:
Roy-043
2024-05-18 11:38:38 +02:00
committed by GitHub
parent e50ef22e7b
commit df49763d3f
12 changed files with 104 additions and 140 deletions

View File

@@ -59,19 +59,23 @@ def get_3d_view():
Returns
-------
Gui::View3DInventor
Return the current `ActiveView` in the active document or `None`.
The Active 3D View or `None`.
"""
if App.GuiUp:
# FIXME The following two imports were added as part of PR4926
# Also see discussion https://forum.freecad.org/viewtopic.php?f=3&t=60251
import FreeCADGui as Gui
from pivy import coin
if Gui.ActiveDocument:
v = Gui.ActiveDocument.ActiveView
if "View3DInventor" in str(type(v)):
return v
if not App.GuiUp:
return None
return None
# FIXME The following two imports were added as part of PR4926
# Also see discussion https://forum.freecadweb.org/viewtopic.php?f=3&t=60251
import FreeCADGui as Gui
from pivy import coin
mw = Gui.getMainWindow()
view = mw.getActiveWindow()
if view is None:
return None
if not hasattr(view, "getSceneGraph"):
return None
return view
get3DView = get_3d_view