@labelbee/lb-annotation 1.5.5-alpha.2 → 1.5.7
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/dist/index.js +7 -7
- package/dist/types/constant/annotation.d.ts +7 -0
- package/dist/types/constant/tool.d.ts +7 -0
- package/dist/types/core/toolOperation/basicToolOperation.d.ts +11 -1
- package/dist/types/core/toolOperation/pointOperation.d.ts +4 -0
- package/dist/types/core/toolOperation/polygonOperation.d.ts +13 -1
- package/dist/types/locales/constants.d.ts +3 -1
- package/dist/types/utils/MathUtils.d.ts +80 -0
- package/dist/types/utils/tool/CommonToolUtils.d.ts +1 -1
- package/dist/types/utils/tool/PolygonUtils.d.ts +8 -1
- package/es/index.js +14 -14
- package/package.json +1 -1
|
@@ -162,3 +162,10 @@ export declare const CLIENT_TOOL_NAME: {
|
|
|
162
162
|
/** 曲线分割点数 */
|
|
163
163
|
export declare const SEGMENT_NUMBER = 16;
|
|
164
164
|
export declare const edgeAdsorptionScope = 10;
|
|
165
|
+
/**
|
|
166
|
+
* 多边形的标注模式
|
|
167
|
+
*/
|
|
168
|
+
export declare enum EPolygonPattern {
|
|
169
|
+
Normal = 0,
|
|
170
|
+
Rect = 1
|
|
171
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CoordinateUtils } from '@/utils/tool/AxisUtils';
|
|
2
2
|
import { EToolName } from '@/constant/tool';
|
|
3
|
-
import { IPolygonConfig } from '@/types/tool/polygon';
|
|
3
|
+
import { IPolygonConfig, IPolygonData } from '@/types/tool/polygon';
|
|
4
4
|
import { EDragStatus, EGrowthMode, ELang } from '../../constant/annotation';
|
|
5
5
|
import ActionsHistory from '../../utils/ActionsHistory';
|
|
6
6
|
import DblClickEventListener from '../../utils/tool/DblClickEventListener';
|
|
@@ -19,6 +19,14 @@ interface IBasicToolOperationProps {
|
|
|
19
19
|
showDefaultCursor?: boolean;
|
|
20
20
|
forbidBasicResultRender?: boolean;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* 参考显示数据
|
|
24
|
+
*/
|
|
25
|
+
interface IReferenceData {
|
|
26
|
+
toolName: EToolName.Polygon | EToolName.Line | EToolName.LineMarker;
|
|
27
|
+
result: IPolygonData[] | ILinePoint[];
|
|
28
|
+
config: any;
|
|
29
|
+
}
|
|
22
30
|
declare class BasicToolOperation extends EventListener {
|
|
23
31
|
container: HTMLElement;
|
|
24
32
|
canvas: HTMLCanvasElement;
|
|
@@ -27,6 +35,7 @@ declare class BasicToolOperation extends EventListener {
|
|
|
27
35
|
basicImgInfo: any;
|
|
28
36
|
isImgError: boolean;
|
|
29
37
|
basicResult?: any;
|
|
38
|
+
referenceData?: IReferenceData;
|
|
30
39
|
dependToolName?: EToolName;
|
|
31
40
|
history: ActionsHistory;
|
|
32
41
|
size: ISize;
|
|
@@ -76,6 +85,7 @@ declare class BasicToolOperation extends EventListener {
|
|
|
76
85
|
get hasMarkerConfig(): any;
|
|
77
86
|
setZoom(zoom: number): void;
|
|
78
87
|
setCurrentPos(currentPos: ICoordinate): void;
|
|
88
|
+
setReferenceData(referenceData: IReferenceData): void;
|
|
79
89
|
/**
|
|
80
90
|
* 外界直接更改当前渲染位置
|
|
81
91
|
* @param zoom
|
|
@@ -104,6 +104,10 @@ declare class PointOperation extends BasicToolOperation {
|
|
|
104
104
|
*/
|
|
105
105
|
renderPoint(point: IPointUnit): void;
|
|
106
106
|
renderPointList(): void;
|
|
107
|
+
/**
|
|
108
|
+
* 顶层渲染图标
|
|
109
|
+
*/
|
|
110
|
+
renderTop(): void;
|
|
107
111
|
render(): void;
|
|
108
112
|
}
|
|
109
113
|
export default PointOperation;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ERotateDirection } from '../../constant/annotation';
|
|
2
|
+
import { EPolygonPattern } from '../../constant/tool';
|
|
1
3
|
import { IPolygonConfig, IPolygonData, IPolygonPoint } from '../../types/tool/polygon';
|
|
2
4
|
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
|
|
3
5
|
interface IPolygonOperationProps extends IBasicToolOperationProps {
|
|
@@ -11,6 +13,7 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
11
13
|
hoverEdgeIndex: number;
|
|
12
14
|
selectedID?: string;
|
|
13
15
|
editPolygonID?: string;
|
|
16
|
+
pattern: EPolygonPattern;
|
|
14
17
|
private dragInfo?;
|
|
15
18
|
private drawingHistory;
|
|
16
19
|
private isCtrl;
|
|
@@ -37,10 +40,12 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
37
40
|
order: number;
|
|
38
41
|
textAttribute: string;
|
|
39
42
|
attribute: string;
|
|
43
|
+
isRect?: boolean | undefined;
|
|
40
44
|
}[];
|
|
41
45
|
get selectedText(): string | undefined;
|
|
42
46
|
isAllowDouble: (e: MouseEvent) => boolean;
|
|
43
47
|
get dataList(): IPolygonData[];
|
|
48
|
+
setPattern(pattern: EPolygonPattern): void;
|
|
44
49
|
/**
|
|
45
50
|
* 当前页面展示的框体
|
|
46
51
|
*/
|
|
@@ -66,6 +71,7 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
66
71
|
* @returns
|
|
67
72
|
*/
|
|
68
73
|
setPolygonDataByID(newPolygonData: Partial<IPolygonData>, id?: string): IPolygonData[];
|
|
74
|
+
rotatePolygon(angle?: number, direction?: ERotateDirection, selectedID?: string | undefined): void;
|
|
69
75
|
addPointInDrawing(e: MouseEvent): void;
|
|
70
76
|
clearResult(): void;
|
|
71
77
|
/**
|
|
@@ -85,7 +91,7 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
85
91
|
* 初始化的添加的数据
|
|
86
92
|
* @returns
|
|
87
93
|
*/
|
|
88
|
-
addDrawingPointToPolygonList(): void;
|
|
94
|
+
addDrawingPointToPolygonList(isRect?: boolean): void;
|
|
89
95
|
setSelectedIdAfterAddingDrawing(newID: string): void;
|
|
90
96
|
/**
|
|
91
97
|
* 获取当前 hover 多边形的 ID
|
|
@@ -105,6 +111,12 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
105
111
|
onLeftDblClick(e: MouseEvent): void;
|
|
106
112
|
onRightDblClick(e: MouseEvent): void;
|
|
107
113
|
onMouseDown(e: MouseEvent): true | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* 判断是否在边界外
|
|
116
|
+
* @param selectedPointList
|
|
117
|
+
* @returns
|
|
118
|
+
*/
|
|
119
|
+
isPolygonOutSide(selectedPointList: IPolygonPoint[]): boolean;
|
|
108
120
|
onDragMove(e: MouseEvent): void;
|
|
109
121
|
onMouseMove(e: MouseEvent): void;
|
|
110
122
|
leftMouseUp(e: MouseEvent): void;
|
|
@@ -11,5 +11,7 @@ export declare enum EMessage {
|
|
|
11
11
|
ClearPartialData = "ClearPartialData",
|
|
12
12
|
MarkerFinish = "MarkerFinish",
|
|
13
13
|
LowerLimitPoint = "LowerLimitPoint",
|
|
14
|
-
NoRotateInDependence = "noRotateInDependence"
|
|
14
|
+
NoRotateInDependence = "noRotateInDependence",
|
|
15
|
+
UnableToReannotation = "unableToReannotation",
|
|
16
|
+
ForbiddenCreationOutsideBoundary = "ForbiddenCreationOutsideBoundary"
|
|
15
17
|
}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 各类的数学运算
|
|
3
3
|
*/
|
|
4
|
+
import { IPolygonPoint } from '@/types/tool/polygon';
|
|
5
|
+
/**
|
|
6
|
+
* 基础的三角运算
|
|
7
|
+
*/
|
|
8
|
+
export declare class Trigonometric {
|
|
9
|
+
static tanAPlusB(tanA: number, tanB: number): number;
|
|
10
|
+
static sinAPlusB(sinA: number, cosA: number, sinB: number, cosB: number): number;
|
|
11
|
+
static cosAPlusB(sinA: number, cosA: number, sinB: number, cosB: number): number;
|
|
12
|
+
}
|
|
4
13
|
export default class MathUtils {
|
|
5
14
|
/**
|
|
6
15
|
* 是否在指定范围内
|
|
@@ -68,4 +77,75 @@ export default class MathUtils {
|
|
|
68
77
|
x: number;
|
|
69
78
|
y: number;
|
|
70
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* 获取线条的垂线
|
|
82
|
+
* @param line
|
|
83
|
+
* @returns
|
|
84
|
+
*/
|
|
85
|
+
static getPerpendicularLine(line: ICoordinate[]): ICoordinate[] | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* 获取当前垂直于直线的最后一个点的垂线点
|
|
88
|
+
* @param line
|
|
89
|
+
* @param coordinate
|
|
90
|
+
* @returns
|
|
91
|
+
*/
|
|
92
|
+
static getPerpendicularFootOfLine(line: ICoordinate[], coordinate: ICoordinate): any;
|
|
93
|
+
/**
|
|
94
|
+
* 从正三角形获取正四边形
|
|
95
|
+
* @param triangle
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
static getQuadrangleFromTriangle(triangle: ICoordinate[]): ICoordinate[];
|
|
99
|
+
/**
|
|
100
|
+
* 矩形拖动线,实现横向的扩大缩小
|
|
101
|
+
* @param dragStartCoord
|
|
102
|
+
* @param currentCoord
|
|
103
|
+
* @param basicLine
|
|
104
|
+
* @returns
|
|
105
|
+
*/
|
|
106
|
+
static getRectPerpendicularOffset(dragStartCoord: ICoordinate, currentCoord: ICoordinate, basicLine: [ICoordinate, ICoordinate]): {
|
|
107
|
+
x: number;
|
|
108
|
+
y: number;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* 获取当前真实 Index
|
|
112
|
+
* @param index
|
|
113
|
+
* @param len
|
|
114
|
+
* @returns
|
|
115
|
+
*/
|
|
116
|
+
static getArrayIndex(index: number, len: number): number;
|
|
117
|
+
/**
|
|
118
|
+
* 在矩形点集拖动一个点时,需要进行一直维持矩形
|
|
119
|
+
* @param pointList
|
|
120
|
+
* @param changePointIndex
|
|
121
|
+
* @param offset
|
|
122
|
+
* @returns
|
|
123
|
+
*/
|
|
124
|
+
static getPointListFromPointOffset(pointList: [ICoordinate, ICoordinate, ICoordinate, ICoordinate], changePointIndex: number, offset: ICoordinate): ICoordinate[];
|
|
125
|
+
/**
|
|
126
|
+
* 获取矩形框旋转中心
|
|
127
|
+
* @param rectPointList
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
static getRectCenterPoint(rectPointList: [ICoordinate, ICoordinate, ICoordinate, ICoordinate]): {
|
|
131
|
+
x: number;
|
|
132
|
+
y: number;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* 获取按指定的 angle 旋转的角度后的矩形
|
|
136
|
+
* @param rotate
|
|
137
|
+
* @param rectPointList
|
|
138
|
+
* @returns
|
|
139
|
+
*/
|
|
140
|
+
static rotateRectPointList(angle: number | undefined, rectPointList: [ICoordinate, ICoordinate, ICoordinate, ICoordinate]): {
|
|
141
|
+
x: number;
|
|
142
|
+
y: number;
|
|
143
|
+
}[];
|
|
144
|
+
/**
|
|
145
|
+
* 通过当前坐标 + 已知两点获取正多边形
|
|
146
|
+
* @param coordinate
|
|
147
|
+
* @param pointList
|
|
148
|
+
* @returns
|
|
149
|
+
*/
|
|
150
|
+
static getRectangleByRightAngle(coordinate: ICoordinate, pointList: IPolygonPoint[]): ICoordinate[];
|
|
71
151
|
}
|
|
@@ -71,7 +71,7 @@ export default class CommonToolUtils {
|
|
|
71
71
|
* @param pointList
|
|
72
72
|
* @returns
|
|
73
73
|
*/
|
|
74
|
-
static findAllLine(pointList: IPolygonPoint[] | point[]): {
|
|
74
|
+
static findAllLine(pointList: IPolygonPoint[] | point[], isClose?: boolean): {
|
|
75
75
|
point1: IPolygonPoint | point;
|
|
76
76
|
point2: IPolygonPoint | point;
|
|
77
77
|
pointIndex: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ERotateDirection } from '@/constant/annotation';
|
|
1
2
|
import { IPolygonData, IPolygonPoint } from '../../types/tool/polygon';
|
|
2
3
|
import { ELineTypes } from '../../constant/tool';
|
|
3
4
|
export default class PolygonUtils {
|
|
@@ -36,7 +37,9 @@ export default class PolygonUtils {
|
|
|
36
37
|
* @param range
|
|
37
38
|
* @returns
|
|
38
39
|
*/
|
|
39
|
-
static getClosestPoint(coordinate: ICoordinate, polygonList: IPolygonData[], lineType?: ELineTypes, range?: number
|
|
40
|
+
static getClosestPoint(coordinate: ICoordinate, polygonList: IPolygonData[], lineType?: ELineTypes, range?: number, option?: {
|
|
41
|
+
isClose?: boolean;
|
|
42
|
+
}): {
|
|
40
43
|
dropFoot: ICoordinate;
|
|
41
44
|
closestEdgeIndex: number;
|
|
42
45
|
closestPolygonID: string;
|
|
@@ -58,4 +61,8 @@ export default class PolygonUtils {
|
|
|
58
61
|
* @returns
|
|
59
62
|
*/
|
|
60
63
|
static getPolygonArea(pointList: IPolygonPoint[]): number;
|
|
64
|
+
static updatePolygonByRotate(direction: ERotateDirection, angle: number | undefined, pointList: IPolygonPoint[]): {
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
}[];
|
|
61
68
|
}
|