mirror of https://gitee.com/cf-fz/WebCAD.git
!3055 修复: 删除模型材质后,undo/redo时模型材质不正确问题。
parent
a30aa7f89c
commit
998430c141
@ -0,0 +1,38 @@
|
||||
import { end } from "xaop";
|
||||
import { app } from "../ApplicationServices/Application";
|
||||
import { GetUseCurMtlEntities } from "../Common/ApplyMaterial";
|
||||
import { CommandNames } from "../Common/CommandNames";
|
||||
import { UpdateDraw } from "../Common/Status";
|
||||
import { CommandHistoryRecord } from "../DatabaseServices/CommandHistoryRecord";
|
||||
import { PhysicalMaterialRecord } from "../DatabaseServices/PhysicalMaterialRecord";
|
||||
|
||||
export class DeleteMaterialReactor
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
const DeleteMtlFunction = () =>
|
||||
{
|
||||
return (cmdName: string, historyRec: CommandHistoryRecord) =>
|
||||
{
|
||||
if (cmdName !== CommandNames.DeleteMtl) return;
|
||||
for (let [id,] of historyRec.HistoryList)
|
||||
{
|
||||
if (id.Object instanceof PhysicalMaterialRecord)
|
||||
this.UpdateMtl(id.Object);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const DeleteMtlUndo = DeleteMtlFunction();
|
||||
const DeleteMtlRedo = DeleteMtlFunction();
|
||||
end(app.Database.hm, app.Database.hm.RedoEvent, DeleteMtlRedo);
|
||||
end(app.Database.hm, app.Database.hm.UndoEvent, DeleteMtlUndo);
|
||||
}
|
||||
|
||||
UpdateMtl(mtl: PhysicalMaterialRecord)
|
||||
{
|
||||
const entities = GetUseCurMtlEntities(mtl, true);
|
||||
for (const en of entities)
|
||||
en.Update(UpdateDraw.Material);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue