@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,443 @@
1
+ /**
2
+ * @author Glenfiddish <edwinlee0927@hotmail.com>
3
+ * @file Implement LineTool's interaction
4
+ * @date 2022-06-02
5
+ */
6
+ import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
7
+ import TextAttributeClass from './textAttributeClass';
8
+ declare enum EStatus {
9
+ Create = 0,
10
+ /** 正在激活 */
11
+ Active = 1,
12
+ /** 没有操作,初始化状态 */
13
+ None = 2
14
+ }
15
+ /** 曲线分割点数 */
16
+ export declare const SEGMENT_NUMBER = 16;
17
+ export declare const LINE_ORDER_OFFSET: {
18
+ x: number;
19
+ y: number;
20
+ };
21
+ /** 圆的半径 */
22
+ export declare const POINT_RADIUS = 3;
23
+ /** 圆的激活半径 */
24
+ export declare const POINT_ACTIVE_RADIUS = 5;
25
+ /** 内侧圆的半径 */
26
+ export declare const INNER_POINT_RADIUS = 2;
27
+ interface ILineOperationProps extends IBasicToolOperationProps {
28
+ }
29
+ declare class LineToolOperation extends BasicToolOperation {
30
+ /**
31
+ * 渲染激活的线段
32
+ * @param coord 当前的坐标
33
+ * @param e 鼠标事件
34
+ */
35
+ drawActivatedLine: (coord?: ICoordinate, e?: MouseEvent, hideTempAxis?: boolean) => void;
36
+ _textAttributInstance?: TextAttributeClass;
37
+ /** 线条是否被选中 */
38
+ get isLineSelected(): "" | ILinePoint[] | undefined;
39
+ /** 选中点线条的点 */
40
+ get selectedLinePoints(): any[];
41
+ /**
42
+ * 绘制hover的点
43
+ * @param coord
44
+ */
45
+ drawHoverPoint: (coord: ICoordinate) => void;
46
+ selectedID?: string;
47
+ updatedLine: ILine;
48
+ toolName: string;
49
+ private lineList;
50
+ private activeLine?;
51
+ private status;
52
+ private isMousedown;
53
+ private prevAxis;
54
+ private activeArea?;
55
+ /** 临时点的渲染坐标 */
56
+ private cursor?;
57
+ private selectedPoint?;
58
+ private actionsHistory?;
59
+ private coordsInsideActiveArea;
60
+ private hoverLineSegmentIndex;
61
+ private isShift;
62
+ private hoverPointID?;
63
+ private dependToolConfig?;
64
+ private isReference;
65
+ private _textAttributeInstance?;
66
+ private textEditingID?;
67
+ private isLineValid;
68
+ private lineDragging;
69
+ private selectedIDs;
70
+ constructor(props: ILineOperationProps);
71
+ /** 创建状态 */
72
+ get isCreate(): boolean;
73
+ /** 激活状态 */
74
+ get isActive(): boolean;
75
+ /** 无状态 */
76
+ get isNone(): boolean;
77
+ /** 线条类型是否为曲线 */
78
+ get isCurve(): boolean;
79
+ /** 线条是否为多色 */
80
+ get isMultipleColor(): boolean;
81
+ get imageSize(): any;
82
+ get lineListLen(): number;
83
+ /** 是否允许边缘吸附 */
84
+ get edgeAdsorptionEnabled(): any;
85
+ get attributeConfigurable(): any;
86
+ get isTextConfigurable(): any;
87
+ get isDependPolygon(): boolean;
88
+ get isDependRect(): boolean;
89
+ get isCurrentAttributeLocked(): boolean;
90
+ get attributeFilteredLines(): ILine[];
91
+ get enableOutOfTarget(): any;
92
+ /**
93
+ * Judgement of showing Order.
94
+ *
95
+ * Origin Config of LineTool: showOrder.
96
+ * Configurable of other tools: isShowOrder.
97
+ */
98
+ get showOrder(): any;
99
+ get edgeAdsorption(): any;
100
+ get attributeList(): any;
101
+ get lowerLimitPointNum(): any;
102
+ get upperLimitPointNum(): any;
103
+ get textCheckType(): any;
104
+ get customFormat(): any;
105
+ get dataList(): ILine[];
106
+ get hasActiveLine(): boolean | undefined;
107
+ /**
108
+ * 视野内的线条
109
+ */
110
+ get viewPortLines(): ILine[];
111
+ get lineStyle(): {
112
+ lineWidth: any;
113
+ color: any;
114
+ opacity: any;
115
+ };
116
+ get selectedText(): string;
117
+ /**
118
+ * 获取当前页面标注结果
119
+ */
120
+ get currentPageResult(): ILine[];
121
+ updateStatus(status: EStatus, resetText?: boolean): void;
122
+ isInBasicPolygon(coord: ICoordinate): boolean;
123
+ getPolygonPointList(): any;
124
+ /**
125
+ * 渲染坐标计算获取下一个点
126
+ * @param coord
127
+ * @returns 绝对坐标
128
+ */
129
+ getNextCoordByRenderCoord(renderCoord: ICoordinate): ICoordinate | undefined;
130
+ /**
131
+ * 绝对坐标计算获取下一个点
132
+ * @param coord
133
+ * @returns 渲染坐标
134
+ */
135
+ getNextCoordByAbsCoord(absCoord: ICoordinate): ICoordinate | undefined;
136
+ /**
137
+ * 检查点是否在线上
138
+ * @param pointList 所有点
139
+ * @param checkPoint
140
+ * @param scope
141
+ */
142
+ pointInLine(pointList: ILinePoint[], checkPoint: ICoordinate, scope: number): boolean;
143
+ /**
144
+ * 根据坐标绘制圆点
145
+ * @param coord
146
+ * @param size
147
+ * @param color
148
+ */
149
+ arc(coord: ICoordinate, size?: number, color?: string): void;
150
+ /**
151
+ * 对存在绘制对象,绘制热区
152
+ */
153
+ renderActiveArea(): void;
154
+ /**
155
+ * Update selectedIDs and rerender
156
+ * @param selectedIDs
157
+ */
158
+ setSelectedIDs(selectedIDs: string[]): void;
159
+ setSelectedID(newID?: string): void;
160
+ /**
161
+ * 添加点
162
+ * @param coord 坐标
163
+ */
164
+ addLinePoint(coord: ICoordinate): void;
165
+ setCreatStatusAndAddPoint(coord: ICoordinate, isRestText?: boolean): void;
166
+ /**
167
+ * 当前激活的线条是否为有效线, 优先获取存在的数据
168
+ */
169
+ isActiveLineValid(): boolean | undefined;
170
+ nextOrder(): number;
171
+ drawCurveLine: (ctx: any, points: ILinePoint[], config: any, applyLineWidth: boolean | undefined, isReference: boolean | undefined, hoverLineSegmentIndex: number) => void;
172
+ /**
173
+ * 绘制线段
174
+ * @param points 点列表
175
+ * @param cursor 临时的左边,用于实时绘制
176
+ * @param color 线条颜色
177
+ * @param showPoint 是否显示点
178
+ */
179
+ drawLine: (points: Array<ILinePoint | ICoordinate>, cursor: ICoordinate | undefined, color: string, showPoint?: boolean, isActive?: boolean) => void;
180
+ drawStraightLine: (points: any[], config: any, isActive?: boolean) => void;
181
+ getLineColorByAttribute(line: {
182
+ attribute: string;
183
+ valid: boolean;
184
+ } | ILine, isSelected?: boolean): string;
185
+ drawLines: () => void;
186
+ /**
187
+ * 渲染已经绘制的线段
188
+ */
189
+ render: (nextPoint?: IPoint) => void;
190
+ /** 重新计算并渲染热区 */
191
+ updateActiveArea(): void;
192
+ getActiveArea(): {
193
+ top: number;
194
+ bottom: number;
195
+ left: number;
196
+ right: number;
197
+ } | undefined;
198
+ /**
199
+ * 绘制线条序号(包含属性或者标签)
200
+ * @param coord
201
+ * @param order
202
+ * @param color
203
+ * @param label
204
+ * @param attribute
205
+ * @param valid
206
+ */
207
+ drawLineNumber(coord: ICoordinate, order: number | undefined, color: string, label?: string, attribute?: string, valid?: boolean): void;
208
+ /**
209
+ * 绘制线条的文本属性
210
+ * @param coord
211
+ * @param text
212
+ * @param color
213
+ */
214
+ drawLineTextAttribute(coord: ICoordinate, color: string, text?: string): void;
215
+ /**
216
+ * Draw the text of lineLength
217
+ *
218
+ * It will be controlled by showLineLength.
219
+ */
220
+ drawLineLength(pointList: ILinePoint[], color: string): void;
221
+ drawText(coord: ICoordinate, text: string, color: string, lineWidth?: number): void;
222
+ /**
223
+ * 更新热区
224
+ * @param offsetX
225
+ * @param offsetY
226
+ */
227
+ moveActiveArea(offsetX: number, offsetY: number): void;
228
+ /**
229
+ * 找到当前hover的点
230
+ * @param coord
231
+ */
232
+ findHoveredPoint(coord: ICoordinate): ILinePoint | undefined;
233
+ /** 找到当前hover的线段 */
234
+ findHoverLine(coord: ICoordinate): ILine | undefined;
235
+ /**
236
+ * 找到当前点的边缘吸附范围
237
+ * @param coord
238
+ */
239
+ getAdsorptionPoint(coord: ICoordinate): ICoordinate | undefined;
240
+ /**
241
+ * 找到由pointList连成线的最近的点, 优先匹配顶点
242
+ * @param axisAreas
243
+ * @param coord 渲染坐标
244
+ * @param pointList
245
+ * @returns 落点的渲染坐标
246
+ */
247
+ findNearestPoint(pointList: ICoordinate[], coord: ICoordinate, minLength?: number): {
248
+ point: ICoordinate;
249
+ minDistance: number;
250
+ } | undefined;
251
+ getPointList(pointList: ILinePoint[]): any[];
252
+ /**
253
+ * 计算依赖拉框、多边形的情况下移动后点是否都在范围内
254
+ * @param offsetX
255
+ * @param offsetY
256
+ */
257
+ moveLineInPolygon: (offsetX: number, offsetY: number) => false | undefined;
258
+ /**
259
+ * 在矩形内移动线条
260
+ * @param offsetX x轴的偏移量
261
+ * @param offsetY y轴的偏移量
262
+ * @param rectHorizontalRange 矩形的水平范围
263
+ * @param rectVerticalRange 矩形的垂直范围
264
+ */
265
+ moveLineInRectRange: (offsetX: number, offsetY: number, rectHorizontalRange: number[], rectVerticalRange: number[]) => void;
266
+ /**
267
+ * 移动选中的线段
268
+ * @param coord
269
+ */
270
+ moveSelectedLine(coord: ICoordinate): void;
271
+ /**
272
+ * 移动选中的点
273
+ * @param coord
274
+ */
275
+ moveSelectPoint(coord: ICoordinate): void;
276
+ /**
277
+ * 根据当前键盘事件和配置获取下一个点的坐标
278
+ * @param e
279
+ * @param coord
280
+ */
281
+ getCoordByConfig(e: MouseEvent | KeyboardEvent | {
282
+ altKey: boolean;
283
+ shiftKey?: boolean;
284
+ }, coord: ICoordinate): ICoordinate | undefined;
285
+ /**
286
+ * 计算出下一个将要绘制的点
287
+ * @param e
288
+ * @param nextPoint
289
+ */
290
+ getNextPoint(e: MouseEvent | KeyboardEvent | {
291
+ altKey: boolean;
292
+ shiftKey?: boolean;
293
+ }, nextPoint: ICoordinate): ICoordinate | undefined;
294
+ lineHover(): void;
295
+ /** 鼠标移动事件 */
296
+ mouseMoveHandler(e: MouseEvent): void;
297
+ onMouseMove(e: MouseEvent): void;
298
+ /**
299
+ * 设置激活区域
300
+ * @param coord
301
+ * @param outsideCancel
302
+ * @todo 拖拽区域取消选中
303
+ */
304
+ setActiveArea(coord: ICoordinate, outsideCancel?: boolean): void;
305
+ /**
306
+ * 根据id选中线条
307
+ * @param id
308
+ */
309
+ setActiveLineByID(id: string): void;
310
+ setActiveLine(pointList?: ILinePoint[]): void;
311
+ onRightClick: (e: MouseEvent) => void;
312
+ historyChanged(funcName: 'undo' | 'redo'): void;
313
+ updateSelectedAttributeAfterHistoryChanged: () => void;
314
+ undo(): void;
315
+ redo(): void;
316
+ /** 坐标是否在图片内 */
317
+ isCoordInsideTarget(coord: ICoordinate): boolean;
318
+ /**
319
+ * 获取当前点插入的索引
320
+ * @returns index
321
+ */
322
+ getPointInsertIndex(coord?: ICoordinate, scope?: number): number;
323
+ getLineWidthScope(): any;
324
+ isMouseCoordOutsideActiveArea(): boolean;
325
+ /** 是否超过上限点 */
326
+ isLinePointsExceed(): any;
327
+ isLinePointsNotEnough(): boolean | undefined;
328
+ updateLineSegmentSpecial(coord: ICoordinate): void;
329
+ onLeftClick: (e: MouseEvent) => void;
330
+ addLinePointToActiveLine(): void;
331
+ onMouseDown(e: MouseEvent): void;
332
+ lineHasChanged(): boolean;
333
+ updateLines(): void;
334
+ onMouseUp(e: MouseEvent): void;
335
+ onDblclick: () => void;
336
+ isTextValid(text: string): boolean | undefined;
337
+ createLineData(): ILine;
338
+ /**
339
+ * 停止当前的线条绘制
340
+ * @param isAppend
341
+ */
342
+ stopLineCreating(isAppend?: boolean): void;
343
+ setActiveStatus(id?: string): void;
344
+ /**
345
+ * 设置为无状态
346
+ * @param updateStatus
347
+ */
348
+ setNoneStatus(updateStatus?: boolean): void;
349
+ setKeyDownStatus(e: KeyboardEvent, value?: boolean): void;
350
+ /** 续标当前激活的线条 */
351
+ continueToEdit(): void;
352
+ onKeyUp: (e: KeyboardEvent) => void;
353
+ /** 创建无效线条,activeLineID存在时为续标(没有按ctrl时不会修改其有无效性),不会设置无效的属性 */
354
+ setInvalidLineOnCreating(e: KeyboardEvent): void;
355
+ onKeyDown(e: KeyboardEvent): void;
356
+ /**
357
+ * 切换到下一个线条
358
+ * @param e
359
+ */
360
+ private selectToNextLine;
361
+ /**
362
+ * 在线条创建时候的键盘事件, 并触发渲染
363
+ * 1.设为无效。
364
+ * 2.Alt取消边缘吸附。
365
+ * 3.Shift绘制垂直/水平线
366
+ * @param e
367
+ */
368
+ keyboardEventWhileLineCreating(e: KeyboardEvent): void;
369
+ /**
370
+ * 计算出下一个点并渲染
371
+ * @param e
372
+ * @param coord
373
+ */
374
+ renderNextPoint(e: MouseEvent | KeyboardEvent | {
375
+ altKey: boolean;
376
+ }, coord: ICoordinate): void;
377
+ deleteSelectedLine(coord: ICoordinate): void;
378
+ /**
379
+ * 删除当前选中的点
380
+ * @param hoverPointID
381
+ */
382
+ deleteSelectedLinePoint(selectedID: string): void;
383
+ /**
384
+ * 右键双击事件,
385
+ * 1. 删除线
386
+ * 2. 删除点
387
+ * @param e
388
+ */
389
+ onRightDblClick: (e: MouseEvent) => void;
390
+ /** 删除激活的线段 */
391
+ deleteLine(): void;
392
+ setInvalidLine(id?: string, valid?: boolean, isRender?: boolean): void;
393
+ /** 数据清空 */
394
+ empty(): void;
395
+ /** 设置线条属性 */
396
+ setAttribute(attribute: string): void;
397
+ /** 设置线条文本标注属性 */
398
+ setTextAttribute(text: string): void;
399
+ /** 更新线条的属性 */
400
+ setLineAttribute(key: 'attribute' | 'textAttribute', value: string, id?: string): void;
401
+ /** 更新外部属性列表的选中值 */
402
+ updateAttribute(attribute: string): void;
403
+ /** 更新线条的属性 */
404
+ updateLineAttributes(line: ILine): void;
405
+ lineStatusChanged(): void;
406
+ updateTextAttribute(text: string): void;
407
+ /** 保存当前绘制的数据, 避免创建中的数据不会被保存到 */
408
+ saveData(): void;
409
+ setTextEditingID(id: string): void;
410
+ setSelectedLineID(id?: string): void;
411
+ attributeLockListChange(attributeLockList: string[]): void;
412
+ setReference: (isReference: boolean) => void;
413
+ /**
414
+ * 计算带点数是否超出限制
415
+ * @param count
416
+ */
417
+ pointsWithinRange: (count: number) => boolean;
418
+ setResult(lineList: ILine[]): void;
419
+ setLineList: (lineList: ILine[]) => void;
420
+ setConfig(config: string): void;
421
+ toggleIsHide(): void;
422
+ clearCanvas(): void;
423
+ /**
424
+ * 清除当前的所有数据
425
+ */
426
+ clearResult(): void;
427
+ exportData(): any[];
428
+ setDefaultAttribute(attribute?: string): void;
429
+ /**
430
+ * 用于 TextAttributeClass 的数据获取
431
+ * @returns
432
+ */
433
+ getCurrentSelectedData(): {
434
+ color: any;
435
+ textAttribute: string;
436
+ };
437
+ renderTextAttribute(): void;
438
+ getTextIconSvg(attribute?: string): any;
439
+ /** 更新文本输入,并且进行关闭 */
440
+ updateSelectedTextAttribute(newTextAttribute?: string): void;
441
+ textChange: (v: string) => void;
442
+ }
443
+ export default LineToolOperation;
@@ -0,0 +1,65 @@
1
+ import { EScribblePattern, EToolName } from '@/constant/tool';
2
+ import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
3
+ interface IProps extends IBasicToolOperationProps {
4
+ }
5
+ declare class ScribbleTool extends BasicToolOperation {
6
+ toolName: EToolName;
7
+ defaultAttributeInfo?: IInputList;
8
+ config: IScribbleConfig;
9
+ private action;
10
+ private cacheCanvas?;
11
+ private cacheContext?;
12
+ private penSize;
13
+ private startPoint?;
14
+ constructor(props: IProps);
15
+ get cursorErase(): string;
16
+ get defaultCursor(): string;
17
+ get color(): string;
18
+ get penSizeWithZoom(): number;
19
+ get cacheCanvasToDataUrl(): string | undefined;
20
+ getOriginCoordinate: (e: MouseEvent) => {
21
+ x: number;
22
+ y: number;
23
+ specialPoint?: boolean | undefined;
24
+ specialEdge?: boolean | undefined;
25
+ } | {
26
+ x: number;
27
+ y: number;
28
+ };
29
+ setPenSize(size: number): void;
30
+ initCacheCanvas(imgNode?: HTMLImageElement): void;
31
+ updateCacheCanvasSize(imgNode: HTMLImageElement): void;
32
+ updateUrl2CacheContext(url: string): void;
33
+ setImgNode(imgNode: HTMLImageElement, basicImgInfo?: Partial<{
34
+ valid: boolean;
35
+ rotate: number;
36
+ }>): void;
37
+ setResult(data: IScribbleData[]): void;
38
+ onKeyDown(e: KeyboardEvent): boolean | void;
39
+ eventBinding(): void;
40
+ onMouseDown: (e: MouseEvent) => undefined;
41
+ onMouseMove: (e: MouseEvent) => undefined;
42
+ onMouseUp: (e: MouseEvent) => undefined;
43
+ mouseEvents: (eventType: 'onMouseMove' | 'onMouseUp' | 'onMouseDown') => (() => void) | ((e: MouseEvent) => void) | ((e: MouseEvent) => void) | ((e: MouseEvent) => void) | (() => void) | ((e: MouseEvent) => void);
44
+ setPattern: (pattern: EScribblePattern) => void;
45
+ setDefaultAttribute(attributeValue: string): void;
46
+ clearStatusAfterLeave(): void;
47
+ onMouseLeave(): void;
48
+ onScribbleStart(e: MouseEvent): void;
49
+ onScribbleMove(e: MouseEvent): void;
50
+ onScribbleEnd(): void;
51
+ eraseArc(e: MouseEvent): void;
52
+ onEraseStart(e: MouseEvent): void;
53
+ onEraseMove(e: MouseEvent): void;
54
+ onEraseEnd(): void;
55
+ exportData(): any[];
56
+ clearCacheCanvas(): void;
57
+ clearResult(): void;
58
+ renderPoint(radius: number): void;
59
+ renderBorderPoint(radius: number): void;
60
+ render(): void;
61
+ /** 撤销 */
62
+ undo(): void;
63
+ redo(): void;
64
+ }
65
+ export default ScribbleTool;
@@ -0,0 +1,41 @@
1
+ import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
2
+ interface ITextResult {
3
+ id: string;
4
+ sourceID: string;
5
+ value: {
6
+ [key: string]: string;
7
+ };
8
+ }
9
+ interface ITextToolProps extends IBasicToolOperationProps {
10
+ }
11
+ declare class TextToolOperation extends BasicToolOperation {
12
+ textList: ITextResult[];
13
+ constructor(props: ITextToolProps);
14
+ get dataList(): ITextResult[];
15
+ get textValueContainerID(): string;
16
+ get textValueContainer(): HTMLElement | null;
17
+ get currentPageResult(): ITextResult[];
18
+ setResult(textResultList: ITextResult[]): void;
19
+ /** 获取单个初始值 */
20
+ getSingleResult: (sourceID?: string) => ITextResult;
21
+ /**
22
+ * 获取初始值结果列表
23
+ */
24
+ getInitResultList: (dataSourceStep: number, basicResultList: any[]) => ITextResult[];
25
+ updateTextValue(k: string, v: string): void;
26
+ /**
27
+ *
28
+ * @param key
29
+ * @param value
30
+ */
31
+ renderText(key: string, value: string): void;
32
+ getTextDomID(key: string): string;
33
+ /** 初始化文本渲染元素 */
34
+ initTextDisplayContainer(): void;
35
+ exportData(): any[];
36
+ destroyCanvas(): void;
37
+ onKeyDown(e: KeyboardEvent): void;
38
+ /** 切换文本区域的显示 */
39
+ toggleTextContainerVisible(isVisible?: boolean): void;
40
+ }
41
+ export default TextToolOperation;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * 查看模式 - 支持简单数据注入查看
3
+ */
4
+ import { TAnnotationViewData, TAnnotationViewLine, TAnnotationViewPolygon, TAnnotationViewBox3d, IBasicStyle, TAnnotationViewCuboid } from '@labelbee/lb-utils';
5
+ import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
6
+ type IViewOperationProps = {
7
+ style: IBasicStyle;
8
+ annotations: TAnnotationViewData[];
9
+ } & IBasicToolOperationProps;
10
+ export interface ISpecificStyle {
11
+ stroke: string;
12
+ thickness: number;
13
+ fill: string;
14
+ radius: number;
15
+ }
16
+ export interface IFontStyle {
17
+ fontFamily: string;
18
+ fontSize: number;
19
+ }
20
+ export default class ViewOperation extends BasicToolOperation {
21
+ style: IBasicStyle;
22
+ annotations: TAnnotationViewData[];
23
+ private mouseHoverID?;
24
+ private loading;
25
+ private renderDomInstance;
26
+ private connectionPoints;
27
+ private connectPointsStatus?;
28
+ constructor(props: IViewOperationProps);
29
+ clearConnectionPoints(): void;
30
+ /**
31
+ * Get the connection points in annotationData.
32
+ * @param newAnnotations
33
+ */
34
+ checkConnectionPoints(newAnnotations?: TAnnotationViewData[]): void;
35
+ setLoading(loading: boolean): void;
36
+ onMouseLeave(): void;
37
+ onMouseDown(e: MouseEvent): true | undefined;
38
+ onMouseMove(e: MouseEvent): void;
39
+ getHoverRectID: (e: MouseEvent) => string | undefined;
40
+ updateData(annotations: TAnnotationViewData[]): void;
41
+ /**
42
+ * 获取当前结果的标注类型
43
+ * @param obj
44
+ * @returns
45
+ */
46
+ private getSpecificStyle;
47
+ /**
48
+ * Get font rendering style
49
+ * @param obj
50
+ * @param style
51
+ * @returns
52
+ */
53
+ private getFontStyle;
54
+ /**
55
+ * Append Draw offset
56
+ */
57
+ appendOffset({ x, y }: ICoordinate): {
58
+ x: number;
59
+ y: number;
60
+ };
61
+ /**
62
+ * 获取当前展示的文本
63
+ * @param result
64
+ * @returns
65
+ */
66
+ getRenderText(result: any, hiddenText?: boolean): {
67
+ headerText: string;
68
+ bottomText: string;
69
+ };
70
+ getReferenceOptions(isReference?: boolean): {
71
+ lineCap?: CanvasLineCap;
72
+ lineDash?: number[];
73
+ };
74
+ /**
75
+ * Focus on the selected lang.
76
+ * @param pointList
77
+ */
78
+ focusPositionByPointList(pointList: ICoordinate[]): void;
79
+ renderConnectionPoints(): void;
80
+ getRenderStyle(annotation: TAnnotationViewData): {
81
+ style: {
82
+ radius: any;
83
+ fill: any;
84
+ thickness: any;
85
+ stroke: any;
86
+ };
87
+ fontStyle: {
88
+ color: string;
89
+ font: string;
90
+ shadowColor: string;
91
+ shadowOffsetX: number;
92
+ shadowOffsetY: number;
93
+ shadowBlur: number;
94
+ };
95
+ };
96
+ renderLine(annotation: TAnnotationViewLine): void;
97
+ renderPolygon(annotation: TAnnotationViewPolygon): void;
98
+ renderSingleCuboid(annotation: TAnnotationViewCuboid): void;
99
+ renderBox3d(annotation: TAnnotationViewBox3d): void;
100
+ render(): void;
101
+ }
102
+ export {};