160 lines
4.2 KiB
JavaScript
160 lines
4.2 KiB
JavaScript
import { useMessage } from '@/hooks/useMessage'
|
|
import WithDraggable from '@/components/common/draggable/WithDraggable'
|
|
import RightAngle from '@/components/floor-plan/modal/lineTypes/RightAngle'
|
|
import DoublePitch from '@/components/floor-plan/modal/lineTypes/DoublePitch'
|
|
import Angle from '@/components/floor-plan/modal/lineTypes/Angle'
|
|
import Diagonal from '@/components/floor-plan/modal/lineTypes/Diagonal'
|
|
import { OUTER_LINE_TYPE } from '@/store/outerLineAtom'
|
|
import OuterLineWall from '@/components/floor-plan/modal/lineTypes/OuterLineWall'
|
|
import { useAuxiliaryDrawing } from '@/hooks/roofcover/useAuxiliaryDrawing'
|
|
import { usePopup } from '@/hooks/usePopup'
|
|
|
|
export default function AuxiliaryDrawing({ id, pos = { x: 50, y: 230 } }) {
|
|
const { getMessage } = useMessage()
|
|
const { closePopup } = usePopup()
|
|
|
|
const types = [
|
|
{ id: 1, name: getMessage('straight.line'), type: OUTER_LINE_TYPE.OUTER_LINE },
|
|
{ id: 2, name: getMessage('right.angle'), type: OUTER_LINE_TYPE.RIGHT_ANGLE },
|
|
{ id: 3, name: getMessage('double.pitch'), type: OUTER_LINE_TYPE.DOUBLE_PITCH },
|
|
{ id: 4, name: getMessage('angle'), type: OUTER_LINE_TYPE.ANGLE },
|
|
{ id: 5, name: getMessage('diagonal'), type: OUTER_LINE_TYPE.DIAGONAL_LINE },
|
|
]
|
|
|
|
const {
|
|
length1,
|
|
setLength1,
|
|
length2,
|
|
setLength2,
|
|
length1Ref,
|
|
length2Ref,
|
|
arrow1,
|
|
setArrow1,
|
|
arrow2,
|
|
setArrow2,
|
|
angle1,
|
|
setAngle1,
|
|
angle1Ref,
|
|
angle2,
|
|
setAngle2,
|
|
angle2Ref,
|
|
type,
|
|
setType,
|
|
arrow1Ref,
|
|
arrow2Ref,
|
|
outerLineDiagonalLength,
|
|
setOuterLineDiagonalLength,
|
|
outerLineDiagonalLengthRef,
|
|
handleRollback,
|
|
handleFix,
|
|
buttonAct,
|
|
setButtonAct,
|
|
cutAuxiliary,
|
|
} = useAuxiliaryDrawing(id)
|
|
|
|
const outerLineProps = {
|
|
length1,
|
|
setLength1,
|
|
length1Ref,
|
|
arrow1,
|
|
setArrow1,
|
|
}
|
|
|
|
const rightAngleProps = {
|
|
length1,
|
|
setLength1,
|
|
length1Ref,
|
|
length2,
|
|
setLength2,
|
|
length2Ref,
|
|
arrow1,
|
|
setArrow1,
|
|
arrow2,
|
|
setArrow2,
|
|
}
|
|
|
|
const doublePitchProps = {
|
|
angle1,
|
|
setAngle1,
|
|
angle1Ref,
|
|
angle2,
|
|
setAngle2,
|
|
angle2Ref,
|
|
length1,
|
|
setLength1,
|
|
length1Ref,
|
|
length2,
|
|
setLength2,
|
|
length2Ref,
|
|
arrow1,
|
|
setArrow1,
|
|
arrow2,
|
|
setArrow2,
|
|
arrow1Ref,
|
|
arrow2Ref,
|
|
}
|
|
|
|
const angleProps = {
|
|
angle1,
|
|
setAngle1,
|
|
angle1Ref,
|
|
length1,
|
|
setLength1,
|
|
length1Ref,
|
|
}
|
|
|
|
const diagonalLineProps = {
|
|
length1,
|
|
setLength1,
|
|
length1Ref,
|
|
length2,
|
|
setLength2,
|
|
length2Ref,
|
|
outerLineDiagonalLength,
|
|
setOuterLineDiagonalLength,
|
|
outerLineDiagonalLengthRef,
|
|
arrow1,
|
|
setArrow1,
|
|
arrow2,
|
|
setArrow2,
|
|
}
|
|
|
|
const onClickButton = (button) => {
|
|
setButtonAct(button.id)
|
|
setType(button.type)
|
|
}
|
|
return (
|
|
<WithDraggable isShow={true} pos={pos} className="r">
|
|
<WithDraggable.Header title={getMessage('modal.auxiliary.drawing')} onClose={() => closePopup(id)} />
|
|
<WithDraggable.Body>
|
|
<div className="modal-btn-wrap">
|
|
{types.map((type, idx) => (
|
|
<button key={idx} className={`btn-frame modal ${buttonAct === type.id ? 'act' : ''}`} onClick={() => onClickButton(type)}>
|
|
{type.name}
|
|
</button>
|
|
))}
|
|
</div>
|
|
<div className="properties-setting-wrap outer">
|
|
<div className="setting-tit">{getMessage('setting')}</div>
|
|
{buttonAct === 1 && <OuterLineWall props={outerLineProps} />}
|
|
{buttonAct === 2 && <RightAngle props={rightAngleProps} />}
|
|
{buttonAct === 3 && <DoublePitch props={doublePitchProps} />}
|
|
{buttonAct === 4 && <Angle props={angleProps} />}
|
|
{buttonAct === 5 && <Diagonal props={diagonalLineProps} />}
|
|
</div>
|
|
<div className="grid-btn-wrap">
|
|
<button className="btn-frame modal mr5" onClick={handleRollback}>
|
|
{getMessage('modal.cover.outline.rollback')}
|
|
</button>
|
|
<button className="btn-frame modal mr5" onClick={cutAuxiliary}>
|
|
{getMessage('contextmenu.auxiliary.cut')}
|
|
</button>
|
|
<button className="btn-frame modal act" onClick={() => handleFix(id)}>
|
|
{getMessage('apply')}
|
|
</button>
|
|
</div>
|
|
</WithDraggable.Body>
|
|
</WithDraggable>
|
|
)
|
|
}
|