dev #599
@ -9,7 +9,7 @@ import BasicSetting from '@/components/floor-plan/modal/basic/BasicSetting'
|
|||||||
import { useMasterController } from '@/hooks/common/useMasterController'
|
import { useMasterController } from '@/hooks/common/useMasterController'
|
||||||
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
|
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
|
||||||
import { GlobalDataContext } from '@/app/GlobalDataProvider'
|
import { GlobalDataContext } from '@/app/GlobalDataProvider'
|
||||||
import { POLYGON_TYPE, MENU } from '@/common/common'
|
import { MENU, POLYGON_TYPE } from '@/common/common'
|
||||||
import { useSwal } from '@/hooks/useSwal'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
import { canvasState, canvasZoomState, currentMenuState } from '@/store/canvasAtom'
|
import { canvasState, canvasZoomState, currentMenuState } from '@/store/canvasAtom'
|
||||||
|
|
||||||
@ -151,23 +151,30 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
// 정렬 함수: 큰 모듈이 있어야 할 위치부터 시작
|
// 정렬 함수: 큰 모듈이 있어야 할 위치부터 시작
|
||||||
const getSortFn = () => {
|
const getSortFn = () => {
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 'south': return (a, b) => b.y - a.y // 아래쪽(y 큼)부터
|
case 'south':
|
||||||
case 'north': return (a, b) => a.y - b.y // 위쪽(y 작음)부터
|
return (a, b) => b.y - a.y // 아래쪽(y 큼)부터
|
||||||
case 'east': return (a, b) => b.x - a.x // 오른쪽(x 큼)부터
|
case 'north':
|
||||||
case 'west': return (a, b) => a.x - b.x // 왼쪽(x 작음)부터
|
return (a, b) => a.y - b.y // 위쪽(y 작음)부터
|
||||||
default: return () => 0
|
case 'east':
|
||||||
|
return (a, b) => b.x - a.x // 오른쪽(x 큼)부터
|
||||||
|
case 'west':
|
||||||
|
return (a, b) => a.x - b.x // 왼쪽(x 작음)부터
|
||||||
|
default:
|
||||||
|
return () => 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 타겟 모듈 찾기 (현재 모듈보다 작아야 할 위치의 모듈)
|
// 타겟 모듈 찾기 (현재 모듈보다 작아야 할 위치의 모듈)
|
||||||
const findTargetModules = (current, margin) => {
|
const findTargetModules = (current, margin) => {
|
||||||
return centerPoints.filter(cp => {
|
return centerPoints.filter((cp) => {
|
||||||
const sameAxis = isVertical
|
const sameAxis = isVertical ? Math.abs(cp.x - current.x) < margin : Math.abs(cp.y - current.y) < margin
|
||||||
? Math.abs(cp.x - current.x) < margin
|
const targetDirection =
|
||||||
: Math.abs(cp.y - current.y) < margin
|
direction === 'south'
|
||||||
const targetDirection = direction === 'south' ? cp.y < current.y
|
? cp.y < current.y
|
||||||
: direction === 'north' ? cp.y > current.y
|
: direction === 'north'
|
||||||
: direction === 'east' ? cp.x < current.x
|
? cp.y > current.y
|
||||||
|
: direction === 'east'
|
||||||
|
? cp.x < current.x
|
||||||
: cp.x > current.x
|
: cp.x > current.x
|
||||||
return sameAxis && targetDirection
|
return sameAxis && targetDirection
|
||||||
})
|
})
|
||||||
@ -178,11 +185,16 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
if (filtered.length === 0) return null
|
if (filtered.length === 0) return null
|
||||||
return filtered.reduce((closest, cp) => {
|
return filtered.reduce((closest, cp) => {
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 'south': return cp.y > closest.y ? cp : closest
|
case 'south':
|
||||||
case 'north': return cp.y < closest.y ? cp : closest
|
return cp.y > closest.y ? cp : closest
|
||||||
case 'east': return cp.x > closest.x ? cp : closest
|
case 'north':
|
||||||
case 'west': return cp.x < closest.x ? cp : closest
|
return cp.y < closest.y ? cp : closest
|
||||||
default: return closest
|
case 'east':
|
||||||
|
return cp.x > closest.x ? cp : closest
|
||||||
|
case 'west':
|
||||||
|
return cp.x < closest.x ? cp : closest
|
||||||
|
default:
|
||||||
|
return closest
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -191,12 +203,12 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
const getGap = (current, target) => {
|
const getGap = (current, target) => {
|
||||||
if (isVertical) {
|
if (isVertical) {
|
||||||
return direction === 'south'
|
return direction === 'south'
|
||||||
? (current.y - current.height / 2) - (target.y + target.height / 2)
|
? current.y - current.height / 2 - (target.y + target.height / 2)
|
||||||
: (target.y - target.height / 2) - (current.y + current.height / 2)
|
: target.y - target.height / 2 - (current.y + current.height / 2)
|
||||||
} else {
|
} else {
|
||||||
return direction === 'east'
|
return direction === 'east'
|
||||||
? (current.x - current.width / 2) - (target.x + target.width / 2)
|
? current.x - current.width / 2 - (target.x + target.width / 2)
|
||||||
: (target.x - target.width / 2) - (current.x + current.width / 2)
|
: target.x - target.width / 2 - (current.x + current.width / 2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,9 +240,13 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
const offsetAxis = isVertical
|
const offsetAxis = isVertical
|
||||||
? Math.abs(cp.x - (current.x + offsetValue)) <= primaryInterval
|
? Math.abs(cp.x - (current.x + offsetValue)) <= primaryInterval
|
||||||
: Math.abs(cp.y - (current.y + offsetValue)) <= primaryInterval
|
: Math.abs(cp.y - (current.y + offsetValue)) <= primaryInterval
|
||||||
const targetDirection = direction === 'south' ? cp.y < current.y
|
const targetDirection =
|
||||||
: direction === 'north' ? cp.y > current.y
|
direction === 'south'
|
||||||
: direction === 'east' ? cp.x < current.x
|
? cp.y < current.y
|
||||||
|
: direction === 'north'
|
||||||
|
? cp.y > current.y
|
||||||
|
: direction === 'east'
|
||||||
|
? cp.x < current.x
|
||||||
: cp.x > current.x
|
: cp.x > current.x
|
||||||
return offsetAxis && targetDirection
|
return offsetAxis && targetDirection
|
||||||
})
|
})
|
||||||
@ -428,12 +444,13 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
let pcsObj = {}
|
let pcsObj = {}
|
||||||
|
|
||||||
models.forEach((model) => {
|
models.forEach((model) => {
|
||||||
pcsObj[model.itemId] = model
|
pcsObj[`${model.pcsSerCd}_${model.itemId}`] = model
|
||||||
})
|
})
|
||||||
res.data?.pcsItemList.forEach((item) => {
|
res.data?.pcsItemList.forEach((item) => {
|
||||||
if (pcsObj[item.itemId]) {
|
const key = `${item.pcsSerCd}_${item.itemId}`
|
||||||
|
if (pcsObj[key]) {
|
||||||
pcsItemList.push({
|
pcsItemList.push({
|
||||||
...pcsObj[item.itemId],
|
...pcsObj[key],
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
})
|
})
|
||||||
@ -560,12 +577,13 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
let pcsItemList = []
|
let pcsItemList = []
|
||||||
let pcsObj = {}
|
let pcsObj = {}
|
||||||
models.forEach((model) => {
|
models.forEach((model) => {
|
||||||
pcsObj[model.itemId] = model
|
pcsObj[`${model.pcsSerCd}_${model.itemId}`] = model
|
||||||
})
|
})
|
||||||
res.data?.pcsItemList.forEach((item) => {
|
res.data?.pcsItemList.forEach((item) => {
|
||||||
if (pcsObj[item.itemId]) {
|
const key = `${item.pcsSerCd}_${item.itemId}`
|
||||||
|
if (pcsObj[key]) {
|
||||||
pcsItemList.push({
|
pcsItemList.push({
|
||||||
...pcsObj[item.itemId],
|
...pcsObj[key],
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user