@labelbee/lb-annotation 1.8.0 → 1.8.1-alpha.0
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 +9 -9
- package/dist/types/core/toolOperation/ViewOperation.d.ts +31 -0
- package/dist/types/utils/MathUtils.d.ts +3 -0
- package/dist/types/utils/tool/DrawUtils.d.ts +14 -13
- package/es/.DS_Store +0 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +1 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +1 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +1 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +2 -0
- package/es/_virtual/filterBoxWorker.js +1 -0
- package/es/_virtual/highlightWorker.js +1 -0
- package/es/_virtual/worker.js +6 -0
- package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +3 -0
- package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +3 -0
- package/es/assets/attributeIcon/icon_editFEN.svg.js +3 -0
- package/es/assets/attributeIcon/icon_editHUANG.svg.js +3 -0
- package/es/assets/attributeIcon/icon_editLAN.svg.js +3 -0
- package/es/assets/attributeIcon/icon_editLV.svg.js +3 -0
- package/es/assets/attributeIcon/icon_editQING.svg.js +3 -0
- package/es/constant/annotation.js +68 -0
- package/es/constant/annotationTask.js +25 -0
- package/es/constant/defaultConfig.js +260 -0
- package/es/constant/keyCode.js +36 -0
- package/es/constant/style.js +67 -0
- package/es/constant/tool.js +181 -0
- package/es/core/index.js +134 -0
- package/es/core/pointCloud/OrbitControls.js +1 -0
- package/es/core/pointCloud/PCDLoader.js +2 -0
- package/es/core/pointCloud/annotation.js +1 -0
- package/es/core/pointCloud/cache.js +1 -0
- package/es/core/pointCloud/index.js +11 -0
- package/es/core/scheduler.js +1 -0
- package/es/core/toolOperation/LineToolOperation.js +1369 -0
- package/es/core/toolOperation/TextToolOperation.js +129 -0
- package/es/core/toolOperation/ViewOperation.js +414 -0
- package/es/core/toolOperation/basicToolOperation.js +796 -0
- package/es/core/toolOperation/checkOperation.js +206 -0
- package/es/core/toolOperation/eventListener.js +35 -0
- package/es/core/toolOperation/measureOperation.js +39 -0
- package/es/core/toolOperation/pointCloud2dOperation.js +1 -0
- package/es/core/toolOperation/pointOperation.js +603 -0
- package/es/core/toolOperation/polygonOperation.js +1160 -0
- package/es/core/toolOperation/rectOperation.js +1166 -0
- package/es/core/toolOperation/segmentByRect.js +1 -0
- package/es/core/toolOperation/tagOperation.js +215 -0
- package/es/core/toolOperation/textAttributeClass.js +201 -0
- package/es/index.js +13 -13
- package/es/locales/constants.js +21 -0
- package/es/locales/en_US/message.js +22 -0
- package/es/locales/index.js +17 -0
- package/es/locales/zh_CN/message.js +22 -0
- package/es/newCore/CanvasScheduler.js +1 -0
- package/es/utils/ActionsHistory.js +78 -0
- package/es/utils/ImgUtils.js +20 -0
- package/es/utils/MathUtils.js +339 -0
- package/es/utils/VectorUtils.js +23 -0
- package/es/utils/tool/AttributeUtils.js +196 -0
- package/es/utils/tool/AxisUtils.js +254 -0
- package/es/utils/tool/CanvasUtils.js +60 -0
- package/es/utils/tool/CommonToolUtils.js +201 -0
- package/es/utils/tool/CurrentOperation.js +35 -0
- package/es/utils/tool/DblClickEventListener.js +100 -0
- package/es/utils/tool/DrawUtils.js +424 -0
- package/es/utils/tool/EnhanceCommonToolUtils.js +1 -0
- package/es/utils/tool/ImgPosUtils.js +56 -0
- package/es/utils/tool/LineToolUtils.js +255 -0
- package/es/utils/tool/MarkerUtils.js +9 -0
- package/es/utils/tool/PolygonUtils.js +453 -0
- package/es/utils/tool/RectUtils.js +153 -0
- package/es/utils/tool/RenderDomClass.js +68 -0
- package/es/utils/tool/RenderDomUtils.js +29 -0
- package/es/utils/tool/StyleUtils.js +29 -0
- package/es/utils/tool/TagUtils.js +127 -0
- package/es/utils/tool/UnitUtils.js +10 -0
- package/es/utils/tool/ZoomUtils.js +70 -0
- package/es/utils/tool/polygonTool.js +126 -0
- package/es/utils/uuid.js +24 -0
- package/package.json +2 -3
- package/LICENSE +0 -203
|
@@ -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 @@
|
|
|
1
|
+
import{ESortDirection as v}from"../../constant/annotation.js";import{EPolygonPattern as u}from"../../constant/tool.js";import c from"../../utils/tool/AxisUtils.js";import m from"../../utils/tool/CommonToolUtils.js";import d from"../../utils/tool/DrawUtils.js";import g from"../../utils/tool/PolygonUtils.js";import p from"../../utils/tool/StyleUtils.js";import I from"./polygonOperation.js";var _=Object.defineProperty,S=Object.defineProperties,L=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,P=(s,t,e)=>t in s?_(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,y=(s,t)=>{for(var e in t||(t={}))w.call(t,e)&&P(s,e,t[e]);if(f)for(var e of f(t))C.call(t,e)&&P(s,e,t[e]);return s},D=(s,t)=>S(s,L(t));class b extends I{constructor(t){super(t);this.selectedIDs=[],this.rightMouseUp=i=>{if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}i.ctrlKey&&this.hoverID?this.emit("addSelectedIDs",this.hoverID):this.emit("setSelectedIDs",this.hoverID)},this.onKeyDown=()=>{},this.onKeyUp=()=>{},this.renderSingleSelectedPolygon=i=>{var r;if(this.selectedPolygons){const n=this.getColor(i.attribute),a=p.getStrokeAndFill(n,i.valid,{isSelected:!0}),l=c.changePointListByZoom(i.pointList,this.zoom,this.currentPos);d.drawSelectedPolygonWithFillAndLine(this.canvas,l,{fillColor:"transparent",strokeColor:a.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(r=this.config)==null?void 0:r.lineType}),i.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(l)}};var e,o;this.showDirectionLine=(e=t.showDirectionLine)!=null?e:!0,this.forbidAddNew=(o=t.forbidAddNew)!=null?o:!1}get getSelectedIDs(){return this.selectedIDs}setSelectedIDs(t){this.selectedIDs=t,this.setSelectedID(this.selectedIDs.length===1?this.selectedIDs[0]:""),this.render()}deleteSelectedID(){super.deleteSelectedID(),this.selectedIDs=[],this.emit("deleteSelectedIDs")}get selectedPolygons(){return g.getPolygonByIDs(this.polygonList,this.selectedIDs)}getLineColor(){return"rgba(0, 255, 255, 0.5)"}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.polygonList)==null||t.forEach(e=>{var o,i,r;if([...this.selectedIDs,this.editPolygonID].includes(e.id))return;const{attribute:n}=e,a=this.getColor(n),l=p.getStrokeAndFill(a,e.valid),h=c.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);d.drawPolygonWithFillAndLine(this.canvas,h,{fillColor:"transparent",strokeColor:l.stroke,pointColor:"white",thickness:(i=(o=this.style)==null?void 0:o.width)!=null?i:2,lineCap:"round",isClose:!0,lineType:(r=this.config)==null?void 0:r.lineType}),e.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(h)}))}renderSelectedPolygon(){var t;(t=this.selectedPolygons)==null||t.forEach(e=>{this.renderSingleSelectedPolygon(e)})}renderRectPolygonDirection(t){t.length<2||d.drawLine(this.canvas,t[0],t[1],{color:"red",thickness:3})}get currentPolygonListByPattern(){return this.polygonList.filter(t=>this.pattern===u.Rect?t.isRect===!0:this.pattern===u.Normal?t.isRect!==!0:!0)}getHoverID(t){var e;const o=this.getCoordinateUnderZoom(t),r=this.currentPolygonListByPattern.map(n=>D(y({},n),{pointList:c.changePointListByZoom(n.pointList,this.zoom)}));return g.getHoverPolygonID(o,r,10,(e=this.config)==null?void 0:e.lineType)}switchToNextPolygon(t=v.ascend){if(this.drawingPointList.length>0)return;const e=this.currentPolygonListByPattern.map(i=>{var r,n,a,l;return D(y({},i),{x:(n=(r=i.pointList[0])==null?void 0:r.x)!=null?n:0,y:(l=(a=i.pointList[0])==null?void 0:a.y)!=null?l:0})}),o=m.getNextSelectedRectID(e,t,this.selectedID);if(o)return this.setSelectedIDs([o.id]),this.render(),[o.id]}setSelectedIdAfterAddingDrawing(t){this.drawingPointList.length!==0&&this.setSelectedID(t)}setSelectedID(t){var e,o;const i=this.selectedID;t!==i&&i&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(o=this._textAttributInstance)==null||o.clearTextAttribute(),this.selectedID=t,this.render()}addPointInDrawing(t){this.forbidAddNew||super.addPointInDrawing(t)}setCanvasSize(t){var e,o;const i=this.pixelRatio;this.size=t,this.setImgInfo(t),this.updateCanvasBasicStyle(this.basicCanvas,t,0),this.updateCanvasBasicStyle(this.canvas,t,10),(e=this.ctx)==null||e.scale(i,i),(o=this.basicCtx)==null||o.scale(i,i),this.initImgPos(),this.renderBasicCanvas(),this.render()}}export{b as default};
|