@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,56 @@
1
- class x{static getInitImgPos(n,t,h=0,c=1,r=!1){(h===90||h===270)&&(t={width:t.height,height:t.width});const d=n.width*c/t.width,i=n.height*c/t.height;let o=r?1:Math.min(d,i);const e={x:(n.width-t.width*o)/2,y:(n.height-t.height*o)/2},s=t.width*o,w=t.height*o;return r&&(o=1),{zoom:o,currentPos:e,imgInfo:{width:s,height:w}}}static getBasicRecPos(n,t,h,c=.9,r=1,d=!1){if(t&&n){const{x:i,y:o,height:e,width:s}=t;let w=h.height/e;s/e>h.width/h.height&&(w=h.width/s);const l=d?1:w*c*r,f={x:h.width/2,y:h.height/2},g={x:(i+s/2)*l,y:(o+e/2)*l};return{currentPos:{x:f.x-g.x,y:f.y-g.y},innerZoom:l}}return!1}}export{x as default};
1
+ class ImgPosUtils {
2
+ static getInitImgPos(canvasSize, imgSize, rotate = 0, zoomRatio = 1, isOriginalSize = false) {
3
+ if (rotate === 90 || rotate === 270) {
4
+ imgSize = {
5
+ width: imgSize.height,
6
+ height: imgSize.width
7
+ };
8
+ }
9
+ const wScale = canvasSize.width * zoomRatio / imgSize.width;
10
+ const hScale = canvasSize.height * zoomRatio / imgSize.height;
11
+ let scale = isOriginalSize ? 1 : Math.min(wScale, hScale);
12
+ const currentPos = {
13
+ x: (canvasSize.width - imgSize.width * scale) / 2,
14
+ y: (canvasSize.height - imgSize.height * scale) / 2
15
+ };
16
+ const width = imgSize.width * scale;
17
+ const height = imgSize.height * scale;
18
+ if (isOriginalSize) {
19
+ scale = 1;
20
+ }
21
+ return {
22
+ zoom: scale,
23
+ currentPos,
24
+ imgInfo: {width, height}
25
+ };
26
+ }
27
+ static getBasicRecPos(imgNode, basicRect, size, shrinkRatio = 0.9, zoomRatio = 1, isOriginalSize = false) {
28
+ if (basicRect && imgNode) {
29
+ const {x, y, height, width} = basicRect;
30
+ let initZoom = size.height / height;
31
+ if (width / height > size.width / size.height) {
32
+ initZoom = size.width / width;
33
+ }
34
+ const zoom = isOriginalSize ? 1 : initZoom * shrinkRatio * zoomRatio;
35
+ const viewCenter = {
36
+ x: size.width / 2,
37
+ y: size.height / 2
38
+ };
39
+ const imgCenter = {
40
+ x: (x + width / 2) * zoom,
41
+ y: (y + height / 2) * zoom
42
+ };
43
+ const currentPos = {
44
+ x: viewCenter.x - imgCenter.x,
45
+ y: viewCenter.y - imgCenter.y
46
+ };
47
+ return {
48
+ currentPos,
49
+ innerZoom: zoom
50
+ };
51
+ }
52
+ return false;
53
+ }
54
+ }
55
+
56
+ export { ImgPosUtils as default };
@@ -1 +1,255 @@
1
- import{EToolName as B,ELineTypes as R}from"../../constant/tool.js";import{createSmoothCurvePointsFromPointList as N}from"./polygonTool.js";import M from"./PolygonUtils.js";import O from"../MathUtils.js";var F=Object.defineProperty,S=Object.defineProperties,W=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,E=(t,n,o)=>n in t?F(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,x=(t,n)=>{for(var o in n||(n={}))q.call(n,o)&&E(t,o,n[o]);if(b)for(var o of b(n))V.call(n,o)&&E(t,o,n[o]);return t},C=(t,n)=>S(t,W(n)),D;(function(t){t[t.Create=0]="Create",t[t.Active=1]="Active",t[t.Edit=1]="Edit",t[t.None=2]="None"})(D||(D={}));var I;(function(t){t.ActiveArea="#B3B8FF"})(I||(I={}));const L=16,G=3,f=class{static isInLine(t,n,o,i=3){const{length:r}=O.getFootOfPerpendicular(t,n,o);return r<i}};let p=f;p.setSpecialEdgeStyle=t=>{t.lineCap="butt",t.setLineDash([10,10])},p.setReferenceCtx=t=>{t.lineCap="butt",t.setLineDash([6])},p.calcOptimalIntersection=(t,n,o,i,r)=>{let c,y=Infinity,a;if(t.find((g,e)=>{if(e===0)return;const s=f.isInLine(n.pointA,g,t[e-1]),l=f.isInLine(n.pointB,g,t[e-1]);return s&&l}))return{point:o};if(t.forEach((g,e)=>{if(e===0)return;const s={pointA:t[e-1],pointB:g},l=f.lineIntersection(n,s);if(l&&n){const{onLine2:P,onLine1:h,x:m,y:_}=l,v=f.calcDistance(o,l);if(f.isOnLine(n.pointB.x,n.pointB.y,g.x,g.y,t[e-1].x,t[e-1].y)){if(f.calcDistance(o,l)<i/r){const T=n.pointB,{footPoint:A,length:w}=O.getFootOfPerpendicular(T,s.pointA,s.pointB,!0);if(w!==void 0){const j=f.calcDistance(s.pointA,A),U=f.calcDistance(s.pointB,A);a={point:A,minDistance:w},w===Infinity&&(a.point=j>U?s.pointB:s.pointA)}}return}v<y&&P&&h&&(y=v,c={x:m,y:_})}}),c)return{point:c,minDistance:y};if(a)return a},p.lineIntersection=(t,n)=>{let o=!1,i=!1;const r=f.getAxisDiff(t),c=f.getAxisDiff(n),y=c.y*r.x-c.x*r.y;if(y===0)return!1;let a=t.pointA.y-n.pointA.y,u=t.pointA.x-n.pointA.x;const g=(n.pointB.x-n.pointA.x)*a-(n.pointB.y-n.pointA.y)*u,e=(t.pointB.x-t.pointA.x)*a-(t.pointB.y-t.pointA.y)*u;a=g/y,u=e/y,a>0&&a<1&&(o=!0),u>0&&u<1&&(i=!0);const s=t.pointA.x+a*(t.pointB.x-t.pointA.x),l=t.pointA.y+a*(t.pointB.y-t.pointA.y);return{x:s,y:l,onLine1:o,onLine2:i}},p.getAxisDiff=t=>({x:t.pointB.x-t.pointA.x,y:t.pointB.y-t.pointA.y}),p.calcDistance=(t,n)=>Math.sqrt(Math.pow(Math.abs(t.x-n.x),2)+Math.pow(Math.abs(t.y-n.y),2)),p.drawCurveLine=(t,n,o,i=!0,r=!1,c)=>{const y=N(n,L);t.save(),t.lineCap="round",t.lineJoin="round",t.strokeStyle=o.color,i&&(t.lineWidth=o.lineWidth),r&&f.setReferenceCtx(t),n.forEach((a,u)=>{const g=a==null?void 0:a.specialEdge,e=y.splice(0,L+1);t.save(),t.beginPath(),c===u&&(t.lineWidth=4),e.forEach(({x:s,y:l},P)=>{const h=P>0?"lineTo":"moveTo";g&&f.setSpecialEdgeStyle(t),t[h](s,l)}),t.stroke(),t.restore()}),t.restore()},p.calcTwoPointDistance=(t,n)=>Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),p.pointOverTarget=(t,n,o,i,r,c,y,a,u,g)=>{const e=t;if(!n)return t;if(o===B.Polygon){const s=f.getPolygonPointList(i,r);if(s.length===0||M.isInPolygon(t,s))return e;const P=s.concat(s[0]).map(d=>u(d)),h=u(n),m=u(t),_={pointA:h,pointB:m},v=f.calcOptimalIntersection(P,_,h,y,a);if(v){const d=g(v==null?void 0:v.point);e.x=d.x,e.y=d.y}else return n;return e}if(o===B.Rect){const{x:s,y:l,width:P,height:h}=i;return e.x=O.withinRange(e.x,[s,s+P]),e.y=O.withinRange(e.y,[l,l+h]),e}return e.x=O.withinRange(e.x,[0,c.width]),e.y=O.withinRange(e.y,[0,c.height]),e},p.getPolygonPointList=(t,n)=>{const{pointList:o}=t,{lineType:i}=n;return i===R.Line?o:M.createSmoothCurvePoints(o.reduce((r,c)=>[...r,c.x,c.y],[]),.5,!0,20)},p.isOnLine=(t,n,o,i,r,c)=>Math.abs((a=>(i-n)/(o-t)*(a-t)+n)(r)-c)<1e-6&&r>=t&&r<=o,p.inArea=({top:t,left:n,right:o,bottom:i},{x:r,y:c})=>c>=t&&c<=i&&r>=n&&r<=o,p.getVHPoint=(t,n,o,i)=>{const r=f.getAngle(t,o);return Math.abs(r)<45?C(x({},n),{y:i.y}):C(x({},n),{x:i.x})},p.getAngle=(t,n)=>{const o=n.x-t.x,i=n.y-t.y;return 360*Math.atan(i/o)/(2*Math.PI)};export{I as EColor,D as EStatus,G as POINT_RADIUS,L as SEGMENT_NUMBER,p as default};
1
+ import { EToolName, ELineTypes } from '../../constant/tool.js';
2
+ import { createSmoothCurvePointsFromPointList } from './polygonTool.js';
3
+ import PolygonUtils from './PolygonUtils.js';
4
+ import MathUtils from '../MathUtils.js';
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __defProps = Object.defineProperties;
8
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var EStatus;
26
+ (function(EStatus2) {
27
+ EStatus2[EStatus2["Create"] = 0] = "Create";
28
+ EStatus2[EStatus2["Active"] = 1] = "Active";
29
+ EStatus2[EStatus2["Edit"] = 1] = "Edit";
30
+ EStatus2[EStatus2["None"] = 2] = "None";
31
+ })(EStatus || (EStatus = {}));
32
+ var EColor;
33
+ (function(EColor2) {
34
+ EColor2["ActiveArea"] = "#B3B8FF";
35
+ })(EColor || (EColor = {}));
36
+ const SEGMENT_NUMBER = 16;
37
+ const POINT_RADIUS = 3;
38
+ const _LineToolUtils = class {
39
+ static isInLine(checkPoint, point1, point2, scope = 3) {
40
+ const {length} = MathUtils.getFootOfPerpendicular(checkPoint, point1, point2);
41
+ if (length < scope) {
42
+ return true;
43
+ }
44
+ return false;
45
+ }
46
+ };
47
+ let LineToolUtils = _LineToolUtils;
48
+ LineToolUtils.setSpecialEdgeStyle = (ctx) => {
49
+ ctx.lineCap = "butt";
50
+ ctx.setLineDash([10, 10]);
51
+ };
52
+ LineToolUtils.setReferenceCtx = (ctx) => {
53
+ ctx.lineCap = "butt";
54
+ ctx.setLineDash([6]);
55
+ };
56
+ LineToolUtils.calcOptimalIntersection = (pointList, matchLine, matchPoint, pointRadius, zoom) => {
57
+ let optimalIntersection;
58
+ let minDistance = Infinity;
59
+ let scopeIntersection;
60
+ const matchLineOnExistLine = pointList.find((p, index) => {
61
+ if (index === 0) {
62
+ return;
63
+ }
64
+ const pointAOnLine = _LineToolUtils.isInLine(matchLine.pointA, p, pointList[index - 1]);
65
+ const pointBOnLine = _LineToolUtils.isInLine(matchLine.pointB, p, pointList[index - 1]);
66
+ return pointAOnLine && pointBOnLine;
67
+ });
68
+ if (matchLineOnExistLine) {
69
+ return {point: matchPoint};
70
+ }
71
+ pointList.forEach((point, index) => {
72
+ if (index === 0) {
73
+ return;
74
+ }
75
+ const line2 = {
76
+ pointA: pointList[index - 1],
77
+ pointB: point
78
+ };
79
+ const intersection = _LineToolUtils.lineIntersection(matchLine, line2);
80
+ if (intersection && matchLine) {
81
+ const {onLine2, onLine1, x, y} = intersection;
82
+ const distance = _LineToolUtils.calcDistance(matchPoint, intersection);
83
+ const matchPointInLine = _LineToolUtils.isOnLine(matchLine.pointB.x, matchLine.pointB.y, point.x, point.y, pointList[index - 1].x, pointList[index - 1].y);
84
+ if (matchPointInLine) {
85
+ const intersectionDistance = _LineToolUtils.calcDistance(matchPoint, intersection);
86
+ if (intersectionDistance < pointRadius / zoom) {
87
+ const cPoint = matchLine.pointB;
88
+ const {footPoint, length} = MathUtils.getFootOfPerpendicular(cPoint, line2.pointA, line2.pointB, true);
89
+ if (length !== void 0) {
90
+ const distPointA = _LineToolUtils.calcDistance(line2.pointA, footPoint);
91
+ const distPointB = _LineToolUtils.calcDistance(line2.pointB, footPoint);
92
+ scopeIntersection = {
93
+ point: footPoint,
94
+ minDistance: length
95
+ };
96
+ if (length === Infinity) {
97
+ scopeIntersection.point = distPointA > distPointB ? line2.pointB : line2.pointA;
98
+ }
99
+ }
100
+ }
101
+ return;
102
+ }
103
+ if (distance < minDistance && onLine2 && onLine1) {
104
+ minDistance = distance;
105
+ optimalIntersection = {
106
+ x,
107
+ y
108
+ };
109
+ }
110
+ }
111
+ });
112
+ if (optimalIntersection) {
113
+ return {point: optimalIntersection, minDistance};
114
+ }
115
+ if (scopeIntersection) {
116
+ return scopeIntersection;
117
+ }
118
+ return void 0;
119
+ };
120
+ LineToolUtils.lineIntersection = (lineA, lineB) => {
121
+ let onLine1 = false;
122
+ let onLine2 = false;
123
+ const lineADiff = _LineToolUtils.getAxisDiff(lineA);
124
+ const lineBDiff = _LineToolUtils.getAxisDiff(lineB);
125
+ const denominator = lineBDiff.y * lineADiff.x - lineBDiff.x * lineADiff.y;
126
+ if (denominator === 0) {
127
+ return false;
128
+ }
129
+ let a = lineA.pointA.y - lineB.pointA.y;
130
+ let b = lineA.pointA.x - lineB.pointA.x;
131
+ const numerator1 = (lineB.pointB.x - lineB.pointA.x) * a - (lineB.pointB.y - lineB.pointA.y) * b;
132
+ const numerator2 = (lineA.pointB.x - lineA.pointA.x) * a - (lineA.pointB.y - lineA.pointA.y) * b;
133
+ a = numerator1 / denominator;
134
+ b = numerator2 / denominator;
135
+ if (a > 0 && a < 1) {
136
+ onLine1 = true;
137
+ }
138
+ if (b > 0 && b < 1) {
139
+ onLine2 = true;
140
+ }
141
+ const x = lineA.pointA.x + a * (lineA.pointB.x - lineA.pointA.x);
142
+ const y = lineA.pointA.y + a * (lineA.pointB.y - lineA.pointA.y);
143
+ return {x, y, onLine1, onLine2};
144
+ };
145
+ LineToolUtils.getAxisDiff = (line) => {
146
+ return {
147
+ x: line.pointB.x - line.pointA.x,
148
+ y: line.pointB.y - line.pointA.y
149
+ };
150
+ };
151
+ LineToolUtils.calcDistance = (point1, point2) => {
152
+ return Math.sqrt(Math.pow(Math.abs(point1.x - point2.x), 2) + Math.pow(Math.abs(point1.y - point2.y), 2));
153
+ };
154
+ LineToolUtils.drawCurveLine = (ctx, points, config, applyLineWidth = true, isReference = false, hoverEdgeIndex) => {
155
+ const pointList = createSmoothCurvePointsFromPointList(points, SEGMENT_NUMBER);
156
+ ctx.save();
157
+ ctx.lineCap = "round";
158
+ ctx.lineJoin = "round";
159
+ ctx.strokeStyle = config.color;
160
+ if (applyLineWidth) {
161
+ ctx.lineWidth = config.lineWidth;
162
+ }
163
+ if (isReference) {
164
+ _LineToolUtils.setReferenceCtx(ctx);
165
+ }
166
+ points.forEach((point, index) => {
167
+ const specialEdge = point == null ? void 0 : point.specialEdge;
168
+ const curveLinePoints = pointList.splice(0, SEGMENT_NUMBER + 1);
169
+ ctx.save();
170
+ ctx.beginPath();
171
+ if (hoverEdgeIndex === index) {
172
+ ctx.lineWidth = 4;
173
+ }
174
+ curveLinePoints.forEach(({x, y}, pointIndex) => {
175
+ const fn = pointIndex > 0 ? "lineTo" : "moveTo";
176
+ if (specialEdge) {
177
+ _LineToolUtils.setSpecialEdgeStyle(ctx);
178
+ }
179
+ ctx[fn](x, y);
180
+ });
181
+ ctx.stroke();
182
+ ctx.restore();
183
+ });
184
+ ctx.restore();
185
+ };
186
+ LineToolUtils.calcTwoPointDistance = (pointA, pointB) => Math.sqrt(Math.pow(pointA.x - pointB.x, 2) + Math.pow(pointA.y - pointB.y, 2));
187
+ LineToolUtils.pointOverTarget = (axis, preAxis, dependToolName, dependData, dependConfig, imageSize, pointRadius, zoom, getRenderAxis, getAbsAxis) => {
188
+ const absAxis = axis;
189
+ if (!preAxis) {
190
+ return axis;
191
+ }
192
+ if (dependToolName === EToolName.Polygon) {
193
+ const polygonPointList = _LineToolUtils.getPolygonPointList(dependData, dependConfig);
194
+ if (polygonPointList.length === 0) {
195
+ return absAxis;
196
+ }
197
+ const inPolygon = PolygonUtils.isInPolygon(axis, polygonPointList);
198
+ if (inPolygon) {
199
+ return absAxis;
200
+ }
201
+ const pointList = polygonPointList.concat(polygonPointList[0]).map((i) => getRenderAxis(i));
202
+ const pointA = getRenderAxis(preAxis);
203
+ const pointB = getRenderAxis(axis);
204
+ const line1 = {
205
+ pointA,
206
+ pointB
207
+ };
208
+ const intersection = _LineToolUtils.calcOptimalIntersection(pointList, line1, pointA, pointRadius, zoom);
209
+ if (intersection) {
210
+ const intersectionAbsAxis = getAbsAxis(intersection == null ? void 0 : intersection.point);
211
+ absAxis.x = intersectionAbsAxis.x;
212
+ absAxis.y = intersectionAbsAxis.y;
213
+ } else {
214
+ return preAxis;
215
+ }
216
+ return absAxis;
217
+ }
218
+ if (dependToolName === EToolName.Rect) {
219
+ const {x, y, width, height} = dependData;
220
+ absAxis.x = MathUtils.withinRange(absAxis.x, [x, x + width]);
221
+ absAxis.y = MathUtils.withinRange(absAxis.y, [y, y + height]);
222
+ return absAxis;
223
+ }
224
+ absAxis.x = MathUtils.withinRange(absAxis.x, [0, imageSize.width]);
225
+ absAxis.y = MathUtils.withinRange(absAxis.y, [0, imageSize.height]);
226
+ return absAxis;
227
+ };
228
+ LineToolUtils.getPolygonPointList = (dependData, dependConfig) => {
229
+ const {pointList} = dependData;
230
+ const {lineType} = dependConfig;
231
+ return lineType === ELineTypes.Line ? pointList : PolygonUtils.createSmoothCurvePoints(pointList.reduce((acc, cur) => {
232
+ return [...acc, cur.x, cur.y];
233
+ }, []), 0.5, true, 20);
234
+ };
235
+ LineToolUtils.isOnLine = (x, y, endX, endY, px, py) => {
236
+ const f = (someX) => {
237
+ return (endY - y) / (endX - x) * (someX - x) + y;
238
+ };
239
+ return Math.abs(f(px) - py) < 1e-6 && px >= x && px <= endX;
240
+ };
241
+ LineToolUtils.inArea = ({top, left, right, bottom}, {x, y}) => y >= top && y <= bottom && x >= left && x <= right;
242
+ LineToolUtils.getVHPoint = (lastPoint, nextPoint, absNextPoint, renderLastPoint) => {
243
+ const angle = _LineToolUtils.getAngle(lastPoint, absNextPoint);
244
+ if (Math.abs(angle) < 45) {
245
+ return __spreadProps(__spreadValues({}, nextPoint), {y: renderLastPoint.y});
246
+ }
247
+ return __spreadProps(__spreadValues({}, nextPoint), {x: renderLastPoint.x});
248
+ };
249
+ LineToolUtils.getAngle = (startPoint, endPoint) => {
250
+ const diffX = endPoint.x - startPoint.x;
251
+ const diffY = endPoint.y - startPoint.y;
252
+ return 360 * Math.atan(diffY / diffX) / (2 * Math.PI);
253
+ };
254
+
255
+ export { EColor, EStatus, POINT_RADIUS, SEGMENT_NUMBER, LineToolUtils as default };
@@ -1 +1,54 @@
1
- import{cloneDeep as c}from"lodash";import f from"./AttributeUtils.js";class u{static getMarkerShowText(t,r=[]){return f.getAttributeShowText(t,r)}}u.getAuxiliaryLineByMarkerList=(o,t)=>{var r;const s=c(o),l=[];let e=s.shift();for(;e;)(r=e.target)==null||r.forEach(n=>{const i=s.find(a=>a.value===n);i&&(e==null?void 0:e[t])&&l.push({start:e[t],end:i[t]})}),e=s.shift();return l},u.getAuxiliaryLineCoord=(o,t)=>{const r=[];return o.forEach(s=>{const{start:l,end:e}=s,n=t.find(a=>a.label===l);if(!n)return;const i=t.find(a=>a.label===e);!i||r.push({start:{x:n.x,y:n.y},end:{x:i.x,y:i.y}})}),r};export{u as default};
1
+ import { cloneDeep } from 'lodash';
2
+ import AttributeUtils from './AttributeUtils.js';
3
+
4
+ class MarkerUtils {
5
+ static getMarkerShowText(marker, markerList = []) {
6
+ return AttributeUtils.getAttributeShowText(marker, markerList);
7
+ }
8
+ }
9
+ MarkerUtils.getAuxiliaryLineByMarkerList = (markerList, attr) => {
10
+ var _a;
11
+ const queue = cloneDeep(markerList);
12
+ const auxiliaryLines = [];
13
+ let currentNode = queue.shift();
14
+ while (currentNode) {
15
+ (_a = currentNode.target) == null ? void 0 : _a.forEach((element) => {
16
+ const targetMarkerListItem = queue.find((i) => i.value === element);
17
+ if (targetMarkerListItem && (currentNode == null ? void 0 : currentNode[attr])) {
18
+ auxiliaryLines.push({
19
+ start: currentNode[attr],
20
+ end: targetMarkerListItem[attr]
21
+ });
22
+ }
23
+ });
24
+ currentNode = queue.shift();
25
+ }
26
+ return auxiliaryLines;
27
+ };
28
+ MarkerUtils.getAuxiliaryLineCoord = (auxiliaryLines, pointList) => {
29
+ const result = [];
30
+ auxiliaryLines.forEach((line) => {
31
+ const {start, end} = line;
32
+ const startPoint = pointList.find((item) => item.label === start);
33
+ if (!startPoint) {
34
+ return;
35
+ }
36
+ const targetPoint = pointList.find((item) => item.label === end);
37
+ if (!targetPoint) {
38
+ return;
39
+ }
40
+ result.push({
41
+ start: {
42
+ x: startPoint.x,
43
+ y: startPoint.y
44
+ },
45
+ end: {
46
+ x: targetPoint.x,
47
+ y: targetPoint.y
48
+ }
49
+ });
50
+ });
51
+ return result;
52
+ };
53
+
54
+ export { MarkerUtils as default };