Merge pull request 'dev' (#563) from dev into prd-deploy
Reviewed-on: #563
This commit is contained in:
commit
3f0e639877
@ -61,28 +61,40 @@ export default function RightAngle({ props }) {
|
|||||||
<div className="grid-direction">
|
<div className="grid-direction">
|
||||||
<button
|
<button
|
||||||
className={`direction up ${arrow1 === '↑' ? 'act' : ''}`}
|
className={`direction up ${arrow1 === '↑' ? 'act' : ''}`}
|
||||||
onClick={() => {
|
onMouseDown={(e) => {
|
||||||
|
e.preventDefault(); // 포커스가 input에서 버튼으로 옮겨가는 것을 원천 차단
|
||||||
|
}}
|
||||||
|
onClick={(e) => {
|
||||||
setArrow1('↑')
|
setArrow1('↑')
|
||||||
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowUp' }))
|
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowUp' }))
|
||||||
}}
|
}}
|
||||||
></button>
|
></button>
|
||||||
<button
|
<button
|
||||||
className={`direction down ${arrow1 === '↓' ? 'act' : ''}`}
|
className={`direction down ${arrow1 === '↓' ? 'act' : ''}`}
|
||||||
onClick={() => {
|
onMouseDown={(e) => {
|
||||||
|
e.preventDefault(); // 포커스가 input에서 버튼으로 옮겨가는 것을 원천 차단
|
||||||
|
}}
|
||||||
|
onClick={(e) => {
|
||||||
setArrow1('↓')
|
setArrow1('↓')
|
||||||
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown' }))
|
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown' }))
|
||||||
}}
|
}}
|
||||||
></button>
|
></button>
|
||||||
<button
|
<button
|
||||||
className={`direction left ${arrow1 === '←' ? 'act' : ''}`}
|
className={`direction left ${arrow1 === '←' ? 'act' : ''}`}
|
||||||
onClick={() => {
|
onMouseDown={(e) => {
|
||||||
|
e.preventDefault(); // 포커스가 input에서 버튼으로 옮겨가는 것을 원천 차단
|
||||||
|
}}
|
||||||
|
onClick={(e) => {
|
||||||
setArrow1('←')
|
setArrow1('←')
|
||||||
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft' }))
|
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft' }))
|
||||||
}}
|
}}
|
||||||
></button>
|
></button>
|
||||||
<button
|
<button
|
||||||
className={`direction right ${arrow1 === '→' ? 'act' : ''}`}
|
className={`direction right ${arrow1 === '→' ? 'act' : ''}`}
|
||||||
onClick={() => {
|
onMouseDown={(e) => {
|
||||||
|
e.preventDefault(); // 포커스가 input에서 버튼으로 옮겨가는 것을 원천 차단
|
||||||
|
}}
|
||||||
|
onClick={(e) => {
|
||||||
setArrow1('→')
|
setArrow1('→')
|
||||||
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight' }))
|
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight' }))
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -323,14 +323,10 @@ export function useRoofAllocationSetting(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const drawOriginRoofLine = () => {
|
const drawOriginRoofLine = () => {
|
||||||
// outerLinePoints 배열을 이용하여 빨간색 Line 객체들 생성
|
const wallLines = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.WALL)
|
||||||
if (outerLinePoints && outerLinePoints.length > 1) {
|
/** 벽면 삭제 */
|
||||||
// 연속된 점들을 연결하여 라인 생성
|
wallLines.forEach((wallLine) => {
|
||||||
for (let i = 0; i < outerLinePoints.length - 1; i++) {
|
wallLine.set({
|
||||||
const point1 = outerLinePoints[i]
|
|
||||||
const point2 = outerLinePoints[i + 1]
|
|
||||||
|
|
||||||
const line = new fabric.Line([point1.x, point1.y, point2.x, point2.y], {
|
|
||||||
stroke: 'black',
|
stroke: 'black',
|
||||||
strokeDashArray: [5, 2],
|
strokeDashArray: [5, 2],
|
||||||
strokeWidth: 1,
|
strokeWidth: 1,
|
||||||
@ -338,28 +334,9 @@ export function useRoofAllocationSetting(id) {
|
|||||||
name: 'originRoofOuterLine',
|
name: 'originRoofOuterLine',
|
||||||
visible: outlineDisplay,
|
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()
|
canvas.renderAll()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 지붕재 오른쪽 마우스 클릭 후 단일로 지붕재 변경 필요한 경우
|
* 지붕재 오른쪽 마우스 클릭 후 단일로 지붕재 변경 필요한 경우
|
||||||
|
|||||||
@ -1,19 +1,7 @@
|
|||||||
import {
|
import { ANGLE_TYPE, canvasState, currentAngleTypeSelector, globalPitchState, pitchTextSelector } from '@/store/canvasAtom'
|
||||||
ANGLE_TYPE,
|
|
||||||
canvasState,
|
|
||||||
currentAngleTypeSelector,
|
|
||||||
globalPitchState,
|
|
||||||
pitchTextSelector,
|
|
||||||
} from '@/store/canvasAtom'
|
|
||||||
import { useRecoilValue } from 'recoil'
|
import { useRecoilValue } from 'recoil'
|
||||||
import { fabric } from 'fabric'
|
import { fabric } from 'fabric'
|
||||||
import {
|
import { calculateIntersection, findAndRemoveClosestPoint, getDegreeByChon, getDegreeInOrientation, isPointOnLine } from '@/util/canvas-util'
|
||||||
calculateIntersection,
|
|
||||||
findAndRemoveClosestPoint,
|
|
||||||
getDegreeByChon,
|
|
||||||
getDegreeInOrientation,
|
|
||||||
isPointOnLine,
|
|
||||||
} from '@/util/canvas-util'
|
|
||||||
import { QPolygon } from '@/components/fabric/QPolygon'
|
import { QPolygon } from '@/components/fabric/QPolygon'
|
||||||
import { isSamePoint, removeDuplicatePolygons } from '@/util/qpolygon-utils'
|
import { isSamePoint, removeDuplicatePolygons } from '@/util/qpolygon-utils'
|
||||||
import { basicSettingState, flowDisplaySelector } from '@/store/settingAtom'
|
import { basicSettingState, flowDisplaySelector } from '@/store/settingAtom'
|
||||||
@ -1392,6 +1380,8 @@ export const usePolygon = () => {
|
|||||||
// 나눠서 중복 제거된 roof return
|
// 나눠서 중복 제거된 roof return
|
||||||
let newRoofs = getSplitRoofsPoints(allLines)
|
let newRoofs = getSplitRoofsPoints(allLines)
|
||||||
|
|
||||||
|
const createdRoofs = []
|
||||||
|
|
||||||
newRoofs = newRoofs.filter((roof) => roof.length !== 0)
|
newRoofs = newRoofs.filter((roof) => roof.length !== 0)
|
||||||
newRoofs.forEach((roofPoint, index) => {
|
newRoofs.forEach((roofPoint, index) => {
|
||||||
let defense, pitch
|
let defense, pitch
|
||||||
@ -1634,8 +1624,8 @@ export const usePolygon = () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
canvas.add(roof)
|
// canvas.add(roof)
|
||||||
addLengthText(roof)
|
createdRoofs.push(roof)
|
||||||
canvas.remove(polygon)
|
canvas.remove(polygon)
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
})
|
})
|
||||||
@ -1645,6 +1635,11 @@ export const usePolygon = () => {
|
|||||||
auxiliaryLines.forEach((line) => {
|
auxiliaryLines.forEach((line) => {
|
||||||
canvas.remove(line)
|
canvas.remove(line)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
createdRoofs.forEach((roof) => {
|
||||||
|
canvas.add(roof)
|
||||||
|
})
|
||||||
|
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
canvas.discardActiveObject()
|
canvas.discardActiveObject()
|
||||||
}
|
}
|
||||||
@ -1970,38 +1965,6 @@ export const usePolygon = () => {
|
|||||||
canvas.renderAll()
|
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 설정
|
* 폴리곤의 라인 속성을 복도치수, 실제치수에 따라 actualSize 설정
|
||||||
* @param polygon
|
* @param polygon
|
||||||
@ -2010,7 +1973,23 @@ export const usePolygon = () => {
|
|||||||
if (!polygon.lines || polygon.lines.length === 0 || !polygon.roofMaterial) {
|
if (!polygon.lines || polygon.lines.length === 0 || !polygon.roofMaterial) {
|
||||||
return
|
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) => {
|
polygon.lines.forEach((line) => {
|
||||||
setActualSize(line, polygon.direction, +polygon.roofMaterial?.pitch)
|
setActualSize(line, polygon.direction, +polygon.roofMaterial?.pitch)
|
||||||
})
|
})
|
||||||
@ -2027,6 +2006,5 @@ export const usePolygon = () => {
|
|||||||
splitPolygonWithLines,
|
splitPolygonWithLines,
|
||||||
splitPolygonWithSeparate,
|
splitPolygonWithSeparate,
|
||||||
setPolygonLinesActualSize,
|
setPolygonLinesActualSize,
|
||||||
unifyLineLengths,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user