@labelbee/lb-annotation 1.0.0-alpha.1

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 (241) hide show
  1. package/README.md +210 -0
  2. package/dist/_virtual/MathUtilsWorker.js +1 -0
  3. package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -0
  4. package/dist/_virtual/filterBoxWorker.js +1 -0
  5. package/dist/_virtual/highlightWorker.js +1 -0
  6. package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -0
  7. package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -0
  8. package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -0
  9. package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -0
  10. package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -0
  11. package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -0
  12. package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -0
  13. package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -0
  14. package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -0
  15. package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -0
  16. package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -0
  17. package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -0
  18. package/dist/assets/attributeIcon/icon_cuboidMore.svg.js +5 -0
  19. package/dist/assets/attributeIcon/icon_cuboidRight.svg.js +5 -0
  20. package/dist/assets/attributeIcon/icon_cuboidTop.svg.js +12 -0
  21. package/dist/assets/attributeIcon/icon_editFEN.svg.js +1 -0
  22. package/dist/assets/attributeIcon/icon_editHUANG.svg.js +1 -0
  23. package/dist/assets/attributeIcon/icon_editLAN.svg.js +1 -0
  24. package/dist/assets/attributeIcon/icon_editLV.svg.js +1 -0
  25. package/dist/assets/attributeIcon/icon_editQING.svg.js +1 -0
  26. package/dist/constant/annotation.js +1 -0
  27. package/dist/constant/annotationTask.js +1 -0
  28. package/dist/constant/defaultConfig.js +1 -0
  29. package/dist/constant/keyCode.js +1 -0
  30. package/dist/constant/style.js +1 -0
  31. package/dist/constant/tool.js +1 -0
  32. package/dist/core/index.js +1 -0
  33. package/dist/core/pointCloud/OrbitControls.js +1 -0
  34. package/dist/core/pointCloud/PCDLoader.js +2 -0
  35. package/dist/core/pointCloud/annotation.js +1 -0
  36. package/dist/core/pointCloud/cache.js +1 -0
  37. package/dist/core/pointCloud/index.js +11 -0
  38. package/dist/core/pointCloud/matrix.js +1 -0
  39. package/dist/core/scheduler.js +1 -0
  40. package/dist/core/toolOperation/LineToolOperation.js +1 -0
  41. package/dist/core/toolOperation/ScribbleTool.js +1 -0
  42. package/dist/core/toolOperation/TextToolOperation.js +1 -0
  43. package/dist/core/toolOperation/ViewOperation.js +1 -0
  44. package/dist/core/toolOperation/basicToolOperation.js +1 -0
  45. package/dist/core/toolOperation/checkOperation.js +1 -0
  46. package/dist/core/toolOperation/cuboidOperation.js +1 -0
  47. package/dist/core/toolOperation/cuboidToggleButtonClass.js +31 -0
  48. package/dist/core/toolOperation/eventListener.js +1 -0
  49. package/dist/core/toolOperation/measureOperation.js +1 -0
  50. package/dist/core/toolOperation/pointCloud2dOperation.js +1 -0
  51. package/dist/core/toolOperation/pointOperation.js +1 -0
  52. package/dist/core/toolOperation/polygonOperation.js +1 -0
  53. package/dist/core/toolOperation/rectOperation.js +1 -0
  54. package/dist/core/toolOperation/segmentByRect.js +1 -0
  55. package/dist/core/toolOperation/tagOperation.js +19 -0
  56. package/dist/core/toolOperation/textAttributeClass.js +37 -0
  57. package/dist/index.js +1 -0
  58. package/dist/locales/constants.js +1 -0
  59. package/dist/locales/en_US/message.js +1 -0
  60. package/dist/locales/index.js +1 -0
  61. package/dist/locales/zh_CN/message.js +1 -0
  62. package/dist/newCore/CanvasScheduler.js +1 -0
  63. package/dist/types/constant/annotation.d.ts +118 -0
  64. package/dist/types/constant/annotationTask.d.ts +16 -0
  65. package/dist/types/constant/defaultConfig.d.ts +273 -0
  66. package/dist/types/constant/keyCode.d.ts +33 -0
  67. package/dist/types/constant/style.d.ts +50 -0
  68. package/dist/types/constant/tool.d.ts +194 -0
  69. package/dist/types/core/index.d.ts +105 -0
  70. package/dist/types/core/pointCloud/OrbitControls.d.ts +60 -0
  71. package/dist/types/core/pointCloud/PCDLoader.d.ts +12 -0
  72. package/dist/types/core/pointCloud/annotation.d.ts +86 -0
  73. package/dist/types/core/pointCloud/cache.d.ts +26 -0
  74. package/dist/types/core/pointCloud/filterBoxWorker.d.ts +1 -0
  75. package/dist/types/core/pointCloud/highlightWorker.d.ts +1 -0
  76. package/dist/types/core/pointCloud/index.d.ts +374 -0
  77. package/dist/types/core/pointCloud/matrix.d.ts +63 -0
  78. package/dist/types/core/scheduler.d.ts +88 -0
  79. package/dist/types/core/toolOperation/LineToolOperation.d.ts +443 -0
  80. package/dist/types/core/toolOperation/ScribbleTool.d.ts +65 -0
  81. package/dist/types/core/toolOperation/TextToolOperation.d.ts +41 -0
  82. package/dist/types/core/toolOperation/ViewOperation.d.ts +102 -0
  83. package/dist/types/core/toolOperation/basicToolOperation.d.ts +266 -0
  84. package/dist/types/core/toolOperation/checkOperation.d.ts +37 -0
  85. package/dist/types/core/toolOperation/cuboidOperation.d.ts +174 -0
  86. package/dist/types/core/toolOperation/cuboidToggleButtonClass.d.ts +38 -0
  87. package/dist/types/core/toolOperation/eventListener.d.ts +33 -0
  88. package/dist/types/core/toolOperation/measureOperation.d.ts +8 -0
  89. package/dist/types/core/toolOperation/pointCloud2dOperation.d.ts +119 -0
  90. package/dist/types/core/toolOperation/pointOperation.d.ts +135 -0
  91. package/dist/types/core/toolOperation/polygonOperation.d.ts +201 -0
  92. package/dist/types/core/toolOperation/rectOperation.d.ts +175 -0
  93. package/dist/types/core/toolOperation/segmentByRect.d.ts +31 -0
  94. package/dist/types/core/toolOperation/tagOperation.d.ts +44 -0
  95. package/dist/types/core/toolOperation/textAttributeClass.d.ts +65 -0
  96. package/dist/types/index.d.ts +37 -0
  97. package/dist/types/locales/constants.d.ts +19 -0
  98. package/dist/types/locales/en_US/message.d.ts +2 -0
  99. package/dist/types/locales/index.d.ts +4 -0
  100. package/dist/types/locales/zh_CN/message.d.ts +2 -0
  101. package/dist/types/newCore/CanvasScheduler.d.ts +31 -0
  102. package/dist/types/newCore/index.d.ts +1 -0
  103. package/dist/types/utils/ActionsHistory.d.ts +32 -0
  104. package/dist/types/utils/EventBus.d.ts +40 -0
  105. package/dist/types/utils/ImgUtils.d.ts +3 -0
  106. package/dist/types/utils/MathUtils.d.ts +172 -0
  107. package/dist/types/utils/MathUtilsWorker.d.ts +29 -0
  108. package/dist/types/utils/VectorUtils.d.ts +16 -0
  109. package/dist/types/utils/tool/AttributeUtils.d.ts +94 -0
  110. package/dist/types/utils/tool/AxisUtils.d.ts +238 -0
  111. package/dist/types/utils/tool/CanvasUtils.d.ts +46 -0
  112. package/dist/types/utils/tool/CommonToolUtils.d.ts +105 -0
  113. package/dist/types/utils/tool/CuboidUtils.d.ts +267 -0
  114. package/dist/types/utils/tool/DblClickEventListener.d.ts +47 -0
  115. package/dist/types/utils/tool/DrawUtils.d.ts +196 -0
  116. package/dist/types/utils/tool/EnhanceCommonToolUtils.d.ts +23 -0
  117. package/dist/types/utils/tool/ImgPosUtils.d.ts +34 -0
  118. package/dist/types/utils/tool/LineToolUtils.d.ts +105 -0
  119. package/dist/types/utils/tool/MarkerUtils.d.ts +27 -0
  120. package/dist/types/utils/tool/PolygonUtils.d.ts +120 -0
  121. package/dist/types/utils/tool/RectUtils.d.ts +69 -0
  122. package/dist/types/utils/tool/RenderDomClass.d.ts +24 -0
  123. package/dist/types/utils/tool/RenderDomUtils.d.ts +3 -0
  124. package/dist/types/utils/tool/StyleUtils.d.ts +15 -0
  125. package/dist/types/utils/tool/TagUtils.d.ts +54 -0
  126. package/dist/types/utils/tool/UnitUtils.d.ts +4 -0
  127. package/dist/types/utils/tool/ZoomUtils.d.ts +16 -0
  128. package/dist/types/utils/tool/polygonTool.d.ts +32 -0
  129. package/dist/types/utils/uuid.d.ts +1 -0
  130. package/dist/utils/ActionsHistory.js +1 -0
  131. package/dist/utils/ImgUtils.js +1 -0
  132. package/dist/utils/MathUtils.js +2 -0
  133. package/dist/utils/VectorUtils.js +1 -0
  134. package/dist/utils/tool/AttributeUtils.js +1 -0
  135. package/dist/utils/tool/AxisUtils.js +1 -0
  136. package/dist/utils/tool/CanvasUtils.js +1 -0
  137. package/dist/utils/tool/CommonToolUtils.js +1 -0
  138. package/dist/utils/tool/CuboidUtils.js +1 -0
  139. package/dist/utils/tool/DblClickEventListener.js +1 -0
  140. package/dist/utils/tool/DrawUtils.js +3 -0
  141. package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -0
  142. package/dist/utils/tool/ImgPosUtils.js +1 -0
  143. package/dist/utils/tool/LineToolUtils.js +1 -0
  144. package/dist/utils/tool/MarkerUtils.js +1 -0
  145. package/dist/utils/tool/PolygonUtils.js +1 -0
  146. package/dist/utils/tool/RectUtils.js +1 -0
  147. package/dist/utils/tool/RenderDomClass.js +20 -0
  148. package/dist/utils/tool/RenderDomUtils.js +16 -0
  149. package/dist/utils/tool/StyleUtils.js +1 -0
  150. package/dist/utils/tool/TagUtils.js +1 -0
  151. package/dist/utils/tool/UnitUtils.js +1 -0
  152. package/dist/utils/tool/ZoomUtils.js +1 -0
  153. package/dist/utils/tool/polygonTool.js +1 -0
  154. package/dist/utils/uuid.js +1 -0
  155. package/es/_virtual/MathUtilsWorker.js +1 -0
  156. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -0
  157. package/es/_virtual/filterBoxWorker.js +1 -0
  158. package/es/_virtual/highlightWorker.js +1 -0
  159. package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -0
  160. package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -0
  161. package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -0
  162. package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -0
  163. package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -0
  164. package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -0
  165. package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -0
  166. package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -0
  167. package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -0
  168. package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -0
  169. package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -0
  170. package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -0
  171. package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -0
  172. package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -0
  173. package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -0
  174. package/es/assets/attributeIcon/icon_editFEN.svg.js +1 -0
  175. package/es/assets/attributeIcon/icon_editHUANG.svg.js +1 -0
  176. package/es/assets/attributeIcon/icon_editLAN.svg.js +1 -0
  177. package/es/assets/attributeIcon/icon_editLV.svg.js +1 -0
  178. package/es/assets/attributeIcon/icon_editQING.svg.js +1 -0
  179. package/es/constant/annotation.js +1 -0
  180. package/es/constant/annotationTask.js +1 -0
  181. package/es/constant/defaultConfig.js +1 -0
  182. package/es/constant/keyCode.js +1 -0
  183. package/es/constant/style.js +1 -0
  184. package/es/constant/tool.js +1 -0
  185. package/es/core/index.js +1 -0
  186. package/es/core/pointCloud/OrbitControls.js +1 -0
  187. package/es/core/pointCloud/PCDLoader.js +2 -0
  188. package/es/core/pointCloud/annotation.js +1 -0
  189. package/es/core/pointCloud/cache.js +1 -0
  190. package/es/core/pointCloud/index.js +11 -0
  191. package/es/core/pointCloud/matrix.js +1 -0
  192. package/es/core/scheduler.js +1 -0
  193. package/es/core/toolOperation/LineToolOperation.js +1 -0
  194. package/es/core/toolOperation/ScribbleTool.js +1 -0
  195. package/es/core/toolOperation/TextToolOperation.js +1 -0
  196. package/es/core/toolOperation/ViewOperation.js +1 -0
  197. package/es/core/toolOperation/basicToolOperation.js +1 -0
  198. package/es/core/toolOperation/checkOperation.js +1 -0
  199. package/es/core/toolOperation/cuboidOperation.js +1 -0
  200. package/es/core/toolOperation/cuboidToggleButtonClass.js +31 -0
  201. package/es/core/toolOperation/eventListener.js +1 -0
  202. package/es/core/toolOperation/measureOperation.js +1 -0
  203. package/es/core/toolOperation/pointCloud2dOperation.js +1 -0
  204. package/es/core/toolOperation/pointOperation.js +1 -0
  205. package/es/core/toolOperation/polygonOperation.js +1 -0
  206. package/es/core/toolOperation/rectOperation.js +1 -0
  207. package/es/core/toolOperation/segmentByRect.js +1 -0
  208. package/es/core/toolOperation/tagOperation.js +19 -0
  209. package/es/core/toolOperation/textAttributeClass.js +37 -0
  210. package/es/index.js +1 -0
  211. package/es/locales/constants.js +1 -0
  212. package/es/locales/en_US/message.js +1 -0
  213. package/es/locales/index.js +1 -0
  214. package/es/locales/zh_CN/message.js +1 -0
  215. package/es/newCore/CanvasScheduler.js +1 -0
  216. package/es/utils/ActionsHistory.js +1 -0
  217. package/es/utils/ImgUtils.js +1 -0
  218. package/es/utils/MathUtils.js +2 -0
  219. package/es/utils/VectorUtils.js +1 -0
  220. package/es/utils/tool/AttributeUtils.js +1 -0
  221. package/es/utils/tool/AxisUtils.js +1 -0
  222. package/es/utils/tool/CanvasUtils.js +1 -0
  223. package/es/utils/tool/CommonToolUtils.js +1 -0
  224. package/es/utils/tool/CuboidUtils.js +1 -0
  225. package/es/utils/tool/DblClickEventListener.js +1 -0
  226. package/es/utils/tool/DrawUtils.js +3 -0
  227. package/es/utils/tool/EnhanceCommonToolUtils.js +1 -0
  228. package/es/utils/tool/ImgPosUtils.js +1 -0
  229. package/es/utils/tool/LineToolUtils.js +1 -0
  230. package/es/utils/tool/MarkerUtils.js +1 -0
  231. package/es/utils/tool/PolygonUtils.js +1 -0
  232. package/es/utils/tool/RectUtils.js +1 -0
  233. package/es/utils/tool/RenderDomClass.js +20 -0
  234. package/es/utils/tool/RenderDomUtils.js +16 -0
  235. package/es/utils/tool/StyleUtils.js +1 -0
  236. package/es/utils/tool/TagUtils.js +1 -0
  237. package/es/utils/tool/UnitUtils.js +1 -0
  238. package/es/utils/tool/ZoomUtils.js +1 -0
  239. package/es/utils/tool/polygonTool.js +1 -0
  240. package/es/utils/uuid.js +1 -0
  241. package/package.json +103 -0
@@ -0,0 +1,196 @@
1
+ import type { ICuboid, ICuboidConfig, IDrawingCuboid } from '@/types/tool/cuboid';
2
+ import { ELineTypes } from '../../constant/tool';
3
+ import { IPolygonPoint } from '../../types/tool/polygon';
4
+ export interface IDrawTextConfig {
5
+ color: string;
6
+ font: string;
7
+ shadowColor: string;
8
+ shadowOffsetX: number;
9
+ shadowOffsetY: number;
10
+ shadowBlur: number;
11
+ textMaxWidth: number;
12
+ offsetX: number;
13
+ offsetY: number;
14
+ textAlign: 'start' | 'center' | 'end' | 'left' | 'right';
15
+ lineHeight: number;
16
+ }
17
+ export default class DrawUtils {
18
+ static drawImg: (canvas: HTMLCanvasElement, imgNode: HTMLImageElement | HTMLCanvasElement, options?: Partial<IOffsetCanvasPosition & {
19
+ imgAttribute: IImageAttribute;
20
+ }>) => void;
21
+ static drawLine(canvas: HTMLCanvasElement, startPoint: IPoint | IPolygonPoint, endPoint: IPoint | IPolygonPoint, options?: Partial<{
22
+ color: string;
23
+ thickness: number;
24
+ lineCap: CanvasLineCap;
25
+ lineDash: number[];
26
+ }>): void;
27
+ /**
28
+ * 查看绘制拉框
29
+ * @param canvas
30
+ * @param rect
31
+ * @param options
32
+ */
33
+ static drawRect(canvas: HTMLCanvasElement, rect: IRect, options?: Partial<{
34
+ color: string;
35
+ thickness: number;
36
+ lineCap: CanvasLineCap;
37
+ hiddenText: boolean;
38
+ lineDash: number[];
39
+ }>): void;
40
+ /**
41
+ * 填充矩形框的绘制
42
+ * @param canvas
43
+ * @param rect
44
+ * @param options
45
+ */
46
+ static drawRectWithFill(canvas: HTMLCanvasElement, rect: IRect, options?: Partial<{
47
+ color: string;
48
+ }>): void;
49
+ /**
50
+ * 通过 DOM 形式创建标签
51
+ * @param parent
52
+ * @param text
53
+ * @param id
54
+ * @returns
55
+ */
56
+ static drawTagByDom(parent: HTMLElement, text: string, id: string): HTMLDivElement | undefined;
57
+ static drawTag(canvas: HTMLCanvasElement, tagList: {
58
+ keyName: string;
59
+ value: string[];
60
+ }[]): HTMLDivElement | undefined;
61
+ /**
62
+ * 绘制点击线条
63
+ * @param canvas
64
+ * @param pointList
65
+ * @param options
66
+ * @returns
67
+ */
68
+ static drawLineWithPointList(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{
69
+ color: string;
70
+ thickness: number;
71
+ lineCap: CanvasLineCap;
72
+ lineType: ELineTypes;
73
+ lineDash: number[];
74
+ hoverEdgeIndex: number;
75
+ }>): IPolygonPoint[] | undefined;
76
+ static drawCircle(canvas: HTMLCanvasElement, anchorPoint: IPoint, radius: number, options?: Partial<{
77
+ startAngleDeg: number;
78
+ endAngleDeg: number;
79
+ thickness: number;
80
+ color: string;
81
+ fill: string;
82
+ }>): void;
83
+ static drawCircleWithFill(canvas: HTMLCanvasElement, anchorPoint: IPoint, radius?: number, options?: Partial<{
84
+ color: string;
85
+ }>): void;
86
+ /**
87
+ * 绘制特殊点 - 三角形
88
+ *
89
+ * @export
90
+ * @param {CanvasRenderingContext2D} ctx
91
+ * @param {ICoord} point
92
+ * @param {number} [pointRadius=6]
93
+ * @param {string} fillStyle
94
+ * @param {boolean} [specialPoint]
95
+ */
96
+ static drawSpecialPoint(canvas: HTMLCanvasElement, point: ICoordinate, pointRadius: number | undefined, fillStyle: string): void;
97
+ static drawPolygon(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{
98
+ color: string;
99
+ thickness: number;
100
+ lineCap: CanvasLineCap;
101
+ isClose: boolean;
102
+ lineType: ELineTypes;
103
+ lineDash: number[];
104
+ }>): IPolygonPoint[];
105
+ static drawPolygonWithFill(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{
106
+ color: string;
107
+ lineType: ELineTypes;
108
+ }>): IPolygonPoint[] | undefined;
109
+ static drawPolygonWithFillAndLine(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{
110
+ strokeColor: string;
111
+ fillColor: string;
112
+ pointColor: string;
113
+ thickness: number;
114
+ lineCap: CanvasLineCap;
115
+ isClose: boolean;
116
+ lineType: ELineTypes;
117
+ }>): IPolygonPoint[];
118
+ /**
119
+ * 绘制多边形带有关键点的多边形
120
+ * @param canvas
121
+ * @param pointList
122
+ * @param options
123
+ * @returns
124
+ */
125
+ static drawPolygonWithKeyPoint(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{
126
+ strokeColor: string;
127
+ fillColor: string;
128
+ pointColor: string;
129
+ thickness: number;
130
+ lineCap: CanvasLineCap;
131
+ isClose: boolean;
132
+ lineType: ELineTypes;
133
+ isFill: boolean;
134
+ }>): IPolygonPoint[];
135
+ static drawSelectedPolygonWithFillAndLine(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{
136
+ strokeColor: string;
137
+ fillColor: string;
138
+ pointColor: string;
139
+ thickness: number;
140
+ lineCap: CanvasLineCap;
141
+ isClose: boolean;
142
+ lineType: ELineTypes;
143
+ }>): IPolygonPoint[];
144
+ static drawText(canvas: HTMLCanvasElement, startPoint: IPoint | IPolygonPoint, text: string, options?: Partial<IDrawTextConfig>): void;
145
+ static wrapText(canvas: HTMLCanvasElement, text: string, x: number, y: number, maxWidth?: number, lineHeight?: number): void;
146
+ /**
147
+ * 绘制箭头
148
+ * @param ctx
149
+ * @param startPoint
150
+ * @param endPoint
151
+ * @param options
152
+ */
153
+ static drawArrow(ctx: CanvasRenderingContext2D, startPoint: IPoint | IPolygonPoint, endPoint: IPoint | IPolygonPoint, options?: Partial<{
154
+ color: string;
155
+ thickness: number;
156
+ lineCap: CanvasLineCap;
157
+ theta: number;
158
+ headLen: number;
159
+ }>): void;
160
+ static drawArrowByCanvas(canvas: HTMLCanvasElement, startPoint: IPoint | IPolygonPoint, endPoint: IPoint | IPolygonPoint, options?: Partial<{
161
+ color: string;
162
+ thickness: number;
163
+ lineCap: CanvasLineCap;
164
+ theta: number;
165
+ headLen: number;
166
+ }>): void;
167
+ /**
168
+ * Expansion of other base draw.
169
+ *
170
+ * Simple Version.
171
+ * @param param0
172
+ */
173
+ static drawCuboid(canvas: HTMLCanvasElement, cuboid: ICuboid | IDrawingCuboid, options?: Partial<{
174
+ strokeColor: string;
175
+ fillColor: string;
176
+ thickness: number;
177
+ }>): void;
178
+ /**
179
+ * Draw Cuboid and Text in header & bottom.
180
+ * @param canvas
181
+ * @param cuboid
182
+ * @param options
183
+ * @param dataConfig
184
+ */
185
+ static drawCuboidWithText(canvas: HTMLCanvasElement, cuboid: ICuboid | IDrawingCuboid, options: {
186
+ strokeColor: string;
187
+ fillColor?: string;
188
+ thickness?: number;
189
+ }, dataConfig: {
190
+ config: ICuboidConfig;
191
+ hiddenText?: boolean;
192
+ selectedID?: string;
193
+ headerText?: string;
194
+ bottomText?: string;
195
+ }): void;
196
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @file Enhance CommonToolUtils with getCurrentOperation, solving circular reference problems.
3
+ * @createDate 2022-08-12
4
+ * @author Ron <ron.f.luo@gmail.com>
5
+ */
6
+ import { ECheckModel, EToolName } from '@/constant/tool';
7
+ import ScribbleTool from '@/core/toolOperation/ScribbleTool';
8
+ import CuboidOperation from '@/core/toolOperation/cuboidOperation';
9
+ import PointCloud2dOperation from '@/core/toolOperation/pointCloud2dOperation';
10
+ import CheckOperation from '../../core/toolOperation/checkOperation';
11
+ import PolygonOperation from '../../core/toolOperation/polygonOperation';
12
+ import RectOperationAsNewName from '../../core/toolOperation/rectOperation';
13
+ import TagOperation from '../../core/toolOperation/tagOperation';
14
+ import LineToolOperation from '../../core/toolOperation/LineToolOperation';
15
+ import PointOperation from '../../core/toolOperation/pointOperation';
16
+ import TextToolOperation from '../../core/toolOperation/TextToolOperation';
17
+ import CommonToolUtils from './CommonToolUtils';
18
+ declare const getCurrentOperation: (toolName: EToolName | ECheckModel) => typeof RectOperationAsNewName | typeof TagOperation | typeof PointOperation | typeof LineToolOperation | typeof TextToolOperation | typeof PolygonOperation | typeof ScribbleTool | typeof PointCloud2dOperation | typeof CuboidOperation | typeof CheckOperation;
19
+ declare class EnhanceCommonToolUtils extends CommonToolUtils {
20
+ static getCurrentOperation: (toolName: EToolName | ECheckModel) => typeof RectOperationAsNewName | typeof TagOperation | typeof PointOperation | typeof LineToolOperation | typeof TextToolOperation | typeof PolygonOperation | typeof ScribbleTool | typeof PointCloud2dOperation | typeof CuboidOperation | typeof CheckOperation;
21
+ }
22
+ export { getCurrentOperation };
23
+ export default EnhanceCommonToolUtils;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * 图像初始化相关函数的
3
+ */
4
+ export default class ImgPosUtils {
5
+ /**
6
+ * 初始化图片在页面中的大小
7
+ * @param canvasSize
8
+ * @param imgSize
9
+ * @param rotate
10
+ * @param zoomRatio
11
+ * @param isOriginalSize
12
+ */
13
+ static getInitImgPos(canvasSize: ISize, imgSize: ISize, rotate?: number, zoomRatio?: number, isOriginalSize?: boolean): {
14
+ zoom: number;
15
+ currentPos: {
16
+ x: number;
17
+ y: number;
18
+ };
19
+ imgInfo: {
20
+ width: number;
21
+ height: number;
22
+ };
23
+ };
24
+ static getBasicRecPos(imgNode: any, basicRect: IRect, size: {
25
+ width: number;
26
+ height: number;
27
+ }, shrinkRatio?: number, zoomRatio?: number, isOriginalSize?: boolean): false | {
28
+ currentPos: {
29
+ x: number;
30
+ y: number;
31
+ };
32
+ innerZoom: number;
33
+ };
34
+ }
@@ -0,0 +1,105 @@
1
+ import { EToolName } from '@/constant/tool';
2
+ export declare enum EStatus {
3
+ /** 正在创建 */
4
+ Create = 0,
5
+ /** 正在激活 */
6
+ Active = 1,
7
+ /** 正在编辑, 撤销与激活状态合并 */
8
+ Edit = 1,
9
+ /** 没有操作 */
10
+ None = 2
11
+ }
12
+ export declare enum EColor {
13
+ ActiveArea = "#B3B8FF"
14
+ }
15
+ export interface IProps {
16
+ canvas: HTMLCanvasElement;
17
+ size: ISize;
18
+ historyChanged?: (undoEnabled: boolean, redoEnabled: boolean) => void;
19
+ }
20
+ /** 曲线分割点数 */
21
+ export declare const SEGMENT_NUMBER = 16;
22
+ export declare const LINE_ORDER_OFFSET: {
23
+ x: number;
24
+ y: number;
25
+ };
26
+ export interface IBasicLine {
27
+ pointA: IPoint;
28
+ pointB: IPoint;
29
+ }
30
+ /** 点半径 */
31
+ export declare const POINT_RADIUS = 3;
32
+ export declare const POINT_ACTIVE_RADIUS = 5;
33
+ /** 普通点内侧圆的半径 */
34
+ export declare const INNER_POINT_RADIUS = 2;
35
+ declare class LineToolUtils {
36
+ /** 为参考显示的线条设置样式 */
37
+ static setSpecialEdgeStyle: (ctx: CanvasRenderingContext2D) => void;
38
+ /** 设置特殊边样式 */
39
+ static setReferenceCtx: (ctx: CanvasRenderingContext2D) => void;
40
+ /**
41
+ * 计算一条线跟多条线的交点,并找到最近距离最近的点
42
+ * @param pointList 点列表
43
+ * @param matchLine 需要计算交点的线条
44
+ * @param matchPoint 计算交点线条的起始点
45
+ * @param pointRadius 点的半径
46
+ */
47
+ static calcOptimalIntersection: (pointList: IPoint[] | ILinePoint[], matchLine: IBasicLine, matchPoint: ICoordinate, pointRadius: number, zoom: number) => {
48
+ point: ICoordinate;
49
+ minDistance?: undefined;
50
+ } | {
51
+ point: IPoint;
52
+ minDistance: number;
53
+ } | undefined;
54
+ static lineIntersection: (lineA: IBasicLine, lineB: IBasicLine) => false | {
55
+ x: number;
56
+ y: number;
57
+ onLine1: boolean;
58
+ onLine2: boolean;
59
+ };
60
+ static getAxisDiff: (line: IBasicLine) => {
61
+ x: number;
62
+ y: number;
63
+ };
64
+ static calcDistance: (point1: IPoint, point2: IPoint) => number;
65
+ static drawCurveLine: (ctx: any, points: ILinePoint[], config: any, applyLineWidth: boolean | undefined, isReference: boolean | undefined, hoverEdgeIndex: number) => void;
66
+ static calcTwoPointDistance: (pointA: IPoint, pointB: IPoint) => number;
67
+ /**
68
+ * 计算在依赖物体目标内与当前线段的交点。
69
+ * 支持的依赖工具: 多边形,矩形。
70
+ * @param axis 当前鼠标的点
71
+ * @param preAxis 上一个标注点
72
+ * @param {EDependPattern} dependPattern 依赖模式
73
+ * @param dependData 依赖工具的数据
74
+ * @param dependConfig 依赖工具的配置
75
+ * @param imageSize 图片尺寸
76
+ * @param pointRadius 点的半径
77
+ * @param zoom 缩放比例
78
+ * @param getRenderAxis 转化为渲染坐标
79
+ * @param getAbsAxis 转化为绝对坐标
80
+ */
81
+ static pointOverTarget: (axis: ICoordinate, preAxis: ICoordinate, dependToolName: EToolName | undefined, dependData: any, dependConfig: any, imageSize: ISize, pointRadius: number, zoom: number, getRenderAxis: (coord: ICoordinate) => ICoordinate | ILinePoint, getAbsAxis: (coord: ICoordinate) => ICoordinate | ILinePoint) => ICoordinate;
82
+ /**
83
+ * 获取多边形的线段
84
+ * @param dependData 多边形数据
85
+ * @param dependConfig 多边形配置
86
+ */
87
+ static getPolygonPointList: (dependData: any, dependConfig: any) => any;
88
+ static isInLine(checkPoint: ICoordinate, point1: IPoint, point2: IPoint, scope?: number): boolean;
89
+ static isOnLine: (x: number, y: number, endX: number, endY: number, px: number, py: number) => boolean;
90
+ static inArea: ({ top, left, right, bottom }: IRectArea, { x, y }: IPoint) => boolean;
91
+ /**
92
+ * 获取水平、垂直线的坐标点
93
+ * @param isStraight
94
+ * @param lastPoint
95
+ * @param nextPoint
96
+ * @param absNextPoint
97
+ * @param renderLastPoint
98
+ */
99
+ static getVHPoint: (lastPoint: ICoordinate, nextPoint: ICoordinate, absNextPoint: ICoordinate, renderLastPoint: ICoordinate) => {
100
+ y: number;
101
+ x: number;
102
+ };
103
+ static getAngle: (startPoint: ICoordinate, endPoint: ICoordinate) => number;
104
+ }
105
+ export default LineToolUtils;
@@ -0,0 +1,27 @@
1
+ declare interface IAuxiliaryLine {
2
+ start: IPointUnit['label'];
3
+ end: IPointUnit['label'];
4
+ }
5
+ declare interface IAuxiliaryLineCoord {
6
+ start: ICoordinate;
7
+ end: ICoordinate;
8
+ }
9
+ export default class MarkerUtils {
10
+ /**
11
+ * 获取列表标注的显示的数据
12
+ * @param marker
13
+ * @param markerList
14
+ * @returns
15
+ */
16
+ static getMarkerShowText(marker: string | undefined, markerList?: IInputList[]): string | undefined;
17
+ /**
18
+ * v3.2.0 仅标点工具 列表标注 根据配置生成辅助线数组,start和end为IMarkerList[attr]
19
+ * eg:[{key:"类别1",value:"类别1",target:["class-lm"]},{key:"类别lm",value:"class-lm",target:["类别1"]}] => [{start:"类别1",end:"类别lm"}]
20
+ */
21
+ static getAuxiliaryLineByMarkerList: (markerList: IMarkerList[], attr: 'key' | 'value') => IAuxiliaryLine[];
22
+ /**
23
+ * 根据辅助线和点数据生成辅助线首尾坐标
24
+ */
25
+ static getAuxiliaryLineCoord: (auxiliaryLines: IAuxiliaryLine[], pointList: IPointUnit[]) => IAuxiliaryLineCoord[];
26
+ }
27
+ export {};
@@ -0,0 +1,120 @@
1
+ import { ERotateDirection } from '@/constant/annotation';
2
+ import { IPolygonData, IPolygonPoint } from '../../types/tool/polygon';
3
+ import { ELineTypes } from '../../constant/tool';
4
+ export default class PolygonUtils {
5
+ static getHoverPolygonID(checkPoint: IPolygonPoint, polygonPoints: {
6
+ pointList: IPolygonPoint[];
7
+ id: string;
8
+ }[], scope?: number, lineType?: ELineTypes): string;
9
+ /**
10
+ * 计算多边形面积(Shoelace Theorem,鞋带定理)
11
+ * @param pointList
12
+ * @returns
13
+ */
14
+ static calcPolygonSize(pointList?: IPolygonPoint[]): number;
15
+ static isInPolygon(checkPoint: IPolygonPoint, polygonPoints: (IPolygonPoint | ICoordinate)[], lineType?: ELineTypes): boolean;
16
+ /**
17
+ * 通过数据转换为平滑曲线的点提交 [{x: number, y: number}...] => [x, ...smoothCurvePoints ,y]
18
+ * @param pointList
19
+ * @returns {Array<number>}
20
+ */
21
+ static createSmoothCurvePointsFromPointList(pointList: Array<{
22
+ x: number;
23
+ y: number;
24
+ [a: string]: any;
25
+ }>, numberOfSegments?: number): any[];
26
+ static createSmoothCurvePoints(points: any[], tension?: number, closed?: boolean, numberOfSegments?: number): any[];
27
+ /**
28
+ * 获取当前 id 的多边形
29
+ * @param polygonList
30
+ * @param id
31
+ * @returns
32
+ */
33
+ static getPolygonByID(polygonList: IPolygonData[], id?: string): IPolygonData | undefined;
34
+ static getPolygonByIDs(polygonList: IPolygonData[], ids?: string[]): IPolygonData[] | undefined;
35
+ static getHoverEdgeIndex(checkPoint: ICoordinate, pointList: IPolygonPoint[], lineType?: ELineTypes, scope?: number): number;
36
+ /**
37
+ * 用于边缘吸附,获取最接近的边
38
+ * @param coord
39
+ * @param polygonList
40
+ * @param lineType
41
+ * @param range
42
+ * @returns
43
+ */
44
+ static getClosestPoint(coordinate: ICoordinate, polygonList: IPolygonData[], lineType?: ELineTypes, range?: number, option?: {
45
+ isClose?: boolean;
46
+ }): {
47
+ dropFoot: ICoordinate;
48
+ closestEdgeIndex: number;
49
+ closestPolygonID: string;
50
+ hasClosed: boolean;
51
+ };
52
+ /**
53
+ * 点集是否在多边形内
54
+ * @param pointList
55
+ * @param polygonPoints
56
+ * @param lineType
57
+ */
58
+ static isPointListInPolygon(pointList: IPolygonPoint[], polygonPoints: IPolygonPoint[], lineType?: ELineTypes): boolean;
59
+ /**
60
+ * 点集是否在多边形外
61
+ */
62
+ static isPointListOutSidePolygon(pointList: IPolygonPoint[], polygonPoints: IPolygonPoint[], lineType?: ELineTypes): boolean;
63
+ /**
64
+ * 获取多边形面积
65
+ * @param pointList
66
+ * @returns
67
+ */
68
+ static getPolygonArea(pointList: IPolygonPoint[]): number;
69
+ static updatePolygonByRotate(direction: ERotateDirection, angle: number | undefined, pointList: IPolygonPoint[]): {
70
+ x: number;
71
+ y: number;
72
+ }[];
73
+ static deletePolygonLastPoint(acc: any, cur: any[], index: number, array: string | any[]): any;
74
+ static concatBeginAndEnd(array: any[]): any[];
75
+ static segmentPolygonByPolygon(pointList: IPolygonPoint[], polygonList: IPolygonData[]): IPolygonPoint[][] | void;
76
+ /**
77
+ * 获取当前多边形的点集
78
+ *
79
+ * @export
80
+ * @param {string} selectedPolygonID
81
+ * @param {IPolygonData[]} polygonList
82
+ * @returns
83
+ */
84
+ static getPolygonPointList(selectedPolygonID: string, polygonList: IPolygonData[]): IPolygonPoint[];
85
+ /**
86
+ * 获取包裹当前 polygon 的 index
87
+ * @param pointList
88
+ * @param polygonList
89
+ * @returns
90
+ */
91
+ static getWrapPolygonIndex(pointList: IPolygonPoint[], polygonList: IPolygonData[]): number;
92
+ /**
93
+ * 获取内部切割后的多边形合体点集
94
+ * @param pointList
95
+ * @param wrapPointList
96
+ * @returns
97
+ */
98
+ static clipPolygonFromWrapPolygon(pointList: IPolygonPoint[], wrapPointList: IPolygonPoint[]): IPolygonPoint[];
99
+ /**
100
+ * 难点:判断凹多边形的方向
101
+ *
102
+ * https://www.huaweicloud.com/articles/12463693.html
103
+ * @param p
104
+ * @returns
105
+ */
106
+ static isPolygonClosewise(p: IPolygonPoint[]): 0 | 1 | -1;
107
+ /**
108
+ * 获取当前点与多边形点集最近的点,并返回 Index
109
+ */
110
+ static getClosePointDistanceFromPolygon(point: ICoordinate, pointList: IPolygonPoint[]): number;
111
+ /**
112
+ * 多边形合成多边形
113
+ * @param selectedPolygon
114
+ * @param combinedPolygon
115
+ */
116
+ static combinePolygonWithPolygon(selectedPolygon: IPolygonData, combinedPolygon: IPolygonData): {
117
+ newPolygon: IPolygonData;
118
+ unionList: string[];
119
+ } | undefined;
120
+ }
@@ -0,0 +1,69 @@
1
+ import { IPolygonPoint } from '../../types/tool/polygon';
2
+ export default class RectUtils {
3
+ static composeResult(result: string, currentStep: number, resultList: any[], stepList: any[], basicImgInfo: any): string;
4
+ static changeCoordinateByRotate(rect: IRect, rotate: number, imgSize: ISize): IRect;
5
+ /**
6
+ * 矩形框顺时针生成点集
7
+ * @param rect
8
+ * @returns
9
+ */
10
+ static translateRect2Points(rect: IRect): IPoint[];
11
+ static translatePoints2Rect(points: IPoint[], basicRect: IRect): IRect | undefined;
12
+ /**
13
+ * 获取当前矩形框点集
14
+ * @param rect
15
+ */
16
+ static getRectPointList(rect: IRect, zoom?: number): {
17
+ x: number;
18
+ y: number;
19
+ }[];
20
+ /**
21
+ * 获取当前矩形框的边集合
22
+ * @param rect
23
+ * @param zoom 缩放比例
24
+ */
25
+ static getRectEdgeList(rect: IRect, zoom?: number): {
26
+ begin: {
27
+ x: number;
28
+ y: number;
29
+ };
30
+ end: {
31
+ x: number;
32
+ y: number;
33
+ };
34
+ }[];
35
+ /**
36
+ * 当前点是否在在矩形内
37
+ * @param coordinate
38
+ * @param rect
39
+ * @param scope
40
+ * @param zoom
41
+ */
42
+ static isInRect(coordinate: ICoordinate, rect: IRect, scope?: number, zoom?: number): boolean;
43
+ /**
44
+ * rect 与 zoom 的乘积
45
+ * @param rect
46
+ * @param zoom
47
+ */
48
+ static getRectUnderZoom(rect: IRect, zoom?: number): {
49
+ x: number;
50
+ y: number;
51
+ width: number;
52
+ height: number;
53
+ id: string;
54
+ sourceID: string;
55
+ valid: boolean;
56
+ order?: number | undefined;
57
+ attribute: string;
58
+ textAttribute: string;
59
+ disableDelete?: boolean | undefined;
60
+ label?: string | undefined;
61
+ };
62
+ /**
63
+ * 判断当前矩形是否不在多边形内
64
+ * @param rect
65
+ * @param polygonPointList
66
+ *
67
+ */
68
+ static isRectNotInPolygon(rect: IRect, polygonPointList: IPolygonPoint[]): boolean;
69
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 渲染 DOM 类
3
+ */
4
+ import { IBasicText } from '@labelbee/lb-utils';
5
+ interface IProps {
6
+ container: HTMLElement;
7
+ height: number;
8
+ }
9
+ export default class RenderDomClass {
10
+ private _domMap;
11
+ private _container;
12
+ private _height;
13
+ constructor(props: IProps);
14
+ wheelChange(e: any): void;
15
+ /**
16
+ * 清除当前渲染的标签
17
+ */
18
+ clearTag(id: string): void;
19
+ /**
20
+ * 对比当前内容和后续内容的区别
21
+ */
22
+ render(annotations: IBasicText[]): void;
23
+ }
24
+ export {};
@@ -0,0 +1,3 @@
1
+ export default class RenderDomUtils {
2
+ static renderInvalidPage(container: HTMLElement, size: ISize, lang: string): HTMLDivElement;
3
+ }
@@ -0,0 +1,15 @@
1
+ export default class StyleUtils {
2
+ static getStrokeAndFill(toolStyle: IToolColorStyle, valid?: boolean, options?: Partial<{
3
+ isSelected: boolean;
4
+ isHover: boolean;
5
+ }>): {
6
+ stroke: string;
7
+ fill: string;
8
+ };
9
+ /**
10
+ * Transformer Style to String
11
+ * @param style
12
+ * @returns
13
+ */
14
+ static getStyle2String(style?: StyleSheetList): string | undefined;
15
+ }
@@ -0,0 +1,54 @@
1
+ export default class TagUtil {
2
+ /**
3
+ * 获取 tag key 的中文名
4
+ *
5
+ * @export
6
+ * @param {string} key
7
+ * @param {IInputList[]} labelInfoSet
8
+ * @returns
9
+ */
10
+ static getTagKeyName(key: string, labelInfoSet: IInputList[]): string | undefined;
11
+ static getTagName([key, value]: [(string | undefined)?, (string | undefined)?], labelInfoSet: IInputList[]): string | undefined;
12
+ /**
13
+ * 获取标签结果中的标签名
14
+ *
15
+ * @export
16
+ * @param {Object} result
17
+ * @param {IInputList[]} labelInfoSet
18
+ * @returns
19
+ */
20
+ static getTagNameList(result: Object, labelInfoSet: IInputList[]): any[];
21
+ /**
22
+ * 没有配置 获取标签结果中的标签名
23
+ * @param result
24
+ * @returns
25
+ */
26
+ static getTagnameListWithoutConfig(result: Object): any[];
27
+ /**
28
+ * 判断当前的 key value 是否在 inputList 里面
29
+ * @param key
30
+ * @param value
31
+ * @param inputList
32
+ * @returns
33
+ */
34
+ static judgeResultIsInInputList(key: string, value: string, inputList: IInputList[]): boolean;
35
+ /**
36
+ * 遍历顶层数据
37
+ * @param inputList
38
+ * @returns
39
+ */
40
+ static getDefaultResultByConfig(inputList: IInputList[]): {
41
+ [a: string]: string;
42
+ };
43
+ /**
44
+ * 获取当前的默认的结果
45
+ * @param inputList
46
+ * @param basicResultList
47
+ * @returns
48
+ */
49
+ static getDefaultTagResult(inputList: IInputList[], basicResultList: any[]): {
50
+ id: string;
51
+ sourceID: any;
52
+ result: any;
53
+ }[];
54
+ }
@@ -0,0 +1,4 @@
1
+ export default class UnitUtils {
2
+ static deg2rad(angleDeg: number): number;
3
+ static rad2deg(angleRad: number): number;
4
+ }