略略略
This commit is contained in:
@@ -39,3 +39,16 @@ export const deleteDepthCanvas = (id: string) => {
|
|||||||
loading: true,
|
loading: true,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分隔后图片
|
||||||
|
* @param data 分隔参数数据
|
||||||
|
* @returns 分隔后图片数据
|
||||||
|
*/
|
||||||
|
export const getSegAnythingImage = (data: object) => {
|
||||||
|
return request({
|
||||||
|
url: `/api/python/segAnything`,
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -133,3 +133,18 @@ export const getAvatarLimit = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户风格图片列表
|
||||||
|
* @param params 获取用户风格图片列表的参数
|
||||||
|
* @param params.pageNum 页码
|
||||||
|
* @param params.pageSize 每页数量
|
||||||
|
* @returns 用户风格图片列表
|
||||||
|
*/
|
||||||
|
export const GetUserStyleImages = (params) => {
|
||||||
|
return request({
|
||||||
|
url: '/api/user/style/images',
|
||||||
|
method: 'get',
|
||||||
|
params,
|
||||||
|
loading: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -105,6 +105,7 @@
|
|||||||
const json = canvasManager.processCanvasDisUrlJSON(canvasData)
|
const json = canvasManager.processCanvasDisUrlJSON(canvasData)
|
||||||
await canvasManager.loadJSON(json)
|
await canvasManager.loadJSON(json)
|
||||||
}
|
}
|
||||||
|
layerManager.setActiveFirstLayer()
|
||||||
globalStore.setLoading(false)
|
globalStore.setLoading(false)
|
||||||
|
|
||||||
stateManager.onMounted()
|
stateManager.onMounted()
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { fabric } from 'fabric-with-all'
|
import { fabric } from 'fabric-with-all'
|
||||||
import { OperationType } from '../tools/layerHelper'
|
import { OperationType } from '../tools/layerHelper'
|
||||||
import { getObjectAlphaToCanvas, traceImageContour, cloneObjects } from '../tools/canvasMethod'
|
import { getObjectAlphaToCanvas, traceImageContour, cloneObjects } from '../tools/canvasMethod'
|
||||||
|
import { getSegAnythingImage } from '@/api/depth-canvas'
|
||||||
|
import { useGlobalStore, useUserInfoStore } from '@/stores'
|
||||||
|
|
||||||
/** 智能框选工具管理器 */
|
/** 智能框选工具管理器 */
|
||||||
export class AISelectboxToolManager {
|
export class AISelectboxToolManager {
|
||||||
@@ -10,6 +12,7 @@ export class AISelectboxToolManager {
|
|||||||
layerManager: any
|
layerManager: any
|
||||||
toolManager: any
|
toolManager: any
|
||||||
|
|
||||||
|
targetObject: any
|
||||||
isDragging: boolean = false
|
isDragging: boolean = false
|
||||||
startX: number = 0
|
startX: number = 0
|
||||||
startY: number = 0
|
startY: number = 0
|
||||||
@@ -54,6 +57,19 @@ export class AISelectboxToolManager {
|
|||||||
this.clear();
|
this.clear();
|
||||||
this.createDemoObject()
|
this.createDemoObject()
|
||||||
this.tcanvas = null;
|
this.tcanvas = null;
|
||||||
|
this.targetObject = null;
|
||||||
|
this.canvasManager.getObjects().forEach((obj) => {
|
||||||
|
if (obj?.info?.isOriginal) {
|
||||||
|
this.targetObject = obj.toObject();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// const image = this.layerManager.getActiveLayer()
|
||||||
|
// if (image && image.info.isAiSelect) {
|
||||||
|
// this.targetObject = image;
|
||||||
|
// } else {
|
||||||
|
// this.targetObject = null;
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
clear() {
|
clear() {
|
||||||
console.log("清除智能框选工具")
|
console.log("清除智能框选工具")
|
||||||
@@ -121,6 +137,7 @@ export class AISelectboxToolManager {
|
|||||||
}
|
}
|
||||||
// 处理绘制图像
|
// 处理绘制图像
|
||||||
async handleDrawImage(object: fabric.Object) {
|
async handleDrawImage(object: fabric.Object) {
|
||||||
|
if (!this.targetObject) return;
|
||||||
const tcanvas = await this.createStaticCanvas(this.demoObject)
|
const tcanvas = await this.createStaticCanvas(this.demoObject)
|
||||||
tcanvas.add(object)
|
tcanvas.add(object)
|
||||||
tcanvas.renderAll();
|
tcanvas.renderAll();
|
||||||
@@ -129,6 +146,7 @@ export class AISelectboxToolManager {
|
|||||||
}
|
}
|
||||||
// 处理图像删除
|
// 处理图像删除
|
||||||
async handleRemoveImage(object: fabric.Object) {
|
async handleRemoveImage(object: fabric.Object) {
|
||||||
|
if (!this.targetObject) return;
|
||||||
const tcanvas = await this.createStaticCanvas(this.demoObject)
|
const tcanvas = await this.createStaticCanvas(this.demoObject)
|
||||||
const rcanvas = await this.createStaticCanvas(object)
|
const rcanvas = await this.createStaticCanvas(object)
|
||||||
const tempCanvas = rcanvas.toCanvasElement();
|
const tempCanvas = rcanvas.toCanvasElement();
|
||||||
@@ -147,6 +165,7 @@ export class AISelectboxToolManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mouseDownEvent(e) {
|
mouseDownEvent(e) {
|
||||||
|
if (!this.targetObject) return;
|
||||||
const tool = this.toolManager.currentTool.value
|
const tool = this.toolManager.currentTool.value
|
||||||
const tools = [OperationType.AISELECT_ADD, OperationType.AISELECT_REMOVE]
|
const tools = [OperationType.AISELECT_ADD, OperationType.AISELECT_REMOVE]
|
||||||
if (!tools.includes(tool)) return;
|
if (!tools.includes(tool)) return;
|
||||||
@@ -157,6 +176,7 @@ export class AISelectboxToolManager {
|
|||||||
this.createIndicatorObject()
|
this.createIndicatorObject()
|
||||||
}
|
}
|
||||||
mouseMoveEvent(e) {
|
mouseMoveEvent(e) {
|
||||||
|
if (!this.targetObject) return;
|
||||||
if (!this.isDragging) return;
|
if (!this.isDragging) return;
|
||||||
var width = e.absolutePointer.x - this.startX
|
var width = e.absolutePointer.x - this.startX
|
||||||
var height = e.absolutePointer.y - this.startY
|
var height = e.absolutePointer.y - this.startY
|
||||||
@@ -173,7 +193,8 @@ export class AISelectboxToolManager {
|
|||||||
this.indicatorObject.set({ width, height, left, top })
|
this.indicatorObject.set({ width, height, left, top })
|
||||||
this.canvasManager.canvas.renderAll()
|
this.canvasManager.canvas.renderAll()
|
||||||
}
|
}
|
||||||
mouseUpEvent(e) {
|
async mouseUpEvent(e) {
|
||||||
|
if (!this.targetObject) return;
|
||||||
if (!this.isDragging) return;
|
if (!this.isDragging) return;
|
||||||
this.isDragging = false;
|
this.isDragging = false;
|
||||||
const object = this.indicatorObject.toJSON("evented")
|
const object = this.indicatorObject.toJSON("evented")
|
||||||
@@ -182,20 +203,32 @@ export class AISelectboxToolManager {
|
|||||||
this.clearIndicatorObject()
|
this.clearIndicatorObject()
|
||||||
this.canvasManager.canvas.renderAll()
|
this.canvasManager.canvas.renderAll()
|
||||||
|
|
||||||
const rect = new fabric.Rect({
|
useGlobalStore().setLoading(true)
|
||||||
left: object.left,
|
const x1 = Math.round(object.left)
|
||||||
top: object.top,
|
const y1 = Math.round(object.top)
|
||||||
width: object.width,
|
const x2 = Math.round(object.left + object.width)
|
||||||
height: object.height,
|
const y2 = Math.round(object.top + object.height)
|
||||||
fill: '#f00',
|
const data = {
|
||||||
strokeWidth: 0,
|
type: "box",
|
||||||
})
|
box: [x1, y1, x2, y2],
|
||||||
|
}
|
||||||
|
const url = await this.getSegAnythingImage(data)
|
||||||
|
const image = await this.loadImageToObject(url)
|
||||||
|
// const rect = new fabric.Rect({
|
||||||
|
// left: object.left,
|
||||||
|
// top: object.top,
|
||||||
|
// width: object.width,
|
||||||
|
// height: object.height,
|
||||||
|
// fill: '#f00',
|
||||||
|
// strokeWidth: 0,
|
||||||
|
// })
|
||||||
const currentTool = this.toolManager.currentTool.value
|
const currentTool = this.toolManager.currentTool.value
|
||||||
if (currentTool === OperationType.AISELECT_ADD) {
|
if (currentTool === OperationType.AISELECT_ADD) {
|
||||||
this.handleDrawImage(rect)
|
await this.handleDrawImage(image)
|
||||||
} else if (currentTool === OperationType.AISELECT_REMOVE) {
|
} else if (currentTool === OperationType.AISELECT_REMOVE) {
|
||||||
this.handleRemoveImage(rect)
|
await this.handleRemoveImage(image)
|
||||||
}
|
}
|
||||||
|
useGlobalStore().setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -218,6 +251,7 @@ export class AISelectboxToolManager {
|
|||||||
absolutePositioned: true,
|
absolutePositioned: true,
|
||||||
};
|
};
|
||||||
async createSelectbox() {
|
async createSelectbox() {
|
||||||
|
if (!this.targetObject) return;
|
||||||
if (!this.demoObject) return
|
if (!this.demoObject) return
|
||||||
const fobject = this.demoObject
|
const fobject = this.demoObject
|
||||||
this.clearDemoObject()
|
this.clearDemoObject()
|
||||||
@@ -263,7 +297,26 @@ export class AISelectboxToolManager {
|
|||||||
this.toolManager.setTool(OperationType.SELECT)
|
this.toolManager.setTool(OperationType.SELECT)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取分隔后图片 */
|
||||||
|
async getSegAnythingImage(obj) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!this.targetObject) return;
|
||||||
|
const user_id = useUserInfoStore().state.userInfo.id;
|
||||||
|
const image_path = this.targetObject.src;
|
||||||
|
const data = {
|
||||||
|
image_path,
|
||||||
|
user_id,
|
||||||
|
...obj,
|
||||||
|
}
|
||||||
|
getSegAnythingImage(data).then((res) => {
|
||||||
|
console.log(res)
|
||||||
|
resolve(res)
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
useGlobalStore().setLoading(false)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
this.clear()
|
this.clear()
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ export class CanvasManager {
|
|||||||
id: createId("image"),
|
id: createId("image"),
|
||||||
name: "图片图层",
|
name: "图片图层",
|
||||||
lock: true,
|
lock: true,
|
||||||
|
isOriginal: true,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
image = img
|
image = img
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ export class LayerManager {
|
|||||||
this.stateManager.toolManager.setTool(OperationType.SELECT)
|
this.stateManager.toolManager.setTool(OperationType.SELECT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setActiveFirstLayer() {
|
||||||
|
this.setActiveID(this.layers.value[0]?.info?.id || "")
|
||||||
|
}
|
||||||
|
|
||||||
getActiveLayer() {
|
getActiveLayer() {
|
||||||
return this.getLayerById(this.activeID.value)
|
return this.getLayerById(this.activeID.value)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ref, computed } from "vue";
|
import { ref, computed } from "vue";
|
||||||
import { ElMessageBox } from 'element-plus'
|
import { OperationType } from '../tools/layerHelper'
|
||||||
import i18n from '@/lang'
|
import i18n from '@/lang'
|
||||||
const t = i18n.global.t
|
const t = i18n.global.t
|
||||||
|
|
||||||
@@ -95,6 +95,7 @@ export class StateManager {
|
|||||||
this.running.value = true
|
this.running.value = true
|
||||||
this.historyIndex.value = index
|
this.historyIndex.value = index
|
||||||
this.canvasManager.loadJSON(state.canvas, false).then(() => {
|
this.canvasManager.loadJSON(state.canvas, false).then(() => {
|
||||||
|
this.toolManager.setTool(OperationType.SELECT)
|
||||||
this.event.emit('canvas:undo', state)
|
this.event.emit('canvas:undo', state)
|
||||||
this.running.value = false
|
this.running.value = false
|
||||||
})
|
})
|
||||||
@@ -108,6 +109,7 @@ export class StateManager {
|
|||||||
this.running.value = true
|
this.running.value = true
|
||||||
this.historyIndex.value = index
|
this.historyIndex.value = index
|
||||||
this.canvasManager.loadJSON(state.canvas, false).then(() => {
|
this.canvasManager.loadJSON(state.canvas, false).then(() => {
|
||||||
|
this.toolManager.setTool(OperationType.SELECT)
|
||||||
this.event.emit('canvas:redo', state)
|
this.event.emit('canvas:redo', state)
|
||||||
this.running.value = false
|
this.running.value = false
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const url =
|
const url =
|
||||||
'https://www.minio-api.aida.com.hk/fida-test/furniture/sketches/1a48ed3a-1faa-4fcd-bf07-765dba1702c5.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=admin%2F20260320%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260320T020948Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=7dc192bac887bce7b02c99d7037c08d9d684310f00add9b0e63b74b36ee63d37'
|
'https://minio-api.aida.com.hk/fida-public-bucket/furniture/sketches/e3082a38-55d2-4313-ad53-55aad715cf67.png'
|
||||||
const openCanvas = () => {
|
const openCanvas = () => {
|
||||||
myEvent.emit('openFlowCanvas', { url })
|
myEvent.emit('openFlowCanvas', { url })
|
||||||
}
|
}
|
||||||
const openDepthCanvas = () => {
|
const openDepthCanvas = () => {
|
||||||
myEvent.emit('openDepthCanvas', { url, canvasId: '69c34539ce996b52f07e625f' })
|
myEvent.emit('openDepthCanvas', { url, canvasId: '' })
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (route.query.depth) {
|
if (route.query.depth) {
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
data.vibe = JSON.parse(data.vibe)
|
||||||
onSubmit(data)
|
onSubmit(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
<p class="title" v-html="$t('Nuic.nuic2Title')"></p>
|
<p class="title" v-html="$t('Nuic.nuic2Title')"></p>
|
||||||
<div class="list">
|
<div class="list">
|
||||||
<div v-for="v in list" :key="v.id" @click="v.active = !v.active">
|
<div v-for="v in list" :key="v.id" @click="v.active = !v.active">
|
||||||
<img :src="v.url" draggable="false" />
|
<img :src="v.imageUrl" draggable="false" />
|
||||||
<div class="active" v-show="v.active">
|
<div class="active" v-show="v.active">
|
||||||
<span>{{ v.title }}</span>
|
<span>{{ v.styleName }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -22,28 +22,35 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
|
import { GetUserStyleImages } from '@/api/user'
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const emit = defineEmits(['next'])
|
const emit = defineEmits(['next'])
|
||||||
const list = ref([
|
const list = ref([])
|
||||||
{ id: 1, url: '/image/nuic/style-1.png', title: '凳子', active: false },
|
const pageSize = ref(8)
|
||||||
{ id: 2, url: '/image/nuic/style-2.png', title: '沙发', active: false },
|
const pageNum = ref(1)
|
||||||
{ id: 3, url: '/image/nuic/style-3.png', title: '凳子', active: false },
|
const totalPages = ref(1)
|
||||||
{ id: 4, url: '/image/nuic/style-4.png', title: '桌子', active: false },
|
|
||||||
{ id: 5, url: '/image/nuic/style-5.png', title: '桌子', active: false },
|
|
||||||
{ id: 6, url: '/image/nuic/style-6.png', title: '桌子', active: false },
|
|
||||||
{ id: 7, url: '/image/nuic/style-7.png', title: '沙发', active: false },
|
|
||||||
{ id: 8, url: '/image/nuic/style-8.png', title: '桌子', active: false }
|
|
||||||
])
|
|
||||||
const onNext = () => {
|
const onNext = () => {
|
||||||
const data = {
|
const data = {
|
||||||
vibe: list.value
|
vibe: JSON.stringify(list.value.filter((v) => v.active).map((v) => v.id))
|
||||||
.filter((v) => v.active)
|
|
||||||
.map((v) => v.id)
|
|
||||||
.join(',')
|
|
||||||
}
|
}
|
||||||
emit('next', data)
|
emit('next', data)
|
||||||
}
|
}
|
||||||
const onLoadMore = () => {}
|
const onLoadMore = () => {
|
||||||
|
GetUserStyleImages({
|
||||||
|
pageNum: pageNum.value,
|
||||||
|
pageSize: pageSize.value
|
||||||
|
}).then((res) => {
|
||||||
|
if (!res) return
|
||||||
|
list.value = res.images.map((v) => ({
|
||||||
|
...v,
|
||||||
|
active: false
|
||||||
|
}))
|
||||||
|
totalPages.value = res.totalPages
|
||||||
|
pageNum.value++
|
||||||
|
if (pageNum.value > totalPages.value) pageNum.value = 1
|
||||||
|
})
|
||||||
|
}
|
||||||
|
onLoadMore()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user