@labelbee/lb-annotation 1.14.0-alpha.3 → 1.14.0-alpha.5

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 (188) hide show
  1. package/dist/_virtual/MathUtilsWorker.js +1 -8
  2. package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -35
  3. package/dist/_virtual/filterBoxWorker.js +1 -8
  4. package/dist/_virtual/highlightWorker.js +1 -8
  5. package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -5
  6. package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -5
  7. package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -5
  8. package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -5
  9. package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -5
  10. package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -5
  11. package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -5
  12. package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -5
  13. package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -5
  14. package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -5
  15. package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
  16. package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -5
  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 +12 -5
  20. package/dist/assets/attributeIcon/icon_editFEN.svg.js +1 -5
  21. package/dist/assets/attributeIcon/icon_editHUANG.svg.js +1 -5
  22. package/dist/assets/attributeIcon/icon_editLAN.svg.js +1 -5
  23. package/dist/assets/attributeIcon/icon_editLV.svg.js +1 -5
  24. package/dist/assets/attributeIcon/icon_editQING.svg.js +1 -5
  25. package/dist/constant/annotation.js +1 -127
  26. package/dist/constant/annotationTask.js +1 -30
  27. package/dist/constant/defaultConfig.js +1 -266
  28. package/dist/constant/keyCode.js +1 -38
  29. package/dist/constant/style.js +1 -98
  30. package/dist/constant/tool.js +1 -236
  31. package/dist/core/index.js +1 -150
  32. package/dist/core/pointCloud/OrbitControls.js +1 -665
  33. package/dist/core/pointCloud/PCDLoader.js +2 -260
  34. package/dist/core/pointCloud/annotation.js +1 -215
  35. package/dist/core/pointCloud/cache.js +1 -53
  36. package/dist/core/pointCloud/index.js +5 -991
  37. package/dist/core/pointCloud/matrix.js +1 -138
  38. package/dist/core/scheduler.js +1 -233
  39. package/dist/core/toolOperation/LineToolOperation.js +1 -1434
  40. package/dist/core/toolOperation/ScribbleTool.js +1 -292
  41. package/dist/core/toolOperation/TextToolOperation.js +1 -131
  42. package/dist/core/toolOperation/ViewOperation.js +1 -556
  43. package/dist/core/toolOperation/basicToolOperation.js +1 -881
  44. package/dist/core/toolOperation/checkOperation.js +1 -208
  45. package/dist/core/toolOperation/cuboidOperation.js +1 -754
  46. package/dist/core/toolOperation/cuboidToggleButtonClass.js +7 -152
  47. package/dist/core/toolOperation/eventListener.js +1 -37
  48. package/dist/core/toolOperation/measureOperation.js +1 -41
  49. package/dist/core/toolOperation/pointCloud2dOperation.js +1 -365
  50. package/dist/core/toolOperation/pointOperation.js +1 -696
  51. package/dist/core/toolOperation/polygonOperation.js +1 -1251
  52. package/dist/core/toolOperation/rectOperation.js +1 -1233
  53. package/dist/core/toolOperation/segmentByRect.js +1 -174
  54. package/dist/core/toolOperation/tagOperation.js +3 -201
  55. package/dist/core/toolOperation/textAttributeClass.js +16 -182
  56. package/dist/index.js +1 -185
  57. package/dist/locales/constants.js +1 -24
  58. package/dist/locales/en_US/message.js +1 -25
  59. package/dist/locales/index.js +1 -19
  60. package/dist/locales/zh_CN/message.js +1 -25
  61. package/dist/newCore/CanvasScheduler.js +1 -35
  62. package/dist/utils/ActionsHistory.js +1 -84
  63. package/dist/utils/ImgUtils.js +1 -23
  64. package/dist/utils/MathUtils.js +2 -385
  65. package/dist/utils/VectorUtils.js +1 -25
  66. package/dist/utils/tool/AttributeUtils.js +1 -218
  67. package/dist/utils/tool/AxisUtils.js +1 -340
  68. package/dist/utils/tool/CanvasUtils.js +1 -62
  69. package/dist/utils/tool/CommonToolUtils.js +1 -174
  70. package/dist/utils/tool/CuboidUtils.js +1 -704
  71. package/dist/utils/tool/DblClickEventListener.js +1 -102
  72. package/dist/utils/tool/DrawUtils.js +3 -492
  73. package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -53
  74. package/dist/utils/tool/ImgPosUtils.js +1 -58
  75. package/dist/utils/tool/LineToolUtils.js +1 -261
  76. package/dist/utils/tool/MarkerUtils.js +1 -56
  77. package/dist/utils/tool/PolygonUtils.js +1 -460
  78. package/dist/utils/tool/RectUtils.js +1 -155
  79. package/dist/utils/tool/RenderDomClass.js +7 -57
  80. package/dist/utils/tool/RenderDomUtils.js +4 -21
  81. package/dist/utils/tool/StyleUtils.js +1 -31
  82. package/dist/utils/tool/TagUtils.js +1 -129
  83. package/dist/utils/tool/UnitUtils.js +1 -12
  84. package/dist/utils/tool/ZoomUtils.js +1 -72
  85. package/dist/utils/tool/polygonTool.js +1 -133
  86. package/dist/utils/uuid.js +1 -26
  87. package/es/_virtual/MathUtilsWorker.js +1 -6
  88. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -31
  89. package/es/_virtual/filterBoxWorker.js +1 -6
  90. package/es/_virtual/highlightWorker.js +1 -6
  91. package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -3
  92. package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -3
  93. package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -3
  94. package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -3
  95. package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -3
  96. package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -3
  97. package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -3
  98. package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -3
  99. package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -3
  100. package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -3
  101. package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -3
  102. package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -3
  103. package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -3
  104. package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -3
  105. package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -3
  106. package/es/assets/attributeIcon/icon_editFEN.svg.js +1 -3
  107. package/es/assets/attributeIcon/icon_editHUANG.svg.js +1 -3
  108. package/es/assets/attributeIcon/icon_editLAN.svg.js +1 -3
  109. package/es/assets/attributeIcon/icon_editLV.svg.js +1 -3
  110. package/es/assets/attributeIcon/icon_editQING.svg.js +1 -3
  111. package/es/constant/annotation.js +1 -113
  112. package/es/constant/annotationTask.js +1 -25
  113. package/es/constant/defaultConfig.js +1 -260
  114. package/es/constant/keyCode.js +1 -36
  115. package/es/constant/style.js +1 -74
  116. package/es/constant/tool.js +1 -220
  117. package/es/core/index.js +1 -148
  118. package/es/core/pointCloud/OrbitControls.js +1 -661
  119. package/es/core/pointCloud/PCDLoader.js +2 -256
  120. package/es/core/pointCloud/annotation.js +1 -211
  121. package/es/core/pointCloud/cache.js +1 -49
  122. package/es/core/pointCloud/index.js +5 -962
  123. package/es/core/pointCloud/matrix.js +1 -109
  124. package/es/core/scheduler.js +1 -228
  125. package/es/core/toolOperation/LineToolOperation.js +1 -1421
  126. package/es/core/toolOperation/ScribbleTool.js +1 -290
  127. package/es/core/toolOperation/TextToolOperation.js +1 -129
  128. package/es/core/toolOperation/ViewOperation.js +1 -549
  129. package/es/core/toolOperation/basicToolOperation.js +1 -877
  130. package/es/core/toolOperation/checkOperation.js +1 -206
  131. package/es/core/toolOperation/cuboidOperation.js +1 -752
  132. package/es/core/toolOperation/cuboidToggleButtonClass.js +7 -150
  133. package/es/core/toolOperation/eventListener.js +1 -35
  134. package/es/core/toolOperation/measureOperation.js +1 -39
  135. package/es/core/toolOperation/pointCloud2dOperation.js +1 -359
  136. package/es/core/toolOperation/pointOperation.js +1 -690
  137. package/es/core/toolOperation/polygonOperation.js +1 -1245
  138. package/es/core/toolOperation/rectOperation.js +1 -1228
  139. package/es/core/toolOperation/segmentByRect.js +1 -172
  140. package/es/core/toolOperation/tagOperation.js +3 -199
  141. package/es/core/toolOperation/textAttributeClass.js +16 -180
  142. package/es/index.js +1 -46
  143. package/es/locales/constants.js +1 -22
  144. package/es/locales/en_US/message.js +1 -23
  145. package/es/locales/index.js +1 -17
  146. package/es/locales/zh_CN/message.js +1 -23
  147. package/es/newCore/CanvasScheduler.js +1 -31
  148. package/es/utils/ActionsHistory.js +1 -78
  149. package/es/utils/ImgUtils.js +1 -21
  150. package/es/utils/MathUtils.js +2 -380
  151. package/es/utils/VectorUtils.js +1 -23
  152. package/es/utils/tool/AttributeUtils.js +1 -212
  153. package/es/utils/tool/AxisUtils.js +1 -335
  154. package/es/utils/tool/CanvasUtils.js +1 -60
  155. package/es/utils/tool/CommonToolUtils.js +1 -172
  156. package/es/utils/tool/CuboidUtils.js +1 -680
  157. package/es/utils/tool/DblClickEventListener.js +1 -100
  158. package/es/utils/tool/DrawUtils.js +3 -490
  159. package/es/utils/tool/EnhanceCommonToolUtils.js +1 -48
  160. package/es/utils/tool/ImgPosUtils.js +1 -56
  161. package/es/utils/tool/LineToolUtils.js +1 -255
  162. package/es/utils/tool/MarkerUtils.js +1 -54
  163. package/es/utils/tool/PolygonUtils.js +1 -458
  164. package/es/utils/tool/RectUtils.js +1 -153
  165. package/es/utils/tool/RenderDomClass.js +7 -55
  166. package/es/utils/tool/RenderDomUtils.js +4 -19
  167. package/es/utils/tool/StyleUtils.js +1 -29
  168. package/es/utils/tool/TagUtils.js +1 -127
  169. package/es/utils/tool/UnitUtils.js +1 -10
  170. package/es/utils/tool/ZoomUtils.js +1 -70
  171. package/es/utils/tool/polygonTool.js +1 -126
  172. package/es/utils/uuid.js +1 -24
  173. package/package.json +3 -4
  174. package/LICENSE +0 -203
  175. package/dist/core/pointCloud/segmentation.js +0 -144
  176. package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +0 -26
  177. package/dist/core/pointCloud/selector/Sse3dSelector.js +0 -16
  178. package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
  179. package/dist/types/core/pointCloud/selector/Sse3dLassoSelector.d.ts +0 -0
  180. package/dist/types/core/pointCloud/selector/Sse3dSelector.d.ts +0 -0
  181. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -12
  182. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -7
  183. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
  184. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -18
  185. package/es/core/pointCloud/segmentation.js +0 -120
  186. package/es/core/pointCloud/selector/Sse3dLassoSelector.js +0 -24
  187. package/es/core/pointCloud/selector/Sse3dSelector.js +0 -14
  188. package/es/core/toolOperation/scribbleTool2.js +0 -249
@@ -1,58 +1 @@
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
+ "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,261 +1 @@
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
+ "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,56 +1 @@
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;
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;