@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.
Files changed (50) hide show
  1. package/README.md +143 -0
  2. package/dist/index.js +76 -0
  3. package/dist/types/constant/annotation.d.ts +63 -0
  4. package/dist/types/constant/annotationTask.d.ts +16 -0
  5. package/dist/types/constant/defaultConfig.d.ts +259 -0
  6. package/dist/types/constant/keyCode.d.ts +32 -0
  7. package/dist/types/constant/style.d.ts +43 -0
  8. package/dist/types/constant/tool.d.ts +161 -0
  9. package/dist/types/core/index.d.ts +74 -0
  10. package/dist/types/core/toolOperation/LineToolOperation.d.ts +419 -0
  11. package/dist/types/core/toolOperation/TextToolOperation.d.ts +41 -0
  12. package/dist/types/core/toolOperation/ViewOperation.d.ts +55 -0
  13. package/dist/types/core/toolOperation/basicToolOperation.d.ts +188 -0
  14. package/dist/types/core/toolOperation/checkOperation.d.ts +37 -0
  15. package/dist/types/core/toolOperation/eventListener.d.ts +33 -0
  16. package/dist/types/core/toolOperation/measureOperation.d.ts +8 -0
  17. package/dist/types/core/toolOperation/pointOperation.d.ts +85 -0
  18. package/dist/types/core/toolOperation/polygonOperation.d.ts +134 -0
  19. package/dist/types/core/toolOperation/rectOperation.d.ts +141 -0
  20. package/dist/types/core/toolOperation/tagOperation.d.ts +44 -0
  21. package/dist/types/core/toolOperation/textAttributeClass.d.ts +56 -0
  22. package/dist/types/index.d.ts +26 -0
  23. package/dist/types/locales/constants.d.ts +15 -0
  24. package/dist/types/locales/en_US/message.d.ts +2 -0
  25. package/dist/types/locales/index.d.ts +4 -0
  26. package/dist/types/locales/zh_CN/message.d.ts +2 -0
  27. package/dist/types/utils/ActionsHistory.d.ts +32 -0
  28. package/dist/types/utils/EventBus.d.ts +40 -0
  29. package/dist/types/utils/ImgUtils.d.ts +3 -0
  30. package/dist/types/utils/MathUtils.d.ts +43 -0
  31. package/dist/types/utils/tool/AttributeUtils.d.ts +87 -0
  32. package/dist/types/utils/tool/AxisUtils.d.ts +189 -0
  33. package/dist/types/utils/tool/CanvasUtils.d.ts +40 -0
  34. package/dist/types/utils/tool/CommonToolUtils.d.ts +118 -0
  35. package/dist/types/utils/tool/DblClickEventListener.d.ts +47 -0
  36. package/dist/types/utils/tool/DrawUtils.d.ts +117 -0
  37. package/dist/types/utils/tool/ImgPosUtils.d.ts +34 -0
  38. package/dist/types/utils/tool/LineToolUtils.d.ts +105 -0
  39. package/dist/types/utils/tool/MarkerUtils.d.ts +9 -0
  40. package/dist/types/utils/tool/PolygonUtils.d.ts +60 -0
  41. package/dist/types/utils/tool/RectUtils.d.ts +69 -0
  42. package/dist/types/utils/tool/RenderDomUtils.d.ts +3 -0
  43. package/dist/types/utils/tool/StyleUtils.d.ts +9 -0
  44. package/dist/types/utils/tool/TagUtils.d.ts +54 -0
  45. package/dist/types/utils/tool/UnitUtils.d.ts +4 -0
  46. package/dist/types/utils/tool/ZoomUtils.d.ts +16 -0
  47. package/dist/types/utils/tool/polygonTool.d.ts +32 -0
  48. package/dist/types/utils/uuid.d.ts +1 -0
  49. package/es/index.js +76 -0
  50. package/package.json +96 -0
@@ -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,9 @@
1
+ export default class MarkerUtils {
2
+ /**
3
+ * 获取列表标注的显示的数据
4
+ * @param marker
5
+ * @param markerList
6
+ * @returns
7
+ */
8
+ static getMarkerShowText(marker: string | undefined, markerList?: IInputList[]): string | undefined;
9
+ }
@@ -0,0 +1,60 @@
1
+ import { IPolygonData, IPolygonPoint } from '../../types/tool/polygon';
2
+ import { ELineTypes } from '../../constant/tool';
3
+ export default class PolygonUtils {
4
+ static getHoverPolygonID(checkPoint: IPolygonPoint, polygonPoints: IPolygonData[], scope?: number, lineType?: ELineTypes): string;
5
+ /**
6
+ * 计算多边形面积(Shoelace Theorem,鞋带定理)
7
+ * @param pointList
8
+ * @returns
9
+ */
10
+ static calcPolygonSize(pointList?: IPolygonPoint[]): number;
11
+ static isInPolygon(checkPoint: IPolygonPoint, polygonPoints: IPolygonPoint[], lineType?: ELineTypes): boolean;
12
+ /**
13
+ * 通过数据转换为平滑曲线的点提交 [{x: number, y: number}...] => [x, ...smoothCurvePoints ,y]
14
+ * @param pointList
15
+ * @returns {Array<number>}
16
+ */
17
+ static createSmoothCurvePointsFromPointList(pointList: Array<{
18
+ x: number;
19
+ y: number;
20
+ }>, numberOfSegments?: number): any[];
21
+ static createSmoothCurvePoints(points: any[], tension?: number, closed?: boolean, numberOfSegments?: number): any[];
22
+ /**
23
+ * 获取当前 id 的多边形
24
+ * @param polygonList
25
+ * @param id
26
+ * @returns
27
+ */
28
+ static getPolygonByID(polygonList: IPolygonData[], id?: string): IPolygonData | undefined;
29
+ static getHoverEdgeIndex(checkPoint: ICoordinate, pointList: IPolygonPoint[], lineType?: ELineTypes, scope?: number): number;
30
+ /**
31
+ * 用于边缘吸附,获取最接近的边
32
+ * @param coord
33
+ * @param polygonList
34
+ * @param lineType
35
+ * @param range
36
+ * @returns
37
+ */
38
+ static getClosestPoint(coordinate: ICoordinate, polygonList: IPolygonData[], lineType?: ELineTypes, range?: number): {
39
+ dropFoot: ICoordinate;
40
+ closestEdgeIndex: number;
41
+ closestPolygonID: string;
42
+ };
43
+ /**
44
+ * 点集是否在多边形内
45
+ * @param pointList
46
+ * @param polygonPoints
47
+ * @param lineType
48
+ */
49
+ static isPointListInPolygon(pointList: IPolygonPoint[], polygonPoints: IPolygonPoint[], lineType?: ELineTypes): boolean;
50
+ /**
51
+ * 点集是否在多边形外
52
+ */
53
+ static isPointListOutSidePolygon(pointList: IPolygonPoint[], polygonPoints: IPolygonPoint[], lineType?: ELineTypes): boolean;
54
+ /**
55
+ * 获取多边形面积
56
+ * @param pointList
57
+ * @returns
58
+ */
59
+ static getPolygonArea(pointList: IPolygonPoint[]): number;
60
+ }
@@ -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,3 @@
1
+ export default class RenderDomUtils {
2
+ static renderInvalidPage(canvas: HTMLCanvasElement, container: HTMLElement, lang: string): HTMLDivElement;
3
+ }
@@ -0,0 +1,9 @@
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
+ }
@@ -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
+ }
@@ -0,0 +1,16 @@
1
+ import { EGrowthMode } from '../../constant/annotation';
2
+ export default class ZoomUtils {
3
+ static zoomChanged: (zoom: number, isZoomIn: boolean, growthMode?: EGrowthMode) => number;
4
+ static wheelChangePos: (imgNode: HTMLImageElement, coord: ICoordinate, operator: 1 | -1 | 0, oldCurrentPos: ICoordinate, options?: Partial<{
5
+ zoom: number;
6
+ innerZoom: number;
7
+ basicZoom: number;
8
+ zoomMax: number;
9
+ rotate: number;
10
+ }>) => {
11
+ currentPos: ICoordinate;
12
+ zoom: number;
13
+ imgInfo: ISize;
14
+ ratio: number;
15
+ } | null;
16
+ }
@@ -0,0 +1,32 @@
1
+ import { ELineTypes } from '../../constant/tool';
2
+ import { IPolygonPoint } from '../../types/tool/polygon';
3
+ export declare function createSmoothCurvePoints(points: any[], tension?: number, closed?: boolean, numberOfSegments?: number): any[];
4
+ /**
5
+ * 通过数据转换为平滑曲线的点提交 [{x: number, y: number}...] => [x, ...smoothCurvePoints ,y]
6
+ * @param pointList
7
+ * @returns {Array<number>}
8
+ */
9
+ export declare const createSmoothCurvePointsFromPointList: (pointList: Array<{
10
+ x: number;
11
+ y: number;
12
+ }>, numberOfSegments?: number) => any[];
13
+ /**
14
+ * 获取当前的坐标是否在多边形内
15
+ *
16
+ * @export
17
+ * @param {IPolygonPoint} checkPoint
18
+ * @param {IPolygonPoint[]} polygonPoints
19
+ * @returns {boolean}
20
+ */
21
+ export declare function isInPolygon(checkPoint: IPolygonPoint, polygonPoints: IPolygonPoint[], lineType?: ELineTypes): boolean;
22
+ /**
23
+ * 获取当 zoom 更改后的 pointList
24
+ * @param pointList
25
+ * @param zoom
26
+ */
27
+ export declare function getPolygonPointUnderZoom(pointList: IPolygonPoint[], zoom?: number): {
28
+ x: number;
29
+ y: number;
30
+ specialPoint?: boolean | undefined;
31
+ specialEdge?: boolean | undefined;
32
+ }[];
@@ -0,0 +1 @@
1
+ export default function uuid(len?: number, radix?: number): string;