-
Notifications
You must be signed in to change notification settings - Fork 105
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
Refinement of various scene functions #1385
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1385 +/- ##
==========================================
+ Coverage 60.21% 60.24% +0.02%
==========================================
Files 207 207
Lines 22248 22244 -4
==========================================
+ Hits 13397 13401 +4
+ Misses 8851 8843 -8 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a big chunk of commented out code in the mesh object, is that replaced by anything or just removed functionality?
Did you have the chance to verify this change also for the Grasshopper scene objects?
the commented out part is (mostly) related to labels, which i think we should handle independently from the individual types of objects in order to avoid repetition. have left it there as a reminder... |
haven't checked GH, but the default behaviour of all functionality remains the same. so i don't expect any problems... |
in any case, the removed code paths were not (obviously) accessible nor documented so i assume there is no real issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some inline comments, but the biggest prob right now is that GH mesh object doesn't work at all (I guess it needs the same refactoring regarding vertex_xyz
).
The other issue is that the removal of draw_vertexlabels
, draw_edgelabels
, draw_facelabels
, draw_vertexnormals
, draw_facenormals
is not so undocumented as mentioned. We use them pretty much every single time in workshops and intro classes to compas. I don't think it can just go away.
src/compas/scene/scene.py
Outdated
def clear_context(self, guids=None): | ||
# type: (list | None) -> None | ||
"""Clear all objects from the visualisation context.""" | ||
clear(guids) | ||
|
||
clear() | ||
def clear(self, clear_scene=True, clear_context=True): | ||
# type: (bool, bool) -> None | ||
"""Clear all objects inside the scene. | ||
|
||
def clear_objects(self): | ||
# type: () -> None | ||
"""Clear all objects inside the scene.""" | ||
Parameters | ||
---------- | ||
context : bool, optional | ||
Clear all objects from the context as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could indeed have a simple test to cover it, because the clear
/clear_context
is already not clear enough by the naming, so, at least adding a test would ensure that this is not broken in the future by accident.
@@ -215,7 +151,7 @@ def draw(self): | |||
disjoint=self.disjoint, | |||
) | |||
|
|||
# geometry.Transform(transformation_to_rhino(self.worldtransformation)) | |||
geometry.Transform(transformation_to_rhino(self.worldtransformation)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird, do you know why it was commented out and why it's needed now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scene objects can have a transformation. before it was applied through the vertex caching. now it is done explicitly here...
self._guids_vertices = guids | ||
self._guid_vertex = dict(zip(guids, vertices)) | ||
|
||
self._guids += guids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This causes an error if the scene has not been drawn at least once because self._guids
is None
. Maybe should be initialized on __init__
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha weird maybe i forgot to push this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you have a scene.draw()
before trying something like scene_object.draw_faces()
it works, but I guess it's a valid case to just draw the faces before drawing the full scene:
import compas
from compas.datastructures import Mesh
from compas.scene import Scene
from compas.colors import Color
# Load a mesh from a sample OBJ file
mesh = Mesh.from_obj(compas.get("tubemesh.obj"))
scene = Scene()
sp = scene.add(mesh)
sp.draw_faces() # this line fails if draw() is after
# drawing scene after faces causes the exception
# scene.draw()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shoud be fixed now
ok. i can put those back. it is actually not crucial for the PR |
will review and push new soon |
LGTM! but will leave @gonzalocasas to say final yes : ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! One last request though: if the draw_vertexnormals
and draw_facenormals
will remain commented out, please add their removal to the changelog
A few backwards compatible tweaks to the scene functionality, especially refinement of how things are cleared from the viz context...
What type of change is this?
Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.CHANGELOG.md
file in theUnreleased
section under the most fitting heading (e.g.Added
,Changed
,Removed
).invoke test
).invoke lint
).compas.datastructures.Mesh
.