수동시 치조 여부에 따라 모듈 가운데 흡착

This commit is contained in:
yjnoh 2025-03-19 17:49:17 +09:00
parent 9bb72bfa3a
commit c34a7fc54d
2 changed files with 42 additions and 49 deletions

View File

@ -100,7 +100,7 @@ export default function ObjectSetting({ id, pos = { x: 50, y: 230 } }) {
] ]
return ( return (
<WithDraggable isShow={true} pos={pos} className="lrr" style={{ visibility: isHidden ? 'hidden' : 'visible' }}> <WithDraggable isShow={true} pos={pos} className="lrr" isHidden={isHidden}>
<WithDraggable.Header title={getMessage('plan.menu.placement.surface.object')} onClose={() => closePopup(id)} /> <WithDraggable.Header title={getMessage('plan.menu.placement.surface.object')} onClose={() => closePopup(id)} />
<WithDraggable.Body> <WithDraggable.Body>
<div className="modal-btn-wrap"> <div className="modal-btn-wrap">

View File

@ -64,9 +64,7 @@ export function useModuleBasicSetting(tabNum) {
const { createRoofPolygon, createMarginPolygon, createPaddingPolygon } = useMode() const { createRoofPolygon, createMarginPolygon, createPaddingPolygon } = useMode()
const { drawDirectionArrow } = usePolygon() const { drawDirectionArrow } = usePolygon()
const moduleSetupOption = useRecoilValue(moduleSetupOptionState) const moduleSetupOption = useRecoilValue(moduleSetupOptionState)
const setManualSetupMode = useSetRecoilState(toggleManualSetupModeState) const setManualSetupMode = useSetRecoilState(toggleManualSetupModeState)
useEffect(() => { useEffect(() => {
@ -440,6 +438,7 @@ export function useModuleBasicSetting(tabNum) {
//레이아웃 수동설치 토글 //레이아웃 수동설치 토글
const moduleSetupSurfaces = canvas?.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) //모듈설치면를 가져옴 const moduleSetupSurfaces = canvas?.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) //모듈설치면를 가져옴
const isChidori = moduleSetupOption.isChidori
if (isManualModuleSetup) { if (isManualModuleSetup) {
if (isManualModuleLayoutSetup) { if (isManualModuleLayoutSetup) {
@ -617,15 +616,16 @@ export function useModuleBasicSetting(tabNum) {
tempModule.left = holdCellCenterX - toFixedWithoutRounding(width / 2, 2) tempModule.left = holdCellCenterX - toFixedWithoutRounding(width / 2, 2)
} }
//움직이는 모듈왼쪽 -> 가운데 if (isChidori) {
if (Math.abs(smallLeft - holdCellCenterX) < snapDistance) { //움직이는 모듈왼쪽 -> 가운데
tempModule.left = holdCellCenterX + intvHor / 2 if (Math.abs(smallLeft - holdCellCenterX) < snapDistance) {
tempModule.left = holdCellCenterX + intvHor / 2
}
// 오른쪽 -> 가운데
if (Math.abs(smallRight - holdCellCenterX) < snapDistance) {
tempModule.left = holdCellCenterX - width - intvHor / 2
}
} }
// 오른쪽 -> 가운데
if (Math.abs(smallRight - holdCellCenterX) < snapDistance) {
tempModule.left = holdCellCenterX - width - intvHor / 2
}
//설치된 셀에 좌측에 스냅 //설치된 셀에 좌측에 스냅
if (Math.abs(smallRight - holdCellLeft) < snapDistance) { if (Math.abs(smallRight - holdCellLeft) < snapDistance) {
// console.log('모듈 좌측 스냅') // console.log('모듈 좌측 스냅')
@ -659,21 +659,16 @@ export function useModuleBasicSetting(tabNum) {
tempModule.top = holdCellCenterY - toFixedWithoutRounding(width / 2, 2) tempModule.top = holdCellCenterY - toFixedWithoutRounding(width / 2, 2)
} }
//위쪽 -> 가운데 if (isChidori) {
if (Math.abs(smallTop - holdCellCenterY) < snapDistance) { //위쪽 -> 가운데
// console.log('holdCellCenterX', holdCellCenterX) if (Math.abs(smallTop - holdCellCenterY) < snapDistance) {
// console.log('smallLeft', smallLeft) tempModule.top = holdCellCenterY + intvHor / 2
}
// console.log('모듈 센터에 스냅') // 밑 -> 가운데
tempModule.top = holdCellCenterY + intvHor / 2 if (Math.abs(smallBottom - holdCellCenterY) < snapDistance) {
tempModule.top = holdCellCenterY - height - intvHor / 2
// console.log('tempModule.left', tempModule.left) }
} }
// 밑 -> 가운데
if (Math.abs(smallBottom - holdCellCenterY) < snapDistance) {
tempModule.top = holdCellCenterY - height - intvHor / 2
}
//설치된 셀에 좌측에 스냅 //설치된 셀에 좌측에 스냅
if (Math.abs(smallRight - holdCellLeft) < snapDistance) { if (Math.abs(smallRight - holdCellLeft) < snapDistance) {
// console.log('모듈 좌측 스냅') // console.log('모듈 좌측 스냅')
@ -881,8 +876,9 @@ export function useModuleBasicSetting(tabNum) {
const manualModuleLayoutSetup = (layoutSetupRef) => { const manualModuleLayoutSetup = (layoutSetupRef) => {
const moduleSetupSurfaces = canvas?.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) //모듈설치면를 가져옴 const moduleSetupSurfaces = canvas?.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) //모듈설치면를 가져옴
const isChidori = moduleSetupOption.isChidori const isChidori = moduleSetupOption.isChidori //치도리 여부
const setupLocation = moduleSetupOption.setupLocation const setupLocation = moduleSetupOption.setupLocation //모듈 설치 위치 처마, 용마루
const isMultiModule = checkedModule.length > 1 //멀티 모듈인지 아닌지 여부
if (isManualModuleLayoutSetup) { if (isManualModuleLayoutSetup) {
if (isManualModuleSetup) { if (isManualModuleSetup) {
@ -1117,15 +1113,16 @@ export function useModuleBasicSetting(tabNum) {
tempModule.left = holdCellCenterX - toFixedWithoutRounding(width / 2, 2) tempModule.left = holdCellCenterX - toFixedWithoutRounding(width / 2, 2)
} }
//움직이는 모듈왼쪽 -> 가운데 if (isChidori) {
if (Math.abs(smallLeft - holdCellCenterX) < snapDistance) { //움직이는 모듈왼쪽 -> 가운데
tempModule.left = holdCellCenterX + intvHor / 2 if (Math.abs(smallLeft - holdCellCenterX) < snapDistance) {
tempModule.left = holdCellCenterX + intvHor / 2
}
// 오른쪽 -> 가운데
if (Math.abs(smallRight - holdCellCenterX) < snapDistance) {
tempModule.left = holdCellCenterX - width - intvHor / 2
}
} }
// 오른쪽 -> 가운데
if (Math.abs(smallRight - holdCellCenterX) < snapDistance) {
tempModule.left = holdCellCenterX - width - intvHor / 2
}
//설치된 셀에 좌측에 스냅 //설치된 셀에 좌측에 스냅
if (Math.abs(smallRight - holdCellLeft) < snapDistance) { if (Math.abs(smallRight - holdCellLeft) < snapDistance) {
// console.log('모듈 좌측 스냅') // console.log('모듈 좌측 스냅')
@ -1159,21 +1156,16 @@ export function useModuleBasicSetting(tabNum) {
tempModule.top = holdCellCenterY - toFixedWithoutRounding(width / 2, 2) tempModule.top = holdCellCenterY - toFixedWithoutRounding(width / 2, 2)
} }
//위쪽 -> 가운데 if (isChidori) {
if (Math.abs(smallTop - holdCellCenterY) < snapDistance) { //위쪽 -> 가운데
// console.log('holdCellCenterX', holdCellCenterX) if (Math.abs(smallTop - holdCellCenterY) < snapDistance) {
// console.log('smallLeft', smallLeft) tempModule.top = holdCellCenterY + intvHor / 2
}
// console.log('모듈 센터에 스냅') // 밑 -> 가운데
tempModule.top = holdCellCenterY + intvHor / 2 if (Math.abs(smallBottom - holdCellCenterY) < snapDistance) {
tempModule.top = holdCellCenterY - height - intvHor / 2
// console.log('tempModule.left', tempModule.left) }
} }
// 밑 -> 가운데
if (Math.abs(smallBottom - holdCellCenterY) < snapDistance) {
tempModule.top = holdCellCenterY - height - intvHor / 2
}
//설치된 셀에 좌측에 스냅 //설치된 셀에 좌측에 스냅
if (Math.abs(smallRight - holdCellLeft) < snapDistance) { if (Math.abs(smallRight - holdCellLeft) < snapDistance) {
// console.log('모듈 좌측 스냅') // console.log('모듈 좌측 스냅')
@ -1256,6 +1248,7 @@ export function useModuleBasicSetting(tabNum) {
addCanvasMouseEventListener('mouse:up', (e) => { addCanvasMouseEventListener('mouse:up', (e) => {
if (!inside) return if (!inside) return
if (tempModule) { if (tempModule) {
let startX, startY let startX, startY
let installedLastHeightCoord = 0 //마지막으로 설치된 모듈의 좌표 let installedLastHeightCoord = 0 //마지막으로 설치된 모듈의 좌표