모듈 그림자 위로 그려지도록 수정
This commit is contained in:
parent
0cb3b13519
commit
f6f385e597
@ -1041,9 +1041,7 @@ export function useModule() {
|
||||
}
|
||||
|
||||
const getObjects = () => {
|
||||
return canvas
|
||||
?.getObjects()
|
||||
.filter((obj) => [BATCH_TYPE.OPENING, BATCH_TYPE.TRIANGLE_DORMER, BATCH_TYPE.PENTAGON_DORMER, BATCH_TYPE.SHADOW].includes(obj.name))
|
||||
return canvas?.getObjects().filter((obj) => [BATCH_TYPE.OPENING, BATCH_TYPE.TRIANGLE_DORMER, BATCH_TYPE.PENTAGON_DORMER].includes(obj.name))
|
||||
}
|
||||
|
||||
const resetSurface = () => {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
|
||||
|
||||
import {
|
||||
@ -8,32 +8,29 @@ import {
|
||||
currentObjectState,
|
||||
isManualModuleLayoutSetupState,
|
||||
isManualModuleSetupState,
|
||||
moduleSetupOptionState,
|
||||
toggleManualSetupModeState,
|
||||
moduleRowColArrayState,
|
||||
moduleSetupOptionState,
|
||||
moduleSetupSurfaceState,
|
||||
toggleManualSetupModeState,
|
||||
} from '@/store/canvasAtom'
|
||||
|
||||
import { rectToPolygon, polygonToTurfPolygon, calculateVisibleModuleHeight, getDegreeByChon, toFixedWithoutRounding } from '@/util/canvas-util'
|
||||
import { calculateVisibleModuleHeight, getDegreeByChon, polygonToTurfPolygon, rectToPolygon, toFixedWithoutRounding } from '@/util/canvas-util'
|
||||
import { basicSettingState, roofDisplaySelector } from '@/store/settingAtom'
|
||||
import offsetPolygon, { calculateAngle, createLinesFromPolygon } from '@/util/qpolygon-utils'
|
||||
import { QPolygon } from '@/components/fabric/QPolygon'
|
||||
import { moduleSetupSurfaceState } from '@/store/canvasAtom'
|
||||
import { useEvent } from '@/hooks/useEvent'
|
||||
import { POLYGON_TYPE, BATCH_TYPE, LINE_TYPE, MODULE_SETUP_TYPE } from '@/common/common'
|
||||
import { BATCH_TYPE, LINE_TYPE, MODULE_SETUP_TYPE, POLYGON_TYPE } from '@/common/common'
|
||||
import * as turf from '@turf/turf'
|
||||
import { useSwal } from '@/hooks/useSwal'
|
||||
import { compasDegAtom } from '@/store/orientationAtom'
|
||||
import { QLine } from '@/components/fabric/QLine'
|
||||
import { useRoofFn } from '@/hooks/common/useRoofFn'
|
||||
import { useEffect } from 'react'
|
||||
import { useMessage } from '@/hooks/useMessage'
|
||||
import { moduleSelectionDataState, selectedModuleState } from '@/store/selectedModuleOptions'
|
||||
import { useMasterController } from '@/hooks/common/useMasterController'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { isObjectNotEmpty } from '@/util/common-utils'
|
||||
import { useCircuitTrestle } from '@/hooks/useCirCuitTrestle'
|
||||
import { useMode } from '@/hooks/useMode'
|
||||
import { usePolygon } from '@/hooks/usePolygon'
|
||||
import { useTurf } from '@/hooks/common/useTurf'
|
||||
|
||||
export function useModuleBasicSetting(tabNum) {
|
||||
@ -91,7 +88,10 @@ export function useModuleBasicSetting(tabNum) {
|
||||
|
||||
if (roofConstructions && roofConstructions.length > 0) {
|
||||
//roofIndex 넣기
|
||||
const roofConstructionArray = roofConstructions.map((detail) => ({ ...detail.trestleDetail, roofIndex: detail.roofIndex }))
|
||||
const roofConstructionArray = roofConstructions.map((detail) => ({
|
||||
...detail.trestleDetail,
|
||||
roofIndex: detail.roofIndex,
|
||||
}))
|
||||
|
||||
//북면 설치 가능 판매점
|
||||
if (moduleSelectionData.common.saleStoreNorthFlg == '1') {
|
||||
@ -137,7 +137,10 @@ 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, roof.pitch, roof.from) }
|
||||
line.attributes = {
|
||||
...line.attributes,
|
||||
offset: getOffset(offsetObjects.addRoof, line, roof.pitch, roof.from),
|
||||
}
|
||||
})
|
||||
//배치면 설치 영역
|
||||
makeModuleInstArea(roof, detail)
|
||||
@ -150,7 +153,11 @@ export function useModuleBasicSetting(tabNum) {
|
||||
const moduleRowArray = []
|
||||
if (isObjectNotEmpty(detail) && detail.module.length > 0) {
|
||||
detail.module.forEach((module) => {
|
||||
moduleRowArray.push({ moduleMaxRows: module.moduleMaxRows, mixModuleMaxRows: module.mixModuleMaxRows, maxRow: detail.moduleMaxRows })
|
||||
moduleRowArray.push({
|
||||
moduleMaxRows: module.moduleMaxRows,
|
||||
mixModuleMaxRows: module.mixModuleMaxRows,
|
||||
maxRow: detail.moduleMaxRows,
|
||||
})
|
||||
})
|
||||
}
|
||||
rowColArray.push(moduleRowArray)
|
||||
@ -831,7 +838,10 @@ export function useModuleBasicSetting(tabNum) {
|
||||
const mixAsgYn = trestlePolygon.modules[0].moduleInfo.mixAsgYn
|
||||
//현재 체크된 모듈기준으로 혼합가능인지 확인 Y === Y, N === N 일때만 설치 가능
|
||||
if (checkedModule[0].mixAsgYn !== mixAsgYn) {
|
||||
swalFire({ text: getMessage('modal.module.basic.setting.module.placement.mix.asg.yn.error'), icon: 'warning' })
|
||||
swalFire({
|
||||
text: getMessage('modal.module.basic.setting.module.placement.mix.asg.yn.error'),
|
||||
icon: 'warning',
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -901,10 +911,10 @@ export function useModuleBasicSetting(tabNum) {
|
||||
setModuleStatisticsData()
|
||||
|
||||
//그림자는 무조건 가장 앞으로
|
||||
const shadowObj = canvas?.getObjects().find((obj) => obj.name === BATCH_TYPE.SHADOW)
|
||||
if (shadowObj) {
|
||||
shadowObj.bringToFront()
|
||||
}
|
||||
// const shadowObj = canvas?.getObjects().find((obj) => obj.name === BATCH_TYPE.SHADOW)
|
||||
// if (shadowObj) {
|
||||
// shadowObj.bringToFront()
|
||||
// }
|
||||
|
||||
// getModuleStatistics()
|
||||
} else {
|
||||
@ -1312,7 +1322,10 @@ export function useModuleBasicSetting(tabNum) {
|
||||
const mixAsgYn = trestlePolygon.modules[0].moduleInfo.mixAsgYn
|
||||
//현재 체크된 모듈기준으로 혼합가능인지 확인 Y === Y, N === N 일때만 설치 가능
|
||||
if (checkedModule[0].mixAsgYn !== mixAsgYn) {
|
||||
swalFire({ text: getMessage('modal.module.basic.setting.module.placement.mix.asg.yn.error'), icon: 'warning' })
|
||||
swalFire({
|
||||
text: getMessage('modal.module.basic.setting.module.placement.mix.asg.yn.error'),
|
||||
icon: 'warning',
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -1764,10 +1777,10 @@ export function useModuleBasicSetting(tabNum) {
|
||||
}
|
||||
})
|
||||
//그림자가 있다면 무조건 그림자를 가장 앞으로 올림
|
||||
const shadowObj = canvas?.getObjects().find((obj) => obj.name === BATCH_TYPE.SHADOW)
|
||||
if (shadowObj) {
|
||||
shadowObj.bringToFront()
|
||||
}
|
||||
// const shadowObj = canvas?.getObjects().find((obj) => obj.name === BATCH_TYPE.SHADOW)
|
||||
// if (shadowObj) {
|
||||
// shadowObj.bringToFront()
|
||||
// }
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -2175,7 +2188,12 @@ export function useModuleBasicSetting(tabNum) {
|
||||
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 }
|
||||
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))
|
||||
@ -2353,7 +2371,12 @@ export function useModuleBasicSetting(tabNum) {
|
||||
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 }
|
||||
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))
|
||||
@ -2533,7 +2556,12 @@ export function useModuleBasicSetting(tabNum) {
|
||||
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 }
|
||||
moduleOptions = {
|
||||
...moduleOptions,
|
||||
fill: module.color,
|
||||
surfaceId: moduleSetupSurface.id,
|
||||
moduleInfo: module,
|
||||
}
|
||||
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
||||
let turfSurface = polygonToTurfPolygon(moduleSetupSurface, true)
|
||||
let disjointFromTrestle = checkModuleDisjointSurface(squarePolygon, turfSurface)
|
||||
@ -2717,7 +2745,12 @@ export function useModuleBasicSetting(tabNum) {
|
||||
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 }
|
||||
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))
|
||||
@ -2829,10 +2862,10 @@ export function useModuleBasicSetting(tabNum) {
|
||||
// setModuleIsSetup(moduleArray)
|
||||
|
||||
//그림자는 무조건 가장 앞으로
|
||||
const shadowObj = canvas?.getObjects().find((obj) => obj.name === BATCH_TYPE.SHADOW)
|
||||
if (shadowObj) {
|
||||
shadowObj.bringToFront()
|
||||
}
|
||||
// const shadowObj = canvas?.getObjects().find((obj) => obj.name === BATCH_TYPE.SHADOW)
|
||||
// if (shadowObj) {
|
||||
// shadowObj.bringToFront()
|
||||
// }
|
||||
})
|
||||
// calculateForApi()
|
||||
|
||||
@ -2841,7 +2874,10 @@ export function useModuleBasicSetting(tabNum) {
|
||||
*/
|
||||
if (type === MODULE_SETUP_TYPE.LAYOUT && failAutoSetupRoof.length) {
|
||||
const roofNames = failAutoSetupRoof.map((roof) => roof.roofMaterial.roofMatlNmJp).join(', ')
|
||||
swalFire({ text: getMessage('modal.module.basic.setting.module.placement.over.max.row', [roofNames]), icon: 'warning' })
|
||||
swalFire({
|
||||
text: getMessage('modal.module.basic.setting.module.placement.over.max.row', [roofNames]),
|
||||
icon: 'warning',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -2937,7 +2973,11 @@ export function useModuleBasicSetting(tabNum) {
|
||||
const pointY2 = top
|
||||
|
||||
//디버깅
|
||||
const finalLine = new QLine([pointX1, pointY1, pointX2, pointY2], { stroke: 'red', strokeWidth: 1, selectable: true })
|
||||
const finalLine = new QLine([pointX1, pointY1, pointX2, pointY2], {
|
||||
stroke: 'red',
|
||||
strokeWidth: 1,
|
||||
selectable: true,
|
||||
})
|
||||
// canvas?.add(finalLine)
|
||||
// canvas?.renderAll()
|
||||
|
||||
@ -2971,7 +3011,14 @@ export function useModuleBasicSetting(tabNum) {
|
||||
type: 'flat',
|
||||
}
|
||||
} else {
|
||||
rtnObj = { target: index === 0 ? 'bottom' : 'top', x1: pointX1, y1: pointY1, x2: pointX2, y2: pointY2, type: 'curve' }
|
||||
rtnObj = {
|
||||
target: index === 0 ? 'bottom' : 'top',
|
||||
x1: pointX1,
|
||||
y1: pointY1,
|
||||
x2: pointX2,
|
||||
y2: pointY2,
|
||||
type: 'curve',
|
||||
}
|
||||
}
|
||||
|
||||
rtnObjArray.push(rtnObj)
|
||||
@ -3058,7 +3105,11 @@ export function useModuleBasicSetting(tabNum) {
|
||||
const pointY2 = coords[2].y + ((coords[2].x - top) / (coords[2].x - coords[1].x)) * (coords[1].y - coords[2].y)
|
||||
|
||||
//디버깅용
|
||||
const finalLine = new QLine([pointX1, pointY1, pointX2, pointY2], { stroke: 'red', strokeWidth: 1, selectable: true })
|
||||
const finalLine = new QLine([pointX1, pointY1, pointX2, pointY2], {
|
||||
stroke: 'red',
|
||||
strokeWidth: 1,
|
||||
selectable: true,
|
||||
})
|
||||
// canvas?.add(finalLine)
|
||||
// canvas?.renderAll()
|
||||
|
||||
@ -3092,7 +3143,14 @@ export function useModuleBasicSetting(tabNum) {
|
||||
type: 'flat',
|
||||
}
|
||||
} else {
|
||||
rtnObj = { target: index === 0 ? 'left' : 'right', x1: pointX1, y1: pointY1, x2: pointX2, y2: pointY2, type: 'curve' }
|
||||
rtnObj = {
|
||||
target: index === 0 ? 'left' : 'right',
|
||||
x1: pointX1,
|
||||
y1: pointY1,
|
||||
x2: pointX2,
|
||||
y2: pointY2,
|
||||
type: 'curve',
|
||||
}
|
||||
}
|
||||
rtnObjArray.push(rtnObj)
|
||||
})
|
||||
@ -3469,7 +3527,10 @@ export function useModuleBasicSetting(tabNum) {
|
||||
const mixAsgYn = trestlePolygon.modules[0].moduleInfo.mixAsgYn
|
||||
//현재 체크된 모듈기준으로 혼합가능인지 확인 Y === Y, N === N 일때만 설치 가능
|
||||
if (checkedModule[0].mixAsgYn !== mixAsgYn) {
|
||||
swalFire({ text: getMessage('modal.module.basic.setting.module.placement.mix.asg.yn.error'), icon: 'warning' })
|
||||
swalFire({
|
||||
text: getMessage('modal.module.basic.setting.module.placement.mix.asg.yn.error'),
|
||||
icon: 'warning',
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -3479,7 +3540,10 @@ export function useModuleBasicSetting(tabNum) {
|
||||
const rectPoints = [
|
||||
{ x: tempModule.left, y: tempModule.top },
|
||||
{ x: tempModule.left + tempModule.width * tempModule.scaleX, y: tempModule.top },
|
||||
{ x: tempModule.left + tempModule.width * tempModule.scaleX, y: tempModule.top + tempModule.height * tempModule.scaleY },
|
||||
{
|
||||
x: tempModule.left + tempModule.width * tempModule.scaleX,
|
||||
y: tempModule.top + tempModule.height * tempModule.scaleY,
|
||||
},
|
||||
{ x: tempModule.left, y: tempModule.top + tempModule.height * tempModule.scaleY },
|
||||
]
|
||||
|
||||
@ -3799,7 +3863,12 @@ export function useModuleBasicSetting(tabNum) {
|
||||
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 }
|
||||
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))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user