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