@labelbee/lb-annotation 1.14.0-alpha.2 → 1.14.0-alpha.3
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 +8 -1
- package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +35 -2
- package/dist/_virtual/filterBoxWorker.js +8 -1
- package/dist/_virtual/highlightWorker.js +8 -1
- package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
- package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +5 -7
- 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 +5 -12
- package/dist/assets/attributeIcon/icon_editFEN.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_editHUANG.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_editLAN.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_editLV.svg.js +5 -1
- package/dist/assets/attributeIcon/icon_editQING.svg.js +5 -1
- package/dist/constant/annotation.js +127 -1
- package/dist/constant/annotationTask.js +30 -1
- package/dist/constant/defaultConfig.js +266 -1
- package/dist/constant/keyCode.js +38 -1
- package/dist/constant/style.js +98 -1
- package/dist/constant/tool.js +236 -1
- package/dist/core/index.js +150 -1
- package/dist/core/pointCloud/OrbitControls.js +665 -1
- package/dist/core/pointCloud/PCDLoader.js +260 -2
- package/dist/core/pointCloud/annotation.js +215 -1
- package/dist/core/pointCloud/cache.js +53 -1
- package/dist/core/pointCloud/index.js +991 -5
- package/dist/core/pointCloud/matrix.js +138 -1
- package/dist/core/pointCloud/segmentation.js +144 -0
- package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +26 -0
- package/dist/core/pointCloud/selector/Sse3dSelector.js +16 -0
- package/dist/core/scheduler.js +233 -1
- package/dist/core/toolOperation/LineToolOperation.js +1434 -1
- package/dist/core/toolOperation/ScribbleTool.js +292 -1
- package/dist/core/toolOperation/TextToolOperation.js +131 -1
- package/dist/core/toolOperation/ViewOperation.js +556 -1
- package/dist/core/toolOperation/basicToolOperation.js +881 -1
- package/dist/core/toolOperation/checkOperation.js +208 -1
- package/dist/core/toolOperation/cuboidOperation.js +754 -1
- package/dist/core/toolOperation/cuboidToggleButtonClass.js +152 -7
- package/dist/core/toolOperation/eventListener.js +37 -1
- package/dist/core/toolOperation/measureOperation.js +41 -1
- package/dist/core/toolOperation/pointCloud2dOperation.js +365 -1
- package/dist/core/toolOperation/pointOperation.js +696 -1
- package/dist/core/toolOperation/polygonOperation.js +1251 -1
- package/dist/core/toolOperation/rectOperation.js +1233 -1
- package/dist/core/toolOperation/segmentByRect.js +174 -1
- package/dist/core/toolOperation/tagOperation.js +201 -3
- package/dist/core/toolOperation/textAttributeClass.js +182 -16
- package/dist/index.js +185 -1
- package/dist/locales/constants.js +24 -1
- package/dist/locales/en_US/message.js +25 -1
- package/dist/locales/index.js +19 -1
- package/dist/locales/zh_CN/message.js +25 -1
- package/dist/newCore/CanvasScheduler.js +35 -1
- 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/dist/utils/ActionsHistory.js +84 -1
- package/dist/utils/ImgUtils.js +23 -1
- package/dist/utils/MathUtils.js +385 -2
- package/dist/utils/VectorUtils.js +25 -1
- package/dist/utils/tool/AttributeUtils.js +218 -1
- package/dist/utils/tool/AxisUtils.js +340 -1
- package/dist/utils/tool/CanvasUtils.js +62 -1
- package/dist/utils/tool/CommonToolUtils.js +174 -1
- package/dist/utils/tool/CuboidUtils.js +704 -1
- package/dist/utils/tool/DblClickEventListener.js +102 -1
- package/dist/utils/tool/DrawUtils.js +492 -3
- package/dist/utils/tool/EnhanceCommonToolUtils.js +53 -1
- package/dist/utils/tool/ImgPosUtils.js +58 -1
- package/dist/utils/tool/LineToolUtils.js +261 -1
- package/dist/utils/tool/MarkerUtils.js +56 -1
- package/dist/utils/tool/PolygonUtils.js +460 -1
- package/dist/utils/tool/RectUtils.js +155 -1
- package/dist/utils/tool/RenderDomClass.js +57 -7
- package/dist/utils/tool/RenderDomUtils.js +21 -4
- package/dist/utils/tool/StyleUtils.js +31 -1
- package/dist/utils/tool/TagUtils.js +129 -1
- package/dist/utils/tool/UnitUtils.js +12 -1
- package/dist/utils/tool/ZoomUtils.js +72 -1
- package/dist/utils/tool/polygonTool.js +133 -1
- package/dist/utils/uuid.js +26 -1
- package/es/_virtual/MathUtilsWorker.js +6 -1
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -2
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
- package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
- package/es/_virtual/filterBoxWorker.js +6 -1
- package/es/_virtual/highlightWorker.js +6 -1
- package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +3 -1
- package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +3 -1
- package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +3 -5
- package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +3 -7
- package/es/assets/attributeIcon/icon_cuboidMore.svg.js +3 -5
- package/es/assets/attributeIcon/icon_cuboidRight.svg.js +3 -5
- package/es/assets/attributeIcon/icon_cuboidTop.svg.js +3 -12
- package/es/assets/attributeIcon/icon_editFEN.svg.js +3 -1
- package/es/assets/attributeIcon/icon_editHUANG.svg.js +3 -1
- package/es/assets/attributeIcon/icon_editLAN.svg.js +3 -1
- package/es/assets/attributeIcon/icon_editLV.svg.js +3 -1
- package/es/assets/attributeIcon/icon_editQING.svg.js +3 -1
- package/es/constant/annotation.js +113 -1
- package/es/constant/annotationTask.js +25 -1
- package/es/constant/defaultConfig.js +260 -1
- package/es/constant/keyCode.js +36 -1
- package/es/constant/style.js +74 -1
- package/es/constant/tool.js +220 -1
- package/es/core/index.js +148 -1
- package/es/core/pointCloud/OrbitControls.js +661 -1
- package/es/core/pointCloud/PCDLoader.js +256 -2
- package/es/core/pointCloud/annotation.js +211 -1
- package/es/core/pointCloud/cache.js +49 -1
- package/es/core/pointCloud/index.js +962 -5
- package/es/core/pointCloud/matrix.js +109 -1
- package/es/core/pointCloud/segmentation.js +120 -0
- package/es/core/pointCloud/selector/Sse3dLassoSelector.js +24 -0
- package/es/core/pointCloud/selector/Sse3dSelector.js +14 -0
- package/es/core/scheduler.js +228 -1
- package/es/core/toolOperation/LineToolOperation.js +1421 -1
- package/es/core/toolOperation/ScribbleTool.js +290 -1
- package/es/core/toolOperation/TextToolOperation.js +129 -1
- package/es/core/toolOperation/ViewOperation.js +549 -1
- package/es/core/toolOperation/basicToolOperation.js +877 -1
- package/es/core/toolOperation/checkOperation.js +206 -1
- package/es/core/toolOperation/cuboidOperation.js +752 -1
- package/es/core/toolOperation/cuboidToggleButtonClass.js +150 -7
- package/es/core/toolOperation/eventListener.js +35 -1
- package/es/core/toolOperation/measureOperation.js +39 -1
- package/es/core/toolOperation/pointCloud2dOperation.js +359 -1
- package/es/core/toolOperation/pointOperation.js +690 -1
- package/es/core/toolOperation/polygonOperation.js +1245 -1
- package/es/core/toolOperation/rectOperation.js +1228 -1
- package/es/core/toolOperation/scribbleTool2.js +249 -0
- package/es/core/toolOperation/segmentByRect.js +172 -1
- package/es/core/toolOperation/tagOperation.js +199 -3
- package/es/core/toolOperation/textAttributeClass.js +180 -16
- package/es/index.js +46 -1
- package/es/locales/constants.js +22 -1
- package/es/locales/en_US/message.js +23 -1
- package/es/locales/index.js +17 -1
- package/es/locales/zh_CN/message.js +23 -1
- package/es/newCore/CanvasScheduler.js +31 -1
- package/es/utils/ActionsHistory.js +78 -1
- package/es/utils/ImgUtils.js +21 -1
- package/es/utils/MathUtils.js +380 -2
- package/es/utils/VectorUtils.js +23 -1
- package/es/utils/tool/AttributeUtils.js +212 -1
- package/es/utils/tool/AxisUtils.js +335 -1
- package/es/utils/tool/CanvasUtils.js +60 -1
- package/es/utils/tool/CommonToolUtils.js +172 -1
- package/es/utils/tool/CuboidUtils.js +680 -1
- package/es/utils/tool/DblClickEventListener.js +100 -1
- package/es/utils/tool/DrawUtils.js +490 -3
- package/es/utils/tool/EnhanceCommonToolUtils.js +48 -1
- package/es/utils/tool/ImgPosUtils.js +56 -1
- package/es/utils/tool/LineToolUtils.js +255 -1
- package/es/utils/tool/MarkerUtils.js +54 -1
- package/es/utils/tool/PolygonUtils.js +458 -1
- package/es/utils/tool/RectUtils.js +153 -1
- package/es/utils/tool/RenderDomClass.js +55 -7
- package/es/utils/tool/RenderDomUtils.js +19 -4
- package/es/utils/tool/StyleUtils.js +29 -1
- package/es/utils/tool/TagUtils.js +127 -1
- package/es/utils/tool/UnitUtils.js +10 -1
- package/es/utils/tool/ZoomUtils.js +70 -1
- package/es/utils/tool/polygonTool.js +126 -1
- package/es/utils/uuid.js +24 -1
- package/package.json +7 -5
|
@@ -1 +1,174 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var lbUtils = require('@labelbee/lb-utils');
|
|
4
|
+
var AxisUtils = require('../../utils/tool/AxisUtils.js');
|
|
5
|
+
var rectOperation = require('./rectOperation.js');
|
|
6
|
+
var keyCode = require('../../constant/keyCode.js');
|
|
7
|
+
|
|
8
|
+
var __async = (__this, __arguments, generator) => {
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
var fulfilled = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.next(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var rejected = (value) => {
|
|
18
|
+
try {
|
|
19
|
+
step(generator.throw(value));
|
|
20
|
+
} catch (e) {
|
|
21
|
+
reject(e);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
25
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
class SegmentByRect extends rectOperation.RectOperation {
|
|
29
|
+
constructor(props) {
|
|
30
|
+
super(props);
|
|
31
|
+
this.onKeydown = (e) => {
|
|
32
|
+
switch (e.keyCode) {
|
|
33
|
+
case keyCode.Esc:
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
this.clearPredictionInfo();
|
|
37
|
+
break;
|
|
38
|
+
case keyCode.Z:
|
|
39
|
+
if (e.ctrlKey) {
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
this.rectList = [];
|
|
43
|
+
this.render();
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
this.segmentPrediction = (e) => __async(this, null, function* () {
|
|
49
|
+
const coord = this.getCoordinateUnderZoom(e);
|
|
50
|
+
this.isRunSegment = true;
|
|
51
|
+
this.render();
|
|
52
|
+
if (!this.runPrediction) {
|
|
53
|
+
this.emit("messageError", "You needs to set runPrediction function");
|
|
54
|
+
this.clearPredictionInfo();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
yield this.runPrediction({
|
|
58
|
+
point: coord,
|
|
59
|
+
rect: {
|
|
60
|
+
x: this.rectList[0].x,
|
|
61
|
+
y: this.rectList[0].y,
|
|
62
|
+
w: this.rectList[0].width,
|
|
63
|
+
h: this.rectList[0].height
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
this.clearPredictionInfo();
|
|
67
|
+
});
|
|
68
|
+
this.isRunSegment = false;
|
|
69
|
+
this.runPrediction = props.runPrediction;
|
|
70
|
+
}
|
|
71
|
+
setRunPrediction(runPrediction) {
|
|
72
|
+
this.runPrediction = runPrediction;
|
|
73
|
+
}
|
|
74
|
+
eventBinding() {
|
|
75
|
+
document.addEventListener("keydown", (e) => this.onKeydown(e));
|
|
76
|
+
super.eventBinding();
|
|
77
|
+
}
|
|
78
|
+
clearPredictionInfo() {
|
|
79
|
+
this.rectList = [];
|
|
80
|
+
this.isShowCursor = false;
|
|
81
|
+
this.coord = {x: -1, y: -1};
|
|
82
|
+
this.drawingRect = void 0;
|
|
83
|
+
this.isRunSegment = false;
|
|
84
|
+
this.clearCanvas();
|
|
85
|
+
this.render();
|
|
86
|
+
}
|
|
87
|
+
onMouseUp(e) {
|
|
88
|
+
if (this.isRunSegment) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (e.button === 0 && this.rectList.length === 1 && !this.isRunSegment) {
|
|
92
|
+
e.stopPropagation();
|
|
93
|
+
this.segmentPrediction(e);
|
|
94
|
+
this.clearActiveStatus();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
super.onMouseUp(e);
|
|
98
|
+
return void 0;
|
|
99
|
+
}
|
|
100
|
+
onMouseDown(e) {
|
|
101
|
+
if (this.isRunSegment) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
super.onMouseDown(e);
|
|
105
|
+
return void 0;
|
|
106
|
+
}
|
|
107
|
+
renderCursorLine() {
|
|
108
|
+
var _a;
|
|
109
|
+
if (!this.ctx) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const {ctx} = this;
|
|
113
|
+
const padding = 10;
|
|
114
|
+
const lineWidth = 1;
|
|
115
|
+
const {x, y} = this.coord;
|
|
116
|
+
ctx.save();
|
|
117
|
+
ctx.strokeStyle = "white";
|
|
118
|
+
ctx.setLineDash([6]);
|
|
119
|
+
ctx.lineWidth = lineWidth;
|
|
120
|
+
ctx.strokeRect(x - padding, y - padding, padding * 2, padding * 2);
|
|
121
|
+
ctx.restore();
|
|
122
|
+
let text = `\u2460 ${lbUtils.i18n.t("FramingOfObjectToBeDivided")}`;
|
|
123
|
+
const isEn = lbUtils.i18n.language === "en";
|
|
124
|
+
let rectWidth = isEn ? 326 : 186;
|
|
125
|
+
if (((_a = this.rectList) == null ? void 0 : _a.length) === 1) {
|
|
126
|
+
text = `\u2461 ${lbUtils.i18n.t("ClickOnTarget")}`;
|
|
127
|
+
rectWidth = isEn ? 232 : 142;
|
|
128
|
+
const radius = 2;
|
|
129
|
+
ctx.save();
|
|
130
|
+
ctx.strokeStyle = "white";
|
|
131
|
+
const margin = lineWidth + padding;
|
|
132
|
+
ctx.beginPath();
|
|
133
|
+
ctx.moveTo(x + margin + radius * 2, y + margin + radius);
|
|
134
|
+
ctx.arc(x + margin + radius, y + margin + radius, radius, 0, Math.PI * 2, true);
|
|
135
|
+
ctx.stroke();
|
|
136
|
+
ctx.restore();
|
|
137
|
+
}
|
|
138
|
+
if (this.isRunSegment) {
|
|
139
|
+
rectWidth = isEn ? 316 : 136;
|
|
140
|
+
text = lbUtils.i18n.t("SplittingAlgorithmPrediction");
|
|
141
|
+
}
|
|
142
|
+
ctx.save();
|
|
143
|
+
ctx.fillStyle = this.style.strokeColor;
|
|
144
|
+
ctx.fillRect(x + padding, y - padding * 4 - 1, rectWidth, 32);
|
|
145
|
+
ctx.restore();
|
|
146
|
+
ctx.save();
|
|
147
|
+
ctx.font = "14px Source Han Sans CN";
|
|
148
|
+
ctx.fillStyle = "white";
|
|
149
|
+
ctx.fillText(text, x + padding + 14, y - padding * 2);
|
|
150
|
+
ctx.restore();
|
|
151
|
+
super.renderCursorLine();
|
|
152
|
+
}
|
|
153
|
+
renderDrawingRect(rect, zoom, isZoom = false) {
|
|
154
|
+
if (this.ctx && rect) {
|
|
155
|
+
const transformRect = AxisUtils["default"].changeRectByZoom(rect, isZoom ? zoom : this.zoom, this.currentPos);
|
|
156
|
+
const {x, y, width, height} = transformRect;
|
|
157
|
+
this.ctx.save();
|
|
158
|
+
this.ctx.lineCap = "butt";
|
|
159
|
+
this.ctx.lineWidth = this.style.strokeWidth;
|
|
160
|
+
this.ctx.strokeStyle = "white";
|
|
161
|
+
this.ctx.strokeRect(x, y, width, height);
|
|
162
|
+
this.ctx.strokeStyle = this.style.strokeColor;
|
|
163
|
+
this.ctx.setLineDash([6]);
|
|
164
|
+
this.ctx.strokeRect(x, y, width, height);
|
|
165
|
+
this.ctx.restore();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
renderTextAttribute() {
|
|
169
|
+
}
|
|
170
|
+
renderSelectedRect() {
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
module.exports = SegmentByRect;
|
|
@@ -1,5 +1,186 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var CommonToolUtils = require('../../utils/tool/CommonToolUtils.js');
|
|
4
|
+
var TagUtils = require('../../utils/tool/TagUtils.js');
|
|
5
|
+
var uuid = require('../../utils/uuid.js');
|
|
6
|
+
var basicToolOperation = require('./basicToolOperation.js');
|
|
7
|
+
|
|
8
|
+
class TagOperation extends basicToolOperation.BasicToolOperation {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.getInitResultList = (dataSourceStep, basicResultList) => {
|
|
12
|
+
if (!(dataSourceStep === 0 || dataSourceStep === void 0) && basicResultList.length === 0) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
return TagUtils.getDefaultTagResult(this.config.inputList, basicResultList);
|
|
16
|
+
};
|
|
17
|
+
this.setLabel = (i, j) => {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
if (this.isImgError) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (!this.basicResult && this.dependToolName) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const labelInfoSet = this.config.inputList;
|
|
26
|
+
if (!labelInfoSet[i]) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const {subSelected} = labelInfoSet[i];
|
|
30
|
+
if (i < labelInfoSet.length && labelInfoSet[i].subSelected && subSelected && j < subSelected.length) {
|
|
31
|
+
const key = labelInfoSet[i].value;
|
|
32
|
+
let value = (_a = subSelected[j]) == null ? void 0 : _a.value;
|
|
33
|
+
const isMulti = (_b = labelInfoSet[i]) == null ? void 0 : _b.isMulti;
|
|
34
|
+
const basicTagResult = this.tagResult.filter((v) => {
|
|
35
|
+
const basicSourceID = `${v.sourceID}`;
|
|
36
|
+
return CommonToolUtils.isSameSourceID(basicSourceID, this.sourceID);
|
|
37
|
+
})[0];
|
|
38
|
+
if (basicTagResult) {
|
|
39
|
+
let times = 0;
|
|
40
|
+
const {result} = basicTagResult;
|
|
41
|
+
if (basicTagResult.sourceID === 0) {
|
|
42
|
+
basicTagResult.sourceID = "0";
|
|
43
|
+
}
|
|
44
|
+
for (const oldKey in basicTagResult.result) {
|
|
45
|
+
if (oldKey === labelInfoSet[i].value) {
|
|
46
|
+
times++;
|
|
47
|
+
if (isMulti === true) {
|
|
48
|
+
const keyList = result[oldKey].split(";").filter((v) => v !== "");
|
|
49
|
+
const index = keyList.indexOf(value);
|
|
50
|
+
if (index === -1) {
|
|
51
|
+
keyList.push(value);
|
|
52
|
+
} else {
|
|
53
|
+
keyList.splice(index, 1);
|
|
54
|
+
}
|
|
55
|
+
value = keyList.join(";");
|
|
56
|
+
}
|
|
57
|
+
if (value === "") {
|
|
58
|
+
if (Object.keys(result).length === 1) {
|
|
59
|
+
this.tagResult = this.tagResult.filter((v) => {
|
|
60
|
+
const basicSourceID = `${v.sourceID}`;
|
|
61
|
+
return CommonToolUtils.isDifferSourceID(basicSourceID, this.sourceID);
|
|
62
|
+
});
|
|
63
|
+
} else if (Object.keys(result).length > 1) {
|
|
64
|
+
delete result[oldKey];
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
result[oldKey] = value;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (times === 0) {
|
|
72
|
+
Object.assign(basicTagResult.result, {[key]: value});
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
this.tagResult = [
|
|
76
|
+
{
|
|
77
|
+
sourceID: this.sourceID,
|
|
78
|
+
id: uuid(8, 62),
|
|
79
|
+
result: {
|
|
80
|
+
[key]: value
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
];
|
|
84
|
+
}
|
|
85
|
+
this.render();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
this.clearResult = (sendMessage = true, value) => {
|
|
89
|
+
if (value) {
|
|
90
|
+
this.tagResult = this.tagResult.map((v) => {
|
|
91
|
+
if (v == null ? void 0 : v.result[value]) {
|
|
92
|
+
delete v.result[value];
|
|
93
|
+
}
|
|
94
|
+
return v;
|
|
95
|
+
});
|
|
96
|
+
} else {
|
|
97
|
+
this.tagResult = [];
|
|
98
|
+
}
|
|
99
|
+
this.render();
|
|
100
|
+
};
|
|
101
|
+
this.config = CommonToolUtils.jsonParser(props.config);
|
|
102
|
+
this.tagResult = [];
|
|
103
|
+
this.labelSelectedList = [];
|
|
104
|
+
this.setShowDefaultCursor(true);
|
|
105
|
+
}
|
|
106
|
+
destroy() {
|
|
107
|
+
this.clearTag();
|
|
108
|
+
super.destroy();
|
|
109
|
+
}
|
|
110
|
+
setResult(tagResult) {
|
|
111
|
+
this.tagResult = tagResult;
|
|
112
|
+
this.render();
|
|
113
|
+
}
|
|
114
|
+
get currentPageResult() {
|
|
115
|
+
return [this.currentTagResult];
|
|
116
|
+
}
|
|
117
|
+
get currentTagResult() {
|
|
118
|
+
var _a;
|
|
119
|
+
return (_a = this.tagResult.filter((v) => {
|
|
120
|
+
const basicSourceID = `${v.sourceID}`;
|
|
121
|
+
return CommonToolUtils.isSameSourceID(basicSourceID, this.sourceID);
|
|
122
|
+
})[0]) != null ? _a : {};
|
|
123
|
+
}
|
|
124
|
+
get sourceID() {
|
|
125
|
+
return CommonToolUtils.getSourceID(this.basicResult);
|
|
126
|
+
}
|
|
127
|
+
onKeyDown(e) {
|
|
128
|
+
if (!CommonToolUtils.hotkeyFilter(e) || super.onKeyDown(e) === false) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
let {keyCode} = e;
|
|
132
|
+
if (keyCode) {
|
|
133
|
+
if (keyCode <= 57 && keyCode >= 49 || keyCode <= 105 && keyCode >= 97) {
|
|
134
|
+
if (keyCode > 57) {
|
|
135
|
+
keyCode -= 97;
|
|
136
|
+
} else {
|
|
137
|
+
keyCode -= 49;
|
|
138
|
+
}
|
|
139
|
+
if (this.config.inputList.length === 1) {
|
|
140
|
+
this.labelSelectedList = [0, keyCode];
|
|
141
|
+
this.setLabel(0, keyCode);
|
|
142
|
+
setTimeout(() => {
|
|
143
|
+
this.labelSelectedList = [];
|
|
144
|
+
this.render();
|
|
145
|
+
}, 500);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (this.labelSelectedList.length === 1) {
|
|
149
|
+
this.labelSelectedList = [this.labelSelectedList[0], keyCode];
|
|
150
|
+
this.setLabel(this.labelSelectedList[0], keyCode);
|
|
151
|
+
setTimeout(() => {
|
|
152
|
+
this.labelSelectedList = [];
|
|
153
|
+
this.render();
|
|
154
|
+
}, 500);
|
|
155
|
+
} else {
|
|
156
|
+
this.labelSelectedList = [keyCode];
|
|
157
|
+
this.emit("expend");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
clearTag() {
|
|
163
|
+
var _a;
|
|
164
|
+
const parentNode = (_a = this.canvas) == null ? void 0 : _a.parentNode;
|
|
165
|
+
const oldDom = window.self.document.getElementById("tagToolTag");
|
|
166
|
+
if (oldDom && parentNode && parentNode.contains(oldDom)) {
|
|
167
|
+
parentNode == null ? void 0 : parentNode.removeChild(oldDom);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
renderTag() {
|
|
171
|
+
var _a, _b, _c, _d, _e, _f;
|
|
172
|
+
this.clearTag();
|
|
173
|
+
if (!(((_a = this.tagResult) == null ? void 0 : _a.length) > 0)) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const dom = document.createElement("div");
|
|
177
|
+
const tagInfoList = TagUtils.getTagNameList((_c = (_b = this.currentTagResult) == null ? void 0 : _b.result) != null ? _c : {}, this.config.inputList);
|
|
178
|
+
dom.innerHTML = (_d = tagInfoList.reduce((acc, cur) => {
|
|
179
|
+
return `${acc}${cur.keyName}: ${cur.value.join(` \u3001 `)}
|
|
180
|
+
`;
|
|
181
|
+
}, "")) != null ? _d : "";
|
|
182
|
+
dom.setAttribute("id", "tagToolTag");
|
|
183
|
+
dom.setAttribute("style", `
|
|
3
184
|
position: absolute;
|
|
4
185
|
top: 0;
|
|
5
186
|
right: 0;
|
|
@@ -16,4 +197,21 @@
|
|
|
16
197
|
background: rgba(102, 111, 255, 1);
|
|
17
198
|
opacity: 0.6;
|
|
18
199
|
clear: both;
|
|
19
|
-
`)
|
|
200
|
+
`);
|
|
201
|
+
(_f = (_e = this.canvas) == null ? void 0 : _e.parentNode) == null ? void 0 : _f.appendChild(dom);
|
|
202
|
+
}
|
|
203
|
+
render() {
|
|
204
|
+
this.renderTag();
|
|
205
|
+
super.render();
|
|
206
|
+
this.emit("render");
|
|
207
|
+
}
|
|
208
|
+
exportData() {
|
|
209
|
+
let {tagResult} = this;
|
|
210
|
+
if (this.isImgError) {
|
|
211
|
+
tagResult = [];
|
|
212
|
+
}
|
|
213
|
+
return [tagResult, this.basicImgInfo];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
module.exports = TagOperation;
|
|
@@ -1,37 +1,203 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var keyCode = require('../../constant/keyCode.js');
|
|
4
|
+
var tool = require('../../constant/tool.js');
|
|
5
|
+
|
|
6
|
+
const defaultWidth = 30;
|
|
7
|
+
const DEFAULT_TEXT_WIDTH = 164;
|
|
8
|
+
class TextAttributeClass {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
this.textKeyDown = (e) => {
|
|
11
|
+
e.stopPropagation();
|
|
12
|
+
switch (e.keyCode) {
|
|
13
|
+
case keyCode.Enter:
|
|
14
|
+
this.submitTextarea();
|
|
15
|
+
this.appendToContainer();
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const {container, icon, color, getCurrentSelectedData, updateSelectedTextAttribute} = props;
|
|
20
|
+
const width = props.width || DEFAULT_TEXT_WIDTH;
|
|
21
|
+
this.container = container;
|
|
22
|
+
this.getCurrentSelectedData = getCurrentSelectedData;
|
|
23
|
+
this.updateSelectedTextAttribute = updateSelectedTextAttribute;
|
|
24
|
+
this._textAttributeDOM = this.initTextAttributeDOM();
|
|
25
|
+
this._iconDOM = this.initIconDOM(icon);
|
|
26
|
+
this._textDOM = this.initTextDOM(width, tool.TEXT_ATTRIBUTE_LINE_HEIGHT);
|
|
27
|
+
this._textareaDOM = this.initTextareaDOM(width, color);
|
|
28
|
+
this.appendToContainer();
|
|
29
|
+
}
|
|
30
|
+
get isExit() {
|
|
31
|
+
if (!this._textAttributeDOM) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
return this.container.contains(this._textAttributeDOM);
|
|
35
|
+
}
|
|
36
|
+
get isExitTextareaDOM() {
|
|
37
|
+
if (!this._textareaDOM) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return this.container.contains(this._textareaDOM);
|
|
41
|
+
}
|
|
42
|
+
updateIcon(icon) {
|
|
43
|
+
if (this._iconDOM) {
|
|
44
|
+
this._iconDOM.innerHTML = icon;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
appendToContainer() {
|
|
48
|
+
if (!this._textAttributeDOM || !this._textDOM || !this._iconDOM) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.container.appendChild(this._textAttributeDOM);
|
|
52
|
+
this._textAttributeDOM.appendChild(this._textDOM);
|
|
53
|
+
this._textAttributeDOM.appendChild(this._iconDOM);
|
|
54
|
+
}
|
|
55
|
+
initTextAttributeDOM() {
|
|
56
|
+
const _textAttributeDOM = document.createElement("div");
|
|
57
|
+
_textAttributeDOM.setAttribute("id", "textArea");
|
|
58
|
+
return _textAttributeDOM;
|
|
59
|
+
}
|
|
60
|
+
initTextDOM(width, lineHeight) {
|
|
61
|
+
const _textDOM = document.createElement("span");
|
|
62
|
+
_textDOM.setAttribute("style", `
|
|
63
|
+
width: ${Math.max(width, defaultWidth)}px;
|
|
64
|
+
line-height: ${lineHeight}px;
|
|
4
65
|
word-break: break-all;
|
|
5
66
|
white-space: pre-line;
|
|
6
67
|
font-style: italic;
|
|
7
|
-
`)
|
|
68
|
+
`);
|
|
69
|
+
return _textDOM;
|
|
70
|
+
}
|
|
71
|
+
initIconDOM(icon) {
|
|
72
|
+
const _iconDOM = document.createElement("div");
|
|
73
|
+
_iconDOM.setAttribute("id", "annotation_text");
|
|
74
|
+
_iconDOM.innerHTML = icon;
|
|
75
|
+
_iconDOM.addEventListener("mouseup", (e) => {
|
|
76
|
+
e.stopPropagation();
|
|
77
|
+
this.renderTextarea();
|
|
78
|
+
});
|
|
79
|
+
_iconDOM.addEventListener("mousedown", (e) => {
|
|
80
|
+
e.stopPropagation();
|
|
81
|
+
});
|
|
82
|
+
_iconDOM.addEventListener("contextmenu", (e) => {
|
|
83
|
+
e.stopPropagation();
|
|
84
|
+
});
|
|
85
|
+
_iconDOM.setAttribute("style", `
|
|
8
86
|
position: absolute;
|
|
9
87
|
left: -20px;
|
|
10
88
|
top: 4px;
|
|
11
89
|
cursor: pointer;
|
|
12
90
|
z-index: 10
|
|
13
|
-
`)
|
|
91
|
+
`);
|
|
92
|
+
return _iconDOM;
|
|
93
|
+
}
|
|
94
|
+
initTextareaDOM(width, color) {
|
|
95
|
+
const _textareaDOM = document.createElement("textarea");
|
|
96
|
+
_textareaDOM.addEventListener("click", (e) => {
|
|
97
|
+
e.stopPropagation();
|
|
98
|
+
});
|
|
99
|
+
_textareaDOM.addEventListener("mouseup", (e) => {
|
|
100
|
+
e.stopPropagation();
|
|
101
|
+
});
|
|
102
|
+
_textareaDOM.setAttribute("style", `
|
|
14
103
|
background-color: transparent;
|
|
15
104
|
border-radius: 5px;
|
|
16
|
-
border-color: ${
|
|
105
|
+
border-color: ${color};
|
|
17
106
|
outline: none;
|
|
18
107
|
resize: none;
|
|
19
|
-
width: ${Math.max(
|
|
20
|
-
`)
|
|
108
|
+
width: ${Math.max(width, 30)}px;
|
|
109
|
+
`);
|
|
110
|
+
_textareaDOM.setAttribute("maxLength", `${tool.TEXT_ATTRIBUTE_MAX_LENGTH}`);
|
|
111
|
+
return _textareaDOM;
|
|
112
|
+
}
|
|
113
|
+
removeTextDOM() {
|
|
114
|
+
if (!this._textAttributeDOM) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (this._textDOM) {
|
|
118
|
+
this._textAttributeDOM.removeChild(this._textDOM);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
removeIconDOM() {
|
|
122
|
+
if (!this._textAttributeDOM) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (this._iconDOM) {
|
|
126
|
+
this._textAttributeDOM.removeChild(this._iconDOM);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
removeTextareaDOM() {
|
|
130
|
+
var _a, _b;
|
|
131
|
+
if (this._textareaDOM && this._textAttributeDOM && ((_a = this._textAttributeDOM) == null ? void 0 : _a.contains(this._textareaDOM))) {
|
|
132
|
+
(_b = this._textAttributeDOM) == null ? void 0 : _b.removeChild(this._textareaDOM);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
submitTextarea() {
|
|
136
|
+
var _a;
|
|
137
|
+
if (this._textareaDOM) {
|
|
138
|
+
this.updateSelectedTextAttribute((_a = this._textareaDOM) == null ? void 0 : _a.value);
|
|
139
|
+
this.removeTextareaDOM();
|
|
140
|
+
this.clearTextAttribute();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
clearTextAttribute() {
|
|
144
|
+
if (this._textAttributeDOM && this.container.contains(this._textAttributeDOM)) {
|
|
145
|
+
this.container.removeChild(this._textAttributeDOM);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
renderTextarea() {
|
|
149
|
+
if (!this._textAttributeDOM || !this._textareaDOM) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const data = this.getCurrentSelectedData();
|
|
153
|
+
if (!data) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const {width = DEFAULT_TEXT_WIDTH, textAttribute, color} = data;
|
|
157
|
+
this._textareaDOM.value = `${textAttribute}`;
|
|
158
|
+
this._textareaDOM.setAttribute("style", `
|
|
21
159
|
background-color: rgba(0,0,0,0.4);
|
|
22
160
|
border-radius: 5px;
|
|
23
|
-
border-color: ${
|
|
161
|
+
border-color: ${color};
|
|
24
162
|
outline: none;
|
|
25
163
|
resize: none;
|
|
26
164
|
font-style: italic;
|
|
27
165
|
font-weight: 900;
|
|
28
166
|
text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.6);
|
|
29
|
-
width: ${Math.max(
|
|
30
|
-
`)
|
|
167
|
+
width: ${Math.max(width, defaultWidth)}px;
|
|
168
|
+
`);
|
|
169
|
+
this._textareaDOM.setAttribute("maxLength", `${tool.TEXT_ATTRIBUTE_MAX_LENGTH}`);
|
|
170
|
+
this._textAttributeDOM.appendChild(this._textareaDOM);
|
|
171
|
+
this.removeIconDOM();
|
|
172
|
+
this.removeTextDOM();
|
|
173
|
+
this._textareaDOM.focus();
|
|
174
|
+
this._textareaDOM.addEventListener("keydown", this.textKeyDown);
|
|
175
|
+
}
|
|
176
|
+
update(textAttribute, position) {
|
|
177
|
+
var _a;
|
|
178
|
+
const {left, top, color, width = DEFAULT_TEXT_WIDTH} = position;
|
|
179
|
+
const newWidth = Math.max(width, defaultWidth);
|
|
180
|
+
(_a = this._textAttributeDOM) == null ? void 0 : _a.setAttribute("style", `
|
|
31
181
|
position: absolute;
|
|
32
|
-
width: ${
|
|
182
|
+
width: ${newWidth}px;
|
|
33
183
|
font-size: 14px;
|
|
34
|
-
left:${
|
|
35
|
-
top: ${
|
|
36
|
-
color: ${
|
|
37
|
-
`)
|
|
184
|
+
left:${left}px;
|
|
185
|
+
top: ${top}px;
|
|
186
|
+
color: ${color};
|
|
187
|
+
`);
|
|
188
|
+
if (this._textDOM) {
|
|
189
|
+
this._textDOM.innerHTML = `${textAttribute}`;
|
|
190
|
+
}
|
|
191
|
+
if (this._textareaDOM) {
|
|
192
|
+
this._textareaDOM.style.width = `${newWidth}px`;
|
|
193
|
+
this._textareaDOM.style.borderColor = `${color}`;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
changeSelected() {
|
|
197
|
+
if (this.isExitTextareaDOM) {
|
|
198
|
+
this.submitTextarea();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
module.exports = TextAttributeClass;
|