diff options
author | Suchita Lad | 2024-08-23 17:55:09 +0530 |
---|---|---|
committer | Suchita Lad | 2024-08-27 13:01:05 +0530 |
commit | 7ff45d978cb838f9f67173ccb164aa04fbe6f046 (patch) | |
tree | 1d31cc26ab1080107d50f8e51e9da279bb44f8e9 | |
parent | f83af0e524f0f8f1f83110f6b5a3dde1fa8a64a2 (diff) | |
download | Common-Interface-Project-7ff45d978cb838f9f67173ccb164aa04fbe6f046.tar.gz Common-Interface-Project-7ff45d978cb838f9f67173ccb164aa04fbe6f046.tar.bz2 Common-Interface-Project-7ff45d978cb838f9f67173ccb164aa04fbe6f046.zip |
Updated files
-rwxr-xr-x | blocks/Xcos/MxGraphParser.py | 54 | ||||
-rw-r--r-- | blocks/Xcos/links/ExplicitLink.py | 10 | ||||
-rw-r--r-- | blocks/Xcos/ports/ExplicitInputPort.py | 2 | ||||
-rw-r--r-- | blocks/Xcos/ports/ExplicitOutputPort.py | 5 |
4 files changed, 37 insertions, 34 deletions
diff --git a/blocks/Xcos/MxGraphParser.py b/blocks/Xcos/MxGraphParser.py index 92e1f2f8..4c0d9e20 100755 --- a/blocks/Xcos/MxGraphParser.py +++ b/blocks/Xcos/MxGraphParser.py @@ -45,7 +45,7 @@ def split_array_by_point(array, point): # Check if the point lies on the line segment between array[i] and array[i + 1] if array[i]['y'] == array[i + 1]['y'] == point['y'] and array[i]['x'] <= point['x'] <= array[i + 1]['x']: # Split the array into two parts - return array[:i+1] + [point], [point] + array[i+1:] + return array[:i+1], array[i+1:] return array, [] for root in model: @@ -155,9 +155,7 @@ for root in model: globals()[style](outroot, attribid, ParentComponent, ordering, geometry) elif 'edge' in attrib: - print(attrib) mxGeometry = cell.find('mxGeometry') - print(mxGeometry) array = mxGeometry.find('Array') celid = cell.attrib.get('id') mxPointList[celid] = array @@ -173,12 +171,10 @@ for root in model: print('ARRAYELEM:', arrayelem) - sourceVertex = attrib['sourceVertex'] targetVertex = attrib['targetVertex'] sourceType = IDLIST[sourceVertex] targetType = IDLIST[targetVertex] - # print("SV:", sourceVertex, "TV:", targetVertex, "ST:", sourceType, "TT:",targetType) # switch vertices if required if sourceType in ['ExplicitInputPort', 'ImplicitInputPort', 'ControlPort'] and targetType in ['ExplicitOutputPort', 'ExplicitLink', 'ImplicitOutputPort', 'ImplicitLink', 'CommandPort', 'CommandControlLink']: @@ -214,25 +210,15 @@ for root in model: edgeDict2[attribid] = (style, sourceVertex, targetVertex, sourceType, targetType, arrayelem) IDLIST[attribid] = style - - # larger_array = arrayelem - # point = {'x': '370', 'y': '70'} - # larger_array = [{k: int(v) for k, v in coord.items()} for coord in larger_array] - # point = {k: int(v) for k, v in point.items()} - - # # Split the array - # array1, array2 = split_array_by_point(larger_array, point) - # print('A1:', array1) - # print('A2:', array2) if addSplit: try: print("SOURCEV:", edgeDict[sourceVertex]) - (style2, sourceVertex2, targetVertex2, sourceType2, targetType2, arrayelem) = edgeDict[sourceVertex] + (style2, sourceVertex2, targetVertex2, sourceType2, targetType2, arrayelem2) = edgeDict[sourceVertex] except KeyError: pass try: print("SOURCET:", edgeDict[targetVertex]) - (style2, sourceVertex2, targetVertex2, sourceType2, targetType2, arrayelem) = edgeDict[targetVertex] + (style2, sourceVertex2, targetVertex2, sourceType2, targetType2, arrayelem2) = edgeDict[targetVertex] except KeyError: pass for a in cell.attrib: @@ -248,7 +234,7 @@ for root in model: point = mxPoint.attrib del point['as'] # print(point) - larger_array = arrayelem + larger_array = arrayelem2 larger_array = [{k: int(v) for k, v in coord.items()} for coord in larger_array] point = {k: int(v) for k, v in point.items()} @@ -256,6 +242,7 @@ for root in model: array1, array2 = split_array_by_point(larger_array, point) print('A1:', array1) print('A2:', array2) + array3 = arrayelem for b in mxPoint.attrib: print('ARRAY of SPlitLink', b, mxPoint.attrib.get(b)) for child in mxPoint: @@ -267,9 +254,9 @@ for root in model: geometry['height'] = mxPoint.attrib.get('height', '7') geometry['x'] = mxPoint.attrib.get('x', '0') geometry['y'] = mxPoint.attrib.get('y', '0') - print("Testing Value1: ", geometry) - splitList.append((attribid, sourceVertex, targetVertex, sourceType, targetType, geometry, array1, array2)) + splitList.append((attribid, sourceVertex, targetVertex, sourceType, targetType, geometry, array1, array2, array3)) + print('SPLIST', splitList) try: print("Source",edgeDict[sourceVertex]) del edgeDict[sourceVertex] @@ -283,11 +270,20 @@ for root in model: except BaseException: traceback.print_exc() -for (attribid, sourceVertex, targetVertex, sourceType, targetType, geometry, array1, array2) in splitList: +generatedsplitblk = {} +for (attribid, sourceVertex, targetVertex, sourceType, targetType, geometry, array1, array2, array3) in splitList: componentOrdering += 1 - SplitBlock(outroot, nextattribid, componentOrdering, geometry) - splitblockid = nextattribid - nextattribid += 1 + if sourceVertex in generatedsplitblk: + splitblockid = generatedsplitblk[sourceVertex] + elif targetVertex in generatedsplitblk: + splitblockid = generatedsplitblk[targetVertex] + else: + SplitBlock(outroot, nextattribid, componentOrdering, geometry) + splitblockid = nextattribid + nextattribid += 1 + generatedsplitblk[sourceVertex] = splitblockid + generatedsplitblk[targetVertex] = splitblockid + inputCount = 0 outputCount = 0 if sourceType == 'ExplicitOutputPort': @@ -323,9 +319,9 @@ for (attribid, sourceVertex, targetVertex, sourceType, targetType, geometry, arr (style2, sourceVertex2, targetVertex2, sourceType2, targetType2) = edgeDict2[sourceVertex] if targetType == 'ExplicitInputPort': (style2, sourceVertex2, targetVertex2, sourceType2, targetType2, arrayelem) = edgeDict2[sourceVertex] - (inputCount, outputCount, nextattribid, nextAttribForSplit) = 1 0 21 10001 addExplicitInputPortForSplit(outroot, splitblockid, sourceVertex2, targetVertex2, sourceType2, targetType2, edgeDict, inputCount, outputCount, nextattribid, nextAttribForSplit, array1) - (inputCount, outputCount, nextattribid, nextAttribForSplit) = addExplicitOutputPortForSplit(outroot, splitblockid, sourceVertex2, targetVertex2, sourceType2, targetType2, edgeDict, inputCount, outputCount, nextattribid, nextAttribForSplit) - (inputCount, outputCount, nextattribid, nextAttribForSplit) = addExplicitOutputPortForSplit(outroot, splitblockid, sourceVertex, targetVertex, sourceType, targetType, edgeDict, inputCount, outputCount, nextattribid, nextAttribForSplit) + (inputCount, outputCount, nextattribid, nextAttribForSplit) = addExplicitInputPortForSplit(outroot, splitblockid, sourceVertex2, targetVertex2, sourceType2, targetType2, edgeDict, inputCount, outputCount, nextattribid, nextAttribForSplit, array1) + (inputCount, outputCount, nextattribid, nextAttribForSplit) = addExplicitOutputPortForSplit(outroot, splitblockid, sourceVertex2, targetVertex2, sourceType2, targetType2, edgeDict, inputCount, outputCount, nextattribid, nextAttribForSplit, array2) + (inputCount, outputCount, nextattribid, nextAttribForSplit) = addExplicitOutputPortForSplit(outroot, splitblockid, sourceVertex, targetVertex, sourceType, targetType, edgeDict, inputCount, outputCount, nextattribid, nextAttribForSplit, array3) elif targetType == 'ImplicitInputPort': geometry = {} geometry['width'] = 8 @@ -375,12 +371,12 @@ for (attribid, sourceVertex, targetVertex, sourceType, targetType, geometry, arr nextAttribForSplit += 1 (style2, sourceVertex2, targetVertex2, sourceType2, targetType2) = edgeDict2[targetVertex] -for (attribid, (style, sourceVertex, targetVertex, sourceType, targetType, arrayelem)) in edgeDict.items(): +for (attribid, (style, sourceVertex, targetVertex, sourceType, targetType, array1)) in edgeDict.items(): print("testing",attribid,style, sourceVertex, targetVertex, sourceType, targetType) if int(attribid) >= 10000: attribid = nextattribid nextattribid += 1 - globals()[style](outroot, attribid, sourceVertex, targetVertex) + globals()[style](outroot, attribid, sourceVertex, targetVertex, array1) outnode = ET.SubElement(outdiagram, 'mxCell') outnode.set('id', str(1)) diff --git a/blocks/Xcos/links/ExplicitLink.py b/blocks/Xcos/links/ExplicitLink.py index a4c1f5a5..9a469b8d 100644 --- a/blocks/Xcos/links/ExplicitLink.py +++ b/blocks/Xcos/links/ExplicitLink.py @@ -1,15 +1,21 @@ from common.AAAAAA import * -def ExplicitLink(outroot, attribid, sourceVertex, targetVertex): +def ExplicitLink(outroot, attribid, sourceVertex, targetVertex, arrayelem): func_name = 'ExplicitLink' outnode = addNode(outroot, func_name, **{'id': attribid}, parent=1, source=sourceVertex, target=targetVertex, style=func_name, value='') + print(arrayelem) mxGeoNode = addNode(outnode, 'mxGeometry', **{'as': 'geometry'}) addNode(mxGeoNode, 'mxPoint', **{'as': 'sourcePoint', 'x': "0.0", 'y': "0.0"}) - addNode(mxGeoNode, 'Array', **{'as': 'points'}) + + arrayNode = addNode(mxGeoNode, 'Array', **{'as': 'points'}) + + for point in arrayelem: + addNode(arrayNode, 'mxPoint', **{'x': point['x'], 'y': point['y']}) + addNode(mxGeoNode, 'mxPoint', **{'as': 'targetPoint', 'x': "0.0", 'y': "0.0"}) return outnode diff --git a/blocks/Xcos/ports/ExplicitInputPort.py b/blocks/Xcos/ports/ExplicitInputPort.py index adbb3836..8bee4041 100644 --- a/blocks/Xcos/ports/ExplicitInputPort.py +++ b/blocks/Xcos/ports/ExplicitInputPort.py @@ -37,7 +37,7 @@ def addExplicitInputPortForSplit(outroot, splitBlock, sourceVertex, targetVertex forSplitBlock=True) edgeDict[nextAttribForSplit] = ('ExplicitLink', sourceVertex, nextAttrib, sourceType, 'ExplicitInputPort', arrayelem) - print('ED:', edgeDict[nextAttribForSplit]) + # print('ED:', edgeDict[nextAttribForSplit]) nextAttrib += 1 nextAttribForSplit += 1 print('ED:', inputCount, outputCount, nextAttrib, nextAttribForSplit) diff --git a/blocks/Xcos/ports/ExplicitOutputPort.py b/blocks/Xcos/ports/ExplicitOutputPort.py index 2cc8e66f..c776fd8e 100644 --- a/blocks/Xcos/ports/ExplicitOutputPort.py +++ b/blocks/Xcos/ports/ExplicitOutputPort.py @@ -26,7 +26,7 @@ def ExplicitOutputPort(outroot, attribid, parentattribid, ordering, geometry, def addExplicitOutputPortForSplit(outroot, splitBlock, sourceVertex, targetVertex, sourceType, targetType, edgeDict, inputCount, - outputCount, nextAttrib, nextAttribForSplit): + outputCount, nextAttrib, nextAttribForSplit, arrayelem): outputCount += 1 geometry = {} geometry['width'] = 8 @@ -36,7 +36,8 @@ def addExplicitOutputPortForSplit(outroot, splitBlock, sourceVertex, targetVerte ExplicitOutputPort(outroot, nextAttrib, splitBlock, outputCount, geometry, forSplitBlock=True) edgeDict[nextAttribForSplit] = ('ExplicitLink', nextAttrib, targetVertex, - 'ExplicitOutputPort', targetType) + 'ExplicitOutputPort', targetType, arrayelem) nextAttrib += 1 nextAttribForSplit += 1 + print(inputCount, outputCount, nextAttrib, nextAttribForSplit) return (inputCount, outputCount, nextAttrib, nextAttribForSplit) |