Compare commits

..

No commits in common. "09a5fdba412e6cadc77808be844360962a82b68f" and "1431dd9d9e32409a0b911b637d7f1f5fd9e66f24" have entirely different histories.

3 changed files with 19 additions and 49 deletions

View File

@ -179,7 +179,7 @@ export function useCanvasSetting(executeEffect = true) {
layout: ['ROOF_ID_SLATE', 'ROOF_ID_SINGLE'].includes(item.roofMatlCd) ? ROOF_MATERIAL_LAYOUT.STAIRS : ROOF_MATERIAL_LAYOUT.PARALLEL, layout: ['ROOF_ID_SLATE', 'ROOF_ID_SINGLE'].includes(item.roofMatlCd) ? ROOF_MATERIAL_LAYOUT.STAIRS : ROOF_MATERIAL_LAYOUT.PARALLEL,
hajebichi: item.roofPchBase && parseInt(item.roofPchBase), hajebichi: item.roofPchBase && parseInt(item.roofPchBase),
pitch: item.inclBase ? parseInt(item.inclBase) : 4, pitch: item.inclBase ? parseInt(item.inclBase) : 4,
angle: getDegreeByChon(item.inclBase ? parseInt(item.inclBase) : 4), //item.angle ? parseInt(item.angle) : 21.8, angle: getDegreeByChon(item.inclBase ? parseInt(item.inclBase): 4) //item.angle ? parseInt(item.angle) : 21.8,
})) }))
setRoofMaterials(roofLists) setRoofMaterials(roofLists)
return roofLists return roofLists
@ -231,9 +231,8 @@ export function useCanvasSetting(executeEffect = true) {
setPolygonLinesActualSize(roof) setPolygonLinesActualSize(roof)
}) })
changeCorridorDimensionText() changeCorridorDimensionText()
canvas.renderAll()
} }
}, [corridorDimension, canvasSetting]) }, [corridorDimension])
useEffect(() => { useEffect(() => {
if (!executeEffect) { if (!executeEffect) {

View File

@ -168,9 +168,6 @@ 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
@ -212,11 +209,7 @@ export const useLine = () => {
} }
} }
line.attributes = { line.attributes = { ...line.attributes, actualSize: Number(line.attributes.actualSize.toFixed(0)) }
...line.attributes,
actualSize: Number(line.attributes.actualSize.toFixed(0)),
isCalculated: true,
}
} }
return { return {

View File

@ -973,6 +973,7 @@ 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)
@ -1042,25 +1043,16 @@ 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: unifiedPlaneSize, planeSize: Math.round(Math.hypot(newLine1.x1 - newLine1.x2, newLine1.y1 - newLine1.y2)) * 10,
actualSize: unifiedActualSize, actualSize: Math.round(Math.hypot(newLine1.x1 - newLine1.x2, newLine1.y1 - newLine1.y2)) * 10,
} }
newLine1.length = maxLength
newLine2.attributes = { newLine2.attributes = {
...line.attributes, ...line.attributes,
planeSize: unifiedPlaneSize, planeSize: Math.round(Math.hypot(newLine2.x1 - newLine2.x2, newLine2.y1 - newLine2.y2)) * 10,
actualSize: unifiedActualSize, actualSize: Math.round(Math.hypot(newLine2.x1 - newLine2.x2, newLine2.y1 - newLine2.y2)) * 10,
} }
newLine2.length = maxLength
newLines.push(newLine1, newLine2) newLines.push(newLine1, newLine2)
divideLines.splice(i, 1) // 기존 line 제거 divideLines.splice(i, 1) // 기존 line 제거
@ -1079,13 +1071,11 @@ 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: line.attributes.planeSize ?? calcLength, planeSize: Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10,
actualSize: line.attributes.actualSize ?? calcLength, actualSize: Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10,
} }
newLine.length = line.attributes.planeSize ?? calcLength
newLines.push(newLine) newLines.push(newLine)
currentPoint = minDistancePoint currentPoint = minDistancePoint
@ -1099,13 +1089,11 @@ 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: line.attributes.planeSize ?? lastCalcLength, planeSize: Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10,
actualSize: line.attributes.actualSize ?? lastCalcLength, actualSize: Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10,
} }
newLine.length = line.attributes.planeSize ?? lastCalcLength
newLines.push(newLine) newLines.push(newLine)
divideLines.splice(i, 1) // 기존 line 제거 divideLines.splice(i, 1) // 기존 line 제거
@ -1958,33 +1946,23 @@ 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 maxLength = Math.max(line1.length, line2.length) const minLength = Math.min(line1.length, line2.length)
line1.setLengthByValue(maxLength * 10) line1.setLengthByValue(minLength * 10)
line2.setLengthByValue(maxLength * 10) line2.setLengthByValue(minLength * 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)
}) })