summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuchita Lad2024-11-19 17:44:21 +0530
committerSuchita Lad2024-11-19 17:44:21 +0530
commitc2f5ae360ee4d77e55b3e65e60dc4f349826f777 (patch)
tree2e34d6e91f5c66383bd45b8c52beca8458903797
parentd6e66dcbfe85bb28a8b2d76c3138da7e0e6c0932 (diff)
downloadCommon-Interface-Project-c2f5ae360ee4d77e55b3e65e60dc4f349826f777.tar.gz
Common-Interface-Project-c2f5ae360ee4d77e55b3e65e60dc4f349826f777.tar.bz2
Common-Interface-Project-c2f5ae360ee4d77e55b3e65e60dc4f349826f777.zip
Added geometry.xsl to get sourcepoint and targetpoint
-rw-r--r--blocks/eda-frontend/public/geometry.xsl268
-rwxr-xr-xblocks/xcos2xml/replacesplitblocks.sh6
2 files changed, 274 insertions, 0 deletions
diff --git a/blocks/eda-frontend/public/geometry.xsl b/blocks/eda-frontend/public/geometry.xsl
new file mode 100644
index 00000000..b98b3d21
--- /dev/null
+++ b/blocks/eda-frontend/public/geometry.xsl
@@ -0,0 +1,268 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:ext="http://exslt.org/common"
+ exclude-result-prefixes="xsl ext">
+
+ <!-- copy all other nodes {{{1 -->
+ <xsl:template match="@*|node()">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:copy>
+ </xsl:template>
+ <!-- }}}1 -->
+ <xsl:key name="k-cell" match="mxCell" use="@id" />
+
+<xsl:template match="mxPoint[@as='sourcePoint']">
+ <xsl:copy>
+ <xsl:apply-templates select="@*" />
+
+ <!-- variable newx -->
+ <xsl:variable name="newx">
+ <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')">
+ <!-- Check for mxCell with sourceVertex -->
+
+ <xsl:for-each select="key('k-cell', ancestor::mxCell/@sourceVertex)">
+ <xsl:variable name="ordering">
+ <xsl:value-of select="@ordering"/>
+ </xsl:variable>
+
+ <xsl:variable name="port" select="substring-before(@style, ';')"/>
+
+ <!-- Find the mxCell whose id matches sourceVertex -->
+ <xsl:for-each select="key('k-cell', @ParentComponent)">
+ <xsl:variable name="noofport">
+ <xsl:choose>
+ <xsl:when test="$port = 'ImplicitOutputPort' or $port = 'ExplicitOutputPort'">
+ <xsl:value-of select="@implicitOutputPorts + @explicitOutputPorts" />
+ </xsl:when>
+ <xsl:when test="$port = 'ImplicitInputPort' or $port = 'ExplicitInputPort'">
+ <xsl:value-of select="@implicitInputPorts + @explicitInputPorts" />
+ </xsl:when>
+ <xsl:when test="$port = 'CommandPort'">
+ <xsl:value-of select="@commandPorts" />
+ </xsl:when>
+ <xsl:when test="$port = 'ControlPort'">
+ <xsl:value-of select="@controlPorts" />
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:for-each select="mxGeometry">
+
+ <xsl:choose>
+ <xsl:when test="$port = 'ImplicitInputPort' or $port = 'ExplicitInputPort'">
+ <xsl:value-of select="@x" />
+ </xsl:when>
+ <xsl:when test="$port = 'CommandPort' or $port = 'ControlPort'">
+ <xsl:value-of select="(@x + @width * (2 * $ordering -1) div (2 * $noofport))" />
+ </xsl:when>
+ <xsl:when test="$port = 'ImplicitOutputPort' or $port = 'ExplicitOutputPort'">
+ <xsl:value-of select="@x + @width" />
+ </xsl:when>
+
+ </xsl:choose>
+ </xsl:for-each>
+
+ </xsl:for-each>
+ </xsl:for-each>
+
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="newy">
+ <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')">
+ <!-- Check for mxCell with sourceVertex -->
+ <xsl:for-each select="key('k-cell', ancestor::mxCell/@sourceVertex)">
+ <xsl:variable name="ordering">
+ <xsl:value-of select="@ordering"/>
+ </xsl:variable>
+
+ <xsl:variable name="port" select="substring-before(@style, ';')"/>
+
+ <!-- Find the mxCell whose id matches sourceVertex -->
+ <xsl:for-each select="key('k-cell', @ParentComponent)">
+ <xsl:variable name="noofport">
+ <xsl:choose>
+ <xsl:when test="$port = 'ImplicitOutputPort' or $port = 'ExplicitOutputPort'">
+ <xsl:value-of select="@implicitOutputPorts + @explicitOutputPorts" />
+ </xsl:when>
+ <xsl:when test="$port = 'ImplicitInputPort' or $port = 'ExplicitInputPort'">
+ <xsl:value-of select="@implicitInputPorts + @explicitInputPorts" />
+ </xsl:when>
+ <xsl:when test="$port = 'CommandPort'">
+ <xsl:value-of select="@commandPorts" />
+ </xsl:when>
+ <xsl:when test="$port = 'ControlPort'">
+ <xsl:value-of select="@controlPorts" />
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:for-each select="mxGeometry">
+ <xsl:choose>
+ <xsl:when test="($port = 'ImplicitOutputPort' or $port = 'ExplicitOutputPort') or ($port = 'ImplicitInputPort' or $port = 'ExplicitInputPort')">
+ <xsl:value-of select="(@y + @height * (2 * $ordering - 1) div (2 * $noofport))" />
+ </xsl:when>
+ <xsl:when test="$port = 'CommandPort'">
+ <xsl:value-of select="@y + @height" />
+ </xsl:when>
+ <xsl:when test="$port = 'ControlPort'">
+ <xsl:value-of select="@y" />
+ </xsl:when>
+
+ </xsl:choose>
+ </xsl:for-each>
+
+ </xsl:for-each>
+ </xsl:for-each>
+
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:attribute name="x">
+ <xsl:value-of select="$newx"/>
+ </xsl:attribute>
+ <xsl:attribute name="y">
+ <xsl:value-of select="$newy"/>
+ </xsl:attribute>
+ <xsl:apply-templates select="node()" />
+
+ </xsl:copy>
+</xsl:template>
+
+<!-- targetpoint -->
+<xsl:template match="mxPoint[@as='targetPoint']">
+ <xsl:copy>
+ <xsl:apply-templates select="@*" />
+
+ <!-- variable newx -->
+ <xsl:variable name="newx">
+ <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')">
+ <!-- Check for mxCell with sourceVertex -->
+
+ <xsl:for-each select="key('k-cell', ancestor::mxCell/@targetVertex)">
+ <xsl:variable name="ordering">
+ <xsl:value-of select="@ordering"/>
+ </xsl:variable>
+
+ <xsl:variable name="port" select="substring-before(@style, ';')"/>
+
+ <!-- Find the mxCell whose id matches sourceVertex -->
+ <xsl:for-each select="key('k-cell', @ParentComponent)">
+ <xsl:variable name="noofport">
+ <xsl:choose>
+ <xsl:when test="$port = 'ImplicitOutputPort' or $port = 'ExplicitOutputPort'">
+ <xsl:value-of select="@implicitOutputPorts + @explicitOutputPorts" />
+ </xsl:when>
+ <xsl:when test="$port = 'ImplicitInputPort' or $port = 'ExplicitInputPort'">
+ <xsl:value-of select="@implicitInputPorts + @explicitInputPorts" />
+ </xsl:when>
+ <xsl:when test="$port = 'CommandPort'">
+ <xsl:value-of select="@commandPorts" />
+ </xsl:when>
+ <xsl:when test="$port = 'ControlPort'">
+ <xsl:value-of select="@controlPorts" />
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:for-each select="mxGeometry">
+
+ <xsl:choose>
+ <xsl:when test="$port = 'ImplicitInputPort' or $port = 'ExplicitInputPort'">
+ <xsl:value-of select="@x" />
+ </xsl:when>
+ <xsl:when test="$port = 'CommandPort' or $port = 'ControlPort'">
+ <xsl:value-of select="(@x + @width * (2 * $ordering -1) div (2 * $noofport))" />
+ </xsl:when>
+ <xsl:when test="$port = 'ImplicitOutputPort' or $port = 'ExplicitOutputPort'">
+ <xsl:value-of select="@x + @width" />
+ </xsl:when>
+
+ </xsl:choose>
+ </xsl:for-each>
+
+ </xsl:for-each>
+ </xsl:for-each>
+
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="newy">
+ <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')">
+ <!-- Check for mxCell with targetVertex -->
+ <xsl:for-each select="key('k-cell', ancestor::mxCell/@targetVertex)">
+ <xsl:variable name="ordering">
+ <xsl:value-of select="@ordering"/>
+ </xsl:variable>
+
+ <xsl:variable name="port" select="substring-before(@style, ';')"/>
+
+ <!-- Find the mxCell whose id matches targetVertex -->
+ <xsl:for-each select="key('k-cell', @ParentComponent)">
+ <xsl:variable name="noofport">
+ <xsl:choose>
+ <xsl:when test="$port = 'ImplicitOutputPort' or $port = 'ExplicitOutputPort'">
+ <xsl:value-of select="@implicitOutputPorts + @explicitOutputPorts" />
+ </xsl:when>
+ <xsl:when test="$port = 'ImplicitInputPort' or $port = 'ExplicitInputPort'">
+ <xsl:value-of select="@implicitInputPorts + @explicitInputPorts" />
+ </xsl:when>
+ <xsl:when test="$port = 'CommandPort'">
+ <xsl:value-of select="@commandPorts" />
+ </xsl:when>
+ <xsl:when test="$port = 'ControlPort'">
+ <xsl:value-of select="@controlPorts" />
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:for-each select="mxGeometry">
+ <xsl:choose>
+ <xsl:when test="($port = 'ImplicitOutputPort' or $port = 'ExplicitOutputPort') or ($port = 'ImplicitInputPort' or $port = 'ExplicitInputPort')">
+ <xsl:value-of select="(@y + @height * (2 * $ordering - 1) div (2 * $noofport))" />
+ </xsl:when>
+ <xsl:when test="$port = 'CommandPort'">
+ <xsl:value-of select="@y + @height" />
+ </xsl:when>
+ <xsl:when test="$port = 'ControlPort'">
+ <xsl:value-of select="@y" />
+ </xsl:when>
+
+ </xsl:choose>
+ </xsl:for-each>
+
+ </xsl:for-each>
+ </xsl:for-each>
+
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:attribute name="x">
+ <xsl:value-of select="$newx"/>
+ </xsl:attribute>
+ <xsl:attribute name="y">
+ <xsl:value-of select="$newy"/>
+ </xsl:attribute>
+ <xsl:apply-templates select="node()" />
+
+ </xsl:copy>
+</xsl:template>
+</xsl:stylesheet>
diff --git a/blocks/xcos2xml/replacesplitblocks.sh b/blocks/xcos2xml/replacesplitblocks.sh
index d703b6fa..4502bf69 100755
--- a/blocks/xcos2xml/replacesplitblocks.sh
+++ b/blocks/xcos2xml/replacesplitblocks.sh
@@ -91,6 +91,12 @@ done
xsltproc "$XSL" "$INPUT1" > "$TMPFILE1"
xmllint --format "$TMPFILE1" > "$TMPFILE2"
+INPUT1="$BASE-old.xml"
+cp -f "$TMPFILE2" "$INPUT1"
+
+
+xsltproc "eda-frontend/public/geometry.xsl" "$INPUT1" > "$TMPFILE1"
+xmllint --format "$TMPFILE1" > "$TMPFILE2"
cp -f "$TMPFILE2" "$TMPFILE1"
exit 0