From 0c1c7452d6de879346101efe9771bc2992ed39c3 Mon Sep 17 00:00:00 2001 From: yjnoh Date: Sat, 8 Feb 2025 19:15:40 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=EB=94=94=EB=B2=84=EA=B9=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/module/useModuleBasicSetting.js | 32 +++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index 111aa7e9..1053f8a7 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -841,6 +841,8 @@ export function useModuleBasicSetting(tabNum) { const flowLines = getFlowLines(moduleSetupSurface, height) //육지붕이 아닐때만 넣는다 육지붕일땐 클릭 이벤트에 별도로 넣어놓음 + // let startPoint = flowLines.bottom + let startPoint = flowLines.bottom const moduleArray = [] @@ -860,6 +862,11 @@ export function useModuleBasicSetting(tabNum) { } } } else { + //밑에가 평면이면 좌측으로 붙여서 배치 + if (flowLines.bottom.type === 'flat') { + startPoint = flowLines.left + } + const maxLeftEndPoint = surfaceMaxLines.left.x1 //최 좌측 const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측 const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단 @@ -919,8 +926,8 @@ export function useModuleBasicSetting(tabNum) { } } else { //디버깅용 - tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) - canvas?.add(tempModule) + // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) + // canvas?.add(tempModule) } } } @@ -965,8 +972,8 @@ export function useModuleBasicSetting(tabNum) { } } - const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측 - const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단 + const maxRightEndPoint = surfaceMaxLines.right.x1 - 100 //최 우측 + const maxTopEndPoint = surfaceMaxLines.top.y1 - 50 //최 상단 const maxBottomEndPoint = surfaceMaxLines.bottom.y1 //최하단 let totalTopEndPoint = Math.abs(maxTopEndPoint - startPoint.y1) //전체 높이에서 현재 높이를 뺌 @@ -1013,6 +1020,7 @@ export function useModuleBasicSetting(tabNum) { canvas?.add(tempModule) moduleSetupArray.push(tempModule) moduleArray.push(tempModule) + canvas.renderAll() } }) } else { @@ -1021,11 +1029,13 @@ export function useModuleBasicSetting(tabNum) { canvas?.add(tempModule) moduleSetupArray.push(tempModule) moduleArray.push(tempModule) + canvas.renderAll() } } else { //디버깅용 - tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) - canvas?.add(tempModule) + // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) + // canvas?.add(tempModule) + // canvas.renderAll() } } } @@ -1134,9 +1144,9 @@ export function useModuleBasicSetting(tabNum) { } else { //최초 한번은 그냥 그린다 //겹치는지 확인해서 포함된 모듈만 그린다 - canvas?.add(tempModule) - moduleSetupArray.push(tempModule) - moduleArray.push(tempModule) + // canvas?.add(tempModule) + // moduleSetupArray.push(tempModule) + // moduleArray.push(tempModule) } } else { //디버깅용 @@ -1243,8 +1253,8 @@ export function useModuleBasicSetting(tabNum) { } } else { //디버깅용 - tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) - canvas?.add(tempModule) + // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) + // canvas?.add(tempModule) } } } From 27e42bb137cbd684e763d2af590eab9209a3df0c Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Sat, 8 Feb 2025 19:30:04 +0900 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=8Cfix:=20default=20global=20local?= =?UTF-8?q?e=20ja=20=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/localeAtom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/store/localeAtom.js b/src/store/localeAtom.js index 0f20fa87..0564e633 100644 --- a/src/store/localeAtom.js +++ b/src/store/localeAtom.js @@ -2,7 +2,7 @@ import { atom } from 'recoil' export const globalLocaleStore = atom({ key: 'globalLocaleState', - default: 'ko', + default: 'ja', }) export const appMessageStore = atom({ From 3c102a2757939d3270f7a36327f525b980ac688a Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Sat, 8 Feb 2025 20:13:57 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=EB=B3=B4=EC=A1=B0=EC=84=A0=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/roofcover/useAuxiliaryDrawing.js | 17 +++++++++++--- src/hooks/useContextMenu.js | 27 +++++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/hooks/roofcover/useAuxiliaryDrawing.js b/src/hooks/roofcover/useAuxiliaryDrawing.js index 4997bdf8..7cacdd03 100644 --- a/src/hooks/roofcover/useAuxiliaryDrawing.js +++ b/src/hooks/roofcover/useAuxiliaryDrawing.js @@ -24,7 +24,7 @@ import { calculateAngle, isSamePoint } from '@/util/qpolygon-utils' import { POLYGON_TYPE } from '@/common/common' // 보조선 작성 -export function useAuxiliaryDrawing(id) { +export function useAuxiliaryDrawing(id, isUseEffect = true) { const canvas = useRecoilValue(canvasState) const { addCanvasMouseEventListener, addDocumentEventListener, removeMouseLine, initEvent } = useEvent() // const { addCanvasMouseEventListener, addDocumentEventListener, removeMouseLine, initEvent } = useContext(EventContext) @@ -654,6 +654,8 @@ export function useAuxiliaryDrawing(id) { selectable: true, name: 'auxiliaryLine', isFixed: true, + attributes: { ...line1.attributes }, + parentId: line1.parentId, }, ) lineHistory.current.push(newLine) @@ -674,6 +676,8 @@ export function useAuxiliaryDrawing(id) { selectable: false, name: 'auxiliaryLine', isFixed: true, + attributes: { ...line1.attributes }, + parentId: line1.parentId, }) lineHistory.current.push(newLine) lineHistory.current = lineHistory.current.filter((history) => history !== line1) @@ -685,6 +689,8 @@ export function useAuxiliaryDrawing(id) { selectable: false, name: 'auxiliaryLine', isFixed: true, + attributes: { ...line1.attributes }, + parentId: line1.parentId, }) lineHistory.current.push(newLine) lineHistory.current = lineHistory.current.filter((history) => history !== line1) @@ -724,6 +730,8 @@ export function useAuxiliaryDrawing(id) { selectable: true, name: 'auxiliaryLine', isFixed: true, + attributes: { ...line1.attributes }, + parentId: line1.parentId, intersectionPoint, }) } else { @@ -733,6 +741,8 @@ export function useAuxiliaryDrawing(id) { selectable: true, name: 'auxiliaryLine', isFixed: true, + attributes: { ...line1.attributes }, + parentId: line1.parentId, intersectionPoint, }) } @@ -825,7 +835,7 @@ export function useAuxiliaryDrawing(id) { //lineHistory.current에 있는 선들 중 startPoint와 endPoint가 겹치는 line은 제거 // 겹치는 선 하나는 canvas에서 제거한다. - const tempLines = [...lineHistory.current] + const tempLines = canvas.getObjects().filter((obj) => obj.name === 'auxiliaryLine' && !obj.isAuxiliaryFixed) lineHistory.current = [] tempLines.forEach((line) => { if ( @@ -842,7 +852,7 @@ export function useAuxiliaryDrawing(id) { lineHistory.current.push(line) }) - const innerLines = lineHistory.current + const innerLines = lineHistory.current.filter((line) => line.name === 'auxiliaryLine' && line.visible) roofBases.forEach((roofBase) => { const tempPolygonPoints = [...roofBase.points].map((obj) => { @@ -865,6 +875,7 @@ export function useAuxiliaryDrawing(id) { actualSize: line.attributes?.actualSize ?? 0, planeSize: line.getLength(), } + line.isAuxiliaryFixed = true return true } }) diff --git a/src/hooks/useContextMenu.js b/src/hooks/useContextMenu.js index 38cdedc1..184a3aea 100644 --- a/src/hooks/useContextMenu.js +++ b/src/hooks/useContextMenu.js @@ -180,6 +180,12 @@ export function useContextMenu() { fn: () => { if (!currentObject) return const roof = canvas.getObjects().filter((obj) => obj.id === currentObject.attributes.roofId)[0] + if (!roof) { + // 아직 innerLines로 세팅이 안되어있는 line인 경우 제거 + canvas.remove(currentObject) + canvas.discardActiveObject() + return + } const innerLines = roof.innerLines?.filter((line) => currentObject.id !== line.id) roof.innerLines = [...innerLines] canvas.remove(currentObject) @@ -221,6 +227,11 @@ export function useContextMenu() { name: 'auxiliaryLine', attributes: { ...currentObject.attributes }, }) + + if (!currentObject.attributes.roofId) { + return + } + canvas .getObjects() .filter((obj) => obj.id === currentObject.attributes.roofId)[0] @@ -235,11 +246,21 @@ export function useContextMenu() { swalFire({ text: '지붕을 선택해주세요.' }) return } - const innerLines = canvas.getObjects().filter((obj) => obj.id === currentObject.attributes.roofId)[0].innerLines - innerLines.forEach((line) => { + const innerLines = canvas.getObjects().filter((obj) => obj.id === currentObject.attributes.roofId)[0]?.innerLines + if (innerLines) { + innerLines.forEach((line) => { + canvas.remove(line) + }) + innerLines.length = 0 + } + + // 확정되지 않은 보조선 + const notFixedAuxiliaryLines = canvas.getObjects().filter((obj) => obj.name === 'auxiliaryLine' && !obj.isAuxiliaryFixed) + + notFixedAuxiliaryLines.forEach((line) => { canvas.remove(line) }) - innerLines.length = 0 + canvas.renderAll() }, }, From ff5c3c5d4c6c3dda44bd353bffa6ab31eb06e26a Mon Sep 17 00:00:00 2001 From: yjnoh Date: Sat, 8 Feb 2025 20:14:05 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=EB=82=A8=EC=B8=A1=20=EB=B9=97=EB=A9=B4,=20?= =?UTF-8?q?=ED=8F=89=EB=A9=B4=EC=9D=BC=EB=95=8C=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 | 144 ++++++++++++---------- 1 file changed, 79 insertions(+), 65 deletions(-) diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index 1053f8a7..72035264 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -861,74 +861,76 @@ export function useModuleBasicSetting(tabNum) { startPoint = { ...startPoint, y1: startPoint.y1 - heightMargin } } } - } else { - //밑에가 평면이면 좌측으로 붙여서 배치 - if (flowLines.bottom.type === 'flat') { - startPoint = flowLines.left - } + } + //밑에가 평면이면 좌측으로 붙여서 배치 + if (flowLines.bottom.type === 'flat' && flowLines.left.type === 'curve') { + startPoint = flowLines.left + } - const maxLeftEndPoint = surfaceMaxLines.left.x1 //최 좌측 - const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측 - const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단 + const maxLeftEndPoint = surfaceMaxLines.left.x1 //최 좌측 + const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측 + const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단 - let totalLeftEndPoint = maxLeftEndPoint - startPoint.x1 - let totalTopEndPoint = maxTopEndPoint - startPoint.y1 - let totalWidth = Math.ceil(Math.abs(maxRightEndPoint - maxLeftEndPoint) / width) - let diffLeftEndPoint = Math.abs(totalLeftEndPoint / width) - let diffTopEndPoint = Math.abs(totalTopEndPoint / height) - let startColPoint = Math.abs(width * Math.ceil(diffLeftEndPoint) - startPoint.x1) - let tempMaxWidth = isMaxSetup ? width / 2 : width //최대배치인지 확인하려고 넣음 - if (isMaxSetup) totalWidth = totalWidth * 2 //최대배치시 2배로 늘려서 반씩 검사하기위함 + let totalLeftEndPoint = maxLeftEndPoint - startPoint.x1 + let totalTopEndPoint = maxTopEndPoint - startPoint.y1 + let totalWidth = Math.ceil(Math.abs(maxRightEndPoint - maxLeftEndPoint) / width) + let diffLeftEndPoint = Math.abs(totalLeftEndPoint / width) + let diffTopEndPoint = Math.abs(totalTopEndPoint / height) + let startColPoint = Math.abs(width * Math.ceil(diffLeftEndPoint) - startPoint.x1) + let tempMaxWidth = isMaxSetup ? width / 2 : width //최대배치인지 확인하려고 넣음 + if (isMaxSetup) totalWidth = totalWidth * 2 //최대배치시 2배로 늘려서 반씩 검사하기위함 - for (let j = 0; j < diffTopEndPoint; j++) { - bottomMargin = j === 0 ? 0 : intvVer * j - for (let i = 0; i <= totalWidth; i++) { - leftMargin = i === 0 ? 0 : intvHor * i - chidoriLength = 0 - if (isChidori && !isMaxSetup) { - chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor - } + for (let j = 0; j < diffTopEndPoint; j++) { + bottomMargin = j === 0 ? 0 : intvVer * j + for (let i = 0; i <= totalWidth; i++) { + leftMargin = i === 0 ? 0 : intvHor * i + chidoriLength = 0 + if (isChidori && !isMaxSetup) { + chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor + } - square = [ - [startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin], - [startColPoint + tempMaxWidth * i + width - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin], - [startColPoint + tempMaxWidth * i + width - chidoriLength + leftMargin, startPoint.y1 - height * j - height - bottomMargin], - [startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - height - bottomMargin], - [startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin], - ] + square = [ + [startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin], + [startColPoint + tempMaxWidth * i + width - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin], + [startColPoint + tempMaxWidth * i + width - chidoriLength + leftMargin, startPoint.y1 - height * j - height - bottomMargin], + [startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - height - bottomMargin], + [startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin], + ] - let squarePolygon = turf.polygon([square]) - let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1) - let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] })) + let squarePolygon = turf.polygon([square]) + let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1) + let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] })) - moduleOptions = { ...moduleOptions, fill: module.color, surfaceId: moduleSetupSurface.id, moduleInfo: module } - let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon }) + moduleOptions = { ...moduleOptions, fill: module.color, surfaceId: moduleSetupSurface.id, moduleInfo: module } + let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon }) - let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, polygonToTurfPolygon(moduleSetupSurface, true)) - let isDisjoint = checkModuleDisjointObjects(squarePolygon, containsBatchObjects) + let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, polygonToTurfPolygon(moduleSetupSurface, true)) + let isDisjoint = checkModuleDisjointObjects(squarePolygon, containsBatchObjects) - if (disjointFromTrestle && isDisjoint) { - if (index > 0) { - setupModule.forEach((item) => { - const isOverlap = item.some((item2) => turf.booleanOverlap(squarePolygon, polygonToTurfPolygon(item2, true))) - if (!isOverlap) { - canvas?.add(tempModule) - moduleSetupArray.push(tempModule) - moduleArray.push(tempModule) - } - }) - } else { - //최초 한번은 그냥 그린다 - //겹치는지 확인해서 포함된 모듈만 그린다 - canvas?.add(tempModule) - moduleSetupArray.push(tempModule) - moduleArray.push(tempModule) - } + if (disjointFromTrestle && isDisjoint) { + if (index > 0) { + setupModule.forEach((item) => { + const isOverlap = item.some((item2) => turf.booleanOverlap(squarePolygon, polygonToTurfPolygon(item2, true))) + if (!isOverlap) { + canvas?.add(tempModule) + moduleSetupArray.push(tempModule) + moduleArray.push(tempModule) + canvas.renderAll() + } + }) } else { - //디버깅용 - // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) - // canvas?.add(tempModule) + //최초 한번은 그냥 그린다 + //겹치는지 확인해서 포함된 모듈만 그린다 + canvas?.add(tempModule) + moduleSetupArray.push(tempModule) + moduleArray.push(tempModule) + canvas.renderAll() } + } else { + //디버깅용 + // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) + // canvas?.add(tempModule) + // canvas.renderAll() } } } @@ -972,8 +974,14 @@ export function useModuleBasicSetting(tabNum) { } } - const maxRightEndPoint = surfaceMaxLines.right.x1 - 100 //최 우측 - const maxTopEndPoint = surfaceMaxLines.top.y1 - 50 //최 상단 + console.log('flowLines.top', flowLines.top) + + if (flowLines.left.type === 'flat') { + startPoint = flowLines.top + } + + const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측 + const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단 const maxBottomEndPoint = surfaceMaxLines.bottom.y1 //최하단 let totalTopEndPoint = Math.abs(maxTopEndPoint - startPoint.y1) //전체 높이에서 현재 높이를 뺌 @@ -1139,19 +1147,22 @@ export function useModuleBasicSetting(tabNum) { canvas?.add(tempModule) moduleSetupArray.push(tempModule) moduleArray.push(tempModule) + canvas.renderAll() } }) } else { //최초 한번은 그냥 그린다 //겹치는지 확인해서 포함된 모듈만 그린다 - // canvas?.add(tempModule) - // moduleSetupArray.push(tempModule) - // moduleArray.push(tempModule) + canvas?.add(tempModule) + moduleSetupArray.push(tempModule) + moduleArray.push(tempModule) + canvas.renderAll() } } else { //디버깅용 - tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) - canvas?.add(tempModule) + // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) + // canvas?.add(tempModule) + // canvas.renderAll() } } } @@ -1242,6 +1253,7 @@ export function useModuleBasicSetting(tabNum) { canvas?.add(tempModule) moduleSetupArray.push(tempModule) moduleArray.push(tempModule) + canvas.renderAll() } }) } else { @@ -1250,11 +1262,13 @@ export function useModuleBasicSetting(tabNum) { canvas?.add(tempModule) moduleSetupArray.push(tempModule) moduleArray.push(tempModule) + canvas.renderAll() } } else { //디버깅용 // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) // canvas?.add(tempModule) + // canvas.renderAll() } } }