@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,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 各类的数学运算
|
|
3
|
+
*/
|
|
4
|
+
export default class MathUtils {
|
|
5
|
+
/**
|
|
6
|
+
* 是否在指定范围内
|
|
7
|
+
* @param value 需要判断的值
|
|
8
|
+
* @param range 范围
|
|
9
|
+
* @returns {boolean} 是否在范围内
|
|
10
|
+
*/
|
|
11
|
+
static isInRange: (value: number | number[], range: number[]) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 限制点在范围,返回
|
|
14
|
+
* @param value
|
|
15
|
+
* @param range
|
|
16
|
+
* @returns {ICoordinate} 在范围内的点
|
|
17
|
+
*/
|
|
18
|
+
static withinRange: (value: number, range: number[]) => number;
|
|
19
|
+
static getRotate(rotate: number): number;
|
|
20
|
+
static getLineLength(point1: ICoordinate, point2: ICoordinate): number;
|
|
21
|
+
/**
|
|
22
|
+
* 计算坐标点的视窗范围
|
|
23
|
+
* @param array 坐标值数组
|
|
24
|
+
* @returns 视窗范围 { top, left, right, bottom }
|
|
25
|
+
*/
|
|
26
|
+
static calcViewportBoundaries: (array: ICoordinate[] | undefined, isCurve?: boolean, numberOfSegments?: number, zoom?: number) => {
|
|
27
|
+
top: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
left: number;
|
|
30
|
+
right: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* 获取当前左边举例线段的最短路径,建议配合 isHoverLine 使用
|
|
34
|
+
*
|
|
35
|
+
* @export
|
|
36
|
+
* @param {ICoordinate} pt
|
|
37
|
+
* @param {ICoordinate} begin
|
|
38
|
+
* @param {ICoordinate} end
|
|
39
|
+
* @param {boolean} ignoreRatio
|
|
40
|
+
* @returns
|
|
41
|
+
*/
|
|
42
|
+
static getFootOfPerpendicular: (pt: ICoordinate, begin: ICoordinate, end: ICoordinate, useAxisRange?: boolean) => any;
|
|
43
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ELang } from '../../constant/annotation';
|
|
2
|
+
import { IPolygonData } from '../../types/tool/polygon';
|
|
3
|
+
import { ETextType } from '../../constant/tool';
|
|
4
|
+
export declare const ATTRIBUTE_COLORS: string[];
|
|
5
|
+
export declare const REGEXP_NUMBER = "^[0-9]+$";
|
|
6
|
+
export declare const REGEXP_ENGLISH = "^[A-Za-z]+$";
|
|
7
|
+
export default class AttributeUtils {
|
|
8
|
+
/**
|
|
9
|
+
* 获取属性icon
|
|
10
|
+
* @param attribute
|
|
11
|
+
* @param attributeList
|
|
12
|
+
*/
|
|
13
|
+
static getAttributeIcon(attribute: string, attributeList: IInputList[], valid?: boolean): HTMLImageElement;
|
|
14
|
+
/**
|
|
15
|
+
* 获取正则校验的string
|
|
16
|
+
* @param textCheckType
|
|
17
|
+
* @param customFormat
|
|
18
|
+
*/
|
|
19
|
+
static checkString(textCheckType: number, customFormat: string): string;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param value 检测的值
|
|
23
|
+
* @param checkString RegExp string
|
|
24
|
+
*/
|
|
25
|
+
static checkTextAttibute(value: string | undefined, checkStrings: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* 获取属性标注显示的数据
|
|
28
|
+
* @param attribute
|
|
29
|
+
* @param attributeList
|
|
30
|
+
* @returns {string} 标注属性
|
|
31
|
+
*/
|
|
32
|
+
static getAttributeShowText(attribute: string | undefined, attributeList?: IInputList[]): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* 获取属性标注的索引
|
|
35
|
+
* @param attribute
|
|
36
|
+
* @param attributeList
|
|
37
|
+
* @returns {number} 属性索引
|
|
38
|
+
*/
|
|
39
|
+
static getAttributeIndex(attribute: string | undefined, attributeList: IInputList[]): number;
|
|
40
|
+
/**
|
|
41
|
+
* 获取属性标注的索引
|
|
42
|
+
* @param attribute
|
|
43
|
+
* @param attributeList
|
|
44
|
+
* @returns {string} 颜色hex值
|
|
45
|
+
*/
|
|
46
|
+
static getAttributeColor(attribute: string | undefined, attributeList: IInputList[]): string;
|
|
47
|
+
/**
|
|
48
|
+
* 文本标注:自动获取下一个序号(取当前数据的最大值 + 1)
|
|
49
|
+
* @param toolResultList 工具的结果集
|
|
50
|
+
* @param textCheckType
|
|
51
|
+
*/
|
|
52
|
+
static getTextAttribute(toolResultList: IRect[] | IPolygonData[] | IPoint[] | ILine[], textCheckType: number): string;
|
|
53
|
+
/**
|
|
54
|
+
* 更改数据的textAttribute
|
|
55
|
+
* @param value
|
|
56
|
+
* @param selectedID 工具中选中数据的ID
|
|
57
|
+
* @param toolList 工具的结果集
|
|
58
|
+
*/
|
|
59
|
+
static textChange(value: string | undefined, selectedID: string, toolList: any[]): any[];
|
|
60
|
+
/**
|
|
61
|
+
* 获取错误提示的文案
|
|
62
|
+
* @param textCheckType
|
|
63
|
+
*/
|
|
64
|
+
static getErrorNotice(textCheckType: number, lang: ELang): string;
|
|
65
|
+
static textAttributeValidate(textCheckType: number, customFormat: string, text: string): boolean | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* 检查结果的文本标注数据是否可以通过
|
|
68
|
+
* @param textCheckType
|
|
69
|
+
* @param customFormat
|
|
70
|
+
* @param resultList 需要检查的结果集
|
|
71
|
+
*/
|
|
72
|
+
static checkTextAttribute(textCheckType: ETextType, customFormat: string, resultList: any[], selectedID?: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* 改变文本标注后 修改全部的LOG
|
|
75
|
+
* @param toolLog LOG数据
|
|
76
|
+
* @param toolList 工具的数据集
|
|
77
|
+
*/
|
|
78
|
+
static changeTextAttributeInLog(toolLog: any[][], toolList: any[]): any[][];
|
|
79
|
+
static getTextIconSvg(attribute: string | undefined, attributeList: IInputList[], attributeConfigurable: boolean | undefined, baseIcon: any): any;
|
|
80
|
+
/**
|
|
81
|
+
* 根据keycode返回attribute, 没有匹配到时为undefined
|
|
82
|
+
* @param keyCode
|
|
83
|
+
* @param attributeList
|
|
84
|
+
* @returns {undefined|string} 没有匹配到时为undefined
|
|
85
|
+
*/
|
|
86
|
+
static getAttributeByKeycode(keyCode: number, attributeList: IInputList[]): string | undefined;
|
|
87
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { IPolygonPoint, IPolygonData, IPolygonConfig } from '../../types/tool/polygon';
|
|
2
|
+
import { EToolName, ELineTypes } from '@/constant/tool';
|
|
3
|
+
export default class AxisUtils {
|
|
4
|
+
/**
|
|
5
|
+
* 获取原图坐标下,相对当前图片的偏移值
|
|
6
|
+
* @param coordinate
|
|
7
|
+
* @param currentPos
|
|
8
|
+
* @param zoom
|
|
9
|
+
*/
|
|
10
|
+
static getOffsetCoordinate(coordinate: ICoordinate, currentPos: ICoordinate, zoom: number): {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
static changeDrawOutsideTarget(coord: ICoordinate, currentPos: ICoordinate, imgInfo: ISize, drawOutsideTarget?: boolean, basicResult?: IRect, zoom?: number): ICoordinate;
|
|
15
|
+
static changeCoordinateByRotate(coordinate: ICoordinate, rotate: number, imgSize: ISize): ICoordinate;
|
|
16
|
+
/**
|
|
17
|
+
* 计算点在 zoom 和 currentPos 的转换
|
|
18
|
+
* @param rect
|
|
19
|
+
* @param zoom
|
|
20
|
+
* @param currentPos
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
static changeRectByZoom(rect: IRect, zoom: number, currentPos?: ICoordinate): {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
id: string;
|
|
29
|
+
sourceID: string;
|
|
30
|
+
valid: boolean;
|
|
31
|
+
order?: number | undefined;
|
|
32
|
+
attribute: string;
|
|
33
|
+
textAttribute: string;
|
|
34
|
+
disableDelete?: boolean | undefined;
|
|
35
|
+
label?: string | undefined;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 计算点在 zoom 和 currentPos 的转换
|
|
39
|
+
* @param point
|
|
40
|
+
* @param zoom
|
|
41
|
+
* @param currentPos
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
static changePointByZoom(point: IPoint | IPolygonPoint, zoom: number, currentPos?: ICoordinate): {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
specialPoint?: boolean | undefined;
|
|
48
|
+
specialEdge?: boolean | undefined;
|
|
49
|
+
} | {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* 计算点集在 zoom 和 currentPos 的转换
|
|
55
|
+
* @param pointList
|
|
56
|
+
* @param zoom
|
|
57
|
+
* @param currentPos
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
static changePointListByZoom(pointList: IPoint[] | IPolygonPoint[], zoom: number, currentPos?: ICoordinate): ({
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
specialPoint?: boolean | undefined;
|
|
64
|
+
specialEdge?: boolean | undefined;
|
|
65
|
+
} | {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
})[];
|
|
69
|
+
/**
|
|
70
|
+
* 扩大点的热区范围
|
|
71
|
+
* @param axis
|
|
72
|
+
* @param radius
|
|
73
|
+
* @returns
|
|
74
|
+
*/
|
|
75
|
+
static axisArea(axis: ICoordinate, radius?: number): {
|
|
76
|
+
x: number;
|
|
77
|
+
y: number;
|
|
78
|
+
}[];
|
|
79
|
+
/**
|
|
80
|
+
* 计算当前坐标相对于原图的坐标
|
|
81
|
+
* @param coord 在 canvas 内的相对坐标
|
|
82
|
+
*/
|
|
83
|
+
static getOriginCoordinateWithOffsetCoordinate(coord: ICoordinate, zoom?: number, currentPos?: {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
}): {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* 获取当前坐标是否在当前点
|
|
92
|
+
* 注意:checkPoint 为原图的坐标
|
|
93
|
+
*
|
|
94
|
+
* @export
|
|
95
|
+
* @param {IPolygonPoint} checkPoint
|
|
96
|
+
* @param {IPolygonPoint[]} polygonPoints
|
|
97
|
+
* @param {number} [scope=3]
|
|
98
|
+
* @returns {number}
|
|
99
|
+
*/
|
|
100
|
+
static returnClosePointIndex(checkPoint: IPolygonPoint, polygonPoints: IPolygonPoint[], scope?: number): number;
|
|
101
|
+
/**
|
|
102
|
+
* 对比两个点是否在一范围内
|
|
103
|
+
*
|
|
104
|
+
* @export
|
|
105
|
+
* @param {IPolygonPoint} currentCoord
|
|
106
|
+
* @param {IPolygonPoint} targetCoord
|
|
107
|
+
* @param {number} scope
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
110
|
+
static getIsInScope(currentCoord: ICoordinate, targetCoord: ICoordinate, scope: number): boolean;
|
|
111
|
+
}
|
|
112
|
+
export declare class CoordinateUtils {
|
|
113
|
+
private currentPos;
|
|
114
|
+
private zoom;
|
|
115
|
+
private basicImgInfo;
|
|
116
|
+
private basicResult?;
|
|
117
|
+
private dependToolConfig?;
|
|
118
|
+
private dependToolName;
|
|
119
|
+
constructor(props: any);
|
|
120
|
+
get isDependPolygon(): boolean;
|
|
121
|
+
get isDependRect(): boolean;
|
|
122
|
+
get isDependOriginalImage(): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* 渲染坐标 => 绝对坐标
|
|
125
|
+
* @param renderCoordinate
|
|
126
|
+
*/
|
|
127
|
+
getAbsCoord(renderCoord: ICoordinate): {
|
|
128
|
+
x: number;
|
|
129
|
+
y: number;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* 绝对坐标 => 渲染坐标
|
|
133
|
+
* @param absoluteCoordinate
|
|
134
|
+
*/
|
|
135
|
+
getRenderCoord(absCoord: ICoordinate): {
|
|
136
|
+
x: number;
|
|
137
|
+
y: number;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* 在矩形内的点
|
|
141
|
+
* @param absCoord
|
|
142
|
+
* @param rect
|
|
143
|
+
*/
|
|
144
|
+
coordInsideRect(absCoord: ICoordinate, rect: {
|
|
145
|
+
x: number;
|
|
146
|
+
y: number;
|
|
147
|
+
height: number;
|
|
148
|
+
width: number;
|
|
149
|
+
}): {
|
|
150
|
+
x: number;
|
|
151
|
+
y: number;
|
|
152
|
+
};
|
|
153
|
+
getPolygonPointList(lineType: ELineTypes, pointList: IPoint[]): any[];
|
|
154
|
+
/**
|
|
155
|
+
* 计算线段与线段的交点
|
|
156
|
+
* @param curCoord
|
|
157
|
+
* @param preCoord
|
|
158
|
+
* @param polygonPointListToLineList
|
|
159
|
+
*/
|
|
160
|
+
getIntersection(curCoord: ICoordinate, preCoord: ICoordinate, polygonPointListToLineList: IPoint[]): {
|
|
161
|
+
point: ICoordinate;
|
|
162
|
+
minDistance?: undefined;
|
|
163
|
+
} | {
|
|
164
|
+
point: IPoint;
|
|
165
|
+
minDistance: number;
|
|
166
|
+
} | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* 在多边形内的点
|
|
169
|
+
* @param absCoord
|
|
170
|
+
* @param rect
|
|
171
|
+
*/
|
|
172
|
+
coordInsidePolygon(curCoord: ICoordinate, preCoord: ICoordinate, polygon: IPolygonData, polygonToolConfig: IPolygonConfig): ICoordinate;
|
|
173
|
+
coordInsideImage(coord: ICoordinate): {
|
|
174
|
+
x: number;
|
|
175
|
+
y: number;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* 根据依赖工具计算下一个点的绝对坐标
|
|
179
|
+
* @param curAbsCoord
|
|
180
|
+
* @param preAbsCoord
|
|
181
|
+
*/
|
|
182
|
+
getNextCoordByDependTool(curAbsCoord: ICoordinate, preAbsCoord: ICoordinate): ICoordinate | undefined;
|
|
183
|
+
setDependInfo(dependToolName: EToolName | '', dependToolConfig?: IRectConfig | IPolygonConfig): void;
|
|
184
|
+
setBasicImgInfo(basicImgInfo: any): void;
|
|
185
|
+
setBasicResult(basicResult: any): void;
|
|
186
|
+
setZoomAndCurrentPos(zoom: number, currentPos: ICoordinate): void;
|
|
187
|
+
isCoordInsideTarget(coord: ICoordinate): boolean;
|
|
188
|
+
isInBasicPolygon(coord: ICoordinate): boolean;
|
|
189
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export default class CanvasUtils {
|
|
2
|
+
static getMousePositionOnCanvasFromEvent(event: MouseEvent, canvas: HTMLCanvasElement): {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
} | null;
|
|
6
|
+
static getClientRect(canvas: HTMLCanvasElement): {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
} | null;
|
|
12
|
+
static getSize(canvas: HTMLCanvasElement): {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
} | null;
|
|
16
|
+
/**
|
|
17
|
+
* 点在视野内
|
|
18
|
+
* @param coord
|
|
19
|
+
* @param viewPort
|
|
20
|
+
*/
|
|
21
|
+
static inViewPort(coord: ICoordinate | undefined, viewPort: {
|
|
22
|
+
top: number;
|
|
23
|
+
bottom: number;
|
|
24
|
+
left: number;
|
|
25
|
+
right: number;
|
|
26
|
+
}): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 计算视野边界点
|
|
29
|
+
* @param canvas
|
|
30
|
+
* @param originOffset
|
|
31
|
+
* @param zoom
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
static getViewPort: (canvas: HTMLCanvasElement | ISize, originOffset: ICoordinate, zoom: number) => {
|
|
35
|
+
top: number;
|
|
36
|
+
bottom: number;
|
|
37
|
+
left: number;
|
|
38
|
+
right: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { IPolygonPoint } from '../../types/tool/polygon';
|
|
2
|
+
import { ESortDirection } from '../../constant/annotation';
|
|
3
|
+
import { ECheckModel, EToolName } from '@/constant/tool';
|
|
4
|
+
import CheckOperation from '../../core/toolOperation/checkOperation';
|
|
5
|
+
import PolygonOperation from '../../core/toolOperation/polygonOperation';
|
|
6
|
+
import RectOperationAsNewName from '../../core/toolOperation/rectOperation';
|
|
7
|
+
import TagOperation from '../../core/toolOperation/tagOperation';
|
|
8
|
+
import LineToolOperation from '../../core/toolOperation/LineToolOperation';
|
|
9
|
+
import PointOperation from '../../core/toolOperation/pointOperation';
|
|
10
|
+
import TextToolOperation from '../../core/toolOperation/TextToolOperation';
|
|
11
|
+
declare type point = {
|
|
12
|
+
id: string;
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
export default class CommonToolUtils {
|
|
17
|
+
/**
|
|
18
|
+
* 找到指定步骤的数据
|
|
19
|
+
* @param step 获取的步骤
|
|
20
|
+
* @param stepList 步骤列表
|
|
21
|
+
* @returns 步骤配置
|
|
22
|
+
*/
|
|
23
|
+
static getStepInfo(step: number, stepList: IStepInfo[]): IStepInfo;
|
|
24
|
+
/**
|
|
25
|
+
* 获取当前步骤的步骤配置信息,用于当前标注配置的获取
|
|
26
|
+
* 注意: 需要与 getStepInfo 区分,因为 getStepInfo 拿取的是直接的步骤信息
|
|
27
|
+
* @export
|
|
28
|
+
* @param {number} currentStep
|
|
29
|
+
* @param {IStepInfo[]} stepList
|
|
30
|
+
* @returns {*}
|
|
31
|
+
*/
|
|
32
|
+
static getCurrentStepInfo(currentStep: number, stepList: IStepInfo[]): any;
|
|
33
|
+
static jsonParser: (content: any, defaultValue?: any) => any;
|
|
34
|
+
/**
|
|
35
|
+
* 获取结果中最大的order
|
|
36
|
+
*
|
|
37
|
+
* @export
|
|
38
|
+
* @param {any[]} result
|
|
39
|
+
* @returns {number}
|
|
40
|
+
*/
|
|
41
|
+
static getMaxOrder(result: any[]): number;
|
|
42
|
+
/**
|
|
43
|
+
* 表单控件控件判断 返回 Boolean
|
|
44
|
+
* hotkey is effective only whene filter return true
|
|
45
|
+
* @param event
|
|
46
|
+
* @returns {boolean}
|
|
47
|
+
*/
|
|
48
|
+
static hotkeyFilter(event: any): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* 筛选当前的步骤配置
|
|
51
|
+
* @param toolName
|
|
52
|
+
*/
|
|
53
|
+
static getCurrentOperation(toolName: EToolName | ECheckModel): typeof CheckOperation | typeof PolygonOperation | typeof TagOperation | typeof LineToolOperation | typeof PointOperation | typeof TextToolOperation | typeof RectOperationAsNewName;
|
|
54
|
+
static getNextSelectedRectID(rectList: point[], sort?: ESortDirection, selectedID?: string): point;
|
|
55
|
+
static getNextSelectedRectIDByEvent(pointList: point[], event: KeyboardEvent, selectedID?: string): point;
|
|
56
|
+
/**
|
|
57
|
+
* 计算当前状态下需要展示的结果集合
|
|
58
|
+
* @param T 当前图片的结果框
|
|
59
|
+
* @param sourceID 当前状态依赖的框体,若依赖原图则返回 '0'
|
|
60
|
+
* @param attributeLockList 当前展示的属性
|
|
61
|
+
* @param selectedID 是否含有选中逻辑
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
static getRenderResultList<T = any>(resultList: any[], sourceID: string, attributeLockList?: string[], selectedID?: string): [T[], T | undefined];
|
|
65
|
+
/**
|
|
66
|
+
* 获取当前依赖情况下的 sourceID 提取
|
|
67
|
+
*/
|
|
68
|
+
static getSourceID(basicResult?: any): any;
|
|
69
|
+
/**
|
|
70
|
+
* 获取当前点集的所有线条
|
|
71
|
+
* @param pointList
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
static findAllLine(pointList: IPolygonPoint[] | point[]): {
|
|
75
|
+
point1: IPolygonPoint | point;
|
|
76
|
+
point2: IPolygonPoint | point;
|
|
77
|
+
pointIndex: number;
|
|
78
|
+
}[];
|
|
79
|
+
/**
|
|
80
|
+
* 转换当前依赖 sourceID
|
|
81
|
+
* @param sourceID
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
static translateSourceID(sourceID: string | number | undefined): string | number;
|
|
85
|
+
/**
|
|
86
|
+
* 兼容判断 sourceID 为 空字符串、不存在、数字的情况
|
|
87
|
+
* @param sourceA
|
|
88
|
+
* @param sourceB
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
static isDifferSourceID(sourceIDA: string | number, sourceIDB: string | number): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* 兼容判断是否为相同类型的 sourceID
|
|
94
|
+
* @param sourceIDA
|
|
95
|
+
* @param sourceIDB
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
static isSameSourceID(sourceIDA: string | number | undefined, sourceIDB: string | number | undefined): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* 获取下一个列表标记的值和位置
|
|
101
|
+
* @param resultList
|
|
102
|
+
* @param markerList
|
|
103
|
+
* @param markerIndex
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
static getNextMarker(resultList: IRect[], markerList?: IInputList[], markerIndex?: number): {
|
|
107
|
+
label: string;
|
|
108
|
+
index: number;
|
|
109
|
+
} | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* 获取当前值在列表标注的位置
|
|
112
|
+
* @param label
|
|
113
|
+
* @param markerList
|
|
114
|
+
* @returns
|
|
115
|
+
*/
|
|
116
|
+
static getCurrentMarkerIndex(label: string, markerList?: IInputList[]): number;
|
|
117
|
+
}
|
|
118
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
declare class DblClickEventListener {
|
|
2
|
+
private dom;
|
|
3
|
+
private setTimeFun?;
|
|
4
|
+
private clickCoord;
|
|
5
|
+
private isDoubleClick;
|
|
6
|
+
private rcTime;
|
|
7
|
+
private delay;
|
|
8
|
+
private mouseUp;
|
|
9
|
+
private mouseMove;
|
|
10
|
+
private dblclick;
|
|
11
|
+
private cacheFunction;
|
|
12
|
+
private mouseDownTime;
|
|
13
|
+
constructor(dom: HTMLElement, delay: number);
|
|
14
|
+
getRcTime(): number;
|
|
15
|
+
/**
|
|
16
|
+
* 获取当前的坐标,用于点击位置的快速获取
|
|
17
|
+
*
|
|
18
|
+
* @param {MouseEvent} e
|
|
19
|
+
* @returns
|
|
20
|
+
* @memberof DblClickEventListen
|
|
21
|
+
*/
|
|
22
|
+
getCoord(e: MouseEvent): {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* 删除绑定事件
|
|
28
|
+
*
|
|
29
|
+
* @returns
|
|
30
|
+
* @memberof DblClickEventListen
|
|
31
|
+
*/
|
|
32
|
+
removeEvent(): void;
|
|
33
|
+
onMouseDown: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* 用于添加鼠标单击事件, 左键双击事件,右键双击事件
|
|
36
|
+
*
|
|
37
|
+
* @param {*} singleClickFun
|
|
38
|
+
* @param {*} leftDblClick
|
|
39
|
+
* @param {*} rightDblClick
|
|
40
|
+
* @param {*} isAllowDouble 是否允许执行 double click,如果为 true 则进行的延迟,否则将立即执行,增加操作流畅性
|
|
41
|
+
* @returns {void}
|
|
42
|
+
* @memberof DblClickEventListen
|
|
43
|
+
*/
|
|
44
|
+
addEvent(singleClickFun: any, leftDblClick: any, rightDblClick: any, isAllowDouble?: (e: any) => boolean): void;
|
|
45
|
+
clearRightDblClick(): void;
|
|
46
|
+
}
|
|
47
|
+
export default DblClickEventListener;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ELineTypes } from '../../constant/tool';
|
|
2
|
+
import { IPolygonPoint } from '../../types/tool/polygon';
|
|
3
|
+
export default class DrawUtils {
|
|
4
|
+
static drawImg: (canvas: HTMLCanvasElement, imgNode: HTMLImageElement, options?: Partial<IOffsetCanvasPosition & {
|
|
5
|
+
imgAttribute: IImageAttribute;
|
|
6
|
+
}>) => void;
|
|
7
|
+
static drawLine(canvas: HTMLCanvasElement, startPoint: IPoint | IPolygonPoint, endPoint: IPoint | IPolygonPoint, options?: Partial<{
|
|
8
|
+
color: string;
|
|
9
|
+
thickness: number;
|
|
10
|
+
lineCap: CanvasLineCap;
|
|
11
|
+
}>): void;
|
|
12
|
+
/**
|
|
13
|
+
* 查看绘制拉框
|
|
14
|
+
* @param canvas
|
|
15
|
+
* @param rect
|
|
16
|
+
* @param options
|
|
17
|
+
*/
|
|
18
|
+
static drawRect(canvas: HTMLCanvasElement, rect: IRect, options?: Partial<{
|
|
19
|
+
color: string;
|
|
20
|
+
thickness: number;
|
|
21
|
+
lineCap: CanvasLineCap;
|
|
22
|
+
}>): void;
|
|
23
|
+
/**
|
|
24
|
+
* 填充矩形框的绘制
|
|
25
|
+
* @param canvas
|
|
26
|
+
* @param rect
|
|
27
|
+
* @param options
|
|
28
|
+
*/
|
|
29
|
+
static drawRectWithFill(canvas: HTMLCanvasElement, rect: IRect, options?: Partial<{
|
|
30
|
+
color: string;
|
|
31
|
+
}>): void;
|
|
32
|
+
static drawTag(canvas: HTMLCanvasElement, tagList: {
|
|
33
|
+
keyName: string;
|
|
34
|
+
value: string[];
|
|
35
|
+
}[]): void;
|
|
36
|
+
/**
|
|
37
|
+
* 绘制点击线条
|
|
38
|
+
* @param canvas
|
|
39
|
+
* @param pointList
|
|
40
|
+
* @param options
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
static drawLineWithPointList(canvas: HTMLCanvasElement, pointList: IPoint[] | IPolygonPoint[], options?: Partial<{
|
|
44
|
+
color: string;
|
|
45
|
+
thickness: number;
|
|
46
|
+
lineCap: CanvasLineCap;
|
|
47
|
+
lineType: ELineTypes;
|
|
48
|
+
hoverEdgeIndex: number;
|
|
49
|
+
}>): void;
|
|
50
|
+
static drawCircle(canvas: HTMLCanvasElement, anchorPoint: IPoint, radius: number, options?: Partial<{
|
|
51
|
+
startAngleDeg: number;
|
|
52
|
+
endAngleDeg: number;
|
|
53
|
+
thickness: number;
|
|
54
|
+
color: string;
|
|
55
|
+
fill: string;
|
|
56
|
+
}>): void;
|
|
57
|
+
static drawCircleWithFill(canvas: HTMLCanvasElement, anchorPoint: IPoint, radius?: number, options?: Partial<{
|
|
58
|
+
color: string;
|
|
59
|
+
}>): void;
|
|
60
|
+
static drawPolygon(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{
|
|
61
|
+
color: string;
|
|
62
|
+
thickness: number;
|
|
63
|
+
lineCap: CanvasLineCap;
|
|
64
|
+
isClose: boolean;
|
|
65
|
+
lineType: ELineTypes;
|
|
66
|
+
}>): void;
|
|
67
|
+
static drawPolygonWithFill(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{
|
|
68
|
+
color: string;
|
|
69
|
+
lineType: ELineTypes;
|
|
70
|
+
}>): void;
|
|
71
|
+
static drawPolygonWithFillAndLine(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{
|
|
72
|
+
strokeColor: string;
|
|
73
|
+
fillColor: string;
|
|
74
|
+
pointColor: string;
|
|
75
|
+
thickness: number;
|
|
76
|
+
lineCap: CanvasLineCap;
|
|
77
|
+
isClose: boolean;
|
|
78
|
+
lineType: ELineTypes;
|
|
79
|
+
}>): void;
|
|
80
|
+
static drawSelectedPolygonWithFillAndLine(canvas: HTMLCanvasElement, pointList: IPolygonPoint[], options?: Partial<{
|
|
81
|
+
strokeColor: string;
|
|
82
|
+
fillColor: string;
|
|
83
|
+
pointColor: string;
|
|
84
|
+
thickness: number;
|
|
85
|
+
lineCap: CanvasLineCap;
|
|
86
|
+
isClose: boolean;
|
|
87
|
+
lineType: ELineTypes;
|
|
88
|
+
}>): void;
|
|
89
|
+
static drawText(canvas: HTMLCanvasElement, startPoint: IPoint | IPolygonPoint, text: string, options?: Partial<{
|
|
90
|
+
color: string;
|
|
91
|
+
font: string;
|
|
92
|
+
shadowColor: string;
|
|
93
|
+
shadowOffsetX: number;
|
|
94
|
+
shadowOffsetY: number;
|
|
95
|
+
shadowBlur: number;
|
|
96
|
+
textMaxWidth: number;
|
|
97
|
+
offsetX: number;
|
|
98
|
+
offsetY: number;
|
|
99
|
+
textAlign: 'start' | 'center' | 'end' | 'left' | 'right';
|
|
100
|
+
}>): void;
|
|
101
|
+
static wrapText(canvas: HTMLCanvasElement, text: string, x: number, y: number, maxWidth?: number, lineHeight?: number): void;
|
|
102
|
+
/**
|
|
103
|
+
* 绘制箭头
|
|
104
|
+
* @param ctx
|
|
105
|
+
* @param startPoint
|
|
106
|
+
* @param endPoint
|
|
107
|
+
* @param options
|
|
108
|
+
*/
|
|
109
|
+
static drawArrow(ctx: CanvasRenderingContext2D, startPoint: IPoint | IPolygonPoint, endPoint: IPoint | IPolygonPoint, options?: Partial<{
|
|
110
|
+
color: string;
|
|
111
|
+
thickness: number;
|
|
112
|
+
lineCap: CanvasLineCap;
|
|
113
|
+
theta: number;
|
|
114
|
+
headLen: number;
|
|
115
|
+
ctx: CanvasRenderingContext2D;
|
|
116
|
+
}>): void;
|
|
117
|
+
}
|
|
@@ -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
|
+
}
|