diff options
author | Suchita Lad | 2024-11-06 13:02:50 +0530 |
---|---|---|
committer | Suchita Lad | 2024-11-06 13:02:50 +0530 |
commit | 51cbc86975301abebfa2b699ee295eeab6e64716 (patch) | |
tree | fbaa4ea1b1d0aa0b126e1dcfc7406f2bd33e4f1e | |
parent | f97f76a57ef5fba792e4b659ecccec04dbc31fbe (diff) | |
download | Common-Interface-Project-51cbc86975301abebfa2b699ee295eeab6e64716.tar.gz Common-Interface-Project-51cbc86975301abebfa2b699ee295eeab6e64716.tar.bz2 Common-Interface-Project-51cbc86975301abebfa2b699ee295eeab6e64716.zip |
Code of mxPoint
-rwxr-xr-x | blocks/Xcos/MxGraphParser.py | 133 | ||||
-rw-r--r-- | blocks/eda-frontend/public/splitblock.xsl | 107 | ||||
-rw-r--r-- | 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 @@ <xsl:param name="sourcetwotgtsecondlink" /> <xsl:param name="sourcethreesrcsecondlink" /> <xsl:param name="sourcethreetgtsecondlink" /> + <xsl:param name="targetonewaypoints" /> + <xsl:param name="sourceonewaypoints" /> + <xsl:param name="sourcetwowaypoints" /> <xsl:param name="x" /> <xsl:param name="y" /> <xsl:param name="parent" /> @@ -84,12 +87,23 @@ <xsl:attribute name="value"></xsl:attribute> <mxGeometry relative="1" as="geometry"> <Array as="points"> - <xsl:for-each select="$targetonelink/mxGeometry/Array/mxPoint"> + <xsl:element name="waypoint"> + <xsl:attribute name="waypoint1"> + <xsl:value-of select="$targetonewaypoints" /> + </xsl:attribute> + <xsl:attribute name="waypoint2"> + <xsl:value-of select="$sourceonewaypoints" /> + </xsl:attribute> + <xsl:attribute name="waypoint3"> + <xsl:value-of select="$sourcetwowaypoints" /> <!-- removed by suchita $targetonelink/@source--> + </xsl:attribute> + </xsl:element> + <!-- <xsl:for-each select="$targetonewaypoints"> <xsl:copy-of select="." /> </xsl:for-each> - <xsl:for-each select="$sourceonelink/mxGeometry/Array/mxPoint"> + <xsl:for-each select="$sourceonewaypoints"> <xsl:copy-of select="." /> - </xsl:for-each> + </xsl:for-each> --> </Array> <xsl:for-each select="$targetonelink/mxGeometry/mxPoint"> <xsl:copy> @@ -171,9 +185,9 @@ <xsl:attribute name="as">sourcePoint</xsl:attribute> </mxPoint> <Array as="points"> - <xsl:for-each select="$sourcetwolink/mxGeometry/Array/mxPoint"> + <!-- <xsl:for-each select="$sourcetwowaypoints"> <xsl:copy-of select="." /> - </xsl:for-each> + </xsl:for-each> --> </Array> </mxGeometry> </xsl:element> @@ -270,6 +284,9 @@ <xsl:variable name="sourcethreesrcsecondlink" select="key('k-srclink', $sourcethreelink/@id)" /> <xsl:variable name="sourcethreetgtsecondlink" select="key('k-tgtlink', $sourcethreelink/@id)" /> + <xsl:variable name="targetonewaypoints" select="$targetonelink/mxGeometry/Array/mxPoint" /> + <xsl:variable name="sourceonewaypoints" select="$sourceonelink/mxGeometry/Array/mxPoint" /> + <xsl:variable name="sourcetwowaypoints" select="$sourcetwolink/mxGeometry/Array/mxPoint" /> <xsl:call-template name="links"> <xsl:with-param name="linktype" select="$linktype"/> <xsl:with-param name="targetonelink" select="$targetonelink"/> @@ -313,6 +330,9 @@ <xsl:variable name="sourcethreesrcsecondlink" select="key('k-commandsrclink', $sourcecommandthreelink/@id)" /> <xsl:variable name="sourcethreetgtsecondlink" select="key('k-commandtgtlink', $sourcecommandthreelink/@id)" /> + <xsl:variable name="targetonewaypoints" select="$targetcommandonelink/mxGeometry/Array/mxPoint" /> + <xsl:variable name="sourceonewaypoints" select="$sourcecommandonelink/mxGeometry/Array/mxPoint" /> + <xsl:variable name="sourcetwowaypoints" select="$sourcecommandtwolink/mxGeometry/Array/mxPoint" /> <xsl:call-template name="links"> <xsl:with-param name="linktype" select="$linktype"/> <xsl:with-param name="targetonelink" select="$targetcommandonelink"/> @@ -331,6 +351,10 @@ <xsl:with-param name="sourcetwotgtsecondlink" select="$sourcetwotgtsecondlink"/> <xsl:with-param name="sourcethreesrcsecondlink" select="$sourcethreesrcsecondlink"/> <xsl:with-param name="sourcethreetgtsecondlink" select="$sourcethreetgtsecondlink"/> + + <xsl:with-param name="targetonewaypoints" select="$targetonewaypoints"/> + <xsl:with-param name="sourceonewaypoints" select="$sourceonewaypoints"/> + <xsl:with-param name="sourcetwowaypoints" select="$sourcetwowaypoints"/> <xsl:with-param name="x" select="$x"/> <xsl:with-param name="y" select="$y"/> <xsl:with-param name="parent" select="$parent"/> @@ -410,7 +434,76 @@ </xsl:otherwise> </xsl:choose> </xsl:variable> + + <xsl:variable name="targetonewaypoints" > + <xsl:choose> + <xsl:when test="$targetimplicitoneid = $targetimplicitonelink/@source"> + <array> + <xsl:for-each select="$targetimplicitonelink/mxGeometry/Array/mxPoint"> + <xsl:sort select="position()" order="descending"/> + <xsl:copy-of select="."/> + </xsl:for-each> + </array> + </xsl:when> + <xsl:when test="$targetimplicitoneid = $targetimplicitonelink/@target"> + <xsl:value-of select="$targetimplicitonelink/mxGeometry/Array/mxPoint"/> + </xsl:when> + <xsl:otherwise> + <xsl:text>No match found</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="sourceonewaypoints" > + <xsl:choose> + <xsl:when test="$sourceimplicitoneid = $sourceimplicitonelink/@target"> + <array> + <xsl:for-each select="$sourceimplicitonelink/mxGeometry/Array/mxPoint"> + <xsl:sort select="position()" order="descending"/> + <xsl:copy-of select="."/> + </xsl:for-each> + </array> + </xsl:when> + <xsl:when test="$sourceimplicitoneid = $sourceimplicitonelink/@source"> + <xsl:value-of select="$sourceimplicitonelink/mxGeometry/Array/mxPoint"/> + </xsl:when> + <xsl:otherwise> + <xsl:text>No match found</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="sourcetwowaypoints" > + <xsl:choose> + <xsl:when test="$sourceimplicittwoid = $sourceimplicittwolink/@target"> + <array> + <xsl:for-each select="$sourceimplicittwolink/mxGeometry/Array/mxPoint"> + <xsl:sort select="position()" order="descending"/> + <xsl:copy-of select="."/> + </xsl:for-each> + </array> + </xsl:when> + <xsl:when test="$sourceimplicittwoid = $sourceimplicittwolink/@source"> + <xsl:value-of select="$sourceimplicittwolink/mxGeometry/Array/mxPoint"/> + </xsl:when> + <xsl:otherwise> + <xsl:text>No match found</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:element name="waypoint"> + <xsl:attribute name="waypoint1"> + <xsl:value-of select="count($targetonewaypoints)" /> + </xsl:attribute> + <xsl:attribute name="waypoint2"> + <xsl:value-of select="count($sourceonewaypoints)" /> + </xsl:attribute> + <xsl:attribute name="waypoint3"> + <xsl:value-of select="count($sourcetwowaypoints)" /> <!-- removed by suchita $targetonelink/@source--> + </xsl:attribute> + </xsl:element> + <xsl:call-template name="links"> <xsl:with-param name="linktype" select="$linktype"/> <xsl:with-param name="targetonelink" select="$targetimplicitonelink"/> @@ -429,6 +522,10 @@ <xsl:with-param name="sourcetwotgtsecondlink" select="$sourcetwotgtsecondlink"/> <xsl:with-param name="sourcethreesrcsecondlink" select="$sourcethreesrcsecondlink"/> <xsl:with-param name="sourcethreetgtsecondlink" select="$sourcethreetgtsecondlink"/> + + <xsl:with-param name="targetonewaypoints" select="$targetonewaypoints"/> + <xsl:with-param name="sourceonewaypoints" select="$sourceonewaypoints"/> + <xsl:with-param name="sourcetwowaypoints" select="$sourcetwowaypoints"/> <xsl:with-param name="x" select="$x"/> <xsl:with-param name="y" select="$y"/> <xsl:with-param name="parent" select="$parent"/> 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 @@ </xsl:attribute> <xsl:attribute name="tarx"> <xsl:choose> - <xsl:when test="mxGeometry/mxPoint[@as='targetPoint']"> - <xsl:value-of select="mxGeometry/mxPoint[@as='targetPoint']/@x" /> - </xsl:when> <xsl:when test="mxGeometry/mxPoint[@as='sourcePoint']"> <xsl:value-of select="mxGeometry/mxPoint[@as='sourcePoint']/@x" /> </xsl:when> @@ -31,15 +28,28 @@ </xsl:attribute> <xsl:attribute name="tary"> <xsl:choose> - <xsl:when test="mxGeometry/mxPoint[@as='targetPoint']"> - <xsl:value-of select="mxGeometry/mxPoint[@as='targetPoint']/@y" /> - </xsl:when> <xsl:when test="mxGeometry/mxPoint[@as='sourcePoint']"> <xsl:value-of select="mxGeometry/mxPoint[@as='sourcePoint']/@y" /> </xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:attribute> + <xsl:attribute name="tar2x"> + <xsl:choose> + <xsl:when test="mxGeometry/mxPoint[@as='targetPoint']"> + <xsl:value-of select="mxGeometry/mxPoint[@as='targetPoint']/@x" /> + </xsl:when> + <xsl:otherwise>0</xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <xsl:attribute name="tar2y"> + <xsl:choose> + <xsl:when test="mxGeometry/mxPoint[@as='targetPoint']"> + <xsl:value-of select="mxGeometry/mxPoint[@as='targetPoint']/@y" /> + </xsl:when> + <xsl:otherwise>0</xsl:otherwise> + </xsl:choose> + </xsl:attribute> <xsl:attribute name="CellType">Unknown</xsl:attribute> <xsl:copy-of select="node()"/> <Object as="parameter_values"/> |