!3021 优化:材质动作修改材质时,被锁定的材质不会被修改

pull/3024/head
黄诗津 1 month ago committed by ChenX
parent 5f6ad34c26
commit 2c20089066

@ -1,3 +1,4 @@
import { Intent, Toaster } from "../../../Common/Toaster";
import { ApplyGoodInfo } from "../../../UI/Components/ApplyGoodInfo";
import { Factory } from "../../CADFactory";
import { CADFiler } from "../../CADFiler";
@ -5,6 +6,7 @@ import { Board } from "../../Entity/Board";
import { Entity } from "../../Entity/Entity";
import { HardwareCompositeEntity } from "../../Hardware/HardwareCompositeEntity";
import { ObjectId } from "../../ObjectId";
import { PhysicalMaterialRecord } from "../../PhysicalMaterialRecord";
import { TemplateAction } from "./TemplateAction";
@Factory
@ -23,7 +25,7 @@ export class TemplateMaterialAction extends TemplateAction
protected override _Update(paramDiff: number)
{
if (!this.parent.MaterialValue) return;
let hasMaterialLock = false;
for (let id of this.Entitys)
{
if (!(id?.Object) || id.IsErase) continue;
@ -32,7 +34,10 @@ export class TemplateMaterialAction extends TemplateAction
if (this.ApplyGoodInfo && en instanceof Board)
ApplyGoodInfo(en, this.parent.MaterialValue);
en.Material = this.parent.MaterialValue.Id;
if ((en.Material?.Object as PhysicalMaterialRecord)?.IsMaterialLock || en.LockMaterial)
hasMaterialLock = true;
else
en.Material = this.parent.MaterialValue.Id;
}
for (let [id, indexs] of this.CompositeEntitys)
@ -40,7 +45,11 @@ export class TemplateMaterialAction extends TemplateAction
if (!(id?.Object) || id.IsErase) continue;
let en = id.Object as HardwareCompositeEntity;
if (en.LockMaterial)
{
hasMaterialLock = true;
continue;
}
let allEntitys: Entity[] = [];
const GetAllEntitys = (hard: HardwareCompositeEntity) =>
{
@ -63,9 +72,21 @@ export class TemplateMaterialAction extends TemplateAction
if (this.ApplyGoodInfo && subE instanceof Board)
ApplyGoodInfo(subE, this.parent.MaterialValue);
subE.Material = this.parent.MaterialValue.Id;
if ((subE.Material?.Object as PhysicalMaterialRecord)?.IsMaterialLock)
hasMaterialLock = true;
else
subE.Material = this.parent.MaterialValue.Id;
}
}
if (hasMaterialLock)
{
Toaster({
message: "注意:有被锁定的材质,无法修改",
intent: Intent.WARNING,
timeout: 3000
});
}
}
//#region -------------------------File-------------------------

Loading…
Cancel
Save