Skip to content

Commit d14607e

Browse files
committed
documentation
1 parent e7d7b35 commit d14607e

File tree

1 file changed

+53
-6
lines changed

1 file changed

+53
-6
lines changed

src/compas/scene/scene.py

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,52 @@ def add(self, item, parent=None, **kwargs):
118118

119119
def clear_context(self, guids=None):
120120
# type: (list | None) -> None
121-
"""Clear all objects from the visualisation context."""
121+
"""Clear the visualisation context.
122+
123+
Parameters
124+
----------
125+
guids : list, optional
126+
The identifiers of the objects in the visualisation context.
127+
128+
Returns
129+
-------
130+
None
131+
132+
Notes
133+
-----
134+
If `guids=None`, this will clear all objects from the visualisation context.
135+
For example, when used in Rhino, it will remove everything from the Rhino model.
136+
This is equivalent to `compas_rhino.clear()`.
137+
138+
If `guids` is a list, only those objects in the list will be removed.
139+
140+
The method is used by `Scene.clear` to remove all objects previously drawn by the scene,
141+
without removing other model objects.
142+
143+
"""
122144
clear(guids)
123145

124146
def clear(self, clear_scene=True, clear_context=True):
125147
# type: (bool, bool) -> None
126-
"""Clear all objects inside the scene.
148+
"""Clear the scene.
127149
128150
Parameters
129151
----------
130-
context : bool, optional
131-
Clear all objects from the context as well.
152+
clear_scene : bool, optional
153+
If True, all scene objects will be removed from the scene tree.
154+
clear_context : bool, optional
155+
If True, all objects drawn by the scene in the visualisation context will be removed.
156+
157+
Returns
158+
-------
159+
None
160+
161+
Notes
162+
-----
163+
To redraw the scene, without modifying any of the other objects in the visualisation context:
164+
165+
>>> scene.clear(clear_scene=False, clear_context=True)
166+
>>> scene.draw()
132167
133168
"""
134169
guids = []
@@ -144,7 +179,13 @@ def clear(self, clear_scene=True, clear_context=True):
144179
self.clear_context(guids)
145180

146181
def draw(self):
147-
"""Draw the scene."""
182+
"""Draw the scene.
183+
184+
This will just draw all scene objects in the scene tree,
185+
without making any modifications to the visualisation context.
186+
For example, it will not remove any of the previously drawn objects.
187+
188+
"""
148189

149190
if not self.context:
150191
raise ValueError("No context detected.")
@@ -161,6 +202,12 @@ def draw(self):
161202
return drawn_objects
162203

163204
def redraw(self):
164-
"""Redraw the scene."""
205+
"""Redraw the scene.
206+
207+
This removes all previously drawn objects from the visualisation context,
208+
before drawing all scene objects in the scene tree.
209+
210+
"""
211+
165212
self.clear(clear_scene=False, clear_context=True)
166213
self.draw()

0 commit comments

Comments
 (0)