Merge branch 'dev' of https://git.hanasys.jp/qcast3/qcast-front into dev_ysCha

This commit is contained in:
ysCha 2026-01-08 18:12:30 +09:00
commit 0edc7bd161
2 changed files with 41 additions and 86 deletions

View File

@ -323,42 +323,19 @@ export function useRoofAllocationSetting(id) {
}
const drawOriginRoofLine = () => {
// outerLinePoints 배열을 이용하여 빨간색 Line 객체들 생성
if (outerLinePoints && outerLinePoints.length > 1) {
// 연속된 점들을 연결하여 라인 생성
for (let i = 0; i < outerLinePoints.length - 1; i++) {
const point1 = outerLinePoints[i]
const point2 = outerLinePoints[i + 1]
const line = new fabric.Line([point1.x, point1.y, point2.x, point2.y], {
stroke: 'black',
strokeDashArray: [5, 2],
strokeWidth: 1,
selectable: false,
name: 'originRoofOuterLine',
visible: outlineDisplay,
})
canvas.add(line)
}
// 마지막 점과 첫 점을 연결하여 폐곡선 만들기
if (outerLinePoints.length > 2) {
const lastPoint = outerLinePoints[outerLinePoints.length - 1]
const firstPoint = outerLinePoints[0]
const closingLine = new fabric.Line([lastPoint.x, lastPoint.y, firstPoint.x, firstPoint.y], {
stroke: 'red',
strokeWidth: 2,
selectable: false,
name: 'originRoofOuterLine',
})
canvas.add(closingLine)
}
canvas.renderAll()
}
const wallLines = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.WALL)
/** 벽면 삭제 */
wallLines.forEach((wallLine) => {
wallLine.set({
stroke: 'black',
strokeDashArray: [5, 2],
strokeWidth: 1,
selectable: false,
name: 'originRoofOuterLine',
visible: outlineDisplay,
})
})
canvas.renderAll()
}
/**

View File

@ -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,
}
}