diff --git a/src/components/common/context-menu/QContextMenu.jsx b/src/components/common/context-menu/QContextMenu.jsx index a86e40af..8e3e2314 100644 --- a/src/components/common/context-menu/QContextMenu.jsx +++ b/src/components/common/context-menu/QContextMenu.jsx @@ -27,7 +27,7 @@ export default function QContextMenu(props) { const handleContextMenu = (e) => { // e.preventDefault() //기존 contextmenu 막고 setContextMenu({ visible: true, x: e.pageX, y: e.pageY }) - console.log(111, canvasProps) + // console.log(111, canvasProps) canvasProps?.upperCanvasEl.removeEventListener('contextmenu', handleContextMenu) //한번 노출 후 이벤트 삭제 } diff --git a/src/hooks/roofcover/useAuxiliaryDrawing.js b/src/hooks/roofcover/useAuxiliaryDrawing.js index 94a7e989..f479a92e 100644 --- a/src/hooks/roofcover/useAuxiliaryDrawing.js +++ b/src/hooks/roofcover/useAuxiliaryDrawing.js @@ -538,59 +538,66 @@ export function useAuxiliaryDrawing(setShowAuxiliaryModal) { // 보조선 절삭 const cutAuxiliary = (e) => { - const auxiliaryLines = canvas.getObjects().filter((obj) => obj.name === 'auxiliaryLine' && !obj.isFixed) + const auxiliaryLines = canvas.getObjects().filter((obj) => obj.name === 'auxiliaryLine') if (auxiliaryLines.length === 0) { return } + const roofBases = canvas.getObjects().filter((obj) => obj.name === 'roofBase') + + const allLines = [...auxiliaryLines] + + roofBases.forEach((roofBase) => { + roofBase.lines.forEach((line) => { + allLines.push(line) + }) + }) + auxiliaryLines.forEach((line1) => { - auxiliaryLines.forEach((line2) => { - const lines = [line1, line2] + allLines.forEach((line2) => { if (line1 === line2) { return } - const intersectionPoint = calculateIntersection(line1, line2) - if (!intersectionPoint || intersectionPoints.current.some((point) => point.x === intersectionPoint.x && point.y === intersectionPoint.y)) { + if (!intersectionPoint) { return } roofAdsorptionPoints.current.push(intersectionPoint) intersectionPoints.current.push(intersectionPoint) - lines.forEach((line) => { - const distance1 = distanceBetweenPoints({ x: line.x1, y: line.y1 }, intersectionPoint) - const distance2 = distanceBetweenPoints({ x: line.x2, y: line.y2 }, intersectionPoint) - if (distance1 === 0 || distance2 === 0) { - return - } - //historyLine에서 기존 line을 제거한다. - lineHistory.current = lineHistory.current.filter((history) => history !== line) + const distance1 = distanceBetweenPoints({ x: line1.x1, y: line1.y1 }, intersectionPoint) + const distance2 = distanceBetweenPoints({ x: line1.x2, y: line1.y2 }, intersectionPoint) - let newLine + if (distance1 === 0 || distance2 === 0) { + return + } + //historyLine에서 기존 line을 제거한다. + lineHistory.current = lineHistory.current.filter((history) => history !== line1) - if (distance1 >= distance2) { - newLine = addLine([line.x1, line.y1, intersectionPoint.x, intersectionPoint.y], { - stroke: 'black', - strokeWidth: 1, - selectable: false, - name: 'auxiliaryLine', - isFixed: true, - intersectionPoint, - }) - } else { - newLine = addLine([line.x2, line.y2, intersectionPoint.x, intersectionPoint.y], { - stroke: 'black', - strokeWidth: 1, - selectable: false, - name: 'auxiliaryLine', - isFixed: true, - intersectionPoint, - }) - } - lineHistory.current.push(newLine) - removeLine(line) - }) + let newLine + + if (distance1 >= distance2) { + newLine = addLine([line1.x1, line1.y1, intersectionPoint.x, intersectionPoint.y], { + stroke: 'black', + strokeWidth: 1, + selectable: false, + name: 'auxiliaryLine', + isFixed: true, + intersectionPoint, + }) + } else { + newLine = addLine([line1.x2, line1.y2, intersectionPoint.x, intersectionPoint.y], { + stroke: 'black', + strokeWidth: 1, + selectable: false, + name: 'auxiliaryLine', + isFixed: true, + intersectionPoint, + }) + } + lineHistory.current.push(newLine) + removeLine(line1) }) }) addCanvasMouseEventListener('mouse:move', mouseMove) diff --git a/src/hooks/roofcover/useRoofShapePassivitySetting.js b/src/hooks/roofcover/useRoofShapePassivitySetting.js index 83ecf7ed..bedbcd11 100644 --- a/src/hooks/roofcover/useRoofShapePassivitySetting.js +++ b/src/hooks/roofcover/useRoofShapePassivitySetting.js @@ -36,6 +36,8 @@ export function useRoofShapePassivitySetting(setShowRoofShapePassivitySettingMod const isFix = useRef(false) const initLines = useRef([]) + const [isLoading, setIsLoading] = useState(false) + const buttons = [ { id: 1, name: getMessage('eaves'), type: TYPES.EAVES }, { id: 2, name: getMessage('gable'), type: TYPES.GABLE }, @@ -49,10 +51,13 @@ export function useRoofShapePassivitySetting(setShowRoofShapePassivitySettingMod if (!outerLineFix || outerLines.length === 0) { swalFire({ text: '외벽선이 없습니다.' }) setShowRoofShapePassivitySettingModal(false) + return } + setIsLoading(true) }, []) useEffect(() => { + if (!isLoading) return addCanvasMouseEventListener('mouse:down', mouseDown) const wallLines = canvas.getObjects().filter((obj) => obj.name === 'wallLine') @@ -75,7 +80,7 @@ export function useRoofShapePassivitySetting(setShowRoofShapePassivitySettingMod canvas?.discardActiveObject() initEvent() } - }, []) + }, [isLoading]) useEffect(() => { const lines = canvas.getObjects().filter((obj) => obj.name === 'outerLine')