From e7d423520fa12ca90257fbe3ba607383524a6c67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=AF=97=E6=B4=A5?= <2723065175@qq.com> Date: Thu, 23 May 2024 09:36:16 +0000 Subject: [PATCH] =?UTF-8?q?!2730=20=E6=96=B0=E5=A2=9E:=E5=8F=B3=E9=94=AE?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=80=89=E4=B8=AD=E7=A9=BA=E9=97=B4=E5=8F=8A?= =?UTF-8?q?=E5=AD=90=E7=A9=BA=E9=97=B4=E6=89=80=E6=9C=89=E5=9B=BE=E5=85=83?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/HighlightNode.ts | 71 +++++++++++++++++++ src/Common/CommandNames.ts | 2 + src/Editor/CommandRegister.ts | 4 ++ src/Editor/ContextMenu.ts | 4 ++ src/UI/Components/CommandPanel/CommandList.ts | 18 +++++ 5 files changed, 99 insertions(+) create mode 100644 src/Add-on/HighlightNode.ts diff --git a/src/Add-on/HighlightNode.ts b/src/Add-on/HighlightNode.ts new file mode 100644 index 000000000..eebfe7180 --- /dev/null +++ b/src/Add-on/HighlightNode.ts @@ -0,0 +1,71 @@ +import { app } from "../ApplicationServices/Application"; +import { Entity } from "../DatabaseServices/Entity/Entity"; +import { TemplateRecord } from "../DatabaseServices/Template/TemplateRecord"; +import { Command } from "../Editor/CommandMachine"; +import { PromptStatus } from "../Editor/PromptResult"; + +//亮显本节点 +export class Command_HighlightNode implements Command +{ + async exec() + { + let ss = await app.Editor.GetSelection({ Msg: "选择需要亮显节点的实体:", UseSelect: true }); + if (ss.Status !== PromptStatus.OK) return; + let ents = ss.SelectSet.SelectEntityList; + + const entSet: Set = new Set(); + app.Editor.SelectCtrl.Cancel(); + + for (const en of ents) + { + if (entSet.has(en)) continue; + let temp = en.Template.Object as TemplateRecord; + for (let t of temp.Objects) + { + if (t && !t.IsErase) + { + let en = t.Object as Entity; + if (en.Visible) + entSet.add(en); + } + } + } + app.Editor.SetSelection([...entSet]); + } +} + +//亮显本节点及子节点 +export class Command_HighlightNodeAndChilds implements Command +{ + async exec() + { + let ss = await app.Editor.GetSelection({ Msg: "选择需要亮显节点和子层的实体:", UseSelect: true }); + if (ss.Status !== PromptStatus.OK) return; + let ents = ss.SelectSet.SelectEntityList; + + const entSet: Set = new Set(); + app.Editor.SelectCtrl.Cancel(); + + for (const en of ents) + { + if (entSet.has(en)) continue; + let temp = en.Template.Object as TemplateRecord; + + let treeNodes: TemplateRecord[] = []; + temp.Traverse((node) => { treeNodes.push(node); }); + + for (let tn of treeNodes) + { + for (let t of tn.Objects) + { + if (t && !t.IsErase) + { + let en = t.Object as Entity; + entSet.add(en); + } + } + } + } + app.Editor.SetSelection([...entSet]); + } +} diff --git a/src/Common/CommandNames.ts b/src/Common/CommandNames.ts index 8b70e72ea..ff796341d 100644 --- a/src/Common/CommandNames.ts +++ b/src/Common/CommandNames.ts @@ -398,4 +398,6 @@ export enum CommandNames AlignLineGroup = "ALIGNLINEGROUP",//呼出对纹组 AddAlignLineGroup = "ADDALIGNLINEGROUP",//添加对纹组 DeleteAlignLineGroup = "DELETEALIGNLINEGROUP",//删除对纹组 + HighlightNode = "HIGHLIGHTNODE",//高亮本节点 + HighlightNodeAndChilds = "HIGHLIGHTNODEANDCHILDS",//亮显本节点及子节点 } diff --git a/src/Editor/CommandRegister.ts b/src/Editor/CommandRegister.ts index f2153d16d..cedbd5667 100644 --- a/src/Editor/CommandRegister.ts +++ b/src/Editor/CommandRegister.ts @@ -229,6 +229,7 @@ import { AddAloneDrillLock } from "../Add-on/DrawDrilling/DrillLock/AloneDrillLo import { RemoveAssocDrillLock } from "../Add-on/DrawDrilling/DrillLock/RemoveAssocDrillLock"; import { RemoveDrillLock } from "../Add-on/DrawDrilling/DrillLock/RemoveDrillLock"; import { Command_FBXImport } from "../Add-on/FBXLoad"; +import { Command_HighlightNode, Command_HighlightNodeAndChilds } from "../Add-on/HighlightNode"; import { Command_Show2DPathLine } from "../Add-on/Show2DPathLine/Show2DPathLine"; import { Command_Show2DPathObject } from "../Add-on/Show2DPathLine/Show2DPathObject"; import { TestFb } from "../Add-on/TestFb"; @@ -438,6 +439,9 @@ export function registerCommand() //暂时关闭这个fbx导入 // commandMachine.RegisterCommand("fbx", new Fbx()); + commandMachine.RegisterCommand(CommandNames.HighlightNode, new Command_HighlightNode()); + commandMachine.RegisterCommand(CommandNames.HighlightNodeAndChilds, new Command_HighlightNodeAndChilds()); + commandMachine.RegisterCommand(CommandNames.HideSelect, new Command_HideSelected()); commandMachine.RegisterCommand(CommandNames.HideUnSelect, new Command_HideUnselected()); commandMachine.RegisterCommand(CommandNames.Show, new Command_ShowAll()); diff --git a/src/Editor/ContextMenu.ts b/src/Editor/ContextMenu.ts index 2639628c2..750f0c927 100644 --- a/src/Editor/ContextMenu.ts +++ b/src/Editor/ContextMenu.ts @@ -60,6 +60,9 @@ const KeyWordCommandMap: Map = new Map(Object.entries({ "X": "SPLITTEMPLATEX", "Y": "SPLITTEMPLATEY", "Z": "SPLITTEMPLATEZ", + + "N": CommandNames.HighlightNode, + "N2": CommandNames.HighlightNodeAndChilds, })); /** @@ -178,6 +181,7 @@ export class ContextMenuServices implements EditorService if (selects[0].Template && selects[0].Template.Object) { let temp = selects[0].Template.Object; + menuKeywords.push({ key: "N", msg: "亮显本节点" }, { key: "N2", msg: "亮显空间子层" }); if (temp instanceof TemplateWineRackRecord) menuKeywords.push({ key: "WR", msg: "编辑酒格模块" }); else if (temp instanceof TemplateBoardRecord || temp instanceof TemplateLeftRightBoardRecord || temp instanceof TemplateTopBottomBoard) diff --git a/src/UI/Components/CommandPanel/CommandList.ts b/src/UI/Components/CommandPanel/CommandList.ts index 96c6cb6ed..9d93163f9 100644 --- a/src/UI/Components/CommandPanel/CommandList.ts +++ b/src/UI/Components/CommandPanel/CommandList.ts @@ -3306,6 +3306,24 @@ export const CommandList: ICommand[] = [ chName: "显示所有", chDes: "显示所有", }, + { + typeId: "hidedisplay", + link: `#`, + defaultCustom: CommandNames.HighlightNode, + command: CommandNames.HighlightNode, + type: "隐藏显示", + chName: "高亮本节点", + chDes: "亮显选中实体当前节点的实体", + }, + { + typeId: "hidedisplay", + link: `#`, + defaultCustom: CommandNames.HighlightNodeAndChilds, + command: CommandNames.HighlightNodeAndChilds, + type: "隐藏显示", + chName: "高亮本节点及子节点", + chDes: "亮显选中实体当前节点的实体和子节点", + }, // 内置命令 {