diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index 2915b548..092c4e59 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -14,7 +14,7 @@ import { } from '@/store/canvasAtom' import { rectToPolygon, polygonToTurfPolygon, calculateVisibleModuleHeight, getDegreeByChon, toFixedWithoutRounding } from '@/util/canvas-util' -import { roofDisplaySelector } from '@/store/settingAtom' +import { basicSettingState, roofDisplaySelector } from '@/store/settingAtom' import offsetPolygon, { calculateAngle, createLinesFromPolygon } from '@/util/qpolygon-utils' import { QPolygon } from '@/components/fabric/QPolygon' import { moduleSetupSurfaceState } from '@/store/canvasAtom' @@ -52,6 +52,7 @@ export function useModuleBasicSetting(tabNum) { const [trestleDetailList, setTrestleDetailList] = useState([]) const selectedModules = useRecoilValue(selectedModuleState) const [saleStoreNorthFlg, setSaleStoreNorthFlg] = useState(false) + const roofSizeSet = useRecoilValue(basicSettingState).roofSizeSet const setCurrentObject = useSetRecoilState(currentObjectState) const { setModuleStatisticsData } = useCircuitTrestle() @@ -358,6 +359,7 @@ export function useModuleBasicSetting(tabNum) { perPixelTargetFind: true, isSaleStoreNorthFlg: moduleSelectionData.common.saleStoreNorthFlg == '1' ? true : false, //북면설치가능점 여부 // angle: -compasDeg, + from: roof.from ?? '', }) setupSurface.setViewLengthText(false) @@ -531,6 +533,7 @@ export function useModuleBasicSetting(tabNum) { for (let i = 0; i < moduleSetupSurfaces.length; i++) { //배치면이 여러개 일때 옮겨가면서 동작해야함 + const moduleSetupSurface = moduleSetupSurfaces[i] turfPolygon = polygonToTurfPolygon(moduleSetupSurfaces[i]) trestlePolygon = moduleSetupSurfaces[i] manualDrawModules = moduleSetupSurfaces[i].modules // 앞에서 자동으로 했을때 추가됨 @@ -542,7 +545,7 @@ export function useModuleBasicSetting(tabNum) { let tmpHeight = flowDirection === 'south' || flowDirection === 'north' ? moduleHeight : moduleWidth let { width, height } = - canvasSetting.roofSizeSet == '1' + moduleSetupSurface.from === 'roofCover' ? calculateVisibleModuleHeight(tmpWidth, tmpHeight, getDegreeByChon(moduleSetupSurfaces[i].roofMaterial.pitch), flowDirection) : { width: tmpWidth, height: tmpHeight } @@ -922,6 +925,7 @@ export function useModuleBasicSetting(tabNum) { } } + //단 열수 지정배치 const manualModuleLayoutSetup = (layoutSetupRef) => { const moduleSetupSurfaces = canvas?.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) //모듈설치면를 가져옴 @@ -1022,6 +1026,7 @@ export function useModuleBasicSetting(tabNum) { for (let i = 0; i < moduleSetupSurfaces.length; i++) { //배치면이 여러개 일때 옮겨가면서 동작해야함 + const moduleSetupSurface = moduleSetupSurfaces[i] turfPolygon = polygonToTurfPolygon(moduleSetupSurfaces[i]) trestlePolygon = moduleSetupSurfaces[i] manualDrawModules = moduleSetupSurfaces[i].modules // 앞에서 자동으로 했을때 추가됨 @@ -1035,11 +1040,11 @@ export function useModuleBasicSetting(tabNum) { let tmpHeight = flowDirection === 'south' || flowDirection === 'north' ? moduleHeight : moduleWidth width = - canvasSetting.roofSizeSet == '1' + moduleSetupSurface.from === 'roofCover' ? calculateVisibleModuleHeight(tmpWidth, tmpHeight, getDegreeByChon(moduleSetupSurfaces[i].roofMaterial.pitch), flowDirection).width : tmpWidth height = - canvasSetting.roofSizeSet == '1' + moduleSetupSurface.from === 'roofCover' ? calculateVisibleModuleHeight(tmpWidth, tmpHeight, getDegreeByChon(moduleSetupSurfaces[i].roofMaterial.pitch), flowDirection).height : tmpHeight @@ -1362,11 +1367,11 @@ export function useModuleBasicSetting(tabNum) { //복시도, 실치수에 따른 모듈 높이 조정 width = - canvasSetting.roofSizeSet == '1' + trestlePolygon.from === 'roofCover' ? calculateVisibleModuleHeight(tmpWidth, tmpHeight, getDegreeByChon(trestlePolygon.roofMaterial.pitch), flowDirection).width : tmpWidth height = - canvasSetting.roofSizeSet == '1' + trestlePolygon.from === 'roofCover' ? calculateVisibleModuleHeight(tmpWidth, tmpHeight, getDegreeByChon(trestlePolygon.roofMaterial.pitch), flowDirection).height : tmpHeight @@ -3229,6 +3234,7 @@ export function useModuleBasicSetting(tabNum) { const mousePoint = canvas.getPointer(e.e) for (let i = 0; i < moduleSetupSurfaces.length; i++) { + const moduleSetupSurface = moduleSetupSurfaces[i] turfPolygon = polygonToTurfPolygon(moduleSetupSurfaces[i], true) trestlePolygon = moduleSetupSurfaces[i] manualDrawModules = moduleSetupSurfaces[i].modules // 앞에서 자동으로 했을때 추가됨 @@ -3241,7 +3247,7 @@ export function useModuleBasicSetting(tabNum) { let tmpHeight = flowDirection === 'south' || flowDirection === 'north' ? moduleHeight : moduleWidth let { width, height } = - canvasSetting.roofSizeSet == '1' + moduleSetupSurface.from === 'roofCover' ? calculateVisibleModuleHeight(tmpWidth, tmpHeight, getDegreeByChon(moduleSetupSurfaces[i].roofMaterial.pitch), flowDirection) : { width: tmpWidth, height: tmpHeight } @@ -3959,7 +3965,7 @@ export function useModuleBasicSetting(tabNum) { 10 } - return canvasSetting.roofSizeSet == '1' + return moduleSetupSurface.from === 'roofCover' ? calculateVisibleModuleHeight(tmpWidth, tmpHeight, getDegreeByChon(moduleSetupSurface.roofMaterial.pitch), moduleSetupSurface.direction) : { width: tmpWidth, height: tmpHeight } } diff --git a/src/hooks/module/useTrestle.js b/src/hooks/module/useTrestle.js index ec9e03d0..5132a344 100644 --- a/src/hooks/module/useTrestle.js +++ b/src/hooks/module/useTrestle.js @@ -1156,12 +1156,12 @@ export const useTrestle = () => { case 'south': { rackInfos.forEach((rackInfo) => { const { rackLen, itemId, supFitQty, supFitIntvlPct, rackRowsCd, smartRack, smartRackYn } = rackInfo - let rackLength = getTrestleLength(rackLen, degree) / 10 + let rackLength = getTrestleLength(rackLen, degree, surface) / 10 if (smartRackYn === 'Y') { let smartRackId = uuidv4() smartRack.forEach(({ seq, setRackTpCd, setRackTpLen, supFitQty }) => { - rackLength = getTrestleLength(setRackTpLen, degree) / 10 + rackLength = getTrestleLength(setRackTpLen, degree, surface) / 10 if (setRackTpCd === 'RACK') { const rack = new fabric.Line([startPointX, startPointY, startPointX, startPointY - rackLength], { name: TRESTLE_MATERIAL.SMART_RACK, @@ -1230,11 +1230,11 @@ export const useTrestle = () => { rackInfos.forEach((rackInfo) => { const { rackLen, itemId, supFitQty, supFitIntvlPct, rackRowsCd, smartRack, smartRackYn } = rackInfo - let rackLength = getTrestleLength(rackLen, degree) / 10 + let rackLength = getTrestleLength(rackLen, degree, surface) / 10 if (smartRackYn === 'Y') { let smartRackId = uuidv4() smartRack.forEach(({ seq, setRackTpCd, setRackTpLen, supFitQty }) => { - rackLength = getTrestleLength(setRackTpLen, degree) / 10 + rackLength = getTrestleLength(setRackTpLen, degree, surface) / 10 if (setRackTpCd === 'RACK') { const rack = new fabric.Line([startPointX, startPointY, startPointX - rackLength, startPointY], { name: TRESTLE_MATERIAL.SMART_RACK, @@ -1302,11 +1302,11 @@ export const useTrestle = () => { case 'west': { rackInfos.forEach((rackInfo) => { const { rackLen, itemId, supFitQty, supFitIntvlPct, rackRowsCd, smartRack, smartRackYn } = rackInfo - let rackLength = getTrestleLength(rackLen, degree) / 10 + let rackLength = getTrestleLength(rackLen, degree, surface) / 10 if (smartRackYn === 'Y') { let smartRackId = uuidv4() smartRack.forEach(({ seq, setRackTpCd, setRackTpLen, supFitQty }) => { - rackLength = getTrestleLength(setRackTpLen, degree) / 10 + rackLength = getTrestleLength(setRackTpLen, degree, surface) / 10 if (setRackTpCd === 'RACK') { const rack = new fabric.Line([startPointX, startPointY, startPointX + rackLength, startPointY], { name: TRESTLE_MATERIAL.SMART_RACK, @@ -1372,11 +1372,11 @@ export const useTrestle = () => { case 'north': { rackInfos.forEach((rackInfo) => { const { rackLen, itemId, supFitQty, supFitIntvlPct, rackRowsCd, smartRack, smartRackYn } = rackInfo - let rackLength = getTrestleLength(rackLen, degree) / 10 + let rackLength = getTrestleLength(rackLen, degree, surface) / 10 if (smartRackYn === 'Y') { let smartRackId = uuidv4() smartRack.forEach(({ seq, setRackTpCd, setRackTpLen, supFitQty }) => { - rackLength = getTrestleLength(setRackTpLen, degree) / 10 + rackLength = getTrestleLength(setRackTpLen, degree, surface) / 10 if (setRackTpCd === 'RACK') { const rack = new fabric.Line([startPointX, startPointY, startPointX, startPointY + rackLength], { name: TRESTLE_MATERIAL.SMART_RACK, @@ -2478,9 +2478,9 @@ export const useTrestle = () => { } // 각도에 따른 길이 반환 - function getTrestleLength(length, degree) { - if (roofSizeSet !== 1) { - // 복시도 입력이 아닌경우 그냥 길이 return + function getTrestleLength(length, degree, surface) { + if (surface.from !== 'roofCover') { + // 지붕덮개로부터 온게 아니면 그냥 length 리턴 return length } const radians = (degree * Math.PI) / 180