Skip to content

Commit

Permalink
control structure hiearchy determined by model order
Browse files Browse the repository at this point in the history
  • Loading branch information
Drakae committed Nov 14, 2024
1 parent 35b0482 commit ca282aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function createControlStructure(
missingFeedback?: Map<string, Node[]>
): ParentNode {
// set the level of the nodes in the control structure automatically
setLevelOfCSNodes(controlStructure.nodes);
// setLevelOfCSNodes(controlStructure.nodes);
// determine the nodes of the control structure graph
const csNodes = controlStructure.nodes.map(n => createControlStructureNode(n, idToSNode, options, idCache));
// children (nodes and edges) of the control structure
Expand Down
16 changes: 13 additions & 3 deletions extension/src-language-server/stpa/diagram/layout-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export class StpaLayoutConfigurator extends DefaultLayoutConfigurator {
let direction = "";
// priority is used to determine the order of the nodes
let priority = "";
if (snode.children?.find(child => child.type === CS_NODE_TYPE)) {
const csParent = snode.children?.find(child => child.type === CS_NODE_TYPE);
if (csParent) {
// options for the control structure
direction = "DOWN";
priority = "1";
Expand Down Expand Up @@ -75,6 +76,11 @@ export class StpaLayoutConfigurator extends DefaultLayoutConfigurator {
options["org.eclipse.elk.layered.crossingMinimization.forceNodeModelOrder"] = "true";
options["org.eclipse.elk.separateConnectedComponents"] = "false";
}
if (csParent) {
options["org.eclipse.elk.layered.considerModelOrder.strategy"] = "PREFER_NODES";
options["org.eclipse.elk.layered.crossingMinimization.forceNodeModelOrder"] = "true";
options["org.eclipse.elk.layered.cycleBreaking.strategy"] = "MODEL_ORDER";
}

return options;
}
Expand Down Expand Up @@ -116,8 +122,9 @@ export class StpaLayoutConfigurator extends DefaultLayoutConfigurator {
"org.eclipse.elk.partitioning.activate": "true",
"org.eclipse.elk.direction": "DOWN",
"org.eclipse.elk.portConstraints": "FIXED_SIDE",
"org.eclipse.elk.layered.considerModelOrder.strategy": "NODES_AND_EDGES",
"org.eclipse.elk.layered.considerModelOrder.strategy": "PREFER_NODES",
"org.eclipse.elk.layered.crossingMinimization.forceNodeModelOrder": "true",
"org.eclipse.elk.layered.cycleBreaking.strategy": "MODEL_ORDER",
// nodes with many edges are streched
"org.eclipse.elk.layered.nodePlacement.strategy": "NETWORK_SIMPLEX",
"org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility.default": "NODE_SIZE",
Expand Down Expand Up @@ -176,14 +183,17 @@ export class StpaLayoutConfigurator extends DefaultLayoutConfigurator {
protected csNodeOptions(node: CSNode): LayoutOptions {
const options: LayoutOptions = {
"org.eclipse.elk.alignment": "CENTER",
"org.eclipse.elk.partitioning.partition": "" + node.level,
// "org.eclipse.elk.partitioning.partition": "" + node.level,
"org.eclipse.elk.nodeSize.constraints": "NODE_LABELS",
// edges do no start at the border of the node
"org.eclipse.elk.spacing.portsSurrounding": "[top=10.0,left=10.0,bottom=10.0,right=10.0]",
"org.eclipse.elk.portConstraints": "FIXED_SIDE",
// nodes with many edges are streched
"org.eclipse.elk.layered.nodePlacement.strategy": "NETWORK_SIMPLEX",
"org.eclipse.elk.layered.nodePlacement.networkSimplex.nodeFlexibility.default": "NODE_SIZE",
"org.eclipse.elk.layered.considerModelOrder.strategy": "PREFER_NODES",
"org.eclipse.elk.layered.crossingMinimization.forceNodeModelOrder": "true",
"org.eclipse.elk.layered.cycleBreaking.strategy": "MODEL_ORDER"
};
if (node.children?.find(child => child.type.startsWith("node"))) {
// node has children nodes
Expand Down

0 comments on commit ca282aa

Please sign in to comment.