-
Notifications
You must be signed in to change notification settings - Fork 4
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
Added click-boxes of show
and locked
#169
Changes from 20 commits
a77b7fd
b325471
c33fda5
6b1c57a
6b35917
379c92e
f44429c
284ff02
cf84750
33acb1e
c01f2de
9b33673
42c079e
83d6d90
b9003f6
5125531
394829a
1a484d5
d66d351
d43c9ea
ba66921
3d07f37
0005609
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,6 +195,7 @@ def __init__( | |
opacity: Optional[float] = None, | ||
doublesided: Optional[bool] = None, | ||
is_visiable: Optional[bool] = None, | ||
is_locked: Optional[bool] = None, | ||
**kwargs, | ||
): | ||
super().__init__(**kwargs) | ||
|
@@ -206,7 +207,8 @@ def __init__( | |
self.linewidth = 1.0 if linewidth is None else linewidth | ||
self.opacity = 1.0 if opacity is None else opacity | ||
self.doublesided = True if doublesided is None else doublesided | ||
self.is_visible = True if is_visiable is None else is_visiable | ||
self.show = True if is_visiable is None else is_visiable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btw, i am not a fan of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
self._is_locked = False if is_locked is None else is_locked | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. were we not going to remove this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes we are, but it would be better to do that in another PR, cuz this attribute is a bit everywhere, this one here is added temporarily to make the form work |
||
|
||
self.is_selected = False | ||
self.background = False | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
from typing import Optional | ||
from typing import Union | ||
|
||
from PySide6.QtCore import QTimer | ||
|
||
from compas.colors import Color | ||
from compas.datastructures import Datastructure | ||
from compas.geometry import Geometry | ||
|
@@ -60,6 +62,15 @@ class ViewerScene(Scene): | |
context : str, optional | ||
The context of the scene. | ||
|
||
Attributes | ||
---------- | ||
observers : set | ||
Set of unique observer objects. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are these objects that observe, or objects that are being observed? what makes something an "observer"? is there a base class somewhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the observer class in PR #181 maybe I remove from here, so is less confusing |
||
update_timer : :class:`QTimer` | ||
Timer to manage update debouncing. | ||
debounce_interval : int | ||
Interval in milliseconds for debouncing updates. | ||
|
||
See Also | ||
-------- | ||
:class:`compas.scene.Scene` | ||
|
@@ -70,10 +81,35 @@ def __init__(self, name: str = "ViewerScene", context: str = "Viewer"): | |
|
||
# Primitive | ||
self.objects: list[ViewerSceneObject] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. btw, this does not initialize the attribute. it just adds a type annotation. if you try to access this attribute an error will be thrown. it should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
self._observers = set() | ||
# Selection | ||
self.instance_colors: dict[tuple[int, int, int], ViewerSceneObject] = {} | ||
self._instance_colors_generator = instance_colors_generator() | ||
# Time Debounce | ||
self._time = None | ||
self.update_timer = QTimer() | ||
self.update_timer.setSingleShot(True) | ||
self.update_timer.timeout.connect(self.update_observers) | ||
self.debounce_interval = 200 | ||
|
||
@property | ||
def viewer(self): | ||
from compas_viewer import Viewer | ||
|
||
return Viewer() | ||
|
||
# TODO: This property will be updated from #181 PR. | ||
@property | ||
def observers(self): | ||
new_observers = [ | ||
self.viewer.renderer, | ||
self.viewer.ui.sidebar, | ||
] | ||
|
||
for observer in new_observers: | ||
self._observers.add(observer) | ||
|
||
return list(self._observers) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks a bit fishy... |
||
|
||
# TODO: These fixed kwargs could be moved to COMPAS core. | ||
def add( | ||
|
@@ -179,4 +215,26 @@ def add( | |
**kwargs, | ||
) | ||
|
||
self.request_update() | ||
return sceneobject | ||
|
||
def remove(self, item: ViewerSceneObject) -> None: | ||
""" | ||
Remove an item from the scene. | ||
|
||
Parameters | ||
---------- | ||
item : :class:`compas_viewer.scene.ViewerSceneObject` | ||
The item to remove. | ||
""" | ||
|
||
super().remove(item) | ||
self.request_update() | ||
|
||
def request_update(self): | ||
if not self.update_timer.isActive(): | ||
self.update_timer.start(self.debounce_interval) | ||
|
||
def update_observers(self): | ||
for observer in self.observers: | ||
observer.update() |
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.
please convert this into understandable sentences...