-
Notifications
You must be signed in to change notification settings - Fork 113
Track guids in drawn objects #1223
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
Conversation
src/compas/scene/sceneobject.py
Outdated
| ---------- | ||
| ITEM_SCENEOBJECT : dict[str, dict[Type[:class:`~compas.data.Data`], Type[:class:`~compas.scene.SceneObject`]]] | ||
| Dictionary mapping data types to the corresponding scene objects types per visualization context. | ||
| item_guids : list[object] |
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.
Or perhaps this attribute goes to SceneObject implementation of each contexts, then the name varies depends on what it is actually tracking. In compas_rhino we call it item_guids, in GH item_gemetries and in blender item_objects?
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.
why not just 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.
That was my initial attention too. But won't guids creates the confusion whether it means guids for itself or the guids for drawn entities of underlying item? I understand a possible distinction could be guid singular refers to self, guids plural refers to drawn entities. Another discussion I didn't want to go there yet is whether we should have guid for SceneObject as well. Anyway, maybe easier to discuss all this in tomorrow's meeting
|
@tomvanmele Ok this is ready for review. The tracking for |
src/compas/scene/sceneobject.py
Outdated
| @staticmethod | ||
| def draw_collection(collection): | ||
| """Drawing method for drawing an entire collection of objects.""" | ||
| @abstractmethod |
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.
should the default not be to call the pluggable and have the pluggable throw the error?
| def clear(self): | ||
| clear() | ||
| guids = [] | ||
| for sceneobject in self.sceneobjects: | ||
| guids += sceneobject.guids | ||
| sceneobject._guids = None | ||
| clear(guids=guids) | ||
|
|
||
| def redraw(self): | ||
| self.clear() | ||
|
|
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.
@tomvanmele How about now? we collect the all guids of scene then clear all together. Also we add guids as argument for clear, so it does not delete the other stuff in context that are not managed by the scene.
| @staticmethod | ||
| def draw_collection(collection): | ||
| """Drawing method for drawing an entire collection of objects.""" | ||
| raise NotImplementedError | ||
| def clear(self): | ||
| """The main clearing method.""" | ||
| clear(guids=self.guids) | ||
| self._guids = None |
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.
Then we also use same same clear function for individual object. In this way the clear function of the object doesn't need to be re-implemented anymore
Still in the work. This is to add the mechanism to track guids in scene objects. So the
drawfunction should now always returns a list of GUIDs. Question: I currently wroteitem_guids, but not sure it is the best name, any other suggestions @tomvanmele ? For instance in GH the draw function will be returning the instances of rhino geometry like Box, Sphere instead of the doc objects. And in blender it will be a list ofbpy.types.Object.