From 637c7a75d5c1a0627e248e116df391ffaf5268c4 Mon Sep 17 00:00:00 2001 From: Jaeyoung Lee Date: Fri, 25 Oct 2024 10:52:54 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B3=80=EB=B3=84=EB=A1=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=9E=91=EC=97=85=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/dictionary.txt | 1 + src/common/common.js | 1 + src/components/Roof2.jsx | 56 +- src/components/fabric/QPolygon.js | 66 +- src/hooks/useMode.js | 53 +- src/util/canvas-util.js | 10 + src/util/qpolygon-utils.js | 1348 +++++++++++++++++------------ 7 files changed, 935 insertions(+), 600 deletions(-) diff --git a/docs/dictionary.txt b/docs/dictionary.txt index 7e07124d..f5f461b7 100644 --- a/docs/dictionary.txt +++ b/docs/dictionary.txt @@ -18,6 +18,7 @@ 출폭: offset 폭: width 경사(구배): pitch +각도: degree 이구배: doublePitch 소매: sleeve 개구: openSpace diff --git a/src/common/common.js b/src/common/common.js index 2319279b..5a14fa38 100644 --- a/src/common/common.js +++ b/src/common/common.js @@ -115,5 +115,6 @@ export const INPUT_TYPE = { export const POLYGON_TYPE = { ROOF: 'roof', + WALL: 'wall', TRESTLE: 'trestle', } diff --git a/src/components/Roof2.jsx b/src/components/Roof2.jsx index 2fe86ecc..fad075bd 100644 --- a/src/components/Roof2.jsx +++ b/src/components/Roof2.jsx @@ -39,7 +39,7 @@ import QEmptyContextMenu from '@/components/common/context-menu/QEmptyContextMen import InitSettingsModal from './InitSettingsModal' import GridSettingsModal from './GridSettingsModal' import { SurfaceShapeModal } from '@/components/ui/SurfaceShape' -import { changeHipAndGableRoof, drawDirectionStringToArrow } from '@/util/qpolygon-utils' +import { changeCurrentRoof, drawDirectionStringToArrow } from '@/util/qpolygon-utils' import ThumbnailList from '@/components/ui/ThumbnailLIst' import ObjectPlacement from '@/components/ui/ObjectPlacement' import { globalLocaleStore } from '@/store/localeAtom' @@ -431,7 +431,7 @@ export default function Roof2(props) { { x: 450, y: 850 }, ] - const polygon = new QPolygon(rectangleType1, { + const polygon = new QPolygon(rectangleType2, { fill: 'transparent', stroke: 'green', strokeWidth: 1, @@ -672,18 +672,52 @@ export default function Roof2(props) { canvas?.renderAll() } + const setHipRoof = () => { + const polygon = canvas?.getObjects().find((obj) => obj.name === 'roof') + const currentRoof = polygon.lines[2] + currentRoof.attributes.type = LINE_TYPE.WALLLINE.EAVES + currentRoof.attributes.offset = 50 + changeCurrentRoof(currentRoof, canvas) + } const setGableRoof = () => { - let offset = Number(prompt('gable roof offset', '50')) + const polygon = canvas?.getObjects().find((obj) => obj.name === 'roof') + const currentRoof = polygon.lines[2] + currentRoof.attributes.type = LINE_TYPE.WALLLINE.GABLE + currentRoof.attributes.offset = 30 + changeCurrentRoof(currentRoof, canvas) + } + const setHipAndGableRoof = () => { + let offset = Number(prompt('팔작지붕 폭', '50')) if (!isNaN(offset) && offset > 0) { const polygon = canvas?.getObjects().find((obj) => obj.name === 'roof') - const currentRoof = polygon.lines[3] + const currentRoof = polygon.lines[2] currentRoof.attributes.type = LINE_TYPE.WALLLINE.HIPANDGABLE currentRoof.attributes.width = offset - changeHipAndGableRoof(currentRoof, canvas) + changeCurrentRoof(currentRoof, canvas) } else { - alert('offset 은 0 보다 커야 함') + alert('폭은 0 보다 커야 함') } } + const setJerkInHeadRoof = () => { + let offset = Number(prompt('팔작지붕 폭', '50')) + if (!isNaN(offset) && offset > 0) { + const polygon = canvas?.getObjects().find((obj) => obj.name === 'roof') + const currentRoof = polygon.lines[2] + currentRoof.attributes.type = LINE_TYPE.WALLLINE.JERKINHEAD + currentRoof.attributes.width = offset + changeCurrentRoof(currentRoof, canvas) + } else { + alert('폭은 0 보다 커야 함') + } + } + const setWallRoof = () => { + let offset = Number(prompt('소매 폭', '0')) + const polygon = canvas?.getObjects().find((obj) => obj.name === 'roof') + const currentRoof = polygon.lines[2] + currentRoof.attributes.type = LINE_TYPE.WALLLINE.WALL + currentRoof.attributes.width = offset + changeCurrentRoof(currentRoof, canvas) + } return ( <> {canvas && ( @@ -810,19 +844,19 @@ export default function Roof2(props) { {/* */} {/*)}*/} - - - - -