currentObject별 context메뉴에 선택 menu 분기 처리
This commit is contained in:
parent
ff7eb36762
commit
fad86d4585
@ -118,6 +118,153 @@ export function useContextMenu() {
|
|||||||
])
|
])
|
||||||
break
|
break
|
||||||
case 'outline':
|
case 'outline':
|
||||||
|
if (['roof', 'auxiliaryLine'].includes(currentObject?.name)) {
|
||||||
|
}
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
setContextMenu([])
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleClick = (e, menu) => {
|
||||||
|
if (menu?.fn) {
|
||||||
|
menu.fn(qContextMenu.currentMousePos)
|
||||||
|
}
|
||||||
|
|
||||||
|
setContextPopupPosition({
|
||||||
|
x: window.innerWidth / 2,
|
||||||
|
y: 180,
|
||||||
|
})
|
||||||
|
setCurrentContextMenu(menu)
|
||||||
|
currentMenuSetting()
|
||||||
|
setQContextMenu({ ...qContextMenu, visible: false })
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleKeyup = (e) => {
|
||||||
|
let menu = null
|
||||||
|
for (let i = 0; i < contextMenu.length; i++) {
|
||||||
|
const temp = contextMenu[i].filter((menu) => {
|
||||||
|
return menu.shortcut?.includes(e.key)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (temp.length > 0) menu = temp[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menu) handleClick(null, menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
currentMenuSetting()
|
||||||
|
}, [gridColor, currentMenu])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (currentContextMenu?.component) addPopup(popupId, 1, currentContextMenu?.component)
|
||||||
|
}, [currentContextMenu])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
console.log('currentObject', currentObject)
|
||||||
|
if (currentObject?.name) {
|
||||||
|
switch (currentObject.name) {
|
||||||
|
case 'triangleDormer':
|
||||||
|
case 'pentagonDormer':
|
||||||
|
if (selectedMenu === 'surface') {
|
||||||
|
setContextMenu([
|
||||||
|
[
|
||||||
|
{
|
||||||
|
id: 'sizeEdit',
|
||||||
|
name: getMessage('contextmenu.size.edit'),
|
||||||
|
component: <SizeSetting id={popupId} target={currentObject} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'dormerRemove',
|
||||||
|
shortcut: ['d', 'D'],
|
||||||
|
name: `${getMessage('contextmenu.remove')}(D)`,
|
||||||
|
fn: () => deleteObject(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'dormerMove',
|
||||||
|
shortcut: ['m', 'M'],
|
||||||
|
name: `${getMessage('contextmenu.move')}(M)`,
|
||||||
|
fn: () => moveObjectBatch(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'dormerCopy',
|
||||||
|
shortcut: ['c', 'C'],
|
||||||
|
name: `${getMessage('contextmenu.copy')}(C)`,
|
||||||
|
fn: () => copyObject(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'roofMaterialEdit',
|
||||||
|
name: getMessage('contextmenu.roof.material.edit'),
|
||||||
|
component: <RoofMaterialSetting id={popupId} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'dormerOffset',
|
||||||
|
name: getMessage('contextmenu.dormer.offset'),
|
||||||
|
component: <DormerOffset id={popupId} title={getMessage('contextmenu.dormer.offset')} />,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
])
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case 'roof':
|
||||||
|
case 'auxiliaryLine':
|
||||||
|
case 'hip':
|
||||||
|
case 'ridge':
|
||||||
|
if (selectedMenu === 'surface') {
|
||||||
|
setContextMenu([
|
||||||
|
[
|
||||||
|
{
|
||||||
|
id: 'sizeEdit',
|
||||||
|
name: getMessage('contextmenu.size.edit'),
|
||||||
|
component: <SizeSetting id={popupId} target={currentObject} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'roofMaterialRemove',
|
||||||
|
shortcut: ['d', 'D'],
|
||||||
|
name: `${getMessage('contextmenu.remove')}(D)`,
|
||||||
|
fn: () => deleteObject(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'roofMaterialMove',
|
||||||
|
shortcut: ['m', 'M'],
|
||||||
|
name: `${getMessage('contextmenu.move')}(M)`,
|
||||||
|
fn: () => moveSurfaceShapeBatch(),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'roofMaterialCopy',
|
||||||
|
shortcut: ['c', 'C'],
|
||||||
|
name: `${getMessage('contextmenu.copy')}(C)`,
|
||||||
|
fn: () => copyObject(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
id: 'roofMaterialEdit',
|
||||||
|
name: getMessage('contextmenu.roof.material.edit'),
|
||||||
|
component: <ContextRoofAllocationSetting id={popupId} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'linePropertyEdit',
|
||||||
|
name: getMessage('contextmenu.line.property.edit'),
|
||||||
|
fn: () => {
|
||||||
|
if (+canvasSetting.roofSizeSet === 3) {
|
||||||
|
swalFire({ text: getMessage('contextmenu.line.property.edit.roof.size.3') })
|
||||||
|
} else {
|
||||||
|
addPopup(popupId, 1, <PlacementSurfaceLineProperty id={popupId} roof={currentObject} />)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// component: <LinePropertySetting id={popupId} target={currentObject} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'flowDirectionEdit',
|
||||||
|
name: getMessage('contextmenu.flow.direction.edit'),
|
||||||
|
component: <FlowDirectionSetting id={popupId} target={currentObject} />,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
])
|
||||||
|
} else if (selectedMenu === 'outline') {
|
||||||
setContextMenu([
|
setContextMenu([
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@ -257,144 +404,8 @@ export function useContextMenu() {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
break
|
|
||||||
default:
|
|
||||||
setContextMenu([])
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleClick = (e, menu) => {
|
|
||||||
if (menu?.fn) {
|
|
||||||
menu.fn(qContextMenu.currentMousePos)
|
|
||||||
}
|
|
||||||
|
|
||||||
setContextPopupPosition({
|
|
||||||
x: window.innerWidth / 2,
|
|
||||||
y: 180,
|
|
||||||
})
|
|
||||||
setCurrentContextMenu(menu)
|
|
||||||
currentMenuSetting()
|
|
||||||
setQContextMenu({ ...qContextMenu, visible: false })
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleKeyup = (e) => {
|
|
||||||
let menu = null
|
|
||||||
for (let i = 0; i < contextMenu.length; i++) {
|
|
||||||
const temp = contextMenu[i].filter((menu) => {
|
|
||||||
return menu.shortcut?.includes(e.key)
|
|
||||||
})
|
|
||||||
|
|
||||||
if (temp.length > 0) menu = temp[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (menu) handleClick(null, menu)
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
currentMenuSetting()
|
|
||||||
}, [gridColor, currentMenu])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (currentContextMenu?.component) addPopup(popupId, 1, currentContextMenu?.component)
|
|
||||||
}, [currentContextMenu])
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log('currentObject', currentObject)
|
|
||||||
if (currentObject?.name) {
|
|
||||||
switch (currentObject.name) {
|
|
||||||
case 'triangleDormer':
|
|
||||||
case 'pentagonDormer':
|
|
||||||
setContextMenu([
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: 'sizeEdit',
|
|
||||||
name: getMessage('contextmenu.size.edit'),
|
|
||||||
component: <SizeSetting id={popupId} target={currentObject} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'dormerRemove',
|
|
||||||
shortcut: ['d', 'D'],
|
|
||||||
name: `${getMessage('contextmenu.remove')}(D)`,
|
|
||||||
fn: () => deleteObject(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'dormerMove',
|
|
||||||
shortcut: ['m', 'M'],
|
|
||||||
name: `${getMessage('contextmenu.move')}(M)`,
|
|
||||||
fn: () => moveObjectBatch(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'dormerCopy',
|
|
||||||
shortcut: ['c', 'C'],
|
|
||||||
name: `${getMessage('contextmenu.copy')}(C)`,
|
|
||||||
fn: () => copyObject(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'roofMaterialEdit',
|
|
||||||
name: getMessage('contextmenu.roof.material.edit'),
|
|
||||||
component: <RoofMaterialSetting id={popupId} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'dormerOffset',
|
|
||||||
name: getMessage('contextmenu.dormer.offset'),
|
|
||||||
component: <DormerOffset id={popupId} title={getMessage('contextmenu.dormer.offset')} />,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
])
|
|
||||||
break
|
|
||||||
case 'roof':
|
|
||||||
setContextMenu([
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: 'sizeEdit',
|
|
||||||
name: getMessage('contextmenu.size.edit'),
|
|
||||||
component: <SizeSetting id={popupId} target={currentObject} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'roofMaterialRemove',
|
|
||||||
shortcut: ['d', 'D'],
|
|
||||||
name: `${getMessage('contextmenu.remove')}(D)`,
|
|
||||||
fn: () => deleteObject(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'roofMaterialMove',
|
|
||||||
shortcut: ['m', 'M'],
|
|
||||||
name: `${getMessage('contextmenu.move')}(M)`,
|
|
||||||
fn: () => moveSurfaceShapeBatch(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'roofMaterialCopy',
|
|
||||||
shortcut: ['c', 'C'],
|
|
||||||
name: `${getMessage('contextmenu.copy')}(C)`,
|
|
||||||
fn: () => copyObject(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: 'roofMaterialEdit',
|
|
||||||
name: getMessage('contextmenu.roof.material.edit'),
|
|
||||||
component: <ContextRoofAllocationSetting id={popupId} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'linePropertyEdit',
|
|
||||||
name: getMessage('contextmenu.line.property.edit'),
|
|
||||||
fn: () => {
|
|
||||||
if (+canvasSetting.roofSizeSet === 3) {
|
|
||||||
swalFire({ text: getMessage('contextmenu.line.property.edit.roof.size.3') })
|
|
||||||
} else {
|
|
||||||
addPopup(popupId, 1, <PlacementSurfaceLineProperty id={popupId} roof={currentObject} />)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// component: <LinePropertySetting id={popupId} target={currentObject} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'flowDirectionEdit',
|
|
||||||
name: getMessage('contextmenu.flow.direction.edit'),
|
|
||||||
component: <FlowDirectionSetting id={popupId} target={currentObject} />,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
])
|
|
||||||
break
|
break
|
||||||
case 'opening':
|
case 'opening':
|
||||||
setContextMenu([
|
setContextMenu([
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user