dev #162

Merged
ysCha merged 2 commits from dev into dev-deploy 2025-06-27 12:40:43 +09:00
2 changed files with 45 additions and 5 deletions

View File

@ -133,7 +133,7 @@ export function useModuleBasicSetting(tabNum) {
const offsetObjects = moduleSelectionData.roofConstructions.find((item) => item.addRoof.index === roofIndex)
roof.lines.forEach((line) => {
line.attributes = { ...line.attributes, offset: getOffset(offsetObjects.addRoof, line.attributes.type, roof.pitch, roof.from) }
line.attributes = { ...line.attributes, offset: getOffset(offsetObjects.addRoof, line, roof.pitch, roof.from) }
})
//배치면 설치 영역
makeModuleInstArea(roof, detail)
@ -167,7 +167,7 @@ export function useModuleBasicSetting(tabNum) {
}
}
const getOffset = (data, type, pitch, from = '') => {
const getOffset = (data, line, pitch, from = '') => {
const degree = getDegreeByChon(pitch) //각도
// 계산 값
@ -185,15 +185,24 @@ export function useModuleBasicSetting(tabNum) {
return numerator / denominator
}
const point1 = { x: line.x1, y: line.y1 }
const point2 = { x: line.x2, y: line.y2 }
let isDiagonal = false // 대각선 있는지 확인
const angle = calculateAngle(point1, point2) //선의 각도 계산
if (!(Math.abs(angle) === 0 || Math.abs(angle) === 180 || Math.abs(angle) === 90)) {
isDiagonal = true
}
//경사 신장률은 1 / cos쎄타
const calculateHeightRate = 1 / Math.cos((degree * Math.PI) / 180)
const calculateValue = calculateHeightRate / calculateExpression(degree)
const eavesResult = from === 'roofCover' ? (data.eavesMargin * Math.cos((degree * Math.PI) / 180)) / 10 : data.eavesMargin / 10
const ridgeResult = from === 'roofCover' ? (data.ridgeMargin * Math.cos((degree * Math.PI) / 180)) / 10 : data.ridgeMargin / 10
const kerabaMargin = from === 'roofCover' ? data.kerabaMargin / calculateValue / 10 : data.kerabaMargin / 10
const kerabaMargin = from === 'roofCover' && isDiagonal ? data.kerabaMargin / calculateValue / 10 : data.kerabaMargin / 10
switch (type) {
switch (line.attributes.type) {
case LINE_TYPE.WALLLINE.EAVES:
return eavesResult
case LINE_TYPE.WALLLINE.GABLE:

View File

@ -77,7 +77,8 @@ export function useCircuitTrestle(executeEffect = false) {
const getRoofSurfaceList = () => {
const roofSurfaceList = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
roofSurfaceList.sort((a, b) => a.left - b.left || b.top - a.top)
return roofSurfaceList
const result = roofSurfaceList
.map((obj) => {
return {
roofSurfaceId: obj.id,
@ -97,6 +98,36 @@ export function useCircuitTrestle(executeEffect = false) {
}
})
.filter((surface) => surface.moduleList.length > 0)
// result 배열에서 roofSurface 값을 기준으로 순서대로 정렬한다.
return groupSort(result)
}
const groupSort = (arr) => {
const result = []
const seen = new Set() // (roofSurface + "|" + roofSurfaceIncl)
let remaining = [...arr]
while (remaining.length > 0) {
const { roofSurface, roofSurfaceIncl } = remaining[0]
const key = `${roofSurface}|${roofSurfaceIncl}`
// 해당 그룹 추출
const group = remaining.filter((item) => item.roofSurface === roofSurface && item.roofSurfaceIncl === roofSurfaceIncl)
// 이미 처리했는지 체크 후 저장
if (!seen.has(key)) {
result.push(...group)
seen.add(key)
}
// remaining에서 제거
remaining = remaining.filter((item) => !(item.roofSurface === roofSurface && item.roofSurfaceIncl === roofSurfaceIncl))
}
return result
}
// 모듈 목록