@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 +1,335 @@
1
- import{EToolName as u,ELineTypes as C}from"../../constant/tool.js";import y from"../MathUtils.js";import x from"./PolygonUtils.js";import v,{POINT_RADIUS as _}from"./LineToolUtils.js";import{getHighlightPoints as P,getHighlightLines as m,getCuboidHoverRange as B}from"./CuboidUtils.js";var L=Object.defineProperty,R=Object.defineProperties,D=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,w=(a,t,e)=>t in a?L(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,f=(a,t)=>{for(var e in t||(t={}))T.call(t,e)&&w(a,e,t[e]);if(O)for(var e of O(t))Z.call(t,e)&&w(a,e,t[e]);return a},c=(a,t)=>R(a,D(t));class I{static getOffsetCoordinate(t,e,i){return{x:t.x*i+e.x,y:t.y*i+e.y}}static changeDrawOutsideTarget(t,e,i,s,n,o){return typeof s=="boolean"&&!s&&(n&&o?(t.x-e.x>(n.x+n.width)*o&&(t.x=(n.x+n.width)*o+e.x),t.x-e.x<n.x*o&&(t.x=n.x*o+e.x),t.y-e.y>(n.y+n.height)*o&&(t.y=(n.y+n.height)*o+e.y),t.y-e.y<n.y*o&&(t.y=n.y*o+e.y)):(t.x-e.x>i.width&&(t.x=i.width+e.x),t.x-e.x<0&&(t.x=e.x),t.y-e.y>i.height&&(t.y=i.height+e.y),t.y-e.y<0&&(t.y=e.y))),t}static changeCoordinateByRotate(t,e,i){const{width:s,height:n}=i,{x:o,y:r}=t;switch(e%360){case 90:return{x:n-r,y:o};case 180:return{x:s-o,y:n-r};case 270:return{x:r,y:s-o};default:return t}}static changeRectByZoom(t,e,i={x:0,y:0}){return c(f({},t),{x:t.x*e+i.x,y:t.y*e+i.y,width:t.width*e,height:t.height*e})}static changePointByZoom(t,e,i={x:0,y:0}){return c(f({},t),{x:t.x*e+i.x,y:t.y*e+i.y})}static changePointListByZoom(t,e,i={x:0,y:0}){return t==null?void 0:t.map(s=>this.changePointByZoom(s,e,i))}static changePlanePointByZoom(t,e,i={x:0,y:0}){return Object.entries(t).reduce((s,[n,o])=>{const r=I.changePointByZoom(o,e,i);return c(f({},s),{[n]:r})},{})}static changeCuboidByZoom(t,e,i={x:0,y:0}){return c(f({},t),{frontPoints:this.changePlanePointByZoom(t.frontPoints,e,i),backPoints:t.backPoints?this.changePlanePointByZoom(t.backPoints,e,i):t.backPoints})}static transformPlain2PointList({tl:t,tr:e,br:i,bl:s}){return[t,e,i,s]}static axisArea(t,e=3){const{x:i,y:s}=t,n=[];for(let o=i-e;o<i+e;o+=e/3)for(let r=s-e;r<s+e;r+=e/3)n.push({x:o,y:r});return n}static getOriginCoordinateWithOffsetCoordinate(t,e=1,i={x:0,y:0}){return{x:(t.x-i.x)/e,y:(t.y-i.y)/e}}static returnClosePointIndex(t,e,i=3){let s=-1;for(let n=0;n<e.length;n++){const o=e[n];this.getIsInScope(t,o,i)&&(s=n)}return s}static isCloseCuboid(t,e,i={scope:5,zoom:1}){const s=P(e),{scope:n=5}=i;for(let r=0;r<s.length;r++){const l=s[r];if(this.getIsInScope(t,l.point,n))return!0}const o=m(e);for(let r=0;r<o.length;r++){const l=o[r],{length:p}=y.getFootOfPerpendicular(t,l.p1,l.p2,!0);if(p<n)return!0}return!!x.isInPolygon(t,B(e))}static isCloseCuboidList(t,e,i={scope:5,zoom:1}){return e.some(s=>this.isCloseCuboid(t,s,i))}static returnClosePointOrLineInCuboid(t,e,i={scope:5,zoom:1}){const s=P(e),{scope:n=5,zoom:o=1}=i;for(let h=0;h<s.length;h++){const g=s[h];if(this.getIsInScope(t,g.point,n))return[{type:"point",points:[this.changePointByZoom(s[h].point,o)],originCuboid:e,positions:g.positions}]}let r=n;const l=m(e);let p;for(let h=0;h<l.length;h++){const g=l[h],{length:d}=y.getFootOfPerpendicular(t,g.p1,g.p2,!0);d<r&&(r=d,p=[{type:"line",points:this.changePointListByZoom([g.p1,g.p2],o),originCuboid:e,positions:g.positions}])}if(p)return p}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class b{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===u.Polygon}get isDependRect(){return this.dependToolName===u.Rect}get isDependOriginalImage(){return this.dependToolName===""}getAbsCoord(t){return{x:(t.x-this.currentPos.x)/this.zoom,y:(t.y-this.currentPos.y)/this.zoom}}getRenderCoord(t){return{x:t.x*this.zoom+this.currentPos.x,y:t.y*this.zoom+this.currentPos.y}}coordInsideRect(t,e){const{x:i,y:s,width:n,height:o}=e;return{x:y.withinRange(t.x,[i,i+n]),y:y.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===C.Curve?x.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return v.calcOptimalIntersection(i,o,s,_,this.zoom)}coordInsidePolygon(t,e,i,s){const{pointList:n}=i,o=s==null?void 0:s.lineType;if(n.length===0)return t;const r=this.getPolygonPointList(o,n);if(x.isInPolygon(t,r))return t;const p=r.concat(r[0]).map(g=>this.getRenderCoord(g)),h=this.getIntersection(t,e,p);return h?this.getAbsCoord(h==null?void 0:h.point):t}coordInsideImage(t){return this.coordInsideRect(t,c(f({},this.basicImgInfo),{x:0,y:0}))}getNextCoordByDependTool(t,e){if(this.isDependRect)return this.coordInsideRect(t,this.basicResult);if(this.isDependPolygon)return this.coordInsidePolygon(t,e,this.basicResult,this.dependToolConfig);if(this.isDependOriginalImage)return this.coordInsideImage(t)}setDependInfo(t,e){this.dependToolName=t!=null?t:"",this.dependToolConfig=t?e:void 0}setBasicImgInfo(t){this.basicImgInfo=t}setBasicResult(t){this.basicResult=t}setZoomAndCurrentPos(t,e){this.zoom=t,this.currentPos=e}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],r=[i,i+n];return y.isInRange(t.x,o)&&y.isInRange(t.y,r)}return y.isInRange(t.x,[0,this.basicImgInfo.width])&&y.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return x.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}export{b as CoordinateUtils,I as default};
1
+ import { EToolName, ELineTypes } from '../../constant/tool.js';
2
+ import MathUtils from '../MathUtils.js';
3
+ import PolygonUtils from './PolygonUtils.js';
4
+ import LineToolUtils, { POINT_RADIUS } from './LineToolUtils.js';
5
+ import { getHighlightPoints, getHighlightLines, getCuboidHoverRange } from './CuboidUtils.js';
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __defProps = Object.defineProperties;
9
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
10
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
13
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
14
+ var __spreadValues = (a, b) => {
15
+ for (var prop in b || (b = {}))
16
+ if (__hasOwnProp.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ if (__getOwnPropSymbols)
19
+ for (var prop of __getOwnPropSymbols(b)) {
20
+ if (__propIsEnum.call(b, prop))
21
+ __defNormalProp(a, prop, b[prop]);
22
+ }
23
+ return a;
24
+ };
25
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
+ class AxisUtils {
27
+ static getOffsetCoordinate(coordinate, currentPos, zoom) {
28
+ return {
29
+ x: coordinate.x * zoom + currentPos.x,
30
+ y: coordinate.y * zoom + currentPos.y
31
+ };
32
+ }
33
+ static changeDrawOutsideTarget(coord, currentPos, imgInfo, drawOutsideTarget, basicResult, zoom) {
34
+ if (typeof drawOutsideTarget === "boolean" && !drawOutsideTarget) {
35
+ if (basicResult && zoom) {
36
+ if (coord.x - currentPos.x > (basicResult.x + basicResult.width) * zoom) {
37
+ coord.x = (basicResult.x + basicResult.width) * zoom + currentPos.x;
38
+ }
39
+ if (coord.x - currentPos.x < basicResult.x * zoom) {
40
+ coord.x = basicResult.x * zoom + currentPos.x;
41
+ }
42
+ if (coord.y - currentPos.y > (basicResult.y + basicResult.height) * zoom) {
43
+ coord.y = (basicResult.y + basicResult.height) * zoom + currentPos.y;
44
+ }
45
+ if (coord.y - currentPos.y < basicResult.y * zoom) {
46
+ coord.y = basicResult.y * zoom + currentPos.y;
47
+ }
48
+ } else {
49
+ if (coord.x - currentPos.x > imgInfo.width) {
50
+ coord.x = imgInfo.width + currentPos.x;
51
+ }
52
+ if (coord.x - currentPos.x < 0) {
53
+ coord.x = currentPos.x;
54
+ }
55
+ if (coord.y - currentPos.y > imgInfo.height) {
56
+ coord.y = imgInfo.height + currentPos.y;
57
+ }
58
+ if (coord.y - currentPos.y < 0) {
59
+ coord.y = currentPos.y;
60
+ }
61
+ }
62
+ }
63
+ return coord;
64
+ }
65
+ static changeCoordinateByRotate(coordinate, rotate, imgSize) {
66
+ const {width, height} = imgSize;
67
+ const {x, y} = coordinate;
68
+ switch (rotate % 360) {
69
+ case 90:
70
+ return {
71
+ x: height - y,
72
+ y: x
73
+ };
74
+ case 180:
75
+ return {
76
+ x: width - x,
77
+ y: height - y
78
+ };
79
+ case 270:
80
+ return {
81
+ x: y,
82
+ y: width - x
83
+ };
84
+ default:
85
+ return coordinate;
86
+ }
87
+ }
88
+ static changeRectByZoom(rect, zoom, currentPos = {x: 0, y: 0}) {
89
+ return __spreadProps(__spreadValues({}, rect), {
90
+ x: rect.x * zoom + currentPos.x,
91
+ y: rect.y * zoom + currentPos.y,
92
+ width: rect.width * zoom,
93
+ height: rect.height * zoom
94
+ });
95
+ }
96
+ static changePointByZoom(point, zoom, currentPos = {x: 0, y: 0}) {
97
+ return __spreadProps(__spreadValues({}, point), {
98
+ x: point.x * zoom + currentPos.x,
99
+ y: point.y * zoom + currentPos.y
100
+ });
101
+ }
102
+ static changePointListByZoom(pointList, zoom, currentPos = {x: 0, y: 0}) {
103
+ return pointList == null ? void 0 : pointList.map((point) => {
104
+ return this.changePointByZoom(point, zoom, currentPos);
105
+ });
106
+ }
107
+ static changePlanePointByZoom(planePoints, zoom, currentPos = {x: 0, y: 0}) {
108
+ return Object.entries(planePoints).reduce((acc, [key, coord]) => {
109
+ const newCoord = AxisUtils.changePointByZoom(coord, zoom, currentPos);
110
+ return __spreadProps(__spreadValues({}, acc), {
111
+ [key]: newCoord
112
+ });
113
+ }, {});
114
+ }
115
+ static changeCuboidByZoom(cuboid, zoom, currentPos = {x: 0, y: 0}) {
116
+ return __spreadProps(__spreadValues({}, cuboid), {
117
+ frontPoints: this.changePlanePointByZoom(cuboid.frontPoints, zoom, currentPos),
118
+ backPoints: cuboid.backPoints ? this.changePlanePointByZoom(cuboid.backPoints, zoom, currentPos) : cuboid.backPoints
119
+ });
120
+ }
121
+ static transformPlain2PointList({tl, tr, br, bl}) {
122
+ return [tl, tr, br, bl];
123
+ }
124
+ static axisArea(axis, radius = 3) {
125
+ const {x, y} = axis;
126
+ const axisArray = [];
127
+ for (let cX = x - radius; cX < x + radius; cX += radius / 3) {
128
+ for (let cY = y - radius; cY < y + radius; cY += radius / 3) {
129
+ axisArray.push({x: cX, y: cY});
130
+ }
131
+ }
132
+ return axisArray;
133
+ }
134
+ static getOriginCoordinateWithOffsetCoordinate(coord, zoom = 1, currentPos = {
135
+ x: 0,
136
+ y: 0
137
+ }) {
138
+ return {
139
+ x: (coord.x - currentPos.x) / zoom,
140
+ y: (coord.y - currentPos.y) / zoom
141
+ };
142
+ }
143
+ static returnClosePointIndex(checkPoint, polygonPoints, scope = 3) {
144
+ let pointIndex = -1;
145
+ for (let i = 0; i < polygonPoints.length; i++) {
146
+ const data = polygonPoints[i];
147
+ if (this.getIsInScope(checkPoint, data, scope)) {
148
+ pointIndex = i;
149
+ }
150
+ }
151
+ return pointIndex;
152
+ }
153
+ static isCloseCuboid(checkPoint, cuboid, options = {scope: 5, zoom: 1}) {
154
+ const points = getHighlightPoints(cuboid);
155
+ const {scope = 5} = options;
156
+ for (let i = 0; i < points.length; i++) {
157
+ const pointData = points[i];
158
+ if (this.getIsInScope(checkPoint, pointData.point, scope)) {
159
+ return true;
160
+ }
161
+ }
162
+ const lines = getHighlightLines(cuboid);
163
+ for (let i = 0; i < lines.length; i++) {
164
+ const line = lines[i];
165
+ const {length} = MathUtils.getFootOfPerpendicular(checkPoint, line.p1, line.p2, true);
166
+ if (length < scope) {
167
+ return true;
168
+ }
169
+ }
170
+ if (PolygonUtils.isInPolygon(checkPoint, getCuboidHoverRange(cuboid))) {
171
+ return true;
172
+ }
173
+ return false;
174
+ }
175
+ static isCloseCuboidList(checkPoint, cuboidList, options = {scope: 5, zoom: 1}) {
176
+ return cuboidList.some((cuboid) => this.isCloseCuboid(checkPoint, cuboid, options));
177
+ }
178
+ static returnClosePointOrLineInCuboid(checkPoint, cuboid, options = {scope: 5, zoom: 1}) {
179
+ const points = getHighlightPoints(cuboid);
180
+ const {scope = 5, zoom = 1} = options;
181
+ for (let i = 0; i < points.length; i++) {
182
+ const pointData = points[i];
183
+ if (this.getIsInScope(checkPoint, pointData.point, scope)) {
184
+ return [
185
+ {
186
+ type: "point",
187
+ points: [this.changePointByZoom(points[i].point, zoom)],
188
+ originCuboid: cuboid,
189
+ positions: pointData.positions
190
+ }
191
+ ];
192
+ }
193
+ }
194
+ let minLength = scope;
195
+ const lines = getHighlightLines(cuboid);
196
+ let linePoints;
197
+ for (let i = 0; i < lines.length; i++) {
198
+ const line = lines[i];
199
+ const {length} = MathUtils.getFootOfPerpendicular(checkPoint, line.p1, line.p2, true);
200
+ if (length < minLength) {
201
+ minLength = length;
202
+ linePoints = [
203
+ {
204
+ type: "line",
205
+ points: this.changePointListByZoom([line.p1, line.p2], zoom),
206
+ originCuboid: cuboid,
207
+ positions: line.positions
208
+ }
209
+ ];
210
+ }
211
+ }
212
+ if (linePoints) {
213
+ return linePoints;
214
+ }
215
+ }
216
+ static getIsInScope(currentCoord, targetCoord, scope) {
217
+ if (Math.abs(currentCoord.x - targetCoord.x) < scope && Math.abs(currentCoord.y - targetCoord.y) < scope) {
218
+ return true;
219
+ }
220
+ return false;
221
+ }
222
+ }
223
+ class CoordinateUtils {
224
+ constructor(props) {
225
+ this.currentPos = props.currentPos;
226
+ this.zoom = props.zoom;
227
+ this.basicImgInfo = props.basicImgInfo;
228
+ this.dependToolName = "";
229
+ }
230
+ get isDependPolygon() {
231
+ return this.dependToolName === EToolName.Polygon;
232
+ }
233
+ get isDependRect() {
234
+ return this.dependToolName === EToolName.Rect;
235
+ }
236
+ get isDependOriginalImage() {
237
+ return this.dependToolName === "";
238
+ }
239
+ getAbsCoord(renderCoord) {
240
+ return {
241
+ x: (renderCoord.x - this.currentPos.x) / this.zoom,
242
+ y: (renderCoord.y - this.currentPos.y) / this.zoom
243
+ };
244
+ }
245
+ getRenderCoord(absCoord) {
246
+ return {
247
+ x: absCoord.x * this.zoom + this.currentPos.x,
248
+ y: absCoord.y * this.zoom + this.currentPos.y
249
+ };
250
+ }
251
+ coordInsideRect(absCoord, rect) {
252
+ const {x, y, width, height} = rect;
253
+ return {
254
+ x: MathUtils.withinRange(absCoord.x, [x, x + width]),
255
+ y: MathUtils.withinRange(absCoord.y, [y, y + height])
256
+ };
257
+ }
258
+ getPolygonPointList(lineType, pointList) {
259
+ return lineType === ELineTypes.Curve ? PolygonUtils.createSmoothCurvePointsFromPointList(pointList) : pointList;
260
+ }
261
+ getIntersection(curCoord, preCoord, polygonPointListToLineList) {
262
+ const pointA = this.getRenderCoord(preCoord);
263
+ const pointB = this.getRenderCoord(curCoord);
264
+ const drawingLine = {
265
+ pointA,
266
+ pointB
267
+ };
268
+ const intersection = LineToolUtils.calcOptimalIntersection(polygonPointListToLineList, drawingLine, pointA, POINT_RADIUS, this.zoom);
269
+ return intersection;
270
+ }
271
+ coordInsidePolygon(curCoord, preCoord, polygon, polygonToolConfig) {
272
+ const {pointList} = polygon;
273
+ const lineType = polygonToolConfig == null ? void 0 : polygonToolConfig.lineType;
274
+ if (pointList.length === 0) {
275
+ return curCoord;
276
+ }
277
+ const polygonPointList = this.getPolygonPointList(lineType, pointList);
278
+ const isInPolygon = PolygonUtils.isInPolygon(curCoord, polygonPointList);
279
+ if (isInPolygon) {
280
+ return curCoord;
281
+ }
282
+ const polygonPointListToLineList = polygonPointList.concat(polygonPointList[0]).map((i) => this.getRenderCoord(i));
283
+ const intersection = this.getIntersection(curCoord, preCoord, polygonPointListToLineList);
284
+ if (intersection) {
285
+ return this.getAbsCoord(intersection == null ? void 0 : intersection.point);
286
+ }
287
+ return curCoord;
288
+ }
289
+ coordInsideImage(coord) {
290
+ return this.coordInsideRect(coord, __spreadProps(__spreadValues({}, this.basicImgInfo), {x: 0, y: 0}));
291
+ }
292
+ getNextCoordByDependTool(curAbsCoord, preAbsCoord) {
293
+ if (this.isDependRect) {
294
+ return this.coordInsideRect(curAbsCoord, this.basicResult);
295
+ }
296
+ if (this.isDependPolygon) {
297
+ return this.coordInsidePolygon(curAbsCoord, preAbsCoord, this.basicResult, this.dependToolConfig);
298
+ }
299
+ if (this.isDependOriginalImage) {
300
+ return this.coordInsideImage(curAbsCoord);
301
+ }
302
+ }
303
+ setDependInfo(dependToolName, dependToolConfig) {
304
+ this.dependToolName = dependToolName != null ? dependToolName : "";
305
+ this.dependToolConfig = dependToolName ? dependToolConfig : void 0;
306
+ }
307
+ setBasicImgInfo(basicImgInfo) {
308
+ this.basicImgInfo = basicImgInfo;
309
+ }
310
+ setBasicResult(basicResult) {
311
+ this.basicResult = basicResult;
312
+ }
313
+ setZoomAndCurrentPos(zoom, currentPos) {
314
+ this.zoom = zoom;
315
+ this.currentPos = currentPos;
316
+ }
317
+ isCoordInsideTarget(coord) {
318
+ if (this.isDependPolygon) {
319
+ return this.isInBasicPolygon(coord);
320
+ }
321
+ if (this.isDependRect) {
322
+ const {x, y, width, height} = this.basicResult;
323
+ const rectHorizontalRange = [x, x + width];
324
+ const rectVerticalRange = [y, y + height];
325
+ return MathUtils.isInRange(coord.x, rectHorizontalRange) && MathUtils.isInRange(coord.y, rectVerticalRange);
326
+ }
327
+ return MathUtils.isInRange(coord.x, [0, this.basicImgInfo.width]) && MathUtils.isInRange(coord.y, [0, this.basicImgInfo.height]);
328
+ }
329
+ isInBasicPolygon(coord) {
330
+ var _a, _b;
331
+ return PolygonUtils.isInPolygon(coord, ((_a = this.basicResult) == null ? void 0 : _a.pointList) || [], (_b = this.dependToolConfig) == null ? void 0 : _b.lineType);
332
+ }
333
+ }
334
+
335
+ export { CoordinateUtils, AxisUtils as default };
@@ -1 +1,60 @@
1
- import l from"../MathUtils.js";class a{static getMousePositionOnCanvasFromEvent(i,t){if(t&&i){const n=t.getBoundingClientRect();return{x:i.clientX-n.left,y:i.clientY-n.top}}return null}static getClientRect(i){if(i){const t=i.getBoundingClientRect();return{x:t.left,y:t.top,width:t.width,height:t.height}}return null}static getSize(i){if(i){const t=i.getBoundingClientRect();return{width:t.width,height:t.height}}return null}static inViewPort(i,t){return i?l.isInRange(i.x,[t.left,t.right])&&l.isInRange(i.y,[t.top,t.bottom]):!1}}a.getViewPort=(e,i,t)=>{const{width:n,height:o}=e,{x:g,y:c}=i,r=(0-c)/t,s=(0-g)/t,h=r+o/t,u=s+n/t;return{top:r,bottom:h,left:s,right:u}},a.getPixelRatio=e=>{if(!e||!window)return 1;const i=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/i};export{a as default};
1
+ import MathUtils from '../MathUtils.js';
2
+
3
+ class CanvasUtils {
4
+ static getMousePositionOnCanvasFromEvent(event, canvas) {
5
+ if (canvas && event) {
6
+ const canvasRect = canvas.getBoundingClientRect();
7
+ return {
8
+ x: event.clientX - canvasRect.left,
9
+ y: event.clientY - canvasRect.top
10
+ };
11
+ }
12
+ return null;
13
+ }
14
+ static getClientRect(canvas) {
15
+ if (canvas) {
16
+ const canvasRect = canvas.getBoundingClientRect();
17
+ return {
18
+ x: canvasRect.left,
19
+ y: canvasRect.top,
20
+ width: canvasRect.width,
21
+ height: canvasRect.height
22
+ };
23
+ }
24
+ return null;
25
+ }
26
+ static getSize(canvas) {
27
+ if (canvas) {
28
+ const canvasRect = canvas.getBoundingClientRect();
29
+ return {
30
+ width: canvasRect.width,
31
+ height: canvasRect.height
32
+ };
33
+ }
34
+ return null;
35
+ }
36
+ static inViewPort(coord, viewPort) {
37
+ if (!coord) {
38
+ return false;
39
+ }
40
+ return MathUtils.isInRange(coord.x, [viewPort.left, viewPort.right]) && MathUtils.isInRange(coord.y, [viewPort.top, viewPort.bottom]);
41
+ }
42
+ }
43
+ CanvasUtils.getViewPort = (canvas, originOffset, zoom) => {
44
+ const {width: canvasWidth, height: canvasHeight} = canvas;
45
+ const {x, y} = originOffset;
46
+ const top = (0 - y) / zoom;
47
+ const left = (0 - x) / zoom;
48
+ const bottom = top + canvasHeight / zoom;
49
+ const right = left + canvasWidth / zoom;
50
+ return {top, bottom, left, right};
51
+ };
52
+ CanvasUtils.getPixelRatio = (context) => {
53
+ if (!context || !window) {
54
+ return 1;
55
+ }
56
+ const backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1;
57
+ return (window.devicePixelRatio || 1) / backingStore;
58
+ };
59
+
60
+ export { CanvasUtils as default };
@@ -1 +1,172 @@
1
- import{isObject as h}from"lodash";import{EStepType as u,ESortDirection as f}from"../../constant/annotation.js";var v=Object.defineProperty,y=Object.defineProperties,_=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,p=(o,t,e)=>t in o?v(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,g=(o,t)=>{for(var e in t||(t={}))O.call(t,e)&&p(o,e,t[e]);if(d)for(var e of d(t))P.call(t,e)&&p(o,e,t[e]);return o},E=(o,t)=>y(o,_(t));class S{static getStepInfo(t,e){return e==null?void 0:e.filter(r=>r.step===t)[0]}static getCurrentStepInfo(t,e){const r=this.getStepInfo(t,e);return r&&(r.type===u.QUALITY_INSPECTION||r.type===u.MANUAL_CORRECTION)?this.getCurrentStepInfo(r.dataSourceStep,e):r}static getMaxOrder(t){let e=0;return t.forEach(r=>{r.order&&r.order>e&&(e=r.order)}),e}static hotkeyFilter(t){const e=t.target||t.srcElement;if(!e)return!0;const{tagName:r,type:i}=e;if(!r||!i)return!0;let n=!0;return(e.isContentEditable||r==="TEXTAREA"||(r==="INPUT"&&i!=="radio"||r==="TEXTAREA")&&!e.readOnly)&&(n=!1),n}static getNextSelectedRectID(t,e=f.ascend,r){let i=1;e===f.descend&&(i=-1);const n=t.sort((s,c)=>s.x-c.x==0?s.y-c.y:i*(s.x-c.x)),l=n.findIndex(s=>s.id===r),a=n.length;return n[(l+1)%a]}static getNextSelectedRectIDByEvent(t,e,r){const i=e.shiftKey?f.descend:f.ascend;return this.getNextSelectedRectID(t,i,r)}static getRenderResultList(t,e,r=[],i){let n;return[t.filter(a=>i&&i===(a==null?void 0:a.id)?(n=a,!1):!(r.length>0&&!r.includes(a==null?void 0:a.attribute)||this.isDifferSourceID(a==null?void 0:a.sourceID,e))),n]}static getSourceID(t){var e;const r="";return t&&(e=t==null?void 0:t.id)!=null?e:r}static findAllLine(t,e=!0){const r=[],i=[...t];i.length>=3&&e===!0&&i.push(g({},i[0]));for(let n=0;n<i.length;n++)i[n+1]&&r.push({point1:i[n],point2:i[n+1],pointIndex:n});return r}static translateSourceID(t){return(t===void 0||t===0||t==="0")&&(t=""),t}static isDifferSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`!=`${e}`}static isSameSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`==`${e}`}static getNextMarker(t,e=[],r){if((e==null?void 0:e.length)===0)return;let i=e.map((n,l)=>E(g({},n),{index:l}));if(typeof r=="number"&&r>0){const n=e[r];if(n&&t.every(l=>l.label!==n.value))return{label:n.value,index:r};i=[...i.slice(r,e.length),...i.slice(0,r)]}for(let n=0;n<i.length;n++)if(!t.some(l=>l.label===i[n].value))return{label:i[n].value,index:i[n].index}}static getCurrentMarkerIndex(t,e=[]){return e.findIndex(r=>t===r.value)}}S.jsonParser=(o,t={})=>{try{return typeof o=="string"?JSON.parse(o):h(o)?o:t}catch(e){return t}};export{S as default};
1
+ import { isObject } from 'lodash';
2
+ import { EStepType, ESortDirection } from '../../constant/annotation.js';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __defProps = Object.defineProperties;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ class CommonToolUtils {
24
+ static getStepInfo(step, stepList) {
25
+ return stepList == null ? void 0 : stepList.filter((info) => info.step === step)[0];
26
+ }
27
+ static getCurrentStepInfo(currentStep, stepList) {
28
+ const currentStepInfo = this.getStepInfo(currentStep, stepList);
29
+ if (currentStepInfo) {
30
+ if (currentStepInfo.type === EStepType.QUALITY_INSPECTION || currentStepInfo.type === EStepType.MANUAL_CORRECTION) {
31
+ return this.getCurrentStepInfo(currentStepInfo.dataSourceStep, stepList);
32
+ }
33
+ }
34
+ return currentStepInfo;
35
+ }
36
+ static getMaxOrder(result) {
37
+ let order = 0;
38
+ result.forEach((v) => {
39
+ if (v.order && v.order > order) {
40
+ order = v.order;
41
+ }
42
+ });
43
+ return order;
44
+ }
45
+ static hotkeyFilter(event) {
46
+ const target = event.target || event.srcElement;
47
+ if (!target) {
48
+ return true;
49
+ }
50
+ const {tagName, type} = target;
51
+ if (!tagName || !type) {
52
+ return true;
53
+ }
54
+ let flag = true;
55
+ if (target.isContentEditable || tagName === "TEXTAREA" || (tagName === "INPUT" && type !== "radio" || tagName === "TEXTAREA") && !target.readOnly) {
56
+ flag = false;
57
+ }
58
+ return flag;
59
+ }
60
+ static getNextSelectedRectID(rectList, sort = ESortDirection.ascend, selectedID) {
61
+ let sign = 1;
62
+ if (sort === ESortDirection.descend) {
63
+ sign = -1;
64
+ }
65
+ const sortRectList = rectList.sort((a, b) => {
66
+ if (a.x - b.x === 0) {
67
+ return a.y - b.y;
68
+ }
69
+ return sign * (a.x - b.x);
70
+ });
71
+ const i = sortRectList.findIndex((v) => v.id === selectedID);
72
+ const len = sortRectList.length;
73
+ return sortRectList[(i + 1) % len];
74
+ }
75
+ static getNextSelectedRectIDByEvent(pointList, event, selectedID) {
76
+ const sortDirection = event.shiftKey ? ESortDirection.descend : ESortDirection.ascend;
77
+ return this.getNextSelectedRectID(pointList, sortDirection, selectedID);
78
+ }
79
+ static getRenderResultList(resultList, sourceID, attributeLockList = [], selectedID) {
80
+ let selectedRect;
81
+ const showingRect = resultList.filter((result) => {
82
+ if (selectedID && selectedID === (result == null ? void 0 : result.id)) {
83
+ selectedRect = result;
84
+ return false;
85
+ }
86
+ if (attributeLockList.length > 0 && !attributeLockList.includes(result == null ? void 0 : result.attribute)) {
87
+ return false;
88
+ }
89
+ if (this.isDifferSourceID(result == null ? void 0 : result.sourceID, sourceID)) {
90
+ return false;
91
+ }
92
+ return true;
93
+ });
94
+ return [showingRect, selectedRect];
95
+ }
96
+ static getSourceID(basicResult) {
97
+ var _a;
98
+ const defaultSourceID = "";
99
+ if (basicResult) {
100
+ return (_a = basicResult == null ? void 0 : basicResult.id) != null ? _a : defaultSourceID;
101
+ }
102
+ return defaultSourceID;
103
+ }
104
+ static findAllLine(pointList, isClose = true) {
105
+ const arr = [];
106
+ const newPoint = [...pointList];
107
+ if (newPoint.length >= 3 && isClose === true) {
108
+ newPoint.push(__spreadValues({}, newPoint[0]));
109
+ }
110
+ for (let i = 0; i < newPoint.length; i++) {
111
+ if (newPoint[i + 1]) {
112
+ arr.push({
113
+ point1: newPoint[i],
114
+ point2: newPoint[i + 1],
115
+ pointIndex: i
116
+ });
117
+ }
118
+ }
119
+ return arr;
120
+ }
121
+ static translateSourceID(sourceID) {
122
+ if (sourceID === void 0 || sourceID === 0 || sourceID === "0") {
123
+ sourceID = "";
124
+ }
125
+ return sourceID;
126
+ }
127
+ static isDifferSourceID(sourceIDA, sourceIDB) {
128
+ sourceIDA = this.translateSourceID(sourceIDA);
129
+ sourceIDB = this.translateSourceID(sourceIDB);
130
+ return `${sourceIDA}` !== `${sourceIDB}`;
131
+ }
132
+ static isSameSourceID(sourceIDA, sourceIDB) {
133
+ sourceIDA = this.translateSourceID(sourceIDA);
134
+ sourceIDB = this.translateSourceID(sourceIDB);
135
+ return `${sourceIDA}` === `${sourceIDB}`;
136
+ }
137
+ static getNextMarker(resultList, markerList = [], markerIndex) {
138
+ if ((markerList == null ? void 0 : markerList.length) === 0) {
139
+ return void 0;
140
+ }
141
+ let newSortList = markerList.map((data, index) => __spreadProps(__spreadValues({}, data), {index}));
142
+ if (typeof markerIndex === "number" && markerIndex > 0) {
143
+ const markerInfo = markerList[markerIndex];
144
+ if (markerInfo && resultList.every((rect) => rect.label !== markerInfo.value)) {
145
+ return {label: markerInfo.value, index: markerIndex};
146
+ }
147
+ newSortList = [...newSortList.slice(markerIndex, markerList.length), ...newSortList.slice(0, markerIndex)];
148
+ }
149
+ for (let i = 0; i < newSortList.length; i++) {
150
+ if (resultList.some((rect) => rect.label === newSortList[i].value)) {
151
+ continue;
152
+ }
153
+ return {label: newSortList[i].value, index: newSortList[i].index};
154
+ }
155
+ return void 0;
156
+ }
157
+ static getCurrentMarkerIndex(label, markerList = []) {
158
+ return markerList.findIndex((marker) => label === marker.value);
159
+ }
160
+ }
161
+ CommonToolUtils.jsonParser = (content, defaultValue = {}) => {
162
+ try {
163
+ if (typeof content === "string") {
164
+ return JSON.parse(content);
165
+ }
166
+ return isObject(content) ? content : defaultValue;
167
+ } catch (e) {
168
+ return defaultValue;
169
+ }
170
+ };
171
+
172
+ export { CommonToolUtils as default };