2026-01-26 16:16:40 +08:00
|
|
|
import { Command } from "./Command.js";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 部件绘制命令
|
|
|
|
|
*/
|
|
|
|
|
export class PartDrawCommand extends Command {
|
|
|
|
|
constructor(options) {
|
|
|
|
|
super({
|
|
|
|
|
name: "部件绘制命令",
|
|
|
|
|
saveState: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.canvas = options.canvas;
|
|
|
|
|
this.partManager = options.partManager;
|
|
|
|
|
this.partCanvas = options.partCanvas;
|
|
|
|
|
this.oldPartCanvas = this.partManager.partCanvas;
|
|
|
|
|
}
|
|
|
|
|
execute() {
|
|
|
|
|
this.partManager.drawPartCanvas(this.partCanvas);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
undo() {
|
|
|
|
|
this.partManager.drawPartCanvas(this.oldPartCanvas);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-27 10:58:27 +08:00
|
|
|
/**
|
|
|
|
|
* 部件点选绘制命令
|
|
|
|
|
*/
|
|
|
|
|
export class PartPointDrawCommand extends Command {
|
|
|
|
|
constructor(options) {
|
|
|
|
|
super({
|
|
|
|
|
name: "部件点选绘制命令",
|
|
|
|
|
saveState: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.canvas = options.canvas;
|
|
|
|
|
this.partManager = options.partManager;
|
|
|
|
|
this.partCanvas = options.partCanvas;
|
|
|
|
|
this.pointList = options.pointList;
|
|
|
|
|
this.oldPartCanvas = this.partManager.partCanvas;
|
|
|
|
|
this.oldPointList = [...this.partManager.pointList];
|
|
|
|
|
}
|
|
|
|
|
async execute() {
|
|
|
|
|
const list = [...this.pointList];
|
|
|
|
|
const canvas = this.partCanvas;
|
|
|
|
|
const res = await this.partManager.pointDrawPartCanvas(list, canvas);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
async undo() {
|
|
|
|
|
const list = [...this.oldPointList];
|
|
|
|
|
const canvas = this.oldPartCanvas;
|
|
|
|
|
const res = await this.partManager.pointDrawPartCanvas(list, canvas);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
}
|