모듈 가대 설치 작업중
This commit is contained in:
parent
b872930043
commit
9554708dfa
@ -62,6 +62,8 @@ export function useModuleBasicSetting() {
|
||||
|
||||
//설치 범위 지정 클릭 이벤트
|
||||
const toggleSelection = (setupSurface) => {
|
||||
console.log('setupSurface', setupSurface)
|
||||
|
||||
const isExist = selectedModuleInstSurfaceArray.some((obj) => obj.parentId === setupSurface.parentId)
|
||||
//최초 선택일때
|
||||
if (!isExist) {
|
||||
@ -379,6 +381,7 @@ export function useModuleBasicSetting() {
|
||||
const autoModuleSetup = () => {
|
||||
initEvent()
|
||||
const moduleSetupSurfaces = moduleSetupSurface //선택 설치면
|
||||
|
||||
const notSelectedTrestlePolygons = canvas
|
||||
?.getObjects()
|
||||
.filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && !moduleSetupSurfaces.includes(obj)) //설치면이 아닌것
|
||||
@ -464,6 +467,13 @@ export function useModuleBasicSetting() {
|
||||
|
||||
const bbox = turf.bbox(difference)
|
||||
|
||||
let surfaceBbox = {
|
||||
minX: bbox[0],
|
||||
maxX: bbox[2],
|
||||
minY: bbox[1],
|
||||
maxY: bbox[3],
|
||||
}
|
||||
|
||||
let width = maxLengthLine.flowDirection === 'right' || maxLengthLine.flowDirection === 'left' ? 172.2 : 113.4
|
||||
let height = maxLengthLine.flowDirection === 'right' || maxLengthLine.flowDirection === 'left' ? 113.4 : 172.2
|
||||
|
||||
@ -475,16 +485,21 @@ export function useModuleBasicSetting() {
|
||||
const cols = Math.floor((bbox[2] - bbox[0]) / width)
|
||||
const rows = Math.floor((bbox[3] - bbox[1]) / height)
|
||||
|
||||
let startCoords = { x: 0, y: 0 }
|
||||
if (moduleSetupSurface.flowDirection === 'south') {
|
||||
startCoords = {
|
||||
x: surfaceBbox.minX,
|
||||
y: surfaceBbox.maxY,
|
||||
}
|
||||
}
|
||||
for (let col = 0; col <= cols; col++) {
|
||||
for (let row = 0; row <= rows; row++) {
|
||||
let x = 0,
|
||||
y = 0,
|
||||
square = [],
|
||||
margin = 0
|
||||
|
||||
if (moduleSetupSurface.flowDirection !== undefined) {
|
||||
//배치면 처림 방향이 정해져있는 경우
|
||||
|
||||
if (moduleSetupSurface.flowDirection === 'south' || moduleSetupSurface.flowDirection === 'north') {
|
||||
//남,북
|
||||
margin = (bbox[2] - bbox[0] - cols * width) / 2 //박스 끝에서 박스 시작값을 빼고 width와 계산된 cols를 곱한값을 뺀뒤 나누기 2 하면 가운데 배치됨
|
||||
@ -513,7 +528,6 @@ export function useModuleBasicSetting() {
|
||||
x = bbox[0] + col * width
|
||||
y = bbox[1] + row * height
|
||||
}
|
||||
|
||||
square = [
|
||||
[x, y],
|
||||
[x + width, y],
|
||||
@ -521,18 +535,14 @@ export function useModuleBasicSetting() {
|
||||
[x, y + height],
|
||||
[x, y],
|
||||
]
|
||||
|
||||
const squarePolygon = turf.polygon([square])
|
||||
const disjointFromTrestle =
|
||||
turf.booleanContains(turfModuleSetupSurface, squarePolygon) || turf.booleanWithin(squarePolygon, turfModuleSetupSurface)
|
||||
|
||||
if (disjointFromTrestle) {
|
||||
let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
|
||||
const points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
||||
|
||||
if (containsBatchObjects.length > 0) {
|
||||
let convertBatchObject
|
||||
|
||||
//도머가 있으면 적용되는 로직
|
||||
const isDisjoint = containsBatchObjects.every((batchObject) => {
|
||||
if (batchObject.type === 'group') {
|
||||
@ -540,10 +550,8 @@ export function useModuleBasicSetting() {
|
||||
} else {
|
||||
convertBatchObject = polygonToTurfPolygon(batchObject)
|
||||
}
|
||||
|
||||
return turf.booleanDisjoint(squarePolygon, convertBatchObject) //도머가 여러개일수있으므로 겹치는게 있다면...
|
||||
})
|
||||
|
||||
if (isDisjoint) {
|
||||
const tempModule = new QPolygon(points, {
|
||||
fill: '#BFFD9F',
|
||||
@ -621,6 +629,34 @@ export function useModuleBasicSetting() {
|
||||
return hull
|
||||
}
|
||||
|
||||
//도형의 내각을 구하는 로직
|
||||
function calculateInteriorAngles(polygon) {
|
||||
const points = polygon.get('points')
|
||||
const angles = []
|
||||
|
||||
for (let i = 0; i < points.length; i++) {
|
||||
// 현재 점과 이전 및 다음 점 정의
|
||||
const current = points[i]
|
||||
const prev = points[(i - 1 + points.length) % points.length]
|
||||
const next = points[(i + 1) % points.length]
|
||||
|
||||
// 벡터 계산
|
||||
const vecA = { x: prev.x - current.x, y: prev.y - current.y }
|
||||
const vecB = { x: next.x - current.x, y: next.y - current.y }
|
||||
|
||||
// 두 벡터 간 각도 계산
|
||||
const dotProduct = vecA.x * vecB.x + vecA.y * vecB.y
|
||||
const magA = Math.sqrt(vecA.x * vecA.x + vecA.y * vecA.y)
|
||||
const magB = Math.sqrt(vecB.x * vecB.x + vecB.y * vecB.y)
|
||||
const angleRad = Math.acos(dotProduct / (magA * magB))
|
||||
const angleDeg = (angleRad * 180) / Math.PI
|
||||
|
||||
// 내부 각도 저장
|
||||
angles.push(180 - angleDeg)
|
||||
}
|
||||
return angles
|
||||
}
|
||||
|
||||
return {
|
||||
makeModuleInstArea,
|
||||
manualModuleSetup,
|
||||
|
||||
@ -419,8 +419,8 @@ export function useSurfaceShapeBatch() {
|
||||
{
|
||||
fill: 'transparent',
|
||||
stroke: 'black', //black
|
||||
strokeWidth: 2,
|
||||
selectable: true,
|
||||
strokeWidth: 1,
|
||||
selectable: false,
|
||||
fontSize: 0,
|
||||
},
|
||||
)
|
||||
@ -429,6 +429,7 @@ export function useSurfaceShapeBatch() {
|
||||
const scale = (length1 - length2) / coord.x
|
||||
|
||||
tmpPolygon.set({ scaleX: scale })
|
||||
tmpPolygon.setViewLengthText(false)
|
||||
|
||||
pointsArray[0].x = 0
|
||||
pointsArray[0].y = length3 //바닥면부터 시작하게
|
||||
@ -584,18 +585,6 @@ export function useSurfaceShapeBatch() {
|
||||
text: '배치면 내용을 전부 삭제하시겠습니까?',
|
||||
type: 'confirm',
|
||||
confirmFn: () => {
|
||||
// canvas?.getObjects().forEach((obj) => {
|
||||
// if (
|
||||
// obj.name === POLYGON_TYPE.ROOF ||
|
||||
// obj.name === BATCH_TYPE.OPENING ||
|
||||
// obj.name === BATCH_TYPE.SHADOW ||
|
||||
// obj.name === BATCH_TYPE.TRIANGLE_DORMER ||
|
||||
// obj.name === BATCH_TYPE.PENTAGON_DORMER ||
|
||||
// obj.name === 'lengthText'
|
||||
// ) {
|
||||
// canvas?.remove(obj)
|
||||
// }
|
||||
// })
|
||||
canvas.clear()
|
||||
swalFire({ text: '삭제 완료 되었습니다.' })
|
||||
},
|
||||
@ -661,34 +650,6 @@ export function useSurfaceShapeBatch() {
|
||||
return groupObjectsArray
|
||||
}
|
||||
|
||||
function getAllRelatedObjects(id) {
|
||||
const ult = []
|
||||
const map = new Map()
|
||||
|
||||
// Create a map of objects by their id
|
||||
canvas.getObjects().forEach((obj) => {
|
||||
map.set(obj.id, obj)
|
||||
})
|
||||
|
||||
// Helper function to recursively find all related objects
|
||||
function findRelatedObjects(id) {
|
||||
const obj = map.get(id)
|
||||
if (obj) {
|
||||
result.push(obj)
|
||||
canvas.getObjects().forEach((o) => {
|
||||
if (o.parentId === id) {
|
||||
findRelatedObjects(o.id)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Start the search with the given parentId
|
||||
findRelatedObjects(id)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
const moveSurfaceShapeBatch = () => {
|
||||
const roof = canvas.getActiveObject()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user