지붕 형상 변경 작업 중

This commit is contained in:
Jaeyoung Lee 2024-11-04 09:39:59 +09:00
parent e28abc4c5a
commit f5661cd01f
2 changed files with 195 additions and 60 deletions

View File

@ -36,10 +36,7 @@ import { QPolygon } from '@/components/fabric/QPolygon'
import offsetPolygon from '@/util/qpolygon-utils'
import { isObjectNotEmpty } from '@/util/common-utils'
import * as turf from '@turf/turf'
import { INPUT_TYPE, Mode, POLYGON_TYPE } from '@/common/common'
import { m } from 'framer-motion'
import { set } from 'react-hook-form'
import { FaWineGlassEmpty } from 'react-icons/fa6'
import { INPUT_TYPE, LINE_TYPE, Mode, POLYGON_TYPE } from '@/common/common'
export function useMode() {
const [mode, setMode] = useRecoilState(modeState)
@ -1511,13 +1508,13 @@ export function useMode() {
const handleOuterlinesTest2 = (polygon, offset = 50) => {
// TODO [ljyoung] : offset 입력 처리 후 제거 해야함.
polygon.lines.forEach((line, index) => {
/*line.attributes = {
line.attributes = {
type: LINE_TYPE.WALLLINE.EAVES,
offset: 40,
width: 50,
pitch: 4,
sleeve: true,
}*/
}
/*if (index === 1 || index === 3) {
line.attributes = {
type: LINE_TYPE.WALLLINE.WALL,

View File

@ -1,6 +1,6 @@
import { fabric } from 'fabric'
import { QLine } from '@/components/fabric/QLine'
import { calculateIntersection, distanceBetweenPoints, findClosestPoint, getDirectionByPoint } from '@/util/canvas-util'
import { calculateIntersection, distanceBetweenPoints, findClosestPoint, getDegreeByChon, getDirectionByPoint } from '@/util/canvas-util'
import { QPolygon } from '@/components/fabric/QPolygon'
import * as turf from '@turf/turf'
import { LINE_TYPE, POLYGON_TYPE } from '@/common/common'
@ -1493,7 +1493,10 @@ const drawRidge = (roof, canvas) => {
const dist1 = distance(startXPoint, startYPoint, currentRoof.x1, currentRoof.y1)
const dist2 = distance(endXPoint, endYPoint, currentRoof.x1, currentRoof.y1)
currentRoof.attributes.ridgeCoordinate = { x1: dist1 < dist2 ? startXPoint : endXPoint, y1: dist1 < dist2 ? startYPoint : endYPoint }
currentRoof.attributes.ridgeCoordinate = {
x1: dist1 < dist2 ? startXPoint : endXPoint,
y1: dist1 < dist2 ? startYPoint : endYPoint,
}
}
}
})
@ -1585,15 +1588,27 @@ const drawHips = (roof, canvas) => {
roofLines
.filter((roof) => roof.attributes.type === LINE_TYPE.WALLLINE.EAVES && roof.attributes.ridgeCoordinate !== undefined)
.forEach((currentRoof, index) => {
const prevRoof = roof.lines[index === 0 ? roof.lines.length - 1 : index - 1]
const nextRoof = roof.lines[index === roof.lines.length - 1 ? 0 : index + 1]
const prevDegree = prevRoof.attributes.pitch > 0 ? getDegreeByChon(prevRoof.attributes.pitch) : prevRoof.attributes.degree
const currentDegree = currentRoof.attributes.pitch > 0 ? getDegreeByChon(currentRoof.attributes.pitch) : currentRoof.attributes.degree
const nextDegree = nextRoof.attributes.pitch > 0 ? getDegreeByChon(nextRoof.attributes.pitch) : nextRoof.attributes.degree
const ridgeCoordinate = currentRoof.attributes.ridgeCoordinate
const hip1 = new QLine([currentRoof.x1, currentRoof.y1, ridgeCoordinate.x1, ridgeCoordinate.y1], {
fontSize: roof.fontSize,
stroke: 'red',
strokeWidth: 1,
name: LINE_TYPE.SUBLINE.HIP,
attributes: { roofId: roof.id, currentRoof: currentRoof.id, planeSize: currentRoof.length, actualSize: currentRoof.length },
attributes: { roofId: roof.id, currentRoof: currentRoof.id },
})
canvas.add(hip1)
const hip1Base = ((Math.abs(hip1.x1 - hip1.x2) + Math.abs(hip1.y1 - hip1.y2)) / 2) * 10
const hip1Height = Math.round(hip1Base / Math.tan(((90 - currentDegree) * Math.PI) / 180))
hip1.attributes.planeSize = Math.round(Math.sqrt(Math.pow(hip1.x1 - hip1.x2, 2) + Math.pow(hip1.y1 - hip1.y2, 2))) * 10
if (prevDegree === currentDegree) {
hip1.attributes.actualSize = Math.round(Math.sqrt(Math.pow(hip1.attributes.planeSize, 2) + Math.pow(hip1Height, 2)))
}
roof.hips.push(hip1)
roof.innerLines.push(hip1)
@ -1602,9 +1617,20 @@ const drawHips = (roof, canvas) => {
stroke: 'red',
strokeWidth: 1,
name: LINE_TYPE.SUBLINE.HIP,
attributes: { roofId: roof.id, currentRoof: currentRoof.id, planeSize: currentRoof.length, actualSize: currentRoof.length },
attributes: {
roofId: roof.id,
currentRoof: currentRoof.id,
planeSize: currentRoof.length,
actualSize: currentRoof.length,
},
})
canvas.add(hip2)
const hip2Base = ((Math.abs(hip2.x1 - hip2.x2) + Math.abs(hip2.y1 - hip2.y2)) / 2) * 10
const hip2Height = Math.round(hip2Base / Math.tan(((90 - currentDegree) * Math.PI) / 180))
hip2.attributes.planeSize = Math.round(Math.sqrt(Math.pow(hip2.x1 - hip2.x2, 2) + Math.pow(hip2.y1 - hip2.y2, 2))) * 10
if (nextDegree === currentDegree) {
hip2.attributes.actualSize = Math.round(Math.sqrt(Math.pow(hip2.attributes.planeSize, 2) + Math.pow(hip2Height, 2)))
}
roof.hips.push(hip2)
roof.innerLines.push(hip2)
})
@ -1627,6 +1653,8 @@ const drawHips = (roof, canvas) => {
prevRoof = index === 0 ? roofLines[roofLines.length - 1] : roofLines[index - 1]
}
})
const prevDegree = prevRoof.attributes.pitch > 0 ? getDegreeByChon(prevRoof.attributes.pitch) : prevRoof.attributes.degree
const currentDegree = currentRoof.attributes.pitch > 0 ? getDegreeByChon(currentRoof.attributes.pitch) : currentRoof.attributes.degree
let ridgePoints = []
ridgeLines.forEach((ridge) => {
@ -1665,9 +1693,20 @@ const drawHips = (roof, canvas) => {
stroke: 'red',
strokeWidth: 1,
name: LINE_TYPE.SUBLINE.HIP,
attributes: { roofId: roof.id, currentRoof: currentRoof.id, planeSize: currentRoof.length, actualSize: currentRoof.length },
attributes: {
roofId: roof.id,
currentRoof: currentRoof.id,
planeSize: currentRoof.length,
actualSize: currentRoof.length,
},
})
canvas.add(hip)
const hipBase = ((Math.abs(hip.x1 - hip.x2) + Math.abs(hip.y1 - hip.y2)) / 2) * 10
const hipHeight = Math.round(hipBase / Math.tan(((90 - currentRoof.attributes.degree) * Math.PI) / 180))
hip.attributes.planeSize = Math.round(Math.sqrt(Math.pow(hip.x1 - hip.x2, 2) + Math.pow(hip.y1 - hip.y2, 2))) * 10
if (prevDegree === currentDegree) {
hip.attributes.actualSize = Math.round(Math.sqrt(Math.pow(hip.attributes.planeSize, 2) + Math.pow(hipHeight, 2)))
}
roof.hips.push(hip)
roof.innerLines.push(hip)
}
@ -1741,7 +1780,6 @@ const getPointInPolygon = (polygon, point, isInclude = false) => {
*/
const getAcrossLine = (polygon, currentLine, dVector) => {
let acrossLine
console.log('dVector : ', dVector)
switch (dVector) {
case 45:
acrossLine = polygon.lines
@ -2128,7 +2166,6 @@ const getMaxRidge = (length) => {
*/
const changeEavesRoof = (currentRoof, canvas) => {
if (currentRoof.attributes.type === LINE_TYPE.WALLLINE.EAVES) {
console.log('changeEavesRoof')
const roofId = currentRoof.attributes.roofId
const wall = canvas?.getObjects().find((object) => object.name === POLYGON_TYPE.WALL && object.attributes.roofId === roofId)
const roof = canvas?.getObjects().find((object) => object.name === POLYGON_TYPE.ROOF && object.id === roofId)
@ -2138,6 +2175,14 @@ const changeEavesRoof = (currentRoof, canvas) => {
if (wallLine.length > 0) {
wallLine = wallLine[0]
}
let prevRoof, nextRoof
roof.lines.forEach((r, index) => {
if (r.id === currentRoof.id) {
currentRoof = r
prevRoof = roof.lines[index === 0 ? roof.lines.length - 1 : index - 1]
nextRoof = roof.lines[index === roof.lines.length - 1 ? 0 : index + 1]
}
})
const midX = (currentRoof.x1 + currentRoof.x2) / 2 // 지붕의 X 중심
const midY = (currentRoof.y1 + currentRoof.y2) / 2 // 지붕의 Y 중심
@ -2161,12 +2206,12 @@ const changeEavesRoof = (currentRoof, canvas) => {
object.x1 !== undefined &&
object.x2 !== undefined,
)
//reDrawPolygon(roof, canvas)
innerLines
.filter((line) => line.name !== LINE_TYPE.SUBLINE.RIDGE && line.name !== LINE_TYPE.SUBLINE.HIP && line.name !== LINE_TYPE.SUBLINE.VALLEY)
.forEach((line) => canvas?.remove(line))
.forEach((line) => {
roof.innerLines = roof.innerLines.filter((l) => l.id !== line.id)
canvas?.remove(line)
})
ridgeLines = ridgeLines.filter(
(ridge) =>
@ -2242,7 +2287,14 @@ const changeEavesRoof = (currentRoof, canvas) => {
}
}
hipLines.forEach((hip) => canvas.remove(hip))
hipLines.forEach((hip) => {
roof.innerLines = roof.innerLines.filter((h) => h.id !== hip.id)
canvas.remove(hip)
})
const prevDegree = prevRoof.attributes.pitch > 0 ? getDegreeByChon(prevRoof.attributes.pitch) : prevRoof.attributes.degree
const currentDegree = currentRoof.attributes.pitch > 0 ? getDegreeByChon(currentRoof.attributes.pitch) : currentRoof.attributes.degree
const nextDegree = nextRoof.attributes.pitch > 0 ? getDegreeByChon(nextRoof.attributes.pitch) : nextRoof.attributes.degree
const hip1 = new QLine([currentRoof.x1, currentRoof.y1, hipX2, hipY2], {
fontSize: roof.fontSize,
@ -2252,11 +2304,16 @@ const changeEavesRoof = (currentRoof, canvas) => {
attributes: {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: currentRoof.length,
actualSize: currentRoof.length,
},
})
canvas?.add(hip1)
roof.innerLines.push(hip1)
const hip1Base = ((Math.abs(hip1.x1 - hip1.x2) + Math.abs(hip1.y1 - hip1.y2)) / 2) * 10
const hip1Height = Math.round(hip1Base / Math.tan(((90 - currentDegree) * Math.PI) / 180))
hip1.attributes.planeSize = Math.round(Math.sqrt(Math.pow(hip1.x1 - hip1.x2, 2) + Math.pow(hip1.y1 - hip1.y2, 2))) * 10
if (prevDegree === currentDegree) {
hip1.attributes.actualSize = Math.round(Math.sqrt(Math.pow(hip1.attributes.planeSize, 2) + Math.pow(hip1Height, 2)))
}
const hip2 = new QLine([currentRoof.x2, currentRoof.y2, hipX2, hipY2], {
fontSize: roof.fontSize,
@ -2271,6 +2328,13 @@ const changeEavesRoof = (currentRoof, canvas) => {
},
})
canvas?.add(hip2)
roof.innerLines.push(hip2)
const hip2Base = ((Math.abs(hip2.x1 - hip2.x2) + Math.abs(hip2.y1 - hip2.y2)) / 2) * 10
const hip2Height = Math.round(hip2Base / Math.tan(((90 - currentDegree) * Math.PI) / 180))
hip2.attributes.planeSize = Math.round(Math.sqrt(Math.pow(hip2.x1 - hip2.x2, 2) + Math.pow(hip2.y1 - hip2.y2, 2))) * 10
if (currentDegree === nextDegree) {
hip2.attributes.actualSize = Math.round(Math.sqrt(Math.pow(hip2.attributes.planeSize, 2) + Math.pow(hip2Height, 2)))
}
}
}
@ -2299,11 +2363,22 @@ const changeGableRoof = (currentRoof, canvas) => {
object.x1 !== undefined &&
object.x2 !== undefined,
)
// reDrawPolygon(roof, canvas)
let prevRoof, nextRoof
roof.lines.forEach((r, index) => {
if (r.id === currentRoof.id) {
currentRoof = r
prevRoof = roof.lines[index === 0 ? roof.lines.length - 1 : index - 1]
nextRoof = roof.lines[index === roof.lines.length - 1 ? 0 : index + 1]
}
})
innerLines
.filter((line) => line.name !== LINE_TYPE.SUBLINE.RIDGE && line.name !== LINE_TYPE.SUBLINE.HIP && line.name !== LINE_TYPE.SUBLINE.VALLEY)
.forEach((line) => canvas?.remove(line))
.forEach((line) => {
roof.innerLines = roof.innerLines.filter((l) => l.id !== line.id)
canvas?.remove(line)
})
ridgeLines = ridgeLines.filter(
(ridge) =>
@ -2324,7 +2399,10 @@ const changeGableRoof = (currentRoof, canvas) => {
)
}
hipLines.forEach((hip) => canvas.remove(hip))
hipLines.forEach((hip) => {
roof.innerLines = roof.innerLines.filter((h) => h.id !== hip.id)
canvas.remove(hip)
})
if ((ridgeLines === undefined || ridgeLines.length === 0) && hipLines.length >= 2) {
let points = []
@ -2356,6 +2434,9 @@ const changeGableRoof = (currentRoof, canvas) => {
}
if (ridgeLines !== undefined && ridgeLines.length > 0) {
const prevDegree = prevRoof.attributes.pitch > 0 ? getDegreeByChon(prevRoof.attributes.pitch) : prevRoof.attributes.degree
const nextDegree = nextRoof.attributes.pitch > 0 ? getDegreeByChon(nextRoof.attributes.pitch) : nextRoof.attributes.degree
const ridge = ridgeLines[0]
if (ridge.x1 === currentRoof.attributes.ridgeCoordinate.x1 && ridge.y1 === currentRoof.attributes.ridgeCoordinate.y1) {
ridge.set({
@ -2375,30 +2456,44 @@ const changeGableRoof = (currentRoof, canvas) => {
})
currentRoof.attributes.ridgeCoordinate = { x1: ridge.x2, y1: ridge.y2 }
}
let hip1 = new QLine([currentRoof.x1, currentRoof.y1, midX, midY], {
fontSize: roof.fontSize,
stroke: 'red',
strokeWidth: 1,
name: LINE_TYPE.SUBLINE.HIP,
attributes: {
roofId: roofId,
currentRoofId: currentRoof.id,
},
})
canvas?.add(hip1)
const hip1Base = ((Math.abs(hip1.x1 - hip1.x2) + Math.abs(hip1.y1 - hip1.y2)) / 2) * 10
const hip1Height = Math.round(hip1Base / Math.tan(((90 - prevDegree) * Math.PI) / 180))
hip1.attributes.planeSize = Math.round(Math.sqrt(Math.pow(hip1.x1 - hip1.x2, 2) + Math.pow(hip1.y1 - hip1.y2, 2))) * 10
hip1.attributes.actualSize = Math.round(Math.sqrt(Math.pow(hip1.attributes.planeSize, 2) + Math.pow(hip1Height, 2)))
roof.innerLines.push(hip1)
let hip2 = new QLine([currentRoof.x2, currentRoof.y2, midX, midY], {
fontSize: roof.fontSize,
stroke: 'red',
strokeWidth: 1,
name: LINE_TYPE.SUBLINE.HIP,
attributes: {
roofId: roofId,
currentRoofId: currentRoof.id,
planeSize: currentRoof.length,
actualSize: currentRoof.length,
},
})
canvas?.add(hip2)
const hip2Base = ((Math.abs(hip2.x1 - hip2.x2) + Math.abs(hip2.y1 - hip2.y2)) / 2) * 10
const hip2Height = Math.round(hip2Base / Math.tan(((90 - nextDegree) * Math.PI) / 180))
hip2.attributes.planeSize = Math.round(Math.sqrt(Math.pow(hip2.x1 - hip2.x2, 2) + Math.pow(hip2.y1 - hip2.y2, 2))) * 10
hip2.attributes.actualSize = Math.round(Math.sqrt(Math.pow(hip2.attributes.planeSize, 2) + Math.pow(hip2Height, 2)))
roof.innerLines.push(hip2)
canvas?.renderAll()
}
let hip1 = new QLine([currentRoof.x1, currentRoof.y1, midX, midY], {
fontSize: roof.fontSize,
stroke: 'red',
strokeWidth: 1,
name: LINE_TYPE.SUBLINE.HIP,
attributes: { roofId: roofId, currentRoofId: currentRoof.id, planeSize: currentRoof.length, actualSize: currentRoof.length },
})
canvas?.add(hip1)
roof.hips.push(hip1)
roof.innerLines.push(hip1)
let hip2 = new QLine([currentRoof.x2, currentRoof.y2, midX, midY], {
fontSize: roof.fontSize,
stroke: 'red',
strokeWidth: 1,
name: LINE_TYPE.SUBLINE.HIP,
attributes: { roofId: roofId, currentRoofId: currentRoof.id, planeSize: currentRoof.length, actualSize: currentRoof.length },
})
canvas?.add(hip2)
roof.hips.push(hip2)
roof.innerLines.push(hip2)
canvas?.renderAll()
}
}
@ -2436,8 +2531,6 @@ const changeHipAndGableRoof = (currentRoof, canvas) => {
const hipY2 = Math.sign(midY - midWallY) * (beta / hypotenuse) * (currentRoof.length / 2) // 추녀마루의 Y 너비
if (Math.sqrt(Math.pow(xWidth, 2) + Math.pow(yWidth, 2)) < Math.sqrt(Math.pow(hipX2, 2) + Math.pow(hipY2, 2))) {
// reDrawPolygon(roof, canvas)
const innerLines = canvas
?.getObjects()
.filter(
@ -2451,7 +2544,10 @@ const changeHipAndGableRoof = (currentRoof, canvas) => {
innerLines
.filter((line) => line.name !== LINE_TYPE.SUBLINE.RIDGE && line.name !== LINE_TYPE.SUBLINE.HIP && line.name !== LINE_TYPE.SUBLINE.VALLEY)
.forEach((line) => canvas?.remove(line))
.forEach((line) => {
roof.innerLines = roof.innerLines.filter((l) => l.id !== line.id)
canvas?.remove(line)
})
ridgeLines = ridgeLines.filter(
(ridge) =>
@ -2502,7 +2598,10 @@ const changeHipAndGableRoof = (currentRoof, canvas) => {
}
}
hipLines.forEach((hip) => canvas.remove(hip))
hipLines.forEach((hip) => {
roof.innerLines = roof.innerLines.filter((h) => h.id !== hip.id)
canvas.remove(hip)
})
hipLines = []
if (ridgeLines.length > 0) {
@ -2540,6 +2639,7 @@ const changeHipAndGableRoof = (currentRoof, canvas) => {
},
})
canvas?.add(hip1)
roof.innerLines.push(hip1)
const hip2 = new QLine([currentRoof.x2, currentRoof.y2, midX + hipX2, midY + hipY2], {
fontSize: roof.fontSize,
@ -2554,8 +2654,7 @@ const changeHipAndGableRoof = (currentRoof, canvas) => {
},
})
canvas?.add(hip2)
console.log('hipLines : ', hipLines)
roof.innerLines.push(hip2)
hipLines.push(hip1)
hipLines.push(hip2)
@ -2572,8 +2671,6 @@ const changeHipAndGableRoof = (currentRoof, canvas) => {
})
})
console.log('hipLines : ', hipLines)
hipLines.forEach((hip) => {
const gableLine = new QLine([hip.x2, hip.y2, currentRoof.attributes.ridgeCoordinate.x1, currentRoof.attributes.ridgeCoordinate.y1], {
fontSize: roof.fontSize,
@ -2587,12 +2684,10 @@ const changeHipAndGableRoof = (currentRoof, canvas) => {
actualSize: currentRoof.length,
},
})
console.log('gableLine : ', gableLine)
canvas?.add(gableLine)
roof.innerLines.push(gableLine)
})
}
console.log('roof.innerLines : ', roof.innerLines)
}
canvas?.renderAll()
}
@ -2648,7 +2743,10 @@ const changeJerkInHeadRoof = (currentRoof, canvas) => {
innerLines
.filter((line) => line.name !== LINE_TYPE.SUBLINE.RIDGE && line.name !== LINE_TYPE.SUBLINE.HIP && line.name !== LINE_TYPE.SUBLINE.VALLEY)
.forEach((line) => canvas?.remove(line))
.forEach((line) => {
roof.innerLines = roof.innerLines.filter((l) => l.id !== line.id)
canvas?.remove(line)
})
ridgeLines = ridgeLines.filter(
(ridge) =>
@ -2699,7 +2797,10 @@ const changeJerkInHeadRoof = (currentRoof, canvas) => {
}
}
hipLines.forEach((hip) => canvas.remove(hip))
hipLines.forEach((hip) => {
roof.innerLines = roof.innerLines.filter((h) => h.id !== hip.id)
canvas.remove(hip)
})
if (ridgeLines.length > 0) {
const ridge = ridgeLines[0]
@ -2745,6 +2846,7 @@ const changeJerkInHeadRoof = (currentRoof, canvas) => {
},
})
canvas?.add(gable1)
roof.innerLines.push(gable1)
hipX1 = (Math.sign(currentRoof.x2 - midX) * currentRoof.attributes.width) / 2
hipY1 = (Math.sign(currentRoof.y2 - midY) * currentRoof.attributes.width) / 2
@ -2762,6 +2864,7 @@ const changeJerkInHeadRoof = (currentRoof, canvas) => {
},
})
canvas?.add(gable2)
roof.innerLines.push(gable2)
const gable3 = new QLine([gable1.x1, gable1.y1, gable2.x1, gable2.y1], {
fontSize: roof.fontSize,
@ -2776,6 +2879,7 @@ const changeJerkInHeadRoof = (currentRoof, canvas) => {
},
})
canvas?.add(gable3)
roof.innerLines.push(gable3)
const hip1 = new QLine([currentRoof.x1, currentRoof.y1, gable1.x1, gable1.y1], {
fontSize: roof.fontSize,
@ -2790,6 +2894,7 @@ const changeJerkInHeadRoof = (currentRoof, canvas) => {
},
})
canvas?.add(hip1)
roof.innerLines.push(hip1)
const hip2 = new QLine([currentRoof.x2, currentRoof.y2, gable2.x1, gable2.y1], {
fontSize: roof.fontSize,
@ -2804,6 +2909,7 @@ const changeJerkInHeadRoof = (currentRoof, canvas) => {
},
})
canvas?.add(hip2)
roof.innerLines.push(hip2)
}
}
}
@ -2873,6 +2979,24 @@ const changeWallRoof = (currentRoof, canvas) => {
y2: nextRoof.y2,
})
const innerLines = canvas
?.getObjects()
.filter(
(object) =>
object.attributes !== undefined &&
object.attributes.roofId === roofId &&
object.attributes.currentRoof === currentRoof.id &&
object.x1 !== undefined &&
object.x2 !== undefined,
)
innerLines
.filter((line) => line.name !== LINE_TYPE.SUBLINE.RIDGE && line.name !== LINE_TYPE.SUBLINE.HIP && line.name !== LINE_TYPE.SUBLINE.VALLEY)
.forEach((line) => {
roof.innerLines = roof.innerLines.filter((l) => l.id !== line.id)
canvas?.remove(line)
})
if (currentRoof.attributes.sleeve && currentRoof.attributes.width > 0 && prevRoof.attributes.offset > 0 && nextRoof.attributes.offset > 0) {
const prevSignX = Math.sign(prevRoof.x1 - prevRoof.x2)
const prevSignY = Math.sign(prevRoof.y1 - prevRoof.y2)
@ -2984,20 +3108,33 @@ const changeWallRoof = (currentRoof, canvas) => {
stroke: 'red',
strokeWidth: 1,
name: LINE_TYPE.SUBLINE.HIP,
attributes: { roofId: roof.id, currentRoofId: currentRoof.id, planeSize: currentRoof.length, actualSize: currentRoof.length },
attributes: {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: currentRoof.length,
actualSize: currentRoof.length,
},
})
let hip2 = new QLine([currentRoof.x2, currentRoof.y2, wallMidX, wallMidY], {
fontSize: roof.fontSize,
stroke: 'red',
strokeWidth: 1,
name: LINE_TYPE.SUBLINE.HIP,
attributes: { roofId: roof.id, currentRoofId: currentRoof.id, planeSize: currentRoof.length, actualSize: currentRoof.length },
attributes: {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: currentRoof.length,
actualSize: currentRoof.length,
},
})
canvas?.add(hip1)
canvas?.add(hip2)
roof.innerLines.push(hip1)
roof.innerLines.push(hip2)
}
if (hipLines.length > 0) {
hipLines.forEach((hip) => {
roof.innerLines = roof.innerLines.filter((h) => h.id !== hip.id)
canvas?.remove(hip)
})
}
@ -3116,6 +3253,7 @@ const reDrawPolygon = (polygon, canvas) => {
return newPolygon
}
function createRoofMarginPolygon(polygon, lines, arcSegments = 0) {
const offsetEdges = []