Compare commits

..

No commits in common. "d951cad178ddce051073e20f2931fecf71d8abe9" and "0abfb5293151edd14c82d11575aea7fc79086daa" have entirely different histories.

15 changed files with 64 additions and 285 deletions

View File

@ -61,7 +61,6 @@ export const LINE_TYPE = {
*/ */
DEFAULT: 'default', DEFAULT: 'default',
EAVES: 'eaves', EAVES: 'eaves',
EAVE_HELP_LINE: 'eaveHelpLine',
GABLE: 'gable', GABLE: 'gable',
GABLE_LEFT: 'gableLeft', //케라바 왼쪽 GABLE_LEFT: 'gableLeft', //케라바 왼쪽
GABLE_RIGHT: 'gableRight', //케라바 오른쪽 GABLE_RIGHT: 'gableRight', //케라바 오른쪽

View File

@ -8,7 +8,6 @@ import { currentObjectState } from '@/store/canvasAtom'
import { useAuxiliaryDrawing } from '@/hooks/roofcover/useAuxiliaryDrawing' import { useAuxiliaryDrawing } from '@/hooks/roofcover/useAuxiliaryDrawing'
import { useSwal } from '@/hooks/useSwal' import { useSwal } from '@/hooks/useSwal'
import { normalizeDigits } from '@/util/input-utils' import { normalizeDigits } from '@/util/input-utils'
import { CalculatorInput } from '@/components/common/input/CalcInput'
export default function AuxiliaryEdit(props) { export default function AuxiliaryEdit(props) {
const contextPopupPosition = useRecoilValue(contextPopupPositionState) const contextPopupPosition = useRecoilValue(contextPopupPositionState)
@ -67,19 +66,7 @@ export default function AuxiliaryEdit(props) {
<p className="mb5">{getMessage('length')}</p> <p className="mb5">{getMessage('length')}</p>
<div className="input-move-wrap mb5"> <div className="input-move-wrap mb5">
<div className="input-move"> <div className="input-move">
{/*<input type="text" className="input-origin" value={verticalSize} onChange={(e) => setVerticalSize(normalizeDigits(e.target.value))} />*/} <input type="text" className="input-origin" value={verticalSize} onChange={(e) => setVerticalSize(normalizeDigits(e.target.value))} />
<CalculatorInput
id=""
name=""
label=""
className="input-origin block"
value={verticalSize}
onChange={(value) => setVerticalSize(value)}
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div> </div>
<span>mm</span> <span>mm</span>
<div className="direction-move-wrap"> <div className="direction-move-wrap">
@ -101,19 +88,7 @@ export default function AuxiliaryEdit(props) {
</div> </div>
<div className="input-move-wrap"> <div className="input-move-wrap">
<div className="input-move"> <div className="input-move">
{/*<input type="text" className="input-origin" value={horizonSize} onChange={(e) => setHorizonSize(normalizeDigits(e.target.value))} />*/} <input type="text" className="input-origin" value={horizonSize} onChange={(e) => setHorizonSize(normalizeDigits(e.target.value))} />
<CalculatorInput
id=""
name=""
label=""
className="input-origin block"
value={horizonSize}
onChange={(value) => setHorizonSize(value)}
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div> </div>
<span>mm</span> <span>mm</span>
<div className="direction-move-wrap"> <div className="direction-move-wrap">

View File

@ -8,21 +8,19 @@ import { useEffect, useState } from 'react'
import Big from 'big.js' import Big from 'big.js'
import { calcLineActualSize, calcLinePlaneSize } from '@/util/qpolygon-utils' import { calcLineActualSize, calcLinePlaneSize } from '@/util/qpolygon-utils'
import { normalizeDigits } from '@/util/input-utils' import { normalizeDigits } from '@/util/input-utils'
import { CalculatorInput } from '@/components/common/input/CalcInput'
export default function AuxiliarySize(props) { export default function AuxiliarySize(props) {
const contextPopupPosition = useRecoilValue(contextPopupPositionState) const contextPopupPosition = useRecoilValue(contextPopupPositionState)
const { id, pos = contextPopupPosition } = props const { id, pos = contextPopupPosition } = props
const [checkedRadio, setCheckedRadio] = useState(null) const [checkedRadio, setCheckedRadio] = useState(null)
const [value1, setValue1] = useState('') const [value1, setValue1] = useState(null)
const [value2, setValue2] = useState('') const [value2, setValue2] = useState(null)
const [size, setSize] = useState(0) const [size, setSize] = useState(0)
const { getMessage } = useMessage() const { getMessage } = useMessage()
const { closePopup } = usePopup() const { closePopup } = usePopup()
const currentObject = useRecoilValue(currentObjectState) const currentObject = useRecoilValue(currentObjectState)
const canvas = useRecoilValue(canvasState) const canvas = useRecoilValue(canvasState)
useEffect(() => { useEffect(() => {
return () => { return () => {
canvas?.discardActiveObject() canvas?.discardActiveObject()
@ -39,7 +37,7 @@ export default function AuxiliarySize(props) {
}, [currentObject]) }, [currentObject])
const handleInput = (e) => { const handleInput = (e) => {
let value = e.replace(/^0+/, '') let value = e.target.value.replace(/^0+/, '')
if (value === '') { if (value === '') {
if (checkedRadio === 1) setValue1(value) if (checkedRadio === 1) setValue1(value)
if (checkedRadio === 2) setValue2(value) if (checkedRadio === 2) setValue2(value)
@ -132,20 +130,7 @@ export default function AuxiliarySize(props) {
<div className="outline-form"> <div className="outline-form">
<span style={{ width: 'auto' }}>{getMessage('length')}</span> <span style={{ width: 'auto' }}>{getMessage('length')}</span>
<div className="input-grid mr5"> <div className="input-grid mr5">
{/*<input type="text" className="input-origin block" value={value1} readOnly={checkedRadio !== 1} onChange={handleInput} />*/} <input type="text" className="input-origin block" value={value1} readOnly={checkedRadio !== 1} onChange={handleInput} />
<CalculatorInput
id=""
name=""
label=""
className="input-origin block"
value={value1}
onChange={handleInput}
readOnly={checkedRadio !== 1}
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>
</div> </div>
@ -164,20 +149,7 @@ export default function AuxiliarySize(props) {
<div className="outline-form"> <div className="outline-form">
<span style={{ width: 'auto' }}>{getMessage('length')}</span> <span style={{ width: 'auto' }}>{getMessage('length')}</span>
<div className="input-grid mr5"> <div className="input-grid mr5">
{/*<input type="text" className="input-origin block" value={value2} readOnly={checkedRadio !== 2} onChange={handleInput} />*/} <input type="text" className="input-origin block" value={value2} readOnly={checkedRadio !== 2} onChange={handleInput} />
<CalculatorInput
id=""
name=""
label=""
className="input-origin block"
value={value2}
onChange={handleInput}
readOnly={checkedRadio !== 2}
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>
</div> </div>

View File

@ -2,7 +2,6 @@ import { useMessage } from '@/hooks/useMessage'
import { useState } from 'react' import { useState } from 'react'
import { currentObjectState } from '@/store/canvasAtom' import { currentObjectState } from '@/store/canvasAtom'
import { useRecoilValue } from 'recoil' import { useRecoilValue } from 'recoil'
import { CalculatorInput } from '@/components/common/input/CalcInput'
const FLOW_LINE_TYPE = { const FLOW_LINE_TYPE = {
DOWN_LEFT: 'downLeft', DOWN_LEFT: 'downLeft',
@ -70,27 +69,13 @@ export default function FlowLine({ FLOW_LINE_REF }) {
<div className="outline-form"> <div className="outline-form">
<span>{getMessage('modal.movement.flow.line.movement')}</span> <span>{getMessage('modal.movement.flow.line.movement')}</span>
<div className="input-grid mr5"> <div className="input-grid mr5">
{/*<input*/} <input
{/* type="text"*/} type="text"
{/* className="input-origin block"*/}
{/* ref={FLOW_LINE_REF.FILLED_INPUT_REF}*/}
{/* value={filledInput}*/}
{/* onFocus={handleFocus}*/}
{/* onChange={handleInput}*/}
{/*/>*/}
<CalculatorInput
id=""
name=""
label=""
className="input-origin block" className="input-origin block"
ref={FLOW_LINE_REF.FILLED_INPUT_REF} ref={FLOW_LINE_REF.FILLED_INPUT_REF}
value={filledInput} value={filledInput}
onFocus={handleFocus} onFocus={handleFocus}
onChange={(value)=>{setFilledInput(value)}} onChange={handleInput}
options={{
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>

View File

@ -3,7 +3,6 @@ import { useState } from 'react'
import { useRecoilValue } from 'recoil' import { useRecoilValue } from 'recoil'
import { currentObjectState } from '@/store/canvasAtom' import { currentObjectState } from '@/store/canvasAtom'
import { normalizeDigits } from '@/util/input-utils' import { normalizeDigits } from '@/util/input-utils'
import { CalculatorInput } from '@/components/common/input/CalcInput'
const UP_DOWN_TYPE = { const UP_DOWN_TYPE = {
UP: 'up', UP: 'up',
@ -36,7 +35,6 @@ export default function Updown({ UP_DOWN_REF }) {
<span>{getMessage('modal.movement.flow.line.position')}</span> <span>{getMessage('modal.movement.flow.line.position')}</span>
<div className="input-grid mr5"> <div className="input-grid mr5">
<input type="text" className="input-origin block" defaultValue={100} readOnly={true} ref={UP_DOWN_REF.POINTER_INPUT_REF} /> <input type="text" className="input-origin block" defaultValue={100} readOnly={true} ref={UP_DOWN_REF.POINTER_INPUT_REF} />
</div> </div>
</div> </div>
<div className="moving-tab-content"> <div className="moving-tab-content">
@ -70,27 +68,13 @@ export default function Updown({ UP_DOWN_REF }) {
<div className="outline-form"> <div className="outline-form">
<span>{getMessage('modal.movement.flow.line.movement')}</span> <span>{getMessage('modal.movement.flow.line.movement')}</span>
<div className="input-grid mr5"> <div className="input-grid mr5">
{/*<input*/} <input
{/* type="text"*/} type="text"
{/* className="input-origin block"*/}
{/* ref={UP_DOWN_REF.FILLED_INPUT_REF}*/}
{/* value={filledInput}*/}
{/* onFocus={handleFocus}*/}
{/* onChange={handleInput}*/}
{/*/>*/}
<CalculatorInput
id=""
name=""
label=""
className="input-origin block" className="input-origin block"
ref={UP_DOWN_REF.FILLED_INPUT_REF} ref={UP_DOWN_REF.FILLED_INPUT_REF}
value={filledInput} value={filledInput}
onFocus={handleFocus} onFocus={handleFocus}
onChange={(value)=>{setFilledInput(value)}} onChange={handleInput}
options={{
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>

View File

@ -59,9 +59,9 @@ export default function DormerOffset(props) {
name="" name=""
label="" label=""
className="input-origin block" className="input-origin block"
value={arrow1LengthRef.current?.value ?? 0} value={arrow1LengthRef.current.value ?? 0}
ref={arrow1LengthRef} ref={arrow1LengthRef}
onChange={() => {}} // No-op function to prevent error onChange={(value) => setArrow1Length(value)}
options={{ options={{
allowNegative: false, allowNegative: false,
allowDecimal: false, allowDecimal: false,
@ -86,20 +86,7 @@ export default function DormerOffset(props) {
</div> </div>
<div className="input-move-wrap"> <div className="input-move-wrap">
<div className="input-move"> <div className="input-move">
{/*<input type="text" className="input-origin" ref={arrow2LengthRef} placeholder="0" />*/} <input type="text" className="input-origin" ref={arrow2LengthRef} placeholder="0" />
<CalculatorInput
id=""
name=""
label=""
className="input-origin block"
value={arrow2LengthRef.current?.value ?? 0}
ref={arrow2LengthRef}
onChange={() => {}} // No-op function to prevent error
options={{
allowNegative: false,
allowDecimal: false,
}}
/>
</div> </div>
<span>mm</span> <span>mm</span>
<div className="direction-move-wrap"> <div className="direction-move-wrap">

View File

@ -1,7 +1,6 @@
import Image from 'next/image' import Image from 'next/image'
import { useMessage } from '@/hooks/useMessage' import { useMessage } from '@/hooks/useMessage'
import { forwardRef, useState } from 'react' import { forwardRef, useState } from 'react'
import { CalculatorInput } from '@/components/common/input/CalcInput'
const PlacementSurface = forwardRef((props, refs) => { const PlacementSurface = forwardRef((props, refs) => {
const { getMessage } = useMessage() const { getMessage } = useMessage()
@ -75,32 +74,10 @@ const PlacementSurface = forwardRef((props, refs) => {
<div className="eaves-keraba-td"> <div className="eaves-keraba-td">
<div className="outline-form"> <div className="outline-form">
<div className="input-grid mr5" style={{ width: '57px' }}> <div className="input-grid mr5" style={{ width: '57px' }}>
{/*<input*/} <input
{/* type="text"*/} type="text"
{/* className="input-origin plane block"*/}
{/* defaultValue={line.value}*/}
{/* ref={*/}
{/* line.isDiagonal*/}
{/* ? lengthetc*/}
{/* : index === 0*/}
{/* ? length1*/}
{/* : index === 1*/}
{/* ? length2*/}
{/* : index === 2*/}
{/* ? length3*/}
{/* : index === 3*/}
{/* ? length4*/}
{/* : length5*/}
{/* }*/}
{/*/>*/}
<CalculatorInput
id=""
name=""
label=""
className="input-origin plane block" className="input-origin plane block"
value={line.value} defaultValue={line.value}
onChange={()=>{}}
ref={ ref={
line.isDiagonal line.isDiagonal
? lengthetc ? lengthetc
@ -114,10 +91,6 @@ const PlacementSurface = forwardRef((props, refs) => {
? length4 ? length4
: length5 : length5
} }
options={{
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>

View File

@ -43,20 +43,7 @@ export default function Eaves({ offsetRef, pitchRef, pitchText }) {
{getMessage('eaves.offset')} {getMessage('eaves.offset')}
</span> </span>
<div className="input-grid mr5"> <div className="input-grid mr5">
{/*<input type="text" className="input-origin block" defaultValue={500} ref={offsetRef} />*/} <input type="text" className="input-origin block" defaultValue={500} ref={offsetRef} />
<CalculatorInput
id=""
name=""
label=""
className="input-origin block"
value={offsetRef.current?.value ?? 500} // Set default value to 500
ref={offsetRef}
onChange={() => {}}
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>
</div> </div>

View File

@ -1,7 +1,6 @@
import { useMessage } from '@/hooks/useMessage' import { useMessage } from '@/hooks/useMessage'
import { useRecoilValue } from 'recoil' import { useRecoilValue } from 'recoil'
import { currentAngleTypeSelector } from '@/store/canvasAtom' import { currentAngleTypeSelector } from '@/store/canvasAtom'
import { CalculatorInput } from '@/components/common/input/CalcInput'
export default function Gable({ offsetRef }) { export default function Gable({ offsetRef }) {
const { getMessage } = useMessage() const { getMessage } = useMessage()
@ -13,20 +12,7 @@ export default function Gable({ offsetRef }) {
{getMessage('gable.offset')} {getMessage('gable.offset')}
</span> </span>
<div className="input-grid mr5"> <div className="input-grid mr5">
{/*<input type="text" className="input-origin block" defaultValue={300} ref={offsetRef} />*/} <input type="text" className="input-origin block" defaultValue={300} ref={offsetRef} />
<CalculatorInput
id=""
name=""
label=""
className="input-origin block"
value={offsetRef.current?.value ?? 300} // Set default value to 500
ref={offsetRef}
onChange={() => {}}
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>
</div> </div>

View File

@ -1,5 +1,4 @@
import { useMessage } from '@/hooks/useMessage' import { useMessage } from '@/hooks/useMessage'
import { CalculatorInput } from '@/components/common/input/CalcInput'
export default function Shed({ offsetRef }) { export default function Shed({ offsetRef }) {
const { getMessage } = useMessage() const { getMessage } = useMessage()
@ -10,20 +9,7 @@ export default function Shed({ offsetRef }) {
{getMessage('shed.width')} {getMessage('shed.width')}
</span> </span>
<div className="input-grid mr5"> <div className="input-grid mr5">
{/*<input type="text" className="input-origin block" defaultValue={300} ref={offsetRef} />*/} <input type="text" className="input-origin block" defaultValue={300} ref={offsetRef} />
<CalculatorInput
id=""
name=""
label=""
className="input-origin block"
value={offsetRef.current?.value ?? 300} // Set default value to 500
ref={offsetRef}
onChange={() => {}}
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>
</div> </div>

View File

@ -1,7 +1,6 @@
import { useMessage } from '@/hooks/useMessage' import { useMessage } from '@/hooks/useMessage'
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { useEvent } from '@/hooks/useEvent' import { useEvent } from '@/hooks/useEvent'
import { CalculatorInput } from '@/components/common/input/CalcInput'
export default function Offset({ length1Ref, arrow1Ref, currentWallLineRef }) { export default function Offset({ length1Ref, arrow1Ref, currentWallLineRef }) {
const { getMessage } = useMessage() const { getMessage } = useMessage()
@ -75,20 +74,7 @@ export default function Offset({ length1Ref, arrow1Ref, currentWallLineRef }) {
<div className="eaves-keraba-td"> <div className="eaves-keraba-td">
<div className="outline-form"> <div className="outline-form">
<div className="input-grid mr5" style={{ width: '100px' }}> <div className="input-grid mr5" style={{ width: '100px' }}>
{/*<input type="text" className="input-origin block" placeholder={0} ref={length1Ref} />*/} <input type="text" className="input-origin block" placeholder={0} ref={length1Ref} />
<CalculatorInput
id=""
name=""
label=""
className="input-origin block"
value={length1Ref.current?.value ?? 0}
ref={length1Ref}
onChange={() => {}}
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>
</div> </div>

View File

@ -1,7 +1,6 @@
import { useMessage } from '@/hooks/useMessage' import { useMessage } from '@/hooks/useMessage'
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react' import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
import { useEvent } from '@/hooks/useEvent' import { useEvent } from '@/hooks/useEvent'
import { CalculatorInput } from '@/components/common/input/CalcInput'
export default forwardRef(function WallLine({ length1Ref, length2Ref, arrow1Ref, arrow2Ref, radioTypeRef, currentWallLineRef }, ref) { export default forwardRef(function WallLine({ length1Ref, length2Ref, arrow1Ref, arrow2Ref, radioTypeRef, currentWallLineRef }, ref) {
const { getMessage } = useMessage() const { getMessage } = useMessage()
@ -47,21 +46,7 @@ export default forwardRef(function WallLine({ length1Ref, length2Ref, arrow1Ref,
<div className="eaves-keraba-td"> <div className="eaves-keraba-td">
<div className="outline-form"> <div className="outline-form">
<div className="input-grid mr5" style={{ width: '100px' }}> <div className="input-grid mr5" style={{ width: '100px' }}>
{/*<input type="text" className="input-origin block" placeholder={0} readOnly={type !== 1} ref={length1Ref} />*/} <input type="text" className="input-origin block" placeholder={0} readOnly={type !== 1} ref={length1Ref} />
<CalculatorInput
id=""
name=""
label=""
className="input-origin block"
value={length1Ref.current?.value ?? 0}
ref={length1Ref}
onChange={() => {}}
readOnly={type !== 1}
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>
</div> </div>
@ -95,21 +80,7 @@ export default forwardRef(function WallLine({ length1Ref, length2Ref, arrow1Ref,
<div className="eaves-keraba-td"> <div className="eaves-keraba-td">
<div className="outline-form"> <div className="outline-form">
<div className="input-grid mr5" style={{ width: '100px' }}> <div className="input-grid mr5" style={{ width: '100px' }}>
{/*<input type="text" className="input-origin block" placeholder={0} readOnly={type !== 2} ref={length2Ref} />*/} <input type="text" className="input-origin block" placeholder={0} readOnly={type !== 2} ref={length2Ref} />
<CalculatorInput
id=""
name=""
label=""
className="input-origin block"
value={length2Ref.current?.value ?? 0}
ref={length2Ref}
onChange={() => {}}
readOnly={type !== 2}
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>
</div> </div>

View File

@ -1,4 +1,4 @@
import { useRecoilState, useRecoilValue, useResetRecoilState } from 'recoil' import { useRecoilValue, useResetRecoilState } from 'recoil'
import { canvasState, currentObjectState } from '@/store/canvasAtom' import { canvasState, currentObjectState } from '@/store/canvasAtom'
import { selectedRoofMaterialSelector } from '@/store/settingAtom' import { selectedRoofMaterialSelector } from '@/store/settingAtom'
import { ROOF_MATERIAL_LAYOUT } from '@/components/floor-plan/modal/placementShape/PlacementShapeSetting' import { ROOF_MATERIAL_LAYOUT } from '@/components/floor-plan/modal/placementShape/PlacementShapeSetting'
@ -25,7 +25,6 @@ export function useRoofFn() {
const { addPitchText } = useLine() const { addPitchText } = useLine()
const { setPolygonLinesActualSize } = usePolygon() const { setPolygonLinesActualSize } = usePolygon()
const { changeCorridorDimensionText } = useText() const { changeCorridorDimensionText } = useText()
const [outerLinePoints, setOuterLinePoints] = useRecoilState(outerLinePointsState)
//면형상 선택 클릭시 지붕 패턴 입히기 //면형상 선택 클릭시 지붕 패턴 입히기
function setSurfaceShapePattern(polygon, mode = 'onlyBorder', trestleMode = false, roofMaterial, isForceChange = false, isDisplay = false) { function setSurfaceShapePattern(polygon, mode = 'onlyBorder', trestleMode = false, roofMaterial, isForceChange = false, isDisplay = false) {
@ -264,9 +263,6 @@ export function useRoofFn() {
const deltaX = roof.left - originalRoofLeft const deltaX = roof.left - originalRoofLeft
const deltaY = roof.top - originalRoofTop const deltaY = roof.top - originalRoofTop
const originOuterLinePoints = [...outerLinePoints]
setOuterLinePoints(originOuterLinePoints.map((point) => ({ x: point.x + deltaX, y: point.y + deltaY })))
// Move all related objects by the delta // Move all related objects by the delta
allRoofObject.forEach((obj) => { allRoofObject.forEach((obj) => {
if (obj.points !== undefined) { if (obj.points !== undefined) {

View File

@ -1,13 +1,7 @@
'use client' 'use client'
import { useRecoilValue, useResetRecoilState } from 'recoil' import { useRecoilValue, useResetRecoilState } from 'recoil'
import { import { canvasSettingState, canvasState, currentCanvasPlanState, currentObjectState, globalPitchState } from '@/store/canvasAtom'
canvasSettingState,
canvasState,
currentCanvasPlanState,
currentObjectState,
globalPitchState,
} from '@/store/canvasAtom'
import { LINE_TYPE, MENU, POLYGON_TYPE } from '@/common/common' import { LINE_TYPE, MENU, POLYGON_TYPE } from '@/common/common'
import { getIntersectionPoint } from '@/util/canvas-util' import { getIntersectionPoint } from '@/util/canvas-util'
import { degreesToRadians } from '@turf/turf' import { degreesToRadians } from '@turf/turf'
@ -885,7 +879,7 @@ export function useSurfaceShapeBatch({ isHidden, setIsHidden }) {
} }
}) })
roof.fire('polygonMoved') // roof.fire('polygonMoved')
roof.fire('modified') roof.fire('modified')
drawDirectionArrow(roof) drawDirectionArrow(roof)
changeCorridorDimensionText() changeCorridorDimensionText()

View File

@ -867,6 +867,7 @@ export const usePolygon = () => {
// innerLine.attributes.isStart = true // innerLine.attributes.isStart = true
// innerLine.parentLine = polygonLine // innerLine.parentLine = polygonLine
// 매핑된 innerLine의 attributes를 변경 (교차점 계산 전에 적용) // 매핑된 innerLine의 attributes를 변경 (교차점 계산 전에 적용)
innerLineMapping.forEach((polygonLine, innerLine) => { innerLineMapping.forEach((polygonLine, innerLine) => {
innerLine.attributes.planeSize = innerLine.attributes.planeSize ?? polygonLine.attributes.planeSize innerLine.attributes.planeSize = innerLine.attributes.planeSize ?? polygonLine.attributes.planeSize
@ -876,6 +877,7 @@ export const usePolygon = () => {
innerLine.attributes.isStart = true innerLine.attributes.isStart = true
innerLine.parentLine = polygonLine innerLine.parentLine = polygonLine
}) })
} }
} }
}) })
@ -1385,7 +1387,7 @@ export const usePolygon = () => {
let representLine let representLine
// 지붕을 그리면서 기존 polygon의 line중 연결된 line을 찾는다. // 지붕을 그리면서 기존 polygon의 line중 연결된 line을 찾는다.
;[...polygonLines, ...innerLines].forEach((line) => { [...polygonLines, ...innerLines].forEach((line) => {
let startFlag = false let startFlag = false
let endFlag = false let endFlag = false
const startPoint = line.startPoint const startPoint = line.startPoint
@ -1400,10 +1402,7 @@ export const usePolygon = () => {
}) })
if (startFlag && endFlag) { if (startFlag && endFlag) {
if ( if (!representLines.includes(line) && line.attributes.type === LINE_TYPE.WALLLINE.EAVES) {
!representLines.includes(line) &&
(line.attributes.type === LINE_TYPE.WALLLINE.EAVES || line.attributes.type === LINE_TYPE.WALLLINE.EAVE_HELP_LINE)
) {
representLines.push(line) representLines.push(line)
} else if (!representLines.includes(line) && line.attributes.type === LINE_TYPE.WALLLINE.HIPANDGABLE) { } else if (!representLines.includes(line) && line.attributes.type === LINE_TYPE.WALLLINE.HIPANDGABLE) {
representLines.push(line) representLines.push(line)
@ -1631,80 +1630,79 @@ export const usePolygon = () => {
// } // }
function findShortestPath(start, end, graph, epsilon = 1) { function findShortestPath(start, end, graph, epsilon = 1) {
const startKey = pointToKey(start, epsilon) const startKey = pointToKey(start, epsilon);
const endKey = pointToKey(end, epsilon) const endKey = pointToKey(end, epsilon);
// 거리와 이전 노드 추적 // 거리와 이전 노드 추적
const distances = { [startKey]: 0 } const distances = { [startKey]: 0 };
const previous = {} const previous = {};
const visited = new Set() const visited = new Set();
// 우선순위 큐 (거리가 짧은 순으로 정렬) // 우선순위 큐 (거리가 짧은 순으로 정렬)
const queue = [{ key: startKey, dist: 0 }] const queue = [{ key: startKey, dist: 0 }];
// 모든 노드 초기화 // 모든 노드 초기화
for (const key in graph) { for (const key in graph) {
if (key !== startKey) { if (key !== startKey) {
distances[key] = Infinity distances[key] = Infinity;
} }
} }
// 우선순위 큐에서 다음 노드 선택 // 우선순위 큐에서 다음 노드 선택
const getNextNode = () => { const getNextNode = () => {
if (queue.length === 0) return null if (queue.length === 0) return null;
queue.sort((a, b) => a.dist - b.dist) queue.sort((a, b) => a.dist - b.dist);
return queue.shift() return queue.shift();
} };
let current let current;
while ((current = getNextNode())) { while ((current = getNextNode())) {
const currentKey = current.key const currentKey = current.key;
// 목적지에 도달하면 종료 // 목적지에 도달하면 종료
if (currentKey === endKey) break if (currentKey === endKey) break;
// 이미 방문한 노드는 건너뜀 // 이미 방문한 노드는 건너뜀
if (visited.has(currentKey)) continue if (visited.has(currentKey)) continue;
visited.add(currentKey) visited.add(currentKey);
// 인접 노드 탐색 // 인접 노드 탐색
for (const neighbor of graph[currentKey] || []) { for (const neighbor of graph[currentKey] || []) {
const neighborKey = pointToKey(neighbor.point, epsilon) const neighborKey = pointToKey(neighbor.point, epsilon);
if (visited.has(neighborKey)) continue if (visited.has(neighborKey)) continue;
const alt = distances[currentKey] + neighbor.distance const alt = distances[currentKey] + neighbor.distance;
// 더 짧은 경로를 찾은 경우 업데이트 // 더 짧은 경로를 찾은 경우 업데이트
if (alt < (distances[neighborKey] || Infinity)) { if (alt < (distances[neighborKey] || Infinity)) {
distances[neighborKey] = alt distances[neighborKey] = alt;
previous[neighborKey] = currentKey previous[neighborKey] = currentKey;
// 우선순위 큐에 추가 // 우선순위 큐에 추가
queue.push({ key: neighborKey, dist: alt }) queue.push({ key: neighborKey, dist: alt });
} }
} }
} }
// 경로 재구성 // 경로 재구성
const path = [] const path = [];
let currentKey = endKey let currentKey = endKey;
// 시작점에 도달할 때까지 역추적 // 시작점에 도달할 때까지 역추적
while (previous[currentKey] !== undefined) { while (previous[currentKey] !== undefined) {
const [x, y] = currentKey.split(',').map(Number) const [x, y] = currentKey.split(',').map(Number);
path.unshift({ x, y }) path.unshift({ x, y });
currentKey = previous[currentKey] currentKey = previous[currentKey];
} }
// 시작점 추가 // 시작점 추가
if (path.length > 0) { if (path.length > 0) {
const [sx, sy] = startKey.split(',').map(Number) const [sx, sy] = startKey.split(',').map(Number);
path.unshift({ x: sx, y: sy }) path.unshift({ x: sx, y: sy });
} }
return path.length > 0 ? path : null return path.length > 0 ? path : null;
} }
// 최종 함수 // 최종 함수
function getPath(start, end, graph, epsilon = 1) { function getPath(start, end, graph, epsilon = 1) {
// startPoint와 arrivalPoint가 될 수 있는 점은 line.attributes.type이 'default' 혹은 null이 아닌 line인 경우에만 가능 // startPoint와 arrivalPoint가 될 수 있는 점은 line.attributes.type이 'default' 혹은 null이 아닌 line인 경우에만 가능