실치수 계산 시 소수점 적용 문제로 인한 수정 모든 roof lines를 확인하여 length 통일
This commit is contained in:
parent
49253b7668
commit
8d5d36fce6
@ -1,19 +1,7 @@
|
||||
import {
|
||||
ANGLE_TYPE,
|
||||
canvasState,
|
||||
currentAngleTypeSelector,
|
||||
globalPitchState,
|
||||
pitchTextSelector,
|
||||
} from '@/store/canvasAtom'
|
||||
import { ANGLE_TYPE, canvasState, currentAngleTypeSelector, globalPitchState, pitchTextSelector } from '@/store/canvasAtom'
|
||||
import { useRecoilValue } from 'recoil'
|
||||
import { fabric } from 'fabric'
|
||||
import {
|
||||
calculateIntersection,
|
||||
findAndRemoveClosestPoint,
|
||||
getDegreeByChon,
|
||||
getDegreeInOrientation,
|
||||
isPointOnLine,
|
||||
} from '@/util/canvas-util'
|
||||
import { calculateIntersection, findAndRemoveClosestPoint, getDegreeByChon, getDegreeInOrientation, isPointOnLine } from '@/util/canvas-util'
|
||||
import { QPolygon } from '@/components/fabric/QPolygon'
|
||||
import { isSamePoint, removeDuplicatePolygons } from '@/util/qpolygon-utils'
|
||||
import { basicSettingState, flowDisplaySelector } from '@/store/settingAtom'
|
||||
@ -1392,6 +1380,8 @@ export const usePolygon = () => {
|
||||
// 나눠서 중복 제거된 roof return
|
||||
let newRoofs = getSplitRoofsPoints(allLines)
|
||||
|
||||
const createdRoofs = []
|
||||
|
||||
newRoofs = newRoofs.filter((roof) => roof.length !== 0)
|
||||
newRoofs.forEach((roofPoint, index) => {
|
||||
let defense, pitch
|
||||
@ -1634,8 +1624,8 @@ export const usePolygon = () => {
|
||||
})
|
||||
})
|
||||
|
||||
canvas.add(roof)
|
||||
addLengthText(roof)
|
||||
// canvas.add(roof)
|
||||
createdRoofs.push(roof)
|
||||
canvas.remove(polygon)
|
||||
canvas.renderAll()
|
||||
})
|
||||
@ -1645,6 +1635,11 @@ export const usePolygon = () => {
|
||||
auxiliaryLines.forEach((line) => {
|
||||
canvas.remove(line)
|
||||
})
|
||||
|
||||
createdRoofs.forEach((roof) => {
|
||||
canvas.add(roof)
|
||||
})
|
||||
|
||||
canvas.renderAll()
|
||||
canvas.discardActiveObject()
|
||||
}
|
||||
@ -1970,38 +1965,6 @@ export const usePolygon = () => {
|
||||
canvas.renderAll()
|
||||
}
|
||||
|
||||
/**
|
||||
* 폴리곤의 라인 길이가 10 이하로 차이나는 경우 작은 값으로 통일
|
||||
* @param polygon
|
||||
*/
|
||||
const unifyLineLengths = (polygon) => {
|
||||
if (!polygon.lines || polygon.lines.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const lines = polygon.lines
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
for (let j = i + 1; j < lines.length; j++) {
|
||||
const length1 = lines[i].getLength()
|
||||
const length2 = lines[j].getLength()
|
||||
const diff = Math.abs(length1 - length2)
|
||||
|
||||
if (diff > 0 && diff <= 10) {
|
||||
const minLength = Math.min(length1, length2)
|
||||
if (length1 > length2) {
|
||||
lines[i].setLengthByValue(minLength)
|
||||
} else {
|
||||
lines[j].setLengthByValue(minLength)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addLengthText(polygon)
|
||||
canvas.renderAll()
|
||||
}
|
||||
|
||||
/**
|
||||
* 폴리곤의 라인 속성을 복도치수, 실제치수에 따라 actualSize 설정
|
||||
* @param polygon
|
||||
@ -2010,7 +1973,23 @@ export const usePolygon = () => {
|
||||
if (!polygon.lines || polygon.lines.length === 0 || !polygon.roofMaterial) {
|
||||
return
|
||||
}
|
||||
unifyLineLengths(polygon)
|
||||
|
||||
// createdRoofs들의 모든 lines를 확인해서 length값이 1이하인 차이가 있으면 통일 시킨다.
|
||||
const allRoofs = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF)
|
||||
const allRoofLines = allRoofs.flatMap((roof) => roof.lines)
|
||||
for (let i = 0; i < allRoofLines.length; i++) {
|
||||
for (let j = i + 1; j < allRoofLines.length; j++) {
|
||||
const line1 = allRoofLines[i]
|
||||
const line2 = allRoofLines[j]
|
||||
const diff = Math.abs(line1.length - line2.length)
|
||||
if (diff > 0 && diff <= 1) {
|
||||
const minLength = Math.min(line1.length, line2.length)
|
||||
line1.setLengthByValue(minLength * 10)
|
||||
line2.setLengthByValue(minLength * 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
polygon.lines.forEach((line) => {
|
||||
setActualSize(line, polygon.direction, +polygon.roofMaterial?.pitch)
|
||||
})
|
||||
@ -2027,6 +2006,5 @@ export const usePolygon = () => {
|
||||
splitPolygonWithLines,
|
||||
splitPolygonWithSeparate,
|
||||
setPolygonLinesActualSize,
|
||||
unifyLineLengths,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user