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:
@@ -349,6 +349,9 @@ def run_pipeline_mode(preset_name: str = "demo"):
|
||||
|
||||
print(f" \033[38;5;245mSwitching to preset: {preset_name}\033[0m")
|
||||
|
||||
# Save current UI panel state before rebuild
|
||||
ui_state = ui_panel.save_state() if ui_panel else None
|
||||
|
||||
try:
|
||||
# Clean up old pipeline
|
||||
pipeline.cleanup()
|
||||
@@ -558,6 +561,10 @@ def run_pipeline_mode(preset_name: str = "demo"):
|
||||
)
|
||||
stage_control.effect = effect # type: ignore[attr-defined]
|
||||
|
||||
# Restore UI panel state if it was saved
|
||||
if ui_state:
|
||||
ui_panel.restore_state(ui_state)
|
||||
|
||||
if ui_panel.stages:
|
||||
first_stage = next(iter(ui_panel.stages))
|
||||
ui_panel.select_stage(first_stage)
|
||||
|
||||
Reference in New Issue
Block a user