Compare commits

..

No commits in common. "f9c598b8d181b1a4bf12a352e863ac8623ecb982" and "30f086f518251e3d3582cc53a021f930e2b855cc" have entirely different histories.

3 changed files with 919 additions and 885 deletions

View File

@ -575,19 +575,7 @@ export function useMovementSetting(id) {
targetBaseLines.push({ line: target, distance: 0 }) targetBaseLines.push({ line: target, distance: 0 })
} }
// Remove duplicate lines targetBaseLines.sort((a, b) => a.distance - b.distance)
const uniqueLines = new Map();
targetBaseLines = targetBaseLines.filter(item => {
const key = `${item.line.x1},${item.line.y1},${item.line.x2},${item.line.y2}`;
if (!uniqueLines.has(key)) {
uniqueLines.set(key, true);
return true;
}
return false;
});
// Sort by distance
targetBaseLines.sort((a, b) => a.distance - b.distance);
targetBaseLines = targetBaseLines.filter((line) => line.distance === targetBaseLines[0].distance) targetBaseLines = targetBaseLines.filter((line) => line.distance === targetBaseLines[0].distance)
if (isGableRoof) { if (isGableRoof) {

View File

@ -162,7 +162,6 @@ export function useContextMenu() {
case 'auxiliaryLine': case 'auxiliaryLine':
case 'hip': case 'hip':
case 'ridge': case 'ridge':
case 'eaveHelpLine':
if (selectedMenu === 'surface') { if (selectedMenu === 'surface') {
setContextMenu([ setContextMenu([
[ [

View File

@ -159,7 +159,7 @@ const movingLineFromSkeleton = (roofId, canvas) => {
// console.log("3333linePosition:::::", result.position); // console.log("3333linePosition:::::", result.position);
const position = movePosition //result.position; const position = movePosition //result.position;
const moveUpDownLength = Big(moveUpDown).times(1).div(10); const absMove = Big(moveUpDown).times(1).div(10);
const modifiedStartPoints = []; const modifiedStartPoints = [];
// oldPoints를 복사해서 새로운 points 배열 생성 // oldPoints를 복사해서 새로운 points 배열 생성
let newPoints = oldPoints.map(point => ({...point})); let newPoints = oldPoints.map(point => ({...point}));
@ -181,22 +181,64 @@ const movingLineFromSkeleton = (roofId, canvas) => {
const offset = line.attributes.offset const offset = line.attributes.offset
// 새로운 좌표 계산 // 새로운 좌표 계산
let newStartPoint = {...originalStartPoint}; let newStartPoint = {...originalStartPoint};
let newEndPoint = {...originalEndPoint} let newEndPoint = {...originalEndPoint};
// 위치와 방향에 따라 좌표 조정
/*
switch (position) {
case 'left':
if (moveDirection === 'up') {
newStartPoint.x = Big(line.startPoint.x).minus(absMove).toNumber();
newEndPoint.x = Big(line.endPoint.x).minus(absMove).toNumber();
} else if (moveDirection === 'down') {
newStartPoint.x = Big(line.startPoint.x).plus(absMove).toNumber();
newEndPoint.x = Big(line.endPoint.x).plus(absMove).toNumber();
}
break;
case 'right':
if (moveDirection === 'up') {
newStartPoint.x = Big(line.startPoint.x).plus(absMove).toNumber();
newEndPoint.x = Big(line.endPoint.x).plus(absMove).toNumber();
} else if (moveDirection === 'down') {
newStartPoint.x = Big(line.startPoint.x).minus(absMove).toNumber();
newEndPoint.x = Big(line.endPoint.x).minus(absMove).toNumber();
}
break;
case 'top':
if (moveDirection === 'up') {
newStartPoint.y = Big(line.startPoint.y).minus(absMove).toNumber();
newEndPoint.y = Big(line.endPoint.y).minus(absMove).toNumber();
} else if (moveDirection === 'down') {
newStartPoint.y = Big(line.startPoint.y).plus(absMove).toNumber();
newEndPoint.y = Big(line.endPoint.y).plus(absMove).toNumber();
}
break;
case 'bottom':
if (moveDirection === 'up') {
newStartPoint.y = Big(line.startPoint.y).plus(absMove).toNumber();
newEndPoint.y = Big(line.endPoint.y).plus(absMove).toNumber();
} else if (moveDirection === 'down') {
newStartPoint.y = Big(line.startPoint.y).minus(absMove).toNumber();
newEndPoint.y = Big(line.endPoint.y).minus(absMove).toNumber();
}
break;
}
*/
// 원본 라인 업데이트 // 원본 라인 업데이트
// newPoints 배열에서 일치하는 포인트들을 찾아서 업데이트 // newPoints 배열에서 일치하는 포인트들을 찾아서 업데이트
console.log('absMove::', moveUpDownLength); console.log('absMove::', absMove);
newPoints.forEach((point, index) => { newPoints.forEach((point, index) => {
if(position === 'bottom'){ if(position === 'bottom'){
if (moveDirection === 'in') { if (moveDirection === 'in') {
if(isSamePoint(roof.basePoints[index], originalStartPoint) || isSamePoint(roof.basePoints[index], originalEndPoint)) { if(isSamePoint(roof.basePoints[index], originalStartPoint) || isSamePoint(roof.basePoints[index], originalEndPoint)) {
point.y = Big(point.y).minus(moveUpDownLength).toNumber(); point.y = Big(point.y).minus(absMove).toNumber();
} }
// if (isSamePoint(roof.basePoints[index], originalEndPoint)) { // if (isSamePoint(roof.basePoints[index], originalEndPoint)) {
// point.y = Big(point.y).minus(absMove).toNumber(); // point.y = Big(point.y).minus(absMove).toNumber();
// } // }
}else if (moveDirection === 'out'){ }else if (moveDirection === 'out'){
if(isSamePoint(roof.basePoints[index], originalStartPoint) || isSamePoint(roof.basePoints[index], originalEndPoint)) { if(isSamePoint(roof.basePoints[index], originalStartPoint) || isSamePoint(roof.basePoints[index], originalEndPoint)) {
point.y = Big(point.y).plus(moveUpDownLength).toNumber(); point.y = Big(point.y).plus(absMove).toNumber();
} }
// if (isSamePoint(roof.basePoints[index], originalEndPoint)) { // if (isSamePoint(roof.basePoints[index], originalEndPoint)) {
// point.y = Big(point.y).plus(absMove).toNumber(); // point.y = Big(point.y).plus(absMove).toNumber();
@ -206,31 +248,31 @@ const movingLineFromSkeleton = (roofId, canvas) => {
}else if (position === 'top'){ }else if (position === 'top'){
if(moveDirection === 'in'){ if(moveDirection === 'in'){
if(isSamePoint(roof.basePoints[index], originalStartPoint)) { if(isSamePoint(roof.basePoints[index], originalStartPoint)) {
point.y = Big(point.y).plus(moveUpDownLength).toNumber(); point.y = Big(point.y).plus(absMove).toNumber();
} }
if (isSamePoint(roof.basePoints[index], originalEndPoint)) { if (isSamePoint(roof.basePoints[index], originalEndPoint)) {
point.y = Big(point.y).plus(moveUpDownLength).toNumber(); point.y = Big(point.y).plus(absMove).toNumber();
} }
}else if(moveDirection === 'out'){ }else if(moveDirection === 'out'){
if(isSamePoint(roof.basePoints[index], originalStartPoint)) { if(isSamePoint(roof.basePoints[index], originalStartPoint)) {
point.y = Big(point.y).minus(moveUpDownLength).toNumber(); point.y = Big(point.y).minus(absMove).toNumber();
} }
if (isSamePoint(roof.basePoints[index], originalEndPoint)) { if (isSamePoint(roof.basePoints[index], originalEndPoint)) {
point.y = Big(point.y).minus(moveUpDownLength).toNumber(); point.y = Big(point.y).minus(absMove).toNumber();
} }
} }
}else if(position === 'left'){ }else if(position === 'left'){
if(moveDirection === 'in'){ if(moveDirection === 'in'){
if(isSamePoint(roof.basePoints[index], originalStartPoint) || isSamePoint(roof.basePoints[index], originalEndPoint)) { if(isSamePoint(roof.basePoints[index], originalStartPoint) || isSamePoint(roof.basePoints[index], originalEndPoint)) {
point.x = Big(point.x).plus(moveUpDownLength).toNumber(); point.x = Big(point.x).plus(absMove).toNumber();
} }
// if (isSamePoint(roof.basePoints[index], originalEndPoint)) { // if (isSamePoint(roof.basePoints[index], originalEndPoint)) {
// point.x = Big(point.x).plus(absMove).toNumber(); // point.x = Big(point.x).plus(absMove).toNumber();
// } // }
}else if(moveDirection === 'out'){ }else if(moveDirection === 'out'){
if(isSamePoint(roof.basePoints[index], originalStartPoint) || isSamePoint(roof.basePoints[index], originalEndPoint)) { if(isSamePoint(roof.basePoints[index], originalStartPoint) || isSamePoint(roof.basePoints[index], originalEndPoint)) {
point.x = Big(point.x).minus(moveUpDownLength).toNumber(); point.x = Big(point.x).minus(absMove).toNumber();
} }
// if (isSamePoint(roof.basePoints[index], originalEndPoint)) { // if (isSamePoint(roof.basePoints[index], originalEndPoint)) {
// point.x = Big(point.x).minus(absMove).toNumber(); // point.x = Big(point.x).minus(absMove).toNumber();
@ -240,17 +282,17 @@ const movingLineFromSkeleton = (roofId, canvas) => {
}else if(position === 'right'){ }else if(position === 'right'){
if(moveDirection === 'in'){ if(moveDirection === 'in'){
if(isSamePoint(roof.basePoints[index], originalStartPoint)) { if(isSamePoint(roof.basePoints[index], originalStartPoint)) {
point.x = Big(point.x).minus(moveUpDownLength).toNumber(); point.x = Big(point.x).minus(absMove).toNumber();
} }
if (isSamePoint(roof.basePoints[index], originalEndPoint)) { if (isSamePoint(roof.basePoints[index], originalEndPoint)) {
point.x = Big(point.x).minus(moveUpDownLength).toNumber(); point.x = Big(point.x).minus(absMove).toNumber();
} }
}else if(moveDirection === 'out'){ }else if(moveDirection === 'out'){
if(isSamePoint(roof.basePoints[index], originalStartPoint)) { if(isSamePoint(roof.basePoints[index], originalStartPoint)) {
point.x = Big(point.x).plus(moveUpDownLength).toNumber(); point.x = Big(point.x).plus(absMove).toNumber();
} }
if (isSamePoint(roof.basePoints[index], originalEndPoint)) { if (isSamePoint(roof.basePoints[index], originalEndPoint)) {
point.x = Big(point.x).plus(moveUpDownLength).toNumber(); point.x = Big(point.x).plus(absMove).toNumber();
} }
} }
@ -398,8 +440,8 @@ export const skeletonBuilder = (roofId, canvas, textMode) => {
*/ */
const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
if (!skeleton?.Edges) return [] if (!skeleton?.Edges) return []
const roof = canvas?.getObjects().find((object) => object.id === roofId) let roof = canvas?.getObjects().find((object) => object.id === roofId)
const wall = canvas.getObjects().find((obj) => obj.name === POLYGON_TYPE.WALL && obj.attributes.roofId === roofId) let wall = canvas.getObjects().find((obj) => obj.name === POLYGON_TYPE.WALL && obj.attributes.roofId === roofId)
let skeletonLines = [] let skeletonLines = []
let findPoints = []; let findPoints = [];
@ -608,9 +650,8 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
canvas.renderAll(); canvas.renderAll();
}); });
if((roof.moveUpDown??0 > 0) || (roof.moveFlowLine??0 > 0) ) { //if((roof.moveUpDown??0 > 0) ) {
const getMoveUpDownLine = () => {
// 같은 라인이 없으므로 새 다각형 라인 생성 // 같은 라인이 없으므로 새 다각형 라인 생성
//라인 편집 //라인 편집
// let i = 0 // let i = 0
@ -657,6 +698,20 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
}); });
} }
// function sortCurrentRoofLines(lines) {
// return [...lines].sort((a, b) => {
// const aX = a.x1 ?? a.get('x1')
// const aY = a.y1 ?? a.get('y1')
// const bX = b.x1 ?? b.get('x1')
// const bY = b.y1 ?? b.get('y1')
// if (aX !== bX) return aX - bX
// return aY - bY
// })
// }
// 각 라인 집합 정렬 // 각 라인 집합 정렬
// roofLines의 방향에 맞춰 currentRoofLines의 방향을 조정 // roofLines의 방향에 맞춰 currentRoofLines의 방향을 조정
@ -729,19 +784,16 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
//wall.baseLine은 움직인라인 //wall.baseLine은 움직인라인
const movedLines = [] const movedLines = []
// 조건에 맞는 라인들만 필터링
const validWallLines = wallLines.filter((wallLine, index) => wallLine.idx - 1 === index); wallLines.forEach((wallLine, index) => {
validWallLines.forEach((wallLine, index) => { // const roofLine = sortedRoofLines[index];
// const currentRoofLine = sortedCurrentRoofLines[index];
// const moveLine = sortedWallBaseLines[index]
// const wallBaseLine = sortedWallBaseLines[index]
const originalIndex = wallLines.indexOf(wallLine); const roofLine = sortRoofLines[index];
const roofLine = sortRoofLines[originalIndex];
const currentRoofLine = currentRoofLines[originalIndex];
const moveLine = wall.baseLines[originalIndex];
const wallBaseLine = wall.baseLines[originalIndex];
// const roofLine = sortRoofLines[index];
if(roofLine.attributes.wallLine !== wallLine.id || (roofLine.idx - 1) !== index ){ if(roofLine.attributes.wallLine !== wallLine.id || (roofLine.idx - 1) !== index ){
console.log("wallLine2::::", wallLine.id) console.log("wallLine2::::", wallLine.id)
@ -752,9 +804,9 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
return false return false
}//roofLines.find(line => line.attributes.wallLineId === wallLine.attributes.wallId); }//roofLines.find(line => line.attributes.wallLineId === wallLine.attributes.wallId);
// const currentRoofLine = currentRoofLines[index]; const currentRoofLine = currentRoofLines[index];
// const moveLine = wall.baseLines[index] const moveLine = wall.baseLines[index]
// const wallBaseLine = wall.baseLines[index] const wallBaseLine = wall.baseLines[index]
//console.log("wallBaseLine", wallBaseLine); //console.log("wallBaseLine", wallBaseLine);
//roofline 외곽선 설정 //roofline 외곽선 설정
@ -795,23 +847,20 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
parentId : roof.id, parentId : roof.id,
fontSize : roof.fontSize, fontSize : roof.fontSize,
stroke : '#3FBAE6', stroke : '#3FBAE6',
strokeWidth: 4, strokeWidth: 2,
name : 'eaveHelpLine', name : 'eaveHelpLine',
lineName : 'eaveHelpLine', lineName : 'eaveHelpLine',
selectable : true,
visible : true, visible : true,
roofId : roofId, roofId : roofId,
selectable: true,
hoverCursor: 'pointer',
attributes : { attributes : {
type: 'eaveHelpLine', type: 'eaveHelpLine',
isStart : true, isStart : true,
pitch: wallLine.attributes.pitch, pitch: wallLine.attributes.pitch,
} }
}); });
//coordinateText(line) //coordinateText(line)
canvas.add(line) canvas.add(line)
line.bringToFront()
canvas.renderAll(); canvas.renderAll();
return line return line
} }
@ -1493,12 +1542,10 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => {
} }
canvas.renderAll() canvas.renderAll()
}); });
} // }
getMoveUpDownLine()
}
if (findPoints.length > 0) { if (findPoints.length > 0) {
// 모든 점에 대해 라인 업데이트를 누적 // 모든 점에 대해 라인 업데이트를 누적