688 lines
25 KiB
JavaScript
688 lines
25 KiB
JavaScript
import { useCallback, useEffect, useState } from 'react'
|
|
import { useRecoilState, useRecoilValue, useResetRecoilState, useSetRecoilState } from 'recoil'
|
|
import {
|
|
adsorptionPointModeState,
|
|
adsorptionRangeState,
|
|
canvasState,
|
|
planSizeSettingState,
|
|
dotLineGridSettingState,
|
|
canvasSettingState,
|
|
} from '@/store/canvasAtom'
|
|
import { globalLocaleStore } from '@/store/localeAtom'
|
|
import { useMessage } from '@/hooks/useMessage'
|
|
import { useAxios } from '@/hooks/useAxios'
|
|
import { useSwal } from '@/hooks/useSwal'
|
|
import {
|
|
correntObjectNoState,
|
|
corridorDimensionSelector,
|
|
settingModalFirstOptionsState,
|
|
settingModalSecondOptionsState,
|
|
settingModalGridOptionsState,
|
|
basicSettingState,
|
|
settingsState,
|
|
roofMaterialsAtom,
|
|
} from '@/store/settingAtom'
|
|
import { POLYGON_TYPE } from '@/common/common'
|
|
import { globalFontAtom } from '@/store/fontAtom'
|
|
import { dimensionLineSettingsState } from '@/store/commonUtilsAtom'
|
|
import { gridColorState } from '@/store/gridAtom'
|
|
import { useColor } from 'react-color-palette'
|
|
|
|
const defaultDotLineGridSetting = {
|
|
INTERVAL: {
|
|
type: 2, // 1: 가로,세로 간격 수동, 2: 비율 간격
|
|
ratioInterval: 910,
|
|
verticalInterval: 910,
|
|
horizontalInterval: 910,
|
|
dimension: 1, // 치수
|
|
},
|
|
DOT: false,
|
|
LINE: false,
|
|
}
|
|
|
|
export function useCanvasSetting() {
|
|
const canvas = useRecoilValue(canvasState)
|
|
// canvas가 null이 아닐 때에만 getObjects 호출
|
|
const canvasObjects = canvas ? canvas.getObjects() : []
|
|
const [correntObjectNo, setCorrentObjectNo] = useRecoilState(correntObjectNoState)
|
|
|
|
const [settingModalFirstOptions, setSettingModalFirstOptions] = useRecoilState(settingModalFirstOptionsState)
|
|
const [settingModalSecondOptions, setSettingModalSecondOptions] = useRecoilState(settingModalSecondOptionsState)
|
|
|
|
const [selectedFont, setSelectedFont] = useState()
|
|
const [selectedFontWeight, setSelectedFontWeight] = useState()
|
|
const [selectedFontSize, setSelectedFontSize] = useState()
|
|
const [selectedFontColor, setSelectedFontColor] = useState()
|
|
const [globalFont, setGlobalFont] = useRecoilState(globalFontAtom)
|
|
|
|
const [adsorptionPointMode, setAdsorptionPointMode] = useRecoilState(adsorptionPointModeState)
|
|
const [adsorptionRange, setAdsorptionRange] = useRecoilState(adsorptionRangeState)
|
|
const [planSizeSettingMode, setPlanSizeSettingMode] = useRecoilState(planSizeSettingState)
|
|
const [dimensionLineSettings, setDimensionLineSettings] = useRecoilState(dimensionLineSettingsState)
|
|
|
|
const setSettingModalGridOptions = useSetRecoilState(settingModalGridOptionsState)
|
|
const [dotLineGridSetting, setDotLineGridSettingState] = useRecoilState(dotLineGridSettingState)
|
|
const resetDotLineGridSetting = useResetRecoilState(dotLineGridSettingState)
|
|
const [currentSetting, setCurrentSetting] = useState(
|
|
JSON.stringify(dotLineGridSetting) === JSON.stringify(defaultDotLineGridSetting) ? { ...defaultDotLineGridSetting } : { ...dotLineGridSetting },
|
|
)
|
|
const [gridColor, setGridColor] = useRecoilState(gridColorState)
|
|
const [color, setColor] = useColor(gridColor ?? '#FF0000')
|
|
|
|
const [settingsData, setSettingsData] = useState({
|
|
...settingModalFirstOptions,
|
|
...settingModalSecondOptions,
|
|
...globalFont,
|
|
...dotLineGridSetting,
|
|
...planSizeSettingMode,
|
|
...dimensionLineSettings,
|
|
...color,
|
|
})
|
|
const [settingsDataSave, setSettingsDataSave] = useState()
|
|
const { option1, option2, dimensionDisplay } = settingModalFirstOptions
|
|
const { option4 } = settingModalSecondOptions
|
|
|
|
const corridorDimension = useRecoilValue(corridorDimensionSelector)
|
|
|
|
const globalLocaleState = useRecoilValue(globalLocaleStore)
|
|
const { get, post } = useAxios(globalLocaleState)
|
|
const { getMessage } = useMessage()
|
|
const { swalFire } = useSwal()
|
|
|
|
const [canvasSetting, setCanvasSetting] = useRecoilState(canvasSettingState)
|
|
const [basicSetting, setBasicSettings] = useRecoilState(basicSettingState)
|
|
|
|
const [roofMaterials, setRoofMaterials] = useRecoilState(roofMaterialsAtom)
|
|
|
|
const SelectOptions = [
|
|
{ id: 1, name: getMessage('modal.canvas.setting.grid.dot.line.setting.line.origin'), value: 1 },
|
|
{ id: 2, name: '1/2', value: 1 / 2 },
|
|
{ id: 3, name: '1/4', value: 1 / 4 },
|
|
{ id: 4, name: '1/10', value: 1 / 10 },
|
|
]
|
|
|
|
useEffect(() => {
|
|
get({ url: `/api/v1/master/getRoofMaterialList` }).then((res) => {
|
|
setRoofMaterials(res.data)
|
|
})
|
|
}, [])
|
|
|
|
useEffect(() => {
|
|
if (!canvas) {
|
|
return
|
|
}
|
|
const { column } = corridorDimension
|
|
const lengthTexts = canvas.getObjects().filter((obj) => obj.name === 'lengthText')
|
|
switch (column) {
|
|
case 'corridorDimension':
|
|
lengthTexts.forEach((obj) => {
|
|
if (obj.planeSize) {
|
|
obj.set({ text: obj.planeSize.toString() })
|
|
}
|
|
})
|
|
break
|
|
case 'realDimension':
|
|
lengthTexts.forEach((obj) => {
|
|
if (obj.actualSize) {
|
|
obj.set({ text: obj.actualSize.toString() })
|
|
}
|
|
})
|
|
break
|
|
case 'noneDimension':
|
|
lengthTexts.forEach((obj) => {
|
|
obj.set({ text: '' })
|
|
})
|
|
break
|
|
}
|
|
canvas?.renderAll()
|
|
}, [corridorDimension])
|
|
|
|
// 배치면 초기설정 변경 시
|
|
useEffect(() => {
|
|
//console.log('useCanvasSetting canvasSetting 실행', canvasSetting)
|
|
if (canvasSetting.flag) {
|
|
basicSettingSave()
|
|
}
|
|
}, [canvasSetting])
|
|
|
|
useEffect(() => {
|
|
console.log('🚀 ~ useEffect ~ settingsDataSave:', settingsDataSave)
|
|
if (settingsDataSave !== undefined) onClickOption2()
|
|
}, [settingsData])
|
|
|
|
const getFonts = (itemValue) => {
|
|
if (!itemValue) return { id: 1, name: 'MS PGothic', value: 'MS PGothic' }
|
|
const data = [
|
|
{ id: 1, name: 'MS PGothic', value: 'MS PGothic' },
|
|
{ id: 2, name: '@Yu Gothic', value: '@Yu Gothic' },
|
|
{ id: 3, name: 'Yu Gothic', value: 'Yu Gothic' },
|
|
{ id: 4, name: '@Yu Gothic UI', value: '@Yu Gothic UI' },
|
|
{ id: 5, name: 'Yu Gothic UI', value: 'Yu Gothic UI' },
|
|
].filter((font) => font.value === itemValue)
|
|
if (data.length !== 0) {
|
|
return data[0]
|
|
} else {
|
|
return { id: 1, name: 'MS PGothic', value: 'MS PGothic' }
|
|
}
|
|
}
|
|
|
|
const getFontSizes = (itemValue) => {
|
|
if (!itemValue) return { id: 16, name: 16, value: 16 }
|
|
const data = [
|
|
...Array.from({ length: 4 }).map((_, index) => {
|
|
return { id: index + 8, name: index + 8, value: index + 8 }
|
|
}),
|
|
...Array.from({ length: 9 }).map((_, index) => {
|
|
return { id: (index + 6) * 2, name: (index + 6) * 2, value: (index + 6) * 2 }
|
|
}),
|
|
{ id: 36, name: 36, value: 36 },
|
|
{ id: 48, name: 48, value: 48 },
|
|
{ id: 72, name: 72, value: 72 },
|
|
].filter((fontSize) => fontSize.value === itemValue)
|
|
if (data.length !== 0) {
|
|
return data[0]
|
|
} else {
|
|
return { id: 16, name: 16, value: 16 }
|
|
}
|
|
}
|
|
|
|
const getFontStyles = (itemValue) => {
|
|
if (!itemValue) return { id: 'normal', name: getMessage('font.style.normal'), value: 'normal' }
|
|
const data = [
|
|
{ id: 'normal', name: getMessage('font.style.normal'), value: 'normal' },
|
|
{ id: 'italic', name: getMessage('font.style.italic'), value: 'italic' },
|
|
{ id: 'bold', name: getMessage('font.style.bold'), value: 'bold' },
|
|
{ id: 'boldAndItalic', name: getMessage('font.style.bold.italic'), value: 'boldAndItalic' },
|
|
].filter((fontStyle) => fontStyle.value === itemValue)
|
|
if (data.length !== 0) {
|
|
return data[0]
|
|
} else {
|
|
return { id: 'normal', name: getMessage('font.style.normal'), value: 'normal' }
|
|
}
|
|
}
|
|
|
|
const getFontColors = (itemValue) => {
|
|
if (!itemValue) return { id: 'black', name: getMessage('color.black'), value: 'black' }
|
|
const data = [
|
|
{ id: 'black', name: getMessage('color.black'), value: 'black' },
|
|
{ id: 'red', name: getMessage('color.red'), value: 'red' },
|
|
{ id: 'blue', name: getMessage('color.blue'), value: 'blue' },
|
|
{ id: 'gray', name: getMessage('color.gray'), value: 'gray' },
|
|
{ id: 'yellow', name: getMessage('color.yellow'), value: 'yellow' },
|
|
{ id: 'green', name: getMessage('color.green'), value: 'green' },
|
|
{ id: 'pink', name: getMessage('color.pink'), value: 'pink' },
|
|
{ id: 'gold', name: getMessage('color.gold'), value: 'gold' },
|
|
{ id: 'darkblue', name: getMessage('color.darkblue'), value: 'darkblue' },
|
|
].filter((fontColor) => fontColor.value === itemValue)
|
|
if (data.length !== 0) {
|
|
return data[0]
|
|
} else {
|
|
return { id: 'black', name: getMessage('color.black'), value: 'black' }
|
|
}
|
|
}
|
|
|
|
// 기본설정(PlacementShapeSetting) 조회 및 초기화
|
|
const fetchBasicSettings = async () => {
|
|
try {
|
|
await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}` }).then((res) => {
|
|
console.log('fetchBasicSettings res ', res)
|
|
if (res.length == 0) return
|
|
|
|
// 'roofs' 배열을 생성하여 각 항목을 추가
|
|
const roofsRow = res.map((item) => {
|
|
return {
|
|
roofSizeSet: item.roofSizeSet,
|
|
roofAngleSet: item.roofAngleSet,
|
|
}
|
|
})
|
|
|
|
const roofsArray = res.some((item) => !item.roofSeq)
|
|
? //최초 지붕재 추가 정보의 경우 roofsArray를 초기화 설정
|
|
res.map(() => ({
|
|
flag: false,
|
|
roofApply: true,
|
|
roofSeq: 1,
|
|
roofType: 1,
|
|
roofWidth: 265,
|
|
roofHeight: 235,
|
|
roofHajebichi: 0,
|
|
roofGap: 455,
|
|
// roofType: 1,
|
|
// roofWidth: 200,
|
|
// roofHeight: 200,
|
|
// roofHajebichi: 200,
|
|
// roofGap: 0,
|
|
roofLayout: 'parallel',
|
|
}))
|
|
: res.map((item) => ({
|
|
flag: false,
|
|
roofApply: item.roofApply === '' || item.roofApply === false ? false : true,
|
|
roofSeq: item.roofSeq,
|
|
roofType: item.roofType,
|
|
roofWidth: item.roofWidth,
|
|
roofHeight: item.roofHeight,
|
|
roofHajebichi: item.roofHajebichi,
|
|
roofGap: item.roofGap,
|
|
roofLayout: item.roofLayout,
|
|
}))
|
|
console.log('roofsArray ', roofsArray)
|
|
// 나머지 데이터와 함께 'roofs' 배열을 patternData에 넣음
|
|
const patternData = {
|
|
roofSizeSet: roofsRow[0].roofSizeSet, // 첫 번째 항목의 값을 사용
|
|
roofAngleSet: roofsRow[0].roofAngleSet, // 첫 번째 항목의 값을 사용
|
|
roofs: roofsArray, // 만들어진 roofs 배열
|
|
}
|
|
|
|
//console.error('patternData', patternData)
|
|
|
|
// 데이터 설정
|
|
setBasicSettings({ ...patternData })
|
|
})
|
|
} catch (error) {
|
|
console.error('Data fetching error:', error)
|
|
}
|
|
|
|
if (!(Object.keys(canvasSetting).length === 0 && canvasSetting.constructor === Object)) {
|
|
setBasicSettings({ ...canvasSetting })
|
|
}
|
|
//setCanvasSetting({ ...basicSetting })
|
|
}
|
|
|
|
// 기본설정(PlacementShapeSetting) 저장
|
|
const basicSettingSave = async () => {
|
|
try {
|
|
const patternData = {
|
|
objectNo: correntObjectNo,
|
|
roofSizeSet: basicSetting.roofSizeSet,
|
|
roofAngleSet: basicSetting.roofAngleSet,
|
|
roofMaterialsAddList: basicSetting.roofs,
|
|
}
|
|
|
|
await post({ url: `/api/canvas-management/canvas-basic-settings`, data: patternData }).then((res) => {
|
|
swalFire({ text: getMessage(res.returnMessage) })
|
|
})
|
|
|
|
//Recoil 설정
|
|
setCanvasSetting({ ...basicSetting, flag: false })
|
|
} catch (error) {
|
|
swalFire({ text: getMessage(res.returnMessage), icon: 'error' })
|
|
}
|
|
}
|
|
|
|
// CanvasSetting 조회 및 초기화
|
|
const fetchSettings = async () => {
|
|
try {
|
|
const res = await get({ url: `/api/canvas-management/canvas-settings/by-object/${correntObjectNo}` })
|
|
console.log('res', res)
|
|
|
|
if (res) {
|
|
const optionData1 = settingModalFirstOptions.option1.map((item) => ({ ...item, selected: res[item.column] }))
|
|
const optionData2 = settingModalFirstOptions.option2.map((item) => ({ ...item, selected: res[item.column] }))
|
|
const optionData3 = settingModalSecondOptions.option3.map((item) => ({ ...item }))
|
|
const optionData4 = settingModalSecondOptions.option4.map((item) => ({ ...item, selected: res[item.column] }))
|
|
const optionData5 = settingModalFirstOptions.dimensionDisplay.map((item) => ({ ...item }))
|
|
|
|
//흡착점 ON/OFF
|
|
setAdsorptionPointMode({ ...adsorptionPointMode, adsorptionPoint: res.adsorpPoint })
|
|
|
|
//치수선 설정
|
|
setDimensionLineSettings({ ...dimensionLineSettings, pixel: res.originPixel, color: res.originColor })
|
|
|
|
//도면크기 설정
|
|
setPlanSizeSettingMode({ ...planSizeSettingMode, originHorizon: res.originHorizon, originVertical: res.originVertical })
|
|
|
|
// 데이터 설정
|
|
setSettingModalFirstOptions({
|
|
...settingModalFirstOptions,
|
|
option1: optionData1,
|
|
option2: optionData2,
|
|
dimensionDisplay: optionData5,
|
|
})
|
|
setSettingModalSecondOptions({
|
|
...settingModalSecondOptions,
|
|
option3: optionData3,
|
|
option4: optionData4,
|
|
})
|
|
|
|
const fontPatternData = {
|
|
commonText: {
|
|
//문자 글꼴 조회 데이터
|
|
fontFamily: getFonts(res.wordFont),
|
|
fontWeight: getFontStyles(res.wordFontStyle),
|
|
fontSize: getFontSizes(res.wordFontSize),
|
|
fontColor: getFontColors(res.wordFontColor),
|
|
},
|
|
flowText: {
|
|
//흐름방향 글꼴 조회 데이터
|
|
fontFamily: getFonts(res.flowFont),
|
|
fontWeight: getFontStyles(res.flowFontStyle),
|
|
fontSize: getFontSizes(res.flowFontSize),
|
|
fontColor: getFontColors(res.flowFontColor),
|
|
},
|
|
dimensionLineText: {
|
|
//치수 글꼴 조회 데이터
|
|
fontFamily: getFonts(res.dimensioFont),
|
|
fontWeight: getFontStyles(res.dimensioFontStyle),
|
|
fontSize: getFontSizes(res.dimensioFontSize),
|
|
fontColor: getFontColors(res.dimensioFontColor),
|
|
},
|
|
circuitNumberText: {
|
|
//회로번호 글꼴 조회 데이터
|
|
fontFamily: getFonts(res.circuitNumFont),
|
|
fontWeight: getFontStyles(res.circuitNumFontStyle),
|
|
fontSize: getFontSizes(res.circuitNumFontSize),
|
|
fontColor: getFontColors(res.circuitNumFontColor),
|
|
},
|
|
lengthText: {
|
|
//치수선 글꼴 조회 데이터
|
|
fontFamily: getFonts(res.lengthFont),
|
|
fontWeight: getFontStyles(res.lengthFontStyle),
|
|
fontSize: getFontSizes(res.lengthFontSize),
|
|
fontColor: getFontColors(res.lengthFontColor),
|
|
},
|
|
}
|
|
|
|
//조회된 글꼴 데이터 set
|
|
setGlobalFont(fontPatternData)
|
|
|
|
//점/선 그리드
|
|
const patternData = {
|
|
INTERVAL: {
|
|
type: res.gridType,
|
|
horizontalInterval: res.gridHorizon * 10,
|
|
verticalInterval: res.gridVertical * 10,
|
|
ratioInterval: res.gridRatio * 10,
|
|
dimension: res.gridDimen,
|
|
},
|
|
DOT: res.dotGridDisplay,
|
|
LINE: res.lineGridDisplay,
|
|
}
|
|
|
|
setDotLineGridSettingState(patternData)
|
|
//setCurrentSetting(patternData)
|
|
|
|
//그리드 색 설정
|
|
setGridColor(res.gridColor)
|
|
} else {
|
|
//조회된 글꼴 데이터가 없는 경우
|
|
|
|
//흡착점 ON/OFF
|
|
setAdsorptionPointMode({ ...adsorptionPointMode, adsorptionPoint: false })
|
|
|
|
//치수선 설정
|
|
setDimensionLineSettings({ ...dimensionLineSettings })
|
|
|
|
//도면크기 설정
|
|
setPlanSizeSettingMode({ ...planSizeSettingMode })
|
|
|
|
// 데이터 설정
|
|
setSettingModalFirstOptions({
|
|
...settingModalFirstOptions,
|
|
})
|
|
setSettingModalSecondOptions({
|
|
...settingModalSecondOptions,
|
|
})
|
|
|
|
setGlobalFont({ ...globalFont })
|
|
|
|
//점/선 그리드
|
|
setDotLineGridSettingState({ ...defaultDotLineGridSetting })
|
|
//setCurrentSetting({ ...defaultDotLineGridSetting })
|
|
|
|
//그리드 색 설정
|
|
setGridColor('#FF0000')
|
|
}
|
|
|
|
frontSettings()
|
|
} catch (error) {
|
|
console.error('Data fetching error:', error)
|
|
}
|
|
}
|
|
|
|
// CanvasSetting 옵션 클릭 후 저장
|
|
const onClickOption2 = async () => {
|
|
// 서버에 전송할 데이터
|
|
const dataToSend = {
|
|
firstOption1: option1.map((item) => ({
|
|
column: item.column,
|
|
selected: item.selected,
|
|
})),
|
|
firstOption2: option2.map((item) => ({
|
|
column: item.column,
|
|
selected: item.selected,
|
|
})),
|
|
firstOption3: dimensionDisplay.map((item) => ({
|
|
column: item.column,
|
|
selected: item.selected,
|
|
})),
|
|
secondOption2: option4.map((item) => ({
|
|
column: item.column,
|
|
selected: item.selected,
|
|
range: item.range,
|
|
})),
|
|
}
|
|
const patternData = {
|
|
//견적서 번호
|
|
objectNo: correntObjectNo,
|
|
//디스플레이 설정(다중)
|
|
allocDisplay: dataToSend.firstOption1[0].selected,
|
|
outlineDisplay: dataToSend.firstOption1[1].selected,
|
|
gridDisplay: dataToSend.firstOption1[2].selected,
|
|
lineDisplay: dataToSend.firstOption1[3].selected,
|
|
wordDisplay: dataToSend.firstOption1[4].selected,
|
|
circuitNumDisplay: dataToSend.firstOption1[5].selected,
|
|
flowDisplay: dataToSend.firstOption1[6].selected,
|
|
trestleDisplay: dataToSend.firstOption1[7].selected,
|
|
imageDisplay: dataToSend.firstOption1[8].selected,
|
|
totalDisplay: dataToSend.firstOption1[9].selected,
|
|
//차수 표시(단 건)
|
|
corridorDimension: dataToSend.firstOption3[0].selected,
|
|
realDimension: dataToSend.firstOption3[1].selected,
|
|
noneDimension: dataToSend.firstOption3[2].selected,
|
|
//화면 표시(단 건)
|
|
onlyBorder: dataToSend.firstOption2[0].selected,
|
|
lineHatch: dataToSend.firstOption2[1].selected,
|
|
allPainted: dataToSend.firstOption2[2].selected,
|
|
//흡착범위 설정(단 건)
|
|
adsorpRangeSmall: dataToSend.secondOption2[0].selected,
|
|
adsorpRangeSmallSemi: dataToSend.secondOption2[1].selected,
|
|
adsorpRangeMedium: dataToSend.secondOption2[2].selected,
|
|
adsorpRangeLarge: dataToSend.secondOption2[3].selected,
|
|
|
|
//흡착점 ON/OFF
|
|
adsorpPoint: adsorptionPointMode.adsorptionPoint,
|
|
//??: adsorptionRange, 사용여부 확인 필요
|
|
|
|
//글꼴 설정
|
|
//문자 글꼴
|
|
wordFont: globalFont.commonText.fontFamily?.value ?? 'MS PGothic',
|
|
wordFontStyle: globalFont.commonText.fontWeight?.value ?? 'normal',
|
|
wordFontSize: globalFont.commonText.fontSize?.value ?? 16,
|
|
wordFontColor: globalFont.commonText.fontColor?.value ?? 'black',
|
|
|
|
//흐름방향 글꼴
|
|
flowFont: globalFont.flowText.fontFamily?.value ?? 'MS PGothic',
|
|
flowFontStyle: globalFont.flowText.fontWeight?.value ?? 'normal',
|
|
flowFontSize: globalFont.flowText.fontSize?.value ?? 16,
|
|
flowFontColor: globalFont.flowText.fontColor?.value ?? 'black',
|
|
|
|
//치수 글꼴
|
|
dimensioFont: globalFont.dimensionLineText.fontFamily?.value ?? 'MS PGothic',
|
|
dimensioFontStyle: globalFont.dimensionLineText.fontWeight?.value ?? 'normal',
|
|
dimensioFontSize: globalFont.dimensionLineText.fontSize?.value ?? 16,
|
|
dimensioFontColor: globalFont.dimensionLineText.fontColor?.value ?? 'black',
|
|
|
|
//회로번호 글꼴
|
|
circuitNumFont: globalFont.circuitNumberText.fontFamily?.value ?? 'MS PGothic',
|
|
circuitNumFontStyle: globalFont.circuitNumberText.fontWeight?.value ?? 'normal',
|
|
circuitNumFontSize: globalFont.circuitNumberText.fontSize?.value ?? 16,
|
|
circuitNumFontColor: globalFont.circuitNumberText.fontColor?.value ?? 'black',
|
|
|
|
//치수선 글꼴
|
|
lengthFont: globalFont.lengthText.fontFamily?.value ?? 'MS PGothic',
|
|
lengthFontStyle: globalFont.lengthText.fontWeight?.value ?? 'normal',
|
|
lengthFontSize: globalFont.lengthText.fontSize?.value ?? 16,
|
|
lengthFontColor: globalFont.lengthText.fontColor?.value ?? 'black',
|
|
|
|
//치수선 설정
|
|
originPixel: dimensionLineSettings.pixel,
|
|
originColor: dimensionLineSettings.color,
|
|
|
|
//도면크기 설정
|
|
originHorizon: planSizeSettingMode.originHorizon,
|
|
originVertical: planSizeSettingMode.originVertical,
|
|
|
|
dotGridDisplay: dotLineGridSetting.DOT,
|
|
lineGridDisplay: dotLineGridSetting.LINE,
|
|
gridType: dotLineGridSetting.INTERVAL.type,
|
|
gridHorizon: dotLineGridSetting.INTERVAL.horizontalInterval / 10,
|
|
gridVertical: dotLineGridSetting.INTERVAL.verticalInterval / 10,
|
|
gridRatio: dotLineGridSetting.INTERVAL.ratioInterval / 10,
|
|
gridDimen: dotLineGridSetting.INTERVAL.dimension,
|
|
|
|
gridColor: gridColor,
|
|
}
|
|
|
|
console.log('patternData ', patternData)
|
|
|
|
// HTTP POST 요청 보내기
|
|
await post({ url: `/api/canvas-management/canvas-settings`, data: patternData })
|
|
.then((res) => {
|
|
swalFire({ text: getMessage(res.returnMessage) })
|
|
|
|
// Canvas 디스플레이 설정 시 해당 옵션 적용
|
|
frontSettings()
|
|
// 저장 후 재조회
|
|
fetchSettings()
|
|
})
|
|
.catch((error) => {
|
|
swalFire({ text: getMessage(res.returnMessage), icon: 'error' })
|
|
})
|
|
|
|
//setAdsorptionRange(item.range)
|
|
}
|
|
|
|
// Canvas 디스플레이 설정 시 해당 옵션 적용
|
|
const frontSettings = async () => {
|
|
const option1 = settingModalFirstOptions.option1
|
|
|
|
// 'allocDisplay' 할당 표시
|
|
// 'outlineDisplay' 외벽선 표시 'outerLine', POLYGON_TYPE.WALL
|
|
// 'gridDisplay' 그리드 표시 'lindGrid', 'dotGrid'
|
|
// 'lineDisplay' 지붕선 표시 'roof', POLYGON_TYPE.ROOF
|
|
// 'wordDisplay' 문자 표시
|
|
// 'circuitNumDisplay' 회로번호 표시
|
|
// 'flowDisplay' 흐름방향 표시 'arrow', 'flowText'
|
|
// 'trestleDisplay' 가대 표시
|
|
// 'imageDisplay' 이미지 표시
|
|
// 'totalDisplay' 집계표 표시
|
|
|
|
let optionName //옵션명
|
|
let optionSelected //옵션상태
|
|
|
|
for (let i = 0; i < option1.length; i++) {
|
|
switch (option1[i].column) {
|
|
case 'allocDisplay': //할당 표시
|
|
optionName = ['1']
|
|
break
|
|
case 'outlineDisplay': //외벽선 표시
|
|
optionName = ['outerLine', POLYGON_TYPE.WALL]
|
|
break
|
|
case 'gridDisplay': //그리드 표시
|
|
optionName = ['lindGrid', 'dotGrid', 'tempGrid']
|
|
break
|
|
case 'lineDisplay': //지붕선 표시
|
|
optionName = ['roof', POLYGON_TYPE.ROOF]
|
|
break
|
|
case 'wordDisplay': //문자 표시
|
|
optionName = ['commonText']
|
|
break
|
|
case 'circuitNumDisplay': //회로번호 표시
|
|
optionName = ['7']
|
|
break
|
|
case 'flowDisplay': //흐름방향 표시
|
|
optionName = ['arrow', 'flowText']
|
|
break
|
|
case 'trestleDisplay': //가대 표시
|
|
optionName = ['8']
|
|
break
|
|
case 'imageDisplay': //이미지 표시
|
|
optionName = ['9']
|
|
break
|
|
case 'totalDisplay': //집계표 표시
|
|
optionName = ['10']
|
|
break
|
|
}
|
|
// 표시 선택 상태(true/false)
|
|
optionSelected = option1[i].selected
|
|
|
|
//canvas.getObjects() >> canvasObjects
|
|
canvasObjects
|
|
.filter((obj) => optionName.includes(obj.name))
|
|
//.filter((obj) => obj.name === optionName)
|
|
.forEach((obj) => {
|
|
obj.set({ visible: optionSelected })
|
|
//obj.set({ visible: !obj.visible })
|
|
})
|
|
|
|
canvas?.renderAll()
|
|
|
|
// console.log(
|
|
// 'optionName',
|
|
// optionName,
|
|
// canvas.getObjects().filter((obj) => optionName.includes(obj.name)),
|
|
// )
|
|
}
|
|
}
|
|
|
|
return {
|
|
canvas,
|
|
correntObjectNo,
|
|
settingModalFirstOptions,
|
|
setSettingModalFirstOptions,
|
|
settingModalSecondOptions,
|
|
setSettingModalSecondOptions,
|
|
adsorptionPointMode,
|
|
setAdsorptionPointMode,
|
|
adsorptionRange,
|
|
setAdsorptionRange,
|
|
fetchSettings,
|
|
frontSettings,
|
|
globalFont,
|
|
setGlobalFont,
|
|
selectedFont,
|
|
setSelectedFont,
|
|
selectedFontWeight,
|
|
setSelectedFontWeight,
|
|
selectedFontSize,
|
|
setSelectedFontSize,
|
|
selectedFontColor,
|
|
setSelectedFontColor,
|
|
dimensionLineSettings,
|
|
setDimensionLineSettings,
|
|
planSizeSettingMode,
|
|
setPlanSizeSettingMode,
|
|
SelectOptions,
|
|
currentSetting,
|
|
setCurrentSetting,
|
|
dotLineGridSettingState,
|
|
setDotLineGridSettingState,
|
|
resetDotLineGridSetting,
|
|
setSettingModalGridOptions,
|
|
gridColor,
|
|
setGridColor,
|
|
color,
|
|
setColor,
|
|
canvasSetting,
|
|
setCanvasSetting,
|
|
basicSetting,
|
|
setBasicSettings,
|
|
fetchBasicSettings,
|
|
basicSettingSave,
|
|
settingsData,
|
|
setSettingsData,
|
|
settingsDataSave,
|
|
setSettingsDataSave,
|
|
}
|
|
}
|