@glodon-aiot/dataset-annotation 3.10.0-alpha.21 → 3.10.0-alpha.23
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/Drawable.mjs +12 -12
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/RectLabel.mjs +136 -108
- package/dist/es/components/DetectionAnnotation/components/LabelMaker/index.mjs +197 -162
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.mjs +75 -34
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.mjs +159 -131
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/hooks/useRegionSelection.mjs +59 -48
- package/dist/es/components/VLMAnnotation/VLMLabelMaker/index.mjs +260 -241
- package/dist/es/index.mjs +1 -1
- package/dist/lib/index.js +3 -3
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useCanvasDrag.d.ts +2 -1
- package/dist/src/components/VLMAnnotation/VLMLabelMaker/hooks/useDrawingMode.d.ts +2 -1
- package/package.json +2 -2
|
@@ -1,65 +1,83 @@
|
|
|
1
|
-
import { useCallback as
|
|
2
|
-
import { fabric as
|
|
3
|
-
import { TEMP_RECT_FILL_COLOR as
|
|
4
|
-
const
|
|
1
|
+
import { useCallback as Q, useEffect as te } from "react";
|
|
2
|
+
import { fabric as j } from "fabric";
|
|
3
|
+
import { TEMP_RECT_FILL_COLOR as V, RECT_STROKE_COLOR as U, TEMP_RECT_STROKE_DASH_ARRAY as v, TRANSPARENT_FILL as oe, REGION_NAME_PREFIX as re, BASE_STROKE_WIDTH as a } from "../../constants.mjs";
|
|
4
|
+
const ne = ({
|
|
5
5
|
canvas: e,
|
|
6
6
|
drawingMode: x,
|
|
7
|
-
draggable:
|
|
8
|
-
setDrawingMode:
|
|
9
|
-
canvasToImageCoords:
|
|
7
|
+
draggable: H,
|
|
8
|
+
setDrawingMode: $,
|
|
9
|
+
canvasToImageCoords: G,
|
|
10
10
|
labelDefinitions: y,
|
|
11
|
-
onChange:
|
|
12
|
-
cropRegionImage:
|
|
13
|
-
updateRegionShapeAndImage:
|
|
14
|
-
performOCRIfNeeded:
|
|
15
|
-
createDeleteControl:
|
|
16
|
-
updateRegionNameText:
|
|
17
|
-
onRegionChange:
|
|
18
|
-
onRegionSelect:
|
|
19
|
-
rectMapRef: h
|
|
11
|
+
onChange: T,
|
|
12
|
+
cropRegionImage: K,
|
|
13
|
+
updateRegionShapeAndImage: L,
|
|
14
|
+
performOCRIfNeeded: B,
|
|
15
|
+
createDeleteControl: D,
|
|
16
|
+
updateRegionNameText: N,
|
|
17
|
+
onRegionChange: S,
|
|
18
|
+
onRegionSelect: w,
|
|
19
|
+
rectMapRef: h,
|
|
20
|
+
textLayersMapRef: z
|
|
20
21
|
}) => {
|
|
21
|
-
const
|
|
22
|
+
const X = Q(() => {
|
|
23
|
+
const Y = /* @__PURE__ */ new Set();
|
|
24
|
+
return z.current.forEach((r) => {
|
|
25
|
+
r.forEach((l) => {
|
|
26
|
+
Y.add(l);
|
|
27
|
+
});
|
|
28
|
+
}), Y;
|
|
29
|
+
}, [z]), R = Q(() => {
|
|
22
30
|
e && (e.skipTargetFind = !1);
|
|
23
31
|
}, [e]);
|
|
24
|
-
return
|
|
25
|
-
if (!e || !x ||
|
|
26
|
-
if (
|
|
27
|
-
const
|
|
28
|
-
e.selection = !1, e.skipTargetFind = !1
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
return te(() => {
|
|
33
|
+
if (!e || !x || H) {
|
|
34
|
+
if (R(), e && !x) {
|
|
35
|
+
const o = e.getActiveObject();
|
|
36
|
+
e.selection = !1, e.skipTargetFind = !1;
|
|
37
|
+
const n = X();
|
|
38
|
+
e.getObjects().forEach((t) => {
|
|
39
|
+
t instanceof j.Rect && n.has(t) ? t.set({
|
|
40
|
+
evented: !0,
|
|
41
|
+
selectable: !1,
|
|
42
|
+
lockMovementX: !0,
|
|
43
|
+
lockMovementY: !0,
|
|
44
|
+
lockScalingX: !0,
|
|
45
|
+
lockScalingY: !0,
|
|
46
|
+
lockRotation: !0
|
|
47
|
+
}) : (t.set("evented", !0), t.set("selectable", !0));
|
|
48
|
+
}), o && e.getObjects().includes(o) && (e.setActiveObject(o), e.renderAll()), e.defaultCursor = "default", e.setCursor("default");
|
|
31
49
|
}
|
|
32
50
|
return;
|
|
33
51
|
}
|
|
34
|
-
|
|
35
|
-
|
|
52
|
+
R(), e.selection = !1, e.skipTargetFind = !0, e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), e.getObjects().forEach((o) => {
|
|
53
|
+
o.set("evented", !1), o.set("selectable", !1);
|
|
36
54
|
}), e.defaultCursor = "crosshair", e.setCursor("crosshair");
|
|
37
|
-
let
|
|
38
|
-
const
|
|
39
|
-
e.getActiveObject() && (e.discardActiveObject(), e.renderAll()),
|
|
40
|
-
const
|
|
41
|
-
l =
|
|
42
|
-
},
|
|
43
|
-
if (l === -1 ||
|
|
55
|
+
let r = -1, l = -1, d = 0, m = 0, f = null;
|
|
56
|
+
const q = (o) => {
|
|
57
|
+
e.getActiveObject() && (e.discardActiveObject(), e.renderAll()), r = -1, l = -1, d = 0, m = 0;
|
|
58
|
+
const t = e.getPointer(o.e);
|
|
59
|
+
l = t.x, r = t.y, e.skipTargetFind = !0;
|
|
60
|
+
}, P = (o) => {
|
|
61
|
+
if (l === -1 || r === -1)
|
|
44
62
|
return;
|
|
45
|
-
const
|
|
46
|
-
let
|
|
47
|
-
if (
|
|
63
|
+
const n = e.getPointer(o.e);
|
|
64
|
+
let t = n.x, c = n.y;
|
|
65
|
+
if (d = Math.abs(t - l), m = Math.abs(c - r), d === 0 || m === 0)
|
|
48
66
|
return;
|
|
49
|
-
let g =
|
|
67
|
+
let g = r > c ? c : r, C = l > t ? t : l, u = d, k = m;
|
|
50
68
|
f && e.remove(f);
|
|
51
|
-
const A = e.getZoom(),
|
|
52
|
-
f = new
|
|
53
|
-
left:
|
|
69
|
+
const A = e.getZoom(), p = a / A;
|
|
70
|
+
f = new j.Rect({
|
|
71
|
+
left: C,
|
|
54
72
|
top: g,
|
|
55
|
-
width:
|
|
56
|
-
height:
|
|
57
|
-
fill:
|
|
58
|
-
stroke:
|
|
59
|
-
strokeWidth:
|
|
73
|
+
width: u,
|
|
74
|
+
height: k,
|
|
75
|
+
fill: V,
|
|
76
|
+
stroke: U,
|
|
77
|
+
strokeWidth: p,
|
|
60
78
|
strokeUniform: !0,
|
|
61
79
|
// 边框宽度不受缩放影响
|
|
62
|
-
strokeDashArray:
|
|
80
|
+
strokeDashArray: v,
|
|
63
81
|
selectable: !1,
|
|
64
82
|
evented: !1,
|
|
65
83
|
objectCaching: !1,
|
|
@@ -67,28 +85,28 @@ const le = ({
|
|
|
67
85
|
statefullCache: !1,
|
|
68
86
|
noScaleCache: !1
|
|
69
87
|
}), e.add(f), e.renderAll();
|
|
70
|
-
},
|
|
71
|
-
if (l === -1 ||
|
|
72
|
-
|
|
88
|
+
}, W = (o) => {
|
|
89
|
+
if (l === -1 || r === -1) {
|
|
90
|
+
r = -1, l = -1;
|
|
73
91
|
return;
|
|
74
92
|
}
|
|
75
|
-
const
|
|
76
|
-
let
|
|
77
|
-
if (
|
|
78
|
-
f && (e.remove(f), e.renderAll()),
|
|
93
|
+
const n = e.getPointer(o.e);
|
|
94
|
+
let t = n.x, c = n.y;
|
|
95
|
+
if (d = Math.abs(t - l), m = Math.abs(c - r), d === 0 || m === 0) {
|
|
96
|
+
f && (e.remove(f), e.renderAll()), r = -1, l = -1;
|
|
79
97
|
return;
|
|
80
98
|
}
|
|
81
|
-
let g =
|
|
99
|
+
let g = r > c ? c : r, C = l > t ? t : l, u = d, k = m;
|
|
82
100
|
f && (e.remove(f), f = null);
|
|
83
|
-
const A =
|
|
84
|
-
left:
|
|
101
|
+
const A = G(C, g), p = u, F = k, E = e.getZoom(), b = a / E, s = new j.Rect({
|
|
102
|
+
left: C,
|
|
85
103
|
top: g,
|
|
86
|
-
width:
|
|
87
|
-
height:
|
|
88
|
-
fill:
|
|
104
|
+
width: u,
|
|
105
|
+
height: k,
|
|
106
|
+
fill: oe,
|
|
89
107
|
// 无填充色
|
|
90
|
-
stroke:
|
|
91
|
-
strokeWidth:
|
|
108
|
+
stroke: U,
|
|
109
|
+
strokeWidth: b,
|
|
92
110
|
strokeUniform: !0,
|
|
93
111
|
// 边框宽度不受缩放影响
|
|
94
112
|
selectable: !0,
|
|
@@ -104,90 +122,90 @@ const le = ({
|
|
|
104
122
|
statefullCache: !1,
|
|
105
123
|
noScaleCache: !1
|
|
106
124
|
});
|
|
107
|
-
e.add(
|
|
108
|
-
const
|
|
109
|
-
y == null || y.forEach((
|
|
110
|
-
|
|
125
|
+
e.add(s), s.controls.deleteControl = D();
|
|
126
|
+
const Z = h.current.size, _ = {};
|
|
127
|
+
y == null || y.forEach((i) => {
|
|
128
|
+
_[i.id] = "";
|
|
111
129
|
});
|
|
112
|
-
const
|
|
130
|
+
const M = {
|
|
113
131
|
id: `region-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
114
|
-
name: `${
|
|
132
|
+
name: `${re}${Z + 1}`,
|
|
115
133
|
// 设置名称:区域+(索引+1)
|
|
116
134
|
shape: {
|
|
117
135
|
name: "rect",
|
|
118
136
|
x: Math.max(0, A.x),
|
|
119
137
|
y: Math.max(0, A.y),
|
|
120
|
-
width:
|
|
121
|
-
height:
|
|
138
|
+
width: p,
|
|
139
|
+
height: F
|
|
122
140
|
},
|
|
123
|
-
content:
|
|
141
|
+
content: _
|
|
124
142
|
};
|
|
125
|
-
if (h.current.set(
|
|
126
|
-
const
|
|
127
|
-
|
|
143
|
+
if (h.current.set(s, M), N(s, M), L(s), S) {
|
|
144
|
+
const i = h.current.get(s);
|
|
145
|
+
i && S(i, "create");
|
|
128
146
|
}
|
|
129
|
-
|
|
130
|
-
if (
|
|
131
|
-
const O = h.current.get(
|
|
147
|
+
K(M).then((i) => {
|
|
148
|
+
if (i) {
|
|
149
|
+
const O = h.current.get(s);
|
|
132
150
|
if (O) {
|
|
133
|
-
if (O.image =
|
|
134
|
-
const
|
|
135
|
-
|
|
151
|
+
if (O.image = i, delete O.textLayouts, T) {
|
|
152
|
+
const ee = Array.from(h.current.values());
|
|
153
|
+
T(ee);
|
|
136
154
|
}
|
|
137
|
-
|
|
155
|
+
B(O, "create");
|
|
138
156
|
}
|
|
139
157
|
}
|
|
140
|
-
}).catch((
|
|
141
|
-
console.error("Failed to crop region image:",
|
|
142
|
-
}), e.setActiveObject(
|
|
143
|
-
if (
|
|
144
|
-
const
|
|
145
|
-
|
|
158
|
+
}).catch((i) => {
|
|
159
|
+
console.error("Failed to crop region image:", i);
|
|
160
|
+
}), e.setActiveObject(s), e.renderAll(), setTimeout(() => {
|
|
161
|
+
if (w) {
|
|
162
|
+
const i = h.current.get(s);
|
|
163
|
+
i && w(i);
|
|
146
164
|
}
|
|
147
165
|
setTimeout(() => {
|
|
148
|
-
if (e &&
|
|
149
|
-
const
|
|
150
|
-
|
|
166
|
+
if (e && s && e.getObjects().includes(s) && (e.setActiveObject(s), e.renderAll(), w)) {
|
|
167
|
+
const i = h.current.get(s);
|
|
168
|
+
i && w(i);
|
|
151
169
|
}
|
|
152
170
|
}, 0);
|
|
153
|
-
}, 0),
|
|
154
|
-
|
|
155
|
-
}),
|
|
156
|
-
|
|
171
|
+
}, 0), s.on("modified", () => {
|
|
172
|
+
L(s);
|
|
173
|
+
}), s.on("moved", () => {
|
|
174
|
+
L(s);
|
|
157
175
|
}), setTimeout(() => {
|
|
158
|
-
if (
|
|
159
|
-
const
|
|
160
|
-
|
|
176
|
+
if (T) {
|
|
177
|
+
const i = Array.from(h.current.values());
|
|
178
|
+
T(i);
|
|
161
179
|
}
|
|
162
|
-
}, 0),
|
|
163
|
-
},
|
|
164
|
-
if (l === -1 ||
|
|
180
|
+
}, 0), r = -1, l = -1, e.selection = !1, $(!1);
|
|
181
|
+
}, I = (o) => {
|
|
182
|
+
if (l === -1 || r === -1)
|
|
165
183
|
return;
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
e:
|
|
171
|
-
pointer:
|
|
184
|
+
const t = e.getElement().getBoundingClientRect(), c = o.clientX, g = o.clientY;
|
|
185
|
+
if (c >= t.left && c <= t.right && g >= t.top && g <= t.bottom) {
|
|
186
|
+
const u = e.getPointer(o);
|
|
187
|
+
P({
|
|
188
|
+
e: o,
|
|
189
|
+
pointer: u
|
|
172
190
|
});
|
|
173
191
|
} else {
|
|
174
|
-
const
|
|
175
|
-
let E = (
|
|
176
|
-
if (E = Math.max(0, Math.min(E,
|
|
192
|
+
const u = e.getZoom(), k = e.viewportTransform ? e.viewportTransform[4] / u : 0, A = e.viewportTransform ? e.viewportTransform[5] / u : 0, p = e.getWidth() / u, F = e.getHeight() / u;
|
|
193
|
+
let E = (c - t.left) / u - k, b = (g - t.top) / u - A;
|
|
194
|
+
if (E = Math.max(0, Math.min(E, p)), b = Math.max(0, Math.min(b, F)), d = Math.abs(E - l), m = Math.abs(b - r), d === 0 || m === 0)
|
|
177
195
|
return;
|
|
178
|
-
let
|
|
196
|
+
let s = r > b ? b : r, Z = l > E ? E : l, _ = d, M = m;
|
|
179
197
|
f && e.remove(f);
|
|
180
|
-
const
|
|
181
|
-
f = new
|
|
182
|
-
left:
|
|
183
|
-
top:
|
|
184
|
-
width:
|
|
185
|
-
height:
|
|
186
|
-
fill:
|
|
187
|
-
stroke:
|
|
198
|
+
const i = e.getZoom(), O = a / i;
|
|
199
|
+
f = new j.Rect({
|
|
200
|
+
left: Z,
|
|
201
|
+
top: s,
|
|
202
|
+
width: _,
|
|
203
|
+
height: M,
|
|
204
|
+
fill: V,
|
|
205
|
+
stroke: U,
|
|
188
206
|
strokeWidth: O,
|
|
189
207
|
strokeUniform: !0,
|
|
190
|
-
strokeDashArray:
|
|
208
|
+
strokeDashArray: v,
|
|
191
209
|
selectable: !1,
|
|
192
210
|
evented: !1,
|
|
193
211
|
objectCaching: !1,
|
|
@@ -196,25 +214,35 @@ const le = ({
|
|
|
196
214
|
}), e.add(f), e.renderAll();
|
|
197
215
|
}
|
|
198
216
|
};
|
|
199
|
-
e.on("mouse:down",
|
|
200
|
-
const
|
|
201
|
-
if (l === -1 ||
|
|
217
|
+
e.on("mouse:down", q), e.on("mouse:move", P), e.on("mouse:up", W), document.addEventListener("mousemove", I);
|
|
218
|
+
const J = (o) => {
|
|
219
|
+
if (l === -1 || r === -1)
|
|
202
220
|
return;
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
e:
|
|
206
|
-
pointer:
|
|
221
|
+
const n = e.getPointer(o);
|
|
222
|
+
W({
|
|
223
|
+
e: o,
|
|
224
|
+
pointer: n
|
|
207
225
|
});
|
|
208
226
|
};
|
|
209
|
-
return document.addEventListener("mouseup",
|
|
210
|
-
e.off("mouse:down",
|
|
211
|
-
|
|
227
|
+
return document.addEventListener("mouseup", J), () => {
|
|
228
|
+
e.off("mouse:down", q), e.off("mouse:move", P), e.off("mouse:up", W), document.removeEventListener("mousemove", I), document.removeEventListener("mouseup", J), f && (e.remove(f), e.renderAll()), e.skipTargetFind = !1;
|
|
229
|
+
const o = X();
|
|
230
|
+
e.getObjects().forEach((n) => {
|
|
231
|
+
n instanceof j.Rect && o.has(n) ? n.set({
|
|
232
|
+
evented: !0,
|
|
233
|
+
selectable: !1,
|
|
234
|
+
lockMovementX: !0,
|
|
235
|
+
lockMovementY: !0,
|
|
236
|
+
lockScalingX: !0,
|
|
237
|
+
lockScalingY: !0,
|
|
238
|
+
lockRotation: !0
|
|
239
|
+
}) : (n.set("evented", !0), n.set("selectable", !0));
|
|
212
240
|
});
|
|
213
241
|
};
|
|
214
|
-
}, [e, x,
|
|
215
|
-
stopDraw:
|
|
242
|
+
}, [e, x, H, R, G, T, K, L, B, D, N, S, w, $, h, X]), {
|
|
243
|
+
stopDraw: R
|
|
216
244
|
};
|
|
217
245
|
};
|
|
218
246
|
export {
|
|
219
|
-
|
|
247
|
+
ne as useDrawingMode
|
|
220
248
|
};
|
|
@@ -1,43 +1,50 @@
|
|
|
1
1
|
import { useEffect as g } from "react";
|
|
2
|
-
import { fabric as
|
|
3
|
-
import { SELECTED_RECT_FILL_COLOR as
|
|
4
|
-
const
|
|
5
|
-
canvas:
|
|
6
|
-
onRegionSelect:
|
|
7
|
-
createDeleteControl:
|
|
8
|
-
textLayersMapRef:
|
|
9
|
-
rectMapRef:
|
|
2
|
+
import { fabric as u } from "fabric";
|
|
3
|
+
import { SELECTED_RECT_FILL_COLOR as L, CONTROL_POINT_COLOR as R, CONTROL_POINT_SIZE as S, TRANSPARENT_FILL as E, BASE_STROKE_WIDTH as A } from "../../constants.mjs";
|
|
4
|
+
const j = ({
|
|
5
|
+
canvas: e,
|
|
6
|
+
onRegionSelect: o,
|
|
7
|
+
createDeleteControl: n,
|
|
8
|
+
textLayersMapRef: a,
|
|
9
|
+
rectMapRef: s
|
|
10
10
|
}) => {
|
|
11
11
|
g(() => {
|
|
12
|
-
if (!
|
|
12
|
+
if (!e)
|
|
13
13
|
return;
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const i = () => {
|
|
15
|
+
const t = /* @__PURE__ */ new Set();
|
|
16
|
+
return a.current.forEach((r) => {
|
|
17
|
+
r.forEach((l) => {
|
|
18
|
+
t.add(l);
|
|
19
19
|
});
|
|
20
|
-
}), t
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
}), t;
|
|
21
|
+
}, f = () => {
|
|
22
|
+
const t = i();
|
|
23
|
+
e.getObjects().forEach((r) => {
|
|
24
|
+
r instanceof u.Rect && !t.has(r) && r.set({
|
|
25
|
+
fill: E
|
|
23
26
|
// 移除填充色
|
|
24
27
|
});
|
|
25
28
|
});
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
}, h = () => {
|
|
30
|
+
f();
|
|
31
|
+
const t = e.getActiveObject();
|
|
32
|
+
if (t && t instanceof u.Rect) {
|
|
33
|
+
if (i().has(t)) {
|
|
34
|
+
e.discardActiveObject(), e.renderAll();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const l = e.getZoom(), d = A / l;
|
|
38
|
+
t.set({
|
|
32
39
|
hasRotatingPoint: !1,
|
|
33
40
|
lockRotation: !0,
|
|
34
41
|
lockUniScaling: !1,
|
|
35
42
|
// 允许非等比缩放,控制点跟随鼠标
|
|
36
|
-
fill:
|
|
43
|
+
fill: L,
|
|
37
44
|
// 选中时添加填充色
|
|
38
45
|
strokeUniform: !0,
|
|
39
46
|
// 确保边框宽度不受缩放影响
|
|
40
|
-
strokeWidth:
|
|
47
|
+
strokeWidth: d,
|
|
41
48
|
// 确保边框宽度一致
|
|
42
49
|
objectCaching: !1,
|
|
43
50
|
// 禁用缓存,避免缩放时边框变虚
|
|
@@ -45,31 +52,35 @@ const L = ({
|
|
|
45
52
|
noScaleCache: !1,
|
|
46
53
|
cornerStyle: "circle",
|
|
47
54
|
// 设置控制点为圆形
|
|
48
|
-
cornerColor:
|
|
55
|
+
cornerColor: R,
|
|
49
56
|
// 设置控制点为紫色(填充色)
|
|
50
57
|
cornerSize: S,
|
|
51
58
|
// 设置控制点大小(默认12,这里设置为6使其更小)
|
|
52
59
|
transparentCorners: !1
|
|
53
60
|
// 不透明,显示填充颜色
|
|
54
|
-
}),
|
|
55
|
-
const
|
|
56
|
-
|
|
61
|
+
}), t.controls && t.controls.mtr && delete t.controls.mtr, t.controls.deleteControl || (t.controls.deleteControl = n()), e.renderAll();
|
|
62
|
+
const c = s.current.get(t);
|
|
63
|
+
c && o && o(c);
|
|
57
64
|
}
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
}, C = () => {
|
|
66
|
+
f();
|
|
67
|
+
const t = e.getActiveObject();
|
|
68
|
+
if (t && t instanceof u.Rect) {
|
|
69
|
+
if (i().has(t)) {
|
|
70
|
+
e.discardActiveObject(), e.renderAll();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const l = e.getZoom(), d = A / l;
|
|
74
|
+
t.set({
|
|
64
75
|
hasRotatingPoint: !1,
|
|
65
76
|
lockRotation: !0,
|
|
66
77
|
lockUniScaling: !1,
|
|
67
78
|
// 允许非等比缩放,控制点跟随鼠标
|
|
68
|
-
fill:
|
|
79
|
+
fill: L,
|
|
69
80
|
// 选中时添加填充色
|
|
70
81
|
strokeUniform: !0,
|
|
71
82
|
// 确保边框宽度不受缩放影响
|
|
72
|
-
strokeWidth:
|
|
83
|
+
strokeWidth: d,
|
|
73
84
|
// 确保边框宽度一致
|
|
74
85
|
objectCaching: !1,
|
|
75
86
|
// 禁用缓存,避免缩放时边框变虚
|
|
@@ -77,26 +88,26 @@ const L = ({
|
|
|
77
88
|
noScaleCache: !1,
|
|
78
89
|
cornerStyle: "circle",
|
|
79
90
|
// 设置控制点为圆形
|
|
80
|
-
cornerColor:
|
|
91
|
+
cornerColor: R,
|
|
81
92
|
// 设置控制点为紫色(填充色)
|
|
82
93
|
cornerSize: S,
|
|
83
94
|
// 设置控制点大小(默认12,这里设置为6使其更小)
|
|
84
95
|
transparentCorners: !1
|
|
85
96
|
// 不透明,显示填充颜色
|
|
86
97
|
});
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
98
|
+
const c = t;
|
|
99
|
+
c.uniformScaling = !1, t.controls && t.controls.mtr && delete t.controls.mtr, t.controls.deleteControl || (t.controls.deleteControl = n()), e.renderAll();
|
|
100
|
+
const m = s.current.get(t);
|
|
101
|
+
m && o && o(m);
|
|
91
102
|
}
|
|
92
|
-
},
|
|
93
|
-
|
|
103
|
+
}, O = () => {
|
|
104
|
+
f(), e.renderAll(), o && o(null);
|
|
94
105
|
};
|
|
95
|
-
return
|
|
96
|
-
|
|
106
|
+
return e.on("selection:created", h), e.on("selection:updated", C), e.on("selection:cleared", O), () => {
|
|
107
|
+
e.off("selection:created", h), e.off("selection:updated", C), e.off("selection:cleared", O);
|
|
97
108
|
};
|
|
98
|
-
}, [
|
|
109
|
+
}, [e, o, n, a, s]);
|
|
99
110
|
};
|
|
100
111
|
export {
|
|
101
|
-
|
|
112
|
+
j as useRegionSelection
|
|
102
113
|
};
|