@labelbee/lb-annotation 1.14.0-alpha.2 → 1.14.0-alpha.21
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/core/pointCloud/annotation.js +1 -1
- package/dist/core/pointCloud/index.js +2 -2
- package/dist/core/scheduler.js +1 -1
- package/dist/core/toolOperation/LineToolOperation.js +1 -1
- package/dist/core/toolOperation/Selection.js +1 -0
- package/dist/core/toolOperation/cuboidOperation.js +1 -1
- package/dist/core/toolOperation/pointCloud2dOperation.js +1 -1
- package/dist/core/toolOperation/pointOperation.js +1 -1
- package/dist/core/toolOperation/polygonOperation.js +1 -1
- package/dist/core/toolOperation/rectOperation.js +1 -1
- package/dist/core/toolOperation/textAttributeClass.js +9 -9
- package/dist/locales/constants.js +1 -1
- package/dist/locales/en_US/message.js +1 -1
- package/dist/locales/zh_CN/message.js +1 -1
- package/dist/types/core/index.d.ts +2 -2
- package/dist/types/core/pointCloud/annotation.d.ts +3 -1
- package/dist/types/core/pointCloud/index.d.ts +9 -4
- package/dist/types/core/scheduler.d.ts +17 -3
- package/dist/types/core/toolOperation/LineToolOperation.d.ts +28 -37
- package/dist/types/core/toolOperation/Selection.d.ts +70 -0
- package/dist/types/core/toolOperation/pointCloud2dOperation.d.ts +1 -10
- package/dist/types/core/toolOperation/pointOperation.d.ts +10 -4
- package/dist/types/core/toolOperation/polygonOperation.d.ts +22 -14
- package/dist/types/core/toolOperation/rectOperation.d.ts +41 -10
- package/dist/types/core/toolOperation/textAttributeClass.d.ts +6 -0
- package/dist/types/locales/constants.d.ts +2 -0
- package/dist/types/utils/tool/CommonToolUtils.d.ts +2 -2
- package/dist/types/utils/tool/EnhanceCommonToolUtils.d.ts +2 -2
- package/dist/types/utils/tool/LineToolUtils.d.ts +1 -0
- package/dist/types/utils/tool/PolygonUtils.d.ts +1 -1
- package/dist/utils/tool/CommonToolUtils.js +1 -1
- package/dist/utils/tool/LineToolUtils.js +1 -1
- package/dist/utils/tool/PolygonUtils.js +1 -1
- package/es/core/pointCloud/annotation.js +1 -1
- package/es/core/pointCloud/index.js +2 -2
- package/es/core/scheduler.js +1 -1
- package/es/core/toolOperation/LineToolOperation.js +1 -1
- package/es/core/toolOperation/Selection.js +1 -0
- package/es/core/toolOperation/cuboidOperation.js +1 -1
- package/es/core/toolOperation/pointCloud2dOperation.js +1 -1
- package/es/core/toolOperation/pointOperation.js +1 -1
- package/es/core/toolOperation/polygonOperation.js +1 -1
- package/es/core/toolOperation/rectOperation.js +1 -1
- package/es/core/toolOperation/textAttributeClass.js +9 -9
- package/es/locales/constants.js +1 -1
- package/es/locales/en_US/message.js +1 -1
- package/es/locales/zh_CN/message.js +1 -1
- package/es/utils/tool/CommonToolUtils.js +1 -1
- package/es/utils/tool/LineToolUtils.js +1 -1
- package/es/utils/tool/PolygonUtils.js +1 -1
- package/package.json +7 -6
- package/LICENSE +0 -203
|
@@ -34,16 +34,17 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
34
34
|
*/
|
|
35
35
|
drawActivatedLine: (coord?: ICoordinate, e?: MouseEvent, hideTempAxis?: boolean) => void;
|
|
36
36
|
_textAttributInstance?: TextAttributeClass;
|
|
37
|
+
/** 选中所有线条 */
|
|
38
|
+
get selectedLines(): ILine[];
|
|
37
39
|
/** 线条是否被选中 */
|
|
38
40
|
get isLineSelected(): "" | ILinePoint[] | undefined;
|
|
39
|
-
/**
|
|
40
|
-
get
|
|
41
|
+
/** 选中单个线条 */
|
|
42
|
+
get selectedLine(): ILine | undefined;
|
|
41
43
|
/**
|
|
42
44
|
* 绘制hover的点
|
|
43
45
|
* @param coord
|
|
44
46
|
*/
|
|
45
47
|
drawHoverPoint: (coord: ICoordinate) => void;
|
|
46
|
-
selectedID?: string;
|
|
47
48
|
updatedLine: ILine;
|
|
48
49
|
toolName: string;
|
|
49
50
|
private lineList;
|
|
@@ -62,11 +63,11 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
62
63
|
private hoverPointID?;
|
|
63
64
|
private dependToolConfig?;
|
|
64
65
|
private isReference;
|
|
65
|
-
|
|
66
|
+
_textAttributeInstance?: TextAttributeClass;
|
|
66
67
|
private textEditingID?;
|
|
67
68
|
private isLineValid;
|
|
68
69
|
private lineDragging;
|
|
69
|
-
private
|
|
70
|
+
private selection;
|
|
70
71
|
constructor(props: ILineOperationProps);
|
|
71
72
|
/** 创建状态 */
|
|
72
73
|
get isCreate(): boolean;
|
|
@@ -88,6 +89,14 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
88
89
|
get isDependRect(): boolean;
|
|
89
90
|
get isCurrentAttributeLocked(): boolean;
|
|
90
91
|
get attributeFilteredLines(): ILine[];
|
|
92
|
+
get selectedIDs(): string[];
|
|
93
|
+
get selectedID(): string | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Judgement of showing Order.
|
|
96
|
+
*
|
|
97
|
+
* Origin Config of LineTool: enableOutOfTarget & outOfTarget.
|
|
98
|
+
* Configurable of other tools: drawOutsideTarget.
|
|
99
|
+
*/
|
|
91
100
|
get enableOutOfTarget(): any;
|
|
92
101
|
/**
|
|
93
102
|
* Judgement of showing Order.
|
|
@@ -99,6 +108,7 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
99
108
|
get edgeAdsorption(): any;
|
|
100
109
|
get attributeList(): any;
|
|
101
110
|
get lowerLimitPointNum(): any;
|
|
111
|
+
get minLength(): any;
|
|
102
112
|
get upperLimitPointNum(): any;
|
|
103
113
|
get textCheckType(): any;
|
|
104
114
|
get customFormat(): any;
|
|
@@ -150,19 +160,13 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
150
160
|
/**
|
|
151
161
|
* 对存在绘制对象,绘制热区
|
|
152
162
|
*/
|
|
153
|
-
renderActiveArea(): void;
|
|
154
|
-
/**
|
|
155
|
-
* Update selectedIDs and rerender
|
|
156
|
-
* @param selectedIDs
|
|
157
|
-
*/
|
|
158
|
-
setSelectedIDs(selectedIDs: string[]): void;
|
|
159
|
-
setSelectedID(newID?: string): void;
|
|
163
|
+
renderActiveArea({ top, left, right, bottom }: IRectArea): void;
|
|
160
164
|
/**
|
|
161
165
|
* 添加点
|
|
162
166
|
* @param coord 坐标
|
|
163
167
|
*/
|
|
164
168
|
addLinePoint(coord: ICoordinate): void;
|
|
165
|
-
|
|
169
|
+
setCreateStatusAndAddPoint(coord: ICoordinate, isRestText?: boolean): void;
|
|
166
170
|
/**
|
|
167
171
|
* 当前激活的线条是否为有效线, 优先获取存在的数据
|
|
168
172
|
*/
|
|
@@ -187,14 +191,6 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
187
191
|
* 渲染已经绘制的线段
|
|
188
192
|
*/
|
|
189
193
|
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
194
|
/**
|
|
199
195
|
* 绘制线条序号(包含属性或者标签)
|
|
200
196
|
* @param coord
|
|
@@ -255,6 +251,12 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
255
251
|
* @param offsetY
|
|
256
252
|
*/
|
|
257
253
|
moveLineInPolygon: (offsetX: number, offsetY: number) => false | undefined;
|
|
254
|
+
getSelectedLinesArea: () => {
|
|
255
|
+
top: number;
|
|
256
|
+
bottom: number;
|
|
257
|
+
left: number;
|
|
258
|
+
right: number;
|
|
259
|
+
};
|
|
258
260
|
/**
|
|
259
261
|
* 在矩形内移动线条
|
|
260
262
|
* @param offsetX x轴的偏移量
|
|
@@ -295,20 +297,8 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
295
297
|
/** 鼠标移动事件 */
|
|
296
298
|
mouseMoveHandler(e: MouseEvent): void;
|
|
297
299
|
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
300
|
setActiveLine(pointList?: ILinePoint[]): void;
|
|
311
|
-
onRightClick: (e: MouseEvent) =>
|
|
301
|
+
onRightClick: (e: MouseEvent) => true | undefined;
|
|
312
302
|
historyChanged(funcName: 'undo' | 'redo'): void;
|
|
313
303
|
updateSelectedAttributeAfterHistoryChanged: () => void;
|
|
314
304
|
undo(): void;
|
|
@@ -328,6 +318,7 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
328
318
|
updateLineSegmentSpecial(coord: ICoordinate): void;
|
|
329
319
|
onLeftClick: (e: MouseEvent) => void;
|
|
330
320
|
addLinePointToActiveLine(): void;
|
|
321
|
+
isCoordOnSelectedArea(coord: ICoordinate): boolean;
|
|
331
322
|
onMouseDown(e: MouseEvent): void;
|
|
332
323
|
lineHasChanged(): boolean;
|
|
333
324
|
updateLines(): void;
|
|
@@ -340,7 +331,6 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
340
331
|
* @param isAppend
|
|
341
332
|
*/
|
|
342
333
|
stopLineCreating(isAppend?: boolean): void;
|
|
343
|
-
setActiveStatus(id?: string): void;
|
|
344
334
|
/**
|
|
345
335
|
* 设置为无状态
|
|
346
336
|
* @param updateStatus
|
|
@@ -397,7 +387,7 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
397
387
|
/** 设置线条文本标注属性 */
|
|
398
388
|
setTextAttribute(text: string): void;
|
|
399
389
|
/** 更新线条的属性 */
|
|
400
|
-
setLineAttribute(key: 'attribute' | 'textAttribute', value: string
|
|
390
|
+
setLineAttribute(key: 'attribute' | 'textAttribute', value: string): void;
|
|
401
391
|
/** 更新外部属性列表的选中值 */
|
|
402
392
|
updateAttribute(attribute: string): void;
|
|
403
393
|
/** 更新线条的属性 */
|
|
@@ -407,7 +397,8 @@ declare class LineToolOperation extends BasicToolOperation {
|
|
|
407
397
|
/** 保存当前绘制的数据, 避免创建中的数据不会被保存到 */
|
|
408
398
|
saveData(): void;
|
|
409
399
|
setTextEditingID(id: string): void;
|
|
410
|
-
|
|
400
|
+
updateAttrWhileIDChanged(id?: string): void;
|
|
401
|
+
setSelectedLineID(id?: string, isAppend?: boolean, triggerAttrUpdate?: boolean): void;
|
|
411
402
|
attributeLockListChange(attributeLockList: string[]): void;
|
|
412
403
|
setReference: (isReference: boolean) => void;
|
|
413
404
|
/**
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Manage selectedIds for ToolInstance
|
|
3
|
+
* @author Glenfiddish <edwinlee0927@hotmail.com>
|
|
4
|
+
* @createdate 2023-03-01
|
|
5
|
+
*/
|
|
6
|
+
import { IPolygonData } from '@/types/tool/polygon';
|
|
7
|
+
import LineToolOperation from './LineToolOperation';
|
|
8
|
+
import PointOperation from './pointOperation';
|
|
9
|
+
import PolygonOperation from './polygonOperation';
|
|
10
|
+
import { RectOperation } from './rectOperation';
|
|
11
|
+
type ToolInstance = PointOperation | PolygonOperation | LineToolOperation | RectOperation;
|
|
12
|
+
type SelectedID = string;
|
|
13
|
+
type SelectedIDs = SelectedID[];
|
|
14
|
+
type DataUnit = IPointUnit | IPolygonData | ILine | IRect;
|
|
15
|
+
type DataList = Array<DataUnit>;
|
|
16
|
+
export type SetDataList = (dataList: DataList) => void;
|
|
17
|
+
declare class Selection {
|
|
18
|
+
private _selectedIDs;
|
|
19
|
+
private toolInstance;
|
|
20
|
+
private stashDataList?;
|
|
21
|
+
constructor(toolInstance: ToolInstance);
|
|
22
|
+
get selectedIDs(): SelectedIDs;
|
|
23
|
+
get selectedID(): string | undefined;
|
|
24
|
+
get visibleDataList(): any[];
|
|
25
|
+
get dataList(): DataList;
|
|
26
|
+
/**
|
|
27
|
+
* Trigger tools and _textAttributeInstance to re-render when _selectedIDs changed
|
|
28
|
+
*/
|
|
29
|
+
private set selectedIDs(value);
|
|
30
|
+
/**
|
|
31
|
+
* Update selectedIDs:
|
|
32
|
+
* Remove selectedID when selectedIDs includes
|
|
33
|
+
* Append selectedID when selectedIDs not includes
|
|
34
|
+
* SelectedID is
|
|
35
|
+
* @param selectedID
|
|
36
|
+
*/
|
|
37
|
+
private updateSelectedIDs;
|
|
38
|
+
/**
|
|
39
|
+
* Set selectedIDs
|
|
40
|
+
* isAppend is true: push or remove from selectedIDs
|
|
41
|
+
* isAppend is false: overwrite selectedIDs
|
|
42
|
+
* @param id
|
|
43
|
+
* @param isAppend
|
|
44
|
+
*/
|
|
45
|
+
setSelectedIDs(id?: string, isAppend?: boolean): void;
|
|
46
|
+
/**
|
|
47
|
+
* Force set selectedIDs not calc
|
|
48
|
+
* @param ids
|
|
49
|
+
*/
|
|
50
|
+
hardSetSelectedIDs(ids: string[]): void;
|
|
51
|
+
selectAll(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Stash data list and pop while paste
|
|
54
|
+
*/
|
|
55
|
+
toStashDataList(): void;
|
|
56
|
+
toUnStashDataList(): DataList | undefined;
|
|
57
|
+
mergeStashData(setDataList: (dataList: DataList) => void): void;
|
|
58
|
+
isIdSelected(id: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Trigger selection events(hijacking tools' key down event)
|
|
61
|
+
* - Copy selected data
|
|
62
|
+
* - Paste stash data
|
|
63
|
+
* - Select visible data
|
|
64
|
+
* @param e
|
|
65
|
+
* @param setDataList
|
|
66
|
+
* @returns if
|
|
67
|
+
*/
|
|
68
|
+
triggerKeyboardEvent(e: KeyboardEvent, setDataList: SetDataList): boolean;
|
|
69
|
+
}
|
|
70
|
+
export default Selection;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* It can expand various types of operations
|
|
3
|
-
*
|
|
4
|
-
* @file PointCloud 2D Operation
|
|
5
|
-
* @createdate 2022-07-11
|
|
6
|
-
* @author Ron <ron.f.luo@gmail.com>
|
|
7
|
-
*/
|
|
8
1
|
import { IPointCloudConfig } from '@labelbee/lb-utils';
|
|
9
2
|
import { ESortDirection } from '@/constant/annotation';
|
|
10
3
|
import { IPolygonData, IPolygonPoint } from '@/types/tool/polygon';
|
|
@@ -20,7 +13,6 @@ declare class PointCloud2dOperation extends PolygonOperation {
|
|
|
20
13
|
forbidAddNew: boolean;
|
|
21
14
|
pointCloudConfig: IPointCloudConfig;
|
|
22
15
|
private checkMode;
|
|
23
|
-
private selectedIDs;
|
|
24
16
|
constructor(props: IPolygonOperationProps & IPointCloud2dOperationProps);
|
|
25
17
|
get getSelectedIDs(): string[];
|
|
26
18
|
get enableDrag(): boolean;
|
|
@@ -41,7 +33,7 @@ declare class PointCloud2dOperation extends PolygonOperation {
|
|
|
41
33
|
* @override
|
|
42
34
|
*/
|
|
43
35
|
rightMouseUp: (e: MouseEvent) => void;
|
|
44
|
-
get selectedPolygons(): IPolygonData[]
|
|
36
|
+
get selectedPolygons(): IPolygonData[];
|
|
45
37
|
updateSelectedPolygonsPoints(offset: Partial<ICoordinate>): void;
|
|
46
38
|
/**
|
|
47
39
|
* keydown event
|
|
@@ -106,7 +98,6 @@ declare class PointCloud2dOperation extends PolygonOperation {
|
|
|
106
98
|
* @returns
|
|
107
99
|
*/
|
|
108
100
|
setPolygonValidAndRender(id: string, isUpdate?: boolean): void;
|
|
109
|
-
onDragMove(e: MouseEvent): void;
|
|
110
101
|
onMouseDown(e: MouseEvent): true | undefined;
|
|
111
102
|
/**
|
|
112
103
|
* Just Update Data. Not Clear Status
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
|
|
2
|
+
import TextAttributeClass from './textAttributeClass';
|
|
3
|
+
import Selection from './Selection';
|
|
2
4
|
export interface IPointOperationProps extends IBasicToolOperationProps {
|
|
3
5
|
style: any;
|
|
4
6
|
forbidAddNew?: boolean;
|
|
@@ -8,18 +10,21 @@ declare class PointOperation extends BasicToolOperation {
|
|
|
8
10
|
config: IPointToolConfig;
|
|
9
11
|
pointList: IPointUnit[];
|
|
10
12
|
hoverID?: string;
|
|
11
|
-
selectedID?: string;
|
|
12
13
|
markerIndex: number;
|
|
13
14
|
dragInfo?: {
|
|
14
15
|
dragStartCoord: ICoordinate;
|
|
15
16
|
originPointList: IPointUnit[];
|
|
16
17
|
};
|
|
18
|
+
selection: Selection;
|
|
19
|
+
_textAttributeInstance?: TextAttributeClass;
|
|
17
20
|
forbidAddNew?: boolean;
|
|
18
21
|
forbidDelete?: boolean;
|
|
19
|
-
private _textAttributInstance?;
|
|
20
22
|
constructor(props: IPointOperationProps);
|
|
21
23
|
get dataList(): IPointUnit[];
|
|
22
24
|
get drawOutsideTarget(): boolean;
|
|
25
|
+
get selectedID(): string | undefined;
|
|
26
|
+
get selectedIDs(): string[];
|
|
27
|
+
get selectedPoints(): IPointUnit[];
|
|
23
28
|
/**
|
|
24
29
|
* 向外部提供标记的更改
|
|
25
30
|
* @param markerIndex
|
|
@@ -54,7 +59,7 @@ declare class PointOperation extends BasicToolOperation {
|
|
|
54
59
|
textChange: (v: string) => void;
|
|
55
60
|
get selectedText(): string | undefined;
|
|
56
61
|
setStyle(toolStyle: any): void;
|
|
57
|
-
setSelectedID(newID?: string): void;
|
|
62
|
+
setSelectedID(newID?: string, isAppend?: boolean): void;
|
|
58
63
|
/**
|
|
59
64
|
* 获取当前配置下的 icon svg
|
|
60
65
|
* @param attribute
|
|
@@ -74,13 +79,14 @@ declare class PointOperation extends BasicToolOperation {
|
|
|
74
79
|
onMouseMove(e: MouseEvent): undefined;
|
|
75
80
|
onMouseUp(e: MouseEvent): true | undefined;
|
|
76
81
|
onDragMove(e: MouseEvent): void;
|
|
82
|
+
onKeyUp(e: KeyboardEvent): boolean | void;
|
|
77
83
|
onKeyDown(e: KeyboardEvent): void;
|
|
78
84
|
isMinDistance: (coord: ICoordinate) => boolean;
|
|
79
85
|
createPoint(e: MouseEvent): void;
|
|
80
86
|
isInPoint(pos: ICoordinate, point: ICoordinate, zoom?: number): boolean;
|
|
81
87
|
getHoverId(): string | undefined;
|
|
82
88
|
get selectedPoint(): IPointUnit | undefined;
|
|
83
|
-
rightMouseUp(): void;
|
|
89
|
+
rightMouseUp(e: MouseEvent): void;
|
|
84
90
|
onTabKeyDown(e: KeyboardEvent): void;
|
|
85
91
|
/**
|
|
86
92
|
* 当前依赖状态下本页的所有的点
|
|
@@ -3,6 +3,7 @@ import { EPolygonPattern } from '../../constant/tool';
|
|
|
3
3
|
import { IPolygonConfig, IPolygonData, IPolygonPoint } from '../../types/tool/polygon';
|
|
4
4
|
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
|
|
5
5
|
import TextAttributeClass from './textAttributeClass';
|
|
6
|
+
import Selection from './Selection';
|
|
6
7
|
export interface IPolygonOperationProps extends IBasicToolOperationProps {
|
|
7
8
|
}
|
|
8
9
|
declare class PolygonOperation extends BasicToolOperation {
|
|
@@ -12,7 +13,6 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
12
13
|
hoverID?: string;
|
|
13
14
|
hoverPointIndex: number;
|
|
14
15
|
hoverEdgeIndex: number;
|
|
15
|
-
selectedID?: string;
|
|
16
16
|
editPolygonID?: string;
|
|
17
17
|
pattern: EPolygonPattern;
|
|
18
18
|
isCombined: boolean;
|
|
@@ -22,19 +22,25 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
22
22
|
changePointIndex?: number[];
|
|
23
23
|
dragTarget: EDragTarget;
|
|
24
24
|
originPolygon?: IPolygonData;
|
|
25
|
+
selectedPolygons?: IPolygonData[];
|
|
25
26
|
dragPrevCoord: ICoordinate;
|
|
26
27
|
originPolygonList: IPolygonData[];
|
|
27
28
|
};
|
|
28
29
|
private drawingHistory;
|
|
29
30
|
isCtrl: boolean;
|
|
30
31
|
isAlt: boolean;
|
|
31
|
-
|
|
32
|
+
_textAttributeInstance?: TextAttributeClass;
|
|
32
33
|
forbidAddNewPolygonFuc?: (e: MouseEvent) => boolean;
|
|
34
|
+
selection: Selection;
|
|
33
35
|
constructor(props: IPolygonOperationProps);
|
|
36
|
+
get selectedIDs(): string[];
|
|
37
|
+
get selectedID(): string | undefined;
|
|
38
|
+
get minArea(): number;
|
|
34
39
|
eventBinding(): void;
|
|
35
40
|
eventUnbinding(): void;
|
|
36
41
|
destroy(): void;
|
|
37
42
|
get selectedPolygon(): IPolygonData | undefined;
|
|
43
|
+
get selectedPolygons(): IPolygonData[];
|
|
38
44
|
get hoverPolygon(): IPolygonData | undefined;
|
|
39
45
|
get enableDrag(): boolean;
|
|
40
46
|
get visiblePolygonList(): IPolygonData[];
|
|
@@ -71,6 +77,11 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
71
77
|
* @memberof RectOperation
|
|
72
78
|
*/
|
|
73
79
|
get currentPageResult(): IPolygonData[];
|
|
80
|
+
/**
|
|
81
|
+
* Just Update Data. Not Clear Status
|
|
82
|
+
* @param polygonList
|
|
83
|
+
*/
|
|
84
|
+
setResultAndSelectedID(polygonList: IPolygonData[], selectedID: string): void;
|
|
74
85
|
setResult(polygonList: IPolygonData[]): void;
|
|
75
86
|
/**
|
|
76
87
|
* 外层 sidabr 调用
|
|
@@ -98,7 +109,7 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
98
109
|
clearActiveStatus(): void;
|
|
99
110
|
clearDrawingStatus(): void;
|
|
100
111
|
setPolygonList(polygonList: IPolygonData[]): void;
|
|
101
|
-
setSelectedID(newID?: string): void;
|
|
112
|
+
setSelectedID(newID?: string, isAppend?: boolean): void;
|
|
102
113
|
setDefaultAttribute(defaultAttribute?: string): void;
|
|
103
114
|
setStyle(toolStyle: any): void;
|
|
104
115
|
setPolygonValidAndRender(id: string): void;
|
|
@@ -116,7 +127,7 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
116
127
|
getHoverID(e: MouseEvent): string;
|
|
117
128
|
getHoverEdgeIndex(e: MouseEvent): number;
|
|
118
129
|
getHoverPointIndex(e: MouseEvent): number;
|
|
119
|
-
|
|
130
|
+
deletePolygons(id?: string[]): void;
|
|
120
131
|
deletePolygonPoint(index: number): void;
|
|
121
132
|
spaceKeydown(): void;
|
|
122
133
|
onTabKeyDown(e: KeyboardEvent): void;
|
|
@@ -142,6 +153,11 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
142
153
|
* @returns
|
|
143
154
|
*/
|
|
144
155
|
isPolygonOutSide(selectedPointList: IPolygonPoint[]): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Update polygon position while enableDrag is true
|
|
158
|
+
* @param e {MouseEvent}
|
|
159
|
+
*/
|
|
160
|
+
onDragMove(e: MouseEvent): void;
|
|
145
161
|
/**
|
|
146
162
|
* According to the mode of dragTarget, get the offset when dragging
|
|
147
163
|
* @param e {MouseEvent}
|
|
@@ -153,11 +169,6 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
153
169
|
y: number;
|
|
154
170
|
};
|
|
155
171
|
dragPolygon(e: MouseEvent, selectedPolygon: IPolygonData): IPolygonPoint[] | undefined;
|
|
156
|
-
/**
|
|
157
|
-
* Update polygon position while enableDrag is true
|
|
158
|
-
* @param e {MouseEvent}
|
|
159
|
-
*/
|
|
160
|
-
onDragMove(e: MouseEvent): void;
|
|
161
172
|
onMouseMove(e: MouseEvent): void;
|
|
162
173
|
/**
|
|
163
174
|
* Emit updateList for views update
|
|
@@ -183,11 +194,8 @@ declare class PolygonOperation extends BasicToolOperation {
|
|
|
183
194
|
updateSelectedTextAttribute(newTextAttribute?: string): void;
|
|
184
195
|
renderTextAttribute(): void;
|
|
185
196
|
renderStaticPolygon(): void;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
* @param selectedPolygon
|
|
189
|
-
*/
|
|
190
|
-
renderSelectedPolygon(): void;
|
|
197
|
+
renderSelectedPolygons(): void;
|
|
198
|
+
renderSelectedPolygon(polygon: IPolygonData): void;
|
|
191
199
|
renderHoverPolygon(): void;
|
|
192
200
|
renderPolygon(): void;
|
|
193
201
|
render(): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
|
|
2
|
+
import TextAttributeClass from './textAttributeClass';
|
|
2
3
|
interface IRectOperationProps extends IBasicToolOperationProps {
|
|
3
4
|
drawOutSideTarget: boolean;
|
|
4
5
|
style: any;
|
|
@@ -12,11 +13,11 @@ declare class RectOperation extends BasicToolOperation {
|
|
|
12
13
|
hoverRectID?: string;
|
|
13
14
|
hoverRectPointIndex: number;
|
|
14
15
|
hoverRectEdgeIndex: number;
|
|
15
|
-
selectedRectID?: string;
|
|
16
16
|
isFlow: boolean;
|
|
17
17
|
config: IRectConfig;
|
|
18
18
|
markerIndex: number;
|
|
19
|
-
|
|
19
|
+
_textAttributeInstance?: TextAttributeClass;
|
|
20
|
+
private selection;
|
|
20
21
|
private dragInfo?;
|
|
21
22
|
constructor(props: IRectOperationProps);
|
|
22
23
|
setResult(rectList: IRect[]): void;
|
|
@@ -28,8 +29,11 @@ declare class RectOperation extends BasicToolOperation {
|
|
|
28
29
|
* @param isUpload
|
|
29
30
|
*/
|
|
30
31
|
setRectList(rectList: IRect[], isUpload?: boolean): void;
|
|
31
|
-
get
|
|
32
|
+
get selectedRectID(): string | undefined;
|
|
32
33
|
get selectedID(): string | undefined;
|
|
34
|
+
get selectedRect(): IRect | undefined;
|
|
35
|
+
get selectedIDs(): string[];
|
|
36
|
+
get selectedRects(): IRect[];
|
|
33
37
|
get selectedText(): string | undefined;
|
|
34
38
|
get dataList(): IRect[];
|
|
35
39
|
/**
|
|
@@ -51,7 +55,7 @@ declare class RectOperation extends BasicToolOperation {
|
|
|
51
55
|
*/
|
|
52
56
|
getCurrentPageResult(rectList: IRect[]): IRect[];
|
|
53
57
|
setSelectedID(newID?: string): void;
|
|
54
|
-
setSelectedRectID(newID?: string): void;
|
|
58
|
+
setSelectedRectID(newID?: string, isAppend?: boolean): void;
|
|
55
59
|
setStyle(toolStyle: any): void;
|
|
56
60
|
/**
|
|
57
61
|
* 向外部提供标记的更改
|
|
@@ -78,8 +82,39 @@ declare class RectOperation extends BasicToolOperation {
|
|
|
78
82
|
* @param attribute
|
|
79
83
|
*/
|
|
80
84
|
getTextIconSvg(attribute?: string): any;
|
|
81
|
-
multiMoveMouseDown(e: MouseEvent): boolean;
|
|
82
85
|
onMouseDown(e: MouseEvent): undefined;
|
|
86
|
+
appendOffsetRect(rect: IRect, offset: ICoordinate): {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
width: number;
|
|
90
|
+
height: number;
|
|
91
|
+
id: string;
|
|
92
|
+
sourceID: string;
|
|
93
|
+
valid: boolean;
|
|
94
|
+
order?: number | undefined;
|
|
95
|
+
attribute: string;
|
|
96
|
+
textAttribute: string;
|
|
97
|
+
disableDelete?: boolean | undefined;
|
|
98
|
+
label?: string | undefined;
|
|
99
|
+
};
|
|
100
|
+
getRectsBoundaries(rects: IRect[], offset: ICoordinate): {
|
|
101
|
+
top: number;
|
|
102
|
+
bottom: number;
|
|
103
|
+
left: number;
|
|
104
|
+
right: number;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* 判断框是否超过依赖范围
|
|
108
|
+
* @param rects
|
|
109
|
+
* @param offset
|
|
110
|
+
* @returns
|
|
111
|
+
*/
|
|
112
|
+
isRectsOutOfTarget(rects: IRect[], offset: ICoordinate): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Update rect position while dragTarget is equal EDragTarget.Plane
|
|
115
|
+
* @param offset
|
|
116
|
+
*/
|
|
117
|
+
moveRects(offset: ICoordinate): void;
|
|
83
118
|
/**
|
|
84
119
|
* Offset is under zooming.
|
|
85
120
|
* @param offset
|
|
@@ -106,6 +141,7 @@ declare class RectOperation extends BasicToolOperation {
|
|
|
106
141
|
shiftRightMouseUp(e: MouseEvent): void;
|
|
107
142
|
onMouseUp(e: MouseEvent): true | undefined;
|
|
108
143
|
onRightDblClick(e: MouseEvent): void;
|
|
144
|
+
deleteSelectedRect(): void;
|
|
109
145
|
onKeyDown(e: KeyboardEvent): true | undefined;
|
|
110
146
|
onKeyUp(e: KeyboardEvent): void;
|
|
111
147
|
onWheel(e: MouseEvent): void;
|
|
@@ -135,11 +171,6 @@ declare class RectOperation extends BasicToolOperation {
|
|
|
135
171
|
* @param isZoom 矩形框是否为缩放后的比例
|
|
136
172
|
*/
|
|
137
173
|
renderDrawingRect(rect: IRect, zoom?: number, isZoom?: boolean): void;
|
|
138
|
-
/**
|
|
139
|
-
* Experiment. Render the multiSelected Rect
|
|
140
|
-
*
|
|
141
|
-
*/
|
|
142
|
-
renderMultiSelectedRect(): void;
|
|
143
174
|
/**
|
|
144
175
|
* 渲染静态框体
|
|
145
176
|
*/
|
|
@@ -48,6 +48,12 @@ export default class TextAttributeClass {
|
|
|
48
48
|
color: string;
|
|
49
49
|
width?: number;
|
|
50
50
|
}): void;
|
|
51
|
+
/**
|
|
52
|
+
* According to oldIDs' and newIDs' value, remove or re-render textarea
|
|
53
|
+
* @param oldIDs
|
|
54
|
+
* @param newIDs
|
|
55
|
+
*/
|
|
56
|
+
selectedIDsChanged(oldIDs: string[], newIDs: string[]): void;
|
|
51
57
|
/**
|
|
52
58
|
* 用于外层切换选中框调用
|
|
53
59
|
*/
|
|
@@ -6,6 +6,8 @@ export declare enum EMessage {
|
|
|
6
6
|
TextCheckCustomErrorNotice = "textCheckCustomErrorNotice",
|
|
7
7
|
UpperLimitErrorNotice = "UpperLimitErrorNotice",
|
|
8
8
|
LowerLimitErrorNotice = "LowerLimitErrorNotice",
|
|
9
|
+
MinAreaLimitErrorNotice = "MinAreaLimitErrorNotice",
|
|
10
|
+
MinLengthLimitErrorNotice = "MinLengthLimitErrorNotice",
|
|
9
11
|
InvalidImage = "InvalidImage",
|
|
10
12
|
DisableDelete = "DisableDelete",
|
|
11
13
|
ClearPartialData = "ClearPartialData",
|
|
@@ -45,10 +45,10 @@ export default class CommonToolUtils {
|
|
|
45
45
|
* @param T 当前图片的结果框
|
|
46
46
|
* @param sourceID 当前状态依赖的框体,若依赖原图则返回 '0'
|
|
47
47
|
* @param attributeLockList 当前展示的属性
|
|
48
|
-
* @param
|
|
48
|
+
* @param selectedIDs 是否含有选中逻辑
|
|
49
49
|
* @returns
|
|
50
50
|
*/
|
|
51
|
-
static getRenderResultList<T = any>(resultList: any[], sourceID: string, attributeLockList?: string[],
|
|
51
|
+
static getRenderResultList<T = any>(resultList: any[], sourceID: string, attributeLockList?: string[], selectedIDs?: string[]): [T[], T[]];
|
|
52
52
|
/**
|
|
53
53
|
* 获取当前依赖情况下的 sourceID 提取
|
|
54
54
|
*/
|
|
@@ -15,9 +15,9 @@ import LineToolOperation from '../../core/toolOperation/LineToolOperation';
|
|
|
15
15
|
import PointOperation from '../../core/toolOperation/pointOperation';
|
|
16
16
|
import TextToolOperation from '../../core/toolOperation/TextToolOperation';
|
|
17
17
|
import CommonToolUtils from './CommonToolUtils';
|
|
18
|
-
declare const getCurrentOperation: (toolName: EToolName | ECheckModel) => typeof
|
|
18
|
+
declare const getCurrentOperation: (toolName: EToolName | ECheckModel) => typeof LineToolOperation | typeof PointOperation | typeof PolygonOperation | typeof RectOperationAsNewName | typeof TagOperation | typeof TextToolOperation | typeof ScribbleTool | typeof PointCloud2dOperation | typeof CuboidOperation | typeof CheckOperation;
|
|
19
19
|
declare class EnhanceCommonToolUtils extends CommonToolUtils {
|
|
20
|
-
static getCurrentOperation: (toolName: EToolName | ECheckModel) => typeof
|
|
20
|
+
static getCurrentOperation: (toolName: EToolName | ECheckModel) => typeof LineToolOperation | typeof PointOperation | typeof PolygonOperation | typeof RectOperationAsNewName | typeof TagOperation | typeof TextToolOperation | typeof ScribbleTool | typeof PointCloud2dOperation | typeof CuboidOperation | typeof CheckOperation;
|
|
21
21
|
}
|
|
22
22
|
export { getCurrentOperation };
|
|
23
23
|
export default EnhanceCommonToolUtils;
|
|
@@ -62,6 +62,7 @@ declare class LineToolUtils {
|
|
|
62
62
|
y: number;
|
|
63
63
|
};
|
|
64
64
|
static calcDistance: (point1: IPoint, point2: IPoint) => number;
|
|
65
|
+
static lineLengthSum(pointList: IPoint[]): number;
|
|
65
66
|
static drawCurveLine: (ctx: any, points: ILinePoint[], config: any, applyLineWidth: boolean | undefined, isReference: boolean | undefined, hoverEdgeIndex: number) => void;
|
|
66
67
|
static calcTwoPointDistance: (pointA: IPoint, pointB: IPoint) => number;
|
|
67
68
|
/**
|
|
@@ -31,7 +31,7 @@ export default class PolygonUtils {
|
|
|
31
31
|
* @returns
|
|
32
32
|
*/
|
|
33
33
|
static getPolygonByID(polygonList: IPolygonData[], id?: string): IPolygonData | undefined;
|
|
34
|
-
static getPolygonByIDs(polygonList: IPolygonData[], ids?: string[]): IPolygonData[]
|
|
34
|
+
static getPolygonByIDs(polygonList: IPolygonData[], ids?: string[]): IPolygonData[];
|
|
35
35
|
static getHoverEdgeIndex(checkPoint: ICoordinate, pointList: IPolygonPoint[], lineType?: ELineTypes, scope?: number): number;
|
|
36
36
|
/**
|
|
37
37
|
* 用于边缘吸附,获取最接近的边
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _=require("lodash"),annotation=require("../../constant/annotation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,t,e)=>t in o?__defProp(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,__spreadValues=(o,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(o,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(o,e,t[e]);return o},__spreadProps=(o,t)=>__defProps(o,__getOwnPropDescs(t));class CommonToolUtils{static getStepInfo(t,e){return e==null?void 0:e.filter(r=>r.step===t)[0]}static getCurrentStepInfo(t,e){const r=this.getStepInfo(t,e);return r&&(r.type===annotation.EStepType.QUALITY_INSPECTION||r.type===annotation.EStepType.MANUAL_CORRECTION)?this.getCurrentStepInfo(r.dataSourceStep,e):r}static getMaxOrder(t){let e=0;return t.forEach(r=>{r.order&&r.order>e&&(e=r.order)}),e}static hotkeyFilter(t){const e=t.target||t.srcElement;if(!e)return!0;const{tagName:r,type:i}=e;if(!r||!i)return!0;let n=!0;return(e.isContentEditable||r==="TEXTAREA"||(r==="INPUT"&&i!=="radio"||r==="TEXTAREA")&&!e.readOnly)&&(n=!1),n}static getNextSelectedRectID(t,e=annotation.ESortDirection.ascend,r){let i=1;e===annotation.ESortDirection.descend&&(i=-1);const n=t.sort((s,c)=>s.x-c.x==0?s.y-c.y:i*(s.x-c.x)),
|
|
1
|
+
"use strict";var _=require("lodash"),annotation=require("../../constant/annotation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,t,e)=>t in o?__defProp(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,__spreadValues=(o,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(o,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(o,e,t[e]);return o},__spreadProps=(o,t)=>__defProps(o,__getOwnPropDescs(t));class CommonToolUtils{static getStepInfo(t,e){return e==null?void 0:e.filter(r=>r.step===t)[0]}static getCurrentStepInfo(t,e){const r=this.getStepInfo(t,e);return r&&(r.type===annotation.EStepType.QUALITY_INSPECTION||r.type===annotation.EStepType.MANUAL_CORRECTION)?this.getCurrentStepInfo(r.dataSourceStep,e):r}static getMaxOrder(t){let e=0;return t.forEach(r=>{r.order&&r.order>e&&(e=r.order)}),e}static hotkeyFilter(t){const e=t.target||t.srcElement;if(!e)return!0;const{tagName:r,type:i}=e;if(!r||!i)return!0;let n=!0;return(e.isContentEditable||r==="TEXTAREA"||(r==="INPUT"&&i!=="radio"||r==="TEXTAREA")&&!e.readOnly)&&(n=!1),n}static getNextSelectedRectID(t,e=annotation.ESortDirection.ascend,r){let i=1;e===annotation.ESortDirection.descend&&(i=-1);const n=t.sort((s,c)=>s.x-c.x==0?s.y-c.y:i*(s.x-c.x)),a=n.findIndex(s=>s.id===r),l=n.length;return n[(a+1)%l]}static getNextSelectedRectIDByEvent(t,e,r){const i=e.shiftKey?annotation.ESortDirection.descend:annotation.ESortDirection.ascend;return this.getNextSelectedRectID(t,i,r)}static getRenderResultList(t,e,r=[],i){const n=[];return[t.filter(l=>i&&i.includes(l.id)?(n.push(l),!1):!(r.length>0&&!r.includes(l==null?void 0:l.attribute)||this.isDifferSourceID(l==null?void 0:l.sourceID,e))),n]}static getSourceID(t){var e;const r="";return t&&(e=t==null?void 0:t.id)!=null?e:r}static findAllLine(t,e=!0){const r=[],i=[...t];i.length>=3&&e===!0&&i.push(__spreadValues({},i[0]));for(let n=0;n<i.length;n++)i[n+1]&&r.push({point1:i[n],point2:i[n+1],pointIndex:n});return r}static translateSourceID(t){return(t===void 0||t===0||t==="0")&&(t=""),t}static isDifferSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`!=`${e}`}static isSameSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`==`${e}`}static getNextMarker(t,e=[],r){if((e==null?void 0:e.length)===0)return;let i=e.map((n,a)=>__spreadProps(__spreadValues({},n),{index:a}));if(typeof r=="number"&&r>0){const n=e[r];if(n&&t.every(a=>a.label!==n.value))return{label:n.value,index:r};i=[...i.slice(r,e.length),...i.slice(0,r)]}for(let n=0;n<i.length;n++)if(!t.some(a=>a.label===i[n].value))return{label:i[n].value,index:i[n].index}}static getCurrentMarkerIndex(t,e=[]){return e.findIndex(r=>t===r.value)}}CommonToolUtils.jsonParser=(o,t={})=>{try{return typeof o=="string"?JSON.parse(o):_.isObject(o)?o:t}catch(e){return t}},module.exports=CommonToolUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),polygonTool=require("./polygonTool.js"),PolygonUtils=require("./PolygonUtils.js"),MathUtils=require("../MathUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,n
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tool=require("../../constant/tool.js"),polygonTool=require("./polygonTool.js"),PolygonUtils=require("./PolygonUtils.js"),MathUtils=require("../MathUtils.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,e,n)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,__spreadValues=(t,e)=>{for(var n in e||(e={}))__hasOwnProp.call(e,n)&&__defNormalProp(t,n,e[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(e))__propIsEnum.call(e,n)&&__defNormalProp(t,n,e[n]);return t},__spreadProps=(t,e)=>__defProps(t,__getOwnPropDescs(e));exports.EStatus=void 0,function(t){t[t.Create=0]="Create",t[t.Active=1]="Active",t[t.Edit=1]="Edit",t[t.None=2]="None"}(exports.EStatus||(exports.EStatus={})),exports.EColor=void 0,function(t){t.ActiveArea="#B3B8FF"}(exports.EColor||(exports.EColor={}));const SEGMENT_NUMBER=16,POINT_RADIUS=3,_LineToolUtils=class{static lineLengthSum(t){let e=0;return t.forEach((n,i)=>{i>0&&(e+=this.calcDistance(t[i-1],n))}),e}static isInLine(t,e,n,i=3){const{length:r}=MathUtils.default.getFootOfPerpendicular(t,e,n);return r<i}};let LineToolUtils=_LineToolUtils;LineToolUtils.setSpecialEdgeStyle=t=>{t.lineCap="butt",t.setLineDash([10,10])},LineToolUtils.setReferenceCtx=t=>{t.lineCap="butt",t.setLineDash([6])},LineToolUtils.calcOptimalIntersection=(t,e,n,i,r)=>{let c,f=Infinity,a;if(t.find((u,o)=>{if(o===0)return;const s=_LineToolUtils.isInLine(e.pointA,u,t[o-1]),l=_LineToolUtils.isInLine(e.pointB,u,t[o-1]);return s&&l}))return{point:n};if(t.forEach((u,o)=>{if(o===0)return;const s={pointA:t[o-1],pointB:u},l=_LineToolUtils.lineIntersection(e,s);if(l&&e){const{onLine2:g,onLine1:y,x:v,y:d}=l,h=_LineToolUtils.calcDistance(n,l);if(_LineToolUtils.isOnLine(e.pointB.x,e.pointB.y,u.x,u.y,t[o-1].x,t[o-1].y)){if(_LineToolUtils.calcDistance(n,l)<i/r){const E=e.pointB,{footPoint:O,length:_}=MathUtils.default.getFootOfPerpendicular(E,s.pointA,s.pointB,!0);if(_!==void 0){const A=_LineToolUtils.calcDistance(s.pointA,O),D=_LineToolUtils.calcDistance(s.pointB,O);a={point:O,minDistance:_},_===Infinity&&(a.point=A>D?s.pointB:s.pointA)}}return}h<f&&g&&y&&(f=h,c={x:v,y:d})}}),c)return{point:c,minDistance:f};if(a)return a},LineToolUtils.lineIntersection=(t,e)=>{let n=!1,i=!1;const r=_LineToolUtils.getAxisDiff(t),c=_LineToolUtils.getAxisDiff(e),f=c.y*r.x-c.x*r.y;if(f===0)return!1;let a=t.pointA.y-e.pointA.y,p=t.pointA.x-e.pointA.x;const u=(e.pointB.x-e.pointA.x)*a-(e.pointB.y-e.pointA.y)*p,o=(t.pointB.x-t.pointA.x)*a-(t.pointB.y-t.pointA.y)*p;a=u/f,p=o/f,a>0&&a<1&&(n=!0),p>0&&p<1&&(i=!0);const s=t.pointA.x+a*(t.pointB.x-t.pointA.x),l=t.pointA.y+a*(t.pointB.y-t.pointA.y);return{x:s,y:l,onLine1:n,onLine2:i}},LineToolUtils.getAxisDiff=t=>({x:t.pointB.x-t.pointA.x,y:t.pointB.y-t.pointA.y}),LineToolUtils.calcDistance=(t,e)=>Math.sqrt(Math.pow(Math.abs(t.x-e.x),2)+Math.pow(Math.abs(t.y-e.y),2)),LineToolUtils.drawCurveLine=(t,e,n,i=!0,r=!1,c)=>{const f=polygonTool.createSmoothCurvePointsFromPointList(e,SEGMENT_NUMBER);t.save(),t.lineCap="round",t.lineJoin="round",t.strokeStyle=n.color,i&&(t.lineWidth=n.lineWidth),r&&_LineToolUtils.setReferenceCtx(t),e.forEach((a,p)=>{const u=a==null?void 0:a.specialEdge,o=f.splice(0,SEGMENT_NUMBER+1);t.save(),t.beginPath(),c===p&&(t.lineWidth=4),o.forEach(({x:s,y:l},g)=>{const y=g>0?"lineTo":"moveTo";u&&_LineToolUtils.setSpecialEdgeStyle(t),t[y](s,l)}),t.stroke(),t.restore()}),t.restore()},LineToolUtils.calcTwoPointDistance=(t,e)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),LineToolUtils.pointOverTarget=(t,e,n,i,r,c,f,a,p,u)=>{const o=t;if(!e)return t;if(n===tool.EToolName.Polygon){const s=_LineToolUtils.getPolygonPointList(i,r);if(s.length===0||PolygonUtils.isInPolygon(t,s))return o;const g=s.concat(s[0]).map(P=>p(P)),y=p(e),v=p(t),d={pointA:y,pointB:v},h=_LineToolUtils.calcOptimalIntersection(g,d,y,f,a);if(h){const P=u(h==null?void 0:h.point);o.x=P.x,o.y=P.y}else return e;return o}if(n===tool.EToolName.Rect){const{x:s,y:l,width:g,height:y}=i;return o.x=MathUtils.default.withinRange(o.x,[s,s+g]),o.y=MathUtils.default.withinRange(o.y,[l,l+y]),o}return o.x=MathUtils.default.withinRange(o.x,[0,c.width]),o.y=MathUtils.default.withinRange(o.y,[0,c.height]),o},LineToolUtils.getPolygonPointList=(t,e)=>{const{pointList:n}=t,{lineType:i}=e;return i===tool.ELineTypes.Line?n:PolygonUtils.createSmoothCurvePoints(n.reduce((r,c)=>[...r,c.x,c.y],[]),.5,!0,20)},LineToolUtils.isOnLine=(t,e,n,i,r,c)=>Math.abs((a=>(i-e)/(n-t)*(a-t)+e)(r)-c)<1e-6&&r>=t&&r<=n,LineToolUtils.inArea=({top:t,left:e,right:n,bottom:i},{x:r,y:c})=>c>=t&&c<=i&&r>=e&&r<=n,LineToolUtils.getVHPoint=(t,e,n,i)=>{const r=_LineToolUtils.getAngle(t,n);return Math.abs(r)<45?__spreadProps(__spreadValues({},e),{y:i.y}):__spreadProps(__spreadValues({},e),{x:i.x})},LineToolUtils.getAngle=(t,e)=>{const n=e.x-t.x,i=e.y-t.y;return 360*Math.atan(i/n)/(2*Math.PI)},exports.POINT_RADIUS=POINT_RADIUS,exports.SEGMENT_NUMBER=SEGMENT_NUMBER,exports.default=LineToolUtils;
|