-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3b0118
commit a5c0fd6
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from PySide6.QtCore import QTimer | ||
|
||
from compas_viewer.base import Base | ||
|
||
|
||
class Observer(Base): | ||
def __init__(self): | ||
self._observers = set( | ||
( | ||
self.viewer.renderer, | ||
self.viewer.ui.sidebar, | ||
) | ||
) | ||
|
||
self._time = None | ||
self.update_timer = QTimer() | ||
self.update_timer.setSingleShot(True) | ||
self.update_timer.timeout.connect(self.update_observers) | ||
self.debounce_interval = 100 | ||
|
||
def add_observer(self, observer): | ||
if observer not in self._observers: | ||
self._observers.add(observer) | ||
|
||
def remove_observer(self, observer): | ||
if observer in self._observers: | ||
self._observers.remove(observer) | ||
|
||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters