File tree Expand file tree Collapse file tree 3 files changed +15
-16
lines changed Expand file tree Collapse file tree 3 files changed +15
-16
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88## Unreleased
99
1010### Added
11-
11+ * Added ` viewerinstance ` in ` compas.scene.Scene ` to support viewers context detection.
1212* Added ` compas_rhino8 ` as starting point for Rhino8 support.
1313* Added ` compas.scene.SceneObjectNode ` .
1414* Added ` compas.scene.SceneTree ` .
Original file line number Diff line number Diff line change 1- from compas .plugins import pluggable
1+ import inspect
2+ from collections import defaultdict
3+
4+ import compas
25from compas .plugins import PluginValidator
6+ from compas .plugins import pluggable
7+
38from .exceptions import NoSceneObjectContextError
49from .exceptions import SceneObjectNotRegisteredError
5- import inspect
6- import compas
7- from collections import defaultdict
810
911ITEM_SCENEOBJECT = defaultdict (dict )
1012
@@ -62,15 +64,9 @@ def is_viewer_open():
6264 bool
6365
6466 """
65- # TODO: implement [without introducing compas_view2 as a dependency..?]
66- # make the viewer app a singleton
67- # check for the exitence of an instance of the singleton
68- # if the instance exists, return True
69- # in this case, the viewer is the current context
70- # to do this without introducing compas_view2 as a dependency,
71- # creating the singleton instance should modify a class attribute of the SceneObject
72- # (or potentially a module level attribute of compas itself)
73- return False
67+ from compas .scene import Scene
68+
69+ return Scene .viewerinstance is not None
7470
7571
7672def _detect_current_context ():
Original file line number Diff line number Diff line change 11from compas .data import Data
22from compas .datastructures import Tree
33from compas .datastructures import TreeNode
4- from .sceneobject import SceneObject
5- from .context import redraw
4+
65from .context import clear
6+ from .context import redraw
7+ from .sceneobject import SceneObject
78
89
910class SceneObjectNode (TreeNode ):
@@ -201,6 +202,8 @@ class Scene(Data):
201202
202203 """
203204
205+ viewerinstance = None
206+
204207 def __init__ (self , name = None , context = None ):
205208 super (Scene , self ).__init__ (name )
206209 self ._tree = SceneTree ("Scene" )
You can’t perform that action at this time.
0 commit comments