@labelbee/lb-annotation 1.5.2
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.
- package/README.md +143 -0
- package/dist/index.js +76 -0
- package/dist/types/constant/annotation.d.ts +63 -0
- package/dist/types/constant/annotationTask.d.ts +16 -0
- package/dist/types/constant/defaultConfig.d.ts +259 -0
- package/dist/types/constant/keyCode.d.ts +32 -0
- package/dist/types/constant/style.d.ts +43 -0
- package/dist/types/constant/tool.d.ts +161 -0
- package/dist/types/core/index.d.ts +74 -0
- package/dist/types/core/toolOperation/LineToolOperation.d.ts +419 -0
- package/dist/types/core/toolOperation/TextToolOperation.d.ts +41 -0
- package/dist/types/core/toolOperation/ViewOperation.d.ts +55 -0
- package/dist/types/core/toolOperation/basicToolOperation.d.ts +188 -0
- package/dist/types/core/toolOperation/checkOperation.d.ts +37 -0
- package/dist/types/core/toolOperation/eventListener.d.ts +33 -0
- package/dist/types/core/toolOperation/measureOperation.d.ts +8 -0
- package/dist/types/core/toolOperation/pointOperation.d.ts +85 -0
- package/dist/types/core/toolOperation/polygonOperation.d.ts +134 -0
- package/dist/types/core/toolOperation/rectOperation.d.ts +141 -0
- package/dist/types/core/toolOperation/tagOperation.d.ts +44 -0
- package/dist/types/core/toolOperation/textAttributeClass.d.ts +56 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/locales/constants.d.ts +15 -0
- package/dist/types/locales/en_US/message.d.ts +2 -0
- package/dist/types/locales/index.d.ts +4 -0
- package/dist/types/locales/zh_CN/message.d.ts +2 -0
- package/dist/types/utils/ActionsHistory.d.ts +32 -0
- package/dist/types/utils/EventBus.d.ts +40 -0
- package/dist/types/utils/ImgUtils.d.ts +3 -0
- package/dist/types/utils/MathUtils.d.ts +43 -0
- package/dist/types/utils/tool/AttributeUtils.d.ts +87 -0
- package/dist/types/utils/tool/AxisUtils.d.ts +189 -0
- package/dist/types/utils/tool/CanvasUtils.d.ts +40 -0
- package/dist/types/utils/tool/CommonToolUtils.d.ts +118 -0
- package/dist/types/utils/tool/DblClickEventListener.d.ts +47 -0
- package/dist/types/utils/tool/DrawUtils.d.ts +117 -0
- package/dist/types/utils/tool/ImgPosUtils.d.ts +34 -0
- package/dist/types/utils/tool/LineToolUtils.d.ts +105 -0
- package/dist/types/utils/tool/MarkerUtils.d.ts +9 -0
- package/dist/types/utils/tool/PolygonUtils.d.ts +60 -0
- package/dist/types/utils/tool/RectUtils.d.ts +69 -0
- package/dist/types/utils/tool/RenderDomUtils.d.ts +3 -0
- package/dist/types/utils/tool/StyleUtils.d.ts +9 -0
- package/dist/types/utils/tool/TagUtils.d.ts +54 -0
- package/dist/types/utils/tool/UnitUtils.d.ts +4 -0
- package/dist/types/utils/tool/ZoomUtils.d.ts +16 -0
- package/dist/types/utils/tool/polygonTool.d.ts +32 -0
- package/dist/types/utils/uuid.d.ts +1 -0
- package/es/index.js +76 -0
- package/package.json +96 -0
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file 实现线条工具的交互
|
|
3
|
+
* @author lijingchi <lijingchi1@sensetime.com>
|
|
4
|
+
*/
|
|
5
|
+
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
|
|
6
|
+
declare enum EStatus {
|
|
7
|
+
Create = 0,
|
|
8
|
+
/** 正在激活 */
|
|
9
|
+
Active = 1,
|
|
10
|
+
/** 没有操作,初始化状态 */
|
|
11
|
+
None = 2
|
|
12
|
+
}
|
|
13
|
+
/** 曲线分割点数 */
|
|
14
|
+
export declare const SEGMENT_NUMBER = 16;
|
|
15
|
+
export declare const LINE_ORDER_OFFSET: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
/** 圆的半径 */
|
|
20
|
+
export declare const POINT_RADIUS = 3;
|
|
21
|
+
/** 圆的激活半径 */
|
|
22
|
+
export declare const POINT_ACTIVE_RADIUS = 5;
|
|
23
|
+
/** 内侧圆的半径 */
|
|
24
|
+
export declare const INNER_POINT_RADIUS = 2;
|
|
25
|
+
interface ILineOperationProps extends IBasicToolOperationProps {
|
|
26
|
+
}
|
|
27
|
+
declare class LineToolOperation extends BasicToolOperation {
|
|
28
|
+
/**
|
|
29
|
+
* 渲染激活的线段
|
|
30
|
+
* @param coord 当前的坐标
|
|
31
|
+
* @param e 鼠标事件
|
|
32
|
+
*/
|
|
33
|
+
drawActivatedLine: (coord?: ICoordinate | undefined, e?: MouseEvent | undefined, hideTempAxis?: boolean | undefined) => void;
|
|
34
|
+
/** 线条是否被选中 */
|
|
35
|
+
get isLineSelected(): "" | ILinePoint[] | undefined;
|
|
36
|
+
/** 选中点线条的点 */
|
|
37
|
+
get selectedLinePoints(): any[];
|
|
38
|
+
/**
|
|
39
|
+
* 绘制hover的点
|
|
40
|
+
* @param coord
|
|
41
|
+
*/
|
|
42
|
+
drawHoverPoint: (coord: ICoordinate) => void;
|
|
43
|
+
selectedID?: string;
|
|
44
|
+
private lineList;
|
|
45
|
+
private activeLine?;
|
|
46
|
+
private status;
|
|
47
|
+
private isMousedown;
|
|
48
|
+
private prevAxis;
|
|
49
|
+
private activeArea?;
|
|
50
|
+
/** 临时点的渲染坐标 */
|
|
51
|
+
private cursor?;
|
|
52
|
+
private selectedPoint?;
|
|
53
|
+
private actionsHistory?;
|
|
54
|
+
private coordsInsideActiveArea;
|
|
55
|
+
private hoverLineSegmentIndex;
|
|
56
|
+
private isShift;
|
|
57
|
+
private hoverPointID?;
|
|
58
|
+
private dependToolConfig?;
|
|
59
|
+
private isReference;
|
|
60
|
+
private _textAttributeInstance?;
|
|
61
|
+
private textEditingID?;
|
|
62
|
+
private isLineValid;
|
|
63
|
+
private lineDragging;
|
|
64
|
+
constructor(props: ILineOperationProps);
|
|
65
|
+
/** 创建状态 */
|
|
66
|
+
get isCreate(): boolean;
|
|
67
|
+
/** 激活状态 */
|
|
68
|
+
get isActive(): boolean;
|
|
69
|
+
/** 无状态 */
|
|
70
|
+
get isNone(): boolean;
|
|
71
|
+
/** 线条类型是否为曲线 */
|
|
72
|
+
get isCurve(): boolean;
|
|
73
|
+
/** 线条是否为多色 */
|
|
74
|
+
get isMultipleColor(): boolean;
|
|
75
|
+
get imageSize(): any;
|
|
76
|
+
get lineListLen(): number;
|
|
77
|
+
/** 是否允许边缘吸附 */
|
|
78
|
+
get edgeAdsorptionEnabled(): any;
|
|
79
|
+
get attributeConfigurable(): any;
|
|
80
|
+
get isTextConfigurable(): any;
|
|
81
|
+
get isDependPolygon(): boolean;
|
|
82
|
+
get isDependRect(): boolean;
|
|
83
|
+
get isCurrentAttributeLocked(): boolean;
|
|
84
|
+
get attributeFilteredLines(): ILine[];
|
|
85
|
+
get enableOutOfTarget(): any;
|
|
86
|
+
get showOrder(): any;
|
|
87
|
+
get edgeAdsorption(): any;
|
|
88
|
+
get attributeList(): any;
|
|
89
|
+
get lowerLimitPointNum(): any;
|
|
90
|
+
get upperLimitPointNum(): any;
|
|
91
|
+
get textCheckType(): any;
|
|
92
|
+
get customFormat(): any;
|
|
93
|
+
get dataList(): ILine[];
|
|
94
|
+
get hasActiveLine(): boolean | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* 视野内的线条
|
|
97
|
+
*/
|
|
98
|
+
get viewPortLines(): ILine[];
|
|
99
|
+
get lineStyle(): {
|
|
100
|
+
lineWidth: any;
|
|
101
|
+
color: any;
|
|
102
|
+
opacity: any;
|
|
103
|
+
};
|
|
104
|
+
get selectedText(): string;
|
|
105
|
+
/**
|
|
106
|
+
* 获取当前页面标注结果
|
|
107
|
+
*/
|
|
108
|
+
get currentPageResult(): ILine[];
|
|
109
|
+
updateStatus(status: EStatus, resetText?: boolean): void;
|
|
110
|
+
isInBasicPolygon(coord: ICoordinate): boolean;
|
|
111
|
+
getPolygonPointList(): any;
|
|
112
|
+
/**
|
|
113
|
+
* 渲染坐标计算获取下一个点
|
|
114
|
+
* @param coord
|
|
115
|
+
* @returns 绝对坐标
|
|
116
|
+
*/
|
|
117
|
+
getNextCoordByRenderCoord(renderCoord: ICoordinate): ICoordinate | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* 绝对坐标计算获取下一个点
|
|
120
|
+
* @param coord
|
|
121
|
+
* @returns 渲染坐标
|
|
122
|
+
*/
|
|
123
|
+
getNextCoordByAbsCoord(absCoord: ICoordinate): ICoordinate | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* 检查点是否在线上
|
|
126
|
+
* @param pointList 所有点
|
|
127
|
+
* @param checkPoint
|
|
128
|
+
* @param scope
|
|
129
|
+
*/
|
|
130
|
+
pointInLine(pointList: ILinePoint[], checkPoint: ICoordinate, scope: number): boolean;
|
|
131
|
+
/**
|
|
132
|
+
* 根据坐标绘制圆点
|
|
133
|
+
* @param coord
|
|
134
|
+
* @param size
|
|
135
|
+
* @param color
|
|
136
|
+
*/
|
|
137
|
+
arc(coord: ICoordinate, size?: number, color?: string): void;
|
|
138
|
+
/**
|
|
139
|
+
* 对存在绘制对象,绘制热区
|
|
140
|
+
*/
|
|
141
|
+
renderActiveArea(): void;
|
|
142
|
+
/**
|
|
143
|
+
* 添加点
|
|
144
|
+
* @param coord 坐标
|
|
145
|
+
*/
|
|
146
|
+
addLinePoint(coord: ICoordinate): void;
|
|
147
|
+
setCreatStatusAndAddPoint(coord: ICoordinate, isRestText?: boolean): void;
|
|
148
|
+
/**
|
|
149
|
+
* 当前激活的线条是否为有效线, 优先获取存在的数据
|
|
150
|
+
*/
|
|
151
|
+
isActiveLineValid(): boolean | undefined;
|
|
152
|
+
nextOrder(): number;
|
|
153
|
+
drawCurveLine: (ctx: any, points: ILinePoint[], config: any, applyLineWidth: boolean | undefined, isReference: boolean | undefined, hoverLineSegmentIndex: number) => void;
|
|
154
|
+
/**
|
|
155
|
+
* 绘制线段
|
|
156
|
+
* @param points 点列表
|
|
157
|
+
* @param cursor 临时的左边,用于实时绘制
|
|
158
|
+
* @param color 线条颜色
|
|
159
|
+
* @param showPoint 是否显示点
|
|
160
|
+
*/
|
|
161
|
+
drawLine: (points: Array<ILinePoint | ICoordinate>, cursor: ICoordinate | undefined, color: string, showPoint?: boolean, isActive?: boolean) => void;
|
|
162
|
+
drawStraightLine: (points: any[], config: any, isActive?: boolean) => void;
|
|
163
|
+
getLineColorByAttribute(line: {
|
|
164
|
+
attribute: string;
|
|
165
|
+
valid: boolean;
|
|
166
|
+
} | ILine, isSelected?: boolean): string;
|
|
167
|
+
drawLines: () => void;
|
|
168
|
+
/**
|
|
169
|
+
* 渲染已经绘制的线段
|
|
170
|
+
*/
|
|
171
|
+
render: (nextPoint?: IPoint | undefined) => void;
|
|
172
|
+
/** 重新计算并渲染热区 */
|
|
173
|
+
updateActiveArea(): void;
|
|
174
|
+
getActiveArea(): {
|
|
175
|
+
top: number;
|
|
176
|
+
bottom: number;
|
|
177
|
+
left: number;
|
|
178
|
+
right: number;
|
|
179
|
+
} | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* 绘制线条序号(包含属性或者标签)
|
|
182
|
+
* @param coord
|
|
183
|
+
* @param order
|
|
184
|
+
* @param color
|
|
185
|
+
* @param label
|
|
186
|
+
* @param attribute
|
|
187
|
+
* @param valid
|
|
188
|
+
*/
|
|
189
|
+
drawLineNumber(coord: ICoordinate, order: number | undefined, color: string, label?: string, attribute?: string, valid?: boolean): void;
|
|
190
|
+
/**
|
|
191
|
+
* 绘制线条的文本属性
|
|
192
|
+
* @param coord
|
|
193
|
+
* @param text
|
|
194
|
+
* @param color
|
|
195
|
+
*/
|
|
196
|
+
drawLineTextAttribute(coord: ICoordinate, color: string, text?: string): void;
|
|
197
|
+
drawText(coord: ICoordinate, text: string, color: string, lineWidth?: number): void;
|
|
198
|
+
/**
|
|
199
|
+
* 更新热区
|
|
200
|
+
* @param offsetX
|
|
201
|
+
* @param offsetY
|
|
202
|
+
*/
|
|
203
|
+
moveActiveArea(offsetX: number, offsetY: number): void;
|
|
204
|
+
/**
|
|
205
|
+
* 找到当前hover的点
|
|
206
|
+
* @param coord
|
|
207
|
+
*/
|
|
208
|
+
findHoveredPoint(coord: ICoordinate): ILinePoint | undefined;
|
|
209
|
+
/** 找到当前hover的线段 */
|
|
210
|
+
findHoverLine(coord: ICoordinate): ILine | undefined;
|
|
211
|
+
/**
|
|
212
|
+
* 找到当前点的边缘吸附范围
|
|
213
|
+
* @param coord
|
|
214
|
+
*/
|
|
215
|
+
getAdsorptionPoint(coord: ICoordinate): ICoordinate | undefined;
|
|
216
|
+
/**
|
|
217
|
+
* 找到由pointList连成线的最近的点, 优先匹配顶点
|
|
218
|
+
* @param axisAreas
|
|
219
|
+
* @param coord 渲染坐标
|
|
220
|
+
* @param pointList
|
|
221
|
+
* @returns 落点的渲染坐标
|
|
222
|
+
*/
|
|
223
|
+
findNearestPoint(pointList: ICoordinate[], coord: ICoordinate, minLength?: number): {
|
|
224
|
+
point: ICoordinate;
|
|
225
|
+
minDistance: number;
|
|
226
|
+
} | undefined;
|
|
227
|
+
getPointList(pointList: ILinePoint[]): any[];
|
|
228
|
+
/**
|
|
229
|
+
* 计算依赖拉框、多边形的情况下移动后点是否都在范围内
|
|
230
|
+
* @param offsetX
|
|
231
|
+
* @param offsetY
|
|
232
|
+
*/
|
|
233
|
+
moveLineInPolygon: (offsetX: number, offsetY: number) => false | undefined;
|
|
234
|
+
/**
|
|
235
|
+
* 在矩形内移动线条
|
|
236
|
+
* @param offsetX x轴的偏移量
|
|
237
|
+
* @param offsetY y轴的偏移量
|
|
238
|
+
* @param rectHorizontalRange 矩形的水平范围
|
|
239
|
+
* @param rectVerticalRange 矩形的垂直范围
|
|
240
|
+
*/
|
|
241
|
+
moveLineInRectRange: (offsetX: number, offsetY: number, rectHorizontalRange: number[], rectVerticalRange: number[]) => void;
|
|
242
|
+
/**
|
|
243
|
+
* 移动选中的线段
|
|
244
|
+
* @param coord
|
|
245
|
+
*/
|
|
246
|
+
moveSelectedLine(coord: ICoordinate): void;
|
|
247
|
+
/**
|
|
248
|
+
* 移动选中的点
|
|
249
|
+
* @param coord
|
|
250
|
+
*/
|
|
251
|
+
moveSelectPoint(coord: ICoordinate): void;
|
|
252
|
+
/**
|
|
253
|
+
* 根据当前键盘事件和配置获取下一个点的坐标
|
|
254
|
+
* @param e
|
|
255
|
+
* @param coord
|
|
256
|
+
*/
|
|
257
|
+
getCoordByConfig(e: MouseEvent | KeyboardEvent | {
|
|
258
|
+
altKey: boolean;
|
|
259
|
+
shiftKey?: boolean;
|
|
260
|
+
}, coord: ICoordinate): ICoordinate | undefined;
|
|
261
|
+
/**
|
|
262
|
+
* 计算出下一个将要绘制的点
|
|
263
|
+
* @param e
|
|
264
|
+
* @param nextPoint
|
|
265
|
+
*/
|
|
266
|
+
getNextPoint(e: MouseEvent | KeyboardEvent | {
|
|
267
|
+
altKey: boolean;
|
|
268
|
+
shiftKey?: boolean;
|
|
269
|
+
}, nextPoint: ICoordinate): ICoordinate | undefined;
|
|
270
|
+
lineHover(): void;
|
|
271
|
+
/** 鼠标移动事件 */
|
|
272
|
+
mouseMoveHandler(e: MouseEvent): void;
|
|
273
|
+
onMouseMove(e: MouseEvent): void;
|
|
274
|
+
/**
|
|
275
|
+
* 设置激活区域
|
|
276
|
+
* @param coord
|
|
277
|
+
* @param outsideCancel
|
|
278
|
+
* @todo 拖拽区域取消选中
|
|
279
|
+
*/
|
|
280
|
+
setActiveArea(coord: ICoordinate, outsideCancel?: boolean): void;
|
|
281
|
+
/**
|
|
282
|
+
* 根据id选中线条
|
|
283
|
+
* @param id
|
|
284
|
+
*/
|
|
285
|
+
setActiveLineByID(id: string): void;
|
|
286
|
+
setActiveLine(pointList?: ILinePoint[]): void;
|
|
287
|
+
onRightClick: (e: MouseEvent) => void;
|
|
288
|
+
historyChanged(funcName: 'undo' | 'redo'): void;
|
|
289
|
+
updateSelectedAttributeAfterHistoryChanged: () => void;
|
|
290
|
+
undo(): void;
|
|
291
|
+
redo(): void;
|
|
292
|
+
/** 坐标是否在图片内 */
|
|
293
|
+
isCoordInsideTarget(coord: ICoordinate): boolean;
|
|
294
|
+
/**
|
|
295
|
+
* 获取当前点插入的索引
|
|
296
|
+
* @returns index
|
|
297
|
+
*/
|
|
298
|
+
getPointInsertIndex(coord?: ICoordinate, scope?: number): number;
|
|
299
|
+
getLineWidthScope(): any;
|
|
300
|
+
isMouseCoordOutsideActiveArea(): boolean;
|
|
301
|
+
/** 是否超过上限点 */
|
|
302
|
+
isLinePointsExceed(): any;
|
|
303
|
+
isLinePointsNotEnough(): boolean | undefined;
|
|
304
|
+
updateLineSegmentSpecial(coord: ICoordinate): void;
|
|
305
|
+
onLeftClick: (e: MouseEvent) => void;
|
|
306
|
+
addLinePointToActiveLine(): void;
|
|
307
|
+
onMouseDown(e: MouseEvent): void;
|
|
308
|
+
lineHasChanged(): boolean;
|
|
309
|
+
updateLines(): void;
|
|
310
|
+
onMouseUp(e: MouseEvent): void;
|
|
311
|
+
onDblclick: () => void;
|
|
312
|
+
isTextValid(text: string): boolean | undefined;
|
|
313
|
+
createLineData(): ILine;
|
|
314
|
+
/**
|
|
315
|
+
* 停止当前的线条绘制
|
|
316
|
+
* @param isAppend
|
|
317
|
+
*/
|
|
318
|
+
stopLineCreating(isAppend?: boolean): void;
|
|
319
|
+
setActiveStatus(id?: string): void;
|
|
320
|
+
/**
|
|
321
|
+
* 设置为无状态
|
|
322
|
+
* @param updateStatus
|
|
323
|
+
*/
|
|
324
|
+
setNoneStatus(updateStatus?: boolean): void;
|
|
325
|
+
setKeyDownStatus(e: KeyboardEvent, value?: boolean): void;
|
|
326
|
+
/** 续标当前激活的线条 */
|
|
327
|
+
continueToEdit(): void;
|
|
328
|
+
onKeyUp: (e: KeyboardEvent) => void;
|
|
329
|
+
/** 创建无效线条,activeLineID存在时为续标(没有按ctrl时不会修改其有无效性),不会设置无效的属性 */
|
|
330
|
+
setInvalidLineOnCreating(e: KeyboardEvent): void;
|
|
331
|
+
onKeyDown(e: KeyboardEvent): void;
|
|
332
|
+
/**
|
|
333
|
+
* 切换到下一个线条
|
|
334
|
+
* @param e
|
|
335
|
+
*/
|
|
336
|
+
private selectToNextLine;
|
|
337
|
+
/**
|
|
338
|
+
* 在线条创建时候的键盘事件, 并触发渲染
|
|
339
|
+
* 1.设为无效。
|
|
340
|
+
* 2.Alt取消边缘吸附。
|
|
341
|
+
* 3.Shift绘制垂直/水平线
|
|
342
|
+
* @param e
|
|
343
|
+
*/
|
|
344
|
+
keyboardEventWhileLineCreating(e: KeyboardEvent): void;
|
|
345
|
+
/**
|
|
346
|
+
* 计算出下一个点并渲染
|
|
347
|
+
* @param e
|
|
348
|
+
* @param coord
|
|
349
|
+
*/
|
|
350
|
+
renderNextPoint(e: MouseEvent | KeyboardEvent | {
|
|
351
|
+
altKey: boolean;
|
|
352
|
+
}, coord: ICoordinate): void;
|
|
353
|
+
deleteSelectedLine(coord: ICoordinate): void;
|
|
354
|
+
/**
|
|
355
|
+
* 删除当前选中的点
|
|
356
|
+
* @param hoverPointID
|
|
357
|
+
*/
|
|
358
|
+
deleteSelectedLinePoint(selectedID: string): void;
|
|
359
|
+
/**
|
|
360
|
+
* 右键双击事件,
|
|
361
|
+
* 1. 删除线
|
|
362
|
+
* 2. 删除点
|
|
363
|
+
* @param e
|
|
364
|
+
*/
|
|
365
|
+
onRightDblClick: (e: MouseEvent) => void;
|
|
366
|
+
/** 删除激活的线段 */
|
|
367
|
+
deleteLine(): void;
|
|
368
|
+
setInvalidLine(id?: string, valid?: boolean, isRender?: boolean): void;
|
|
369
|
+
/** 数据清空 */
|
|
370
|
+
empty(): void;
|
|
371
|
+
/** 设置线条属性 */
|
|
372
|
+
setAttribute(attribute: string): void;
|
|
373
|
+
/** 设置线条文本标注属性 */
|
|
374
|
+
setTextAttribute(text: string): void;
|
|
375
|
+
/** 更新线条的属性 */
|
|
376
|
+
setLineAttribute(key: 'attribute' | 'textAttribute', value: string, id?: string): void;
|
|
377
|
+
/** 更新外部属性列表的选中值 */
|
|
378
|
+
updateAttribute(attribute: string): void;
|
|
379
|
+
/** 更新线条的属性 */
|
|
380
|
+
updateLineAttributes(line: ILine): void;
|
|
381
|
+
lineStatusChanged(): void;
|
|
382
|
+
updateTextAttribute(text: string): void;
|
|
383
|
+
/** 保存当前绘制的数据, 避免创建中的数据不会被保存到 */
|
|
384
|
+
saveData(): void;
|
|
385
|
+
setTextEditingID(id: string): void;
|
|
386
|
+
setSelectedLineID(id?: string): void;
|
|
387
|
+
attributeLockListChange(attributeLockList: string[]): void;
|
|
388
|
+
setReference: (isReference: boolean) => void;
|
|
389
|
+
/**
|
|
390
|
+
* 计算带点数是否超出限制
|
|
391
|
+
* @param count
|
|
392
|
+
*/
|
|
393
|
+
pointsWithinRange: (count: number) => boolean;
|
|
394
|
+
setResult(lineList: ILine[]): void;
|
|
395
|
+
setLineList: (lineList: ILine[]) => void;
|
|
396
|
+
setConfig(config: string): void;
|
|
397
|
+
toggleIsHide(): void;
|
|
398
|
+
clearCanvas(): void;
|
|
399
|
+
/**
|
|
400
|
+
* 清除当前的所有数据
|
|
401
|
+
*/
|
|
402
|
+
clearResult(): void;
|
|
403
|
+
exportData(): any[];
|
|
404
|
+
setDefaultAttribute(attribute?: string): void;
|
|
405
|
+
/**
|
|
406
|
+
* 用于 TextAttributeClass 的数据获取
|
|
407
|
+
* @returns
|
|
408
|
+
*/
|
|
409
|
+
getCurrentSelectedData(): {
|
|
410
|
+
color: any;
|
|
411
|
+
textAttribute: string;
|
|
412
|
+
};
|
|
413
|
+
renderTextAttribute(): void;
|
|
414
|
+
getTextIconSvg(attribute?: string): any;
|
|
415
|
+
/** 更新文本输入,并且进行关闭 */
|
|
416
|
+
updateSelectedTextAttribute(newTextAttribute?: string): void;
|
|
417
|
+
textChange: (v: string) => void;
|
|
418
|
+
}
|
|
419
|
+
export default LineToolOperation;
|
|
@@ -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 | undefined) => 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,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 查看模式 - 支持简单数据注入查看
|
|
3
|
+
*/
|
|
4
|
+
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
|
|
5
|
+
interface IBasicStyle {
|
|
6
|
+
color?: string;
|
|
7
|
+
fill?: string;
|
|
8
|
+
thickness?: number;
|
|
9
|
+
}
|
|
10
|
+
interface IAnnotationData {
|
|
11
|
+
type: 'rect' | 'polygon' | 'line' | 'point';
|
|
12
|
+
annotation: IBasicRect & IBasicPolygon & IBasicLine & IPoint;
|
|
13
|
+
}
|
|
14
|
+
interface IBasicRect extends IBasicStyle {
|
|
15
|
+
id: string;
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}
|
|
21
|
+
interface IBasicPolygon extends IBasicStyle {
|
|
22
|
+
id: string;
|
|
23
|
+
pointList: IPoint[];
|
|
24
|
+
}
|
|
25
|
+
declare type IBasicLine = IBasicPolygon;
|
|
26
|
+
interface IPoint extends IBasicStyle {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
radius?: number;
|
|
30
|
+
}
|
|
31
|
+
declare type IViewOperationProps = {
|
|
32
|
+
style: IBasicStyle;
|
|
33
|
+
annotations: IAnnotationData[];
|
|
34
|
+
} & IBasicToolOperationProps;
|
|
35
|
+
export default class ViewOperation extends BasicToolOperation {
|
|
36
|
+
style: IBasicStyle;
|
|
37
|
+
annotations: IAnnotationData[];
|
|
38
|
+
private mouseHoverID?;
|
|
39
|
+
private loading;
|
|
40
|
+
constructor(props: IViewOperationProps);
|
|
41
|
+
setLoading(loading: boolean): void;
|
|
42
|
+
onMouseLeave(): void;
|
|
43
|
+
onMouseDown(e: MouseEvent): true | undefined;
|
|
44
|
+
onMouseMove(e: MouseEvent): void;
|
|
45
|
+
getHoverRectID: (e: MouseEvent) => string | undefined;
|
|
46
|
+
updateData(annotations: IAnnotationData[]): void;
|
|
47
|
+
/**
|
|
48
|
+
* 获取当前结果的标注类型
|
|
49
|
+
* @param obj
|
|
50
|
+
* @returns
|
|
51
|
+
*/
|
|
52
|
+
private getSpecificStyle;
|
|
53
|
+
render(): void;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { EDragStatus, EGrowthMode, ELang } from '../../constant/annotation';
|
|
2
|
+
import ActionsHistory from '../../utils/ActionsHistory';
|
|
3
|
+
import DblClickEventListener from '../../utils/tool/DblClickEventListener';
|
|
4
|
+
import EventListener from './eventListener';
|
|
5
|
+
import { CoordinateUtils } from '@/utils/tool/AxisUtils';
|
|
6
|
+
import { EToolName } from '@/constant/tool';
|
|
7
|
+
import { IPolygonConfig } from '@/types/tool/polygon';
|
|
8
|
+
interface IBasicToolOperationProps {
|
|
9
|
+
container: HTMLElement;
|
|
10
|
+
size: ISize;
|
|
11
|
+
imgNode?: HTMLImageElement;
|
|
12
|
+
style?: any;
|
|
13
|
+
rotate?: number;
|
|
14
|
+
imgAttribute?: any;
|
|
15
|
+
forbidOperation?: boolean;
|
|
16
|
+
config: string;
|
|
17
|
+
defaultAttribute?: string;
|
|
18
|
+
forbidCursorLine?: boolean;
|
|
19
|
+
showDefaultCursor?: boolean;
|
|
20
|
+
}
|
|
21
|
+
declare class BasicToolOperation extends EventListener {
|
|
22
|
+
container: HTMLElement;
|
|
23
|
+
canvas: HTMLCanvasElement;
|
|
24
|
+
basicCanvas: HTMLCanvasElement;
|
|
25
|
+
imgNode?: HTMLImageElement;
|
|
26
|
+
basicImgInfo: any;
|
|
27
|
+
isImgError: boolean;
|
|
28
|
+
basicResult?: any;
|
|
29
|
+
dependToolName?: EToolName;
|
|
30
|
+
history: ActionsHistory;
|
|
31
|
+
size: ISize;
|
|
32
|
+
isShowCursor: boolean;
|
|
33
|
+
forbidOperation: boolean;
|
|
34
|
+
style: any;
|
|
35
|
+
zoom: number;
|
|
36
|
+
currentPos: ICoordinate;
|
|
37
|
+
coord: ICoordinate;
|
|
38
|
+
imgInfo?: ISize;
|
|
39
|
+
isDrag: boolean;
|
|
40
|
+
isSpaceKey: boolean;
|
|
41
|
+
attributeLockList: string[];
|
|
42
|
+
dblClickListener: DblClickEventListener;
|
|
43
|
+
isHidden: boolean;
|
|
44
|
+
config: any;
|
|
45
|
+
dragStatus: EDragStatus;
|
|
46
|
+
defaultAttribute: string;
|
|
47
|
+
forbidCursorLine: boolean;
|
|
48
|
+
lang: ELang;
|
|
49
|
+
private _firstClickCoordinate?;
|
|
50
|
+
private innerZoom;
|
|
51
|
+
private currentPosStorage?;
|
|
52
|
+
private basicZoom;
|
|
53
|
+
private isSpaceClick;
|
|
54
|
+
private isDragStart;
|
|
55
|
+
private startTime;
|
|
56
|
+
private _ctx?;
|
|
57
|
+
private _imgAttribute?;
|
|
58
|
+
private _invalidDOM?;
|
|
59
|
+
private showDefaultCursor;
|
|
60
|
+
coordUtils: CoordinateUtils;
|
|
61
|
+
constructor(props: IBasicToolOperationProps);
|
|
62
|
+
onContextmenu(e: MouseEvent): void;
|
|
63
|
+
get ctx(): CanvasRenderingContext2D | null;
|
|
64
|
+
get basicCtx(): CanvasRenderingContext2D | null;
|
|
65
|
+
get rotate(): any;
|
|
66
|
+
get valid(): any;
|
|
67
|
+
get baseIcon(): any;
|
|
68
|
+
get defaultCursor(): "default" | "none";
|
|
69
|
+
/** 数据列表,根据其判断是否可以旋转 */
|
|
70
|
+
get dataList(): any[];
|
|
71
|
+
setZoom(zoom: number): void;
|
|
72
|
+
setCurrentPos(currentPos: ICoordinate): void;
|
|
73
|
+
/**
|
|
74
|
+
* 外界直接更改当前渲染位置
|
|
75
|
+
* @param zoom
|
|
76
|
+
* @param currentPos
|
|
77
|
+
*/
|
|
78
|
+
updatePosition(params: {
|
|
79
|
+
zoom: number;
|
|
80
|
+
currentPos: ICoordinate;
|
|
81
|
+
}): void;
|
|
82
|
+
setLang(lang: ELang): void;
|
|
83
|
+
setShowDefaultCursor(showDefaultCursor: boolean): void;
|
|
84
|
+
get forbidMouseOperation(): boolean;
|
|
85
|
+
init(): void;
|
|
86
|
+
destroy(): void;
|
|
87
|
+
createCanvas(size: ISize): void;
|
|
88
|
+
destroyCanvas(): void;
|
|
89
|
+
/**
|
|
90
|
+
* 设置框的样式
|
|
91
|
+
* @param lineWidth
|
|
92
|
+
* @param strokeColor
|
|
93
|
+
*/
|
|
94
|
+
setStyle(toolStyle: any): void;
|
|
95
|
+
setImgNode(imgNode: HTMLImageElement, basicImgInfo?: Partial<{
|
|
96
|
+
valid: boolean;
|
|
97
|
+
rotate: number;
|
|
98
|
+
}>): void;
|
|
99
|
+
setErrorImg(): void;
|
|
100
|
+
setBasicImgInfo(basicImgInfo: any): void;
|
|
101
|
+
setForbidOperation(forbidOperation: boolean): void;
|
|
102
|
+
setForbidCursorLine(forbidCursorLine: boolean): void;
|
|
103
|
+
setIsHidden(isHidden: boolean): void;
|
|
104
|
+
/**
|
|
105
|
+
* 用于外界直接控制序号的是否展示
|
|
106
|
+
* @param isShowOrder
|
|
107
|
+
*/
|
|
108
|
+
setIsShowOrder(isShowOrder: boolean): void;
|
|
109
|
+
/** 获取坐标值 */
|
|
110
|
+
getCoordinate(e: MouseEvent): {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
};
|
|
114
|
+
/** 获取当前zoom 下的坐标 */
|
|
115
|
+
getCoordinateUnderZoom(e: MouseEvent): {
|
|
116
|
+
x: number;
|
|
117
|
+
y: number;
|
|
118
|
+
};
|
|
119
|
+
getGetCenterCoordinate(): {
|
|
120
|
+
x: number;
|
|
121
|
+
y: number;
|
|
122
|
+
};
|
|
123
|
+
/** 用于初始化图片的位置 */
|
|
124
|
+
initImgPos: () => Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* 用于依赖情况下的图片初始化
|
|
127
|
+
*/
|
|
128
|
+
initPosition(): void;
|
|
129
|
+
getCurrentPos: (coord: any) => {
|
|
130
|
+
y: number;
|
|
131
|
+
x: number;
|
|
132
|
+
};
|
|
133
|
+
/** 撤销 */
|
|
134
|
+
undo(): void;
|
|
135
|
+
/** 重做 */
|
|
136
|
+
redo(): void;
|
|
137
|
+
clearCanvas(): void;
|
|
138
|
+
clearBasicCanvas(): void;
|
|
139
|
+
/** 事件绑定 */
|
|
140
|
+
eventBinding(): void;
|
|
141
|
+
eventUnbinding(): void;
|
|
142
|
+
clearImgDrag(): void;
|
|
143
|
+
onMouseDown(e: MouseEvent): void | boolean;
|
|
144
|
+
onMouseMove(e: MouseEvent): boolean | void;
|
|
145
|
+
onMouseUp(e: MouseEvent): boolean | void;
|
|
146
|
+
onMouseLeave(): void;
|
|
147
|
+
onClick(e: MouseEvent): void;
|
|
148
|
+
onLeftDblClick(e: MouseEvent): void;
|
|
149
|
+
onRightDblClick(e: MouseEvent): void;
|
|
150
|
+
onKeyDown(e: KeyboardEvent): boolean | void;
|
|
151
|
+
onKeyUp(e: KeyboardEvent): boolean | void;
|
|
152
|
+
onWheel(e: any, isRender?: boolean): boolean | void;
|
|
153
|
+
wheelChangePos: (coord: ICoordinate, operator: 1 | -1 | 0, newZoom?: number | undefined) => void;
|
|
154
|
+
/**
|
|
155
|
+
* 通过ZOOM_LEVEL, 计算出下一个缩放的值。
|
|
156
|
+
* @param isZoomIn 是否为放大
|
|
157
|
+
*/
|
|
158
|
+
zoomChanged: (isZoomIn: boolean, growthMode?: EGrowthMode) => void;
|
|
159
|
+
renderCursorLine(lineColor?: any): void;
|
|
160
|
+
drawImg: () => void;
|
|
161
|
+
/**
|
|
162
|
+
* 更改当前 canvas 整体的大小,需要重新初始化
|
|
163
|
+
* @param size
|
|
164
|
+
*/
|
|
165
|
+
setSize(size: ISize): void;
|
|
166
|
+
setImgAttribute(imgAttribute: IImageAttribute): void;
|
|
167
|
+
clearResult(sendMessage?: boolean | string): void;
|
|
168
|
+
setValid(valid: boolean): void;
|
|
169
|
+
setRotate(rotate: number): void;
|
|
170
|
+
setBasicResult(basicResult: any): void;
|
|
171
|
+
setDependName(dependToolName: EToolName, dependToolConfig?: IRectConfig | IPolygonConfig): void;
|
|
172
|
+
setAttributeLockList(attributeLockList: string[]): void;
|
|
173
|
+
setConfig(config: string): void;
|
|
174
|
+
/**
|
|
175
|
+
* 进行图片旋转操作
|
|
176
|
+
* @returns
|
|
177
|
+
*/
|
|
178
|
+
updateRotate(): false | undefined;
|
|
179
|
+
/** 获取当前属性颜色 */
|
|
180
|
+
getColor(attribute?: string, config?: any): any;
|
|
181
|
+
getLineColor(attribute?: string): any;
|
|
182
|
+
clearInvalidPage(): void;
|
|
183
|
+
renderInvalidPage(): void;
|
|
184
|
+
renderBasicCanvas(): void;
|
|
185
|
+
render(): void;
|
|
186
|
+
changeStyle(newAttribute?: string): void;
|
|
187
|
+
}
|
|
188
|
+
export { IBasicToolOperationProps, BasicToolOperation };
|