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