버그 수정

This commit is contained in:
Jaeyoung Lee 2025-02-09 10:36:17 +09:00
parent 4101a3ede9
commit 84323b2c1d

View File

@ -11,7 +11,7 @@ import Big from 'big.js'
const TWO_PI = Math.PI * 2
export const defineQPloygon = () => {
fabric.QPolygon.fromObject = function (object, callback) {
fabric.QPolygon.fromObject = function(object, callback) {
fabric.Object._fromObject('QPolygon', object, callback, 'points')
}
}
@ -631,7 +631,7 @@ export const drawGabledRoof = (roofId, canvas, settingModalFirstOptions) => {
const adjust = Math.sqrt(
Math.pow(Math.round(Math.abs(pitchSizeLine.x1 - pitchSizeLine.x2) * 10), 2) +
Math.pow(Math.round(Math.abs(pitchSizeLine.y1 - pitchSizeLine.y2) * 10), 2),
Math.pow(Math.round(Math.abs(pitchSizeLine.y1 - pitchSizeLine.y2) * 10), 2),
)
const currentDegree = currentRoof.attributes.pitch > 0 ? getDegreeByChon(currentRoof.attributes.pitch) : currentRoof.attributes.degree
const height = Math.tan(currentDegree * (Math.PI / 180)) * adjust
@ -664,7 +664,7 @@ export const drawShedRoof = (roofId, canvas, settingModalFirstOptions) => {
if (shedDegree === 0) {
shedDegree = getDegreeByChon(shedChon)
}
const getHeight = function (adjust, degree) {
const getHeight = function(adjust, degree) {
return Math.tan(degree * (Math.PI / 180)) * adjust
}
@ -832,7 +832,10 @@ const drawRidge = (roof, canvas, textMode) => {
.filter((roof) => isInnerLine(prevRoof, currentRoof, nextRoof, roof))
.forEach((innerRoof) => {
const vector1 = { x: currentX2.minus(currentX1), y: currentY2.minus(currentY1) }
const vector2 = { x: Big(innerRoof.x2).minus(Big(innerRoof.x1)), y: Big(innerRoof.y2).minus(Big(innerRoof.y1)) }
const vector2 = {
x: Big(innerRoof.x2).minus(Big(innerRoof.x1)),
y: Big(innerRoof.y2).minus(Big(innerRoof.y1)),
}
const dotProduct = vector1.x.times(vector2.x).plus(vector1.y.times(vector2.y))
const magnitude1 = vector1.x.pow(2).plus(vector1.y.pow(2)).sqrt()
@ -857,7 +860,12 @@ const drawRidge = (roof, canvas, textMode) => {
.sqrt()
.div(10)
console.log('ridgeMinLength : ', ridgeMinLength.toNumber())
console.log('check ridgeMinLength', calcLinePlaneSize({ x1: nextRoof.x1, y1: nextRoof.y1, x2: nextRoof.x2, y2: nextRoof.y2 }))
console.log('check ridgeMinLength', calcLinePlaneSize({
x1: nextRoof.x1,
y1: nextRoof.y1,
x2: nextRoof.x2,
y2: nextRoof.y2,
}))
}
if (currentAngle === 90 || currentAngle === 270) {
currentY2 = innerRoof.y1
@ -870,7 +878,12 @@ const drawRidge = (roof, canvas, textMode) => {
.sqrt()
.div(10)
console.log('ridgeMinLength : ', ridgeMinLength.toNumber())
console.log('check ridgeMinLength', calcLinePlaneSize({ x1: nextRoof.x1, y1: nextRoof.y1, x2: innerRoof.x2, y2: nextRoof.y2 }))
console.log('check ridgeMinLength', calcLinePlaneSize({
x1: nextRoof.x1,
y1: nextRoof.y1,
x2: innerRoof.x2,
y2: nextRoof.y2,
}))
}
}
if (Math.abs(currentAngle - ibAngle) === 0) {
@ -885,7 +898,12 @@ const drawRidge = (roof, canvas, textMode) => {
.sqrt()
.div(10)
console.log('ridgeMinLength : ', ridgeMinLength.toNumber())
console.log('check ridgeMinLength', calcLinePlaneSize({ x1: prevRoof.x1, y1: prevRoof.y1, x2: prevRoof.x2, y2: innerRoof.y1 }))
console.log('check ridgeMinLength', calcLinePlaneSize({
x1: prevRoof.x1,
y1: prevRoof.y1,
x2: prevRoof.x2,
y2: innerRoof.y1,
}))
}
if (currentAngle === 90 || currentAngle === 270) {
currentY1 = innerRoof.y2
@ -898,7 +916,12 @@ const drawRidge = (roof, canvas, textMode) => {
.sqrt()
.div(10)
console.log('ridgeMinLength : ', ridgeMinLength.toNumber())
console.log('check ridgeMinLength', calcLinePlaneSize({ x1: prevRoof.x1, y1: prevRoof.y1, x2: innerRoof.x2, y2: prevRoof.y2 }))
console.log('check ridgeMinLength', calcLinePlaneSize({
x1: prevRoof.x1,
y1: prevRoof.y1,
x2: innerRoof.x2,
y2: prevRoof.y2,
}))
}
}
}
@ -1005,10 +1028,20 @@ const drawRidge = (roof, canvas, textMode) => {
// 시작점에서 종료점까지의 평면길이
//startXPoint.minus(endXPoint).abs().pow(2).plus(startYPoint.minus(endYPoint).abs().pow(2)).sqrt()
const hypo = Big(
calcLinePlaneSize({ x1: startXPoint.toNumber(), y1: startYPoint.toNumber(), x2: endXPoint.toNumber(), y2: endYPoint.toNumber() }),
calcLinePlaneSize({
x1: startXPoint.toNumber(),
y1: startYPoint.toNumber(),
x2: endXPoint.toNumber(),
y2: endYPoint.toNumber(),
}),
).div(10)
// 현재 지붕선과 마주하는 지붕선을 잇는 선분의 교차점까지의 길이
const intersectLength = Big(calcLinePlaneSize({ x1: midX.toNumber(), y1: midY.toNumber(), x2: intersectLine.x, y2: intersectLine.y })).div(10)
const intersectLength = Big(calcLinePlaneSize({
x1: midX.toNumber(),
y1: midY.toNumber(),
x2: intersectLine.x,
y2: intersectLine.y,
})).div(10)
//마주하는 지붕선까지의 길이가 현재 지붕선의 이전, 다음 지붕선의 길이보다 작을때
if (intersectLength.lt(Big(prevRoof.attributes.planeSize).div(10)) && intersectLength.lt(Big(nextRoof.attributes.planeSize).div(10))) {
endXPoint = startXPoint
@ -1190,10 +1223,20 @@ const drawHips = (roof, canvas, textMode) => {
attributes: {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: ridgeCoordinate.x1, y2: ridgeCoordinate.y1 }),
planeSize: calcLinePlaneSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: ridgeCoordinate.x1,
y2: ridgeCoordinate.y1,
}),
actualSize:
prevDegree === currentDegree
? calcLineActualSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: ridgeCoordinate.x1, y2: ridgeCoordinate.y1 }, currentDegree)
? calcLineActualSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: ridgeCoordinate.x1,
y2: ridgeCoordinate.y1,
}, currentDegree)
: 0,
},
})
@ -1215,10 +1258,20 @@ const drawHips = (roof, canvas, textMode) => {
attributes: {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: ridgeCoordinate.x1, y2: ridgeCoordinate.y1 }),
planeSize: calcLinePlaneSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: ridgeCoordinate.x1,
y2: ridgeCoordinate.y1,
}),
actualSize:
prevDegree === currentDegree
? calcLineActualSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: ridgeCoordinate.x1, y2: ridgeCoordinate.y1 }, currentDegree)
? calcLineActualSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: ridgeCoordinate.x1,
y2: ridgeCoordinate.y1,
}, currentDegree)
: 0,
},
})
@ -1293,10 +1346,20 @@ const drawHips = (roof, canvas, textMode) => {
attributes: {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: ridgePoints.x, y2: ridgePoints.y }),
planeSize: calcLinePlaneSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: ridgePoints.x,
y2: ridgePoints.y,
}),
actualSize:
prevDegree === currentDegree
? calcLineActualSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: ridgePoints.x, y2: ridgePoints.y }, currentDegree)
? calcLineActualSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: ridgePoints.x,
y2: ridgePoints.y,
}, currentDegree)
: 0,
},
})
@ -1379,7 +1442,7 @@ const connectLinePoint = (polygon, canvas, textMode) => {
.reduce((prev, current) => {
if (prev !== undefined) {
return Math.sqrt(Math.pow(Math.abs(current.x - p1.x), 2) + Math.pow(Math.abs(current.y - p1.y), 2)) <
Math.sqrt(Math.pow(Math.abs(prev.x - p1.x), 2) + Math.pow(Math.abs(prev.y - p1.y), 2))
Math.sqrt(Math.pow(Math.abs(prev.x - p1.x), 2) + Math.pow(Math.abs(prev.y - p1.y), 2))
? current
: prev
} else {
@ -1691,7 +1754,7 @@ const changeEavesRoof = (currentRoof, canvas, textMode) => {
const midX = Big(currentRoof.x1).plus(Big(currentRoof.x2)).div(2) // 지붕의 X 중심
const midY = Big(currentRoof.y1).plus(Big(currentRoof.y2)).div(2) // 지붕의 Y 중심
const midWallX = Big(wallLine.x1).plus(wallLine.x).div(2)
const midWallX = Big(wallLine.x1).plus(Big(wallLine.x2)).div(2)
const midWallY = Big(wallLine.y1).plus(Big(wallLine.y2)).div(2) // 벽의 Y 중심
const alpha = midX.minus(midWallX) // 벽과 지붕의 X 거리
const beta = midY.minus(midWallY) // 벽과 지붕의 Y 거리
@ -1817,13 +1880,18 @@ const changeEavesRoof = (currentRoof, canvas, textMode) => {
attributes: {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: hipX2.toNumber(), y2: hipY2.toNumber() }),
planeSize: calcLinePlaneSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: hipX2.toNumber(),
y2: hipY2.toNumber(),
}),
actualSize:
prevDegree === currentDegree
? calcLineActualSize(
{ x1: currentRoof.x1, y1: currentRoof.y1, x2: hipX2.toNumber(), y2: hipY2.toNumber() },
Big(90 - currentDegree).toNumber(),
)
{ x1: currentRoof.x1, y1: currentRoof.y1, x2: hipX2.toNumber(), y2: hipY2.toNumber() },
Big(90 - currentDegree).toNumber(),
)
: 0,
},
})
@ -1840,13 +1908,18 @@ const changeEavesRoof = (currentRoof, canvas, textMode) => {
attributes: {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: hipX2.toNumber(), y2: hipY2.toNumber() }),
planeSize: calcLinePlaneSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: hipX2.toNumber(),
y2: hipY2.toNumber(),
}),
actualSize:
currentDegree === nextDegree
? calcLineActualSize(
{ x1: currentRoof.x2, y1: currentRoof.y2, x2: hipX2.toNumber(), y2: hipY2.toNumber() },
Big(90 - currentDegree).toNumber(),
)
{ x1: currentRoof.x2, y1: currentRoof.y2, x2: hipX2.toNumber(), y2: hipY2.toNumber() },
Big(90 - currentDegree).toNumber(),
)
: 0,
},
})
@ -1996,8 +2069,18 @@ const changeGableRoof = (currentRoof, canvas, textMode) => {
attributes: {
roofId: roofId,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: midX.toNumber(), y2: midY.toNumber() }),
actualSize: calcLineActualSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: midX.toNumber(), y2: midY.toNumber() }, Big(90 - prevDegree)),
planeSize: calcLinePlaneSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: midX.toNumber(),
y2: midY.toNumber(),
}),
actualSize: calcLineActualSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: midX.toNumber(),
y2: midY.toNumber(),
}, Big(90 - prevDegree)),
},
})
canvas?.add(hip1)
@ -2016,7 +2099,12 @@ const changeGableRoof = (currentRoof, canvas, textMode) => {
attributes: {
roofId: roofId,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: midX.toNumber(), y2: midY.toNumber() }),
planeSize: calcLinePlaneSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: midX.toNumber(),
y2: midY.toNumber(),
}),
actualSize: calcLineActualSize(
{ x1: currentRoof.x2, y1: currentRoof.y2, x2: midX.toNumber(), y2: midY.toNumber() },
Big(90 - nextDegree).toNumber(),
@ -2213,9 +2301,19 @@ const changeHipAndGableRoof = (currentRoof, canvas, textMode) => {
attributes: {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: midX.plus(hipX2).toNumber(), y2: midY.plus(hipY2).toNumber() }),
planeSize: calcLinePlaneSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: midX.plus(hipX2).toNumber(),
y2: midY.plus(hipY2).toNumber(),
}),
actualSize: calcLineActualSize(
{ x1: currentRoof.x1, y1: currentRoof.y1, x2: midX.plus(hipX2).toNumber(), y2: midY.plus(hipY2).toNumber() },
{
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: midX.plus(hipX2).toNumber(),
y2: midY.plus(hipY2).toNumber(),
},
Big(90 - prevDegree).toNumber(),
),
},
@ -2238,9 +2336,19 @@ const changeHipAndGableRoof = (currentRoof, canvas, textMode) => {
attributes: {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: midX.plus(hipX2).toNumber(), y2: midY.plus(hipY2).toNumber() }),
planeSize: calcLinePlaneSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: midX.plus(hipX2).toNumber(),
y2: midY.plus(hipY2).toNumber(),
}),
actualSize: calcLineActualSize(
{ x1: currentRoof.x2, y1: currentRoof.y2, x2: midX.plus(hipX2).toNumber(), y2: midY.plus(hipY2).toNumber() },
{
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: midX.plus(hipX2).toNumber(),
y2: midY.plus(hipY2).toNumber(),
},
Big(90 - nextDegree).toNumber(),
),
},
@ -2286,7 +2394,12 @@ const changeHipAndGableRoof = (currentRoof, canvas, textMode) => {
y2: currentRoof.attributes.ridgeCoordinate.y1,
}),
actualSize: calcLineActualSize(
{ x1: hip.x2, y1: hip.y2, x2: currentRoof.attributes.ridgeCoordinate.x1, y2: currentRoof.attributes.ridgeCoordinate.y1 },
{
x1: hip.x2,
y1: hip.y2,
x2: currentRoof.attributes.ridgeCoordinate.x1,
y2: currentRoof.attributes.ridgeCoordinate.y1,
},
Big(90 - gableDegree).toNumber(),
),
},
@ -2505,7 +2618,12 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
y2: hipY2.toNumber(),
}),
actualSize: calcLineActualSize(
{ x1: midX.plus(hipX1).toNumber(), y1: midY.plus(hipY1).toNumber(), x2: hipX2.toNumber(), y2: hipY2.toNumber() },
{
x1: midX.plus(hipX1).toNumber(),
y1: midY.plus(hipY1).toNumber(),
x2: hipX2.toNumber(),
y2: hipY2.toNumber(),
},
Big(90 - gableDegree).toNumber(),
),
},
@ -2537,7 +2655,12 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
y2: hipY2.toNumber(),
}),
actualSize: calcLineActualSize(
{ x1: midX.plus(hipX1).toNumber(), y1: midY.plus(hipY1).toNumber(), x2: hipX2.toNumber(), y2: hipY2.toNumber() },
{
x1: midX.plus(hipX1).toNumber(),
y1: midY.plus(hipY1).toNumber(),
x2: hipX2.toNumber(),
y2: hipY2.toNumber(),
},
Big(90 - gableDegree).toNumber(),
),
},
@ -2581,7 +2704,12 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: gable1.x1, y2: gable1.y1 }),
actualSize: calcLineActualSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: gable1.x1, y2: gable1.y1 }, Big(90 - prevDegree).toNumber()),
actualSize: calcLineActualSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: gable1.x1,
y2: gable1.y1,
}, Big(90 - prevDegree).toNumber()),
},
})
// const hip1Base = ((Math.abs(hip1.x1 - hip1.x2) + Math.abs(hip1.y1 - hip1.y2)) / 2) * 10
@ -2603,7 +2731,12 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: gable2.x1, y2: gable2.y1 }),
actualSize: calcLineActualSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: gable2.x1, y2: gable2.y1 }, Big(90 - nextDegree).toNumber()),
actualSize: calcLineActualSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: gable2.x1,
y2: gable2.y1,
}, Big(90 - nextDegree).toNumber()),
},
})
// const hip2Base = ((Math.abs(hip2.x1 - hip2.x2) + Math.abs(hip2.y1 - hip2.y2)) / 2) * 10
@ -2912,7 +3045,12 @@ const changeWallRoof = (currentRoof, canvas, textMode) => {
attributes: {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: wallMidX.toNumber(), y2: wallMidY.toNumber() }),
planeSize: calcLinePlaneSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: wallMidX.toNumber(),
y2: wallMidY.toNumber(),
}),
actualSize: calcLineActualSize(
{ x1: currentRoof.x1, y1: currentRoof.y1, x2: wallMidX.toNumber(), y2: wallMidY.toNumber() },
Big(90 - prevDegree).toNumber(),
@ -2933,7 +3071,12 @@ const changeWallRoof = (currentRoof, canvas, textMode) => {
attributes: {
roofId: roof.id,
currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: wallMidX.toNumber(), y2: wallMidY.toNumber() }),
planeSize: calcLinePlaneSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: wallMidX.toNumber(),
y2: wallMidY.toNumber(),
}),
actualSize: calcLineActualSize(
{ x1: currentRoof.x2, y1: currentRoof.y2, x2: wallMidX.toNumber(), y2: wallMidY.toNumber() },
Big(90 - nextDegree).toNumber(),
@ -3334,7 +3477,7 @@ const drawCenterLine = (roof, canvas, textMode) => {
const adjust = Math.sqrt(
Math.pow(Math.round(Math.abs(pitchSizeLine.x1 - pitchSizeLine.x2) * 10), 2) +
Math.pow(Math.round(Math.abs(pitchSizeLine.y1 - pitchSizeLine.y2) * 10), 2),
Math.pow(Math.round(Math.abs(pitchSizeLine.y1 - pitchSizeLine.y2) * 10), 2),
)
const currentDegree = currentRoof.attributes.pitch > 0 ? getDegreeByChon(currentRoof.attributes.pitch) : currentRoof.attributes.degree
const height = Math.tan(currentDegree * (Math.PI / 180)) * adjust