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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/dist/_virtual/MathUtilsWorker.js +8 -1
  2. package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +35 -2
  3. package/dist/_virtual/filterBoxWorker.js +8 -1
  4. package/dist/_virtual/highlightWorker.js +8 -1
  5. package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +5 -1
  6. package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +5 -1
  7. package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +5 -1
  8. package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +5 -1
  9. package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +5 -1
  10. package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +5 -1
  11. package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +5 -1
  12. package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +5 -1
  13. package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +5 -1
  14. package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +5 -1
  15. package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -5
  16. package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +5 -7
  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 +5 -12
  20. package/dist/assets/attributeIcon/icon_editFEN.svg.js +5 -1
  21. package/dist/assets/attributeIcon/icon_editHUANG.svg.js +5 -1
  22. package/dist/assets/attributeIcon/icon_editLAN.svg.js +5 -1
  23. package/dist/assets/attributeIcon/icon_editLV.svg.js +5 -1
  24. package/dist/assets/attributeIcon/icon_editQING.svg.js +5 -1
  25. package/dist/constant/annotation.js +127 -1
  26. package/dist/constant/annotationTask.js +30 -1
  27. package/dist/constant/defaultConfig.js +266 -1
  28. package/dist/constant/keyCode.js +38 -1
  29. package/dist/constant/style.js +98 -1
  30. package/dist/constant/tool.js +236 -1
  31. package/dist/core/index.js +150 -1
  32. package/dist/core/pointCloud/OrbitControls.js +665 -1
  33. package/dist/core/pointCloud/PCDLoader.js +260 -2
  34. package/dist/core/pointCloud/annotation.js +215 -1
  35. package/dist/core/pointCloud/cache.js +53 -1
  36. package/dist/core/pointCloud/index.js +991 -5
  37. package/dist/core/pointCloud/matrix.js +138 -1
  38. package/dist/core/pointCloud/segmentation.js +144 -0
  39. package/dist/core/pointCloud/selector/Sse3dLassoSelector.js +26 -0
  40. package/dist/core/pointCloud/selector/Sse3dSelector.js +16 -0
  41. package/dist/core/scheduler.js +233 -1
  42. package/dist/core/toolOperation/LineToolOperation.js +1434 -1
  43. package/dist/core/toolOperation/ScribbleTool.js +292 -1
  44. package/dist/core/toolOperation/TextToolOperation.js +131 -1
  45. package/dist/core/toolOperation/ViewOperation.js +556 -1
  46. package/dist/core/toolOperation/basicToolOperation.js +881 -1
  47. package/dist/core/toolOperation/checkOperation.js +208 -1
  48. package/dist/core/toolOperation/cuboidOperation.js +754 -1
  49. package/dist/core/toolOperation/cuboidToggleButtonClass.js +152 -7
  50. package/dist/core/toolOperation/eventListener.js +37 -1
  51. package/dist/core/toolOperation/measureOperation.js +41 -1
  52. package/dist/core/toolOperation/pointCloud2dOperation.js +365 -1
  53. package/dist/core/toolOperation/pointOperation.js +696 -1
  54. package/dist/core/toolOperation/polygonOperation.js +1251 -1
  55. package/dist/core/toolOperation/rectOperation.js +1233 -1
  56. package/dist/core/toolOperation/segmentByRect.js +174 -1
  57. package/dist/core/toolOperation/tagOperation.js +201 -3
  58. package/dist/core/toolOperation/textAttributeClass.js +182 -16
  59. package/dist/index.js +185 -1
  60. package/dist/locales/constants.js +24 -1
  61. package/dist/locales/en_US/message.js +25 -1
  62. package/dist/locales/index.js +19 -1
  63. package/dist/locales/zh_CN/message.js +25 -1
  64. package/dist/newCore/CanvasScheduler.js +35 -1
  65. package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
  66. package/dist/types/core/pointCloud/selector/Sse3dLassoSelector.d.ts +0 -0
  67. package/dist/types/core/pointCloud/selector/Sse3dSelector.d.ts +0 -0
  68. package/dist/utils/ActionsHistory.js +84 -1
  69. package/dist/utils/ImgUtils.js +23 -1
  70. package/dist/utils/MathUtils.js +385 -2
  71. package/dist/utils/VectorUtils.js +25 -1
  72. package/dist/utils/tool/AttributeUtils.js +218 -1
  73. package/dist/utils/tool/AxisUtils.js +340 -1
  74. package/dist/utils/tool/CanvasUtils.js +62 -1
  75. package/dist/utils/tool/CommonToolUtils.js +174 -1
  76. package/dist/utils/tool/CuboidUtils.js +704 -1
  77. package/dist/utils/tool/DblClickEventListener.js +102 -1
  78. package/dist/utils/tool/DrawUtils.js +492 -3
  79. package/dist/utils/tool/EnhanceCommonToolUtils.js +53 -1
  80. package/dist/utils/tool/ImgPosUtils.js +58 -1
  81. package/dist/utils/tool/LineToolUtils.js +261 -1
  82. package/dist/utils/tool/MarkerUtils.js +56 -1
  83. package/dist/utils/tool/PolygonUtils.js +460 -1
  84. package/dist/utils/tool/RectUtils.js +155 -1
  85. package/dist/utils/tool/RenderDomClass.js +57 -7
  86. package/dist/utils/tool/RenderDomUtils.js +21 -4
  87. package/dist/utils/tool/StyleUtils.js +31 -1
  88. package/dist/utils/tool/TagUtils.js +129 -1
  89. package/dist/utils/tool/UnitUtils.js +12 -1
  90. package/dist/utils/tool/ZoomUtils.js +72 -1
  91. package/dist/utils/tool/polygonTool.js +133 -1
  92. package/dist/utils/uuid.js +26 -1
  93. package/es/_virtual/MathUtilsWorker.js +6 -1
  94. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
  95. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
  96. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -2
  97. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
  98. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
  99. package/es/_virtual/filterBoxWorker.js +6 -1
  100. package/es/_virtual/highlightWorker.js +6 -1
  101. package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +3 -1
  102. package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +3 -1
  103. package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +3 -1
  104. package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +3 -1
  105. package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +3 -1
  106. package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +3 -1
  107. package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +3 -1
  108. package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +3 -1
  109. package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +3 -1
  110. package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +3 -1
  111. package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +3 -5
  112. package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +3 -7
  113. package/es/assets/attributeIcon/icon_cuboidMore.svg.js +3 -5
  114. package/es/assets/attributeIcon/icon_cuboidRight.svg.js +3 -5
  115. package/es/assets/attributeIcon/icon_cuboidTop.svg.js +3 -12
  116. package/es/assets/attributeIcon/icon_editFEN.svg.js +3 -1
  117. package/es/assets/attributeIcon/icon_editHUANG.svg.js +3 -1
  118. package/es/assets/attributeIcon/icon_editLAN.svg.js +3 -1
  119. package/es/assets/attributeIcon/icon_editLV.svg.js +3 -1
  120. package/es/assets/attributeIcon/icon_editQING.svg.js +3 -1
  121. package/es/constant/annotation.js +113 -1
  122. package/es/constant/annotationTask.js +25 -1
  123. package/es/constant/defaultConfig.js +260 -1
  124. package/es/constant/keyCode.js +36 -1
  125. package/es/constant/style.js +74 -1
  126. package/es/constant/tool.js +220 -1
  127. package/es/core/index.js +148 -1
  128. package/es/core/pointCloud/OrbitControls.js +661 -1
  129. package/es/core/pointCloud/PCDLoader.js +256 -2
  130. package/es/core/pointCloud/annotation.js +211 -1
  131. package/es/core/pointCloud/cache.js +49 -1
  132. package/es/core/pointCloud/index.js +962 -5
  133. package/es/core/pointCloud/matrix.js +109 -1
  134. package/es/core/pointCloud/segmentation.js +120 -0
  135. package/es/core/pointCloud/selector/Sse3dLassoSelector.js +24 -0
  136. package/es/core/pointCloud/selector/Sse3dSelector.js +14 -0
  137. package/es/core/scheduler.js +228 -1
  138. package/es/core/toolOperation/LineToolOperation.js +1421 -1
  139. package/es/core/toolOperation/ScribbleTool.js +290 -1
  140. package/es/core/toolOperation/TextToolOperation.js +129 -1
  141. package/es/core/toolOperation/ViewOperation.js +549 -1
  142. package/es/core/toolOperation/basicToolOperation.js +877 -1
  143. package/es/core/toolOperation/checkOperation.js +206 -1
  144. package/es/core/toolOperation/cuboidOperation.js +752 -1
  145. package/es/core/toolOperation/cuboidToggleButtonClass.js +150 -7
  146. package/es/core/toolOperation/eventListener.js +35 -1
  147. package/es/core/toolOperation/measureOperation.js +39 -1
  148. package/es/core/toolOperation/pointCloud2dOperation.js +359 -1
  149. package/es/core/toolOperation/pointOperation.js +690 -1
  150. package/es/core/toolOperation/polygonOperation.js +1245 -1
  151. package/es/core/toolOperation/rectOperation.js +1228 -1
  152. package/es/core/toolOperation/scribbleTool2.js +249 -0
  153. package/es/core/toolOperation/segmentByRect.js +172 -1
  154. package/es/core/toolOperation/tagOperation.js +199 -3
  155. package/es/core/toolOperation/textAttributeClass.js +180 -16
  156. package/es/index.js +46 -1
  157. package/es/locales/constants.js +22 -1
  158. package/es/locales/en_US/message.js +23 -1
  159. package/es/locales/index.js +17 -1
  160. package/es/locales/zh_CN/message.js +23 -1
  161. package/es/newCore/CanvasScheduler.js +31 -1
  162. package/es/utils/ActionsHistory.js +78 -1
  163. package/es/utils/ImgUtils.js +21 -1
  164. package/es/utils/MathUtils.js +380 -2
  165. package/es/utils/VectorUtils.js +23 -1
  166. package/es/utils/tool/AttributeUtils.js +212 -1
  167. package/es/utils/tool/AxisUtils.js +335 -1
  168. package/es/utils/tool/CanvasUtils.js +60 -1
  169. package/es/utils/tool/CommonToolUtils.js +172 -1
  170. package/es/utils/tool/CuboidUtils.js +680 -1
  171. package/es/utils/tool/DblClickEventListener.js +100 -1
  172. package/es/utils/tool/DrawUtils.js +490 -3
  173. package/es/utils/tool/EnhanceCommonToolUtils.js +48 -1
  174. package/es/utils/tool/ImgPosUtils.js +56 -1
  175. package/es/utils/tool/LineToolUtils.js +255 -1
  176. package/es/utils/tool/MarkerUtils.js +54 -1
  177. package/es/utils/tool/PolygonUtils.js +458 -1
  178. package/es/utils/tool/RectUtils.js +153 -1
  179. package/es/utils/tool/RenderDomClass.js +55 -7
  180. package/es/utils/tool/RenderDomUtils.js +19 -4
  181. package/es/utils/tool/StyleUtils.js +29 -1
  182. package/es/utils/tool/TagUtils.js +127 -1
  183. package/es/utils/tool/UnitUtils.js +10 -1
  184. package/es/utils/tool/ZoomUtils.js +70 -1
  185. package/es/utils/tool/polygonTool.js +126 -1
  186. package/es/utils/uuid.js +24 -1
  187. package/package.json +7 -5
@@ -1 +1,206 @@
1
- import{cloneDeep as L}from"lodash";import w from"../../utils/tool/CommonToolUtils.js";import R from"../../utils/tool/RectUtils.js";import D from"../../utils/tool/TagUtils.js";import{DEFAULT_TEXT_OFFSET as I}from"../../constant/annotation.js";import{EToolName as c}from"../../constant/tool.js";import S from"../../utils/tool/AttributeUtils.js";import f from"../../utils/tool/AxisUtils.js";import d from"../../utils/tool/DrawUtils.js";import O from"../../utils/tool/StyleUtils.js";import{BasicToolOperation as U}from"./basicToolOperation.js";var y=Object.defineProperty,P=Object.getOwnPropertySymbols,C=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable,g=(a,i,t)=>i in a?y(a,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[i]=t,_=(a,i)=>{for(var t in i||(i={}))C.call(i,t)&&g(a,t,i[t]);if(P)for(var t of P(i))j.call(i,t)&&g(a,t,i[t]);return a};const b={x:8,y:26},x=2;class E extends U{constructor(i){super(i);this.getHoverRectID=t=>{var o,e;const s=this.getCoordinateUnderZoom(t),l=(e=(o=this.resultList.find(r=>r.toolName===c.Rect))==null?void 0:o.result)!=null?e:[];if(l.length>0){const r=l.filter(n=>R.isInRect(s,n,x,this.zoom));if(r.length===0)return"";if(r.length===1)return r[0].id;if(r.length>1)return r.map(h=>({size:h.width*h.height,id:h.id})).sort((h,u)=>h.size-u.size)[0].id}return""},this.resultList=[],this.hoverID=[],this.fillID=[],this.render=this.render.bind(this),this.drawPolygon=this.drawPolygon.bind(this),this.drawRect=this.drawRect.bind(this),this.drawTag=this.drawTag.bind(this),this.setShowDefaultCursor(!0),this.forbidOperation=!0}onMouseDown(i){var t,o;if(super.onMouseDown(i)||this.forbidMouseOperation||!this.imgInfo)return!0;const e=this.mouseHoverID,s=(o=(t=this.resultList.find(l=>l.toolName===c.Rect))==null?void 0:t.result)!=null?o:[];if(i.button===0){let l=[e],r=!0;e&&s.find(n=>n.id===e&&(n==null?void 0:n.isSelected))&&(r=!1),e||(l=s.map(n=>n.id),r=!1),this.emit("setSelectedID",l,r),this.render()}}updateRotate(){}onMouseMove(i){if(super.onMouseMove(i)||this.forbidMouseOperation||!this.imgInfo)return;const t=this.mouseHoverID,o=this.getHoverRectID(i);if(t!==o){this.mouseHoverID=o;let e=[o];o||(e=[]),this.emit("setHoverID",e),this.render()}}setResult(i){this.resultList=L(i),this.render()}drawPolygon(i,t){i==null||i.forEach(o=>{var e,s,l,r,n;const h=this.getColor(o.attribute,t),u=O.getStrokeAndFill(h,o.valid);let v=(s=(e=this.style)==null?void 0:e.width)!=null?s:2;this.hoverID.includes(o.id)?(v=4,d.drawPolygonWithFillAndLine(this.canvas,f.changePointListByZoom(o.pointList,this.zoom,this.currentPos),{fillColor:u.fill,strokeColor:u.stroke,pointColor:"white",thickness:v,lineCap:"round",isClose:!0,lineType:t==null?void 0:t.lineType})):d.drawPolygon(this.canvas,f.changePointListByZoom(o.pointList,this.zoom,this.currentPos),{color:u.fill,lineType:(l=this.config)==null?void 0:l.lineType,thickness:v,isClose:!0});let m=`${(n=S.getAttributeShowText(o.attribute,(r=t==null?void 0:t.attributeList)!=null?r:[]))!=null?n:""}`;(t==null?void 0:t.isShowOrder)&&(o==null?void 0:o.order)>0&&(m=`${o.order} ${m}`),d.drawText(this.canvas,f.changePointByZoom(o.pointList[0],this.zoom,this.currentPos),m,_({color:u.stroke},I));const p=f.changePointListByZoom(o.pointList||[],this.zoom,this.currentPos),T=p[p.length-1];d.drawText(this.canvas,{x:T.x+b.x,y:T.y+b.y},o==null?void 0:o.textAttribute,_({color:u.stroke},I))})}drawRect(i,t){i==null||i.forEach(o=>{let e=1;this.hoverID.includes(o.id)&&(e=3);const s=this.getColor(o.attribute,t),l=f.changeRectByZoom(o,this.zoom,this.currentPos);d.drawRect(this.canvas,l,{color:(o==null?void 0:o.valid)?s.valid.stroke:s.invalid.stroke,thickness:e}),this.fillID.includes(o.id)&&d.drawRectWithFill(this.canvas,l,{color:(o==null?void 0:o.valid)?s.valid.fill:s.invalid.fill})})}drawTag(i,t){const o=i.reduce((e,s)=>[...e,...(t==null?void 0:t.inputList)?D.getTagNameList(s.result,t.inputList):D.getTagnameListWithoutConfig(s.result)],[]);d.drawTag(this.canvas,o)}setHoverID(i){this.hoverID=i,this.render()}setFillID(i){this.fillID=i,this.render()}render(){var i;super.render(),(i=this.resultList)==null||i.forEach(t=>{switch(t==null?void 0:t.toolName){case c.Rect:this.drawRect(t.result,w.jsonParser(t.config));break;case c.Polygon:this.drawPolygon(t.result,w.jsonParser(t.config));break;case c.Tag:this.drawTag(t.result,w.jsonParser(t.config));break}})}exportData(){return[[],{}]}}export{E as default};
1
+ import { cloneDeep } from 'lodash';
2
+ import CommonToolUtils from '../../utils/tool/CommonToolUtils.js';
3
+ import RectUtils from '../../utils/tool/RectUtils.js';
4
+ import TagUtil from '../../utils/tool/TagUtils.js';
5
+ import { DEFAULT_TEXT_OFFSET } from '../../constant/annotation.js';
6
+ import { EToolName } from '../../constant/tool.js';
7
+ import AttributeUtils from '../../utils/tool/AttributeUtils.js';
8
+ import AxisUtils from '../../utils/tool/AxisUtils.js';
9
+ import DrawUtils from '../../utils/tool/DrawUtils.js';
10
+ import StyleUtils from '../../utils/tool/StyleUtils.js';
11
+ import { BasicToolOperation } from './basicToolOperation.js';
12
+
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
17
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
18
+ var __spreadValues = (a, b) => {
19
+ for (var prop in b || (b = {}))
20
+ if (__hasOwnProp.call(b, prop))
21
+ __defNormalProp(a, prop, b[prop]);
22
+ if (__getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(b)) {
24
+ if (__propIsEnum.call(b, prop))
25
+ __defNormalProp(a, prop, b[prop]);
26
+ }
27
+ return a;
28
+ };
29
+ const TEXT_ATTRIBUTE_OFFSET = {
30
+ x: 8,
31
+ y: 26
32
+ };
33
+ const newScope = 2;
34
+ class CheckOperation extends BasicToolOperation {
35
+ constructor(props) {
36
+ super(props);
37
+ this.getHoverRectID = (e) => {
38
+ var _a, _b;
39
+ const coordinate = this.getCoordinateUnderZoom(e);
40
+ const currentShowList = (_b = (_a = this.resultList.find((v) => v.toolName === EToolName.Rect)) == null ? void 0 : _a.result) != null ? _b : [];
41
+ if (currentShowList.length > 0) {
42
+ const hoverList = currentShowList.filter((rect) => RectUtils.isInRect(coordinate, rect, newScope, this.zoom));
43
+ if (hoverList.length === 0) {
44
+ return "";
45
+ }
46
+ if (hoverList.length === 1) {
47
+ return hoverList[0].id;
48
+ }
49
+ if (hoverList.length > 1) {
50
+ const rectSizeList = hoverList.map((rect) => ({size: rect.width * rect.height, id: rect.id})).sort((a, b) => a.size - b.size);
51
+ return rectSizeList[0].id;
52
+ }
53
+ }
54
+ return "";
55
+ };
56
+ this.resultList = [];
57
+ this.hoverID = [];
58
+ this.fillID = [];
59
+ this.render = this.render.bind(this);
60
+ this.drawPolygon = this.drawPolygon.bind(this);
61
+ this.drawRect = this.drawRect.bind(this);
62
+ this.drawTag = this.drawTag.bind(this);
63
+ this.setShowDefaultCursor(true);
64
+ this.forbidOperation = true;
65
+ }
66
+ onMouseDown(e) {
67
+ var _a, _b;
68
+ if (super.onMouseDown(e) || this.forbidMouseOperation || !this.imgInfo) {
69
+ return true;
70
+ }
71
+ const newMouseSelectedID = this.mouseHoverID;
72
+ const currentShowList = (_b = (_a = this.resultList.find((v) => v.toolName === EToolName.Rect)) == null ? void 0 : _a.result) != null ? _b : [];
73
+ if (e.button === 0) {
74
+ let selectedID = [newMouseSelectedID];
75
+ let isShow = true;
76
+ if (newMouseSelectedID && currentShowList.find((rect) => rect.id === newMouseSelectedID && (rect == null ? void 0 : rect.isSelected))) {
77
+ isShow = false;
78
+ }
79
+ if (!newMouseSelectedID) {
80
+ selectedID = currentShowList.map((rect) => rect.id);
81
+ isShow = false;
82
+ }
83
+ this.emit("setSelectedID", selectedID, isShow);
84
+ this.render();
85
+ }
86
+ }
87
+ updateRotate() {
88
+ }
89
+ onMouseMove(e) {
90
+ if (super.onMouseMove(e) || this.forbidMouseOperation || !this.imgInfo) {
91
+ return;
92
+ }
93
+ const oldMouseHoverID = this.mouseHoverID;
94
+ const newMouseHoverID = this.getHoverRectID(e);
95
+ if (oldMouseHoverID !== newMouseHoverID) {
96
+ this.mouseHoverID = newMouseHoverID;
97
+ let hoverID = [newMouseHoverID];
98
+ if (!newMouseHoverID) {
99
+ hoverID = [];
100
+ }
101
+ this.emit("setHoverID", hoverID);
102
+ this.render();
103
+ }
104
+ }
105
+ setResult(result) {
106
+ this.resultList = cloneDeep(result);
107
+ this.render();
108
+ }
109
+ drawPolygon(polygonList, config) {
110
+ polygonList == null ? void 0 : polygonList.forEach((polygon) => {
111
+ var _a, _b, _c, _d, _e;
112
+ const toolColor = this.getColor(polygon.attribute, config);
113
+ const toolData = StyleUtils.getStrokeAndFill(toolColor, polygon.valid);
114
+ let thickness = (_b = (_a = this.style) == null ? void 0 : _a.width) != null ? _b : 2;
115
+ if (this.hoverID.includes(polygon.id)) {
116
+ thickness = 4;
117
+ DrawUtils.drawPolygonWithFillAndLine(this.canvas, AxisUtils.changePointListByZoom(polygon.pointList, this.zoom, this.currentPos), {
118
+ fillColor: toolData.fill,
119
+ strokeColor: toolData.stroke,
120
+ pointColor: "white",
121
+ thickness,
122
+ lineCap: "round",
123
+ isClose: true,
124
+ lineType: config == null ? void 0 : config.lineType
125
+ });
126
+ } else {
127
+ DrawUtils.drawPolygon(this.canvas, AxisUtils.changePointListByZoom(polygon.pointList, this.zoom, this.currentPos), {
128
+ color: toolData.fill,
129
+ lineType: (_c = this.config) == null ? void 0 : _c.lineType,
130
+ thickness,
131
+ isClose: true
132
+ });
133
+ }
134
+ let showText = `${(_e = AttributeUtils.getAttributeShowText(polygon.attribute, (_d = config == null ? void 0 : config.attributeList) != null ? _d : [])) != null ? _e : ""}`;
135
+ if ((config == null ? void 0 : config.isShowOrder) && (polygon == null ? void 0 : polygon.order) > 0) {
136
+ showText = `${polygon.order} ${showText}`;
137
+ }
138
+ DrawUtils.drawText(this.canvas, AxisUtils.changePointByZoom(polygon.pointList[0], this.zoom, this.currentPos), showText, __spreadValues({
139
+ color: toolData.stroke
140
+ }, DEFAULT_TEXT_OFFSET));
141
+ const transformPointList = AxisUtils.changePointListByZoom(polygon.pointList || [], this.zoom, this.currentPos);
142
+ const endPoint = transformPointList[transformPointList.length - 1];
143
+ DrawUtils.drawText(this.canvas, {x: endPoint.x + TEXT_ATTRIBUTE_OFFSET.x, y: endPoint.y + TEXT_ATTRIBUTE_OFFSET.y}, polygon == null ? void 0 : polygon.textAttribute, __spreadValues({
144
+ color: toolData.stroke
145
+ }, DEFAULT_TEXT_OFFSET));
146
+ });
147
+ }
148
+ drawRect(rectList, config) {
149
+ rectList == null ? void 0 : rectList.forEach((rect) => {
150
+ let thickness = 1;
151
+ if (this.hoverID.includes(rect.id)) {
152
+ thickness = 3;
153
+ }
154
+ const toolColor = this.getColor(rect.attribute, config);
155
+ const renderRect = AxisUtils.changeRectByZoom(rect, this.zoom, this.currentPos);
156
+ DrawUtils.drawRect(this.canvas, renderRect, {
157
+ color: (rect == null ? void 0 : rect.valid) ? toolColor.valid.stroke : toolColor.invalid.stroke,
158
+ thickness
159
+ });
160
+ if (this.fillID.includes(rect.id)) {
161
+ DrawUtils.drawRectWithFill(this.canvas, renderRect, {
162
+ color: (rect == null ? void 0 : rect.valid) ? toolColor.valid.fill : toolColor.invalid.fill
163
+ });
164
+ }
165
+ });
166
+ }
167
+ drawTag(tagList, config) {
168
+ const tagInfoList = tagList.reduce((acc, cur) => {
169
+ return [
170
+ ...acc,
171
+ ...(config == null ? void 0 : config.inputList) ? TagUtil.getTagNameList(cur.result, config.inputList) : TagUtil.getTagnameListWithoutConfig(cur.result)
172
+ ];
173
+ }, []);
174
+ DrawUtils.drawTag(this.canvas, tagInfoList);
175
+ }
176
+ setHoverID(hoverID) {
177
+ this.hoverID = hoverID;
178
+ this.render();
179
+ }
180
+ setFillID(fillID) {
181
+ this.fillID = fillID;
182
+ this.render();
183
+ }
184
+ render() {
185
+ var _a;
186
+ super.render();
187
+ (_a = this.resultList) == null ? void 0 : _a.forEach((item) => {
188
+ switch (item == null ? void 0 : item.toolName) {
189
+ case EToolName.Rect:
190
+ this.drawRect(item.result, CommonToolUtils.jsonParser(item.config));
191
+ break;
192
+ case EToolName.Polygon:
193
+ this.drawPolygon(item.result, CommonToolUtils.jsonParser(item.config));
194
+ break;
195
+ case EToolName.Tag:
196
+ this.drawTag(item.result, CommonToolUtils.jsonParser(item.config));
197
+ break;
198
+ }
199
+ });
200
+ }
201
+ exportData() {
202
+ return [[], {}];
203
+ }
204
+ }
205
+
206
+ export { CheckOperation as default };