지붕 덮개 points 조정 및 기능 수정
This commit is contained in:
parent
b5f86115e3
commit
c667e44596
@ -1815,9 +1815,13 @@ export function useMode() {
|
||||
}
|
||||
})
|
||||
|
||||
wall.attributes = {
|
||||
roofId: roof.id,
|
||||
}
|
||||
wall.set({
|
||||
originX: 'center',
|
||||
originY: 'center',
|
||||
attributes: {
|
||||
roofId: roof.id,
|
||||
},
|
||||
})
|
||||
|
||||
//외벽선 삭제
|
||||
canvas
|
||||
|
||||
@ -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')
|
||||
}
|
||||
}
|
||||
@ -632,7 +632,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
|
||||
@ -665,7 +665,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
|
||||
}
|
||||
|
||||
@ -764,7 +764,7 @@ export const drawRidgeRoof = (roofId, canvas, settingModalFirstOptions) => {
|
||||
drawHips(roof, canvas, textMode)
|
||||
connectLinePoint(roof, canvas, textMode)
|
||||
modifyRidge(roof, canvas, textMode)
|
||||
// drawCenterLine(roof, canvas, textMode)
|
||||
drawCenterLine(roof, canvas, textMode)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -776,8 +776,6 @@ export const drawRidgeRoof = (roofId, canvas, settingModalFirstOptions) => {
|
||||
*/
|
||||
const drawRidge = (roof, canvas, textMode) => {
|
||||
console.log('roof.lines : ', roof.lines)
|
||||
console.log('textMode : ', textMode)
|
||||
|
||||
const wallLines = canvas?.getObjects().find((object) => object.name === POLYGON_TYPE.WALL && object.attributes.roofId === roof.id).lines // 외벽의 라인
|
||||
const roofLines = roof.lines // 지붕의 라인
|
||||
let ridgeRoof = []
|
||||
@ -802,7 +800,6 @@ const drawRidge = (roof, canvas, textMode) => {
|
||||
|
||||
// 지붕의 길이가 짧은 순으로 정렬
|
||||
ridgeRoof.sort((a, b) => a.length - b.length)
|
||||
console.log('마루 순서 : ', ridgeRoof.map((item) => item.length).join(','))
|
||||
|
||||
ridgeRoof.forEach((item) => {
|
||||
if (getMaxRidge(roofLines.length) > roof.ridges.length) {
|
||||
@ -826,8 +823,6 @@ const drawRidge = (roof, canvas, textMode) => {
|
||||
let ridgeMaxLength = Big(Math.max(prevRoof.attributes.planeSize, nextRoof.attributes.planeSize)).div(10)
|
||||
let ridgeMinLength = Big(Math.min(prevRoof.attributes.planeSize, nextRoof.attributes.planeSize)).div(10)
|
||||
|
||||
console.log('ridgeMinLength : ', ridgeMinLength.toNumber(), 'ridgeMaxLength : ', ridgeMaxLength.toNumber())
|
||||
|
||||
const currentAngle = Math.atan2(currentY2.minus(currentY1).toNumber(), currentX2.minus(currentX1).toNumber()) * (180 / Math.PI)
|
||||
anotherRoof
|
||||
.filter((roof) => isInnerLine(prevRoof, currentRoof, nextRoof, roof))
|
||||
@ -860,13 +855,6 @@ const drawRidge = (roof, canvas, textMode) => {
|
||||
.plus(Big(nextRoof.y1).minus(Big(nextRoof.y2)).times(10).round().pow(2))
|
||||
.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,
|
||||
}))
|
||||
}
|
||||
if (currentAngle === 90 || currentAngle === 270) {
|
||||
currentY2 = innerRoof.y1
|
||||
@ -878,13 +866,6 @@ const drawRidge = (roof, canvas, textMode) => {
|
||||
.plus(Big(nextRoof.y1).minus(Big(nextRoof.y2)).times(10).round().pow(2))
|
||||
.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,
|
||||
}))
|
||||
}
|
||||
}
|
||||
if (Math.abs(currentAngle - ibAngle) === 0) {
|
||||
@ -898,13 +879,6 @@ const drawRidge = (roof, canvas, textMode) => {
|
||||
.plus(Big(prevRoof.y1).minus(Big(innerRoof.y1)).times(10).round().pow(2))
|
||||
.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,
|
||||
}))
|
||||
}
|
||||
if (currentAngle === 90 || currentAngle === 270) {
|
||||
currentY1 = innerRoof.y2
|
||||
@ -916,13 +890,6 @@ const drawRidge = (roof, canvas, textMode) => {
|
||||
.plus(Big(prevRoof.y2).minus(prevRoof.y2).times(10).round().pow(2))
|
||||
.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,
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1012,19 +979,8 @@ const drawRidge = (roof, canvas, textMode) => {
|
||||
const diffX = Big(intersectLine.x).minus(startXPoint).round(1).abs().lt(1) ? Big(0) : Big(intersectLine.x).minus(startXPoint).round(1)
|
||||
const diffY = Big(intersectLine.y).minus(startYPoint).round(1).abs().lt(1) ? Big(0) : Big(intersectLine.y).minus(startYPoint).round(1)
|
||||
// 시작점에서 ridgeBaseLength 만큼 떨어진 지점까지 용마루 길이로 본다.
|
||||
console.log('diffX : ', diffX.toNumber(), 'diffY : ', diffY.toNumber())
|
||||
console.log('ridgeBaseLength : ', ridgeBaseLength.toNumber())
|
||||
console.log('Math.sign(diffX.toNumber()) : ', Math.sign(diffX.toNumber()), diffX.abs().minus(ridgeBaseLength).toNumber())
|
||||
console.log('Math.sign(diffY.toNumber()) : ', Math.sign(diffY.toNumber()), diffY.abs().minus(ridgeBaseLength).toNumber())
|
||||
endXPoint = startXPoint.plus(Big(Math.sign(diffX.toNumber())).times(diffX.abs().minus(ridgeBaseLength)))
|
||||
endYPoint = startYPoint.plus(Big(Math.sign(diffY.toNumber())).times(diffY.abs().minus(ridgeBaseLength)))
|
||||
console.log(
|
||||
'intersectLine : ',
|
||||
Big(intersectLine.x).minus(startXPoint).round(1).toNumber(),
|
||||
Big(intersectLine.y).minus(startYPoint).round(1).toNumber(),
|
||||
)
|
||||
console.log('startXPoint : ', startXPoint.toNumber(), 'startYPoint : ', startYPoint.toNumber())
|
||||
console.log('endXPoint : ', endXPoint.toNumber(), 'endYPoint : ', endYPoint.toNumber())
|
||||
|
||||
// 시작점에서 종료점까지의 평면길이
|
||||
//startXPoint.minus(endXPoint).abs().pow(2).plus(startYPoint.minus(endYPoint).abs().pow(2)).sqrt()
|
||||
@ -1037,12 +993,14 @@ const drawRidge = (roof, canvas, textMode) => {
|
||||
}),
|
||||
).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
|
||||
@ -1191,7 +1149,6 @@ export const segmentsOverlap = (line1, line2) => {
|
||||
* @param textMode
|
||||
*/
|
||||
const drawHips = (roof, canvas, textMode) => {
|
||||
console.log('textMode : ', textMode)
|
||||
const roofLines = roof.lines
|
||||
const ridgeLines = canvas?.getObjects().filter((object) => object.name === LINE_TYPE.SUBLINE.RIDGE && object.attributes.roofId === roof.id)
|
||||
|
||||
@ -1232,12 +1189,15 @@ const drawHips = (roof, canvas, textMode) => {
|
||||
}),
|
||||
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,
|
||||
},
|
||||
})
|
||||
@ -1267,12 +1227,15 @@ const drawHips = (roof, canvas, textMode) => {
|
||||
}),
|
||||
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,
|
||||
},
|
||||
})
|
||||
@ -1318,8 +1281,6 @@ const drawHips = (roof, canvas, textMode) => {
|
||||
}
|
||||
})
|
||||
|
||||
console.log('currentRoof : ', currentRoof.length)
|
||||
console.log(ridgePoints)
|
||||
ridgePoints = ridgePoints.reduce((prev, current) => {
|
||||
if (prev !== undefined) {
|
||||
// Math.abs(prev.x - currentRoof.x1)
|
||||
@ -1355,12 +1316,15 @@ const drawHips = (roof, canvas, textMode) => {
|
||||
}),
|
||||
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,
|
||||
},
|
||||
})
|
||||
@ -1369,11 +1333,6 @@ const drawHips = (roof, canvas, textMode) => {
|
||||
roof.innerLines.push(hip)
|
||||
}
|
||||
})
|
||||
roof.innerLines.forEach((hip) => {
|
||||
console.log('hip 길이 : ', hip.attributes.planeSize, ' actual : ', hip.attributes.actualSize)
|
||||
hip.textMode = 'actual'
|
||||
hip.addLengthText()
|
||||
})
|
||||
canvas?.renderAll()
|
||||
}
|
||||
|
||||
@ -1391,7 +1350,6 @@ const connectLinePoint = (polygon, canvas, textMode) => {
|
||||
const lineDegrees = [
|
||||
...new Set(polygon.lines.map((line) => (line.attributes.pitch > 0 ? getDegreeByChon(line.attributes.pitch) : line.attributes.degree))),
|
||||
]
|
||||
console.log('lineDegrees : ', lineDegrees)
|
||||
|
||||
//마루
|
||||
polygon.ridges.forEach((ridge) => {
|
||||
@ -1443,7 +1401,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 {
|
||||
@ -1890,9 +1848,9 @@ const changeEavesRoof = (currentRoof, canvas, textMode) => {
|
||||
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,
|
||||
},
|
||||
})
|
||||
@ -1918,9 +1876,9 @@ const changeEavesRoof = (currentRoof, canvas, textMode) => {
|
||||
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,
|
||||
},
|
||||
})
|
||||
@ -1987,8 +1945,6 @@ const changeGableRoof = (currentRoof, canvas, textMode) => {
|
||||
hipLines = hipLines.filter(
|
||||
(hip) => (hip.x1 === currentRoof.x1 && hip.y1 === currentRoof.y1) || (hip.x1 === currentRoof.x2 && hip.y1 === currentRoof.y2),
|
||||
)
|
||||
console.log('ridgeLines : ', ridgeLines)
|
||||
console.log('hipLines : ', hipLines)
|
||||
|
||||
if (hipLines === undefined || hipLines.length === 0) {
|
||||
hipLines = innerLines.filter(
|
||||
@ -2076,12 +2032,15 @@ const changeGableRoof = (currentRoof, canvas, textMode) => {
|
||||
x2: midX.toNumber(),
|
||||
y2: midY.toNumber(),
|
||||
}),
|
||||
actualSize: calcLineActualSize({
|
||||
x1: currentRoof.x1,
|
||||
y1: currentRoof.y1,
|
||||
x2: midX.toNumber(),
|
||||
y2: midY.toNumber(),
|
||||
}, Big(90 - prevDegree)),
|
||||
actualSize: calcLineActualSize(
|
||||
{
|
||||
x1: currentRoof.x1,
|
||||
y1: currentRoof.y1,
|
||||
x2: midX.toNumber(),
|
||||
y2: midY.toNumber(),
|
||||
},
|
||||
Big(90 - prevDegree),
|
||||
),
|
||||
},
|
||||
})
|
||||
canvas?.add(hip1)
|
||||
@ -2376,8 +2335,8 @@ const changeHipAndGableRoof = (currentRoof, canvas, textMode) => {
|
||||
})
|
||||
})
|
||||
|
||||
const gableDegree = i === 0 ? prevDegree : nextDegree
|
||||
hipLines.forEach((hip, i) => {
|
||||
const gableDegree = i === 0 ? prevDegree : nextDegree
|
||||
const gableLine = new QLine([hip.x2, hip.y2, currentRoof.attributes.ridgeCoordinate.x1, currentRoof.attributes.ridgeCoordinate.y1], {
|
||||
parentId: roof.id,
|
||||
fontSize: roof.fontSize,
|
||||
@ -2602,7 +2561,7 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
|
||||
let hipY1 = (Math.sign(currentRoof.y1 - midY) * currentRoof.attributes.width) / 2
|
||||
|
||||
const gableDegree = currentRoof.attributes.degree > 0 ? currentRoof.attributes.degree : getDegreeByChon(currentRoof.attributes.pitch)
|
||||
const gable1 = new QLine([midX.plus(hipX1).toNumber(), midY.plus(hipY1).toNumber(), hipX2.toNumber(), hipY2.toNumber()], {
|
||||
const gable1 = new QLine([midX.plus(hipX1).toNumber(), midY.plus(hipY1).toNumber(), hipX2, hipY2], {
|
||||
parentId: roof.id,
|
||||
fontSize: roof.fontSize,
|
||||
stroke: '#1083E3',
|
||||
@ -2615,15 +2574,15 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
|
||||
planeSize: calcLinePlaneSize({
|
||||
x1: midX.plus(hipX1).toNumber(),
|
||||
y1: midY.plus(hipY1).toNumber(),
|
||||
x2: hipX2.toNumber(),
|
||||
y2: hipY2.toNumber(),
|
||||
x2: hipX2,
|
||||
y2: hipY2,
|
||||
}),
|
||||
actualSize: calcLineActualSize(
|
||||
{
|
||||
x1: midX.plus(hipX1).toNumber(),
|
||||
y1: midY.plus(hipY1).toNumber(),
|
||||
x2: hipX2.toNumber(),
|
||||
y2: hipY2.toNumber(),
|
||||
x2: hipX2,
|
||||
y2: hipY2,
|
||||
},
|
||||
Big(90 - gableDegree).toNumber(),
|
||||
),
|
||||
@ -2639,7 +2598,7 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
|
||||
hipX1 = (Math.sign(currentRoof.x2 - midX) * currentRoof.attributes.width) / 2
|
||||
hipY1 = (Math.sign(currentRoof.y2 - midY) * currentRoof.attributes.width) / 2
|
||||
|
||||
const gable2 = new QLine([midX.plus(hipX1).toNumber(), midY.plus(hipY1).toNumber(), hipX2.toNumber(), hipY2.toNumber()], {
|
||||
const gable2 = new QLine([midX.plus(hipX1).toNumber(), midY.plus(hipY1).toNumber(), hipX2, hipY2], {
|
||||
parentId: roof.id,
|
||||
fontSize: roof.fontSize,
|
||||
stroke: '#1083E3',
|
||||
@ -2652,15 +2611,15 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
|
||||
planeSize: calcLinePlaneSize({
|
||||
x1: midX.plus(hipX1).toNumber(),
|
||||
y1: midY.plus(hipY1).toNumber(),
|
||||
x2: hipX2.toNumber(),
|
||||
y2: hipY2.toNumber(),
|
||||
x2: hipX2,
|
||||
y2: hipY2,
|
||||
}),
|
||||
actualSize: calcLineActualSize(
|
||||
{
|
||||
x1: midX.plus(hipX1).toNumber(),
|
||||
y1: midY.plus(hipY1).toNumber(),
|
||||
x2: hipX2.toNumber(),
|
||||
y2: hipY2.toNumber(),
|
||||
x2: hipX2,
|
||||
y2: hipY2,
|
||||
},
|
||||
Big(90 - gableDegree).toNumber(),
|
||||
),
|
||||
@ -2705,12 +2664,15 @@ 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
|
||||
@ -2732,12 +2694,15 @@ 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
|
||||
@ -2746,8 +2711,6 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
|
||||
// hip2.attributes.actualSize = Math.round(Math.sqrt(Math.pow(hip2.attributes.planeSize, 2) + Math.pow(hip2Height, 2)))
|
||||
canvas?.add(hip2)
|
||||
|
||||
console.log('currentRoof.id : ', currentRoof.id)
|
||||
|
||||
// hip1.set({ visible: false })
|
||||
hip1.setViewLengthText(false)
|
||||
// gable3.set({ visible: false })
|
||||
@ -3253,7 +3216,6 @@ const drawCenterLine = (roof, canvas, textMode) => {
|
||||
const hips = roof.innerLines.filter(
|
||||
(line) => (currentRoof.x1 === line.x1 && currentRoof.y1 === line.y1) || (currentRoof.x2 === line.x1 && currentRoof.y2 === line.y1),
|
||||
)
|
||||
// console.log('hips : ', hips)
|
||||
|
||||
const ridge = roof.innerLines
|
||||
.filter((line) => line.name === LINE_TYPE.SUBLINE.RIDGE)
|
||||
@ -3279,41 +3241,17 @@ const drawCenterLine = (roof, canvas, textMode) => {
|
||||
}
|
||||
return prevDistance < currentDistance ? prev : current
|
||||
}, null)
|
||||
/*console.log('currentRoof : ', currentRoof.attributes.planeSize, currentRoof)
|
||||
console.log(
|
||||
roof.innerLines
|
||||
.filter((line) => line.name === LINE_TYPE.SUBLINE.RIDGE)
|
||||
.filter((line) => {
|
||||
if (currentRoof.x1 === currentRoof.x2) {
|
||||
console.log('currentRoof.x1 === currentRoof.x2', line.x1 === line.x2, line)
|
||||
if (line.x1 === line.x2) {
|
||||
return line
|
||||
}
|
||||
} else {
|
||||
console.log('currentRoof.x1 !== currentRoof.x2', line.y1 === line.y2, line)
|
||||
if (line.y1 === line.y2) {
|
||||
return line
|
||||
}
|
||||
}
|
||||
}),
|
||||
)
|
||||
console.log('currentRoof.x1 === currentRoof.x2 : ', currentRoof.x1 === currentRoof.x2)
|
||||
console.log('ridge : ', ridge)
|
||||
console.log('hips : ', hips)*/
|
||||
let points = []
|
||||
if (hips.length === 2 && Math.abs(hips[0].x2 - hips[1].x2) < 1 && Math.abs(hips[0].y2 - hips[1].y2) < 1) {
|
||||
// console.log('삼각')
|
||||
const x1 = (currentRoof.x1 + currentRoof.x2) / 2
|
||||
const y1 = (currentRoof.y1 + currentRoof.y2) / 2
|
||||
points.push(x1, y1, hips[0].x2, hips[0].y2)
|
||||
} else if (hips.length > 1) {
|
||||
// console.log('삼각 아님')
|
||||
if (
|
||||
((ridge?.x1 === hips[0].x2 && ridge?.y1 === hips[0].y2) || (ridge?.x2 === hips[0].x2 && ridge?.y2 === hips[0].y2)) &&
|
||||
((ridge?.x1 === hips[1].x2 && ridge?.y1 === hips[1].y2) || (ridge?.x2 === hips[1].x2 && ridge?.y2 === hips[1].y2))
|
||||
) {
|
||||
//사각이면 마루와 현재 라인 사이에 길이를 구한다
|
||||
// console.log('사각')
|
||||
if (Math.sign(currentRoof.x1 - currentRoof.x2) === 0) {
|
||||
const yPoints = [currentRoof.y1, currentRoof.y2, ridge.y1, ridge.y2].sort((a, b) => a - b)
|
||||
const x1 = (currentRoof.x1 + currentRoof.x2) / 2
|
||||
@ -3338,7 +3276,6 @@ const drawCenterLine = (roof, canvas, textMode) => {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// console.log('사각 아님')
|
||||
if (Math.sign(currentRoof.x1 - currentRoof.x2) === 0) {
|
||||
let xPoints = []
|
||||
xPoints.push(ridge?.x1, ridge?.x2)
|
||||
@ -3424,7 +3361,6 @@ const drawCenterLine = (roof, canvas, textMode) => {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// console.log('else : ')
|
||||
if (currentRoof.attributes.type === LINE_TYPE.WALLLINE.JERKINHEAD) {
|
||||
const gables = canvas
|
||||
.getObjects()
|
||||
@ -3461,6 +3397,7 @@ const drawCenterLine = (roof, canvas, textMode) => {
|
||||
}
|
||||
}
|
||||
if (points !== null) {
|
||||
const currentDegree = currentRoof.attributes.pitch > 0 ? getDegreeByChon(currentRoof.attributes.pitch) : currentRoof.attributes.degree
|
||||
const pitchSizeLine = new QLine(points, {
|
||||
parentId: roof.id,
|
||||
stroke: '#000000',
|
||||
@ -3468,22 +3405,16 @@ const drawCenterLine = (roof, canvas, textMode) => {
|
||||
strokeDashArray: [5, 5],
|
||||
selectable: false,
|
||||
fontSize: roof.fontSize,
|
||||
textMode: textMode,
|
||||
attributes: {
|
||||
roofId: roof.id,
|
||||
type: 'pitchSizeLine',
|
||||
planeSize: calcLineActualSize({ x1: points[0], y1: points[1], x2: points[2], y2: points[3] }, currentDegree),
|
||||
actualSize: calcLineActualSize({ x1: points[0], y1: points[1], x2: points[2], y2: points[3] }, currentDegree),
|
||||
},
|
||||
})
|
||||
canvas.add(pitchSizeLine)
|
||||
canvas.renderAll()
|
||||
|
||||
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),
|
||||
)
|
||||
const currentDegree = currentRoof.attributes.pitch > 0 ? getDegreeByChon(currentRoof.attributes.pitch) : currentRoof.attributes.degree
|
||||
const height = Math.tan(currentDegree * (Math.PI / 180)) * adjust
|
||||
const lengthText = Math.round(Math.sqrt(Math.pow(adjust, 2) + Math.pow(height, 2)))
|
||||
pitchSizeLine.setLengthText(lengthText)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user