From 51cbc86975301abebfa2b699ee295eeab6e64716 Mon Sep 17 00:00:00 2001
From: Suchita Lad
Date: Wed, 6 Nov 2024 13:02:50 +0530
Subject: Code of mxPoint
---
blocks/Xcos/MxGraphParser.py | 133 ++++++++++++++++--------------
blocks/eda-frontend/public/splitblock.xsl | 107 ++++++++++++++++++++++--
blocks/xcos2xml/links/ExplicitLink.xsl | 22 +++--
3 files changed, 191 insertions(+), 71 deletions(-)
diff --git a/blocks/Xcos/MxGraphParser.py b/blocks/Xcos/MxGraphParser.py
index 9580a733..350bfb18 100755
--- a/blocks/Xcos/MxGraphParser.py
+++ b/blocks/Xcos/MxGraphParser.py
@@ -167,11 +167,8 @@ def addPort3ForSplit(outroot, splitblockid, sourceVertex, targetVertex, sourceTy
elif sourceType == 'ImplicitLink' or targetType == 'ImplicitLink':
if targetType == 'ImplicitOutputPort' or sourceType == 'ImplicitOutputPort':
return addImplicitInputPortForSplit(outroot, splitblockid, sourceVertex, targetVertex, sourceType, targetType, inputCount, outputCount, nextattribid, nextAttribForSplit, array3)
- elif targetType == 'ImplicitInputPort' or sourceType == 'ImplicitInputPort':
- return addImplicitOutputPortForSplit(outroot, splitblockid, sourceVertex, targetVertex, sourceType, targetType, inputCount, outputCount, nextattribid, nextAttribForSplit, array3)
else:
- print('Error: (sourceType, targetType, sourceType2, targetType2) =',
- '(', sourceType, ',', targetType, ',', sourceType2, ',', targetType2, ')')
+ return addImplicitOutputPortForSplit(outroot, splitblockid, sourceVertex, targetVertex, sourceType, targetType, inputCount, outputCount, nextattribid, nextAttribForSplit, array3)
elif sourceType == 'CommandControlLink':
if targetType == 'ControlPort':
return addCommandPortForSplit(outroot, splitblockid, sourceVertex, targetVertex, sourceType, targetType, inputCount, outputCount, nextattribid, nextAttribForSplit, array3)
@@ -378,12 +375,16 @@ for root in model:
continue
split_point = None
-
+ split_point2 = None
+ print('attribid:', attribid)
print('targetVertex:', targetVertex, 'blkgeometry:', targetVertex in blkgeometry)
+ print('sourceVertex:', sourceVertex, 'blkgeometry:', sourceVertex in blkgeometry)
+ print('tarx' in attrib and 'tary' in attrib)
- if 'tarx' in attrib and 'tary' in attrib:
+ if 'tarx' in attrib and 'tary' in attrib and (attrib['tarx'] != '0' or attrib['tary'] != '0'):
point = {'x': attrib['tarx'], 'y': attrib['tary']}
split_point = point
+ print('SPOINT:', split_point)
waypoints.insert(0, point)
elif sourceVertex in blkgeometry:
vertex = blkgeometry[sourceVertex]
@@ -391,13 +392,18 @@ for root in model:
waypoints.insert(0, point)
- if targetVertex in blkgeometry:
+ if 'tar2x' in attrib and 'tar2y' in attrib and (attrib['tar2x'] != '0' or attrib['tar2y'] != '0'):
+ point = {'x': attrib['tar2x'], 'y': attrib['tar2y']}
+ split_point2 = point
+ print('SPOINT2:', split_point2)
+ waypoints.append(point)
+ elif targetVertex in blkgeometry:
vertex = blkgeometry[targetVertex]
point = {'x': vertex['x'], 'y': vertex['y']}
waypoints.append(point)
IDLIST[attribid] = style
- link_data = (attribid, sourceVertex, targetVertex, sourceType, targetType, style, waypoints, addSplit, split_point)
+ link_data = (attribid, sourceVertex, targetVertex, sourceType, targetType, style, waypoints, addSplit, split_point, split_point2)
edgeDict[attribid] = link_data
edgeList.append(link_data)
except BaseException:
@@ -415,62 +421,69 @@ for key, value in edgeDict.items():
print()
newEdgeDict = {}
-for (attribid, sourceVertex, targetVertex, sourceType, targetType, style, waypoints, addSplit, split_point) in edgeList:
- link_data = (attribid, sourceVertex, targetVertex, sourceType, targetType, style, waypoints, addSplit, split_point)
-
+for (attribid, sourceVertex, targetVertex, sourceType, targetType, style, waypoints, addSplit, split_point, split_point2) in edgeList:
+ link_data = (attribid, sourceVertex, targetVertex, sourceType, targetType, style, waypoints, addSplit, split_point, split_point2)
+ print('NEWEDGE00:', attribid, waypoints, split_point, addSplit)
if not addSplit:
newEdgeDict[attribid] = [link_data]
+ print('NEWEDGE:', attribid, waypoints, split_point)
continue
- try:
- linkSegments = newEdgeDict[sourceVertex]
- attribid2 = sourceVertex
- except KeyError:
- pass
- try:
- linkSegments = newEdgeDict[targetVertex]
- attribid2 = targetVertex
- except KeyError:
- pass
-
- print('split_point:', split_point)
- result, i, left_array, right_array = identify_segment(linkSegments, split_point)
- if not result:
- sys.exit(0)
- (linkid, sourceVertex2, targetVertex2, sourceType2, targetType2, style2, waypoints2, addSplit2, split_point2) = linkSegments[i]
- array3 = waypoints
-
- componentOrdering += 1
- geometry = {}
- geometry['height'] = 7
- geometry['width'] = 7
- geometry['x'] = split_point['x']
- geometry['y'] = split_point['y']
- if sourceType2 == 'ControlPort' or sourceType2 == 'CommandPort' or sourceType2 == 'CommandControlLink':
- split_style = 'CLKSPLIT_f'
- func_name = 'CLKSPLIT_f'
- else:
- split_style = 'SPLIT_f;flip=false;mirror=false'
- func_name = 'SPLIT_f'
- SplitBlock(outroot, nextattribid, componentOrdering, geometry, parent=parentattribid, style=split_style, func_name=func_name)
- splitblockid = nextattribid
- nextattribid += 1
-
- inputCount = 0
- outputCount = 0
- port1 = nextattribid
- (inputCount, outputCount, nextattribid, nextAttribForSplit) = addPort1ForSplit(outroot, splitblockid, sourceVertex2, targetVertex2, sourceType, targetType, sourceType2, targetType2, inputCount, outputCount, nextattribid, nextAttribForSplit, left_array)
- port2 = nextattribid
- (inputCount, outputCount, nextattribid, nextAttribForSplit) = addPort2ForSplit(outroot, splitblockid, sourceVertex2, targetVertex2, sourceType, targetType, sourceType2, targetType2, inputCount, outputCount, nextattribid, nextAttribForSplit, right_array)
- port3 = nextattribid
- (inputCount, outputCount, nextattribid, nextAttribForSplit) = addPort3ForSplit(outroot, splitblockid, sourceVertex, targetVertex, sourceType, targetType, sourceType2, targetType2, inputCount, outputCount, nextattribid, nextAttribForSplit, array3)
-
- newEdgeDict[attribid2][i] = ((nextAttribForSplit, sourceVertex2, port1, sourceType2, targetType, style2, left_array, addSplit2, split_point2))
- nextAttribForSplit += 1
- newEdgeDict[attribid2].insert(i + 1, (nextAttribForSplit, port2, targetVertex2, sourceType, targetType2, style2, right_array, addSplit2, split_point2))
- nextAttribForSplit += 1
- newEdgeDict[attribid] = [(nextAttribForSplit, port3, targetVertex, sourceType, targetType, style, waypoints, addSplit, split_point)]
- nextAttribForSplit += 1
+ for attribid2 in sourceVertex, targetVertex:
+ try:
+ linkSegments = newEdgeDict[attribid2]
+ print('linkSegments:',linkSegments)
+ except KeyError:
+ continue
+
+ print('split_point:', split_point, linkSegments)
+ result, i, left_array, right_array = identify_segment(linkSegments, split_point)
+ print('LR:', left_array, right_array)
+ print('waypoints:',waypoints)
+ if not result:
+ sys.exit(0)
+ (linkid, sourceVertex2, targetVertex2, sourceType2, targetType2, style2, waypoints2, addSplit2, split_point, split_point2) = linkSegments[i]
+ print('SP2:',split_point2)
+ array3 = waypoints
+ print('ARRAY3:',array3)
+
+ componentOrdering += 1
+ geometry = {}
+ geometry['height'] = 7
+ geometry['width'] = 7
+ geometry['x'] = split_point['x']
+ geometry['y'] = split_point['y']
+ if sourceType2 == 'ControlPort' or sourceType2 == 'CommandPort' or sourceType2 == 'CommandControlLink':
+ split_style = 'CLKSPLIT_f'
+ func_name = 'CLKSPLIT_f'
+ else:
+ split_style = 'SPLIT_f;flip=false;mirror=false'
+ func_name = 'SPLIT_f'
+ SplitBlock(outroot, nextattribid, componentOrdering, geometry, parent=parentattribid, style=split_style, func_name=func_name)
+ splitblockid = nextattribid
+ nextattribid += 1
+
+ inputCount = 0
+ outputCount = 0
+ port1 = nextattribid
+ (inputCount, outputCount, nextattribid, nextAttribForSplit) = addPort1ForSplit(outroot, splitblockid, sourceVertex2, targetVertex2, sourceType, targetType, sourceType2, targetType2, inputCount, outputCount, nextattribid, nextAttribForSplit, left_array)
+ print('nextAttribForSplit1:',nextAttribForSplit)
+ port2 = nextattribid
+ (inputCount, outputCount, nextattribid, nextAttribForSplit) = addPort2ForSplit(outroot, splitblockid, sourceVertex2, targetVertex2, sourceType, targetType, sourceType2, targetType2, inputCount, outputCount, nextattribid, nextAttribForSplit, right_array)
+ print('nextAttribForSplit2:',nextAttribForSplit)
+ port3 = nextattribid
+ (inputCount, outputCount, nextattribid, nextAttribForSplit) = addPort3ForSplit(outroot, splitblockid, sourceVertex, targetVertex, sourceType, targetType, sourceType2, targetType2, inputCount, outputCount, nextattribid, nextAttribForSplit, array3)
+ print('nextAttribForSplit3:',nextAttribForSplit)
+ newEdgeDict[attribid2][i] = ((nextAttribForSplit, sourceVertex2, port1, sourceType2, targetType, style2, left_array, addSplit2, split_point2))
+ nextAttribForSplit += 1
+ newEdgeDict[attribid2].insert(i + 1, (nextAttribForSplit, port2, targetVertex2, sourceType, targetType2, style2, right_array, addSplit2, split_point2))
+ nextAttribForSplit += 1
+ for (__, __, __, __, __, __, tmp_array, __, tmp_split_point) in newEdgeDict[attribid2]:
+ print('NEWEDGE2:', attribid2, tmp_array, tmp_split_point )
+ newEdgeDict[attribid] = [(nextAttribForSplit, port3, targetVertex, sourceType, targetType, style, waypoints, addSplit, split_point)]
+ nextAttribForSplit += 1
+ for (__, __, __, __, __, __, tmp_array, __, tmp_split_point) in newEdgeDict[attribid]:
+ print('NEWEDGE3:', attribid, tmp_array, tmp_split_point )
print()
for key, newEdges in newEdgeDict.items():
diff --git a/blocks/eda-frontend/public/splitblock.xsl b/blocks/eda-frontend/public/splitblock.xsl
index ef9b3b0d..cfc18a5c 100644
--- a/blocks/eda-frontend/public/splitblock.xsl
+++ b/blocks/eda-frontend/public/splitblock.xsl
@@ -40,6 +40,9 @@
+
+
+
@@ -84,12 +87,23 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -171,9 +185,9 @@
sourcePoint
-
+
@@ -270,6 +284,9 @@
+
+
+
@@ -313,6 +330,9 @@
+
+
+
@@ -331,6 +351,10 @@
+
+
+
+
@@ -410,7 +434,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No match found
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No match found
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No match found
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -429,6 +522,10 @@
+
+
+
+
diff --git a/blocks/xcos2xml/links/ExplicitLink.xsl b/blocks/xcos2xml/links/ExplicitLink.xsl
index 4800ec1e..4300f588 100644
--- a/blocks/xcos2xml/links/ExplicitLink.xsl
+++ b/blocks/xcos2xml/links/ExplicitLink.xsl
@@ -20,9 +20,6 @@
-
-
-
@@ -31,15 +28,28 @@
-
-
-
0
+
+
+
+
+
+ 0
+
+
+
+
+
+
+
+ 0
+
+
Unknown
--
cgit