@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,754 +1 @@
1
- 'use strict';
2
-
3
- var CommonToolUtils = require('../../utils/tool/CommonToolUtils.js');
4
- var AxisUtils = require('../../utils/tool/AxisUtils.js');
5
- var uuid = require('../../utils/uuid.js');
6
- var CuboidUtils = require('../../utils/tool/CuboidUtils.js');
7
- var PolygonUtils = require('../../utils/tool/PolygonUtils.js');
8
- var annotation = require('../../constant/annotation.js');
9
- var AttributeUtils = require('../../utils/tool/AttributeUtils.js');
10
- var tool = require('../../constant/tool.js');
11
- var keyCode = require('../../constant/keyCode.js');
12
- var basicToolOperation = require('./basicToolOperation.js');
13
- var DrawUtils = require('../../utils/tool/DrawUtils.js');
14
- var cuboidToggleButtonClass = require('./cuboidToggleButtonClass.js');
15
- var textAttributeClass = require('./textAttributeClass.js');
16
- var index = require('../../locales/index.js');
17
- var constants = require('../../locales/constants.js');
18
-
19
- var __defProp = Object.defineProperty;
20
- var __defProps = Object.defineProperties;
21
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
22
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
23
- var __hasOwnProp = Object.prototype.hasOwnProperty;
24
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
25
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
26
- var __spreadValues = (a, b) => {
27
- for (var prop in b || (b = {}))
28
- if (__hasOwnProp.call(b, prop))
29
- __defNormalProp(a, prop, b[prop]);
30
- if (__getOwnPropSymbols)
31
- for (var prop of __getOwnPropSymbols(b)) {
32
- if (__propIsEnum.call(b, prop))
33
- __defNormalProp(a, prop, b[prop]);
34
- }
35
- return a;
36
- };
37
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
38
- var EDrawingStatus;
39
- (function(EDrawingStatus2) {
40
- EDrawingStatus2[EDrawingStatus2["Ready"] = 1] = "Ready";
41
- EDrawingStatus2[EDrawingStatus2["FirstPoint"] = 2] = "FirstPoint";
42
- EDrawingStatus2[EDrawingStatus2["Cuboid"] = 3] = "Cuboid";
43
- })(EDrawingStatus || (EDrawingStatus = {}));
44
- const TEXT_MAX_WIDTH = 164;
45
- class CuboidOperation extends basicToolOperation.BasicToolOperation {
46
- constructor(props) {
47
- super(props);
48
- this.drawingStatus = 1;
49
- this.cuboidList = [];
50
- this.hoverID = "";
51
- this.getHoverData = (e) => {
52
- const coordinate = this.getCoordinateUnderZoom(e);
53
- const {currentShowList} = this;
54
- if ((currentShowList == null ? void 0 : currentShowList.length) > 0) {
55
- const polygonList = currentShowList.map((cuboid) => {
56
- return {id: cuboid.id, pointList: AxisUtils["default"].changePointListByZoom(CuboidUtils.getCuboidHoverRange(cuboid), this.zoom)};
57
- });
58
- const hoverID = PolygonUtils.getHoverPolygonID(coordinate, polygonList);
59
- if (hoverID) {
60
- return {
61
- hoverID,
62
- hoverCuboid: currentShowList.find((cuboid) => cuboid.id === hoverID)
63
- };
64
- }
65
- }
66
- return {};
67
- };
68
- this.textChange = (v) => {
69
- if (this.config.textConfigurable === false || !this.selectedID) {
70
- return;
71
- }
72
- this.setCuboidList(AttributeUtils["default"].textChange(v, this.selectedID, this.cuboidList));
73
- this.emit("selectedChange");
74
- this.render();
75
- };
76
- this.config = CommonToolUtils.jsonParser(props.config);
77
- this.getCurrentSelectedData = this.getCurrentSelectedData.bind(this);
78
- this.updateSelectedTextAttribute = this.updateSelectedTextAttribute.bind(this);
79
- }
80
- get selectedText() {
81
- var _a, _b;
82
- return (_b = (_a = this.selectedCuboid) == null ? void 0 : _a.textAttribute) != null ? _b : "";
83
- }
84
- destroy() {
85
- super.destroy();
86
- if (this._textAttributeInstance) {
87
- this._textAttributeInstance.clearTextAttribute();
88
- }
89
- }
90
- get currentShowList() {
91
- let cuboidList = [];
92
- const [showingCuboid, selectedCuboid] = CommonToolUtils.getRenderResultList(this.cuboidList, CommonToolUtils.getSourceID(this.basicResult), this.attributeLockList, this.selectedID);
93
- cuboidList = showingCuboid;
94
- if (this.isHidden) {
95
- cuboidList = [];
96
- }
97
- if (selectedCuboid) {
98
- cuboidList.push(selectedCuboid);
99
- }
100
- return cuboidList;
101
- }
102
- get selectedCuboid() {
103
- return this.cuboidList.find((v) => v.id === this.selectedID);
104
- }
105
- get dataList() {
106
- return this.cuboidList;
107
- }
108
- get isNeedCheckCuboidSize() {
109
- var _a, _b;
110
- return ((_a = this.config) == null ? void 0 : _a.minWidth) >= 0 && ((_b = this.config) == null ? void 0 : _b.minHeight) >= 0;
111
- }
112
- getIsHoverSelectedCuboid(e) {
113
- const currentCoord = this.getCoordinateUnderZoom(e);
114
- const {selectedCuboid} = this;
115
- return selectedCuboid && AxisUtils["default"].isCloseCuboid(currentCoord, AxisUtils["default"].changeCuboidByZoom(selectedCuboid, this.zoom));
116
- }
117
- isForbiddenMove(e, cuboid) {
118
- const coord = this.getCoordinateInOrigin(e);
119
- if (coord.y > cuboid.frontPoints.br.y) {
120
- return true;
121
- }
122
- return false;
123
- }
124
- updateSelectedCuboid(newCuboid) {
125
- this.cuboidList = this.cuboidList.map((cuboid) => {
126
- if (cuboid.id === this.selectedID) {
127
- return newCuboid;
128
- }
129
- return cuboid;
130
- });
131
- }
132
- getStylesToRender(attribute, valid) {
133
- var _a, _b;
134
- const toolColor = this.getColor(attribute);
135
- const strokeColor = valid ? toolColor == null ? void 0 : toolColor.valid.stroke : toolColor == null ? void 0 : toolColor.invalid.stroke;
136
- const fillColor = valid ? toolColor == null ? void 0 : toolColor.valid.fill : toolColor == null ? void 0 : toolColor.invalid.fill;
137
- const lineWidth = (_b = (_a = this.style) == null ? void 0 : _a.width) != null ? _b : 2;
138
- return {strokeColor, toolColor, fillColor, lineWidth};
139
- }
140
- getCurrentSelectedData() {
141
- const {selectedCuboid} = this;
142
- if (!selectedCuboid) {
143
- return;
144
- }
145
- const {strokeColor: color} = this.getStylesToRender(selectedCuboid.attribute, selectedCuboid.valid);
146
- return {
147
- width: TEXT_MAX_WIDTH,
148
- textAttribute: selectedCuboid.textAttribute,
149
- color
150
- };
151
- }
152
- updateSelectedTextAttribute(newTextAttribute) {
153
- if (this._textAttributeInstance && newTextAttribute && this.selectedID) {
154
- let textAttribute = newTextAttribute;
155
- if (AttributeUtils["default"].textAttributeValidate(this.config.textCheckType, "", textAttribute) === false) {
156
- this.emit("messageError", AttributeUtils["default"].getErrorNotice(this.config.textCheckType, this.lang));
157
- textAttribute = "";
158
- }
159
- this.setCuboidList(AttributeUtils["default"].textChange(textAttribute, this.selectedID, this.cuboidList));
160
- this.history.pushHistory(this.cuboidList);
161
- this.emit("updateTextAttribute");
162
- this.render();
163
- }
164
- }
165
- setResult(cuboidList) {
166
- this.clearActiveStatus();
167
- this.setCuboidList(cuboidList);
168
- this.render();
169
- }
170
- get currentPageResult() {
171
- return this.cuboidList;
172
- }
173
- clearResult() {
174
- this.setCuboidList([], true);
175
- this.deleteSelectedID();
176
- this.render();
177
- }
178
- exportData() {
179
- const {cuboidList} = this;
180
- return [cuboidList, this.basicImgInfo];
181
- }
182
- setSelectedID(newID) {
183
- var _a, _b;
184
- const oldID = this.selectedID;
185
- if (newID !== oldID && oldID) {
186
- (_a = this._textAttributeInstance) == null ? void 0 : _a.changeSelected();
187
- }
188
- if (!newID) {
189
- (_b = this._textAttributeInstance) == null ? void 0 : _b.clearTextAttribute();
190
- }
191
- this.selectedID = newID;
192
- this.emit("selectedChange");
193
- }
194
- setSelectedIDAndRender(newID) {
195
- this.setSelectedID(newID);
196
- this.render();
197
- }
198
- setCuboidValidAndRender(id) {
199
- if (!id) {
200
- return;
201
- }
202
- const newPolygonList = this.cuboidList.map((cuboid) => {
203
- if (cuboid.id === id) {
204
- return __spreadProps(__spreadValues({}, cuboid), {
205
- valid: !cuboid.valid
206
- });
207
- }
208
- return cuboid;
209
- });
210
- this.setCuboidList(newPolygonList, true);
211
- this.history.pushHistory(this.cuboidList);
212
- this.render();
213
- }
214
- onRightDblClick(e) {
215
- super.onRightDblClick(e);
216
- const {hoverID} = this.getHoverData(e);
217
- if (this.selectedID && this.selectedID === hoverID) {
218
- this.deleteCuboid(hoverID);
219
- }
220
- }
221
- setCuboidList(cuboidList, isUpload = false) {
222
- const oldLen = this.cuboidList.length;
223
- this.cuboidList = cuboidList;
224
- if (oldLen !== cuboidList.length) {
225
- this.emit("updatePageNumber");
226
- }
227
- if (isUpload) {
228
- this.emit("updateResult");
229
- }
230
- }
231
- deleteCuboid(id) {
232
- var _a;
233
- if (!id) {
234
- return;
235
- }
236
- this.setCuboidList(this.cuboidList.filter((v) => v.id !== id));
237
- this.history.pushHistory(this.cuboidList);
238
- this.setSelectedID("");
239
- (_a = this._textAttributeInstance) == null ? void 0 : _a.clearTextAttribute();
240
- this.render();
241
- }
242
- onKeyDown(e) {
243
- if (!CommonToolUtils.hotkeyFilter(e)) {
244
- return;
245
- }
246
- if (super.onKeyDown(e) === false) {
247
- return;
248
- }
249
- const {keyCode: keyCode$1} = e;
250
- switch (keyCode$1) {
251
- case keyCode.Ctrl:
252
- if (this.drawingCuboid) {
253
- this.drawingCuboid = __spreadProps(__spreadValues({}, this.drawingCuboid), {
254
- valid: false
255
- });
256
- this.render();
257
- }
258
- break;
259
- case keyCode.Delete:
260
- if (this.selectedID) {
261
- this.deleteCuboid(this.selectedID);
262
- }
263
- break;
264
- case keyCode.Z:
265
- this.setIsHidden(!this.isHidden);
266
- this.render();
267
- break;
268
- case keyCode.F:
269
- if (this.selectedID) {
270
- this.setCuboidValidAndRender(this.selectedID);
271
- }
272
- break;
273
- default: {
274
- if (this.config.attributeConfigurable) {
275
- const keyCode2Attribute = AttributeUtils["default"].getAttributeByKeycode(keyCode$1, this.config.attributeList);
276
- if (keyCode2Attribute !== void 0) {
277
- this.setDefaultAttribute(keyCode2Attribute);
278
- }
279
- }
280
- }
281
- }
282
- }
283
- onKeyUp(e) {
284
- super.onKeyUp(e);
285
- switch (e.keyCode) {
286
- case keyCode.Ctrl:
287
- if (this.drawingCuboid) {
288
- this.drawingCuboid = __spreadProps(__spreadValues({}, this.drawingCuboid), {
289
- valid: true
290
- });
291
- this.render();
292
- }
293
- break;
294
- }
295
- }
296
- onMouseDown(e) {
297
- if (super.onMouseDown(e) || this.forbidMouseOperation || e.ctrlKey === true) {
298
- return;
299
- }
300
- const {selectedCuboid} = this;
301
- if (!selectedCuboid || e.button === 2 || e.button === 0 && this.isSpaceKey === true) {
302
- return;
303
- }
304
- if (!this.getIsHoverSelectedCuboid(e)) {
305
- return;
306
- }
307
- this.dragStatus = annotation.EDragStatus.Start;
308
- const dragStartCoord = this.getCoordinateUnderZoom(e);
309
- const DEFAULT_DRAG_INFO = {
310
- initCuboid: selectedCuboid,
311
- dragStartCoord
312
- };
313
- const highlightInfo = AxisUtils["default"].returnClosePointOrLineInCuboid(dragStartCoord, AxisUtils["default"].changeCuboidByZoom(selectedCuboid, this.zoom));
314
- const firstHighlightInfo = highlightInfo == null ? void 0 : highlightInfo[0];
315
- switch (firstHighlightInfo == null ? void 0 : firstHighlightInfo.type) {
316
- case "point":
317
- this.dragInfo = __spreadProps(__spreadValues({}, DEFAULT_DRAG_INFO), {
318
- dragTarget: annotation.EDragTarget.Point,
319
- positions: firstHighlightInfo.positions
320
- });
321
- break;
322
- case "line":
323
- this.dragInfo = __spreadProps(__spreadValues({}, DEFAULT_DRAG_INFO), {
324
- dragTarget: annotation.EDragTarget.Line,
325
- positions: firstHighlightInfo.positions
326
- });
327
- break;
328
- default: {
329
- this.dragInfo = __spreadProps(__spreadValues({}, DEFAULT_DRAG_INFO), {
330
- dragTarget: annotation.EDragTarget.Cuboid
331
- });
332
- }
333
- }
334
- }
335
- onMouseUp(e) {
336
- if (super.onMouseUp(e) || this.forbidMouseOperation || !this.imgInfo) {
337
- return void 0;
338
- }
339
- if (this.dragInfo && this.dragStatus === annotation.EDragStatus.Move) {
340
- this.dragInfo = void 0;
341
- this.dragStatus = annotation.EDragStatus.Wait;
342
- this.history.pushHistory(this.cuboidList);
343
- this.emit("updateResult");
344
- return;
345
- }
346
- const basicSourceID = CommonToolUtils.getSourceID(this.basicResult);
347
- if (e.button === 0) {
348
- if (this.hoverID && e.ctrlKey && !this.drawingCuboid) {
349
- this.setCuboidValidAndRender(this.hoverID);
350
- return;
351
- }
352
- if (!this.drawingCuboid) {
353
- this.createNewDrawingCuboid(e, basicSourceID);
354
- return;
355
- }
356
- if (this.drawingCuboid) {
357
- switch (this.drawingStatus) {
358
- case 2:
359
- this.closeNewDrawingFrontPlane();
360
- break;
361
- case 3:
362
- this.closeAndCreateNewCuboid();
363
- break;
364
- }
365
- }
366
- }
367
- if (e.button === 2) {
368
- this.rightMouseUp(e);
369
- }
370
- }
371
- onMouseMove(e) {
372
- var _a;
373
- if (super.onMouseMove(e) || this.forbidMouseOperation || !this.imgInfo) {
374
- return;
375
- }
376
- if (this.selectedID && this.dragInfo) {
377
- this.onDragMove(e);
378
- return;
379
- }
380
- if (this.drawingCuboid) {
381
- if (this.drawingFrontPlanesMove(e)) {
382
- return;
383
- }
384
- this.drawingBackPlaneMove(e);
385
- return;
386
- }
387
- this.hoverID = (_a = this.getHoverData(e).hoverID) != null ? _a : "";
388
- this.onHoverMove(e);
389
- }
390
- drawingFrontPlanesMove(e) {
391
- if (this.drawingCuboid && this.firstClickCoord && this.drawingStatus === 2) {
392
- const coord = this.getCoordinateInOrigin(e);
393
- this.drawingCuboid = __spreadProps(__spreadValues({}, this.drawingCuboid), {
394
- frontPoints: CuboidUtils.getPlainPointsByDiagonalPoints(this.firstClickCoord, coord)
395
- });
396
- this.render();
397
- return true;
398
- }
399
- }
400
- drawingBackPlaneMove(e) {
401
- if (this.drawingCuboid && this.firstClickCoord && this.drawingStatus === 3) {
402
- const coord = this.getCoordinateInOrigin(e);
403
- if (this.isForbiddenMove(e, this.drawingCuboid)) {
404
- return;
405
- }
406
- this.drawingCuboid = __spreadProps(__spreadValues({}, this.drawingCuboid), {
407
- backPoints: CuboidUtils.getPointsByBottomRightPoint({coord, points: this.drawingCuboid.frontPoints})
408
- });
409
- this.render();
410
- }
411
- }
412
- onDragMove(e) {
413
- if (!this.dragInfo || !this.selectedID) {
414
- return;
415
- }
416
- const {dragTarget, initCuboid, dragStartCoord, positions} = this.dragInfo;
417
- const coordinate = this.getCoordinateUnderZoom(e);
418
- const offset = {
419
- x: (coordinate.x - dragStartCoord.x) / this.zoom,
420
- y: (coordinate.y - dragStartCoord.y) / this.zoom
421
- };
422
- this.dragStatus = annotation.EDragStatus.Move;
423
- const newCuboid = CuboidUtils.getCuboidDragMove({offset, cuboid: initCuboid, dragTarget, positions});
424
- if ((newCuboid == null ? void 0 : newCuboid.backPoints) && (newCuboid == null ? void 0 : newCuboid.backPoints.br.y) > (newCuboid == null ? void 0 : newCuboid.frontPoints.br.y)) {
425
- return;
426
- }
427
- if (newCuboid) {
428
- this.updateSelectedCuboid(newCuboid);
429
- }
430
- this.render();
431
- }
432
- onHoverMove(e) {
433
- const {selectedCuboid} = this;
434
- if (selectedCuboid) {
435
- const currentCoord = this.getCoordinateUnderZoom(e);
436
- const highlightInfo = AxisUtils["default"].returnClosePointOrLineInCuboid(currentCoord, AxisUtils["default"].changeCuboidByZoom(selectedCuboid, this.zoom), {
437
- zoom: 1 / this.zoom,
438
- scope: 5
439
- });
440
- this.highlightInfo = highlightInfo;
441
- this.render();
442
- }
443
- }
444
- createNewDrawingCuboid(e, basicSourceID) {
445
- if (!this.imgInfo) {
446
- return;
447
- }
448
- const coordinate = this.getCoordinateInOrigin(e);
449
- this.drawingCuboid = {
450
- attribute: this.defaultAttribute,
451
- direction: annotation.ECuboidDirection.Front,
452
- valid: !e.ctrlKey,
453
- id: uuid(8, 62),
454
- sourceID: basicSourceID,
455
- textAttribute: "",
456
- order: CommonToolUtils.getMaxOrder(this.cuboidList.filter((v) => CommonToolUtils.isSameSourceID(v.sourceID, basicSourceID))) + 1,
457
- frontPoints: {
458
- tl: coordinate,
459
- bl: coordinate,
460
- tr: coordinate,
461
- br: coordinate
462
- }
463
- };
464
- this.firstClickCoord = __spreadValues({}, coordinate);
465
- this.drawingStatus = 2;
466
- if (this.config.textConfigurable) {
467
- let textAttribute = "";
468
- textAttribute = AttributeUtils["default"].getTextAttribute(this.cuboidList.filter((cuboid) => CommonToolUtils.isSameSourceID(cuboid.sourceID, basicSourceID)), this.config.textCheckType);
469
- this.drawingCuboid = __spreadProps(__spreadValues({}, this.drawingCuboid), {
470
- textAttribute
471
- });
472
- }
473
- }
474
- closeNewDrawingFrontPlane() {
475
- this.drawingStatus = 3;
476
- }
477
- closeAndCreateNewCuboid() {
478
- var _a, _b;
479
- if (!((_a = this.drawingCuboid) == null ? void 0 : _a.frontPoints) || !this.drawingCuboid.backPoints) {
480
- return;
481
- }
482
- if (this.isNeedCheckCuboidSize && CuboidUtils.isCuboidWithInLimits({cuboid: this.drawingCuboid, config: this.config}) === false) {
483
- this.emit("messageInfo", index.getMessagesByLocale(constants.EMessage.RectErrorSizeNotice, this.lang));
484
- } else {
485
- this.setCuboidList([...this.cuboidList, this.drawingCuboid]);
486
- this.setSelectedID((_b = this.drawingCuboid) == null ? void 0 : _b.id);
487
- this.history.pushHistory(this.cuboidList);
488
- }
489
- this.clearDrawingStatus();
490
- this.render();
491
- }
492
- deleteSelectedID() {
493
- this.setSelectedID("");
494
- }
495
- clearDrawingStatus() {
496
- if (this.drawingCuboid) {
497
- this.drawingCuboid = void 0;
498
- this.drawingStatus = 1;
499
- }
500
- }
501
- clearActiveStatus() {
502
- this.clearDrawingStatus();
503
- this.deleteSelectedID();
504
- }
505
- rightMouseUp(e) {
506
- const {hoverID, hoverCuboid} = this.getHoverData(e);
507
- this.setSelectedID(hoverID);
508
- if (hoverCuboid) {
509
- this.setDefaultAttribute(hoverCuboid.attribute);
510
- }
511
- if (this.drawingCuboid) {
512
- this.clearDrawingStatus();
513
- }
514
- this.render();
515
- }
516
- renderHighlightCuboidCom(cuboid) {
517
- const transformCuboid = AxisUtils["default"].changeCuboidByZoom(cuboid, this.zoom, this.currentPos);
518
- const isHover = transformCuboid.id === this.hoverID;
519
- const isSelected = transformCuboid.id === this.selectedID;
520
- const {strokeColor, lineWidth} = this.getStylesToRender(transformCuboid.attribute, transformCuboid.valid);
521
- const defaultStyle = {
522
- color: strokeColor,
523
- thickness: lineWidth
524
- };
525
- if (isHover || isSelected) {
526
- const hoverPointList = CuboidUtils.getHighlightPoints(transformCuboid);
527
- hoverPointList.forEach((data) => {
528
- DrawUtils.drawCircleWithFill(this.canvas, data.point, 5, __spreadValues({}, defaultStyle));
529
- });
530
- if (isSelected) {
531
- const highlightLine = CuboidUtils.getHighlightLines(transformCuboid);
532
- highlightLine.forEach((line) => {
533
- DrawUtils.drawLine(this.canvas, line.p1, line.p2, {color: strokeColor, thickness: lineWidth + 2});
534
- });
535
- hoverPointList.forEach((data) => {
536
- DrawUtils.drawCircleWithFill(this.canvas, data.point, 3, {color: "white"});
537
- });
538
- }
539
- }
540
- }
541
- renderSingleCuboid(cuboid) {
542
- var _a, _b;
543
- const transformCuboid = AxisUtils["default"].changeCuboidByZoom(cuboid, this.zoom, this.currentPos);
544
- const {strokeColor, fillColor} = this.getStylesToRender(transformCuboid.attribute, transformCuboid.valid);
545
- const lineWidth = (_b = (_a = this.style) == null ? void 0 : _a.width) != null ? _b : 2;
546
- const {hiddenText = false} = this.style;
547
- DrawUtils.drawCuboidWithText(this.canvas, transformCuboid, {strokeColor, fillColor, thickness: lineWidth}, {
548
- config: this.config,
549
- hiddenText,
550
- selectedID: this.selectedID
551
- });
552
- this.renderTextAttribute();
553
- }
554
- setDefaultAttribute(defaultAttribute) {
555
- const oldDefault = this.defaultAttribute;
556
- this.defaultAttribute = defaultAttribute != null ? defaultAttribute : "";
557
- if (oldDefault !== defaultAttribute) {
558
- this.changeStyle(defaultAttribute);
559
- this.emit("changeAttributeSidebar");
560
- const {selectedCuboid} = this;
561
- if (this._textAttributeInstance) {
562
- if (this.attributeLockList.length > 0 && !this.attributeLockList.includes(this.defaultAttribute)) {
563
- this._textAttributeInstance.clearTextAttribute();
564
- } else {
565
- this._textAttributeInstance.updateIcon(this.getTextIconSvg(defaultAttribute));
566
- }
567
- }
568
- if (selectedCuboid) {
569
- this.setCuboidList(this.cuboidList.map((v) => {
570
- if (v.id === this.selectedID) {
571
- return __spreadProps(__spreadValues({}, v), {
572
- attribute: this.defaultAttribute
573
- });
574
- }
575
- return v;
576
- }));
577
- this.history.pushHistory(this.cuboidList);
578
- this.render();
579
- return;
580
- }
581
- if (this.drawingCuboid) {
582
- this.drawingCuboid = __spreadProps(__spreadValues({}, this.drawingCuboid), {
583
- attribute: this.defaultAttribute
584
- });
585
- this.render();
586
- }
587
- }
588
- }
589
- renderToggleButton() {
590
- const {selectedCuboid} = this;
591
- if (!this.ctx || !selectedCuboid) {
592
- return;
593
- }
594
- const {attribute, valid} = selectedCuboid;
595
- const {strokeColor: color} = this.getStylesToRender(attribute, valid);
596
- if (!this.toggleButtonInstance) {
597
- this.toggleButtonInstance = new cuboidToggleButtonClass({
598
- container: this.container,
599
- cuboidButtonMove: (type) => this.updateMouseOperation(type),
600
- toggleDirection: (direction) => this.toggleDirection(direction)
601
- });
602
- }
603
- const toggleOffset = CuboidUtils.getToggleDirectionButtonOffset({
604
- cuboid: selectedCuboid,
605
- zoom: this.zoom,
606
- currentPos: this.currentPos
607
- });
608
- this.toggleButtonInstance.update({
609
- left: toggleOffset.left,
610
- top: toggleOffset.top,
611
- color
612
- });
613
- }
614
- renderTextAttribute() {
615
- var _a;
616
- const {selectedCuboid} = this;
617
- if (!this.ctx || this.config.textConfigurable === false || !selectedCuboid) {
618
- return;
619
- }
620
- const {strokeColor: color} = this.getStylesToRender(selectedCuboid.attribute, selectedCuboid.valid);
621
- const {attribute, textAttribute, frontPoints} = selectedCuboid;
622
- const offset = CuboidUtils.getCuboidTextAttributeOffset({
623
- cuboid: selectedCuboid,
624
- currentPos: this.currentPos,
625
- zoom: this.zoom
626
- });
627
- const newWidth = (frontPoints.br.x - frontPoints.bl.x) * this.zoom * 0.8;
628
- if (!this._textAttributeInstance) {
629
- this._textAttributeInstance = new textAttributeClass({
630
- width: tool.DEFAULT_TEXT_MAX_WIDTH,
631
- container: this.container,
632
- icon: this.getTextIconSvg(attribute),
633
- color,
634
- getCurrentSelectedData: this.getCurrentSelectedData,
635
- updateSelectedTextAttribute: this.updateSelectedTextAttribute
636
- });
637
- }
638
- if (this._textAttributeInstance && !((_a = this._textAttributeInstance) == null ? void 0 : _a.isExit)) {
639
- this._textAttributeInstance.appendToContainer();
640
- }
641
- this._textAttributeInstance.update(`${textAttribute}`, {
642
- left: offset.left,
643
- top: offset.top,
644
- color,
645
- width: newWidth
646
- });
647
- }
648
- renderDrawing() {
649
- if (this.drawingCuboid) {
650
- this.renderSingleCuboid(this.drawingCuboid);
651
- }
652
- }
653
- renderStatic() {
654
- if (!this.isHidden) {
655
- this.currentShowList.forEach((cuboid) => this.renderSingleCuboid(cuboid));
656
- }
657
- }
658
- renderSelected() {
659
- var _a;
660
- const {selectedCuboid} = this;
661
- if (selectedCuboid) {
662
- this.renderSingleCuboid(selectedCuboid);
663
- this.renderHighlightCuboidCom(selectedCuboid);
664
- this.renderToggleButton();
665
- } else {
666
- (_a = this.toggleButtonInstance) == null ? void 0 : _a.clearCuboidButtonDOM();
667
- this.toggleButtonInstance = void 0;
668
- }
669
- }
670
- updateMouseOperation(type) {
671
- if (type === "in") {
672
- this.setForbidCursorLine(true);
673
- this.setForbidOperation(true);
674
- this.setShowDefaultCursor(true);
675
- } else {
676
- this.setForbidCursorLine(false);
677
- this.setShowDefaultCursor(false);
678
- this.setForbidOperation(false);
679
- }
680
- }
681
- toggleDirection(direction) {
682
- if (this.cuboidList && this.selectedCuboid) {
683
- this.setCuboidList(this.cuboidList.map((i) => {
684
- var _a;
685
- return i.id === ((_a = this.selectedCuboid) == null ? void 0 : _a.id) ? __spreadProps(__spreadValues({}, i), {direction}) : i;
686
- }));
687
- this.history.pushHistory(this.cuboidList);
688
- this.render();
689
- }
690
- }
691
- renderHover() {
692
- var _a;
693
- if (this.dragInfo) {
694
- return;
695
- }
696
- (_a = this.highlightInfo) == null ? void 0 : _a.forEach((data) => {
697
- var _a2, _b;
698
- const {strokeColor} = this.getStylesToRender(data.originCuboid.attribute, data.originCuboid.valid);
699
- const thickness = 8;
700
- switch (data.type) {
701
- case "point":
702
- (_a2 = data.points) == null ? void 0 : _a2.forEach((point) => {
703
- DrawUtils.drawCircleWithFill(this.canvas, AxisUtils["default"].changePointByZoom(point, this.zoom, this.currentPos), thickness, {
704
- color: strokeColor
705
- });
706
- });
707
- break;
708
- case "line": {
709
- const pointList = (_b = data.points) == null ? void 0 : _b.map((point) => AxisUtils["default"].changePointByZoom(point, this.zoom, this.currentPos));
710
- if (pointList) {
711
- DrawUtils.drawLineWithPointList(this.canvas, pointList, {color: strokeColor, thickness});
712
- }
713
- break;
714
- }
715
- }
716
- });
717
- }
718
- renderCuboid() {
719
- this.renderStatic();
720
- this.renderDrawing();
721
- this.renderSelected();
722
- this.renderHover();
723
- }
724
- render() {
725
- if (!this.ctx) {
726
- return;
727
- }
728
- super.render();
729
- this.renderCuboid();
730
- this.renderCursorLine(this.getLineColor(this.defaultAttribute));
731
- }
732
- undo() {
733
- const cuboidList = this.history.undo();
734
- if (cuboidList) {
735
- if (cuboidList.length !== this.cuboidList.length) {
736
- this.setSelectedID("");
737
- }
738
- this.setCuboidList(cuboidList, true);
739
- this.render();
740
- }
741
- }
742
- redo() {
743
- const cuboidList = this.history.redo();
744
- if (cuboidList) {
745
- if (cuboidList.length !== this.cuboidList.length) {
746
- this.setSelectedID("");
747
- }
748
- this.setCuboidList(cuboidList, true);
749
- this.render();
750
- }
751
- }
752
- }
753
-
754
- module.exports = CuboidOperation;
1
+ "use strict";var CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),uuid=require("../../utils/uuid.js"),CuboidUtils=require("../../utils/tool/CuboidUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),annotation=require("../../constant/annotation.js"),AttributeUtils=require("../../utils/tool/AttributeUtils.js"),tool=require("../../constant/tool.js"),keyCode=require("../../constant/keyCode.js"),basicToolOperation=require("./basicToolOperation.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),cuboidToggleButtonClass=require("./cuboidToggleButtonClass.js"),textAttributeClass=require("./textAttributeClass.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(u,t,i)=>t in u?__defProp(u,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[t]=i,__spreadValues=(u,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(u,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(u,i,t[i]);return u},__spreadProps=(u,t)=>__defProps(u,__getOwnPropDescs(t)),EDrawingStatus;(function(u){u[u.Ready=1]="Ready",u[u.FirstPoint=2]="FirstPoint",u[u.Cuboid=3]="Cuboid"})(EDrawingStatus||(EDrawingStatus={}));const TEXT_MAX_WIDTH=164;class CuboidOperation extends basicToolOperation.BasicToolOperation{constructor(t){super(t);this.drawingStatus=1,this.cuboidList=[],this.hoverID="",this.getHoverData=i=>{const e=this.getCoordinateUnderZoom(i),{currentShowList:s}=this;if((s==null?void 0:s.length)>0){const o=s.map(n=>({id:n.id,pointList:AxisUtils.default.changePointListByZoom(CuboidUtils.getCuboidHoverRange(n),this.zoom)})),r=PolygonUtils.getHoverPolygonID(e,o);if(r)return{hoverID:r,hoverCuboid:s.find(n=>n.id===r)}}return{}},this.textChange=i=>{this.config.textConfigurable===!1||!this.selectedID||(this.setCuboidList(AttributeUtils.default.textChange(i,this.selectedID,this.cuboidList)),this.emit("selectedChange"),this.render())},this.config=CommonToolUtils.jsonParser(t.config),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this)}get selectedText(){var t,i;return(i=(t=this.selectedCuboid)==null?void 0:t.textAttribute)!=null?i:""}destroy(){super.destroy(),this._textAttributeInstance&&this._textAttributeInstance.clearTextAttribute()}get currentShowList(){let t=[];const[i,e]=CommonToolUtils.getRenderResultList(this.cuboidList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=i,this.isHidden&&(t=[]),e&&t.push(e),t}get selectedCuboid(){return this.cuboidList.find(t=>t.id===this.selectedID)}get dataList(){return this.cuboidList}get isNeedCheckCuboidSize(){var t,i;return((t=this.config)==null?void 0:t.minWidth)>=0&&((i=this.config)==null?void 0:i.minHeight)>=0}getIsHoverSelectedCuboid(t){const i=this.getCoordinateUnderZoom(t),{selectedCuboid:e}=this;return e&&AxisUtils.default.isCloseCuboid(i,AxisUtils.default.changeCuboidByZoom(e,this.zoom))}isForbiddenMove(t,i){return this.getCoordinateInOrigin(t).y>i.frontPoints.br.y}updateSelectedCuboid(t){this.cuboidList=this.cuboidList.map(i=>i.id===this.selectedID?t:i)}getStylesToRender(t,i){var e,s;const o=this.getColor(t),r=i?o==null?void 0:o.valid.stroke:o==null?void 0:o.invalid.stroke,n=i?o==null?void 0:o.valid.fill:o==null?void 0:o.invalid.fill,d=(s=(e=this.style)==null?void 0:e.width)!=null?s:2;return{strokeColor:r,toolColor:o,fillColor:n,lineWidth:d}}getCurrentSelectedData(){const{selectedCuboid:t}=this;if(!t)return;const{strokeColor:i}=this.getStylesToRender(t.attribute,t.valid);return{width:TEXT_MAX_WIDTH,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributeInstance&&t&&this.selectedID){let i=t;AttributeUtils.default.textAttributeValidate(this.config.textCheckType,"",i)===!1&&(this.emit("messageError",AttributeUtils.default.getErrorNotice(this.config.textCheckType,this.lang)),i=""),this.setCuboidList(AttributeUtils.default.textChange(i,this.selectedID,this.cuboidList)),this.history.pushHistory(this.cuboidList),this.emit("updateTextAttribute"),this.render()}}setResult(t){this.clearActiveStatus(),this.setCuboidList(t),this.render()}get currentPageResult(){return this.cuboidList}clearResult(){this.setCuboidList([],!0),this.deleteSelectedID(),this.render()}exportData(){const{cuboidList:t}=this;return[t,this.basicImgInfo]}setSelectedID(t){var i,e;const s=this.selectedID;t!==s&&s&&((i=this._textAttributeInstance)==null||i.changeSelected()),t||(e=this._textAttributeInstance)==null||e.clearTextAttribute(),this.selectedID=t,this.emit("selectedChange")}setSelectedIDAndRender(t){this.setSelectedID(t),this.render()}setCuboidValidAndRender(t){if(!t)return;const i=this.cuboidList.map(e=>e.id===t?__spreadProps(__spreadValues({},e),{valid:!e.valid}):e);this.setCuboidList(i,!0),this.history.pushHistory(this.cuboidList),this.render()}onRightDblClick(t){super.onRightDblClick(t);const{hoverID:i}=this.getHoverData(t);this.selectedID&&this.selectedID===i&&this.deleteCuboid(i)}setCuboidList(t,i=!1){const e=this.cuboidList.length;this.cuboidList=t,e!==t.length&&this.emit("updatePageNumber"),i&&this.emit("updateResult")}deleteCuboid(t){var i;!t||(this.setCuboidList(this.cuboidList.filter(e=>e.id!==t)),this.history.pushHistory(this.cuboidList),this.setSelectedID(""),(i=this._textAttributeInstance)==null||i.clearTextAttribute(),this.render())}onKeyDown(t){if(!CommonToolUtils.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:i}=t;switch(i){case keyCode.Ctrl:this.drawingCuboid&&(this.drawingCuboid=__spreadProps(__spreadValues({},this.drawingCuboid),{valid:!1}),this.render());break;case keyCode.Delete:this.selectedID&&this.deleteCuboid(this.selectedID);break;case keyCode.Z:this.setIsHidden(!this.isHidden),this.render();break;case keyCode.F:this.selectedID&&this.setCuboidValidAndRender(this.selectedID);break;default:if(this.config.attributeConfigurable){const e=AttributeUtils.default.getAttributeByKeycode(i,this.config.attributeList);e!==void 0&&this.setDefaultAttribute(e)}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case keyCode.Ctrl:this.drawingCuboid&&(this.drawingCuboid=__spreadProps(__spreadValues({},this.drawingCuboid),{valid:!0}),this.render());break}}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||t.ctrlKey===!0)return;const{selectedCuboid:i}=this;if(!i||t.button===2||t.button===0&&this.isSpaceKey===!0||!this.getIsHoverSelectedCuboid(t))return;this.dragStatus=annotation.EDragStatus.Start;const e=this.getCoordinateUnderZoom(t),s={initCuboid:i,dragStartCoord:e},o=AxisUtils.default.returnClosePointOrLineInCuboid(e,AxisUtils.default.changeCuboidByZoom(i,this.zoom)),r=o==null?void 0:o[0];switch(r==null?void 0:r.type){case"point":this.dragInfo=__spreadProps(__spreadValues({},s),{dragTarget:annotation.EDragTarget.Point,positions:r.positions});break;case"line":this.dragInfo=__spreadProps(__spreadValues({},s),{dragTarget:annotation.EDragTarget.Line,positions:r.positions});break;default:this.dragInfo=__spreadProps(__spreadValues({},s),{dragTarget:annotation.EDragTarget.Cuboid})}}onMouseUp(t){if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return;if(this.dragInfo&&this.dragStatus===annotation.EDragStatus.Move){this.dragInfo=void 0,this.dragStatus=annotation.EDragStatus.Wait,this.history.pushHistory(this.cuboidList),this.emit("updateResult");return}const i=CommonToolUtils.getSourceID(this.basicResult);if(t.button===0){if(this.hoverID&&t.ctrlKey&&!this.drawingCuboid){this.setCuboidValidAndRender(this.hoverID);return}if(!this.drawingCuboid){this.createNewDrawingCuboid(t,i);return}if(this.drawingCuboid)switch(this.drawingStatus){case 2:this.closeNewDrawingFrontPlane();break;case 3:this.closeAndCreateNewCuboid();break}}t.button===2&&this.rightMouseUp(t)}onMouseMove(t){var i;if(!(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)){if(this.selectedID&&this.dragInfo){this.onDragMove(t);return}if(this.drawingCuboid){if(this.drawingFrontPlanesMove(t))return;this.drawingBackPlaneMove(t);return}this.hoverID=(i=this.getHoverData(t).hoverID)!=null?i:"",this.onHoverMove(t)}}drawingFrontPlanesMove(t){if(this.drawingCuboid&&this.firstClickCoord&&this.drawingStatus===2){const i=this.getCoordinateInOrigin(t);return this.drawingCuboid=__spreadProps(__spreadValues({},this.drawingCuboid),{frontPoints:CuboidUtils.getPlainPointsByDiagonalPoints(this.firstClickCoord,i)}),this.render(),!0}}drawingBackPlaneMove(t){if(this.drawingCuboid&&this.firstClickCoord&&this.drawingStatus===3){const i=this.getCoordinateInOrigin(t);if(this.isForbiddenMove(t,this.drawingCuboid))return;this.drawingCuboid=__spreadProps(__spreadValues({},this.drawingCuboid),{backPoints:CuboidUtils.getPointsByBottomRightPoint({coord:i,points:this.drawingCuboid.frontPoints})}),this.render()}}onDragMove(t){if(!this.dragInfo||!this.selectedID)return;const{dragTarget:i,initCuboid:e,dragStartCoord:s,positions:o}=this.dragInfo,r=this.getCoordinateUnderZoom(t),n={x:(r.x-s.x)/this.zoom,y:(r.y-s.y)/this.zoom};this.dragStatus=annotation.EDragStatus.Move;const d=CuboidUtils.getCuboidDragMove({offset:n,cuboid:e,dragTarget:i,positions:o});(d==null?void 0:d.backPoints)&&(d==null?void 0:d.backPoints.br.y)>(d==null?void 0:d.frontPoints.br.y)||(d&&this.updateSelectedCuboid(d),this.render())}onHoverMove(t){const{selectedCuboid:i}=this;if(i){const e=this.getCoordinateUnderZoom(t),s=AxisUtils.default.returnClosePointOrLineInCuboid(e,AxisUtils.default.changeCuboidByZoom(i,this.zoom),{zoom:1/this.zoom,scope:5});this.highlightInfo=s,this.render()}}createNewDrawingCuboid(t,i){if(!this.imgInfo)return;const e=this.getCoordinateInOrigin(t);if(this.drawingCuboid={attribute:this.defaultAttribute,direction:annotation.ECuboidDirection.Front,valid:!t.ctrlKey,id:uuid(8,62),sourceID:i,textAttribute:"",order:CommonToolUtils.getMaxOrder(this.cuboidList.filter(s=>CommonToolUtils.isSameSourceID(s.sourceID,i)))+1,frontPoints:{tl:e,bl:e,tr:e,br:e}},this.firstClickCoord=__spreadValues({},e),this.drawingStatus=2,this.config.textConfigurable){let s="";s=AttributeUtils.default.getTextAttribute(this.cuboidList.filter(o=>CommonToolUtils.isSameSourceID(o.sourceID,i)),this.config.textCheckType),this.drawingCuboid=__spreadProps(__spreadValues({},this.drawingCuboid),{textAttribute:s})}}closeNewDrawingFrontPlane(){this.drawingStatus=3}closeAndCreateNewCuboid(){var t,i;!((t=this.drawingCuboid)==null?void 0:t.frontPoints)||!this.drawingCuboid.backPoints||(this.isNeedCheckCuboidSize&&CuboidUtils.isCuboidWithInLimits({cuboid:this.drawingCuboid,config:this.config})===!1?this.emit("messageInfo",index.getMessagesByLocale(constants.EMessage.RectErrorSizeNotice,this.lang)):(this.setCuboidList([...this.cuboidList,this.drawingCuboid]),this.setSelectedID((i=this.drawingCuboid)==null?void 0:i.id),this.history.pushHistory(this.cuboidList)),this.clearDrawingStatus(),this.render())}deleteSelectedID(){this.setSelectedID("")}clearDrawingStatus(){this.drawingCuboid&&(this.drawingCuboid=void 0,this.drawingStatus=1)}clearActiveStatus(){this.clearDrawingStatus(),this.deleteSelectedID()}rightMouseUp(t){const{hoverID:i,hoverCuboid:e}=this.getHoverData(t);this.setSelectedID(i),e&&this.setDefaultAttribute(e.attribute),this.drawingCuboid&&this.clearDrawingStatus(),this.render()}renderHighlightCuboidCom(t){const i=AxisUtils.default.changeCuboidByZoom(t,this.zoom,this.currentPos),e=i.id===this.hoverID,s=i.id===this.selectedID,{strokeColor:o,lineWidth:r}=this.getStylesToRender(i.attribute,i.valid),n={color:o,thickness:r};if(e||s){const d=CuboidUtils.getHighlightPoints(i);d.forEach(a=>{DrawUtils.drawCircleWithFill(this.canvas,a.point,5,__spreadValues({},n))}),s&&(CuboidUtils.getHighlightLines(i).forEach(h=>{DrawUtils.drawLine(this.canvas,h.p1,h.p2,{color:o,thickness:r+2})}),d.forEach(h=>{DrawUtils.drawCircleWithFill(this.canvas,h.point,3,{color:"white"})}))}}renderSingleCuboid(t){var i,e;const s=AxisUtils.default.changeCuboidByZoom(t,this.zoom,this.currentPos),{strokeColor:o,fillColor:r}=this.getStylesToRender(s.attribute,s.valid),n=(e=(i=this.style)==null?void 0:i.width)!=null?e:2,{hiddenText:d=!1}=this.style;DrawUtils.drawCuboidWithText(this.canvas,s,{strokeColor:o,fillColor:r,thickness:n},{config:this.config,hiddenText:d,selectedID:this.selectedID}),this.renderTextAttribute()}setDefaultAttribute(t){const i=this.defaultAttribute;if(this.defaultAttribute=t!=null?t:"",i!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedCuboid:e}=this;if(this._textAttributeInstance&&(this.attributeLockList.length>0&&!this.attributeLockList.includes(this.defaultAttribute)?this._textAttributeInstance.clearTextAttribute():this._textAttributeInstance.updateIcon(this.getTextIconSvg(t))),e){this.setCuboidList(this.cuboidList.map(s=>s.id===this.selectedID?__spreadProps(__spreadValues({},s),{attribute:this.defaultAttribute}):s)),this.history.pushHistory(this.cuboidList),this.render();return}this.drawingCuboid&&(this.drawingCuboid=__spreadProps(__spreadValues({},this.drawingCuboid),{attribute:this.defaultAttribute}),this.render())}}renderToggleButton(){const{selectedCuboid:t}=this;if(!this.ctx||!t)return;const{attribute:i,valid:e}=t,{strokeColor:s}=this.getStylesToRender(i,e);this.toggleButtonInstance||(this.toggleButtonInstance=new cuboidToggleButtonClass({container:this.container,cuboidButtonMove:r=>this.updateMouseOperation(r),toggleDirection:r=>this.toggleDirection(r)}));const o=CuboidUtils.getToggleDirectionButtonOffset({cuboid:t,zoom:this.zoom,currentPos:this.currentPos});this.toggleButtonInstance.update({left:o.left,top:o.top,color:s})}renderTextAttribute(){var t;const{selectedCuboid:i}=this;if(!this.ctx||this.config.textConfigurable===!1||!i)return;const{strokeColor:e}=this.getStylesToRender(i.attribute,i.valid),{attribute:s,textAttribute:o,frontPoints:r}=i,n=CuboidUtils.getCuboidTextAttributeOffset({cuboid:i,currentPos:this.currentPos,zoom:this.zoom}),d=(r.br.x-r.bl.x)*this.zoom*.8;this._textAttributeInstance||(this._textAttributeInstance=new textAttributeClass({width:tool.DEFAULT_TEXT_MAX_WIDTH,container:this.container,icon:this.getTextIconSvg(s),color:e,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributeInstance&&!((t=this._textAttributeInstance)==null?void 0:t.isExit)&&this._textAttributeInstance.appendToContainer(),this._textAttributeInstance.update(`${o}`,{left:n.left,top:n.top,color:e,width:d})}renderDrawing(){this.drawingCuboid&&this.renderSingleCuboid(this.drawingCuboid)}renderStatic(){this.isHidden||this.currentShowList.forEach(t=>this.renderSingleCuboid(t))}renderSelected(){var t;const{selectedCuboid:i}=this;i?(this.renderSingleCuboid(i),this.renderHighlightCuboidCom(i),this.renderToggleButton()):((t=this.toggleButtonInstance)==null||t.clearCuboidButtonDOM(),this.toggleButtonInstance=void 0)}updateMouseOperation(t){t==="in"?(this.setForbidCursorLine(!0),this.setForbidOperation(!0),this.setShowDefaultCursor(!0)):(this.setForbidCursorLine(!1),this.setShowDefaultCursor(!1),this.setForbidOperation(!1))}toggleDirection(t){this.cuboidList&&this.selectedCuboid&&(this.setCuboidList(this.cuboidList.map(i=>{var e;return i.id===((e=this.selectedCuboid)==null?void 0:e.id)?__spreadProps(__spreadValues({},i),{direction:t}):i})),this.history.pushHistory(this.cuboidList),this.render())}renderHover(){var t;this.dragInfo||(t=this.highlightInfo)==null||t.forEach(i=>{var e,s;const{strokeColor:o}=this.getStylesToRender(i.originCuboid.attribute,i.originCuboid.valid),r=8;switch(i.type){case"point":(e=i.points)==null||e.forEach(n=>{DrawUtils.drawCircleWithFill(this.canvas,AxisUtils.default.changePointByZoom(n,this.zoom,this.currentPos),r,{color:o})});break;case"line":{const n=(s=i.points)==null?void 0:s.map(d=>AxisUtils.default.changePointByZoom(d,this.zoom,this.currentPos));n&&DrawUtils.drawLineWithPointList(this.canvas,n,{color:o,thickness:r});break}}})}renderCuboid(){this.renderStatic(),this.renderDrawing(),this.renderSelected(),this.renderHover()}render(){!this.ctx||(super.render(),this.renderCuboid(),this.renderCursorLine(this.getLineColor(this.defaultAttribute)))}undo(){const t=this.history.undo();t&&(t.length!==this.cuboidList.length&&this.setSelectedID(""),this.setCuboidList(t,!0),this.render())}redo(){const t=this.history.redo();t&&(t.length!==this.cuboidList.length&&this.setSelectedID(""),this.setCuboidList(t,!0),this.render())}}module.exports=CuboidOperation;