@labelbee/lb-annotation 1.8.0 → 1.9.0-alpha.2
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/README.md +65 -0
- package/dist/index.js +20 -9
- package/dist/types/constant/tool.d.ts +3 -1
- package/dist/types/core/index.d.ts +24 -4
- package/dist/types/core/pointCloud/OrbitControls.d.ts +60 -0
- package/dist/types/core/pointCloud/PCDLoader.d.ts +11 -0
- package/dist/types/core/pointCloud/annotation.d.ts +47 -0
- package/dist/types/core/pointCloud/cache.d.ts +16 -0
- package/dist/types/core/pointCloud/index.d.ts +325 -0
- package/dist/types/core/scheduler.d.ts +71 -0
- package/dist/types/core/toolOperation/basicToolOperation.d.ts +20 -2
- package/dist/types/core/toolOperation/eventListener.d.ts +2 -2
- package/dist/types/core/toolOperation/pointCloud2dOperation.d.ts +80 -0
- package/dist/types/core/toolOperation/polygonOperation.d.ts +21 -7
- package/dist/types/core/toolOperation/segmentByRect.d.ts +31 -0
- package/dist/types/index.d.ts +9 -3
- package/dist/types/newCore/CanvasScheduler.d.ts +31 -0
- package/dist/types/newCore/index.d.ts +1 -0
- package/dist/types/utils/MathUtils.d.ts +6 -0
- package/dist/types/utils/tool/CommonToolUtils.d.ts +0 -13
- package/dist/types/utils/tool/EnhanceCommonToolUtils.d.ts +20 -0
- package/dist/types/utils/tool/PolygonUtils.d.ts +1 -0
- package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +3 -0
- package/es/assets/attributeIcon/icon_editFEN.svg.js +3 -0
- package/es/assets/attributeIcon/icon_editHUANG.svg.js +3 -0
- package/es/assets/attributeIcon/icon_editLAN.svg.js +3 -0
- package/es/assets/attributeIcon/icon_editLV.svg.js +3 -0
- package/es/assets/attributeIcon/icon_editQING.svg.js +3 -0
- package/es/constant/annotation.js +68 -0
- package/es/constant/annotationTask.js +25 -0
- package/es/constant/defaultConfig.js +260 -0
- package/es/constant/keyCode.js +36 -0
- package/es/constant/style.js +67 -0
- package/es/constant/tool.js +183 -0
- package/es/core/index.js +145 -0
- package/es/core/pointCloud/OrbitControls.js +661 -0
- package/es/core/pointCloud/PCDLoader.js +238 -0
- package/es/core/pointCloud/annotation.js +98 -0
- package/es/core/pointCloud/cache.js +42 -0
- package/es/core/pointCloud/index.js +771 -0
- package/es/core/scheduler.js +184 -0
- package/es/core/toolOperation/LineToolOperation.js +1369 -0
- package/es/core/toolOperation/TextToolOperation.js +129 -0
- package/es/core/toolOperation/ViewOperation.js +410 -0
- package/es/core/toolOperation/basicToolOperation.js +817 -0
- package/es/core/toolOperation/checkOperation.js +206 -0
- package/es/core/toolOperation/eventListener.js +35 -0
- package/es/core/toolOperation/measureOperation.js +39 -0
- package/es/core/toolOperation/pointCloud2dOperation.js +197 -0
- package/es/core/toolOperation/pointOperation.js +603 -0
- package/es/core/toolOperation/polygonOperation.js +1201 -0
- package/es/core/toolOperation/rectOperation.js +1170 -0
- package/es/core/toolOperation/segmentByRect.js +172 -0
- package/es/core/toolOperation/tagOperation.js +215 -0
- package/es/core/toolOperation/textAttributeClass.js +201 -0
- package/es/index.js +25 -14
- package/es/locales/constants.js +21 -0
- package/es/locales/en_US/message.js +22 -0
- package/es/locales/index.js +17 -0
- package/es/locales/zh_CN/message.js +22 -0
- package/es/newCore/CanvasScheduler.js +31 -0
- package/es/utils/ActionsHistory.js +78 -0
- package/es/utils/ImgUtils.js +20 -0
- package/es/utils/MathUtils.js +283 -0
- package/es/utils/VectorUtils.js +23 -0
- package/es/utils/tool/AttributeUtils.js +196 -0
- package/es/utils/tool/AxisUtils.js +254 -0
- package/es/utils/tool/CanvasUtils.js +60 -0
- package/es/utils/tool/CommonToolUtils.js +172 -0
- package/es/utils/tool/CurrentOperation.js +35 -0
- package/es/utils/tool/DblClickEventListener.js +100 -0
- package/es/utils/tool/DrawUtils.js +424 -0
- package/es/utils/tool/EnhanceCommonToolUtils.js +39 -0
- package/es/utils/tool/ImgPosUtils.js +56 -0
- package/es/utils/tool/LineToolUtils.js +255 -0
- package/es/utils/tool/MarkerUtils.js +9 -0
- package/es/utils/tool/PolygonUtils.js +458 -0
- package/es/utils/tool/RectUtils.js +153 -0
- package/es/utils/tool/RenderDomClass.js +68 -0
- package/es/utils/tool/RenderDomUtils.js +29 -0
- package/es/utils/tool/StyleUtils.js +29 -0
- package/es/utils/tool/TagUtils.js +127 -0
- package/es/utils/tool/UnitUtils.js +10 -0
- package/es/utils/tool/ZoomUtils.js +70 -0
- package/es/utils/tool/polygonTool.js +126 -0
- package/es/utils/uuid.js +24 -0
- package/package.json +6 -4
package/es/core/index.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { ELang } from '../constant/annotation.js';
|
|
2
|
+
import { getConfig, styleDefaultConfig } from '../constant/defaultConfig.js';
|
|
3
|
+
import { HybridToolUtils, ToolScheduler } from './scheduler.js';
|
|
4
|
+
|
|
5
|
+
var __async = (__this, __arguments, generator) => {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
var fulfilled = (value) => {
|
|
8
|
+
try {
|
|
9
|
+
step(generator.next(value));
|
|
10
|
+
} catch (e) {
|
|
11
|
+
reject(e);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var rejected = (value) => {
|
|
15
|
+
try {
|
|
16
|
+
step(generator.throw(value));
|
|
17
|
+
} catch (e) {
|
|
18
|
+
reject(e);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
22
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
const loadImage = (imgSrc) => {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const img = document.createElement("img");
|
|
28
|
+
img.crossOrigin = "Anonymous";
|
|
29
|
+
img.onerror = (e) => {
|
|
30
|
+
console.error(e);
|
|
31
|
+
reject(img);
|
|
32
|
+
};
|
|
33
|
+
img.src = imgSrc;
|
|
34
|
+
img.onload = () => {
|
|
35
|
+
resolve(img);
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
class AnnotationEngine {
|
|
40
|
+
constructor(props) {
|
|
41
|
+
this.setImgSrc = (imgSrc) => __async(this, null, function* () {
|
|
42
|
+
const imgNode = yield loadImage(imgSrc);
|
|
43
|
+
if (!imgNode) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.setImgNode(imgNode);
|
|
47
|
+
});
|
|
48
|
+
var _a, _b;
|
|
49
|
+
this.container = props.container;
|
|
50
|
+
this.size = props.size;
|
|
51
|
+
this.toolName = props.toolName;
|
|
52
|
+
this.imgNode = props.imgNode;
|
|
53
|
+
this.config = (_a = props.config) != null ? _a : JSON.stringify(getConfig(HybridToolUtils.getTopToolName(props.toolName)));
|
|
54
|
+
this.style = (_b = props.style) != null ? _b : styleDefaultConfig;
|
|
55
|
+
this.toolScheduler = new ToolScheduler(props);
|
|
56
|
+
this.i18nLanguage = "cn";
|
|
57
|
+
this._initToolOperation();
|
|
58
|
+
}
|
|
59
|
+
setToolName(toolName, config) {
|
|
60
|
+
this.toolName = toolName;
|
|
61
|
+
const defaultConfig = config || JSON.stringify(getConfig(HybridToolUtils.getTopToolName(toolName)));
|
|
62
|
+
this.config = defaultConfig;
|
|
63
|
+
this._initToolOperation();
|
|
64
|
+
}
|
|
65
|
+
setImgNode(imgNode, basicImgInfo) {
|
|
66
|
+
this.toolScheduler.setImgNode(imgNode, basicImgInfo);
|
|
67
|
+
this.imgNode = imgNode;
|
|
68
|
+
}
|
|
69
|
+
setSize(size) {
|
|
70
|
+
this.size = size;
|
|
71
|
+
this.toolScheduler.setSize(size);
|
|
72
|
+
}
|
|
73
|
+
setStyle(style) {
|
|
74
|
+
this.style = style;
|
|
75
|
+
}
|
|
76
|
+
_initToolOperation() {
|
|
77
|
+
this.toolScheduler.destroyAllLayer();
|
|
78
|
+
let toolList = [];
|
|
79
|
+
const config = {hiddenImg: true};
|
|
80
|
+
if (HybridToolUtils.isSingleTool(this.toolName)) {
|
|
81
|
+
toolList = [this.toolName];
|
|
82
|
+
Object.assign(config, {hiddenImg: false});
|
|
83
|
+
} else {
|
|
84
|
+
toolList = this.toolName;
|
|
85
|
+
}
|
|
86
|
+
if (toolList.length > 1) {
|
|
87
|
+
this.toolScheduler.createOperation(void 0, this.imgNode);
|
|
88
|
+
}
|
|
89
|
+
toolList.forEach((toolName, i) => {
|
|
90
|
+
const toolInstance = this.toolScheduler.createOperation(toolName, void 0, config);
|
|
91
|
+
if (i === toolList.length - 1) {
|
|
92
|
+
this.toolInstance = toolInstance;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
this.setLang(this.i18nLanguage);
|
|
96
|
+
}
|
|
97
|
+
setBasicInfo(dependToolName, basicResult) {
|
|
98
|
+
this.dependToolName = dependToolName;
|
|
99
|
+
this.basicResult = basicResult;
|
|
100
|
+
this.toolInstance.setDependName(dependToolName);
|
|
101
|
+
this.toolInstance.setBasicResult(basicResult);
|
|
102
|
+
this.toolInstance.renderBasicCanvas();
|
|
103
|
+
}
|
|
104
|
+
clearBasicResult() {
|
|
105
|
+
this.setBasicInfo();
|
|
106
|
+
}
|
|
107
|
+
forbidOperation() {
|
|
108
|
+
this.toolInstance.setForbidOperation(true);
|
|
109
|
+
}
|
|
110
|
+
launchOperation() {
|
|
111
|
+
this.toolInstance.setForbidOperation(false);
|
|
112
|
+
}
|
|
113
|
+
setLang(i18nLanguage) {
|
|
114
|
+
this.i18nLanguage = i18nLanguage;
|
|
115
|
+
switch (i18nLanguage) {
|
|
116
|
+
case "cn":
|
|
117
|
+
this.toolInstance.setLang(ELang.Zh);
|
|
118
|
+
break;
|
|
119
|
+
case "en":
|
|
120
|
+
this.toolInstance.setLang(ELang.US);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
setDataInjectionAtCreation(dataInjectionAtCreation) {
|
|
125
|
+
this.toolInstance.setDataInjectionAtCreation(dataInjectionAtCreation);
|
|
126
|
+
}
|
|
127
|
+
setRenderEnhance(renderEnhance) {
|
|
128
|
+
this.toolInstance.setRenderEnhance(renderEnhance);
|
|
129
|
+
}
|
|
130
|
+
switchLastTwoCanvas() {
|
|
131
|
+
const newInstance = this.toolScheduler.switchLastTwoCanvas();
|
|
132
|
+
if (newInstance) {
|
|
133
|
+
this.toolInstance = newInstance;
|
|
134
|
+
return newInstance;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
get firstToolInstance() {
|
|
138
|
+
return this.toolScheduler.getFirstToolOperation();
|
|
139
|
+
}
|
|
140
|
+
setCustomRenderStyle(customRenderStyle) {
|
|
141
|
+
this.toolInstance.setCustomRenderStyle(customRenderStyle);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export { AnnotationEngine as default };
|