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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) 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/utils/ActionsHistory.js +1 -84
  63. package/dist/utils/ImgUtils.js +1 -23
  64. package/dist/utils/MathUtils.js +2 -385
  65. package/dist/utils/VectorUtils.js +1 -25
  66. package/dist/utils/tool/AttributeUtils.js +1 -218
  67. package/dist/utils/tool/AxisUtils.js +1 -340
  68. package/dist/utils/tool/CanvasUtils.js +1 -62
  69. package/dist/utils/tool/CommonToolUtils.js +1 -174
  70. package/dist/utils/tool/CuboidUtils.js +1 -704
  71. package/dist/utils/tool/DblClickEventListener.js +1 -102
  72. package/dist/utils/tool/DrawUtils.js +3 -492
  73. package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -53
  74. package/dist/utils/tool/ImgPosUtils.js +1 -58
  75. package/dist/utils/tool/LineToolUtils.js +1 -261
  76. package/dist/utils/tool/MarkerUtils.js +1 -56
  77. package/dist/utils/tool/PolygonUtils.js +1 -460
  78. package/dist/utils/tool/RectUtils.js +1 -155
  79. package/dist/utils/tool/RenderDomClass.js +7 -57
  80. package/dist/utils/tool/RenderDomUtils.js +4 -21
  81. package/dist/utils/tool/StyleUtils.js +1 -31
  82. package/dist/utils/tool/TagUtils.js +1 -129
  83. package/dist/utils/tool/UnitUtils.js +1 -12
  84. package/dist/utils/tool/ZoomUtils.js +1 -72
  85. package/dist/utils/tool/polygonTool.js +1 -133
  86. package/dist/utils/uuid.js +1 -26
  87. package/es/_virtual/MathUtilsWorker.js +1 -6
  88. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -31
  89. package/es/_virtual/filterBoxWorker.js +1 -6
  90. package/es/_virtual/highlightWorker.js +1 -6
  91. package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -3
  92. package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -3
  93. package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -3
  94. package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -3
  95. package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -3
  96. package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -3
  97. package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -3
  98. package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -3
  99. package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -3
  100. package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -3
  101. package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -3
  102. package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -3
  103. package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -3
  104. package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -3
  105. package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -3
  106. package/es/assets/attributeIcon/icon_editFEN.svg.js +1 -3
  107. package/es/assets/attributeIcon/icon_editHUANG.svg.js +1 -3
  108. package/es/assets/attributeIcon/icon_editLAN.svg.js +1 -3
  109. package/es/assets/attributeIcon/icon_editLV.svg.js +1 -3
  110. package/es/assets/attributeIcon/icon_editQING.svg.js +1 -3
  111. package/es/constant/annotation.js +1 -113
  112. package/es/constant/annotationTask.js +1 -25
  113. package/es/constant/defaultConfig.js +1 -260
  114. package/es/constant/keyCode.js +1 -36
  115. package/es/constant/style.js +1 -74
  116. package/es/constant/tool.js +1 -220
  117. package/es/core/index.js +1 -148
  118. package/es/core/pointCloud/OrbitControls.js +1 -661
  119. package/es/core/pointCloud/PCDLoader.js +2 -256
  120. package/es/core/pointCloud/annotation.js +1 -211
  121. package/es/core/pointCloud/cache.js +1 -49
  122. package/es/core/pointCloud/index.js +5 -962
  123. package/es/core/pointCloud/matrix.js +1 -109
  124. package/es/core/scheduler.js +1 -228
  125. package/es/core/toolOperation/LineToolOperation.js +1 -1421
  126. package/es/core/toolOperation/ScribbleTool.js +1 -290
  127. package/es/core/toolOperation/TextToolOperation.js +1 -129
  128. package/es/core/toolOperation/ViewOperation.js +1 -549
  129. package/es/core/toolOperation/basicToolOperation.js +1 -877
  130. package/es/core/toolOperation/checkOperation.js +1 -206
  131. package/es/core/toolOperation/cuboidOperation.js +1 -752
  132. package/es/core/toolOperation/cuboidToggleButtonClass.js +7 -150
  133. package/es/core/toolOperation/eventListener.js +1 -35
  134. package/es/core/toolOperation/measureOperation.js +1 -39
  135. package/es/core/toolOperation/pointCloud2dOperation.js +1 -359
  136. package/es/core/toolOperation/pointOperation.js +1 -690
  137. package/es/core/toolOperation/polygonOperation.js +1 -1245
  138. package/es/core/toolOperation/rectOperation.js +1 -1228
  139. package/es/core/toolOperation/segmentByRect.js +1 -172
  140. package/es/core/toolOperation/tagOperation.js +3 -199
  141. package/es/core/toolOperation/textAttributeClass.js +16 -180
  142. package/es/index.js +1 -46
  143. package/es/locales/constants.js +1 -22
  144. package/es/locales/en_US/message.js +1 -23
  145. package/es/locales/index.js +1 -17
  146. package/es/locales/zh_CN/message.js +1 -23
  147. package/es/newCore/CanvasScheduler.js +1 -31
  148. package/es/utils/ActionsHistory.js +1 -78
  149. package/es/utils/ImgUtils.js +1 -21
  150. package/es/utils/MathUtils.js +2 -380
  151. package/es/utils/VectorUtils.js +1 -23
  152. package/es/utils/tool/AttributeUtils.js +1 -212
  153. package/es/utils/tool/AxisUtils.js +1 -335
  154. package/es/utils/tool/CanvasUtils.js +1 -60
  155. package/es/utils/tool/CommonToolUtils.js +1 -172
  156. package/es/utils/tool/CuboidUtils.js +1 -680
  157. package/es/utils/tool/DblClickEventListener.js +1 -100
  158. package/es/utils/tool/DrawUtils.js +3 -490
  159. package/es/utils/tool/EnhanceCommonToolUtils.js +1 -48
  160. package/es/utils/tool/ImgPosUtils.js +1 -56
  161. package/es/utils/tool/LineToolUtils.js +1 -255
  162. package/es/utils/tool/MarkerUtils.js +1 -54
  163. package/es/utils/tool/PolygonUtils.js +1 -458
  164. package/es/utils/tool/RectUtils.js +1 -153
  165. package/es/utils/tool/RenderDomClass.js +7 -55
  166. package/es/utils/tool/RenderDomUtils.js +4 -19
  167. package/es/utils/tool/StyleUtils.js +1 -29
  168. package/es/utils/tool/TagUtils.js +1 -127
  169. package/es/utils/tool/UnitUtils.js +1 -10
  170. package/es/utils/tool/ZoomUtils.js +1 -70
  171. package/es/utils/tool/polygonTool.js +1 -126
  172. package/es/utils/uuid.js +1 -24
  173. package/package.json +3 -4
  174. package/LICENSE +0 -203
  175. package/dist/core/pointCloud/segmentation.js +0 -144
  176. package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +0 -26
  177. package/dist/core/pointCloud/selector/Sse3dSelector.js +0 -16
  178. package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
  179. package/dist/types/core/pointCloud/selector/Sse3dLassoSelector.d.ts +0 -0
  180. package/dist/types/core/pointCloud/selector/Sse3dSelector.d.ts +0 -0
  181. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +0 -12
  182. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +0 -7
  183. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +0 -11
  184. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +0 -18
  185. package/es/core/pointCloud/segmentation.js +0 -120
  186. package/es/core/pointCloud/selector/Sse3dLassoSelector.js +0 -24
  187. package/es/core/pointCloud/selector/Sse3dSelector.js +0 -14
  188. package/es/core/toolOperation/scribbleTool2.js +0 -249
@@ -1,212 +1 @@
1
- import { isNumber } from 'lodash';
2
- import { ToolStyleUtils } from '@labelbee/lb-utils';
3
- import { ICON_ARRAY, NULL_ICON, NULL_COLOR, COLORS_ARRAY } from '../../constant/style.js';
4
- import { ETextType } from '../../constant/tool.js';
5
- import Locale from '../../locales/index.js';
6
- import { EMessage } from '../../locales/constants.js';
7
- import MathUtils from '../MathUtils.js';
8
- import INVALID_ICON from '../../assets/attributeIcon/icon_canvasEdit_miss.svg.js';
9
-
10
- var __defProp = Object.defineProperty;
11
- var __defProps = Object.defineProperties;
12
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
13
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
14
- var __hasOwnProp = Object.prototype.hasOwnProperty;
15
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
16
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
17
- var __spreadValues = (a, b) => {
18
- for (var prop in b || (b = {}))
19
- if (__hasOwnProp.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- if (__getOwnPropSymbols)
22
- for (var prop of __getOwnPropSymbols(b)) {
23
- if (__propIsEnum.call(b, prop))
24
- __defNormalProp(a, prop, b[prop]);
25
- }
26
- return a;
27
- };
28
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
29
- const REGEXP_NUMBER = "^[0-9]+$";
30
- const REGEXP_ENGLISH = "^[A-Za-z]+$";
31
- class AttributeUtils {
32
- static getAttributeIcon(attribute, attributeList, valid = true) {
33
- var _a;
34
- const attributeIndex = attributeList.findIndex((i) => i.value === attribute);
35
- let src = (_a = ICON_ARRAY[attributeIndex % ICON_ARRAY.length]) != null ? _a : NULL_ICON;
36
- if (!valid) {
37
- src = INVALID_ICON;
38
- }
39
- src = "";
40
- const img = new Image();
41
- img.src = src;
42
- return img;
43
- }
44
- static checkString(textCheckType, customFormat) {
45
- let regExpString = "";
46
- switch (textCheckType) {
47
- case ETextType.Order:
48
- case ETextType.NumberOnly:
49
- regExpString = REGEXP_NUMBER;
50
- break;
51
- case ETextType.EnglishOnly:
52
- regExpString = REGEXP_ENGLISH;
53
- break;
54
- case ETextType.CustomFormat:
55
- regExpString = customFormat;
56
- break;
57
- }
58
- return regExpString;
59
- }
60
- static checkTextAttibute(value, checkStrings) {
61
- if (value === void 0 || value === "") {
62
- return true;
63
- }
64
- try {
65
- return new RegExp(checkStrings).test(value);
66
- } catch (error) {
67
- return false;
68
- }
69
- }
70
- static getAttributeShowText(attribute, attributeList = []) {
71
- var _a, _b;
72
- try {
73
- const attributeIndex = attributeList.findIndex((i) => i.value === attribute);
74
- return (_b = (_a = attributeList[attributeIndex]) == null ? void 0 : _a.key) != null ? _b : attribute;
75
- } catch (error) {
76
- return attribute;
77
- }
78
- }
79
- static getAttributeIndex(attribute, attributeList) {
80
- try {
81
- const attributeIndex = attributeList.findIndex((i) => i.value === attribute);
82
- if (attributeIndex >= 8) {
83
- return attributeIndex % 8;
84
- }
85
- return attributeIndex;
86
- } catch (error) {
87
- return -1;
88
- }
89
- }
90
- static getAttributeColor(attribute, attributeList) {
91
- try {
92
- const attributeIndex = this.getAttributeIndex(attribute, attributeList);
93
- if (attributeIndex === -1) {
94
- return NULL_COLOR;
95
- }
96
- return COLORS_ARRAY[attributeIndex % COLORS_ARRAY.length];
97
- } catch (error) {
98
- return NULL_COLOR;
99
- }
100
- }
101
- static getTextAttribute(toolResultList, textCheckType) {
102
- try {
103
- if (textCheckType === ETextType.Order) {
104
- const textAttributeList = toolResultList.map((i) => parseInt(i.textAttribute, 10)).filter((order) => {
105
- return isNumber(order) && order < Number.MAX_SAFE_INTEGER && order >= 0;
106
- });
107
- textAttributeList.sort((a, b) => a - b);
108
- const maxOrder = textAttributeList.pop();
109
- return `${(maxOrder || 0) + 1}`;
110
- }
111
- return "";
112
- } catch (error) {
113
- return "";
114
- }
115
- }
116
- static textChange(value, selectedID, toolList) {
117
- return toolList.map((item) => {
118
- if (item.id === selectedID) {
119
- return __spreadProps(__spreadValues({}, item), {
120
- textAttribute: value
121
- });
122
- }
123
- return item;
124
- });
125
- }
126
- static getErrorNotice(textCheckType, lang) {
127
- switch (textCheckType) {
128
- case ETextType.Order:
129
- case ETextType.NumberOnly:
130
- return Locale.getMessagesByLocale(EMessage.TextCheckNumberErrorNotice, lang);
131
- case ETextType.EnglishOnly:
132
- return Locale.getMessagesByLocale(EMessage.TextCheckEnglishErrorNotice, lang);
133
- case ETextType.CustomFormat:
134
- return Locale.getMessagesByLocale(EMessage.TextCheckCustomErrorNotice, lang);
135
- default:
136
- return "";
137
- }
138
- }
139
- static textAttributeValidate(textCheckType, customFormat, text) {
140
- try {
141
- const reg = new RegExp(this.checkString(textCheckType, customFormat));
142
- return reg.test(text);
143
- } catch (error) {
144
- }
145
- }
146
- static checkTextAttribute(textCheckType, customFormat, resultList, selectedID) {
147
- let error = false;
148
- resultList.forEach((item) => {
149
- if ((item == null ? void 0 : item.textAttribute) === void 0 || (item == null ? void 0 : item.textAttribute) === "") {
150
- return;
151
- }
152
- if ((selectedID ? item.id === selectedID : true) && !this.textAttributeValidate(textCheckType, customFormat, item.textAttribute)) {
153
- error = true;
154
- }
155
- });
156
- if (error) {
157
- return true;
158
- }
159
- return false;
160
- }
161
- static changeTextAttributeInLog(toolLog, toolList) {
162
- return toolLog == null ? void 0 : toolLog.map((item) => {
163
- return item == null ? void 0 : item.map((info) => {
164
- if ((toolList == null ? void 0 : toolList.findIndex((i) => (i == null ? void 0 : i.id) === (info == null ? void 0 : info.id))) > -1) {
165
- const changeRect = toolList == null ? void 0 : toolList.find((i) => (i == null ? void 0 : i.id) === (info == null ? void 0 : info.id));
166
- return __spreadProps(__spreadValues({}, info), {
167
- textAttribute: changeRect == null ? void 0 : changeRect.textAttribute
168
- });
169
- }
170
- return info;
171
- });
172
- });
173
- }
174
- static getTextIconSvg(attribute = "", attributeList, attributeConfigurable = false, baseIcon) {
175
- var _a;
176
- if (attributeConfigurable === true) {
177
- const attributeIndex = (attributeList == null ? void 0 : attributeList.findIndex((i) => (i == null ? void 0 : i.value) === attribute)) % COLORS_ARRAY.length + 1;
178
- const color = (_a = attributeList == null ? void 0 : attributeList.find((i) => i.value === attribute)) == null ? void 0 : _a.color;
179
- if (color) {
180
- const getHexColor = ToolStyleUtils.rgbaStringToHex(color);
181
- return this.generateIconAttribute({fill: getHexColor});
182
- }
183
- return ICON_ARRAY[attributeIndex];
184
- }
185
- return baseIcon;
186
- }
187
- static generateIconAttribute({
188
- fill,
189
- width = 16,
190
- height = 16,
191
- xmlns = "http://www.w3.org/2000/svg",
192
- xlink = "http://www.w3.org/1999/xlink"
193
- }) {
194
- return `<span style={color:${fill}}><svg xmlns=${xmlns} xmlns:xlink=${xlink} width=${width} height=${height} viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill='currentColor'/></g></g></svg></span>`;
195
- }
196
- static getAttributeByKeycode(keyCode, attributeList) {
197
- var _a;
198
- let num;
199
- if (MathUtils.isInRange(keyCode, [48, 57])) {
200
- num = keyCode - 48;
201
- }
202
- if (MathUtils.isInRange(keyCode, [96, 105])) {
203
- num = keyCode - 96;
204
- }
205
- if (num === 0) {
206
- return "";
207
- }
208
- return num ? (_a = attributeList[num - 1]) == null ? void 0 : _a.value : void 0;
209
- }
210
- }
211
-
212
- export { REGEXP_ENGLISH, REGEXP_NUMBER, AttributeUtils as default };
1
+ import{isNumber as I}from"lodash";import{ToolStyleUtils as O}from"@labelbee/lb-utils";import{ICON_ARRAY as c,NULL_ICON as E,NULL_COLOR as f,COLORS_ARRAY as d}from"../../constant/style.js";import{ETextType as s}from"../../constant/tool.js";import g from"../../locales/index.js";import{EMessage as p}from"../../locales/constants.js";import h from"../MathUtils.js";import y from"../../assets/attributeIcon/icon_canvasEdit_miss.svg.js";var w=Object.defineProperty,N=Object.defineProperties,P=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,x=(l,t,r)=>t in l?w(l,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):l[t]=r,b=(l,t)=>{for(var r in t||(t={}))R.call(t,r)&&x(l,r,t[r]);if(v)for(var r of v(t))T.call(t,r)&&x(l,r,t[r]);return l},m=(l,t)=>N(l,P(t));const _="^[0-9]+$",A="^[A-Za-z]+$";class M{static getAttributeIcon(t,r,e=!0){var n;const a=r.findIndex(o=>o.value===t);let i=(n=c[a%c.length])!=null?n:E;e||(i=y),i="";const u=new Image;return u.src=i,u}static checkString(t,r){let e="";switch(t){case s.Order:case s.NumberOnly:e=_;break;case s.EnglishOnly:e=A;break;case s.CustomFormat:e=r;break}return e}static checkTextAttibute(t,r){if(t===void 0||t==="")return!0;try{return new RegExp(r).test(t)}catch(e){return!1}}static getAttributeShowText(t,r=[]){var e,n;try{const a=r.findIndex(i=>i.value===t);return(n=(e=r[a])==null?void 0:e.key)!=null?n:t}catch(a){return t}}static getAttributeIndex(t,r){try{const e=r.findIndex(n=>n.value===t);return e>=8?e%8:e}catch(e){return-1}}static getAttributeColor(t,r){try{const e=this.getAttributeIndex(t,r);return e===-1?f:d[e%d.length]}catch(e){return f}}static getTextAttribute(t,r){try{if(r===s.Order){const e=t.map(a=>parseInt(a.textAttribute,10)).filter(a=>I(a)&&a<Number.MAX_SAFE_INTEGER&&a>=0);return e.sort((a,i)=>a-i),`${(e.pop()||0)+1}`}return""}catch(e){return""}}static textChange(t,r,e){return e.map(n=>n.id===r?m(b({},n),{textAttribute:t}):n)}static getErrorNotice(t,r){switch(t){case s.Order:case s.NumberOnly:return g.getMessagesByLocale(p.TextCheckNumberErrorNotice,r);case s.EnglishOnly:return g.getMessagesByLocale(p.TextCheckEnglishErrorNotice,r);case s.CustomFormat:return g.getMessagesByLocale(p.TextCheckCustomErrorNotice,r);default:return""}}static textAttributeValidate(t,r,e){try{return new RegExp(this.checkString(t,r)).test(e)}catch(n){}}static checkTextAttribute(t,r,e,n){let a=!1;return e.forEach(i=>{(i==null?void 0:i.textAttribute)===void 0||(i==null?void 0:i.textAttribute)===""||(n?i.id===n:!0)&&!this.textAttributeValidate(t,r,i.textAttribute)&&(a=!0)}),!!a}static changeTextAttributeInLog(t,r){return t==null?void 0:t.map(e=>e==null?void 0:e.map(n=>{if((r==null?void 0:r.findIndex(a=>(a==null?void 0:a.id)===(n==null?void 0:n.id)))>-1){const a=r==null?void 0:r.find(i=>(i==null?void 0:i.id)===(n==null?void 0:n.id));return m(b({},n),{textAttribute:a==null?void 0:a.textAttribute})}return n}))}static getTextIconSvg(t="",r,e=!1,n){var a;if(e===!0){const i=(r==null?void 0:r.findIndex(o=>(o==null?void 0:o.value)===t))%d.length+1,u=(a=r==null?void 0:r.find(o=>o.value===t))==null?void 0:a.color;if(u){const o=O.rgbaStringToHex(u);return this.generateIconAttribute({fill:o})}return c[i]}return n}static generateIconAttribute({fill:t,width:r=16,height:e=16,xmlns:n="http://www.w3.org/2000/svg",xlink:a="http://www.w3.org/1999/xlink"}){return`<span style={color:${t}}><svg xmlns=${n} xmlns:xlink=${a} width=${r} height=${e} viewBox="0 0 16 16"><defs><clipPath id="a"><path d="M0,0H16V-16H0Z" fill="none"/></clipPath><clipPath id="b"><path d="M13.75-2.937H2.25a.5.5,0,0,0-.5.5v.563a.125.125,0,0,0,.125.125h12.25a.125.125,0,0,0,.125-.125v-.562A.5.5,0,0,0,13.75-2.937ZM4.027-4.25a.632.632,0,0,0,.094-.008l2.628-.461a.153.153,0,0,0,.083-.044l6.623-6.623a.156.156,0,0,0,0-.22l-2.6-2.6a.155.155,0,0,0-.111-.045.155.155,0,0,0-.111.045L4.012-7.581a.159.159,0,0,0-.044.083L3.508-4.87a.524.524,0,0,0,.147.466.529.529,0,0,0,.372.155Z" fill="none"/></clipPath></defs><g transform="translate(0 16)"><g clip-path="url(#a)"><path d="M-5-21H21V5H-5Z" fill="rgba(0,0,0,0)"/></g><g clip-path="url(#b)"><path d="M-3.25-19.25h22.5V3.25H-3.25Z" fill='currentColor'/></g></g></svg></span>`}static getAttributeByKeycode(t,r){var e;let n;return h.isInRange(t,[48,57])&&(n=t-48),h.isInRange(t,[96,105])&&(n=t-96),n===0?"":n?(e=r[n-1])==null?void 0:e.value:void 0}}export{A as REGEXP_ENGLISH,_ as REGEXP_NUMBER,M as default};
@@ -1,335 +1 @@
1
- import { EToolName, ELineTypes } from '../../constant/tool.js';
2
- import MathUtils from '../MathUtils.js';
3
- import PolygonUtils from './PolygonUtils.js';
4
- import LineToolUtils, { POINT_RADIUS } from './LineToolUtils.js';
5
- import { getHighlightPoints, getHighlightLines, getCuboidHoverRange } from './CuboidUtils.js';
6
-
7
- var __defProp = Object.defineProperty;
8
- var __defProps = Object.defineProperties;
9
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
10
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
13
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
14
- var __spreadValues = (a, b) => {
15
- for (var prop in b || (b = {}))
16
- if (__hasOwnProp.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- if (__getOwnPropSymbols)
19
- for (var prop of __getOwnPropSymbols(b)) {
20
- if (__propIsEnum.call(b, prop))
21
- __defNormalProp(a, prop, b[prop]);
22
- }
23
- return a;
24
- };
25
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
- class AxisUtils {
27
- static getOffsetCoordinate(coordinate, currentPos, zoom) {
28
- return {
29
- x: coordinate.x * zoom + currentPos.x,
30
- y: coordinate.y * zoom + currentPos.y
31
- };
32
- }
33
- static changeDrawOutsideTarget(coord, currentPos, imgInfo, drawOutsideTarget, basicResult, zoom) {
34
- if (typeof drawOutsideTarget === "boolean" && !drawOutsideTarget) {
35
- if (basicResult && zoom) {
36
- if (coord.x - currentPos.x > (basicResult.x + basicResult.width) * zoom) {
37
- coord.x = (basicResult.x + basicResult.width) * zoom + currentPos.x;
38
- }
39
- if (coord.x - currentPos.x < basicResult.x * zoom) {
40
- coord.x = basicResult.x * zoom + currentPos.x;
41
- }
42
- if (coord.y - currentPos.y > (basicResult.y + basicResult.height) * zoom) {
43
- coord.y = (basicResult.y + basicResult.height) * zoom + currentPos.y;
44
- }
45
- if (coord.y - currentPos.y < basicResult.y * zoom) {
46
- coord.y = basicResult.y * zoom + currentPos.y;
47
- }
48
- } else {
49
- if (coord.x - currentPos.x > imgInfo.width) {
50
- coord.x = imgInfo.width + currentPos.x;
51
- }
52
- if (coord.x - currentPos.x < 0) {
53
- coord.x = currentPos.x;
54
- }
55
- if (coord.y - currentPos.y > imgInfo.height) {
56
- coord.y = imgInfo.height + currentPos.y;
57
- }
58
- if (coord.y - currentPos.y < 0) {
59
- coord.y = currentPos.y;
60
- }
61
- }
62
- }
63
- return coord;
64
- }
65
- static changeCoordinateByRotate(coordinate, rotate, imgSize) {
66
- const {width, height} = imgSize;
67
- const {x, y} = coordinate;
68
- switch (rotate % 360) {
69
- case 90:
70
- return {
71
- x: height - y,
72
- y: x
73
- };
74
- case 180:
75
- return {
76
- x: width - x,
77
- y: height - y
78
- };
79
- case 270:
80
- return {
81
- x: y,
82
- y: width - x
83
- };
84
- default:
85
- return coordinate;
86
- }
87
- }
88
- static changeRectByZoom(rect, zoom, currentPos = {x: 0, y: 0}) {
89
- return __spreadProps(__spreadValues({}, rect), {
90
- x: rect.x * zoom + currentPos.x,
91
- y: rect.y * zoom + currentPos.y,
92
- width: rect.width * zoom,
93
- height: rect.height * zoom
94
- });
95
- }
96
- static changePointByZoom(point, zoom, currentPos = {x: 0, y: 0}) {
97
- return __spreadProps(__spreadValues({}, point), {
98
- x: point.x * zoom + currentPos.x,
99
- y: point.y * zoom + currentPos.y
100
- });
101
- }
102
- static changePointListByZoom(pointList, zoom, currentPos = {x: 0, y: 0}) {
103
- return pointList == null ? void 0 : pointList.map((point) => {
104
- return this.changePointByZoom(point, zoom, currentPos);
105
- });
106
- }
107
- static changePlanePointByZoom(planePoints, zoom, currentPos = {x: 0, y: 0}) {
108
- return Object.entries(planePoints).reduce((acc, [key, coord]) => {
109
- const newCoord = AxisUtils.changePointByZoom(coord, zoom, currentPos);
110
- return __spreadProps(__spreadValues({}, acc), {
111
- [key]: newCoord
112
- });
113
- }, {});
114
- }
115
- static changeCuboidByZoom(cuboid, zoom, currentPos = {x: 0, y: 0}) {
116
- return __spreadProps(__spreadValues({}, cuboid), {
117
- frontPoints: this.changePlanePointByZoom(cuboid.frontPoints, zoom, currentPos),
118
- backPoints: cuboid.backPoints ? this.changePlanePointByZoom(cuboid.backPoints, zoom, currentPos) : cuboid.backPoints
119
- });
120
- }
121
- static transformPlain2PointList({tl, tr, br, bl}) {
122
- return [tl, tr, br, bl];
123
- }
124
- static axisArea(axis, radius = 3) {
125
- const {x, y} = axis;
126
- const axisArray = [];
127
- for (let cX = x - radius; cX < x + radius; cX += radius / 3) {
128
- for (let cY = y - radius; cY < y + radius; cY += radius / 3) {
129
- axisArray.push({x: cX, y: cY});
130
- }
131
- }
132
- return axisArray;
133
- }
134
- static getOriginCoordinateWithOffsetCoordinate(coord, zoom = 1, currentPos = {
135
- x: 0,
136
- y: 0
137
- }) {
138
- return {
139
- x: (coord.x - currentPos.x) / zoom,
140
- y: (coord.y - currentPos.y) / zoom
141
- };
142
- }
143
- static returnClosePointIndex(checkPoint, polygonPoints, scope = 3) {
144
- let pointIndex = -1;
145
- for (let i = 0; i < polygonPoints.length; i++) {
146
- const data = polygonPoints[i];
147
- if (this.getIsInScope(checkPoint, data, scope)) {
148
- pointIndex = i;
149
- }
150
- }
151
- return pointIndex;
152
- }
153
- static isCloseCuboid(checkPoint, cuboid, options = {scope: 5, zoom: 1}) {
154
- const points = getHighlightPoints(cuboid);
155
- const {scope = 5} = options;
156
- for (let i = 0; i < points.length; i++) {
157
- const pointData = points[i];
158
- if (this.getIsInScope(checkPoint, pointData.point, scope)) {
159
- return true;
160
- }
161
- }
162
- const lines = getHighlightLines(cuboid);
163
- for (let i = 0; i < lines.length; i++) {
164
- const line = lines[i];
165
- const {length} = MathUtils.getFootOfPerpendicular(checkPoint, line.p1, line.p2, true);
166
- if (length < scope) {
167
- return true;
168
- }
169
- }
170
- if (PolygonUtils.isInPolygon(checkPoint, getCuboidHoverRange(cuboid))) {
171
- return true;
172
- }
173
- return false;
174
- }
175
- static isCloseCuboidList(checkPoint, cuboidList, options = {scope: 5, zoom: 1}) {
176
- return cuboidList.some((cuboid) => this.isCloseCuboid(checkPoint, cuboid, options));
177
- }
178
- static returnClosePointOrLineInCuboid(checkPoint, cuboid, options = {scope: 5, zoom: 1}) {
179
- const points = getHighlightPoints(cuboid);
180
- const {scope = 5, zoom = 1} = options;
181
- for (let i = 0; i < points.length; i++) {
182
- const pointData = points[i];
183
- if (this.getIsInScope(checkPoint, pointData.point, scope)) {
184
- return [
185
- {
186
- type: "point",
187
- points: [this.changePointByZoom(points[i].point, zoom)],
188
- originCuboid: cuboid,
189
- positions: pointData.positions
190
- }
191
- ];
192
- }
193
- }
194
- let minLength = scope;
195
- const lines = getHighlightLines(cuboid);
196
- let linePoints;
197
- for (let i = 0; i < lines.length; i++) {
198
- const line = lines[i];
199
- const {length} = MathUtils.getFootOfPerpendicular(checkPoint, line.p1, line.p2, true);
200
- if (length < minLength) {
201
- minLength = length;
202
- linePoints = [
203
- {
204
- type: "line",
205
- points: this.changePointListByZoom([line.p1, line.p2], zoom),
206
- originCuboid: cuboid,
207
- positions: line.positions
208
- }
209
- ];
210
- }
211
- }
212
- if (linePoints) {
213
- return linePoints;
214
- }
215
- }
216
- static getIsInScope(currentCoord, targetCoord, scope) {
217
- if (Math.abs(currentCoord.x - targetCoord.x) < scope && Math.abs(currentCoord.y - targetCoord.y) < scope) {
218
- return true;
219
- }
220
- return false;
221
- }
222
- }
223
- class CoordinateUtils {
224
- constructor(props) {
225
- this.currentPos = props.currentPos;
226
- this.zoom = props.zoom;
227
- this.basicImgInfo = props.basicImgInfo;
228
- this.dependToolName = "";
229
- }
230
- get isDependPolygon() {
231
- return this.dependToolName === EToolName.Polygon;
232
- }
233
- get isDependRect() {
234
- return this.dependToolName === EToolName.Rect;
235
- }
236
- get isDependOriginalImage() {
237
- return this.dependToolName === "";
238
- }
239
- getAbsCoord(renderCoord) {
240
- return {
241
- x: (renderCoord.x - this.currentPos.x) / this.zoom,
242
- y: (renderCoord.y - this.currentPos.y) / this.zoom
243
- };
244
- }
245
- getRenderCoord(absCoord) {
246
- return {
247
- x: absCoord.x * this.zoom + this.currentPos.x,
248
- y: absCoord.y * this.zoom + this.currentPos.y
249
- };
250
- }
251
- coordInsideRect(absCoord, rect) {
252
- const {x, y, width, height} = rect;
253
- return {
254
- x: MathUtils.withinRange(absCoord.x, [x, x + width]),
255
- y: MathUtils.withinRange(absCoord.y, [y, y + height])
256
- };
257
- }
258
- getPolygonPointList(lineType, pointList) {
259
- return lineType === ELineTypes.Curve ? PolygonUtils.createSmoothCurvePointsFromPointList(pointList) : pointList;
260
- }
261
- getIntersection(curCoord, preCoord, polygonPointListToLineList) {
262
- const pointA = this.getRenderCoord(preCoord);
263
- const pointB = this.getRenderCoord(curCoord);
264
- const drawingLine = {
265
- pointA,
266
- pointB
267
- };
268
- const intersection = LineToolUtils.calcOptimalIntersection(polygonPointListToLineList, drawingLine, pointA, POINT_RADIUS, this.zoom);
269
- return intersection;
270
- }
271
- coordInsidePolygon(curCoord, preCoord, polygon, polygonToolConfig) {
272
- const {pointList} = polygon;
273
- const lineType = polygonToolConfig == null ? void 0 : polygonToolConfig.lineType;
274
- if (pointList.length === 0) {
275
- return curCoord;
276
- }
277
- const polygonPointList = this.getPolygonPointList(lineType, pointList);
278
- const isInPolygon = PolygonUtils.isInPolygon(curCoord, polygonPointList);
279
- if (isInPolygon) {
280
- return curCoord;
281
- }
282
- const polygonPointListToLineList = polygonPointList.concat(polygonPointList[0]).map((i) => this.getRenderCoord(i));
283
- const intersection = this.getIntersection(curCoord, preCoord, polygonPointListToLineList);
284
- if (intersection) {
285
- return this.getAbsCoord(intersection == null ? void 0 : intersection.point);
286
- }
287
- return curCoord;
288
- }
289
- coordInsideImage(coord) {
290
- return this.coordInsideRect(coord, __spreadProps(__spreadValues({}, this.basicImgInfo), {x: 0, y: 0}));
291
- }
292
- getNextCoordByDependTool(curAbsCoord, preAbsCoord) {
293
- if (this.isDependRect) {
294
- return this.coordInsideRect(curAbsCoord, this.basicResult);
295
- }
296
- if (this.isDependPolygon) {
297
- return this.coordInsidePolygon(curAbsCoord, preAbsCoord, this.basicResult, this.dependToolConfig);
298
- }
299
- if (this.isDependOriginalImage) {
300
- return this.coordInsideImage(curAbsCoord);
301
- }
302
- }
303
- setDependInfo(dependToolName, dependToolConfig) {
304
- this.dependToolName = dependToolName != null ? dependToolName : "";
305
- this.dependToolConfig = dependToolName ? dependToolConfig : void 0;
306
- }
307
- setBasicImgInfo(basicImgInfo) {
308
- this.basicImgInfo = basicImgInfo;
309
- }
310
- setBasicResult(basicResult) {
311
- this.basicResult = basicResult;
312
- }
313
- setZoomAndCurrentPos(zoom, currentPos) {
314
- this.zoom = zoom;
315
- this.currentPos = currentPos;
316
- }
317
- isCoordInsideTarget(coord) {
318
- if (this.isDependPolygon) {
319
- return this.isInBasicPolygon(coord);
320
- }
321
- if (this.isDependRect) {
322
- const {x, y, width, height} = this.basicResult;
323
- const rectHorizontalRange = [x, x + width];
324
- const rectVerticalRange = [y, y + height];
325
- return MathUtils.isInRange(coord.x, rectHorizontalRange) && MathUtils.isInRange(coord.y, rectVerticalRange);
326
- }
327
- return MathUtils.isInRange(coord.x, [0, this.basicImgInfo.width]) && MathUtils.isInRange(coord.y, [0, this.basicImgInfo.height]);
328
- }
329
- isInBasicPolygon(coord) {
330
- var _a, _b;
331
- return PolygonUtils.isInPolygon(coord, ((_a = this.basicResult) == null ? void 0 : _a.pointList) || [], (_b = this.dependToolConfig) == null ? void 0 : _b.lineType);
332
- }
333
- }
334
-
335
- export { CoordinateUtils, AxisUtils as default };
1
+ import{EToolName as u,ELineTypes as C}from"../../constant/tool.js";import y from"../MathUtils.js";import x from"./PolygonUtils.js";import v,{POINT_RADIUS as _}from"./LineToolUtils.js";import{getHighlightPoints as P,getHighlightLines as m,getCuboidHoverRange as B}from"./CuboidUtils.js";var L=Object.defineProperty,R=Object.defineProperties,D=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,w=(a,t,e)=>t in a?L(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,f=(a,t)=>{for(var e in t||(t={}))T.call(t,e)&&w(a,e,t[e]);if(O)for(var e of O(t))Z.call(t,e)&&w(a,e,t[e]);return a},c=(a,t)=>R(a,D(t));class I{static getOffsetCoordinate(t,e,i){return{x:t.x*i+e.x,y:t.y*i+e.y}}static changeDrawOutsideTarget(t,e,i,s,n,o){return typeof s=="boolean"&&!s&&(n&&o?(t.x-e.x>(n.x+n.width)*o&&(t.x=(n.x+n.width)*o+e.x),t.x-e.x<n.x*o&&(t.x=n.x*o+e.x),t.y-e.y>(n.y+n.height)*o&&(t.y=(n.y+n.height)*o+e.y),t.y-e.y<n.y*o&&(t.y=n.y*o+e.y)):(t.x-e.x>i.width&&(t.x=i.width+e.x),t.x-e.x<0&&(t.x=e.x),t.y-e.y>i.height&&(t.y=i.height+e.y),t.y-e.y<0&&(t.y=e.y))),t}static changeCoordinateByRotate(t,e,i){const{width:s,height:n}=i,{x:o,y:r}=t;switch(e%360){case 90:return{x:n-r,y:o};case 180:return{x:s-o,y:n-r};case 270:return{x:r,y:s-o};default:return t}}static changeRectByZoom(t,e,i={x:0,y:0}){return c(f({},t),{x:t.x*e+i.x,y:t.y*e+i.y,width:t.width*e,height:t.height*e})}static changePointByZoom(t,e,i={x:0,y:0}){return c(f({},t),{x:t.x*e+i.x,y:t.y*e+i.y})}static changePointListByZoom(t,e,i={x:0,y:0}){return t==null?void 0:t.map(s=>this.changePointByZoom(s,e,i))}static changePlanePointByZoom(t,e,i={x:0,y:0}){return Object.entries(t).reduce((s,[n,o])=>{const r=I.changePointByZoom(o,e,i);return c(f({},s),{[n]:r})},{})}static changeCuboidByZoom(t,e,i={x:0,y:0}){return c(f({},t),{frontPoints:this.changePlanePointByZoom(t.frontPoints,e,i),backPoints:t.backPoints?this.changePlanePointByZoom(t.backPoints,e,i):t.backPoints})}static transformPlain2PointList({tl:t,tr:e,br:i,bl:s}){return[t,e,i,s]}static axisArea(t,e=3){const{x:i,y:s}=t,n=[];for(let o=i-e;o<i+e;o+=e/3)for(let r=s-e;r<s+e;r+=e/3)n.push({x:o,y:r});return n}static getOriginCoordinateWithOffsetCoordinate(t,e=1,i={x:0,y:0}){return{x:(t.x-i.x)/e,y:(t.y-i.y)/e}}static returnClosePointIndex(t,e,i=3){let s=-1;for(let n=0;n<e.length;n++){const o=e[n];this.getIsInScope(t,o,i)&&(s=n)}return s}static isCloseCuboid(t,e,i={scope:5,zoom:1}){const s=P(e),{scope:n=5}=i;for(let r=0;r<s.length;r++){const l=s[r];if(this.getIsInScope(t,l.point,n))return!0}const o=m(e);for(let r=0;r<o.length;r++){const l=o[r],{length:p}=y.getFootOfPerpendicular(t,l.p1,l.p2,!0);if(p<n)return!0}return!!x.isInPolygon(t,B(e))}static isCloseCuboidList(t,e,i={scope:5,zoom:1}){return e.some(s=>this.isCloseCuboid(t,s,i))}static returnClosePointOrLineInCuboid(t,e,i={scope:5,zoom:1}){const s=P(e),{scope:n=5,zoom:o=1}=i;for(let h=0;h<s.length;h++){const g=s[h];if(this.getIsInScope(t,g.point,n))return[{type:"point",points:[this.changePointByZoom(s[h].point,o)],originCuboid:e,positions:g.positions}]}let r=n;const l=m(e);let p;for(let h=0;h<l.length;h++){const g=l[h],{length:d}=y.getFootOfPerpendicular(t,g.p1,g.p2,!0);d<r&&(r=d,p=[{type:"line",points:this.changePointListByZoom([g.p1,g.p2],o),originCuboid:e,positions:g.positions}])}if(p)return p}static getIsInScope(t,e,i){return Math.abs(t.x-e.x)<i&&Math.abs(t.y-e.y)<i}}class b{constructor(t){this.currentPos=t.currentPos,this.zoom=t.zoom,this.basicImgInfo=t.basicImgInfo,this.dependToolName=""}get isDependPolygon(){return this.dependToolName===u.Polygon}get isDependRect(){return this.dependToolName===u.Rect}get isDependOriginalImage(){return this.dependToolName===""}getAbsCoord(t){return{x:(t.x-this.currentPos.x)/this.zoom,y:(t.y-this.currentPos.y)/this.zoom}}getRenderCoord(t){return{x:t.x*this.zoom+this.currentPos.x,y:t.y*this.zoom+this.currentPos.y}}coordInsideRect(t,e){const{x:i,y:s,width:n,height:o}=e;return{x:y.withinRange(t.x,[i,i+n]),y:y.withinRange(t.y,[s,s+o])}}getPolygonPointList(t,e){return t===C.Curve?x.createSmoothCurvePointsFromPointList(e):e}getIntersection(t,e,i){const s=this.getRenderCoord(e),n=this.getRenderCoord(t),o={pointA:s,pointB:n};return v.calcOptimalIntersection(i,o,s,_,this.zoom)}coordInsidePolygon(t,e,i,s){const{pointList:n}=i,o=s==null?void 0:s.lineType;if(n.length===0)return t;const r=this.getPolygonPointList(o,n);if(x.isInPolygon(t,r))return t;const p=r.concat(r[0]).map(g=>this.getRenderCoord(g)),h=this.getIntersection(t,e,p);return h?this.getAbsCoord(h==null?void 0:h.point):t}coordInsideImage(t){return this.coordInsideRect(t,c(f({},this.basicImgInfo),{x:0,y:0}))}getNextCoordByDependTool(t,e){if(this.isDependRect)return this.coordInsideRect(t,this.basicResult);if(this.isDependPolygon)return this.coordInsidePolygon(t,e,this.basicResult,this.dependToolConfig);if(this.isDependOriginalImage)return this.coordInsideImage(t)}setDependInfo(t,e){this.dependToolName=t!=null?t:"",this.dependToolConfig=t?e:void 0}setBasicImgInfo(t){this.basicImgInfo=t}setBasicResult(t){this.basicResult=t}setZoomAndCurrentPos(t,e){this.zoom=t,this.currentPos=e}isCoordInsideTarget(t){if(this.isDependPolygon)return this.isInBasicPolygon(t);if(this.isDependRect){const{x:e,y:i,width:s,height:n}=this.basicResult,o=[e,e+s],r=[i,i+n];return y.isInRange(t.x,o)&&y.isInRange(t.y,r)}return y.isInRange(t.x,[0,this.basicImgInfo.width])&&y.isInRange(t.y,[0,this.basicImgInfo.height])}isInBasicPolygon(t){var e,i;return x.isInPolygon(t,((e=this.basicResult)==null?void 0:e.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}}export{b as CoordinateUtils,I as default};
@@ -1,60 +1 @@
1
- import MathUtils from '../MathUtils.js';
2
-
3
- class CanvasUtils {
4
- static getMousePositionOnCanvasFromEvent(event, canvas) {
5
- if (canvas && event) {
6
- const canvasRect = canvas.getBoundingClientRect();
7
- return {
8
- x: event.clientX - canvasRect.left,
9
- y: event.clientY - canvasRect.top
10
- };
11
- }
12
- return null;
13
- }
14
- static getClientRect(canvas) {
15
- if (canvas) {
16
- const canvasRect = canvas.getBoundingClientRect();
17
- return {
18
- x: canvasRect.left,
19
- y: canvasRect.top,
20
- width: canvasRect.width,
21
- height: canvasRect.height
22
- };
23
- }
24
- return null;
25
- }
26
- static getSize(canvas) {
27
- if (canvas) {
28
- const canvasRect = canvas.getBoundingClientRect();
29
- return {
30
- width: canvasRect.width,
31
- height: canvasRect.height
32
- };
33
- }
34
- return null;
35
- }
36
- static inViewPort(coord, viewPort) {
37
- if (!coord) {
38
- return false;
39
- }
40
- return MathUtils.isInRange(coord.x, [viewPort.left, viewPort.right]) && MathUtils.isInRange(coord.y, [viewPort.top, viewPort.bottom]);
41
- }
42
- }
43
- CanvasUtils.getViewPort = (canvas, originOffset, zoom) => {
44
- const {width: canvasWidth, height: canvasHeight} = canvas;
45
- const {x, y} = originOffset;
46
- const top = (0 - y) / zoom;
47
- const left = (0 - x) / zoom;
48
- const bottom = top + canvasHeight / zoom;
49
- const right = left + canvasWidth / zoom;
50
- return {top, bottom, left, right};
51
- };
52
- CanvasUtils.getPixelRatio = (context) => {
53
- if (!context || !window) {
54
- return 1;
55
- }
56
- const backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1;
57
- return (window.devicePixelRatio || 1) / backingStore;
58
- };
59
-
60
- export { CanvasUtils as default };
1
+ import l from"../MathUtils.js";class a{static getMousePositionOnCanvasFromEvent(i,t){if(t&&i){const n=t.getBoundingClientRect();return{x:i.clientX-n.left,y:i.clientY-n.top}}return null}static getClientRect(i){if(i){const t=i.getBoundingClientRect();return{x:t.left,y:t.top,width:t.width,height:t.height}}return null}static getSize(i){if(i){const t=i.getBoundingClientRect();return{width:t.width,height:t.height}}return null}static inViewPort(i,t){return i?l.isInRange(i.x,[t.left,t.right])&&l.isInRange(i.y,[t.top,t.bottom]):!1}}a.getViewPort=(e,i,t)=>{const{width:n,height:o}=e,{x:g,y:c}=i,r=(0-c)/t,s=(0-g)/t,h=r+o/t,u=s+n/t;return{top:r,bottom:h,left:s,right:u}},a.getPixelRatio=e=>{if(!e||!window)return 1;const i=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/i};export{a as default};