@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,110 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var annotation = require('../../constant/annotation.js');
|
|
4
|
-
var icon_cuboidFAB = require('../../assets/attributeIcon/icon_cuboidFAB.svg.js');
|
|
5
|
-
var icon_cuboidMore = require('../../assets/attributeIcon/icon_cuboidMore.svg.js');
|
|
6
|
-
var icon_cuboidRight = require('../../assets/attributeIcon/icon_cuboidRight.svg.js');
|
|
7
|
-
var icon_cuboidLeft = require('../../assets/attributeIcon/icon_cuboidLeft.svg.js');
|
|
8
|
-
var icon_cuboidTop = require('../../assets/attributeIcon/icon_cuboidTop.svg.js');
|
|
9
|
-
|
|
10
|
-
const MORE_ICON_LISTS = [
|
|
11
|
-
{
|
|
12
|
-
icon: icon_cuboidRight,
|
|
13
|
-
id: "cuboidRight"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
icon: icon_cuboidLeft,
|
|
17
|
-
id: "cuboidLeft"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
icon: icon_cuboidTop,
|
|
21
|
-
id: "cuboidTop"
|
|
22
|
-
}
|
|
23
|
-
];
|
|
24
|
-
class CuboidToggleButtonClass {
|
|
25
|
-
constructor(props) {
|
|
26
|
-
const {container, cuboidButtonMove, toggleDirection} = props;
|
|
27
|
-
this.container = container;
|
|
28
|
-
this.direction = annotation.ECuboidDirection.Front;
|
|
29
|
-
this.isFrontSide = true;
|
|
30
|
-
this.cuboidButtonMove = cuboidButtonMove;
|
|
31
|
-
this.onToggleDirection = toggleDirection;
|
|
32
|
-
this._cuboidButtonDOM = this.initCuboidButtonDOM();
|
|
33
|
-
this._cuboidFABDOM = this.initcuboidFABDOM(icon_cuboidFAB);
|
|
34
|
-
this._cuboidMoreDOM = this.initcuboidMoreDOM(icon_cuboidMore);
|
|
35
|
-
this._cuboidMoreListDOM = this.initcuboidMoreListDOM();
|
|
36
|
-
this.appendToContainer();
|
|
37
|
-
}
|
|
38
|
-
appendToContainer() {
|
|
39
|
-
if (!this._cuboidButtonDOM || !this._cuboidFABDOM || !this._cuboidMoreDOM) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
this.container.appendChild(this._cuboidButtonDOM);
|
|
43
|
-
this._cuboidButtonDOM.appendChild(this._cuboidFABDOM);
|
|
44
|
-
this._cuboidButtonDOM.appendChild(this._cuboidMoreDOM);
|
|
45
|
-
}
|
|
46
|
-
initCuboidButtonDOM() {
|
|
47
|
-
const _cuboidButtonDOM = document.createElement("div");
|
|
48
|
-
_cuboidButtonDOM.setAttribute("id", "LABELBEE_CUBOID_BUTTON_BOX");
|
|
49
|
-
_cuboidButtonDOM.setAttribute("style", `
|
|
1
|
+
"use strict";var annotation=require("../../constant/annotation.js"),icon_cuboidFAB=require("../../assets/attributeIcon/icon_cuboidFAB.svg.js"),icon_cuboidMore=require("../../assets/attributeIcon/icon_cuboidMore.svg.js"),icon_cuboidRight=require("../../assets/attributeIcon/icon_cuboidRight.svg.js"),icon_cuboidLeft=require("../../assets/attributeIcon/icon_cuboidLeft.svg.js"),icon_cuboidTop=require("../../assets/attributeIcon/icon_cuboidTop.svg.js");const MORE_ICON_LISTS=[{icon:icon_cuboidRight,id:"cuboidRight"},{icon:icon_cuboidLeft,id:"cuboidLeft"},{icon:icon_cuboidTop,id:"cuboidTop"}];class CuboidToggleButtonClass{constructor(i){const{container:t,cuboidButtonMove:o,toggleDirection:e}=i;this.container=t,this.direction=annotation.ECuboidDirection.Front,this.isFrontSide=!0,this.cuboidButtonMove=o,this.onToggleDirection=e,this._cuboidButtonDOM=this.initCuboidButtonDOM(),this._cuboidFABDOM=this.initcuboidFABDOM(icon_cuboidFAB),this._cuboidMoreDOM=this.initcuboidMoreDOM(icon_cuboidMore),this._cuboidMoreListDOM=this.initcuboidMoreListDOM(),this.appendToContainer()}appendToContainer(){!this._cuboidButtonDOM||!this._cuboidFABDOM||!this._cuboidMoreDOM||(this.container.appendChild(this._cuboidButtonDOM),this._cuboidButtonDOM.appendChild(this._cuboidFABDOM),this._cuboidButtonDOM.appendChild(this._cuboidMoreDOM))}initCuboidButtonDOM(){const i=document.createElement("div");return i.setAttribute("id","LABELBEE_CUBOID_BUTTON_BOX"),i.setAttribute("style",`
|
|
50
2
|
width: 40px;
|
|
51
3
|
height: 74px;
|
|
52
4
|
border-radius: 10px;
|
|
53
5
|
background-color: #FFFFFF;
|
|
54
6
|
z-index: 10;
|
|
55
|
-
`);
|
|
56
|
-
_cuboidButtonDOM.addEventListener("mouseover", (e) => {
|
|
57
|
-
e.stopPropagation();
|
|
58
|
-
setTimeout(() => {
|
|
59
|
-
this.cuboidButtonMove("in");
|
|
60
|
-
}, 100);
|
|
61
|
-
});
|
|
62
|
-
_cuboidButtonDOM.addEventListener("mouseleave", (e) => {
|
|
63
|
-
e.stopPropagation();
|
|
64
|
-
setTimeout(() => {
|
|
65
|
-
this.cuboidButtonMove("out");
|
|
66
|
-
}, 100);
|
|
67
|
-
});
|
|
68
|
-
return _cuboidButtonDOM;
|
|
69
|
-
}
|
|
70
|
-
initcuboidFABDOM(icon) {
|
|
71
|
-
const _cuboidFAB = document.createElement("div");
|
|
72
|
-
_cuboidFAB.setAttribute("id", "CUBOID_FORWARD_AND_BACK_SWITCH");
|
|
73
|
-
_cuboidFAB.innerHTML = icon;
|
|
74
|
-
_cuboidFAB.addEventListener("mouseup", (e) => {
|
|
75
|
-
e.stopPropagation();
|
|
76
|
-
this.isFrontSide = !this.isFrontSide;
|
|
77
|
-
this.direction = this.isFrontSide ? annotation.ECuboidDirection.Front : annotation.ECuboidDirection.Back;
|
|
78
|
-
this.onToggleDirection(this.direction);
|
|
79
|
-
});
|
|
80
|
-
return _cuboidFAB;
|
|
81
|
-
}
|
|
82
|
-
initcuboidMoreDOM(icon) {
|
|
83
|
-
const _iconDOM = document.createElement("div");
|
|
84
|
-
_iconDOM.setAttribute("id", "CUBOID_MORE_ICON");
|
|
85
|
-
_iconDOM.innerHTML = icon;
|
|
86
|
-
_iconDOM.addEventListener("mouseup", (e) => {
|
|
87
|
-
if (this._cuboidButtonDOM && this._cuboidMoreListDOM) {
|
|
88
|
-
if (this._cuboidButtonDOM.contains(this._cuboidMoreListDOM)) {
|
|
89
|
-
this.clearCuboidMoreListDOM();
|
|
90
|
-
} else {
|
|
91
|
-
this._cuboidButtonDOM.appendChild(this._cuboidMoreListDOM);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
e.stopPropagation();
|
|
95
|
-
});
|
|
96
|
-
_iconDOM.addEventListener("mousedown", (e) => {
|
|
97
|
-
e.stopPropagation();
|
|
98
|
-
});
|
|
99
|
-
_iconDOM.addEventListener("contextmenu", (e) => {
|
|
100
|
-
e.stopPropagation();
|
|
101
|
-
});
|
|
102
|
-
return _iconDOM;
|
|
103
|
-
}
|
|
104
|
-
initcuboidMoreListDOM() {
|
|
105
|
-
const cuboidMoreListDOM = document.createElement("div");
|
|
106
|
-
cuboidMoreListDOM.setAttribute("id", "CUBOID_MORE_LIST_ICON");
|
|
107
|
-
cuboidMoreListDOM.setAttribute("style", `
|
|
7
|
+
`),i.addEventListener("mouseover",t=>{t.stopPropagation(),setTimeout(()=>{this.cuboidButtonMove("in")},100)}),i.addEventListener("mouseleave",t=>{t.stopPropagation(),setTimeout(()=>{this.cuboidButtonMove("out")},100)}),i}initcuboidFABDOM(i){const t=document.createElement("div");return t.setAttribute("id","CUBOID_FORWARD_AND_BACK_SWITCH"),t.innerHTML=i,t.addEventListener("mouseup",o=>{o.stopPropagation(),this.isFrontSide=!this.isFrontSide,this.direction=this.isFrontSide?annotation.ECuboidDirection.Front:annotation.ECuboidDirection.Back,this.onToggleDirection(this.direction)}),t}initcuboidMoreDOM(i){const t=document.createElement("div");return t.setAttribute("id","CUBOID_MORE_ICON"),t.innerHTML=i,t.addEventListener("mouseup",o=>{this._cuboidButtonDOM&&this._cuboidMoreListDOM&&(this._cuboidButtonDOM.contains(this._cuboidMoreListDOM)?this.clearCuboidMoreListDOM():this._cuboidButtonDOM.appendChild(this._cuboidMoreListDOM)),o.stopPropagation()}),t.addEventListener("mousedown",o=>{o.stopPropagation()}),t.addEventListener("contextmenu",o=>{o.stopPropagation()}),t}initcuboidMoreListDOM(){const i=document.createElement("div");i.setAttribute("id","CUBOID_MORE_LIST_ICON"),i.setAttribute("style",`
|
|
108
8
|
height: 36px;
|
|
109
9
|
border-radius: 10px;
|
|
110
10
|
background-color: #FFFFFF;
|
|
@@ -114,43 +14,12 @@ class CuboidToggleButtonClass {
|
|
|
114
14
|
bottom: 0px;
|
|
115
15
|
left: 44px;
|
|
116
16
|
display: flex;
|
|
117
|
-
`);
|
|
118
|
-
let str = "";
|
|
119
|
-
const iconStyle = `margin-left:4px;margin-right:4px;display:flex;align-items:center;`;
|
|
120
|
-
MORE_ICON_LISTS.forEach((i, index) => {
|
|
121
|
-
const lastIconStyle = index === MORE_ICON_LISTS.length - 1 ? "margin-left:0px;margin-right:0px;" : "";
|
|
122
|
-
str += `<span id=${i.id} key=${index} style=${iconStyle}${lastIconStyle}>${i.icon}</span>`;
|
|
123
|
-
});
|
|
124
|
-
cuboidMoreListDOM.innerHTML = str;
|
|
125
|
-
cuboidMoreListDOM.childNodes.forEach((item) => {
|
|
126
|
-
item.addEventListener("click", (e) => {
|
|
127
|
-
e.stopPropagation();
|
|
128
|
-
switch (item == null ? void 0 : item.id) {
|
|
129
|
-
case "cuboidLeft":
|
|
130
|
-
this.onToggleDirection(annotation.ECuboidDirection.Left);
|
|
131
|
-
break;
|
|
132
|
-
case "cuboidRight":
|
|
133
|
-
this.onToggleDirection(annotation.ECuboidDirection.Right);
|
|
134
|
-
break;
|
|
135
|
-
case "cuboidTop":
|
|
136
|
-
this.onToggleDirection(annotation.ECuboidDirection.Top);
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
this.clearCuboidMoreListDOM();
|
|
140
|
-
this.cuboidButtonMove("out");
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
return cuboidMoreListDOM;
|
|
144
|
-
}
|
|
145
|
-
update(position) {
|
|
146
|
-
var _a;
|
|
147
|
-
const {left, top, color} = position;
|
|
148
|
-
(_a = this._cuboidButtonDOM) == null ? void 0 : _a.setAttribute("style", `
|
|
17
|
+
`);let t="";const o="margin-left:4px;margin-right:4px;display:flex;align-items:center;";return MORE_ICON_LISTS.forEach((e,n)=>{const s=n===MORE_ICON_LISTS.length-1?"margin-left:0px;margin-right:0px;":"";t+=`<span id=${e.id} key=${n} style=${o}${s}>${e.icon}</span>`}),i.innerHTML=t,i.childNodes.forEach(e=>{e.addEventListener("click",n=>{switch(n.stopPropagation(),e==null?void 0:e.id){case"cuboidLeft":this.onToggleDirection(annotation.ECuboidDirection.Left);break;case"cuboidRight":this.onToggleDirection(annotation.ECuboidDirection.Right);break;case"cuboidTop":this.onToggleDirection(annotation.ECuboidDirection.Top);break}this.clearCuboidMoreListDOM(),this.cuboidButtonMove("out")})}),i}update(i){var t;const{left:o,top:e,color:n}=i;(t=this._cuboidButtonDOM)==null||t.setAttribute("style",`
|
|
149
18
|
position: absolute;
|
|
150
19
|
font-size: 14px;
|
|
151
|
-
left:${
|
|
152
|
-
top: ${
|
|
153
|
-
color: ${
|
|
20
|
+
left:${o}px;
|
|
21
|
+
top: ${e}px;
|
|
22
|
+
color: ${n};
|
|
154
23
|
width: 41px;
|
|
155
24
|
height: 74px;
|
|
156
25
|
border-radius: 10px;
|
|
@@ -159,18 +28,4 @@ class CuboidToggleButtonClass {
|
|
|
159
28
|
text-align: center;
|
|
160
29
|
padding-top: 10px;
|
|
161
30
|
z-index: 10;
|
|
162
|
-
`);
|
|
163
|
-
}
|
|
164
|
-
clearCuboidButtonDOM() {
|
|
165
|
-
if (this._cuboidButtonDOM && this.container.contains(this._cuboidButtonDOM)) {
|
|
166
|
-
this.container.removeChild(this._cuboidButtonDOM);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
clearCuboidMoreListDOM() {
|
|
170
|
-
if (this._cuboidButtonDOM && this._cuboidMoreListDOM && this._cuboidButtonDOM.contains(this._cuboidMoreListDOM)) {
|
|
171
|
-
this._cuboidButtonDOM.removeChild(this._cuboidMoreListDOM);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
module.exports = CuboidToggleButtonClass;
|
|
31
|
+
`)}clearCuboidButtonDOM(){this._cuboidButtonDOM&&this.container.contains(this._cuboidButtonDOM)&&this.container.removeChild(this._cuboidButtonDOM)}clearCuboidMoreListDOM(){this._cuboidButtonDOM&&this._cuboidMoreListDOM&&this._cuboidButtonDOM.contains(this._cuboidMoreListDOM)&&this._cuboidButtonDOM.removeChild(this._cuboidMoreListDOM)}}module.exports=CuboidToggleButtonClass;
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
class EventListener {
|
|
4
|
-
constructor() {
|
|
5
|
-
this._events = new Map();
|
|
6
|
-
}
|
|
7
|
-
on(eventName, callback) {
|
|
8
|
-
const existEvents = this._events.get(eventName) || [];
|
|
9
|
-
if (!existEvents.some((fn) => fn === callback)) {
|
|
10
|
-
this._events.set(eventName, existEvents.concat(callback));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
singleOn(eventName, callback) {
|
|
14
|
-
this._events.set(eventName, [callback]);
|
|
15
|
-
}
|
|
16
|
-
emit(eventName, ...args) {
|
|
17
|
-
const listener = this._events.get(eventName);
|
|
18
|
-
if (listener) {
|
|
19
|
-
listener.forEach((fn) => {
|
|
20
|
-
if (fn) {
|
|
21
|
-
fn(...args);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
unbind(eventName, callback) {
|
|
27
|
-
const existEvents = this._events.get(eventName);
|
|
28
|
-
if (existEvents) {
|
|
29
|
-
this._events.set(eventName, existEvents.filter((fn) => fn !== callback));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
unbindAll(eventName) {
|
|
33
|
-
this._events.delete(eventName);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
module.exports = EventListener;
|
|
1
|
+
"use strict";class EventListener{constructor(){this._events=new Map}on(t,e){const s=this._events.get(t)||[];s.some(n=>n===e)||this._events.set(t,s.concat(e))}singleOn(t,e){this._events.set(t,[e])}emit(t,...e){const s=this._events.get(t);s&&s.forEach(n=>{n&&n(...e)})}unbind(t,e){const s=this._events.get(t);s&&this._events.set(t,s.filter(n=>n!==e))}unbindAll(t){this._events.delete(t)}}module.exports=EventListener;
|
|
@@ -1,41 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var rectOperation = require('./rectOperation.js');
|
|
4
|
-
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __defProps = Object.defineProperties;
|
|
7
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
const config = {
|
|
25
|
-
textConfigurable: false,
|
|
26
|
-
attributeConfigurable: true,
|
|
27
|
-
attributeList: []
|
|
28
|
-
};
|
|
29
|
-
class MeasureOperation extends rectOperation.RectOperation {
|
|
30
|
-
constructor(props) {
|
|
31
|
-
super(__spreadProps(__spreadValues({}, props), {config: JSON.stringify(config)}));
|
|
32
|
-
}
|
|
33
|
-
setSelectedIdAfterAddingDrawingRect() {
|
|
34
|
-
if (!this.drawingRect) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
this.setSelectedRectID(this.drawingRect.id);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
module.exports = MeasureOperation;
|
|
1
|
+
"use strict";var rectOperation=require("./rectOperation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,e,t)=>e in r?__defProp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,__spreadValues=(r,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(r,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(r,t,e[t]);return r},__spreadProps=(r,e)=>__defProps(r,__getOwnPropDescs(e));const config={textConfigurable:!1,attributeConfigurable:!0,attributeList:[]};class MeasureOperation extends rectOperation.RectOperation{constructor(e){super(__spreadProps(__spreadValues({},e),{config:JSON.stringify(config)}))}setSelectedIdAfterAddingDrawingRect(){!this.drawingRect||this.setSelectedRectID(this.drawingRect.id)}}module.exports=MeasureOperation;
|
|
@@ -1,365 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var lbUtils = require('@labelbee/lb-utils');
|
|
4
|
-
var annotation = require('../../constant/annotation.js');
|
|
5
|
-
var tool = require('../../constant/tool.js');
|
|
6
|
-
var AxisUtils = require('../../utils/tool/AxisUtils.js');
|
|
7
|
-
var CommonToolUtils = require('../../utils/tool/CommonToolUtils.js');
|
|
8
|
-
var DrawUtils = require('../../utils/tool/DrawUtils.js');
|
|
9
|
-
var PolygonUtils = require('../../utils/tool/PolygonUtils.js');
|
|
10
|
-
var defaultConfig = require('../../constant/defaultConfig.js');
|
|
11
|
-
var _ = require('lodash');
|
|
12
|
-
var polygonOperation = require('./polygonOperation.js');
|
|
13
|
-
var basicToolOperation = require('./basicToolOperation.js');
|
|
14
|
-
|
|
15
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
|
-
|
|
17
|
-
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
18
|
-
|
|
19
|
-
var __defProp = Object.defineProperty;
|
|
20
|
-
var __defProps = Object.defineProperties;
|
|
21
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
22
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
23
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
24
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
25
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
26
|
-
var __spreadValues = (a, b) => {
|
|
27
|
-
for (var prop in b || (b = {}))
|
|
28
|
-
if (__hasOwnProp.call(b, prop))
|
|
29
|
-
__defNormalProp(a, prop, b[prop]);
|
|
30
|
-
if (__getOwnPropSymbols)
|
|
31
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
32
|
-
if (__propIsEnum.call(b, prop))
|
|
33
|
-
__defNormalProp(a, prop, b[prop]);
|
|
34
|
-
}
|
|
35
|
-
return a;
|
|
36
|
-
};
|
|
37
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
38
|
-
class PointCloud2dOperation extends polygonOperation {
|
|
39
|
-
constructor(props) {
|
|
40
|
-
super(props);
|
|
41
|
-
this.selectedIDs = [];
|
|
42
|
-
this.rightMouseUp = (e) => {
|
|
43
|
-
var _a;
|
|
44
|
-
if (this.drawingPointList.length > 0) {
|
|
45
|
-
this.addDrawingPointToPolygonList();
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (e.ctrlKey) {
|
|
49
|
-
this.emit("addSelectedIDs", this.hoverID);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
this.emit("setSelectedIDs", this.hoverID);
|
|
53
|
-
const hoverAttribute = (_a = this.polygonList.find((v) => v.id === this.hoverID)) == null ? void 0 : _a.attribute;
|
|
54
|
-
if (hoverAttribute && hoverAttribute !== this.defaultAttribute) {
|
|
55
|
-
this.emit("syncAttribute", hoverAttribute);
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
this.onKeyDown = () => {
|
|
59
|
-
};
|
|
60
|
-
this.onKeyUp = () => {
|
|
61
|
-
};
|
|
62
|
-
this.renderSingleSelectedPolygon = (selectedPolygon) => {
|
|
63
|
-
var _a;
|
|
64
|
-
if (selectedPolygon) {
|
|
65
|
-
const color = this.getPointCloudLineColor(selectedPolygon);
|
|
66
|
-
const polygon = AxisUtils["default"].changePointListByZoom(selectedPolygon.pointList, this.zoom, this.currentPos);
|
|
67
|
-
DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas, polygon, {
|
|
68
|
-
fillColor: "transparent",
|
|
69
|
-
strokeColor: color,
|
|
70
|
-
pointColor: "white",
|
|
71
|
-
thickness: 2,
|
|
72
|
-
lineCap: "round",
|
|
73
|
-
isClose: true,
|
|
74
|
-
lineType: (_a = this.config) == null ? void 0 : _a.lineType
|
|
75
|
-
});
|
|
76
|
-
if (selectedPolygon.isRect === true && this.showDirectionLine === true) {
|
|
77
|
-
this.renderRectPolygonDirection(polygon);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
this.emitUpdatePolygonByDrag = () => {
|
|
82
|
-
if (this.dragInfo) {
|
|
83
|
-
const {originPolygonList} = this.dragInfo;
|
|
84
|
-
if (this.selectedIDs.length > 0) {
|
|
85
|
-
const emitUpdateList = [];
|
|
86
|
-
this.polygonList.forEach((polygon) => {
|
|
87
|
-
if (this.selectedIDs.includes(polygon.id)) {
|
|
88
|
-
const originPolygon = originPolygonList.find((i) => i.id === polygon.id);
|
|
89
|
-
if (originPolygon) {
|
|
90
|
-
emitUpdateList.push({newPolygon: polygon, originPolygon});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
this.emit("updatePolygonByDrag", emitUpdateList);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var _a, _b, _c, _d, _e, _f;
|
|
99
|
-
this.showDirectionLine = (_a = props.showDirectionLine) != null ? _a : true;
|
|
100
|
-
this.forbidAddNew = (_b = props.forbidAddNew) != null ? _b : false;
|
|
101
|
-
this.pointCloudConfig = (_c = CommonToolUtils.jsonParser(props.config)) != null ? _c : {};
|
|
102
|
-
this.hideAttributes = [];
|
|
103
|
-
this.checkMode = (_d = props.checkMode) != null ? _d : false;
|
|
104
|
-
if (this.forbidAddNew === false && props.checkMode === true) {
|
|
105
|
-
this.forbidAddNew = true;
|
|
106
|
-
}
|
|
107
|
-
this.config = __spreadProps(__spreadValues({}, defaultConfig.polygonConfig), {
|
|
108
|
-
textConfigurable: false,
|
|
109
|
-
attributeConfigurable: true,
|
|
110
|
-
attributeList: (_f = (_e = this.pointCloudConfig) == null ? void 0 : _e.attributeList) != null ? _f : []
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
get getSelectedIDs() {
|
|
114
|
-
return this.selectedIDs;
|
|
115
|
-
}
|
|
116
|
-
get enableDrag() {
|
|
117
|
-
return Boolean(this.selectedIDs.length > 0 && this.dragInfo);
|
|
118
|
-
}
|
|
119
|
-
get visiblePolygonList() {
|
|
120
|
-
return this.polygonList.filter((i) => !this.hideAttributes.includes(i.attribute));
|
|
121
|
-
}
|
|
122
|
-
setHiddenAttributes(hideAttributes) {
|
|
123
|
-
this.hideAttributes = hideAttributes;
|
|
124
|
-
}
|
|
125
|
-
setConfig(config) {
|
|
126
|
-
var _a;
|
|
127
|
-
const newConfig = CommonToolUtils.jsonParser(config);
|
|
128
|
-
this.pointCloudConfig = newConfig;
|
|
129
|
-
this.config = __spreadProps(__spreadValues({}, this.config), {
|
|
130
|
-
attributeList: (_a = newConfig == null ? void 0 : newConfig.attributeList) != null ? _a : []
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
dragMouseDown(e) {
|
|
134
|
-
if (this.checkMode) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
super.dragMouseDown(e);
|
|
138
|
-
}
|
|
139
|
-
deletePolygon(id) {
|
|
140
|
-
if (this.checkMode) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
super.deletePolygon(id);
|
|
144
|
-
}
|
|
145
|
-
deletePolygonPoint(index) {
|
|
146
|
-
if (this.checkMode) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
super.deletePolygonPoint(index);
|
|
150
|
-
}
|
|
151
|
-
setSelectedIDs(selectedIDs) {
|
|
152
|
-
this.selectedIDs = selectedIDs;
|
|
153
|
-
if (this.selectedIDs.length < 2) {
|
|
154
|
-
this.setSelectedID(this.selectedIDs.length === 1 ? this.selectedIDs[0] : "");
|
|
155
|
-
}
|
|
156
|
-
this.render();
|
|
157
|
-
}
|
|
158
|
-
deleteSelectedID() {
|
|
159
|
-
super.deleteSelectedID();
|
|
160
|
-
this.selectedIDs = [];
|
|
161
|
-
this.emit("deleteSelectedIDs");
|
|
162
|
-
}
|
|
163
|
-
get selectedPolygons() {
|
|
164
|
-
return PolygonUtils.getPolygonByIDs(this.polygonList, this.selectedIDs);
|
|
165
|
-
}
|
|
166
|
-
updateSelectedPolygonsPoints(offset) {
|
|
167
|
-
var _a, _b;
|
|
168
|
-
if (this.selectedPolygons && ((_a = this.selectedPolygons) == null ? void 0 : _a.length) > 0) {
|
|
169
|
-
const originPolygonList = ___default["default"].cloneDeep(this.selectedPolygons);
|
|
170
|
-
const updateList = [];
|
|
171
|
-
(_b = this.selectedPolygons) == null ? void 0 : _b.forEach((polygon, index) => {
|
|
172
|
-
polygon.pointList = polygon.pointList.map((point) => {
|
|
173
|
-
var _a2, _b2;
|
|
174
|
-
const {x, y} = point;
|
|
175
|
-
return __spreadProps(__spreadValues({}, point), {
|
|
176
|
-
x: x + ((_a2 = offset.x) != null ? _a2 : 0),
|
|
177
|
-
y: y + ((_b2 = offset.y) != null ? _b2 : 0)
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
updateList.push({originPolygon: originPolygonList[index], newPolygon: polygon});
|
|
181
|
-
});
|
|
182
|
-
this.emit("updateResult");
|
|
183
|
-
this.emit("updatePolygonByDrag", updateList);
|
|
184
|
-
this.render();
|
|
185
|
-
this.history.pushHistory(this.polygonList);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
getLineColor() {
|
|
189
|
-
return "rgba(0, 255, 255, 0.5)";
|
|
190
|
-
}
|
|
191
|
-
getPointCloudLineColor(polygon) {
|
|
192
|
-
return polygon.valid === false ? lbUtils.INVALID_COLOR : lbUtils.toolStyleConverter.getColorFromConfig({attribute: polygon.attribute}, __spreadProps(__spreadValues({}, this.pointCloudConfig), {attributeConfigurable: true}), {}).stroke;
|
|
193
|
-
}
|
|
194
|
-
renderStaticPolygon() {
|
|
195
|
-
var _a;
|
|
196
|
-
if (this.isHidden === false) {
|
|
197
|
-
(_a = this.visiblePolygonList) == null ? void 0 : _a.forEach((polygon) => {
|
|
198
|
-
var _a2, _b, _c;
|
|
199
|
-
if ([...this.selectedIDs, this.editPolygonID].includes(polygon.id)) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
const lineColor = this.getPointCloudLineColor(polygon);
|
|
203
|
-
const transformPointList = AxisUtils["default"].changePointListByZoom(polygon.pointList || [], this.zoom, this.currentPos);
|
|
204
|
-
DrawUtils.drawPolygonWithFillAndLine(this.canvas, transformPointList, {
|
|
205
|
-
fillColor: "transparent",
|
|
206
|
-
strokeColor: lineColor,
|
|
207
|
-
pointColor: "white",
|
|
208
|
-
thickness: (_b = (_a2 = this.style) == null ? void 0 : _a2.width) != null ? _b : 2,
|
|
209
|
-
lineCap: "round",
|
|
210
|
-
isClose: true,
|
|
211
|
-
lineType: (_c = this.config) == null ? void 0 : _c.lineType
|
|
212
|
-
});
|
|
213
|
-
if (polygon.isRect === true && this.showDirectionLine === true) {
|
|
214
|
-
this.renderRectPolygonDirection(transformPointList);
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
renderSelectedPolygon() {
|
|
220
|
-
var _a;
|
|
221
|
-
(_a = this.selectedPolygons) == null ? void 0 : _a.forEach((polygon) => {
|
|
222
|
-
this.renderSingleSelectedPolygon(polygon);
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
renderRectPolygonDirection(polygon) {
|
|
226
|
-
if (polygon.length < 2) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
DrawUtils.drawLine(this.canvas, polygon[0], polygon[1], {
|
|
230
|
-
color: "white",
|
|
231
|
-
thickness: 3,
|
|
232
|
-
lineDash: [6]
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
get currentPolygonListByPattern() {
|
|
236
|
-
return this.polygonList.filter((v) => {
|
|
237
|
-
if (this.pattern === tool.EPolygonPattern.Rect) {
|
|
238
|
-
return v.isRect === true;
|
|
239
|
-
}
|
|
240
|
-
if (this.pattern === tool.EPolygonPattern.Normal) {
|
|
241
|
-
return v.isRect !== true;
|
|
242
|
-
}
|
|
243
|
-
return true;
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
getHoverID(e) {
|
|
247
|
-
var _a;
|
|
248
|
-
const coordinate = this.getCoordinateUnderZoom(e);
|
|
249
|
-
const currentPolygonList = this.currentPolygonListByPattern;
|
|
250
|
-
const polygonListWithZoom = currentPolygonList.map((polygon) => __spreadProps(__spreadValues({}, polygon), {
|
|
251
|
-
pointList: AxisUtils["default"].changePointListByZoom(polygon.pointList, this.zoom)
|
|
252
|
-
}));
|
|
253
|
-
return PolygonUtils.getHoverPolygonID(coordinate, polygonListWithZoom, 10, (_a = this.config) == null ? void 0 : _a.lineType);
|
|
254
|
-
}
|
|
255
|
-
switchToNextPolygon(sort = annotation.ESortDirection.ascend) {
|
|
256
|
-
if (this.drawingPointList.length > 0) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
const sortList = this.currentPolygonListByPattern.map((v) => {
|
|
260
|
-
var _a, _b, _c, _d;
|
|
261
|
-
return __spreadProps(__spreadValues({}, v), {
|
|
262
|
-
x: (_b = (_a = v.pointList[0]) == null ? void 0 : _a.x) != null ? _b : 0,
|
|
263
|
-
y: (_d = (_c = v.pointList[0]) == null ? void 0 : _c.y) != null ? _d : 0
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
const nextSelectedResult = CommonToolUtils.getNextSelectedRectID(sortList, sort, this.selectedID);
|
|
267
|
-
if (nextSelectedResult) {
|
|
268
|
-
this.setSelectedIDs([nextSelectedResult.id]);
|
|
269
|
-
this.render();
|
|
270
|
-
return [nextSelectedResult.id];
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
setSelectedIdAfterAddingDrawing(newID) {
|
|
274
|
-
if (this.drawingPointList.length === 0) {
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
this.setSelectedID(newID);
|
|
278
|
-
}
|
|
279
|
-
updateTextAttribute(newID) {
|
|
280
|
-
var _a, _b;
|
|
281
|
-
const oldID = this.selectedID;
|
|
282
|
-
if (newID !== oldID && oldID) {
|
|
283
|
-
(_a = this._textAttributInstance) == null ? void 0 : _a.changeSelected();
|
|
284
|
-
}
|
|
285
|
-
if (!newID) {
|
|
286
|
-
(_b = this._textAttributInstance) == null ? void 0 : _b.clearTextAttribute();
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
setSelectedID(newID) {
|
|
290
|
-
this.updateTextAttribute(newID);
|
|
291
|
-
this.selectedID = newID;
|
|
292
|
-
this.render();
|
|
293
|
-
}
|
|
294
|
-
addPointInDrawing(e) {
|
|
295
|
-
if (this.forbidAddNew) {
|
|
296
|
-
return;
|
|
297
|
-
}
|
|
298
|
-
super.addPointInDrawing(e);
|
|
299
|
-
}
|
|
300
|
-
setCanvasSize(size) {
|
|
301
|
-
var _a, _b;
|
|
302
|
-
const pixel = this.pixelRatio;
|
|
303
|
-
this.size = size;
|
|
304
|
-
this.setImgInfo(size);
|
|
305
|
-
this.updateCanvasBasicStyle(this.basicCanvas, size, 0);
|
|
306
|
-
this.updateCanvasBasicStyle(this.canvas, size, 10);
|
|
307
|
-
(_a = this.ctx) == null ? void 0 : _a.scale(pixel, pixel);
|
|
308
|
-
(_b = this.basicCtx) == null ? void 0 : _b.scale(pixel, pixel);
|
|
309
|
-
this.initImgPos();
|
|
310
|
-
this.renderBasicCanvas();
|
|
311
|
-
this.render();
|
|
312
|
-
}
|
|
313
|
-
setPolygonValidAndRender(id, isUpdate = false) {
|
|
314
|
-
if (isUpdate) {
|
|
315
|
-
super.setPolygonValidAndRender(id);
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
this.emit("validUpdate", id);
|
|
319
|
-
}
|
|
320
|
-
onDragMove(e) {
|
|
321
|
-
const newPolygonList = this.polygonList.map((v) => {
|
|
322
|
-
if (this.selectedIDs.includes(v.id)) {
|
|
323
|
-
const selectedPointList = this.dragPolygon(e, v);
|
|
324
|
-
if (!selectedPointList) {
|
|
325
|
-
return v;
|
|
326
|
-
}
|
|
327
|
-
const newData = __spreadProps(__spreadValues({}, v), {
|
|
328
|
-
pointList: selectedPointList
|
|
329
|
-
});
|
|
330
|
-
if (v.isRect === true && this.pattern === tool.EPolygonPattern.Normal) {
|
|
331
|
-
Object.assign(newData, {isRect: false});
|
|
332
|
-
}
|
|
333
|
-
return newData;
|
|
334
|
-
}
|
|
335
|
-
return v;
|
|
336
|
-
});
|
|
337
|
-
this.dragInfo.dragPrevCoord = this.getCoordinateUnderZoom(e);
|
|
338
|
-
this.setPolygonList(newPolygonList);
|
|
339
|
-
this.render();
|
|
340
|
-
}
|
|
341
|
-
onMouseDown(e) {
|
|
342
|
-
if (basicToolOperation.BasicToolOperation.prototype.onMouseDown.call(this, e) || this.forbidMouseOperation || e.ctrlKey === true || e.button !== 0) {
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
if (this.selectedIDs.length < 2) {
|
|
346
|
-
return super.onMouseDown(e);
|
|
347
|
-
}
|
|
348
|
-
const dragStartCoord = this.getCoordinateUnderZoom(e);
|
|
349
|
-
this.dragInfo = {
|
|
350
|
-
dragStartCoord,
|
|
351
|
-
dragTarget: annotation.EDragTarget.Plane,
|
|
352
|
-
initPointList: [],
|
|
353
|
-
changePointIndex: [0],
|
|
354
|
-
originPolygon: this.selectedPolygon,
|
|
355
|
-
dragPrevCoord: dragStartCoord,
|
|
356
|
-
originPolygonList: this.polygonList
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
setResultAndSelectedID(polygonList, selectedID) {
|
|
360
|
-
this.setPolygonList(polygonList);
|
|
361
|
-
this.setSelectedIDs([selectedID]);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
module.exports = PointCloud2dOperation;
|
|
1
|
+
"use strict";var lbUtils=require("@labelbee/lb-utils"),annotation=require("../../constant/annotation.js"),tool=require("../../constant/tool.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),defaultConfig=require("../../constant/defaultConfig.js"),_=require("lodash"),polygonOperation=require("./polygonOperation.js"),basicToolOperation=require("./basicToolOperation.js");function _interopDefaultLegacy(s){return s&&typeof s=="object"&&"default"in s?s:{default:s}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(s,t,e)=>t in s?__defProp(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,__spreadValues=(s,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(s,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(s,e,t[e]);return s},__spreadProps=(s,t)=>__defProps(s,__getOwnPropDescs(t));class PointCloud2dOperation extends polygonOperation{constructor(t){super(t);this.selectedIDs=[],this.rightMouseUp=l=>{var d;if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}if(l.ctrlKey){this.emit("addSelectedIDs",this.hoverID);return}this.emit("setSelectedIDs",this.hoverID);const a=(d=this.polygonList.find(u=>u.id===this.hoverID))==null?void 0:d.attribute;a&&a!==this.defaultAttribute&&this.emit("syncAttribute",a)},this.onKeyDown=()=>{},this.onKeyUp=()=>{},this.renderSingleSelectedPolygon=l=>{var d;if(l){const a=this.getPointCloudLineColor(l),u=AxisUtils.default.changePointListByZoom(l.pointList,this.zoom,this.currentPos);DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,u,{fillColor:"transparent",strokeColor:a,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(d=this.config)==null?void 0:d.lineType}),l.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(u)}},this.emitUpdatePolygonByDrag=()=>{if(this.dragInfo){const{originPolygonList:l}=this.dragInfo;if(this.selectedIDs.length>0){const d=[];this.polygonList.forEach(a=>{if(this.selectedIDs.includes(a.id)){const u=l.find(c=>c.id===a.id);u&&d.push({newPolygon:a,originPolygon:u})}}),this.emit("updatePolygonByDrag",d)}}};var e,i,o,n,r,h;this.showDirectionLine=(e=t.showDirectionLine)!=null?e:!0,this.forbidAddNew=(i=t.forbidAddNew)!=null?i:!1,this.pointCloudConfig=(o=CommonToolUtils.jsonParser(t.config))!=null?o:{},this.hideAttributes=[],this.checkMode=(n=t.checkMode)!=null?n:!1,this.forbidAddNew===!1&&t.checkMode===!0&&(this.forbidAddNew=!0),this.config=__spreadProps(__spreadValues({},defaultConfig.polygonConfig),{textConfigurable:!1,attributeConfigurable:!0,attributeList:(h=(r=this.pointCloudConfig)==null?void 0:r.attributeList)!=null?h:[]})}get getSelectedIDs(){return this.selectedIDs}get enableDrag(){return Boolean(this.selectedIDs.length>0&&this.dragInfo)}get visiblePolygonList(){return this.polygonList.filter(t=>!this.hideAttributes.includes(t.attribute))}setHiddenAttributes(t){this.hideAttributes=t}setConfig(t){var e;const i=CommonToolUtils.jsonParser(t);this.pointCloudConfig=i,this.config=__spreadProps(__spreadValues({},this.config),{attributeList:(e=i==null?void 0:i.attributeList)!=null?e:[]})}dragMouseDown(t){this.checkMode||super.dragMouseDown(t)}deletePolygon(t){this.checkMode||super.deletePolygon(t)}deletePolygonPoint(t){this.checkMode||super.deletePolygonPoint(t)}setSelectedIDs(t){this.selectedIDs=t,this.selectedIDs.length<2&&this.setSelectedID(this.selectedIDs.length===1?this.selectedIDs[0]:""),this.render()}deleteSelectedID(){super.deleteSelectedID(),this.selectedIDs=[],this.emit("deleteSelectedIDs")}get selectedPolygons(){return PolygonUtils.getPolygonByIDs(this.polygonList,this.selectedIDs)}updateSelectedPolygonsPoints(t){var e,i;if(this.selectedPolygons&&((e=this.selectedPolygons)==null?void 0:e.length)>0){const o=___default.default.cloneDeep(this.selectedPolygons),n=[];(i=this.selectedPolygons)==null||i.forEach((r,h)=>{r.pointList=r.pointList.map(l=>{var d,a;const{x:u,y:c}=l;return __spreadProps(__spreadValues({},l),{x:u+((d=t.x)!=null?d:0),y:c+((a=t.y)!=null?a:0)})}),n.push({originPolygon:o[h],newPolygon:r})}),this.emit("updateResult"),this.emit("updatePolygonByDrag",n),this.render(),this.history.pushHistory(this.polygonList)}}getLineColor(){return"rgba(0, 255, 255, 0.5)"}getPointCloudLineColor(t){return t.valid===!1?lbUtils.INVALID_COLOR:lbUtils.toolStyleConverter.getColorFromConfig({attribute:t.attribute},__spreadProps(__spreadValues({},this.pointCloudConfig),{attributeConfigurable:!0}),{}).stroke}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.visiblePolygonList)==null||t.forEach(e=>{var i,o,n;if([...this.selectedIDs,this.editPolygonID].includes(e.id))return;const r=this.getPointCloudLineColor(e),h=AxisUtils.default.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);DrawUtils.drawPolygonWithFillAndLine(this.canvas,h,{fillColor:"transparent",strokeColor:r,pointColor:"white",thickness:(o=(i=this.style)==null?void 0:i.width)!=null?o:2,lineCap:"round",isClose:!0,lineType:(n=this.config)==null?void 0:n.lineType}),e.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(h)}))}renderSelectedPolygon(){var t;(t=this.selectedPolygons)==null||t.forEach(e=>{this.renderSingleSelectedPolygon(e)})}renderRectPolygonDirection(t){t.length<2||DrawUtils.drawLine(this.canvas,t[0],t[1],{color:"white",thickness:3,lineDash:[6]})}get currentPolygonListByPattern(){return this.polygonList.filter(t=>this.pattern===tool.EPolygonPattern.Rect?t.isRect===!0:this.pattern===tool.EPolygonPattern.Normal?t.isRect!==!0:!0)}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),n=this.currentPolygonListByPattern.map(r=>__spreadProps(__spreadValues({},r),{pointList:AxisUtils.default.changePointListByZoom(r.pointList,this.zoom)}));return PolygonUtils.getHoverPolygonID(i,n,10,(e=this.config)==null?void 0:e.lineType)}switchToNextPolygon(t=annotation.ESortDirection.ascend){if(this.drawingPointList.length>0)return;const e=this.currentPolygonListByPattern.map(o=>{var n,r,h,l;return __spreadProps(__spreadValues({},o),{x:(r=(n=o.pointList[0])==null?void 0:n.x)!=null?r:0,y:(l=(h=o.pointList[0])==null?void 0:h.y)!=null?l:0})}),i=CommonToolUtils.getNextSelectedRectID(e,t,this.selectedID);if(i)return this.setSelectedIDs([i.id]),this.render(),[i.id]}setSelectedIdAfterAddingDrawing(t){this.drawingPointList.length!==0&&this.setSelectedID(t)}updateTextAttribute(t){var e,i;const o=this.selectedID;t!==o&&o&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute()}setSelectedID(t){this.updateTextAttribute(t),this.selectedID=t,this.render()}addPointInDrawing(t){this.forbidAddNew||super.addPointInDrawing(t)}setCanvasSize(t){var e,i;const o=this.pixelRatio;this.size=t,this.setImgInfo(t),this.updateCanvasBasicStyle(this.basicCanvas,t,0),this.updateCanvasBasicStyle(this.canvas,t,10),(e=this.ctx)==null||e.scale(o,o),(i=this.basicCtx)==null||i.scale(o,o),this.initImgPos(),this.renderBasicCanvas(),this.render()}setPolygonValidAndRender(t,e=!1){if(e){super.setPolygonValidAndRender(t);return}this.emit("validUpdate",t)}onDragMove(t){const e=this.polygonList.map(i=>{if(this.selectedIDs.includes(i.id)){const o=this.dragPolygon(t,i);if(!o)return i;const n=__spreadProps(__spreadValues({},i),{pointList:o});return i.isRect===!0&&this.pattern===tool.EPolygonPattern.Normal&&Object.assign(n,{isRect:!1}),n}return i});this.dragInfo.dragPrevCoord=this.getCoordinateUnderZoom(t),this.setPolygonList(e),this.render()}onMouseDown(t){if(basicToolOperation.BasicToolOperation.prototype.onMouseDown.call(this,t)||this.forbidMouseOperation||t.ctrlKey===!0||t.button!==0)return;if(this.selectedIDs.length<2)return super.onMouseDown(t);const e=this.getCoordinateUnderZoom(t);this.dragInfo={dragStartCoord:e,dragTarget:annotation.EDragTarget.Plane,initPointList:[],changePointIndex:[0],originPolygon:this.selectedPolygon,dragPrevCoord:e,originPolygonList:this.polygonList}}setResultAndSelectedID(t,e){this.setPolygonList(t),this.setSelectedIDs([e])}}module.exports=PointCloud2dOperation;
|