외벽선 속성 설정 추가
This commit is contained in:
parent
0bf1fbfe56
commit
05d2db69c3
@ -6,14 +6,19 @@ export default function PropertiesSetting(props) {
|
|||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const { setShowPropertiesSettingModal } = props
|
const { setShowPropertiesSettingModal } = props
|
||||||
|
|
||||||
const { handleSetEaves, handleSetGable, handleRollback, handleFix } = usePropertiesSetting()
|
const { handleSetEaves, handleSetGable, handleRollback, handleFix, closeModal } = usePropertiesSetting()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WithDraggable isShow={true}>
|
<WithDraggable isShow={true}>
|
||||||
<div className={`modal-pop-wrap ssm`}>
|
<div className={`modal-pop-wrap ssm`}>
|
||||||
<div className="modal-head">
|
<div className="modal-head">
|
||||||
<h1 className="title">{getMessage('modal.canvas.setting.wallline.properties.setting')}</h1>
|
<h1 className="title">{getMessage('modal.canvas.setting.wallline.properties.setting')}</h1>
|
||||||
<button className="modal-close" onClick={() => setShowPropertiesSettingModal(false)}>
|
<button
|
||||||
|
className="modal-close"
|
||||||
|
onClick={() => {
|
||||||
|
closeModal(setShowPropertiesSettingModal)
|
||||||
|
}}
|
||||||
|
>
|
||||||
닫기
|
닫기
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -34,7 +39,13 @@ export default function PropertiesSetting(props) {
|
|||||||
<button className="btn-frame modal mr5" onClick={handleRollback}>
|
<button className="btn-frame modal mr5" onClick={handleRollback}>
|
||||||
{getMessage('modal.cover.outline.rollback')}
|
{getMessage('modal.cover.outline.rollback')}
|
||||||
</button>
|
</button>
|
||||||
<button className="btn-frame modal act" onClick={handleFix}>
|
<button
|
||||||
|
className="btn-frame modal act"
|
||||||
|
onClick={() => {
|
||||||
|
handleFix()
|
||||||
|
setShowPropertiesSettingModal(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
{getMessage('modal.cover.outline.finish')}
|
{getMessage('modal.cover.outline.finish')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,27 +1,17 @@
|
|||||||
import { useEffect, useRef } from 'react'
|
import { useEffect, useRef } from 'react'
|
||||||
|
import { LINE_TYPE } from '@/common/common'
|
||||||
import { useRecoilValue } from 'recoil'
|
import { useRecoilValue } from 'recoil'
|
||||||
import { canvasState } from '@/store/canvasAtom'
|
import { canvasState } from '@/store/canvasAtom'
|
||||||
import { LINE_TYPE } from '@/common/common'
|
|
||||||
|
|
||||||
export function usePropertiesSetting() {
|
export function usePropertiesSetting() {
|
||||||
const currentLine = useRef(null)
|
const currentLine = useRef(null)
|
||||||
|
const currentIdx = useRef(-1)
|
||||||
const canvas = useRecoilValue(canvasState)
|
const canvas = useRecoilValue(canvasState)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initLineSetting()
|
selectNextLine()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const lines = canvas?.getObjects().filter((obj) => obj.name === 'outerLine')
|
|
||||||
lines.forEach((line) => {
|
|
||||||
line.set({
|
|
||||||
type: line.type,
|
|
||||||
stroke: line.type === LINE_TYPE.WALLLINE.EAVES ? '#45CD7D' : line.type === LINE_TYPE.WALLLINE.GABLE ? '#3FBAE6' : '#000000',
|
|
||||||
strokeWidth: 4,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}, [currentLine.current])
|
|
||||||
|
|
||||||
const handleSetEaves = () => {
|
const handleSetEaves = () => {
|
||||||
currentLine.current.set({
|
currentLine.current.set({
|
||||||
stroke: '#45CD7D',
|
stroke: '#45CD7D',
|
||||||
@ -32,13 +22,12 @@ export function usePropertiesSetting() {
|
|||||||
pitch: 4,
|
pitch: 4,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
canvas.renderAll()
|
||||||
nextLineSetting()
|
selectNextLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSetGable = () => {
|
const handleSetGable = () => {
|
||||||
currentLine.current.set({
|
currentLine.current.set({
|
||||||
type: LINE_TYPE.WALLLINE.GABLE,
|
|
||||||
stroke: '#3FBAE6',
|
stroke: '#3FBAE6',
|
||||||
strokeWidth: 4,
|
strokeWidth: 4,
|
||||||
attributes: {
|
attributes: {
|
||||||
@ -46,44 +35,95 @@ export function usePropertiesSetting() {
|
|||||||
type: LINE_TYPE.WALLLINE.GABLE,
|
type: LINE_TYPE.WALLLINE.GABLE,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
canvas.renderAll()
|
||||||
nextLineSetting()
|
selectNextLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
const initLineSetting = () => {
|
const selectNextLine = () => {
|
||||||
currentLine.current = canvas?.getObjects().filter((obj) => obj.name === 'outerLine')[0]
|
const lines = canvas.getObjects().filter((obj) => obj.name === 'outerLine')
|
||||||
|
currentIdx.current++
|
||||||
|
|
||||||
|
if (currentIdx.current >= lines.length) {
|
||||||
|
currentIdx.current = lines.length
|
||||||
|
currentLine.current = lines[currentIdx.current - 1]
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
currentLine.current = lines[currentIdx.current]
|
||||||
|
|
||||||
currentLine.current.set({
|
currentLine.current.set({
|
||||||
stroke: '#EA10AC',
|
stroke: '#EA10AC',
|
||||||
strokeWidth: 4,
|
strokeWidth: 4,
|
||||||
})
|
})
|
||||||
|
|
||||||
canvas?.renderAll()
|
canvas.renderAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextLineSetting = () => {
|
const selectPrevLine = () => {
|
||||||
// currentLine.current의 값은 currentLine.current의 idx 다음 값, 없을 경우는 null
|
const lines = canvas.getObjects().filter((obj) => obj.name === 'outerLine')
|
||||||
currentLine.current = canvas?.getObjects().find((obj) => obj.idx === currentLine.current.idx + 1)
|
|
||||||
|
|
||||||
if (!currentLine.current) {
|
currentIdx.current--
|
||||||
canvas?.renderAll()
|
|
||||||
handleFix()
|
if (currentIdx.current <= -1) {
|
||||||
|
currentIdx.current = -1
|
||||||
|
selectNextLine()
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
lines.forEach((line, index) => {
|
||||||
|
if (index >= currentIdx.current) {
|
||||||
|
delete line.attributes
|
||||||
|
line.set({
|
||||||
|
stroke: '#000000',
|
||||||
|
strokeWidth: 4,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
currentIdx.current--
|
||||||
|
canvas.renderAll()
|
||||||
|
selectNextLine()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRollback = () => {
|
||||||
|
selectPrevLine()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleFix = () => {
|
||||||
|
if (!confirm('외벽선 속성 설정을 완료하시겠습니까?')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const lines = canvas.getObjects().filter((obj) => obj.name === 'outerLine')
|
||||||
|
|
||||||
|
lines.forEach((line) => {
|
||||||
|
line.set({
|
||||||
|
attributes: line.attributes ? line.attributes : { offset: 0, type: LINE_TYPE.WALLLINE.WALL },
|
||||||
|
stroke: '#000000',
|
||||||
|
strokeWidth: 4,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
canvas.renderAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
const closeModal = (fn) => {
|
||||||
|
if (!confirm('외벽선 속성 설정을 종료 하시겠습니까?')) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
currentLine.current = currentLine.current.set({
|
const lines = canvas.getObjects().filter((obj) => obj.name === 'outerLine')
|
||||||
stroke: '#EA10AC',
|
|
||||||
strokeWidth: 4,
|
lines.forEach((line) => {
|
||||||
|
line.set({
|
||||||
|
attributes: { offset: 0, type: LINE_TYPE.WALLLINE.WALL },
|
||||||
|
stroke: '#000000',
|
||||||
|
strokeWidth: 4,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
canvas?.renderAll()
|
canvas.renderAll()
|
||||||
|
|
||||||
|
fn(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentLineSetting = () => {}
|
return { handleSetEaves, handleSetGable, handleRollback, handleFix, closeModal }
|
||||||
|
|
||||||
const handleRollback = () => {}
|
|
||||||
|
|
||||||
const handleFix = () => {}
|
|
||||||
|
|
||||||
return { handleSetEaves, handleSetGable, handleRollback, handleFix }
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user