diff options
author | Sunil Shetye | 2025-06-11 17:30:11 +0530 |
---|---|---|
committer | Sunil Shetye | 2025-06-11 18:36:01 +0530 |
commit | bfb401015baf7e9960b85b7c81abc6ffa8a82d7a (patch) | |
tree | d75bb2102ca90ed9ae3b112b7d91c7cc4b2eba47 | |
parent | 265c796af7d8132b453dc2f406c4b081af749dfa (diff) | |
download | Common-Interface-Project-bfb401015baf7e9960b85b7c81abc6ffa8a82d7a.tar.gz Common-Interface-Project-bfb401015baf7e9960b85b7c81abc6ffa8a82d7a.tar.bz2 Common-Interface-Project-bfb401015baf7e9960b85b7c81abc6ffa8a82d7a.zip |
fix position of ports
do not set terminal point if the source/target is a vertex
-rw-r--r-- | blocks/eda-frontend/src/components/SchematicEditor/ComponentProperties.js | 14 | ||||
-rw-r--r-- | blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js | 4 |
2 files changed, 10 insertions, 8 deletions
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/ComponentProperties.js b/blocks/eda-frontend/src/components/SchematicEditor/ComponentProperties.js index 794c0751..8575e5e7 100644 --- a/blocks/eda-frontend/src/components/SchematicEditor/ComponentProperties.js +++ b/blocks/eda-frontend/src/components/SchematicEditor/ComponentProperties.js @@ -23,7 +23,7 @@ function getXY (portOrientation, offsetPorts, newTotalPorts, i, block) { switch (portOrientation) { case 'ExplicitInputPort': xPos = 0 - yPos = 1 - (2 * i + 1) / (2 * newTotalPorts) + yPos = (2 * i + 1) / (2 * newTotalPorts) pointX = -portSize pointY = -portSize / 2 ports = 'explicitInputPorts' @@ -31,7 +31,7 @@ function getXY (portOrientation, offsetPorts, newTotalPorts, i, block) { break case 'ImplicitInputPort': xPos = 0 - yPos = 1 - (2 * (offsetPorts + i) + 1) / (2 * newTotalPorts) + yPos = (2 * (offsetPorts + i) + 1) / (2 * newTotalPorts) pointX = -portSize pointY = -portSize / 2 ports = 'implicitInputPorts' @@ -47,7 +47,7 @@ function getXY (portOrientation, offsetPorts, newTotalPorts, i, block) { break case 'ExplicitOutputPort': xPos = 1 - yPos = 1 - (2 * i + 1) / (2 * newTotalPorts) + yPos = (2 * i + 1) / (2 * newTotalPorts) pointX = 0 pointY = -portSize / 2 ports = 'explicitOutputPorts' @@ -55,7 +55,7 @@ function getXY (portOrientation, offsetPorts, newTotalPorts, i, block) { break case 'ImplicitOutputPort': xPos = 1 - yPos = 1 - (2 * (offsetPorts + i) + 1) / (2 * newTotalPorts) + yPos = (2 * (offsetPorts + i) + 1) / (2 * newTotalPorts) pointX = 0 pointY = -portSize / 2 ports = 'implicitOutputPorts' @@ -85,8 +85,10 @@ function adjustPorts (newPorts, offsetPorts, newTotalPorts, oldPorts, block, por for (let i = 0; i < Math.min(newPorts, oldPorts); i++) { console.log('moving port', i) const { xPos, yPos, pins } = getXY(portOrientation, offsetPorts, newTotalPorts, i, block) - pins[i].geometry.x = xPos - pins[i].geometry.y = yPos + const geometry = pins[i].geometry.clone() + geometry.x = xPos + geometry.y = yPos + graph.getModel().setGeometry(pins[i], geometry) } for (let i = oldPorts; i < newPorts; i++) { console.log('adding port', i) diff --git a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js index b4fc9aa2..2d3e017b 100644 --- a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js +++ b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js @@ -582,13 +582,13 @@ function parseXmlToGraph (xmlDoc, graph) { const x1 = Number(cellAttrs.tarx.value) const y1 = Number(cellAttrs.tary.value) - if (sourceCell && (x1 !== 0 || y1 !== 0)) { + if (sourceCell && sourceCell.edge && (x1 !== 0 || y1 !== 0)) { const terminalPoint = new mxPoint(x1, y1) edge.geometry.setTerminalPoint(terminalPoint, true) } const x2 = Number(cellAttrs.tar2x.value) const y2 = Number(cellAttrs.tar2y.value) - if (targetCell && (x2 !== 0 || y2 !== 0)) { + if (targetCell && targetCell.edge && (x2 !== 0 || y2 !== 0)) { const terminalPoint2 = new mxPoint(x2, y2) edge.geometry.setTerminalPoint(terminalPoint2, false) } |