Merge branch 'dev' of ssh://git.jetbrains.space/nalpari/q-cast-iii/qcast-front into dev

This commit is contained in:
김민식 2025-02-08 20:30:19 +09:00
commit af19411521
4 changed files with 122 additions and 66 deletions

View File

@ -841,6 +841,8 @@ export function useModuleBasicSetting(tabNum) {
const flowLines = getFlowLines(moduleSetupSurface, height) const flowLines = getFlowLines(moduleSetupSurface, height)
//육지붕이 아닐때만 넣는다 육지붕일땐 클릭 이벤트에 별도로 넣어놓음 //육지붕이 아닐때만 넣는다 육지붕일땐 클릭 이벤트에 별도로 넣어놓음
// let startPoint = flowLines.bottom
let startPoint = flowLines.bottom let startPoint = flowLines.bottom
const moduleArray = [] const moduleArray = []
@ -859,69 +861,76 @@ export function useModuleBasicSetting(tabNum) {
startPoint = { ...startPoint, y1: startPoint.y1 - heightMargin } startPoint = { ...startPoint, y1: startPoint.y1 - heightMargin }
} }
} }
} else { }
const maxLeftEndPoint = surfaceMaxLines.left.x1 //최 좌측 //밑에가 평면이면 좌측으로 붙여서 배치
const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측 if (flowLines.bottom.type === 'flat' && flowLines.left.type === 'curve') {
const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단 startPoint = flowLines.left
}
let totalLeftEndPoint = maxLeftEndPoint - startPoint.x1 const maxLeftEndPoint = surfaceMaxLines.left.x1 //최 좌측
let totalTopEndPoint = maxTopEndPoint - startPoint.y1 const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측
let totalWidth = Math.ceil(Math.abs(maxRightEndPoint - maxLeftEndPoint) / width) const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단
let diffLeftEndPoint = Math.abs(totalLeftEndPoint / width)
let diffTopEndPoint = Math.abs(totalTopEndPoint / height)
let startColPoint = Math.abs(width * Math.ceil(diffLeftEndPoint) - startPoint.x1)
let tempMaxWidth = isMaxSetup ? width / 2 : width //최대배치인지 확인하려고 넣음
if (isMaxSetup) totalWidth = totalWidth * 2 //최대배치시 2배로 늘려서 반씩 검사하기위함
for (let j = 0; j < diffTopEndPoint; j++) { let totalLeftEndPoint = maxLeftEndPoint - startPoint.x1
bottomMargin = j === 0 ? 0 : intvVer * j let totalTopEndPoint = maxTopEndPoint - startPoint.y1
for (let i = 0; i <= totalWidth; i++) { let totalWidth = Math.ceil(Math.abs(maxRightEndPoint - maxLeftEndPoint) / width)
leftMargin = i === 0 ? 0 : intvHor * i let diffLeftEndPoint = Math.abs(totalLeftEndPoint / width)
chidoriLength = 0 let diffTopEndPoint = Math.abs(totalTopEndPoint / height)
if (isChidori && !isMaxSetup) { let startColPoint = Math.abs(width * Math.ceil(diffLeftEndPoint) - startPoint.x1)
chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor let tempMaxWidth = isMaxSetup ? width / 2 : width //최대배치인지 확인하려고 넣음
} if (isMaxSetup) totalWidth = totalWidth * 2 //최대배치시 2배로 늘려서 반씩 검사하기위함
square = [ for (let j = 0; j < diffTopEndPoint; j++) {
[startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin], bottomMargin = j === 0 ? 0 : intvVer * j
[startColPoint + tempMaxWidth * i + width - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin], for (let i = 0; i <= totalWidth; i++) {
[startColPoint + tempMaxWidth * i + width - chidoriLength + leftMargin, startPoint.y1 - height * j - height - bottomMargin], leftMargin = i === 0 ? 0 : intvHor * i
[startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - height - bottomMargin], chidoriLength = 0
[startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin], if (isChidori && !isMaxSetup) {
] chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor
}
let squarePolygon = turf.polygon([square]) square = [
let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1) [startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin],
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] })) [startColPoint + tempMaxWidth * i + width - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin],
[startColPoint + tempMaxWidth * i + width - chidoriLength + leftMargin, startPoint.y1 - height * j - height - bottomMargin],
[startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - height - bottomMargin],
[startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin],
]
moduleOptions = { ...moduleOptions, fill: module.color, surfaceId: moduleSetupSurface.id, moduleInfo: module } let squarePolygon = turf.polygon([square])
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon }) let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, polygonToTurfPolygon(moduleSetupSurface, true)) moduleOptions = { ...moduleOptions, fill: module.color, surfaceId: moduleSetupSurface.id, moduleInfo: module }
let isDisjoint = checkModuleDisjointObjects(squarePolygon, containsBatchObjects) let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
if (disjointFromTrestle && isDisjoint) { let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, polygonToTurfPolygon(moduleSetupSurface, true))
if (index > 0) { let isDisjoint = checkModuleDisjointObjects(squarePolygon, containsBatchObjects)
setupModule.forEach((item) => {
const isOverlap = item.some((item2) => turf.booleanOverlap(squarePolygon, polygonToTurfPolygon(item2, true))) if (disjointFromTrestle && isDisjoint) {
if (!isOverlap) { if (index > 0) {
canvas?.add(tempModule) setupModule.forEach((item) => {
moduleSetupArray.push(tempModule) const isOverlap = item.some((item2) => turf.booleanOverlap(squarePolygon, polygonToTurfPolygon(item2, true)))
moduleArray.push(tempModule) if (!isOverlap) {
} canvas?.add(tempModule)
}) moduleSetupArray.push(tempModule)
} else { moduleArray.push(tempModule)
//최초 한번은 그냥 그린다 canvas.renderAll()
//겹치는지 확인해서 포함된 모듈만 그린다 }
canvas?.add(tempModule) })
moduleSetupArray.push(tempModule)
moduleArray.push(tempModule)
}
} else { } else {
//디버깅용 //최초 한번은 그냥 그린다
tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) //겹치는지 확인해서 포함된 모듈만 그린다
canvas?.add(tempModule) canvas?.add(tempModule)
moduleSetupArray.push(tempModule)
moduleArray.push(tempModule)
canvas.renderAll()
} }
} else {
//디버깅용
// tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 })
// canvas?.add(tempModule)
// canvas.renderAll()
} }
} }
} }
@ -965,6 +974,12 @@ export function useModuleBasicSetting(tabNum) {
} }
} }
console.log('flowLines.top', flowLines.top)
if (flowLines.left.type === 'flat') {
startPoint = flowLines.top
}
const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측 const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측
const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단 const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단
const maxBottomEndPoint = surfaceMaxLines.bottom.y1 //최하단 const maxBottomEndPoint = surfaceMaxLines.bottom.y1 //최하단
@ -1013,6 +1028,7 @@ export function useModuleBasicSetting(tabNum) {
canvas?.add(tempModule) canvas?.add(tempModule)
moduleSetupArray.push(tempModule) moduleSetupArray.push(tempModule)
moduleArray.push(tempModule) moduleArray.push(tempModule)
canvas.renderAll()
} }
}) })
} else { } else {
@ -1021,11 +1037,13 @@ export function useModuleBasicSetting(tabNum) {
canvas?.add(tempModule) canvas?.add(tempModule)
moduleSetupArray.push(tempModule) moduleSetupArray.push(tempModule)
moduleArray.push(tempModule) moduleArray.push(tempModule)
canvas.renderAll()
} }
} else { } else {
//디버깅용 //디버깅용
tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 })
canvas?.add(tempModule) // canvas?.add(tempModule)
// canvas.renderAll()
} }
} }
} }
@ -1129,6 +1147,7 @@ export function useModuleBasicSetting(tabNum) {
canvas?.add(tempModule) canvas?.add(tempModule)
moduleSetupArray.push(tempModule) moduleSetupArray.push(tempModule)
moduleArray.push(tempModule) moduleArray.push(tempModule)
canvas.renderAll()
} }
}) })
} else { } else {
@ -1137,11 +1156,13 @@ export function useModuleBasicSetting(tabNum) {
canvas?.add(tempModule) canvas?.add(tempModule)
moduleSetupArray.push(tempModule) moduleSetupArray.push(tempModule)
moduleArray.push(tempModule) moduleArray.push(tempModule)
canvas.renderAll()
} }
} else { } else {
//디버깅용 //디버깅용
tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 })
canvas?.add(tempModule) // canvas?.add(tempModule)
// canvas.renderAll()
} }
} }
} }
@ -1232,6 +1253,7 @@ export function useModuleBasicSetting(tabNum) {
canvas?.add(tempModule) canvas?.add(tempModule)
moduleSetupArray.push(tempModule) moduleSetupArray.push(tempModule)
moduleArray.push(tempModule) moduleArray.push(tempModule)
canvas.renderAll()
} }
}) })
} else { } else {
@ -1240,11 +1262,13 @@ export function useModuleBasicSetting(tabNum) {
canvas?.add(tempModule) canvas?.add(tempModule)
moduleSetupArray.push(tempModule) moduleSetupArray.push(tempModule)
moduleArray.push(tempModule) moduleArray.push(tempModule)
canvas.renderAll()
} }
} else { } else {
//디버깅용 //디버깅용
tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 }) // tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 })
canvas?.add(tempModule) // canvas?.add(tempModule)
// canvas.renderAll()
} }
} }
} }

View File

@ -24,7 +24,7 @@ import { calculateAngle, isSamePoint } from '@/util/qpolygon-utils'
import { POLYGON_TYPE } from '@/common/common' import { POLYGON_TYPE } from '@/common/common'
// 보조선 작성 // 보조선 작성
export function useAuxiliaryDrawing(id) { export function useAuxiliaryDrawing(id, isUseEffect = true) {
const canvas = useRecoilValue(canvasState) const canvas = useRecoilValue(canvasState)
const { addCanvasMouseEventListener, addDocumentEventListener, removeMouseLine, initEvent } = useEvent() const { addCanvasMouseEventListener, addDocumentEventListener, removeMouseLine, initEvent } = useEvent()
// const { addCanvasMouseEventListener, addDocumentEventListener, removeMouseLine, initEvent } = useContext(EventContext) // const { addCanvasMouseEventListener, addDocumentEventListener, removeMouseLine, initEvent } = useContext(EventContext)
@ -654,6 +654,8 @@ export function useAuxiliaryDrawing(id) {
selectable: true, selectable: true,
name: 'auxiliaryLine', name: 'auxiliaryLine',
isFixed: true, isFixed: true,
attributes: { ...line1.attributes },
parentId: line1.parentId,
}, },
) )
lineHistory.current.push(newLine) lineHistory.current.push(newLine)
@ -674,6 +676,8 @@ export function useAuxiliaryDrawing(id) {
selectable: false, selectable: false,
name: 'auxiliaryLine', name: 'auxiliaryLine',
isFixed: true, isFixed: true,
attributes: { ...line1.attributes },
parentId: line1.parentId,
}) })
lineHistory.current.push(newLine) lineHistory.current.push(newLine)
lineHistory.current = lineHistory.current.filter((history) => history !== line1) lineHistory.current = lineHistory.current.filter((history) => history !== line1)
@ -685,6 +689,8 @@ export function useAuxiliaryDrawing(id) {
selectable: false, selectable: false,
name: 'auxiliaryLine', name: 'auxiliaryLine',
isFixed: true, isFixed: true,
attributes: { ...line1.attributes },
parentId: line1.parentId,
}) })
lineHistory.current.push(newLine) lineHistory.current.push(newLine)
lineHistory.current = lineHistory.current.filter((history) => history !== line1) lineHistory.current = lineHistory.current.filter((history) => history !== line1)
@ -724,6 +730,8 @@ export function useAuxiliaryDrawing(id) {
selectable: true, selectable: true,
name: 'auxiliaryLine', name: 'auxiliaryLine',
isFixed: true, isFixed: true,
attributes: { ...line1.attributes },
parentId: line1.parentId,
intersectionPoint, intersectionPoint,
}) })
} else { } else {
@ -733,6 +741,8 @@ export function useAuxiliaryDrawing(id) {
selectable: true, selectable: true,
name: 'auxiliaryLine', name: 'auxiliaryLine',
isFixed: true, isFixed: true,
attributes: { ...line1.attributes },
parentId: line1.parentId,
intersectionPoint, intersectionPoint,
}) })
} }
@ -825,7 +835,7 @@ export function useAuxiliaryDrawing(id) {
//lineHistory.current에 있는 선들 중 startPoint와 endPoint가 겹치는 line은 제거 //lineHistory.current에 있는 선들 중 startPoint와 endPoint가 겹치는 line은 제거
// 겹치는 선 하나는 canvas에서 제거한다. // 겹치는 선 하나는 canvas에서 제거한다.
const tempLines = [...lineHistory.current] const tempLines = canvas.getObjects().filter((obj) => obj.name === 'auxiliaryLine' && !obj.isAuxiliaryFixed)
lineHistory.current = [] lineHistory.current = []
tempLines.forEach((line) => { tempLines.forEach((line) => {
if ( if (
@ -842,7 +852,7 @@ export function useAuxiliaryDrawing(id) {
lineHistory.current.push(line) lineHistory.current.push(line)
}) })
const innerLines = lineHistory.current const innerLines = lineHistory.current.filter((line) => line.name === 'auxiliaryLine' && line.visible)
roofBases.forEach((roofBase) => { roofBases.forEach((roofBase) => {
const tempPolygonPoints = [...roofBase.points].map((obj) => { const tempPolygonPoints = [...roofBase.points].map((obj) => {
@ -865,6 +875,7 @@ export function useAuxiliaryDrawing(id) {
actualSize: line.attributes?.actualSize ?? 0, actualSize: line.attributes?.actualSize ?? 0,
planeSize: line.getLength(), planeSize: line.getLength(),
} }
line.isAuxiliaryFixed = true
return true return true
} }
}) })

View File

@ -180,6 +180,12 @@ export function useContextMenu() {
fn: () => { fn: () => {
if (!currentObject) return if (!currentObject) return
const roof = canvas.getObjects().filter((obj) => obj.id === currentObject.attributes.roofId)[0] const roof = canvas.getObjects().filter((obj) => obj.id === currentObject.attributes.roofId)[0]
if (!roof) {
// 아직 innerLines로 세팅이 안되어있는 line인 경우 제거
canvas.remove(currentObject)
canvas.discardActiveObject()
return
}
const innerLines = roof.innerLines?.filter((line) => currentObject.id !== line.id) const innerLines = roof.innerLines?.filter((line) => currentObject.id !== line.id)
roof.innerLines = [...innerLines] roof.innerLines = [...innerLines]
canvas.remove(currentObject) canvas.remove(currentObject)
@ -221,6 +227,11 @@ export function useContextMenu() {
name: 'auxiliaryLine', name: 'auxiliaryLine',
attributes: { ...currentObject.attributes }, attributes: { ...currentObject.attributes },
}) })
if (!currentObject.attributes.roofId) {
return
}
canvas canvas
.getObjects() .getObjects()
.filter((obj) => obj.id === currentObject.attributes.roofId)[0] .filter((obj) => obj.id === currentObject.attributes.roofId)[0]
@ -235,11 +246,21 @@ export function useContextMenu() {
swalFire({ text: '지붕을 선택해주세요.' }) swalFire({ text: '지붕을 선택해주세요.' })
return return
} }
const innerLines = canvas.getObjects().filter((obj) => obj.id === currentObject.attributes.roofId)[0].innerLines const innerLines = canvas.getObjects().filter((obj) => obj.id === currentObject.attributes.roofId)[0]?.innerLines
innerLines.forEach((line) => { if (innerLines) {
innerLines.forEach((line) => {
canvas.remove(line)
})
innerLines.length = 0
}
// 확정되지 않은 보조선
const notFixedAuxiliaryLines = canvas.getObjects().filter((obj) => obj.name === 'auxiliaryLine' && !obj.isAuxiliaryFixed)
notFixedAuxiliaryLines.forEach((line) => {
canvas.remove(line) canvas.remove(line)
}) })
innerLines.length = 0
canvas.renderAll() canvas.renderAll()
}, },
}, },

View File

@ -2,7 +2,7 @@ import { atom } from 'recoil'
export const globalLocaleStore = atom({ export const globalLocaleStore = atom({
key: 'globalLocaleState', key: 'globalLocaleState',
default: 'ko', default: 'ja',
}) })
export const appMessageStore = atom({ export const appMessageStore = atom({