context 오류 수정

This commit is contained in:
yjnoh 2024-09-09 11:07:09 +09:00
parent 38754db30d
commit ad1898c289
2 changed files with 37 additions and 6 deletions

View File

@ -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' //

View File

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