summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Shetye2024-09-23 15:05:15 +0530
committerSunil Shetye2024-09-24 17:12:29 +0530
commitc771f7b1c551b3ab38e67cb6aa76ac28c9254bec (patch)
tree01cd5d6f2562bf3e5d7ea41aa6c1a7e786a6402b
parente9c2cdb6330f463dc835c3649bc9c38dce4d6278 (diff)
downloadCommon-Interface-Project-c771f7b1c551b3ab38e67cb6aa76ac28c9254bec.tar.gz
Common-Interface-Project-c771f7b1c551b3ab38e67cb6aa76ac28c9254bec.tar.bz2
Common-Interface-Project-c771f7b1c551b3ab38e67cb6aa76ac28c9254bec.zip
fix numerator in revised layout
add left-right and up-down logic exclude endpoints in waypoints
-rwxr-xr-xblocks/Xcos/MxGraphParser.py42
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js6
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js1
-rw-r--r--blocks/xcos2xml/ports/port.xsl44
4 files changed, 68 insertions, 25 deletions
diff --git a/blocks/Xcos/MxGraphParser.py b/blocks/Xcos/MxGraphParser.py
index 83839f6a..497c3699 100755
--- a/blocks/Xcos/MxGraphParser.py
+++ b/blocks/Xcos/MxGraphParser.py
@@ -41,19 +41,40 @@ outmodel = ET.SubElement(outdiagram, 'mxGraphModel')
outmodel.set('as', 'model')
-def check_point_on_array(array, point):
+def check_point_on_array(array, point, left_right_direction=True):
if array is None:
return False, array, []
+
+ pointX = float(point['x'])
+ pointY = float(point['y'])
+
for i in range(len(array) - 1):
+ leftX = float(array[i]['x'])
+ leftY = float(array[i]['y'])
+ rightX = float(array[i + 1]['x'])
+ rightY = float(array[i + 1]['y'])
+
# Check if the point lies on the line segment between array[i] and array[i + 1]
- if -40 <= float(array[i]['y']) - float(point['y']) <= 40 and \
- -40 <= float(array[i + 1]['y']) - float(point['y']) <= 40 and \
- float(array[i]['x']) <= float(point['x']) <= float(array[i + 1]['x']):
- return True, array[:i + 1], array[i + 1:]
- if -40 <= float(array[i]['x']) - float(point['x']) <= 40 and \
- -40 <= float(array[i + 1]['x']) - float(point['x']) <= 40 and \
- float(array[i]['y']) <= float(point['y']) <= float(array[i + 1]['y']):
- return True, array[:i + 1], array[i + 1:]
+ if -40 <= leftY - pointY <= 40 and \
+ -40 <= rightY - pointY <= 40 and \
+ leftX <= pointX <= rightX:
+ return True, array[:i + 1] + [point], [point] + array[i + 1:]
+ if -40 <= leftX - pointX <= 40 and \
+ -40 <= rightX - pointX <= 40 and \
+ leftY <= pointY <= rightY:
+ return True, array[:i + 1] + [point], [point] + array[i + 1:]
+
+ if left_right_direction:
+ if -20 <= leftY - pointY <= 20:
+ print('to the left / right')
+ return True, array[:i + 1] + [point], [point] + array[i + 1:]
+ else:
+ if -20 <= leftX - pointX <= 20:
+ print('on the up / down')
+ return True, array[:i + 1] + [point], [point] + array[i + 1:]
+
+ # switch direction for the next waypoint
+ left_right_direction = not left_right_direction
return False, array, []
def identify_segment(array, point):
@@ -378,7 +399,8 @@ for key, newEdges in newEdgeDict.items():
if int(attribid) >= 10000:
attribid = nextattribid
nextattribid += 1
- globals()[style](outroot, attribid, sourceVertex, targetVertex, waypoints)
+ globals()[style](outroot, attribid, sourceVertex, targetVertex,
+ waypoints[1:-1])
outnode = ET.SubElement(outdiagram, 'mxCell')
outnode.set('id', str(1))
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js
index e3771232..27cb7bc1 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js
@@ -276,7 +276,9 @@ export default function LoadGrid (container, sidebar, outline) {
break
}
text = style + '\n' +
- 'UID: ' + cell.id + '\n'
+ 'UID: ' + cell.id + '\n' +
+ 'Source: ' + cell.source.id + '\n' +
+ 'Target: ' + cell.target.id + '\n'
return text
}
@@ -318,7 +320,7 @@ export default function LoadGrid (container, sidebar, outline) {
} else {
const geometry = cell.geometry
- text = 'Block Name: ' + attribute + '\n' +
+ text = attribute + '\n' +
'UID: ' + cell.id + '\n' +
'Style: ' + cell.style + '\n' +
'Flip: ' + flip + '\n' +
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js
index 46555b64..fc42b313 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js
@@ -412,6 +412,7 @@ function parseXmlToGraph (xmlDoc, graph) {
v1.implicitOutputPorts = 0
v1.controlPorts = 0
v1.commandPorts = 0
+ v1.simulationFunction = cellAttrs.simulationFunction.value
} else if (cellAttrs.CellType?.value === 'Pin') {
const style = cellAttrs.style.value.replace(/;.*/, '')
const vertexId = cellAttrs.id.value
diff --git a/blocks/xcos2xml/ports/port.xsl b/blocks/xcos2xml/ports/port.xsl
index 5513b6d6..31016a5e 100644
--- a/blocks/xcos2xml/ports/port.xsl
+++ b/blocks/xcos2xml/ports/port.xsl
@@ -23,11 +23,15 @@
<xsl:attribute name="targetVertex">0</xsl:attribute>
<xsl:attribute name="tarx">0</xsl:attribute>
<xsl:attribute name="tary">0</xsl:attribute>
- <mxGeometry x="0" width="8" height="8" relative="1" as="geometry">
- <xsl:variable name="numerator" select="2 * number($explicitInputPorts + $implicitInputPorts) - (2 * (position() - 1) + 1)" />
+ <mxGeometry>
+ <xsl:variable name="numerator" select="2 * position() - 1" />
<xsl:attribute name="y">
<xsl:value-of select="$numerator div (2 * number($explicitInputPorts + $implicitInputPorts))"/>
</xsl:attribute>
+ <xsl:attribute name="width">8</xsl:attribute>
+ <xsl:attribute name="height">8</xsl:attribute>
+ <xsl:attribute name="relative">1</xsl:attribute>
+ <xsl:attribute name="as">geometry</xsl:attribute>
<mxPoint x="-8" y="-4" as="offset"/>
</mxGeometry>
<Object as="parameter_values"/>
@@ -51,12 +55,17 @@
<xsl:attribute name="targetVertex">0</xsl:attribute>
<xsl:attribute name="tarx">0</xsl:attribute>
<xsl:attribute name="tary">0</xsl:attribute>
- <mxGeometry x="1" width="8" height="8" relative="1" as="geometry">
- <xsl:variable name="numerator" select="2 * number($explicitOutputPorts + $implicitOutputPorts) - (2 * (position() - 1) + 1)" />
- <xsl:attribute name="y">
- <xsl:value-of select="$numerator div (2 * number($explicitOutputPorts + $implicitOutputPorts))"/>
- </xsl:attribute>
- <mxPoint x="0" y="-4" as="offset"/>
+ <mxGeometry>
+ <xsl:variable name="numerator" select="2 * position() - 1" />
+ <xsl:attribute name="x">1</xsl:attribute>
+ <xsl:attribute name="y">
+ <xsl:value-of select="$numerator div (2 * number($explicitOutputPorts + $implicitOutputPorts))"/>
+ </xsl:attribute>
+ <xsl:attribute name="width">8</xsl:attribute>
+ <xsl:attribute name="height">8</xsl:attribute>
+ <xsl:attribute name="relative">1</xsl:attribute>
+ <xsl:attribute name="as">geometry</xsl:attribute>
+ <mxPoint y="-4" as="offset"/>
</mxGeometry>
<Object as="parameter_values"/>
<Object as="displayProperties"/>
@@ -79,12 +88,17 @@
<xsl:attribute name="targetVertex">0</xsl:attribute>
<xsl:attribute name="tarx">0</xsl:attribute>
<xsl:attribute name="tary">0</xsl:attribute>
- <mxGeometry y="1" width="8" height="8" relative="1" as="geometry">
- <xsl:variable name="numerator" select="2 * number($commandPorts) - (2 * (position() - 1) + 1)" />
+ <mxGeometry>
+ <xsl:variable name="numerator" select="2 * position() - 1" />
<xsl:attribute name="x">
<xsl:value-of select="$numerator div (2 * number($commandPorts))"/>
</xsl:attribute>
- <mxPoint x="-4" y="0" as="offset"/>
+ <xsl:attribute name="y">1</xsl:attribute>
+ <xsl:attribute name="width">8</xsl:attribute>
+ <xsl:attribute name="height">8</xsl:attribute>
+ <xsl:attribute name="relative">1</xsl:attribute>
+ <xsl:attribute name="as">geometry</xsl:attribute>
+ <mxPoint x="-4" as="offset"/>
</mxGeometry>
<Object as="parameter_values"/>
<Object as="displayProperties"/>
@@ -107,11 +121,15 @@
<xsl:attribute name="targetVertex">0</xsl:attribute>
<xsl:attribute name="tarx">0</xsl:attribute>
<xsl:attribute name="tary">0</xsl:attribute>
- <mxGeometry y="0" width="8" height="8" relative="1" as="geometry">
- <xsl:variable name="numerator" select="2 * number($controlPorts) - (2 * (position() - 1) + 1)" />
+ <mxGeometry>
+ <xsl:variable name="numerator" select="2 * position() - 1" />
<xsl:attribute name="x">
<xsl:value-of select="$numerator div (2 * number($controlPorts))"/>
</xsl:attribute>
+ <xsl:attribute name="width">8</xsl:attribute>
+ <xsl:attribute name="height">8</xsl:attribute>
+ <xsl:attribute name="relative">1</xsl:attribute>
+ <xsl:attribute name="as">geometry</xsl:attribute>
<mxPoint x="-4" y="-8" as="offset"/>
</mxGeometry>
<Object as="parameter_values"/>