From 3f8015b1d3c36830fee9cd4b9fe36603c7b0ab30 Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Tue, 24 Sep 2024 08:32:31 +0200 Subject: [PATCH 1/2] [Fix #527] Improved auto-layout of nodes and fixed weird behavior of links between nodes --- src/components/editor/faultTree/canvas/EditorCanvas.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/editor/faultTree/canvas/EditorCanvas.tsx b/src/components/editor/faultTree/canvas/EditorCanvas.tsx index 8e4a9ed9..d46b3307 100644 --- a/src/components/editor/faultTree/canvas/EditorCanvas.tsx +++ b/src/components/editor/faultTree/canvas/EditorCanvas.tsx @@ -235,7 +235,10 @@ const EditorCanvas = ({ joint.layout.DirectedGraph.layout(graph.getSubgraph(autoLayoutElements), { dagre: dagre, graphlib: graphlib, - setVertices: true, + setLinkVertices: false, // Avoid weird behavior of links (described in https://github.com/kbss-cvut/fta-fmea-ui/issues/527) + rankDir: "TB", // Direction top-to-bottom + nodeSep: 50, // Horizontal separation between nodes + rankSep: 100, // Vertical separation between ranks marginX: 20, marginY: 20, }); From 705e928c69b2012505cf54bfe500b24774d58e6d Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Tue, 24 Sep 2024 09:10:59 +0200 Subject: [PATCH 2/2] [Upd #527] Auto-layout is not confused anymore by manually moved nodes --- src/components/editor/faultTree/canvas/EditorCanvas.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/editor/faultTree/canvas/EditorCanvas.tsx b/src/components/editor/faultTree/canvas/EditorCanvas.tsx index d46b3307..5d070ed3 100644 --- a/src/components/editor/faultTree/canvas/EditorCanvas.tsx +++ b/src/components/editor/faultTree/canvas/EditorCanvas.tsx @@ -241,6 +241,7 @@ const EditorCanvas = ({ rankSep: 100, // Vertical separation between ranks marginX: 20, marginY: 20, + preserveNodeGeometry: true, }); // Manual Layout manualLayoutElements.forEach((el) => {