From 8d5d36fce6576f78d9856cbd6852242288898279 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Thu, 8 Jan 2026 16:41:11 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=EC=8B=A4=EC=B9=98=EC=88=98=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=20=EC=8B=9C=20=EC=86=8C=EC=88=98=EC=A0=90=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20=EB=AC=B8=EC=A0=9C=EB=A1=9C=20=EC=9D=B8=ED=95=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=AA=A8=EB=93=A0=20roof=20lines=EB=A5=BC?= =?UTF-8?q?=20=ED=99=95=EC=9D=B8=ED=95=98=EC=97=AC=20length=20=ED=86=B5?= =?UTF-8?q?=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/usePolygon.js | 78 +++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 50 deletions(-) diff --git a/src/hooks/usePolygon.js b/src/hooks/usePolygon.js index 8822fd5f..bc63c50c 100644 --- a/src/hooks/usePolygon.js +++ b/src/hooks/usePolygon.js @@ -1,19 +1,7 @@ -import { - ANGLE_TYPE, - canvasState, - currentAngleTypeSelector, - globalPitchState, - pitchTextSelector, -} from '@/store/canvasAtom' +import { ANGLE_TYPE, canvasState, currentAngleTypeSelector, globalPitchState, pitchTextSelector } from '@/store/canvasAtom' import { useRecoilValue } from 'recoil' import { fabric } from 'fabric' -import { - calculateIntersection, - findAndRemoveClosestPoint, - getDegreeByChon, - getDegreeInOrientation, - isPointOnLine, -} from '@/util/canvas-util' +import { calculateIntersection, findAndRemoveClosestPoint, getDegreeByChon, getDegreeInOrientation, isPointOnLine } from '@/util/canvas-util' import { QPolygon } from '@/components/fabric/QPolygon' import { isSamePoint, removeDuplicatePolygons } from '@/util/qpolygon-utils' import { basicSettingState, flowDisplaySelector } from '@/store/settingAtom' @@ -1392,6 +1380,8 @@ export const usePolygon = () => { // 나눠서 중복 제거된 roof return let newRoofs = getSplitRoofsPoints(allLines) + const createdRoofs = [] + newRoofs = newRoofs.filter((roof) => roof.length !== 0) newRoofs.forEach((roofPoint, index) => { let defense, pitch @@ -1634,8 +1624,8 @@ export const usePolygon = () => { }) }) - canvas.add(roof) - addLengthText(roof) + // canvas.add(roof) + createdRoofs.push(roof) canvas.remove(polygon) canvas.renderAll() }) @@ -1645,6 +1635,11 @@ export const usePolygon = () => { auxiliaryLines.forEach((line) => { canvas.remove(line) }) + + createdRoofs.forEach((roof) => { + canvas.add(roof) + }) + canvas.renderAll() canvas.discardActiveObject() } @@ -1970,38 +1965,6 @@ export const usePolygon = () => { canvas.renderAll() } - /** - * 폴리곤의 라인 길이가 10 이하로 차이나는 경우 작은 값으로 통일 - * @param polygon - */ - const unifyLineLengths = (polygon) => { - if (!polygon.lines || polygon.lines.length === 0) { - return - } - - const lines = polygon.lines - - for (let i = 0; i < lines.length; i++) { - for (let j = i + 1; j < lines.length; j++) { - const length1 = lines[i].getLength() - const length2 = lines[j].getLength() - const diff = Math.abs(length1 - length2) - - if (diff > 0 && diff <= 10) { - const minLength = Math.min(length1, length2) - if (length1 > length2) { - lines[i].setLengthByValue(minLength) - } else { - lines[j].setLengthByValue(minLength) - } - } - } - } - - addLengthText(polygon) - canvas.renderAll() - } - /** * 폴리곤의 라인 속성을 복도치수, 실제치수에 따라 actualSize 설정 * @param polygon @@ -2010,7 +1973,23 @@ export const usePolygon = () => { if (!polygon.lines || polygon.lines.length === 0 || !polygon.roofMaterial) { return } - unifyLineLengths(polygon) + + // createdRoofs들의 모든 lines를 확인해서 length값이 1이하인 차이가 있으면 통일 시킨다. + const allRoofs = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF) + const allRoofLines = allRoofs.flatMap((roof) => roof.lines) + for (let i = 0; i < allRoofLines.length; i++) { + for (let j = i + 1; j < allRoofLines.length; j++) { + const line1 = allRoofLines[i] + const line2 = allRoofLines[j] + const diff = Math.abs(line1.length - line2.length) + if (diff > 0 && diff <= 1) { + const minLength = Math.min(line1.length, line2.length) + line1.setLengthByValue(minLength * 10) + line2.setLengthByValue(minLength * 10) + } + } + } + polygon.lines.forEach((line) => { setActualSize(line, polygon.direction, +polygon.roofMaterial?.pitch) }) @@ -2027,6 +2006,5 @@ export const usePolygon = () => { splitPolygonWithLines, splitPolygonWithSeparate, setPolygonLinesActualSize, - unifyLineLengths, } } From fbb1f352e9f8f7b686fa8a5f87d6c145ac4c18e9 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Thu, 8 Jan 2026 17:03:14 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=EB=B2=BD=20=EB=9D=BC=EC=9D=B8=20wallLine?= =?UTF-8?q?=20=EC=86=8D=EC=84=B1=20=EB=B3=80=EA=B2=BD=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../roofcover/useRoofAllocationSetting.js | 49 +++++-------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/src/hooks/roofcover/useRoofAllocationSetting.js b/src/hooks/roofcover/useRoofAllocationSetting.js index 69479eef..70874765 100644 --- a/src/hooks/roofcover/useRoofAllocationSetting.js +++ b/src/hooks/roofcover/useRoofAllocationSetting.js @@ -323,42 +323,19 @@ export function useRoofAllocationSetting(id) { } const drawOriginRoofLine = () => { - // outerLinePoints 배열을 이용하여 빨간색 Line 객체들 생성 - if (outerLinePoints && outerLinePoints.length > 1) { - // 연속된 점들을 연결하여 라인 생성 - for (let i = 0; i < outerLinePoints.length - 1; i++) { - const point1 = outerLinePoints[i] - const point2 = outerLinePoints[i + 1] - - const line = new fabric.Line([point1.x, point1.y, point2.x, point2.y], { - stroke: 'black', - strokeDashArray: [5, 2], - strokeWidth: 1, - selectable: false, - name: 'originRoofOuterLine', - visible: outlineDisplay, - }) - - canvas.add(line) - } - - // 마지막 점과 첫 점을 연결하여 폐곡선 만들기 - if (outerLinePoints.length > 2) { - const lastPoint = outerLinePoints[outerLinePoints.length - 1] - const firstPoint = outerLinePoints[0] - - const closingLine = new fabric.Line([lastPoint.x, lastPoint.y, firstPoint.x, firstPoint.y], { - stroke: 'red', - strokeWidth: 2, - selectable: false, - name: 'originRoofOuterLine', - }) - - canvas.add(closingLine) - } - - canvas.renderAll() - } + const wallLines = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.WALL) + /** 벽면 삭제 */ + wallLines.forEach((wallLine) => { + wallLine.set({ + stroke: 'black', + strokeDashArray: [5, 2], + strokeWidth: 1, + selectable: false, + name: 'originRoofOuterLine', + visible: outlineDisplay, + }) + }) + canvas.renderAll() } /** From de707796a36ab3cc909632de934c8748b7384a57 Mon Sep 17 00:00:00 2001 From: ysCha Date: Thu, 8 Jan 2026 18:12:10 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=EB=8D=94=EB=B8=94=EA=B3=84=EC=82=B0?= =?UTF-8?q?=ED=8C=A8=EB=93=9C=EB=85=B8=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../floor-plan/modal/lineTypes/RightAngle.jsx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/components/floor-plan/modal/lineTypes/RightAngle.jsx b/src/components/floor-plan/modal/lineTypes/RightAngle.jsx index ef2f00e2..a4356b4a 100644 --- a/src/components/floor-plan/modal/lineTypes/RightAngle.jsx +++ b/src/components/floor-plan/modal/lineTypes/RightAngle.jsx @@ -61,28 +61,40 @@ export default function RightAngle({ props }) {