From 9d3ef80f576d42618227812263af8f4b0d577632 Mon Sep 17 00:00:00 2001 From: Nicole Rappe Date: Tue, 25 Feb 2025 17:22:40 -0700 Subject: [PATCH] Added automatic workflow centering when loading workflows from JSON files. --- borealis.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/borealis.py b/borealis.py index 22517fb..6dcab3d 100644 --- a/borealis.py +++ b/borealis.py @@ -97,7 +97,7 @@ def save_workflow(graph: NodeGraph): def load_workflow(graph: NodeGraph): """ Loads a workflow (including node values, connections, positions, etc.) - from a specified JSON file. + from a specified JSON file, and then centers the view on all loaded nodes. """ ensure_workflows_folder() file_filter = "JSON Files (*.json);;All Files (*.*)" @@ -108,11 +108,16 @@ def load_workflow(graph: NodeGraph): try: graph.load_session(file_path) + + # After loading, center the viewer on all nodes. + all_nodes = graph.all_nodes() + if all_nodes: + graph.viewer().zoom_to_nodes([node.view for node in all_nodes]) + print(f"Workflow loaded from {file_path}") except Exception as e: QtWidgets.QMessageBox.critical(None, "Error Loading Workflow", str(e)) - def import_nodes_from_folder(package_name): """ Recursively import all modules from the given package.