Merge branch 'dev' of https://git.jetbrains.space/nalpari/q-cast-iii/qcast-front into qcast-pub
This commit is contained in:
commit
d80368d3a9
@ -50,7 +50,6 @@ export default async function RootLayout({ children }) {
|
|||||||
isLoggedIn: session.isLoggedIn,
|
isLoggedIn: session.isLoggedIn,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!headerPathname.includes('/login') && !session.isLoggedIn) {
|
if (!headerPathname.includes('/login') && !session.isLoggedIn) {
|
||||||
redirect('/login')
|
redirect('/login')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import Image from 'next/image'
|
|||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { useRecoilState } from 'recoil'
|
import { useRecoilState } from 'recoil'
|
||||||
import { useAxios } from '@/hooks/useAxios'
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
import { setSession } from '@/lib/authActions'
|
import { setSession, login } from '@/lib/authActions'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { globalLocaleStore } from '@/store/localeAtom'
|
import { globalLocaleStore } from '@/store/localeAtom'
|
||||||
import { sessionStore } from '@/store/commonAtom'
|
import { sessionStore } from '@/store/commonAtom'
|
||||||
@ -36,7 +36,7 @@ export default function Login() {
|
|||||||
const result = { ...response, storeLvl: response.groupId === '60000' ? '1' : '2', pwdInitYn: 'Y' }
|
const result = { ...response, storeLvl: response.groupId === '60000' ? '1' : '2', pwdInitYn: 'Y' }
|
||||||
setSession(result)
|
setSession(result)
|
||||||
setSessionState(result)
|
setSessionState(result)
|
||||||
router.push('/')
|
login()
|
||||||
} else {
|
} else {
|
||||||
router.push('/login')
|
router.push('/login')
|
||||||
}
|
}
|
||||||
@ -87,7 +87,6 @@ export default function Login() {
|
|||||||
}
|
}
|
||||||
await promisePost({ url: '/api/login/v1.0/login', data: param })
|
await promisePost({ url: '/api/login/v1.0/login', data: param })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log('🚀 ~ .then ~ res:', res)
|
|
||||||
if (res) {
|
if (res) {
|
||||||
if (res.data.result.resultCode === 'S') {
|
if (res.data.result.resultCode === 'S') {
|
||||||
setSession(res.data.data)
|
setSession(res.data.data)
|
||||||
@ -98,7 +97,8 @@ export default function Login() {
|
|||||||
} else {
|
} else {
|
||||||
Cookies.remove('chkLoginId')
|
Cookies.remove('chkLoginId')
|
||||||
}
|
}
|
||||||
router.push('/')
|
// router.push('/')
|
||||||
|
login()
|
||||||
} else {
|
} else {
|
||||||
alert(res.data.result.resultMsg)
|
alert(res.data.result.resultMsg)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,21 +3,106 @@ import { useRecoilValue } from 'recoil'
|
|||||||
import { contextPopupPositionState } from '@/store/popupAtom'
|
import { contextPopupPositionState } from '@/store/popupAtom'
|
||||||
import { usePopup } from '@/hooks/usePopup'
|
import { usePopup } from '@/hooks/usePopup'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
import { polygonToTurfPolygon } from '@/util/canvas-util'
|
||||||
|
import { deepCopyArray } from '@/util/common-utils'
|
||||||
|
import { canvasState } from '@/store/canvasAtom'
|
||||||
|
import * as turf from '@turf/turf'
|
||||||
|
import { POLYGON_TYPE } from '@/common/common'
|
||||||
|
|
||||||
export default function PanelEdit(props) {
|
export default function PanelEdit(props) {
|
||||||
const contextPopupPosition = useRecoilValue(contextPopupPositionState)
|
const contextPopupPosition = useRecoilValue(contextPopupPositionState)
|
||||||
const { id, pos = contextPopupPosition, type = 'move', apply } = props
|
const { id, pos = contextPopupPosition, type = 'move', apply } = props
|
||||||
const { closePopup } = usePopup()
|
const { closePopup } = usePopup()
|
||||||
const [length, setLength] = useState(0)
|
const [length, setLength] = useState(0)
|
||||||
const [direction, setDirection] = useState('')
|
const [direction, setDirection] = useState('up')
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
|
const canvas = useRecoilValue(canvasState)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (canvas) {
|
||||||
|
const isSetupModules = canvas.getObjects().filter((obj) => obj.name === 'module') // selectedObj에 없는 객체만 필터링
|
||||||
|
isSetupModules.forEach((obj) => obj.set({ lockMovementX: false, lockMovementY: false }))
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
//모듈 이동 적용
|
||||||
const handleApply = () => {
|
const handleApply = () => {
|
||||||
apply()
|
contextModuleMove(length, direction)
|
||||||
closePopup(id)
|
closePopup(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const contextModuleMove = (length, direction) => {
|
||||||
|
const checkModuleDisjointSurface = (squarePolygon, turfModuleSetupSurface) => {
|
||||||
|
return turf.booleanContains(turfModuleSetupSurface, squarePolygon) || turf.booleanWithin(squarePolygon, turfModuleSetupSurface)
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectedObj = canvas.getActiveObjects() //선택된 객체들을 가져옴
|
||||||
|
const selectedIds = selectedObj.map((obj) => obj.id) // selectedObj의 ID 추출
|
||||||
|
|
||||||
|
canvas.discardActiveObject() //선택해제
|
||||||
|
|
||||||
|
const isSetupModules = canvas.getObjects().filter((obj) => obj.name === 'module' && !selectedIds.includes(obj.id)) // selectedObj에 없는 객체만 필터링
|
||||||
|
const selectedModules = canvas.getObjects().filter((obj) => selectedIds.includes(obj.id) && obj.name === 'module') //선택했던 객체들만 가져옴
|
||||||
|
const setupSurface = canvas
|
||||||
|
.getObjects()
|
||||||
|
.filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE && obj.id === selectedModules[0].surfaceId)[0]
|
||||||
|
const isOverlapArray = []
|
||||||
|
const isInSurfaceArray = []
|
||||||
|
|
||||||
|
if (selectedModules) {
|
||||||
|
canvas.remove(...selectedModules)
|
||||||
|
|
||||||
|
selectedModules.forEach((module) => {
|
||||||
|
module.set({
|
||||||
|
originCoords: {
|
||||||
|
left: module.left,
|
||||||
|
top: module.top,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (direction === 'up') {
|
||||||
|
module.set({ ...module, top: module.top - Number(length) })
|
||||||
|
} else if (direction === 'down') {
|
||||||
|
module.set({ ...module, top: module.top + Number(length) })
|
||||||
|
} else if (direction === 'left') {
|
||||||
|
module.set({ ...module, left: module.left - Number(length) })
|
||||||
|
} else if (direction === 'right') {
|
||||||
|
module.set({ ...module, left: module.left + Number(length) })
|
||||||
|
}
|
||||||
|
module.setCoords()
|
||||||
|
canvas.renderAll()
|
||||||
|
|
||||||
|
//다른 모듈과 겹치는지 확인하는 로직
|
||||||
|
const isOverlap = isSetupModules.some((isSetupModule) =>
|
||||||
|
turf.booleanOverlap(polygonToTurfPolygon(module, true), polygonToTurfPolygon(isSetupModule, true)),
|
||||||
|
)
|
||||||
|
isOverlapArray.push(isOverlap)
|
||||||
|
|
||||||
|
const turfModuleSetupSurface = polygonToTurfPolygon(setupSurface, true)
|
||||||
|
const turfModule = polygonToTurfPolygon(module, true)
|
||||||
|
|
||||||
|
//나갔는지 확인하는 로직
|
||||||
|
const isInSurface = turf.booleanContains(turfModuleSetupSurface, turfModule) || turf.booleanWithin(turfModule, turfModuleSetupSurface)
|
||||||
|
isInSurfaceArray.push(isInSurface)
|
||||||
|
})
|
||||||
|
|
||||||
|
const isNotOverlap = isOverlapArray.some((isOverlap) => isOverlap) // true면 겹침
|
||||||
|
const isNotOutSurface = isInSurfaceArray.every((isOutSurface) => isOutSurface) //false면 밖으로 나감
|
||||||
|
|
||||||
|
//안겹치고 안나갔으면 이동시킨다 아니면 원래 위치로 돌려놓는다
|
||||||
|
if (isNotOverlap || !isNotOutSurface) {
|
||||||
|
selectedModules.forEach((module) => {
|
||||||
|
module.set({ ...module, left: module.originCoords.left, top: module.originCoords.top })
|
||||||
|
module.setCoords()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
canvas.add(...selectedModules)
|
||||||
|
canvas.renderAll()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WithDraggable isShow={true} pos={pos}>
|
<WithDraggable isShow={true} pos={pos}>
|
||||||
<div className={`modal-pop-wrap xm mount`}>
|
<div className={`modal-pop-wrap xm mount`}>
|
||||||
@ -34,33 +119,33 @@ export default function PanelEdit(props) {
|
|||||||
<div className="grid-input-form">
|
<div className="grid-input-form">
|
||||||
<span className="mr10">{getMessage('margin')}</span>
|
<span className="mr10">{getMessage('margin')}</span>
|
||||||
<div className="input-grid mr5">
|
<div className="input-grid mr5">
|
||||||
<input type="text" className="input-origin" defaultValue={0} onClick={(e) => setLength(e.target.value)} />
|
<input type="text" className="input-origin" defaultValue={0} onKeyUp={(e) => setLength(e.target.value)} />
|
||||||
</div>
|
</div>
|
||||||
<span>mm</span>
|
<span>mm</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid-direction">
|
<div className="grid-direction">
|
||||||
<button
|
<button
|
||||||
className={`direction up ${direction === '↑' ? 'act' : ''}`}
|
className={`direction up ${direction === 'up' ? 'act' : ''}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setDirection('↑')
|
setDirection('up')
|
||||||
}}
|
}}
|
||||||
></button>
|
></button>
|
||||||
<button
|
<button
|
||||||
className={`direction down ${direction === '↓' ? 'act' : ''}`}
|
className={`direction down ${direction === 'down' ? 'act' : ''}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setDirection('↓')
|
setDirection('down')
|
||||||
}}
|
}}
|
||||||
></button>
|
></button>
|
||||||
<button
|
<button
|
||||||
className={`direction left ${direction === '←' ? 'act' : ''}`}
|
className={`direction left ${direction === 'left' ? 'act' : ''}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setDirection('←')
|
setDirection('left')
|
||||||
}}
|
}}
|
||||||
></button>
|
></button>
|
||||||
<button
|
<button
|
||||||
className={`direction right ${direction === '→' ? 'act' : ''}`}
|
className={`direction right ${direction === 'right' ? 'act' : ''}`}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setDirection('→')
|
setDirection('right')
|
||||||
}}
|
}}
|
||||||
></button>
|
></button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -65,6 +65,7 @@ export function useCanvasConfigInitialize() {
|
|||||||
roofInit() //화면표시 초기화
|
roofInit() //화면표시 초기화
|
||||||
groupDimensionInit()
|
groupDimensionInit()
|
||||||
reGroupInit() //그룹 객체 재그룹
|
reGroupInit() //그룹 객체 재그룹
|
||||||
|
moduleInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
const gridInit = () => {
|
const gridInit = () => {
|
||||||
@ -196,5 +197,19 @@ export function useCanvasConfigInitialize() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const moduleInit = () => {
|
||||||
|
canvas
|
||||||
|
.getObjects()
|
||||||
|
.filter((obj) => obj.name === 'module')
|
||||||
|
.forEach((obj) => {
|
||||||
|
obj.set({
|
||||||
|
selectable: true,
|
||||||
|
lockMovementX: false,
|
||||||
|
lockMovementY: false,
|
||||||
|
})
|
||||||
|
obj.setViewLengthText(false)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return { canvasLoadInit, gridInit }
|
return { canvasLoadInit, gridInit }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -603,8 +603,12 @@ export function useCommonUtils() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const deleteObject = () => {
|
const deleteObject = () => {
|
||||||
const obj = canvas?.getActiveObject()
|
const selectedObj = canvas?.getActiveObjects()
|
||||||
commonDeleteText(obj)
|
if (selectedObj) {
|
||||||
|
selectedObj.forEach((obj) => {
|
||||||
|
commonDeleteText(obj)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const moveObject = () => {
|
const moveObject = () => {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||||
import { canvasState } from '@/store/canvasAtom'
|
import { canvasState } from '@/store/canvasAtom'
|
||||||
import { rectToPolygon } from '@/util/canvas-util'
|
import { rectToPolygon, setSurfaceShapePattern, polygonToTurfPolygon } from '@/util/canvas-util'
|
||||||
import { roofDisplaySelector } from '@/store/settingAtom'
|
import { basicSettingState, roofDisplaySelector } from '@/store/settingAtom'
|
||||||
import offsetPolygon, { calculateAngle } from '@/util/qpolygon-utils'
|
import offsetPolygon, { calculateAngle } from '@/util/qpolygon-utils'
|
||||||
import { QPolygon } from '@/components/fabric/QPolygon'
|
import { QPolygon } from '@/components/fabric/QPolygon'
|
||||||
import { moduleSetupSurfaceState, moduleIsSetupState } from '@/store/canvasAtom'
|
import { moduleSetupSurfaceState, moduleIsSetupState } from '@/store/canvasAtom'
|
||||||
@ -14,6 +14,7 @@ import { canvasSettingState } from '@/store/canvasAtom'
|
|||||||
import { compasDegAtom } from '@/store/orientationAtom'
|
import { compasDegAtom } from '@/store/orientationAtom'
|
||||||
import { QLine } from '@/components/fabric/QLine'
|
import { QLine } from '@/components/fabric/QLine'
|
||||||
import { useRoofFn } from '@/hooks/common/useRoofFn'
|
import { useRoofFn } from '@/hooks/common/useRoofFn'
|
||||||
|
import { useEffect } from 'react'
|
||||||
|
|
||||||
export function useModuleBasicSetting() {
|
export function useModuleBasicSetting() {
|
||||||
const canvas = useRecoilValue(canvasState)
|
const canvas = useRecoilValue(canvasState)
|
||||||
@ -25,10 +26,37 @@ export function useModuleBasicSetting() {
|
|||||||
const canvasSetting = useRecoilValue(canvasSettingState)
|
const canvasSetting = useRecoilValue(canvasSettingState)
|
||||||
const compasDeg = useRecoilValue(compasDegAtom)
|
const compasDeg = useRecoilValue(compasDegAtom)
|
||||||
const { setSurfaceShapePattern } = useRoofFn()
|
const { setSurfaceShapePattern } = useRoofFn()
|
||||||
|
const [basicSetting, setBasicSettings] = useRecoilState(basicSettingState)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// console.log('basicSetting', basicSetting)
|
||||||
|
if (canvas) {
|
||||||
|
canvas.selection = true
|
||||||
|
canvas.selectionFullyContained = true
|
||||||
|
// canvas.on('selection:created', (e) => {
|
||||||
|
// console.log('selection:created', e.selected)
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
// const { addTargetMouseEventListener, addCanvasMouseEventListener, initEvent } = useContext(EventContext)
|
// const { addTargetMouseEventListener, addCanvasMouseEventListener, initEvent } = useContext(EventContext)
|
||||||
let selectedModuleInstSurfaceArray = []
|
let selectedModuleInstSurfaceArray = []
|
||||||
|
|
||||||
|
const moduleOptions = {
|
||||||
|
fill: '#BFFD9F',
|
||||||
|
stroke: 'black',
|
||||||
|
strokeWidth: 0.1,
|
||||||
|
selectable: true, // 선택 가능하게 설정
|
||||||
|
lockMovementX: true, // X 축 이동 잠금
|
||||||
|
lockMovementY: true, // Y 축 이동 잠금
|
||||||
|
lockRotation: true, // 회전 잠금
|
||||||
|
lockScalingX: true, // X 축 크기 조정 잠금
|
||||||
|
lockScalingY: true, // Y 축 크기 조정 잠금
|
||||||
|
parentId: moduleSetupSurface.parentId,
|
||||||
|
surfaceId: moduleSetupSurface.id,
|
||||||
|
name: 'module',
|
||||||
|
}
|
||||||
|
|
||||||
//모듈,회로에서 다른메뉴 -> 배치면으로 갈 경수 초기화
|
//모듈,회로에서 다른메뉴 -> 배치면으로 갈 경수 초기화
|
||||||
const restoreModuleInstArea = () => {
|
const restoreModuleInstArea = () => {
|
||||||
//설치면 삭제
|
//설치면 삭제
|
||||||
@ -176,21 +204,6 @@ export function useModuleBasicSetting() {
|
|||||||
obj.name === BATCH_TYPE.SHADOW,
|
obj.name === BATCH_TYPE.SHADOW,
|
||||||
) //도머s 객체
|
) //도머s 객체
|
||||||
|
|
||||||
const moduleOptions = {
|
|
||||||
fill: '#BFFD9F',
|
|
||||||
stroke: 'black',
|
|
||||||
strokeWidth: 0.1,
|
|
||||||
selectable: false, // 선택 가능하게 설정
|
|
||||||
lockMovementX: true, // X 축 이동 잠금
|
|
||||||
lockMovementY: true, // Y 축 이동 잠금
|
|
||||||
lockRotation: true, // 회전 잠금
|
|
||||||
lockScalingX: true, // X 축 크기 조정 잠금
|
|
||||||
lockScalingY: true, // Y 축 크기 조정 잠금
|
|
||||||
opacity: 0.8,
|
|
||||||
parentId: moduleSetupSurface.parentId,
|
|
||||||
name: 'module',
|
|
||||||
}
|
|
||||||
|
|
||||||
if (moduleSetupSurfaces.length !== 0) {
|
if (moduleSetupSurfaces.length !== 0) {
|
||||||
let tempModule
|
let tempModule
|
||||||
let manualDrawModules = []
|
let manualDrawModules = []
|
||||||
@ -229,7 +242,7 @@ export function useModuleBasicSetting() {
|
|||||||
tempModule = new fabric.Rect({
|
tempModule = new fabric.Rect({
|
||||||
fill: 'white',
|
fill: 'white',
|
||||||
stroke: 'black',
|
stroke: 'black',
|
||||||
strokeWidth: 1,
|
strokeWidth: 0.3,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
left: mousePoint.x - width / 2,
|
left: mousePoint.x - width / 2,
|
||||||
@ -240,7 +253,6 @@ export function useModuleBasicSetting() {
|
|||||||
lockRotation: true,
|
lockRotation: true,
|
||||||
lockScalingX: true,
|
lockScalingX: true,
|
||||||
lockScalingY: true,
|
lockScalingY: true,
|
||||||
opacity: 0.8,
|
|
||||||
name: 'tempModule',
|
name: 'tempModule',
|
||||||
parentId: moduleSetupSurfaces[i].parentId,
|
parentId: moduleSetupSurfaces[i].parentId,
|
||||||
})
|
})
|
||||||
@ -440,6 +452,7 @@ export function useModuleBasicSetting() {
|
|||||||
canvas?.remove(tempModule)
|
canvas?.remove(tempModule)
|
||||||
//안겹치면 넣는다
|
//안겹치면 넣는다
|
||||||
// tempModule.setCoords()
|
// tempModule.setCoords()
|
||||||
|
moduleOptions.surfaceId = trestlePolygon.id
|
||||||
let manualModule = new QPolygon(tempModule.points, { ...moduleOptions })
|
let manualModule = new QPolygon(tempModule.points, { ...moduleOptions })
|
||||||
canvas?.add(manualModule)
|
canvas?.add(manualModule)
|
||||||
manualDrawModules.push(manualModule)
|
manualDrawModules.push(manualModule)
|
||||||
@ -516,15 +529,15 @@ export function useModuleBasicSetting() {
|
|||||||
const moduleOptions = {
|
const moduleOptions = {
|
||||||
fill: '#BFFD9F',
|
fill: '#BFFD9F',
|
||||||
stroke: 'black',
|
stroke: 'black',
|
||||||
strokeWidth: 0.1,
|
strokeWidth: 0.3,
|
||||||
selectable: false, // 선택 가능하게 설정
|
selectable: true, // 선택 가능하게 설정
|
||||||
lockMovementX: true, // X 축 이동 잠금
|
lockMovementX: true, // X 축 이동 잠금
|
||||||
lockMovementY: true, // Y 축 이동 잠금
|
lockMovementY: true, // Y 축 이동 잠금
|
||||||
lockRotation: true, // 회전 잠금
|
lockRotation: true, // 회전 잠금
|
||||||
lockScalingX: true, // X 축 크기 조정 잠금
|
lockScalingX: true, // X 축 크기 조정 잠금
|
||||||
lockScalingY: true, // Y 축 크기 조정 잠금
|
lockScalingY: true, // Y 축 크기 조정 잠금
|
||||||
opacity: 0.8,
|
|
||||||
parentId: moduleSetupSurface.parentId,
|
parentId: moduleSetupSurface.parentId,
|
||||||
|
surfaceId: moduleSetupSurface.id,
|
||||||
name: 'module',
|
name: 'module',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -593,7 +606,8 @@ export function useModuleBasicSetting() {
|
|||||||
return turf.booleanContains(turfModuleSetupSurface, squarePolygon) || turf.booleanWithin(squarePolygon, turfModuleSetupSurface)
|
return turf.booleanContains(turfModuleSetupSurface, squarePolygon) || turf.booleanWithin(squarePolygon, turfModuleSetupSurface)
|
||||||
}
|
}
|
||||||
|
|
||||||
const downFlowSetupModule = (surfaceMaxLines, width, height, moduleSetupArray, flowModuleLine, isCenter = false) => {
|
const downFlowSetupModule = (surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface, isCenter = false) => {
|
||||||
|
const flowModuleLine = moduleSetupSurface.flowLines
|
||||||
let startPoint = flowModuleLine.bottom
|
let startPoint = flowModuleLine.bottom
|
||||||
|
|
||||||
if (isCenter) {
|
if (isCenter) {
|
||||||
@ -637,9 +651,9 @@ export function useModuleBasicSetting() {
|
|||||||
if (isMaxSetup) totalWidth = totalWidth * 2 //최대배치시 2배로 늘려서 반씩 검사하기위함
|
if (isMaxSetup) totalWidth = totalWidth * 2 //최대배치시 2배로 늘려서 반씩 검사하기위함
|
||||||
|
|
||||||
for (let j = 0; j < diffTopEndPoint; j++) {
|
for (let j = 0; j < diffTopEndPoint; j++) {
|
||||||
bottomMargin = j === 0 ? 1 : 2
|
bottomMargin = 1 * j
|
||||||
for (let i = 0; i <= totalWidth; i++) {
|
for (let i = 0; i <= totalWidth; i++) {
|
||||||
leftMargin = i === 0 ? 1 : 2
|
leftMargin = 1 * i
|
||||||
chidoriLength = 0
|
chidoriLength = 0
|
||||||
if (isChidori) {
|
if (isChidori) {
|
||||||
chidoriLength = j % 2 === 0 ? 0 : width / 2
|
chidoriLength = j % 2 === 0 ? 0 : width / 2
|
||||||
@ -657,6 +671,7 @@ export function useModuleBasicSetting() {
|
|||||||
let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
|
let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
|
||||||
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
||||||
|
|
||||||
|
moduleOptions.surfaceId = moduleSetupSurface.id
|
||||||
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
||||||
canvas?.add(tempModule)
|
canvas?.add(tempModule)
|
||||||
moduleSetupArray.push(tempModule)
|
moduleSetupArray.push(tempModule)
|
||||||
@ -664,7 +679,8 @@ export function useModuleBasicSetting() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const leftFlowSetupModule = (surfaceMaxLines, width, height, moduleSetupArray, aaa, isCenter = false) => {
|
const leftFlowSetupModule = (surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface, isCenter = false) => {
|
||||||
|
const flowModuleLine = moduleSetupSurface.flowLines
|
||||||
let startPoint = flowModuleLine.left
|
let startPoint = flowModuleLine.left
|
||||||
|
|
||||||
//중앙배치일 경우에는 계산한다
|
//중앙배치일 경우에는 계산한다
|
||||||
@ -718,6 +734,7 @@ export function useModuleBasicSetting() {
|
|||||||
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
||||||
|
|
||||||
// if (disjointFromTrestle && isDisjoint) {
|
// if (disjointFromTrestle && isDisjoint) {
|
||||||
|
moduleOptions.surfaceId = moduleSetupSurface.id
|
||||||
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
||||||
canvas?.add(tempModule)
|
canvas?.add(tempModule)
|
||||||
moduleSetupArray.push(tempModule)
|
moduleSetupArray.push(tempModule)
|
||||||
@ -725,7 +742,8 @@ export function useModuleBasicSetting() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const topFlowSetupModule = (surfaceMaxLines, width, height, moduleSetupArray, flowModuleLine, isCenter = false) => {
|
const topFlowSetupModule = (surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface, isCenter = false) => {
|
||||||
|
const flowModuleLine = moduleSetupSurface.flowLines
|
||||||
let startPoint = flowModuleLine.top
|
let startPoint = flowModuleLine.top
|
||||||
|
|
||||||
if (isCenter) {
|
if (isCenter) {
|
||||||
@ -789,6 +807,7 @@ export function useModuleBasicSetting() {
|
|||||||
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
||||||
|
|
||||||
// if (disjointFromTrestle && isDisjoint) {
|
// if (disjointFromTrestle && isDisjoint) {
|
||||||
|
moduleOptions.surfaceId = moduleSetupSurface.id
|
||||||
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
||||||
canvas?.add(tempModule)
|
canvas?.add(tempModule)
|
||||||
moduleSetupArray.push(tempModule)
|
moduleSetupArray.push(tempModule)
|
||||||
@ -796,7 +815,8 @@ export function useModuleBasicSetting() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const rightFlowSetupModule = (surfaceMaxLines, width, height, moduleSetupArray, flowModuleLine, isCenter = false) => {
|
const rightFlowSetupModule = (surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface, isCenter = false) => {
|
||||||
|
const flowModuleLine = moduleSetupSurface.flowLines
|
||||||
let startPoint = flowModuleLine.right
|
let startPoint = flowModuleLine.right
|
||||||
|
|
||||||
if (isCenter) {
|
if (isCenter) {
|
||||||
@ -850,6 +870,7 @@ export function useModuleBasicSetting() {
|
|||||||
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
||||||
|
|
||||||
// if (disjointFromTrestle && isDisjoint) {
|
// if (disjointFromTrestle && isDisjoint) {
|
||||||
|
moduleOptions.surfaceId = moduleSetupSurface.id
|
||||||
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
||||||
canvas?.add(tempModule)
|
canvas?.add(tempModule)
|
||||||
moduleSetupArray.push(tempModule)
|
moduleSetupArray.push(tempModule)
|
||||||
@ -883,44 +904,44 @@ export function useModuleBasicSetting() {
|
|||||||
if (setupLocation === 'eaves') {
|
if (setupLocation === 'eaves') {
|
||||||
// 흐름방향이 남쪽일때
|
// 흐름방향이 남쪽일때
|
||||||
if (moduleSetupSurface.flowDirection === 'south') {
|
if (moduleSetupSurface.flowDirection === 'south') {
|
||||||
downFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface.flowLines)
|
downFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface)
|
||||||
}
|
}
|
||||||
if (moduleSetupSurface.flowDirection === 'west') {
|
if (moduleSetupSurface.flowDirection === 'west') {
|
||||||
leftFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface.flowLines)
|
leftFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface)
|
||||||
}
|
}
|
||||||
if (moduleSetupSurface.flowDirection === 'east') {
|
if (moduleSetupSurface.flowDirection === 'east') {
|
||||||
rightFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface.flowLines)
|
rightFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface)
|
||||||
}
|
}
|
||||||
if (moduleSetupSurface.flowDirection === 'north') {
|
if (moduleSetupSurface.flowDirection === 'north') {
|
||||||
topFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface.flowLines)
|
topFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface)
|
||||||
}
|
}
|
||||||
} else if (setupLocation === 'ridge') {
|
} else if (setupLocation === 'ridge') {
|
||||||
//용마루
|
//용마루
|
||||||
if (moduleSetupSurface.flowDirection === 'south') {
|
if (moduleSetupSurface.flowDirection === 'south') {
|
||||||
topFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface.flowLines)
|
topFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface)
|
||||||
}
|
}
|
||||||
if (moduleSetupSurface.flowDirection === 'west') {
|
if (moduleSetupSurface.flowDirection === 'west') {
|
||||||
rightFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface.flowLines)
|
rightFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface)
|
||||||
}
|
}
|
||||||
if (moduleSetupSurface.flowDirection === 'east') {
|
if (moduleSetupSurface.flowDirection === 'east') {
|
||||||
leftFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface.flowLines)
|
leftFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface)
|
||||||
}
|
}
|
||||||
if (moduleSetupSurface.flowDirection === 'north') {
|
if (moduleSetupSurface.flowDirection === 'north') {
|
||||||
downFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface.flowLines)
|
downFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface)
|
||||||
}
|
}
|
||||||
} else if (setupLocation === 'center') {
|
} else if (setupLocation === 'center') {
|
||||||
//중가면
|
//중가면
|
||||||
if (moduleSetupSurface.flowDirection === 'south') {
|
if (moduleSetupSurface.flowDirection === 'south') {
|
||||||
downFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface.flowLines, true)
|
downFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface, true)
|
||||||
}
|
}
|
||||||
if (moduleSetupSurface.flowDirection === 'west') {
|
if (moduleSetupSurface.flowDirection === 'west') {
|
||||||
leftFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface.flowLines, true)
|
leftFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface, true)
|
||||||
}
|
}
|
||||||
if (moduleSetupSurface.flowDirection === 'east') {
|
if (moduleSetupSurface.flowDirection === 'east') {
|
||||||
rightFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface.flowLines, true)
|
rightFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface, true)
|
||||||
}
|
}
|
||||||
if (moduleSetupSurface.flowDirection === 'north') {
|
if (moduleSetupSurface.flowDirection === 'north') {
|
||||||
topFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface.flowLines, true)
|
topFlowSetupModule(surfaceMaxLines, width, height, moduleSetupArray, moduleSetupSurface, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1214,20 +1235,6 @@ export function useModuleBasicSetting() {
|
|||||||
return turf.polygon([coordinates])
|
return turf.polygon([coordinates])
|
||||||
}
|
}
|
||||||
|
|
||||||
const polygonToTurfPolygon = (object, current = false) => {
|
|
||||||
let coordinates
|
|
||||||
coordinates = object.points.map((point) => [point.x, point.y])
|
|
||||||
if (current) coordinates = object.getCurrentPoints().map((point) => [point.x, point.y])
|
|
||||||
coordinates.push(coordinates[0])
|
|
||||||
return turf.polygon(
|
|
||||||
[coordinates],
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
parentId: object.parentId,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const batchObjectGroupToTurfPolygon = (group) => {
|
const batchObjectGroupToTurfPolygon = (group) => {
|
||||||
const polygons = group.getObjects().filter((obj) => obj.type === 'QPolygon')
|
const polygons = group.getObjects().filter((obj) => obj.type === 'QPolygon')
|
||||||
let allPoints = []
|
let allPoints = []
|
||||||
@ -1547,14 +1554,14 @@ export function useModuleBasicSetting() {
|
|||||||
fill: '#BFFD9F',
|
fill: '#BFFD9F',
|
||||||
stroke: 'black',
|
stroke: 'black',
|
||||||
strokeWidth: 0.1,
|
strokeWidth: 0.1,
|
||||||
selectable: false, // 선택 가능하게 설정
|
selectable: true, // 선택 가능하게 설정
|
||||||
lockMovementX: true, // X 축 이동 잠금
|
lockMovementX: true, // X 축 이동 잠금
|
||||||
lockMovementY: true, // Y 축 이동 잠금
|
lockMovementY: true, // Y 축 이동 잠금
|
||||||
lockRotation: true, // 회전 잠금
|
lockRotation: true, // 회전 잠금
|
||||||
lockScalingX: true, // X 축 크기 조정 잠금
|
lockScalingX: true, // X 축 크기 조정 잠금
|
||||||
lockScalingY: true, // Y 축 크기 조정 잠금
|
lockScalingY: true, // Y 축 크기 조정 잠금
|
||||||
opacity: 0.8,
|
|
||||||
parentId: moduleSetupSurface.parentId,
|
parentId: moduleSetupSurface.parentId,
|
||||||
|
surfaceId: moduleSetupSurface.id,
|
||||||
name: 'module',
|
name: 'module',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1602,7 +1609,7 @@ export function useModuleBasicSetting() {
|
|||||||
const mousePoint = canvas.getPointer(e.e)
|
const mousePoint = canvas.getPointer(e.e)
|
||||||
|
|
||||||
for (let i = 0; i < moduleSetupSurfaces.length; i++) {
|
for (let i = 0; i < moduleSetupSurfaces.length; i++) {
|
||||||
turfPolygon = polygonToTurfPolygon(moduleSetupSurfaces[i])
|
turfPolygon = polygonToTurfPolygon(moduleSetupSurfaces[i], true)
|
||||||
trestlePolygon = moduleSetupSurfaces[i]
|
trestlePolygon = moduleSetupSurfaces[i]
|
||||||
manualDrawModules = moduleSetupSurfaces[i].modules // 앞에서 자동으로 했을때 추가됨
|
manualDrawModules = moduleSetupSurfaces[i].modules // 앞에서 자동으로 했을때 추가됨
|
||||||
flowDirection = moduleSetupSurfaces[i].flowDirection //도형의 방향
|
flowDirection = moduleSetupSurfaces[i].flowDirection //도형의 방향
|
||||||
@ -1627,7 +1634,7 @@ export function useModuleBasicSetting() {
|
|||||||
tempModule = new fabric.Rect({
|
tempModule = new fabric.Rect({
|
||||||
fill: 'white',
|
fill: 'white',
|
||||||
stroke: 'black',
|
stroke: 'black',
|
||||||
strokeWidth: 1,
|
strokeWidth: 0.3,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
left: mousePoint.x - width / 2,
|
left: mousePoint.x - width / 2,
|
||||||
@ -1638,7 +1645,6 @@ export function useModuleBasicSetting() {
|
|||||||
lockRotation: true,
|
lockRotation: true,
|
||||||
lockScalingX: true,
|
lockScalingX: true,
|
||||||
lockScalingY: true,
|
lockScalingY: true,
|
||||||
opacity: 0.8,
|
|
||||||
name: 'tempModule',
|
name: 'tempModule',
|
||||||
parentId: moduleSetupSurfaces[i].parentId,
|
parentId: moduleSetupSurfaces[i].parentId,
|
||||||
})
|
})
|
||||||
@ -1833,8 +1839,7 @@ export function useModuleBasicSetting() {
|
|||||||
//마우스 클릭시 set으로 해당 위치에 셀을 넣음
|
//마우스 클릭시 set으로 해당 위치에 셀을 넣음
|
||||||
const isOverlap = manualDrawModules.some((module) => turf.booleanOverlap(tempTurfModule, polygonToTurfPolygon(module))) //겹치는지 확인
|
const isOverlap = manualDrawModules.some((module) => turf.booleanOverlap(tempTurfModule, polygonToTurfPolygon(module))) //겹치는지 확인
|
||||||
if (!isOverlap) {
|
if (!isOverlap) {
|
||||||
console.log('tempModule.points', tempModule.points)
|
moduleOptions.surfaceId = trestlePolygon.id
|
||||||
|
|
||||||
let manualModule = new QPolygon(tempModule.points, { ...moduleOptions })
|
let manualModule = new QPolygon(tempModule.points, { ...moduleOptions })
|
||||||
canvas?.add(manualModule)
|
canvas?.add(manualModule)
|
||||||
manualDrawModules.push(tempModule)
|
manualDrawModules.push(tempModule)
|
||||||
@ -1956,14 +1961,14 @@ export function useModuleBasicSetting() {
|
|||||||
fill: '#BFFD9F',
|
fill: '#BFFD9F',
|
||||||
stroke: 'black',
|
stroke: 'black',
|
||||||
strokeWidth: 0.1,
|
strokeWidth: 0.1,
|
||||||
selectable: false, // 선택 가능하게 설정
|
selectable: true, // 선택 가능하게 설정
|
||||||
lockMovementX: true, // X 축 이동 잠금
|
lockMovementX: true, // X 축 이동 잠금
|
||||||
lockMovementY: true, // Y 축 이동 잠금
|
lockMovementY: true, // Y 축 이동 잠금
|
||||||
lockRotation: true, // 회전 잠금
|
lockRotation: true, // 회전 잠금
|
||||||
lockScalingX: true, // X 축 크기 조정 잠금
|
lockScalingX: true, // X 축 크기 조정 잠금
|
||||||
lockScalingY: true, // Y 축 크기 조정 잠금
|
lockScalingY: true, // Y 축 크기 조정 잠금
|
||||||
opacity: 0.8,
|
|
||||||
parentId: moduleSetupSurface.parentId,
|
parentId: moduleSetupSurface.parentId,
|
||||||
|
surfaceId: moduleSetupSurface.id,
|
||||||
name: 'module',
|
name: 'module',
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2066,6 +2071,7 @@ export function useModuleBasicSetting() {
|
|||||||
let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
|
let turfCoordnates = squarePolygon.geometry.coordinates[0].slice(0, -1)
|
||||||
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
||||||
|
|
||||||
|
moduleOptions.surfaceId = moduleSetupSurface.id
|
||||||
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
||||||
canvas?.add(tempModule)
|
canvas?.add(tempModule)
|
||||||
moduleSetupArray.push(tempModule)
|
moduleSetupArray.push(tempModule)
|
||||||
@ -2105,6 +2111,7 @@ export function useModuleBasicSetting() {
|
|||||||
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
||||||
|
|
||||||
// if (disjointFromTrestle && isDisjoint) {
|
// if (disjointFromTrestle && isDisjoint) {
|
||||||
|
moduleOptions.surfaceId = moduleSetupSurface.id
|
||||||
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
||||||
canvas?.add(tempModule)
|
canvas?.add(tempModule)
|
||||||
moduleSetupArray.push(tempModule)
|
moduleSetupArray.push(tempModule)
|
||||||
@ -2147,6 +2154,7 @@ export function useModuleBasicSetting() {
|
|||||||
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
||||||
|
|
||||||
// if (disjointFromTrestle && isDisjoint) {
|
// if (disjointFromTrestle && isDisjoint) {
|
||||||
|
moduleOptions.surfaceId = moduleSetupSurface.id
|
||||||
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
||||||
canvas?.add(tempModule)
|
canvas?.add(tempModule)
|
||||||
moduleSetupArray.push(tempModule)
|
moduleSetupArray.push(tempModule)
|
||||||
@ -2187,6 +2195,7 @@ export function useModuleBasicSetting() {
|
|||||||
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
let points = turfCoordnates.map((coord) => ({ x: coord[0], y: coord[1] }))
|
||||||
|
|
||||||
// if (disjointFromTrestle && isDisjoint) {
|
// if (disjointFromTrestle && isDisjoint) {
|
||||||
|
moduleOptions.surfaceId = moduleSetupSurface.id
|
||||||
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
let tempModule = new QPolygon(points, { ...moduleOptions, turfPoints: squarePolygon })
|
||||||
canvas?.add(tempModule)
|
canvas?.add(tempModule)
|
||||||
moduleSetupArray.push(tempModule)
|
moduleSetupArray.push(tempModule)
|
||||||
@ -2274,6 +2283,8 @@ export function useModuleBasicSetting() {
|
|||||||
// canvas.add(groupTest)
|
// canvas.add(groupTest)
|
||||||
})
|
})
|
||||||
// console.log(calculateForApi())
|
// console.log(calculateForApi())
|
||||||
|
|
||||||
|
//드래그 하기위해 기능 활성화
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@ -597,12 +597,13 @@ export function useContextMenu() {
|
|||||||
],
|
],
|
||||||
])
|
])
|
||||||
break
|
break
|
||||||
case 'panel':
|
case 'module':
|
||||||
setContextMenu([
|
setContextMenu([
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
id: 'remove',
|
id: 'remove',
|
||||||
name: getMessage('contextmenu.remove'),
|
name: getMessage('contextmenu.remove'),
|
||||||
|
fn: () => deleteObject(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'move',
|
id: 'move',
|
||||||
@ -661,7 +662,7 @@ export function useContextMenu() {
|
|||||||
],
|
],
|
||||||
])
|
])
|
||||||
break
|
break
|
||||||
case 'module':
|
case 'moduleSetupSurface':
|
||||||
case 'dimensionLineText':
|
case 'dimensionLineText':
|
||||||
setContextMenu([
|
setContextMenu([
|
||||||
[
|
[
|
||||||
|
|||||||
@ -59,33 +59,36 @@ export async function setSession(data) {
|
|||||||
await session.save()
|
await session.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function login(formData) {
|
export async function login() {
|
||||||
const session = await getSession()
|
const session = await getSession()
|
||||||
|
if (session) {
|
||||||
const userId = formData.get('id')
|
redirect('/')
|
||||||
const password = formData.get('password')
|
|
||||||
|
|
||||||
console.log('id:', userId)
|
|
||||||
console.log('password:', password)
|
|
||||||
|
|
||||||
// const loginUser = await getUserByIdAndPassword({ userId, password })
|
|
||||||
const loginUser = {
|
|
||||||
id: 1,
|
|
||||||
userId: 'test123',
|
|
||||||
name: 'jinsoo Kim',
|
|
||||||
email: 'jinsoo.kim@example.com',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loginUser) {
|
// const userId = formData.get('id')
|
||||||
throw Error('Wrong Credentials!')
|
// const password = formData.get('password')
|
||||||
}
|
|
||||||
|
|
||||||
session.name = loginUser.name
|
// console.log('id:', userId)
|
||||||
session.userId = loginUser.userId
|
// console.log('password:', password)
|
||||||
session.email = loginUser.email
|
|
||||||
session.isLoggedIn = true
|
|
||||||
console.log('session:', session)
|
|
||||||
|
|
||||||
await session.save()
|
// // const loginUser = await getUserByIdAndPassword({ userId, password })
|
||||||
redirect('/')
|
// const loginUser = {
|
||||||
|
// id: 1,
|
||||||
|
// userId: 'test123',
|
||||||
|
// name: 'jinsoo Kim',
|
||||||
|
// email: 'jinsoo.kim@example.com',
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (!loginUser) {
|
||||||
|
// throw Error('Wrong Credentials!')
|
||||||
|
// }
|
||||||
|
|
||||||
|
// session.name = loginUser.name
|
||||||
|
// session.userId = loginUser.userId
|
||||||
|
// session.email = loginUser.email
|
||||||
|
// session.isLoggedIn = true
|
||||||
|
// console.log('session:', session)
|
||||||
|
|
||||||
|
// await session.save()
|
||||||
|
// redirect('/')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -751,18 +751,6 @@ export const pointsToTurfPolygon = (points) => {
|
|||||||
return turf.polygon([coordinates])
|
return turf.polygon([coordinates])
|
||||||
}
|
}
|
||||||
|
|
||||||
export const polygonToTurfPolygon = (polygon) => {
|
|
||||||
const coordinates = polygon.points.map((point) => [point.x, point.y])
|
|
||||||
coordinates.push(coordinates[0])
|
|
||||||
return turf.polygon(
|
|
||||||
[coordinates],
|
|
||||||
{},
|
|
||||||
{
|
|
||||||
parentId: polygon.parentId,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const triangleToPolygon = (triangle) => {
|
export const triangleToPolygon = (triangle) => {
|
||||||
const points = []
|
const points = []
|
||||||
const halfWidth = triangle.width / 2
|
const halfWidth = triangle.width / 2
|
||||||
@ -1003,3 +991,17 @@ export function findAndRemoveClosestPoint(targetPoint, points) {
|
|||||||
|
|
||||||
return closestPoint
|
return closestPoint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function polygonToTurfPolygon(object, current = false) {
|
||||||
|
let coordinates
|
||||||
|
coordinates = object.points.map((point) => [point.x, point.y])
|
||||||
|
if (current) coordinates = object.getCurrentPoints().map((point) => [point.x, point.y])
|
||||||
|
coordinates.push(coordinates[0])
|
||||||
|
return turf.polygon(
|
||||||
|
[coordinates],
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
parentId: object.parentId,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user