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

@@ -29,8 +29,12 @@ const props = defineProps({
type: Boolean,
default: false,
},
clothingMinIOPath: {
type: String,
default: "", // 衣服底图URL-线稿
},
});
console.log(props.clothingMinIOPath)
const commandManager = inject("commandManager");
const layerManager = inject("layerManager"); // 图层管理器
@@ -249,7 +253,13 @@ const redGreenToolsList = ref([
// 根据模式选择工具列表
const toolsList = computed(() => {
return props.isRedGreenMode ? redGreenToolsList.value : normalToolsList.value;
const list = props.isRedGreenMode ? redGreenToolsList.value : normalToolsList.value;
return list.filter(tool => {
if(tool.id === OperationType.PART){
return !!props.clothingMinIOPath;
}
return true;
});
});
function selectTool(tool, isRedGreenMode = false) {

View File

@@ -86,6 +86,10 @@ const props = defineProps({
type: Boolean,
default: false, // 是否启用红绿图模式
},
clothingMinIOPath: {
type: String,
default: "", // 衣服底图URL-线稿
},
clothingImageUrl: {
type: String,
default: "", // 衣服底图URL-线稿
@@ -378,6 +382,7 @@ onMounted(async () => {
selectionManager = new SelectionManager({
canvas: canvasManager.canvas,
layerManager,
props,
});
canvasManager.setSelectionManager(selectionManager);
@@ -387,6 +392,7 @@ onMounted(async () => {
layerManager,
canvasManager,
toolManager,
props,
});
canvasManager.setPartManager(partManager);
@@ -1203,6 +1209,7 @@ defineExpose({
v-if="canvasManagerLoaded"
:activeTool="activeTool"
:isRedGreenMode="isRedGreenMode"
:clothingMinIOPath="props.clothingMinIOPath"
@tool-selected="handleToolSelect"
@red-green-tool-selected="handleRedGreenToolSelect"
@toggle-red-green-mode="toggleRedGreenMode"

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;

View File

@@ -335,15 +335,15 @@ const otherData = {
color: {rgba: {r:255,g:0,b:0,a:1}},
printObject: {
prints: [
{
ifSingle: false,
level2Type: "Pattern",
designType: "Library",
path: "/src/assets/images/canvas/yinhua1.jpg",
location: [250, 780],
scale: [0.3, 0.4],
angle: 0,
},
// {
// ifSingle: false,
// level2Type: "Pattern",
// designType: "Library",
// path: "/src/assets/images/canvas/yinhua1.jpg",
// location: [250, 780],
// scale: [0.3, 0.4],
// angle: 0,
// },
{
ifSingle: true,
level2Type: "Pattern",

View File

@@ -10,6 +10,7 @@
<editCanvas v-if="canvasLoad" :config="canvasConfig"
@canvasInit="canvasInit"
is-edit
:clothingMinIOPath="selectDetail.minIOPath"
:clothingImageUrl="selectDetail.path"
:clothingImageUrl2="selectDetail.undividedLayer_"
showFixedLayer

View File

@@ -440,7 +440,10 @@ export const Https = {
getHistoryNotification: `/api/message/getHistoryNotification`, //获取历史消息
oneClickRead: `/api/message/oneClickRead`, //全部设为已读
personalHomepage: `/api/account/personalHomepage`, //获取个人主页信息
refreshMinioUrl: `/api/third/party/refreshMinioUrl` //获取可以使用的minio地址
refreshMinioUrl: `/api/third/party/refreshMinioUrl`, //获取可以使用的minio地址
// 画布
segAnything: `/api/python/segAnything`,//分割Anything
},
axiosGet(url, config) {