@labelbee/lb-annotation 1.14.0-alpha.3 → 1.14.0-alpha.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.
Files changed (189) hide show
  1. package/dist/_virtual/MathUtilsWorker.js +1 -8
  2. package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -35
  3. package/dist/_virtual/filterBoxWorker.js +1 -8
  4. package/dist/_virtual/highlightWorker.js +1 -8
  5. package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -5
  6. package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -5
  7. package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -5
  8. package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -5
  9. package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -5
  10. package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -5
  11. package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -5
  12. package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -5
  13. package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -5
  14. package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -5
  15. package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
  16. package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -5
  17. package/dist/assets/attributeIcon/icon_cuboidMore.svg.js +5 -5
  18. package/dist/assets/attributeIcon/icon_cuboidRight.svg.js +5 -5
  19. package/dist/assets/attributeIcon/icon_cuboidTop.svg.js +12 -5
  20. package/dist/assets/attributeIcon/icon_editFEN.svg.js +1 -5
  21. package/dist/assets/attributeIcon/icon_editHUANG.svg.js +1 -5
  22. package/dist/assets/attributeIcon/icon_editLAN.svg.js +1 -5
  23. package/dist/assets/attributeIcon/icon_editLV.svg.js +1 -5
  24. package/dist/assets/attributeIcon/icon_editQING.svg.js +1 -5
  25. package/dist/constant/annotation.js +1 -127
  26. package/dist/constant/annotationTask.js +1 -30
  27. package/dist/constant/defaultConfig.js +1 -266
  28. package/dist/constant/keyCode.js +1 -38
  29. package/dist/constant/style.js +1 -98
  30. package/dist/constant/tool.js +1 -236
  31. package/dist/core/index.js +1 -150
  32. package/dist/core/pointCloud/OrbitControls.js +1 -665
  33. package/dist/core/pointCloud/PCDLoader.js +2 -260
  34. package/dist/core/pointCloud/annotation.js +1 -215
  35. package/dist/core/pointCloud/cache.js +1 -53
  36. package/dist/core/pointCloud/index.js +5 -991
  37. package/dist/core/pointCloud/matrix.js +1 -138
  38. package/dist/core/scheduler.js +1 -233
  39. package/dist/core/toolOperation/LineToolOperation.js +1 -1434
  40. package/dist/core/toolOperation/ScribbleTool.js +1 -292
  41. package/dist/core/toolOperation/TextToolOperation.js +1 -131
  42. package/dist/core/toolOperation/ViewOperation.js +1 -556
  43. package/dist/core/toolOperation/basicToolOperation.js +1 -881
  44. package/dist/core/toolOperation/checkOperation.js +1 -208
  45. package/dist/core/toolOperation/cuboidOperation.js +1 -754
  46. package/dist/core/toolOperation/cuboidToggleButtonClass.js +7 -152
  47. package/dist/core/toolOperation/eventListener.js +1 -37
  48. package/dist/core/toolOperation/measureOperation.js +1 -41
  49. package/dist/core/toolOperation/pointCloud2dOperation.js +1 -365
  50. package/dist/core/toolOperation/pointOperation.js +1 -696
  51. package/dist/core/toolOperation/polygonOperation.js +1 -1251
  52. package/dist/core/toolOperation/rectOperation.js +1 -1233
  53. package/dist/core/toolOperation/segmentByRect.js +1 -174
  54. package/dist/core/toolOperation/tagOperation.js +3 -201
  55. package/dist/core/toolOperation/textAttributeClass.js +16 -182
  56. package/dist/index.js +1 -185
  57. package/dist/locales/constants.js +1 -24
  58. package/dist/locales/en_US/message.js +1 -25
  59. package/dist/locales/index.js +1 -19
  60. package/dist/locales/zh_CN/message.js +1 -25
  61. package/dist/newCore/CanvasScheduler.js +1 -35
  62. package/dist/types/core/pointCloud/index.d.ts +2 -2
  63. package/dist/utils/ActionsHistory.js +1 -84
  64. package/dist/utils/ImgUtils.js +1 -23
  65. package/dist/utils/MathUtils.js +2 -385
  66. package/dist/utils/VectorUtils.js +1 -25
  67. package/dist/utils/tool/AttributeUtils.js +1 -218
  68. package/dist/utils/tool/AxisUtils.js +1 -340
  69. package/dist/utils/tool/CanvasUtils.js +1 -62
  70. package/dist/utils/tool/CommonToolUtils.js +1 -174
  71. package/dist/utils/tool/CuboidUtils.js +1 -704
  72. package/dist/utils/tool/DblClickEventListener.js +1 -102
  73. package/dist/utils/tool/DrawUtils.js +3 -492
  74. package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -53
  75. package/dist/utils/tool/ImgPosUtils.js +1 -58
  76. package/dist/utils/tool/LineToolUtils.js +1 -261
  77. package/dist/utils/tool/MarkerUtils.js +1 -56
  78. package/dist/utils/tool/PolygonUtils.js +1 -460
  79. package/dist/utils/tool/RectUtils.js +1 -155
  80. package/dist/utils/tool/RenderDomClass.js +7 -57
  81. package/dist/utils/tool/RenderDomUtils.js +4 -21
  82. package/dist/utils/tool/StyleUtils.js +1 -31
  83. package/dist/utils/tool/TagUtils.js +1 -129
  84. package/dist/utils/tool/UnitUtils.js +1 -12
  85. package/dist/utils/tool/ZoomUtils.js +1 -72
  86. package/dist/utils/tool/polygonTool.js +1 -133
  87. package/dist/utils/uuid.js +1 -26
  88. package/es/_virtual/MathUtilsWorker.js +1 -6
  89. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -31
  90. package/es/_virtual/filterBoxWorker.js +1 -6
  91. package/es/_virtual/highlightWorker.js +1 -6
  92. package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -3
  93. package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -3
  94. package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -3
  95. package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -3
  96. package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -3
  97. package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -3
  98. package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -3
  99. package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -3
  100. package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -3
  101. package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -3
  102. package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -3
  103. package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -3
  104. package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -3
  105. package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -3
  106. package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -3
  107. package/es/assets/attributeIcon/icon_editFEN.svg.js +1 -3
  108. package/es/assets/attributeIcon/icon_editHUANG.svg.js +1 -3
  109. package/es/assets/attributeIcon/icon_editLAN.svg.js +1 -3
  110. package/es/assets/attributeIcon/icon_editLV.svg.js +1 -3
  111. package/es/assets/attributeIcon/icon_editQING.svg.js +1 -3
  112. package/es/constant/annotation.js +1 -113
  113. package/es/constant/annotationTask.js +1 -25
  114. package/es/constant/defaultConfig.js +1 -260
  115. package/es/constant/keyCode.js +1 -36
  116. package/es/constant/style.js +1 -74
  117. package/es/constant/tool.js +1 -220
  118. package/es/core/index.js +1 -148
  119. package/es/core/pointCloud/OrbitControls.js +1 -661
  120. package/es/core/pointCloud/PCDLoader.js +2 -256
  121. package/es/core/pointCloud/annotation.js +1 -211
  122. package/es/core/pointCloud/cache.js +1 -49
  123. package/es/core/pointCloud/index.js +5 -962
  124. package/es/core/pointCloud/matrix.js +1 -109
  125. package/es/core/scheduler.js +1 -228
  126. package/es/core/toolOperation/LineToolOperation.js +1 -1421
  127. package/es/core/toolOperation/ScribbleTool.js +1 -290
  128. package/es/core/toolOperation/TextToolOperation.js +1 -129
  129. package/es/core/toolOperation/ViewOperation.js +1 -549
  130. package/es/core/toolOperation/basicToolOperation.js +1 -877
  131. package/es/core/toolOperation/checkOperation.js +1 -206
  132. package/es/core/toolOperation/cuboidOperation.js +1 -752
  133. package/es/core/toolOperation/cuboidToggleButtonClass.js +7 -150
  134. package/es/core/toolOperation/eventListener.js +1 -35
  135. package/es/core/toolOperation/measureOperation.js +1 -39
  136. package/es/core/toolOperation/pointCloud2dOperation.js +1 -359
  137. package/es/core/toolOperation/pointOperation.js +1 -690
  138. package/es/core/toolOperation/polygonOperation.js +1 -1245
  139. package/es/core/toolOperation/rectOperation.js +1 -1228
  140. package/es/core/toolOperation/segmentByRect.js +1 -172
  141. package/es/core/toolOperation/tagOperation.js +3 -199
  142. package/es/core/toolOperation/textAttributeClass.js +16 -180
  143. package/es/index.js +1 -46
  144. package/es/locales/constants.js +1 -22
  145. package/es/locales/en_US/message.js +1 -23
  146. package/es/locales/index.js +1 -17
  147. package/es/locales/zh_CN/message.js +1 -23
  148. package/es/newCore/CanvasScheduler.js +1 -31
  149. package/es/utils/ActionsHistory.js +1 -78
  150. package/es/utils/ImgUtils.js +1 -21
  151. package/es/utils/MathUtils.js +2 -380
  152. package/es/utils/VectorUtils.js +1 -23
  153. package/es/utils/tool/AttributeUtils.js +1 -212
  154. package/es/utils/tool/AxisUtils.js +1 -335
  155. package/es/utils/tool/CanvasUtils.js +1 -60
  156. package/es/utils/tool/CommonToolUtils.js +1 -172
  157. package/es/utils/tool/CuboidUtils.js +1 -680
  158. package/es/utils/tool/DblClickEventListener.js +1 -100
  159. package/es/utils/tool/DrawUtils.js +3 -490
  160. package/es/utils/tool/EnhanceCommonToolUtils.js +1 -48
  161. package/es/utils/tool/ImgPosUtils.js +1 -56
  162. package/es/utils/tool/LineToolUtils.js +1 -255
  163. package/es/utils/tool/MarkerUtils.js +1 -54
  164. package/es/utils/tool/PolygonUtils.js +1 -458
  165. package/es/utils/tool/RectUtils.js +1 -153
  166. package/es/utils/tool/RenderDomClass.js +7 -55
  167. package/es/utils/tool/RenderDomUtils.js +4 -19
  168. package/es/utils/tool/StyleUtils.js +1 -29
  169. package/es/utils/tool/TagUtils.js +1 -127
  170. package/es/utils/tool/UnitUtils.js +1 -10
  171. package/es/utils/tool/ZoomUtils.js +1 -70
  172. package/es/utils/tool/polygonTool.js +1 -126
  173. package/es/utils/uuid.js +1 -24
  174. package/package.json +3 -4
  175. package/LICENSE +0 -203
  176. package/dist/core/pointCloud/segmentation.js +0 -144
  177. package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +0 -26
  178. package/dist/core/pointCloud/selector/Sse3dSelector.js +0 -16
  179. package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
  180. package/dist/types/core/pointCloud/selector/Sse3dLassoSelector.d.ts +0 -0
  181. package/dist/types/core/pointCloud/selector/Sse3dSelector.d.ts +0 -0
  182. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -12
  183. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -7
  184. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
  185. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -18
  186. package/es/core/pointCloud/segmentation.js +0 -120
  187. package/es/core/pointCloud/selector/Sse3dLassoSelector.js +0 -24
  188. package/es/core/pointCloud/selector/Sse3dSelector.js +0 -14
  189. package/es/core/toolOperation/scribbleTool2.js +0 -249
@@ -1,340 +1 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var tool = require('../../constant/tool.js');
6
- var MathUtils = require('../MathUtils.js');
7
- var PolygonUtils = require('./PolygonUtils.js');
8
- var LineToolUtils = require('./LineToolUtils.js');
9
- var CuboidUtils = require('./CuboidUtils.js');
10
-
11
- var __defProp = Object.defineProperty;
12
- var __defProps = Object.defineProperties;
13
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
14
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
17
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
18
- var __spreadValues = (a, b) => {
19
- for (var prop in b || (b = {}))
20
- if (__hasOwnProp.call(b, prop))
21
- __defNormalProp(a, prop, b[prop]);
22
- if (__getOwnPropSymbols)
23
- for (var prop of __getOwnPropSymbols(b)) {
24
- if (__propIsEnum.call(b, prop))
25
- __defNormalProp(a, prop, b[prop]);
26
- }
27
- return a;
28
- };
29
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
30
- class AxisUtils {
31
- static getOffsetCoordinate(coordinate, currentPos, zoom) {
32
- return {
33
- x: coordinate.x * zoom + currentPos.x,
34
- y: coordinate.y * zoom + currentPos.y
35
- };
36
- }
37
- static changeDrawOutsideTarget(coord, currentPos, imgInfo, drawOutsideTarget, basicResult, zoom) {
38
- if (typeof drawOutsideTarget === "boolean" && !drawOutsideTarget) {
39
- if (basicResult && zoom) {
40
- if (coord.x - currentPos.x > (basicResult.x + basicResult.width) * zoom) {
41
- coord.x = (basicResult.x + basicResult.width) * zoom + currentPos.x;
42
- }
43
- if (coord.x - currentPos.x < basicResult.x * zoom) {
44
- coord.x = basicResult.x * zoom + currentPos.x;
45
- }
46
- if (coord.y - currentPos.y > (basicResult.y + basicResult.height) * zoom) {
47
- coord.y = (basicResult.y + basicResult.height) * zoom + currentPos.y;
48
- }
49
- if (coord.y - currentPos.y < basicResult.y * zoom) {
50
- coord.y = basicResult.y * zoom + currentPos.y;
51
- }
52
- } else {
53
- if (coord.x - currentPos.x > imgInfo.width) {
54
- coord.x = imgInfo.width + currentPos.x;
55
- }
56
- if (coord.x - currentPos.x < 0) {
57
- coord.x = currentPos.x;
58
- }
59
- if (coord.y - currentPos.y > imgInfo.height) {
60
- coord.y = imgInfo.height + currentPos.y;
61
- }
62
- if (coord.y - currentPos.y < 0) {
63
- coord.y = currentPos.y;
64
- }
65
- }
66
- }
67
- return coord;
68
- }
69
- static changeCoordinateByRotate(coordinate, rotate, imgSize) {
70
- const {width, height} = imgSize;
71
- const {x, y} = coordinate;
72
- switch (rotate % 360) {
73
- case 90:
74
- return {
75
- x: height - y,
76
- y: x
77
- };
78
- case 180:
79
- return {
80
- x: width - x,
81
- y: height - y
82
- };
83
- case 270:
84
- return {
85
- x: y,
86
- y: width - x
87
- };
88
- default:
89
- return coordinate;
90
- }
91
- }
92
- static changeRectByZoom(rect, zoom, currentPos = {x: 0, y: 0}) {
93
- return __spreadProps(__spreadValues({}, rect), {
94
- x: rect.x * zoom + currentPos.x,
95
- y: rect.y * zoom + currentPos.y,
96
- width: rect.width * zoom,
97
- height: rect.height * zoom
98
- });
99
- }
100
- static changePointByZoom(point, zoom, currentPos = {x: 0, y: 0}) {
101
- return __spreadProps(__spreadValues({}, point), {
102
- x: point.x * zoom + currentPos.x,
103
- y: point.y * zoom + currentPos.y
104
- });
105
- }
106
- static changePointListByZoom(pointList, zoom, currentPos = {x: 0, y: 0}) {
107
- return pointList == null ? void 0 : pointList.map((point) => {
108
- return this.changePointByZoom(point, zoom, currentPos);
109
- });
110
- }
111
- static changePlanePointByZoom(planePoints, zoom, currentPos = {x: 0, y: 0}) {
112
- return Object.entries(planePoints).reduce((acc, [key, coord]) => {
113
- const newCoord = AxisUtils.changePointByZoom(coord, zoom, currentPos);
114
- return __spreadProps(__spreadValues({}, acc), {
115
- [key]: newCoord
116
- });
117
- }, {});
118
- }
119
- static changeCuboidByZoom(cuboid, zoom, currentPos = {x: 0, y: 0}) {
120
- return __spreadProps(__spreadValues({}, cuboid), {
121
- frontPoints: this.changePlanePointByZoom(cuboid.frontPoints, zoom, currentPos),
122
- backPoints: cuboid.backPoints ? this.changePlanePointByZoom(cuboid.backPoints, zoom, currentPos) : cuboid.backPoints
123
- });
124
- }
125
- static transformPlain2PointList({tl, tr, br, bl}) {
126
- return [tl, tr, br, bl];
127
- }
128
- static axisArea(axis, radius = 3) {
129
- const {x, y} = axis;
130
- const axisArray = [];
131
- for (let cX = x - radius; cX < x + radius; cX += radius / 3) {
132
- for (let cY = y - radius; cY < y + radius; cY += radius / 3) {
133
- axisArray.push({x: cX, y: cY});
134
- }
135
- }
136
- return axisArray;
137
- }
138
- static getOriginCoordinateWithOffsetCoordinate(coord, zoom = 1, currentPos = {
139
- x: 0,
140
- y: 0
141
- }) {
142
- return {
143
- x: (coord.x - currentPos.x) / zoom,
144
- y: (coord.y - currentPos.y) / zoom
145
- };
146
- }
147
- static returnClosePointIndex(checkPoint, polygonPoints, scope = 3) {
148
- let pointIndex = -1;
149
- for (let i = 0; i < polygonPoints.length; i++) {
150
- const data = polygonPoints[i];
151
- if (this.getIsInScope(checkPoint, data, scope)) {
152
- pointIndex = i;
153
- }
154
- }
155
- return pointIndex;
156
- }
157
- static isCloseCuboid(checkPoint, cuboid, options = {scope: 5, zoom: 1}) {
158
- const points = CuboidUtils.getHighlightPoints(cuboid);
159
- const {scope = 5} = options;
160
- for (let i = 0; i < points.length; i++) {
161
- const pointData = points[i];
162
- if (this.getIsInScope(checkPoint, pointData.point, scope)) {
163
- return true;
164
- }
165
- }
166
- const lines = CuboidUtils.getHighlightLines(cuboid);
167
- for (let i = 0; i < lines.length; i++) {
168
- const line = lines[i];
169
- const {length} = MathUtils["default"].getFootOfPerpendicular(checkPoint, line.p1, line.p2, true);
170
- if (length < scope) {
171
- return true;
172
- }
173
- }
174
- if (PolygonUtils.isInPolygon(checkPoint, CuboidUtils.getCuboidHoverRange(cuboid))) {
175
- return true;
176
- }
177
- return false;
178
- }
179
- static isCloseCuboidList(checkPoint, cuboidList, options = {scope: 5, zoom: 1}) {
180
- return cuboidList.some((cuboid) => this.isCloseCuboid(checkPoint, cuboid, options));
181
- }
182
- static returnClosePointOrLineInCuboid(checkPoint, cuboid, options = {scope: 5, zoom: 1}) {
183
- const points = CuboidUtils.getHighlightPoints(cuboid);
184
- const {scope = 5, zoom = 1} = options;
185
- for (let i = 0; i < points.length; i++) {
186
- const pointData = points[i];
187
- if (this.getIsInScope(checkPoint, pointData.point, scope)) {
188
- return [
189
- {
190
- type: "point",
191
- points: [this.changePointByZoom(points[i].point, zoom)],
192
- originCuboid: cuboid,
193
- positions: pointData.positions
194
- }
195
- ];
196
- }
197
- }
198
- let minLength = scope;
199
- const lines = CuboidUtils.getHighlightLines(cuboid);
200
- let linePoints;
201
- for (let i = 0; i < lines.length; i++) {
202
- const line = lines[i];
203
- const {length} = MathUtils["default"].getFootOfPerpendicular(checkPoint, line.p1, line.p2, true);
204
- if (length < minLength) {
205
- minLength = length;
206
- linePoints = [
207
- {
208
- type: "line",
209
- points: this.changePointListByZoom([line.p1, line.p2], zoom),
210
- originCuboid: cuboid,
211
- positions: line.positions
212
- }
213
- ];
214
- }
215
- }
216
- if (linePoints) {
217
- return linePoints;
218
- }
219
- }
220
- static getIsInScope(currentCoord, targetCoord, scope) {
221
- if (Math.abs(currentCoord.x - targetCoord.x) < scope && Math.abs(currentCoord.y - targetCoord.y) < scope) {
222
- return true;
223
- }
224
- return false;
225
- }
226
- }
227
- class CoordinateUtils {
228
- constructor(props) {
229
- this.currentPos = props.currentPos;
230
- this.zoom = props.zoom;
231
- this.basicImgInfo = props.basicImgInfo;
232
- this.dependToolName = "";
233
- }
234
- get isDependPolygon() {
235
- return this.dependToolName === tool.EToolName.Polygon;
236
- }
237
- get isDependRect() {
238
- return this.dependToolName === tool.EToolName.Rect;
239
- }
240
- get isDependOriginalImage() {
241
- return this.dependToolName === "";
242
- }
243
- getAbsCoord(renderCoord) {
244
- return {
245
- x: (renderCoord.x - this.currentPos.x) / this.zoom,
246
- y: (renderCoord.y - this.currentPos.y) / this.zoom
247
- };
248
- }
249
- getRenderCoord(absCoord) {
250
- return {
251
- x: absCoord.x * this.zoom + this.currentPos.x,
252
- y: absCoord.y * this.zoom + this.currentPos.y
253
- };
254
- }
255
- coordInsideRect(absCoord, rect) {
256
- const {x, y, width, height} = rect;
257
- return {
258
- x: MathUtils["default"].withinRange(absCoord.x, [x, x + width]),
259
- y: MathUtils["default"].withinRange(absCoord.y, [y, y + height])
260
- };
261
- }
262
- getPolygonPointList(lineType, pointList) {
263
- return lineType === tool.ELineTypes.Curve ? PolygonUtils.createSmoothCurvePointsFromPointList(pointList) : pointList;
264
- }
265
- getIntersection(curCoord, preCoord, polygonPointListToLineList) {
266
- const pointA = this.getRenderCoord(preCoord);
267
- const pointB = this.getRenderCoord(curCoord);
268
- const drawingLine = {
269
- pointA,
270
- pointB
271
- };
272
- const intersection = LineToolUtils["default"].calcOptimalIntersection(polygonPointListToLineList, drawingLine, pointA, LineToolUtils.POINT_RADIUS, this.zoom);
273
- return intersection;
274
- }
275
- coordInsidePolygon(curCoord, preCoord, polygon, polygonToolConfig) {
276
- const {pointList} = polygon;
277
- const lineType = polygonToolConfig == null ? void 0 : polygonToolConfig.lineType;
278
- if (pointList.length === 0) {
279
- return curCoord;
280
- }
281
- const polygonPointList = this.getPolygonPointList(lineType, pointList);
282
- const isInPolygon = PolygonUtils.isInPolygon(curCoord, polygonPointList);
283
- if (isInPolygon) {
284
- return curCoord;
285
- }
286
- const polygonPointListToLineList = polygonPointList.concat(polygonPointList[0]).map((i) => this.getRenderCoord(i));
287
- const intersection = this.getIntersection(curCoord, preCoord, polygonPointListToLineList);
288
- if (intersection) {
289
- return this.getAbsCoord(intersection == null ? void 0 : intersection.point);
290
- }
291
- return curCoord;
292
- }
293
- coordInsideImage(coord) {
294
- return this.coordInsideRect(coord, __spreadProps(__spreadValues({}, this.basicImgInfo), {x: 0, y: 0}));
295
- }
296
- getNextCoordByDependTool(curAbsCoord, preAbsCoord) {
297
- if (this.isDependRect) {
298
- return this.coordInsideRect(curAbsCoord, this.basicResult);
299
- }
300
- if (this.isDependPolygon) {
301
- return this.coordInsidePolygon(curAbsCoord, preAbsCoord, this.basicResult, this.dependToolConfig);
302
- }
303
- if (this.isDependOriginalImage) {
304
- return this.coordInsideImage(curAbsCoord);
305
- }
306
- }
307
- setDependInfo(dependToolName, dependToolConfig) {
308
- this.dependToolName = dependToolName != null ? dependToolName : "";
309
- this.dependToolConfig = dependToolName ? dependToolConfig : void 0;
310
- }
311
- setBasicImgInfo(basicImgInfo) {
312
- this.basicImgInfo = basicImgInfo;
313
- }
314
- setBasicResult(basicResult) {
315
- this.basicResult = basicResult;
316
- }
317
- setZoomAndCurrentPos(zoom, currentPos) {
318
- this.zoom = zoom;
319
- this.currentPos = currentPos;
320
- }
321
- isCoordInsideTarget(coord) {
322
- if (this.isDependPolygon) {
323
- return this.isInBasicPolygon(coord);
324
- }
325
- if (this.isDependRect) {
326
- const {x, y, width, height} = this.basicResult;
327
- const rectHorizontalRange = [x, x + width];
328
- const rectVerticalRange = [y, y + height];
329
- return MathUtils["default"].isInRange(coord.x, rectHorizontalRange) && MathUtils["default"].isInRange(coord.y, rectVerticalRange);
330
- }
331
- return MathUtils["default"].isInRange(coord.x, [0, this.basicImgInfo.width]) && MathUtils["default"].isInRange(coord.y, [0, this.basicImgInfo.height]);
332
- }
333
- isInBasicPolygon(coord) {
334
- var _a, _b;
335
- return PolygonUtils.isInPolygon(coord, ((_a = this.basicResult) == null ? void 0 : _a.pointList) || [], (_b = this.dependToolConfig) == null ? void 0 : _b.lineType);
336
- }
337
- }
338
-
339
- exports.CoordinateUtils = CoordinateUtils;
340
- exports["default"] = AxisUtils;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),MathUtils=require("../MathUtils.js"),PolygonUtils=require("./PolygonUtils.js"),LineToolUtils=require("./LineToolUtils.js"),CuboidUtils=require("./CuboidUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(h,t,e)=>t in h?__defProp(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e,__spreadValues=(h,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(h,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(h,e,t[e]);return h},__spreadProps=(h,t)=>__defProps(h,__getOwnPropDescs(t));class AxisUtils{static getOffsetCoordinate(t,e,i){return{x:t.x*i+e.x,y:t.y*i+e.y}}static changeDrawOutsideTarget(t,e,i,s,n,o){return typeof s=="boolean"&&!s&&(n&&o?(t.x-e.x>(n.x+n.width)*o&&(t.x=(n.x+n.width)*o+e.x),t.x-e.x<n.x*o&&(t.x=n.x*o+e.x),t.y-e.y>(n.y+n.height)*o&&(t.y=(n.y+n.height)*o+e.y),t.y-e.y<n.y*o&&(t.y=n.y*o+e.y)):(t.x-e.x>i.width&&(t.x=i.width+e.x),t.x-e.x<0&&(t.x=e.x),t.y-e.y>i.height&&(t.y=i.height+e.y),t.y-e.y<0&&(t.y=e.y))),t}static changeCoordinateByRotate(t,e,i){const{width:s,height:n}=i,{x:o,y:r}=t;switch(e%360){case 90:return{x:n-r,y:o};case 180:return{x:s-o,y:n-r};case 270:return{x:r,y:s-o};default:return t}}static changeRectByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y,width:t.width*e,height:t.height*e})}static changePointByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{x:t.x*e+i.x,y:t.y*e+i.y})}static changePointListByZoom(t,e,i={x:0,y:0}){return t==null?void 0:t.map(s=>this.changePointByZoom(s,e,i))}static changePlanePointByZoom(t,e,i={x:0,y:0}){return Object.entries(t).reduce((s,[n,o])=>{const r=AxisUtils.changePointByZoom(o,e,i);return __spreadProps(__spreadValues({},s),{[n]:r})},{})}static changeCuboidByZoom(t,e,i={x:0,y:0}){return __spreadProps(__spreadValues({},t),{frontPoints:this.changePlanePointByZoom(t.frontPoints,e,i),backPoints:t.backPoints?this.changePlanePointByZoom(t.backPoints,e,i):t.backPoints})}static transformPlain2PointList({tl:t,tr:e,br:i,bl:s}){return[t,e,i,s]}static axisArea(t,e=3){const{x:i,y:s}=t,n=[];for(let o=i-e;o<i+e;o+=e/3)for(let r=s-e;r<s+e;r+=e/3)n.push({x:o,y:r});return n}static getOriginCoordinateWithOffsetCoordinate(t,e=1,i={x:0,y:0}){return{x:(t.x-i.x)/e,y:(t.y-i.y)/e}}static returnClosePointIndex(t,e,i=3){let s=-1;for(let n=0;n<e.length;n++){const o=e[n];this.getIsInScope(t,o,i)&&(s=n)}return s}static isCloseCuboid(t,e,i={scope:5,zoom:1}){const s=CuboidUtils.getHighlightPoints(e),{scope:n=5}=i;for(let r=0;r<s.length;r++){const g=s[r];if(this.getIsInScope(t,g.point,n))return!0}const o=CuboidUtils.getHighlightLines(e);for(let r=0;r<o.length;r++){const g=o[r],{length:y}=MathUtils.default.getFootOfPerpendicular(t,g.p1,g.p2,!0);if(y<n)return!0}return!!PolygonUtils.isInPolygon(t,CuboidUtils.getCuboidHoverRange(e))}static isCloseCuboidList(t,e,i={scope:5,zoom:1}){return e.some(s=>this.isCloseCuboid(t,s,i))}static returnClosePointOrLineInCuboid(t,e,i={scope:5,zoom:1}){const s=CuboidUtils.getHighlightPoints(e),{scope:n=5,zoom:o=1}=i;for(let a=0;a<s.length;a++){const l=s[a];if(this.getIsInScope(t,l.point,n))return[{type:"point",points:[this.changePointByZoom(s[a].point,o)],originCuboid:e,positions:l.positions}]}let r=n;const g=CuboidUtils.getHighlightLines(e);let y;for(let a=0;a<g.length;a++){const l=g[a],{length:p}=MathUtils.default.getFootOfPerpendicular(t,l.p1,l.p2,!0);p<r&&(r=p,y=[{type:"line",points:this.changePointListByZoom([l.p1,l.p2],o),originCuboid:e,positions:l.positions}])}if(y)return y}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class CoordinateUtils{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===tool.EToolName.Polygon}get isDependRect(){return this.dependToolName===tool.EToolName.Rect}get isDependOriginalImage(){return this.dependToolName===""}getAbsCoord(t){return{x:(t.x-this.currentPos.x)/this.zoom,y:(t.y-this.currentPos.y)/this.zoom}}getRenderCoord(t){return{x:t.x*this.zoom+this.currentPos.x,y:t.y*this.zoom+this.currentPos.y}}coordInsideRect(t,e){const{x:i,y:s,width:n,height:o}=e;return{x:MathUtils.default.withinRange(t.x,[i,i+n]),y:MathUtils.default.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===tool.ELineTypes.Curve?PolygonUtils.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return LineToolUtils.default.calcOptimalIntersection(i,o,s,LineToolUtils.POINT_RADIUS,this.zoom)}coordInsidePolygon(t,e,i,s){const{pointList:n}=i,o=s==null?void 0:s.lineType;if(n.length===0)return t;const r=this.getPolygonPointList(o,n);if(PolygonUtils.isInPolygon(t,r))return t;const y=r.concat(r[0]).map(l=>this.getRenderCoord(l)),a=this.getIntersection(t,e,y);return a?this.getAbsCoord(a==null?void 0:a.point):t}coordInsideImage(t){return this.coordInsideRect(t,__spreadProps(__spreadValues({},this.basicImgInfo),{x:0,y:0}))}getNextCoordByDependTool(t,e){if(this.isDependRect)return this.coordInsideRect(t,this.basicResult);if(this.isDependPolygon)return this.coordInsidePolygon(t,e,this.basicResult,this.dependToolConfig);if(this.isDependOriginalImage)return this.coordInsideImage(t)}setDependInfo(t,e){this.dependToolName=t!=null?t:"",this.dependToolConfig=t?e:void 0}setBasicImgInfo(t){this.basicImgInfo=t}setBasicResult(t){this.basicResult=t}setZoomAndCurrentPos(t,e){this.zoom=t,this.currentPos=e}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],r=[i,i+n];return MathUtils.default.isInRange(t.x,o)&&MathUtils.default.isInRange(t.y,r)}return MathUtils.default.isInRange(t.x,[0,this.basicImgInfo.width])&&MathUtils.default.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return PolygonUtils.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}exports.CoordinateUtils=CoordinateUtils,exports.default=AxisUtils;
@@ -1,62 +1 @@
1
- 'use strict';
2
-
3
- var MathUtils = require('../MathUtils.js');
4
-
5
- class CanvasUtils {
6
- static getMousePositionOnCanvasFromEvent(event, canvas) {
7
- if (canvas && event) {
8
- const canvasRect = canvas.getBoundingClientRect();
9
- return {
10
- x: event.clientX - canvasRect.left,
11
- y: event.clientY - canvasRect.top
12
- };
13
- }
14
- return null;
15
- }
16
- static getClientRect(canvas) {
17
- if (canvas) {
18
- const canvasRect = canvas.getBoundingClientRect();
19
- return {
20
- x: canvasRect.left,
21
- y: canvasRect.top,
22
- width: canvasRect.width,
23
- height: canvasRect.height
24
- };
25
- }
26
- return null;
27
- }
28
- static getSize(canvas) {
29
- if (canvas) {
30
- const canvasRect = canvas.getBoundingClientRect();
31
- return {
32
- width: canvasRect.width,
33
- height: canvasRect.height
34
- };
35
- }
36
- return null;
37
- }
38
- static inViewPort(coord, viewPort) {
39
- if (!coord) {
40
- return false;
41
- }
42
- return MathUtils["default"].isInRange(coord.x, [viewPort.left, viewPort.right]) && MathUtils["default"].isInRange(coord.y, [viewPort.top, viewPort.bottom]);
43
- }
44
- }
45
- CanvasUtils.getViewPort = (canvas, originOffset, zoom) => {
46
- const {width: canvasWidth, height: canvasHeight} = canvas;
47
- const {x, y} = originOffset;
48
- const top = (0 - y) / zoom;
49
- const left = (0 - x) / zoom;
50
- const bottom = top + canvasHeight / zoom;
51
- const right = left + canvasWidth / zoom;
52
- return {top, bottom, left, right};
53
- };
54
- CanvasUtils.getPixelRatio = (context) => {
55
- if (!context || !window) {
56
- return 1;
57
- }
58
- const backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1;
59
- return (window.devicePixelRatio || 1) / backingStore;
60
- };
61
-
62
- module.exports = CanvasUtils;
1
+ "use strict";var MathUtils=require("../MathUtils.js");class CanvasUtils{static getMousePositionOnCanvasFromEvent(i,t){if(t&&i){const n=t.getBoundingClientRect();return{x:i.clientX-n.left,y:i.clientY-n.top}}return null}static getClientRect(i){if(i){const t=i.getBoundingClientRect();return{x:t.left,y:t.top,width:t.width,height:t.height}}return null}static getSize(i){if(i){const t=i.getBoundingClientRect();return{width:t.width,height:t.height}}return null}static inViewPort(i,t){return i?MathUtils.default.isInRange(i.x,[t.left,t.right])&&MathUtils.default.isInRange(i.y,[t.top,t.bottom]):!1}}CanvasUtils.getViewPort=(e,i,t)=>{const{width:n,height:s}=e,{x:l,y:o}=i,a=(0-o)/t,r=(0-l)/t,g=a+s/t,c=r+n/t;return{top:a,bottom:g,left:r,right:c}},CanvasUtils.getPixelRatio=e=>{if(!e||!window)return 1;const i=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/i},module.exports=CanvasUtils;
@@ -1,174 +1 @@
1
- 'use strict';
2
-
3
- var _ = require('lodash');
4
- var annotation = require('../../constant/annotation.js');
5
-
6
- var __defProp = Object.defineProperty;
7
- var __defProps = Object.defineProperties;
8
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
- var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
- class CommonToolUtils {
26
- static getStepInfo(step, stepList) {
27
- return stepList == null ? void 0 : stepList.filter((info) => info.step === step)[0];
28
- }
29
- static getCurrentStepInfo(currentStep, stepList) {
30
- const currentStepInfo = this.getStepInfo(currentStep, stepList);
31
- if (currentStepInfo) {
32
- if (currentStepInfo.type === annotation.EStepType.QUALITY_INSPECTION || currentStepInfo.type === annotation.EStepType.MANUAL_CORRECTION) {
33
- return this.getCurrentStepInfo(currentStepInfo.dataSourceStep, stepList);
34
- }
35
- }
36
- return currentStepInfo;
37
- }
38
- static getMaxOrder(result) {
39
- let order = 0;
40
- result.forEach((v) => {
41
- if (v.order && v.order > order) {
42
- order = v.order;
43
- }
44
- });
45
- return order;
46
- }
47
- static hotkeyFilter(event) {
48
- const target = event.target || event.srcElement;
49
- if (!target) {
50
- return true;
51
- }
52
- const {tagName, type} = target;
53
- if (!tagName || !type) {
54
- return true;
55
- }
56
- let flag = true;
57
- if (target.isContentEditable || tagName === "TEXTAREA" || (tagName === "INPUT" && type !== "radio" || tagName === "TEXTAREA") && !target.readOnly) {
58
- flag = false;
59
- }
60
- return flag;
61
- }
62
- static getNextSelectedRectID(rectList, sort = annotation.ESortDirection.ascend, selectedID) {
63
- let sign = 1;
64
- if (sort === annotation.ESortDirection.descend) {
65
- sign = -1;
66
- }
67
- const sortRectList = rectList.sort((a, b) => {
68
- if (a.x - b.x === 0) {
69
- return a.y - b.y;
70
- }
71
- return sign * (a.x - b.x);
72
- });
73
- const i = sortRectList.findIndex((v) => v.id === selectedID);
74
- const len = sortRectList.length;
75
- return sortRectList[(i + 1) % len];
76
- }
77
- static getNextSelectedRectIDByEvent(pointList, event, selectedID) {
78
- const sortDirection = event.shiftKey ? annotation.ESortDirection.descend : annotation.ESortDirection.ascend;
79
- return this.getNextSelectedRectID(pointList, sortDirection, selectedID);
80
- }
81
- static getRenderResultList(resultList, sourceID, attributeLockList = [], selectedID) {
82
- let selectedRect;
83
- const showingRect = resultList.filter((result) => {
84
- if (selectedID && selectedID === (result == null ? void 0 : result.id)) {
85
- selectedRect = result;
86
- return false;
87
- }
88
- if (attributeLockList.length > 0 && !attributeLockList.includes(result == null ? void 0 : result.attribute)) {
89
- return false;
90
- }
91
- if (this.isDifferSourceID(result == null ? void 0 : result.sourceID, sourceID)) {
92
- return false;
93
- }
94
- return true;
95
- });
96
- return [showingRect, selectedRect];
97
- }
98
- static getSourceID(basicResult) {
99
- var _a;
100
- const defaultSourceID = "";
101
- if (basicResult) {
102
- return (_a = basicResult == null ? void 0 : basicResult.id) != null ? _a : defaultSourceID;
103
- }
104
- return defaultSourceID;
105
- }
106
- static findAllLine(pointList, isClose = true) {
107
- const arr = [];
108
- const newPoint = [...pointList];
109
- if (newPoint.length >= 3 && isClose === true) {
110
- newPoint.push(__spreadValues({}, newPoint[0]));
111
- }
112
- for (let i = 0; i < newPoint.length; i++) {
113
- if (newPoint[i + 1]) {
114
- arr.push({
115
- point1: newPoint[i],
116
- point2: newPoint[i + 1],
117
- pointIndex: i
118
- });
119
- }
120
- }
121
- return arr;
122
- }
123
- static translateSourceID(sourceID) {
124
- if (sourceID === void 0 || sourceID === 0 || sourceID === "0") {
125
- sourceID = "";
126
- }
127
- return sourceID;
128
- }
129
- static isDifferSourceID(sourceIDA, sourceIDB) {
130
- sourceIDA = this.translateSourceID(sourceIDA);
131
- sourceIDB = this.translateSourceID(sourceIDB);
132
- return `${sourceIDA}` !== `${sourceIDB}`;
133
- }
134
- static isSameSourceID(sourceIDA, sourceIDB) {
135
- sourceIDA = this.translateSourceID(sourceIDA);
136
- sourceIDB = this.translateSourceID(sourceIDB);
137
- return `${sourceIDA}` === `${sourceIDB}`;
138
- }
139
- static getNextMarker(resultList, markerList = [], markerIndex) {
140
- if ((markerList == null ? void 0 : markerList.length) === 0) {
141
- return void 0;
142
- }
143
- let newSortList = markerList.map((data, index) => __spreadProps(__spreadValues({}, data), {index}));
144
- if (typeof markerIndex === "number" && markerIndex > 0) {
145
- const markerInfo = markerList[markerIndex];
146
- if (markerInfo && resultList.every((rect) => rect.label !== markerInfo.value)) {
147
- return {label: markerInfo.value, index: markerIndex};
148
- }
149
- newSortList = [...newSortList.slice(markerIndex, markerList.length), ...newSortList.slice(0, markerIndex)];
150
- }
151
- for (let i = 0; i < newSortList.length; i++) {
152
- if (resultList.some((rect) => rect.label === newSortList[i].value)) {
153
- continue;
154
- }
155
- return {label: newSortList[i].value, index: newSortList[i].index};
156
- }
157
- return void 0;
158
- }
159
- static getCurrentMarkerIndex(label, markerList = []) {
160
- return markerList.findIndex((marker) => label === marker.value);
161
- }
162
- }
163
- CommonToolUtils.jsonParser = (content, defaultValue = {}) => {
164
- try {
165
- if (typeof content === "string") {
166
- return JSON.parse(content);
167
- }
168
- return _.isObject(content) ? content : defaultValue;
169
- } catch (e) {
170
- return defaultValue;
171
- }
172
- };
173
-
174
- module.exports = CommonToolUtils;
1
+ "use strict";var _=require("lodash"),annotation=require("../../constant/annotation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,t,e)=>t in o?__defProp(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,__spreadValues=(o,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(o,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(o,e,t[e]);return o},__spreadProps=(o,t)=>__defProps(o,__getOwnPropDescs(t));class CommonToolUtils{static getStepInfo(t,e){return e==null?void 0:e.filter(r=>r.step===t)[0]}static getCurrentStepInfo(t,e){const r=this.getStepInfo(t,e);return r&&(r.type===annotation.EStepType.QUALITY_INSPECTION||r.type===annotation.EStepType.MANUAL_CORRECTION)?this.getCurrentStepInfo(r.dataSourceStep,e):r}static getMaxOrder(t){let e=0;return t.forEach(r=>{r.order&&r.order>e&&(e=r.order)}),e}static hotkeyFilter(t){const e=t.target||t.srcElement;if(!e)return!0;const{tagName:r,type:i}=e;if(!r||!i)return!0;let n=!0;return(e.isContentEditable||r==="TEXTAREA"||(r==="INPUT"&&i!=="radio"||r==="TEXTAREA")&&!e.readOnly)&&(n=!1),n}static getNextSelectedRectID(t,e=annotation.ESortDirection.ascend,r){let i=1;e===annotation.ESortDirection.descend&&(i=-1);const n=t.sort((s,c)=>s.x-c.x==0?s.y-c.y:i*(s.x-c.x)),l=n.findIndex(s=>s.id===r),a=n.length;return n[(l+1)%a]}static getNextSelectedRectIDByEvent(t,e,r){const i=e.shiftKey?annotation.ESortDirection.descend:annotation.ESortDirection.ascend;return this.getNextSelectedRectID(t,i,r)}static getRenderResultList(t,e,r=[],i){let n;return[t.filter(a=>i&&i===(a==null?void 0:a.id)?(n=a,!1):!(r.length>0&&!r.includes(a==null?void 0:a.attribute)||this.isDifferSourceID(a==null?void 0:a.sourceID,e))),n]}static getSourceID(t){var e;const r="";return t&&(e=t==null?void 0:t.id)!=null?e:r}static findAllLine(t,e=!0){const r=[],i=[...t];i.length>=3&&e===!0&&i.push(__spreadValues({},i[0]));for(let n=0;n<i.length;n++)i[n+1]&&r.push({point1:i[n],point2:i[n+1],pointIndex:n});return r}static translateSourceID(t){return(t===void 0||t===0||t==="0")&&(t=""),t}static isDifferSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`!=`${e}`}static isSameSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`==`${e}`}static getNextMarker(t,e=[],r){if((e==null?void 0:e.length)===0)return;let i=e.map((n,l)=>__spreadProps(__spreadValues({},n),{index:l}));if(typeof r=="number"&&r>0){const n=e[r];if(n&&t.every(l=>l.label!==n.value))return{label:n.value,index:r};i=[...i.slice(r,e.length),...i.slice(0,r)]}for(let n=0;n<i.length;n++)if(!t.some(l=>l.label===i[n].value))return{label:i[n].value,index:i[n].index}}static getCurrentMarkerIndex(t,e=[]){return e.findIndex(r=>t===r.value)}}CommonToolUtils.jsonParser=(o,t={})=>{try{return typeof o=="string"?JSON.parse(o):_.isObject(o)?o:t}catch(e){return t}},module.exports=CommonToolUtils;