@labelbee/lb-annotation 1.8.0 → 1.9.0-alpha.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 (96) hide show
  1. package/README.md +65 -0
  2. package/dist/index.js +20 -9
  3. package/dist/types/constant/tool.d.ts +3 -1
  4. package/dist/types/core/index.d.ts +24 -4
  5. package/dist/types/core/pointCloud/OrbitControls.d.ts +60 -0
  6. package/dist/types/core/pointCloud/PCDLoader.d.ts +11 -0
  7. package/dist/types/core/pointCloud/annotation.d.ts +47 -0
  8. package/dist/types/core/pointCloud/cache.d.ts +16 -0
  9. package/dist/types/core/pointCloud/index.d.ts +325 -0
  10. package/dist/types/core/scheduler.d.ts +71 -0
  11. package/dist/types/core/toolOperation/basicToolOperation.d.ts +20 -2
  12. package/dist/types/core/toolOperation/eventListener.d.ts +2 -2
  13. package/dist/types/core/toolOperation/pointCloud2dOperation.d.ts +80 -0
  14. package/dist/types/core/toolOperation/polygonOperation.d.ts +21 -7
  15. package/dist/types/core/toolOperation/segmentByRect.d.ts +31 -0
  16. package/dist/types/index.d.ts +9 -3
  17. package/dist/types/newCore/CanvasScheduler.d.ts +31 -0
  18. package/dist/types/newCore/index.d.ts +1 -0
  19. package/dist/types/utils/MathUtils.d.ts +6 -0
  20. package/dist/types/utils/tool/CommonToolUtils.d.ts +0 -13
  21. package/dist/types/utils/tool/EnhanceCommonToolUtils.d.ts +20 -0
  22. package/dist/types/utils/tool/PolygonUtils.d.ts +1 -0
  23. package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +3 -0
  24. package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +3 -0
  25. package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +3 -0
  26. package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +3 -0
  27. package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +3 -0
  28. package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +3 -0
  29. package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +3 -0
  30. package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +3 -0
  31. package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +3 -0
  32. package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +3 -0
  33. package/es/assets/attributeIcon/icon_editFEN.svg.js +3 -0
  34. package/es/assets/attributeIcon/icon_editHUANG.svg.js +3 -0
  35. package/es/assets/attributeIcon/icon_editLAN.svg.js +3 -0
  36. package/es/assets/attributeIcon/icon_editLV.svg.js +3 -0
  37. package/es/assets/attributeIcon/icon_editQING.svg.js +3 -0
  38. package/es/constant/annotation.js +68 -0
  39. package/es/constant/annotationTask.js +25 -0
  40. package/es/constant/defaultConfig.js +260 -0
  41. package/es/constant/keyCode.js +36 -0
  42. package/es/constant/style.js +67 -0
  43. package/es/constant/tool.js +183 -0
  44. package/es/core/index.js +145 -0
  45. package/es/core/pointCloud/OrbitControls.js +661 -0
  46. package/es/core/pointCloud/PCDLoader.js +238 -0
  47. package/es/core/pointCloud/annotation.js +98 -0
  48. package/es/core/pointCloud/cache.js +42 -0
  49. package/es/core/pointCloud/index.js +771 -0
  50. package/es/core/scheduler.js +184 -0
  51. package/es/core/toolOperation/LineToolOperation.js +1369 -0
  52. package/es/core/toolOperation/TextToolOperation.js +129 -0
  53. package/es/core/toolOperation/ViewOperation.js +410 -0
  54. package/es/core/toolOperation/basicToolOperation.js +817 -0
  55. package/es/core/toolOperation/checkOperation.js +206 -0
  56. package/es/core/toolOperation/eventListener.js +35 -0
  57. package/es/core/toolOperation/measureOperation.js +39 -0
  58. package/es/core/toolOperation/pointCloud2dOperation.js +197 -0
  59. package/es/core/toolOperation/pointOperation.js +603 -0
  60. package/es/core/toolOperation/polygonOperation.js +1201 -0
  61. package/es/core/toolOperation/rectOperation.js +1170 -0
  62. package/es/core/toolOperation/segmentByRect.js +172 -0
  63. package/es/core/toolOperation/tagOperation.js +215 -0
  64. package/es/core/toolOperation/textAttributeClass.js +201 -0
  65. package/es/index.js +25 -14
  66. package/es/locales/constants.js +21 -0
  67. package/es/locales/en_US/message.js +22 -0
  68. package/es/locales/index.js +17 -0
  69. package/es/locales/zh_CN/message.js +22 -0
  70. package/es/newCore/CanvasScheduler.js +31 -0
  71. package/es/utils/ActionsHistory.js +78 -0
  72. package/es/utils/ImgUtils.js +20 -0
  73. package/es/utils/MathUtils.js +283 -0
  74. package/es/utils/VectorUtils.js +23 -0
  75. package/es/utils/tool/AttributeUtils.js +196 -0
  76. package/es/utils/tool/AxisUtils.js +254 -0
  77. package/es/utils/tool/CanvasUtils.js +60 -0
  78. package/es/utils/tool/CommonToolUtils.js +172 -0
  79. package/es/utils/tool/CurrentOperation.js +35 -0
  80. package/es/utils/tool/DblClickEventListener.js +100 -0
  81. package/es/utils/tool/DrawUtils.js +424 -0
  82. package/es/utils/tool/EnhanceCommonToolUtils.js +39 -0
  83. package/es/utils/tool/ImgPosUtils.js +56 -0
  84. package/es/utils/tool/LineToolUtils.js +255 -0
  85. package/es/utils/tool/MarkerUtils.js +9 -0
  86. package/es/utils/tool/PolygonUtils.js +458 -0
  87. package/es/utils/tool/RectUtils.js +153 -0
  88. package/es/utils/tool/RenderDomClass.js +68 -0
  89. package/es/utils/tool/RenderDomUtils.js +29 -0
  90. package/es/utils/tool/StyleUtils.js +29 -0
  91. package/es/utils/tool/TagUtils.js +127 -0
  92. package/es/utils/tool/UnitUtils.js +10 -0
  93. package/es/utils/tool/ZoomUtils.js +70 -0
  94. package/es/utils/tool/polygonTool.js +126 -0
  95. package/es/utils/uuid.js +24 -0
  96. package/package.json +6 -4
@@ -0,0 +1,206 @@
1
+ import { cloneDeep } from 'lodash';
2
+ import CommonToolUtils from '../../utils/tool/CommonToolUtils.js';
3
+ import RectUtils from '../../utils/tool/RectUtils.js';
4
+ import TagUtil from '../../utils/tool/TagUtils.js';
5
+ import { DEFAULT_TEXT_OFFSET } from '../../constant/annotation.js';
6
+ import { EToolName } from '../../constant/tool.js';
7
+ import AttributeUtils from '../../utils/tool/AttributeUtils.js';
8
+ import AxisUtils from '../../utils/tool/AxisUtils.js';
9
+ import DrawUtils from '../../utils/tool/DrawUtils.js';
10
+ import StyleUtils from '../../utils/tool/StyleUtils.js';
11
+ import { BasicToolOperation } from './basicToolOperation.js';
12
+
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
17
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
18
+ var __spreadValues = (a, b) => {
19
+ for (var prop in b || (b = {}))
20
+ if (__hasOwnProp.call(b, prop))
21
+ __defNormalProp(a, prop, b[prop]);
22
+ if (__getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(b)) {
24
+ if (__propIsEnum.call(b, prop))
25
+ __defNormalProp(a, prop, b[prop]);
26
+ }
27
+ return a;
28
+ };
29
+ const TEXT_ATTRIBUTE_OFFSET = {
30
+ x: 8,
31
+ y: 26
32
+ };
33
+ const newScope = 2;
34
+ class CheckOperation extends BasicToolOperation {
35
+ constructor(props) {
36
+ super(props);
37
+ this.getHoverRectID = (e) => {
38
+ var _a, _b;
39
+ const coordinate = this.getCoordinateUnderZoom(e);
40
+ const currentShowList = (_b = (_a = this.resultList.find((v) => v.toolName === EToolName.Rect)) == null ? void 0 : _a.result) != null ? _b : [];
41
+ if (currentShowList.length > 0) {
42
+ const hoverList = currentShowList.filter((rect) => RectUtils.isInRect(coordinate, rect, newScope, this.zoom));
43
+ if (hoverList.length === 0) {
44
+ return "";
45
+ }
46
+ if (hoverList.length === 1) {
47
+ return hoverList[0].id;
48
+ }
49
+ if (hoverList.length > 1) {
50
+ const rectSizeList = hoverList.map((rect) => ({size: rect.width * rect.height, id: rect.id})).sort((a, b) => a.size - b.size);
51
+ return rectSizeList[0].id;
52
+ }
53
+ }
54
+ return "";
55
+ };
56
+ this.resultList = [];
57
+ this.hoverID = [];
58
+ this.fillID = [];
59
+ this.render = this.render.bind(this);
60
+ this.drawPolygon = this.drawPolygon.bind(this);
61
+ this.drawRect = this.drawRect.bind(this);
62
+ this.drawTag = this.drawTag.bind(this);
63
+ this.setShowDefaultCursor(true);
64
+ this.forbidOperation = true;
65
+ }
66
+ onMouseDown(e) {
67
+ var _a, _b;
68
+ if (super.onMouseDown(e) || this.forbidMouseOperation || !this.imgInfo) {
69
+ return true;
70
+ }
71
+ const newMouseSelectedID = this.mouseHoverID;
72
+ const currentShowList = (_b = (_a = this.resultList.find((v) => v.toolName === EToolName.Rect)) == null ? void 0 : _a.result) != null ? _b : [];
73
+ if (e.button === 0) {
74
+ let selectedID = [newMouseSelectedID];
75
+ let isShow = true;
76
+ if (newMouseSelectedID && currentShowList.find((rect) => rect.id === newMouseSelectedID && (rect == null ? void 0 : rect.isSelected))) {
77
+ isShow = false;
78
+ }
79
+ if (!newMouseSelectedID) {
80
+ selectedID = currentShowList.map((rect) => rect.id);
81
+ isShow = false;
82
+ }
83
+ this.emit("setSelectedID", selectedID, isShow);
84
+ this.render();
85
+ }
86
+ }
87
+ updateRotate() {
88
+ }
89
+ onMouseMove(e) {
90
+ if (super.onMouseMove(e) || this.forbidMouseOperation || !this.imgInfo) {
91
+ return;
92
+ }
93
+ const oldMouseHoverID = this.mouseHoverID;
94
+ const newMouseHoverID = this.getHoverRectID(e);
95
+ if (oldMouseHoverID !== newMouseHoverID) {
96
+ this.mouseHoverID = newMouseHoverID;
97
+ let hoverID = [newMouseHoverID];
98
+ if (!newMouseHoverID) {
99
+ hoverID = [];
100
+ }
101
+ this.emit("setHoverID", hoverID);
102
+ this.render();
103
+ }
104
+ }
105
+ setResult(result) {
106
+ this.resultList = cloneDeep(result);
107
+ this.render();
108
+ }
109
+ drawPolygon(polygonList, config) {
110
+ polygonList == null ? void 0 : polygonList.forEach((polygon) => {
111
+ var _a, _b, _c, _d, _e;
112
+ const toolColor = this.getColor(polygon.attribute, config);
113
+ const toolData = StyleUtils.getStrokeAndFill(toolColor, polygon.valid);
114
+ let thickness = (_b = (_a = this.style) == null ? void 0 : _a.width) != null ? _b : 2;
115
+ if (this.hoverID.includes(polygon.id)) {
116
+ thickness = 4;
117
+ DrawUtils.drawPolygonWithFillAndLine(this.canvas, AxisUtils.changePointListByZoom(polygon.pointList, this.zoom, this.currentPos), {
118
+ fillColor: toolData.fill,
119
+ strokeColor: toolData.stroke,
120
+ pointColor: "white",
121
+ thickness,
122
+ lineCap: "round",
123
+ isClose: true,
124
+ lineType: config == null ? void 0 : config.lineType
125
+ });
126
+ } else {
127
+ DrawUtils.drawPolygon(this.canvas, AxisUtils.changePointListByZoom(polygon.pointList, this.zoom, this.currentPos), {
128
+ color: toolData.fill,
129
+ lineType: (_c = this.config) == null ? void 0 : _c.lineType,
130
+ thickness,
131
+ isClose: true
132
+ });
133
+ }
134
+ let showText = `${(_e = AttributeUtils.getAttributeShowText(polygon.attribute, (_d = config == null ? void 0 : config.attributeList) != null ? _d : [])) != null ? _e : ""}`;
135
+ if ((config == null ? void 0 : config.isShowOrder) && (polygon == null ? void 0 : polygon.order) > 0) {
136
+ showText = `${polygon.order} ${showText}`;
137
+ }
138
+ DrawUtils.drawText(this.canvas, AxisUtils.changePointByZoom(polygon.pointList[0], this.zoom, this.currentPos), showText, __spreadValues({
139
+ color: toolData.stroke
140
+ }, DEFAULT_TEXT_OFFSET));
141
+ const transformPointList = AxisUtils.changePointListByZoom(polygon.pointList || [], this.zoom, this.currentPos);
142
+ const endPoint = transformPointList[transformPointList.length - 1];
143
+ DrawUtils.drawText(this.canvas, {x: endPoint.x + TEXT_ATTRIBUTE_OFFSET.x, y: endPoint.y + TEXT_ATTRIBUTE_OFFSET.y}, polygon == null ? void 0 : polygon.textAttribute, __spreadValues({
144
+ color: toolData.stroke
145
+ }, DEFAULT_TEXT_OFFSET));
146
+ });
147
+ }
148
+ drawRect(rectList, config) {
149
+ rectList == null ? void 0 : rectList.forEach((rect) => {
150
+ let thickness = 1;
151
+ if (this.hoverID.includes(rect.id)) {
152
+ thickness = 3;
153
+ }
154
+ const toolColor = this.getColor(rect.attribute, config);
155
+ const renderRect = AxisUtils.changeRectByZoom(rect, this.zoom, this.currentPos);
156
+ DrawUtils.drawRect(this.canvas, renderRect, {
157
+ color: (rect == null ? void 0 : rect.valid) ? toolColor.valid.stroke : toolColor.invalid.stroke,
158
+ thickness
159
+ });
160
+ if (this.fillID.includes(rect.id)) {
161
+ DrawUtils.drawRectWithFill(this.canvas, renderRect, {
162
+ color: (rect == null ? void 0 : rect.valid) ? toolColor.valid.fill : toolColor.invalid.fill
163
+ });
164
+ }
165
+ });
166
+ }
167
+ drawTag(tagList, config) {
168
+ const tagInfoList = tagList.reduce((acc, cur) => {
169
+ return [
170
+ ...acc,
171
+ ...(config == null ? void 0 : config.inputList) ? TagUtil.getTagNameList(cur.result, config.inputList) : TagUtil.getTagnameListWithoutConfig(cur.result)
172
+ ];
173
+ }, []);
174
+ DrawUtils.drawTag(this.canvas, tagInfoList);
175
+ }
176
+ setHoverID(hoverID) {
177
+ this.hoverID = hoverID;
178
+ this.render();
179
+ }
180
+ setFillID(fillID) {
181
+ this.fillID = fillID;
182
+ this.render();
183
+ }
184
+ render() {
185
+ var _a;
186
+ super.render();
187
+ (_a = this.resultList) == null ? void 0 : _a.forEach((item) => {
188
+ switch (item == null ? void 0 : item.toolName) {
189
+ case EToolName.Rect:
190
+ this.drawRect(item.result, CommonToolUtils.jsonParser(item.config));
191
+ break;
192
+ case EToolName.Polygon:
193
+ this.drawPolygon(item.result, CommonToolUtils.jsonParser(item.config));
194
+ break;
195
+ case EToolName.Tag:
196
+ this.drawTag(item.result, CommonToolUtils.jsonParser(item.config));
197
+ break;
198
+ }
199
+ });
200
+ }
201
+ exportData() {
202
+ return [[], {}];
203
+ }
204
+ }
205
+
206
+ export { CheckOperation as default };
@@ -0,0 +1,35 @@
1
+ class EventListener {
2
+ constructor() {
3
+ this._events = new Map();
4
+ }
5
+ on(eventName, callback) {
6
+ const existEvents = this._events.get(eventName) || [];
7
+ if (!existEvents.some((fn) => fn === callback)) {
8
+ this._events.set(eventName, existEvents.concat(callback));
9
+ }
10
+ }
11
+ singleOn(eventName, callback) {
12
+ this._events.set(eventName, [callback]);
13
+ }
14
+ emit(eventName, ...args) {
15
+ const listener = this._events.get(eventName);
16
+ if (listener) {
17
+ listener.forEach((fn) => {
18
+ if (fn) {
19
+ fn(...args);
20
+ }
21
+ });
22
+ }
23
+ }
24
+ unbind(eventName, callback) {
25
+ const existEvents = this._events.get(eventName);
26
+ if (existEvents) {
27
+ this._events.set(eventName, existEvents.filter((fn) => fn !== callback));
28
+ }
29
+ }
30
+ unbindAll(eventName) {
31
+ this._events.delete(eventName);
32
+ }
33
+ }
34
+
35
+ export { EventListener as default };
@@ -0,0 +1,39 @@
1
+ import { RectOperation } from './rectOperation.js';
2
+
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ const config = {
23
+ textConfigurable: false,
24
+ attributeConfigurable: true,
25
+ attributeList: []
26
+ };
27
+ class MeasureOperation extends RectOperation {
28
+ constructor(props) {
29
+ super(__spreadProps(__spreadValues({}, props), {config: JSON.stringify(config)}));
30
+ }
31
+ setSelectedIdAfterAddingDrawingRect() {
32
+ if (!this.drawingRect) {
33
+ return;
34
+ }
35
+ this.setSelectedRectID(this.drawingRect.id);
36
+ }
37
+ }
38
+
39
+ export { MeasureOperation as default };
@@ -0,0 +1,197 @@
1
+ import { ESortDirection } from '../../constant/annotation.js';
2
+ import { EPolygonPattern } from '../../constant/tool.js';
3
+ import AxisUtils from '../../utils/tool/AxisUtils.js';
4
+ import CommonToolUtils from '../../utils/tool/CommonToolUtils.js';
5
+ import DrawUtils from '../../utils/tool/DrawUtils.js';
6
+ import PolygonUtils from '../../utils/tool/PolygonUtils.js';
7
+ import StyleUtils from '../../utils/tool/StyleUtils.js';
8
+ import PolygonOperation from './polygonOperation.js';
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __defProps = Object.defineProperties;
12
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
13
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
14
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
15
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
16
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
17
+ var __spreadValues = (a, b) => {
18
+ for (var prop in b || (b = {}))
19
+ if (__hasOwnProp.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ if (__getOwnPropSymbols)
22
+ for (var prop of __getOwnPropSymbols(b)) {
23
+ if (__propIsEnum.call(b, prop))
24
+ __defNormalProp(a, prop, b[prop]);
25
+ }
26
+ return a;
27
+ };
28
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
29
+ class PointCloud2dOperation extends PolygonOperation {
30
+ constructor(props) {
31
+ super(props);
32
+ this.selectedIDs = [];
33
+ this.rightMouseUp = (e) => {
34
+ if (this.drawingPointList.length > 0) {
35
+ this.addDrawingPointToPolygonList();
36
+ return;
37
+ }
38
+ if (e.ctrlKey && this.hoverID) {
39
+ this.emit("addSelectedIDs", this.hoverID);
40
+ } else {
41
+ this.emit("setSelectedIDs", this.hoverID);
42
+ }
43
+ };
44
+ this.onKeyDown = () => {
45
+ };
46
+ this.onKeyUp = () => {
47
+ };
48
+ this.renderSingleSelectedPolygon = (selectedPolygon) => {
49
+ var _a;
50
+ if (this.selectedPolygons) {
51
+ const toolColor = this.getColor(selectedPolygon.attribute);
52
+ const toolData = StyleUtils.getStrokeAndFill(toolColor, selectedPolygon.valid, {isSelected: true});
53
+ const polygon = AxisUtils.changePointListByZoom(selectedPolygon.pointList, this.zoom, this.currentPos);
54
+ DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas, polygon, {
55
+ fillColor: "transparent",
56
+ strokeColor: toolData.stroke,
57
+ pointColor: "white",
58
+ thickness: 2,
59
+ lineCap: "round",
60
+ isClose: true,
61
+ lineType: (_a = this.config) == null ? void 0 : _a.lineType
62
+ });
63
+ if (selectedPolygon.isRect === true && this.showDirectionLine === true) {
64
+ this.renderRectPolygonDirection(polygon);
65
+ }
66
+ }
67
+ };
68
+ var _a, _b;
69
+ this.showDirectionLine = (_a = props.showDirectionLine) != null ? _a : true;
70
+ this.forbidAddNew = (_b = props.forbidAddNew) != null ? _b : false;
71
+ }
72
+ get getSelectedIDs() {
73
+ return this.selectedIDs;
74
+ }
75
+ setSelectedIDs(selectedIDs) {
76
+ this.selectedIDs = selectedIDs;
77
+ this.setSelectedID(this.selectedIDs.length === 1 ? this.selectedIDs[0] : "");
78
+ this.render();
79
+ }
80
+ deleteSelectedID() {
81
+ super.deleteSelectedID();
82
+ this.selectedIDs = [];
83
+ this.emit("deleteSelectedIDs");
84
+ }
85
+ get selectedPolygons() {
86
+ return PolygonUtils.getPolygonByIDs(this.polygonList, this.selectedIDs);
87
+ }
88
+ getLineColor() {
89
+ return "rgba(0, 255, 255, 0.5)";
90
+ }
91
+ renderStaticPolygon() {
92
+ var _a;
93
+ if (this.isHidden === false) {
94
+ (_a = this.polygonList) == null ? void 0 : _a.forEach((polygon) => {
95
+ var _a2, _b, _c;
96
+ if ([...this.selectedIDs, this.editPolygonID].includes(polygon.id)) {
97
+ return;
98
+ }
99
+ const {attribute} = polygon;
100
+ const toolColor = this.getColor(attribute);
101
+ const toolData = StyleUtils.getStrokeAndFill(toolColor, polygon.valid);
102
+ const transformPointList = AxisUtils.changePointListByZoom(polygon.pointList || [], this.zoom, this.currentPos);
103
+ DrawUtils.drawPolygonWithFillAndLine(this.canvas, transformPointList, {
104
+ fillColor: "transparent",
105
+ strokeColor: toolData.stroke,
106
+ pointColor: "white",
107
+ thickness: (_b = (_a2 = this.style) == null ? void 0 : _a2.width) != null ? _b : 2,
108
+ lineCap: "round",
109
+ isClose: true,
110
+ lineType: (_c = this.config) == null ? void 0 : _c.lineType
111
+ });
112
+ if (polygon.isRect === true && this.showDirectionLine === true) {
113
+ this.renderRectPolygonDirection(transformPointList);
114
+ }
115
+ });
116
+ }
117
+ }
118
+ renderSelectedPolygon() {
119
+ var _a;
120
+ (_a = this.selectedPolygons) == null ? void 0 : _a.forEach((polygon) => {
121
+ this.renderSingleSelectedPolygon(polygon);
122
+ });
123
+ }
124
+ renderRectPolygonDirection(polygon) {
125
+ if (polygon.length < 2) {
126
+ return;
127
+ }
128
+ DrawUtils.drawLine(this.canvas, polygon[0], polygon[1], {
129
+ color: "red",
130
+ thickness: 3
131
+ });
132
+ }
133
+ get currentPolygonListByPattern() {
134
+ return this.polygonList.filter((v) => {
135
+ if (this.pattern === EPolygonPattern.Rect) {
136
+ return v.isRect === true;
137
+ }
138
+ if (this.pattern === EPolygonPattern.Normal) {
139
+ return v.isRect !== true;
140
+ }
141
+ return true;
142
+ });
143
+ }
144
+ getHoverID(e) {
145
+ var _a;
146
+ const coordinate = this.getCoordinateUnderZoom(e);
147
+ const currentPolygonList = this.currentPolygonListByPattern;
148
+ const polygonListWithZoom = currentPolygonList.map((polygon) => __spreadProps(__spreadValues({}, polygon), {
149
+ pointList: AxisUtils.changePointListByZoom(polygon.pointList, this.zoom)
150
+ }));
151
+ return PolygonUtils.getHoverPolygonID(coordinate, polygonListWithZoom, 10, (_a = this.config) == null ? void 0 : _a.lineType);
152
+ }
153
+ switchToNextPolygon(sort = ESortDirection.ascend) {
154
+ if (this.drawingPointList.length > 0) {
155
+ return;
156
+ }
157
+ const sortList = this.currentPolygonListByPattern.map((v) => {
158
+ var _a, _b, _c, _d;
159
+ return __spreadProps(__spreadValues({}, v), {
160
+ x: (_b = (_a = v.pointList[0]) == null ? void 0 : _a.x) != null ? _b : 0,
161
+ y: (_d = (_c = v.pointList[0]) == null ? void 0 : _c.y) != null ? _d : 0
162
+ });
163
+ });
164
+ const nextSelectedResult = CommonToolUtils.getNextSelectedRectID(sortList, sort, this.selectedID);
165
+ if (nextSelectedResult) {
166
+ this.setSelectedIDs([nextSelectedResult.id]);
167
+ }
168
+ this.render();
169
+ return [nextSelectedResult.id];
170
+ }
171
+ setSelectedIdAfterAddingDrawing(newID) {
172
+ if (this.drawingPointList.length === 0) {
173
+ return;
174
+ }
175
+ this.setSelectedID(newID);
176
+ }
177
+ setSelectedID(newID) {
178
+ var _a, _b;
179
+ const oldID = this.selectedID;
180
+ if (newID !== oldID && oldID) {
181
+ (_a = this._textAttributInstance) == null ? void 0 : _a.changeSelected();
182
+ }
183
+ if (!newID) {
184
+ (_b = this._textAttributInstance) == null ? void 0 : _b.clearTextAttribute();
185
+ }
186
+ this.selectedID = newID;
187
+ this.render();
188
+ }
189
+ addPointInDrawing(e) {
190
+ if (this.forbidAddNew) {
191
+ return;
192
+ }
193
+ super.addPointInDrawing(e);
194
+ }
195
+ }
196
+
197
+ export { PointCloud2dOperation as default };