Compare commits

..

No commits in common. "83769c55abc5b27648ef5298b8983fa767f4f6b8" and "8f1874c3cdb511ad931cf6ada6694e444ac98222" have entirely different histories.

10 changed files with 1073 additions and 1356 deletions

View File

@ -57,7 +57,6 @@ export default function Qna() {
endRow : endRow, endRow : endRow,
schMainYn : 'N', schMainYn : 'N',
siteTpCd : 'QC', siteTpCd : 'QC',
langCd : 'JA',
}) })
const apiUrl = `${url}?${params.toString()}` const apiUrl = `${url}?${params.toString()}`

View File

@ -1693,13 +1693,13 @@ export default function Estimate({}) {
{/* 파일첨부 끝 */} {/* 파일첨부 끝 */}
{/* 견적특이사항 시작 */} {/* 견적특이사항 시작 */}
<div className="table-box-title-wrap"> <div className="table-box-title-wrap">
{/*<div className="title-wrap">*/} <div className="title-wrap">
{/* <h3 className="product">{getMessage('estimate.detail.header.specialEstimate')}</h3>*/} <h3 className="product">{getMessage('estimate.detail.header.specialEstimate')}</h3>
{/* <div className="estimate-check-btn">*/} <div className="estimate-check-btn">
{/* <button className={`estimate-arr-btn down mr5 ${hidden ? '' : 'on'}`} onClick={() => setHidden(false)}></button>*/} <button className={`estimate-arr-btn down mr5 ${hidden ? '' : 'on'}`} onClick={() => setHidden(false)}></button>
{/* <button className={`estimate-arr-btn up ${hidden ? 'on' : ''}`} onClick={() => setHidden(true)}></button>*/} <button className={`estimate-arr-btn up ${hidden ? 'on' : ''}`} onClick={() => setHidden(true)}></button>
{/* </div>*/} </div>
{/*</div>*/} </div>
</div> </div>
{/* 견적 특이사항 코드영역시작 */} {/* 견적 특이사항 코드영역시작 */}
<div className={`estimate-check-wrap ${hidden ? 'hide' : ''}`}> <div className={`estimate-check-wrap ${hidden ? 'hide' : ''}`}>

View File

@ -11,7 +11,6 @@ import { moduleSelectionDataState } from '@/store/selectedModuleOptions'
import { useCanvasPopupStatusController } from '@/hooks/common/useCanvasPopupStatusController' import { useCanvasPopupStatusController } from '@/hooks/common/useCanvasPopupStatusController'
import { isObjectNotEmpty } from '@/util/common-utils' import { isObjectNotEmpty } from '@/util/common-utils'
import { normalizeDecimal} from '@/util/input-utils' import { normalizeDecimal} from '@/util/input-utils'
import { CalculatorInput } from '@/components/common/input/CalcInput'
export default function Module({ setTabNum }) { export default function Module({ setTabNum }) {
const { getMessage } = useMessage() const { getMessage } = useMessage()
@ -186,23 +185,11 @@ export default function Module({ setTabNum }) {
<div className="eaves-keraba-td"> <div className="eaves-keraba-td">
<div className="outline-form"> <div className="outline-form">
<div className="grid-select mr10"> <div className="grid-select mr10">
{/*<input*/} <input
{/* type="text"*/} type="text"
{/* className="input-origin block"*/}
{/* value={inputInstallHeight}*/}
{/* onChange={(e) => setInputInstallHeight(normalizeDecimal(e.target.value))}*/}
{/*/>*/}
<CalculatorInput
id=""
name=""
label=""
className="input-origin block" className="input-origin block"
value={inputInstallHeight} value={inputInstallHeight}
onChange={(value) => setInputInstallHeight(value)} onChange={(e) => setInputInstallHeight(normalizeDecimal(e.target.value))}
options={{
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span className="thin">m</span> <span className="thin">m</span>

View File

@ -10,7 +10,6 @@ import { useModuleBasicSetting } from '@/hooks/module/useModuleBasicSetting'
import { useCommonCode } from '@/hooks/common/useCommonCode' import { useCommonCode } from '@/hooks/common/useCommonCode'
import Swal from 'sweetalert2' import Swal from 'sweetalert2'
import { normalizeDecimal} from '@/util/input-utils' import { normalizeDecimal} from '@/util/input-utils'
import { CalculatorInput } from '@/components/common/input/CalcInput'
export const Orientation = forwardRef((props, ref) => { export const Orientation = forwardRef((props, ref) => {
const { getMessage } = useMessage() const { getMessage } = useMessage()
@ -437,26 +436,13 @@ export const Orientation = forwardRef((props, ref) => {
<label htmlFor="ch99">{getMessage('modal.module.basic.setting.orientation.setting.angle.passivity')}</label> <label htmlFor="ch99">{getMessage('modal.module.basic.setting.orientation.setting.angle.passivity')}</label>
</div> </div>
<div className="input-grid mr10" style={{ width: '60px' }}> <div className="input-grid mr10" style={{ width: '60px' }}>
{/*<input*/} <input
{/* type="text"*/} type="text"
{/* className="input-origin block"*/}
{/* value={inputCompasDeg}*/}
{/* readOnly={!hasAnglePassivity}*/}
{/* placeholder={0}*/}
{/* onChange={(e) => checkDegree(e.target.value)}*/}
{/*/>*/}
<CalculatorInput
id=""
name=""
label=""
className="input-origin block" className="input-origin block"
value={inputCompasDeg} value={inputCompasDeg}
readOnly={!hasAnglePassivity} readOnly={!hasAnglePassivity}
onChange={(value) => setInputCompasDeg(value)} placeholder={0}
options={{ onChange={(e) => checkDegree(e.target.value)}
allowNegative: true,
allowDecimal: false
}}
/> />
</div> </div>
<span className="thin">°</span> <span className="thin">°</span>
@ -547,19 +533,7 @@ export const Orientation = forwardRef((props, ref) => {
<div className="outline-form mt15"> <div className="outline-form mt15">
<span>{getMessage('modal.module.basic.setting.module.placement.area')}</span> <span>{getMessage('modal.module.basic.setting.module.placement.area')}</span>
<div className="input-grid mr10" style={{ width: '60px' }}> <div className="input-grid mr10" style={{ width: '60px' }}>
{/*<input type="text" className="input-origin block" value={inputMargin} onChange={(e) => setInputMargin(normalizeDecimal(e.target.value))} />*/} <input type="text" className="input-origin block" value={inputMargin} onChange={(e) => setInputMargin(normalizeDecimal(e.target.value))} />
<CalculatorInput
id=""
name=""
label=""
className="input-origin block"
value={inputMargin}
onChange={(value) => setInputMargin(value)}
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div> </div>
<span className="thin">m</span> <span className="thin">m</span>
</div> </div>
@ -587,23 +561,11 @@ export const Orientation = forwardRef((props, ref) => {
<div className="outline-form"> <div className="outline-form">
<span>{getMessage('modal.module.basic.setting.module.fitting.height')}</span> <span>{getMessage('modal.module.basic.setting.module.fitting.height')}</span>
<div className="input-grid mr10"> <div className="input-grid mr10">
{/*<input*/} <input
{/* type="text"*/} type="text"
{/* className="input-origin block"*/}
{/* value={inputInstallHeight}*/}
{/* onChange={(e) => handleChangeInstallHeight(normalizeDecimal(e.target.value))}*/}
{/*/>*/}
<CalculatorInput
id=""
name=""
label=""
className="input-origin block" className="input-origin block"
value={inputInstallHeight} value={inputInstallHeight}
onChange={(value) => handleChangeInstallHeight(value)} onChange={(e) => handleChangeInstallHeight(normalizeDecimal(e.target.value))}
options={{
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span className="thin">m</span> <span className="thin">m</span>
@ -627,23 +589,11 @@ export const Orientation = forwardRef((props, ref) => {
<div className="outline-form"> <div className="outline-form">
<span>{getMessage('modal.module.basic.setting.module.standard.snowfall.amount')}</span> <span>{getMessage('modal.module.basic.setting.module.standard.snowfall.amount')}</span>
<div className="input-grid mr10"> <div className="input-grid mr10">
{/*<input*/} <input
{/* type="text"*/} type="text"
{/* className="input-origin block"*/}
{/* value={inputVerticalSnowCover}*/}
{/* onChange={(e) => handleChangeVerticalSnowCover(normalizeDecimal(e.target.value))}*/}
{/*/>*/}
<CalculatorInput
id=""
name=""
label=""
className="input-origin block" className="input-origin block"
value={inputInstallHeight} value={inputVerticalSnowCover}
onChange={(value) => handleChangeVerticalSnowCover(value)} onChange={(e) => handleChangeVerticalSnowCover(normalizeDecimal(e.target.value))}
options={{
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span className="thin">cm</span> <span className="thin">cm</span>

View File

@ -10,7 +10,6 @@ import { forwardRef, useContext, useEffect, useImperativeHandle, useRef, useStat
import { useRecoilState, useRecoilValue } from 'recoil' import { useRecoilState, useRecoilValue } from 'recoil'
import Swal from 'sweetalert2' import Swal from 'sweetalert2'
import { normalizeDigits } from '@/util/input-utils' import { normalizeDigits } from '@/util/input-utils'
import { CalculatorInput } from '@/components/common/input/CalcInput'
const Trestle = forwardRef((props, ref) => { const Trestle = forwardRef((props, ref) => {
const { tabNum, setTabNum, trestleTrigger, roofs, setRoofs, moduleSelectionData, setModuleSelectionData, setRoofsStore } = props const { tabNum, setTabNum, trestleTrigger, roofs, setRoofs, moduleSelectionData, setModuleSelectionData, setRoofsStore } = props
@ -886,24 +885,12 @@ const Trestle = forwardRef((props, ref) => {
<div className="outline-form mr15"> <div className="outline-form mr15">
<span>{getMessage('modal.module.basic.setting.module.placement.area.eaves')}</span> <span>{getMessage('modal.module.basic.setting.module.placement.area.eaves')}</span>
<div className="input-grid mr10"> <div className="input-grid mr10">
{/*<input*/} <input
{/* type="number"*/} type="number"
{/* className="input-origin block"*/}
{/* value={eavesMargin ?? 0}*/}
{/* // onChange={(e) => dispatch({ type: 'SET_TRESTLE_DETAIL', roof: { ...trestleState, eavesMargin: e.target.value } })}*/}
{/* onChange={(e) => setEavesMargin(+e.target.value)}*/}
{/*/>*/}
<CalculatorInput
id=""
name=""
label=""
className="input-origin block" className="input-origin block"
value={eavesMargin ?? 0} value={eavesMargin ?? 0}
onChange={(value) => setEavesMargin(value)} // onChange={(e) => dispatch({ type: 'SET_TRESTLE_DETAIL', roof: { ...trestleState, eavesMargin: e.target.value } })}
options={{ onChange={(e) => setEavesMargin(+e.target.value)}
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>
@ -911,24 +898,12 @@ const Trestle = forwardRef((props, ref) => {
<div className="outline-form mr15"> <div className="outline-form mr15">
<span>{getMessage('modal.module.basic.setting.module.placement.area.ridge')}</span> <span>{getMessage('modal.module.basic.setting.module.placement.area.ridge')}</span>
<div className="input-grid mr10"> <div className="input-grid mr10">
{/*<input*/} <input
{/* type="number"*/} type="number"
{/* className="input-origin block"*/}
{/* value={ridgeMargin ?? 0}*/}
{/* // onChange={(e) => dispatch({ type: 'SET_TRESTLE_DETAIL', roof: { ...trestleState, ridgeMargin: e.target.value } })}*/}
{/* onChange={(e) => setRidgeMargin(+e.target.value)}*/}
{/*/>*/}
<CalculatorInput
id=""
name=""
label=""
className="input-origin block" className="input-origin block"
value={ridgeMargin ?? 0} value={ridgeMargin ?? 0}
onChange={(value) => setRidgeMargin(value)} // onChange={(e) => dispatch({ type: 'SET_TRESTLE_DETAIL', roof: { ...trestleState, ridgeMargin: e.target.value } })}
options={{ onChange={(e) => setRidgeMargin(+e.target.value)}
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>
@ -936,24 +911,12 @@ const Trestle = forwardRef((props, ref) => {
<div className="outline-form "> <div className="outline-form ">
<span>{getMessage('modal.module.basic.setting.module.placement.area.keraba')}</span> <span>{getMessage('modal.module.basic.setting.module.placement.area.keraba')}</span>
<div className="input-grid mr10"> <div className="input-grid mr10">
{/*<input*/} <input
{/* type="number"*/} type="number"
{/* className="input-origin block"*/}
{/* value={kerabaMargin ?? 0}*/}
{/* // onChange={(e) => dispatch({ type: 'SET_TRESTLE_DETAIL', roof: { ...trestleState, kerabaMargin: e.target.value } })}*/}
{/* onChange={(e) => setKerabaMargin(+e.target.value)}*/}
{/*/>*/}
<CalculatorInput
id=""
name=""
label=""
className="input-origin block" className="input-origin block"
value={kerabaMargin ?? 0} value={kerabaMargin ?? 0}
onChange={(value) => setKerabaMargin(value)} // onChange={(e) => dispatch({ type: 'SET_TRESTLE_DETAIL', roof: { ...trestleState, kerabaMargin: e.target.value } })}
options={{ onChange={(e) => setKerabaMargin(+e.target.value)}
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span className="thin">mm</span> <span className="thin">mm</span>

View File

@ -23,7 +23,6 @@ import { QcastContext } from '@/app/QcastProvider'
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu' import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
import { useSwal } from '@/hooks/useSwal' import { useSwal } from '@/hooks/useSwal'
import { sanitizeIntegerInputEvent } from '@/util/input-utils' import { sanitizeIntegerInputEvent } from '@/util/input-utils'
import { CalculatorInput } from '@/components/common/input/CalcInput'
export default function StuffDetail() { export default function StuffDetail() {
const [stuffSearch, setStuffSearch] = useRecoilState(stuffSearchState) const [stuffSearch, setStuffSearch] = useRecoilState(stuffSearchState)
@ -1205,10 +1204,8 @@ export default function StuffDetail() {
} }
// //
const onValid = async (actionType) => { const onValid = async () => {
const formData = form.getValues(); const formData = form.getValues()
if(actionType !== 'save') return false
console.log('Action type:', actionType); // 'save' 'tempSave'
let errors = {} let errors = {}
let fieldNm let fieldNm
@ -1718,7 +1715,7 @@ export default function StuffDetail() {
<button type="button" className="btn-origin grey mr5" onClick={onTempSave} style={{ display: showButton }}> <button type="button" className="btn-origin grey mr5" onClick={onTempSave} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.tempSave')} {getMessage('stuff.detail.btn.tempSave')}
</button> </button>
<button type="button" onClick={() => onValid('save')} className="btn-origin navy mr5" style={{ display: showButton }}> <button type="submit" className="btn-origin navy mr5" style={{ display: showButton }}>
{getMessage('stuff.detail.btn.save')} {getMessage('stuff.detail.btn.save')}
</button> </button>
<button <button
@ -2116,25 +2113,13 @@ export default function StuffDetail() {
<td> <td>
<div className="flx-box"> <div className="flx-box">
<div className="input-wrap mr10" style={{ width: '200px' }}> <div className="input-wrap mr10" style={{ width: '200px' }}>
{/*<input*/} <input
{/* type="text"*/} type="text"
{/* className="input-light"*/}
{/* onInput={handleKeyUp}*/}
{/* onBlur={handleBlur}*/}
{/* value={form.watch('verticalSnowCover') || ''}*/}
{/* {...register('verticalSnowCover')}*/}
{/*/>*/}
<CalculatorInput
id="verticalSnowCover"
name="verticalSnowCover"
label=""
className="input-light" className="input-light"
onInput={handleKeyUp}
onBlur={handleBlur}
value={form.watch('verticalSnowCover') || ''} value={form.watch('verticalSnowCover') || ''}
onChange={(value) => form.setValue('verticalSnowCover', value)} {...register('verticalSnowCover')}
options={{
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span className="mr10">cm</span> <span className="mr10">cm</span>
@ -2188,25 +2173,13 @@ export default function StuffDetail() {
<td> <td>
<div className="flx-box"> <div className="flx-box">
<div className="input-wrap mr10" style={{ width: '200px' }}> <div className="input-wrap mr10" style={{ width: '200px' }}>
{/*<input*/} <input
{/* type="text"*/} type="text"
{/* className="input-light"*/}
{/* onInput={handleKeyUp}*/}
{/* onBlur={handleBlur}*/}
{/* value={form.watch('installHeight') || ''}*/}
{/* {...register('installHeight')}*/}
{/*/>*/}
<CalculatorInput
id="installHeight"
name="installHeight"
label=""
className="input-light" className="input-light"
onInput={handleKeyUp}
onBlur={handleBlur}
value={form.watch('installHeight') || ''} value={form.watch('installHeight') || ''}
onChange={(value) => form.setValue('installHeight', value)} {...register('installHeight')}
options={{
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span>m</span> <span>m</span>
@ -2243,7 +2216,7 @@ export default function StuffDetail() {
<button type="button" className="btn-origin grey mr5" onClick={onTempSave} style={{ display: showButton }}> <button type="button" className="btn-origin grey mr5" onClick={onTempSave} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.tempSave')} {getMessage('stuff.detail.btn.tempSave')}
</button> </button>
<button type="button" onClick={() => onValid('save')} className="btn-origin navy mr5" style={{ display: showButton }}> <button type="submit" className="btn-origin navy mr5" style={{ display: showButton }}>
{getMessage('stuff.detail.btn.save')} {getMessage('stuff.detail.btn.save')}
</button> </button>
<button <button
@ -2280,7 +2253,7 @@ export default function StuffDetail() {
> >
{getMessage('stuff.detail.btn.moveList')} {getMessage('stuff.detail.btn.moveList')}
</button> </button>
<button type="button" onClick={() => onValid('save')} className="btn-origin navy mr5" style={{ display: showButton }}> <button type="submit" className="btn-origin navy mr5" style={{ display: showButton }}>
{getMessage('stuff.detail.btn.save')} {getMessage('stuff.detail.btn.save')}
</button> </button>
<button type="button" className="btn-origin grey" onClick={onDelete} style={{ display: showButton }}> <button type="button" className="btn-origin grey" onClick={onDelete} style={{ display: showButton }}>
@ -2294,7 +2267,7 @@ export default function StuffDetail() {
<button type="button" className="btn-origin grey mr5" onClick={onTempSave} style={{ display: showButton }}> <button type="button" className="btn-origin grey mr5" onClick={onTempSave} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.tempSave')} {getMessage('stuff.detail.btn.tempSave')}
</button> </button>
<button type="button" onClick={() => onValid('save')} className="btn-origin navy mr5" style={{ display: showButton }}> <button type="submit" className="btn-origin navy mr5" style={{ display: showButton }}>
{getMessage('stuff.detail.btn.save')} {getMessage('stuff.detail.btn.save')}
</button> </button>
<button <button
@ -2712,25 +2685,13 @@ export default function StuffDetail() {
<td> <td>
<div className="flx-box"> <div className="flx-box">
<div className="input-wrap mr10" style={{ width: '200px' }}> <div className="input-wrap mr10" style={{ width: '200px' }}>
{/*<input*/} <input
{/* type="text"*/} type="text"
{/* className="input-light"*/}
{/* onInput={handleKeyUp}*/}
{/* onBlur={handleBlur}*/}
{/* value={form.watch('verticalSnowCover') || ''}*/}
{/* {...register('verticalSnowCover')}*/}
{/*/>*/}
<CalculatorInput
id="verticalSnowCover"
name="verticalSnowCover"
label=""
className="input-light" className="input-light"
onInput={handleKeyUp}
onBlur={handleBlur}
value={form.watch('verticalSnowCover') || ''} value={form.watch('verticalSnowCover') || ''}
onChange={(value) => form.setValue('verticalSnowCover', value)} {...register('verticalSnowCover')}
options={{
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span className="mr10">cm</span> <span className="mr10">cm</span>
@ -2787,26 +2748,13 @@ export default function StuffDetail() {
<td> <td>
<div className="flx-box"> <div className="flx-box">
<div className="input-wrap mr10" style={{ width: '200px' }}> <div className="input-wrap mr10" style={{ width: '200px' }}>
{/*<input*/} <input
{/* type="text"*/} type="text"
{/* className="input-light"*/}
{/* onInput={handleKeyUp}*/}
{/* onBlur={handleBlur}*/}
{/* value={form.watch('installHeight') || ''}*/}
{/* {...register('installHeight')}*/}
{/*/>*/}
<CalculatorInput
id="installHeight"
name="installHeight"
label=""
className="input-light" className="input-light"
onInput={handleKeyUp}
onBlur={handleBlur}
value={form.watch('installHeight') || ''} value={form.watch('installHeight') || ''}
onChange={(value) => form.setValue('installHeight', value)} {...register('installHeight')}
options={{
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span>m</span> <span>m</span>
@ -2887,7 +2835,7 @@ export default function StuffDetail() {
> >
{getMessage('stuff.detail.btn.moveList')} {getMessage('stuff.detail.btn.moveList')}
</button> </button>
<button type="button" onClick={() => onValid('save')} className="btn-origin navy mr5" style={{ display: showButton }}> <button type="submit" className="btn-origin navy mr5" style={{ display: showButton }}>
{getMessage('stuff.detail.btn.save')} {getMessage('stuff.detail.btn.save')}
</button> </button>
<button type="button" className="btn-origin grey" onClick={onDelete} style={{ display: showButton }}> <button type="button" className="btn-origin grey" onClick={onDelete} style={{ display: showButton }}>
@ -2901,7 +2849,7 @@ export default function StuffDetail() {
<button type="button" className="btn-origin grey mr5" onClick={onTempSave} style={{ display: showButton }}> <button type="button" className="btn-origin grey mr5" onClick={onTempSave} style={{ display: showButton }}>
{getMessage('stuff.detail.btn.tempSave')} {getMessage('stuff.detail.btn.tempSave')}
</button> </button>
<button type="button" onClick={() => onValid('save')} className="btn-origin navy mr5" style={{ display: showButton }}> <button type="submit" className="btn-origin navy mr5" style={{ display: showButton }}>
{getMessage('stuff.detail.btn.save')} {getMessage('stuff.detail.btn.save')}
</button> </button>
<button <button

View File

@ -116,7 +116,6 @@ export function useEavesGableEdit(id) {
useEffect(() => { useEffect(() => {
typeRef.current = type typeRef.current = type
radioTypeRef.current = '1'
}, [type]) }, [type])
const mouseOverEvent = (e) => { const mouseOverEvent = (e) => {

View File

@ -631,7 +631,7 @@ export function useMovementSetting(id) {
} }
return Big(0); // 기본값으로 0 반환 또는 다른 적절한 기본값 return Big(0); // 기본값으로 0 반환 또는 다른 적절한 기본값
})(); })();
if (Math.abs(target.y1 - target.y2) < 0.5) { if (target.y1 === target.y2) {
value = value.neg() value = value.neg()
} }
} else { } else {

View File

@ -851,15 +851,12 @@ export const usePolygon = () => {
// innerLines와 polygonLines의 겹침을 확인하고 type 변경 // innerLines와 polygonLines의 겹침을 확인하고 type 변경
innerLines.forEach((innerLine) => { innerLines.forEach((innerLine) => {
polygonLines.forEach((polygonLine) => { polygonLines.forEach((polygonLine) => {
if (polygonLine.attributes.type === LINE_TYPE.WALLLINE.EAVES) {
return
}
if (checkLineOverlap(innerLine, polygonLine)) { if (checkLineOverlap(innerLine, polygonLine)) {
// innerLine의 type을 polygonLine의 type으로 변경 // innerLine의 type을 polygonLine의 type으로 변경
if (innerLine.attributes && polygonLine.attributes.type) { if (innerLine.attributes && polygonLine.attributes.type) {
// innerLine이 polygonLine보다 긴 경우 polygonLine.need를 false로 변경 // innerLine이 polygonLine보다 긴 경우 polygonLine.need를 false로 변경
if (polygonLine.length < innerLine.length) { if (polygonLine.length < innerLine.length) {
if (polygonLine.lineName !== 'eaveHelpLine' || polygonLine.lineName !== 'eaveHelpLine') { if (polygonLine.lineName !== 'eaveHelpLine') {
polygonLine.need = false polygonLine.need = false
} }
} }
@ -1017,7 +1014,6 @@ export const usePolygon = () => {
canvas.add(line) canvas.add(line)
}) })
canvas.renderAll()*/ canvas.renderAll()*/
polygonLines = polygonLines.filter((line) => line.need) polygonLines = polygonLines.filter((line) => line.need)
polygonLines.forEach((line) => { polygonLines.forEach((line) => {
@ -1381,6 +1377,7 @@ export const usePolygon = () => {
let newRoofs = getSplitRoofsPoints(allLines) let newRoofs = getSplitRoofsPoints(allLines)
newRoofs = newRoofs.filter((roof) => roof.length !== 0) newRoofs = newRoofs.filter((roof) => roof.length !== 0)
newRoofs.forEach((roofPoint, index) => { newRoofs.forEach((roofPoint, index) => {
let defense, pitch let defense, pitch
@ -1414,124 +1411,6 @@ export const usePolygon = () => {
} }
}) })
// representLines가 없다면 A,B타입중 하나임
if (representLines.length === 0) {
// 1. roofPoint로 폴리곤의 라인들을 생성
const roofPolygonLines = []
for (let i = 0; i < roofPoint.length; i++) {
const nextIndex = (i + 1) % roofPoint.length
const startPt = roofPoint[i]
const endPt = roofPoint[nextIndex]
roofPolygonLines.push({
x1: startPt.x,
y1: startPt.y,
x2: endPt.x,
y2: endPt.y,
startPoint: startPt,
endPoint: endPt,
})
}
// 3. 평행 여부 확인 함수
const checkParallel = (line1, line2) => {
const v1x = line1.x2 - line1.x1
const v1y = line1.y2 - line1.y1
const v2x = line2.x2 - line2.x1
const v2y = line2.y2 - line2.y1
const length1 = Math.sqrt(v1x ** 2 + v1y ** 2)
const length2 = Math.sqrt(v2x ** 2 + v2y ** 2)
if (length1 === 0 || length2 === 0) return false
const norm1x = v1x / length1
const norm1y = v1y / length1
const norm2x = v2x / length2
const norm2y = v2y / length2
const EPSILON = 0.01
const crossProduct = Math.abs(norm1x * norm2y - norm1y * norm2x)
const dotProduct = norm1x * norm2x + norm1y * norm2y
return crossProduct < EPSILON || Math.abs(Math.abs(dotProduct) - 1) < EPSILON
}
// 4. 점에서 라인까지의 거리 계산 함수
const getDistanceFromPointToLine = (point, lineP1, lineP2) => {
const A = point.x - lineP1.x
const B = point.y - lineP1.y
const C = lineP2.x - lineP1.x
const D = lineP2.y - lineP1.y
const dot = A * C + B * D
const lenSq = C * C + D * D
let param = -1
if (lenSq !== 0) {
param = dot / lenSq
}
let xx, yy
if (param < 0) {
xx = lineP1.x
yy = lineP1.y
} else if (param > 1) {
xx = lineP2.x
yy = lineP2.y
} else {
xx = lineP1.x + param * C
yy = lineP1.y + param * D
}
const dx = point.x - xx
const dy = point.y - yy
return Math.sqrt(dx * dx + dy * dy)
}
// 5. 두 평행한 라인 사이의 거리 계산 (한 라인의 중점에서 다른 라인까지의 거리)
const getDistanceBetweenParallelLines = (line1, line2) => {
const midPoint = {
x: (line1.x1 + line1.x2) / 2,
y: (line1.y1 + line1.y2) / 2,
}
return getDistanceFromPointToLine(midPoint, { x: line2.x1, y: line2.y1 }, { x: line2.x2, y: line2.y2 })
}
// 6. roofPolygonLines의 모든 라인에서 평행하면서 가장 가까운 EAVES 라인 찾기
let closestLine = null
let minDistance = Infinity
roofPolygonLines.forEach((roofLine) => {
;[...polygonLines, ...innerLines].forEach((line) => {
// EAVES 타입만 필터링
if (line.attributes?.type !== LINE_TYPE.WALLLINE.EAVES && line.attributes?.type !== LINE_TYPE.WALLLINE.EAVE_HELP_LINE) {
return
}
const lineObj = {
x1: line.startPoint.x,
y1: line.startPoint.y,
x2: line.endPoint.x,
y2: line.endPoint.y,
}
if (checkParallel(roofLine, lineObj)) {
const distance = getDistanceBetweenParallelLines(roofLine, lineObj)
if (distance < minDistance && distance > 0) {
minDistance = distance
closestLine = line
}
}
})
})
if (closestLine) {
representLines.push(closestLine)
}
}
// representLines중 가장 긴 line을 찾는다. // representLines중 가장 긴 line을 찾는다.
representLines.forEach((line) => { representLines.forEach((line) => {
if (!representLine) { if (!representLine) {

File diff suppressed because it is too large Load Diff