변별로 설정 작업중
This commit is contained in:
parent
78d27e9bef
commit
637c7a75d5
@ -18,6 +18,7 @@
|
|||||||
출폭: offset
|
출폭: offset
|
||||||
폭: width
|
폭: width
|
||||||
경사(구배): pitch
|
경사(구배): pitch
|
||||||
|
각도: degree
|
||||||
이구배: doublePitch
|
이구배: doublePitch
|
||||||
소매: sleeve
|
소매: sleeve
|
||||||
개구: openSpace
|
개구: openSpace
|
||||||
|
|||||||
@ -115,5 +115,6 @@ export const INPUT_TYPE = {
|
|||||||
|
|
||||||
export const POLYGON_TYPE = {
|
export const POLYGON_TYPE = {
|
||||||
ROOF: 'roof',
|
ROOF: 'roof',
|
||||||
|
WALL: 'wall',
|
||||||
TRESTLE: 'trestle',
|
TRESTLE: 'trestle',
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,7 @@ import QEmptyContextMenu from '@/components/common/context-menu/QEmptyContextMen
|
|||||||
import InitSettingsModal from './InitSettingsModal'
|
import InitSettingsModal from './InitSettingsModal'
|
||||||
import GridSettingsModal from './GridSettingsModal'
|
import GridSettingsModal from './GridSettingsModal'
|
||||||
import { SurfaceShapeModal } from '@/components/ui/SurfaceShape'
|
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 ThumbnailList from '@/components/ui/ThumbnailLIst'
|
||||||
import ObjectPlacement from '@/components/ui/ObjectPlacement'
|
import ObjectPlacement from '@/components/ui/ObjectPlacement'
|
||||||
import { globalLocaleStore } from '@/store/localeAtom'
|
import { globalLocaleStore } from '@/store/localeAtom'
|
||||||
@ -431,7 +431,7 @@ export default function Roof2(props) {
|
|||||||
{ x: 450, y: 850 },
|
{ x: 450, y: 850 },
|
||||||
]
|
]
|
||||||
|
|
||||||
const polygon = new QPolygon(rectangleType1, {
|
const polygon = new QPolygon(rectangleType2, {
|
||||||
fill: 'transparent',
|
fill: 'transparent',
|
||||||
stroke: 'green',
|
stroke: 'green',
|
||||||
strokeWidth: 1,
|
strokeWidth: 1,
|
||||||
@ -672,18 +672,52 @@ export default function Roof2(props) {
|
|||||||
canvas?.renderAll()
|
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 = () => {
|
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) {
|
if (!isNaN(offset) && offset > 0) {
|
||||||
const polygon = canvas?.getObjects().find((obj) => obj.name === 'roof')
|
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.type = LINE_TYPE.WALLLINE.HIPANDGABLE
|
||||||
currentRoof.attributes.width = offset
|
currentRoof.attributes.width = offset
|
||||||
changeHipAndGableRoof(currentRoof, canvas)
|
changeCurrentRoof(currentRoof, canvas)
|
||||||
} else {
|
} 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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{canvas && (
|
{canvas && (
|
||||||
@ -810,19 +844,19 @@ export default function Roof2(props) {
|
|||||||
</Button>
|
</Button>
|
||||||
{/* </>*/}
|
{/* </>*/}
|
||||||
{/*)}*/}
|
{/*)}*/}
|
||||||
<Button className={'m-1 p-2'} onClick={null}>
|
<Button className={'m-1 p-2'} onClick={setHipRoof}>
|
||||||
용마루지붕
|
용마루지붕
|
||||||
</Button>
|
</Button>
|
||||||
<Button className={'m-1 p-2'} onClick={setGableRoof}>
|
<Button className={'m-1 p-2'} onClick={setHipAndGableRoof}>
|
||||||
팔작지붕
|
팔작지붕
|
||||||
</Button>
|
</Button>
|
||||||
<Button className={'m-1 p-2'} onClick={null}>
|
<Button className={'m-1 p-2'} onClick={setGableRoof}>
|
||||||
박공지붕
|
박공지붕
|
||||||
</Button>
|
</Button>
|
||||||
<Button className={'m-1 p-2'} onClick={null}>
|
<Button className={'m-1 p-2'} onClick={setJerkInHeadRoof}>
|
||||||
반절처지붕
|
반절처지붕
|
||||||
</Button>
|
</Button>
|
||||||
<Button className={'m-1 p-2'} onClick={null}>
|
<Button className={'m-1 p-2'} onClick={setWallRoof}>
|
||||||
벽지붕
|
벽지붕
|
||||||
</Button>
|
</Button>
|
||||||
<Button className="m-1 p-2" onClick={() => saveImage(uuidv4(), userId, setThumbnails)}>
|
<Button className="m-1 p-2" onClick={() => saveImage(uuidv4(), userId, setThumbnails)}>
|
||||||
|
|||||||
@ -2,26 +2,36 @@ import { fabric } from 'fabric'
|
|||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { QLine } from '@/components/fabric/QLine'
|
import { QLine } from '@/components/fabric/QLine'
|
||||||
import { distanceBetweenPoints, findTopTwoIndexesByDistance, getDirectionByPoint, sortedPointLessEightPoint, sortedPoints } from '@/util/canvas-util'
|
import { distanceBetweenPoints, findTopTwoIndexesByDistance, getDirectionByPoint, sortedPointLessEightPoint, sortedPoints } from '@/util/canvas-util'
|
||||||
import { calculateAngle, drawDirectionArrow, drawRidgeRoof, inPolygon, toGeoJSON } from '@/util/qpolygon-utils'
|
import { calculateAngle, drawRidgeRoof, inPolygon, toGeoJSON } from '@/util/qpolygon-utils'
|
||||||
import * as turf from '@turf/turf'
|
import * as turf from '@turf/turf'
|
||||||
|
import { LINE_TYPE } from '@/common/common'
|
||||||
|
|
||||||
export const QPolygon = fabric.util.createClass(fabric.Polygon, {
|
export const QPolygon = fabric.util.createClass(fabric.Polygon, {
|
||||||
type: 'QPolygon',
|
type: 'QPolygon',
|
||||||
lines: [],
|
// lines: [],
|
||||||
texts: [],
|
// texts: [],
|
||||||
id: null,
|
id: null,
|
||||||
length: 0,
|
length: 0,
|
||||||
hips: [],
|
// hips: [],
|
||||||
ridges: [],
|
// ridges: [],
|
||||||
connectRidges: [],
|
// connectRidges: [],
|
||||||
cells: [],
|
// cells: [],
|
||||||
parentId: null,
|
parentId: null,
|
||||||
innerLines: [],
|
// innerLines: [],
|
||||||
children: [],
|
// children: [],
|
||||||
initOptions: null,
|
initOptions: null,
|
||||||
direction: null,
|
direction: null,
|
||||||
arrow: null,
|
arrow: null,
|
||||||
initialize: function (points, options, canvas) {
|
initialize: function (points, options, canvas) {
|
||||||
|
this.lines = []
|
||||||
|
this.texts = []
|
||||||
|
this.hips = []
|
||||||
|
this.ridges = []
|
||||||
|
this.connectRidges = []
|
||||||
|
this.cells = []
|
||||||
|
this.innerLines = []
|
||||||
|
this.children = []
|
||||||
|
|
||||||
// 소수점 전부 제거
|
// 소수점 전부 제거
|
||||||
points.forEach((point) => {
|
points.forEach((point) => {
|
||||||
point.x = Math.round(point.x)
|
point.x = Math.round(point.x)
|
||||||
@ -180,10 +190,42 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 보조선 그리기
|
// 보조선 그리기
|
||||||
drawHelpLine(pitch = 4) {
|
drawHelpLine() {
|
||||||
// drawHelpLineInHexagon(this, pitch)
|
// drawHelpLineInHexagon(this, pitch)
|
||||||
console.log('drawHelpLine roofId : ', this.id)
|
const types = []
|
||||||
drawRidgeRoof(this.id, pitch, this.canvas)
|
this.lines.forEach((line) => types.push(line.attributes.type))
|
||||||
|
|
||||||
|
const eavesType = [LINE_TYPE.WALLLINE.EAVES, LINE_TYPE.WALLLINE.HIPANDGABLE]
|
||||||
|
const gableType = [LINE_TYPE.WALLLINE.GABLE, LINE_TYPE.WALLLINE.JERKINHEAD]
|
||||||
|
|
||||||
|
const isEaves = types.every((type) => eavesType.includes(type))
|
||||||
|
const gableOdd = types.filter((type, i) => i % 2 === 0)
|
||||||
|
const gableEven = types.filter((type, i) => i % 2 === 1)
|
||||||
|
const hasShed = types.includes(LINE_TYPE.WALLLINE.SHED)
|
||||||
|
|
||||||
|
// A형, B형 박공 지붕
|
||||||
|
if (
|
||||||
|
(gableOdd.every((type) => type === LINE_TYPE.WALLLINE.EAVES) && gableEven.every((type) => gableType.includes(type))) ||
|
||||||
|
(gableEven.every((type) => type === LINE_TYPE.WALLLINE.EAVES) && gableOdd.every((type) => gableType.includes(type)))
|
||||||
|
) {
|
||||||
|
console.log('박공 지붕')
|
||||||
|
} else if (hasShed) {
|
||||||
|
//편류지붕
|
||||||
|
let shedIndex = 0
|
||||||
|
types.forEach((type, i) => {
|
||||||
|
if (type === LINE_TYPE.WALLLINE.SHED) {
|
||||||
|
shedIndex = i
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const shedOdd = types.filter((type, i) => i % 2 === shedIndex % 2).filter((type) => type !== LINE_TYPE.WALLLINE.SHED)
|
||||||
|
const shedEven = types.filter((type, i) => i % 2 !== shedIndex % 2)
|
||||||
|
types.forEach((type, i) => console.log(type, i, i % 2, shedIndex % 2, i % 2 === shedIndex % 2))
|
||||||
|
if (shedOdd.every((type) => type === LINE_TYPE.WALLLINE.EAVES) && shedEven.every((type) => type === LINE_TYPE.WALLLINE.GABLE)) {
|
||||||
|
console.log('편류지붕')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
drawRidgeRoof(this.id, this.canvas)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addLengthText() {
|
addLengthText() {
|
||||||
|
|||||||
@ -36,7 +36,7 @@ import { QPolygon } from '@/components/fabric/QPolygon'
|
|||||||
import offsetPolygon from '@/util/qpolygon-utils'
|
import offsetPolygon from '@/util/qpolygon-utils'
|
||||||
import { isObjectNotEmpty } from '@/util/common-utils'
|
import { isObjectNotEmpty } from '@/util/common-utils'
|
||||||
import * as turf from '@turf/turf'
|
import * as turf from '@turf/turf'
|
||||||
import { INPUT_TYPE, LINE_TYPE, Mode } from '@/common/common'
|
import { INPUT_TYPE, Mode, POLYGON_TYPE } from '@/common/common'
|
||||||
|
|
||||||
export function useMode() {
|
export function useMode() {
|
||||||
const [mode, setMode] = useRecoilState(modeState)
|
const [mode, setMode] = useRecoilState(modeState)
|
||||||
@ -1506,32 +1506,23 @@ export function useMode() {
|
|||||||
*벽 지붕 외곽선 생성 polygon을 입력받아 만들기
|
*벽 지붕 외곽선 생성 polygon을 입력받아 만들기
|
||||||
*/
|
*/
|
||||||
const handleOuterlinesTest2 = (polygon, offset = 50) => {
|
const handleOuterlinesTest2 = (polygon, offset = 50) => {
|
||||||
console.log('polygon : ', polygon)
|
|
||||||
// TODO [ljyoung] : offset 입력 처리 후 제거 해야함.
|
// TODO [ljyoung] : offset 입력 처리 후 제거 해야함.
|
||||||
polygon.lines.forEach((line, index) => {
|
polygon.lines.forEach((line, index) => {
|
||||||
line.attributes = {
|
/*line.attributes = {
|
||||||
type: LINE_TYPE.WALLLINE.EAVES,
|
type: LINE_TYPE.WALLLINE.EAVES,
|
||||||
offset: 40,
|
offset: 40,
|
||||||
width: 50,
|
width: 50,
|
||||||
pitch: 4,
|
pitch: 4,
|
||||||
sleeve: true,
|
sleeve: true,
|
||||||
}
|
}*/
|
||||||
/*if (index === 1 || index === 3) {
|
/*if (index === 1 || index === 3) {
|
||||||
line.attributes = {
|
line.attributes = {
|
||||||
type: LINE_TYPE.WALLLINE.WALL,
|
type: LINE_TYPE.WALLLINE.WALL,
|
||||||
offset: 0, //출폭
|
offset: 50, //출폭
|
||||||
width: 30, //폭
|
width: 30, //폭
|
||||||
pitch: 4, //구배
|
pitch: 4, //구배
|
||||||
sleeve: true, //소매
|
sleeve: true, //소매
|
||||||
}
|
}
|
||||||
} else if (index === 0) {
|
|
||||||
line.attributes = {
|
|
||||||
type: LINE_TYPE.WALLLINE.EAVES,
|
|
||||||
offset: 0,
|
|
||||||
width: 50,
|
|
||||||
pitch: 4,
|
|
||||||
sleeve: true,
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
line.attributes = {
|
line.attributes = {
|
||||||
type: LINE_TYPE.WALLLINE.EAVES,
|
type: LINE_TYPE.WALLLINE.EAVES,
|
||||||
@ -1541,6 +1532,31 @@ export function useMode() {
|
|||||||
sleeve: true,
|
sleeve: true,
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
/* if (index === 1) {
|
||||||
|
line.attributes = {
|
||||||
|
type: LINE_TYPE.WALLLINE.SHED,
|
||||||
|
offset: 20, //출폭
|
||||||
|
width: 30, //폭
|
||||||
|
pitch: 4, //구배
|
||||||
|
sleeve: true, //소매
|
||||||
|
}
|
||||||
|
} else if (index === 3) {
|
||||||
|
line.attributes = {
|
||||||
|
type: LINE_TYPE.WALLLINE.EAVES,
|
||||||
|
offset: 50, //출폭
|
||||||
|
width: 30, //폭
|
||||||
|
pitch: 4, //구배
|
||||||
|
sleeve: true, //소매
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
line.attributes = {
|
||||||
|
type: LINE_TYPE.WALLLINE.GABLE,
|
||||||
|
offset: 30,
|
||||||
|
width: 50,
|
||||||
|
pitch: 4,
|
||||||
|
sleeve: true,
|
||||||
|
}
|
||||||
|
}*/
|
||||||
})
|
})
|
||||||
|
|
||||||
const roof = drawRoofPolygon(polygon) //지붕 그리기
|
const roof = drawRoofPolygon(polygon) //지붕 그리기
|
||||||
@ -1730,7 +1746,7 @@ export function useMode() {
|
|||||||
return { x1: point.x, y1: point.y }
|
return { x1: point.x, y1: point.y }
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
roof.name = 'roof'
|
roof.name = POLYGON_TYPE.ROOF
|
||||||
roof.setWall(wall)
|
roof.setWall(wall)
|
||||||
|
|
||||||
roof.lines.forEach((line, index) => {
|
roof.lines.forEach((line, index) => {
|
||||||
@ -1750,13 +1766,12 @@ export function useMode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wall.lines.forEach((line, index) => {
|
wall.lines.forEach((line, index) => {
|
||||||
line.attributes = {
|
line.attributes.roofId = roof.id
|
||||||
roofId: roof.id,
|
line.attributes.currentRoof = roof.lines[index].id
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('roof : ', roof)
|
console.log('drawRoofPolygon roof : ', roof)
|
||||||
console.log('wall : ', wall)
|
console.log('drawRoofPolygon wall : ', wall)
|
||||||
|
|
||||||
setRoof(roof)
|
setRoof(roof)
|
||||||
setWall(wall)
|
setWall(wall)
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { intersect } from 'mathjs'
|
import { intersect } from 'mathjs'
|
||||||
import * as turf from '@turf/turf'
|
import * as turf from '@turf/turf'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collection of function to use on canvas
|
* Collection of function to use on canvas
|
||||||
*/
|
*/
|
||||||
@ -261,6 +262,15 @@ export const getDegreeByChon = (chon) => {
|
|||||||
return Number((radians * (180 / Math.PI)).toFixed(2))
|
return Number((radians * (180 / Math.PI)).toFixed(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 각도를 입력받아 촌을 반환
|
||||||
|
* @param degree
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
|
export const getChonByDegree = (degree) => {
|
||||||
|
return Number((Math.tan((degree * Math.PI) / 180) * 10).toFixed(2))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 두 점 사이의 방향을 반환합니다.
|
* 두 점 사이의 방향을 반환합니다.
|
||||||
* @param a {fabric.Object}
|
* @param a {fabric.Object}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user