diff --git a/src/components/common/context-menu/QContextMenu.jsx b/src/components/common/context-menu/QContextMenu.jsx index 4658ef6f..cacb041c 100644 --- a/src/components/common/context-menu/QContextMenu.jsx +++ b/src/components/common/context-menu/QContextMenu.jsx @@ -12,7 +12,7 @@ export default function QContextMenu(props) { let contextType = '' if (activeObject) { - if (activeObject.initOptions) { + if (activeObject.initOptions && activeObject.initOptions.name) { //이건 바뀔 가능성이 있음 if (activeObject.initOptions.name.indexOf('guide') > -1) { contextType = 'surface' //면형상 diff --git a/src/hooks/useMode.js b/src/hooks/useMode.js index 46709a76..df0dc0d2 100644 --- a/src/hooks/useMode.js +++ b/src/hooks/useMode.js @@ -1213,13 +1213,44 @@ export function useMode() { } const templateSideMode = () => { - changeMode(canvas, Mode.EDIT) - if (historyPoints.current.length >= 4) { - const wall = drawWallPolygon() - setWall(wall) + const firstPoint = historyPoints.current[0] + const lastPoint = historyPoints.current[historyPoints.current.length - 1] + historyPoints.current.forEach((point) => { + canvas?.remove(point) + }) + drawLineWithLength(lastPoint, firstPoint) - console.log('sideWall', wall) + // 캔버스에서 모든 라인 객체를 찾습니다. + const lines = historyLines.current + historyLines.current = [] + + // 각 라인의 시작점과 끝점을 사용하여 다각형의 점 배열을 생성합니다. + const points = lines.map((line) => ({ x: line.x1, y: line.y1 })) + + // 모든 라인 객체를 캔버스에서 제거합니다. + lines.forEach((line) => { + canvas?.remove(line) + }) + + // 점 배열을 사용하여 새로운 다각형 객체를 생성합니다. + const polygon = new QPolygon( + points, + { + stroke: 'black', + fill: 'transparent', + viewLengthText: true, + fontSize: 15, + selectable: true, + }, + canvas, + ) + + // 새로운 다각형 객체를 캔버스에 추가합니다. + canvas.add(polygon) + + changeMode(canvas, Mode.DEFAULT) + return polygon } }