흐름방향 설정 수정
This commit is contained in:
parent
873cbcf2d2
commit
b5aeed7874
@ -159,6 +159,7 @@ export const SAVE_KEY = [
|
|||||||
'offset',
|
'offset',
|
||||||
'arrow',
|
'arrow',
|
||||||
'surfaceCompass',
|
'surfaceCompass',
|
||||||
|
'surfaceCompassType',
|
||||||
'moduleCompass',
|
'moduleCompass',
|
||||||
'isFixed',
|
'isFixed',
|
||||||
'modules',
|
'modules',
|
||||||
|
|||||||
@ -5,9 +5,14 @@ import { useRecoilValue } from 'recoil'
|
|||||||
import { contextPopupPositionState } from '@/store/popupAtom'
|
import { contextPopupPositionState } from '@/store/popupAtom'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { usePopup } from '@/hooks/usePopup'
|
import { usePopup } from '@/hooks/usePopup'
|
||||||
import { useSurfaceShapeBatch } from '@/hooks/surface/useSurfaceShapeBatch'
|
|
||||||
import { FLOW_DIRECTION_TYPE, useFlowDirectionSetting } from '@/hooks/contextpopup/useFlowDirectionSetting'
|
|
||||||
import { canvasState } from '@/store/canvasAtom'
|
import { canvasState } from '@/store/canvasAtom'
|
||||||
|
import { usePolygon } from '@/hooks/usePolygon'
|
||||||
|
|
||||||
|
const FLOW_DIRECTION_TYPE = {
|
||||||
|
EIGHT_AZIMUTH: 'eightAzimuth',
|
||||||
|
TWENTY_FOUR_AZIMUTH: 'twentyFourAzimuth',
|
||||||
|
}
|
||||||
|
|
||||||
export default function FlowDirectionSetting(props) {
|
export default function FlowDirectionSetting(props) {
|
||||||
const contextPopupPosition = useRecoilValue(contextPopupPositionState)
|
const contextPopupPosition = useRecoilValue(contextPopupPositionState)
|
||||||
const { id, pos = contextPopupPosition, target } = props
|
const { id, pos = contextPopupPosition, target } = props
|
||||||
@ -20,10 +25,9 @@ export default function FlowDirectionSetting(props) {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const [compasDeg, setCompasDeg] = useState(null)
|
const [compasDeg, setCompasDeg] = useState(target.surfaceCompass ?? null)
|
||||||
const [flowDirection, setFlowDirection] = useState(target.direction)
|
const [flowDirection, setFlowDirection] = useState(target.direction)
|
||||||
const { closePopup } = usePopup()
|
const { closePopup } = usePopup()
|
||||||
const { changeSurfaceFlowDirection, type, setType } = useFlowDirectionSetting(id)
|
|
||||||
|
|
||||||
const orientations = [
|
const orientations = [
|
||||||
{ name: `${getMessage('commons.none')}`, value: 0 },
|
{ name: `${getMessage('commons.none')}`, value: 0 },
|
||||||
@ -36,7 +40,27 @@ export default function FlowDirectionSetting(props) {
|
|||||||
{ name: `${getMessage('commons.north')}${getMessage('commons.west')}`, value: 135 },
|
{ name: `${getMessage('commons.north')}${getMessage('commons.west')}`, value: 135 },
|
||||||
{ name: `${getMessage('commons.north')}`, value: 180 },
|
{ name: `${getMessage('commons.north')}`, value: 180 },
|
||||||
]
|
]
|
||||||
const [selectedOrientation, setSelectedOrientation] = useState(orientations[0])
|
|
||||||
|
const { drawDirectionArrow } = usePolygon()
|
||||||
|
|
||||||
|
const [type, setType] = useState(target.surfaceCompassType ?? FLOW_DIRECTION_TYPE.EIGHT_AZIMUTH)
|
||||||
|
|
||||||
|
const changeSurfaceFlowDirection = (roof, direction, orientation) => {
|
||||||
|
roof.set({
|
||||||
|
direction: direction,
|
||||||
|
surfaceCompass: orientation,
|
||||||
|
surfaceCompassType: type,
|
||||||
|
})
|
||||||
|
drawDirectionArrow(roof)
|
||||||
|
canvas?.renderAll()
|
||||||
|
closePopup(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
const [selectedOrientation, setSelectedOrientation] = useState(
|
||||||
|
target.surfaceCompassType !== null && target.surfaceCompassType === FLOW_DIRECTION_TYPE.EIGHT_AZIMUTH
|
||||||
|
? orientations.find((item) => item.value === target.surfaceCompass)
|
||||||
|
: orientations[0],
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WithDraggable isShow={true} pos={pos}>
|
<WithDraggable isShow={true} pos={pos}>
|
||||||
@ -84,9 +108,8 @@ export default function FlowDirectionSetting(props) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="grid-select ">
|
<div className="grid-select ">
|
||||||
<QSelectBox
|
<QSelectBox
|
||||||
title={''}
|
title={selectedOrientation.name}
|
||||||
options={orientations}
|
options={orientations}
|
||||||
value={selectedOrientation}
|
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setType(FLOW_DIRECTION_TYPE.EIGHT_AZIMUTH)
|
setType(FLOW_DIRECTION_TYPE.EIGHT_AZIMUTH)
|
||||||
setSelectedOrientation(e)
|
setSelectedOrientation(e)
|
||||||
@ -116,7 +139,7 @@ export default function FlowDirectionSetting(props) {
|
|||||||
{Array.from({ length: 180 / 15 + 1 }).map((dot, index) => (
|
{Array.from({ length: 180 / 15 + 1 }).map((dot, index) => (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
className={`circle ${compasDeg === 15 * (12 + index) ? 'act' : ''}`}
|
className={`circle ${compasDeg === 15 * (12 + index) && type === FLOW_DIRECTION_TYPE.TWENTY_FOUR_AZIMUTH ? 'act' : ''}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setType(FLOW_DIRECTION_TYPE.TWENTY_FOUR_AZIMUTH)
|
setType(FLOW_DIRECTION_TYPE.TWENTY_FOUR_AZIMUTH)
|
||||||
setCompasDeg(15 * (12 + index))
|
setCompasDeg(15 * (12 + index))
|
||||||
@ -126,7 +149,7 @@ export default function FlowDirectionSetting(props) {
|
|||||||
{Array.from({ length: 180 / 15 - 1 }).map((dot, index) => (
|
{Array.from({ length: 180 / 15 - 1 }).map((dot, index) => (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
className={`circle ${compasDeg === 15 * (index + 1) ? 'act' : ''}`}
|
className={`circle ${compasDeg === 15 * (index + 1) && type === FLOW_DIRECTION_TYPE.TWENTY_FOUR_AZIMUTH ? 'act' : ''}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setType(FLOW_DIRECTION_TYPE.TWENTY_FOUR_AZIMUTH)
|
setType(FLOW_DIRECTION_TYPE.TWENTY_FOUR_AZIMUTH)
|
||||||
setCompasDeg(15 * (index + 1))
|
setCompasDeg(15 * (index + 1))
|
||||||
|
|||||||
@ -1,30 +0,0 @@
|
|||||||
import { canvasState } from '@/store/canvasAtom'
|
|
||||||
import { useRecoilValue } from 'recoil'
|
|
||||||
import { usePolygon } from '@/hooks/usePolygon'
|
|
||||||
import { useState } from 'react'
|
|
||||||
import { usePopup } from '@/hooks/usePopup'
|
|
||||||
|
|
||||||
export const FLOW_DIRECTION_TYPE = {
|
|
||||||
EIGHT_AZIMUTH: 'eightAzimuth',
|
|
||||||
TWENTY_FOUR_AZIMUTH: 'twentyFourAzimuth',
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useFlowDirectionSetting(id) {
|
|
||||||
const canvas = useRecoilValue(canvasState)
|
|
||||||
const { drawDirectionArrow } = usePolygon()
|
|
||||||
const { closePopup } = usePopup()
|
|
||||||
|
|
||||||
const [type, setType] = useState(FLOW_DIRECTION_TYPE.EIGHT_AZIMUTH)
|
|
||||||
|
|
||||||
const changeSurfaceFlowDirection = (roof, direction, orientation) => {
|
|
||||||
roof.set({
|
|
||||||
direction: direction,
|
|
||||||
surfaceCompass: orientation,
|
|
||||||
})
|
|
||||||
drawDirectionArrow(roof)
|
|
||||||
canvas?.renderAll()
|
|
||||||
closePopup(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
return { changeSurfaceFlowDirection, type, setType }
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user