@glodon-aiot/dataset-annotation 3.14.0-alpha.31 → 3.15.0-alpha.1
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/es/DatasetContext/index.mjs +3 -6
- package/dist/es/components/DetectionAnnotation/components/ImageDetail/index.mjs +91 -94
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/Drawable.mjs +28 -37
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +101 -145
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +195 -256
- package/dist/es/components/DetectionAnnotation/index.mjs +424 -456
- package/dist/es/components/Iconfont/index.mjs +2 -2
- package/dist/es/components/OcrAnnotation/MarkKVOCRModal/KVOCRLabelMaker/index.mjs +1 -1
- package/dist/es/components/OcrAnnotation/MarkOCRBoxModal/OCRBoxMaker/index.mjs +1 -1
- package/dist/es/components/OcrAnnotation/OcrModal/index.mjs +45 -43
- package/dist/es/components/PicZipImportModal/index.mjs +293 -308
- package/dist/es/components/PreLabelOCR/index.mjs +1 -1
- package/dist/es/constant.mjs +3 -3
- package/dist/es/featuresConfig.mjs +9 -13
- package/dist/es/index.mjs +7 -11
- package/dist/lib/index.js +3 -4
- package/dist/src/DatasetContext/index.d.ts +0 -2
- package/dist/src/components/DetectionAnnotation/components/ImageDetail/index.d.ts +0 -1
- package/dist/src/constant.d.ts +1 -1
- package/dist/src/featuresConfig.d.ts +0 -4
- package/dist/src/index.d.ts +0 -3
- package/package.json +2 -2
- package/dist/es/components/DetectionAnnotation/components/ImageModal/index.mjs +0 -129
- package/dist/es/components/DetectionAnnotation/components/ImageModal/style.less.mjs +0 -4
- package/dist/es/components/PicZipImportModal/config.mjs +0 -47
- package/dist/es/components/PicZipImportModal/pic_vlm_json_zip.svg.mjs +0 -4
- package/dist/es/components/PicZipImportModal/pic_vlm_zip.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/RegionItem.mjs +0 -170
- package/dist/es/components/VLMAnnotation/TextAnnotationPanel.mjs +0 -94
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.mjs +0 -116
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.mjs +0 -115
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.mjs +0 -42
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.mjs +0 -55
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.mjs +0 -51
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.mjs +0 -62
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +0 -377
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.mjs +0 -100
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.mjs +0 -106
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.mjs +0 -101
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.mjs +0 -103
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.mjs +0 -38
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.mjs +0 -173
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.mjs +0 -72
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +0 -116
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.mjs +0 -98
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.mjs +0 -156
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/ai.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/del.png.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/error.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/loading.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/icons/star.svg.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +0 -651
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.mjs +0 -33
- package/dist/es/components/VLMAnnotation/components/DragButton.mjs +0 -18
- package/dist/es/components/VLMAnnotation/components/FitToScreenButton.mjs +0 -16
- package/dist/es/components/VLMAnnotation/components/RectangleButton.mjs +0 -30
- package/dist/es/components/VLMAnnotation/components/Toolbar.mjs +0 -40
- package/dist/es/components/VLMAnnotation/components/ZoomControls.mjs +0 -44
- package/dist/es/components/VLMAnnotation/constants.mjs +0 -57
- package/dist/es/components/VLMAnnotation/index.mjs +0 -279
- package/dist/es/components/VLMAnnotation/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.mjs +0 -343
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.mjs +0 -240
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.mjs +0 -201
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/index.mjs +0 -455
- package/dist/es/components/VLMAnnotationDetail/MarkVLMBoxModal/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/VlmModal/index.mjs +0 -149
- package/dist/es/components/VLMAnnotationDetail/VlmModal/style.less.mjs +0 -4
- package/dist/es/components/VLMAnnotationDetail/index.mjs +0 -449
- package/dist/es/components/VLMAnnotationDetail/style.less.mjs +0 -4
- package/dist/es/createVlmtasetAnnotation/index.mjs +0 -131
- package/dist/src/components/DetectionAnnotation/components/ImageModal/index.d.ts +0 -34
- package/dist/src/components/Iconfont/font_4439177_tgvowh6bmlb.d.ts +0 -0
- package/dist/src/components/PicZipImportModal/config.d.ts +0 -23
- package/dist/src/components/VLMAnnotation/ImageAnnotationDebugger.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/RegionItem.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/TextAnnotationPanel.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.d.ts +0 -13
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasSetup.d.ts +0 -38
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasZoom.d.ts +0 -18
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCropRegionImage.d.ts +0 -7
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteControl.d.ts +0 -13
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDeleteRegion.d.ts +0 -22
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +0 -34
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRControl.d.ts +0 -16
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRLoadingIcon.d.ts +0 -11
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useOCRRecognition.d.ts +0 -29
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionBoundaryCheck.d.ts +0 -31
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionHover.d.ts +0 -13
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionLoader.d.ts +0 -41
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionNameText.d.ts +0 -12
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.d.ts +0 -16
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionUpdate.d.ts +0 -32
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useTextLayouts.d.ts +0 -25
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/index.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/utils/coordinateUtils.d.ts +0 -32
- package/dist/src/components/VLMAnnotation/components/DragButton.d.ts +0 -7
- package/dist/src/components/VLMAnnotation/components/FitToScreenButton.d.ts +0 -6
- package/dist/src/components/VLMAnnotation/components/RectangleButton.d.ts +0 -7
- package/dist/src/components/VLMAnnotation/components/Toolbar.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/components/ZoomControls.d.ts +0 -4
- package/dist/src/components/VLMAnnotation/constants.d.ts +0 -113
- package/dist/src/components/VLMAnnotation/index.d.ts +0 -6
- package/dist/src/components/VLMAnnotation/types.d.ts +0 -187
- package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/AttributeDetail/index.d.ts +0 -14
- package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/QAGenerationConfig.d.ts +0 -12
- package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/QADetail/index.d.ts +0 -12
- package/dist/src/components/VLMAnnotationDetail/MarkVLMBoxModal/index.d.ts +0 -12
- package/dist/src/components/VLMAnnotationDetail/VlmModal/index.d.ts +0 -17
- package/dist/src/components/VLMAnnotationDetail/index.d.ts +0 -6
- package/dist/src/createVlmtasetAnnotation/index.d.ts +0 -16
|
@@ -1,376 +1,315 @@
|
|
|
1
|
-
var
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { fabric as
|
|
5
|
-
import { useKeyPress as
|
|
1
|
+
var J = Math.pow;
|
|
2
|
+
import { jsx as l, jsxs as Q } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as se, useState as b, useEffect as g } from "react";
|
|
4
|
+
import { fabric as R } from "fabric";
|
|
5
|
+
import { useKeyPress as P } from "ahooks";
|
|
6
6
|
import "./style.less.mjs";
|
|
7
7
|
import le from "react-dom";
|
|
8
|
-
import { Spin as
|
|
9
|
-
import
|
|
10
|
-
import { drawable as
|
|
11
|
-
import { ZoomInOutlined as
|
|
12
|
-
import
|
|
13
|
-
import { approxeq as
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
var
|
|
18
|
-
let
|
|
19
|
-
(
|
|
20
|
-
const
|
|
8
|
+
import { Spin as ce, Space as fe, Tooltip as X, Button as Z } from "antd";
|
|
9
|
+
import _ from "./RectLabel.mjs";
|
|
10
|
+
import { drawable as de } from "./Drawable.mjs";
|
|
11
|
+
import { ZoomInOutlined as ue, ZoomOutOutlined as me, DragOutlined as ge } from "@ant-design/icons";
|
|
12
|
+
import he from "classnames";
|
|
13
|
+
import { approxeq as L } from "../../../../utils/index.mjs";
|
|
14
|
+
const $ = (r) => {
|
|
15
|
+
r.off("mouse:down"), r.off("mouse:up");
|
|
16
|
+
}, k = (r) => {
|
|
17
|
+
var a, w, f;
|
|
18
|
+
let s = [];
|
|
19
|
+
(a = r.object) != null && a.aCoords && (s = [r.object.aCoords.tl, r.object.aCoords.tr, r.object.aCoords.br, r.object.aCoords.bl]);
|
|
20
|
+
const c = {
|
|
21
21
|
x: 0,
|
|
22
22
|
y: 0
|
|
23
|
-
},
|
|
23
|
+
}, d = {
|
|
24
24
|
width: 0,
|
|
25
25
|
height: 0
|
|
26
26
|
};
|
|
27
|
-
return
|
|
28
|
-
id:
|
|
29
|
-
label:
|
|
30
|
-
color:
|
|
31
|
-
box: (
|
|
27
|
+
return r.canvas.backgroundImage && typeof r.canvas.backgroundImage != "string" && (c.x = ((w = r.canvas.backgroundImage.aCoords) == null ? void 0 : w.tl.x) || 0, c.y = ((f = r.canvas.backgroundImage.aCoords) == null ? void 0 : f.tl.y) || 0, d.width = r.canvas.backgroundImage.width || 0, d.height = r.canvas.backgroundImage.height || 0), {
|
|
28
|
+
id: r.config.id,
|
|
29
|
+
label: r.config.name,
|
|
30
|
+
color: r.config.color,
|
|
31
|
+
box: (s == null ? void 0 : s.map((u) => [L(u.x - c.x, 0) ? 0 : L(u.x - c.x, d.width) ? d.width : u.x - c.x, L(u.y - c.y, 0) ? 0 : L(u.y - c.y, d.height) ? d.height : u.y - c.y])) || []
|
|
32
32
|
};
|
|
33
|
-
},
|
|
34
|
-
const
|
|
35
|
-
labels:
|
|
36
|
-
imageUrl:
|
|
37
|
-
pen:
|
|
38
|
-
onImageLoad:
|
|
33
|
+
}, Ne = (r) => {
|
|
34
|
+
const s = se(null), {
|
|
35
|
+
labels: c,
|
|
36
|
+
imageUrl: d,
|
|
37
|
+
pen: a,
|
|
38
|
+
onImageLoad: w,
|
|
39
39
|
onChange: f,
|
|
40
|
-
isPreLabel:
|
|
41
|
-
disabled:
|
|
42
|
-
renderLabelItem:
|
|
43
|
-
} =
|
|
40
|
+
isPreLabel: u,
|
|
41
|
+
disabled: x,
|
|
42
|
+
renderLabelItem: O
|
|
43
|
+
} = r, [N, B] = b(!0), [e, T] = b(), [pe, V] = b({}), [y, U] = b(), [H, ee] = b({
|
|
44
44
|
left: 0,
|
|
45
45
|
top: 0
|
|
46
|
-
}), [
|
|
46
|
+
}), [te, S] = b([1, 1]), [j, K] = b(), [h, v] = b([]), [p, E] = b(x || !1), A = (t, o) => {
|
|
47
47
|
if (!e)
|
|
48
48
|
return;
|
|
49
|
-
|
|
49
|
+
o || (o = {
|
|
50
50
|
x: e.getCenter().left,
|
|
51
51
|
y: e.getCenter().top
|
|
52
52
|
});
|
|
53
53
|
let n = e.getZoom();
|
|
54
|
-
n *=
|
|
55
|
-
|
|
54
|
+
n *= J(0.999, t), n > 20 && (n = 20), n < 0.01 && (n = 0.01), e.zoomToPoint(
|
|
55
|
+
o,
|
|
56
56
|
n
|
|
57
57
|
// 传入修改后的缩放级别
|
|
58
|
-
),
|
|
58
|
+
), S([n, n]);
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
g(() => {
|
|
61
|
+
h.forEach((t) => {
|
|
62
|
+
t.renderLabel();
|
|
63
63
|
});
|
|
64
|
-
}, [
|
|
65
|
-
const
|
|
64
|
+
}, [te, h, e]);
|
|
65
|
+
const W = (t) => {
|
|
66
66
|
var n;
|
|
67
|
-
if (((n =
|
|
67
|
+
if (((n = t.target) == null ? void 0 : n.tagName) === "INPUT" || !e)
|
|
68
68
|
return;
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const i = s._fabricRect;
|
|
74
|
-
return i && i === t;
|
|
75
|
-
})), d >= 0 && r[d]) {
|
|
76
|
-
const s = r[d];
|
|
77
|
-
j.current.add(s.config.id), s.destroy(), r.splice(d, 1), f && f(r.map(O)), setTimeout(() => {
|
|
78
|
-
j.current.delete(s.config.id);
|
|
79
|
-
}, 100);
|
|
80
|
-
} else if (t && e) {
|
|
81
|
-
const s = r.findIndex((i) => {
|
|
82
|
-
const v = i._fabricRect;
|
|
83
|
-
return v && v === t;
|
|
84
|
-
});
|
|
85
|
-
if (s >= 0 && r[s]) {
|
|
86
|
-
const i = r[s];
|
|
87
|
-
j.current.add(i.config.id), i.destroy(), r.splice(s, 1), f && f(r.map(O)), setTimeout(() => {
|
|
88
|
-
j.current.delete(i.config.id);
|
|
89
|
-
}, 100);
|
|
90
|
-
} else
|
|
91
|
-
e.remove(t), e.discardActiveObject(), e.renderAll();
|
|
92
|
-
}
|
|
93
|
-
return [...r];
|
|
69
|
+
const o = e == null ? void 0 : e.getActiveObject();
|
|
70
|
+
o && v((i) => {
|
|
71
|
+
const I = i.findIndex((z) => z.object === o);
|
|
72
|
+
return i[I] && (i[I].destroy(), i.splice(I, 1)), f && f(i.map(k)), [...i];
|
|
94
73
|
});
|
|
95
74
|
};
|
|
96
|
-
|
|
97
|
-
|
|
75
|
+
P("Delete", W), P("Backspace", W), P("ctrl", () => {
|
|
76
|
+
E(!0);
|
|
98
77
|
}, {
|
|
99
78
|
events: ["keydown"]
|
|
100
|
-
}),
|
|
101
|
-
|
|
79
|
+
}), P("ctrl", () => {
|
|
80
|
+
x || E(!1);
|
|
102
81
|
}, {
|
|
103
82
|
events: ["keyup"]
|
|
104
|
-
}),
|
|
105
|
-
|
|
106
|
-
}, [
|
|
107
|
-
const
|
|
108
|
-
e &&
|
|
109
|
-
const n =
|
|
110
|
-
return n > -1 && (
|
|
83
|
+
}), g(() => {
|
|
84
|
+
E(x || !1);
|
|
85
|
+
}, [x]);
|
|
86
|
+
const q = (t) => {
|
|
87
|
+
e && $(e), v((o) => {
|
|
88
|
+
const n = o.findIndex((i) => i === t);
|
|
89
|
+
return n > -1 && (o.splice(n, 1), f && f(o.map(k)), Y()), [...o];
|
|
111
90
|
});
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
const n =
|
|
115
|
-
return n > -1 && (
|
|
91
|
+
}, F = (t) => {
|
|
92
|
+
v((o) => {
|
|
93
|
+
const n = o.findIndex((i) => i === t);
|
|
94
|
+
return n > -1 && (o[n] = t, f && f(o.map(k))), [...o];
|
|
116
95
|
});
|
|
117
96
|
};
|
|
118
|
-
|
|
97
|
+
g(() => {
|
|
119
98
|
if (!e)
|
|
120
99
|
return;
|
|
121
|
-
const
|
|
122
|
-
return
|
|
123
|
-
|
|
124
|
-
id:
|
|
125
|
-
name:
|
|
126
|
-
color:
|
|
127
|
-
points:
|
|
128
|
-
hideDelete:
|
|
100
|
+
const t = [];
|
|
101
|
+
return c.filter((o) => o.color).forEach((o) => {
|
|
102
|
+
t.push(new _({
|
|
103
|
+
id: o.id,
|
|
104
|
+
name: o.label,
|
|
105
|
+
color: o.color,
|
|
106
|
+
points: o.box.map((n) => [n[0] + H.left, n[1] + H.top]),
|
|
107
|
+
hideDelete: u
|
|
129
108
|
}, e, {
|
|
130
|
-
onChange:
|
|
131
|
-
onDelete:
|
|
132
|
-
renderLabelItem:
|
|
109
|
+
onChange: F,
|
|
110
|
+
onDelete: q,
|
|
111
|
+
renderLabelItem: O ? (n) => O ? O(o) : n.name : void 0
|
|
133
112
|
}));
|
|
134
|
-
}),
|
|
135
|
-
|
|
113
|
+
}), v(t), t.forEach((o) => {
|
|
114
|
+
o.render(e);
|
|
136
115
|
}), () => {
|
|
137
|
-
|
|
138
|
-
|
|
116
|
+
t.forEach((o) => {
|
|
117
|
+
o.canvas !== e && o.destroy();
|
|
139
118
|
});
|
|
140
119
|
};
|
|
141
|
-
}, [e,
|
|
142
|
-
const
|
|
143
|
-
e &&
|
|
144
|
-
const
|
|
145
|
-
id: (
|
|
146
|
-
name: (
|
|
147
|
-
color: (
|
|
148
|
-
points:
|
|
149
|
-
hideDelete:
|
|
120
|
+
}, [e, d]);
|
|
121
|
+
const Y = () => {
|
|
122
|
+
e && de(e, (t) => {
|
|
123
|
+
const o = new _({
|
|
124
|
+
id: (a == null ? void 0 : a.id) || t.id,
|
|
125
|
+
name: (a == null ? void 0 : a.label) || t.label,
|
|
126
|
+
color: (a == null ? void 0 : a.color) || t.color,
|
|
127
|
+
points: t.box.map((n) => [n[0], n[1]]),
|
|
128
|
+
hideDelete: u
|
|
150
129
|
}, e, {
|
|
151
|
-
onChange:
|
|
152
|
-
onDelete:
|
|
130
|
+
onChange: F,
|
|
131
|
+
onDelete: q
|
|
153
132
|
});
|
|
154
|
-
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
let
|
|
158
|
-
e && (e.on("mouse:down", (
|
|
159
|
-
|
|
160
|
-
}), e.on("mouse:move", (
|
|
161
|
-
if (
|
|
162
|
-
const n = new
|
|
133
|
+
o.active = !0, h.push(o), f && f(h.map(k)), v([...h]);
|
|
134
|
+
}, u);
|
|
135
|
+
}, oe = () => {
|
|
136
|
+
let t = !1;
|
|
137
|
+
e && (e.on("mouse:down", (o) => {
|
|
138
|
+
t = !0, e.selection = !1;
|
|
139
|
+
}), e.on("mouse:move", (o) => {
|
|
140
|
+
if (t && o && o.e) {
|
|
141
|
+
const n = new R.Point(o.e.movementX, o.e.movementY);
|
|
163
142
|
e.relativePan(n);
|
|
164
143
|
}
|
|
165
|
-
}), e.on("mouse:up", (
|
|
166
|
-
|
|
144
|
+
}), e.on("mouse:up", (o) => {
|
|
145
|
+
t = !1, e.selection = !0;
|
|
167
146
|
}));
|
|
168
|
-
},
|
|
147
|
+
}, ne = () => {
|
|
169
148
|
e && (e.off("mouse:down"), e.off("mouse:move"), e.off("mouse:up"));
|
|
170
149
|
};
|
|
171
|
-
|
|
172
|
-
if (!e)
|
|
173
|
-
return;
|
|
174
|
-
const o = (t) => {
|
|
175
|
-
const n = e, r = n == null ? void 0 : n._currentTransform;
|
|
176
|
-
if (!r)
|
|
177
|
-
return;
|
|
178
|
-
const d = r.action;
|
|
179
|
-
if (!d || !d.startsWith("scale"))
|
|
180
|
-
return;
|
|
181
|
-
const s = e.backgroundImage, i = s == null ? void 0 : s.aCoords;
|
|
182
|
-
if (!i)
|
|
183
|
-
return;
|
|
184
|
-
const v = e.getPointer(t.e);
|
|
185
|
-
if (v.x < i.tl.x || v.x > i.br.x || v.y < i.tl.y || v.y > i.br.y) {
|
|
186
|
-
const w = n == null ? void 0 : n._onMouseUp;
|
|
187
|
-
typeof w == "function" && w(t.e);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
return e.on("mouse:move", o), () => {
|
|
191
|
-
e.off("mouse:move", o);
|
|
192
|
-
};
|
|
193
|
-
}, [e]), h(() => {
|
|
194
|
-
if (!e)
|
|
195
|
-
return;
|
|
196
|
-
const o = (t) => {
|
|
197
|
-
const n = e;
|
|
198
|
-
if (!!!(n != null && n._currentTransform))
|
|
199
|
-
return;
|
|
200
|
-
const d = n == null ? void 0 : n._onMouseUp;
|
|
201
|
-
typeof d == "function" && d(t.e);
|
|
202
|
-
};
|
|
203
|
-
return e.on("mouse:out", o), () => {
|
|
204
|
-
e.off("mouse:out", o);
|
|
205
|
-
};
|
|
206
|
-
}, [e]), h(() => {
|
|
150
|
+
g(() => {
|
|
207
151
|
if (e)
|
|
208
|
-
return
|
|
152
|
+
return p ? (oe(), e.defaultCursor = "grab", e.on("mouse:down:before", () => {
|
|
209
153
|
e.setCursor("grabbing");
|
|
210
154
|
}), e.on("mouse:up", () => {
|
|
211
155
|
e.defaultCursor = "grab";
|
|
212
|
-
}), e.getObjects(),
|
|
156
|
+
}), e.getObjects(), v((t) => (t.forEach((o) => {
|
|
213
157
|
var n;
|
|
214
|
-
return (n =
|
|
215
|
-
}),
|
|
158
|
+
return (n = o.object) == null ? void 0 : n.set("evented", !1);
|
|
159
|
+
}), t))) : (e.defaultCursor = "default", e.off("mouse:down:before"), e.off("mouse:up"), e.setCursor("default"), v((t) => (t.forEach((o) => {
|
|
216
160
|
var n;
|
|
217
|
-
return (n =
|
|
218
|
-
}),
|
|
219
|
-
|
|
161
|
+
return (n = o.object) == null ? void 0 : n.set("evented", !0);
|
|
162
|
+
}), t)), Y()), () => {
|
|
163
|
+
ne();
|
|
220
164
|
};
|
|
221
|
-
}, [e,
|
|
222
|
-
if (e == null || e.on("mouse:wheel", (
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
x:
|
|
226
|
-
y:
|
|
227
|
-
}),
|
|
165
|
+
}, [e, p]), g(() => {
|
|
166
|
+
if (e == null || e.on("mouse:wheel", (t) => {
|
|
167
|
+
const o = t.e.deltaY;
|
|
168
|
+
A(o, {
|
|
169
|
+
x: t.e.offsetX,
|
|
170
|
+
y: t.e.offsetY
|
|
171
|
+
}), h.forEach((n) => {
|
|
228
172
|
n.renderLabel();
|
|
229
173
|
});
|
|
230
|
-
}), !
|
|
231
|
-
return
|
|
232
|
-
e && (
|
|
174
|
+
}), !p)
|
|
175
|
+
return Y(), () => {
|
|
176
|
+
e && ($(e), e.off("mouse:wheel"));
|
|
233
177
|
};
|
|
234
|
-
}, [e,
|
|
235
|
-
const
|
|
236
|
-
|
|
178
|
+
}, [e, a, h, p]);
|
|
179
|
+
const re = () => {
|
|
180
|
+
V({}), U(void 0), S([1, 1]), e == null || e.dispose(), T(void 0);
|
|
237
181
|
};
|
|
238
|
-
return
|
|
239
|
-
B(!0),
|
|
240
|
-
|
|
182
|
+
return g(() => {
|
|
183
|
+
B(!0), re(), !(!s.current || !d) && R.Image.fromURL(d, (t) => {
|
|
184
|
+
t.set({
|
|
241
185
|
originX: "center",
|
|
242
186
|
originY: "center"
|
|
243
|
-
}),
|
|
187
|
+
}), U(t), B(!1);
|
|
244
188
|
}, {
|
|
245
189
|
crossOrigin: "anonymous"
|
|
246
190
|
});
|
|
247
|
-
}, [
|
|
248
|
-
if (!
|
|
191
|
+
}, [d]), g(() => {
|
|
192
|
+
if (!y && e) {
|
|
249
193
|
try {
|
|
250
194
|
e.clear();
|
|
251
|
-
} catch (
|
|
195
|
+
} catch (M) {
|
|
252
196
|
}
|
|
253
197
|
return;
|
|
254
198
|
}
|
|
255
|
-
if (!
|
|
199
|
+
if (!s.current || !s.current.parentElement)
|
|
256
200
|
return;
|
|
257
|
-
const
|
|
258
|
-
if (!(
|
|
201
|
+
const t = y == null ? void 0 : y.getElement();
|
|
202
|
+
if (!(t != null && t.width) || !(t != null && t.height))
|
|
259
203
|
return;
|
|
260
|
-
const
|
|
261
|
-
let
|
|
262
|
-
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
const
|
|
204
|
+
const o = t.width / t.height, n = s.current.parentElement.offsetWidth, i = s.current.parentElement.offsetHeight, I = n / t.width, z = i / t.height;
|
|
205
|
+
let C = [n, i];
|
|
206
|
+
I > z ? C = [i * o, i] : C = [n, n / o];
|
|
207
|
+
const ae = C[0] / t.width, ie = C[1] / t.height, D = Math.min(ae, ie);
|
|
208
|
+
S([D, D]);
|
|
209
|
+
const m = new R.Canvas(s.current, {
|
|
266
210
|
containerClass: "marking-canvas",
|
|
267
211
|
width: n,
|
|
268
|
-
height:
|
|
212
|
+
height: i
|
|
269
213
|
});
|
|
270
|
-
if (
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
214
|
+
if (m == null || m.setZoom(D), m == null || m.renderAll(), m && y) {
|
|
215
|
+
const M = (n - C[0]) / D / 2, G = (i - C[1]) / D / 2;
|
|
216
|
+
m.setBackgroundImage(
|
|
217
|
+
y,
|
|
274
218
|
() => {
|
|
275
|
-
|
|
276
|
-
left:
|
|
277
|
-
top:
|
|
278
|
-
}),
|
|
219
|
+
m.renderAll(), ee({
|
|
220
|
+
left: M,
|
|
221
|
+
top: G
|
|
222
|
+
}), T(m), w && w();
|
|
279
223
|
},
|
|
280
224
|
// 刷新画布
|
|
281
225
|
{
|
|
282
226
|
originX: "left",
|
|
283
227
|
originY: "top",
|
|
284
|
-
left:
|
|
285
|
-
top:
|
|
228
|
+
left: M,
|
|
229
|
+
top: G
|
|
286
230
|
}
|
|
287
231
|
);
|
|
288
232
|
}
|
|
289
|
-
}, [
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
return n && c && (n.labelConfig = {
|
|
302
|
-
id: c.id,
|
|
303
|
-
name: c.label,
|
|
304
|
-
color: c.color
|
|
305
|
-
}, f && f(o.map(O))), e && (c ? e.defaultCursor = "copy" : e.defaultCursor = "default"), [...o];
|
|
233
|
+
}, [y]), g(() => {
|
|
234
|
+
h.length > c.length && h.forEach((t) => {
|
|
235
|
+
c.find((o) => o.id === t.config.id) || t.destroy();
|
|
236
|
+
});
|
|
237
|
+
}, [c.length]), g(() => {
|
|
238
|
+
e && (p || v((t) => {
|
|
239
|
+
const o = e == null ? void 0 : e.getActiveObject(), n = t.find((i) => i.object === o);
|
|
240
|
+
return n && a && (n.labelConfig = {
|
|
241
|
+
id: a.id,
|
|
242
|
+
name: a.label,
|
|
243
|
+
color: a.color
|
|
244
|
+
}, f && f(t.map(k))), e && (a ? e.defaultCursor = "copy" : e.defaultCursor = "default"), [...t];
|
|
306
245
|
}));
|
|
307
|
-
}, [
|
|
308
|
-
var
|
|
309
|
-
if (
|
|
310
|
-
const
|
|
311
|
-
|
|
246
|
+
}, [a, e, p]), g(() => {
|
|
247
|
+
var t;
|
|
248
|
+
if (N && s.current && !j) {
|
|
249
|
+
const o = document.createElement("div");
|
|
250
|
+
o.setAttribute("style", "width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; position: absolute;top: 0;"), (t = s.current.parentElement) == null || t.appendChild(o), le.render(/* @__PURE__ */ l(ce, {}), o), K(o);
|
|
312
251
|
} else
|
|
313
|
-
!
|
|
314
|
-
}, [
|
|
252
|
+
!N && j && (j.remove(), K(null));
|
|
253
|
+
}, [N, s.current, j]), /* @__PURE__ */ Q("div", {
|
|
315
254
|
style: {
|
|
316
255
|
width: "100%",
|
|
317
256
|
height: "100%",
|
|
318
257
|
display: "flex"
|
|
319
258
|
},
|
|
320
|
-
children: [/* @__PURE__ */
|
|
259
|
+
children: [/* @__PURE__ */ l("div", {
|
|
321
260
|
className: "marker-toolbar",
|
|
322
|
-
children: /* @__PURE__ */
|
|
261
|
+
children: /* @__PURE__ */ l("div", {
|
|
323
262
|
className: "create-mode-select",
|
|
324
|
-
children: /* @__PURE__ */
|
|
263
|
+
children: /* @__PURE__ */ Q(fe, {
|
|
325
264
|
direction: "vertical",
|
|
326
265
|
size: 16,
|
|
327
|
-
children: [/* @__PURE__ */
|
|
266
|
+
children: [/* @__PURE__ */ l(X, {
|
|
328
267
|
title: "放大-鼠标滚轮前滑",
|
|
329
268
|
placement: "right",
|
|
330
|
-
children: /* @__PURE__ */
|
|
331
|
-
icon: /* @__PURE__ */
|
|
269
|
+
children: /* @__PURE__ */ l(Z, {
|
|
270
|
+
icon: /* @__PURE__ */ l(ue, {}),
|
|
332
271
|
onClick: () => {
|
|
333
|
-
|
|
272
|
+
A(-100);
|
|
334
273
|
}
|
|
335
274
|
})
|
|
336
|
-
}), /* @__PURE__ */
|
|
275
|
+
}), /* @__PURE__ */ l(X, {
|
|
337
276
|
title: "缩小-鼠标滚轮后滑",
|
|
338
277
|
placement: "right",
|
|
339
|
-
children: /* @__PURE__ */
|
|
340
|
-
icon: /* @__PURE__ */
|
|
278
|
+
children: /* @__PURE__ */ l(Z, {
|
|
279
|
+
icon: /* @__PURE__ */ l(me, {}),
|
|
341
280
|
onClick: () => {
|
|
342
|
-
|
|
281
|
+
A(100);
|
|
343
282
|
}
|
|
344
283
|
})
|
|
345
|
-
}), !
|
|
284
|
+
}), !x && /* @__PURE__ */ l(X, {
|
|
346
285
|
title: "拖动-按住ctrl",
|
|
347
286
|
placement: "right",
|
|
348
|
-
children: /* @__PURE__ */
|
|
349
|
-
disabled:
|
|
350
|
-
icon: /* @__PURE__ */
|
|
351
|
-
className:
|
|
287
|
+
children: /* @__PURE__ */ l(Z, {
|
|
288
|
+
disabled: x,
|
|
289
|
+
icon: /* @__PURE__ */ l(ge, {}),
|
|
290
|
+
className: p ? "active" : "",
|
|
352
291
|
onClick: () => {
|
|
353
|
-
|
|
292
|
+
E(!p);
|
|
354
293
|
}
|
|
355
294
|
})
|
|
356
295
|
})]
|
|
357
296
|
})
|
|
358
297
|
})
|
|
359
|
-
}), /* @__PURE__ */
|
|
360
|
-
className:
|
|
298
|
+
}), /* @__PURE__ */ l("div", {
|
|
299
|
+
className: he({
|
|
361
300
|
"label-maker-wrap": !0,
|
|
362
|
-
draggable:
|
|
301
|
+
draggable: p
|
|
363
302
|
}),
|
|
364
|
-
onContextMenu: (
|
|
365
|
-
|
|
303
|
+
onContextMenu: (t) => {
|
|
304
|
+
t.preventDefault();
|
|
366
305
|
},
|
|
367
|
-
children: /* @__PURE__ */
|
|
306
|
+
children: /* @__PURE__ */ l("canvas", {
|
|
368
307
|
className: "label-maker-canvas",
|
|
369
|
-
ref:
|
|
308
|
+
ref: s
|
|
370
309
|
})
|
|
371
310
|
})]
|
|
372
311
|
});
|
|
373
312
|
};
|
|
374
313
|
export {
|
|
375
|
-
|
|
314
|
+
Ne as default
|
|
376
315
|
};
|