Files
aida_front/src/component/Canvas/CanvasEditor/commands/PartCommands.js

57 lines
1.3 KiB
JavaScript
Raw Normal View History

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;
}
}
/**
* 部件点选绘制命令
*/
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;
}
}