diff --git a/src/components/Roof2.jsx b/src/components/Roof2.jsx index 7467a634..3fce8640 100644 --- a/src/components/Roof2.jsx +++ b/src/components/Roof2.jsx @@ -80,7 +80,6 @@ export default function Roof2(props) { setMode, changeMode, handleClear, - fillCellInPolygon, zoomIn, zoomOut, zoom, @@ -580,7 +579,7 @@ export default function Roof2(props) { > 그리드 설정 - + ) diff --git a/src/hooks/useMode.js b/src/hooks/useMode.js index 11cc0ec2..c7f2f5b2 100644 --- a/src/hooks/useMode.js +++ b/src/hooks/useMode.js @@ -123,9 +123,13 @@ export function useMode() { }, [guideLineInfo]) const drawMouseLines = (e) => { + console.log('guideLineInfo', guideLineInfo) + let isGuideLineMode = false, isGuideDotMode = false - let guideDotLength, guideLineLength, horizontalLineArray, verticalLineArray + let guideDotLength, guideLineLengthHori, guideLineLengthVert, horizontalLineArray, verticalLineArray + + console.log() if (isObjectNotEmpty(guideLineInfo)) { const guideLineState = guideLineInfo.filter((item) => item.guideMode === 'guideLine') @@ -136,13 +140,15 @@ export function useMode() { isGuideDotMode = guideDotState.length > 0 if (isGuideDotMode) { - guideDotLength = Number(guideDotState[0].moduleLength) + guideLineLengthHori = Number(guideDotState[0].moduleHoriLength) + guideLineLengthVert = Number(guideDotState[0].moduleVertLength) } if (isGuideLineMode) { horizontalLineArray = [...guideLineState[0].horizontalLineArray] verticalLineArray = [...guideLineState[0].verticalLineArray] - guideLineLength = Number(guideLineState[0].moduleLength) + guideLineLengthHori = Number(guideLineState[0].moduleHoriLength) + guideLineLengthVert = Number(guideLineState[0].moduleVertLength) } } @@ -161,17 +167,17 @@ export function useMode() { const xDiff = Math.abs(pointer.x - closetVerticalLine.x1) const yDiff = Math.abs(pointer.y - closestHorizontalLine.y1) - const x = pointer.x - guideLineLength * Math.floor(pointer.x / guideLineLength) - const y = pointer.y - guideLineLength * Math.floor(pointer.y / guideLineLength) + const x = pointer.x - guideLineLengthHori * Math.floor(pointer.x / guideLineLengthHori) + const y = pointer.y - guideLineLengthVert * Math.floor(pointer.y / guideLineLengthVert) - const xRate = x / guideLineLength - const yRate = y / guideLineLength + const xRate = x / guideLineLengthHori + const yRate = y / guideLineLengthVert const isAttachX = xRate >= 0.4 && xRate <= 0.7 const isAttachY = yRate >= 0.4 && yRate <= 0.7 if (isAttachX && isAttachY) { - newX = Math.floor(pointer.x / guideLineLength) * guideLineLength + guideLineLength / 2 - newY = Math.floor(pointer.y / guideLineLength) * guideLineLength + guideLineLength / 2 + newX = Math.floor(pointer.x / guideLineLengthHori) * guideLineLengthHori + guideLineLengthHori / 2 + newY = Math.floor(pointer.y / guideLineLengthVert) * guideLineLengthVert + guideLineLengthVert / 2 } else { if (Math.min(xDiff, yDiff) <= 20) { if (xDiff < yDiff) { @@ -184,17 +190,17 @@ export function useMode() { } } } else if (isGuideDotMode && mode === Mode.EDIT) { - const x = pointer.x - guideDotLength * Math.floor(pointer.x / guideDotLength) - const y = pointer.y - guideDotLength * Math.floor(pointer.y / guideDotLength) + const x = pointer.x - guideLineLengthHori * Math.floor(pointer.x / guideLineLengthHori) + const y = pointer.y - guideLineLengthVert * Math.floor(pointer.y / guideLineLengthVert) - const xRate = x / guideDotLength - const yRate = y / guideDotLength + const xRate = x / guideLineLengthHori + const yRate = y / guideLineLengthVert const isAttachX = xRate >= 0.4 && xRate <= 0.7 const isAttachY = yRate >= 0.4 && yRate <= 0.7 if (isAttachX && isAttachY) { - newX = Math.floor(pointer.x / guideDotLength) * guideDotLength + guideDotLength / 2 - newY = Math.floor(pointer.y / guideDotLength) * guideDotLength + guideDotLength / 2 + newX = Math.floor(pointer.x / guideLineLengthHori) * guideLineLengthHori + guideLineLengthHori / 2 + newY = Math.floor(pointer.y / guideLineLengthVert) * guideLineLengthVert + guideLineLengthVert / 2 } } else if (isGuideLineMode && mode === Mode.EDIT) { const closestHorizontalLine = getClosestHorizontalLine(pointer, horizontalLineArray) @@ -202,17 +208,17 @@ export function useMode() { const xDiff = Math.abs(pointer.x - closetVerticalLine.x1) const yDiff = Math.abs(pointer.y - closestHorizontalLine.y1) - const x = pointer.x - guideLineLength * Math.floor(pointer.x / guideLineLength) - const y = pointer.y - guideLineLength * Math.floor(pointer.y / guideLineLength) + const x = pointer.x - guideLineLengthHori * Math.floor(pointer.x / guideLineLengthHori) + const y = pointer.y - guideLineLengthVert * Math.floor(pointer.y / guideLineLengthVert) - const xRate = x / guideLineLength - const yRate = y / guideLineLength + const xRate = x / guideLineLengthHori + const yRate = y / guideLineLengthVert const isAttachX = xRate >= 0.4 && xRate <= 0.7 const isAttachY = yRate >= 0.4 && yRate <= 0.7 if (isAttachX && isAttachY) { - newX = Math.floor(pointer.x / guideLineLength) * guideLineLength + guideLineLength / 2 - newY = Math.floor(pointer.y / guideLineLength) * guideLineLength + guideLineLength / 2 + newX = Math.floor(pointer.x / guideLineLengthHori) * guideLineLengthHori + guideLineLengthHori / 2 + newY = Math.floor(pointer.y / guideLineLengthVert) * guideLineLengthVert + guideLineLengthVert / 2 } else { if (Math.min(xDiff, yDiff) <= 20) { if (xDiff < yDiff) {