From 5c592e95ccefa38164b101cdfedbf9164420fed6 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Thu, 19 Jun 2025 17:02:29 +0900 Subject: [PATCH] =?UTF-8?q?[1121]=20=E3=80=90HANASYS=20DESIGN=E3=80=91?= =?UTF-8?q?=E4=B8=A1=E7=AB=AF=E3=82=B1=E3=83=BC=E3=83=96=E3=83=AB=E3=81=AE?= =?UTF-8?q?=E7=A9=8D=E7=AE=97=E6=9D=A1=E4=BB=B6=20=EC=96=91=EB=8B=A8?= =?UTF-8?q?=EC=BC=80=EC=9D=B4=EB=B8=94=20=EA=B2=AC=EC=A0=81=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/module/useTrestle.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/hooks/module/useTrestle.js b/src/hooks/module/useTrestle.js index 4e907c91..8c34ab6b 100644 --- a/src/hooks/module/useTrestle.js +++ b/src/hooks/module/useTrestle.js @@ -2287,17 +2287,21 @@ export const useTrestle = () => { const { width: currentWidth, height: currentHeight, moduleInfo: currentModuleInfo } = m1 const { width: neighborWidth, height: neighborHeight, moduleInfo: neighborModuleInfo } = m2 + const maxWidth = Math.max(currentWidth, neighborWidth) + const maxHeight = Math.max(currentHeight, neighborHeight) + const { moduleTpCd: currentModuleTpCd } = currentModuleInfo const { moduleTpCd: neighborModuleTpCd } = neighborModuleInfo const { x: m1X, y: m1Y } = m1.getCenterPoint() const { x: m2X, y: m2Y } = m2.getCenterPoint() + sizes.push({ width: currentWidth, height: currentHeight }) if (currentModuleTpCd !== neighborModuleTpCd) { sizes.push({ width: neighborWidth, height: neighborHeight }) } - - /*m1.set({ fill: m1Fill }) + /* + m1.set({ fill: m1Fill }) m2.set({ fill: m2Fill }) canvas.renderAll()*/ @@ -2331,13 +2335,13 @@ export const useTrestle = () => { // console.log(maxX, maxY, halfMaxX, halfMaxY) if (Math.abs(m1X - m2X) < 1) { - return Math.abs(Math.abs(m1Y - m2Y) - maxY) < 1 + return Math.abs(Math.abs(m1Y - m2Y) - maxY) < 1 || Math.abs(m2Y - m1Y) <= halfMaxY } else if (Math.abs(m1Y - m2Y) < 1) { - return Math.abs(Math.abs(m1X - m2X) - maxX) < 1 + return Math.abs(Math.abs(m1X - m2X) - maxX) < 1 || Math.abs(m2X - m1X) <= halfMaxX } return ( - (Math.abs(m1X - m2X) < maxX - moduleIntvlHor / 10 && Math.abs(m1Y - m2Y) < maxY - moduleIntvlVer / 10) || + (Math.abs(m1X - m2X) < maxX - moduleIntvlHor / 10 + 1 && Math.abs(m1Y - m2Y) < maxY - moduleIntvlVer / 10) || (Math.abs(Math.abs(m1X - m2X) - maxX / 2) < halfMaxX + 1 && Math.abs(Math.abs(m1Y - m2Y) - maxY) < halfMaxY + 1) || (Math.abs(Math.abs(m1X - m2X) - maxX) < halfMaxX + 1 && Math.abs(Math.abs(m1Y - m2Y) - maxY / 2) < halfMaxY + 1) ) @@ -2353,9 +2357,9 @@ export const useTrestle = () => { } if (Math.abs(m1X - m2X) < 1) { - return Math.abs(Math.abs(m1Y - m2Y) - maxX) < 1 + return Math.abs(Math.abs(m1Y - m2Y) - maxX) < 1 || Math.abs(m2Y - m1Y) <= halfMaxY } else if (Math.abs(m1Y - m2Y) < 1) { - return Math.abs(Math.abs(m1X - m2X) - maxY) < 1 + return Math.abs(Math.abs(m1X - m2X) - maxY) < 1 || Math.abs(m2X - m1X) <= halfMaxX } return ( @@ -3201,6 +3205,7 @@ export const useTrestle = () => { let cnt = 0 const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) const modules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE) + debugger surfaces.forEach((surface) => { const modules = surface.modules const groups = groupByType(modules)