From 9a023e3b76426f41596fa8168f3599dd7f208ab5 Mon Sep 17 00:00:00 2001 From: yjnoh Date: Mon, 10 Mar 2025 14:26:16 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=A4=EB=B8=8C=EC=A0=9D=ED=8A=B8=20?= =?UTF-8?q?=EB=B0=B0=EC=B9=98=20=EB=A6=AC=EC=82=AC=EC=9D=B4=EC=A6=88=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20=EA=B7=B8=EB=A6=BC=EC=9E=90=20?= =?UTF-8?q?=EC=9E=90=EC=9C=A0=20=EB=AA=A8=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../floor-plan/modal/object/SizeSetting.jsx | 6 +- src/hooks/object/useObjectBatch.js | 69 ++++++++++++------- 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/src/components/floor-plan/modal/object/SizeSetting.jsx b/src/components/floor-plan/modal/object/SizeSetting.jsx index d5c9f0d9..34e86ed8 100644 --- a/src/components/floor-plan/modal/object/SizeSetting.jsx +++ b/src/components/floor-plan/modal/object/SizeSetting.jsx @@ -33,9 +33,9 @@ export default function SizeSetting(props) { const height = heightRef.current.value if (target.name === BATCH_TYPE.OPENING || target.name === BATCH_TYPE.SHADOW) { - resizeObjectBatch(settingTarget, target, width, height) + resizeObjectBatch(settingTarget, target, width, height, id) } else if (target.name === POLYGON_TYPE.ROOF) { - resizeSurfaceShapeBatch(settingTarget, target, width, height) + resizeSurfaceShapeBatch(settingTarget, target, width, height, id) } } @@ -87,7 +87,7 @@ export default function SizeSetting(props) {
-
diff --git a/src/hooks/object/useObjectBatch.js b/src/hooks/object/useObjectBatch.js index c0c6bf75..1761aa16 100644 --- a/src/hooks/object/useObjectBatch.js +++ b/src/hooks/object/useObjectBatch.js @@ -22,6 +22,7 @@ import { v4 as uuidv4 } from 'uuid' import { fontSelector } from '@/store/fontAtom' import { useRoofFn } from '@/hooks/common/useRoofFn' import { roofDisplaySelector } from '@/store/settingAtom' +import { usePopup } from '@/hooks/usePopup' export function useObjectBatch({ isHidden, setIsHidden }) { const { getMessage } = useMessage() @@ -33,6 +34,7 @@ export function useObjectBatch({ isHidden, setIsHidden }) { const { setSurfaceShapePattern } = useRoofFn() const lengthTextFont = useRecoilValue(fontSelector('lengthText')) const roofDisplay = useRecoilValue(roofDisplaySelector) + const { closePopup } = usePopup() useEffect(() => { if (canvas) { @@ -160,12 +162,15 @@ export function useObjectBatch({ isHidden, setIsHidden }) { const rectPolygon = pointsToTurfPolygon(rectToPolygon(rect)) const selectedSurfacePolygon = polygonToTurfPolygon(selectedSurface) - //지붕 밖으로 그렸을때 - if (!turf.booleanWithin(rectPolygon, selectedSurfacePolygon)) { - swalFire({ text: getMessage('batch.object.outside.roof'), icon: 'error' }) - //일단 지워 - deleteTempObjects() - return + //그림자는 배치면이 겹친부분에도 그려져야 한다 + if (rect.name === BATCH_TYPE.OPENING_TEMP) { + //지붕 밖으로 그렸을때 + if (!turf.booleanWithin(rectPolygon, selectedSurfacePolygon)) { + swalFire({ text: getMessage('batch.object.outside.roof'), icon: 'error' }) + //일단 지워 + deleteTempObjects() + return + } } if (!isCrossChecked) { @@ -242,12 +247,15 @@ export function useObjectBatch({ isHidden, setIsHidden }) { const rectPolygon = pointsToTurfPolygon(rectToPolygon(rect)) const selectedSurfacePolygon = polygonToTurfPolygon(selectedSurface) - //지붕 밖으로 그렸을때 - if (!turf.booleanWithin(rectPolygon, selectedSurfacePolygon)) { - swalFire({ text: getMessage('batch.object.outside.roof'), icon: 'error' }) - //일단 지워 - deleteTempObjects() - return + //그림자는 배치면이 겹친부분에도 그려져야 한다 + if (rect.name === BATCH_TYPE.OPENING_TEMP) { + //지붕 밖으로 그렸을때 + if (!turf.booleanWithin(rectPolygon, selectedSurfacePolygon)) { + swalFire({ text: getMessage('batch.object.outside.roof'), icon: 'error' }) + //일단 지워 + deleteTempObjects() + return + } } if (!isCrossChecked) { @@ -1269,7 +1277,7 @@ export function useObjectBatch({ isHidden, setIsHidden }) { return { leftPoints, rightPoints, groupPoints } } - const resizeObjectBatch = (side, target, width, height) => { + const resizeObjectBatch = (side, target, width, height, popupId) => { const objectWidth = target.width const objectHeight = target.height @@ -1318,6 +1326,10 @@ export function useObjectBatch({ isHidden, setIsHidden }) { originY: target.originY, left: changedCoords.x, top: changedCoords.y, + height: toFixedWithoutRounding(height / 10, 1), + width: toFixedWithoutRounding(width / 10, 1), + scaleX: 1, + scaleY: 1, }) // target.setCoords() @@ -1327,6 +1339,8 @@ export function useObjectBatch({ isHidden, setIsHidden }) { target.points = currentPoints if (target.type === 'group') reGroupObject(target) + + closePopup(popupId) } const reGroupObject = (groupObj) => { @@ -1402,21 +1416,30 @@ export function useObjectBatch({ isHidden, setIsHidden }) { points: rectToPolygon(obj), }) - const turfObject = pointsToTurfPolygon(obj.points) + //그림자는 아무데나 설치 할 수 있게 해달라고 함 + if (obj.name === BATCH_TYPE.OPENING) { + const turfObject = pointsToTurfPolygon(obj.points) - if (turf.booleanWithin(turfObject, turfSurface)) { + if (turf.booleanWithin(turfObject, turfSurface)) { + obj.set({ + lockMovementX: true, + lockMovementY: true, + }) + + obj.setCoords() + } else { + swalFire({ + title: getMessage('batch.object.outside.roof'), + icon: 'warning', + }) + obj.set({ ...originObj, lockMovementX: true, lockMovementY: true }) + } + } else { obj.set({ lockMovementX: true, lockMovementY: true, }) - - obj.setCoords() - } else { - swalFire({ - title: getMessage('batch.object.outside.roof'), - icon: 'warning', - }) - obj.set({ ...originObj, lockMovementX: true, lockMovementY: true }) + obj.bringToFront() } } else { obj.set({