From faa45a5eac751982952d19407785da507d1c2151 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Sat, 8 Feb 2025 16:34:27 +0900 Subject: [PATCH] =?UTF-8?q?=EC=99=B8=EB=B2=BD=EC=84=A0=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20=EB=B0=8F=20=EA=B2=BD=EC=82=AC=20=EC=98=A4=EB=A5=98?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContextRoofAllocationSetting.jsx | 3 +- .../roofAllocation/RoofAllocationSetting.jsx | 1 + src/hooks/common/useRoofFn.js | 29 ++++++++++++++++++- .../roofcover/useRoofAllocationSetting.js | 7 ++++- src/hooks/useContextMenu.js | 6 ++-- 5 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/components/floor-plan/modal/roofAllocation/ContextRoofAllocationSetting.jsx b/src/components/floor-plan/modal/roofAllocation/ContextRoofAllocationSetting.jsx index 4a911e9e..2374c582 100644 --- a/src/components/floor-plan/modal/roofAllocation/ContextRoofAllocationSetting.jsx +++ b/src/components/floor-plan/modal/roofAllocation/ContextRoofAllocationSetting.jsx @@ -199,9 +199,10 @@ export default function ContextRoofAllocationSetting(props) { type="text" className="input-origin block" onChange={(e) => { - handleChangeInput(e, currentAngleType === 'slope' ? 'pitch' : 'angle', index) + // handleChangeInput(e, currentAngleType === 'slope' ? 'pitch' : 'angle', index) handleChangePitch(e, index) }} + value={currentAngleType === 'slope' ? roof.pitch : roof.angle} defaultValue={currentAngleType === 'slope' ? roof.pitch : roof.angle} /> diff --git a/src/components/floor-plan/modal/roofAllocation/RoofAllocationSetting.jsx b/src/components/floor-plan/modal/roofAllocation/RoofAllocationSetting.jsx index e9f4468c..acd2291c 100644 --- a/src/components/floor-plan/modal/roofAllocation/RoofAllocationSetting.jsx +++ b/src/components/floor-plan/modal/roofAllocation/RoofAllocationSetting.jsx @@ -201,6 +201,7 @@ export default function RoofAllocationSetting(props) { onChange={(e) => { handleChangePitch(e, index) }} + value={currentAngleType === 'slope' ? roof.pitch : roof.angle} defaultValue={currentAngleType === 'slope' ? roof.pitch : roof.angle} /> diff --git a/src/hooks/common/useRoofFn.js b/src/hooks/common/useRoofFn.js index 2b81ea05..95af888c 100644 --- a/src/hooks/common/useRoofFn.js +++ b/src/hooks/common/useRoofFn.js @@ -307,5 +307,32 @@ export function useRoofFn() { return area.points.map((p) => fabric.util.transformPoint({ x: p.x - area.pathOffset.x, y: p.y - area.pathOffset.y }, area.calcTransformMatrix())) } - return { setSurfaceShapePattern, removeRoofMaterial, removeAllRoofMaterial, moveRoofMaterial } + const removeOuterLines = (currentMousePos) => { + const roofBase = canvas + .getObjects() + .filter((obj) => obj.name === POLYGON_TYPE.ROOF) + .filter((roof) => roof.inPolygon(currentMousePos)) + + if (roofBase.length === 0) { + return + } + + const roof = roofBase[0] + const wall = roof.wall + + canvas.remove(roof) + canvas.remove(wall) + + const allRoofObject = canvas + .getObjects() + .filter((obj) => /*obj !== roof && obj !== wall &&*/ obj.attributes?.roofId === roof.id || obj.parentId === roof.id || obj.parentId === wall.id) + + allRoofObject.forEach((obj) => { + canvas.remove(obj) + }) + + canvas.renderAll() + } + + return { setSurfaceShapePattern, removeRoofMaterial, removeAllRoofMaterial, moveRoofMaterial, removeOuterLines } } diff --git a/src/hooks/roofcover/useRoofAllocationSetting.js b/src/hooks/roofcover/useRoofAllocationSetting.js index ae8c78a0..c4fe1f39 100644 --- a/src/hooks/roofcover/useRoofAllocationSetting.js +++ b/src/hooks/roofcover/useRoofAllocationSetting.js @@ -495,7 +495,12 @@ export function useRoofAllocationSetting(id) { } const handleChangePitch = (e, index) => { - const value = e.target.value + let value = e.target.value + + const reg = /^[0-9]+(\.[0-9]{0,1})?$/ + if (!reg.test(value)) { + value = value.substring(0, value.length - 1) + } const newRoofList = currentRoofList.map((roof, idx) => { if (idx === index) { const result = diff --git a/src/hooks/useContextMenu.js b/src/hooks/useContextMenu.js index bb3c1683..38cdedc1 100644 --- a/src/hooks/useContextMenu.js +++ b/src/hooks/useContextMenu.js @@ -68,7 +68,7 @@ export function useContextMenu() { const { settingsData, setSettingsDataSave } = useCanvasSetting() const { swalFire } = useSwal() const { alignModule, modulesRemove, moduleRoofRemove } = useModule() - const { removeRoofMaterial, removeAllRoofMaterial, moveRoofMaterial } = useRoofFn() + const { removeRoofMaterial, removeAllRoofMaterial, moveRoofMaterial, removeOuterLines } = useRoofFn() const currentMenuSetting = () => { switch (currentMenu) { @@ -150,7 +150,9 @@ export function useContextMenu() { { id: 'wallLineRemove', name: getMessage('contextmenu.wallline.remove'), - fn: () => deleteOuterLineObject(), + fn: (currentMousePos) => { + removeOuterLines(currentMousePos) + }, }, ], [