wallines index 수정

This commit is contained in:
yscha 2025-12-13 03:14:21 +09:00
parent aa6ec20baa
commit 44b2f66a8f

View File

@ -766,15 +766,19 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
}); });
}; };
const sortedWallLines = sortCurrentRoofLines(wall.lines); // const sortedWallLines = sortCurrentRoofLines(wall.lines);
// roofLines의 방향에 맞춰 currentRoofLines 조정 후 정렬 // roofLines의 방향에 맞춰 currentRoofLines 조정 후 정렬
const alignedCurrentRoofLines = alignLineDirection(currentRoofLines, roofLines); const alignedCurrentRoofLines = alignLineDirection(currentRoofLines, roofLines);
const sortedCurrentRoofLines = sortCurrentRoofLines(alignedCurrentRoofLines); const sortedCurrentRoofLines = sortCurrentRoofLines(alignedCurrentRoofLines);
const sortedRoofLines = sortCurrentRoofLines(roofLines); // const sortedRoofLines = sortCurrentRoofLines(roofLines);
const sortedWallBaseLines = sortCurrentRoofLines(wall.baseLines); const sortedWallBaseLines = sortCurrentRoofLines(wall.baseLines);
const sortedBaseLines = sortBaseLinesByWallLines(wall.baseLines, wallLines); // const sortedBaseLines = sortBaseLinesByWallLines(wall.baseLines, wallLines);
const sortRoofLines = sortBaseLinesByWallLines(roofLines, wallLines); const sortRoofLines = sortBaseLinesByWallLines(roofLines, wallLines);
// 원본 wallLines를 복사하여 사용
const sortedWallLines = [...wallLines];
const sortedBaseLines = sortBaseLinesByWallLines(wall.baseLines, sortedWallLines);
const sortedRoofLines = sortBaseLinesByWallLines(roofLines, sortedWallLines);
//wall.lines 는 기본 벽 라인 //wall.lines 는 기본 벽 라인
//wall.baseLine은 움직인라인 //wall.baseLine은 움직인라인
@ -1487,12 +1491,6 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
}); });
} }
// const polygon = canvas.getObjects().find(obj => obj.type === 'QPolygon' && obj.id === roofId);
// if (polygon) {
// removeMatchingLines(polygon, wallLine);
// canvas.requestRenderAll();
// }
if (findPoints.length > 0) { if (findPoints.length > 0) {
// 모든 점에 대해 라인 업데이트를 누적 // 모든 점에 대해 라인 업데이트를 누적
return findPoints.reduce((innerLines, point) => { return findPoints.reduce((innerLines, point) => {
@ -1500,42 +1498,6 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
}, [...innerLines]); }, [...innerLines]);
} }
const polygon = canvas.getObjects().find(obj => obj.type === 'QPolygon' && obj.id === roofId);
if (polygon && polygon.lines) {
// Find all lines that match your condition (e.g., stroke color)
const linesToRemoves = polygon.lines.filter(line =>
line.stroke === '#1083E3' // Your condition here
);
// Remove each matching line
linesToRemoves.forEach(lineToRemove => {
const index = polygon.lines.indexOf(lineToRemove);
if (index > -1) {
polygon.lines.splice(index, 1);
}
// Remove from canvas if needed
if (lineToRemove.canvas) {
lineToRemove.canvas.remove(lineToRemove);
}
});
// Update polygon points
const newPoints = polygon.lines.map(line => {
return { x: line.x1, y: line.y1 };
});
polygon.set({ points: newPoints });
polygon.initLines();
canvas.requestRenderAll();
}
// Usage
return innerLines; return innerLines;
} }
@ -3512,37 +3474,3 @@ export const sortBaseLinesByWallLines = (baseLines, wallLines) => {
return sortedBaseLines; return sortedBaseLines;
}; };
function removeMatchingLines(polygon, roofLine) {
if (!polygon.lines) return;
// Find lines that match the roofLine coordinates
const linesToRemove = polygon.lines.filter(line => {
return (line.x1 === roofLine.x1 && line.y1 === roofLine.y1 &&
line.x2 === roofLine.x2 && line.y2 === roofLine.y2) ||
(line.x1 === roofLine.x2 && line.y1 === roofLine.y2 &&
line.x2 === roofLine.x1 && line.y2 === roofLine.y1);
});
// Remove the matching lines
linesToRemove.forEach(lineToRemove => {
const index = polygon.lines.indexOf(lineToRemove);
if (index > -1) {
polygon.lines.splice(index, 1);
}
if (lineToRemove.canvas) {
lineToRemove.canvas.remove(lineToRemove);
}
});
// Update polygon points
if (linesToRemove.length > 0) {
const newPoints = polygon.lines.map(line => {
return { x: line.x1, y: line.y1 };
});
polygon.set({ points: newPoints });
polygon.initLines();
}
}