modal hidden 기능 추가
This commit is contained in:
parent
6929878cca
commit
dbb3a3fce0
@ -19,7 +19,8 @@ export default function ObjectSetting({ id, pos = { x: 50, y: 230 } }) {
|
|||||||
const canvas = useRecoilValue(canvasState)
|
const canvas = useRecoilValue(canvasState)
|
||||||
const [buttonAct, setButtonAct] = useState(1)
|
const [buttonAct, setButtonAct] = useState(1)
|
||||||
const { swalFire } = useSwal()
|
const { swalFire } = useSwal()
|
||||||
const { applyOpeningAndShadow, applyDormers } = useObjectBatch()
|
const [isHidden, setIsHidden] = useState(false)
|
||||||
|
const { applyOpeningAndShadow, applyDormers } = useObjectBatch({ isHidden, setIsHidden })
|
||||||
const { closePopup } = usePopup()
|
const { closePopup } = usePopup()
|
||||||
|
|
||||||
const surfaceShapePolygons = canvas?.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF)
|
const surfaceShapePolygons = canvas?.getObjects().filter((obj) => obj.name === POLYGON_TYPE.ROOF)
|
||||||
@ -58,6 +59,7 @@ export default function ObjectSetting({ id, pos = { x: 50, y: 230 } }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//개구배치, 그림자배치
|
//개구배치, 그림자배치
|
||||||
|
setIsHidden(true)
|
||||||
if (buttonAct === 1 || buttonAct === 2) {
|
if (buttonAct === 1 || buttonAct === 2) {
|
||||||
applyOpeningAndShadow(objectPlacement, buttonAct, surfaceShapePolygons)
|
applyOpeningAndShadow(objectPlacement, buttonAct, surfaceShapePolygons)
|
||||||
} else {
|
} else {
|
||||||
@ -71,9 +73,10 @@ export default function ObjectSetting({ id, pos = { x: 50, y: 230 } }) {
|
|||||||
{ id: 3, name: getMessage('modal.object.setting.type.triangle.dormer') },
|
{ id: 3, name: getMessage('modal.object.setting.type.triangle.dormer') },
|
||||||
{ id: 4, name: getMessage('modal.object.setting.type.pentagon.dormer') },
|
{ id: 4, name: getMessage('modal.object.setting.type.pentagon.dormer') },
|
||||||
]
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WithDraggable isShow={true} pos={pos}>
|
<WithDraggable isShow={true} pos={pos}>
|
||||||
<div className={`modal-pop-wrap lrr`}>
|
<div className={`modal-pop-wrap lrr`} style={{ visibility: isHidden ? 'hidden' : 'visible' }}>
|
||||||
<div className="modal-head">
|
<div className="modal-head">
|
||||||
<h1 className="title">{getMessage('plan.menu.placement.surface.object')} </h1>
|
<h1 className="title">{getMessage('plan.menu.placement.surface.object')} </h1>
|
||||||
<button className="modal-close" onClick={() => closePopup(id)}>
|
<button className="modal-close" onClick={() => closePopup(id)}>
|
||||||
|
|||||||
@ -4,13 +4,13 @@ import { useRecoilValue } from 'recoil'
|
|||||||
import { canvasState } from '@/store/canvasAtom'
|
import { canvasState } from '@/store/canvasAtom'
|
||||||
import { BATCH_TYPE, INPUT_TYPE } from '@/common/common'
|
import { BATCH_TYPE, INPUT_TYPE } from '@/common/common'
|
||||||
import { useEvent } from '@/hooks/useEvent'
|
import { useEvent } from '@/hooks/useEvent'
|
||||||
import { pointsToTurfPolygon, polygonToTurfPolygon, rectToPolygon, triangleToPolygon, setSurfaceShapePattern } from '@/util/canvas-util'
|
import { pointsToTurfPolygon, polygonToTurfPolygon, rectToPolygon, setSurfaceShapePattern, triangleToPolygon } from '@/util/canvas-util'
|
||||||
import { useSwal } from '@/hooks/useSwal'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
import * as turf from '@turf/turf'
|
import * as turf from '@turf/turf'
|
||||||
import { usePolygon } from '@/hooks/usePolygon'
|
import { usePolygon } from '@/hooks/usePolygon'
|
||||||
import { QPolygon } from '@/components/fabric/QPolygon'
|
import { QPolygon } from '@/components/fabric/QPolygon'
|
||||||
|
|
||||||
export function useObjectBatch() {
|
export function useObjectBatch({ isHidden, setIsHidden }) {
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const canvas = useRecoilValue(canvasState)
|
const canvas = useRecoilValue(canvasState)
|
||||||
const { addCanvasMouseEventListener, initEvent } = useEvent()
|
const { addCanvasMouseEventListener, initEvent } = useEvent()
|
||||||
@ -21,12 +21,12 @@ export function useObjectBatch() {
|
|||||||
const selectedType = objectPlacement.typeRef.current.find((radio) => radio.checked).value
|
const selectedType = objectPlacement.typeRef.current.find((radio) => radio.checked).value
|
||||||
const isCrossChecked = buttonAct === 1 ? objectPlacement.isCrossRef.current.checked : false
|
const isCrossChecked = buttonAct === 1 ? objectPlacement.isCrossRef.current.checked : false
|
||||||
const objName = buttonAct === 1 ? BATCH_TYPE.OPENING : BATCH_TYPE.SHADOW
|
const objName = buttonAct === 1 ? BATCH_TYPE.OPENING : BATCH_TYPE.SHADOW
|
||||||
const objTempName = buttonAct === 1 ? BATCH_TYPE.OPENING_TEMP : BATCH_TYPE.SHADOW_TEMP
|
|
||||||
|
|
||||||
|
const objTempName = buttonAct === 1 ? BATCH_TYPE.OPENING_TEMP : BATCH_TYPE.SHADOW_TEMP
|
||||||
let rect, isDown, origX, origY
|
let rect, isDown, origX, origY
|
||||||
let selectedSurface
|
let selectedSurface
|
||||||
|
|
||||||
//프리입력
|
//프리입력
|
||||||
|
console.log('useObjectBatch', isHidden)
|
||||||
if (selectedType === INPUT_TYPE.FREE) {
|
if (selectedType === INPUT_TYPE.FREE) {
|
||||||
addCanvasMouseEventListener('mouse:down', (e) => {
|
addCanvasMouseEventListener('mouse:down', (e) => {
|
||||||
isDown = true
|
isDown = true
|
||||||
@ -41,6 +41,7 @@ export function useObjectBatch() {
|
|||||||
if (!selectedSurface) {
|
if (!selectedSurface) {
|
||||||
swalFire({ text: '지붕안에 그려야해요', icon: 'error' })
|
swalFire({ text: '지붕안에 그려야해요', icon: 'error' })
|
||||||
initEvent() //이벤트 초기화
|
initEvent() //이벤트 초기화
|
||||||
|
if (setIsHidden) setIsHidden(false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +118,8 @@ export function useObjectBatch() {
|
|||||||
rect.set({ name: objName })
|
rect.set({ name: objName })
|
||||||
rect.setCoords()
|
rect.setCoords()
|
||||||
initEvent()
|
initEvent()
|
||||||
|
|
||||||
|
if (setIsHidden) setIsHidden(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else if (selectedType === INPUT_TYPE.DIMENSION) {
|
} else if (selectedType === INPUT_TYPE.DIMENSION) {
|
||||||
@ -196,6 +199,7 @@ export function useObjectBatch() {
|
|||||||
rect.set({ name: objName })
|
rect.set({ name: objName })
|
||||||
rect.setCoords()
|
rect.setCoords()
|
||||||
initEvent()
|
initEvent()
|
||||||
|
if (setIsHidden) setIsHidden(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -399,6 +403,7 @@ export function useObjectBatch() {
|
|||||||
|
|
||||||
isDown = false
|
isDown = false
|
||||||
initEvent()
|
initEvent()
|
||||||
|
if (setIsHidden) setIsHidden(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else if (buttonAct === 4) {
|
} else if (buttonAct === 4) {
|
||||||
@ -494,6 +499,7 @@ export function useObjectBatch() {
|
|||||||
//지붕 밖으로 그렸을때
|
//지붕 밖으로 그렸을때
|
||||||
if (!turf.booleanWithin(pentagonPolygon, selectedSurfacePolygon)) {
|
if (!turf.booleanWithin(pentagonPolygon, selectedSurfacePolygon)) {
|
||||||
swalFire({ text: '개구를 배치할 수 없습니다.', icon: 'error' })
|
swalFire({ text: '개구를 배치할 수 없습니다.', icon: 'error' })
|
||||||
|
|
||||||
//일단 지워
|
//일단 지워
|
||||||
deleteTempObjects()
|
deleteTempObjects()
|
||||||
return
|
return
|
||||||
@ -574,6 +580,7 @@ export function useObjectBatch() {
|
|||||||
|
|
||||||
isDown = false
|
isDown = false
|
||||||
initEvent()
|
initEvent()
|
||||||
|
if (setIsHidden) setIsHidden(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -591,6 +598,7 @@ export function useObjectBatch() {
|
|||||||
)
|
)
|
||||||
canvas?.remove(...deleteTarget)
|
canvas?.remove(...deleteTarget)
|
||||||
initEvent() //이벤트 초기화
|
initEvent() //이벤트 초기화
|
||||||
|
if (setIsHidden) setIsHidden(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const splitDormerTriangle = (triangle, direction) => {
|
const splitDormerTriangle = (triangle, direction) => {
|
||||||
@ -690,28 +698,40 @@ export function useObjectBatch() {
|
|||||||
leftPoints = [
|
leftPoints = [
|
||||||
{ x: points[0].x, y: points[0].y },
|
{ x: points[0].x, y: points[0].y },
|
||||||
{ x: points[0].x - (points[1].y - points[0].y), y: points[0].y - (points[0].x - points[1].x) },
|
{ x: points[0].x - (points[1].y - points[0].y), y: points[0].y - (points[0].x - points[1].x) },
|
||||||
{ x: points[0].x - (points[1].y - points[0].y) - (points[2].y - points[1].y), y: points[0].y - (points[0].x - points[1].x) },
|
{
|
||||||
|
x: points[0].x - (points[1].y - points[0].y) - (points[2].y - points[1].y),
|
||||||
|
y: points[0].y - (points[0].x - points[1].x),
|
||||||
|
},
|
||||||
{ x: points[0].x - (points[1].y - points[0].y) - (points[2].y - points[1].y), y: points[0].y },
|
{ x: points[0].x - (points[1].y - points[0].y) - (points[2].y - points[1].y), y: points[0].y },
|
||||||
]
|
]
|
||||||
|
|
||||||
rightPoints = [
|
rightPoints = [
|
||||||
{ x: points[0].x, y: points[0].y },
|
{ x: points[0].x, y: points[0].y },
|
||||||
{ x: points[0].x - (points[1].y - points[0].y), y: points[0].y + (points[0].x - points[1].x) },
|
{ x: points[0].x - (points[1].y - points[0].y), y: points[0].y + (points[0].x - points[1].x) },
|
||||||
{ x: points[0].x - (points[1].y - points[0].y) - (points[2].y - points[1].y), y: points[0].y + (points[0].x - points[1].x) },
|
{
|
||||||
|
x: points[0].x - (points[1].y - points[0].y) - (points[2].y - points[1].y),
|
||||||
|
y: points[0].y + (points[0].x - points[1].x),
|
||||||
|
},
|
||||||
{ x: points[0].x - (points[1].y - points[0].y) - (points[2].y - points[1].y), y: points[0].y },
|
{ x: points[0].x - (points[1].y - points[0].y) - (points[2].y - points[1].y), y: points[0].y },
|
||||||
]
|
]
|
||||||
} else if (direction === 'right') {
|
} else if (direction === 'right') {
|
||||||
leftPoints = [
|
leftPoints = [
|
||||||
{ x: points[0].x, y: points[0].y },
|
{ x: points[0].x, y: points[0].y },
|
||||||
{ x: points[0].x + (points[1].y - points[0].y), y: points[0].y + (points[0].x - points[1].x) },
|
{ x: points[0].x + (points[1].y - points[0].y), y: points[0].y + (points[0].x - points[1].x) },
|
||||||
{ x: points[0].x + (points[1].y - points[0].y) + (points[2].y - points[1].y), y: points[0].y + (points[0].x - points[1].x) },
|
{
|
||||||
|
x: points[0].x + (points[1].y - points[0].y) + (points[2].y - points[1].y),
|
||||||
|
y: points[0].y + (points[0].x - points[1].x),
|
||||||
|
},
|
||||||
{ x: points[0].x + (points[1].y - points[0].y) + (points[2].y - points[1].y), y: points[0].y },
|
{ x: points[0].x + (points[1].y - points[0].y) + (points[2].y - points[1].y), y: points[0].y },
|
||||||
]
|
]
|
||||||
|
|
||||||
rightPoints = [
|
rightPoints = [
|
||||||
{ x: points[0].x, y: points[0].y },
|
{ x: points[0].x, y: points[0].y },
|
||||||
{ x: points[0].x + (points[1].y - points[0].y), y: points[0].y - (points[0].x - points[1].x) },
|
{ x: points[0].x + (points[1].y - points[0].y), y: points[0].y - (points[0].x - points[1].x) },
|
||||||
{ x: points[0].x + (points[1].y - points[0].y) + (points[2].y - points[1].y), y: points[0].y - (points[0].x - points[1].x) },
|
{
|
||||||
|
x: points[0].x + (points[1].y - points[0].y) + (points[2].y - points[1].y),
|
||||||
|
y: points[0].y - (points[0].x - points[1].x),
|
||||||
|
},
|
||||||
{ x: points[0].x + (points[1].y - points[0].y) + (points[2].y - points[1].y), y: points[0].y },
|
{ x: points[0].x + (points[1].y - points[0].y) + (points[2].y - points[1].y), y: points[0].y },
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user