From c771f7b1c551b3ab38e67cb6aa76ac28c9254bec Mon Sep 17 00:00:00 2001
From: Sunil Shetye
Date: Mon, 23 Sep 2024 15:05:15 +0530
Subject: fix numerator in revised layout
add left-right and up-down logic
exclude endpoints in waypoints
---
blocks/Xcos/MxGraphParser.py | 42 ++++++++++++++++-----
.../SchematicEditor/Helper/ComponentDrag.js | 6 ++-
.../SchematicEditor/Helper/ToolbarTools.js | 1 +
blocks/xcos2xml/ports/port.xsl | 44 +++++++++++++++-------
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 @@
0
0
0
-
-
+
+
+ 8
+ 8
+ 1
+ geometry
@@ -51,12 +55,17 @@
0
0
0
-
-
-
-
-
-
+
+
+ 1
+
+
+
+ 8
+ 8
+ 1
+ geometry
+
@@ -79,12 +88,17 @@
0
0
0
-
-
+
+
-
+ 1
+ 8
+ 8
+ 1
+ geometry
+
@@ -107,11 +121,15 @@
0
0
0
-
-
+
+
+ 8
+ 8
+ 1
+ geometry
--
cgit