모듈 회로, 육지붕 회전 로직 추가 작업
This commit is contained in:
parent
f65c34a7ad
commit
0cee2ec00d
@ -9,17 +9,16 @@ import { useEvent } from '@/hooks/useEvent'
|
|||||||
const PitchPlacement = forwardRef((props, refs) => {
|
const PitchPlacement = forwardRef((props, refs) => {
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const [setupLocation, setSetupLocation] = useState('south')
|
const [setupLocation, setSetupLocation] = useState('south')
|
||||||
const { flatRoofMakeModuleInstArea } = useModuleBasicSetting()
|
const { makeModuleInstArea } = useModuleBasicSetting()
|
||||||
const canvas = useRecoilValue(canvasState)
|
const canvas = useRecoilValue(canvasState)
|
||||||
const { initEvent } = useEvent()
|
const { initEvent } = useEvent()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
flatRoofMakeModuleInstArea(setupLocation)
|
makeModuleInstArea()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleChangeSetupLocation()
|
handleChangeSetupLocation()
|
||||||
flatRoofMakeModuleInstArea(setupLocation)
|
|
||||||
}, [setupLocation])
|
}, [setupLocation])
|
||||||
|
|
||||||
const moduleData = {
|
const moduleData = {
|
||||||
@ -57,9 +56,9 @@ const PitchPlacement = forwardRef((props, refs) => {
|
|||||||
return null
|
return null
|
||||||
} else {
|
} else {
|
||||||
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) //모듈설치면를 가져옴
|
||||||
|
|
||||||
moduleSetupSurfaces.forEach((surface, index) => {
|
moduleSetupSurfaces.forEach((surface, index) => {
|
||||||
const excretaLine = surface.lines
|
const excretaLine = surface.lines
|
||||||
|
|
||||||
excretaLine.forEach((line) => {
|
excretaLine.forEach((line) => {
|
||||||
line.set({
|
line.set({
|
||||||
stroke: '#642EFB',
|
stroke: '#642EFB',
|
||||||
@ -73,7 +72,6 @@ const PitchPlacement = forwardRef((props, refs) => {
|
|||||||
excretaLine.forEach((obj) => obj.set({ stroke: '#642EFB', isSelected: false }))
|
excretaLine.forEach((obj) => obj.set({ stroke: '#642EFB', isSelected: false }))
|
||||||
if (!line.isSelected) {
|
if (!line.isSelected) {
|
||||||
line.set({ stroke: 'red', isSelected: true })
|
line.set({ stroke: 'red', isSelected: true })
|
||||||
surface.fire('mousedown')
|
|
||||||
} else {
|
} else {
|
||||||
line.set({ stroke: '#642EFB', isSelected: false })
|
line.set({ stroke: '#642EFB', isSelected: false })
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,7 +52,7 @@ export function useModuleBasicSetting() {
|
|||||||
const makeModuleInstArea = () => {
|
const makeModuleInstArea = () => {
|
||||||
//지붕 객체 반환
|
//지붕 객체 반환
|
||||||
const roofs = canvas.getObjects().filter((obj) => obj.name === 'roof')
|
const roofs = canvas.getObjects().filter((obj) => obj.name === 'roof')
|
||||||
let offsetLength = -20
|
let offsetLength = canvasSetting.roofSizeSet === 3 ? -90 : -20
|
||||||
|
|
||||||
if (!roofs) {
|
if (!roofs) {
|
||||||
return
|
return
|
||||||
@ -97,6 +97,8 @@ export function useModuleBasicSetting() {
|
|||||||
setupSurface.setViewLengthText(false)
|
setupSurface.setViewLengthText(false)
|
||||||
canvas.add(setupSurface) //모듈설치면 만들기
|
canvas.add(setupSurface) //모듈설치면 만들기
|
||||||
|
|
||||||
|
//육지붕이 아닐때만 넣는다 육지붕일땐 클릭 이벤트에 별도로 넣어놓음
|
||||||
|
if (canvasSetting.roofSizeSet !== 3) {
|
||||||
const flowLines = {
|
const flowLines = {
|
||||||
bottom: bottomTopFlowLine(setupSurface).find((obj) => obj.target === 'bottom'),
|
bottom: bottomTopFlowLine(setupSurface).find((obj) => obj.target === 'bottom'),
|
||||||
top: bottomTopFlowLine(setupSurface).find((obj) => obj.target === 'top'),
|
top: bottomTopFlowLine(setupSurface).find((obj) => obj.target === 'top'),
|
||||||
@ -105,117 +107,8 @@ export function useModuleBasicSetting() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupSurface.set({ flowLines: flowLines })
|
setupSurface.set({ flowLines: flowLines })
|
||||||
|
|
||||||
//지붕면 선택 금지
|
|
||||||
roof.set({
|
|
||||||
selectable: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
//모듈설치면 클릭이벤트
|
|
||||||
addTargetMouseEventListener('mousedown', setupSurface, function () {
|
|
||||||
toggleSelection(setupSurface)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const flatRoofMakeModuleInstArea = (flatBatchType) => {
|
|
||||||
//지붕 객체 반환
|
|
||||||
|
|
||||||
const moduleSetupSurfaces = canvas?.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) //모듈설치면를 가져옴
|
|
||||||
const roofs = canvas.getObjects().filter((obj) => obj.name === 'roof')
|
|
||||||
let offsetLength = -90
|
|
||||||
|
|
||||||
if (!roofs) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
roofs.forEach((roof) => {
|
|
||||||
const isExistSurface = canvas.getObjects().find((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.parentId === roof.id)
|
|
||||||
if (isExistSurface) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setSurfaceShapePattern(roof, roofDisplay.column, true) //패턴 변경
|
|
||||||
const offsetPoints = offsetPolygon(roof.points, offsetLength) //안쪽 offset
|
|
||||||
//모듈설치영역?? 생성
|
|
||||||
|
|
||||||
const surfaceId = uuidv4()
|
|
||||||
|
|
||||||
let setupSurface = new QPolygon(offsetPoints, {
|
|
||||||
stroke: 'red',
|
|
||||||
fill: 'transparent',
|
|
||||||
strokeDashArray: [10, 4],
|
|
||||||
strokeWidth: 1,
|
|
||||||
lockMovementX: true,
|
|
||||||
lockMovementY: true,
|
|
||||||
lockRotation: true,
|
|
||||||
lockScalingX: true,
|
|
||||||
lockScalingY: true,
|
|
||||||
selectable: true,
|
|
||||||
parentId: roof.id, //가대 폴리곤의 임시 인덱스를 넣어줌
|
|
||||||
name: POLYGON_TYPE.MODULE_SETUP_SURFACE,
|
|
||||||
flowDirection: roof.direction,
|
|
||||||
direction: roof.direction,
|
|
||||||
flipX: roof.flipX,
|
|
||||||
flipY: roof.flipY,
|
|
||||||
surfaceId: surfaceId,
|
|
||||||
originX: 'center',
|
|
||||||
originY: 'center',
|
|
||||||
modules: [],
|
|
||||||
})
|
|
||||||
|
|
||||||
setupSurface.setViewLengthText(false)
|
|
||||||
canvas.add(setupSurface) //모듈설치면 만들기
|
|
||||||
|
|
||||||
//남쪽 선택
|
|
||||||
if (flatBatchType === 'excreta') {
|
|
||||||
//변별로 선택
|
|
||||||
const excretaLines = canvas.getObjects().filter((obj) => obj.name === 'flatExcretaLine')
|
|
||||||
excretaLines.forEach((obj) => {
|
|
||||||
if (obj.isSelected === true) {
|
|
||||||
const points1 = { x: obj.x1, y: obj.y1 }
|
|
||||||
const points2 = { x: obj.x2, y: obj.y2 }
|
|
||||||
const angle = calculateAngle(points1, points2)
|
|
||||||
|
|
||||||
roof.angle = -angle
|
|
||||||
setupSurface.angle = -angle
|
|
||||||
roof.fire('modified')
|
|
||||||
setupSurface.fire('modified')
|
|
||||||
}
|
|
||||||
canvas.remove(obj)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
roof.angle = -compasDeg
|
|
||||||
setupSurface.angle = -compasDeg
|
|
||||||
}
|
|
||||||
canvas.renderAll()
|
|
||||||
|
|
||||||
let currentPoints = setupSurface.getCurrentPoints()
|
|
||||||
let lines = []
|
|
||||||
|
|
||||||
for (let i = 0; i < currentPoints.length; i++) {
|
|
||||||
const start = currentPoints[i]
|
|
||||||
const end = currentPoints[(i + 1) % currentPoints.length]
|
|
||||||
const line = new QLine([start.x, start.y, end.x, end.y], {})
|
|
||||||
lines.push(line)
|
|
||||||
}
|
|
||||||
|
|
||||||
setupSurface.lines.forEach((targetLine, index) => {
|
|
||||||
targetLine.x1 = lines[index].x1
|
|
||||||
targetLine.y1 = lines[index].line.y1
|
|
||||||
targetLine.x2 = lines[index].line.x2
|
|
||||||
targetLine.y2 = lines[index].line.y2
|
|
||||||
})
|
|
||||||
|
|
||||||
const flowLines = {
|
|
||||||
bottom: bottomTopFlowLine(setupSurface).find((obj) => obj.target === 'bottom'),
|
|
||||||
top: bottomTopFlowLine(setupSurface).find((obj) => obj.target === 'top'),
|
|
||||||
left: leftRightFlowLine(setupSurface).find((obj) => obj.target === 'left'),
|
|
||||||
right: leftRightFlowLine(setupSurface).find((obj) => obj.target === 'right'),
|
|
||||||
}
|
|
||||||
|
|
||||||
setupSurface.set({ flowLines: flowLines })
|
|
||||||
|
|
||||||
//지붕면 선택 금지
|
//지붕면 선택 금지
|
||||||
roof.set({
|
roof.set({
|
||||||
selectable: false,
|
selectable: false,
|
||||||
@ -1420,8 +1313,8 @@ export function useModuleBasicSetting() {
|
|||||||
strokeWidth: 1,
|
strokeWidth: 1,
|
||||||
selectable: true,
|
selectable: true,
|
||||||
})
|
})
|
||||||
canvas?.add(finalLine)
|
// canvas?.add(finalLine)
|
||||||
canvas?.renderAll()
|
// canvas?.renderAll()
|
||||||
|
|
||||||
let rtnObj
|
let rtnObj
|
||||||
//평평하면
|
//평평하면
|
||||||
@ -1543,8 +1436,8 @@ export function useModuleBasicSetting() {
|
|||||||
strokeWidth: 1,
|
strokeWidth: 1,
|
||||||
selectable: true,
|
selectable: true,
|
||||||
})
|
})
|
||||||
canvas?.add(finalLine)
|
// canvas?.add(finalLine)
|
||||||
canvas?.renderAll()
|
// canvas?.renderAll()
|
||||||
|
|
||||||
let rtnObj
|
let rtnObj
|
||||||
//평평하면
|
//평평하면
|
||||||
@ -1695,6 +1588,37 @@ export function useModuleBasicSetting() {
|
|||||||
let flowDirection
|
let flowDirection
|
||||||
let trestlePolygon
|
let trestlePolygon
|
||||||
|
|
||||||
|
//남쪽 선택
|
||||||
|
if (flatBatchType === 'excreta') {
|
||||||
|
//변별로 선택
|
||||||
|
const excretaLines = canvas.getObjects().filter((obj) => obj.name === 'flatExcretaLine')
|
||||||
|
excretaLines.forEach((obj) => {
|
||||||
|
if (obj.isSelected === true) {
|
||||||
|
const points1 = { x: obj.x1, y: obj.y1 }
|
||||||
|
const points2 = { x: obj.x2, y: obj.y2 }
|
||||||
|
const angle = calculateAngle(points1, points2)
|
||||||
|
|
||||||
|
//변별로 선택으로 되어있을때 모듈면을 회전시키기
|
||||||
|
const targetdSurface = moduleSetupSurfaces.filter((surface) => surface.surfaceId === obj.surfaceId)[0]
|
||||||
|
targetdSurface.angle = -angle
|
||||||
|
//변별로 선택되어있는 지붕도 회전시키기
|
||||||
|
const targetRoof = canvas.getObjects().filter((roof) => roof.name === POLYGON_TYPE.ROOF && roof.id === targetdSurface.parentId)[0]
|
||||||
|
targetRoof.angle = -angle
|
||||||
|
|
||||||
|
targetRoof.fire('modified')
|
||||||
|
targetdSurface.fire('modified')
|
||||||
|
}
|
||||||
|
canvas.remove(obj)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
moduleSetupSurfaces.forEach((surface) => {
|
||||||
|
const targetRoof = canvas.getObjects().filter((roof) => roof.name === POLYGON_TYPE.ROOF && roof.id === surface.parentId)[0]
|
||||||
|
if (targetRoof) targetRoof.angle = -compasDeg
|
||||||
|
surface.angle = -compasDeg
|
||||||
|
})
|
||||||
|
}
|
||||||
|
canvas.renderAll()
|
||||||
|
|
||||||
addCanvasMouseEventListener('mouse:move', (e) => {
|
addCanvasMouseEventListener('mouse:move', (e) => {
|
||||||
//마우스 이벤트 삭제 후 재추가
|
//마우스 이벤트 삭제 후 재추가
|
||||||
const mousePoint = canvas.getPointer(e.e)
|
const mousePoint = canvas.getPointer(e.e)
|
||||||
@ -1746,129 +1670,129 @@ export function useModuleBasicSetting() {
|
|||||||
/**
|
/**
|
||||||
* 스냅기능
|
* 스냅기능
|
||||||
*/
|
*/
|
||||||
// let snapDistance = 10
|
let snapDistance = 10
|
||||||
// let cellSnapDistance = 20
|
let cellSnapDistance = 20
|
||||||
|
|
||||||
// const trestleLeft = moduleSetupSurfaces[i].left
|
const trestleLeft = moduleSetupSurfaces[i].left
|
||||||
// const trestleTop = moduleSetupSurfaces[i].top
|
const trestleTop = moduleSetupSurfaces[i].top
|
||||||
// const trestleRight = trestleLeft + moduleSetupSurfaces[i].width * moduleSetupSurfaces[i].scaleX
|
const trestleRight = trestleLeft + moduleSetupSurfaces[i].width * moduleSetupSurfaces[i].scaleX
|
||||||
// const trestleBottom = trestleTop + moduleSetupSurfaces[i].height * moduleSetupSurfaces[i].scaleY
|
const trestleBottom = trestleTop + moduleSetupSurfaces[i].height * moduleSetupSurfaces[i].scaleY
|
||||||
// const bigCenterY = (trestleTop + trestleTop + moduleSetupSurfaces[i].height) / 2
|
const bigCenterY = (trestleTop + trestleTop + moduleSetupSurfaces[i].height) / 2
|
||||||
|
|
||||||
// // 작은 폴리곤의 경계 좌표 계산
|
// 작은 폴리곤의 경계 좌표 계산
|
||||||
// const smallLeft = tempModule.left
|
const smallLeft = tempModule.left
|
||||||
// const smallTop = tempModule.top
|
const smallTop = tempModule.top
|
||||||
// const smallRight = smallLeft + tempModule.width * tempModule.scaleX
|
const smallRight = smallLeft + tempModule.width * tempModule.scaleX
|
||||||
// const smallBottom = smallTop + tempModule.height * tempModule.scaleY
|
const smallBottom = smallTop + tempModule.height * tempModule.scaleY
|
||||||
// const smallCenterX = smallLeft + (tempModule.width * tempModule.scaleX) / 2
|
const smallCenterX = smallLeft + (tempModule.width * tempModule.scaleX) / 2
|
||||||
// const smallCenterY = smallTop + (tempModule.height * tempModule.scaleX) / 2
|
const smallCenterY = smallTop + (tempModule.height * tempModule.scaleX) / 2
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * 미리 깔아놓은 셀이 있을때 셀에 흡착됨
|
* 미리 깔아놓은 셀이 있을때 셀에 흡착됨
|
||||||
// */
|
*/
|
||||||
// if (manualDrawModules) {
|
if (manualDrawModules) {
|
||||||
// manualDrawModules.forEach((cell) => {
|
manualDrawModules.forEach((cell) => {
|
||||||
// const holdCellLeft = cell.left
|
const holdCellLeft = cell.left
|
||||||
// const holdCellTop = cell.top
|
const holdCellTop = cell.top
|
||||||
// const holdCellRight = holdCellLeft + cell.width * cell.scaleX
|
const holdCellRight = holdCellLeft + cell.width * cell.scaleX
|
||||||
// const holdCellBottom = holdCellTop + cell.height * cell.scaleY
|
const holdCellBottom = holdCellTop + cell.height * cell.scaleY
|
||||||
// const holdCellCenterX = holdCellLeft + (cell.width * cell.scaleX) / 2
|
const holdCellCenterX = holdCellLeft + (cell.width * cell.scaleX) / 2
|
||||||
// const holdCellCenterY = holdCellTop + (cell.height * cell.scaleY) / 2
|
const holdCellCenterY = holdCellTop + (cell.height * cell.scaleY) / 2
|
||||||
|
|
||||||
// //설치된 셀에 좌측에 스냅
|
//설치된 셀에 좌측에 스냅
|
||||||
// if (Math.abs(smallRight - holdCellLeft) < snapDistance) {
|
if (Math.abs(smallRight - holdCellLeft) < snapDistance) {
|
||||||
// tempModule.left = holdCellLeft - width - 0.5
|
tempModule.left = holdCellLeft - width - 1
|
||||||
// }
|
}
|
||||||
|
|
||||||
// //설치된 셀에 우측에 스냅
|
//설치된 셀에 우측에 스냅
|
||||||
// if (Math.abs(smallLeft - holdCellRight) < snapDistance) {
|
if (Math.abs(smallLeft - holdCellRight) < snapDistance) {
|
||||||
// tempModule.left = holdCellRight + 0.5
|
tempModule.left = holdCellRight + 0.5
|
||||||
// }
|
}
|
||||||
|
|
||||||
// //설치된 셀에 위쪽에 스냅
|
//설치된 셀에 위쪽에 스냅
|
||||||
// if (Math.abs(smallBottom - holdCellTop) < snapDistance) {
|
if (Math.abs(smallBottom - holdCellTop) < snapDistance) {
|
||||||
// tempModule.top = holdCellTop - height - 0.5
|
tempModule.top = holdCellTop - height - 1
|
||||||
// }
|
}
|
||||||
|
|
||||||
// //설치된 셀에 밑쪽에 스냅
|
//설치된 셀에 밑쪽에 스냅
|
||||||
// if (Math.abs(smallTop - holdCellBottom) < snapDistance) {
|
if (Math.abs(smallTop - holdCellBottom) < snapDistance) {
|
||||||
// tempModule.top = holdCellBottom + 0.5
|
tempModule.top = holdCellBottom + 1
|
||||||
// }
|
}
|
||||||
// //가운데 -> 가운데
|
//가운데 -> 가운데
|
||||||
// if (Math.abs(smallCenterX - holdCellCenterX) < cellSnapDistance) {
|
if (Math.abs(smallCenterX - holdCellCenterX) < cellSnapDistance) {
|
||||||
// tempModule.left = holdCellCenterX - width / 2
|
tempModule.left = holdCellCenterX - width / 2
|
||||||
// }
|
}
|
||||||
// //왼쪽 -> 가운데
|
//왼쪽 -> 가운데
|
||||||
// if (Math.abs(smallLeft - holdCellCenterX) < cellSnapDistance) {
|
if (Math.abs(smallLeft - holdCellCenterX) < cellSnapDistance) {
|
||||||
// tempModule.left = holdCellCenterX
|
tempModule.left = holdCellCenterX
|
||||||
// }
|
}
|
||||||
// // 오른쪽 -> 가운데
|
// 오른쪽 -> 가운데
|
||||||
// if (Math.abs(smallRight - holdCellCenterX) < cellSnapDistance) {
|
if (Math.abs(smallRight - holdCellCenterX) < cellSnapDistance) {
|
||||||
// tempModule.left = holdCellCenterX - width
|
tempModule.left = holdCellCenterX - width
|
||||||
// }
|
}
|
||||||
// //세로 가운데 -> 가운데
|
//세로 가운데 -> 가운데
|
||||||
// if (Math.abs(smallCenterY - holdCellCenterY) < cellSnapDistance) {
|
if (Math.abs(smallCenterY - holdCellCenterY) < cellSnapDistance) {
|
||||||
// tempModule.top = holdCellCenterY - height / 2
|
tempModule.top = holdCellCenterY - height / 2
|
||||||
// }
|
}
|
||||||
// //위쪽 -> 가운데
|
//위쪽 -> 가운데
|
||||||
// if (Math.abs(smallTop - holdCellCenterY) < cellSnapDistance) {
|
if (Math.abs(smallTop - holdCellCenterY) < cellSnapDistance) {
|
||||||
// tempModule.top = holdCellCenterY
|
tempModule.top = holdCellCenterY
|
||||||
// }
|
}
|
||||||
// //아랫쪽 -> 가운데
|
//아랫쪽 -> 가운데
|
||||||
// if (Math.abs(smallBottom - holdCellCenterY) < cellSnapDistance) {
|
if (Math.abs(smallBottom - holdCellCenterY) < cellSnapDistance) {
|
||||||
// tempModule.top = holdCellCenterY - height
|
tempModule.top = holdCellCenterY - height
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // 위쪽 변에 스냅
|
// 위쪽 변에 스냅
|
||||||
// if (Math.abs(smallTop - trestleTop) < snapDistance) {
|
if (Math.abs(smallTop - trestleTop) < snapDistance) {
|
||||||
// tempModule.top = trestleTop
|
tempModule.top = trestleTop
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // 아래쪽 변에 스냅
|
// 아래쪽 변에 스냅
|
||||||
// if (Math.abs(smallTop + tempModule.height * tempModule.scaleY - (trestleTop + moduleSetupSurfaces[i].height)) < snapDistance) {
|
if (Math.abs(smallTop + tempModule.height * tempModule.scaleY - (trestleTop + moduleSetupSurfaces[i].height)) < snapDistance) {
|
||||||
// tempModule.top = trestleTop + moduleSetupSurfaces[i].height - tempModule.height * tempModule.scaleY
|
tempModule.top = trestleTop + moduleSetupSurfaces[i].height - tempModule.height * tempModule.scaleY
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // 왼쪽변에 스냅
|
// 왼쪽변에 스냅
|
||||||
// if (Math.abs(smallLeft - trestleLeft) < snapDistance) {
|
if (Math.abs(smallLeft - trestleLeft) < snapDistance) {
|
||||||
// tempModule.left = trestleLeft
|
tempModule.left = trestleLeft
|
||||||
// }
|
}
|
||||||
// //오른쪽 변에 스냅
|
//오른쪽 변에 스냅
|
||||||
// if (Math.abs(smallRight - trestleRight) < snapDistance) {
|
if (Math.abs(smallRight - trestleRight) < snapDistance) {
|
||||||
// tempModule.left = trestleRight - tempModule.width * tempModule.scaleX
|
tempModule.left = trestleRight - tempModule.width * tempModule.scaleX
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (flowDirection === 'south' || flowDirection === 'north') {
|
if (flowDirection === 'south' || flowDirection === 'north') {
|
||||||
// // 모듈왼쪽이 세로중앙선에 붙게 스냅
|
// 모듈왼쪽이 세로중앙선에 붙게 스냅
|
||||||
// if (Math.abs(smallLeft - (trestleLeft + moduleSetupSurfaces[i].width / 2)) < snapDistance) {
|
if (Math.abs(smallLeft - (trestleLeft + moduleSetupSurfaces[i].width / 2)) < snapDistance) {
|
||||||
// tempModule.left = trestleLeft + moduleSetupSurfaces[i].width / 2
|
tempModule.left = trestleLeft + moduleSetupSurfaces[i].width / 2
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // 모듈이 가운데가 세로중앙선에 붙게 스냅
|
// 모듈이 가운데가 세로중앙선에 붙게 스냅
|
||||||
// if (Math.abs(smallCenterX - (trestleLeft + moduleSetupSurfaces[i].width / 2)) < snapDistance) {
|
if (Math.abs(smallCenterX - (trestleLeft + moduleSetupSurfaces[i].width / 2)) < snapDistance) {
|
||||||
// tempModule.left = trestleLeft + moduleSetupSurfaces[i].width / 2 - (tempModule.width * tempModule.scaleX) / 2
|
tempModule.left = trestleLeft + moduleSetupSurfaces[i].width / 2 - (tempModule.width * tempModule.scaleX) / 2
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // 모듈오른쪽이 세로중앙선에 붙게 스냅
|
// 모듈오른쪽이 세로중앙선에 붙게 스냅
|
||||||
// if (Math.abs(smallRight - (trestleLeft + moduleSetupSurfaces[i].width / 2)) < snapDistance) {
|
if (Math.abs(smallRight - (trestleLeft + moduleSetupSurfaces[i].width / 2)) < snapDistance) {
|
||||||
// tempModule.left = trestleLeft + moduleSetupSurfaces[i].width / 2 - tempModule.width * tempModule.scaleX
|
tempModule.left = trestleLeft + moduleSetupSurfaces[i].width / 2 - tempModule.width * tempModule.scaleX
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// // 모듈이 가로중앙선에 스냅
|
// 모듈이 가로중앙선에 스냅
|
||||||
// if (Math.abs(smallTop + tempModule.height / 2 - bigCenterY) < snapDistance) {
|
if (Math.abs(smallTop + tempModule.height / 2 - bigCenterY) < snapDistance) {
|
||||||
// tempModule.top = bigCenterY - tempModule.height / 2
|
tempModule.top = bigCenterY - tempModule.height / 2
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (Math.abs(smallTop - (trestleTop + moduleSetupSurfaces[i].height / 2)) < snapDistance) {
|
if (Math.abs(smallTop - (trestleTop + moduleSetupSurfaces[i].height / 2)) < snapDistance) {
|
||||||
// tempModule.top = trestleTop + moduleSetupSurfaces[i].height / 2
|
tempModule.top = trestleTop + moduleSetupSurfaces[i].height / 2
|
||||||
// }
|
}
|
||||||
// // 모듈 밑면이 가로중앙선에 스냅
|
// 모듈 밑면이 가로중앙선에 스냅
|
||||||
// if (Math.abs(smallBottom - (trestleTop + moduleSetupSurfaces[i].height / 2)) < snapDistance) {
|
if (Math.abs(smallBottom - (trestleTop + moduleSetupSurfaces[i].height / 2)) < snapDistance) {
|
||||||
// tempModule.top = trestleTop + moduleSetupSurfaces[i].height / 2 - tempModule.height * tempModule.scaleY
|
tempModule.top = trestleTop + moduleSetupSurfaces[i].height / 2 - tempModule.height * tempModule.scaleY
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
tempModule.setCoords()
|
tempModule.setCoords()
|
||||||
canvas?.renderAll()
|
canvas?.renderAll()
|
||||||
@ -1952,10 +1876,10 @@ export function useModuleBasicSetting() {
|
|||||||
obj.name === BATCH_TYPE.SHADOW,
|
obj.name === BATCH_TYPE.SHADOW,
|
||||||
) //도머s 객체
|
) //도머s 객체
|
||||||
|
|
||||||
if (moduleSetupSurfaces.length === 0) {
|
// if (moduleSetupSurfaces.length === 0) {
|
||||||
alert('선택된 모듈 설치면이 없습니다.')
|
// alert('선택된 모듈 설치면이 없습니다.')
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
//어짜피 자동으로 누르면 선택안된데도 다 날아간다
|
//어짜피 자동으로 누르면 선택안된데도 다 날아간다
|
||||||
canvas.getObjects().forEach((obj) => {
|
canvas.getObjects().forEach((obj) => {
|
||||||
@ -1976,34 +1900,66 @@ export function useModuleBasicSetting() {
|
|||||||
const flatBatchType = placementFlatRef.setupLocation.current.value
|
const flatBatchType = placementFlatRef.setupLocation.current.value
|
||||||
|
|
||||||
//남쪽 선택
|
//남쪽 선택
|
||||||
// if (flatBatchType === 'excreta') {
|
if (flatBatchType === 'excreta') {
|
||||||
// //변별로 선택
|
//변별로 선택
|
||||||
// const excretaLines = canvas.getObjects().filter((obj) => obj.name === 'flatExcretaLine')
|
const excretaLines = canvas.getObjects().filter((obj) => obj.name === 'flatExcretaLine')
|
||||||
// excretaLines.forEach((obj) => {
|
excretaLines.forEach((obj) => {
|
||||||
// if (obj.isSelected === true) {
|
if (obj.isSelected === true) {
|
||||||
// const points1 = { x: obj.x1, y: obj.y1 }
|
const points1 = { x: obj.x1, y: obj.y1 }
|
||||||
// const points2 = { x: obj.x2, y: obj.y2 }
|
const points2 = { x: obj.x2, y: obj.y2 }
|
||||||
// const angle = calculateAngle(points1, points2)
|
const angle = calculateAngle(points1, points2)
|
||||||
|
|
||||||
// const targetdSurface = moduleSetupSurfaces.filter((surface) => surface.surfaceId === obj.surfaceId)[0]
|
// const targetdSurface = moduleSetupSurfaces.filter((surface) => surface.surfaceId === obj.surfaceId)[0]
|
||||||
// const targetRoof = canvas.getObjects().filter((roof) => roof.name === POLYGON_TYPE.ROOF && roof.id === targetdSurface.parentId)[0]
|
const targetSurface = canvas
|
||||||
|
.getObjects()
|
||||||
|
.filter((surface) => surface.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && surface.surfaceId === obj.surfaceId)[0]
|
||||||
|
const targetRoof = canvas.getObjects().filter((roof) => roof.name === POLYGON_TYPE.ROOF && roof.id === targetSurface.parentId)[0]
|
||||||
|
|
||||||
// targetRoof.angle = -angle
|
targetRoof.angle = -angle
|
||||||
// targetdSurface.angle = -angle
|
targetSurface.angle = -angle
|
||||||
|
|
||||||
// targetRoof.fire('modified')
|
targetRoof.fire('modified')
|
||||||
// targetdSurface.fire('modified')
|
targetSurface.fire('modified')
|
||||||
// }
|
moduleSetupSurfaces.push(targetSurface)
|
||||||
// canvas.remove(obj)
|
}
|
||||||
// })
|
canvas.remove(obj)
|
||||||
// } else {
|
})
|
||||||
// moduleSetupSurfaces.forEach((surface) => {
|
} else {
|
||||||
// const targetRoof = canvas.getObjects().filter((roof) => roof.name === POLYGON_TYPE.ROOF && roof.id === surface.parentId)[0]
|
moduleSetupSurfaces.forEach((surface) => {
|
||||||
// if (targetRoof) targetRoof.angle = -compasDeg
|
const targetRoof = canvas.getObjects().filter((roof) => roof.name === POLYGON_TYPE.ROOF && roof.id === surface.parentId)[0]
|
||||||
// surface.angle = -compasDeg
|
if (targetRoof) targetRoof.angle = -compasDeg
|
||||||
// })
|
surface.angle = -compasDeg
|
||||||
// }
|
})
|
||||||
// canvas.renderAll()
|
}
|
||||||
|
canvas.renderAll()
|
||||||
|
|
||||||
|
moduleSetupSurfaces.forEach((surface) => {
|
||||||
|
let currentPoints = surface.getCurrentPoints()
|
||||||
|
let lines = []
|
||||||
|
|
||||||
|
for (let i = 0; i < currentPoints.length; i++) {
|
||||||
|
const start = currentPoints[i]
|
||||||
|
const end = currentPoints[(i + 1) % currentPoints.length]
|
||||||
|
const line = new QLine([start.x, start.y, end.x, end.y], {})
|
||||||
|
lines.push(line)
|
||||||
|
}
|
||||||
|
|
||||||
|
surface.lines.forEach((targetLine, index) => {
|
||||||
|
targetLine.x1 = lines[index].x1
|
||||||
|
targetLine.y1 = lines[index].y1
|
||||||
|
targetLine.x2 = lines[index].x2
|
||||||
|
targetLine.y2 = lines[index].y2
|
||||||
|
})
|
||||||
|
|
||||||
|
const flowLines = {
|
||||||
|
bottom: bottomTopFlowLine(surface).find((obj) => obj.target === 'bottom'),
|
||||||
|
top: bottomTopFlowLine(surface).find((obj) => obj.target === 'top'),
|
||||||
|
left: leftRightFlowLine(surface).find((obj) => obj.target === 'left'),
|
||||||
|
right: leftRightFlowLine(surface).find((obj) => obj.target === 'right'),
|
||||||
|
}
|
||||||
|
|
||||||
|
surface.set({ flowLines: flowLines })
|
||||||
|
})
|
||||||
|
|
||||||
const moduleOptions = {
|
const moduleOptions = {
|
||||||
fill: '#BFFD9F',
|
fill: '#BFFD9F',
|
||||||
@ -2306,8 +2262,8 @@ export function useModuleBasicSetting() {
|
|||||||
//겹치는지 확인
|
//겹치는지 확인
|
||||||
if (isOverlap) {
|
if (isOverlap) {
|
||||||
//겹쳐있으면 삭제
|
//겹쳐있으면 삭제
|
||||||
// canvas?.remove(module)
|
canvas?.remove(module)
|
||||||
module.set({ fill: 'rgba(72, 161, 250, 0.4)', stroke: 'black', strokeWidth: 0.1 })
|
// module.set({ fill: 'rgba(72, 161, 250, 0.4)', stroke: 'black', strokeWidth: 0.1 })
|
||||||
canvas.renderAll()
|
canvas.renderAll()
|
||||||
setupedModules.splice(index, 1)
|
setupedModules.splice(index, 1)
|
||||||
return false
|
return false
|
||||||
@ -2334,6 +2290,5 @@ export function useModuleBasicSetting() {
|
|||||||
restoreModuleInstArea,
|
restoreModuleInstArea,
|
||||||
manualFlatroofModuleSetup,
|
manualFlatroofModuleSetup,
|
||||||
autoFlatroofModuleSetup,
|
autoFlatroofModuleSetup,
|
||||||
flatRoofMakeModuleInstArea,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user