diff --git a/src/hooks/roofcover/useOuterLineWall.js b/src/hooks/roofcover/useOuterLineWall.js index e5f14cc1..ebe1d8ad 100644 --- a/src/hooks/roofcover/useOuterLineWall.js +++ b/src/hooks/roofcover/useOuterLineWall.js @@ -252,6 +252,7 @@ export function useOuterLineWall(id, propertiesId) { canvas?.renderAll() setOuterLineFix(true) closePopup(id) + ccwCheck() addPopup(propertiesId, 1, ) } @@ -905,6 +906,51 @@ export function useOuterLineWall(id, propertiesId) { } } + // 시계방향으로 그려진 경우 반시게방향으로 변경 + const ccwCheck = () => { + let outerLines = canvas.getObjects().filter((obj) => obj.name === 'outerLine') + + if (outerLines.length < 2) { + swalFire({ text: getMessage('wall.line.not.found') }) + return + } + + /** + * 외벽선이 시계방향인지 시계반대 방향인지 확인 + */ + const outerLinePoints = outerLines.map((line) => ({ x: line.x1, y: line.y1 })) + let counterClockwise = true + let signedArea = 0 + + outerLinePoints.forEach((point, index) => { + const nextPoint = outerLinePoints[(index + 1) % outerLinePoints.length] + signedArea += point.x * nextPoint.y - point.y * nextPoint.x + }) + + if (signedArea > 0) { + counterClockwise = false + } + /** 시계 방향일 경우 외벽선 reverse*/ + if (!counterClockwise) { + outerLines.reverse().forEach((line, index) => { + addLine([line.x2, line.y2, line.x1, line.y1], { + stroke: line.stroke, + strokeWidth: line.strokeWidth, + idx: index, + selectable: line.selectable, + name: 'outerLine', + x1: line.x2, + y1: line.y2, + x2: line.x1, + y2: line.y1, + visible: line.visible, + }) + canvas.remove(line) + }) + canvas.renderAll() + } + } + return { points, setPoints, diff --git a/src/hooks/roofcover/useRoofShapeSetting.js b/src/hooks/roofcover/useRoofShapeSetting.js index edf0e7b6..9e1d00ff 100644 --- a/src/hooks/roofcover/useRoofShapeSetting.js +++ b/src/hooks/roofcover/useRoofShapeSetting.js @@ -179,46 +179,6 @@ export function useRoofShapeSetting(id) { let outerLines = canvas.getObjects().filter((obj) => obj.name === 'outerLine') let direction - if (outerLines.length < 2) { - swalFire({ text: getMessage('wall.line.not.found') }) - return - } - - /** - * 외벽선이 시계방향인지 시계반대 방향인지 확인 - */ - const outerLinePoints = outerLines.map((line) => ({ x: line.x1, y: line.y1 })) - let counterClockwise = true - let signedArea = 0 - - outerLinePoints.forEach((point, index) => { - const nextPoint = outerLinePoints[(index + 1) % outerLinePoints.length] - signedArea += point.x * nextPoint.y - point.y * nextPoint.x - }) - - if (signedArea > 0) { - counterClockwise = false - } - /** 시계 방향일 경우 외벽선 reverse*/ - if (!counterClockwise) { - outerLines.reverse().forEach((line, index) => { - addLine([line.x2, line.y2, line.x1, line.y1], { - stroke: line.stroke, - strokeWidth: line.strokeWidth, - idx: index, - selectable: line.selectable, - name: 'outerLine', - x1: line.x2, - y1: line.y2, - x2: line.x1, - y2: line.y1, - visible: line.visible, - }) - canvas.remove(line) - }) - canvas.renderAll() - } - if ([1, 2, 3, 5, 6, 7, 8].includes(shapeNum)) { // 변별로 설정이 아닌 경우 경사를 지붕재에 적용해주어야함 setRoofPitch() @@ -507,7 +467,7 @@ export function useRoofShapeSetting(id) { originX: 'center', originY: 'center', }) - polygon.setViewLengthText(false) + // polygon.setViewLengthText(false) polygon.lines = [...outerLines] addPitchTextsByOuterLines() diff --git a/src/hooks/useMode.js b/src/hooks/useMode.js index 69eb955c..6030f43f 100644 --- a/src/hooks/useMode.js +++ b/src/hooks/useMode.js @@ -1820,7 +1820,13 @@ export function useMode() { x: xDiff.eq(0) ? offsetCurrentPoint.x : nextWall.x1, y: yDiff.eq(0) ? offsetCurrentPoint.y : nextWall.y1, } - const diffOffset = Big(nextWall.attributes.offset).minus(Big(currentWall.attributes.offset)) + let diffOffset + if (nextWall.index > currentWall.index) { + diffOffset = Big(nextWall.attributes.offset).minus(Big(currentWall.attributes.offset)).abs() + } else { + diffOffset = Big(currentWall.attributes.offset).minus(Big(nextWall.attributes.offset)) + } + const offsetPoint2 = { x: yDiff.eq(0) ? offsetPoint1.x : Big(offsetPoint1.x).plus(diffOffset).toNumber(), y: xDiff.eq(0) ? offsetPoint1.y : Big(offsetPoint1.y).plus(diffOffset).toNumber(),