From 9b99be56a8525d85f9fbaae6a94372577c6fe3cc Mon Sep 17 00:00:00 2001 From: minsik Date: Wed, 27 Nov 2024 17:15:43 +0900 Subject: [PATCH 1/3] =?UTF-8?q?polygon=20=EA=B2=BD=EC=82=AC,=20=EA=B0=81?= =?UTF-8?q?=EB=8F=84,=20=EB=B0=A9=ED=96=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/qpolygon-utils.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/qpolygon-utils.js b/src/util/qpolygon-utils.js index e580fbb7..4f1e9178 100644 --- a/src/util/qpolygon-utils.js +++ b/src/util/qpolygon-utils.js @@ -1640,7 +1640,13 @@ export const drawGabledRoof = (roofId, canvas) => { selectable: false, fontSize: roof.fontSize, name: 'roofPolygon', - attributes: { roofId: roof.id, currentRoof: currentRoof.id }, + attributes: { + roofId: roof.id, + currentRoof: currentRoof.id, + pitch: currentRoof.attributes.pitch, + degree: currentRoof.attributes.degree, + direction: currentRoof.direction, + }, }) const currentDegree = currentRoof.attributes.pitch > 0 ? getDegreeByChon(currentRoof.attributes.pitch) : currentRoof.attributes.degree //지붕 각도에 따른 실측치 조정 From f603a5defa2667d2a1cf28d9696c02f03ae97133 Mon Sep 17 00:00:00 2001 From: minsik Date: Wed, 27 Nov 2024 17:16:07 +0900 Subject: [PATCH 2/3] =?UTF-8?q?useContext=20=20->=20useEvent=20=EC=9B=90?= =?UTF-8?q?=EB=B3=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/module/useModuleBasicSetting.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index f9900f56..067d9f8a 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -18,8 +18,8 @@ export function useModuleBasicSetting() { const roofDisplay = useRecoilValue(roofDisplaySelector) const [moduleSetupSurface, setModuleSetupSurface] = useRecoilState(moduleSetupSurfaceState) const [moduleIsSetup, setModuleIsSetup] = useRecoilState(moduleIsSetupState) - // const { addTargetMouseEventListener, addCanvasMouseEventListener, initEvent } = useEvent() - const { addTargetMouseEventListener, addCanvasMouseEventListener, initEvent } = useContext(EventContext) + const { addTargetMouseEventListener, addCanvasMouseEventListener, initEvent } = useEvent() + // const { addTargetMouseEventListener, addCanvasMouseEventListener, initEvent } = useContext(EventContext) const [flowModuleLine, setFlowModuleLine] = useState({}) let selectedModuleInstSurfaceArray = [] From d5eb0c71aecd54a7b357dd3196ff18744898c3f8 Mon Sep 17 00:00:00 2001 From: minsik Date: Wed, 27 Nov 2024 17:16:24 +0900 Subject: [PATCH 3/3] =?UTF-8?q?A,=20B=20=ED=8C=A8=ED=84=B4=20=EC=A7=80?= =?UTF-8?q?=EB=B6=95=EB=A9=B4=20=ED=95=A0=EB=8B=B9=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../roofcover/useRoofAllocationSetting.js | 11 +++-- src/hooks/usePolygon.js | 42 +++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/hooks/roofcover/useRoofAllocationSetting.js b/src/hooks/roofcover/useRoofAllocationSetting.js index 6cde3635..ebb0184a 100644 --- a/src/hooks/roofcover/useRoofAllocationSetting.js +++ b/src/hooks/roofcover/useRoofAllocationSetting.js @@ -18,7 +18,7 @@ import { menuTypeState } from '@/store/menuAtom' export function useRoofAllocationSetting(id) { const canvas = useRecoilValue(canvasState) const roofDisplay = useRecoilValue(roofDisplaySelector) - const { drawDirectionArrow, addLengthText, splitPolygonWithLines } = usePolygon() + const { drawDirectionArrow, addLengthText, splitPolygonWithLines, splitPolygonWithSeparate } = usePolygon() const [popupId, setPopupId] = useState(uuidv4()) const { addPopup, closePopup, closeAll } = usePopup() const { getMessage } = useMessage() @@ -188,16 +188,19 @@ export function useRoofAllocationSetting(id) { const wallLines = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.WALL) roofBases.forEach((roofBase) => { try { - splitPolygonWithLines(roofBase) + if (roofBase.separatePolygon.length > 0) { + splitPolygonWithSeparate(roofBase.separatePolygon) + } else { + splitPolygonWithLines(roofBase) + } } catch (e) { return } - roofBase.innerLines.forEach((line) => { canvas.remove(line) }) - // canvas.remove(roofBase) + canvas.remove(roofBase) }) wallLines.forEach((wallLine) => { diff --git a/src/hooks/usePolygon.js b/src/hooks/usePolygon.js index 56052379..a844dd6b 100644 --- a/src/hooks/usePolygon.js +++ b/src/hooks/usePolygon.js @@ -1026,6 +1026,47 @@ export const usePolygon = () => { }) } + const splitPolygonWithSeparate = (separates) => { + separates.forEach((separate) => { + const points = separate.lines.map((line) => { + return { x: line.x1, y: line.y1 } + }) + let defense = '' + switch (separate.attributes.direction) { + case 'top': + defense = 'east' + break + case 'right': + defense = 'south' + break + case 'bottom': + defense = 'west' + break + case 'left': + defense = 'north' + break + } + + const roof = new QPolygon(points, { + fontSize: separate.fontSize, + stroke: 'black', + fill: 'transparent', + strokeWidth: 3, + name: POLYGON_TYPE.ROOF, + originX: 'center', + originY: 'center', + selectable: true, + defense: defense, + pitch: separate.attributes.pitch, + direction: defense, + }) + + canvas.add(roof) + }) + + canvas.renderAll() + } + return { addPolygon, addPolygonByLines, @@ -1033,5 +1074,6 @@ export const usePolygon = () => { drawDirectionArrow, addLengthText, splitPolygonWithLines, + splitPolygonWithSeparate, } }