@labelbee/lb-annotation 1.14.0-alpha.3 → 1.14.0-alpha.6

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