오브젝트 이동 수정
This commit is contained in:
parent
69ebe48570
commit
4ac63f2376
@ -92,7 +92,7 @@ export function useModuleSelection(props) {
|
|||||||
//해당 메뉴 이동시 배치면 삭제
|
//해당 메뉴 이동시 배치면 삭제
|
||||||
const moduleSurfacesArray = canvas
|
const moduleSurfacesArray = canvas
|
||||||
.getObjects()
|
.getObjects()
|
||||||
.filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE || obj.name === POLYGON_TYPE.MODULE)
|
.filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE || obj.name === POLYGON_TYPE.MODULE || obj.name === POLYGON_TYPE.OBJECT_SURFACE)
|
||||||
if (moduleSurfacesArray.length > 0) {
|
if (moduleSurfacesArray.length > 0) {
|
||||||
moduleSurfacesArray.forEach((moduleSurface) => {
|
moduleSurfacesArray.forEach((moduleSurface) => {
|
||||||
canvas.remove(moduleSurface)
|
canvas.remove(moduleSurface)
|
||||||
|
|||||||
@ -78,7 +78,15 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getConstructionListData = async (params) => {
|
const getConstructionListData = async (params) => {
|
||||||
if (params.trestleMkrCd && params.constMthdCd && params.roofBaseCd) {
|
if (
|
||||||
|
params.trestleMkrCd &&
|
||||||
|
params.constMthdCd &&
|
||||||
|
params.roofBaseCd &&
|
||||||
|
params.illuminationTp &&
|
||||||
|
params.stdWindSpeed &&
|
||||||
|
params.instHt &&
|
||||||
|
params.stdSnowLd
|
||||||
|
) {
|
||||||
const optionsList = await getConstructionList(params)
|
const optionsList = await getConstructionList(params)
|
||||||
setConstructionList(optionsList.data)
|
setConstructionList(optionsList.data)
|
||||||
}
|
}
|
||||||
@ -151,7 +159,7 @@ export function useModuleTabContents({ tabIndex, addRoof, setAddedRoofs, roofTab
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isExistData) {
|
if (isExistData) {
|
||||||
setConstructionListParams({
|
setConstructionListParams({
|
||||||
...moduleSelectionInitParams,
|
...moduleSelectionData.common,
|
||||||
...roofBaseParams,
|
...roofBaseParams,
|
||||||
roofBaseCd: selectedRoofBase.roofBaseCd,
|
roofBaseCd: selectedRoofBase.roofBaseCd,
|
||||||
inclCd: addRoof.pitch,
|
inclCd: addRoof.pitch,
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { useEffect } from 'react'
|
|||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { useRecoilValue } from 'recoil'
|
import { useRecoilValue } from 'recoil'
|
||||||
import { canvasState } from '@/store/canvasAtom'
|
import { canvasState } from '@/store/canvasAtom'
|
||||||
import { BATCH_TYPE, INPUT_TYPE } from '@/common/common'
|
import { BATCH_TYPE, INPUT_TYPE, POLYGON_TYPE } from '@/common/common'
|
||||||
import { useEvent } from '@/hooks/useEvent'
|
import { useEvent } from '@/hooks/useEvent'
|
||||||
import { pointsToTurfPolygon, polygonToTurfPolygon, rectToPolygon, triangleToPolygon } from '@/util/canvas-util'
|
import { pointsToTurfPolygon, polygonToTurfPolygon, rectToPolygon, triangleToPolygon } from '@/util/canvas-util'
|
||||||
import { useSwal } from '@/hooks/useSwal'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
@ -955,8 +955,8 @@ export function useObjectBatch({ isHidden, setIsHidden }) {
|
|||||||
})
|
})
|
||||||
reGroupObjects.push(newObj)
|
reGroupObjects.push(newObj)
|
||||||
canvas.remove(obj)
|
canvas.remove(obj)
|
||||||
if (obj.direction) {
|
if (newObj.direction) {
|
||||||
drawDirectionArrow(obj)
|
drawDirectionArrow(newObj)
|
||||||
}
|
}
|
||||||
newObj.fire('modified')
|
newObj.fire('modified')
|
||||||
})
|
})
|
||||||
@ -977,6 +977,7 @@ export function useObjectBatch({ isHidden, setIsHidden }) {
|
|||||||
|
|
||||||
const moveObjectBatch = () => {
|
const moveObjectBatch = () => {
|
||||||
const obj = canvas.getActiveObject()
|
const obj = canvas.getActiveObject()
|
||||||
|
const parentSurface = canvas?.getObjects().filter((item) => item.name === POLYGON_TYPE.ROOF && item.id === obj.parentId)[0]
|
||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
obj.set({
|
obj.set({
|
||||||
@ -984,14 +985,42 @@ export function useObjectBatch({ isHidden, setIsHidden }) {
|
|||||||
lockMovementY: false,
|
lockMovementY: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const originObj = { ...obj }
|
||||||
addCanvasMouseEventListener('mouse:up', (e) => {
|
addCanvasMouseEventListener('mouse:up', (e) => {
|
||||||
obj.set({
|
//개구, 그림자 타입일 경우 폴리곤 타입 변경
|
||||||
lockMovementX: true,
|
if (BATCH_TYPE.OPENING === obj.name || BATCH_TYPE.SHADOW === obj.name) {
|
||||||
lockMovementY: true,
|
obj.set({
|
||||||
})
|
points: rectToPolygon(obj),
|
||||||
|
})
|
||||||
|
|
||||||
|
const turfSurface = pointsToTurfPolygon(parentSurface.points)
|
||||||
|
const turfObject = pointsToTurfPolygon(obj.points)
|
||||||
|
|
||||||
|
if (turf.booleanWithin(turfObject, turfSurface)) {
|
||||||
|
obj.set({
|
||||||
|
lockMovementX: true,
|
||||||
|
lockMovementY: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
obj.setCoords()
|
||||||
|
} else {
|
||||||
|
swalFire({
|
||||||
|
title: getMessage('batch.object.outside.roof'),
|
||||||
|
icon: 'warning',
|
||||||
|
})
|
||||||
|
obj.set({ ...originObj, lockMovementX: true, lockMovementY: true })
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
obj.set({
|
||||||
|
lockMovementX: true,
|
||||||
|
lockMovementY: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (obj.type === 'group') reGroupObject(obj)
|
||||||
|
obj.setCoords()
|
||||||
|
}
|
||||||
|
canvas.discardActiveObject()
|
||||||
initEvent()
|
initEvent()
|
||||||
obj.setCoords()
|
|
||||||
if (obj.type === 'group') reGroupObject(obj)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -464,7 +464,7 @@ export function useContextMenu() {
|
|||||||
id: 'openingMove',
|
id: 'openingMove',
|
||||||
shortcut: ['m', 'M'],
|
shortcut: ['m', 'M'],
|
||||||
name: `${getMessage('contextmenu.move')}(M)`,
|
name: `${getMessage('contextmenu.move')}(M)`,
|
||||||
fn: () => moveObject(),
|
fn: () => moveObjectBatch(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'openingCopy',
|
id: 'openingCopy',
|
||||||
@ -667,7 +667,7 @@ export function useContextMenu() {
|
|||||||
id: 'move',
|
id: 'move',
|
||||||
shortcut: ['m', 'M'],
|
shortcut: ['m', 'M'],
|
||||||
name: `${getMessage('contextmenu.move')}(M)`,
|
name: `${getMessage('contextmenu.move')}(M)`,
|
||||||
fn: () => moveObject(),
|
fn: () => moveObjectBatch(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'copy',
|
id: 'copy',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user