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

# Conflicts:
#	src/hooks/useCirCuitTrestle.js
This commit is contained in:
김민식 2025-02-08 18:57:04 +09:00
commit e58c5b27f6
8 changed files with 157 additions and 156 deletions

View File

@ -185,6 +185,7 @@ export const SAVE_KEY = [
'moduleInfo',
'circuitNumber',
'circuit',
'onlyOffset',
]
export const OBJECT_PROTOTYPE = [fabric.Line.prototype, fabric.Polygon.prototype, fabric.Triangle.prototype]

View File

@ -5,7 +5,6 @@ import { checkedModuleState, currentCanvasPlanState } from '@/store/canvasAtom'
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
import { moduleSelectionDataState, selectedModuleState } from '@/store/selectedModuleOptions'
import { isObjectNotEmpty } from '@/util/common-utils'
import { useCanvasPopupStatusController } from '@/hooks/common/useCanvasPopupStatusController'
const Placement = forwardRef((props, refs) => {
const { getMessage } = useMessage()
@ -20,8 +19,7 @@ const Placement = forwardRef((props, refs) => {
const setCheckedModules = useSetRecoilState(checkedModuleState)
const moduleSelectionData = useRecoilValue(moduleSelectionDataState)
const { trigger: moduleSelectedDataTrigger } = useCanvasPopupStatusController(2)
const { makeModuleInitArea } = useModuleBasicSetting(3)
//
useEffect(() => {
@ -31,6 +29,7 @@ const Placement = forwardRef((props, refs) => {
if (isChidroriValue) {
setIsChidoriNotAble(true)
}
makeModuleInitArea(moduleSelectionData)
}
}, [])

View File

@ -31,7 +31,11 @@ export function useCanvasConfigInitialize() {
const flowTexts = canvas.getObjects().filter((obj) => obj.name === 'flowText')
if (basicSetting.roofAngleSet === 'slope') {
offsetTexts.forEach((obj) => {
obj.set({ text: `${!obj.originText ? '' : obj.originText + '-'}${obj.pitch}${angleUnit}` })
let text = `${!obj.originText ? '' : obj.originText}`
if (!obj.onlyOffset) {
text = text + `-∠${obj.pitch}${angleUnit}`
}
obj.set({ text: text })
})
flowTexts.forEach((obj) => {
obj.set({ text: `${!obj.originText ? '' : obj.originText + '-'}${obj.pitch}${pitchText}` })
@ -40,7 +44,11 @@ export function useCanvasConfigInitialize() {
if (basicSetting.roofAngleSet === 'flat') {
offsetTexts.forEach((obj) => {
obj.set({ text: `${!obj.originText ? '' : obj.originText + '-'}${getDegreeByChon(obj.pitch)}${angleUnit}` })
let text = `${!obj.originText ? '' : obj.originText}`
if (!obj.onlyOffset) {
text = text + `-∠${getDegreeByChon(obj.pitch)}${angleUnit}`
}
obj.set({ text: text })
})
flowTexts.forEach((obj) => {
obj.set({ text: `${!obj.originText ? '' : obj.originText + '-'}${getDegreeByChon(obj.pitch)}${pitchText}` })

View File

@ -19,7 +19,7 @@ import { moduleStatisticsState } from '@/store/circuitTrestleAtom'
import { moduleSelectionDataState, selectedModuleState } from '@/store/selectedModuleOptions'
import { useMasterController } from '@/hooks/common/useMasterController'
import { v4 as uuidv4 } from 'uuid'
import { useCircuitTrestle } from '@/hooks/useCirCuitTrestle'
// import { useCircuitTrestle } from '@/hooks/useCirCuitTrestle'
import { isObjectNotEmpty } from '@/util/common-utils'
export function useModuleBasicSetting(tabNum) {
@ -29,7 +29,7 @@ export function useModuleBasicSetting(tabNum) {
const [moduleSetupSurface, setModuleSetupSurface] = useRecoilState(moduleSetupSurfaceState)
const [moduleIsSetup, setModuleIsSetup] = useRecoilState(moduleIsSetupState)
const { addCanvasMouseEventListener, initEvent, removeMouseEvent, addTargetMouseEventListener } = useEvent()
const { setModuleStatisticsData } = useCircuitTrestle()
// const { setModuleStatisticsData } = useCircuitTrestle()
const { swalFire } = useSwal()
const compasDeg = useRecoilValue(compasDegAtom)
@ -52,6 +52,7 @@ export function useModuleBasicSetting(tabNum) {
useEffect(() => {
// console.log('basicSetting', basicSetting)
if (canvas) {
//드래그 여부
// canvas.selection = true
@ -62,17 +63,13 @@ export function useModuleBasicSetting(tabNum) {
// const { addTargetMouseEventListener, addCanvasMouseEventListener, initEvent } = useContext(EventContext)
//모듈 선택에서 선택된 값들 넘어옴
useEffect(() => {
console.log('moduleSelectionData', moduleSelectionData)
console.log('canvasSetting.roofSizeSet', canvasSetting.roofSizeSet)
if (isObjectNotEmpty(moduleSelectionData)) {
const makeModuleInitArea = () => {
if (isObjectNotEmpty(moduleSelectionData) && tabNum === 3) {
if (canvasSetting.roofSizeSet !== '3') {
const common = moduleSelectionData.common
const roofConstructions = moduleSelectionData.roofConstructions
console.log('roofConstructions', roofConstructions)
// console.log('roofConstructions', roofConstructions)
if (roofConstructions && roofConstructions.length > 0) {
const listParams = roofConstructions.map((item) => {
@ -109,7 +106,10 @@ export function useModuleBasicSetting(tabNum) {
})
}
}
}, [moduleSelectionData])
}
// console.log('moduleSelectionData', moduleSelectionData)
// console.log('canvasSetting.roofSizeSet', canvasSetting.roofSizeSet)
//가대 상세 데이터 조회
const getTrestleDetailListData = async () => {
@ -310,7 +310,7 @@ export function useModuleBasicSetting(tabNum) {
canvas?.renderAll()
selectedModuleInstSurfaceArray.push(setupSurface)
console.log('selectedModuleInstSurfaceArray', selectedModuleInstSurfaceArray)
// console.log('selectedModuleInstSurfaceArray', selectedModuleInstSurfaceArray)
setCurrentObject({ name: 'moduleSetupSurface', arrayData: [...selectedModuleInstSurfaceArray] })
} else {
@ -839,7 +839,7 @@ export function useModuleBasicSetting(tabNum) {
checkedModule.forEach((module, index) => {
const { width, height } = getModuleWidthHeight(maxLengthLine, moduleSetupSurface, module)
const flowLines = getFlowLines(moduleSetupSurface, width)
const flowLines = getFlowLines(moduleSetupSurface, height)
//육지붕이 아닐때만 넣는다 육지붕일땐 클릭 이벤트에 별도로 넣어놓음
let startPoint = flowLines.bottom
const moduleArray = []
@ -859,81 +859,73 @@ export function useModuleBasicSetting(tabNum) {
startPoint = { ...startPoint, y1: startPoint.y1 - heightMargin }
}
}
}
// else {
// //중앙배치가 아닐때도 흐름 방향 기준면으로 양면이 직선이면 가운데 배치
// if (flowModuleLine.bottom.type === 'flat' && flowModuleLine.left.type === 'flat' && flowModuleLine.right.type === 'flat') {
// //하단 기준으로 양면이 직선이면 하단 방면으로 가운데로 배치
// const halfWidthLength = Math.abs(startPoint.x1 + startPoint.x2) / 2 //밑에 길이에서 반을 가른다
// const halfModuleWidthLength = width / 2
// startPoint = { ...startPoint, x1: halfWidthLength - halfModuleWidthLength }
// }
// }
} else {
const maxLeftEndPoint = surfaceMaxLines.left.x1 //최 좌측
const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측
const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단
const maxLeftEndPoint = surfaceMaxLines.left.x1 //최 좌측
const maxRightEndPoint = surfaceMaxLines.right.x1 //최 우측
const maxTopEndPoint = surfaceMaxLines.top.y1 //최 상단
let totalLeftEndPoint = maxLeftEndPoint - startPoint.x1
let totalTopEndPoint = maxTopEndPoint - startPoint.y1
let totalWidth = Math.ceil(Math.abs(maxRightEndPoint - maxLeftEndPoint) / width)
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배로 늘려서 반씩 검사하기위함
let totalLeftEndPoint = maxLeftEndPoint - startPoint.x1
let totalTopEndPoint = maxTopEndPoint - startPoint.y1
let totalWidth = Math.ceil(Math.abs(maxRightEndPoint - maxLeftEndPoint) / width)
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++) {
bottomMargin = j === 0 ? 0 : intvVer * j
for (let i = 0; i <= totalWidth; i++) {
leftMargin = i === 0 ? 0 : intvHor * i
chidoriLength = 0
if (isChidori && !isMaxSetup) {
chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor
}
square = [
[startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin],
[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],
]
let squarePolygon = turf.polygon([square])
let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
moduleOptions = { ...moduleOptions, fill: module.color, surfaceId: moduleSetupSurface.id, moduleInfo: module }
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, polygonToTurfPolygon(moduleSetupSurface, true))
let isDisjoint = checkModuleDisjointObjects(squarePolygon, containsBatchObjects)
if (disjointFromTrestle && isDisjoint) {
if (index > 0) {
setupModule.forEach((item) => {
const isOverlap = item.some((item2) => turf.booleanOverlap(squarePolygon, polygonToTurfPolygon(item2, true)))
if (!isOverlap) {
canvas?.add(tempModule)
moduleSetupArray.push(tempModule)
moduleArray.push(tempModule)
}
})
} else {
//최초 한번은 그냥 그린다
//겹치는지 확인해서 포함된 모듈만 그린다
canvas?.add(tempModule)
moduleSetupArray.push(tempModule)
moduleArray.push(tempModule)
for (let j = 0; j < diffTopEndPoint; j++) {
bottomMargin = j === 0 ? 0 : intvVer * j
for (let i = 0; i <= totalWidth; i++) {
leftMargin = i === 0 ? 0 : intvHor * i
chidoriLength = 0
if (isChidori && !isMaxSetup) {
chidoriLength = j % 2 === 0 ? 0 : width / 2 - intvHor
}
square = [
[startColPoint + tempMaxWidth * i - chidoriLength + leftMargin, startPoint.y1 - height * j - bottomMargin],
[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],
]
let squarePolygon = turf.polygon([square])
let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
moduleOptions = { ...moduleOptions, fill: module.color, surfaceId: moduleSetupSurface.id, moduleInfo: module }
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, polygonToTurfPolygon(moduleSetupSurface, true))
let isDisjoint = checkModuleDisjointObjects(squarePolygon, containsBatchObjects)
if (disjointFromTrestle && isDisjoint) {
if (index > 0) {
setupModule.forEach((item) => {
const isOverlap = item.some((item2) => turf.booleanOverlap(squarePolygon, polygonToTurfPolygon(item2, true)))
if (!isOverlap) {
canvas?.add(tempModule)
moduleSetupArray.push(tempModule)
moduleArray.push(tempModule)
}
})
} else {
//최초 한번은 그냥 그린다
//겹치는지 확인해서 포함된 모듈만 그린다
canvas?.add(tempModule)
moduleSetupArray.push(tempModule)
moduleArray.push(tempModule)
}
} else {
//디버깅용
tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 })
canvas?.add(tempModule)
}
} else {
//디버깅용
tempModule.set({ fill: 'rgba(255,190,41, 0.4)', stroke: 'black', strokeWidth: 1 })
canvas?.add(tempModule)
}
}
}
setupModule.push(moduleArray)
})
}
@ -1055,7 +1047,7 @@ export function useModuleBasicSetting(tabNum) {
checkedModule.forEach((module, index) => {
const { width, height } = getModuleWidthHeight(maxLengthLine, moduleSetupSurface, module)
const flowLines = getFlowLines(moduleSetupSurface, width)
const flowLines = getFlowLines(moduleSetupSurface, height)
let startPoint = flowLines.top
const moduleArray = []
@ -1389,9 +1381,7 @@ export function useModuleBasicSetting(tabNum) {
return hull
}
const bottomTopFlowLine = (surface, width) => {
console.log('bottom', width)
const bottomTopFlowLine = (surface, length) => {
const flowArray = []
const bottomFlow = surface.lines.reduce(
@ -1450,7 +1440,7 @@ export function useModuleBasicSetting(tabNum) {
const angle2 = Math.abs(Math.round(Math.atan(height2 / adjust2) * (180 / Math.PI) * 1000) / 1000)
const angle3 = 180 - (angle1 + angle2)
const charlie = Number(width) + 3 // 평행선길이 약간 여유를 줌
const charlie = Number(length) + 3 // 평행선길이 약간 여유를 줌
const alpha = (charlie * Math.sin((angle1 * Math.PI) / 180)) / Math.sin((angle3 * Math.PI) / 180)
const beta = Math.sqrt(alpha ** 2 + charlie ** 2 - 2 * alpha * charlie * Math.cos((angle2 * Math.PI) / 180))
const h = beta * Math.sin((angle1 * Math.PI) / 180) // 높이
@ -1467,6 +1457,9 @@ export function useModuleBasicSetting(tabNum) {
strokeWidth: 1,
selectable: true,
})
console.log(`index ${index} : finalLine`, pointX1, pointY1, pointX2, pointY2)
canvas?.add(finalLine)
canvas?.renderAll()
@ -1509,9 +1502,7 @@ export function useModuleBasicSetting(tabNum) {
return rtnObjArray
}
const leftRightFlowLine = (surface, width) => {
console.log('left', width)
const leftRightFlowLine = (surface, length) => {
const flowArray = []
const leftFlow = surface.lines.reduce(
(acc, line, index) => {
@ -1567,7 +1558,7 @@ export function useModuleBasicSetting(tabNum) {
const angle2 = Math.abs(Math.round(Math.atan(adjust2 / height2) * (180 / Math.PI) * 1000) / 1000)
const angle3 = 180 - (angle1 + angle2)
const charlie = Number(width) + 3 // 평행선길이 약간 여유를 줌
const charlie = Number(length) + 3 // 평행선길이 약간 여유를 줌
const alpha = (charlie * Math.sin((angle1 * Math.PI) / 180)) / Math.sin((angle3 * Math.PI) / 180)
const beta = Math.sqrt(alpha ** 2 + charlie ** 2 - 2 * alpha * charlie * Math.cos((angle2 * Math.PI) / 180))
@ -2201,7 +2192,7 @@ export function useModuleBasicSetting(tabNum) {
checkedModule.forEach((module, index) => {
const { width, height } = getModuleWidthHeight(maxLengthLine, moduleSetupSurface, module)
const flowLines = getFlowLines(moduleSetupSurface, width)
const flowLines = getFlowLines(moduleSetupSurface, height)
let startPoint = flowLines.bottom
@ -2292,7 +2283,7 @@ export function useModuleBasicSetting(tabNum) {
const flatRoofTopFlowSetupModule = (surfaceMaxLines, maxLengthLine, moduleSetupArray, moduleSetupSurface, marginWidth, marginHeight) => {
checkedModule.forEach((module, index) => {
const { width, height } = getModuleWidthHeight(maxLengthLine, moduleSetupSurface, module)
const flowLines = getFlowLines(moduleSetupSurface, width)
const flowLines = getFlowLines(moduleSetupSurface, height)
let startPoint = flowLines.top
const maxLeftEndPoint = surfaceMaxLines.left.x1 //최 좌측
@ -2490,7 +2481,7 @@ export function useModuleBasicSetting(tabNum) {
const getModuleStatistics = () => {
const surfaces = canvas.getObjects().filter((obj) => POLYGON_TYPE.MODULE_SETUP_SURFACE === obj.name)
console.log('🚀 ~ getModuleStatistics ~ surfaces:', surfaces)
// console.log('🚀 ~ getModuleStatistics ~ surfaces:', surfaces)
let totalWpout = 0
let moduleInfo = {}
const rows = surfaces.map((surface) => {
@ -2505,7 +2496,7 @@ export function useModuleBasicSetting(tabNum) {
moduleInfo[module.moduleInfo.itemId].amount++
})
totalWpout += wpOut
console.log('🚀 ~ moduleData.rows=surfaces.map ~ module:', module)
// console.log('🚀 ~ moduleData.rows=surfaces.map ~ module:', module)
const rowObject = {}
Object.keys(moduleInfo).forEach((key) => {
rowObject[key] = moduleInfo[key].amount
@ -2519,8 +2510,8 @@ export function useModuleBasicSetting(tabNum) {
}
})
console.log('🚀 ~ getModuleStatistics ~ rows:', rows)
console.log('🚀 ~ getModuleStatistics ~ moduleInfo:', moduleInfo)
// console.log('🚀 ~ getModuleStatistics ~ rows:', rows)
// console.log('🚀 ~ getModuleStatistics ~ moduleInfo:', moduleInfo)
const header = [
{ name: getMessage('modal.panel.batch.statistic.roof.shape'), prop: 'name' },
...Object.keys(moduleInfo).map((key) => {
@ -2540,7 +2531,7 @@ export function useModuleBasicSetting(tabNum) {
footer.push(footerData[key])
})
footer.push((totalWpout / 1000).toFixed(3))
console.log({ header: header, rows, footer: footer })
// console.log({ header: header, rows, footer: footer })
setModuleStatistics({ header: header, rows, footer: footer })
}
@ -2574,14 +2565,14 @@ export function useModuleBasicSetting(tabNum) {
: { width: tmpWidth, height: tmpHeight }
}
const getFlowLines = (moduleSetupSurface, width) => {
const getFlowLines = (moduleSetupSurface, length) => {
let flowLines = {}
flowLines = {
bottom: bottomTopFlowLine(moduleSetupSurface, width).find((obj) => obj.target === 'bottom'),
top: bottomTopFlowLine(moduleSetupSurface, width).find((obj) => obj.target === 'top'),
left: leftRightFlowLine(moduleSetupSurface, width).find((obj) => obj.target === 'left'),
right: leftRightFlowLine(moduleSetupSurface, width).find((obj) => obj.target === 'right'),
bottom: bottomTopFlowLine(moduleSetupSurface, length).find((obj) => obj.target === 'bottom'),
top: bottomTopFlowLine(moduleSetupSurface, length).find((obj) => obj.target === 'top'),
left: leftRightFlowLine(moduleSetupSurface, length).find((obj) => obj.target === 'left'),
right: leftRightFlowLine(moduleSetupSurface, length).find((obj) => obj.target === 'right'),
}
return flowLines
}
@ -2595,5 +2586,6 @@ export function useModuleBasicSetting(tabNum) {
manualFlatroofModuleSetup,
autoFlatroofModuleSetup,
checkModuleDisjointObjects,
makeModuleInitArea,
}
}

View File

@ -62,7 +62,7 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab
// setConstMthdList([]) //공법 초기화
// setRoofBaseList([]) //지붕밑바탕 초기화
// setConstructionList([]) //공법 초기화
resetSelected()
resetSelected(1)
}
//처마력바 체크
@ -114,8 +114,6 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab
isObjectNotEmpty(moduleSelectionData.roofConstructions[tabIndex].trestle) &&
isObjectNotEmpty(moduleSelectionData.roofConstructions[tabIndex].construction)
) {
// console.log('moduleSelectionData', moduleSelectionData)
const roofConstructions = moduleSelectionData.roofConstructions.filter((item) => item.roofIndex === tabIndex)[0]
setModuleConstructionSelectionData(roofConstructions)
}
@ -127,6 +125,18 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab
}
}, [moduleConstructionSelectionData])
useEffect(() => {
//되돌아왔을때 재호출 하여 선택한다
if (isExistData) {
setTrestleParams({
moduleTpCd: selectedModules.itemTp,
roofMatlCd: addRoof.roofMatlCd,
raftBaseCd: selectedRaftBase.raftBaseCd ? selectedRaftBase.raftBaseCd : '',
workingWidth: lengthBase,
})
}
}, [isExistData])
useEffect(() => {
if (isExistData) {
setConstructionListParams({
@ -158,6 +168,7 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab
//모듈 변경
useEffect(() => {
//lengbase는 무조건 있다고 가정 하고 최초에 실행 방지
if (selectedModules) {
//여기서부터 시작
//가대메이커 파라메터 만들기
@ -362,7 +373,7 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab
isObjectNotEmpty(moduleSelectionInitOriginData.current) &&
!isEqualObjects(moduleSelectionInitOriginData.current, moduleSelectionInitParams)
) {
resetSelected()
resetSelected(2)
}
}, [moduleSelectionInitParams])
@ -372,10 +383,10 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab
} else {
setHajebichi(Number(e.target.value))
}
resetSelected()
resetSelected(3)
}
const resetSelected = () => {
const resetSelected = (num) => {
//가대 선택 초기화
setSelectedTrestle({})

View File

@ -197,10 +197,10 @@ export function useRoofShapeSetting(id) {
// 변별로 설정중 한쪽흐름일 경우 한쪽흐름의 pitch로 설정
if (pitch) {
outerLines.forEach((line) => {
if (line.attributes.type === LINE_TYPE.WALLLINE.EAVES) {
if (line.attributes.type === LINE_TYPE.WALLLINE.SHED) {
line.attributes = {
...line.attributes,
pitch: pitch,
pitch: pitchRef.current,
onlyOffset: true,
}
}
@ -228,15 +228,15 @@ export function useRoofShapeSetting(id) {
offset: eavesOffset / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.EAVES,
onlyOffset: true,
}
}
if (line.direction === 'top') {
line.attributes = {
offset: shedWidth / 10,
pitch: pitch,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.SHED,
onlyOffset: true,
}
}
} else {
@ -245,7 +245,6 @@ export function useRoofShapeSetting(id) {
offset: eavesOffset / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.EAVES,
onlyOffset: true,
}
}
@ -254,6 +253,7 @@ export function useRoofShapeSetting(id) {
offset: shedWidth / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.SHED,
onlyOffset: true,
}
}
}
@ -276,7 +276,6 @@ export function useRoofShapeSetting(id) {
offset: eavesOffset / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.EAVES,
onlyOffset: true,
}
}
@ -285,6 +284,7 @@ export function useRoofShapeSetting(id) {
offset: shedWidth / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.SHED,
onlyOffset: true,
}
}
} else {
@ -293,7 +293,6 @@ export function useRoofShapeSetting(id) {
offset: eavesOffset / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.EAVES,
onlyOffset: true,
}
}
@ -302,6 +301,7 @@ export function useRoofShapeSetting(id) {
offset: shedWidth / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.SHED,
onlyOffset: true,
}
}
}
@ -323,7 +323,6 @@ export function useRoofShapeSetting(id) {
offset: eavesOffset / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.EAVES,
onlyOffset: true,
}
}
@ -332,6 +331,7 @@ export function useRoofShapeSetting(id) {
offset: shedWidth / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.SHED,
onlyOffset: true,
}
}
} else {
@ -340,7 +340,6 @@ export function useRoofShapeSetting(id) {
offset: eavesOffset / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.EAVES,
onlyOffset: true,
}
}
@ -349,6 +348,7 @@ export function useRoofShapeSetting(id) {
offset: shedWidth / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.SHED,
onlyOffset: true,
}
}
}
@ -371,7 +371,6 @@ export function useRoofShapeSetting(id) {
offset: eavesOffset / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.EAVES,
onlyOffset: true,
}
}
@ -380,6 +379,7 @@ export function useRoofShapeSetting(id) {
offset: shedWidth / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.SHED,
onlyOffset: true,
}
}
} else {
@ -388,7 +388,6 @@ export function useRoofShapeSetting(id) {
offset: eavesOffset / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.EAVES,
onlyOffset: true,
}
}
@ -397,6 +396,7 @@ export function useRoofShapeSetting(id) {
offset: shedWidth / 10,
pitch: pitchRef.current,
type: LINE_TYPE.WALLLINE.SHED,
onlyOffset: true,
}
}
}
@ -503,7 +503,7 @@ export function useRoofShapeSetting(id) {
outerLines.forEach((line) => {
line.attributes = {
offset: eavesOffset / 10,
pitch: pitchRef.current,
pitch: currentAngleType === ANGLE_TYPE.SLOPE ? pitch : getChonByDegree(pitch),
type: LINE_TYPE.WALLLINE.EAVES,
onlyOffset: false,
}
@ -526,7 +526,7 @@ export function useRoofShapeSetting(id) {
} else if (line.direction === 'top' || line.direction === 'bottom') {
line.attributes = {
offset: eavesOffset / 10,
pitch: pitchRef.current,
pitch: currentAngleType === ANGLE_TYPE.SLOPE ? pitch : getChonByDegree(pitch),
type: LINE_TYPE.WALLLINE.EAVES,
}
}
@ -549,7 +549,7 @@ export function useRoofShapeSetting(id) {
} else if (line.direction === 'left' || line.direction === 'right') {
line.attributes = {
offset: eavesOffset / 10,
pitch: pitchRef.current,
pitch: currentAngleType === ANGLE_TYPE.SLOPE ? pitch : getChonByDegree(pitch),
type: LINE_TYPE.WALLLINE.EAVES,
}
}

View File

@ -26,6 +26,7 @@ export function useCircuitTrestle() {
const selectedModules = useRecoilValue(selectedModuleState)
const { managementState, setManagementState, managementStateLoaded } = useContext(GlobalDataContext)
const canvas = useRecoilValue(canvasState)
const { trigger: moduleSelectedDataTrigger } = useCanvasPopupStatusController(2)
const [moduleSelectionData, setModuleSelectionData] = useRecoilState(moduleSelectionDataState)
const setModuleStatistics = useSetRecoilState(moduleStatisticsState)
const { getMessage } = useMessage()
@ -178,30 +179,17 @@ export function useCircuitTrestle() {
const setPowerConditionerData = () => {}
const setModuleStatisticsData = () => {
// const roofSurfaceList = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
// const modules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE)
// roofSurfaceList.forEach((surface) => {
// surface.modules = modules.filter((module) => module.surfaceId === surface.id)
// })
// console.log('roofSurfaceList', roofSurfaceList)
// console.log('modules', modules)
console.log('moduleSelectionData', moduleSelectionData)
if (
!moduleSelectionData ||
!moduleSelectionData.module ||
Object.keys(moduleSelectionData.module).length === 0 ||
moduleSelectionData.module?.itemList?.length === 0
)
return
console.log(canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE))
if (selectedModules?.length === 0) return
const tempHeader = [
{ name: getMessage('simulator.table.sub1'), prop: 'name' },
{ name: getMessage('modal.circuit.trestle.setting.circuit.allocation.passivity.circuit'), prop: 'circuit' },
// ...moduleSelectionData.module?.itemList?.map((module) => {
// return {
// name: module.itemNm,
// prop: module.itemId,
// }
// }),
...selectedModules?.itemList?.map((module) => {
return {
name: module.itemNm,
prop: module.itemId,
}
}),
{ name: `${getMessage('modal.panel.batch.statistic.power.generation.amount')}(kW)`, prop: 'wpOut' },
]
const surfaceObjects = {}
@ -250,7 +238,7 @@ export function useCircuitTrestle() {
circuit: surfaceObjects[key].circuit,
wpOut: parseFloat(surfaceObjects[key].wpOut / 1000),
}
moduleSelectionData.module.itemList.forEach((module) => {
selectedModules.itemList.forEach((module) => {
tempRow[module.itemId] = surfaceObjects[key][module.itemId]
})
tempRows.push(tempRow)
@ -261,7 +249,7 @@ export function useCircuitTrestle() {
circuit: surfaceObjects[key].circuits[circuit].circuit,
wpOut: parseFloat(surfaceObjects[key].circuits[circuit].circuits.wpOut / 1000),
}
moduleSelectionData.module.itemList.forEach((module) => {
selectedModules.itemList.forEach((module) => {
row[module.itemId] = surfaceObjects[key].circuits[circuit].circuits[module.itemId]
})
tempRows.push(row)
@ -273,8 +261,8 @@ export function useCircuitTrestle() {
circuit: '-',
wpOut: tempRows.reduce((acc, row) => acc + row.wpOut, 0),
}
moduleSelectionData.module.itemList.forEach((module) => {
tempFooter[module.itemId] = tempRows.reduce((acc, row) => acc + (row[module.itemId] ?? 0), 0)
selectedModules.itemList.forEach((module) => {
tempFooter[module.itemId] = tempRows.reduce((acc, row) => acc + row[module.itemId], 0)
})
canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE)
setModuleStatistics({ header: tempHeader, rows: tempRows.filter((row) => row.wpOut !== 0), footer: tempFooter })

View File

@ -93,10 +93,11 @@ export const useLine = () => {
let left, top
const textStr =
currentAngleType === ANGLE_TYPE.SLOPE
? `${attributes.offset ? attributes.offset * 10 : attributes.width * 10}${!onlyOffset && attributes.pitch ? '-∠' + attributes.pitch + angleUnit : ''}`
: `${attributes.offset ? attributes.offset * 10 : attributes.width * 10}${!onlyOffset && attributes.pitch ? '-∠' + getDegreeByChon(attributes.pitch) + angleUnit : ''}`
const textStr = `${attributes.offset ? attributes.offset * 10 : attributes.width * 10}`
// currentAngleType === ANGLE_TYPE.SLOPE
// ? `${attributes.offset ? attributes.offset * 10 : attributes.width * 10}${!onlyOffset && attributes.pitch ? '-∠' + attributes.pitch + angleUnit : ''}`
// : `${attributes.offset ? attributes.offset * 10 : attributes.width * 10}${!onlyOffset && attributes.pitch ? '-∠' + getDegreeByChon(attributes.pitch) + angleUnit : ''}`
if (direction === 'top') {
left = (startPoint.x + endPoint.x) / 2
@ -125,6 +126,7 @@ export const useLine = () => {
name: 'pitchText',
parentId: line.id,
pitch: attributes.pitch,
onlyOffset,
})
canvas.add(text)