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