diff options
author | Suchita Lad | 2024-12-26 17:47:03 +0530 |
---|---|---|
committer | Suchita Lad | 2024-12-26 17:47:03 +0530 |
commit | febdc56eb686aaaef05157357525eaef4a7dcd93 (patch) | |
tree | 0d503094e59215e15d62477928fe2d6df717a9de | |
parent | 0620e9ccd9632c0bae017f0f15f12e0d6ef71736 (diff) | |
download | Common-Interface-Project-febdc56eb686aaaef05157357525eaef4a7dcd93.tar.gz Common-Interface-Project-febdc56eb686aaaef05157357525eaef4a7dcd93.tar.bz2 Common-Interface-Project-febdc56eb686aaaef05157357525eaef4a7dcd93.zip |
Updated xsl files for geometry point values
-rwxr-xr-x | blocks/Xcos/XmlParser.py | 12 | ||||
-rw-r--r-- | blocks/eda-frontend/public/geometry.xsl | 183 | ||||
-rw-r--r-- | blocks/xcos2xml/head.xsl | 31 | ||||
-rw-r--r-- | blocks/xcos2xml/links/ExplicitLink.xsl | 8 |
4 files changed, 161 insertions, 73 deletions
diff --git a/blocks/Xcos/XmlParser.py b/blocks/Xcos/XmlParser.py index 709f6c15..c17c94b2 100755 --- a/blocks/Xcos/XmlParser.py +++ b/blocks/Xcos/XmlParser.py @@ -272,20 +272,24 @@ def check_point_on_array(array, point, left_right_direction=True): return True, array[:i + 1] + [point], [point] + array[i + 1:] # if left_right_direction: - if -20 <= leftX - pointX <= 20: + if -20 <= leftX - pointX <= 20 and \ + (leftY <= pointY <= rightY or leftY >= pointY >= rightY): print('to the left / right') return True, array[:i + 1] + [point], [point] + array[i + 1:] # else: - if -20 <= leftY - pointY <= 20: + if -20 <= leftY - pointY <= 20 and \ + (leftX <= pointX <= rightX or leftX >= pointX >= rightX): print('on the up / down') return True, array[:i + 1] + [point], [point] + array[i + 1:] # if left_right_direction: - if -20 <= rightX - pointX <= 20: + if -20 <= rightX - pointX <= 20 and \ + (leftY <= pointY <= rightY or leftY >= pointY >= rightY): print('to the right / right') return True, array[:i + 1] + [point], [point] + array[i + 1:] # else: - if -20 <= rightY - pointY <= 20: + if -20 <= rightY - pointY <= 20 and \ + (leftX <= pointX <= rightX or leftX >= pointX >= rightX): print('on the up / down') return True, array[:i + 1] + [point], [point] + array[i + 1:] diff --git a/blocks/eda-frontend/public/geometry.xsl b/blocks/eda-frontend/public/geometry.xsl index 94757f79..967a35b9 100644 --- a/blocks/eda-frontend/public/geometry.xsl +++ b/blocks/eda-frontend/public/geometry.xsl @@ -19,11 +19,11 @@ <!-- variable newx --> <xsl:variable name="newx"> - <xsl:choose> + <!-- <xsl:choose> <xsl:when test="(@x != '0.0' or @y != '0.0')"> <xsl:value-of select="@x"/> </xsl:when> - <xsl:when test="(@x = '0.0' and @y = '0.0')"> + <xsl:when test="(@x = '0.0' and @y = '0.0')"> --> <!-- Check for mxCell with sourceVertex --> <xsl:for-each select="key('k-cell', ancestor::mxCell/@sourceVertex)"> @@ -66,20 +66,21 @@ </xsl:when> </xsl:choose> + </xsl:for-each> </xsl:for-each> </xsl:for-each> - </xsl:when> - </xsl:choose> + <!-- </xsl:when> + </xsl:choose> --> </xsl:variable> <xsl:variable name="newy"> - <xsl:choose> + <!-- <xsl:choose> <xsl:when test="(@x != '0.0' or @y != '0.0')"> <xsl:value-of select="@y"/> </xsl:when> - <xsl:when test="(@x = '0.0' and @y = '0.0')"> + <xsl:when test="(@x = '0.0' and @y = '0.0')"> --> <!-- Check for mxCell with sourceVertex --> <xsl:for-each select="key('k-cell', ancestor::mxCell/@sourceVertex)"> <xsl:variable name="ordering"> @@ -125,14 +126,40 @@ </xsl:for-each> </xsl:for-each> - </xsl:when> - </xsl:choose> + <!-- </xsl:when> + </xsl:choose> --> </xsl:variable> - <xsl:attribute name="x"> - <xsl:value-of select="$newx"/> + <xsl:attribute name="x11"> + <xsl:value-of select="@x"/> + </xsl:attribute> + <xsl:attribute name="width"> + <xsl:value-of select="@width"/> + </xsl:attribute> + <!-- <xsl:attribute name="ordering"> + <xsl:value-of select="$ordering"/> + </xsl:attribute> + <xsl:attribute name="noofport"> + <xsl:value-of select="$noofport"/> + </xsl:attribute> --> + <xsl:attribute name="x"> + <xsl:choose> + <xsl:when test="$newx = ''"> + <xsl:value-of select="@x"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$newx"/> + </xsl:otherwise> + </xsl:choose> </xsl:attribute> <xsl:attribute name="y"> - <xsl:value-of select="$newy"/> + <xsl:choose> + <xsl:when test="$newy = ''"> + <xsl:value-of select="@y"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$newy"/> + </xsl:otherwise> + </xsl:choose> </xsl:attribute> <xsl:apply-templates select="node()" /> @@ -146,11 +173,11 @@ <!-- variable newx --> <xsl:variable name="newx"> - <xsl:choose> + <!-- <xsl:choose> <xsl:when test="(@x != '0.0' or @y != '0.0')"> <xsl:value-of select="@x"/> </xsl:when> - <xsl:when test="(@x = '0.0' and @y = '0.0')"> + <xsl:when test="(@x = '0.0' and @y = '0.0')"> --> <!-- Check for mxCell with sourceVertex --> <xsl:for-each select="key('k-cell', ancestor::mxCell/@targetVertex)"> @@ -198,15 +225,15 @@ </xsl:for-each> </xsl:for-each> - </xsl:when> - </xsl:choose> + <!-- </xsl:when> + </xsl:choose> --> </xsl:variable> <xsl:variable name="newy"> - <xsl:choose> + <!-- <xsl:choose> <xsl:when test="(@x != '0.0' or @y != '0.0')"> <xsl:value-of select="@y"/> </xsl:when> - <xsl:when test="(@x = '0.0' and @y = '0.0')"> + <xsl:when test="(@x = '0.0' and @y = '0.0')"> --> <!-- Check for mxCell with targetVertex --> <xsl:for-each select="key('k-cell', ancestor::mxCell/@targetVertex)"> <xsl:variable name="ordering"> @@ -252,15 +279,29 @@ </xsl:for-each> </xsl:for-each> - </xsl:when> - </xsl:choose> + <!-- </xsl:when> + </xsl:choose> --> </xsl:variable> - <xsl:attribute name="x"> - <xsl:value-of select="$newx"/> + <xsl:attribute name="x"> + <xsl:choose> + <xsl:when test="$newx = ''"> + <xsl:value-of select="@x"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$newx"/> + </xsl:otherwise> + </xsl:choose> </xsl:attribute> <xsl:attribute name="y"> - <xsl:value-of select="$newy"/> - </xsl:attribute> + <xsl:choose> + <xsl:when test="$newy = ''"> + <xsl:value-of select="@y"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$newy"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> <xsl:apply-templates select="node()" /> </xsl:copy> @@ -270,11 +311,11 @@ <xsl:copy> <xsl:apply-templates select="@*" /> <xsl:variable name="newtarx"> - <xsl:choose> + <!-- <xsl:choose> <xsl:when test="(@tarx != '0.0' or @tary != '0.0')"> <xsl:value-of select="@tarx"/> </xsl:when> - <xsl:when test="(@tarx = '0.0' and @tary = '0.0')"> + <xsl:when test="(@tarx = '0.0' and @tary = '0.0')"> --> <xsl:for-each select="key('k-cell', @sourceVertex)"> <xsl:variable name="ordering"> <xsl:value-of select="@ordering"/> @@ -320,15 +361,15 @@ </xsl:for-each> </xsl:for-each> - </xsl:when> - </xsl:choose> + <!-- </xsl:when> + </xsl:choose> --> </xsl:variable> <xsl:variable name="newtary"> - <xsl:choose> + <!-- <xsl:choose> <xsl:when test="(@tarx != '0.0' or @tary != '0.0')"> <xsl:value-of select="@tary"/> </xsl:when> - <xsl:when test="(@tarx = '0.0' and @tary = '0.0')"> + <xsl:when test="(@tarx = '0.0' and @tary = '0.0')"> --> <!-- Check for mxCell with sourceVertex --> <xsl:for-each select="key('k-cell', @sourceVertex)"> <xsl:variable name="ordering"> @@ -374,18 +415,18 @@ </xsl:for-each> </xsl:for-each> - </xsl:when> - </xsl:choose> + <!-- </xsl:when> + </xsl:choose> --> </xsl:variable> <!-- tar2x & tar2y --> <xsl:variable name="newtar2x"> - <xsl:choose> + <!-- <xsl:choose> <xsl:when test="(@tar2x != '0.0' or @tar2y != '0.0')"> <xsl:value-of select="@tar2x"/> </xsl:when> - <xsl:when test="(@tar2x = '0.0' and @tar2y = '0.0')"> + <xsl:when test="(@tar2x = '0.0' and @tar2y = '0.0')"> --> <!-- Check for mxCell with sourceVertex --> <xsl:for-each select="key('k-cell', @targetVertex)"> @@ -433,15 +474,15 @@ </xsl:for-each> </xsl:for-each> - </xsl:when> - </xsl:choose> + <!-- </xsl:when> + </xsl:choose> --> </xsl:variable> <xsl:variable name="newtar2y"> - <xsl:choose> + <!-- <xsl:choose> <xsl:when test="(@tar2x != '0.0' or @tar2y != '0.0')"> <xsl:value-of select="@tar2y"/> </xsl:when> - <xsl:when test="(@tar2x = '0.0' and @tar2y = '0.0')"> + <xsl:when test="(@tar2x = '0.0' and @tar2y = '0.0')"> --> <!-- Check for mxCell with targetVertex --> <xsl:for-each select="key('k-cell', @targetVertex)"> <xsl:variable name="ordering"> @@ -487,23 +528,77 @@ </xsl:for-each> </xsl:for-each> - </xsl:when> - </xsl:choose> + <!-- </xsl:when> + </xsl:choose> --> </xsl:variable> - <xsl:attribute name="tarx"> - <xsl:value-of select="$newtarx"/> + <xsl:attribute name="tarx"> + <xsl:choose> + <xsl:when test="$newtarx = ''"> + <xsl:value-of select="@tarx"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$newtarx"/> + </xsl:otherwise> + </xsl:choose> + <!-- <xsl:value-of select="$newtarx"/> --> </xsl:attribute> <xsl:attribute name="tary"> - <xsl:value-of select="$newtary"/> + <xsl:choose> + <xsl:when test="$newtary = ''"> + <xsl:value-of select="@tary"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$newtary"/> + </xsl:otherwise> + </xsl:choose> + <!-- <xsl:value-of select="$newtary"/> --> </xsl:attribute> <xsl:attribute name="tar2x"> - <xsl:value-of select="$newtar2x"/> + <xsl:choose> + <xsl:when test="$newtar2x = ''"> + <xsl:value-of select="@tar2x"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$newtar2x"/> + </xsl:otherwise> + </xsl:choose> + <!-- <xsl:value-of select="$newtar2x"/> --> </xsl:attribute> <xsl:attribute name="tar2y"> - <xsl:value-of select="$newtar2y"/> + <xsl:choose> + <xsl:when test="$newtar2y = ''"> + <xsl:value-of select="@tar2y"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$newtar2y"/> + </xsl:otherwise> + </xsl:choose> + <!-- <xsl:value-of select="$newtar2y"/> --> </xsl:attribute> <xsl:apply-templates select="node()" /> + + + <!-- <xsl:attribute name="x"> + <xsl:choose> + <xsl:when test="$newx = ''"> + <xsl:value-of select="@x"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$newx"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> + <xsl:attribute name="y"> + <xsl:choose> + <xsl:when test="$newy = ''"> + <xsl:value-of select="@y"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$newy"/> + </xsl:otherwise> + </xsl:choose> + </xsl:attribute> --> </xsl:copy> </xsl:template> diff --git a/blocks/xcos2xml/head.xsl b/blocks/xcos2xml/head.xsl index f44e5322..9525b080 100644 --- a/blocks/xcos2xml/head.xsl +++ b/blocks/xcos2xml/head.xsl @@ -471,26 +471,18 @@ </xsl:template> <xsl:template name="mxGeometry" match="mxGeometry"> <xsl:element name="mxGeometry"> - <xsl:attribute name="x"> - <xsl:choose> - <xsl:when test="@x"> + <xsl:if test="@x"> + <xsl:attribute name="x"> <xsl:value-of select="format-number(@x+$originx,'0.0')" /> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="format-number($originx,'0.0')" /> - </xsl:otherwise> - </xsl:choose> - </xsl:attribute> - <xsl:attribute name="y"> - <xsl:choose> - <xsl:when test="@y"> + </xsl:attribute> + </xsl:if> + + <xsl:if test="@y"> + <xsl:attribute name="y"> <xsl:value-of select="format-number(@y+$originy,'0.0')" /> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="format-number($originy,'0.0')" /> - </xsl:otherwise> - </xsl:choose> - </xsl:attribute> + </xsl:attribute> + </xsl:if> + <xsl:if test="@width"> <xsl:attribute name="width"> <xsl:value-of select="@width" /> @@ -516,9 +508,6 @@ </xsl:template> <xsl:template name="mxPoint" match="mxPoint"> <xsl:element name="mxPoint"> - <xsl:attribute name="testmx"> - <xsl:value-of select="@x" /> - </xsl:attribute> <xsl:if test="@as"> <xsl:attribute name="as"> <xsl:value-of select="@as" /> diff --git a/blocks/xcos2xml/links/ExplicitLink.xsl b/blocks/xcos2xml/links/ExplicitLink.xsl index d20c05e4..3f712132 100644 --- a/blocks/xcos2xml/links/ExplicitLink.xsl +++ b/blocks/xcos2xml/links/ExplicitLink.xsl @@ -13,7 +13,7 @@ <xsl:attribute name="tarx"> <xsl:choose> <xsl:when test="mxGeometry/mxPoint[@as='sourcePoint']"> - <xsl:value-of select="mxGeometry/mxPoint[@as='sourcePoint']/@x" /> + <xsl:value-of select="format-number(mxGeometry/mxPoint[@as='sourcePoint']/@x+$originx,'0.0')" /> </xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> @@ -21,7 +21,7 @@ <xsl:attribute name="tary"> <xsl:choose> <xsl:when test="mxGeometry/mxPoint[@as='sourcePoint']"> - <xsl:value-of select="mxGeometry/mxPoint[@as='sourcePoint']/@y" /> + <xsl:value-of select="format-number(mxGeometry/mxPoint[@as='sourcePoint']/@y+$originy,'0.0')" /> </xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> @@ -29,7 +29,7 @@ <xsl:attribute name="tar2x"> <xsl:choose> <xsl:when test="mxGeometry/mxPoint[@as='targetPoint']"> - <xsl:value-of select="mxGeometry/mxPoint[@as='targetPoint']/@x" /> + <xsl:value-of select="format-number(mxGeometry/mxPoint[@as='targetPoint']/@x+$originx,'0.0')" /> </xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> @@ -37,7 +37,7 @@ <xsl:attribute name="tar2y"> <xsl:choose> <xsl:when test="mxGeometry/mxPoint[@as='targetPoint']"> - <xsl:value-of select="mxGeometry/mxPoint[@as='targetPoint']/@y" /> + <xsl:value-of select="format-number(mxGeometry/mxPoint[@as='targetPoint']/@y+$originy,'0.0')" /> </xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> |