@labelbee/lb-annotation 1.14.0-alpha.3 → 1.14.0-alpha.5
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 +1 -8
- package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -35
- package/dist/_virtual/filterBoxWorker.js +1 -8
- package/dist/_virtual/highlightWorker.js +1 -8
- package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -5
- 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 +12 -5
- package/dist/assets/attributeIcon/icon_editFEN.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editHUANG.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editLAN.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editLV.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editQING.svg.js +1 -5
- package/dist/constant/annotation.js +1 -127
- package/dist/constant/annotationTask.js +1 -30
- package/dist/constant/defaultConfig.js +1 -266
- package/dist/constant/keyCode.js +1 -38
- package/dist/constant/style.js +1 -98
- package/dist/constant/tool.js +1 -236
- package/dist/core/index.js +1 -150
- package/dist/core/pointCloud/OrbitControls.js +1 -665
- package/dist/core/pointCloud/PCDLoader.js +2 -260
- package/dist/core/pointCloud/annotation.js +1 -215
- package/dist/core/pointCloud/cache.js +1 -53
- package/dist/core/pointCloud/index.js +5 -991
- package/dist/core/pointCloud/matrix.js +1 -138
- package/dist/core/scheduler.js +1 -233
- package/dist/core/toolOperation/LineToolOperation.js +1 -1434
- package/dist/core/toolOperation/ScribbleTool.js +1 -292
- package/dist/core/toolOperation/TextToolOperation.js +1 -131
- package/dist/core/toolOperation/ViewOperation.js +1 -556
- package/dist/core/toolOperation/basicToolOperation.js +1 -881
- package/dist/core/toolOperation/checkOperation.js +1 -208
- package/dist/core/toolOperation/cuboidOperation.js +1 -754
- package/dist/core/toolOperation/cuboidToggleButtonClass.js +7 -152
- package/dist/core/toolOperation/eventListener.js +1 -37
- package/dist/core/toolOperation/measureOperation.js +1 -41
- package/dist/core/toolOperation/pointCloud2dOperation.js +1 -365
- package/dist/core/toolOperation/pointOperation.js +1 -696
- package/dist/core/toolOperation/polygonOperation.js +1 -1251
- package/dist/core/toolOperation/rectOperation.js +1 -1233
- package/dist/core/toolOperation/segmentByRect.js +1 -174
- package/dist/core/toolOperation/tagOperation.js +3 -201
- package/dist/core/toolOperation/textAttributeClass.js +16 -182
- package/dist/index.js +1 -185
- package/dist/locales/constants.js +1 -24
- package/dist/locales/en_US/message.js +1 -25
- package/dist/locales/index.js +1 -19
- package/dist/locales/zh_CN/message.js +1 -25
- package/dist/newCore/CanvasScheduler.js +1 -35
- package/dist/utils/ActionsHistory.js +1 -84
- package/dist/utils/ImgUtils.js +1 -23
- package/dist/utils/MathUtils.js +2 -385
- package/dist/utils/VectorUtils.js +1 -25
- package/dist/utils/tool/AttributeUtils.js +1 -218
- package/dist/utils/tool/AxisUtils.js +1 -340
- package/dist/utils/tool/CanvasUtils.js +1 -62
- package/dist/utils/tool/CommonToolUtils.js +1 -174
- package/dist/utils/tool/CuboidUtils.js +1 -704
- package/dist/utils/tool/DblClickEventListener.js +1 -102
- package/dist/utils/tool/DrawUtils.js +3 -492
- package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -53
- package/dist/utils/tool/ImgPosUtils.js +1 -58
- package/dist/utils/tool/LineToolUtils.js +1 -261
- package/dist/utils/tool/MarkerUtils.js +1 -56
- package/dist/utils/tool/PolygonUtils.js +1 -460
- package/dist/utils/tool/RectUtils.js +1 -155
- package/dist/utils/tool/RenderDomClass.js +7 -57
- package/dist/utils/tool/RenderDomUtils.js +4 -21
- package/dist/utils/tool/StyleUtils.js +1 -31
- package/dist/utils/tool/TagUtils.js +1 -129
- package/dist/utils/tool/UnitUtils.js +1 -12
- package/dist/utils/tool/ZoomUtils.js +1 -72
- package/dist/utils/tool/polygonTool.js +1 -133
- package/dist/utils/uuid.js +1 -26
- package/es/_virtual/MathUtilsWorker.js +1 -6
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -31
- package/es/_virtual/filterBoxWorker.js +1 -6
- package/es/_virtual/highlightWorker.js +1 -6
- package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -3
- package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -3
- package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -3
- package/es/assets/attributeIcon/icon_editFEN.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editHUANG.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editLAN.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editLV.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editQING.svg.js +1 -3
- package/es/constant/annotation.js +1 -113
- package/es/constant/annotationTask.js +1 -25
- package/es/constant/defaultConfig.js +1 -260
- package/es/constant/keyCode.js +1 -36
- package/es/constant/style.js +1 -74
- package/es/constant/tool.js +1 -220
- package/es/core/index.js +1 -148
- package/es/core/pointCloud/OrbitControls.js +1 -661
- package/es/core/pointCloud/PCDLoader.js +2 -256
- package/es/core/pointCloud/annotation.js +1 -211
- package/es/core/pointCloud/cache.js +1 -49
- package/es/core/pointCloud/index.js +5 -962
- package/es/core/pointCloud/matrix.js +1 -109
- package/es/core/scheduler.js +1 -228
- package/es/core/toolOperation/LineToolOperation.js +1 -1421
- package/es/core/toolOperation/ScribbleTool.js +1 -290
- package/es/core/toolOperation/TextToolOperation.js +1 -129
- package/es/core/toolOperation/ViewOperation.js +1 -549
- package/es/core/toolOperation/basicToolOperation.js +1 -877
- package/es/core/toolOperation/checkOperation.js +1 -206
- package/es/core/toolOperation/cuboidOperation.js +1 -752
- package/es/core/toolOperation/cuboidToggleButtonClass.js +7 -150
- package/es/core/toolOperation/eventListener.js +1 -35
- package/es/core/toolOperation/measureOperation.js +1 -39
- package/es/core/toolOperation/pointCloud2dOperation.js +1 -359
- package/es/core/toolOperation/pointOperation.js +1 -690
- package/es/core/toolOperation/polygonOperation.js +1 -1245
- package/es/core/toolOperation/rectOperation.js +1 -1228
- package/es/core/toolOperation/segmentByRect.js +1 -172
- package/es/core/toolOperation/tagOperation.js +3 -199
- package/es/core/toolOperation/textAttributeClass.js +16 -180
- package/es/index.js +1 -46
- package/es/locales/constants.js +1 -22
- package/es/locales/en_US/message.js +1 -23
- package/es/locales/index.js +1 -17
- package/es/locales/zh_CN/message.js +1 -23
- package/es/newCore/CanvasScheduler.js +1 -31
- package/es/utils/ActionsHistory.js +1 -78
- package/es/utils/ImgUtils.js +1 -21
- package/es/utils/MathUtils.js +2 -380
- package/es/utils/VectorUtils.js +1 -23
- package/es/utils/tool/AttributeUtils.js +1 -212
- package/es/utils/tool/AxisUtils.js +1 -335
- package/es/utils/tool/CanvasUtils.js +1 -60
- package/es/utils/tool/CommonToolUtils.js +1 -172
- package/es/utils/tool/CuboidUtils.js +1 -680
- package/es/utils/tool/DblClickEventListener.js +1 -100
- package/es/utils/tool/DrawUtils.js +3 -490
- package/es/utils/tool/EnhanceCommonToolUtils.js +1 -48
- package/es/utils/tool/ImgPosUtils.js +1 -56
- package/es/utils/tool/LineToolUtils.js +1 -255
- package/es/utils/tool/MarkerUtils.js +1 -54
- package/es/utils/tool/PolygonUtils.js +1 -458
- package/es/utils/tool/RectUtils.js +1 -153
- package/es/utils/tool/RenderDomClass.js +7 -55
- package/es/utils/tool/RenderDomUtils.js +4 -19
- package/es/utils/tool/StyleUtils.js +1 -29
- package/es/utils/tool/TagUtils.js +1 -127
- package/es/utils/tool/UnitUtils.js +1 -10
- package/es/utils/tool/ZoomUtils.js +1 -70
- package/es/utils/tool/polygonTool.js +1 -126
- package/es/utils/uuid.js +1 -24
- package/package.json +3 -4
- package/LICENSE +0 -203
- package/dist/core/pointCloud/segmentation.js +0 -144
- package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +0 -26
- package/dist/core/pointCloud/selector/Sse3dSelector.js +0 -16
- 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/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -12
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -7
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -18
- package/es/core/pointCloud/segmentation.js +0 -120
- package/es/core/pointCloud/selector/Sse3dLassoSelector.js +0 -24
- package/es/core/pointCloud/selector/Sse3dSelector.js +0 -14
- package/es/core/toolOperation/scribbleTool2.js +0 -249
|
@@ -1,556 +1 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _ = require('lodash');
|
|
4
|
-
var rgba = require('color-rgba');
|
|
5
|
-
var DrawUtils = require('../../utils/tool/DrawUtils.js');
|
|
6
|
-
var AxisUtils = require('../../utils/tool/AxisUtils.js');
|
|
7
|
-
var RectUtils = require('../../utils/tool/RectUtils.js');
|
|
8
|
-
var PolygonUtils = require('../../utils/tool/PolygonUtils.js');
|
|
9
|
-
var MathUtils = require('../../utils/MathUtils.js');
|
|
10
|
-
var RenderDomClass = require('../../utils/tool/RenderDomClass.js');
|
|
11
|
-
var tool = require('../../constant/tool.js');
|
|
12
|
-
var annotation = require('../../constant/annotation.js');
|
|
13
|
-
var ImgPosUtils = require('../../utils/tool/ImgPosUtils.js');
|
|
14
|
-
var basicToolOperation = require('./basicToolOperation.js');
|
|
15
|
-
var matrix = require('../pointCloud/matrix.js');
|
|
16
|
-
|
|
17
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
-
|
|
19
|
-
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
20
|
-
var rgba__default = /*#__PURE__*/_interopDefaultLegacy(rgba);
|
|
21
|
-
|
|
22
|
-
var __defProp = Object.defineProperty;
|
|
23
|
-
var __defProps = Object.defineProperties;
|
|
24
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
25
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
26
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
27
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
28
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
29
|
-
var __spreadValues = (a, b) => {
|
|
30
|
-
for (var prop in b || (b = {}))
|
|
31
|
-
if (__hasOwnProp.call(b, prop))
|
|
32
|
-
__defNormalProp(a, prop, b[prop]);
|
|
33
|
-
if (__getOwnPropSymbols)
|
|
34
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
35
|
-
if (__propIsEnum.call(b, prop))
|
|
36
|
-
__defNormalProp(a, prop, b[prop]);
|
|
37
|
-
}
|
|
38
|
-
return a;
|
|
39
|
-
};
|
|
40
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
41
|
-
const newScope = 3;
|
|
42
|
-
const DEFAULT_RADIUS = 3;
|
|
43
|
-
const DEFAULT_STROKE_COLOR = "#6371FF";
|
|
44
|
-
class ViewOperation extends basicToolOperation.BasicToolOperation {
|
|
45
|
-
constructor(props) {
|
|
46
|
-
super(__spreadProps(__spreadValues({}, props), {showDefaultCursor: true}));
|
|
47
|
-
this.style = {};
|
|
48
|
-
this.annotations = [];
|
|
49
|
-
this.connectionPoints = [];
|
|
50
|
-
this.getHoverRectID = (e) => {
|
|
51
|
-
var _a, _b;
|
|
52
|
-
const coordinate = this.getCoordinateUnderZoom(e);
|
|
53
|
-
const originCoordinate = AxisUtils["default"].changePointByZoom(coordinate, 1 / this.zoom);
|
|
54
|
-
if (((_a = this.annotations) == null ? void 0 : _a.length) <= 0 || !((_b = this.annotations) == null ? void 0 : _b.length)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
let id = "";
|
|
58
|
-
let minArea = Number.MAX_SAFE_INTEGER;
|
|
59
|
-
for (let i = 0; i < this.annotations.length; i++) {
|
|
60
|
-
const annotation = this.annotations[i];
|
|
61
|
-
switch (annotation.type) {
|
|
62
|
-
case "rect": {
|
|
63
|
-
const rect = annotation.annotation;
|
|
64
|
-
if (RectUtils.isInRect(coordinate, rect, newScope, this.zoom)) {
|
|
65
|
-
const area = rect.width * rect.height;
|
|
66
|
-
if (area < minArea) {
|
|
67
|
-
id = rect.id;
|
|
68
|
-
minArea = area;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
case "polygon": {
|
|
74
|
-
const polygon = annotation.annotation;
|
|
75
|
-
if (PolygonUtils.isInPolygon(originCoordinate, polygon.pointList)) {
|
|
76
|
-
const area = PolygonUtils.getPolygonArea(polygon.pointList);
|
|
77
|
-
if (area < minArea) {
|
|
78
|
-
id = polygon.id;
|
|
79
|
-
minArea = area;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return id;
|
|
87
|
-
};
|
|
88
|
-
var _a;
|
|
89
|
-
this.style = (_a = props.style) != null ? _a : {stroke: DEFAULT_STROKE_COLOR, thickness: 3};
|
|
90
|
-
this.annotations = props.annotations;
|
|
91
|
-
this.loading = false;
|
|
92
|
-
this.renderDomInstance = new RenderDomClass({
|
|
93
|
-
container: this.container,
|
|
94
|
-
height: this.canvas.height
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
clearConnectionPoints() {
|
|
98
|
-
this.connectionPoints = [];
|
|
99
|
-
this.render();
|
|
100
|
-
}
|
|
101
|
-
checkConnectionPoints(newAnnotations = this.annotations) {
|
|
102
|
-
var _a, _b;
|
|
103
|
-
if (this.connectPointsStatus) {
|
|
104
|
-
(_b = (_a = this.connectPointsStatus).close) == null ? void 0 : _b.call(_a);
|
|
105
|
-
}
|
|
106
|
-
this.emit("connectionPointsStatusUpdate", () => {
|
|
107
|
-
return new Promise((resolve) => {
|
|
108
|
-
const {promise, close} = MathUtils["default"].getCollectionPointByAnnotationDataPromise(newAnnotations);
|
|
109
|
-
this.connectPointsStatus = {
|
|
110
|
-
close
|
|
111
|
-
};
|
|
112
|
-
promise.then((res) => {
|
|
113
|
-
this.connectionPoints = res.connectionPoints;
|
|
114
|
-
this.render();
|
|
115
|
-
this.connectPointsStatus = void 0;
|
|
116
|
-
resolve({connectionPoints: res.connectionPoints});
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
setLoading(loading) {
|
|
122
|
-
this.loading = loading;
|
|
123
|
-
this.render();
|
|
124
|
-
}
|
|
125
|
-
onMouseLeave() {
|
|
126
|
-
super.onMouseLeave();
|
|
127
|
-
this.mouseHoverID = void 0;
|
|
128
|
-
this.emit("onChange", "hover", []);
|
|
129
|
-
}
|
|
130
|
-
onMouseDown(e) {
|
|
131
|
-
if (super.onMouseDown(e) || this.forbidMouseOperation || !this.imgInfo) {
|
|
132
|
-
return true;
|
|
133
|
-
}
|
|
134
|
-
const newMouseSelectedID = this.mouseHoverID;
|
|
135
|
-
if (e.button === 0) {
|
|
136
|
-
let selectedID = [];
|
|
137
|
-
if (newMouseSelectedID) {
|
|
138
|
-
selectedID = [newMouseSelectedID];
|
|
139
|
-
}
|
|
140
|
-
this.emit("onChange", "selected", selectedID);
|
|
141
|
-
this.render();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
onMouseMove(e) {
|
|
145
|
-
if (super.onMouseMove(e) || this.forbidMouseOperation || !this.imgInfo) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const oldMouseHoverID = this.mouseHoverID;
|
|
149
|
-
const newMouseHoverID = this.getHoverRectID(e);
|
|
150
|
-
if (oldMouseHoverID !== newMouseHoverID) {
|
|
151
|
-
this.mouseHoverID = newMouseHoverID;
|
|
152
|
-
let hoverID = [];
|
|
153
|
-
if (newMouseHoverID) {
|
|
154
|
-
hoverID = [newMouseHoverID];
|
|
155
|
-
}
|
|
156
|
-
this.emit("onChange", "hover", hoverID);
|
|
157
|
-
this.render();
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
updateData(annotations) {
|
|
161
|
-
this.annotations = annotations;
|
|
162
|
-
this.render();
|
|
163
|
-
}
|
|
164
|
-
getSpecificStyle(obj) {
|
|
165
|
-
const specificStyle = ___default["default"].pick(obj, ["stroke", "thickness", "fill", "radius"]);
|
|
166
|
-
const newStyle = __spreadValues(__spreadValues({}, this.style), specificStyle);
|
|
167
|
-
if (newStyle.stroke) {
|
|
168
|
-
Object.assign(newStyle, {
|
|
169
|
-
color: newStyle.stroke
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
return newStyle;
|
|
173
|
-
}
|
|
174
|
-
getFontStyle(obj, style) {
|
|
175
|
-
var _a, _b;
|
|
176
|
-
const fontSize = (_a = obj == null ? void 0 : obj.fontSize) != null ? _a : 14;
|
|
177
|
-
const fontFamily = (_b = obj == null ? void 0 : obj.fontFamily) != null ? _b : "Arial";
|
|
178
|
-
return __spreadProps(__spreadValues({}, annotation.DEFAULT_TEXT_SHADOW), {
|
|
179
|
-
color: style.stroke,
|
|
180
|
-
font: `normal normal 600 ${fontSize}px ${fontFamily}`
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
appendOffset({x, y}) {
|
|
184
|
-
return {x: x + annotation.DEFAULT_TEXT_OFFSET.offsetX, y: y + annotation.DEFAULT_TEXT_OFFSET.offsetY};
|
|
185
|
-
}
|
|
186
|
-
getRenderText(result, hiddenText = false) {
|
|
187
|
-
let headerText = "";
|
|
188
|
-
let bottomText = "";
|
|
189
|
-
if (!result || hiddenText === true) {
|
|
190
|
-
return {headerText, bottomText};
|
|
191
|
-
}
|
|
192
|
-
if (result == null ? void 0 : result.order) {
|
|
193
|
-
headerText = `${result.order}`;
|
|
194
|
-
}
|
|
195
|
-
if (result == null ? void 0 : result.label) {
|
|
196
|
-
if (headerText) {
|
|
197
|
-
headerText = `${headerText}_${result.label}`;
|
|
198
|
-
} else {
|
|
199
|
-
headerText = `${result.label}`;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
if (result == null ? void 0 : result.attribute) {
|
|
203
|
-
if (headerText) {
|
|
204
|
-
headerText = `${headerText} ${result.attribute}`;
|
|
205
|
-
} else {
|
|
206
|
-
headerText = `${result.attribute}`;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
if (result == null ? void 0 : result.textAttribute) {
|
|
210
|
-
bottomText = result == null ? void 0 : result.textAttribute;
|
|
211
|
-
}
|
|
212
|
-
return {headerText, bottomText};
|
|
213
|
-
}
|
|
214
|
-
getReferenceOptions(isReference) {
|
|
215
|
-
return isReference ? {lineCap: "butt", lineDash: [20, 20]} : {};
|
|
216
|
-
}
|
|
217
|
-
focusPositionByPointList(pointList) {
|
|
218
|
-
const basicZone = MathUtils["default"].calcViewportBoundaries(pointList);
|
|
219
|
-
const newBoundary = {
|
|
220
|
-
x: basicZone.left,
|
|
221
|
-
y: basicZone.top,
|
|
222
|
-
width: basicZone.right - basicZone.left,
|
|
223
|
-
height: basicZone.bottom - basicZone.top
|
|
224
|
-
};
|
|
225
|
-
const pos = ImgPosUtils.getBasicRecPos(this.imgNode, newBoundary, this.size, 0.5);
|
|
226
|
-
if (pos) {
|
|
227
|
-
this.setCurrentPos(pos.currentPos);
|
|
228
|
-
this.setCurrentPosStorage(pos.currentPos);
|
|
229
|
-
const {imgInfo} = this;
|
|
230
|
-
const {innerZoom} = this.innerPosAndZoom;
|
|
231
|
-
if (imgInfo) {
|
|
232
|
-
this.setImgInfo(__spreadProps(__spreadValues({}, imgInfo), {
|
|
233
|
-
width: imgInfo.width / innerZoom * pos.innerZoom,
|
|
234
|
-
height: imgInfo.height / innerZoom * pos.innerZoom
|
|
235
|
-
}));
|
|
236
|
-
}
|
|
237
|
-
this.setZoom(pos.innerZoom);
|
|
238
|
-
this.render();
|
|
239
|
-
this.renderBasicCanvas();
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
renderConnectionPoints() {
|
|
243
|
-
this.connectionPoints.forEach((point) => {
|
|
244
|
-
const renderPoint = AxisUtils["default"].changePointByZoom(point, this.zoom, this.currentPos);
|
|
245
|
-
DrawUtils.drawCircleWithFill(this.canvas, renderPoint, 4, {color: "#fff"});
|
|
246
|
-
DrawUtils.drawCircleWithFill(this.canvas, renderPoint, 2, {color: "#000"});
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
getRenderStyle(annotation) {
|
|
250
|
-
const style = this.getSpecificStyle(annotation.annotation);
|
|
251
|
-
const fontStyle = this.getFontStyle(annotation.annotation, style);
|
|
252
|
-
return {
|
|
253
|
-
style,
|
|
254
|
-
fontStyle
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
renderLine(annotation$1) {
|
|
258
|
-
var _a, _b, _c;
|
|
259
|
-
if (annotation$1.type !== "line") {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
const {style, fontStyle} = this.getRenderStyle(annotation$1);
|
|
263
|
-
const line = annotation$1.annotation;
|
|
264
|
-
if (!(((_a = line == null ? void 0 : line.pointList) == null ? void 0 : _a.length) >= 2)) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
const {lineType = tool.ELineTypes.Line} = line;
|
|
268
|
-
const renderLineWithZoom = AxisUtils["default"].changePointListByZoom((_b = line == null ? void 0 : line.pointList) != null ? _b : [], this.zoom, this.currentPos);
|
|
269
|
-
const lineRenderOptions = __spreadProps(__spreadValues(__spreadValues({}, style), this.getReferenceOptions(line == null ? void 0 : line.isReference)), {
|
|
270
|
-
lineType,
|
|
271
|
-
strokeColor: style.stroke
|
|
272
|
-
});
|
|
273
|
-
let newPointList = [];
|
|
274
|
-
if (line.showKeyPoint) {
|
|
275
|
-
newPointList = DrawUtils.drawPolygonWithKeyPoint(this.canvas, renderLineWithZoom, lineRenderOptions);
|
|
276
|
-
} else {
|
|
277
|
-
newPointList = DrawUtils.drawPolygon(this.canvas, renderLineWithZoom, lineRenderOptions);
|
|
278
|
-
}
|
|
279
|
-
const isShowDirection = (line == null ? void 0 : line.showDirection) === true && ((_c = line == null ? void 0 : line.pointList) == null ? void 0 : _c.length) >= 2;
|
|
280
|
-
if (isShowDirection) {
|
|
281
|
-
let startPoint = renderLineWithZoom[0];
|
|
282
|
-
let endPoint = MathUtils["default"].getLineCenterPoint([renderLineWithZoom[0], renderLineWithZoom[1]]);
|
|
283
|
-
if (lineType === tool.ELineTypes.Curve) {
|
|
284
|
-
const pos = Math.floor(tool.SEGMENT_NUMBER / 2);
|
|
285
|
-
startPoint = newPointList[pos];
|
|
286
|
-
endPoint = newPointList[pos + 1];
|
|
287
|
-
}
|
|
288
|
-
DrawUtils.drawArrowByCanvas(this.canvas, startPoint, endPoint, {
|
|
289
|
-
color: style.stroke,
|
|
290
|
-
thickness: style.thickness
|
|
291
|
-
});
|
|
292
|
-
DrawUtils.drawCircle(this.canvas, renderLineWithZoom[0], style.thickness + 6, {
|
|
293
|
-
color: style.stroke,
|
|
294
|
-
thickness: style.thickness
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
const {headerText, bottomText} = this.getRenderText(line, line == null ? void 0 : line.hiddenText);
|
|
298
|
-
if (headerText) {
|
|
299
|
-
DrawUtils.drawText(this.canvas, this.appendOffset(renderLineWithZoom[0]), headerText, fontStyle);
|
|
300
|
-
}
|
|
301
|
-
if (bottomText) {
|
|
302
|
-
const endPoint = renderLineWithZoom[renderLineWithZoom.length - 1];
|
|
303
|
-
DrawUtils.drawText(this.canvas, this.appendOffset({x: endPoint.x + annotation.TEXT_ATTRIBUTE_OFFSET.x, y: endPoint.y + annotation.TEXT_ATTRIBUTE_OFFSET.y}), bottomText, fontStyle);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
renderPolygon(annotation$1) {
|
|
307
|
-
var _a, _b, _c, _d, _e;
|
|
308
|
-
if (annotation$1.type !== "polygon") {
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
const {style, fontStyle} = this.getRenderStyle(annotation$1);
|
|
312
|
-
const polygon = annotation$1.annotation;
|
|
313
|
-
if (!(((_a = polygon == null ? void 0 : polygon.pointList) == null ? void 0 : _a.length) >= 3)) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
const {lineType = tool.ELineTypes.Line} = polygon;
|
|
317
|
-
const renderPolygon = AxisUtils["default"].changePointListByZoom((_b = polygon == null ? void 0 : polygon.pointList) != null ? _b : [], this.zoom, this.currentPos);
|
|
318
|
-
if (polygon.id === this.mouseHoverID || style.fill) {
|
|
319
|
-
const fillArr = rgba__default["default"]((_d = (_c = style == null ? void 0 : style.fill) != null ? _c : style == null ? void 0 : style.stroke) != null ? _d : DEFAULT_STROKE_COLOR);
|
|
320
|
-
const fill = `rgba(${fillArr[0]}, ${fillArr[1]}, ${fillArr[2]},${fillArr[3] * 0.8})`;
|
|
321
|
-
DrawUtils.drawPolygonWithFill(this.canvas, renderPolygon, {color: fill, lineType});
|
|
322
|
-
}
|
|
323
|
-
const polygonRenderOptions = __spreadProps(__spreadValues(__spreadProps(__spreadValues({}, style), {
|
|
324
|
-
isClose: true
|
|
325
|
-
}), this.getReferenceOptions(polygon == null ? void 0 : polygon.isReference)), {
|
|
326
|
-
lineType,
|
|
327
|
-
strokeColor: style.stroke
|
|
328
|
-
});
|
|
329
|
-
let newPointList = [];
|
|
330
|
-
if (polygon.showKeyPoint) {
|
|
331
|
-
newPointList = DrawUtils.drawPolygonWithKeyPoint(this.canvas, renderPolygon, polygonRenderOptions);
|
|
332
|
-
} else {
|
|
333
|
-
newPointList = DrawUtils.drawPolygon(this.canvas, renderPolygon, polygonRenderOptions);
|
|
334
|
-
}
|
|
335
|
-
const isShowDirection = (polygon == null ? void 0 : polygon.showDirection) === true && ((_e = polygon == null ? void 0 : polygon.pointList) == null ? void 0 : _e.length) >= 2;
|
|
336
|
-
if (isShowDirection) {
|
|
337
|
-
let startPoint = renderPolygon[0];
|
|
338
|
-
let endPoint = MathUtils["default"].getLineCenterPoint([renderPolygon[0], renderPolygon[1]]);
|
|
339
|
-
if (lineType === tool.ELineTypes.Curve) {
|
|
340
|
-
const pos = Math.floor(tool.SEGMENT_NUMBER / 2);
|
|
341
|
-
startPoint = newPointList[pos];
|
|
342
|
-
endPoint = newPointList[pos + 1];
|
|
343
|
-
}
|
|
344
|
-
DrawUtils.drawArrowByCanvas(this.canvas, startPoint, endPoint, {
|
|
345
|
-
color: style.stroke,
|
|
346
|
-
thickness: style.thickness
|
|
347
|
-
});
|
|
348
|
-
DrawUtils.drawCircle(this.canvas, renderPolygon[0], style.thickness + 6, {
|
|
349
|
-
color: style.stroke,
|
|
350
|
-
thickness: style.thickness
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
const {headerText, bottomText} = this.getRenderText(polygon, polygon == null ? void 0 : polygon.hiddenText);
|
|
354
|
-
if (headerText) {
|
|
355
|
-
DrawUtils.drawText(this.canvas, this.appendOffset(renderPolygon[0]), headerText, fontStyle);
|
|
356
|
-
}
|
|
357
|
-
if (bottomText) {
|
|
358
|
-
const endPoint = renderPolygon[renderPolygon.length - 1];
|
|
359
|
-
DrawUtils.drawText(this.canvas, this.appendOffset({x: endPoint.x + annotation.TEXT_ATTRIBUTE_OFFSET.x, y: endPoint.y + annotation.TEXT_ATTRIBUTE_OFFSET.y}), bottomText, fontStyle);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
renderSingleCuboid(annotation) {
|
|
363
|
-
var _a, _b;
|
|
364
|
-
const {style} = this.getRenderStyle(annotation);
|
|
365
|
-
const cuboid = annotation.annotation;
|
|
366
|
-
const fillArr = rgba__default["default"]((_b = (_a = style == null ? void 0 : style.fill) != null ? _a : style == null ? void 0 : style.stroke) != null ? _b : DEFAULT_STROKE_COLOR);
|
|
367
|
-
const fillColor = `rgba(${fillArr[0]}, ${fillArr[1]}, ${fillArr[2]},${fillArr[3] * 0.8})`;
|
|
368
|
-
const strokeColor = style.stroke;
|
|
369
|
-
const transformCuboid = AxisUtils["default"].changeCuboidByZoom(cuboid, this.zoom, this.currentPos);
|
|
370
|
-
const {headerText, bottomText} = this.getRenderText(cuboid, cuboid == null ? void 0 : cuboid.hiddenText);
|
|
371
|
-
DrawUtils.drawCuboidWithText(this.canvas, transformCuboid, {strokeColor, fillColor, thickness: style.thickness}, {
|
|
372
|
-
config: this.config,
|
|
373
|
-
hiddenText: cuboid == null ? void 0 : cuboid.hiddenText,
|
|
374
|
-
headerText,
|
|
375
|
-
bottomText
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
renderBox3d(annotation) {
|
|
379
|
-
if (annotation.type !== "box3d") {
|
|
380
|
-
return;
|
|
381
|
-
}
|
|
382
|
-
const data = annotation.annotation;
|
|
383
|
-
const viewDataPointList = matrix.pointCloudLidar2image(data, data.calib);
|
|
384
|
-
const defaultViewStyle = {
|
|
385
|
-
fill: "transparent"
|
|
386
|
-
};
|
|
387
|
-
const extraData = ___default["default"].pick(data, ["stroke", "thickness"]);
|
|
388
|
-
viewDataPointList.forEach((v, i) => {
|
|
389
|
-
const newAnnotation = __spreadValues(__spreadProps(__spreadValues({}, extraData), {
|
|
390
|
-
id: `${annotation.annotation.id}-${i}`,
|
|
391
|
-
pointList: v.pointList
|
|
392
|
-
}), defaultViewStyle);
|
|
393
|
-
switch (v.type) {
|
|
394
|
-
case "line":
|
|
395
|
-
this.renderLine({
|
|
396
|
-
type: "line",
|
|
397
|
-
annotation: newAnnotation
|
|
398
|
-
});
|
|
399
|
-
break;
|
|
400
|
-
case "polygon":
|
|
401
|
-
this.renderPolygon({
|
|
402
|
-
type: "polygon",
|
|
403
|
-
annotation: newAnnotation
|
|
404
|
-
});
|
|
405
|
-
break;
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
render() {
|
|
410
|
-
try {
|
|
411
|
-
super.render();
|
|
412
|
-
if (this.loading === true) {
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
const globalDomTextAnnotation = this.annotations.filter((v) => v.type === "text" && v.annotation.position === "rt").map((v) => v.annotation);
|
|
416
|
-
this.renderDomInstance.render(globalDomTextAnnotation);
|
|
417
|
-
this.annotations.forEach((annotation) => {
|
|
418
|
-
var _a, _b, _c, _d, _e;
|
|
419
|
-
const style = this.getSpecificStyle(annotation.annotation);
|
|
420
|
-
const fontStyle = this.getFontStyle(annotation.annotation, style);
|
|
421
|
-
switch (annotation.type) {
|
|
422
|
-
case "rect": {
|
|
423
|
-
const rect = annotation.annotation;
|
|
424
|
-
const {hiddenText = false, isReference, hiddenRectSize = false} = rect;
|
|
425
|
-
const {zoom} = this;
|
|
426
|
-
const renderRect = AxisUtils["default"].changeRectByZoom(rect, this.zoom, this.currentPos);
|
|
427
|
-
const {x, y, width, height} = renderRect;
|
|
428
|
-
if (rect.id === this.mouseHoverID || style.fill) {
|
|
429
|
-
const fillArr = rgba__default["default"]((_b = (_a = style == null ? void 0 : style.fill) != null ? _a : style == null ? void 0 : style.stroke) != null ? _b : DEFAULT_STROKE_COLOR);
|
|
430
|
-
const fill = `rgba(${fillArr[0]}, ${fillArr[1]}, ${fillArr[2]},${fillArr[3] * 0.8})`;
|
|
431
|
-
DrawUtils.drawRectWithFill(this.canvas, renderRect, {color: fill});
|
|
432
|
-
}
|
|
433
|
-
DrawUtils.drawRect(this.canvas, renderRect, __spreadValues(__spreadProps(__spreadValues({}, style), {
|
|
434
|
-
hiddenText: true
|
|
435
|
-
}), this.getReferenceOptions(isReference)));
|
|
436
|
-
const {headerText, bottomText} = this.getRenderText(rect, rect == null ? void 0 : rect.hiddenText);
|
|
437
|
-
if (headerText) {
|
|
438
|
-
DrawUtils.drawText(this.canvas, {x, y: y - 6}, headerText, __spreadValues({
|
|
439
|
-
textMaxWidth: 300
|
|
440
|
-
}, fontStyle));
|
|
441
|
-
}
|
|
442
|
-
const rectSize = `${Math.round(width / zoom)} * ${Math.round(height / zoom)}`;
|
|
443
|
-
const textSizeWidth = rectSize.length * 7;
|
|
444
|
-
if (!hiddenText && !hiddenRectSize) {
|
|
445
|
-
DrawUtils.drawText(this.canvas, {x: x + width - textSizeWidth, y: y + height + 15}, rectSize, fontStyle);
|
|
446
|
-
}
|
|
447
|
-
if (bottomText) {
|
|
448
|
-
const marginTop = 20;
|
|
449
|
-
const textWidth = Math.max(20, width - textSizeWidth);
|
|
450
|
-
DrawUtils.drawText(this.canvas, {x, y: y + height + marginTop}, rect.textAttribute, __spreadValues({
|
|
451
|
-
textMaxWidth: textWidth
|
|
452
|
-
}, fontStyle));
|
|
453
|
-
}
|
|
454
|
-
break;
|
|
455
|
-
}
|
|
456
|
-
case "polygon": {
|
|
457
|
-
this.renderPolygon(annotation);
|
|
458
|
-
break;
|
|
459
|
-
}
|
|
460
|
-
case "line": {
|
|
461
|
-
this.renderLine(annotation);
|
|
462
|
-
break;
|
|
463
|
-
}
|
|
464
|
-
case "point": {
|
|
465
|
-
const point = annotation.annotation;
|
|
466
|
-
const renderPoint = AxisUtils["default"].changePointByZoom(point, this.zoom, this.currentPos);
|
|
467
|
-
const radius = (_c = style.radius) != null ? _c : DEFAULT_RADIUS;
|
|
468
|
-
DrawUtils.drawCircle(this.canvas, renderPoint, radius, style);
|
|
469
|
-
const {headerText, bottomText} = this.getRenderText(point, point == null ? void 0 : point.hiddenText);
|
|
470
|
-
if (headerText) {
|
|
471
|
-
DrawUtils.drawText(this.canvas, {x: renderPoint.x + radius / 2, y: renderPoint.y - radius - 4}, headerText, __spreadValues({
|
|
472
|
-
textAlign: "center"
|
|
473
|
-
}, fontStyle));
|
|
474
|
-
}
|
|
475
|
-
if (bottomText) {
|
|
476
|
-
DrawUtils.drawText(this.canvas, this.appendOffset({x: renderPoint.x + radius, y: renderPoint.y + radius + 24}), bottomText, fontStyle);
|
|
477
|
-
}
|
|
478
|
-
break;
|
|
479
|
-
}
|
|
480
|
-
case "text": {
|
|
481
|
-
const textAnnotation = annotation.annotation;
|
|
482
|
-
const {
|
|
483
|
-
text,
|
|
484
|
-
x,
|
|
485
|
-
y,
|
|
486
|
-
textMaxWidth,
|
|
487
|
-
color = "white",
|
|
488
|
-
background = "rgba(0, 0, 0, 0.6)",
|
|
489
|
-
lineHeight = 25,
|
|
490
|
-
font = tool.DEFAULT_FONT,
|
|
491
|
-
position
|
|
492
|
-
} = textAnnotation;
|
|
493
|
-
const paddingTB = 10;
|
|
494
|
-
const paddingLR = 10;
|
|
495
|
-
const renderPoint = AxisUtils["default"].changePointByZoom({x, y}, this.zoom, this.currentPos);
|
|
496
|
-
const {
|
|
497
|
-
width,
|
|
498
|
-
height,
|
|
499
|
-
fontHeight = 0
|
|
500
|
-
} = MathUtils["default"].getTextArea(this.canvas, textAnnotation.text, textMaxWidth, font, lineHeight);
|
|
501
|
-
if (position === "rt") {
|
|
502
|
-
break;
|
|
503
|
-
}
|
|
504
|
-
DrawUtils.drawRectWithFill(this.canvas, {
|
|
505
|
-
x: renderPoint.x,
|
|
506
|
-
y: renderPoint.y,
|
|
507
|
-
width: width + paddingLR * 2,
|
|
508
|
-
height: height + paddingTB * 2,
|
|
509
|
-
id: "",
|
|
510
|
-
sourceID: "",
|
|
511
|
-
valid: true,
|
|
512
|
-
textAttribute: "",
|
|
513
|
-
attribute: ""
|
|
514
|
-
}, {
|
|
515
|
-
color: background
|
|
516
|
-
});
|
|
517
|
-
DrawUtils.drawText(this.canvas, {
|
|
518
|
-
x: renderPoint.x + paddingLR,
|
|
519
|
-
y: renderPoint.y + fontHeight + paddingTB
|
|
520
|
-
}, text, {
|
|
521
|
-
color,
|
|
522
|
-
lineHeight,
|
|
523
|
-
font,
|
|
524
|
-
textMaxWidth
|
|
525
|
-
});
|
|
526
|
-
break;
|
|
527
|
-
}
|
|
528
|
-
case "box3d": {
|
|
529
|
-
this.renderBox3d(annotation);
|
|
530
|
-
break;
|
|
531
|
-
}
|
|
532
|
-
case "cuboid": {
|
|
533
|
-
this.renderSingleCuboid(annotation);
|
|
534
|
-
break;
|
|
535
|
-
}
|
|
536
|
-
default: {
|
|
537
|
-
break;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
(_e = (_d = annotation.annotation) == null ? void 0 : _d.renderEnhance) == null ? void 0 : _e.call(_d, {
|
|
541
|
-
ctx: this.ctx,
|
|
542
|
-
canvas: this.canvas,
|
|
543
|
-
currentPos: this.currentPos,
|
|
544
|
-
zoom: this.zoom,
|
|
545
|
-
data: annotation,
|
|
546
|
-
toolInstance: this
|
|
547
|
-
});
|
|
548
|
-
});
|
|
549
|
-
this.renderConnectionPoints();
|
|
550
|
-
} catch (e) {
|
|
551
|
-
console.error("ViewOperation Render Error", e);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
module.exports = ViewOperation;
|
|
1
|
+
"use strict";var _=require("lodash"),rgba=require("color-rgba"),DrawUtils=require("../../utils/tool/DrawUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),RectUtils=require("../../utils/tool/RectUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),MathUtils=require("../../utils/MathUtils.js"),RenderDomClass=require("../../utils/tool/RenderDomClass.js"),tool=require("../../constant/tool.js"),annotation=require("../../constant/annotation.js"),ImgPosUtils=require("../../utils/tool/ImgPosUtils.js"),basicToolOperation=require("./basicToolOperation.js"),matrix=require("../pointCloud/matrix.js");function _interopDefaultLegacy(v){return v&&typeof v=="object"&&"default"in v?v:{default:v}}var ___default=_interopDefaultLegacy(_),rgba__default=_interopDefaultLegacy(rgba),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(v,t,e)=>t in v?__defProp(v,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):v[t]=e,__spreadValues=(v,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(v,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(v,e,t[e]);return v},__spreadProps=(v,t)=>__defProps(v,__getOwnPropDescs(t));const newScope=3,DEFAULT_RADIUS=3,DEFAULT_STROKE_COLOR="#6371FF";class ViewOperation extends basicToolOperation.BasicToolOperation{constructor(t){super(__spreadProps(__spreadValues({},t),{showDefaultCursor:!0}));this.style={},this.annotations=[],this.connectionPoints=[],this.getHoverRectID=o=>{var i,r;const c=this.getCoordinateUnderZoom(o),n=AxisUtils.default.changePointByZoom(c,1/this.zoom);if(((i=this.annotations)==null?void 0:i.length)<=0||!((r=this.annotations)==null?void 0:r.length))return;let h="",s=Number.MAX_SAFE_INTEGER;for(let l=0;l<this.annotations.length;l++){const a=this.annotations[l];switch(a.type){case"rect":{const d=a.annotation;if(RectUtils.isInRect(c,d,newScope,this.zoom)){const u=d.width*d.height;u<s&&(h=d.id,s=u)}break}case"polygon":{const d=a.annotation;if(PolygonUtils.isInPolygon(n,d.pointList)){const u=PolygonUtils.getPolygonArea(d.pointList);u<s&&(h=d.id,s=u)}break}}}return h};var e;this.style=(e=t.style)!=null?e:{stroke:DEFAULT_STROKE_COLOR,thickness:3},this.annotations=t.annotations,this.loading=!1,this.renderDomInstance=new RenderDomClass({container:this.container,height:this.canvas.height})}clearConnectionPoints(){this.connectionPoints=[],this.render()}checkConnectionPoints(t=this.annotations){var e,o;this.connectPointsStatus&&((o=(e=this.connectPointsStatus).close)==null||o.call(e)),this.emit("connectionPointsStatusUpdate",()=>new Promise(i=>{const{promise:r,close:c}=MathUtils.default.getCollectionPointByAnnotationDataPromise(t);this.connectPointsStatus={close:c},r.then(n=>{this.connectionPoints=n.connectionPoints,this.render(),this.connectPointsStatus=void 0,i({connectionPoints:n.connectionPoints})})}))}setLoading(t){this.loading=t,this.render()}onMouseLeave(){super.onMouseLeave(),this.mouseHoverID=void 0,this.emit("onChange","hover",[])}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return!0;const e=this.mouseHoverID;if(t.button===0){let o=[];e&&(o=[e]),this.emit("onChange","selected",o),this.render()}}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.mouseHoverID,o=this.getHoverRectID(t);if(e!==o){this.mouseHoverID=o;let i=[];o&&(i=[o]),this.emit("onChange","hover",i),this.render()}}updateData(t){this.annotations=t,this.render()}getSpecificStyle(t){const e=___default.default.pick(t,["stroke","thickness","fill","radius"]),o=__spreadValues(__spreadValues({},this.style),e);return o.stroke&&Object.assign(o,{color:o.stroke}),o}getFontStyle(t,e){var o,i;const r=(o=t==null?void 0:t.fontSize)!=null?o:14,c=(i=t==null?void 0:t.fontFamily)!=null?i:"Arial";return __spreadProps(__spreadValues({},annotation.DEFAULT_TEXT_SHADOW),{color:e.stroke,font:`normal normal 600 ${r}px ${c}`})}appendOffset({x:t,y:e}){return{x:t+annotation.DEFAULT_TEXT_OFFSET.offsetX,y:e+annotation.DEFAULT_TEXT_OFFSET.offsetY}}getRenderText(t,e=!1){let o="",i="";return!t||e===!0?{headerText:o,bottomText:i}:((t==null?void 0:t.order)&&(o=`${t.order}`),(t==null?void 0:t.label)&&(o?o=`${o}_${t.label}`:o=`${t.label}`),(t==null?void 0:t.attribute)&&(o?o=`${o} ${t.attribute}`:o=`${t.attribute}`),(t==null?void 0:t.textAttribute)&&(i=t==null?void 0:t.textAttribute),{headerText:o,bottomText:i})}getReferenceOptions(t){return t?{lineCap:"butt",lineDash:[20,20]}:{}}focusPositionByPointList(t){const e=MathUtils.default.calcViewportBoundaries(t),o={x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top},i=ImgPosUtils.getBasicRecPos(this.imgNode,o,this.size,.5);if(i){this.setCurrentPos(i.currentPos),this.setCurrentPosStorage(i.currentPos);const{imgInfo:r}=this,{innerZoom:c}=this.innerPosAndZoom;r&&this.setImgInfo(__spreadProps(__spreadValues({},r),{width:r.width/c*i.innerZoom,height:r.height/c*i.innerZoom})),this.setZoom(i.innerZoom),this.render(),this.renderBasicCanvas()}}renderConnectionPoints(){this.connectionPoints.forEach(t=>{const e=AxisUtils.default.changePointByZoom(t,this.zoom,this.currentPos);DrawUtils.drawCircleWithFill(this.canvas,e,4,{color:"#fff"}),DrawUtils.drawCircleWithFill(this.canvas,e,2,{color:"#000"})})}getRenderStyle(t){const e=this.getSpecificStyle(t.annotation),o=this.getFontStyle(t.annotation,e);return{style:e,fontStyle:o}}renderLine(t){var e,o,i;if(t.type!=="line")return;const{style:r,fontStyle:c}=this.getRenderStyle(t),n=t.annotation;if(!(((e=n==null?void 0:n.pointList)==null?void 0:e.length)>=2))return;const{lineType:h=tool.ELineTypes.Line}=n,s=AxisUtils.default.changePointListByZoom((o=n==null?void 0:n.pointList)!=null?o:[],this.zoom,this.currentPos),l=__spreadProps(__spreadValues(__spreadValues({},r),this.getReferenceOptions(n==null?void 0:n.isReference)),{lineType:h,strokeColor:r.stroke});let a=[];if(n.showKeyPoint?a=DrawUtils.drawPolygonWithKeyPoint(this.canvas,s,l):a=DrawUtils.drawPolygon(this.canvas,s,l),(n==null?void 0:n.showDirection)===!0&&((i=n==null?void 0:n.pointList)==null?void 0:i.length)>=2){let g=s[0],y=MathUtils.default.getLineCenterPoint([s[0],s[1]]);if(h===tool.ELineTypes.Curve){const f=Math.floor(tool.SEGMENT_NUMBER/2);g=a[f],y=a[f+1]}DrawUtils.drawArrowByCanvas(this.canvas,g,y,{color:r.stroke,thickness:r.thickness}),DrawUtils.drawCircle(this.canvas,s[0],r.thickness+6,{color:r.stroke,thickness:r.thickness})}const{headerText:u,bottomText:p}=this.getRenderText(n,n==null?void 0:n.hiddenText);if(u&&DrawUtils.drawText(this.canvas,this.appendOffset(s[0]),u,c),p){const g=s[s.length-1];DrawUtils.drawText(this.canvas,this.appendOffset({x:g.x+annotation.TEXT_ATTRIBUTE_OFFSET.x,y:g.y+annotation.TEXT_ATTRIBUTE_OFFSET.y}),p,c)}}renderPolygon(t){var e,o,i,r,c;if(t.type!=="polygon")return;const{style:n,fontStyle:h}=this.getRenderStyle(t),s=t.annotation;if(!(((e=s==null?void 0:s.pointList)==null?void 0:e.length)>=3))return;const{lineType:l=tool.ELineTypes.Line}=s,a=AxisUtils.default.changePointListByZoom((o=s==null?void 0:s.pointList)!=null?o:[],this.zoom,this.currentPos);if(s.id===this.mouseHoverID||n.fill){const f=rgba__default.default((r=(i=n==null?void 0:n.fill)!=null?i:n==null?void 0:n.stroke)!=null?r:DEFAULT_STROKE_COLOR),T=`rgba(${f[0]}, ${f[1]}, ${f[2]},${f[3]*.8})`;DrawUtils.drawPolygonWithFill(this.canvas,a,{color:T,lineType:l})}const d=__spreadProps(__spreadValues(__spreadProps(__spreadValues({},n),{isClose:!0}),this.getReferenceOptions(s==null?void 0:s.isReference)),{lineType:l,strokeColor:n.stroke});let u=[];if(s.showKeyPoint?u=DrawUtils.drawPolygonWithKeyPoint(this.canvas,a,d):u=DrawUtils.drawPolygon(this.canvas,a,d),(s==null?void 0:s.showDirection)===!0&&((c=s==null?void 0:s.pointList)==null?void 0:c.length)>=2){let f=a[0],T=MathUtils.default.getLineCenterPoint([a[0],a[1]]);if(l===tool.ELineTypes.Curve){const x=Math.floor(tool.SEGMENT_NUMBER/2);f=u[x],T=u[x+1]}DrawUtils.drawArrowByCanvas(this.canvas,f,T,{color:n.stroke,thickness:n.thickness}),DrawUtils.drawCircle(this.canvas,a[0],n.thickness+6,{color:n.stroke,thickness:n.thickness})}const{headerText:g,bottomText:y}=this.getRenderText(s,s==null?void 0:s.hiddenText);if(g&&DrawUtils.drawText(this.canvas,this.appendOffset(a[0]),g,h),y){const f=a[a.length-1];DrawUtils.drawText(this.canvas,this.appendOffset({x:f.x+annotation.TEXT_ATTRIBUTE_OFFSET.x,y:f.y+annotation.TEXT_ATTRIBUTE_OFFSET.y}),y,h)}}renderSingleCuboid(t){var e,o;const{style:i}=this.getRenderStyle(t),r=t.annotation,c=rgba__default.default((o=(e=i==null?void 0:i.fill)!=null?e:i==null?void 0:i.stroke)!=null?o:DEFAULT_STROKE_COLOR),n=`rgba(${c[0]}, ${c[1]}, ${c[2]},${c[3]*.8})`,h=i.stroke,s=AxisUtils.default.changeCuboidByZoom(r,this.zoom,this.currentPos),{headerText:l,bottomText:a}=this.getRenderText(r,r==null?void 0:r.hiddenText);DrawUtils.drawCuboidWithText(this.canvas,s,{strokeColor:h,fillColor:n,thickness:i.thickness},{config:this.config,hiddenText:r==null?void 0:r.hiddenText,headerText:l,bottomText:a})}renderBox3d(t){if(t.type!=="box3d")return;const e=t.annotation,o=matrix.pointCloudLidar2image(e,e.calib),i={fill:"transparent"},r=___default.default.pick(e,["stroke","thickness"]);o.forEach((c,n)=>{const h=__spreadValues(__spreadProps(__spreadValues({},r),{id:`${t.annotation.id}-${n}`,pointList:c.pointList}),i);switch(c.type){case"line":this.renderLine({type:"line",annotation:h});break;case"polygon":this.renderPolygon({type:"polygon",annotation:h});break}})}render(){try{if(super.render(),this.loading===!0)return;const t=this.annotations.filter(e=>e.type==="text"&&e.annotation.position==="rt").map(e=>e.annotation);this.renderDomInstance.render(t),this.annotations.forEach(e=>{var o,i,r,c,n;const h=this.getSpecificStyle(e.annotation),s=this.getFontStyle(e.annotation,h);switch(e.type){case"rect":{const l=e.annotation,{hiddenText:a=!1,isReference:d,hiddenRectSize:u=!1}=l,{zoom:p}=this,g=AxisUtils.default.changeRectByZoom(l,this.zoom,this.currentPos),{x:y,y:f,width:T,height:x}=g;if(l.id===this.mouseHoverID||h.fill){const P=rgba__default.default((i=(o=h==null?void 0:h.fill)!=null?o:h==null?void 0:h.stroke)!=null?i:DEFAULT_STROKE_COLOR),b=`rgba(${P[0]}, ${P[1]}, ${P[2]},${P[3]*.8})`;DrawUtils.drawRectWithFill(this.canvas,g,{color:b})}DrawUtils.drawRect(this.canvas,g,__spreadValues(__spreadProps(__spreadValues({},h),{hiddenText:!0}),this.getReferenceOptions(d)));const{headerText:w,bottomText:S}=this.getRenderText(l,l==null?void 0:l.hiddenText);w&&DrawUtils.drawText(this.canvas,{x:y,y:f-6},w,__spreadValues({textMaxWidth:300},s));const m=`${Math.round(T/p)} * ${Math.round(x/p)}`,k=m.length*7;if(!a&&!u&&DrawUtils.drawText(this.canvas,{x:y+T-k,y:f+x+15},m,s),S){const P=20,b=Math.max(20,T-k);DrawUtils.drawText(this.canvas,{x:y,y:f+x+P},l.textAttribute,__spreadValues({textMaxWidth:b},s))}break}case"polygon":{this.renderPolygon(e);break}case"line":{this.renderLine(e);break}case"point":{const l=e.annotation,a=AxisUtils.default.changePointByZoom(l,this.zoom,this.currentPos),d=(r=h.radius)!=null?r:DEFAULT_RADIUS;DrawUtils.drawCircle(this.canvas,a,d,h);const{headerText:u,bottomText:p}=this.getRenderText(l,l==null?void 0:l.hiddenText);u&&DrawUtils.drawText(this.canvas,{x:a.x+d/2,y:a.y-d-4},u,__spreadValues({textAlign:"center"},s)),p&&DrawUtils.drawText(this.canvas,this.appendOffset({x:a.x+d,y:a.y+d+24}),p,s);break}case"text":{const l=e.annotation,{text:a,x:d,y:u,textMaxWidth:p,color:g="white",background:y="rgba(0, 0, 0, 0.6)",lineHeight:f=25,font:T=tool.DEFAULT_FONT,position:x}=l,w=10,S=10,m=AxisUtils.default.changePointByZoom({x:d,y:u},this.zoom,this.currentPos),{width:k,height:P,fontHeight:b=0}=MathUtils.default.getTextArea(this.canvas,l.text,p,T,f);if(x==="rt")break;DrawUtils.drawRectWithFill(this.canvas,{x:m.x,y:m.y,width:k+S*2,height:P+w*2,id:"",sourceID:"",valid:!0,textAttribute:"",attribute:""},{color:y}),DrawUtils.drawText(this.canvas,{x:m.x+S,y:m.y+b+w},a,{color:g,lineHeight:f,font:T,textMaxWidth:p});break}case"box3d":{this.renderBox3d(e);break}case"cuboid":{this.renderSingleCuboid(e);break}default:break}(n=(c=e.annotation)==null?void 0:c.renderEnhance)==null||n.call(c,{ctx:this.ctx,canvas:this.canvas,currentPos:this.currentPos,zoom:this.zoom,data:e,toolInstance:this})}),this.renderConnectionPoints()}catch(t){console.error("ViewOperation Render Error",t)}}}module.exports=ViewOperation;
|