summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuchita Lad2024-11-21 17:43:41 +0530
committerSuchita Lad2024-11-21 17:43:41 +0530
commit1d4a0bf094181a0014f8be804cd4119f026fcbdf (patch)
treedf05ecb16576b99b88e9c87dbf810cfd88c48921
parentc77b2d1bf58600322ce750d60db7d6a4d7a7f634 (diff)
downloadCommon-Interface-Project-1d4a0bf094181a0014f8be804cd4119f026fcbdf.tar.gz
Common-Interface-Project-1d4a0bf094181a0014f8be804cd4119f026fcbdf.tar.bz2
Common-Interface-Project-1d4a0bf094181a0014f8be804cd4119f026fcbdf.zip
Updated value of tarx, tary, tar2x, tar2y
-rw-r--r--blocks/eda-frontend/public/geometry.xsl242
-rw-r--r--blocks/eda-frontend/public/splitblock.xsl41
-rw-r--r--blocks/eda-frontend/src/utils/GalleryUtils.js15
3 files changed, 292 insertions, 6 deletions
diff --git a/blocks/eda-frontend/public/geometry.xsl b/blocks/eda-frontend/public/geometry.xsl
index b98b3d21..94757f79 100644
--- a/blocks/eda-frontend/public/geometry.xsl
+++ b/blocks/eda-frontend/public/geometry.xsl
@@ -265,4 +265,246 @@
</xsl:copy>
</xsl:template>
+<!-- mxcell tarx & tary & tar2x & tar2y -->
+<xsl:template match="mxCell[@edge='1']">
+ <xsl:copy>
+ <xsl:apply-templates select="@*" />
+ <xsl:variable name="newtarx">
+ <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:for-each select="key('k-cell', @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="newtary">
+ <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')">
+ <!-- Check for mxCell with sourceVertex -->
+ <xsl:for-each select="key('k-cell', @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>
+
+
+<!-- tar2x & tar2y -->
+ <xsl:variable name="newtar2x">
+ <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')">
+ <!-- Check for mxCell with sourceVertex -->
+
+ <xsl:for-each select="key('k-cell', @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="newtar2y">
+ <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')">
+ <!-- Check for mxCell with targetVertex -->
+ <xsl:for-each select="key('k-cell', @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="tarx">
+ <xsl:value-of select="$newtarx"/>
+ </xsl:attribute>
+ <xsl:attribute name="tary">
+ <xsl:value-of select="$newtary"/>
+ </xsl:attribute>
+ <xsl:attribute name="tar2x">
+ <xsl:value-of select="$newtar2x"/>
+ </xsl:attribute>
+ <xsl:attribute name="tar2y">
+ <xsl:value-of select="$newtar2y"/>
+ </xsl:attribute>
+ <xsl:apply-templates select="node()" />
+
+ </xsl:copy>
+</xsl:template>
</xsl:stylesheet>
diff --git a/blocks/eda-frontend/public/splitblock.xsl b/blocks/eda-frontend/public/splitblock.xsl
index 0e9710a2..b7771126 100644
--- a/blocks/eda-frontend/public/splitblock.xsl
+++ b/blocks/eda-frontend/public/splitblock.xsl
@@ -105,23 +105,22 @@
<mxGeometry relative="1" as="geometry">
<mxPoint>
<xsl:attribute name="x">
- <xsl:value-of select="$sourceoneblockx" />
+ <xsl:value-of select="$targetoneblockx" />
</xsl:attribute>
<xsl:attribute name="y">
- <xsl:value-of select="$sourceoneblocky" />
+ <xsl:value-of select="$targetoneblocky" />
</xsl:attribute>
<xsl:attribute name="as">sourcePoint</xsl:attribute>
</mxPoint>
- <!-- targetPoint added by suchita -->
<mxPoint>
<xsl:attribute name="x">
- <xsl:value-of select="$targetoneblockx" />
+ <xsl:value-of select="$sourceoneblockx" />
</xsl:attribute>
<xsl:attribute name="y">
- <xsl:value-of select="$targetoneblocky" />
+ <xsl:value-of select="$sourceoneblocky" />
</xsl:attribute>
<xsl:attribute name="as">targetPoint</xsl:attribute>
- </mxPoint>
+ </mxPoint>
<Array as="points">
<xsl:for-each select="$targetonewaypoints">
<xsl:copy-of select="." />
@@ -568,6 +567,36 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
+
+ <!-- <xsl:element name="variables">
+ <xsl:attribute name="targetonelinkassort">
+ <xsl:value-of select="$targetonelinkassort" />
+ </xsl:attribute>
+ <xsl:attribute name="targetoneblockx">
+ <xsl:value-of select="$targetoneblockx" />
+ </xsl:attribute>
+ <xsl:attribute name="targetoneblocky">
+ <xsl:value-of select="$targetoneblocky" />
+ </xsl:attribute>
+ <xsl:attribute name="sourceonelinkassort">
+ <xsl:value-of select="$sourceonelinkassort" />
+ </xsl:attribute>
+ <xsl:attribute name="sourceoneblockx">
+ <xsl:value-of select="$sourceoneblockx" />
+ </xsl:attribute>
+ <xsl:attribute name="sourceoneblocky">
+ <xsl:value-of select="$sourceoneblocky" />
+ </xsl:attribute>
+ <xsl:attribute name="sourcetwolinkassort">
+ <xsl:value-of select="$sourcetwolinkassort" />
+ </xsl:attribute>
+ <xsl:attribute name="sourcetwoblockx">
+ <xsl:value-of select="$sourcetwoblockx" />
+ </xsl:attribute>
+ <xsl:attribute name="sourcetwoblocky">
+ <xsl:value-of select="$sourcetwoblocky" />
+ </xsl:attribute>
+ </xsl:element> -->
<!-- }}} -->
<!-- targetonewaypoints, sourceonewaypoints: find waypoints of links connected to ports connected to splitblock (node-set) {{{ -->
diff --git a/blocks/eda-frontend/src/utils/GalleryUtils.js b/blocks/eda-frontend/src/utils/GalleryUtils.js
index cebfd93c..5abf4b9b 100644
--- a/blocks/eda-frontend/src/utils/GalleryUtils.js
+++ b/blocks/eda-frontend/src/utils/GalleryUtils.js
@@ -9,6 +9,17 @@ const getXsltProcessor = async () => {
return processor
}
+const getGeometryXsltProcessor = async () => {
+ const xcos2xml = '/geometry.xsl'
+ const response = await fetch(xcos2xml)
+ const text = await response.text()
+ const parser = new DOMParser()
+ const xsl = parser.parseFromString(text, 'application/xml')
+ const processor = new XSLTProcessor()
+ processor.importStylesheet(xsl)
+ return processor
+}
+
const getSplitXsltProcessor = async () => {
const xcos2xml = '/splitblock.xsl'
const response = await fetch(xcos2xml)
@@ -33,6 +44,8 @@ export const transformXcos = async (xmlDoc) => {
xmlDoc = removeSplits1(xmlDoc, splitProcessor)
const processor = await getXsltProcessor()
xmlDoc = processor.transformToDocument(xmlDoc)
+ const geometryprocessor = await getGeometryXsltProcessor()
+ xmlDoc = geometryprocessor.transformToDocument(xmlDoc)
return xmlDoc
}
@@ -109,6 +122,8 @@ export const transformXcos2 = async (xmlDoc) => {
xmlDoc = await removeSplits(xmlDoc, splitProcessor, 1)
const processor = await getXsltProcessor()
xmlDoc = processor.transformToDocument(xmlDoc)
+ const geometryprocessor = await getGeometryXsltProcessor()
+ xmlDoc = geometryprocessor.transformToDocument(xmlDoc)
return xmlDoc
}