summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuchita Lad2024-10-29 12:19:01 +0530
committerSuchita Lad2024-10-29 12:19:01 +0530
commitb47abc1ff685f033778fb848baab7a981a65283d (patch)
treee6f41fb2551d291571874bfb69862ae0b4b4f6bb
parent81d543d5f8379756ca1dae06a179a7d76f1630ae (diff)
downloadCommon-Interface-Project-b47abc1ff685f033778fb848baab7a981a65283d.tar.gz
Common-Interface-Project-b47abc1ff685f033778fb848baab7a981a65283d.tar.bz2
Common-Interface-Project-b47abc1ff685f033778fb848baab7a981a65283d.zip
Added ordering attribute
-rwxr-xr-xblocks/Xcos/MxGraphParser.py6
-rw-r--r--blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js63
-rw-r--r--blocks/xcos2xml/ports/port.xsl20
3 files changed, 68 insertions, 21 deletions
diff --git a/blocks/Xcos/MxGraphParser.py b/blocks/Xcos/MxGraphParser.py
index f985ad28..7360cf10 100755
--- a/blocks/Xcos/MxGraphParser.py
+++ b/blocks/Xcos/MxGraphParser.py
@@ -285,7 +285,11 @@ for root in model:
else:
orderingname = stylename
portCount[ParentComponent][orderingname] += 1
- ordering = portCount[ParentComponent][orderingname]
+
+ try:
+ ordering = attrib['ordering']
+ except KeyError:
+ ordering = portCount[ParentComponent][orderingname]
geometry = dict(componentGeometry)
mxGeometry = cell.find('mxGeometry')
if mxGeometry is not None:
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js
index ed4d7c47..cab8e760 100644
--- a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js
+++ b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js
@@ -402,6 +402,7 @@ function parseXmlToGraph (xmlDoc, graph) {
let cells = xmlDoc.documentElement.children[0].children
let cellslength = cells.length
let remainingcells = []
+ let portCount
try {
console.log('cellslength=', cellslength)
while (cellslength > 0 && cellslength !== oldcellslength) {
@@ -410,9 +411,17 @@ function parseXmlToGraph (xmlDoc, graph) {
const cellAttrs = cell.attributes
const cellChildren = cell.children
if (cellAttrs.CellType?.value === 'Component') { // is component
+ portCount = {
+ ExplicitInputPort: 0,
+ ImplicitInputPort: 0,
+ ControlPort: 0,
+ ExplicitOutputPort: 0,
+ ImplicitOutputPort: 0,
+ CommandPort: 0
+ }
const style = cellAttrs.style.value
const styleObject = styleToObject(style)
- // console.log(styleObject)
+ console.log(styleObject)
if (styleObject.rotation === undefined) {
blockrotation = 0
} else {
@@ -479,20 +488,23 @@ function parseXmlToGraph (xmlDoc, graph) {
portrotation = parseInt(styleObject.rotation)
}
let rotate = portrotation - blockrotation
- if (stylename == 'ControlPort' || stylename == 'CommandPort') {
+ if (stylename === 'ControlPort' || stylename === 'CommandPort') {
rotate -= 90
}
+ if (rotate < 0) {
+ rotate += 360
+ }
const vertexId = cellAttrs.id.value
const geom = cellChildren[0].attributes
-
+ console.log('CELLATTR:', cellAttrs)
let xPos = (geom.x !== undefined) ? Number(geom.x.value) : 0
let yPos = (geom.y !== undefined) ? Number(geom.y.value) : 0
- if (rotate != 0) {
- console.log('Ports:', styleObject)
- console.log('DIFF:', rotate)
- console.log(geom, xPos, yPos, portSize)
- }
+ // if (rotate != 0) {
+ console.log('Ports:', styleObject)
+ console.log('DIFF:', rotate)
+ console.log(geom, xPos, yPos, portSize)
+ // }
let pointX
let pointY
@@ -540,40 +552,59 @@ function parseXmlToGraph (xmlDoc, graph) {
pointY = -portSize / 2
break
}
- const xPos_old = xPos
+ const xPosOld = xPos
switch (rotatename.portdirection) {
case L2T:
xPos = yPos
- yPos = xPos_old
+ yPos = xPosOld
break
case L2R:
- xPos = 1 - xPos_old
- yPos = yPos
+ xPos = 1 - xPosOld
+ // yPos = yPos
break
case L2B:
xPos = yPos
- yPos = 1 - xPos_old
+ yPos = 1 - xPosOld
break
case T2R:
xPos = 1 - yPos
- yPos = xPos_old
+ yPos = xPosOld
break
case T2B:
- xPos = xPos_old
+ xPos = xPosOld
yPos = 1 - yPos
break
case T2L:
xPos = yPos
- yPos = xPos_old
+ yPos = xPosOld
break
}
const point = new mxPoint(pointX, pointY)
const vp = graph.insertVertex(v1, vertexId, null, xPos, yPos, portSize, portSize, style)
+
vp.geometry.relative = true
vp.geometry.offset = point
vp.CellType = 'Pin'
+ let orderingname
+ if (stylename === 'ImplicitInputPort') {
+ orderingname = 'ExplicitInputPort'
+ } else if (stylename === 'ImplicitOutputPort') {
+ orderingname = 'ExplicitOutputPort'
+ } else {
+ orderingname = stylename
+ }
+ portCount[orderingname] += 1
+ let ordering
+ if (cellAttrs.ordering) {
+ ordering = cellAttrs.ordering
+ } else {
+ ordering = portCount[orderingname]
+ }
+
+ vp.ordering = ordering
vp.ParentComponent = v1.id
+ // console.log('vp.ordering =:', cellAttrs.ordering)
} else if (cellAttrs.edge) { // is edge
const edgeId = cellAttrs.id.value
diff --git a/blocks/xcos2xml/ports/port.xsl b/blocks/xcos2xml/ports/port.xsl
index 1dee1872..435db041 100644
--- a/blocks/xcos2xml/ports/port.xsl
+++ b/blocks/xcos2xml/ports/port.xsl
@@ -22,6 +22,9 @@
<xsl:attribute name="id">
<xsl:value-of select="@id" />
</xsl:attribute>
+ <xsl:attribute name="ordering">
+ <xsl:value-of select="@ordering" />
+ </xsl:attribute>
<xsl:attribute name="vertex">1</xsl:attribute>
<xsl:attribute name="CellType">Pin</xsl:attribute>
<xsl:attribute name="ParentComponent">
@@ -32,7 +35,7 @@
<xsl:attribute name="tarx">0</xsl:attribute>
<xsl:attribute name="tary">0</xsl:attribute>
<mxGeometry>
- <xsl:variable name="numerator" select="2 * position() - 1" />
+ <xsl:variable name="numerator" select="2 * @ordering - 1" />
<xsl:attribute name="y">
<xsl:value-of select="$numerator div (2 * number($explicitInputPorts + $implicitInputPorts))"/>
</xsl:attribute>
@@ -54,6 +57,9 @@
<xsl:attribute name="id">
<xsl:value-of select="@id" />
</xsl:attribute>
+ <xsl:attribute name="ordering">
+ <xsl:value-of select="@ordering" />
+ </xsl:attribute>
<xsl:attribute name="vertex">1</xsl:attribute>
<xsl:attribute name="CellType">Pin</xsl:attribute>
<xsl:attribute name="ParentComponent">
@@ -64,7 +70,7 @@
<xsl:attribute name="tarx">0</xsl:attribute>
<xsl:attribute name="tary">0</xsl:attribute>
<mxGeometry>
- <xsl:variable name="numerator" select="2 * position() - 1" />
+ <xsl:variable name="numerator" select="2 * @ordering - 1" />
<xsl:attribute name="x">1</xsl:attribute>
<xsl:attribute name="y">
<xsl:value-of select="$numerator div (2 * number($explicitOutputPorts + $implicitOutputPorts))"/>
@@ -87,6 +93,9 @@
<xsl:attribute name="id">
<xsl:value-of select="@id" />
</xsl:attribute>
+ <xsl:attribute name="ordering">
+ <xsl:value-of select="@ordering" />
+ </xsl:attribute>
<xsl:attribute name="vertex">1</xsl:attribute>
<xsl:attribute name="CellType">Pin</xsl:attribute>
<xsl:attribute name="ParentComponent">
@@ -97,7 +106,7 @@
<xsl:attribute name="tarx">0</xsl:attribute>
<xsl:attribute name="tary">0</xsl:attribute>
<mxGeometry>
- <xsl:variable name="numerator" select="2 * position() - 1" />
+ <xsl:variable name="numerator" select="2 * @ordering - 1" />
<xsl:attribute name="x">
<xsl:value-of select="$numerator div (2 * number($commandPorts))"/>
</xsl:attribute>
@@ -120,6 +129,9 @@
<xsl:attribute name="id">
<xsl:value-of select="@id" />
</xsl:attribute>
+ <xsl:attribute name="ordering">
+ <xsl:value-of select="@ordering" />
+ </xsl:attribute>
<xsl:attribute name="vertex">1</xsl:attribute>
<xsl:attribute name="CellType">Pin</xsl:attribute>
<xsl:attribute name="ParentComponent">
@@ -130,7 +142,7 @@
<xsl:attribute name="tarx">0</xsl:attribute>
<xsl:attribute name="tary">0</xsl:attribute>
<mxGeometry>
- <xsl:variable name="numerator" select="2 * position() - 1" />
+ <xsl:variable name="numerator" select="2 * @ordering - 1" />
<xsl:attribute name="x">
<xsl:value-of select="$numerator div (2 * number($controlPorts))"/>
</xsl:attribute>