Compare commits
No commits in common. "d70e2f73462d8024672cedc6a5bc4d60ae00be70" and "0124200ef03ef885c3eb9630cfeb81c93e5b285b" have entirely different histories.
d70e2f7346
...
0124200ef0
@ -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 { MENU, POLYGON_TYPE } from '@/common/common'
|
import { POLYGON_TYPE, MENU } 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,31 +151,24 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
// 정렬 함수: 큰 모듈이 있어야 할 위치부터 시작
|
// 정렬 함수: 큰 모듈이 있어야 할 위치부터 시작
|
||||||
const getSortFn = () => {
|
const getSortFn = () => {
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 'south':
|
case 'south': return (a, b) => b.y - a.y // 아래쪽(y 큼)부터
|
||||||
return (a, b) => b.y - a.y // 아래쪽(y 큼)부터
|
case 'north': return (a, b) => a.y - b.y // 위쪽(y 작음)부터
|
||||||
case 'north':
|
case 'east': return (a, b) => b.x - a.x // 오른쪽(x 큼)부터
|
||||||
return (a, b) => a.y - b.y // 위쪽(y 작음)부터
|
case 'west': return (a, b) => a.x - b.x // 왼쪽(x 작음)부터
|
||||||
case 'east':
|
default: return () => 0
|
||||||
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 ? Math.abs(cp.x - current.x) < margin : Math.abs(cp.y - current.y) < margin
|
const sameAxis = isVertical
|
||||||
const targetDirection =
|
? Math.abs(cp.x - current.x) < margin
|
||||||
direction === 'south'
|
: Math.abs(cp.y - current.y) < margin
|
||||||
? cp.y < current.y
|
const targetDirection = direction === 'south' ? cp.y < current.y
|
||||||
: direction === 'north'
|
: direction === 'north' ? cp.y > current.y
|
||||||
? cp.y > current.y
|
: direction === 'east' ? cp.x < current.x
|
||||||
: direction === 'east'
|
: cp.x > current.x
|
||||||
? cp.x < current.x
|
|
||||||
: cp.x > current.x
|
|
||||||
return sameAxis && targetDirection
|
return sameAxis && targetDirection
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -185,16 +178,11 @@ 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':
|
case 'south': return cp.y > closest.y ? cp : closest
|
||||||
return cp.y > closest.y ? cp : closest
|
case 'north': return cp.y < closest.y ? cp : closest
|
||||||
case 'north':
|
case 'east': return cp.x > closest.x ? cp : closest
|
||||||
return cp.y < closest.y ? cp : closest
|
case 'west': return cp.x < closest.x ? cp : closest
|
||||||
case 'east':
|
default: return closest
|
||||||
return cp.x > closest.x ? cp : closest
|
|
||||||
case 'west':
|
|
||||||
return cp.x < closest.x ? cp : closest
|
|
||||||
default:
|
|
||||||
return closest
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -203,12 +191,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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,14 +228,10 @@ 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 =
|
const targetDirection = direction === 'south' ? cp.y < current.y
|
||||||
direction === 'south'
|
: direction === 'north' ? cp.y > current.y
|
||||||
? cp.y < current.y
|
: direction === 'east' ? cp.x < current.x
|
||||||
: direction === 'north'
|
: cp.x > current.x
|
||||||
? cp.y > current.y
|
|
||||||
: direction === 'east'
|
|
||||||
? cp.x < current.x
|
|
||||||
: cp.x > current.x
|
|
||||||
return offsetAxis && targetDirection
|
return offsetAxis && targetDirection
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -444,13 +428,12 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
let pcsObj = {}
|
let pcsObj = {}
|
||||||
|
|
||||||
models.forEach((model) => {
|
models.forEach((model) => {
|
||||||
pcsObj[`${model.pcsSerCd}_${model.itemId}`] = model
|
pcsObj[model.itemId] = model
|
||||||
})
|
})
|
||||||
res.data?.pcsItemList.forEach((item) => {
|
res.data?.pcsItemList.forEach((item) => {
|
||||||
const key = `${item.pcsSerCd}_${item.itemId}`
|
if (pcsObj[item.itemId]) {
|
||||||
if (pcsObj[key]) {
|
|
||||||
pcsItemList.push({
|
pcsItemList.push({
|
||||||
...pcsObj[key],
|
...pcsObj[item.itemId],
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
})
|
})
|
||||||
@ -577,13 +560,12 @@ export default function CircuitTrestleSetting({ id }) {
|
|||||||
let pcsItemList = []
|
let pcsItemList = []
|
||||||
let pcsObj = {}
|
let pcsObj = {}
|
||||||
models.forEach((model) => {
|
models.forEach((model) => {
|
||||||
pcsObj[`${model.pcsSerCd}_${model.itemId}`] = model
|
pcsObj[model.itemId] = model
|
||||||
})
|
})
|
||||||
res.data?.pcsItemList.forEach((item) => {
|
res.data?.pcsItemList.forEach((item) => {
|
||||||
const key = `${item.pcsSerCd}_${item.itemId}`
|
if (pcsObj[item.itemId]) {
|
||||||
if (pcsObj[key]) {
|
|
||||||
pcsItemList.push({
|
pcsItemList.push({
|
||||||
...pcsObj[key],
|
...pcsObj[item.itemId],
|
||||||
isUsed: false,
|
isUsed: false,
|
||||||
id: uuidv4(),
|
id: uuidv4(),
|
||||||
})
|
})
|
||||||
|
|||||||
@ -5992,19 +5992,6 @@ export const calcLineActualSize = (points, degree = 0) => {
|
|||||||
return Big(planeSize).div(theta).round().toNumber()
|
return Big(planeSize).div(theta).round().toNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const calcLineActualSize2 = (points, degree = 0) => {
|
|
||||||
const planeSize = calcLinePlaneSize(points)
|
|
||||||
|
|
||||||
const xLength = Math.abs(points.x2 - points.x1) * 10
|
|
||||||
const yLength = Math.abs(points.y2 - points.y1) * 10
|
|
||||||
const hx = xLength * Math.tan(degree * (Math.PI / 180))
|
|
||||||
|
|
||||||
const hy = yLength * Math.tan(degree * (Math.PI / 180))
|
|
||||||
const actualSize = Math.sqrt(hx ** 2 + planeSize ** 2)
|
|
||||||
const actualSize2 = Math.sqrt(hy ** 2 + planeSize ** 2)
|
|
||||||
return actualSize
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 포인트와 기울기를 기준으로 선의 길이를 구한다.
|
* 포인트와 기울기를 기준으로 선의 길이를 구한다.
|
||||||
* @param lineLength
|
* @param lineLength
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { LINE_TYPE, POLYGON_TYPE } from '@/common/common'
|
import { LINE_TYPE, POLYGON_TYPE } from '@/common/common'
|
||||||
import { SkeletonBuilder } from '@/lib/skeletons'
|
import { SkeletonBuilder } from '@/lib/skeletons'
|
||||||
import { calcLineActualSize, calcLineActualSize2, calcLinePlaneSize, toGeoJSON } from '@/util/qpolygon-utils'
|
import { calcLineActualSize, calcLinePlaneSize, toGeoJSON } from '@/util/qpolygon-utils'
|
||||||
import { QLine } from '@/components/fabric/QLine'
|
import { QLine } from '@/components/fabric/QLine'
|
||||||
import { getDegreeByChon } from '@/util/canvas-util'
|
import { getDegreeByChon } from '@/util/canvas-util'
|
||||||
import Big from 'big.js'
|
import Big from 'big.js'
|
||||||
@ -1805,7 +1805,7 @@ function processGableEdge(edgeResult, baseLines, skeletonLines, selectBaseLine,
|
|||||||
function isOuterEdge(p1, p2, edges) {
|
function isOuterEdge(p1, p2, edges) {
|
||||||
const tolerance = 0.1;
|
const tolerance = 0.1;
|
||||||
return edges.some(edge => {
|
return edges.some(edge => {
|
||||||
const lineStart = { x: edge.Begin.X, y: edge.Begin.Y }
|
const lineStart = { x: edge.Begin.X, y: edge.Begin.Y };
|
||||||
const lineEnd = { x: edge.End.X, y: edge.End.Y };
|
const lineEnd = { x: edge.End.X, y: edge.End.Y };
|
||||||
const forwardMatch = Math.abs(lineStart.x - p1.x) < tolerance && Math.abs(lineStart.y - p1.y) < tolerance && Math.abs(lineEnd.x - p2.x) < tolerance && Math.abs(lineEnd.y - p2.y) < tolerance;
|
const forwardMatch = Math.abs(lineStart.x - p1.x) < tolerance && Math.abs(lineStart.y - p1.y) < tolerance && Math.abs(lineEnd.x - p2.x) < tolerance && Math.abs(lineEnd.y - p2.y) < tolerance;
|
||||||
const backwardMatch = Math.abs(lineStart.x - p2.x) < tolerance && Math.abs(lineStart.y - p2.y) < tolerance && Math.abs(lineEnd.x - p1.x) < tolerance && Math.abs(lineEnd.y - p1.y) < tolerance;
|
const backwardMatch = Math.abs(lineStart.x - p2.x) < tolerance && Math.abs(lineStart.y - p2.y) < tolerance && Math.abs(lineEnd.x - p1.x) < tolerance && Math.abs(lineEnd.y - p1.y) < tolerance;
|
||||||
@ -1848,7 +1848,7 @@ function addRawLine(id, skeletonLines, p1, p2, lineType, color, width, pitch, is
|
|||||||
p2,
|
p2,
|
||||||
attributes: {
|
attributes: {
|
||||||
roofId: id,
|
roofId: id,
|
||||||
actualSize: (isDiagonal) ? calcLineActualSize2(
|
actualSize: (isDiagonal) ? calcLineActualSize(
|
||||||
{
|
{
|
||||||
x1: p1.x,
|
x1: p1.x,
|
||||||
y1: p1.y,
|
y1: p1.y,
|
||||||
@ -1869,7 +1869,7 @@ function addRawLine(id, skeletonLines, p1, p2, lineType, color, width, pitch, is
|
|||||||
};
|
};
|
||||||
|
|
||||||
skeletonLines.push(newLine);
|
skeletonLines.push(newLine);
|
||||||
console.log('skeletonLines', skeletonLines);
|
//console.log('skeletonLines', skeletonLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user