部件选取

This commit is contained in:
李志鹏
2026-01-26 16:16:40 +08:00
parent ba49b02ebe
commit 9cecbdcf9b
11 changed files with 245 additions and 144 deletions

View File

@@ -106,7 +106,6 @@ export class FillGroupLayerBackgroundCommand extends Command {
});
}
}
// 判断fabricObjects是否是组对象
const firstObj = layer.fabricObjects?.[0] || null;
// 如果没有找到第一个对象,则直接添加到当前画布
@@ -173,8 +172,8 @@ export class FillGroupLayerBackgroundCommand extends Command {
}
const canvasObj = findObjectById(this.canvas, firstObj?.id)?.object;
if (
(canvasObj && canvasObj.type === "group") ||
canvasObj._objects?.length > 0
canvasObj && (canvasObj.type === "group" ||
canvasObj._objects?.length > 0)
) {
this.newFill.set({
left: 0,

View File

@@ -147,11 +147,11 @@ export class LassoCutoutCommand extends CompositeCommand {
}
// 确定源图层
const sourceLayer = this.layerManager.getActiveLayer();
if (!sourceLayer) {
console.error("无法执行套索抠图:源图层无效");
return false;
}
// const sourceLayer = this.layerManager.getActiveLayer();
// if (!sourceLayer) {
// console.error("无法执行套索抠图:源图层无效");
// return false;
// }
// 获取源图层的所有对象(包括子图层)
// const sourceObjects = this._getLayerObjects(sourceLayer);
@@ -225,7 +225,7 @@ export class LassoCutoutCommand extends CompositeCommand {
const layers = this.layerManager.layers.value;
var topLayerIndex = 0;
layers.forEach((layer, index) => {
if(this.originalLayer)layers.forEach((layer, index) => {
if (layer.id === this.originalLayer.id) {
topLayerIndex = index;
}else if (layer.children.length > 0) {

View File

@@ -0,0 +1,26 @@
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;
}
}