From 3dd1053eff7b70c3bbe12a3737994bfab90953c9 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Fri, 27 Jun 2025 09:52:29 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EB=8C=80=EA=B0=81=EC=9D=B4=20=EC=95=84?= =?UTF-8?q?=EB=8B=8C=EA=B2=BD=EC=9A=B0=EB=8A=94=20=EA=B8=B0=EB=B3=B8?= =?UTF-8?q?=EA=B0=92=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/module/useModuleBasicSetting.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index d95cf077..2915b548 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -133,7 +133,7 @@ export function useModuleBasicSetting(tabNum) { const offsetObjects = moduleSelectionData.roofConstructions.find((item) => item.addRoof.index === roofIndex) roof.lines.forEach((line) => { - line.attributes = { ...line.attributes, offset: getOffset(offsetObjects.addRoof, line.attributes.type, roof.pitch, roof.from) } + line.attributes = { ...line.attributes, offset: getOffset(offsetObjects.addRoof, line, roof.pitch, roof.from) } }) //배치면 설치 영역 makeModuleInstArea(roof, detail) @@ -167,7 +167,7 @@ export function useModuleBasicSetting(tabNum) { } } - const getOffset = (data, type, pitch, from = '') => { + const getOffset = (data, line, pitch, from = '') => { const degree = getDegreeByChon(pitch) //각도 // 계산 값 @@ -185,15 +185,24 @@ export function useModuleBasicSetting(tabNum) { return numerator / denominator } + const point1 = { x: line.x1, y: line.y1 } + const point2 = { x: line.x2, y: line.y2 } + let isDiagonal = false // 대각선 있는지 확인 + + const angle = calculateAngle(point1, point2) //선의 각도 계산 + if (!(Math.abs(angle) === 0 || Math.abs(angle) === 180 || Math.abs(angle) === 90)) { + isDiagonal = true + } + //경사 신장률은 1 / cos쎄타 const calculateHeightRate = 1 / Math.cos((degree * Math.PI) / 180) const calculateValue = calculateHeightRate / calculateExpression(degree) const eavesResult = from === 'roofCover' ? (data.eavesMargin * Math.cos((degree * Math.PI) / 180)) / 10 : data.eavesMargin / 10 const ridgeResult = from === 'roofCover' ? (data.ridgeMargin * Math.cos((degree * Math.PI) / 180)) / 10 : data.ridgeMargin / 10 - const kerabaMargin = from === 'roofCover' ? data.kerabaMargin / calculateValue / 10 : data.kerabaMargin / 10 + const kerabaMargin = from === 'roofCover' && isDiagonal ? data.kerabaMargin / calculateValue / 10 : data.kerabaMargin / 10 - switch (type) { + switch (line.attributes.type) { case LINE_TYPE.WALLLINE.EAVES: return eavesResult case LINE_TYPE.WALLLINE.GABLE: From f9fb5b7b50d6682698474782257c868c371b8ae2 Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Fri, 27 Jun 2025 10:46:09 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EB=8F=99=EB=A9=B4=20=EC=A0=95=EB=A0=AC=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useCirCuitTrestle.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/hooks/useCirCuitTrestle.js b/src/hooks/useCirCuitTrestle.js index 60c2b74f..12e1b28b 100644 --- a/src/hooks/useCirCuitTrestle.js +++ b/src/hooks/useCirCuitTrestle.js @@ -77,7 +77,8 @@ export function useCircuitTrestle(executeEffect = false) { const getRoofSurfaceList = () => { const roofSurfaceList = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) roofSurfaceList.sort((a, b) => a.left - b.left || b.top - a.top) - return roofSurfaceList + + const result = roofSurfaceList .map((obj) => { return { roofSurfaceId: obj.id, @@ -97,6 +98,36 @@ export function useCircuitTrestle(executeEffect = false) { } }) .filter((surface) => surface.moduleList.length > 0) + + // result 배열에서 roofSurface 값을 기준으로 순서대로 정렬한다. + + return groupSort(result) + } + + const groupSort = (arr) => { + const result = [] + const seen = new Set() // (roofSurface + "|" + roofSurfaceIncl) + + let remaining = [...arr] + + while (remaining.length > 0) { + const { roofSurface, roofSurfaceIncl } = remaining[0] + const key = `${roofSurface}|${roofSurfaceIncl}` + + // 해당 그룹 추출 + const group = remaining.filter((item) => item.roofSurface === roofSurface && item.roofSurfaceIncl === roofSurfaceIncl) + + // 이미 처리했는지 체크 후 저장 + if (!seen.has(key)) { + result.push(...group) + seen.add(key) + } + + // remaining에서 제거 + remaining = remaining.filter((item) => !(item.roofSurface === roofSurface && item.roofSurfaceIncl === roofSurfaceIncl)) + } + + return result } // 모듈 목록