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