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