@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,208 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _ = require('lodash');
|
|
4
|
-
var CommonToolUtils = require('../../utils/tool/CommonToolUtils.js');
|
|
5
|
-
var RectUtils = require('../../utils/tool/RectUtils.js');
|
|
6
|
-
var TagUtils = require('../../utils/tool/TagUtils.js');
|
|
7
|
-
var annotation = require('../../constant/annotation.js');
|
|
8
|
-
var tool = require('../../constant/tool.js');
|
|
9
|
-
var AttributeUtils = require('../../utils/tool/AttributeUtils.js');
|
|
10
|
-
var AxisUtils = require('../../utils/tool/AxisUtils.js');
|
|
11
|
-
var DrawUtils = require('../../utils/tool/DrawUtils.js');
|
|
12
|
-
var StyleUtils = require('../../utils/tool/StyleUtils.js');
|
|
13
|
-
var basicToolOperation = require('./basicToolOperation.js');
|
|
14
|
-
|
|
15
|
-
var __defProp = Object.defineProperty;
|
|
16
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
17
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
19
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
|
|
20
|
-
var __spreadValues = (a, b) => {
|
|
21
|
-
for (var prop in b || (b = {}))
|
|
22
|
-
if (__hasOwnProp.call(b, prop))
|
|
23
|
-
__defNormalProp(a, prop, b[prop]);
|
|
24
|
-
if (__getOwnPropSymbols)
|
|
25
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
26
|
-
if (__propIsEnum.call(b, prop))
|
|
27
|
-
__defNormalProp(a, prop, b[prop]);
|
|
28
|
-
}
|
|
29
|
-
return a;
|
|
30
|
-
};
|
|
31
|
-
const TEXT_ATTRIBUTE_OFFSET = {
|
|
32
|
-
x: 8,
|
|
33
|
-
y: 26
|
|
34
|
-
};
|
|
35
|
-
const newScope = 2;
|
|
36
|
-
class CheckOperation extends basicToolOperation.BasicToolOperation {
|
|
37
|
-
constructor(props) {
|
|
38
|
-
super(props);
|
|
39
|
-
this.getHoverRectID = (e) => {
|
|
40
|
-
var _a, _b;
|
|
41
|
-
const coordinate = this.getCoordinateUnderZoom(e);
|
|
42
|
-
const currentShowList = (_b = (_a = this.resultList.find((v) => v.toolName === tool.EToolName.Rect)) == null ? void 0 : _a.result) != null ? _b : [];
|
|
43
|
-
if (currentShowList.length > 0) {
|
|
44
|
-
const hoverList = currentShowList.filter((rect) => RectUtils.isInRect(coordinate, rect, newScope, this.zoom));
|
|
45
|
-
if (hoverList.length === 0) {
|
|
46
|
-
return "";
|
|
47
|
-
}
|
|
48
|
-
if (hoverList.length === 1) {
|
|
49
|
-
return hoverList[0].id;
|
|
50
|
-
}
|
|
51
|
-
if (hoverList.length > 1) {
|
|
52
|
-
const rectSizeList = hoverList.map((rect) => ({size: rect.width * rect.height, id: rect.id})).sort((a, b) => a.size - b.size);
|
|
53
|
-
return rectSizeList[0].id;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return "";
|
|
57
|
-
};
|
|
58
|
-
this.resultList = [];
|
|
59
|
-
this.hoverID = [];
|
|
60
|
-
this.fillID = [];
|
|
61
|
-
this.render = this.render.bind(this);
|
|
62
|
-
this.drawPolygon = this.drawPolygon.bind(this);
|
|
63
|
-
this.drawRect = this.drawRect.bind(this);
|
|
64
|
-
this.drawTag = this.drawTag.bind(this);
|
|
65
|
-
this.setShowDefaultCursor(true);
|
|
66
|
-
this.forbidOperation = true;
|
|
67
|
-
}
|
|
68
|
-
onMouseDown(e) {
|
|
69
|
-
var _a, _b;
|
|
70
|
-
if (super.onMouseDown(e) || this.forbidMouseOperation || !this.imgInfo) {
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
const newMouseSelectedID = this.mouseHoverID;
|
|
74
|
-
const currentShowList = (_b = (_a = this.resultList.find((v) => v.toolName === tool.EToolName.Rect)) == null ? void 0 : _a.result) != null ? _b : [];
|
|
75
|
-
if (e.button === 0) {
|
|
76
|
-
let selectedID = [newMouseSelectedID];
|
|
77
|
-
let isShow = true;
|
|
78
|
-
if (newMouseSelectedID && currentShowList.find((rect) => rect.id === newMouseSelectedID && (rect == null ? void 0 : rect.isSelected))) {
|
|
79
|
-
isShow = false;
|
|
80
|
-
}
|
|
81
|
-
if (!newMouseSelectedID) {
|
|
82
|
-
selectedID = currentShowList.map((rect) => rect.id);
|
|
83
|
-
isShow = false;
|
|
84
|
-
}
|
|
85
|
-
this.emit("setSelectedID", selectedID, isShow);
|
|
86
|
-
this.render();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
updateRotate() {
|
|
90
|
-
}
|
|
91
|
-
onMouseMove(e) {
|
|
92
|
-
if (super.onMouseMove(e) || this.forbidMouseOperation || !this.imgInfo) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const oldMouseHoverID = this.mouseHoverID;
|
|
96
|
-
const newMouseHoverID = this.getHoverRectID(e);
|
|
97
|
-
if (oldMouseHoverID !== newMouseHoverID) {
|
|
98
|
-
this.mouseHoverID = newMouseHoverID;
|
|
99
|
-
let hoverID = [newMouseHoverID];
|
|
100
|
-
if (!newMouseHoverID) {
|
|
101
|
-
hoverID = [];
|
|
102
|
-
}
|
|
103
|
-
this.emit("setHoverID", hoverID);
|
|
104
|
-
this.render();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
setResult(result) {
|
|
108
|
-
this.resultList = _.cloneDeep(result);
|
|
109
|
-
this.render();
|
|
110
|
-
}
|
|
111
|
-
drawPolygon(polygonList, config) {
|
|
112
|
-
polygonList == null ? void 0 : polygonList.forEach((polygon) => {
|
|
113
|
-
var _a, _b, _c, _d, _e;
|
|
114
|
-
const toolColor = this.getColor(polygon.attribute, config);
|
|
115
|
-
const toolData = StyleUtils.getStrokeAndFill(toolColor, polygon.valid);
|
|
116
|
-
let thickness = (_b = (_a = this.style) == null ? void 0 : _a.width) != null ? _b : 2;
|
|
117
|
-
if (this.hoverID.includes(polygon.id)) {
|
|
118
|
-
thickness = 4;
|
|
119
|
-
DrawUtils.drawPolygonWithFillAndLine(this.canvas, AxisUtils["default"].changePointListByZoom(polygon.pointList, this.zoom, this.currentPos), {
|
|
120
|
-
fillColor: toolData.fill,
|
|
121
|
-
strokeColor: toolData.stroke,
|
|
122
|
-
pointColor: "white",
|
|
123
|
-
thickness,
|
|
124
|
-
lineCap: "round",
|
|
125
|
-
isClose: true,
|
|
126
|
-
lineType: config == null ? void 0 : config.lineType
|
|
127
|
-
});
|
|
128
|
-
} else {
|
|
129
|
-
DrawUtils.drawPolygon(this.canvas, AxisUtils["default"].changePointListByZoom(polygon.pointList, this.zoom, this.currentPos), {
|
|
130
|
-
color: toolData.fill,
|
|
131
|
-
lineType: (_c = this.config) == null ? void 0 : _c.lineType,
|
|
132
|
-
thickness,
|
|
133
|
-
isClose: true
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
let showText = `${(_e = AttributeUtils["default"].getAttributeShowText(polygon.attribute, (_d = config == null ? void 0 : config.attributeList) != null ? _d : [])) != null ? _e : ""}`;
|
|
137
|
-
if ((config == null ? void 0 : config.isShowOrder) && (polygon == null ? void 0 : polygon.order) > 0) {
|
|
138
|
-
showText = `${polygon.order} ${showText}`;
|
|
139
|
-
}
|
|
140
|
-
DrawUtils.drawText(this.canvas, AxisUtils["default"].changePointByZoom(polygon.pointList[0], this.zoom, this.currentPos), showText, __spreadValues({
|
|
141
|
-
color: toolData.stroke
|
|
142
|
-
}, annotation.DEFAULT_TEXT_OFFSET));
|
|
143
|
-
const transformPointList = AxisUtils["default"].changePointListByZoom(polygon.pointList || [], this.zoom, this.currentPos);
|
|
144
|
-
const endPoint = transformPointList[transformPointList.length - 1];
|
|
145
|
-
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({
|
|
146
|
-
color: toolData.stroke
|
|
147
|
-
}, annotation.DEFAULT_TEXT_OFFSET));
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
drawRect(rectList, config) {
|
|
151
|
-
rectList == null ? void 0 : rectList.forEach((rect) => {
|
|
152
|
-
let thickness = 1;
|
|
153
|
-
if (this.hoverID.includes(rect.id)) {
|
|
154
|
-
thickness = 3;
|
|
155
|
-
}
|
|
156
|
-
const toolColor = this.getColor(rect.attribute, config);
|
|
157
|
-
const renderRect = AxisUtils["default"].changeRectByZoom(rect, this.zoom, this.currentPos);
|
|
158
|
-
DrawUtils.drawRect(this.canvas, renderRect, {
|
|
159
|
-
color: (rect == null ? void 0 : rect.valid) ? toolColor.valid.stroke : toolColor.invalid.stroke,
|
|
160
|
-
thickness
|
|
161
|
-
});
|
|
162
|
-
if (this.fillID.includes(rect.id)) {
|
|
163
|
-
DrawUtils.drawRectWithFill(this.canvas, renderRect, {
|
|
164
|
-
color: (rect == null ? void 0 : rect.valid) ? toolColor.valid.fill : toolColor.invalid.fill
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
drawTag(tagList, config) {
|
|
170
|
-
const tagInfoList = tagList.reduce((acc, cur) => {
|
|
171
|
-
return [
|
|
172
|
-
...acc,
|
|
173
|
-
...(config == null ? void 0 : config.inputList) ? TagUtils.getTagNameList(cur.result, config.inputList) : TagUtils.getTagnameListWithoutConfig(cur.result)
|
|
174
|
-
];
|
|
175
|
-
}, []);
|
|
176
|
-
DrawUtils.drawTag(this.canvas, tagInfoList);
|
|
177
|
-
}
|
|
178
|
-
setHoverID(hoverID) {
|
|
179
|
-
this.hoverID = hoverID;
|
|
180
|
-
this.render();
|
|
181
|
-
}
|
|
182
|
-
setFillID(fillID) {
|
|
183
|
-
this.fillID = fillID;
|
|
184
|
-
this.render();
|
|
185
|
-
}
|
|
186
|
-
render() {
|
|
187
|
-
var _a;
|
|
188
|
-
super.render();
|
|
189
|
-
(_a = this.resultList) == null ? void 0 : _a.forEach((item) => {
|
|
190
|
-
switch (item == null ? void 0 : item.toolName) {
|
|
191
|
-
case tool.EToolName.Rect:
|
|
192
|
-
this.drawRect(item.result, CommonToolUtils.jsonParser(item.config));
|
|
193
|
-
break;
|
|
194
|
-
case tool.EToolName.Polygon:
|
|
195
|
-
this.drawPolygon(item.result, CommonToolUtils.jsonParser(item.config));
|
|
196
|
-
break;
|
|
197
|
-
case tool.EToolName.Tag:
|
|
198
|
-
this.drawTag(item.result, CommonToolUtils.jsonParser(item.config));
|
|
199
|
-
break;
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
exportData() {
|
|
204
|
-
return [[], {}];
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
module.exports = CheckOperation;
|
|
1
|
+
"use strict";var _=require("lodash"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),RectUtils=require("../../utils/tool/RectUtils.js"),TagUtils=require("../../utils/tool/TagUtils.js"),annotation=require("../../constant/annotation.js"),tool=require("../../constant/tool.js"),AttributeUtils=require("../../utils/tool/AttributeUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),StyleUtils=require("../../utils/tool/StyleUtils.js"),basicToolOperation=require("./basicToolOperation.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(a,e,t)=>e in a?__defProp(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,__spreadValues=(a,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(a,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(a,t,e[t]);return a};const TEXT_ATTRIBUTE_OFFSET={x:8,y:26},newScope=2;class CheckOperation extends basicToolOperation.BasicToolOperation{constructor(e){super(e);this.getHoverRectID=t=>{var i,o;const s=this.getCoordinateUnderZoom(t),l=(o=(i=this.resultList.find(r=>r.toolName===tool.EToolName.Rect))==null?void 0:i.result)!=null?o:[];if(l.length>0){const r=l.filter(n=>RectUtils.isInRect(s,n,newScope,this.zoom));if(r.length===0)return"";if(r.length===1)return r[0].id;if(r.length>1)return r.map(u=>({size:u.width*u.height,id:u.id})).sort((u,h)=>u.size-h.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(e){var t,i;if(super.onMouseDown(e)||this.forbidMouseOperation||!this.imgInfo)return!0;const o=this.mouseHoverID,s=(i=(t=this.resultList.find(l=>l.toolName===tool.EToolName.Rect))==null?void 0:t.result)!=null?i:[];if(e.button===0){let l=[o],r=!0;o&&s.find(n=>n.id===o&&(n==null?void 0:n.isSelected))&&(r=!1),o||(l=s.map(n=>n.id),r=!1),this.emit("setSelectedID",l,r),this.render()}}updateRotate(){}onMouseMove(e){if(super.onMouseMove(e)||this.forbidMouseOperation||!this.imgInfo)return;const t=this.mouseHoverID,i=this.getHoverRectID(e);if(t!==i){this.mouseHoverID=i;let o=[i];i||(o=[]),this.emit("setHoverID",o),this.render()}}setResult(e){this.resultList=_.cloneDeep(e),this.render()}drawPolygon(e,t){e==null||e.forEach(i=>{var o,s,l,r,n;const u=this.getColor(i.attribute,t),h=StyleUtils.getStrokeAndFill(u,i.valid);let d=(s=(o=this.style)==null?void 0:o.width)!=null?s:2;this.hoverID.includes(i.id)?(d=4,DrawUtils.drawPolygonWithFillAndLine(this.canvas,AxisUtils.default.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{fillColor:h.fill,strokeColor:h.stroke,pointColor:"white",thickness:d,lineCap:"round",isClose:!0,lineType:t==null?void 0:t.lineType})):DrawUtils.drawPolygon(this.canvas,AxisUtils.default.changePointListByZoom(i.pointList,this.zoom,this.currentPos),{color:h.fill,lineType:(l=this.config)==null?void 0:l.lineType,thickness:d,isClose:!0});let c=`${(n=AttributeUtils.default.getAttributeShowText(i.attribute,(r=t==null?void 0:t.attributeList)!=null?r:[]))!=null?n:""}`;(t==null?void 0:t.isShowOrder)&&(i==null?void 0:i.order)>0&&(c=`${i.order} ${c}`),DrawUtils.drawText(this.canvas,AxisUtils.default.changePointByZoom(i.pointList[0],this.zoom,this.currentPos),c,__spreadValues({color:h.stroke},annotation.DEFAULT_TEXT_OFFSET));const v=AxisUtils.default.changePointListByZoom(i.pointList||[],this.zoom,this.currentPos),f=v[v.length-1];DrawUtils.drawText(this.canvas,{x:f.x+TEXT_ATTRIBUTE_OFFSET.x,y:f.y+TEXT_ATTRIBUTE_OFFSET.y},i==null?void 0:i.textAttribute,__spreadValues({color:h.stroke},annotation.DEFAULT_TEXT_OFFSET))})}drawRect(e,t){e==null||e.forEach(i=>{let o=1;this.hoverID.includes(i.id)&&(o=3);const s=this.getColor(i.attribute,t),l=AxisUtils.default.changeRectByZoom(i,this.zoom,this.currentPos);DrawUtils.drawRect(this.canvas,l,{color:(i==null?void 0:i.valid)?s.valid.stroke:s.invalid.stroke,thickness:o}),this.fillID.includes(i.id)&&DrawUtils.drawRectWithFill(this.canvas,l,{color:(i==null?void 0:i.valid)?s.valid.fill:s.invalid.fill})})}drawTag(e,t){const i=e.reduce((o,s)=>[...o,...(t==null?void 0:t.inputList)?TagUtils.getTagNameList(s.result,t.inputList):TagUtils.getTagnameListWithoutConfig(s.result)],[]);DrawUtils.drawTag(this.canvas,i)}setHoverID(e){this.hoverID=e,this.render()}setFillID(e){this.fillID=e,this.render()}render(){var e;super.render(),(e=this.resultList)==null||e.forEach(t=>{switch(t==null?void 0:t.toolName){case tool.EToolName.Rect:this.drawRect(t.result,CommonToolUtils.jsonParser(t.config));break;case tool.EToolName.Polygon:this.drawPolygon(t.result,CommonToolUtils.jsonParser(t.config));break;case tool.EToolName.Tag:this.drawTag(t.result,CommonToolUtils.jsonParser(t.config));break}})}exportData(){return[[],{}]}}module.exports=CheckOperation;
|