From 186716d5831f5be6d1ef4a1e17baa76f737f5ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=8B=9D?= <43837214+Minsiki@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:13:12 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=ED=99=9C=EC=84=B1=ED=99=94=20=EB=A9=94?= =?UTF-8?q?=EB=89=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/floor-plan/CanvasMenu.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/floor-plan/CanvasMenu.jsx b/src/components/floor-plan/CanvasMenu.jsx index 515ff459..b52b4a91 100644 --- a/src/components/floor-plan/CanvasMenu.jsx +++ b/src/components/floor-plan/CanvasMenu.jsx @@ -408,7 +408,7 @@ export default function CanvasMenu(props) { const checkMenuState = (menu) => { return ( (['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.type === 'outline') || - (selectedMenu === 'module' && ['drawing', 'placement'].includes(menu.type)) || + (selectedMenu === 'module' && ['placement', 'outline', 'surface'].includes(menu.type)) || (isExistModule() && ['placement', 'outline'].some((num) => num === menu.type)) || (['estimate', 'simulation'].includes(selectedMenu) && ['placement', 'outline', 'surface'].includes(menu.type)) ) From ea8c3bdd717e189d23baf008712b3039419de1a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=8B=9D?= <43837214+Minsiki@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:13:25 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=ED=9A=8C=EB=A1=9C=EC=9E=88=EC=9D=84?= =?UTF-8?q?=EB=95=8C=20=EB=AA=A8=EB=93=88=20=EC=88=98=EC=A0=95=20=EB=B6=88?= =?UTF-8?q?=EA=B0=80=ED=95=98=EA=B2=8C=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/module/useModule.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/hooks/module/useModule.js b/src/hooks/module/useModule.js index f3fc0348..50e8e091 100644 --- a/src/hooks/module/useModule.js +++ b/src/hooks/module/useModule.js @@ -536,14 +536,7 @@ export function useModule() { const moduleRowRemove = (type) => { const activeModule = canvas.getObjects().filter((obj) => canvas.getActiveObjects()[0].id === obj.id)[0] - if (activeModule.circuit) { - swalFire({ - title: getMessage('can.not.remove.module'), - icon: 'error', - type: 'alert', - }) - return - } + c const rowModules = getRowModules(activeModule) const otherModules = getOtherModules(rowModules) const objects = getObjects() @@ -671,6 +664,9 @@ export function useModule() { const moduleSetupSurface = canvas .getObjects() .filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === activeModule.surfaceId)[0] + if (moduleSetupSurface.modules.filter((module) => module.circuit).length > 0) { + return + } let width = -1 let isWarning = false if (targetModules.length === 0) { @@ -776,6 +772,9 @@ export function useModule() { const moduleSetupSurface = canvas .getObjects() .filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === activeModule.surfaceId)[0] + if (moduleSetupSurface.modules.filter((module) => module.circuit).length > 0) { + return + } let height = -1 let isWarning = false canvas.discardActiveObject() @@ -855,6 +854,14 @@ export function useModule() { } const alignModule = (type, surfaceArray) => { + if (activeModule.circuit) { + swalFire({ + title: getMessage('can.not.remove.module'), + icon: 'error', + type: 'alert', + }) + return + } surfaceArray.forEach((surface) => { const modules = surface.modules @@ -939,6 +946,7 @@ export function useModule() { .getObjects() .filter((module) => module.name === POLYGON_TYPE.MODULE && module.surfaceId === surface.id) .forEach((module) => { + canvas.remove(module.circuit) canvas.remove(module) }) }) From 7f90a9f18a007ad375448c2e7d2791d65a43b1b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=8B=9D?= <43837214+Minsiki@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:13:37 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=ED=9A=8C=EB=A1=9C=EC=9E=88=EC=9D=84?= =?UTF-8?q?=EB=95=8C=20=EB=AA=A8=EB=93=88=20=EC=88=98=EC=A0=95=20=EB=B6=88?= =?UTF-8?q?=EA=B0=80=ED=95=98=EA=B2=8C=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useContextMenu.js | 60 +++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/src/hooks/useContextMenu.js b/src/hooks/useContextMenu.js index 842cad28..f1cb43e4 100644 --- a/src/hooks/useContextMenu.js +++ b/src/hooks/useContextMenu.js @@ -706,12 +706,68 @@ export function useContextMenu() { { id: 'moduleVerticalCenterAlign', name: getMessage('contextmenu.module.vertical.align'), - fn: () => alignModule(MODULE_ALIGN_TYPE.VERTICAL, currentObject.arrayData ?? [currentObject]), + fn: () => { + if (currentObject.arrayData) { + let existCircuit = false + currentObject.arrayData.forEach((surface) => { + surface.modules.forEach((module) => { + if (module.circuit) existCircuit = true + }) + }) + if (existCircuit) { + swalFire({ + title: getMessage('can.not.move.module'), + icon: 'error', + type: 'alert', + }) + return + } + } else { + const allocatedModules = currentObject.modules.filter((module) => module.circuit !== null) + if (allocatedModules.length > 0) { + swalFire({ + title: getMessage('can.not.move.module'), + icon: 'error', + type: 'alert', + }) + return + } + } + alignModule(MODULE_ALIGN_TYPE.VERTICAL, currentObject.arrayData ?? [currentObject]) + }, }, { id: 'moduleHorizonCenterAlign', name: getMessage('contextmenu.module.horizon.align'), - fn: () => alignModule(MODULE_ALIGN_TYPE.HORIZONTAL, currentObject.arrayData ?? [currentObject]), + fn: () => { + if (currentObject.arrayData) { + let existCircuit = false + currentObject.arrayData.forEach((surface) => { + surface.modules.forEach((module) => { + if (module.circuit) existCircuit = true + }) + }) + if (existCircuit) { + swalFire({ + title: getMessage('can.not.move.module'), + icon: 'error', + type: 'alert', + }) + return + } + } else { + const allocatedModules = currentObject.modules.filter((module) => module.circuit !== null) + if (allocatedModules.length > 0) { + swalFire({ + title: getMessage('can.not.move.module'), + icon: 'error', + type: 'alert', + }) + return + } + } + alignModule(MODULE_ALIGN_TYPE.HORIZONTAL, currentObject.arrayData ?? [currentObject]) + }, }, { id: 'moduleRemove', From bc3a19d041cd19ad157bec191c491d7a76ade7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=8B=9D?= <43837214+Minsiki@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:13:58 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=EC=B9=98=EC=88=98=EC=84=A0=20property=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dimensionLine/DimensionLineSetting.jsx | 33 +++++++++++-------- src/hooks/common/useCommonUtils.js | 4 +++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx b/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx index a49c9ad6..e08bc839 100644 --- a/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx +++ b/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx @@ -31,6 +31,7 @@ export default function DimensionLineSetting(props) { useEffect(() => { if (canvas) { const dimensionObject = canvas.getActiveObject() + console.log(dimensionObject) const id = dimensionObject.groupId const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0] if (!textObj) return @@ -38,6 +39,7 @@ export default function DimensionLineSetting(props) { setBasicLength(+dimensionObject.length) setSelectedSlope1(dimensionObject.angle1) setSelectedSlope2(dimensionObject.angle2) + setSlopeAble(dimensionObject.slopeAble) } if (basicSetting.roofAngleSet === 'slope') { @@ -65,13 +67,13 @@ export default function DimensionLineSetting(props) { }, []) useEffect(() => { - if (!slopeAble) { - const dimensionObject = canvas.getActiveObject() - dimensionObject.set({ - angle1: null, - angle2: null, - }) - } + // if (!slopeAble) { + // const dimensionObject = canvas.getActiveObject() + // dimensionObject.set({ + // angle1: null, + // angle2: null, + // }) + // } }, [slopeAble]) const handleChangeLength = () => { @@ -79,19 +81,24 @@ export default function DimensionLineSetting(props) { const dimensionObject = canvas.getActiveObject() const id = dimensionObject.groupId const textObj = dimensionObject._objects.filter((obj) => obj.name === 'dimensionLineText' && obj.group.groupId === id)[0] - let resultText = +changeLength > 0 ? +changeLength : '0' - console.log(changeLength) + let resultText = +changeLength > 0 ? +changeLength : dimensionObject.length + if (slopeAble) { resultText = !selectedSlope2 - ? calculateLength(basicLength, selectedSlope1.value).toFixed(0) - : calculateLength(basicLength, selectedSlope1.value, selectedSlope2.value).toFixed(0) + ? calculateLength(resultText, selectedSlope1.value).toFixed(0) + : calculateLength(resultText, selectedSlope1.value, selectedSlope2.value).toFixed(0) } textObj.set({ text: String(resultText), }) - dimensionObject.set({ length: +resultText }) + dimensionObject.set({ + length: +changeLength > 0 ? +changeLength : dimensionObject.length, + slopeAble: slopeAble, + angle1: selectedSlope1, + angle2: selectedSlope2, + }) setBasicLength(resultText) setChangeLength('') canvas.renderAll() @@ -153,7 +160,7 @@ export default function DimensionLineSetting(props) {