#1438 지붕면 할당 후 계산식 수정

This commit is contained in:
hyojun.choi 2026-01-28 17:09:51 +09:00
parent ea6a17e375
commit ba19434224
2 changed files with 46 additions and 17 deletions

View File

@ -168,6 +168,9 @@ export const useLine = () => {
* @param pitch * @param pitch
*/ */
const setActualSize = (line, direction, pitch = globalPitch) => { const setActualSize = (line, direction, pitch = globalPitch) => {
if (line.attributes.isCalculated) {
return
}
const { x1, y1, x2, y2 } = line const { x1, y1, x2, y2 } = line
const isHorizontal = y1 === y2 const isHorizontal = y1 === y2
@ -209,7 +212,11 @@ export const useLine = () => {
} }
} }
line.attributes = { ...line.attributes, actualSize: Number(line.attributes.actualSize.toFixed(0)) } line.attributes = {
...line.attributes,
actualSize: Number(line.attributes.actualSize.toFixed(0)),
isCalculated: true,
}
} }
return { return {

View File

@ -973,7 +973,6 @@ export const usePolygon = () => {
}) })
canvas.renderAll() canvas.renderAll()
/*polygonLines.forEach((line) => { /*polygonLines.forEach((line) => {
line.set({ strokeWidth: 10 }) line.set({ strokeWidth: 10 })
canvas.add(line) canvas.add(line)
@ -1043,16 +1042,25 @@ export const usePolygon = () => {
name: 'newLine', name: 'newLine',
}) })
// 두 라인 중 큰 길이로 통일
const length1 = Math.round(Math.hypot(newLine1.x1 - newLine1.x2, newLine1.y1 - newLine1.y2)) * 10
const length2 = Math.round(Math.hypot(newLine2.x1 - newLine2.x2, newLine2.y1 - newLine2.y2)) * 10
const maxLength = Math.max(length1, length2)
const unifiedPlaneSize = line.attributes.planeSize ?? maxLength
const unifiedActualSize = line.attributes.actualSize ?? maxLength
newLine1.attributes = { newLine1.attributes = {
...line.attributes, ...line.attributes,
planeSize: Math.round(Math.hypot(newLine1.x1 - newLine1.x2, newLine1.y1 - newLine1.y2)) * 10, planeSize: unifiedPlaneSize,
actualSize: Math.round(Math.hypot(newLine1.x1 - newLine1.x2, newLine1.y1 - newLine1.y2)) * 10, actualSize: unifiedActualSize,
} }
newLine1.length = maxLength
newLine2.attributes = { newLine2.attributes = {
...line.attributes, ...line.attributes,
planeSize: Math.round(Math.hypot(newLine2.x1 - newLine2.x2, newLine2.y1 - newLine2.y2)) * 10, planeSize: unifiedPlaneSize,
actualSize: Math.round(Math.hypot(newLine2.x1 - newLine2.x2, newLine2.y1 - newLine2.y2)) * 10, actualSize: unifiedActualSize,
} }
newLine2.length = maxLength
newLines.push(newLine1, newLine2) newLines.push(newLine1, newLine2)
divideLines.splice(i, 1) // 기존 line 제거 divideLines.splice(i, 1) // 기존 line 제거
@ -1071,11 +1079,13 @@ export const usePolygon = () => {
name: 'newLine', name: 'newLine',
}) })
const calcLength = Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10
newLine.attributes = { newLine.attributes = {
...line.attributes, ...line.attributes,
planeSize: Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10, planeSize: line.attributes.planeSize ?? calcLength,
actualSize: Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10, actualSize: line.attributes.actualSize ?? calcLength,
} }
newLine.length = line.attributes.planeSize ?? calcLength
newLines.push(newLine) newLines.push(newLine)
currentPoint = minDistancePoint currentPoint = minDistancePoint
@ -1089,11 +1099,13 @@ export const usePolygon = () => {
attributes: line.attributes, attributes: line.attributes,
name: 'newLine', name: 'newLine',
}) })
const lastCalcLength = Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10
newLine.attributes = { newLine.attributes = {
...line.attributes, ...line.attributes,
planeSize: Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10, planeSize: line.attributes.planeSize ?? lastCalcLength,
actualSize: Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10, actualSize: line.attributes.actualSize ?? lastCalcLength,
} }
newLine.length = line.attributes.planeSize ?? lastCalcLength
newLines.push(newLine) newLines.push(newLine)
divideLines.splice(i, 1) // 기존 line 제거 divideLines.splice(i, 1) // 기존 line 제거
@ -1946,23 +1958,33 @@ export const usePolygon = () => {
const line2 = allRoofLines[j] const line2 = allRoofLines[j]
const diff = Math.abs(line1.length - line2.length) const diff = Math.abs(line1.length - line2.length)
if (diff > 0 && diff <= 2) { if (diff > 0 && diff <= 2) {
const minLength = Math.min(line1.length, line2.length) const maxLength = Math.max(line1.length, line2.length)
line1.setLengthByValue(minLength * 10) line1.setLengthByValue(maxLength * 10)
line2.setLengthByValue(minLength * 10) line2.setLengthByValue(maxLength * 10)
// attributes도 통일
const maxPlaneSize = Math.max(line1.attributes.planeSize || 0, line2.attributes.planeSize || 0)
const maxActualSize = Math.max(line1.attributes.actualSize || 0, line2.attributes.actualSize || 0)
line1.attributes.planeSize = maxPlaneSize
line1.attributes.actualSize = maxActualSize
line2.attributes.planeSize = maxPlaneSize
line2.attributes.actualSize = maxActualSize
} }
} }
} }
polygon.lines.forEach((line, index) => { polygon.lines.forEach((line, index) => {
if (line.attributes.isCalculated) {
return
}
//text 와 planSize 및 actualSize가 안맞는 문제 //text 와 planSize 및 actualSize가 안맞는 문제
const nextText = polygon?.texts?.[index]?.text /*const nextText = polygon?.texts?.[index]?.text
const nextPlaneSize = Number(nextText) const nextPlaneSize = Number(nextText)
if (nextText != null && nextText !== '' && Number.isFinite(nextPlaneSize) ) { if (nextText != null && nextText !== '' && Number.isFinite(nextPlaneSize)) {
if(line.attributes.actualSize !== nextPlaneSize && line.attributes.planeSize !== nextPlaneSize) { if (line.attributes.actualSize !== nextPlaneSize && line.attributes.planeSize !== nextPlaneSize) {
line.attributes.planeSize = nextPlaneSize line.attributes.planeSize = nextPlaneSize
} }
}*/
}
setActualSize(line, polygon.direction, +polygon.roofMaterial?.pitch) setActualSize(line, polygon.direction, +polygon.roofMaterial?.pitch)
}) })