@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,102 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var AxisUtils = require('./AxisUtils.js');
|
|
4
|
+
|
|
5
|
+
class DblClickEventListener {
|
|
6
|
+
constructor(dom, delay) {
|
|
7
|
+
this.rcTime = 0;
|
|
8
|
+
this.mouseDownTime = 0;
|
|
9
|
+
this.onMouseDown = () => {
|
|
10
|
+
this.mouseDownTime = new Date().getTime();
|
|
11
|
+
};
|
|
12
|
+
this.dom = dom;
|
|
13
|
+
this.isDoubleClick = false;
|
|
14
|
+
this.delay = delay;
|
|
15
|
+
}
|
|
16
|
+
getRcTime() {
|
|
17
|
+
return this.rcTime;
|
|
18
|
+
}
|
|
19
|
+
getCoord(e) {
|
|
20
|
+
return {
|
|
21
|
+
x: e.clientX,
|
|
22
|
+
y: e.clientY
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
removeEvent() {
|
|
26
|
+
if (!this.dom) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.dom.removeEventListener("mouseup", this.mouseUp);
|
|
30
|
+
this.dom.removeEventListener("mousemove", this.mouseMove);
|
|
31
|
+
this.dom.removeEventListener("dblclick", this.dblclick);
|
|
32
|
+
this.dom.removeEventListener("mousedown", this.onMouseDown);
|
|
33
|
+
}
|
|
34
|
+
addEvent(singleClickFun, leftDblClick, rightDblClick, isAllowDouble) {
|
|
35
|
+
if (!this.dom) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
this.removeEvent();
|
|
39
|
+
this.mouseUp = (e) => {
|
|
40
|
+
const cTime = new Date().getTime();
|
|
41
|
+
const isDoubleClick = isAllowDouble ? isAllowDouble(e) : true;
|
|
42
|
+
if (cTime - this.mouseDownTime > this.delay || isDoubleClick !== true) {
|
|
43
|
+
singleClickFun(e);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (e.button === 2) {
|
|
47
|
+
if (this.rcTime === 0) {
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
this.rcTime = 0;
|
|
50
|
+
}, this.delay);
|
|
51
|
+
this.rcTime = cTime;
|
|
52
|
+
} else {
|
|
53
|
+
if (cTime - this.rcTime < this.delay) {
|
|
54
|
+
rightDblClick(e);
|
|
55
|
+
clearTimeout(this.setTimeFun);
|
|
56
|
+
this.cacheFunction = void 0;
|
|
57
|
+
}
|
|
58
|
+
this.rcTime = 0;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (this.setTimeFun) {
|
|
63
|
+
clearTimeout(this.setTimeFun);
|
|
64
|
+
}
|
|
65
|
+
this.clickCoord = this.getCoord(e);
|
|
66
|
+
this.cacheFunction = () => singleClickFun(e);
|
|
67
|
+
this.setTimeFun = setTimeout(() => {
|
|
68
|
+
if (this.isDoubleClick) {
|
|
69
|
+
this.isDoubleClick = false;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.cacheFunction();
|
|
73
|
+
this.clickCoord = void 0;
|
|
74
|
+
}, this.delay);
|
|
75
|
+
};
|
|
76
|
+
this.mouseMove = (e) => {
|
|
77
|
+
const currentCoord = this.getCoord(e);
|
|
78
|
+
if (this.clickCoord && !AxisUtils["default"].getIsInScope(currentCoord, this.clickCoord, 10)) {
|
|
79
|
+
if (this.cacheFunction) {
|
|
80
|
+
this.cacheFunction();
|
|
81
|
+
}
|
|
82
|
+
this.clickCoord = void 0;
|
|
83
|
+
this.cacheFunction = null;
|
|
84
|
+
clearTimeout(this.setTimeFun);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
this.dblclick = (e) => {
|
|
88
|
+
this.isDoubleClick = true;
|
|
89
|
+
this.clickCoord = void 0;
|
|
90
|
+
leftDblClick(e);
|
|
91
|
+
};
|
|
92
|
+
this.dom.addEventListener("mouseup", this.mouseUp);
|
|
93
|
+
this.dom.addEventListener("mousemove", this.mouseMove);
|
|
94
|
+
this.dom.addEventListener("dblclick", this.dblclick);
|
|
95
|
+
this.dom.addEventListener("mousedown", this.onMouseDown);
|
|
96
|
+
}
|
|
97
|
+
clearRightDblClick() {
|
|
98
|
+
this.rcTime = 0;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
module.exports = DblClickEventListener;
|
|
@@ -1,3 +1,492 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tool = require('../../constant/tool.js');
|
|
4
|
+
var PolygonUtils = require('./PolygonUtils.js');
|
|
5
|
+
var UnitUtils = require('./UnitUtils.js');
|
|
6
|
+
var AxisUtils = require('./AxisUtils.js');
|
|
7
|
+
var CuboidUtils = require('./CuboidUtils.js');
|
|
8
|
+
var AttributeUtils = require('./AttributeUtils.js');
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __defProps = Object.defineProperties;
|
|
12
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
13
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
14
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
16
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
17
|
+
var __spreadValues = (a, b) => {
|
|
18
|
+
for (var prop in b || (b = {}))
|
|
19
|
+
if (__hasOwnProp.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
if (__getOwnPropSymbols)
|
|
22
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
23
|
+
if (__propIsEnum.call(b, prop))
|
|
24
|
+
__defNormalProp(a, prop, b[prop]);
|
|
25
|
+
}
|
|
26
|
+
return a;
|
|
27
|
+
};
|
|
28
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
29
|
+
const DEFAULT_ZOOM = 1;
|
|
30
|
+
const DEFAULT_CURRENT_POS = {
|
|
31
|
+
x: 0,
|
|
32
|
+
y: 0
|
|
33
|
+
};
|
|
34
|
+
const DEFAULT_ROTATE = 0;
|
|
35
|
+
const DEFAULT_COLOR = "";
|
|
36
|
+
const _DrawUtils = class {
|
|
37
|
+
static drawLine(canvas, startPoint, endPoint, options = {}) {
|
|
38
|
+
const ctx = canvas.getContext("2d");
|
|
39
|
+
const {color = DEFAULT_COLOR, thickness = 1, lineCap = "round", lineDash} = options;
|
|
40
|
+
ctx.save();
|
|
41
|
+
ctx.strokeStyle = color;
|
|
42
|
+
ctx.lineWidth = thickness;
|
|
43
|
+
ctx.lineCap = lineCap;
|
|
44
|
+
if (lineDash) {
|
|
45
|
+
ctx.setLineDash(lineDash);
|
|
46
|
+
}
|
|
47
|
+
ctx.beginPath();
|
|
48
|
+
ctx.moveTo(startPoint.x, startPoint.y);
|
|
49
|
+
ctx.lineTo(endPoint.x + 1, endPoint.y + 1);
|
|
50
|
+
ctx.stroke();
|
|
51
|
+
ctx.restore();
|
|
52
|
+
}
|
|
53
|
+
static drawRect(canvas, rect, options = {}) {
|
|
54
|
+
const ctx = canvas.getContext("2d");
|
|
55
|
+
const {color = DEFAULT_COLOR, thickness = 1, lineCap = "round", hiddenText = false, lineDash} = options;
|
|
56
|
+
ctx.save();
|
|
57
|
+
ctx.strokeStyle = color;
|
|
58
|
+
ctx.lineWidth = thickness;
|
|
59
|
+
ctx.lineCap = lineCap;
|
|
60
|
+
if (Array.isArray(lineDash)) {
|
|
61
|
+
ctx.setLineDash(lineDash);
|
|
62
|
+
}
|
|
63
|
+
ctx.fillStyle = color;
|
|
64
|
+
ctx.strokeRect(rect.x, rect.y, rect.width, rect.height);
|
|
65
|
+
if (hiddenText === false) {
|
|
66
|
+
let showText = "";
|
|
67
|
+
if (rect.attribute) {
|
|
68
|
+
showText = `${showText} ${rect.attribute}`;
|
|
69
|
+
}
|
|
70
|
+
this.drawText(canvas, {x: rect.x, y: rect.y - 5}, showText);
|
|
71
|
+
if (rect.textAttribute) {
|
|
72
|
+
const text = `${~~rect.width} * ${~~rect.height}`;
|
|
73
|
+
const textSizeWidth = text.length * 7;
|
|
74
|
+
const marginTop = 0;
|
|
75
|
+
const textWidth = Math.max(20, rect.width - textSizeWidth);
|
|
76
|
+
this.drawText(canvas, {x: rect.x, y: rect.y + rect.height + 20 + marginTop}, rect.textAttribute, {
|
|
77
|
+
textMaxWidth: textWidth
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
ctx.restore();
|
|
82
|
+
}
|
|
83
|
+
static drawRectWithFill(canvas, rect, options = {}) {
|
|
84
|
+
const ctx = canvas.getContext("2d");
|
|
85
|
+
const {color = DEFAULT_COLOR} = options;
|
|
86
|
+
ctx.save();
|
|
87
|
+
ctx.fillStyle = color;
|
|
88
|
+
ctx.fillRect(rect.x, rect.y, rect.width, rect.height);
|
|
89
|
+
ctx.restore();
|
|
90
|
+
}
|
|
91
|
+
static drawTagByDom(parent, text, id) {
|
|
92
|
+
const parentNode = parent;
|
|
93
|
+
if (!((text == null ? void 0 : text.length) > 0)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const dom = document.createElement("div");
|
|
97
|
+
dom.innerHTML = text;
|
|
98
|
+
dom.setAttribute("id", id);
|
|
99
|
+
parentNode == null ? void 0 : parentNode.appendChild(dom);
|
|
100
|
+
return dom;
|
|
101
|
+
}
|
|
102
|
+
static drawTag(canvas, tagList) {
|
|
103
|
+
var _a;
|
|
104
|
+
const parentNode = canvas == null ? void 0 : canvas.parentNode;
|
|
105
|
+
const oldDom = window.self.document.getElementById("tagToolTag");
|
|
106
|
+
if (oldDom && parentNode && parentNode.contains(oldDom)) {
|
|
107
|
+
parentNode == null ? void 0 : parentNode.removeChild(oldDom);
|
|
108
|
+
}
|
|
109
|
+
if (!((tagList == null ? void 0 : tagList.length) > 0)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const dom = document.createElement("div");
|
|
113
|
+
dom.innerHTML = (_a = tagList.reduce((acc, cur) => {
|
|
114
|
+
return `${acc}${cur.keyName}: ${cur.value.join(` \u3001 `)}
|
|
115
|
+
`;
|
|
116
|
+
}, "")) != null ? _a : "";
|
|
117
|
+
dom.setAttribute("id", "tagToolTag");
|
|
118
|
+
parentNode == null ? void 0 : parentNode.appendChild(dom);
|
|
119
|
+
return dom;
|
|
120
|
+
}
|
|
121
|
+
static drawLineWithPointList(canvas, pointList, options = {}) {
|
|
122
|
+
if (pointList.length < 2) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const ctx = canvas.getContext("2d");
|
|
126
|
+
const {
|
|
127
|
+
color = DEFAULT_COLOR,
|
|
128
|
+
thickness = 1,
|
|
129
|
+
lineCap = "round",
|
|
130
|
+
lineType = tool.ELineTypes.Line,
|
|
131
|
+
lineDash,
|
|
132
|
+
hoverEdgeIndex
|
|
133
|
+
} = options;
|
|
134
|
+
ctx.save();
|
|
135
|
+
const setStyle = () => {
|
|
136
|
+
ctx.strokeStyle = color;
|
|
137
|
+
ctx.lineWidth = thickness;
|
|
138
|
+
ctx.lineCap = lineCap;
|
|
139
|
+
if (Array.isArray(lineDash)) {
|
|
140
|
+
ctx.setLineDash(lineDash);
|
|
141
|
+
} else {
|
|
142
|
+
ctx.setLineDash([]);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
setStyle();
|
|
146
|
+
if (lineType === tool.ELineTypes.Curve) {
|
|
147
|
+
if (hoverEdgeIndex !== void 0 && hoverEdgeIndex > -1) {
|
|
148
|
+
pointList.push(pointList[0]);
|
|
149
|
+
}
|
|
150
|
+
pointList = PolygonUtils.createSmoothCurvePointsFromPointList([...pointList], tool.SEGMENT_NUMBER);
|
|
151
|
+
if (hoverEdgeIndex !== void 0 && hoverEdgeIndex > -1) {
|
|
152
|
+
pointList = pointList.slice((tool.SEGMENT_NUMBER + 1) * hoverEdgeIndex, (tool.SEGMENT_NUMBER + 1) * (hoverEdgeIndex + 1));
|
|
153
|
+
}
|
|
154
|
+
} else if (hoverEdgeIndex !== void 0 && hoverEdgeIndex > -1) {
|
|
155
|
+
pointList = [...pointList, pointList[0]];
|
|
156
|
+
pointList = pointList.slice(hoverEdgeIndex, hoverEdgeIndex + 2);
|
|
157
|
+
}
|
|
158
|
+
const specialEdgeList = [];
|
|
159
|
+
ctx.beginPath();
|
|
160
|
+
ctx.moveTo(pointList[0].x, pointList[0].y);
|
|
161
|
+
for (let i = 0; i < pointList.length - 1; i++) {
|
|
162
|
+
if (pointList[i].specialEdge) {
|
|
163
|
+
specialEdgeList.push({
|
|
164
|
+
i1: i,
|
|
165
|
+
i2: i + 1
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
ctx.lineTo(pointList[i + 1].x, pointList[i + 1].y);
|
|
169
|
+
}
|
|
170
|
+
ctx.stroke();
|
|
171
|
+
ctx.save();
|
|
172
|
+
ctx.lineWidth = thickness * 0.8;
|
|
173
|
+
ctx.lineCap = "butt";
|
|
174
|
+
ctx.strokeStyle = "white";
|
|
175
|
+
ctx.setLineDash([3, 3]);
|
|
176
|
+
specialEdgeList.forEach((v) => {
|
|
177
|
+
const point1 = pointList[v.i1];
|
|
178
|
+
const point2 = pointList[v.i2];
|
|
179
|
+
ctx.beginPath();
|
|
180
|
+
ctx.moveTo(point1.x, point1.y);
|
|
181
|
+
ctx.lineTo(point2.x, point2.y);
|
|
182
|
+
ctx.stroke();
|
|
183
|
+
});
|
|
184
|
+
ctx.restore();
|
|
185
|
+
const DEFAULT_SPECIAL_POINT_RADIUS = 4;
|
|
186
|
+
const DEFAULT_BORDER = 2;
|
|
187
|
+
pointList.forEach((p) => {
|
|
188
|
+
if (p.specialPoint) {
|
|
189
|
+
this.drawSpecialPoint(canvas, p, DEFAULT_SPECIAL_POINT_RADIUS + DEFAULT_BORDER, color);
|
|
190
|
+
this.drawSpecialPoint(canvas, p, DEFAULT_SPECIAL_POINT_RADIUS, "white");
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
ctx.restore();
|
|
194
|
+
return pointList;
|
|
195
|
+
}
|
|
196
|
+
static drawCircle(canvas, anchorPoint, radius, options = {}) {
|
|
197
|
+
const ctx = canvas.getContext("2d");
|
|
198
|
+
const {
|
|
199
|
+
startAngleDeg = 0,
|
|
200
|
+
endAngleDeg = 360,
|
|
201
|
+
thickness = 1,
|
|
202
|
+
color = DEFAULT_COLOR,
|
|
203
|
+
fill = DEFAULT_COLOR
|
|
204
|
+
} = options;
|
|
205
|
+
const startAngleRad = UnitUtils.deg2rad(startAngleDeg);
|
|
206
|
+
const endAngleRad = UnitUtils.deg2rad(endAngleDeg);
|
|
207
|
+
ctx.save();
|
|
208
|
+
ctx.beginPath();
|
|
209
|
+
ctx.strokeStyle = color;
|
|
210
|
+
ctx.fillStyle = fill;
|
|
211
|
+
ctx.lineWidth = thickness;
|
|
212
|
+
ctx.arc(anchorPoint.x, anchorPoint.y, radius, startAngleRad, endAngleRad, false);
|
|
213
|
+
ctx.stroke();
|
|
214
|
+
if (fill) {
|
|
215
|
+
ctx.fill();
|
|
216
|
+
}
|
|
217
|
+
ctx.closePath();
|
|
218
|
+
ctx.restore();
|
|
219
|
+
}
|
|
220
|
+
static drawCircleWithFill(canvas, anchorPoint, radius = 3, options = {}) {
|
|
221
|
+
const ctx = canvas.getContext("2d");
|
|
222
|
+
const {color = DEFAULT_COLOR} = options;
|
|
223
|
+
ctx.save();
|
|
224
|
+
const startAngleRad = UnitUtils.deg2rad(0);
|
|
225
|
+
const endAngleRad = UnitUtils.deg2rad(360);
|
|
226
|
+
ctx.fillStyle = color;
|
|
227
|
+
ctx.beginPath();
|
|
228
|
+
ctx.arc(anchorPoint.x, anchorPoint.y, radius, startAngleRad, endAngleRad, false);
|
|
229
|
+
ctx.fill();
|
|
230
|
+
ctx.restore();
|
|
231
|
+
}
|
|
232
|
+
static drawSpecialPoint(canvas, point, pointRadius = 6, fillStyle) {
|
|
233
|
+
const ctx = canvas.getContext("2d");
|
|
234
|
+
const {x, y} = point;
|
|
235
|
+
ctx.save();
|
|
236
|
+
ctx.beginPath();
|
|
237
|
+
ctx.fillStyle = fillStyle;
|
|
238
|
+
const newPointRadius = pointRadius * 1.5;
|
|
239
|
+
const xl = newPointRadius * Math.sqrt(3) / 2;
|
|
240
|
+
const yl = newPointRadius / 2;
|
|
241
|
+
ctx.moveTo(x, y - newPointRadius);
|
|
242
|
+
ctx.lineTo(x - xl, y + yl);
|
|
243
|
+
ctx.lineTo(x + xl, y + yl);
|
|
244
|
+
ctx.closePath();
|
|
245
|
+
ctx.fill();
|
|
246
|
+
ctx.restore();
|
|
247
|
+
}
|
|
248
|
+
static drawPolygon(canvas, pointList, options = {}) {
|
|
249
|
+
const {isClose = false, lineType = tool.ELineTypes.Line} = options;
|
|
250
|
+
if (isClose === true) {
|
|
251
|
+
pointList = [...pointList, pointList[0]];
|
|
252
|
+
}
|
|
253
|
+
if (lineType === tool.ELineTypes.Curve) {
|
|
254
|
+
pointList = PolygonUtils.createSmoothCurvePointsFromPointList([...pointList]);
|
|
255
|
+
}
|
|
256
|
+
this.drawLineWithPointList(canvas, pointList, __spreadProps(__spreadValues({}, options), {
|
|
257
|
+
lineType: tool.ELineTypes.Line
|
|
258
|
+
}));
|
|
259
|
+
return pointList;
|
|
260
|
+
}
|
|
261
|
+
static drawPolygonWithFill(canvas, pointList, options = {}) {
|
|
262
|
+
if (pointList.length < 2) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const ctx = canvas.getContext("2d");
|
|
266
|
+
const {color = DEFAULT_COLOR, lineType = tool.ELineTypes.Line} = options;
|
|
267
|
+
ctx.save();
|
|
268
|
+
ctx.fillStyle = color;
|
|
269
|
+
ctx.beginPath();
|
|
270
|
+
if (lineType === tool.ELineTypes.Curve) {
|
|
271
|
+
pointList = PolygonUtils.createSmoothCurvePointsFromPointList([...pointList, pointList[0]]);
|
|
272
|
+
}
|
|
273
|
+
const [startPoint, ...otherPointList] = pointList;
|
|
274
|
+
ctx.moveTo(startPoint.x, startPoint.y);
|
|
275
|
+
otherPointList.forEach((point) => {
|
|
276
|
+
ctx.lineTo(point.x, point.y);
|
|
277
|
+
});
|
|
278
|
+
ctx.fill();
|
|
279
|
+
ctx.restore();
|
|
280
|
+
return pointList;
|
|
281
|
+
}
|
|
282
|
+
static drawPolygonWithFillAndLine(canvas, pointList, options = {}) {
|
|
283
|
+
const {strokeColor, fillColor, thickness, lineCap, isClose, lineType} = options;
|
|
284
|
+
const newPointList = this.drawPolygon(canvas, pointList, {
|
|
285
|
+
color: strokeColor,
|
|
286
|
+
thickness,
|
|
287
|
+
lineCap,
|
|
288
|
+
isClose,
|
|
289
|
+
lineType
|
|
290
|
+
});
|
|
291
|
+
this.drawPolygonWithFill(canvas, pointList, {color: fillColor, lineType});
|
|
292
|
+
return newPointList;
|
|
293
|
+
}
|
|
294
|
+
static drawPolygonWithKeyPoint(canvas, pointList, options = {}) {
|
|
295
|
+
const {pointColor = "white", strokeColor} = options;
|
|
296
|
+
const newPointList = this.drawPolygon(canvas, pointList, options);
|
|
297
|
+
newPointList.forEach((point) => {
|
|
298
|
+
this.drawCircleWithFill(canvas, point, 4, {color: strokeColor});
|
|
299
|
+
this.drawCircleWithFill(canvas, point, 3, {color: pointColor});
|
|
300
|
+
});
|
|
301
|
+
return newPointList;
|
|
302
|
+
}
|
|
303
|
+
static drawSelectedPolygonWithFillAndLine(canvas, pointList, options = {}) {
|
|
304
|
+
const {pointColor = "white", strokeColor} = options;
|
|
305
|
+
const newPointList = this.drawPolygonWithFillAndLine(canvas, pointList, options);
|
|
306
|
+
newPointList.forEach((point) => {
|
|
307
|
+
this.drawCircleWithFill(canvas, point, 4, {color: strokeColor});
|
|
308
|
+
this.drawCircleWithFill(canvas, point, 3, {color: pointColor});
|
|
309
|
+
});
|
|
310
|
+
return newPointList;
|
|
311
|
+
}
|
|
312
|
+
static drawText(canvas, startPoint, text, options = {}) {
|
|
313
|
+
if (!text) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const ctx = canvas.getContext("2d");
|
|
317
|
+
const {
|
|
318
|
+
color = DEFAULT_COLOR,
|
|
319
|
+
font = tool.DEFAULT_FONT,
|
|
320
|
+
shadowColor = "",
|
|
321
|
+
shadowBlur = 0,
|
|
322
|
+
shadowOffsetX = 0,
|
|
323
|
+
shadowOffsetY = 0,
|
|
324
|
+
textMaxWidth = 164,
|
|
325
|
+
offsetX = 0,
|
|
326
|
+
offsetY = 0,
|
|
327
|
+
textAlign = "start",
|
|
328
|
+
lineHeight
|
|
329
|
+
} = options;
|
|
330
|
+
ctx.save();
|
|
331
|
+
ctx.textAlign = textAlign;
|
|
332
|
+
ctx.fillStyle = color != null ? color : "white";
|
|
333
|
+
ctx.font = font;
|
|
334
|
+
ctx.shadowColor = shadowColor;
|
|
335
|
+
ctx.shadowOffsetX = shadowOffsetX;
|
|
336
|
+
ctx.shadowOffsetY = shadowOffsetY;
|
|
337
|
+
ctx.shadowBlur = shadowBlur;
|
|
338
|
+
this.wrapText(canvas, `${text}`, startPoint.x + offsetX, startPoint.y + offsetY, textMaxWidth, lineHeight);
|
|
339
|
+
ctx.restore();
|
|
340
|
+
}
|
|
341
|
+
static wrapText(canvas, text, x, y, maxWidth, lineHeight) {
|
|
342
|
+
if (typeof text !== "string" || typeof x !== "number" || typeof y !== "number") {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const context = canvas.getContext("2d");
|
|
346
|
+
if (typeof maxWidth === "undefined") {
|
|
347
|
+
maxWidth = canvas && canvas.width || 300;
|
|
348
|
+
}
|
|
349
|
+
if (typeof lineHeight === "undefined") {
|
|
350
|
+
lineHeight = canvas && parseInt(window.getComputedStyle(canvas).lineHeight, 10) || parseInt(window.getComputedStyle(document.body).lineHeight, 10);
|
|
351
|
+
}
|
|
352
|
+
const arrParagraph = text.split("\n");
|
|
353
|
+
for (let i = 0; i < arrParagraph.length; i++) {
|
|
354
|
+
const arrText = arrParagraph[i].split("");
|
|
355
|
+
let line = "";
|
|
356
|
+
for (let n = 0; n < arrText.length; n++) {
|
|
357
|
+
const testLine = line + arrText[n];
|
|
358
|
+
const metrics = context.measureText(testLine);
|
|
359
|
+
const testWidth = metrics.width;
|
|
360
|
+
if (!maxWidth) {
|
|
361
|
+
maxWidth = 300;
|
|
362
|
+
}
|
|
363
|
+
if (testWidth > maxWidth && n > 0) {
|
|
364
|
+
context.fillText(line, x, y);
|
|
365
|
+
line = arrText[n];
|
|
366
|
+
y += lineHeight;
|
|
367
|
+
} else {
|
|
368
|
+
line = testLine;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
context.fillText(line, x, y);
|
|
372
|
+
y += lineHeight;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
static drawArrow(ctx, startPoint, endPoint, options = {}) {
|
|
376
|
+
const {color = DEFAULT_COLOR, thickness = 1, lineCap = "round", theta = 30, headLen = 10} = options;
|
|
377
|
+
const angle = Math.atan2(startPoint.y - endPoint.y, startPoint.x - endPoint.x) * 180 / Math.PI;
|
|
378
|
+
const angle1 = (angle + theta) * Math.PI / 180;
|
|
379
|
+
const angle2 = (angle - theta) * Math.PI / 180;
|
|
380
|
+
const topX = headLen * Math.cos(angle1);
|
|
381
|
+
const topY = headLen * Math.sin(angle1);
|
|
382
|
+
const botX = headLen * Math.cos(angle2);
|
|
383
|
+
const botY = headLen * Math.sin(angle2);
|
|
384
|
+
ctx.save();
|
|
385
|
+
ctx.strokeStyle = color;
|
|
386
|
+
ctx.lineWidth = thickness;
|
|
387
|
+
ctx.lineCap = lineCap;
|
|
388
|
+
ctx.beginPath();
|
|
389
|
+
ctx.moveTo(endPoint.x + topX, endPoint.y + topY);
|
|
390
|
+
ctx.lineTo(endPoint.x, endPoint.y);
|
|
391
|
+
ctx.lineTo(endPoint.x + botX, endPoint.y + botY);
|
|
392
|
+
ctx.stroke();
|
|
393
|
+
ctx.restore();
|
|
394
|
+
}
|
|
395
|
+
static drawArrowByCanvas(canvas, startPoint, endPoint, options = {}) {
|
|
396
|
+
const ctx = canvas.getContext("2d");
|
|
397
|
+
this.drawArrow(ctx, startPoint, endPoint, options);
|
|
398
|
+
}
|
|
399
|
+
static drawCuboid(canvas, cuboid, options = {}) {
|
|
400
|
+
const {backPoints, direction, frontPoints} = cuboid;
|
|
401
|
+
const {strokeColor, thickness, fillColor} = options;
|
|
402
|
+
const defaultStyle = {
|
|
403
|
+
color: strokeColor,
|
|
404
|
+
thickness
|
|
405
|
+
};
|
|
406
|
+
if (backPoints) {
|
|
407
|
+
const backPointList = AxisUtils["default"].transformPlain2PointList(backPoints);
|
|
408
|
+
_DrawUtils.drawPolygon(canvas, backPointList, __spreadProps(__spreadValues({}, defaultStyle), {isClose: true}));
|
|
409
|
+
const sideLine = CuboidUtils.getCuboidAllSideLine(cuboid);
|
|
410
|
+
sideLine == null ? void 0 : sideLine.forEach((line) => {
|
|
411
|
+
_DrawUtils.drawLine(canvas, line.p1, line.p2, __spreadValues({}, defaultStyle));
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
const pointList = AxisUtils["default"].transformPlain2PointList(frontPoints);
|
|
415
|
+
if (direction && backPoints && frontPoints) {
|
|
416
|
+
const points = CuboidUtils.getPointListsByDirection({direction, frontPoints, backPoints});
|
|
417
|
+
if (points) {
|
|
418
|
+
_DrawUtils.drawPolygonWithFill(canvas, points, {color: fillColor});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
_DrawUtils.drawPolygon(canvas, pointList, __spreadProps(__spreadValues({}, defaultStyle), {isClose: true}));
|
|
422
|
+
}
|
|
423
|
+
static drawCuboidWithText(canvas, cuboid, options, dataConfig) {
|
|
424
|
+
const {strokeColor} = options;
|
|
425
|
+
const textColor = strokeColor;
|
|
426
|
+
const {config, hiddenText, selectedID, headerText, bottomText} = dataConfig;
|
|
427
|
+
const {backPoints, frontPoints, textAttribute} = cuboid;
|
|
428
|
+
const frontPointsSizeWidth = frontPoints.br.x - frontPoints.bl.x;
|
|
429
|
+
_DrawUtils.drawCuboid(canvas, cuboid, options);
|
|
430
|
+
let showText = "";
|
|
431
|
+
if ((config == null ? void 0 : config.isShowOrder) && cuboid.order && (cuboid == null ? void 0 : cuboid.order) > 0) {
|
|
432
|
+
showText = `${cuboid.order}`;
|
|
433
|
+
}
|
|
434
|
+
if (cuboid.attribute) {
|
|
435
|
+
showText = `${showText} ${AttributeUtils["default"].getAttributeShowText(cuboid.attribute, config == null ? void 0 : config.attributeList)}`;
|
|
436
|
+
}
|
|
437
|
+
if (!hiddenText && backPoints && showText) {
|
|
438
|
+
_DrawUtils.drawText(canvas, {x: backPoints.tl.x, y: backPoints.tl.y - 5}, headerText != null ? headerText : showText, {
|
|
439
|
+
color: strokeColor,
|
|
440
|
+
textMaxWidth: 300
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
const textPosition = CuboidUtils.getCuboidTextAttributeOffset({
|
|
444
|
+
cuboid,
|
|
445
|
+
currentPos: {x: 0, y: 0},
|
|
446
|
+
zoom: 1,
|
|
447
|
+
topOffset: 16,
|
|
448
|
+
leftOffset: 0
|
|
449
|
+
});
|
|
450
|
+
if (!hiddenText && textAttribute && cuboid.id !== selectedID) {
|
|
451
|
+
const textWidth = Math.max(20, frontPointsSizeWidth * 0.8);
|
|
452
|
+
_DrawUtils.drawText(canvas, {x: textPosition.left, y: textPosition.top}, bottomText != null ? bottomText : textAttribute, {
|
|
453
|
+
color: textColor,
|
|
454
|
+
textMaxWidth: textWidth
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
let DrawUtils = _DrawUtils;
|
|
460
|
+
DrawUtils.drawImg = (canvas, imgNode, options = {}) => {
|
|
461
|
+
const ctx = canvas.getContext("2d");
|
|
462
|
+
const {zoom = DEFAULT_ZOOM, currentPos = DEFAULT_CURRENT_POS, rotate = DEFAULT_ROTATE, imgAttribute} = options;
|
|
463
|
+
ctx.save();
|
|
464
|
+
switch (rotate) {
|
|
465
|
+
case 0:
|
|
466
|
+
ctx.translate(currentPos.x, currentPos.y);
|
|
467
|
+
break;
|
|
468
|
+
case 90:
|
|
469
|
+
ctx.translate(currentPos.x + imgNode.height * zoom, currentPos.y);
|
|
470
|
+
ctx.rotate(90 * Math.PI / 180);
|
|
471
|
+
break;
|
|
472
|
+
case 180:
|
|
473
|
+
ctx.translate(currentPos.x + imgNode.width * zoom, currentPos.y + imgNode.height * zoom);
|
|
474
|
+
ctx.rotate(Math.PI);
|
|
475
|
+
break;
|
|
476
|
+
case 270:
|
|
477
|
+
ctx.translate(currentPos.x, currentPos.y + imgNode.width * zoom);
|
|
478
|
+
ctx.rotate(270 * Math.PI / 180);
|
|
479
|
+
break;
|
|
480
|
+
default:
|
|
481
|
+
ctx.translate(currentPos.x, currentPos.y);
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
if (imgAttribute) {
|
|
485
|
+
const {contrast, saturation, brightness} = imgAttribute;
|
|
486
|
+
ctx.filter = `saturate(${saturation + 100}%) contrast(${contrast + 100}%) brightness(${brightness + 100}%)`;
|
|
487
|
+
}
|
|
488
|
+
ctx.drawImage(imgNode, 0, 0, imgNode.width * zoom, imgNode.height * zoom);
|
|
489
|
+
ctx.restore();
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
module.exports = DrawUtils;
|
|
@@ -1 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tool = require('../../constant/tool.js');
|
|
6
|
+
var ScribbleTool = require('../../core/toolOperation/ScribbleTool.js');
|
|
7
|
+
var cuboidOperation = require('../../core/toolOperation/cuboidOperation.js');
|
|
8
|
+
var pointCloud2dOperation = require('../../core/toolOperation/pointCloud2dOperation.js');
|
|
9
|
+
var checkOperation = require('../../core/toolOperation/checkOperation.js');
|
|
10
|
+
var polygonOperation = require('../../core/toolOperation/polygonOperation.js');
|
|
11
|
+
var rectOperation = require('../../core/toolOperation/rectOperation.js');
|
|
12
|
+
var tagOperation = require('../../core/toolOperation/tagOperation.js');
|
|
13
|
+
var LineToolOperation = require('../../core/toolOperation/LineToolOperation.js');
|
|
14
|
+
var pointOperation = require('../../core/toolOperation/pointOperation.js');
|
|
15
|
+
var TextToolOperation = require('../../core/toolOperation/TextToolOperation.js');
|
|
16
|
+
var segmentByRect = require('../../core/toolOperation/segmentByRect.js');
|
|
17
|
+
var CommonToolUtils = require('./CommonToolUtils.js');
|
|
18
|
+
|
|
19
|
+
const getCurrentOperation = (toolName) => {
|
|
20
|
+
switch (toolName) {
|
|
21
|
+
case tool.EToolName.Rect:
|
|
22
|
+
case tool.EToolName.RectTrack:
|
|
23
|
+
return rectOperation.RectOperation;
|
|
24
|
+
case tool.EToolName.SegmentByRect:
|
|
25
|
+
return segmentByRect;
|
|
26
|
+
case tool.EToolName.Tag:
|
|
27
|
+
return tagOperation;
|
|
28
|
+
case tool.EToolName.Polygon:
|
|
29
|
+
return polygonOperation;
|
|
30
|
+
case tool.ECheckModel.Check:
|
|
31
|
+
return checkOperation;
|
|
32
|
+
case tool.EToolName.Line:
|
|
33
|
+
return LineToolOperation["default"];
|
|
34
|
+
case tool.EToolName.Point:
|
|
35
|
+
return pointOperation;
|
|
36
|
+
case tool.EToolName.Text:
|
|
37
|
+
return TextToolOperation;
|
|
38
|
+
case tool.EToolName.ScribbleTool:
|
|
39
|
+
return ScribbleTool;
|
|
40
|
+
case tool.EToolName.Cuboid:
|
|
41
|
+
return cuboidOperation;
|
|
42
|
+
case tool.EToolName.PointCloudPolygon:
|
|
43
|
+
return pointCloud2dOperation;
|
|
44
|
+
default:
|
|
45
|
+
throw new Error("not match tool");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
class EnhanceCommonToolUtils extends CommonToolUtils {
|
|
49
|
+
}
|
|
50
|
+
EnhanceCommonToolUtils.getCurrentOperation = getCurrentOperation;
|
|
51
|
+
|
|
52
|
+
exports["default"] = EnhanceCommonToolUtils;
|
|
53
|
+
exports.getCurrentOperation = getCurrentOperation;
|