diff options
author | Sunil Shetye | 2025-06-12 21:09:39 +0530 |
---|---|---|
committer | Sunil Shetye | 2025-06-12 21:09:39 +0530 |
commit | c98afc7def98a7d5be5a7bc024c928838d80fbf9 (patch) | |
tree | 9b8dda4206325a4ca1f394c1eda00bbb2b24c6e8 | |
parent | 566ee37ec1d620390c4a00a79cba7773e75f4ddd (diff) | |
download | Common-Interface-Project-c98afc7def98a7d5be5a7bc024c928838d80fbf9.tar.gz Common-Interface-Project-c98afc7def98a7d5be5a7bc024c928838d80fbf9.tar.bz2 Common-Interface-Project-c98afc7def98a7d5be5a7bc024c928838d80fbf9.zip |
rename variables for clarity
4 files changed, 17 insertions, 22 deletions
diff --git a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js index 55487fee..8d264463 100644 --- a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js +++ b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ComponentDrag.js @@ -102,7 +102,7 @@ function getXY (cell) { return [x, y] } -export default function loadGrid (container, sidebar, outline, setMainDiagramBackup, setActiveSuperBlockCell) { +export default function LoadGrid (container, sidebar, outline, setMainDiagramBackup, setActiveCellId) { // Checks if the browser is supported if (!mxClient.isBrowserSupported()) { // Displays an error message if the browser is not supported. @@ -163,7 +163,7 @@ export default function loadGrid (container, sidebar, outline, setMainDiagramBac // Save current diagram setMainDiagramBackup(getCurrentDiagramXML(graph.getModel())) - setActiveSuperBlockCell(cell) + setActiveCellId(cell.id) //update cell.SuperBlockDiagram whenever new block is added in editor manually // Parse the subdiagram diff --git a/blocks/eda-frontend/src/components/SchematicEditor/Helper/SvgParser.js b/blocks/eda-frontend/src/components/SchematicEditor/Helper/SvgParser.js index de42b7de..44734d6c 100644 --- a/blocks/eda-frontend/src/components/SchematicEditor/Helper/SvgParser.js +++ b/blocks/eda-frontend/src/components/SchematicEditor/Helper/SvgParser.js @@ -3,7 +3,7 @@ import 'mxgraph/javascript/src/css/common.css' import mxGraphFactory from 'mxgraph' -import { getRotationParameters, getPins, getPointXY, getXYPos, getSuperblockdiagram } from './ToolbarTools' +import { getRotationParameters, getPins, getPointXY, getXYPos, getSuperBlockDiagram } from './ToolbarTools' const { mxPoint @@ -56,7 +56,7 @@ export function getSvgMetadata (graph, parent, evt, target, x, y, component) { v1.controlPorts = 0 v1.commandPorts = 0 v1.simulationFunction = component.simulation_function - v1.SuperBlockDiagram = getSuperblockdiagram(component.super_block) + v1.SuperBlockDiagram = getSuperBlockDiagram(component.super_block) v1.pins = { explicitInputPorts: [], implicitInputPorts: [], diff --git a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js index 23ca543e..3378a7e2 100644 --- a/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js +++ b/blocks/eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js @@ -357,7 +357,7 @@ export function getXYPos (rotationParameters, xPos, yPos) { return { xPos, yPos } } -export function getSuperblockdiagram (xml) { +export function getSuperBlockDiagram (xml) { xml = '<SuperBlockDiagram as="child" background="-1" title="">' + xml + '</SuperBlockDiagram>' const updatedDOM = mxUtils.parseXml(xml) return updatedDOM.getElementsByTagName('SuperBlockDiagram')[0] diff --git a/blocks/eda-frontend/src/pages/SchematicEditor.js b/blocks/eda-frontend/src/pages/SchematicEditor.js index 507bd6d2..857543f8 100644 --- a/blocks/eda-frontend/src/pages/SchematicEditor.js +++ b/blocks/eda-frontend/src/pages/SchematicEditor.js @@ -12,9 +12,9 @@ import LayoutMain from '../components/Shared/LayoutMain' import SchematicToolbar from '../components/SchematicEditor/SchematicToolbar' import RightSidebar from '../components/SchematicEditor/RightSidebar' import PropertiesSidebar from '../components/SchematicEditor/PropertiesSidebar' -import loadGrid from '../components/SchematicEditor/Helper/ComponentDrag' +import LoadGrid from '../components/SchematicEditor/Helper/ComponentDrag' -import { renderGalleryXML, getSuperblockdiagram } from '../components/SchematicEditor/Helper/ToolbarTools' +import { renderGalleryXML, getSuperBlockDiagram } from '../components/SchematicEditor/Helper/ToolbarTools' import '../components/SchematicEditor/Helper/SchematicEditor.css' import { fetchDiagram, fetchSchematic } from '../redux/saveSchematicSlice' import { useDispatch, useSelector } from 'react-redux' @@ -42,24 +42,22 @@ export default function SchematicEditor (props) { const isLoading = useSelector(state => state.saveSchematic.isLoading) const xmlData = useSelector(state => state.saveSchematic.xmlData) const [mainDiagramBackup, setMainDiagramBackup] = useState('') - const [activeSuperBlockCell, setActiveSuperBlockCell] = useState(null) + const [activeCellId, setActiveCellId] = useState(null) const handleDrawerToggle = () => { setMobileOpen(!mobileOpen) } function handleCloseClick () { - if (!activeSuperBlockCell) return + if (!activeCellId) return const updatedXML = getCurrentDiagramXML(graph.getModel()) - console.log('updatedXML::', typeof updatedXML, updatedXML) - const updatedDOM1 = getSuperblockdiagram(updatedXML) - console.log('updatedDOM1:', typeof updatedDOM1, updatedDOM1) + const superBlockDiagram = getSuperBlockDiagram(updatedXML) const xpath = '/SuperBlockDiagram/mxGraphModel/root/mxCell[@style]' const xpathResult = document.evaluate( xpath, - updatedDOM1, + superBlockDiagram, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null @@ -78,16 +76,14 @@ export default function SchematicEditor (props) { const defaultStyle = styleToObject(style).default styleCounts[defaultStyle] = (styleCounts[defaultStyle] || 0) + 1 }) - console.log('Style counts:', styleCounts) const maindiagram = mainDiagramBackup renderGalleryXML(maindiagram) - const blkcell = graph.getModel().getCell(activeSuperBlockCell.id) - if (blkcell !== null) { - blkcell.SuperBlockDiagram = updatedDOM1 - console.log('bkcell:', blkcell) + const activeCell = graph.getModel().getCell(activeCellId) + if (activeCell !== null) { + activeCell.SuperBlockDiagram = superBlockDiagram const refreshDisplay = changePorts( - blkcell, + activeCell, styleCounts['OUT_f'] || 0, styleCounts['OUTIMPL_f'] || 0, styleCounts['CLKOUTV_f'] || 0, @@ -100,12 +96,11 @@ export default function SchematicEditor (props) { graph.refresh() } - console.log('blockElem:', refreshDisplay, blkcell) - // Hide the close button const closeBtn = document.getElementById('closeButton') if (closeBtn) closeBtn.style.display = 'none' } + setActiveCellId(null) } @@ -120,7 +115,7 @@ export default function SchematicEditor (props) { const container = gridRef.current const sidebar = compRef.current const outline = outlineRef.current - loadGrid(container, sidebar, outline, setMainDiagramBackup, setActiveSuperBlockCell) + LoadGrid(container, sidebar, outline, setMainDiagramBackup, setActiveCellId) if (props.location.search !== '') { const query = new URLSearchParams(props.location.search) |