This commit is contained in:
李志鹏
2026-01-15 17:15:05 +08:00
parent 28b6153ab0
commit 7101daeb90
8 changed files with 68 additions and 17 deletions

View File

@@ -1661,6 +1661,7 @@ export class CanvasManager {
height: image.height,
},
isPrintTrims: true,
// ...(item.object || {}),
});
this.canvas.add(rect);
let layer = createLayer({

View File

@@ -5,6 +5,8 @@ import { CreateSelectionCommand } from "../commands/SelectionCommands";
import { ClearSelectionCommand } from "../commands/LassoCutoutCommand";
import addIcon from "@/assets/images/canvas/add.png";
import removeIcon from "@/assets/images/canvas/remove.png";
import { Https } from "@/tool/https";
import store from "@/store";
/**
* 部件选择管理器
@@ -25,6 +27,7 @@ export class PartManager {
this.layerManager = options.layerManager;
this.canvasManager = options.canvasManager;
this.toolManager = options.toolManager;
this.props = options.props;
// 状态
this.isActive = false;
@@ -214,17 +217,25 @@ export class PartManager {
this.canvas.upperCanvasEl.style.cursor = icon;
}
// 点选工具模式下移动事件处理
_pointMoveHandler(options) {
}
_pointMoveHandler(options) { }
// 点选工具模式下抬起事件处理
_pointUpHandler(options) {
const button = options.button;
const isLeft = button === 1;// 左键1添加 右键3删除
this.canvas.upperCanvasEl.style.cursor = this.defaultCursor;
const fixedObject = this.canvasManager.getFixedLayerObject();
if (!fixedObject) return console.warn("未找到固定图层");
const { x, y } = options.pointer;
const fixedObject = this.canvasManager.getFixedLayerObject({ x, y });
console.log("==========", fixedObject)
const width = fixedObject.width * fixedObject.scaleX;
const height = fixedObject.height * fixedObject.scaleY;
const X = x - (fixedObject.left - width / 2);
const Y = y - (fixedObject.top - height / 2);
this.getSegAnythingImage({
image_path: "aida-users/24299/sketch/70bb39cc-63e0-44a9-a627-3542d0f9cd70.png",
type: "point",
points: [[X, Y], [X - 10, Y - 10]],
labels: [1, 0],
});
}
@@ -265,6 +276,23 @@ export class PartManager {
// 获取分隔后图片
async getSegAnythingImage(obj) {
const user_id = store.state.UserHabit.userDetail.userId;
const data = {
user_id,
...obj,
}
Https.axiosPost(Https.httpUrls.segAnything, data)
.then(response => {
console.log(response);
})
.catch(error => {
console.error(error);
});
}
/**
* 清除选区
*/

View File

@@ -37,6 +37,7 @@ export class ToolManager {
this.activeTool = options.activeTool || {
value: OperationType.SELECT,
};
this.props = options.props;
// 红绿图模式状态
this.isRedGreenMode = false;