From ea6a17e375010cc161d630b1e4b1c4b8f8b3e660 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Wed, 28 Jan 2026 15:24:47 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EA=B8=B8=EC=9D=B4=20=EA=B3=84=EC=82=B0=20?= =?UTF-8?q?=ED=9B=84=20=EB=A0=8C=EB=8D=94=EB=A7=81=20=EC=95=88=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=ED=98=84=EC=83=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/option/useCanvasSetting.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hooks/option/useCanvasSetting.js b/src/hooks/option/useCanvasSetting.js index 072a2987..d6cc0e2b 100644 --- a/src/hooks/option/useCanvasSetting.js +++ b/src/hooks/option/useCanvasSetting.js @@ -179,7 +179,7 @@ export function useCanvasSetting(executeEffect = true) { layout: ['ROOF_ID_SLATE', 'ROOF_ID_SINGLE'].includes(item.roofMatlCd) ? ROOF_MATERIAL_LAYOUT.STAIRS : ROOF_MATERIAL_LAYOUT.PARALLEL, hajebichi: item.roofPchBase && parseInt(item.roofPchBase), pitch: item.inclBase ? parseInt(item.inclBase) : 4, - angle: getDegreeByChon(item.inclBase ? parseInt(item.inclBase): 4) //item.angle ? parseInt(item.angle) : 21.8, + angle: getDegreeByChon(item.inclBase ? parseInt(item.inclBase) : 4), //item.angle ? parseInt(item.angle) : 21.8, })) setRoofMaterials(roofLists) return roofLists @@ -231,8 +231,9 @@ export function useCanvasSetting(executeEffect = true) { setPolygonLinesActualSize(roof) }) changeCorridorDimensionText() + canvas.renderAll() } - }, [corridorDimension]) + }, [corridorDimension, canvasSetting]) useEffect(() => { if (!executeEffect) { From ba194342243057cf6885a402a33d7b97cf8197ba Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Wed, 28 Jan 2026 17:09:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?#1438=20=EC=A7=80=EB=B6=95=EB=A9=B4=20?= =?UTF-8?q?=ED=95=A0=EB=8B=B9=20=ED=9B=84=20=EA=B3=84=EC=82=B0=EC=8B=9D=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 --- src/hooks/useLine.js | 9 ++++++- src/hooks/usePolygon.js | 54 +++++++++++++++++++++++++++++------------ 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/hooks/useLine.js b/src/hooks/useLine.js index 3e1d72e6..0d678afa 100644 --- a/src/hooks/useLine.js +++ b/src/hooks/useLine.js @@ -168,6 +168,9 @@ export const useLine = () => { * @param pitch */ const setActualSize = (line, direction, pitch = globalPitch) => { + if (line.attributes.isCalculated) { + return + } const { x1, y1, x2, y2 } = line const isHorizontal = y1 === y2 @@ -209,7 +212,11 @@ export const useLine = () => { } } - line.attributes = { ...line.attributes, actualSize: Number(line.attributes.actualSize.toFixed(0)) } + line.attributes = { + ...line.attributes, + actualSize: Number(line.attributes.actualSize.toFixed(0)), + isCalculated: true, + } } return { diff --git a/src/hooks/usePolygon.js b/src/hooks/usePolygon.js index b862047a..cca65475 100644 --- a/src/hooks/usePolygon.js +++ b/src/hooks/usePolygon.js @@ -973,7 +973,6 @@ export const usePolygon = () => { }) canvas.renderAll() - /*polygonLines.forEach((line) => { line.set({ strokeWidth: 10 }) canvas.add(line) @@ -1043,16 +1042,25 @@ export const usePolygon = () => { name: 'newLine', }) + // 두 라인 중 큰 길이로 통일 + const length1 = Math.round(Math.hypot(newLine1.x1 - newLine1.x2, newLine1.y1 - newLine1.y2)) * 10 + const length2 = Math.round(Math.hypot(newLine2.x1 - newLine2.x2, newLine2.y1 - newLine2.y2)) * 10 + const maxLength = Math.max(length1, length2) + const unifiedPlaneSize = line.attributes.planeSize ?? maxLength + const unifiedActualSize = line.attributes.actualSize ?? maxLength + newLine1.attributes = { ...line.attributes, - planeSize: Math.round(Math.hypot(newLine1.x1 - newLine1.x2, newLine1.y1 - newLine1.y2)) * 10, - actualSize: Math.round(Math.hypot(newLine1.x1 - newLine1.x2, newLine1.y1 - newLine1.y2)) * 10, + planeSize: unifiedPlaneSize, + actualSize: unifiedActualSize, } + newLine1.length = maxLength newLine2.attributes = { ...line.attributes, - planeSize: Math.round(Math.hypot(newLine2.x1 - newLine2.x2, newLine2.y1 - newLine2.y2)) * 10, - actualSize: Math.round(Math.hypot(newLine2.x1 - newLine2.x2, newLine2.y1 - newLine2.y2)) * 10, + planeSize: unifiedPlaneSize, + actualSize: unifiedActualSize, } + newLine2.length = maxLength newLines.push(newLine1, newLine2) divideLines.splice(i, 1) // 기존 line 제거 @@ -1071,11 +1079,13 @@ export const usePolygon = () => { name: 'newLine', }) + const calcLength = Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10 newLine.attributes = { ...line.attributes, - planeSize: Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10, - actualSize: Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10, + planeSize: line.attributes.planeSize ?? calcLength, + actualSize: line.attributes.actualSize ?? calcLength, } + newLine.length = line.attributes.planeSize ?? calcLength newLines.push(newLine) currentPoint = minDistancePoint @@ -1089,11 +1099,13 @@ export const usePolygon = () => { attributes: line.attributes, name: 'newLine', }) + const lastCalcLength = Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10 newLine.attributes = { ...line.attributes, - planeSize: Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10, - actualSize: Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10, + planeSize: line.attributes.planeSize ?? lastCalcLength, + actualSize: line.attributes.actualSize ?? lastCalcLength, } + newLine.length = line.attributes.planeSize ?? lastCalcLength newLines.push(newLine) divideLines.splice(i, 1) // 기존 line 제거 @@ -1946,23 +1958,33 @@ export const usePolygon = () => { const line2 = allRoofLines[j] const diff = Math.abs(line1.length - line2.length) if (diff > 0 && diff <= 2) { - const minLength = Math.min(line1.length, line2.length) - line1.setLengthByValue(minLength * 10) - line2.setLengthByValue(minLength * 10) + const maxLength = Math.max(line1.length, line2.length) + line1.setLengthByValue(maxLength * 10) + line2.setLengthByValue(maxLength * 10) + // attributes도 통일 + const maxPlaneSize = Math.max(line1.attributes.planeSize || 0, line2.attributes.planeSize || 0) + const maxActualSize = Math.max(line1.attributes.actualSize || 0, line2.attributes.actualSize || 0) + line1.attributes.planeSize = maxPlaneSize + line1.attributes.actualSize = maxActualSize + line2.attributes.planeSize = maxPlaneSize + line2.attributes.actualSize = maxActualSize } } } polygon.lines.forEach((line, index) => { + if (line.attributes.isCalculated) { + return + } //text 와 planSize 및 actualSize가 안맞는 문제 - const nextText = polygon?.texts?.[index]?.text + /*const nextText = polygon?.texts?.[index]?.text const nextPlaneSize = Number(nextText) - if (nextText != null && nextText !== '' && Number.isFinite(nextPlaneSize) ) { - if(line.attributes.actualSize !== nextPlaneSize && line.attributes.planeSize !== nextPlaneSize) { + if (nextText != null && nextText !== '' && Number.isFinite(nextPlaneSize)) { + if (line.attributes.actualSize !== nextPlaneSize && line.attributes.planeSize !== nextPlaneSize) { line.attributes.planeSize = nextPlaneSize } + }*/ - } setActualSize(line, polygon.direction, +polygon.roofMaterial?.pitch) })