Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Aug 22, 2024
1 parent e7d7b35 commit d14607e
Showing 1 changed file with 53 additions and 6 deletions.
59 changes: 53 additions & 6 deletions src/compas/scene/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,52 @@ def add(self, item, parent=None, **kwargs):

def clear_context(self, guids=None):
# type: (list | None) -> None
"""Clear all objects from the visualisation context."""
"""Clear the visualisation context.
Parameters
----------
guids : list, optional
The identifiers of the objects in the visualisation context.
Returns
-------
None
Notes
-----
If `guids=None`, this will clear all objects from the visualisation context.
For example, when used in Rhino, it will remove everything from the Rhino model.
This is equivalent to `compas_rhino.clear()`.
If `guids` is a list, only those objects in the list will be removed.
The method is used by `Scene.clear` to remove all objects previously drawn by the scene,
without removing other model objects.
"""
clear(guids)

Check warning on line 144 in src/compas/scene/scene.py

View check run for this annotation

Codecov / codecov/patch

src/compas/scene/scene.py#L144

Added line #L144 was not covered by tests

def clear(self, clear_scene=True, clear_context=True):
# type: (bool, bool) -> None
"""Clear all objects inside the scene.
"""Clear the scene.
Parameters
----------
context : bool, optional
Clear all objects from the context as well.
clear_scene : bool, optional
If True, all scene objects will be removed from the scene tree.
clear_context : bool, optional
If True, all objects drawn by the scene in the visualisation context will be removed.
Returns
-------
None
Notes
-----
To redraw the scene, without modifying any of the other objects in the visualisation context:
>>> scene.clear(clear_scene=False, clear_context=True)
>>> scene.draw()
"""
guids = []
Expand All @@ -144,7 +179,13 @@ def clear(self, clear_scene=True, clear_context=True):
self.clear_context(guids)

Check warning on line 179 in src/compas/scene/scene.py

View check run for this annotation

Codecov / codecov/patch

src/compas/scene/scene.py#L178-L179

Added lines #L178 - L179 were not covered by tests

def draw(self):
"""Draw the scene."""
"""Draw the scene.
This will just draw all scene objects in the scene tree,
without making any modifications to the visualisation context.
For example, it will not remove any of the previously drawn objects.
"""

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

def redraw(self):
"""Redraw the scene."""
"""Redraw the scene.
This removes all previously drawn objects from the visualisation context,
before drawing all scene objects in the scene tree.
"""

self.clear(clear_scene=False, clear_context=True)
self.draw()

Check warning on line 213 in src/compas/scene/scene.py

View check run for this annotation

Codecov / codecov/patch

src/compas/scene/scene.py#L212-L213

Added lines #L212 - L213 were not covered by tests

0 comments on commit d14607e

Please sign in to comment.