@labelbee/lb-annotation 1.14.0-alpha.3 → 1.14.0-alpha.5
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/_virtual/MathUtilsWorker.js +1 -8
- package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -35
- package/dist/_virtual/filterBoxWorker.js +1 -8
- package/dist/_virtual/highlightWorker.js +1 -8
- package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -5
- package/dist/assets/attributeIcon/icon_cuboidMore.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidRight.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidTop.svg.js +12 -5
- package/dist/assets/attributeIcon/icon_editFEN.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editHUANG.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editLAN.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editLV.svg.js +1 -5
- package/dist/assets/attributeIcon/icon_editQING.svg.js +1 -5
- package/dist/constant/annotation.js +1 -127
- package/dist/constant/annotationTask.js +1 -30
- package/dist/constant/defaultConfig.js +1 -266
- package/dist/constant/keyCode.js +1 -38
- package/dist/constant/style.js +1 -98
- package/dist/constant/tool.js +1 -236
- package/dist/core/index.js +1 -150
- package/dist/core/pointCloud/OrbitControls.js +1 -665
- package/dist/core/pointCloud/PCDLoader.js +2 -260
- package/dist/core/pointCloud/annotation.js +1 -215
- package/dist/core/pointCloud/cache.js +1 -53
- package/dist/core/pointCloud/index.js +5 -991
- package/dist/core/pointCloud/matrix.js +1 -138
- package/dist/core/scheduler.js +1 -233
- package/dist/core/toolOperation/LineToolOperation.js +1 -1434
- package/dist/core/toolOperation/ScribbleTool.js +1 -292
- package/dist/core/toolOperation/TextToolOperation.js +1 -131
- package/dist/core/toolOperation/ViewOperation.js +1 -556
- package/dist/core/toolOperation/basicToolOperation.js +1 -881
- package/dist/core/toolOperation/checkOperation.js +1 -208
- package/dist/core/toolOperation/cuboidOperation.js +1 -754
- package/dist/core/toolOperation/cuboidToggleButtonClass.js +7 -152
- package/dist/core/toolOperation/eventListener.js +1 -37
- package/dist/core/toolOperation/measureOperation.js +1 -41
- package/dist/core/toolOperation/pointCloud2dOperation.js +1 -365
- package/dist/core/toolOperation/pointOperation.js +1 -696
- package/dist/core/toolOperation/polygonOperation.js +1 -1251
- package/dist/core/toolOperation/rectOperation.js +1 -1233
- package/dist/core/toolOperation/segmentByRect.js +1 -174
- package/dist/core/toolOperation/tagOperation.js +3 -201
- package/dist/core/toolOperation/textAttributeClass.js +16 -182
- package/dist/index.js +1 -185
- package/dist/locales/constants.js +1 -24
- package/dist/locales/en_US/message.js +1 -25
- package/dist/locales/index.js +1 -19
- package/dist/locales/zh_CN/message.js +1 -25
- package/dist/newCore/CanvasScheduler.js +1 -35
- package/dist/utils/ActionsHistory.js +1 -84
- package/dist/utils/ImgUtils.js +1 -23
- package/dist/utils/MathUtils.js +2 -385
- package/dist/utils/VectorUtils.js +1 -25
- package/dist/utils/tool/AttributeUtils.js +1 -218
- package/dist/utils/tool/AxisUtils.js +1 -340
- package/dist/utils/tool/CanvasUtils.js +1 -62
- package/dist/utils/tool/CommonToolUtils.js +1 -174
- package/dist/utils/tool/CuboidUtils.js +1 -704
- package/dist/utils/tool/DblClickEventListener.js +1 -102
- package/dist/utils/tool/DrawUtils.js +3 -492
- package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -53
- package/dist/utils/tool/ImgPosUtils.js +1 -58
- package/dist/utils/tool/LineToolUtils.js +1 -261
- package/dist/utils/tool/MarkerUtils.js +1 -56
- package/dist/utils/tool/PolygonUtils.js +1 -460
- package/dist/utils/tool/RectUtils.js +1 -155
- package/dist/utils/tool/RenderDomClass.js +7 -57
- package/dist/utils/tool/RenderDomUtils.js +4 -21
- package/dist/utils/tool/StyleUtils.js +1 -31
- package/dist/utils/tool/TagUtils.js +1 -129
- package/dist/utils/tool/UnitUtils.js +1 -12
- package/dist/utils/tool/ZoomUtils.js +1 -72
- package/dist/utils/tool/polygonTool.js +1 -133
- package/dist/utils/uuid.js +1 -26
- package/es/_virtual/MathUtilsWorker.js +1 -6
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -31
- package/es/_virtual/filterBoxWorker.js +1 -6
- package/es/_virtual/highlightWorker.js +1 -6
- package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -3
- package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -3
- package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -3
- package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -3
- package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -3
- package/es/assets/attributeIcon/icon_editFEN.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editHUANG.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editLAN.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editLV.svg.js +1 -3
- package/es/assets/attributeIcon/icon_editQING.svg.js +1 -3
- package/es/constant/annotation.js +1 -113
- package/es/constant/annotationTask.js +1 -25
- package/es/constant/defaultConfig.js +1 -260
- package/es/constant/keyCode.js +1 -36
- package/es/constant/style.js +1 -74
- package/es/constant/tool.js +1 -220
- package/es/core/index.js +1 -148
- package/es/core/pointCloud/OrbitControls.js +1 -661
- package/es/core/pointCloud/PCDLoader.js +2 -256
- package/es/core/pointCloud/annotation.js +1 -211
- package/es/core/pointCloud/cache.js +1 -49
- package/es/core/pointCloud/index.js +5 -962
- package/es/core/pointCloud/matrix.js +1 -109
- package/es/core/scheduler.js +1 -228
- package/es/core/toolOperation/LineToolOperation.js +1 -1421
- package/es/core/toolOperation/ScribbleTool.js +1 -290
- package/es/core/toolOperation/TextToolOperation.js +1 -129
- package/es/core/toolOperation/ViewOperation.js +1 -549
- package/es/core/toolOperation/basicToolOperation.js +1 -877
- package/es/core/toolOperation/checkOperation.js +1 -206
- package/es/core/toolOperation/cuboidOperation.js +1 -752
- package/es/core/toolOperation/cuboidToggleButtonClass.js +7 -150
- package/es/core/toolOperation/eventListener.js +1 -35
- package/es/core/toolOperation/measureOperation.js +1 -39
- package/es/core/toolOperation/pointCloud2dOperation.js +1 -359
- package/es/core/toolOperation/pointOperation.js +1 -690
- package/es/core/toolOperation/polygonOperation.js +1 -1245
- package/es/core/toolOperation/rectOperation.js +1 -1228
- package/es/core/toolOperation/segmentByRect.js +1 -172
- package/es/core/toolOperation/tagOperation.js +3 -199
- package/es/core/toolOperation/textAttributeClass.js +16 -180
- package/es/index.js +1 -46
- package/es/locales/constants.js +1 -22
- package/es/locales/en_US/message.js +1 -23
- package/es/locales/index.js +1 -17
- package/es/locales/zh_CN/message.js +1 -23
- package/es/newCore/CanvasScheduler.js +1 -31
- package/es/utils/ActionsHistory.js +1 -78
- package/es/utils/ImgUtils.js +1 -21
- package/es/utils/MathUtils.js +2 -380
- package/es/utils/VectorUtils.js +1 -23
- package/es/utils/tool/AttributeUtils.js +1 -212
- package/es/utils/tool/AxisUtils.js +1 -335
- package/es/utils/tool/CanvasUtils.js +1 -60
- package/es/utils/tool/CommonToolUtils.js +1 -172
- package/es/utils/tool/CuboidUtils.js +1 -680
- package/es/utils/tool/DblClickEventListener.js +1 -100
- package/es/utils/tool/DrawUtils.js +3 -490
- package/es/utils/tool/EnhanceCommonToolUtils.js +1 -48
- package/es/utils/tool/ImgPosUtils.js +1 -56
- package/es/utils/tool/LineToolUtils.js +1 -255
- package/es/utils/tool/MarkerUtils.js +1 -54
- package/es/utils/tool/PolygonUtils.js +1 -458
- package/es/utils/tool/RectUtils.js +1 -153
- package/es/utils/tool/RenderDomClass.js +7 -55
- package/es/utils/tool/RenderDomUtils.js +4 -19
- package/es/utils/tool/StyleUtils.js +1 -29
- package/es/utils/tool/TagUtils.js +1 -127
- package/es/utils/tool/UnitUtils.js +1 -10
- package/es/utils/tool/ZoomUtils.js +1 -70
- package/es/utils/tool/polygonTool.js +1 -126
- package/es/utils/uuid.js +1 -24
- package/package.json +3 -4
- package/LICENSE +0 -203
- package/dist/core/pointCloud/segmentation.js +0 -144
- package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +0 -26
- package/dist/core/pointCloud/selector/Sse3dSelector.js +0 -16
- package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
- package/dist/types/core/pointCloud/selector/Sse3dLassoSelector.d.ts +0 -0
- package/dist/types/core/pointCloud/selector/Sse3dSelector.d.ts +0 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -12
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -7
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -18
- package/es/core/pointCloud/segmentation.js +0 -120
- package/es/core/pointCloud/selector/Sse3dLassoSelector.js +0 -24
- package/es/core/pointCloud/selector/Sse3dSelector.js +0 -14
- package/es/core/toolOperation/scribbleTool2.js +0 -249
|
@@ -1,206 +1 @@
|
|
|
1
|
-
import {
|
|
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 };
|
|
1
|
+
import{cloneDeep as L}from"lodash";import w from"../../utils/tool/CommonToolUtils.js";import R from"../../utils/tool/RectUtils.js";import D from"../../utils/tool/TagUtils.js";import{DEFAULT_TEXT_OFFSET as I}from"../../constant/annotation.js";import{EToolName as c}from"../../constant/tool.js";import S from"../../utils/tool/AttributeUtils.js";import f from"../../utils/tool/AxisUtils.js";import d from"../../utils/tool/DrawUtils.js";import O from"../../utils/tool/StyleUtils.js";import{BasicToolOperation as U}from"./basicToolOperation.js";var y=Object.defineProperty,P=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable,g=(a,i,t)=>i in a?y(a,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[i]=t,_=(a,i)=>{for(var t in i||(i={}))C.call(i,t)&&g(a,t,i[t]);if(P)for(var t of P(i))j.call(i,t)&&g(a,t,i[t]);return a};const b={x:8,y:26},x=2;class E extends U{constructor(i){super(i);this.getHoverRectID=t=>{var o,e;const s=this.getCoordinateUnderZoom(t),l=(e=(o=this.resultList.find(r=>r.toolName===c.Rect))==null?void 0:o.result)!=null?e:[];if(l.length>0){const r=l.filter(n=>R.isInRect(s,n,x,this.zoom));if(r.length===0)return"";if(r.length===1)return r[0].id;if(r.length>1)return r.map(h=>({size:h.width*h.height,id:h.id})).sort((h,u)=>h.size-u.size)[0].id}return""},this.resultList=[],this.hoverID=[],this.fillID=[],this.render=this.render.bind(this),this.drawPolygon=this.drawPolygon.bind(this),this.drawRect=this.drawRect.bind(this),this.drawTag=this.drawTag.bind(this),this.setShowDefaultCursor(!0),this.forbidOperation=!0}onMouseDown(i){var t,o;if(super.onMouseDown(i)||this.forbidMouseOperation||!this.imgInfo)return!0;const e=this.mouseHoverID,s=(o=(t=this.resultList.find(l=>l.toolName===c.Rect))==null?void 0:t.result)!=null?o:[];if(i.button===0){let l=[e],r=!0;e&&s.find(n=>n.id===e&&(n==null?void 0:n.isSelected))&&(r=!1),e||(l=s.map(n=>n.id),r=!1),this.emit("setSelectedID",l,r),this.render()}}updateRotate(){}onMouseMove(i){if(super.onMouseMove(i)||this.forbidMouseOperation||!this.imgInfo)return;const t=this.mouseHoverID,o=this.getHoverRectID(i);if(t!==o){this.mouseHoverID=o;let e=[o];o||(e=[]),this.emit("setHoverID",e),this.render()}}setResult(i){this.resultList=L(i),this.render()}drawPolygon(i,t){i==null||i.forEach(o=>{var e,s,l,r,n;const h=this.getColor(o.attribute,t),u=O.getStrokeAndFill(h,o.valid);let v=(s=(e=this.style)==null?void 0:e.width)!=null?s:2;this.hoverID.includes(o.id)?(v=4,d.drawPolygonWithFillAndLine(this.canvas,f.changePointListByZoom(o.pointList,this.zoom,this.currentPos),{fillColor:u.fill,strokeColor:u.stroke,pointColor:"white",thickness:v,lineCap:"round",isClose:!0,lineType:t==null?void 0:t.lineType})):d.drawPolygon(this.canvas,f.changePointListByZoom(o.pointList,this.zoom,this.currentPos),{color:u.fill,lineType:(l=this.config)==null?void 0:l.lineType,thickness:v,isClose:!0});let m=`${(n=S.getAttributeShowText(o.attribute,(r=t==null?void 0:t.attributeList)!=null?r:[]))!=null?n:""}`;(t==null?void 0:t.isShowOrder)&&(o==null?void 0:o.order)>0&&(m=`${o.order} ${m}`),d.drawText(this.canvas,f.changePointByZoom(o.pointList[0],this.zoom,this.currentPos),m,_({color:u.stroke},I));const p=f.changePointListByZoom(o.pointList||[],this.zoom,this.currentPos),T=p[p.length-1];d.drawText(this.canvas,{x:T.x+b.x,y:T.y+b.y},o==null?void 0:o.textAttribute,_({color:u.stroke},I))})}drawRect(i,t){i==null||i.forEach(o=>{let e=1;this.hoverID.includes(o.id)&&(e=3);const s=this.getColor(o.attribute,t),l=f.changeRectByZoom(o,this.zoom,this.currentPos);d.drawRect(this.canvas,l,{color:(o==null?void 0:o.valid)?s.valid.stroke:s.invalid.stroke,thickness:e}),this.fillID.includes(o.id)&&d.drawRectWithFill(this.canvas,l,{color:(o==null?void 0:o.valid)?s.valid.fill:s.invalid.fill})})}drawTag(i,t){const o=i.reduce((e,s)=>[...e,...(t==null?void 0:t.inputList)?D.getTagNameList(s.result,t.inputList):D.getTagnameListWithoutConfig(s.result)],[]);d.drawTag(this.canvas,o)}setHoverID(i){this.hoverID=i,this.render()}setFillID(i){this.fillID=i,this.render()}render(){var i;super.render(),(i=this.resultList)==null||i.forEach(t=>{switch(t==null?void 0:t.toolName){case c.Rect:this.drawRect(t.result,w.jsonParser(t.config));break;case c.Polygon:this.drawPolygon(t.result,w.jsonParser(t.config));break;case c.Tag:this.drawTag(t.result,w.jsonParser(t.config));break}})}exportData(){return[[],{}]}}export{E as default};
|