From e0a760c06e1a68006b5b5128129c6a4c671f65f9 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Thu, 28 Nov 2024 14:58:12 +0100 Subject: [PATCH 1/5] remove invisible declarations container if no declarations are shown. --- .../kieler/sccharts/ui/synthesis/hooks/DeclarationsHook.xtend | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/DeclarationsHook.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/DeclarationsHook.xtend index a9fa464877..dfcd02c9be 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/DeclarationsHook.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/hooks/DeclarationsHook.xtend @@ -64,10 +64,10 @@ class DeclarationsHook extends SynthesisHook { val parent = node.regionExtendedContainer val declarations = parent?.getProperty(ControlflowRegionStyles.DECLARATIONS_CONTAINER) if (declarations !== null) { - val container = declarations.eContainer as KContainerRendering + val container = declarations.eContainer.eContainer.eContainer as KContainerRendering // Hide declarations if (declarations !== null && container !== null) { - container.children.remove(declarations) + container.children.removeIf([true]) } } } From 31d5147d8044eaae648b6df4f3e95eea70b28066 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Thu, 28 Nov 2024 18:10:08 +0100 Subject: [PATCH 2/5] take the names of the model elements instead of the label texts for inlining. Fixes inlining while referenced port labels are turned off. --- .../ui/synthesis/EquationSynthesis.xtend | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend index 9f4f86694c..bbc0a551fc 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend @@ -35,15 +35,14 @@ import de.cau.cs.kieler.kexpressions.kext.DeclarationScope import de.cau.cs.kieler.kexpressions.kext.extensions.KExtDeclarationExtensions import de.cau.cs.kieler.kicool.ui.synthesis.KGTLoader import de.cau.cs.kieler.klighd.SynthesisOption +import de.cau.cs.kieler.klighd.internal.util.KlighdInternalProperties import de.cau.cs.kieler.klighd.kgraph.KIdentifier import de.cau.cs.kieler.klighd.kgraph.KNode import de.cau.cs.kieler.klighd.kgraph.KPort import de.cau.cs.kieler.klighd.krendering.Colors import de.cau.cs.kieler.klighd.krendering.KContainerRendering -import de.cau.cs.kieler.klighd.krendering.KPolygon import de.cau.cs.kieler.klighd.krendering.KPolyline import de.cau.cs.kieler.klighd.krendering.KRendering -import de.cau.cs.kieler.klighd.krendering.KText import de.cau.cs.kieler.klighd.krendering.LineStyle import de.cau.cs.kieler.klighd.krendering.ViewSynthesisShared import de.cau.cs.kieler.klighd.krendering.extensions.KEdgeExtensions @@ -986,17 +985,25 @@ class EquationSynthesis extends SubSynthesis { val inputNames = newHashMap for (inputNode : child.children.filter(KNode).filter[getProperty(INPUT_FLAG)]) { - val name = inputNode.data.filter(KPolygon).head.children.filter(KText).head.text - inputNames.put(name, inputNode) + val valuedObjectRef = inputNode.properties.get(KlighdInternalProperties.MODEL_ELEMENT) + // only care for inputs that have a valued object as a reference, ignore others such as constants. + if (valuedObjectRef instanceof ValuedObjectReference) { + val name = valuedObjectRef.valuedObject.name + inputNames.put(name, inputNode) + } } val outputNames = newHashMap for (outputNode : child.children.filter(KNode).filter[getProperty(OUTPUT_FLAG)]) { - val name = outputNode.data.filter(KPolygon).head.children.filter(KText).head.text - outputNames.put(name, outputNode) + val valuedObjectRef = outputNode.properties.get(KlighdInternalProperties.MODEL_ELEMENT) + if (valuedObjectRef instanceof ValuedObjectReference) { + val name = valuedObjectRef.valuedObject.name + outputNames.put(name, outputNode) + } } for (port : node.ports.immutableCopy.reverseView) { - val portName = port.labels.head?.text + val reference = port.properties.get(KlighdInternalProperties.MODEL_ELEMENT) + val portName = if(reference instanceof ValuedObjectReference) reference.valuedObject.name else "" val portSide = port.portSide val newPort = port.copy From 784410df5abbbb2a6f642e33a9d967998394d59f Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Fri, 29 Nov 2024 14:42:06 +0100 Subject: [PATCH 3/5] fix combination of turned on "automatic inline" and turned off "local variables" options. --- .../sccharts/ui/synthesis/EquationSimplification.xtend | 2 +- .../kieler/sccharts/ui/synthesis/EquationSynthesis.xtend | 6 ++++-- .../sccharts/ui/synthesis/EquationSynthesisHelper.xtend | 7 ++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSimplification.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSimplification.xtend index 772e298a0b..be26ffb3e8 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSimplification.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSimplification.xtend @@ -618,7 +618,7 @@ class EquationSimplification { private def isLocalValuedObject(KNode node) { val element = node.sourceElement if (element instanceof ValuedObjectReference) { - return currentRegion.declarations.contains((element as ValuedObjectReference).valuedObject.declaration) + return currentRegions.peek.declarations.contains((element as ValuedObjectReference).valuedObject.declaration) } return false } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend index bbc0a551fc..5a4bdf3592 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend @@ -282,7 +282,7 @@ class EquationSynthesis extends SubSynthesis { showWireLabels = SHOW_WIRE_LABELS.booleanValue combineAllDataAccessNodes = COMBINE_ALL_DATA_ACCESS.booleanValue showArrows = SHOW_ARROWS.booleanValue - currentRegion = rootNode.sourceElement as DataflowRegion + currentRegions.push(rootNode.sourceElement as DataflowRegion) var nodes = newLinkedList val List lastKNodes = newArrayList for (assignment : elements) { @@ -307,7 +307,9 @@ class EquationSynthesis extends SubSynthesis { n.addLayoutParam(CoreOptions.NODE_SIZE_MINIMUM, new KVector(0, 0)) n.addLayoutParam(CoreOptions.PADDING, new ElkPadding(0, 0, 0, 0)) } - return nodes.reWireInlining.addMissingReferenceInputs + val result = nodes.reWireInlining.addMissingReferenceInputs + currentRegions.pop + return result } /** diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesisHelper.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesisHelper.xtend index f8b8090dcf..568528d514 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesisHelper.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesisHelper.xtend @@ -40,6 +40,7 @@ import de.cau.cs.kieler.sccharts.ui.synthesis.styles.EquationStyles import de.cau.cs.kieler.sccharts.ui.synthesis.styles.TransitionStyles import java.util.Comparator import java.util.List +import java.util.Stack import org.eclipse.elk.alg.layered.options.LayeredOptions import org.eclipse.elk.core.options.CoreOptions import org.eclipse.elk.core.options.PortSide @@ -72,7 +73,11 @@ class EquationSynthesisHelper { protected var showWireLabels = false protected var combineAllDataAccessNodes = false protected var showArrows = false - protected var DataflowRegion currentRegion = null + /* + * only contains a single element with the current region during transformation. If automatic inline is on, this + * is a stack of the processed regions, with the top region being the current one. + */ + protected var Stack currentRegions = new Stack /** * removes a node from the list and from the graph From 8eab2111044709a0bc572cec197e5e1ffb976966 Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Fri, 29 Nov 2024 17:53:42 +0100 Subject: [PATCH 4/5] route direct connections from inputs to outputs in inlined dataflow inside the node. Fixes #27 --- .../ui/synthesis/EquationSynthesis.xtend | 27 +++++++++++++++++-- .../synthesis/EquationSynthesisHelper.xtend | 1 - 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend index 5a4bdf3592..3362e41d92 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend @@ -26,6 +26,7 @@ import de.cau.cs.kieler.kexpressions.TextExpression import de.cau.cs.kieler.kexpressions.Value import de.cau.cs.kieler.kexpressions.ValuedObject import de.cau.cs.kieler.kexpressions.ValuedObjectReference +import de.cau.cs.kieler.kexpressions.VariableDeclaration import de.cau.cs.kieler.kexpressions.VectorValue import de.cau.cs.kieler.kexpressions.extensions.KExpressionsCreateExtensions import de.cau.cs.kieler.kexpressions.extensions.KExpressionsValuedObjectExtensions @@ -763,7 +764,6 @@ class EquationSynthesis extends SubSynthesis { ] target.ports.add(targetPort) } - edge.setLayoutOption(LayeredOptions.INSIDE_SELF_LOOPS_YO, true) edge.source = source edge.sourcePort = sourcePort edge.target = target @@ -860,7 +860,6 @@ class EquationSynthesis extends SubSynthesis { ] after.ports.add(targetPort) } - edge.setLayoutOption(LayeredOptions.INSIDE_SELF_LOOPS_YO, true) edge.source = before edge.sourcePort = sourcePort edge.target = after @@ -1049,6 +1048,30 @@ class EquationSynthesis extends SubSynthesis { for (node : inlinedNodes) { nodes.betterRemove(node, null) } + + + // activate inside self loops on inlined reference nodes that directly connect an input to an output. + for (refNode : nodes.filter [properties.get(KlighdInternalProperties.MODEL_ELEMENT) instanceof DataflowRegion]) { + // inside self loops go directly from an input to an output. + val insideSelfLoops = refNode.outgoingEdges.filter[ + val sourceElement = it.sourcePort.properties.get(KlighdInternalProperties.MODEL_ELEMENT) + val targetElement = it.targetPort.properties.get(KlighdInternalProperties.MODEL_ELEMENT) + return refNode.incomingEdges.contains(it) + && sourceElement instanceof ValuedObjectReference + && targetElement instanceof ValuedObjectReference + && (sourceElement as ValuedObjectReference).valuedObject.eContainer instanceof VariableDeclaration + && (targetElement as ValuedObjectReference).valuedObject.eContainer instanceof VariableDeclaration + && ((sourceElement as ValuedObjectReference).valuedObject.eContainer as VariableDeclaration).isInput + && ((targetElement as ValuedObjectReference).valuedObject.eContainer as VariableDeclaration).isOutput + ] + insideSelfLoops.forEach [ + addLayoutParam(LayeredOptions.INSIDE_SELF_LOOPS_YO, true) + ] + if (!insideSelfLoops.empty) { + refNode.addLayoutParam(LayeredOptions.INSIDE_SELF_LOOPS_ACTIVATE, true) + } + } + return nodes } diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesisHelper.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesisHelper.xtend index 568528d514..29ea50e53d 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesisHelper.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesisHelper.xtend @@ -339,7 +339,6 @@ class EquationSynthesisHelper { return } val edge = createEdge - DiagramSyntheses.setLayoutOption(edge, LayeredOptions.INSIDE_SELF_LOOPS_YO, true) edge.source = source.node edge.sourcePort = source edge.target = target.node From f70af38d82bb7bef45312971ef41e280070c294f Mon Sep 17 00:00:00 2001 From: Niklas Rentz Date: Mon, 2 Dec 2024 09:20:33 +0100 Subject: [PATCH 5/5] Avoid accidental Swastika in inlined DF examples, for example on DF-0600 --- .../ui/synthesis/EquationSynthesis.xtend | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend index 3362e41d92..b6833936bf 100644 --- a/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend +++ b/plugins/de.cau.cs.kieler.sccharts.ui/src/de/cau/cs/kieler/sccharts/ui/synthesis/EquationSynthesis.xtend @@ -1002,16 +1002,17 @@ class EquationSynthesis extends SubSynthesis { } } + // go through all ports, but the non-east ones in reverse. Avoids accitental Swastika in many examples. for (port : node.ports.immutableCopy.reverseView) { - val reference = port.properties.get(KlighdInternalProperties.MODEL_ELEMENT) - val portName = if(reference instanceof ValuedObjectReference) reference.valuedObject.name else "" val portSide = port.portSide - val newPort = port.copy - - newPort.addLayoutParam(CoreOptions::PORT_BORDER_OFFSET, 0d) - child.ports += newPort - if (portSide != PortSide.EAST) { + val reference = port.properties.get(KlighdInternalProperties.MODEL_ELEMENT) + val portName = if(reference instanceof ValuedObjectReference) reference.valuedObject.name else "" + val newPort = port.copy + + newPort.addLayoutParam(CoreOptions::PORT_BORDER_OFFSET, 0d) + child.ports += newPort + for (edge : node.incomingEdges.immutableCopy.filter[targetPort == port]) { edge.target = child edge.targetPort = newPort @@ -1026,7 +1027,17 @@ class EquationSynthesis extends SubSynthesis { inputNode.remove } } - } else if (portSide == PortSide.EAST) { + } + } + for (port : node.ports.immutableCopy) { + val portSide = port.portSide + if (portSide == PortSide.EAST) { + val reference = port.properties.get(KlighdInternalProperties.MODEL_ELEMENT) + val portName = if(reference instanceof ValuedObjectReference) reference.valuedObject.name else "" + val newPort = port.copy + + newPort.addLayoutParam(CoreOptions::PORT_BORDER_OFFSET, 0d) + child.ports += newPort for (edge : node.outgoingEdges.immutableCopy.filter[sourcePort == port]) { edge.source = child edge.sourcePort = newPort