보조선 작성 수직 수평모드 추가
This commit is contained in:
parent
9e2e4bff58
commit
c431061a0b
@ -118,8 +118,7 @@ export default function WallLineSetting(props) {
|
|||||||
<div className={`modal-pop-wrap r mount`}>
|
<div className={`modal-pop-wrap r mount`}>
|
||||||
<div className="modal-head">
|
<div className="modal-head">
|
||||||
<h1 className="title">{getMessage('modal.cover.outline.drawing')}</h1>
|
<h1 className="title">{getMessage('modal.cover.outline.drawing')}</h1>
|
||||||
{/*<button className="modal-close" onClick={() => closePopup(id)}>*/}
|
<button className="modal-close" onClick={() => closePopup(id)}></button>
|
||||||
<button className="modal-close">닫기</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<div className="modal-btn-wrap">
|
<div className="modal-btn-wrap">
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useRef, useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||||
import { adsorptionRangeState, canvasState } from '@/store/canvasAtom'
|
import { adsorptionRangeState, canvasState, verticalHorizontalModeState } from '@/store/canvasAtom'
|
||||||
import { useEvent } from '@/hooks/useEvent'
|
import { useEvent } from '@/hooks/useEvent'
|
||||||
import { useMouse } from '@/hooks/useMouse'
|
import { useMouse } from '@/hooks/useMouse'
|
||||||
import { useLine } from '@/hooks/useLine'
|
import { useLine } from '@/hooks/useLine'
|
||||||
@ -21,6 +21,7 @@ import { useAdsorptionPoint } from '@/hooks/useAdsorptionPoint'
|
|||||||
import { useSwal } from '@/hooks/useSwal'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
import { booleanPointInPolygon } from '@turf/turf'
|
import { booleanPointInPolygon } from '@turf/turf'
|
||||||
import { usePopup } from '@/hooks/usePopup'
|
import { usePopup } from '@/hooks/usePopup'
|
||||||
|
import { calculateAngle } from '@/util/qpolygon-utils'
|
||||||
|
|
||||||
// 보조선 작성
|
// 보조선 작성
|
||||||
export function useAuxiliaryDrawing(id) {
|
export function useAuxiliaryDrawing(id) {
|
||||||
@ -60,6 +61,7 @@ export function useAuxiliaryDrawing(id) {
|
|||||||
|
|
||||||
const outerLineDiagonalLengthRef = useRef(0)
|
const outerLineDiagonalLengthRef = useRef(0)
|
||||||
const intersectionPoints = useRef([])
|
const intersectionPoints = useRef([])
|
||||||
|
const verticalHorizontalMode = useRecoilValue(verticalHorizontalModeState)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
arrow1Ref.current = arrow1
|
arrow1Ref.current = arrow1
|
||||||
@ -100,6 +102,10 @@ export function useAuxiliaryDrawing(id) {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
addCanvasMouseEventListener('mouse:down', mouseDown)
|
||||||
|
}, [verticalHorizontalMode])
|
||||||
|
|
||||||
const clear = () => {
|
const clear = () => {
|
||||||
addCanvasMouseEventListener('mouse:move', mouseMove)
|
addCanvasMouseEventListener('mouse:move', mouseMove)
|
||||||
setLength1(0)
|
setLength1(0)
|
||||||
@ -453,11 +459,26 @@ export function useAuxiliaryDrawing(id) {
|
|||||||
|
|
||||||
const mouseDown = (e) => {
|
const mouseDown = (e) => {
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
const pointer = getIntersectMousePoint(e)
|
let pointer = getIntersectMousePoint(e)
|
||||||
|
|
||||||
mousePointerArr.current.push(pointer)
|
if (mousePointerArr.current.length === 1) {
|
||||||
if (mousePointerArr.current.length === 2) {
|
const currentPoint = canvas.getPointer(e.e)
|
||||||
drawLine(mousePointerArr.current[0], mousePointerArr.current[1])
|
const prevPoint = mousePointerArr.current[0]
|
||||||
|
|
||||||
|
const degreeByTwoPoints = calculateAngle(prevPoint, currentPoint)
|
||||||
|
|
||||||
|
const degree = Math.round(degreeByTwoPoints / 45) * 45
|
||||||
|
|
||||||
|
if (verticalHorizontalMode) {
|
||||||
|
pointer = {
|
||||||
|
x: prevPoint.x + distanceBetweenPoints(currentPoint, prevPoint) * Math.cos((degree * Math.PI) / 180),
|
||||||
|
y: prevPoint.y + distanceBetweenPoints(currentPoint, prevPoint) * Math.sin((degree * Math.PI) / 180),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mousePointerArr.current.push(pointer)
|
||||||
|
|
||||||
|
drawLine()
|
||||||
} else {
|
} else {
|
||||||
const circle = new fabric.Circle({
|
const circle = new fabric.Circle({
|
||||||
radius: 3,
|
radius: 3,
|
||||||
@ -471,6 +492,7 @@ export function useAuxiliaryDrawing(id) {
|
|||||||
})
|
})
|
||||||
canvas.add(circle)
|
canvas.add(circle)
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
|
mousePointerArr.current.push(pointer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -401,7 +401,7 @@ export const usePolygon = () => {
|
|||||||
const addTextByArrows = (arrows, txt, canvas) => {
|
const addTextByArrows = (arrows, txt, canvas) => {
|
||||||
arrows.forEach((arrow, index) => {
|
arrows.forEach((arrow, index) => {
|
||||||
const text = new fabric.Text(`${txt}${index + 1} (${arrow.pitch}寸)`, {
|
const text = new fabric.Text(`${txt}${index + 1} (${arrow.pitch}寸)`, {
|
||||||
fontSize: arrow.parent.fontSize,
|
fontSize: fontSize,
|
||||||
fill: 'black',
|
fill: 'black',
|
||||||
originX: 'center',
|
originX: 'center',
|
||||||
originY: 'center',
|
originY: 'center',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user