From b145c09fa41e322379c1f19a227dc7565f5b9572 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=AF=97=E6=B4=A5?= <2723065175@qq.com> Date: Wed, 13 Mar 2024 01:46:35 +0000 Subject: [PATCH] =?UTF-8?q?!2312=20=E5=8A=9F=E8=83=BD:=E6=9D=BF=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=8E=92=E9=92=BB=E9=94=81=E5=AE=9A=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Add-on/Batch/BatchModifySealOrDrill.ts | 23 +++- src/Add-on/BoardEditor/UpdateBoardInfos.ts | 8 +- src/Add-on/BoardFindModify.ts | 8 +- src/Add-on/DrawDrilling/DeleteDrill.ts | 1 + src/Add-on/DrawDrilling/DrawDrillingTool.ts | 32 ++--- .../DrawDrilling/DrillLock/AllDrillUnlock.ts | 45 +++++++ .../DrawDrilling/DrillLock/AssociationLock.ts | 67 ++++++++++ .../DrillLock/AssociationUnlock.ts | 105 ++++++++++++++++ .../DrawDrilling/DrillLock/IndependentLock.ts | 114 ++++++++++++++++++ src/Add-on/DrawDrilling/DrillingReactor.ts | 6 +- src/Common/CommandNames.ts | 5 + src/DatabaseServices/Entity/Board.ts | 70 ++++++++++- src/Editor/CommandRegister.ts | 10 ++ src/UI/Components/Board/BoardCommon.tsx | 22 +++- src/UI/Components/Board/BoardProcessModal.tsx | 58 +++++++-- src/UI/Components/Board/CommonBoardOption.tsx | 39 +++++- src/UI/Components/CommandPanel/CommandList.ts | 50 ++++++++ 17 files changed, 615 insertions(+), 48 deletions(-) create mode 100644 src/Add-on/DrawDrilling/DrillLock/AllDrillUnlock.ts create mode 100644 src/Add-on/DrawDrilling/DrillLock/AssociationLock.ts create mode 100644 src/Add-on/DrawDrilling/DrillLock/AssociationUnlock.ts create mode 100644 src/Add-on/DrawDrilling/DrillLock/IndependentLock.ts diff --git a/src/Add-on/Batch/BatchModifySealOrDrill.ts b/src/Add-on/Batch/BatchModifySealOrDrill.ts index 4f7c0b7f5..8e8de9867 100644 --- a/src/Add-on/Batch/BatchModifySealOrDrill.ts +++ b/src/Add-on/Batch/BatchModifySealOrDrill.ts @@ -48,9 +48,9 @@ export class BatchModify implements Command if (keyRes.Status !== PromptStatus.Keyword) return; const store = RightPanelStore.GetInstance(); - store.m_IsShow = true; if (keyRes.StringResult === "S") { + store.m_IsShow = true; store.sealingStore.isNotUpdateStore = true; let config = new DialogUserConfig(store.sealingStore, BoardModalType.Sealing); await config.LoadAndInitConfig(); @@ -64,10 +64,29 @@ export class BatchModify implements Command } else if (keyRes.StringResult === "D") { + let unlockDrillBoard = brs.filter(br => !br.DrillLock); + if (unlockDrillBoard.length != brs.length) + { + AppToaster.show({ + message: "选中的板存在独立排钻锁,独立排钻锁的板不可以修改", + timeout: 5000, + intent: Intent.WARNING, + }); + } + if (!unlockDrillBoard.length) + { + AppToaster.show({ + message: "当前没有可以修改的板", + timeout: 5000, + intent: Intent.WARNING, + }); + return; + } + store.m_IsShow = true; store.m_TabId = RightTabId.Drill; setTimeout(() => //当前命令结束后在进入编辑 { - store.drillingStore.StartEditor(brs); + store.drillingStore.StartEditor(unlockDrillBoard); }, 0); } else if (keyRes.StringResult === "R") diff --git a/src/Add-on/BoardEditor/UpdateBoardInfos.ts b/src/Add-on/BoardEditor/UpdateBoardInfos.ts index a2fa97159..7f5e5ff9d 100644 --- a/src/Add-on/BoardEditor/UpdateBoardInfos.ts +++ b/src/Add-on/BoardEditor/UpdateBoardInfos.ts @@ -174,7 +174,7 @@ export class UpdateBoardInfos implements Command br.GroovesAddWidth = parseFloat(option[i]) || 0; break; case "upDrill": - if (option.highDrill.length === 4 && !br.IsSpecialShape) + if (option.highDrill.length === 4 && !br.IsSpecialShape && !br.DrillLock) { let index = DRILL_KEYS.indexOf(i); ParseBoardRectHoleType(br, drillOption); @@ -183,7 +183,7 @@ export class UpdateBoardInfos implements Command } break; case "downDrill": - if (option.highDrill.length === 4 && !br.IsSpecialShape) + if (option.highDrill.length === 4 && !br.IsSpecialShape && !br.DrillLock) { let index = DRILL_KEYS.indexOf(i); ParseBoardRectHoleType(br, drillOption); @@ -192,7 +192,7 @@ export class UpdateBoardInfos implements Command } break; case "leftDrill": - if (option.highDrill.length === 4 && !br.IsSpecialShape) + if (option.highDrill.length === 4 && !br.IsSpecialShape && !br.DrillLock) { let index = DRILL_KEYS.indexOf(i); ParseBoardRectHoleType(br, drillOption); @@ -201,7 +201,7 @@ export class UpdateBoardInfos implements Command } break; case "rightDrill": - if (option.highDrill.length === 4 && !br.IsSpecialShape) + if (option.highDrill.length === 4 && !br.IsSpecialShape && !br.DrillLock) { let index = DRILL_KEYS.indexOf(i); ParseBoardRectHoleType(br, drillOption); diff --git a/src/Add-on/BoardFindModify.ts b/src/Add-on/BoardFindModify.ts index 669f2f041..a65d57793 100644 --- a/src/Add-on/BoardFindModify.ts +++ b/src/Add-on/BoardFindModify.ts @@ -416,28 +416,28 @@ export class BoardFindModify implements Command } break; case "upDrill": - if (!br.IsSpecialShape) + if (!br.IsSpecialShape && !br.DrillLock) { let index = DRILL_KEYS.indexOf(i); drillOption.up = option.highDrill[index]; } break; case "downDrill": - if (!br.IsSpecialShape) + if (!br.IsSpecialShape && !br.DrillLock) { let index = DRILL_KEYS.indexOf(i); drillOption.down = option.highDrill[index]; } break; case "leftDrill": - if (!br.IsSpecialShape) + if (!br.IsSpecialShape && !br.DrillLock) { let index = DRILL_KEYS.indexOf(i); drillOption.left = option.highDrill[index]; } break; case "rightDrill": - if (!br.IsSpecialShape) + if (!br.IsSpecialShape && !br.DrillLock) { let index = DRILL_KEYS.indexOf(i); drillOption.right = option.highDrill[index]; diff --git a/src/Add-on/DrawDrilling/DeleteDrill.ts b/src/Add-on/DrawDrilling/DeleteDrill.ts index f7f12c9c6..bf55605b9 100644 --- a/src/Add-on/DrawDrilling/DeleteDrill.ts +++ b/src/Add-on/DrawDrilling/DeleteDrill.ts @@ -80,6 +80,7 @@ export class DeleteDrill implements Command } return; case EDeleteDrillType.Face: + ens = ens.filter((br: Board) => !br.DrillLock); //锁定排钻的板不参与计算 DrawDrillingTool.GetInstance().ClearExitDrilling(ens as Board[]); return; case EDeleteDrillType.Nail: diff --git a/src/Add-on/DrawDrilling/DrawDrillingTool.ts b/src/Add-on/DrawDrilling/DrawDrillingTool.ts index 5ffc34c33..defed70bc 100644 --- a/src/Add-on/DrawDrilling/DrawDrillingTool.ts +++ b/src/Add-on/DrawDrilling/DrawDrillingTool.ts @@ -1242,7 +1242,7 @@ export class DrawDrillingTool extends Singleton this._hasBackupOption = this.HasConfig(f.DrillType + "_备选"); } } - private ClassifyBoardList(brList: Board[] | Set): Map + private ClassifyBoardList(brList: Board[]): Map { let brMap: Map = new Map(); //根据柜名房名分类 @@ -1256,17 +1256,24 @@ export class DrawDrillingTool extends Singleton } return brMap; } + /** + * 注意:如果存在排钻锁,就会影响排钻删除 + */ ClearExitDrilling(brs: Board[]) { for (let i = 0; i < brs.length; i++) { let br = brs[i]; + br.ClearDrillList(undefined);//删除仅与自身关联的排钻 for (let j = i + 1; j < brs.length; j++) { //没修改的板件之间不清除排钻 if (br.TempData?.unChange && brs[j].TempData?.unChange) continue; + + if (brs[j].DrillAssociationLock.has(br.Id)) continue; //如果关联排钻锁Id存在,就不删除 + br.ClearDrillList(brs[j].Id); } } @@ -1279,6 +1286,8 @@ export class DrawDrillingTool extends Singleton for (let f of checkRes.CollisonFaces) { + if (f.InterBoard.DrillLock || f.InterBoard.DrillAssociationLock.has(f.LocalBoard.Id)) continue; //如果有排钻锁就不用更新 + this.Exec(f, false); if (this._useBackup) this.Exec(f, true); @@ -1303,6 +1312,7 @@ export class DrawDrillingTool extends Singleton if (suitableOptions.length === 0) { app.Editor.Prompt("碰撞面长度" + f.Length + "没有合适的规则,或者当前配置不存在" + f.DrillType + "类型排钻", LogType.Error, [f.LocalBoard, f.InterBoard].filter(e => e)); + app.Editor.Prompt("长度" + f.Length + "没有合适的规则,或者当前配置不存在" + f.DrillType + "类型排钻", LogType.Error); return; } for (let suitableOption of suitableOptions) @@ -1379,28 +1389,18 @@ export class DrawDrillingTool extends Singleton } /**分类并排钻 */ - async ClassifyAndDrilling(brList: Board[] | Set): Promise + async ClassifyAndDrilling(brList: Board[]): Promise //保持一下数据类型统一就这么难吗 { - if (brList instanceof Set) - { - if (brList.size < 2) return; - } - else if (brList.length < 2) return; + brList = brList.filter(br => !br.DrillLock); //锁定排钻的板不参与计算 + if (brList.length < 2) return; //清理掉已经存在的排钻 - this.ClearExitDrilling([...brList]); + this.ClearExitDrilling(brList); this._collsionFaces.length = 0; //拆单尺寸的板件不排钻 - if (brList instanceof Set) - { - for (let br of brList) - if (this.IsSplitBoard(br)) - brList.delete(br); - } - else - arrayRemoveIf(brList, (br) => this.IsSplitBoard(br)); + arrayRemoveIf(brList, (br) => this.IsSplitBoard(br)); let brMap = this.ClassifyBoardList(brList); for (let [, bs] of brMap) diff --git a/src/Add-on/DrawDrilling/DrillLock/AllDrillUnlock.ts b/src/Add-on/DrawDrilling/DrillLock/AllDrillUnlock.ts new file mode 100644 index 000000000..7e4a347bf --- /dev/null +++ b/src/Add-on/DrawDrilling/DrillLock/AllDrillUnlock.ts @@ -0,0 +1,45 @@ +import { Intent } from "@blueprintjs/core"; +import { app } from "../../../ApplicationServices/Application"; +import { Board } from "../../../DatabaseServices/Entity/Board"; +import { Command } from "../../../Editor/CommandMachine"; +import { AppToaster } from "../../../UI/Components/Toaster"; + +export class AllDrillUnlock implements Command +{ + async exec() + { + //所有存在排钻锁的板 + const associationBoards = app.Database.ModelSpace.Entitys.filter(br => + { + if (!br.IsErase && br instanceof Board) + { + if (br.DrillLock === true || br.DrillAssociationLock.size > 0) + return true; + } + return false; + }) as Board[]; + + if (associationBoards.length) + { + for (const associationBoard of associationBoards) + { + associationBoard.ClearAllDrillLock(); + } + + AppToaster.show({ + message: `解除所有排钻锁成功`, + intent: Intent.SUCCESS, + timeout: 3000, + }); + } + else + { + AppToaster.show({ + message: `当前没有板设置了排钻锁`, + intent: Intent.WARNING, + timeout: 3000, + }); + } + + } +} diff --git a/src/Add-on/DrawDrilling/DrillLock/AssociationLock.ts b/src/Add-on/DrawDrilling/DrillLock/AssociationLock.ts new file mode 100644 index 000000000..4fa9fd68b --- /dev/null +++ b/src/Add-on/DrawDrilling/DrillLock/AssociationLock.ts @@ -0,0 +1,67 @@ +import { Intent } from "@blueprintjs/core"; +import { app } from "../../../ApplicationServices/Application"; +import { Log, LogType } from "../../../Common/Log"; +import { Board } from "../../../DatabaseServices/Entity/Board"; +import { Command } from "../../../Editor/CommandMachine"; +import { PromptStatus } from "../../../Editor/PromptResult"; +import { AppToaster } from "../../../UI/Components/Toaster"; + +export class AssociationLock implements Command +{ + async exec() + { + const BoardRes = await app.Editor.GetEntity({ + Msg: "请选择锁定排钻的板", + Filter: { filterTypes: [Board] } + }); + if (BoardRes.Status !== PromptStatus.OK) return; + const FirstBoard = BoardRes.Entity as Board; + const FirstBoardId = FirstBoard.Id; + + const drillAssociationLock = FirstBoard.DrillAssociationLock; + const associationBoards = [...drillAssociationLock].map(o => o.Object as Board); //读取第一块板关联锁定的板集合 + const existAssociationBoards = associationBoards.filter(br => !br.IsErase); //存在的板 + + if (existAssociationBoards.length) + { + app.Editor.SetSelection(existAssociationBoards); //亮显关联的板 + AppToaster.show({ + message: `当前板已存在${existAssociationBoards.length}块关联的板,已显示当前关联过的板`, + intent: Intent.PRIMARY, + timeout: 3000, + }); + } + + const associationBoardRes = await app.Editor.GetSelection({ + Msg: "请选择需要关联锁定排钻的板", + Filter: { + filterTypes: [Board], + filterFunction: (obj, ent) => + { + if (ent.Id === FirstBoardId) + return false; + return true; + } + } + }); + + if (associationBoardRes.Status === PromptStatus.OK) + { + const associationBoards = associationBoardRes.SelectSet.SelectEntityList as Board[]; + for (const associationBoard of associationBoards) + { + const associationBoardId = associationBoard.Id; + FirstBoard.AppendDrillAssociationLock(associationBoardId); + + associationBoard.AppendDrillAssociationLock(FirstBoardId); + } + + AppToaster.show({ + message: `排钻关联锁定成功,共关联了${associationBoards.length}块板`, + intent: Intent.SUCCESS, + timeout: 3000, + }); + Log(`排钻关联锁定成功,共关联了${associationBoards.length}块板`, LogType.Info, [...associationBoards]); + } + } +} diff --git a/src/Add-on/DrawDrilling/DrillLock/AssociationUnlock.ts b/src/Add-on/DrawDrilling/DrillLock/AssociationUnlock.ts new file mode 100644 index 000000000..f17813ec6 --- /dev/null +++ b/src/Add-on/DrawDrilling/DrillLock/AssociationUnlock.ts @@ -0,0 +1,105 @@ +import { app } from "../../../ApplicationServices/Application"; +import { Log, LogType } from "../../../Common/Log"; +import { Intent } from "../../../Common/Toaster"; +import { Board } from "../../../DatabaseServices/Entity/Board"; +import { Command } from "../../../Editor/CommandMachine"; +import { PromptStatus } from "../../../Editor/PromptResult"; +import { AppToaster } from "../../../UI/Components/Toaster"; + +export class AssociationUnlock implements Command +{ + async exec() + { + const associationBoardIndex = app.Database.ModelSpace.Entitys.findIndex(ent => + { + if (!ent.IsErase && ent instanceof Board) + { + return Boolean(ent.DrillAssociationLock.size); + } + return false; + }); + + if (associationBoardIndex === -1) + { + AppToaster.show({ + message: "不存在关联排钻锁定的板", + intent: Intent.WARNING, + timeout: 2000, + }); + return; + } + + while (true) + { + const BoardRes = await app.Editor.GetEntity({ + Msg: "请选择解除排钻锁定的板", + Filter: { filterTypes: [Board] } + }); + if (BoardRes.Status !== PromptStatus.OK) return; + const FirstBoard = BoardRes.Entity as Board; + + const drillAssociationLock = FirstBoard.DrillAssociationLock; + const associationBoards = [...drillAssociationLock.values()].map(o => o.Object as Board); //读取第一块板关联锁定的板集合 + + if (!associationBoards.length) + { + AppToaster.show({ + message: "当前板不存在关联排钻锁定的板", + intent: Intent.WARNING, + timeout: 2000, + }); + continue; + } + + while (true) + { + const DisassociateBoardRes = await app.Editor.GetSelection({ + Msg: "请选择需要解除关联锁定的板", + Filter: { + filterTypes: [Board], + filterFunction: (obj, ent) => + { + return associationBoards.some(br => br.objectId === ent.objectId); + } + }, + KeyWordList: [{ key: "A", msg: "选中所有关联的板" }] + }); + + if (DisassociateBoardRes.Status === PromptStatus.Keyword) + { + if (DisassociateBoardRes.StringResult === "A") + { + app.Editor.SetSelection(associationBoards); //亮显关联的板 + } + } + else if (DisassociateBoardRes.Status === PromptStatus.OK) + { + const disassociateBoards = DisassociateBoardRes.SelectSet.SelectEntityList as Board[]; //取消关联的板 + DisassociateBoard(disassociateBoards, FirstBoard); + return; + } + else + return; + } + } + + //解除板排钻锁关联 + function DisassociateBoard(brs: Board[], FirstBoard: Board) + { + for (const br of brs) + { + const associationBoardId = br.Id; + FirstBoard.ClearDrillAssociationLock(associationBoardId); + + br.ClearDrillAssociationLock(FirstBoard.Id); + } + + AppToaster.show({ + message: `排钻关联解除锁定成功,共解除了${brs.length}块板`, + intent: Intent.SUCCESS, + timeout: 3000, + }); + Log(`排钻关联解除锁定成功,共解除了${brs.length}块板`, LogType.Info, [...brs]); + } + } +} diff --git a/src/Add-on/DrawDrilling/DrillLock/IndependentLock.ts b/src/Add-on/DrawDrilling/DrillLock/IndependentLock.ts new file mode 100644 index 000000000..187bc6ea6 --- /dev/null +++ b/src/Add-on/DrawDrilling/DrillLock/IndependentLock.ts @@ -0,0 +1,114 @@ +import { Intent } from "@blueprintjs/core"; +import { app } from "../../../ApplicationServices/Application"; +import { Log, LogType } from "../../../Common/Log"; +import { Board } from "../../../DatabaseServices/Entity/Board"; +import { Command } from "../../../Editor/CommandMachine"; +import { PromptStatus } from "../../../Editor/PromptResult"; +import { AppToaster } from "../../../UI/Components/Toaster"; + +export class IndependentLockAndUnLock implements Command +{ + private isLock: boolean; + constructor(isLock: boolean) + { + this.isLock = isLock; + } + async exec() + { + const lockBoards = app.Database.ModelSpace.Entitys.filter(ent => + { + if (!ent.IsErase && ent instanceof Board) + { + return Boolean(ent.DrillLock === true); + } + return false; + }) as Board[]; + + if (this.isLock) + { + if (lockBoards.length) + { + app.Editor.SetSelection(lockBoards); //亮显关联的板 + + AppToaster.show({ + message: `已存在${lockBoards.length}块排钻锁定的板,以显示锁定的板`, + intent: Intent.PRIMARY, + timeout: 3000, + }); + } + + let brRes = await app.Editor.GetSelection({ + Msg: "请选择需要排钻锁定的板", + Filter: { filterTypes: [Board] }, + }); + + if (brRes.Status === PromptStatus.OK) + { + const brs = brRes.SelectSet.SelectEntityList as Board[]; + for (let ent of brs) + { + ent.DrillLock = this.isLock; + } + + AppToaster.show({ + message: `成功锁定${brs.length}块板`, + intent: Intent.SUCCESS, + timeout: 3000, + }); + Log(`成功锁定${brs.length}块板`, LogType.Info, [...brs]); + } + } + else + { + if (!lockBoards.length) + { + AppToaster.show({ + message: `当前图纸没有排钻锁定的板`, + intent: Intent.WARNING, + timeout: 3000, + }); + return; + } + while (true) + { + let brRes = await app.Editor.GetSelection({ + Msg: "请选择需要解除排钻锁定的板", + Filter: { + filterTypes: [Board], + filterFunction: (obj, ent) => + { + return (ent as Board).DrillLock; + } + }, + KeyWordList: [{ key: "A", msg: "选中所有已锁定排钻的板" }] + }); + + if (brRes.Status === PromptStatus.Keyword) + { + if (brRes.StringResult === "A") + { + app.Editor.SetSelection(lockBoards); //亮显关联的板 + } + } + else if (brRes.Status === PromptStatus.OK) + { + const brs = brRes.SelectSet.SelectEntityList as Board[]; + for (let ent of brs) + { + ent.DrillLock = this.isLock; + } + + AppToaster.show({ + message: `成功解除锁定${brs.length}块板`, + intent: Intent.SUCCESS, + timeout: 3000, + }); + Log(`成功解除锁定${brs.length}块板`, LogType.Info, [...brs]); + break; + } + else + break; + } + } + } +} diff --git a/src/Add-on/DrawDrilling/DrillingReactor.ts b/src/Add-on/DrawDrilling/DrillingReactor.ts index f0838ece2..c2b4b6385 100644 --- a/src/Add-on/DrawDrilling/DrillingReactor.ts +++ b/src/Add-on/DrawDrilling/DrillingReactor.ts @@ -106,7 +106,6 @@ export class DrillingReactor { if (!e.IsErase) { - e.ClearAllDrillList(); brs.add(e); } } @@ -148,10 +147,11 @@ export class DrillingReactor brs.add(br); } + const arrBrs = [...brs]; const tool = DrawDrillingTool.GetInstance(); - await tool.ClassifyAndDrilling(brs); + await tool.ClassifyAndDrilling(arrBrs); - for (let br of brs) + for (let br of arrBrs) { if (br.TempData?.unChange) br.TempData = undefined; diff --git a/src/Common/CommandNames.ts b/src/Common/CommandNames.ts index f99d0019f..17f10c71d 100644 --- a/src/Common/CommandNames.ts +++ b/src/Common/CommandNames.ts @@ -167,6 +167,11 @@ export enum CommandNames DimStyle = "DIMSTYLE", TextStyle = "TEXTSTYLE", ToggleDrillingReactor = "TOGGLEDRILLINGREACTOR", + IndependentDrillLock = "INDEPENDENTDRILLLOCK", + AssociationDrillLock = "ASSOCIATIONDRILLLOCK", + IndependentDrillUnlock = "INDEPENDENTDRILLUNLOCK", + AssociationDrillUnlock = "ASSOCIATIONDRILLUNLOCK", + AllDrillUnlock = "ALLDRILLUNLOCK", Esc = "ESC", Wireframe = "WIREFRAME", Conceptual = "CONCEPTUAL", diff --git a/src/DatabaseServices/Entity/Board.ts b/src/DatabaseServices/Entity/Board.ts index cf8d5513e..a8e81e90b 100644 --- a/src/DatabaseServices/Entity/Board.ts +++ b/src/DatabaseServices/Entity/Board.ts @@ -121,6 +121,8 @@ export class Board extends ExtrudeSolid private _2DModelingList: I2DModeling[] = []; private _3DModelingList: I3DModeling[] = []; private _CustomNumber: number = null;//自定义编号 + private _DrillLock = false; //排钻独立锁 + private _DrillAssociationLock = new Set(); //排钻关联锁 //仅在渲染器中使用倒角 //del_exp_start//del_exp_end protected bevelEnabled: boolean = true; @@ -287,6 +289,39 @@ export class Board extends ExtrudeSolid return this._DrillList; } + get DrillLock() + { + return this._DrillLock; + } + + set DrillLock(v: boolean) + { + this.WriteAllObjectRecord(); + this._DrillLock = v; + } + + get DrillAssociationLock(): Set + { + return this._DrillAssociationLock; + } + + AppendDrillAssociationLock(o: ObjectId) + { + this.WriteAllObjectRecord(); + this._DrillAssociationLock.add(o); + } + ClearDrillAssociationLock(o: ObjectId) + { + this.WriteAllObjectRecord(); + this._DrillAssociationLock.delete(o); + } + ClearAllDrillLock() + { + this.WriteAllObjectRecord(); + this._DrillLock = false; + this._DrillAssociationLock.clear(); + } + get LayerNails() { return this._LayerNails; @@ -694,6 +729,14 @@ export class Board extends ExtrudeSolid if (d && d.Object) d.Object.Erase(); } + + for (const br of this._DrillAssociationLock) //删除排钻锁关联板的信息 + { + if (br?.Object instanceof Board) + { + br.Object.ClearDrillAssociationLock(this.Id); + } + } this.ClearLayerNails(); } get RotateMat() @@ -2068,12 +2111,26 @@ export class Board extends ExtrudeSolid let count = file.Read(); processData.highBoardEdgeRemark = file.ReadArray(count); } + + this._DrillAssociationLock.clear(); + if (ver > 14) + { + this._DrillLock = file.Read(); + + //读取关联排钻锁映射 + const size = file.Read(); + for (let i = 0; i < size; i++) + { + const id = file.ReadObjectId(); + this._DrillAssociationLock.add(id); + } + } } WriteFile(file: CADFiler) { super.WriteFile(file); - file.Write(14); + file.Write(15); // file.Write(this._SpaceOCS.toArray()); ver < 6 file.Write(this._BoardType); file.Write(this._Name); @@ -2133,6 +2190,17 @@ export class Board extends ExtrudeSolid { file.Write(r); } + + //ver>14 + { + file.Write(this._DrillLock); + const count = this._DrillAssociationLock.size; + file.Write(count); + for (const id of this._DrillAssociationLock) + { + file.WriteObjectId(id); + } + } } } diff --git a/src/Editor/CommandRegister.ts b/src/Editor/CommandRegister.ts index d561fbdc4..63431bbed 100644 --- a/src/Editor/CommandRegister.ts +++ b/src/Editor/CommandRegister.ts @@ -221,6 +221,10 @@ import { ApplyModel2ToBoard } from "../Add-on/DrawBoard/ApplyModel2ToBoard"; import { ParseHandle } from "../Add-on/DrawBoard/ParseHandle"; import { ParseHinge } from "../Add-on/DrawBoard/ParseHinge"; import { Command_BoardInfoDimTool } from "../Add-on/DrawDim/BoardInfoDimTool"; +import { AllDrillUnlock } from "../Add-on/DrawDrilling/DrillLock/AllDrillUnlock"; +import { AssociationLock } from "../Add-on/DrawDrilling/DrillLock/AssociationLock"; +import { AssociationUnlock } from "../Add-on/DrawDrilling/DrillLock/AssociationUnlock"; +import { IndependentLockAndUnLock } from "../Add-on/DrawDrilling/DrillLock/IndependentLock"; import { Command_FBXImport } from "../Add-on/FBXLoad"; import { Command_Show2DPathLine } from "../Add-on/Show2DPathLine/Show2DPathLine"; import { Command_Show2DPathObject } from "../Add-on/Show2DPathLine/Show2DPathObject"; @@ -825,6 +829,12 @@ export function registerCommand() commandMachine.RegisterCommand(CommandNames.EditorBBS, new ShowEditorBBS()); commandMachine.RegisterCommand(CommandNames.ToggleDrillingReactor, new ToggleDrillingReactor()); + commandMachine.RegisterCommand(CommandNames.IndependentDrillLock, new IndependentLockAndUnLock(true)); + commandMachine.RegisterCommand(CommandNames.IndependentDrillUnlock, new IndependentLockAndUnLock(false)); + commandMachine.RegisterCommand(CommandNames.AssociationDrillLock, new AssociationLock()); + commandMachine.RegisterCommand(CommandNames.AssociationDrillUnlock, new AssociationUnlock()); + commandMachine.RegisterCommand(CommandNames.AllDrillUnlock, new AllDrillUnlock()); + commandMachine.RegisterCommand(CommandNames.CuttingFace, new CuttingByFace()); commandMachine.RegisterCommand(CommandNames.CuttingRectFace, new CuttingByRectFace()); diff --git a/src/UI/Components/Board/BoardCommon.tsx b/src/UI/Components/Board/BoardCommon.tsx index a061f54d8..f7381c37e 100644 --- a/src/UI/Components/Board/BoardCommon.tsx +++ b/src/UI/Components/Board/BoardCommon.tsx @@ -484,6 +484,7 @@ interface I5InputComponent extends ISetItemOption highDrillOption?: IHightDrillOption; isRemarks?: boolean; edgeRemarks?: string[]; + otherBoardData?: { [key: string]: any; }; } /** @@ -494,6 +495,9 @@ export class Input5Or4Component extends React.Component { render() { + const isDrillLock = this.props.otherBoardData?.isDrillLock; + const isAssociationDrillLock = this.props.otherBoardData?.isAssociationDrillLock; + const options = [...userConfig.DrillConfigs.keys(), "不排"]; const { isRemarks, highDrillOption, isShowEditor, type, upKey, leftKey, downKey, rightKey, centerKey, @@ -515,8 +519,9 @@ export class Input5Or4Component extends React.Component isShow && { highDrillOption.up = e.currentTarget.value; @@ -558,6 +563,7 @@ export class Input5Or4Component extends React.Component isShow && @@ -607,6 +613,7 @@ export class Input5Or4Component extends React.Component isShow && @@ -645,8 +652,9 @@ export class Input5Or4Component extends React.Component isShow && { highDrillOption.down = e.currentTarget.value; @@ -682,6 +690,7 @@ interface IDrillTypeSelect br: Board; isShowHigh?: boolean; onFocus?: Function; + otherBoardData?: { [key: string]: any; }; drillOption: IHightDrillOption; } @@ -796,15 +805,17 @@ export class DrillTypeSelectCom extends React.Component{ } return options; } + + getDrillLockInfo = () => + { + const { isAssociationDrillLock = false, isDrillLock = false } = this.props.otherBoardData; + let msg = ""; + let flag = ""; + if (isAssociationDrillLock && isDrillLock) + flag = "独立锁和关联锁"; + else if (isDrillLock) + flag = "独立锁"; + else if (isAssociationDrillLock) + flag = "关联锁"; + + if (flag) + msg = `当前板存在${flag}`; + return msg; + }; async UNSAFE_componentWillMount() { this.updateTags(); @@ -405,6 +422,7 @@ export class BoardProcessModal extends React.Component{ @@ -450,16 +468,33 @@ export class BoardProcessModal extends React.Component{ { - this.props.br && - { - this.props.otherBoardData.isChaiDan = !this.props.otherBoardData.isChaiDan; - }} - /> + this.props.br && + <> + + { + this.props.otherBoardData.isChaiDan = !this.props.otherBoardData.isChaiDan; + }} + /> + + + { + const islock = this.props.otherBoardData.isHeightDrillLock; + this.props.otherBoardData.isHeightDrillLock = !islock; + this.props.otherBoardData.isDrillLock = !islock; + }} + /> + + } { @@ -515,6 +550,7 @@ export class BoardProcessModal extends React.Component{ isShowEditor={true} isRemarks={isEdgeRemarks} highDrillOption={this.props.drillOption} + otherBoardData={this.props.otherBoardData} /> } diff --git a/src/UI/Components/Board/CommonBoardOption.tsx b/src/UI/Components/Board/CommonBoardOption.tsx index 0f2a0f27d..9d5f2bea3 100644 --- a/src/UI/Components/Board/CommonBoardOption.tsx +++ b/src/UI/Components/Board/CommonBoardOption.tsx @@ -41,6 +41,7 @@ export function AddCommonBoardProps(Com: React.ComponentType return class extends React.Component<{ board: Board; }, {}> { static displayName = 'BoardOption'; + private curDrillLock = false; //记录打开时的状态 public _ConfigOption: SingleBoardOption = observable({ name: "", type: 0, rotateX: 0, rotateY: 0, rotateZ: 0, openDir: BoardOpenDir.None }); @@ -64,7 +65,7 @@ export function AddCommonBoardProps(Com: React.ComponentType public canDrawSpecial = observable.box(true); public canModeling = observable.box(true); public remarks: [string, string][] = observable(Array.from({ length: 12 }, () => ["", ""]) as [string, string][]); - public otherBoardData = observable({ isChaiDan: true }); + public otherBoardData = observable({ isChaiDan: true, isDrillLock: false, isHeightDrillLock: false }); public _UIConfigOPtion: IUiOption = observable({ name: "", type: "0", rotateX: "0", rotateY: "0", rotateZ: "0" }); @@ -166,8 +167,14 @@ export function AddCommonBoardProps(Com: React.ComponentType this.remarks[i][1] = this._ProcessOption.remarks[i][1]; } - this.otherBoardData.isChaiDan = this.CurrentBoard.IsChaiDan; + Object.assign(this.otherBoardData, { + isChaiDan: this.CurrentBoard.IsChaiDan, + isDrillLock: this.CurrentBoard.DrillLock, + isAssociationDrillLock: this.CurrentBoard.DrillAssociationLock.size > 0, + isHeightDrillLock: this.CurrentBoard.DrillLock || this.CurrentBoard.DrillAssociationLock.size > 0, + }); + this.curDrillLock = this.otherBoardData.isHeightDrillLock; }); public InitRectBoardDrillOption = action(() => { @@ -272,6 +279,34 @@ export function AddCommonBoardProps(Com: React.ComponentType board.IsChaiDan = this.otherBoardData.isChaiDan; + if (this.otherBoardData.isHeightDrillLock != this.curDrillLock) + { + if (this.otherBoardData.isHeightDrillLock) + { + this.CurrentBoard.DrillLock = true; + AppToaster.show({ + message: "成功锁定当前板排钻独立锁", + timeout: 2000, + intent: Intent.SUCCESS, + }); + } + else + { + const currentBoard = this.CurrentBoard; + const associationBoards = [...currentBoard.DrillAssociationLock.values()].map(o => o.Object as Board); + for (const board of associationBoards) + { + board.ClearDrillAssociationLock(currentBoard.Id); + } + currentBoard.ClearAllDrillLock(); + AppToaster.show({ + message: "成功解锁当前板排钻独立锁和关联锁", + timeout: 2000, + intent: Intent.SUCCESS, + }); + } + } + app.Editor.ModalManage.Destory(); board.AutoUpdate = oldAutoUpdate; diff --git a/src/UI/Components/CommandPanel/CommandList.ts b/src/UI/Components/CommandPanel/CommandList.ts index 3818ec910..d9947fd91 100644 --- a/src/UI/Components/CommandPanel/CommandList.ts +++ b/src/UI/Components/CommandPanel/CommandList.ts @@ -1110,6 +1110,56 @@ export const CommandList: ICommand[] = [ chName: "开关排钻反应器", chDes: "开关排钻反应器", }, + { + icon: IconEnum.IndependentDrillLock, + typeId: "pz", + link: `#`, + defaultCustom: CommandNames.IndependentDrillLock, + command: CommandNames.IndependentDrillLock, + type: "排钻", + chName: "独立排钻锁", + chDes: "独立排钻锁", + }, + { + icon: IconEnum.IndependentDrillUnlock, + typeId: "pz", + link: `#`, + defaultCustom: CommandNames.IndependentDrillUnlock, + command: CommandNames.IndependentDrillUnlock, + type: "排钻", + chName: "解除独立排钻锁", + chDes: "解除独立排钻锁", + }, + { + icon: IconEnum.AssociationDrillLock, + typeId: "pz", + link: `#`, + defaultCustom: CommandNames.AssociationDrillLock, + command: CommandNames.AssociationDrillLock, + type: "排钻", + chName: "关联排钻锁", + chDes: "关联排钻锁", + }, + { + icon: IconEnum.AssociationDrillUnlock, + typeId: "pz", + link: `#`, + defaultCustom: CommandNames.AssociationDrillUnlock, + command: CommandNames.AssociationDrillUnlock, + type: "排钻", + chName: "解除关联排钻锁", + chDes: "解除关联排钻锁", + }, + { + icon: IconEnum.AllDrillUnlock, + typeId: "pz", + link: `#`, + defaultCustom: CommandNames.AllDrillUnlock, + command: CommandNames.AllDrillUnlock, + type: "排钻", + chName: "解除所有排钻锁", + chDes: "解除所有排钻锁", + }, // { // icon: IconEnum.HideDrill, // typeId: "pz",