@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,20 +1,68 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DrawUtils from './DrawUtils.js';
|
|
2
|
+
import StyleUtils from './StyleUtils.js';
|
|
3
|
+
|
|
4
|
+
class RenderDomClass {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
this._domMap = new Map();
|
|
7
|
+
this._container = props.container;
|
|
8
|
+
this._height = props.height;
|
|
9
|
+
}
|
|
10
|
+
wheelChange(e) {
|
|
11
|
+
e.stopPropagation();
|
|
12
|
+
}
|
|
13
|
+
clearTag(id) {
|
|
14
|
+
const parentNode = this._container;
|
|
15
|
+
const oldDom = window.self.document.getElementById(id);
|
|
16
|
+
if (oldDom && parentNode && parentNode.contains(oldDom)) {
|
|
17
|
+
oldDom.removeEventListener("wheel", this.wheelChange);
|
|
18
|
+
parentNode == null ? void 0 : parentNode.removeChild(oldDom);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
render(annotations) {
|
|
22
|
+
const oldKeys = Array.from(this._domMap.keys());
|
|
23
|
+
const newKeys = annotations.map((v) => v.id);
|
|
24
|
+
annotations.forEach((v) => {
|
|
25
|
+
const {text, textMaxWidth, color = "white", background = "rgba(0, 0, 0, 0.6)", style} = v;
|
|
26
|
+
if (this._domMap.has(v.id)) {
|
|
27
|
+
const dom = this._domMap.get(v.id);
|
|
28
|
+
if (dom) {
|
|
29
|
+
dom.innerHTML = text;
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
const dom = DrawUtils.drawTagByDom(this._container, text, v.id);
|
|
33
|
+
if (dom) {
|
|
34
|
+
dom.setAttribute("style", `
|
|
2
35
|
position: absolute;
|
|
3
36
|
top: 0;
|
|
4
37
|
right: 0;
|
|
5
38
|
z-index: 20;
|
|
6
39
|
padding: 8px 20px;
|
|
7
40
|
font-size: 15px;
|
|
8
|
-
max-width: ${
|
|
9
|
-
color: ${
|
|
41
|
+
max-width: ${textMaxWidth}px;
|
|
42
|
+
color: ${color};
|
|
10
43
|
text-align: left;
|
|
11
44
|
line-height: 32px;
|
|
12
45
|
word-break: break-all;
|
|
13
46
|
white-space: pre-wrap;
|
|
14
|
-
background: ${
|
|
47
|
+
background: ${background};
|
|
15
48
|
opacity: 0.9;
|
|
16
|
-
max-height: ${this._height
|
|
49
|
+
max-height: ${this._height * 0.8}px;
|
|
17
50
|
overflow-y: scroll;
|
|
18
51
|
clear: both;
|
|
19
|
-
${
|
|
20
|
-
`)
|
|
52
|
+
${StyleUtils.getStyle2String(style)}
|
|
53
|
+
`);
|
|
54
|
+
dom.addEventListener("wheel", this.wheelChange);
|
|
55
|
+
this._domMap.set(v.id, dom);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
oldKeys.forEach((key) => {
|
|
60
|
+
if (newKeys.indexOf(key) === -1) {
|
|
61
|
+
this.clearTag(key);
|
|
62
|
+
this._domMap.delete(key);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { RenderDomClass as default };
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Locale from '../../locales/index.js';
|
|
2
|
+
import { EMessage } from '../../locales/constants.js';
|
|
3
|
+
|
|
4
|
+
const INVALID_PAGE_CLASS_NAME = "bee-invalid-page";
|
|
5
|
+
class RenderDomUtils {
|
|
6
|
+
static renderInvalidPage(container, size, lang) {
|
|
7
|
+
const invalidDOM = document.createElement("div");
|
|
8
|
+
invalidDOM.setAttribute("style", `
|
|
2
9
|
position: absolute;
|
|
3
10
|
left: 0px;
|
|
4
11
|
top: 0px;
|
|
5
|
-
width: ${
|
|
6
|
-
height: ${
|
|
12
|
+
width: ${size.width}px;
|
|
13
|
+
height: ${size.height}px;
|
|
7
14
|
background: rgba(255, 87, 34, 1);
|
|
8
15
|
overflow: hidden;
|
|
9
16
|
color: white;
|
|
@@ -13,4 +20,12 @@ import n from"../../locales/index.js";import{EMessage as s}from"../../locales/co
|
|
|
13
20
|
font-size: 30px;
|
|
14
21
|
opacity: 0.7;
|
|
15
22
|
z-index: 30;
|
|
16
|
-
`)
|
|
23
|
+
`);
|
|
24
|
+
invalidDOM.innerHTML = Locale.getMessagesByLocale(EMessage.InvalidImage, lang);
|
|
25
|
+
invalidDOM.className = INVALID_PAGE_CLASS_NAME;
|
|
26
|
+
container.appendChild(invalidDOM);
|
|
27
|
+
return invalidDOM;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { RenderDomUtils as default };
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
class
|
|
1
|
+
class StyleUtils {
|
|
2
|
+
static getStrokeAndFill(toolStyle, valid = true, options = {}) {
|
|
3
|
+
const {isSelected = false, isHover = false} = options;
|
|
4
|
+
if (isSelected) {
|
|
5
|
+
return {
|
|
6
|
+
stroke: valid ? toolStyle.validSelected.stroke : toolStyle.invalidSelected.stroke,
|
|
7
|
+
fill: valid ? toolStyle.validSelected.fill : toolStyle.invalidSelected.fill
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
if (isHover) {
|
|
11
|
+
return {
|
|
12
|
+
stroke: valid ? toolStyle.validHover.stroke : toolStyle.invalidHover.stroke,
|
|
13
|
+
fill: valid ? toolStyle.validHover.fill : toolStyle.invalidHover.fill
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
stroke: valid ? toolStyle.valid.stroke : toolStyle.invalid.stroke,
|
|
18
|
+
fill: valid ? toolStyle.valid.fill : toolStyle.invalid.fill
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
static getStyle2String(style) {
|
|
22
|
+
if (!style) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
return Object.entries(style).reduce((acc, cur) => `${acc} ${cur[0]}: ${cur[1]};`, "");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { StyleUtils as default };
|
|
@@ -1 +1,127 @@
|
|
|
1
|
-
import
|
|
1
|
+
import uuid from '../uuid.js';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
class TagUtil {
|
|
20
|
+
static getTagKeyName(key, labelInfoSet) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
if (!labelInfoSet) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
return (_b = (_a = labelInfoSet.find((v) => v.value === key)) == null ? void 0 : _a.key) != null ? _b : "";
|
|
26
|
+
}
|
|
27
|
+
static getTagName([key = "", value = ""], labelInfoSet) {
|
|
28
|
+
if (!labelInfoSet) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
for (const i of labelInfoSet) {
|
|
32
|
+
if (i.value === key) {
|
|
33
|
+
if (!i.subSelected) {
|
|
34
|
+
console.error("\u6807\u7B7E\u89E3\u6790\u9519\u8BEF", key, value);
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
for (const j of i.subSelected) {
|
|
38
|
+
if (j.value === value) {
|
|
39
|
+
return j.key;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
static getTagNameList(result, labelInfoSet) {
|
|
46
|
+
if (Object.keys(result).length <= 0) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
return Object.entries(result).reduce((acc, cur) => {
|
|
50
|
+
const [key, value] = cur;
|
|
51
|
+
if (value && value.length > 0) {
|
|
52
|
+
const valueList = value.split(";");
|
|
53
|
+
const nameList = {
|
|
54
|
+
keyName: this.getTagKeyName(key, labelInfoSet),
|
|
55
|
+
value: valueList.map((v) => this.getTagName([key, v], labelInfoSet))
|
|
56
|
+
};
|
|
57
|
+
return [...acc, nameList];
|
|
58
|
+
}
|
|
59
|
+
return acc;
|
|
60
|
+
}, []).filter((v) => v);
|
|
61
|
+
}
|
|
62
|
+
static getTagnameListWithoutConfig(result) {
|
|
63
|
+
if (Object.keys(result).length <= 0) {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
return Object.entries(result).reduce((acc, cur) => {
|
|
67
|
+
const [key, value] = cur;
|
|
68
|
+
const valueList = value.split(";");
|
|
69
|
+
const nameList = {
|
|
70
|
+
keyName: key,
|
|
71
|
+
value: valueList
|
|
72
|
+
};
|
|
73
|
+
return [...acc, nameList];
|
|
74
|
+
}, []).filter((v) => v);
|
|
75
|
+
}
|
|
76
|
+
static judgeResultIsInInputList(key, value, inputList) {
|
|
77
|
+
if (!key || !value || !inputList) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
const a = inputList.filter((v) => {
|
|
81
|
+
if (v.value === key && v.subSelected) {
|
|
82
|
+
const resultValue = value == null ? void 0 : value.split(";");
|
|
83
|
+
return (v == null ? void 0 : v.subSelected.filter((i) => resultValue.indexOf(i.value) > -1).length) > 0;
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
});
|
|
87
|
+
return a.length > 0;
|
|
88
|
+
}
|
|
89
|
+
static getDefaultResultByConfig(inputList) {
|
|
90
|
+
return inputList.reduce((acc, cur) => {
|
|
91
|
+
if (cur.subSelected) {
|
|
92
|
+
cur.subSelected.forEach((data) => {
|
|
93
|
+
var _a;
|
|
94
|
+
if (data.isDefault) {
|
|
95
|
+
const originResult = (_a = acc[cur.value]) != null ? _a : "";
|
|
96
|
+
let originResultList = [];
|
|
97
|
+
if (originResult.length > 0) {
|
|
98
|
+
originResultList = originResult.split(";");
|
|
99
|
+
}
|
|
100
|
+
originResultList.push(data.value);
|
|
101
|
+
acc[cur.value] = originResultList.join(";");
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return acc;
|
|
106
|
+
}, {});
|
|
107
|
+
}
|
|
108
|
+
static getDefaultTagResult(inputList, basicResultList) {
|
|
109
|
+
const defaultResult = this.getDefaultResultByConfig(inputList);
|
|
110
|
+
if (basicResultList.length > 0) {
|
|
111
|
+
return basicResultList.map((v) => ({
|
|
112
|
+
id: uuid(),
|
|
113
|
+
sourceID: v.id,
|
|
114
|
+
result: __spreadValues({}, defaultResult)
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
return [
|
|
118
|
+
{
|
|
119
|
+
id: uuid(),
|
|
120
|
+
sourceID: "",
|
|
121
|
+
result: __spreadValues({}, defaultResult)
|
|
122
|
+
}
|
|
123
|
+
];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export { TagUtil as default };
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
class
|
|
1
|
+
class UnitUtils {
|
|
2
|
+
static deg2rad(angleDeg) {
|
|
3
|
+
return angleDeg * Math.PI / 180;
|
|
4
|
+
}
|
|
5
|
+
static rad2deg(angleRad) {
|
|
6
|
+
return angleRad * 180 / Math.PI;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { UnitUtils as default };
|
|
@@ -1 +1,70 @@
|
|
|
1
|
-
import{EGrowthMode
|
|
1
|
+
import { EGrowthMode } from '../../constant/annotation.js';
|
|
2
|
+
import MathUtils from '../MathUtils.js';
|
|
3
|
+
|
|
4
|
+
const ZOOM_LEVEL = [1, 5, 10, 20, 30, 50, 80, 100].concat(Array.from({length: 9}).map((i, index) => (index + 2) * 100));
|
|
5
|
+
class ZoomUtils {
|
|
6
|
+
}
|
|
7
|
+
ZoomUtils.zoomChanged = (zoom, isZoomIn, growthMode = EGrowthMode.Linear) => {
|
|
8
|
+
switch (growthMode) {
|
|
9
|
+
case EGrowthMode.Intelligence: {
|
|
10
|
+
const maxZoom = Math.max(...ZOOM_LEVEL);
|
|
11
|
+
const minZoom = Math.min(...ZOOM_LEVEL);
|
|
12
|
+
const zoomIndex = ZOOM_LEVEL.slice(0, ZOOM_LEVEL.length).findIndex((i, index) => zoom >= i && (zoom < ZOOM_LEVEL[index + 1] || i === maxZoom));
|
|
13
|
+
let newZoom;
|
|
14
|
+
if (zoomIndex === -1) {
|
|
15
|
+
if (zoom >= minZoom && zoom <= maxZoom) {
|
|
16
|
+
newZoom = isZoomIn ? maxZoom : minZoom;
|
|
17
|
+
} else {
|
|
18
|
+
newZoom = isZoomIn ? minZoom : zoom;
|
|
19
|
+
}
|
|
20
|
+
} else {
|
|
21
|
+
const newZoomIndex = isZoomIn ? zoomIndex + 1 : zoomIndex - (ZOOM_LEVEL.includes(zoom) ? 1 : 0);
|
|
22
|
+
newZoom = ZOOM_LEVEL[MathUtils.withinRange(newZoomIndex, [0, ZOOM_LEVEL.length - 1])];
|
|
23
|
+
}
|
|
24
|
+
return newZoom;
|
|
25
|
+
}
|
|
26
|
+
default: {
|
|
27
|
+
const ratio = isZoomIn ? 2 : 1 / 2;
|
|
28
|
+
return zoom * ratio;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
ZoomUtils.wheelChangePos = (imgNode, coord, operator, oldCurrentPos, options = {}) => {
|
|
33
|
+
const {zoom = 1, innerZoom = 1, basicZoom = 1, zoomMax = 1e3, rotate = 0} = options;
|
|
34
|
+
const {x, y} = oldCurrentPos;
|
|
35
|
+
const ratio = parseFloat((zoom + 1 / 10).toFixed(1)) / 5;
|
|
36
|
+
if (imgNode && coord) {
|
|
37
|
+
let {width, height} = imgNode;
|
|
38
|
+
if ([90, 270].includes(rotate)) {
|
|
39
|
+
width = imgNode.height;
|
|
40
|
+
height = imgNode.width;
|
|
41
|
+
}
|
|
42
|
+
const imgWidth = width * innerZoom;
|
|
43
|
+
const imgHeight = height * innerZoom;
|
|
44
|
+
const offsetLeft = coord.x - x;
|
|
45
|
+
const offsetTop = coord.y - y;
|
|
46
|
+
const ratioX = offsetLeft / imgWidth;
|
|
47
|
+
const ratioY = offsetTop / imgHeight;
|
|
48
|
+
let currentZoom = zoom + operator * ratio;
|
|
49
|
+
currentZoom = MathUtils.withinRange(currentZoom, [basicZoom, zoomMax]);
|
|
50
|
+
const changeX = width * currentZoom * ratioX;
|
|
51
|
+
const changeY = height * currentZoom * ratioY;
|
|
52
|
+
const currentX = x + (offsetLeft - changeX);
|
|
53
|
+
const currentY = y + (offsetTop - changeY);
|
|
54
|
+
return {
|
|
55
|
+
zoom: currentZoom,
|
|
56
|
+
currentPos: {
|
|
57
|
+
x: currentX,
|
|
58
|
+
y: currentY
|
|
59
|
+
},
|
|
60
|
+
imgInfo: {
|
|
61
|
+
width: width * currentZoom,
|
|
62
|
+
height: height * currentZoom
|
|
63
|
+
},
|
|
64
|
+
ratio
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { ZoomUtils as default };
|
|
@@ -1 +1,126 @@
|
|
|
1
|
-
import{ELineTypes
|
|
1
|
+
import { ELineTypes, SEGMENT_NUMBER } from '../../constant/tool.js';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
function createSmoothCurvePoints(points, tension = 0.5, closed = false, numberOfSegments = 16) {
|
|
23
|
+
if (points.length < 4) {
|
|
24
|
+
return points;
|
|
25
|
+
}
|
|
26
|
+
const result = [];
|
|
27
|
+
const ps = points.slice(0);
|
|
28
|
+
let x;
|
|
29
|
+
let y;
|
|
30
|
+
let t1x;
|
|
31
|
+
let t2x;
|
|
32
|
+
let t1y;
|
|
33
|
+
let t2y;
|
|
34
|
+
let c1;
|
|
35
|
+
let c2;
|
|
36
|
+
let c3;
|
|
37
|
+
let c4;
|
|
38
|
+
let st;
|
|
39
|
+
let t;
|
|
40
|
+
let i;
|
|
41
|
+
if (closed) {
|
|
42
|
+
ps.unshift(points[points.length - 1]);
|
|
43
|
+
ps.unshift(points[points.length - 2]);
|
|
44
|
+
ps.unshift(points[points.length - 1]);
|
|
45
|
+
ps.unshift(points[points.length - 2]);
|
|
46
|
+
ps.push(points[0]);
|
|
47
|
+
ps.push(points[1]);
|
|
48
|
+
} else {
|
|
49
|
+
ps.unshift(points[1]);
|
|
50
|
+
ps.unshift(points[0]);
|
|
51
|
+
ps.push(points[points.length - 2]);
|
|
52
|
+
ps.push(points[points.length - 1]);
|
|
53
|
+
}
|
|
54
|
+
for (i = 2; i < ps.length - 4; i += 2) {
|
|
55
|
+
t1x = (ps[i + 2] - ps[i - 2]) * tension;
|
|
56
|
+
t2x = (ps[i + 4] - ps[i - 0]) * tension;
|
|
57
|
+
t1y = (ps[i + 3] - ps[i - 1]) * tension;
|
|
58
|
+
t2y = (ps[i + 5] - ps[i + 1]) * tension;
|
|
59
|
+
for (t = 0; t <= numberOfSegments; t++) {
|
|
60
|
+
st = t / numberOfSegments;
|
|
61
|
+
c1 = 2 * Math.pow(st, 3) - 3 * Math.pow(st, 2) + 1;
|
|
62
|
+
c2 = -(2 * Math.pow(st, 3)) + 3 * Math.pow(st, 2);
|
|
63
|
+
c3 = Math.pow(st, 3) - 2 * Math.pow(st, 2) + st;
|
|
64
|
+
c4 = Math.pow(st, 3) - Math.pow(st, 2);
|
|
65
|
+
x = c1 * ps[i] + c2 * ps[i + 2] + c3 * t1x + c4 * t2x;
|
|
66
|
+
y = c1 * ps[i + 1] + c2 * ps[i + 3] + c3 * t1y + c4 * t2y;
|
|
67
|
+
result.push(x);
|
|
68
|
+
result.push(y);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const formatResult = [];
|
|
72
|
+
for (let j = 0; j < result.length - 1; j += 2) {
|
|
73
|
+
formatResult.push({
|
|
74
|
+
x: result[j],
|
|
75
|
+
y: result[j + 1]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
if (closed) {
|
|
79
|
+
for (let j = 0; j < numberOfSegments + 1; j++) {
|
|
80
|
+
const d = formatResult.shift();
|
|
81
|
+
formatResult.push(d);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return formatResult;
|
|
85
|
+
}
|
|
86
|
+
const createSmoothCurvePointsFromPointList = (pointList, numberOfSegments = 16) => createSmoothCurvePoints(pointList.reduce((acc, cur) => {
|
|
87
|
+
return [...acc, cur.x, cur.y];
|
|
88
|
+
}, []), 0.5, false, numberOfSegments);
|
|
89
|
+
function isInPolygon(checkPoint, polygonPoints, lineType = ELineTypes.Line) {
|
|
90
|
+
let counter = 0;
|
|
91
|
+
let i;
|
|
92
|
+
let xinters;
|
|
93
|
+
let p1;
|
|
94
|
+
let p2;
|
|
95
|
+
polygonPoints = [...polygonPoints];
|
|
96
|
+
if (lineType === ELineTypes.Curve) {
|
|
97
|
+
polygonPoints = createSmoothCurvePoints(polygonPoints.reduce((acc, cur) => {
|
|
98
|
+
return [...acc, cur.x, cur.y];
|
|
99
|
+
}, []), 0.5, true, SEGMENT_NUMBER);
|
|
100
|
+
}
|
|
101
|
+
[p1] = polygonPoints;
|
|
102
|
+
const pointCount = polygonPoints.length;
|
|
103
|
+
for (i = 1; i <= pointCount; i++) {
|
|
104
|
+
p2 = polygonPoints[i % pointCount];
|
|
105
|
+
if (checkPoint.x > Math.min(p1.x, p2.x) && checkPoint.x <= Math.max(p1.x, p2.x)) {
|
|
106
|
+
if (checkPoint.y <= Math.max(p1.y, p2.y)) {
|
|
107
|
+
if (p1.x !== p2.x) {
|
|
108
|
+
xinters = (checkPoint.x - p1.x) * (p2.y - p1.y) / (p2.x - p1.x) + p1.y;
|
|
109
|
+
if (p1.y === p2.y || checkPoint.y <= xinters) {
|
|
110
|
+
counter++;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
p1 = p2;
|
|
116
|
+
}
|
|
117
|
+
if (counter % 2 === 0) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
function getPolygonPointUnderZoom(pointList, zoom = 1) {
|
|
123
|
+
return pointList.map((v) => __spreadProps(__spreadValues({}, v), {x: v.x * zoom, y: v.y * zoom}));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { createSmoothCurvePoints, createSmoothCurvePointsFromPointList, getPolygonPointUnderZoom, isInPolygon };
|
package/es/utils/uuid.js
CHANGED
|
@@ -1 +1,24 @@
|
|
|
1
|
-
function
|
|
1
|
+
function uuid(len = 8, radix = 62) {
|
|
2
|
+
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");
|
|
3
|
+
const id = [];
|
|
4
|
+
let i;
|
|
5
|
+
radix = radix || chars.length;
|
|
6
|
+
if (len) {
|
|
7
|
+
for (i = 0; i < len; i++) {
|
|
8
|
+
id[i] = chars[0 | Math.random() * radix];
|
|
9
|
+
}
|
|
10
|
+
} else {
|
|
11
|
+
let r;
|
|
12
|
+
id[8] = id[13] = id[18] = id[23] = "-";
|
|
13
|
+
id[14] = "4";
|
|
14
|
+
for (i = 0; i < 36; i++) {
|
|
15
|
+
if (!id[i]) {
|
|
16
|
+
r = 0 | Math.random() * 16;
|
|
17
|
+
id[i] = chars[i === 19 ? r & 3 | 8 : r];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return id.join("");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { uuid as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-annotation",
|
|
3
|
-
"version": "1.14.0-alpha.
|
|
3
|
+
"version": "1.14.0-alpha.3",
|
|
4
4
|
"description": "Annotation tool collection",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotation",
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git@github.com:open-mmlab/labelbee.git"
|
|
17
17
|
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
18
21
|
"license": "Apache-2.0",
|
|
19
22
|
"files": [
|
|
20
23
|
"dist",
|
|
@@ -39,8 +42,7 @@
|
|
|
39
42
|
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
40
43
|
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx --fix --format=pretty ./src && npm run lint:prettier && npm run build:type",
|
|
41
44
|
"lint:prettier": "npm run prettier && prettier --version && prettier --check \"src/**/*.{js,jsx,ts,tsx,less,md,json}\" --end-of-line auto",
|
|
42
|
-
"prettier": "prettier --write \"**/**.{js,jsx,tsx,ts,less,md,json}\""
|
|
43
|
-
"prepublishOnly": "npm run build"
|
|
45
|
+
"prettier": "prettier --write \"**/**.{js,jsx,tsx,ts,less,md,json}\""
|
|
44
46
|
},
|
|
45
47
|
"lint-staged": {
|
|
46
48
|
"src/**/*.{ts,tsx}": [
|
|
@@ -92,11 +94,11 @@
|
|
|
92
94
|
"typescript": "^4.2.3"
|
|
93
95
|
},
|
|
94
96
|
"dependencies": {
|
|
95
|
-
"@labelbee/lb-utils": "^1.7.0-alpha.
|
|
97
|
+
"@labelbee/lb-utils": "^1.7.0-alpha.3",
|
|
96
98
|
"@turf/turf": "5.1.6",
|
|
97
99
|
"color-rgba": "^2.3.0",
|
|
98
100
|
"lodash": "^4.17.20",
|
|
99
101
|
"three": ">=0.141.0"
|
|
100
102
|
},
|
|
101
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "8387be3b500f75c181f38b73ea85fcc8a2543c26"
|
|
102
104
|
}
|