next-element-vue 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +2 -2
- package/dist/index.js +165 -74
- package/dist/index.min.js +3 -3
- package/dist/index.umd.js +165 -74
- package/dist/index.umd.min.js +3 -3
- package/dist/packages/components/labelimg/src/hooks/canvas-context-hook.d.ts +47 -2
- package/dist/packages/components/labelimg/src/widgets/draggable-rect.d.ts +2 -0
- package/dist/packages/components/labelme/src/hooks/canvas-content.d.ts +4 -0
- package/dist/packages/hooks/use-locale/index.d.ts +1 -0
- package/dist/packages/locale/lang/en.d.ts +1 -0
- package/dist/packages/locale/lang/zh-cn.d.ts +1 -0
- package/dist/packages/locale/lang/zh-tw.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 作 者:huangteng
|
|
4
4
|
* 邮 箱:htengweb@163.com
|
|
5
|
-
* 当前版本:0.3.
|
|
6
|
-
* 发布日期:2024-
|
|
5
|
+
* 当前版本:0.3.6 v
|
|
6
|
+
* 发布日期:2024-09-15
|
|
7
7
|
* 地 址:https://www.npmjs.com/package/next-element-vue
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -797,7 +797,8 @@
|
|
|
797
797
|
confirmDeleteLabel: "确定要删除该标注吗?",
|
|
798
798
|
saveLabel: "保存当前标注",
|
|
799
799
|
instructions: "使用说明",
|
|
800
|
-
labelNoUpdate: "暂无标签数据更新"
|
|
800
|
+
labelNoUpdate: "暂无标签数据更新",
|
|
801
|
+
zoomRestore: "还原"
|
|
801
802
|
},
|
|
802
803
|
labelme: {
|
|
803
804
|
saveLabel: "保存",
|
|
@@ -881,7 +882,8 @@
|
|
|
881
882
|
confirmDeleteLabel: "Are you sure you want to delete this annotation?",
|
|
882
883
|
saveLabel: "save label",
|
|
883
884
|
instructions: "instructions",
|
|
884
|
-
labelNoUpdate: "No label data update"
|
|
885
|
+
labelNoUpdate: "No label data update",
|
|
886
|
+
zoomRestore: "restore zoom"
|
|
885
887
|
},
|
|
886
888
|
labelme: {
|
|
887
889
|
saveLabel: "saving...",
|
|
@@ -965,7 +967,8 @@
|
|
|
965
967
|
confirmDeleteLabel: "确定要删除该标注吗?",
|
|
966
968
|
saveLabel: "保存当前标注",
|
|
967
969
|
instructions: "使用说明",
|
|
968
|
-
labelNoUpdate: "暂无标签数据更新"
|
|
970
|
+
labelNoUpdate: "暂无标签数据更新",
|
|
971
|
+
zoomRestore: "还原"
|
|
969
972
|
},
|
|
970
973
|
labelme: {
|
|
971
974
|
saveLabel: "保存"
|
|
@@ -3367,7 +3370,7 @@
|
|
|
3367
3370
|
}
|
|
3368
3371
|
if ("select" === col.type) {
|
|
3369
3372
|
const placeholder = t("next.form.select") + (col.searchPlaceholder || col.searchLabel || col.label);
|
|
3370
|
-
return vue.createVNode(elementPlus.ElSelect, {
|
|
3373
|
+
return !formParams[col.prop] && col.multiple && (formParams[col.prop] = []), vue.createVNode(elementPlus.ElSelect, {
|
|
3371
3374
|
modelValue: formParams[col.prop],
|
|
3372
3375
|
"onUpdate:modelValue": $event => formParams[col.prop] = $event,
|
|
3373
3376
|
clearable: !0,
|
|
@@ -5779,7 +5782,7 @@
|
|
|
5779
5782
|
emits: [ "fullscreen", "save" ],
|
|
5780
5783
|
setup(props, {emit: emit}) {
|
|
5781
5784
|
const _ns = vue.inject("ns", {}), {t: t} = useLocale(), switchFillscreen = val => {
|
|
5782
|
-
emit("fullscreen", val);
|
|
5785
|
+
emit("fullscreen", val), document.body.style.overflow = val ? "hidden" : "auto";
|
|
5783
5786
|
};
|
|
5784
5787
|
return () => vue.createVNode(vue.Fragment, null, [ vue.createVNode(vue.Fragment, null, [ vue.createVNode("ul", {
|
|
5785
5788
|
class: [ _ns.be("header", "tool") ]
|
|
@@ -6158,7 +6161,7 @@
|
|
|
6158
6161
|
},
|
|
6159
6162
|
emits: [ "change" ],
|
|
6160
6163
|
setup(props, {emit: emit, expose: expose}) {
|
|
6161
|
-
const ns = vue.inject("ns", {}), _emit = vue.inject("_emit", null), canvasMainRef = vue.ref(), canvasBaseRef = vue.ref(), canvasRectRef = vue.ref(), labels = vue.ref([]), drawBaseCanvas = vue.ref({}), formatLabelsType = () => {
|
|
6164
|
+
const ns = vue.inject("ns", {}), _emit = vue.inject("_emit", null), mainBasaeRef = vue.ref(), canvasMainRef = vue.ref(), canvasBaseRef = vue.ref(), canvasRectRef = vue.ref(), labels = vue.ref([]), drawBaseCanvas = vue.ref({}), formatLabelsType = () => {
|
|
6162
6165
|
const _labels = deepClone(labels.value);
|
|
6163
6166
|
let yolo_label = [];
|
|
6164
6167
|
return {
|
|
@@ -6176,22 +6179,39 @@
|
|
|
6176
6179
|
canvasRectRef.value.width = canvasWidth, canvasRectRef.value.height = canvasHeight,
|
|
6177
6180
|
canvasRectRef.value.style.width = canvasWidth + "px", canvasRectRef.value.style.height = canvasHeight + "px";
|
|
6178
6181
|
}, loadingImage = vue.ref(!1), renderImageLabel = rowInfo => {
|
|
6179
|
-
|
|
6180
|
-
const typeName = props.classes[rect.type];
|
|
6181
|
-
return typeName && (rect.typeName = typeName), rect;
|
|
6182
|
-
})) : [])(rowInfo);
|
|
6183
|
-
const clientHeight = canvasMainRef.value?.clientHeight, ctx = canvasBaseRef.value?.getContext("2d");
|
|
6182
|
+
const ctx = canvasBaseRef.value?.getContext("2d");
|
|
6184
6183
|
if (rowInfo?.imageSrc) {
|
|
6185
6184
|
const image = new Image;
|
|
6186
6185
|
image.src = rowInfo.imageSrc, loadingImage.value = !0, image.onload = () => {
|
|
6187
6186
|
loadingImage.value = !1;
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6187
|
+
const {canvasWidth: canvasWidth, canvasHeight: canvasHeight, scaleFactor: scaleFactor, originWidth: originWidth, originHeight: originHeight} = (image => {
|
|
6188
|
+
const clientWidth = mainBasaeRef.value?.elementInstance.clientWidth, clientHeight = mainBasaeRef.value?.elementInstance.clientHeight;
|
|
6189
|
+
let {width: width, height: height} = image, scaleFactor = 1;
|
|
6190
|
+
const scale = width / height;
|
|
6191
|
+
if (scale > 1 ? (width = clientWidth, height = clientWidth / scale) : (width = clientHeight * scale,
|
|
6192
|
+
height = clientHeight), height > clientHeight) {
|
|
6193
|
+
const scale = height / clientHeight;
|
|
6194
|
+
height = clientHeight, width /= scale;
|
|
6195
|
+
} else if (width > clientWidth) {
|
|
6196
|
+
const scale = width / clientWidth;
|
|
6197
|
+
width = clientWidth, height /= scale;
|
|
6198
|
+
}
|
|
6199
|
+
const canvasWidth = parseInt(width.toString()), canvasHeight = parseInt(height.toString());
|
|
6200
|
+
return scaleFactor = Number((canvasWidth / canvasHeight).toFixed(2)), {
|
|
6201
|
+
canvasWidth: canvasWidth,
|
|
6202
|
+
canvasHeight: canvasHeight,
|
|
6203
|
+
scaleFactor: scaleFactor,
|
|
6204
|
+
originWidth: image.width,
|
|
6205
|
+
originHeight: image.height
|
|
6206
|
+
};
|
|
6207
|
+
})(image);
|
|
6208
|
+
labels.value = ((rowInfo, originWidth, originHeight) => rowInfo.labels ? rowInfo.labels.map((rect => {
|
|
6209
|
+
const typeName = props.classes[rect.type];
|
|
6210
|
+
return typeName && (rect.typeName = typeName), rect.originWidth || (rect.originWidth = originWidth),
|
|
6211
|
+
rect.originHeight || (rect.originHeight = originHeight), rect;
|
|
6212
|
+
})) : [])(rowInfo, originWidth, originHeight), image.style.width = canvasWidth + "px",
|
|
6213
|
+
image.style.height = canvasHeight + "px", setContainerWidthHeight(canvasWidth, canvasHeight),
|
|
6214
|
+
labels.value = ((labels, canvasHeight) => {
|
|
6195
6215
|
let scale_rects = [];
|
|
6196
6216
|
for (let i = 0; i < labels.length; i++) {
|
|
6197
6217
|
const rect = labels[i], scale = parseFloat((canvasHeight / rect.canvasHeight).toFixed(3));
|
|
@@ -6203,8 +6223,10 @@
|
|
|
6203
6223
|
return scale_rects;
|
|
6204
6224
|
})(labels.value, canvasHeight);
|
|
6205
6225
|
const {updateLabels: updateLabels, addDrawRect: addDrawRect, hitCanvasLabel: hitCanvasLabel} = (options => {
|
|
6206
|
-
const {ctx: ctx, labels: labels, image: image, canvasWidth: canvasWidth, canvasHeight: canvasHeight} = options, updateLabels =
|
|
6207
|
-
|
|
6226
|
+
const {canvas: canvas, ctx: ctx, labels: labels, image: image, canvasWidth: canvasWidth, canvasHeight: canvasHeight} = options, updateLabels = scaleOffset => {
|
|
6227
|
+
scaleOffset && (canvas.width = canvasWidth, ctx.save(), ctx.translate(scaleOffset.x, scaleOffset.y),
|
|
6228
|
+
ctx.scale(scaleOffset.scale, scaleOffset.scale)), ctx.clearRect(0, 0, canvasWidth, canvasHeight),
|
|
6229
|
+
ctx.drawImage(image, 0, 0, canvasWidth, canvasHeight);
|
|
6208
6230
|
for (let i = 0; i < labels.length; i++) {
|
|
6209
6231
|
const rect = labels[i], {startX: startX, startY: startY, rectWidth: rectWidth, rectHeight: rectHeight, type: type} = rect, color = colors$1[type % colors$1.length];
|
|
6210
6232
|
if (ctx.font = "bold 14px serif", ctx.textBaseline = "top", ctx.save(), ctx.strokeStyle = color,
|
|
@@ -6219,7 +6241,8 @@
|
|
|
6219
6241
|
updateLabels: updateLabels,
|
|
6220
6242
|
addDrawRect: (rect, color = "#f30635") => {
|
|
6221
6243
|
const {startX: startX, startY: startY, rectWidth: rectWidth, rectHeight: rectHeight} = rect;
|
|
6222
|
-
ctx.strokeStyle = color, ctx.strokeRect(startX, startY, rectWidth, rectHeight)
|
|
6244
|
+
ctx.save(), ctx.strokeStyle = color, ctx.strokeRect(startX, startY, rectWidth, rectHeight),
|
|
6245
|
+
ctx.restore();
|
|
6223
6246
|
},
|
|
6224
6247
|
hitCanvasLabel: (x, y) => {
|
|
6225
6248
|
let hit_rect = null, hit_index = null, color = null;
|
|
@@ -6246,7 +6269,7 @@
|
|
|
6246
6269
|
});
|
|
6247
6270
|
drawBaseCanvas.value.updateLabels = updateLabels, drawBaseCanvas.value.addDrawRect = addDrawRect,
|
|
6248
6271
|
drawBaseCanvas.value.hitCanvasLabel = hitCanvasLabel;
|
|
6249
|
-
const {clearCanvas: clearCanvas, removeEventAll: removeEventAll} = ((canvas, callback, keyW) => {
|
|
6272
|
+
const {clearCanvas: clearCanvas, removeEventAll: removeEventAll} = (({canvas: canvas, originWidth: originWidth, originHeight: originHeight}, callback, keyW) => {
|
|
6250
6273
|
const canvasWidth = canvas.width, canvasHeight = canvas.height, ctx = canvas?.getContext("2d"), clearCanvas = () => {
|
|
6251
6274
|
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
|
|
6252
6275
|
};
|
|
@@ -6260,14 +6283,16 @@
|
|
|
6260
6283
|
rectWidth: rectWidth,
|
|
6261
6284
|
rectHeight: rectHeight,
|
|
6262
6285
|
canvasWidth: canvasWidth,
|
|
6263
|
-
canvasHeight: canvasHeight
|
|
6286
|
+
canvasHeight: canvasHeight,
|
|
6287
|
+
originWidth: originWidth,
|
|
6288
|
+
originHeight: originHeight
|
|
6264
6289
|
}, {
|
|
6265
6290
|
endX: endX,
|
|
6266
6291
|
endY: endY
|
|
6267
6292
|
});
|
|
6268
6293
|
}, documentKeydown = event => {
|
|
6269
|
-
"KeyW" === event.code && (isWKeyPressed = !0,
|
|
6270
|
-
canvas.style.zIndex = "11", keyW && keyW());
|
|
6294
|
+
isWKeyPressed || "KeyW" === event.code && (event.preventDefault(), isWKeyPressed = !0,
|
|
6295
|
+
canvas.style.cursor = "crosshair", canvas.style.zIndex = "11", keyW && keyW());
|
|
6271
6296
|
}, documentKeyup = event => {
|
|
6272
6297
|
isDrawing || "KeyW" === event.code && (isWKeyPressed = !1, canvas.style.cursor = "unset",
|
|
6273
6298
|
canvas.style.zIndex = "0");
|
|
@@ -6277,13 +6302,13 @@
|
|
|
6277
6302
|
};
|
|
6278
6303
|
document.addEventListener("keydown", documentKeydown), document.addEventListener("keyup", documentKeyup),
|
|
6279
6304
|
document.addEventListener("mouseup", documentMouseup);
|
|
6280
|
-
const canvasMousedown =
|
|
6281
|
-
isWKeyPressed && (isDrawing = !0, startX =
|
|
6282
|
-
}, canvasMousemove =
|
|
6283
|
-
isDrawing && isWKeyPressed && (isRectDraw = !0, endX =
|
|
6305
|
+
const canvasMousedown = event => {
|
|
6306
|
+
isWKeyPressed && (isDrawing = !0, startX = event.offsetX, startY = event.offsetY);
|
|
6307
|
+
}, canvasMousemove = event => {
|
|
6308
|
+
isDrawing && isWKeyPressed && (isRectDraw = !0, endX = event.offsetX, endY = event.offsetY,
|
|
6284
6309
|
drawRect());
|
|
6285
|
-
}, canvasMouseup =
|
|
6286
|
-
|
|
6310
|
+
}, canvasMouseup = event => {
|
|
6311
|
+
event.stopPropagation(), isRectDraw && (isDrawing = !1, isWKeyPressed = !1, canvas.style.cursor = "unset",
|
|
6287
6312
|
canvas.style.zIndex = "0", drawRectDone(), isRectDraw = !1);
|
|
6288
6313
|
};
|
|
6289
6314
|
canvas.addEventListener("mousedown", canvasMousedown), canvas.addEventListener("mousemove", canvasMousemove),
|
|
@@ -6297,12 +6322,16 @@
|
|
|
6297
6322
|
clearCanvas: clearCanvas,
|
|
6298
6323
|
drawRect: drawRect,
|
|
6299
6324
|
removeEventAll: () => {
|
|
6300
|
-
document.removeEventListener("
|
|
6325
|
+
document.removeEventListener("keydown", documentKeydown), document.removeEventListener("keyup", documentKeyup),
|
|
6301
6326
|
document.removeEventListener("mouseup", documentMouseup), canvas.removeEventListener("mousedown", canvasMousedown),
|
|
6302
6327
|
canvas.removeEventListener("mousemove", canvasMousemove), canvas.removeEventListener("mouseup", canvasMouseup);
|
|
6303
6328
|
}
|
|
6304
6329
|
};
|
|
6305
|
-
})(
|
|
6330
|
+
})({
|
|
6331
|
+
canvas: canvasRectRef.value,
|
|
6332
|
+
originWidth: originWidth,
|
|
6333
|
+
originHeight: originHeight
|
|
6334
|
+
}, ((rect, {endX: endX, endY: endY}) => {
|
|
6306
6335
|
activate_add_label.value = rect, drawBaseCanvas.value.addDrawRect(rect), updateContextmenuLabelFixed(endX, endY, rect);
|
|
6307
6336
|
}), (() => {
|
|
6308
6337
|
onCloseDraggableRectFixed();
|
|
@@ -6319,11 +6348,14 @@
|
|
|
6319
6348
|
updateContextmenuLabelFixed(x, y, hit_rect);
|
|
6320
6349
|
}));
|
|
6321
6350
|
})), canvasBaseRef.value.addEventListener("click", (e => {
|
|
6351
|
+
if (e.ctrlKey) return;
|
|
6322
6352
|
const x = e.offsetX, y = e.offsetY, {hit_rect: hit_rect, hit_index: hit_index, color: color} = drawBaseCanvas.value.hitCanvasLabel(x, y);
|
|
6323
6353
|
onCloseDraggableRectFixed(), onCloseContentmenuLabel(), hit_rect && vue.nextTick((() => {
|
|
6324
6354
|
updateDraggableRectFixed(x, y, hit_rect, hit_index, color);
|
|
6325
6355
|
}));
|
|
6326
6356
|
}));
|
|
6357
|
+
}, onWindowWheel = e => {
|
|
6358
|
+
e.ctrlKey && e.preventDefault();
|
|
6327
6359
|
};
|
|
6328
6360
|
vue.onMounted((() => {
|
|
6329
6361
|
vue.watch((() => props.rowInfo), (info => {
|
|
@@ -6332,15 +6364,20 @@
|
|
|
6332
6364
|
}), {
|
|
6333
6365
|
deep: !0,
|
|
6334
6366
|
immediate: !0
|
|
6335
|
-
}), vue.watch((() => props.
|
|
6367
|
+
}), vue.watch((() => props.classes), (() => {
|
|
6368
|
+
const rowInfo = vue.toRaw(props.rowInfo);
|
|
6369
|
+
renderImageLabel(rowInfo);
|
|
6370
|
+
})), vue.watch((() => props.contextClientHeight), (height => {
|
|
6336
6371
|
if (valueExist(height)) {
|
|
6337
6372
|
canvasMainRef.value.style.height = height + "px";
|
|
6338
6373
|
const rowInfo = vue.toRaw(props.rowInfo);
|
|
6339
6374
|
renderImageLabel(rowInfo);
|
|
6340
6375
|
}
|
|
6341
|
-
}))
|
|
6376
|
+
})), window.addEventListener("wheel", onWindowWheel, {
|
|
6377
|
+
passive: !1
|
|
6378
|
+
});
|
|
6342
6379
|
})), vue.onUnmounted((() => {
|
|
6343
|
-
drawBaseCanvas.value.removeEventAll();
|
|
6380
|
+
drawBaseCanvas.value.removeEventAll?.(), window.removeEventListener("wheel", onWindowWheel);
|
|
6344
6381
|
}));
|
|
6345
6382
|
const contextmenuLabelFixed = vue.ref({
|
|
6346
6383
|
show: !1,
|
|
@@ -6384,9 +6421,9 @@
|
|
|
6384
6421
|
draggableRectFixed.value.width = 0, draggableRectFixed.value.height = 0, draggableRectFixed.value.activateRect = null,
|
|
6385
6422
|
draggableRectFixed.value.activateIndex = null, draggableRectFixed.value.color = null;
|
|
6386
6423
|
}, onDraggleRectResize = rect => {
|
|
6387
|
-
draggableRectFixed.value.activateRect = rect
|
|
6424
|
+
draggableRectFixed.value.activateRect = rect;
|
|
6388
6425
|
const i = labels.value.findIndex((o => isEqual(o, rect)));
|
|
6389
|
-
i > -1 && labels.value.splice(i, 1, rect);
|
|
6426
|
+
i > -1 && labels.value.splice(i, 1, rect), drawBaseCanvas.value.updateLabels();
|
|
6390
6427
|
const {rects: rects, label_txt: label_txt} = formatLabelsType();
|
|
6391
6428
|
_emit("change", rects, label_txt), emit("change", rects, label_txt);
|
|
6392
6429
|
}, onContextmenuDraggable = (e, rect) => {
|
|
@@ -6430,6 +6467,7 @@
|
|
|
6430
6467
|
}
|
|
6431
6468
|
});
|
|
6432
6469
|
return () => vue.createVNode(vue.Fragment, null, [ vue.createVNode(NextSpinLoading, {
|
|
6470
|
+
ref: mainBasaeRef,
|
|
6433
6471
|
loading: loadingImage.value,
|
|
6434
6472
|
class: [ ns.b("loading") ]
|
|
6435
6473
|
}, {
|
|
@@ -6474,13 +6512,15 @@
|
|
|
6474
6512
|
},
|
|
6475
6513
|
emits: [ "delete", "select" ],
|
|
6476
6514
|
setup(props, {emit: emit}) {
|
|
6477
|
-
const {t: t} = useLocale(), ns = vue.inject("ns", {}), labels = vue.ref([])
|
|
6478
|
-
|
|
6515
|
+
const {t: t} = useLocale(), ns = vue.inject("ns", {}), labels = vue.ref([]), formatLabelsTypeName = labels => labels.length ? labels.map((rect => {
|
|
6516
|
+
const typeName = props.classes[rect.type];
|
|
6517
|
+
return typeName && (rect.typeName = typeName), rect;
|
|
6518
|
+
})) : [];
|
|
6519
|
+
vue.watch((() => props.classes), (() => {
|
|
6520
|
+
labels.value = formatLabelsTypeName(labels.value);
|
|
6521
|
+
})), vue.watch((() => props.labels), (rects => {
|
|
6479
6522
|
const _rects = vue.toRaw(rects);
|
|
6480
|
-
labels.value = (
|
|
6481
|
-
const typeName = props.classes[rect.type];
|
|
6482
|
-
return typeName && (rect.typeName = typeName), rect;
|
|
6483
|
-
})) : [])(_rects);
|
|
6523
|
+
labels.value = formatLabelsTypeName(_rects);
|
|
6484
6524
|
}), {
|
|
6485
6525
|
deep: !0,
|
|
6486
6526
|
immediate: !0
|
|
@@ -6860,8 +6900,17 @@
|
|
|
6860
6900
|
this.destroyedObservers = callback;
|
|
6861
6901
|
}
|
|
6862
6902
|
canvasMouseClick(e) {
|
|
6863
|
-
e.stopPropagation(), this.isDrawing = !0, this.mouseOffset.x = e.offsetX, this.mouseOffset.y = e.offsetY
|
|
6864
|
-
|
|
6903
|
+
e.stopPropagation(), this.isDrawing = !0, this.mouseOffset.x = e.offsetX, this.mouseOffset.y = e.offsetY;
|
|
6904
|
+
const [x, y] = [ e.offsetX, e.offsetY ];
|
|
6905
|
+
let is_add = !0;
|
|
6906
|
+
for (let i = 0; i < this.vertexes.length; i++) {
|
|
6907
|
+
const p = this.vertexes[i];
|
|
6908
|
+
if (Math.sqrt((x - p[0]) ** 2 + (y - p[1]) ** 2) < 8) {
|
|
6909
|
+
is_add = !1;
|
|
6910
|
+
break;
|
|
6911
|
+
}
|
|
6912
|
+
}
|
|
6913
|
+
is_add && this.vertexes.push([ x, y ]), this.vertexes = vertexesUnique(this.vertexes);
|
|
6865
6914
|
}
|
|
6866
6915
|
canvasMousemove(e) {
|
|
6867
6916
|
e.stopPropagation(), this.isDrawing && (this.mouseOffset.x = e.offsetX, this.mouseOffset.y = e.offsetY,
|
|
@@ -6889,11 +6938,12 @@
|
|
|
6889
6938
|
pointCentreIndex;
|
|
6890
6939
|
vertexRadius;
|
|
6891
6940
|
edgeCentreRadius;
|
|
6941
|
+
pointRecover;
|
|
6892
6942
|
observers=[];
|
|
6893
6943
|
constructor(canvas, ctx) {
|
|
6894
6944
|
this.canvas = canvas, this.ctx = ctx, this.vertexes = [], this.isEditing = !1, this.canClickEvent = !0,
|
|
6895
6945
|
this.isMoveEditing = !1, this.pointVertexIndex = -1, this.pointCentreIndex = -1,
|
|
6896
|
-
this.vertexRadius = 8, this.edgeCentreRadius = 5;
|
|
6946
|
+
this.vertexRadius = 8, this.edgeCentreRadius = 5, this.pointRecover = [];
|
|
6897
6947
|
}
|
|
6898
6948
|
drawPolygonPath(vertexes, mouseX, mouseY) {
|
|
6899
6949
|
const ctx = this.ctx;
|
|
@@ -6974,7 +7024,9 @@
|
|
|
6974
7024
|
}
|
|
6975
7025
|
canvasMousedown(e) {
|
|
6976
7026
|
e.stopPropagation(), e.preventDefault(), this.canClickEvent = !0;
|
|
6977
|
-
const {offsetX: x, offsetY: y} = e
|
|
7027
|
+
const {offsetX: x, offsetY: y} = e;
|
|
7028
|
+
this.pointRecover = [ x, y ];
|
|
7029
|
+
const vertex_i = this.pointInVertexes(x, y);
|
|
6978
7030
|
isValueExist(vertex_i) && (this.isMoveEditing = !0, this.pointVertexIndex = vertex_i,
|
|
6979
7031
|
this.vertexes.splice(this.pointVertexIndex, 1, [ x, y ]));
|
|
6980
7032
|
const i = this.pointInEdgeCentre(x, y);
|
|
@@ -6985,11 +7037,19 @@
|
|
|
6985
7037
|
}
|
|
6986
7038
|
canvasMouseup(e) {
|
|
6987
7039
|
e.stopPropagation(), e.preventDefault();
|
|
6988
|
-
|
|
7040
|
+
let {offsetX: x, offsetY: y} = e;
|
|
7041
|
+
this.vertexes = vertexesUnique(this.vertexes);
|
|
7042
|
+
for (let i = 0; i < this.vertexes.length; i++) {
|
|
7043
|
+
const p = this.vertexes[i], radius = Math.sqrt((x - p[0]) ** 2 + (y - p[1]) ** 2);
|
|
7044
|
+
if (radius < 8 && radius > 0 && this.pointRecover.length) {
|
|
7045
|
+
x = this.pointRecover[0], y = this.pointRecover[1], this.pointRecover = [];
|
|
7046
|
+
break;
|
|
7047
|
+
}
|
|
7048
|
+
}
|
|
6989
7049
|
this.pointVertexIndex > -1 && this.vertexes.splice(this.pointVertexIndex, 1, [ x, y ]),
|
|
6990
7050
|
this.pointCentreIndex > -1 && this.vertexes.splice(this.pointCentreIndex, 1, [ x, y ]),
|
|
6991
7051
|
this.isMoveEditing = !1, this.pointVertexIndex = -1, this.pointCentreIndex = -1,
|
|
6992
|
-
this.notifyObservers();
|
|
7052
|
+
this.drawPolygon(this.vertexes), this.notifyObservers();
|
|
6993
7053
|
}
|
|
6994
7054
|
canvasMouseClick(e) {
|
|
6995
7055
|
e.stopPropagation();
|
|
@@ -7022,15 +7082,17 @@
|
|
|
7022
7082
|
canvasWidth;
|
|
7023
7083
|
canvasHeight;
|
|
7024
7084
|
paths;
|
|
7085
|
+
scaleX;
|
|
7086
|
+
scaleY;
|
|
7025
7087
|
editDrawPolygon;
|
|
7026
7088
|
createPolygonVertexes;
|
|
7027
7089
|
editVertexes;
|
|
7028
7090
|
editPolygonObservers=[];
|
|
7029
7091
|
constructor(options) {
|
|
7030
|
-
const {canvas: canvas, ctx: ctx, image: image, canvasWidth: canvasWidth, canvasHeight: canvasHeight, paths: paths} = options;
|
|
7092
|
+
const {canvas: canvas, ctx: ctx, image: image, canvasWidth: canvasWidth, canvasHeight: canvasHeight, paths: paths, scaleX: scaleX, scaleY: scaleY} = options;
|
|
7031
7093
|
this.canvas = canvas, this.ctx = ctx, this.image = image, this.canvasWidth = canvasWidth,
|
|
7032
|
-
this.canvasHeight = canvasHeight, this.paths = paths || [], this.
|
|
7033
|
-
this.render(), this.createPolygonVertexes = new CreatePolygonVertexes(canvas, ctx),
|
|
7094
|
+
this.canvasHeight = canvasHeight, this.paths = paths || [], this.scaleX = scaleX || 1,
|
|
7095
|
+
this.scaleY = scaleY || 1, this.editVertexes = [], this.render(), this.createPolygonVertexes = new CreatePolygonVertexes(canvas, ctx),
|
|
7034
7096
|
this.editDrawPolygon = new EditPolygonPath(canvas, ctx), this.createPolygonVertexes.vertexesChangeEventListener(((vertexes, mouseOffset) => {
|
|
7035
7097
|
this.render(), this.editDrawPolygon.drawPolygon(vertexes, mouseOffset), this.editVertexes = vertexes,
|
|
7036
7098
|
this.notifyObservers();
|
|
@@ -7051,12 +7113,14 @@
|
|
|
7051
7113
|
}
|
|
7052
7114
|
drawPolygons(paths) {
|
|
7053
7115
|
const ctx = this.ctx;
|
|
7116
|
+
ctx.scale(this.scaleX, this.scaleY);
|
|
7054
7117
|
for (let i = 0; i < paths.length; i++) {
|
|
7055
7118
|
const path = paths[i].path;
|
|
7056
7119
|
if (!path.length) return;
|
|
7057
7120
|
const color = colors[i % colors.length];
|
|
7058
|
-
ctx.beginPath(), ctx.lineWidth = 2, ctx.strokeStyle = color, ctx.fillStyle = hexToRgba(color, .2)
|
|
7059
|
-
|
|
7121
|
+
ctx.beginPath(), ctx.lineWidth = 2, ctx.strokeStyle = color, ctx.fillStyle = hexToRgba(color, .2);
|
|
7122
|
+
const startX = path[0][0], startY = path[0][1];
|
|
7123
|
+
ctx.moveTo(startX, startY);
|
|
7060
7124
|
for (let i = 1; i < path.length; i++) {
|
|
7061
7125
|
const [x, y] = path[i];
|
|
7062
7126
|
ctx.lineTo(x, y);
|
|
@@ -7066,7 +7130,7 @@
|
|
|
7066
7130
|
}
|
|
7067
7131
|
initCanvas=() => {
|
|
7068
7132
|
this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight), this.ctx.drawImage(this.image, 0, 0, this.canvasWidth, this.canvasHeight),
|
|
7069
|
-
this.drawPolygons(this.paths);
|
|
7133
|
+
this.ctx.save(), this.drawPolygons(this.paths), this.ctx.restore();
|
|
7070
7134
|
};
|
|
7071
7135
|
render=() => {
|
|
7072
7136
|
this.initCanvas();
|
|
@@ -7092,22 +7156,40 @@
|
|
|
7092
7156
|
},
|
|
7093
7157
|
emits: [ "editPolygon" ],
|
|
7094
7158
|
setup(props, {emit: emit, expose: expose}) {
|
|
7095
|
-
const ns = vue.inject("ns", {}), canvasMainRef = vue.ref(), canvasBaseRef = vue.ref(), drawCanvas = vue.ref(), setContainerWidthHeight = (canvasWidth, canvasHeight) => {
|
|
7159
|
+
const ns = vue.inject("ns", {}), mainBasaeRef = vue.ref(), canvasMainRef = vue.ref(), canvasBaseRef = vue.ref(), drawCanvas = vue.ref(), setContainerWidthHeight = (canvasWidth, canvasHeight) => {
|
|
7096
7160
|
canvasMainRef.value.style.width = canvasWidth + "px", canvasMainRef.value.style.height = canvasHeight + "px",
|
|
7097
7161
|
canvasBaseRef.value.width = canvasWidth, canvasBaseRef.value.height = canvasHeight,
|
|
7098
7162
|
canvasBaseRef.value.style.width = canvasWidth + "px", canvasBaseRef.value.style.height = canvasHeight + "px";
|
|
7099
7163
|
}, loadingImage = vue.ref(!1), renderImageLabel = rowInfo => {
|
|
7100
|
-
const
|
|
7164
|
+
const ctx = canvasBaseRef.value?.getContext("2d");
|
|
7101
7165
|
if (rowInfo?.imageSrc) {
|
|
7102
7166
|
const image = new Image;
|
|
7103
7167
|
image.src = rowInfo.imageSrc, loadingImage.value = !0, image.onload = () => {
|
|
7104
7168
|
loadingImage.value = !1;
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7169
|
+
const {canvasWidth: canvasWidth, canvasHeight: canvasHeight, scaleFactor: scaleFactor, scaleX: scaleX, scaleY: scaleY} = (image => {
|
|
7170
|
+
const clientWidth = mainBasaeRef.value?.elementInstance.clientWidth, clientHeight = mainBasaeRef.value?.elementInstance.clientHeight;
|
|
7171
|
+
let {width: width, height: height} = image, scaleFactor = 1;
|
|
7172
|
+
const aspect_ratio = width / height;
|
|
7173
|
+
if (aspect_ratio > 1 ? (width = clientWidth, height = clientWidth / aspect_ratio) : (width = clientHeight * aspect_ratio,
|
|
7174
|
+
height = clientHeight), height > clientHeight) {
|
|
7175
|
+
const scale = height / clientHeight;
|
|
7176
|
+
height = clientHeight, width /= scale;
|
|
7177
|
+
} else if (width > clientWidth) {
|
|
7178
|
+
const scale = width / clientWidth;
|
|
7179
|
+
width = clientWidth, height /= scale;
|
|
7180
|
+
}
|
|
7181
|
+
const canvasWidth = parseInt(width.toString()), canvasHeight = parseInt(height.toString());
|
|
7182
|
+
scaleFactor = Number((canvasWidth / canvasHeight).toFixed(2));
|
|
7183
|
+
const scaleX = (canvasWidth / image.width).toFixed(8), scaleY = (canvasHeight / image.height).toFixed(8);
|
|
7184
|
+
return {
|
|
7185
|
+
canvasWidth: canvasWidth,
|
|
7186
|
+
canvasHeight: canvasHeight,
|
|
7187
|
+
scaleFactor: scaleFactor,
|
|
7188
|
+
scaleX: Number(scaleX),
|
|
7189
|
+
scaleY: Number(scaleY)
|
|
7190
|
+
};
|
|
7191
|
+
})(image);
|
|
7192
|
+
image.style.width = canvasWidth + "px", image.style.height = canvasHeight + "px",
|
|
7111
7193
|
setContainerWidthHeight(canvasWidth, canvasHeight), drawCanvas.value = new CreateDrawCanvas({
|
|
7112
7194
|
canvas: canvasBaseRef.value,
|
|
7113
7195
|
ctx: ctx,
|
|
@@ -7115,7 +7197,9 @@
|
|
|
7115
7197
|
canvasWidth: canvasWidth,
|
|
7116
7198
|
canvasHeight: canvasHeight,
|
|
7117
7199
|
scaleFactor: scaleFactor,
|
|
7118
|
-
paths: rowInfo.labels
|
|
7200
|
+
paths: rowInfo.labels,
|
|
7201
|
+
scaleX: scaleX,
|
|
7202
|
+
scaleY: scaleY
|
|
7119
7203
|
}), drawCanvas.value.updatePolygon((vertexes => {
|
|
7120
7204
|
emit("editPolygon", {
|
|
7121
7205
|
vertexes: vertexes,
|
|
@@ -7151,6 +7235,7 @@
|
|
|
7151
7235
|
}));
|
|
7152
7236
|
}
|
|
7153
7237
|
}), () => vue.createVNode(vue.Fragment, null, [ vue.createVNode(NextSpinLoading, {
|
|
7238
|
+
ref: mainBasaeRef,
|
|
7154
7239
|
loading: loadingImage.value,
|
|
7155
7240
|
class: [ ns.b("loading") ],
|
|
7156
7241
|
style: {
|
|
@@ -7184,7 +7269,7 @@
|
|
|
7184
7269
|
emits: [ "fullscreen", "save" ],
|
|
7185
7270
|
setup(props, {emit: emit}) {
|
|
7186
7271
|
const _ns = vue.inject("ns", {}), {t: t} = useLocale(), switchFillscreen = val => {
|
|
7187
|
-
emit("fullscreen", val);
|
|
7272
|
+
emit("fullscreen", val), document.body.style.overflow = val ? "hidden" : "auto";
|
|
7188
7273
|
};
|
|
7189
7274
|
return () => vue.createVNode(vue.Fragment, null, [ vue.createVNode(vue.Fragment, null, [ vue.createVNode("ul", {
|
|
7190
7275
|
class: [ _ns.be("header", "tool") ]
|
|
@@ -7404,20 +7489,25 @@
|
|
|
7404
7489
|
if (loading.value) return;
|
|
7405
7490
|
loading.value = !0;
|
|
7406
7491
|
const node = currentNode.value;
|
|
7407
|
-
emit("save", {
|
|
7492
|
+
return emit("save", {
|
|
7408
7493
|
node: node
|
|
7409
7494
|
}, (imageItem => {
|
|
7410
7495
|
labelImages.value[activateNodeIndex.value] = imageItem || node, activateNodeIndex.value = index,
|
|
7411
7496
|
loading.value = !1;
|
|
7412
7497
|
}), (() => {
|
|
7413
7498
|
loading.value = !1;
|
|
7414
|
-
}));
|
|
7499
|
+
})), !0;
|
|
7415
7500
|
}, isFullscreen = vue.ref(!1), onSwitchFillscreen = val => {
|
|
7416
7501
|
isFullscreen.value = val, updateMainContentHeight(), vue.nextTick((() => {
|
|
7417
7502
|
canvasContextRef.value.rerenderImage();
|
|
7418
7503
|
}));
|
|
7419
7504
|
}, onEditPlygonChange = plygon => {
|
|
7420
|
-
emit("edit-polygon", plygon);
|
|
7505
|
+
currentNode.value.labels = plygon, emit("edit-polygon", plygon);
|
|
7506
|
+
}, onToolHeaderSave = () => {
|
|
7507
|
+
onChangeActivateNode(activateNodeIndex.value) || elementPlus.ElMessage({
|
|
7508
|
+
type: "info",
|
|
7509
|
+
message: t("next.labelimg.labelNoUpdate")
|
|
7510
|
+
});
|
|
7421
7511
|
};
|
|
7422
7512
|
return () => vue.createVNode(vue.Fragment, null, [ vue.createVNode("div", {
|
|
7423
7513
|
ref: layoutLabelRef,
|
|
@@ -7438,7 +7528,8 @@
|
|
|
7438
7528
|
isFullscreen: isFullscreen.value,
|
|
7439
7529
|
imageIndex: activateNodeIndex.value,
|
|
7440
7530
|
imageLength: labelImages.value.length,
|
|
7441
|
-
onFullscreen: onSwitchFillscreen
|
|
7531
|
+
onFullscreen: onSwitchFillscreen,
|
|
7532
|
+
onSave: onToolHeaderSave
|
|
7442
7533
|
}, null) ]), vue.createVNode("div", {
|
|
7443
7534
|
ref: mainRef,
|
|
7444
7535
|
class: [ ns.b("main") ]
|
|
@@ -7556,7 +7647,7 @@
|
|
|
7556
7647
|
})(app);
|
|
7557
7648
|
};
|
|
7558
7649
|
var index = {
|
|
7559
|
-
version: "0.3.
|
|
7650
|
+
version: "0.3.6",
|
|
7560
7651
|
install: install
|
|
7561
7652
|
};
|
|
7562
7653
|
exports.NextContainer = NextContainer, exports.NextCrudTable = NextCrudTable, exports.NextCrudTableVirtualized = NextCrudTableVirtualized,
|
|
@@ -7603,7 +7694,7 @@
|
|
|
7603
7694
|
}), exports.useGetDerivedNamespace = useGetDerivedNamespace, exports.useLanguage = (locale, lang) => {
|
|
7604
7695
|
const localeRef = vue.isRef(locale) ? locale : vue.ref(locale), nextLang = localeLang[lang] || localeLang["zh-cn"];
|
|
7605
7696
|
localeRef.value.name = lang, localeRef.value.next = nextLang.next;
|
|
7606
|
-
}, exports.useLocale = useLocale, exports.useNamespace = useNamespace, exports.version = "0.3.
|
|
7697
|
+
}, exports.useLocale = useLocale, exports.useNamespace = useNamespace, exports.version = "0.3.6",
|
|
7607
7698
|
Object.defineProperty(exports, "__esModule", {
|
|
7608
7699
|
value: !0
|
|
7609
7700
|
});
|