Implement pipeline hot-rebuild with state preservation
- Add save_state/restore_state methods to CameraStage - Add save_state/restore_state methods to DisplayStage - Extend Pipeline._copy_stage_state() to preserve camera/display state - Add save_state/restore_state methods to UIPanel for UI state preservation - Update pipeline_runner to preserve UI state across preset changes Camera state preserved: - Position (x, y) - Mode (feed, scroll, horizontal, etc.) - Speed, zoom, canvas dimensions - Internal timing state Display state preserved: - Initialization status - Dimensions - Reuse flag for display reinitialization UI Panel state preserved: - Stage enabled/disabled status - Parameter values - Selected stage and focused parameter - Scroll position This enables manual/event-driven rebuilds when inlet-outlet connections change, while preserving all relevant state across pipeline mutations.
This commit is contained in:
@@ -204,6 +204,15 @@ class Pipeline:
|
||||
if hasattr(old_stage, "_enabled"):
|
||||
new_stage._enabled = old_stage._enabled
|
||||
|
||||
# Preserve camera state
|
||||
if hasattr(old_stage, "save_state") and hasattr(new_stage, "restore_state"):
|
||||
try:
|
||||
state = old_stage.save_state()
|
||||
new_stage.restore_state(state)
|
||||
except Exception:
|
||||
# If state preservation fails, continue without it
|
||||
pass
|
||||
|
||||
def _rebuild(self) -> None:
|
||||
"""Rebuild execution order after mutation without full reinitialization."""
|
||||
self._capability_map = self._build_capability_map()
|
||||
|
||||
Reference in New Issue
Block a user