!2615 优化排钻锁功能和提示

pull/2622/head
黄诗津 7 months ago committed by ChenX
parent c90e467707
commit da9f033711

@ -223,6 +223,14 @@ export class LinearCutting implements Command
app.Database.ModelSpace.Append(br2);
br2.RepairRelevance();
br2.GrooveCheckAllAutoSplit();
//新的板需要重新关联板的关联排钻锁
for (const o of br.DrillAssociationLock)
{
br2.DrillAssociationLock.add(o);
if (o && o.Object)
(o.Object as Board).DrillAssociationLock.add(br2.Id);
}
spliteEnts.push(br2);
fixPath.SetBoardPath2d(br2);

@ -83,20 +83,27 @@ export class AddAssocDrillLock implements Command
if (associationBoardRes.Status === PromptStatus.OK)
{
const associationBoards = associationBoardRes.SelectSet.SelectEntityList as Board[];
for (const associationBoard of associationBoards)
const associBoards = []; //成功关联的板
let count = 0; //没有关联的板数量
const assocBrIds = new Set(FirstBoard.DrillList.keys());
for (const br of associationBoards)
{
const associationBoardId = associationBoard.Id;
FirstBoard.AppendDrillAssociationLock(associationBoardId);
associationBoard.AppendDrillAssociationLock(FirstBoardId);
if (assocBrIds.has(br.Id))
{
associBoards.push(br);
FirstBoard.AppendDrillAssociationLock(br.Id);
br.AppendDrillAssociationLock(FirstBoard.Id);
}
else
count++;
}
AppToaster.show({
message: `排钻关联锁定成功,共关联了${associationBoards.length}块板`,
message: `${associBoards.length}块板关联了排钻锁,有${count}块板没有关联排钻,未关联排钻锁`,
intent: Intent.SUCCESS,
timeout: 3000,
});
Log(`排钻关联锁定成功,关联了${associationBoards.length}块板`, LogType.Info, [...associationBoards]);
Log(`${associBoards.length}块板关联了排钻锁,查看关联的板:`, LogType.Info, [...associBoards]);
return;
}
}
@ -127,7 +134,15 @@ export class AddAssocDrillLock implements Command
if (BoardRes.SelectSet.SelectObjectCount === 2)
{
const [br1, br2] = BoardRes.SelectSet.SelectEntityList as Board[];
if (br1.DrillAssociationLock.has(br2.Id))
if ([...br1.DrillList.keys()].every(id => br2.Id != id))
{
AppToaster.show({
message: `选中的板之间没有排钻,请先排钻再关联`,
intent: Intent.WARNING,
timeout: 3000,
});
}
else if (br1.DrillAssociationLock.has(br2.Id))
{
AppToaster.show({
message: `选中的板已关联,请勿重复关联`,

@ -69,6 +69,7 @@ export class AddAloneDrillLock implements Command
});
return;
}
let isShow = false;
while (true)
{
let brRes = await app.Editor.GetSelection({
@ -80,14 +81,18 @@ export class AddAloneDrillLock implements Command
return (ent as Board).DrillLock;
}
},
KeyWordList: [{ key: "A", msg: "选中所有已锁定排钻的板" }]
KeyWordList: [{ key: "A", msg: isShow ? "取消选中所有已锁定排钻的板" : "选中所有已锁定排钻的板" }]
});
if (brRes.Status === PromptStatus.Keyword)
{
if (brRes.StringResult === "A")
{
app.Editor.SetSelection(lockBoards); //亮显关联的板
isShow = !isShow;
if (isShow)
app.Editor.SetSelection(lockBoards);
else
app.Editor.SelectCtrl.SelectSet.Clear();
}
}
else if (brRes.Status === PromptStatus.OK)

@ -30,7 +30,7 @@ export class RemoveAssocDrillLock implements Command
}
//选择方案
let plan = 0;
let plan = 1;
//显示模式
let viewMode = false;
@ -47,7 +47,6 @@ export class RemoveAssocDrillLock implements Command
{
const associationBoardId = br.Id;
FirstBoard.ClearDrillAssociationLock(associationBoardId);
br.ClearDrillAssociationLock(FirstBoard.Id);
}
@ -170,17 +169,19 @@ export class RemoveAssocDrillLock implements Command
{
for (const br of allBoards)
{
br.ClearAllDrillLock();
br.ClearAllAssociDrillLock();
}
AppToaster.show({
message: `成功解除排钻锁成功`,
message: `成功解除关联排钻锁`,
intent: Intent.SUCCESS,
timeout: 3000,
});
}
return;
}
else
return;
}
else
return;

@ -66,7 +66,8 @@ export class RemoveDrillLock implements Command
{
for (const br of allBoards)
{
br.ClearAllDrillLock();
br.DrillLock = false;
br.ClearAllAssociDrillLock();
}
AppToaster.show({

@ -144,17 +144,14 @@ export class DrillingReactor
for (const br of brs)
{
if (br.DrillLock) continue;
let noClearDrills = [];
let assBrs = [...br.DrillList.keys()].map(id => id.Object) as Board[];
for (const assBr of assBrs)
for (const [id] of br.DrillList)
{
if (assBr.DrillAssociationLock.has(br.Id) || assBr.DrillLock)
const assBr = id?.Object as Board;
if (assBr && !(assBr.DrillAssociationLock.has(br.Id) || assBr.DrillLock))
{
noClearDrills.push(assBr.Id);
br.ClearDrillList(id);
}
}
let needClearDrills = [...br.DrillList.keys()].filter(id => !noClearDrills.includes(id));
needClearDrills.forEach(id => br.ClearDrillList(id));
}
let sbs = this.GetSurroundBoards(brs);

@ -234,18 +234,53 @@ export class Command_Join implements Command
while (brs.length > 1)
{
let br = brs.shift();//取第一个
let joinBrs: ExtrudeSolid[] = []; //合并了的板
//剩余的 无法合并的板件
let remBrs = brs.filter(b =>
{
let isSuccess = br.Join(b);
if (isSuccess)
{
b.Erase();
joinBrs.push(b);
return false;
}
return true;
});
if ([br, ...joinBrs].every(b => b instanceof Board))
{
let nbr = br as Board;
for (const joinBr of joinBrs)
{
let njoinBr = joinBr as Board;
if (njoinBr.DrillLock)
nbr.DrillLock = njoinBr.DrillLock;
if (njoinBr.DrillAssociationLock.size > 0)
{
for (const o of njoinBr.DrillAssociationLock)
{
nbr.DrillAssociationLock.add(o);
if (o && o.Object)
(o.Object as Board).DrillAssociationLock.add(nbr.Id);
}
}
for (const [o, drs] of njoinBr.DrillList)
{
nbr.AppendDrillList(o, drs);
let br = (o.Object as Board);
br.AppendDrillList(nbr.Id, drs);
br.WriteAllObjectRecord();
(o.Object as Board).DrillList.delete(njoinBr.Id);
}
njoinBr.WriteAllObjectRecord();
njoinBr.DrillList.clear();
njoinBr.Erase();
}
}
if (remBrs.length === brs.length)
{
//br无法和当前brs中任意一个合并时进入

@ -315,11 +315,19 @@ export class Board extends ExtrudeSolid
this.WriteAllObjectRecord();
this._DrillAssociationLock.delete(o);
}
ClearAllDrillLock()
ClearAllAssociDrillLock()
{
this.WriteAllObjectRecord();
this._DrillLock = false;
this._DrillAssociationLock.clear();
for (const o of this._DrillAssociationLock)
{
this.ClearDrillAssociationLock(o);
if (o && o.Object)
{
let br = o.Object as Board;
br.ClearDrillAssociationLock(this.Id);
}
}
}
get LayerNails()
@ -1193,6 +1201,7 @@ export class Board extends ExtrudeSolid
Clone(): this
{
let br = super.Clone();
br._DrillAssociationLock.clear();
br._DrillList.clear();
br._LayerNails.length = 0;
br.RelativeHardware.length = 0;
@ -1482,7 +1491,7 @@ export class Board extends ExtrudeSolid
//如果没有开排钻反应器,那么需要重新关联排钻
//排钻列表
let dris: [ObjectId, ObjectId[][]][] = [];
if (!HostApplicationServices.openDrillingReactor)
if (!HostApplicationServices.openDrillingReactor || this.DrillLock || this.DrillAssociationLock.size > 0)
{
for (let d of this._DrillList)
{
@ -1534,7 +1543,7 @@ export class Board extends ExtrudeSolid
});
//如果没有开排钻反应器,那么需要重新关联排钻
if (!HostApplicationServices.openDrillingReactor)
if (!HostApplicationServices.openDrillingReactor || this.DrillLock || this.DrillAssociationLock.size > 0)
{
for (let d of dris)
{

@ -7,6 +7,7 @@ import { app } from '../../../ApplicationServices/Application';
import { CheckObjectType, CheckoutValid } from '../../../Common/CheckoutVaildValue';
import { DataAdapter } from '../../../Common/DataAdapter';
import { safeEval } from '../../../Common/eval';
import { Log, LogType } from '../../../Common/Log';
import { FixedNotZero } from '../../../Common/Utils';
import { Board } from '../../../DatabaseServices/Entity/Board';
import { BoardOpenDir } from '../../../DatabaseServices/Entity/BoardInterface';
@ -296,10 +297,11 @@ export function AddCommonBoardProps(Com: React.ComponentType<ICommonOptionProps>
currentBoard.ClearDrillAssociationLock(board.Id);
}
AppToaster.show({
message: "成功解锁当前板排钻独立锁",
message: "排钻关联解除锁定成功",
timeout: 2000,
intent: Intent.SUCCESS,
});
Log(`排钻关联解除锁定成功,共解除了${associationBoards.length}块板`, LogType.Info, [...associationBoards]);
}
app.Editor.ModalManage.Destory();

Loading…
Cancel
Save