@labelbee/lb-annotation 1.0.0-alpha.1

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 (241) hide show
  1. package/README.md +210 -0
  2. package/dist/_virtual/MathUtilsWorker.js +1 -0
  3. package/dist/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -0
  4. package/dist/_virtual/filterBoxWorker.js +1 -0
  5. package/dist/_virtual/highlightWorker.js +1 -0
  6. package/dist/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -0
  7. package/dist/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -0
  8. package/dist/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -0
  9. package/dist/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -0
  10. package/dist/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -0
  11. package/dist/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -0
  12. package/dist/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -0
  13. package/dist/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -0
  14. package/dist/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -0
  15. package/dist/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -0
  16. package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -0
  17. package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -0
  18. package/dist/assets/attributeIcon/icon_cuboidMore.svg.js +5 -0
  19. package/dist/assets/attributeIcon/icon_cuboidRight.svg.js +5 -0
  20. package/dist/assets/attributeIcon/icon_cuboidTop.svg.js +12 -0
  21. package/dist/assets/attributeIcon/icon_editFEN.svg.js +1 -0
  22. package/dist/assets/attributeIcon/icon_editHUANG.svg.js +1 -0
  23. package/dist/assets/attributeIcon/icon_editLAN.svg.js +1 -0
  24. package/dist/assets/attributeIcon/icon_editLV.svg.js +1 -0
  25. package/dist/assets/attributeIcon/icon_editQING.svg.js +1 -0
  26. package/dist/constant/annotation.js +1 -0
  27. package/dist/constant/annotationTask.js +1 -0
  28. package/dist/constant/defaultConfig.js +1 -0
  29. package/dist/constant/keyCode.js +1 -0
  30. package/dist/constant/style.js +1 -0
  31. package/dist/constant/tool.js +1 -0
  32. package/dist/core/index.js +1 -0
  33. package/dist/core/pointCloud/OrbitControls.js +1 -0
  34. package/dist/core/pointCloud/PCDLoader.js +2 -0
  35. package/dist/core/pointCloud/annotation.js +1 -0
  36. package/dist/core/pointCloud/cache.js +1 -0
  37. package/dist/core/pointCloud/index.js +11 -0
  38. package/dist/core/pointCloud/matrix.js +1 -0
  39. package/dist/core/scheduler.js +1 -0
  40. package/dist/core/toolOperation/LineToolOperation.js +1 -0
  41. package/dist/core/toolOperation/ScribbleTool.js +1 -0
  42. package/dist/core/toolOperation/TextToolOperation.js +1 -0
  43. package/dist/core/toolOperation/ViewOperation.js +1 -0
  44. package/dist/core/toolOperation/basicToolOperation.js +1 -0
  45. package/dist/core/toolOperation/checkOperation.js +1 -0
  46. package/dist/core/toolOperation/cuboidOperation.js +1 -0
  47. package/dist/core/toolOperation/cuboidToggleButtonClass.js +31 -0
  48. package/dist/core/toolOperation/eventListener.js +1 -0
  49. package/dist/core/toolOperation/measureOperation.js +1 -0
  50. package/dist/core/toolOperation/pointCloud2dOperation.js +1 -0
  51. package/dist/core/toolOperation/pointOperation.js +1 -0
  52. package/dist/core/toolOperation/polygonOperation.js +1 -0
  53. package/dist/core/toolOperation/rectOperation.js +1 -0
  54. package/dist/core/toolOperation/segmentByRect.js +1 -0
  55. package/dist/core/toolOperation/tagOperation.js +19 -0
  56. package/dist/core/toolOperation/textAttributeClass.js +37 -0
  57. package/dist/index.js +1 -0
  58. package/dist/locales/constants.js +1 -0
  59. package/dist/locales/en_US/message.js +1 -0
  60. package/dist/locales/index.js +1 -0
  61. package/dist/locales/zh_CN/message.js +1 -0
  62. package/dist/newCore/CanvasScheduler.js +1 -0
  63. package/dist/types/constant/annotation.d.ts +118 -0
  64. package/dist/types/constant/annotationTask.d.ts +16 -0
  65. package/dist/types/constant/defaultConfig.d.ts +273 -0
  66. package/dist/types/constant/keyCode.d.ts +33 -0
  67. package/dist/types/constant/style.d.ts +50 -0
  68. package/dist/types/constant/tool.d.ts +194 -0
  69. package/dist/types/core/index.d.ts +105 -0
  70. package/dist/types/core/pointCloud/OrbitControls.d.ts +60 -0
  71. package/dist/types/core/pointCloud/PCDLoader.d.ts +12 -0
  72. package/dist/types/core/pointCloud/annotation.d.ts +86 -0
  73. package/dist/types/core/pointCloud/cache.d.ts +26 -0
  74. package/dist/types/core/pointCloud/filterBoxWorker.d.ts +1 -0
  75. package/dist/types/core/pointCloud/highlightWorker.d.ts +1 -0
  76. package/dist/types/core/pointCloud/index.d.ts +374 -0
  77. package/dist/types/core/pointCloud/matrix.d.ts +63 -0
  78. package/dist/types/core/scheduler.d.ts +88 -0
  79. package/dist/types/core/toolOperation/LineToolOperation.d.ts +443 -0
  80. package/dist/types/core/toolOperation/ScribbleTool.d.ts +65 -0
  81. package/dist/types/core/toolOperation/TextToolOperation.d.ts +41 -0
  82. package/dist/types/core/toolOperation/ViewOperation.d.ts +102 -0
  83. package/dist/types/core/toolOperation/basicToolOperation.d.ts +266 -0
  84. package/dist/types/core/toolOperation/checkOperation.d.ts +37 -0
  85. package/dist/types/core/toolOperation/cuboidOperation.d.ts +174 -0
  86. package/dist/types/core/toolOperation/cuboidToggleButtonClass.d.ts +38 -0
  87. package/dist/types/core/toolOperation/eventListener.d.ts +33 -0
  88. package/dist/types/core/toolOperation/measureOperation.d.ts +8 -0
  89. package/dist/types/core/toolOperation/pointCloud2dOperation.d.ts +119 -0
  90. package/dist/types/core/toolOperation/pointOperation.d.ts +135 -0
  91. package/dist/types/core/toolOperation/polygonOperation.d.ts +201 -0
  92. package/dist/types/core/toolOperation/rectOperation.d.ts +175 -0
  93. package/dist/types/core/toolOperation/segmentByRect.d.ts +31 -0
  94. package/dist/types/core/toolOperation/tagOperation.d.ts +44 -0
  95. package/dist/types/core/toolOperation/textAttributeClass.d.ts +65 -0
  96. package/dist/types/index.d.ts +37 -0
  97. package/dist/types/locales/constants.d.ts +19 -0
  98. package/dist/types/locales/en_US/message.d.ts +2 -0
  99. package/dist/types/locales/index.d.ts +4 -0
  100. package/dist/types/locales/zh_CN/message.d.ts +2 -0
  101. package/dist/types/newCore/CanvasScheduler.d.ts +31 -0
  102. package/dist/types/newCore/index.d.ts +1 -0
  103. package/dist/types/utils/ActionsHistory.d.ts +32 -0
  104. package/dist/types/utils/EventBus.d.ts +40 -0
  105. package/dist/types/utils/ImgUtils.d.ts +3 -0
  106. package/dist/types/utils/MathUtils.d.ts +172 -0
  107. package/dist/types/utils/MathUtilsWorker.d.ts +29 -0
  108. package/dist/types/utils/VectorUtils.d.ts +16 -0
  109. package/dist/types/utils/tool/AttributeUtils.d.ts +94 -0
  110. package/dist/types/utils/tool/AxisUtils.d.ts +238 -0
  111. package/dist/types/utils/tool/CanvasUtils.d.ts +46 -0
  112. package/dist/types/utils/tool/CommonToolUtils.d.ts +105 -0
  113. package/dist/types/utils/tool/CuboidUtils.d.ts +267 -0
  114. package/dist/types/utils/tool/DblClickEventListener.d.ts +47 -0
  115. package/dist/types/utils/tool/DrawUtils.d.ts +196 -0
  116. package/dist/types/utils/tool/EnhanceCommonToolUtils.d.ts +23 -0
  117. package/dist/types/utils/tool/ImgPosUtils.d.ts +34 -0
  118. package/dist/types/utils/tool/LineToolUtils.d.ts +105 -0
  119. package/dist/types/utils/tool/MarkerUtils.d.ts +27 -0
  120. package/dist/types/utils/tool/PolygonUtils.d.ts +120 -0
  121. package/dist/types/utils/tool/RectUtils.d.ts +69 -0
  122. package/dist/types/utils/tool/RenderDomClass.d.ts +24 -0
  123. package/dist/types/utils/tool/RenderDomUtils.d.ts +3 -0
  124. package/dist/types/utils/tool/StyleUtils.d.ts +15 -0
  125. package/dist/types/utils/tool/TagUtils.d.ts +54 -0
  126. package/dist/types/utils/tool/UnitUtils.d.ts +4 -0
  127. package/dist/types/utils/tool/ZoomUtils.d.ts +16 -0
  128. package/dist/types/utils/tool/polygonTool.d.ts +32 -0
  129. package/dist/types/utils/uuid.d.ts +1 -0
  130. package/dist/utils/ActionsHistory.js +1 -0
  131. package/dist/utils/ImgUtils.js +1 -0
  132. package/dist/utils/MathUtils.js +2 -0
  133. package/dist/utils/VectorUtils.js +1 -0
  134. package/dist/utils/tool/AttributeUtils.js +1 -0
  135. package/dist/utils/tool/AxisUtils.js +1 -0
  136. package/dist/utils/tool/CanvasUtils.js +1 -0
  137. package/dist/utils/tool/CommonToolUtils.js +1 -0
  138. package/dist/utils/tool/CuboidUtils.js +1 -0
  139. package/dist/utils/tool/DblClickEventListener.js +1 -0
  140. package/dist/utils/tool/DrawUtils.js +3 -0
  141. package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -0
  142. package/dist/utils/tool/ImgPosUtils.js +1 -0
  143. package/dist/utils/tool/LineToolUtils.js +1 -0
  144. package/dist/utils/tool/MarkerUtils.js +1 -0
  145. package/dist/utils/tool/PolygonUtils.js +1 -0
  146. package/dist/utils/tool/RectUtils.js +1 -0
  147. package/dist/utils/tool/RenderDomClass.js +20 -0
  148. package/dist/utils/tool/RenderDomUtils.js +16 -0
  149. package/dist/utils/tool/StyleUtils.js +1 -0
  150. package/dist/utils/tool/TagUtils.js +1 -0
  151. package/dist/utils/tool/UnitUtils.js +1 -0
  152. package/dist/utils/tool/ZoomUtils.js +1 -0
  153. package/dist/utils/tool/polygonTool.js +1 -0
  154. package/dist/utils/uuid.js +1 -0
  155. package/es/_virtual/MathUtilsWorker.js +1 -0
  156. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +2 -0
  157. package/es/_virtual/filterBoxWorker.js +1 -0
  158. package/es/_virtual/highlightWorker.js +1 -0
  159. package/es/assets/attributeIcon/icon_canvasEdit0.svg.js +1 -0
  160. package/es/assets/attributeIcon/icon_canvasEdit1.svg.js +1 -0
  161. package/es/assets/attributeIcon/icon_canvasEdit2.svg.js +1 -0
  162. package/es/assets/attributeIcon/icon_canvasEdit3.svg.js +1 -0
  163. package/es/assets/attributeIcon/icon_canvasEdit4.svg.js +1 -0
  164. package/es/assets/attributeIcon/icon_canvasEdit5.svg.js +1 -0
  165. package/es/assets/attributeIcon/icon_canvasEdit6.svg.js +1 -0
  166. package/es/assets/attributeIcon/icon_canvasEdit7.svg.js +1 -0
  167. package/es/assets/attributeIcon/icon_canvasEdit8.svg.js +1 -0
  168. package/es/assets/attributeIcon/icon_canvasEdit_miss.svg.js +1 -0
  169. package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -0
  170. package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -0
  171. package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -0
  172. package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -0
  173. package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -0
  174. package/es/assets/attributeIcon/icon_editFEN.svg.js +1 -0
  175. package/es/assets/attributeIcon/icon_editHUANG.svg.js +1 -0
  176. package/es/assets/attributeIcon/icon_editLAN.svg.js +1 -0
  177. package/es/assets/attributeIcon/icon_editLV.svg.js +1 -0
  178. package/es/assets/attributeIcon/icon_editQING.svg.js +1 -0
  179. package/es/constant/annotation.js +1 -0
  180. package/es/constant/annotationTask.js +1 -0
  181. package/es/constant/defaultConfig.js +1 -0
  182. package/es/constant/keyCode.js +1 -0
  183. package/es/constant/style.js +1 -0
  184. package/es/constant/tool.js +1 -0
  185. package/es/core/index.js +1 -0
  186. package/es/core/pointCloud/OrbitControls.js +1 -0
  187. package/es/core/pointCloud/PCDLoader.js +2 -0
  188. package/es/core/pointCloud/annotation.js +1 -0
  189. package/es/core/pointCloud/cache.js +1 -0
  190. package/es/core/pointCloud/index.js +11 -0
  191. package/es/core/pointCloud/matrix.js +1 -0
  192. package/es/core/scheduler.js +1 -0
  193. package/es/core/toolOperation/LineToolOperation.js +1 -0
  194. package/es/core/toolOperation/ScribbleTool.js +1 -0
  195. package/es/core/toolOperation/TextToolOperation.js +1 -0
  196. package/es/core/toolOperation/ViewOperation.js +1 -0
  197. package/es/core/toolOperation/basicToolOperation.js +1 -0
  198. package/es/core/toolOperation/checkOperation.js +1 -0
  199. package/es/core/toolOperation/cuboidOperation.js +1 -0
  200. package/es/core/toolOperation/cuboidToggleButtonClass.js +31 -0
  201. package/es/core/toolOperation/eventListener.js +1 -0
  202. package/es/core/toolOperation/measureOperation.js +1 -0
  203. package/es/core/toolOperation/pointCloud2dOperation.js +1 -0
  204. package/es/core/toolOperation/pointOperation.js +1 -0
  205. package/es/core/toolOperation/polygonOperation.js +1 -0
  206. package/es/core/toolOperation/rectOperation.js +1 -0
  207. package/es/core/toolOperation/segmentByRect.js +1 -0
  208. package/es/core/toolOperation/tagOperation.js +19 -0
  209. package/es/core/toolOperation/textAttributeClass.js +37 -0
  210. package/es/index.js +1 -0
  211. package/es/locales/constants.js +1 -0
  212. package/es/locales/en_US/message.js +1 -0
  213. package/es/locales/index.js +1 -0
  214. package/es/locales/zh_CN/message.js +1 -0
  215. package/es/newCore/CanvasScheduler.js +1 -0
  216. package/es/utils/ActionsHistory.js +1 -0
  217. package/es/utils/ImgUtils.js +1 -0
  218. package/es/utils/MathUtils.js +2 -0
  219. package/es/utils/VectorUtils.js +1 -0
  220. package/es/utils/tool/AttributeUtils.js +1 -0
  221. package/es/utils/tool/AxisUtils.js +1 -0
  222. package/es/utils/tool/CanvasUtils.js +1 -0
  223. package/es/utils/tool/CommonToolUtils.js +1 -0
  224. package/es/utils/tool/CuboidUtils.js +1 -0
  225. package/es/utils/tool/DblClickEventListener.js +1 -0
  226. package/es/utils/tool/DrawUtils.js +3 -0
  227. package/es/utils/tool/EnhanceCommonToolUtils.js +1 -0
  228. package/es/utils/tool/ImgPosUtils.js +1 -0
  229. package/es/utils/tool/LineToolUtils.js +1 -0
  230. package/es/utils/tool/MarkerUtils.js +1 -0
  231. package/es/utils/tool/PolygonUtils.js +1 -0
  232. package/es/utils/tool/RectUtils.js +1 -0
  233. package/es/utils/tool/RenderDomClass.js +20 -0
  234. package/es/utils/tool/RenderDomUtils.js +16 -0
  235. package/es/utils/tool/StyleUtils.js +1 -0
  236. package/es/utils/tool/TagUtils.js +1 -0
  237. package/es/utils/tool/UnitUtils.js +1 -0
  238. package/es/utils/tool/ZoomUtils.js +1 -0
  239. package/es/utils/tool/polygonTool.js +1 -0
  240. package/es/utils/uuid.js +1 -0
  241. package/package.json +103 -0
@@ -0,0 +1 @@
1
+ import{i18n as _}from"@labelbee/lb-utils";import D from"../../utils/MathUtils.js";import j from"../../utils/tool/RectUtils.js";import N from"lodash";import{ERotateDirection as W,EDragStatus as x,ESortDirection as U,EDragTarget as v,TEXT_ATTRIBUTE_OFFSET as E,DEFAULT_TEXT_OFFSET as k}from"../../constant/annotation.js";import L from"../../constant/keyCode.js";import{EPolygonPattern as w,edgeAdsorptionScope as R,ELineTypes as O,EToolName as H}from"../../constant/tool.js";import C from"../../locales/index.js";import{EMessage as S}from"../../locales/constants.js";import K from"../../utils/ActionsHistory.js";import b from"../../utils/tool/AttributeUtils.js";import a from"../../utils/tool/AxisUtils.js";import B from"../../utils/tool/CanvasUtils.js";import u from"../../utils/tool/CommonToolUtils.js";import P from"../../utils/tool/DrawUtils.js";import y from"../../utils/tool/PolygonUtils.js";import A from"../../utils/tool/StyleUtils.js";import M from"../../utils/uuid.js";import{BasicToolOperation as $}from"./basicToolOperation.js";import V from"./textAttributeClass.js";var X=Object.defineProperty,Y=Object.defineProperties,q=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,F=(I,t,e)=>t in I?X(I,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):I[t]=e,f=(I,t)=>{for(var e in t||(t={}))G.call(t,e)&&F(I,e,t[e]);if(Z)for(var e of Z(t))J.call(t,e)&&F(I,e,t[e]);return I},m=(I,t)=>Y(I,q(t));const z=164;class Q extends ${constructor(t){super(t);this.isAllowDouble=e=>{const{selectedID:i}=this,s=this.getHoverID(e);return!!(i&&i===s)},this.textChange=e=>{this.config.textConfigurable===!1||!this.selectedID||(this.setPolygonList(b.textChange(e,this.selectedID,this.polygonList)),this.emit("selectedChange"),this.render())},this.emitUpdatePolygonByDrag=()=>{if(this.dragInfo){const{originPolygon:e}=this.dragInfo;this.emit("updatePolygonByDrag",[{newPolygon:this.selectedPolygon,originPolygon:e}])}},this.config=u.jsonParser(t.config),this.drawingPointList=[],this.polygonList=[],this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.drawingHistory=new K,this.isCtrl=!1,this.isAlt=!1,this.isCombined=!1,this.pattern=w.Normal,this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this)}eventBinding(){super.eventBinding(),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseup",this.dragMouseUp),this.dblClickListener.addEvent(this.onMouseUp,this.onLeftDblClick,this.onRightDblClick,this.isAllowDouble)}eventUnbinding(){super.eventUnbinding(),this.container.removeEventListener("mouseup",this.dragMouseUp)}destroy(){super.destroy(),this._textAttributInstance&&this._textAttributInstance.clearTextAttribute()}get selectedPolygon(){return y.getPolygonByID(this.visiblePolygonList,this.selectedID)}get hoverPolygon(){return this.visiblePolygonList.find(t=>t.id===this.hoverID&&t.id!==this.selectedID)}get enableDrag(){return Boolean(this.selectedID&&this.dragInfo)}get visiblePolygonList(){return this.polygonList}get polygonListUnderZoom(){return this.visiblePolygonList.map(t=>m(f({},t),{pointList:a.changePointListByZoom(t.pointList,this.zoom)}))}get selectedText(){var t;return(t=this.selectedPolygon)==null?void 0:t.textAttribute}get dataList(){return this.polygonList}setPattern(t,e=!1){var i;((i=this.drawingPointList)==null?void 0:i.length)>0&&e===!0||(this.pattern=t)}get currentShowList(){let t=[];const[e,i]=u.getRenderResultList(this.visiblePolygonList,u.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=u.getRenderResultList(this.polygonList,u.getSourceID(this.basicResult),[]);return t}setResult(t){this.clearActiveStatus(),this.setPolygonList(t),this.render()}setPolygonDataByID(t,e){return this.polygonList.map(i=>i.id===e?f(f({},i),t):i)}rotatePolygon(t=1,e=W.Clockwise,i=this.selectedID){if(!i)return;const s=y.getPolygonByID(this.polygonList,i);if(!s)return;const o=y.updatePolygonByRotate(e,t,s==null?void 0:s.pointList);this.setPolygonList(this.setPolygonDataByID({pointList:o},i)),this.render()}addPointInDrawing(t){if(!this.imgInfo||this.forbidAddNewPolygonFuc&&this.forbidAddNewPolygonFuc(t))return;const{upperLimitPointNum:e,edgeAdsorption:i}=this.config;if(e&&this.drawingPointList.length>=e){this.emit("messageInfo",`${C.getMessagesByLocale(S.UpperLimitErrorNotice,this.lang)}${e}`);return}this.deleteSelectedID();const s=this.getCoordinateUnderZoom(t),o=a.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(a.returnClosePointIndex(o,a.changePointListByZoom(this.drawingPointList,this.zoom))===0){this.addDrawingPointToPolygonList();return}const{dropFoot:n}=y.getClosestPoint(o,this.polygonListUnderZoom,this.config.lineType,R),r=a.changePointByZoom(n&&t.altKey===!1&&i?n:o,1/this.zoom);if(this.pattern===w.Rect&&this.drawingPointList.length===2){const h=D.getRectangleByRightAngle(r,this.drawingPointList);if(this.drawingPointList=h,this.config.drawOutsideTarget===!1&&this.imgInfo&&this.isPolygonOutSide(this.drawingPointList)){this.emit("messageInfo",`${C.getMessagesByLocale(S.ForbiddenCreationOutsideBoundary,this.lang)}`),this.drawingPointList=[];return}this.addDrawingPointToPolygonList(!0);return}this.drawingPointList.push(r),this.drawingPointList.length===1?this.drawingHistory.initRecord(this.drawingPointList):this.drawingHistory.pushHistory(this.drawingPointList)}clearResult(){this.setPolygonList([]),this.deleteSelectedID(),this.render()}clearPolygonDrag(){this.drawingPointList=[],this.dragInfo=void 0,this.dragInfo=void 0,this.dragStatus=x.Wait,this.hoverEdgeIndex=-1,this.hoverPointIndex=-1,this.hoverID=""}clearActiveStatus(){this.clearPolygonDrag(),this.deleteSelectedID()}clearDrawingStatus(){this.drawingPointList=[]}setPolygonList(t){const e=this.polygonList.length;this.polygonList=t,e!==t.length&&this.emit("updatePageNumber")}setSelectedID(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render(),this.emit("selectedChange")}setDefaultAttribute(t=""){const e=this.defaultAttribute;if(this.defaultAttribute=t,e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedID:i}=this;if(i&&(this.selectedPolygon&&(this.selectedPolygon.attribute=t),this.history.pushHistory(this.polygonList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}setPolygonValidAndRender(t){if(!t)return;const e=this.polygonList.map(i=>{var s;if(i.id===t){const o=(s=i==null?void 0:i.valid)!=null?s:!0;return m(f({},i),{valid:!o})}return i});this.setPolygonList(e),this.history.pushHistory(this.polygonList),this.render(),this.emit("updateResult")}addDrawingPointToPolygonList(t){let{lowerLimitPointNum:e=3}=this.config;e<3&&(e=3);let i;if(this.drawingPointList.length<e){this.drawingPointList=[],this.editPolygonID="";return}const s=u.getSourceID(this.basicResult),o=[...this.polygonList];if(this.editPolygonID){const l=o.find(n=>n.id===this.editPolygonID);if(!l)return;l.pointList=this.drawingPointList,this.editPolygonID=""}else{const l=M(8,62);let n={id:l,sourceID:s,valid:!this.isCtrl,textAttribute:"",pointList:this.drawingPointList,attribute:this.defaultAttribute,order:u.getMaxOrder(o.filter(r=>u.isSameSourceID(r.sourceID,s)))+1};if(this.config.textConfigurable){let r="";r=b.getTextAttribute(this.polygonList.filter(h=>u.isSameSourceID(h.sourceID,s)),this.config.textCheckType),n=m(f({},n),{textAttribute:r})}this.pattern===w.Rect&&t===!0&&(n=m(f({},n),{isRect:!0})),o.push(n),i=n,this.setSelectedIdAfterAddingDrawing(l)}this.setPolygonList(o),this.isCtrl=!1,this.drawingPointList=[],this.history.pushHistory(o),i&&this.emit("polygonCreated",i,this.zoom,this.currentPos)}setSelectedIdAfterAddingDrawing(t){this.drawingPointList.length!==0&&(this.config.textConfigurable?this.setSelectedID(t):this.deleteSelectedID())}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),s=this.currentShowList.map(o=>m(f({},o),{pointList:a.changePointListByZoom(o.pointList,this.zoom)}));return y.getHoverPolygonID(i,s,10,(e=this.config)==null?void 0:e.lineType)}getHoverEdgeIndex(t){var e;if(!this.selectedID)return-1;const i=this.selectedPolygon;if(!i)return-1;const s=this.getCoordinateUnderZoom(t),o=a.changePointListByZoom(i.pointList,this.zoom);return y.getHoverEdgeIndex(s,o,(e=this.config)==null?void 0:e.lineType)}getHoverPointIndex(t){if(!this.selectedID)return-1;const e=this.selectedPolygon;if(!e)return-1;const i=this.getCoordinateUnderZoom(t),s=a.changePointListByZoom(e.pointList,this.zoom);return a.returnClosePointIndex(i,s)}deletePolygon(t){var e;if(!t)return;const i=this.polygonList.find(s=>s.id===t);this.emit("deletedObject",{deletedObject:i,id:t}),this.setPolygonList(this.polygonList.filter(s=>s.id!==t)),this.history.pushHistory(this.polygonList),(e=this._textAttributInstance)==null||e.clearTextAttribute(),this.emit("selectedChange"),this.render()}deletePolygonPoint(t){if(!this.selectedID)return;const{selectedPolygon:e}=this;if(!e)return;let{lowerLimitPointNum:i}=this.config;if(i<3&&(i=3),e.pointList.length<=i){this.emit("messageInfo",`${C.getMessagesByLocale(S.LowerLimitErrorNotice,this.lang)}${i}`);return}e==null||e.pointList.splice(t,1),this.history.pushHistory(this.polygonList),this.render()}spaceKeydown(){var t,e,i;if(this.selectedID){if(((t=this.selectedPolygon)==null?void 0:t.isRect)===!0){this.emit("messageInfo",`${C.getMessagesByLocale(S.UnableToReannotation,this.lang)}`);return}this.editPolygonID=this.selectedID,this.drawingPointList=(i=(e=this.selectedPolygon)==null?void 0:e.pointList)!=null?i:[],this.drawingHistory.empty(),this.drawingHistory.initRecord(this.drawingPointList),this.hoverID="",this.deleteSelectedID(),this.render()}}onTabKeyDown(t){t.preventDefault();let e=U.ascend;t.shiftKey&&(e=U.descend),this.switchToNextPolygon(e)}switchToNextPolygon(t){if(this.drawingPointList.length>0)return;const[e,i]=u.getRenderResultList(this.polygonList,u.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let s=[...e];i&&(s=[...s,i]);const o=B.getViewPort(this.canvas,this.currentPos,this.zoom),l=s.map(r=>{var h,c,g,d;return m(f({},r),{x:(c=(h=r.pointList[0])==null?void 0:h.x)!=null?c:0,y:(d=(g=r.pointList[0])==null?void 0:g.y)!=null?d:0})}).filter(r=>B.inViewPort({x:r.x,y:r.y},o)),n=u.getNextSelectedRectID(l,t,this.selectedID);if(n){this.setSelectedID(n.id);const{selectedPolygon:r}=this;r&&this.setDefaultAttribute(r.attribute)}this.render()}onKeyDown(t){if(!u.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case L.Space:this.spaceKeydown();break;case L.Esc:this.drawingPointList=[],this.editPolygonID="";break;case L.F:this.selectedID&&this.setPolygonValidAndRender(this.selectedID);break;case L.Z:if(t.altKey){this.onCombinedExecute();return}this.setIsHidden(!this.isHidden),this.render();break;case L.Delete:this.deletePolygon(this.selectedID),this.render();break;case L.Ctrl:this.isCtrl=!0;break;case L.Alt:this.isAlt===!1&&(t.preventDefault(),this.isAlt=!0,this.render());break;case L.Tab:{this.onTabKeyDown(t);break}case L.X:t.altKey&&this.segment();break;default:{if(this.config.attributeConfigurable){const i=b.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case L.Ctrl:this.isCtrl=!1;break;case L.Alt:{const e=this.isAlt;this.isAlt=!1,e===!0&&this.render();break}}}rightMouseUp(t){if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}this.setSelectedID(this.hoverID);const{selectedPolygon:e}=this;e&&this.setDefaultAttribute(e.attribute)}onLeftDblClick(t){if(this.hoverEdgeIndex>-1){const e=this.getCoordinateUnderZoom(t),{selectedPolygon:i}=this;if(!i)return;if(i.isRect===!0){this.emit("messageInfo",`${C.getMessagesByLocale(S.ForbidAddNewPoint,this.lang)}`),this.clearPolygonDrag();return}const{dropFoot:s}=y.getClosestPoint(e,this.polygonListUnderZoom,this.config.lineType,R);if(!s)return;const{upperLimitPointNum:o}=this.config;if(o&&i.pointList.length>=o){this.emit("messageInfo",`${C.getMessagesByLocale(S.UpperLimitErrorNotice,this.lang)}${o}`),this.clearPolygonDrag();return}i==null||i.pointList.splice(this.hoverEdgeIndex+1,0,a.changePointByZoom(s,1/this.zoom)),this.setPolygonDataByID(i,this.selectedID),this.history.pushHistory(this.polygonList),this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.render()}this.dragInfo=void 0}onRightDblClick(t){this.dragInfo=void 0,this.clearImgDrag();const e=this.getHoverID(t),i=this.getHoverPointIndex(t);if(this.hoverPointIndex>-1&&this.hoverPointIndex===i){this.deletePolygonPoint(i),this.dragInfo=void 0,this.hoverPointIndex=-1,this.render();return}this.hoverID===this.selectedID&&this.deletePolygon(e),this.render()}onMouseDown(t){if(!(super.onMouseDown(t)||this.forbidMouseOperation||t.ctrlKey===!0))return this.dragMouseDown(t),!0}dragMouseDown(t){const e=this.selectedPolygon;if(!e||t.button!==0||this.getHoverID(t)!==this.selectedID)return;const s=e.pointList,o=this.getCoordinateUnderZoom(t);let l=[0],n=v.Plane;this.dragStatus=x.Start;const r=this.getHoverPointIndex(t),h=this.getHoverEdgeIndex(t);r>-1?(n=v.Point,l=[r]):h>-1&&this.hoverEdgeIndex>-1&&(n=v.Line,l=[h,(h+1)%s.length]),this.dragInfo={dragStartCoord:o,dragTarget:n,initPointList:s,changePointIndex:l,originPolygon:this.selectedPolygon,dragPrevCoord:o,originPolygonList:this.polygonList}}segment(){var t;if(!this.selectedID||((t=this.config)==null?void 0:t.lineType)!==O.Line)return;const e=y.getPolygonPointList(this.selectedID,this.currentShowList),i=this.currentShowList.filter(l=>l.id!==this.selectedID);if(i.length===0||e.length===0)return;const s=y.getWrapPolygonIndex(e,i);let o=[...this.polygonList];if(s===-1){const l=y.segmentPolygonByPolygon(e,i);if(!l)return;const n=l.shift();if(!n)return;let r="",h=!0;const c=u.getSourceID(this.basicResult);let g="";o=this.polygonList.map(d=>{var p,T;return d.id===this.selectedID?(r=d.attribute,h=(p=d==null?void 0:d.valid)!=null?p:!0,g=(T=d==null?void 0:d.textAttribute)!=null?T:"",m(f({},d),{pointList:n})):d}),l.length>0&&l.forEach((d,p)=>{o.push({sourceID:c,id:M(8,62),pointList:d,valid:h,order:u.getMaxOrder(this.currentShowList)+1+p,attribute:r,textAttribute:g})})}else o[s].pointList=y.clipPolygonFromWrapPolygon(e,o[s].pointList),o=o.filter(l=>l.id!==this.selectedID);this.setPolygonList(o),this.history.pushHistory(o),this.render()}onCombinedExecute(){if(!this.selectedID){this.emit("messageInfo",_.t("PolygonsToBeCombinedNeedToBeSelected"));return}this.isCombined=!this.isCombined}combine(t){var e;const i=this.getHoverID(t);if(!i||!this.selectedID||this.selectedID===i)return;if(((e=this.config)==null?void 0:e.lineType)!==O.Line){this.emit("messageInfo",_.t("CurveModeDoesNotSupportCutting"));return}const s=this.polygonList.find(h=>h.id===this.selectedID),o=this.currentShowList.find(h=>h.id===i);if(!o||!s)return;const l=y.combinePolygonWithPolygon(s,o);if(!l)return;const{newPolygon:n,unionList:r}=l;if(r.length===1&&n){const h=this.polygonList.filter(c=>!r.includes(c.id)).map(c=>c.id===this.selectedID?n:c);this.setPolygonList(h),this.history.pushHistory(h),this.render(),this.emit("messageInfo",_.t("CombineSuccess"))}else this.emit("messageInfo",_.t("CombiningFailedNotify"));this.isCombined=!1}isPolygonOutSide(t){if(this.dependToolName&&this.basicCanvas&&this.basicResult){let n=!1;switch(this.dependToolName){case H.Rect:{n=t.filter(r=>!j.isInRect(r,this.basicResult)).length>0;break}case H.Polygon:{n=y.isPointListOutSidePolygon(t,this.basicResult.pointList,this.config.lineType);break}}return n}if(!this.imgInfo)return!1;const{left:e,top:i,right:s,bottom:o}=D.calcViewportBoundaries(a.changePointListByZoom(t,this.zoom)),l=1e-5;return e<0||i<0||s>this.imgInfo.width+l||o>this.imgInfo.height+l}getDragOffset(t,e){var i;const s=this.getCoordinateUnderZoom(t),{dragTarget:o,dragPrevCoord:l,changePointIndex:n,initPointList:r,dragStartCoord:h}=this.dragInfo;if(this.pattern===w.Rect&&(e==null?void 0:e.isRect)===!0&&n&&[v.Line].includes(o)){const c=D.getArrayIndex(n[0]-2,4),g=D.getArrayIndex(n[0]-1,4),d=[r[c],r[g]],p=D.getRectPerpendicularOffset(h,s,d);return{x:p.x/this.zoom,y:p.y/this.zoom}}return((i=this.dragInfo)==null?void 0:i.dragTarget)===v.Plane?{x:(s.x-l.x)/this.zoom,y:(s.y-l.y)/this.zoom}:{x:(s.x-h.x)/this.zoom,y:(s.y-h.y)/this.zoom}}dragPolygon(t,e){let i=N.cloneDeep(e==null?void 0:e.pointList);if(!i||!this.dragInfo)return;const{initPointList:s,dragTarget:o,changePointIndex:l}=this.dragInfo,n=this.getDragOffset(t,e);switch(this.dragStatus=x.Move,o){case v.Plane:i=i.map(r=>m(f({},r),{x:r.x+n.x,y:r.y+n.y}));break;case v.Point:case v.Line:i=i.map((r,h)=>l&&l.includes(h)?m(f({},r),{x:s[h].x+n.x,y:s[h].y+n.y}):r);break}if(this.pattern===w.Rect&&(e==null?void 0:e.isRect)===!0&&o===v.Point&&l&&(i=D.getPointListFromPointOffset(s,l[0],n)),!(this.config.drawOutsideTarget===!1&&this.imgInfo&&this.isPolygonOutSide(i)))return i}onDragMove(t){const e=this.polygonList.map(i=>{if(i.id===this.selectedID){const s=this.dragPolygon(t,i);if(!s)return i;const o=m(f({},i),{pointList:s});return i.isRect===!0&&this.pattern===w.Normal&&Object.assign(o,{isRect:!1}),o}return i});this.dragInfo.dragPrevCoord=this.getCoordinateUnderZoom(t),this.setPolygonList(e),this.render()}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;if(this.enableDrag){this.onDragMove(t);return}let e=-1,i=-1;const{selectedID:s}=this;if(s&&(this.hoverEdgeIndex=-1,this.hoverPointIndex=-1,e=this.getHoverPointIndex(t),e>-1?this.hoverPointIndex=e:(i=this.getHoverEdgeIndex(t),this.hoverEdgeIndex=i)),this.drawingPointList.length>0)return;const o=this.getHoverID(t);this.hoverID!==o&&(this.hoverID=o,this.render())}leftMouseUpdateValid(t){const e=this.getHoverID(t);return this.drawingPointList.length===0&&t.ctrlKey===!0&&e?(this.setPolygonValidAndRender(e),!0):!1}leftMouseUp(t){this.leftMouseUpdateValid(t)||this.addPointInDrawing(t)}onMouseUp(t){if(this.isCombined){switch(t.button){case 0:this.combine(t);break;case 2:this.isCombined=!1;break;default:return}return}if(!(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)){if(this.dragInfo&&this.dragStatus===x.Move){this.emit("updateResult"),this.emitUpdatePolygonByDrag(),this.dragInfo=void 0,this.dragStatus=x.Wait,this.history.pushHistory(this.polygonList);return}switch(t.button){case 0:{this.leftMouseUp(t);break}case 2:{this.rightMouseUp(t);break}}this.render()}}dragMouseUp(){this.dragStatus===x.Start&&(this.dragInfo=void 0,this.dragStatus=x.Wait)}exportData(){const{polygonList:t}=this;return[t,this.basicImgInfo]}getTextIconSvg(t=""){return b.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}getCurrentSelectedData(){const{selectedPolygon:t}=this;if(!t)return;const e=this.getColor(t.attribute),i=t.valid?e==null?void 0:e.valid.stroke:e==null?void 0:e.invalid.stroke;return{width:z,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;b.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",b.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPolygonList(b.textChange(e,this.selectedID,this.polygonList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t;const{selectedPolygon:e}=this;if(!this.ctx||this.config.textConfigurable===!1||!e)return;const{pointList:i,attribute:s,valid:o,textAttribute:l}=e,{x:n,y:r}=i[i.length-1],h=z,c=a.getOffsetCoordinate({x:n,y:r},this.currentPos,this.zoom),g=this.getColor(s),d=o?g==null?void 0:g.valid.stroke:g==null?void 0:g.invalid.stroke;this._textAttributInstance||(this._textAttributInstance=new V({width:h,container:this.container,icon:this.getTextIconSvg(s),color:d,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((t=this._textAttributInstance)==null?void 0:t.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${l}`,{left:c.x,top:c.y,color:d,width:h})}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.visiblePolygonList)==null||t.forEach(e=>{var i,s,o,l,n;if([this.selectedID,this.editPolygonID].includes(e.id))return;const{textAttribute:r,attribute:h}=e,c=this.getColor(h),g=A.getStrokeAndFill(c,e.valid),d=a.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);P.drawPolygonWithFillAndLine(this.canvas,d,{fillColor:g.fill,strokeColor:g.stroke,pointColor:"white",thickness:(s=(i=this.style)==null?void 0:i.width)!=null?s:2,lineCap:"round",isClose:!0,lineType:(o=this.config)==null?void 0:o.lineType});let p=`${(l=b.getAttributeShowText(h,this.config.attributeList))!=null?l:""}`;((n=this.config)==null?void 0:n.isShowOrder)&&(e==null?void 0:e.order)>0&&(p=`${e.order} ${p}`),P.drawText(this.canvas,d[0],p,f({color:g.stroke},k));const T=d[d.length-1];P.drawText(this.canvas,{x:T.x+E.x,y:T.y+E.y},r,f({color:g.stroke},k))}))}renderSelectedPolygon(){var t,e,i;const{selectedPolygon:s}=this;if(s){const o=this.getColor(s.attribute),l=A.getStrokeAndFill(o,s.valid,{isSelected:!0});P.drawSelectedPolygonWithFillAndLine(this.canvas,a.changePointListByZoom(s.pointList,this.zoom,this.currentPos),{fillColor:l.fill,strokeColor:l.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(t=this.config)==null?void 0:t.lineType});let n=`${(e=b.getAttributeShowText(s.attribute,this.config.attributeList))!=null?e:""}`;((i=this.config)==null?void 0:i.isShowOrder)&&(s==null?void 0:s.order)>0&&(n=`${s.order} ${n}`),P.drawText(this.canvas,a.changePointByZoom(s.pointList[0],this.zoom,this.currentPos),n,f({color:l.stroke},k)),this.renderTextAttribute()}}renderHoverPolygon(){var t;if(this.hoverID&&this.hoverID!==this.editPolygonID){const{hoverPolygon:e}=this;if(e){let i="";const s=this.getColor(e.attribute);e.valid?i=s.validHover.fill:i=A.getStrokeAndFill(s,!1,{isHover:!0}).fill,P.drawPolygonWithFill(this.canvas,a.changePointListByZoom(e.pointList,this.zoom,this.currentPos),{color:i,lineType:(t=this.config)==null?void 0:t.lineType})}}}renderPolygon(){var t,e,i,s;this.renderStaticPolygon(),this.renderHoverPolygon(),this.renderSelectedPolygon();const o=this.getColor(this.defaultAttribute),l=A.getStrokeAndFill(o,!this.isCtrl);if(((t=this.drawingPointList)==null?void 0:t.length)>0){let n=[...this.drawingPointList],r=a.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.pattern===w.Rect&&n.length===2)n=D.getRectangleByRightAngle(r,n);else{if(((e=this.config)==null?void 0:e.edgeAdsorption)&&this.isAlt===!1){const{dropFoot:h}=y.getClosestPoint(r,this.polygonList,(i=this.config)==null?void 0:i.lineType,R/this.zoom);h&&(r=h)}n.push(r)}P.drawSelectedPolygonWithFillAndLine(this.canvas,a.changePointListByZoom(n,this.zoom,this.currentPos),{fillColor:l.fill,strokeColor:l.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!1,lineType:this.config.lineType})}if(this.hoverPointIndex>-1&&this.selectedID){const n=this.selectedPolygon;if(!n)return;const r=A.getStrokeAndFill(o,n.valid,{isSelected:!0}),h=n==null?void 0:n.pointList[this.hoverPointIndex];if(h){const{x:c,y:g}=a.changePointByZoom(h,this.zoom,this.currentPos);P.drawCircleWithFill(this.canvas,{x:c,y:g},5,{color:r.fill})}}if(this.hoverEdgeIndex>-1&&this.selectedID){const n=this.selectedPolygon;if(!n)return;const r=A.getStrokeAndFill(o,n.valid,{isSelected:!0});P.drawLineWithPointList(this.canvas,a.changePointListByZoom(n.pointList,this.zoom,this.currentPos),{color:r.stroke,thickness:10,hoverEdgeIndex:this.hoverEdgeIndex,lineType:(s=this.config)==null?void 0:s.lineType})}}render(){!this.ctx||(super.render(),this.renderPolygon(),this.renderCursorLine(this.getLineColor(this.defaultAttribute)))}renderCursorLine(t){if(super.renderCursorLine(t),this.isCombined){const{x:e,y:i}=this.coord,s=10,o=186,l=32;P.drawRectWithFill(this.canvas,{x:e+s,y:i-s*4-1,width:o,height:l},{color:"black"}),P.drawText(this.canvas,{x:e,y:i},_.t("ClickAnotherPolygon"),{textAlign:"center",color:"white",offsetX:o/2+s,offsetY:-(l/2+s/2)}),P.drawRect(this.canvas,{x:e-s,y:i-s,width:s*2,height:s*2},{lineDash:[6],color:"white"})}}undo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.undo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.undo();t&&(t.length!==this.polygonList.length&&this.deleteSelectedID(),this.setPolygonList(t),this.render())}redo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.redo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.redo();t&&(t.length!==this.polygonList.length&&this.deleteSelectedID(),this.setPolygonList(t),this.render())}deleteSelectedID(){this.setSelectedID("")}}export{Q as default};
@@ -0,0 +1 @@
1
+ import N from"../../utils/MathUtils.js";import S from"../../utils/tool/AxisUtils.js";import y from"../../utils/tool/RectUtils.js";import{EDragStatus as L,ESortDirection as O,DEFAULT_TEXT_SHADOW as T}from"../../constant/annotation.js";import{EDragTarget as w,EOperationMode as _}from"../../constant/tool.js";import p from"../../constant/keyCode.js";import A from"../../locales/index.js";import{EMessage as P}from"../../locales/constants.js";import C from"../../utils/tool/AttributeUtils.js";import U from"../../utils/tool/CanvasUtils.js";import R from"../../utils/tool/CommonToolUtils.js";import k from"../../utils/tool/DrawUtils.js";import B from"../../utils/tool/MarkerUtils.js";import{getPolygonPointUnderZoom as E}from"../../utils/tool/polygonTool.js";import K from"../../utils/uuid.js";import{BasicToolOperation as V}from"./basicToolOperation.js";import $ from"./textAttributeClass.js";var F=Object.defineProperty,X=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,H=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,j=(D,t,e)=>t in D?F(D,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):D[t]=e,x=(D,t)=>{for(var e in t||(t={}))G.call(t,e)&&j(D,e,t[e]);if(H)for(var e of H(t))J.call(t,e)&&j(D,e,t[e]);return D},m=(D,t)=>X(D,Y(t));const M=6;class W extends V{constructor(t){super(t);this.setMarkerIndex=e=>{this.markerIndex=e},this.setMarkerIndexAndSelect=e=>{if(!this.config.markerList)return;this.markerIndex=e;const i=this.config.markerList[e].value,r=this.currentPageResult.find(o=>o.label===i);r&&(this.setSelectedID(r.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(r.attribute)),this.emit("markIndexChange")},this.getHoverRectID=e=>{const i=this.getCoordinateUnderZoom(e),r=M,{currentShowList:o}=this;if(o.length>0){if(this.selectedRectID){const{selectedRect:g}=this;if(g&&y.isInRect(i,g,r,this.zoom))return g.id}const h=o.filter(g=>y.isInRect(i,g,r,this.zoom));if(h.length===0)return"";if(h.length===1)return h[0].id;if(h.length>1)return h.map(s=>({size:s.width*s.height,id:s.id})).sort((s,f)=>s.size-f.size)[0].id}return""},this.textChange=e=>{this.config.textConfigurable!==!0||!this.selectedRectID||(this.setRectList(C.textChange(e,this.selectedRectID,this.rectList),!0),this.emit("selectedChange"),this.render())},this.drawOutSideTarget=t.drawOutSideTarget||!1,this.rectList=[],this.isFlow=!0,this.config=R.jsonParser(t.config),this.hoverRectEdgeIndex=-1,this.hoverRectPointIndex=-1,this.markerIndex=0,this.setStyle(t.style),this.createNewDrawingRect=this.createNewDrawingRect.bind(this),this.getDrawingRectWithRectList=this.getDrawingRectWithRectList.bind(this),this.setSelectedIdAfterAddingDrawingRect=this.setSelectedIdAfterAddingDrawingRect.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedRectTextAttribute=this.updateSelectedRectTextAttribute.bind(this),this.setSelectedID=this.setSelectedID.bind(this)}setResult(t){if(this.clearActiveStatus(),this.setRectList(t),this.hasMarkerConfig){const e=R.getNextMarker(this.getCurrentPageResult(t),this.config.markerList);e&&this.setMarkerIndex(e.index)}this.render()}destroy(){super.destroy(),this._textAttributInstance&&this._textAttributInstance.clearTextAttribute()}setConfig(t,e=!1){this.config=R.jsonParser(t),e===!0&&this.clearResult(!1)}setRectList(t,e=!1){const i=this.rectList.length;this.rectList=t,i!==t.length&&this.emit("updatePageNumber"),e&&this.emit("updateResult")}get selectedRect(){return this.rectList.find(t=>t.id===this.selectedRectID)}get selectedID(){return this.selectedRectID}get selectedText(){var t;return(t=this.selectedRect)==null?void 0:t.textAttribute}get dataList(){return this.rectList}get currentShowList(){let t=[];const[e,i]=R.getRenderResultList(this.rectList,R.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=R.getRenderResultList(this.rectList,R.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=R.getRenderResultList(t,R.getSourceID(this.basicResult),[]);return e}setSelectedID(t){this.setSelectedRectID(t)}setSelectedRectID(t){var e,i;const r=this.selectedRectID;t!==r&&r&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedRectID=t,this.render(),this.emit("selectedChange")}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}updateSelectedRectTextAttribute(t){if(this._textAttributInstance&&t){let e=t;C.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",C.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setRectList(this.rectList.map(i=>i.id===this.selectedRectID?m(x({},i),{textAttribute:e}):i),!0),this.emit("updateTextAttribute"),this.render()}}getHoverRectPointIndex(t){return this.selectedRect?S.returnClosePointIndex(this.getCoordinateUnderZoom(t),y.getRectPointList(this.selectedRect,this.zoom),M+2):-1}getHoverRectEdgeIndex(t){if(!this.selectedRect)return-1;let e=-1;const{selectedRect:i}=this,r=y.getRectEdgeList(i,this.zoom),o=this.getCoordinateUnderZoom(t);for(let h=0;h<r.length;h++){const g=r[h],{length:s}=N.getFootOfPerpendicular(o,g.begin,g.end);s<M+10&&(e=h)}return e}getTextIconSvg(t=""){return C.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}multiMoveMouseDown(t){const e=this.getCoordinateUnderZoom(t),i=this.getHoverRectID(t);return this.isMultiMoveMode&&i&&t.button===0?(this.dragInfo={dragStartCoord:e,dragTarget:w.Plane,startTime:+new Date,originRectList:this.rectList},this.dragStatus=L.Start,!0):!1}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||t.ctrlKey===!0||this.multiMoveMouseDown(t))return;const e=this.getCoordinateUnderZoom(t),i=this.getHoverRectID(t),r=this.currentShowList.find(o=>o.id===this.selectedRectID);if(!(!r||t.button===2||t.button===0&&this.isSpaceKey===!0)){if(this.selectedRectID){if(this.getHoverRectPointIndex(t)>-1){const o=w.Point;this.dragInfo={dragStartCoord:e,dragTarget:o,startTime:+new Date,firstRect:r},this.dragStatus=L.Start;return}if(this.getHoverRectEdgeIndex(t)>-1){const o=w.Line;this.dragInfo={dragStartCoord:e,dragTarget:o,startTime:+new Date,firstRect:r},this.dragStatus=L.Start;return}}if(i===this.selectedRectID&&!this.drawingRect){const o=w.Plane;this.dragInfo={dragStartCoord:e,dragTarget:o,firstRect:r,startTime:+new Date},this.dragStatus=L.Start}}}onDragMoveAll(t){var e,i;!((i=(e=this.dragInfo)==null?void 0:e.originRectList)==null?void 0:i.length)||(this.setRectList(this.dragInfo.originRectList.map(r=>m(x({},r),{x:r.x+t.x/this.zoom,y:r.y+t.y/this.zoom}))),this.render())}onDragMove(t){var e,i,r,o,h,g;if(!this.dragInfo)return;const s={x:t.x-this.dragInfo.dragStartCoord.x,y:t.y-this.dragInfo.dragStartCoord.y};if(this.dragStatus=L.Move,this.isMultiMoveMode){this.onDragMoveAll(s);return}if(!this.dragInfo.firstRect)return;const f=y.getRectUnderZoom(this.dragInfo.firstRect,this.zoom),{x:l,y:c,width:u,height:d}=f;let n=this.rectList.filter(a=>a.id===this.selectedRectID)[0];switch(this.dragInfo.dragTarget){case w.Plane:n=m(x({},n),{x:l+s.x,y:c+s.y,width:u,height:d});break;case w.Point:{let a=l,b=c,I=u,v=d;switch(this.hoverRectPointIndex){case 0:{a=u-s.x<0?l+u:l+s.x,b=d-s.y<0?c+d:c+s.y,I=Math.abs(s.x-u),v=Math.abs(s.y-d);break}case 1:{a=u+s.x>0?l:l+u+s.x,b=d-s.y<0?c+d:c+s.y,I=Math.abs(u+s.x),v=Math.abs(d-s.y);break}case 2:{a=u+s.x>0?l:l+u+s.x,b=d+s.y>0?c:c+d+s.y,I=Math.abs(u+s.x),v=d+s.y>0?d+s.y:Math.abs(d+s.y);break}case 3:{a=u-s.x<0?l+u:l+s.x,b=d+s.y>0?c:c+d+s.y,I=Math.abs(s.x-u),v=d+s.y>0?d+s.y:Math.abs(d+s.y);break}default:return}n=m(x({},n),{x:a,y:b,width:I,height:v})}break;case w.Line:{let a=l,b=c,I=u,v=d;switch(this.hoverRectEdgeIndex){case 0:{b=d-s.y<0?c+d:c+s.y,v=Math.abs(s.y-d);break}case 1:{a=u+s.x>0?l:l+u+s.x,I=Math.abs(u+s.x);break}case 2:{b=d+s.y>0?c:c+d+s.y,v=d+s.y>0?d+s.y:Math.abs(d+s.y);break}case 3:{a=u-s.x<0?l+u:l+s.x,I=Math.abs(s.x-u);break}default:return}n=m(x({},n),{x:a,y:b,width:I,height:v});break}default:return}if(this.config.drawOutsideTarget===!1){if(this.basicResult){if(((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&y.isRectNotInPolygon(n,E(this.basicResult.pointList,this.zoom)))return;const a=this.basicResult.x*this.zoom,b=this.basicResult.y*this.zoom,I=this.basicResult.width*this.zoom,v=this.basicResult.height*this.zoom;if(this.dragInfo.dragTarget!==w.Plane&&(n.x<a-.01||n.y<b-.01||n.width>a+I-n.x+.01||n.height>b+v-n.y+.01))return;if(n.x<a&&(n.x=a),n.y<b&&(n.y=b),n.width>a+I-n.x)switch(this.dragInfo.dragTarget){case w.Plane:n.x=a+I-u;break;case w.Point:case w.Line:s.x>0&&s.y>0&&(n.width=a+I-n.x);break;default:return}if(n.height>b+v-n.y)switch(this.dragInfo.dragTarget){case w.Plane:n.y=b+v-d;break}}else if(n.x<0&&(n.x=0),n.y<0&&(n.y=0),this.imgInfo)switch(this.dragInfo.dragTarget){case w.Plane:n.x+n.width>((r=this.imgInfo)==null?void 0:r.width)&&(n.x=this.imgInfo.width-u),n.y+n.height>((o=this.imgInfo)==null?void 0:o.height)&&(n.y=this.imgInfo.height-d);break;default:if(n.x+n.width>((h=this.imgInfo)==null?void 0:h.width)+.01||n.y+n.height>((g=this.imgInfo)==null?void 0:g.height)+.01)return}}this.setRectList(this.rectList.map(a=>a.id===n.id?y.getRectUnderZoom(n,1/this.zoom):a)),this.render()}onMouseMove(t){var e,i;if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const r=this.getCoordinateUnderZoom(t),o=S.changeDrawOutsideTarget(r,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if((this.selectedRectID||this.isMultiMoveMode)&&this.dragInfo){this.onDragMove(o);return}if(this.selectedRectID){const s=this.getHoverRectPointIndex(t);if(s!==this.hoverRectPointIndex){this.hoverRectPointIndex=s,this.hoverRectEdgeIndex=-1,this.render();return}if(this.hoverRectPointIndex===-1){const f=this.getHoverRectEdgeIndex(t);if(f!==this.hoverRectEdgeIndex){this.hoverRectEdgeIndex=f,this.render();return}}}const h=this.getHoverRectID(t),g=this.hoverRectID;if(this.hoverRectID=h,h!==g&&this.render(),this.drawingRect&&this.firstClickCoord){let{x:s,y:f}=this.firstClickCoord,{width:l,height:c}=this.drawingRect;if(l=Math.abs(s-o.x),c=Math.abs(f-o.y),o.x<s&&(s=o.x),o.y<f&&(f=o.y),this.config.drawOutsideTarget===!1){if(((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&y.isRectNotInPolygon(m(x({},this.drawingRect),{x:s,y:f,width:l,height:c}),E(this.basicResult.pointList,this.zoom)))return;o.x<0&&(l=Math.abs(this.firstClickCoord.x),s=0),o.y<0&&(c=Math.abs(this.firstClickCoord.y),f=0),this.imgInfo&&(s+l>this.imgInfo.width&&(l=Math.abs(this.imgInfo.width-s)),f+c>this.imgInfo.height&&(c=Math.abs(this.imgInfo.height-f)))}this.drawingRect=m(x({},this.drawingRect),{x:s,y:f,width:l,height:c}),this.render()}}setAttributeLockList(t){this.setSelectedRectID(void 0),super.setAttributeLockList(t)}setBasicResult(t){super.setBasicResult(t),this.clearActiveStatus()}setRectValidAndRender(t){!t||(this.setRectList(this.rectList.map(e=>e.id===t?m(x({},e),{valid:!e.valid}):e),!0),this.render(),this.emit("updateResult"))}createNewDrawingRect(t,e){if(!this.imgInfo)return;const i=this.getCoordinateUnderZoom(t),r=S.changeDrawOutsideTarget(i,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(this.setSelectedRectID(""),this.hoverRectID="",this.drawOutSideTarget&&(r.x<0&&(r.x=0),r.y<0&&(r.y=0)),this.drawingRect=m(x({},r),{width:0,height:0,attribute:this.defaultAttribute,valid:!t.ctrlKey,id:K(8,62),sourceID:e,textAttribute:""}),this.hasMarkerConfig){const o=R.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(o)this.drawingRect&&(this.drawingRect=m(x({},this.drawingRect),{label:o.label})),this.markerIndex=o.index,this.emit("markIndexChange");else{this.emit("messageInfo",A.getMessagesByLocale(P.MarkerFinish,this.lang)),this.drawingRect=void 0;return}}if(this.config.textConfigurable){let o="";o=C.getTextAttribute(this.rectList.filter(h=>R.isSameSourceID(h.sourceID,e)),this.config.textCheckType),this.drawingRect&&(this.drawingRect=m(x({},this.drawingRect),{textAttribute:o}))}if(Object.assign(this.drawingRect,{order:R.getMaxOrder(this.rectList.filter(o=>R.isSameSourceID(o.sourceID,e)))+1}),this.firstClickCoord=x({},r),this.firstCurrentPos=x({},this.currentPos),this.dataInjectionAtCreation){const o=this.dataInjectionAtCreation(this.drawingRect);o&&Object.assign(this.drawingRect,o)}}addDrawingRectToRectList(){if(!this.drawingRect)return;let{width:t,height:e}=this.drawingRect;if(t/=this.zoom,e/=this.zoom,Math.round(t)<this.config.minWidth||Math.round(e)<this.config.minHeight){this.emit("messageInfo",A.getMessagesByLocale(P.RectErrorSizeNotice,this.lang)),this.drawingRect=void 0,this.firstClickCoord=void 0,this.dragInfo=void 0,this.dragStatus=L.Wait,this.render();return}const i=this.getDrawingRectWithRectList();this.setRectList(i,!0),this.history.pushHistory(this.rectList),this.setSelectedIdAfterAddingDrawingRect(),this.firstClickCoord=void 0,this.drawingRect=void 0,this.dragInfo=void 0,this.dragStatus=L.Wait}setSelectedIdAfterAddingDrawingRect(){!this.drawingRect||(this.config.textConfigurable?this.setSelectedRectID(this.drawingRect.id):this.setSelectedRectID())}getDrawingRectWithRectList(){if(!this.drawingRect)return this.rectList;let{x:t,y:e,width:i,height:r}=this.drawingRect;return t/=this.zoom,e/=this.zoom,i/=this.zoom,r/=this.zoom,[...this.rectList,m(x({},this.drawingRect),{x:t,y:e,width:i,height:r})]}rightMouseUp(t){const e=this.getHoverRectID(t),i=this.rectList.find(o=>o.id===e),{selectedRectID:r}=this;if(this.setSelectedRectID(void 0),i&&this.setDefaultAttribute(i.attribute),this.drawingRect)this.drawingRect=void 0,this.firstClickCoord=void 0;else if(r!==e&&this.dblClickListener.clearRightDblClick(),this.setSelectedRectID(e),this.hoverRectID="",(i==null?void 0:i.label)&&this.hasMarkerConfig){const o=R.getCurrentMarkerIndex(i.label,this.config.markerList);o>=0&&(this.setMarkerIndex(o),this.emit("markIndexChange"))}this.render()}shiftRightMouseUp(t){const e=this.getHoverRectID(t);this.emit("shiftRightMouseUp",e)}onMouseUp(t){if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return!0;if(this.dragInfo&&this.dragStatus===L.Move){this.dragInfo=void 0,this.dragStatus=L.Wait,this.history.pushHistory(this.rectList),this.emit("updateResult");return}if(this.isMultiMoveMode&&this.setOperationMode(_.General),t.button===2&&t.shiftKey===!0){this.shiftRightMouseUp(t);return}if(t.button===2){this.rightMouseUp(t);return}const e=R.getSourceID(this.basicResult);if(this.drawingRect){this.addDrawingRectToRectList();return}if(t.ctrlKey===!0&&t.button===0&&this.hoverRectID){this.setRectValidAndRender(this.hoverRectID);return}this.createNewDrawingRect(t,e),this.render()}onRightDblClick(t){super.onRightDblClick(t);const e=this.getHoverRectID(t);this.selectedRectID&&this.selectedRectID===e&&this.deleteRect(e)}onKeyDown(t){if(!R.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case p.Ctrl:this.drawingRect&&(this.drawingRect=m(x({},this.drawingRect),{valid:!t.ctrlKey}),this.render());break;case p.F:this.selectedRectID&&this.setRectValidAndRender(this.selectedRectID);break;case p.Z:this.setIsHidden(!this.isHidden),this.render();break;case p.Delete:this.deleteRect(this.selectedRectID);break;case p.Tab:{if(t.preventDefault(),this.drawingRect)return;let i=O.ascend;t.shiftKey&&(i=O.descend);const[r,o]=R.getRenderResultList(this.rectList,R.getSourceID(this.basicResult),this.attributeLockList,this.selectedRectID);let h=[...r];o&&(h=[...h,o]);const g=U.getViewPort(this.canvas,this.currentPos,this.zoom);h=h.filter(f=>U.inViewPort({x:f.x,y:f.y},g));const s=R.getNextSelectedRectID(h,i,this.selectedRectID);s&&(this.setSelectedRectID(s.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(s.attribute));break}default:{if(this.config.attributeConfigurable){const i=C.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}return!0}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case p.Ctrl:this.drawingRect&&(this.drawingRect=m(x({},this.drawingRect),{valid:!0}),this.render());break}}onWheel(t){const e=this.zoom;let i,r;this.drawingRect&&this.firstClickCoord&&(i=y.getRectUnderZoom(this.drawingRect,1/e),r=S.changePointByZoom(this.firstClickCoord,1/e)),super.onWheel(t,!1),i&&r&&(this.drawingRect=y.getRectUnderZoom(i,this.zoom),this.firstClickCoord=S.changePointByZoom(r,this.zoom)),this.render()}getCurrentSelectedData(){const{selectedRect:t}=this;if(!t)return;const e=this.getColor(t.attribute),i=t.valid?e==null?void 0:e.valid.stroke:e==null?void 0:e.invalid.stroke;return{width:t.width*this.zoom*.6,textAttribute:t.textAttribute,color:i}}getRenderStyle(t){const e=this.customRenderStyle&&this.customRenderStyle(t);if(e)return e;const i=this.getColor(t.attribute);let r,o;return t.valid===!1?(r=i==null?void 0:i.invalid.stroke,o=i==null?void 0:i.invalid.fill):(r=i==null?void 0:i.valid.stroke,o=i==null?void 0:i.valid.fill),{strokeColor:r,fillColor:o,textColor:r,toolColor:i}}renderTextAttribute(){var t;const{selectedRect:e}=this;if(!this.ctx||this.config.textConfigurable!==!0||!e)return;const{x:i,y:r,width:o,height:h,attribute:g,valid:s}=e,f=o*this.zoom*.6,l=S.getOffsetCoordinate({x:i,y:r+h},this.currentPos,this.zoom),c=this.getColor(g),u=s?c==null?void 0:c.valid.stroke:c==null?void 0:c.invalid.stroke,d=4;this._textAttributInstance||(this._textAttributInstance=new $({width:f,container:this.container,icon:this.getTextIconSvg(g),color:u,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedRectTextAttribute})),this._textAttributInstance&&!((t=this._textAttributInstance)==null?void 0:t.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${e.textAttribute}`,{left:l.x,top:l.y+d,color:u,width:f})}renderSelectedRect(t){if(!this.ctx||!t)return;const{ctx:e}=this;let i=10;const r=y.getRectPointList(t),o=r.length,h=this.getColor(t.attribute);r.forEach((g,s)=>{var f,l;if(e.save(),e.moveTo(g.x,g.y),e.beginPath(),this.hoverRectPointIndex===s?i=M+6:i=M,t.valid===!1?(e.strokeStyle=h==null?void 0:h.invalid.stroke,e.fillStyle=h==null?void 0:h.invalid.stroke):(e.strokeStyle=h==null?void 0:h.valid.stroke,e.fillStyle=h==null?void 0:h.valid.stroke),e.arc(g.x*this.zoom+this.currentPos.x,g.y*this.zoom+this.currentPos.y,i,0,2*Math.PI),e.fill(),this.hoverRectEdgeIndex===s){e.beginPath(),e.lineWidth=10;const c=this.getColor(t.attribute),u=t.valid===!1?(f=c==null?void 0:c.invalid)==null?void 0:f.stroke:(l=c==null?void 0:c.valid)==null?void 0:l.stroke;e.strokeStyle=u,e.moveTo(r[s].x*this.zoom+this.currentPos.x,r[s].y*this.zoom+this.currentPos.y),e.lineTo(r[(s+1)%o].x*this.zoom+this.currentPos.x,r[(s+1)%o].y*this.zoom+this.currentPos.y),e.stroke()}e.restore()}),this.renderTextAttribute()}renderDrawingRect(t,e=this.zoom,i=!1){var r,o,h,g;if(this.ctx&&t){const{ctx:s,style:f}=this,{hiddenText:l=!1}=f;s.save();const{strokeColor:c,fillColor:u,textColor:d}=this.getRenderStyle(t);s.font="lighter 14px Arial";let n="";((r=this.config)==null?void 0:r.isShowOrder)&&t.order&&(t==null?void 0:t.order)>0&&(n=`${t.order}`),t.label&&this.hasMarkerConfig&&(n=`${R.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${B.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&(n=`${n} ${C.getAttributeShowText(t.attribute,(o=this.config)==null?void 0:o.attributeList)}`);const a=S.changeRectByZoom(t,i?e:this.zoom,this.currentPos);l||k.drawText(this.canvas,{x:a.x,y:a.y-6},n,m(x({color:c,font:"normal normal 900 14px SourceHanSansCN-Regular"},T),{textMaxWidth:300}));const b=(g=(h=this.style)==null?void 0:h.width)!=null?g:2;(t.id===this.hoverRectID||t.id===this.selectedRectID||this.isMultiMoveMode)&&k.drawRectWithFill(this.canvas,a,{color:u}),k.drawRect(this.canvas,a,{color:c,thickness:b,hiddenText:!0}),s.restore();let I=`${Math.round(t.width)} * ${Math.round(t.height)}`;i===!0&&(I=`${Math.round(t.width/this.zoom)} * ${Math.round(a.height/this.zoom)}`);const v=I.length*7;if(l||k.drawText(this.canvas,{x:a.x+a.width-v,y:a.y+a.height+15},I,x({color:d,font:"normal normal 600 14px Arial"},T)),!l&&t.textAttribute&&t.id!==this.selectedRectID){const z=0,Z=Math.max(20,a.width-v);k.drawText(this.canvas,{x:a.x,y:a.y+a.height+20+z},t.textAttribute,x({color:d,font:"italic normal 900 14px Arial",textMaxWidth:Z},T))}}}renderMultiSelectedRect(){!this.isMultiMoveMode||this.rectList.forEach(t=>{this.renderDrawingRect(t),this.renderSelectedRect(t)})}renderStaticRect(){var t;if(!(((t=this.rectList)==null?void 0:t.length)>0&&JSON.stringify(this.rectList)))return;const{renderEnhance:e={}}=this,[i,r]=R.getRenderResultList(this.rectList,R.getSourceID(this.basicResult),this.attributeLockList,this.selectedRectID);this.isHidden||i==null||i.forEach(o=>{this.renderDrawingRect(o),e.staticRender&&e.staticRender(this.canvas,S.changeRectByZoom(o,this.zoom,this.currentPos),this.getRenderStyle(o))}),r&&(this.renderDrawingRect(r),this.renderSelectedRect(r),e.selectedRender&&e.selectedRender(this.canvas,S.changeRectByZoom(r,this.zoom,this.currentPos),this.getRenderStyle(r)))}renderCreatingRect(){if(!this.drawingRect)return;const{renderEnhance:t={}}=this;this.renderDrawingRect(this.drawingRect,1,!0),t.creatingRender&&t.creatingRender(this.canvas,S.changeRectByZoom(this.drawingRect,1,this.currentPos),this.getRenderStyle(this.drawingRect))}renderRect(){switch(this.operationMode){case _.MultiMove:this.renderMultiSelectedRect();break;default:this.renderStaticRect(),this.renderCreatingRect()}}render(){!this.ctx||(super.render(),this.renderRect(),this.renderCursorLine(this.getLineColor(this.defaultAttribute)))}setDefaultAttribute(t){const e=this.defaultAttribute;if(this.defaultAttribute=t!=null?t:"",e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedRect:i}=this;if(i&&(this.setRectList(this.rectList.map(r=>r.id===this.selectedID?m(x({},r),{attribute:this.defaultAttribute}):r),!0),this.history.pushHistory(this.rectList),this.render()),this.drawingRect&&(this.drawingRect=m(x({},this.drawingRect),{attribute:this.defaultAttribute}),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(this.defaultAttribute)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}setValid(t){super.setValid(t),this.emit("updateResult")}clearActiveStatus(){this.drawingRect=void 0,this.firstClickCoord=void 0,this.dragInfo=void 0,this.dragStatus=L.Wait,this.setSelectedRectID(void 0),this.setOperationMode(_.General)}clearResult(t=!0){const e=this.rectList.filter(i=>i.disableDelete===!0);e.length>0&&t&&this.emit("messageInfo",A.getMessagesByLocale(P.ClearPartialData,this.lang)),this.setRectList(e,!0),this.setSelectedRectID(void 0)}deleteRect(t){var e;if(!t)return;const i=this.rectList.find(r=>r.id===t);if((i==null?void 0:i.disableDelete)===!0){this.emit("messageInfo",A.getMessagesByLocale(P.DisableDelete,this.lang));return}this.setRectList(this.rectList.filter(r=>r.id!==t),!0),this.history.pushHistory(this.rectList),this.setSelectedRectID(void 0),(e=this._textAttributInstance)==null||e.clearTextAttribute(),this.render()}exportData(){const{rectList:t}=this;return[t,this.basicImgInfo]}undo(){const t=this.history.undo();t&&(t.length!==this.rectList.length&&this.setSelectedRectID(""),this.setRectList(t,!0),this.render())}redo(){const t=this.history.redo();t&&(t.length!==this.rectList.length&&this.setSelectedRectID(""),this.setRectList(t,!0),this.render())}}export{W as RectOperation,W as default};
@@ -0,0 +1 @@
1
+ import{i18n as d}from"@labelbee/lb-utils";import m from"../../utils/tool/AxisUtils.js";import{RectOperation as g}from"./rectOperation.js";import f from"../../constant/keyCode.js";var p=(u,e,t)=>new Promise((i,c)=>{var r=s=>{try{o(t.next(s))}catch(h){c(h)}},n=s=>{try{o(t.throw(s))}catch(h){c(h)}},o=s=>s.done?i(s.value):Promise.resolve(s.value).then(r,n);o((t=t.apply(u,e)).next())});class y extends g{constructor(e){super(e);this.onKeydown=t=>{switch(t.keyCode){case f.Esc:t.preventDefault(),t.stopPropagation(),this.clearPredictionInfo();break;case f.Z:t.ctrlKey&&(t.preventDefault(),t.stopPropagation(),this.rectList=[],this.render());break}},this.segmentPrediction=t=>p(this,null,function*(){const i=this.getCoordinateUnderZoom(t);if(this.isRunSegment=!0,this.render(),!this.runPrediction){this.emit("messageError","You needs to set runPrediction function"),this.clearPredictionInfo();return}yield this.runPrediction({point:i,rect:{x:this.rectList[0].x,y:this.rectList[0].y,w:this.rectList[0].width,h:this.rectList[0].height}}),this.clearPredictionInfo()}),this.isRunSegment=!1,this.runPrediction=e.runPrediction}setRunPrediction(e){this.runPrediction=e}eventBinding(){document.addEventListener("keydown",e=>this.onKeydown(e)),super.eventBinding()}clearPredictionInfo(){this.rectList=[],this.isShowCursor=!1,this.coord={x:-1,y:-1},this.drawingRect=void 0,this.isRunSegment=!1,this.clearCanvas(),this.render()}onMouseUp(e){if(!this.isRunSegment){if(e.button===0&&this.rectList.length===1&&!this.isRunSegment){e.stopPropagation(),this.segmentPrediction(e),this.clearActiveStatus();return}super.onMouseUp(e)}}onMouseDown(e){this.isRunSegment||super.onMouseDown(e)}renderCursorLine(){var e;if(!this.ctx)return;const{ctx:t}=this,i=10,c=1,{x:r,y:n}=this.coord;t.save(),t.strokeStyle="white",t.setLineDash([6]),t.lineWidth=c,t.strokeRect(r-i,n-i,i*2,i*2),t.restore();let o=`\u2460 ${d.t("FramingOfObjectToBeDivided")}`;const s=d.language==="en";let h=s?326:186;if(((e=this.rectList)==null?void 0:e.length)===1){o=`\u2461 ${d.t("ClickOnTarget")}`,h=s?232:142;const a=2;t.save(),t.strokeStyle="white";const l=c+i;t.beginPath(),t.moveTo(r+l+a*2,n+l+a),t.arc(r+l+a,n+l+a,a,0,Math.PI*2,!0),t.stroke(),t.restore()}this.isRunSegment&&(h=s?316:136,o=d.t("SplittingAlgorithmPrediction")),t.save(),t.fillStyle=this.style.strokeColor,t.fillRect(r+i,n-i*4-1,h,32),t.restore(),t.save(),t.font="14px Source Han Sans CN",t.fillStyle="white",t.fillText(o,r+i+14,n-i*2),t.restore(),super.renderCursorLine()}renderDrawingRect(e,t,i=!1){if(this.ctx&&e){const c=m.changeRectByZoom(e,i?t:this.zoom,this.currentPos),{x:r,y:n,width:o,height:s}=c;this.ctx.save(),this.ctx.lineCap="butt",this.ctx.lineWidth=this.style.strokeWidth,this.ctx.strokeStyle="white",this.ctx.strokeRect(r,n,o,s),this.ctx.strokeStyle=this.style.strokeColor,this.ctx.setLineDash([6]),this.ctx.strokeRect(r,n,o,s),this.ctx.restore()}}renderTextAttribute(){}renderSelectedRect(){}}export{y as default};
@@ -0,0 +1,19 @@
1
+ import c from"../../utils/tool/CommonToolUtils.js";import m from"../../utils/tool/TagUtils.js";import T from"../../utils/uuid.js";import{BasicToolOperation as D}from"./basicToolOperation.js";class R extends D{constructor(t){super(t);this.getInitResultList=(e,s)=>!(e===0||e===void 0)&&s.length===0?[]:m.getDefaultTagResult(this.config.inputList,s),this.setLabel=(e,s)=>{var i,h;if(this.isImgError||!this.basicResult&&this.dependToolName)return;const l=this.config.inputList;if(!l[e])return;const{subSelected:o}=l[e];if(e<l.length&&l[e].subSelected&&o&&s<o.length){const d=l[e].value;let r=(i=o[s])==null?void 0:i.value;const g=(h=l[e])==null?void 0:h.isMulti,u=this.tagResult.filter(f=>{const n=`${f.sourceID}`;return c.isSameSourceID(n,this.sourceID)})[0];if(u){let f=0;const{result:n}=u;u.sourceID===0&&(u.sourceID="0");for(const p in u.result)if(p===l[e].value){if(f++,g===!0){const a=n[p].split(";").filter(I=>I!==""),b=a.indexOf(r);b===-1?a.push(r):a.splice(b,1),r=a.join(";")}r===""?Object.keys(n).length===1?this.tagResult=this.tagResult.filter(a=>{const b=`${a.sourceID}`;return c.isDifferSourceID(b,this.sourceID)}):Object.keys(n).length>1&&delete n[p]:n[p]=r}f===0&&Object.assign(u.result,{[d]:r})}else this.tagResult=[{sourceID:this.sourceID,id:T(8,62),result:{[d]:r}}];this.render()}},this.clearResult=(e=!0,s)=>{s?this.tagResult=this.tagResult.map(i=>((i==null?void 0:i.result[s])&&delete i.result[s],i)):this.tagResult=[],this.render()},this.config=c.jsonParser(t.config),this.tagResult=[],this.labelSelectedList=[],this.setShowDefaultCursor(!0)}destroy(){this.clearTag(),super.destroy()}setResult(t){this.tagResult=t,this.render()}get currentPageResult(){return[this.currentTagResult]}get currentTagResult(){var t;return(t=this.tagResult.filter(e=>{const s=`${e.sourceID}`;return c.isSameSourceID(s,this.sourceID)})[0])!=null?t:{}}get sourceID(){return c.getSourceID(this.basicResult)}onKeyDown(t){if(!c.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;let{keyCode:e}=t;if(e&&(e<=57&&e>=49||e<=105&&e>=97)){if(e>57?e-=97:e-=49,this.config.inputList.length===1){this.labelSelectedList=[0,e],this.setLabel(0,e),setTimeout(()=>{this.labelSelectedList=[],this.render()},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],e],this.setLabel(this.labelSelectedList[0],e),setTimeout(()=>{this.labelSelectedList=[],this.render()},500)):(this.labelSelectedList=[e],this.emit("expend"))}}clearTag(){var t;const e=(t=this.canvas)==null?void 0:t.parentNode,s=window.self.document.getElementById("tagToolTag");s&&e&&e.contains(s)&&(e==null||e.removeChild(s))}renderTag(){var t,e,s,i,h,l;if(this.clearTag(),!(((t=this.tagResult)==null?void 0:t.length)>0))return;const o=document.createElement("div"),d=m.getTagNameList((s=(e=this.currentTagResult)==null?void 0:e.result)!=null?s:{},this.config.inputList);o.innerHTML=(i=d.reduce((r,g)=>`${r}${g.keyName}: ${g.value.join(" \u3001 ")}
2
+ `,""))!=null?i:"",o.setAttribute("id","tagToolTag"),o.setAttribute("style",`
3
+ position: absolute;
4
+ top: 0;
5
+ right: 0;
6
+ z-index: 5;
7
+
8
+ padding: 0 20px;
9
+
10
+ font-size: 15px;
11
+ color: white;
12
+ text-align: right;
13
+ line-height: 32px;
14
+ white-space: pre;
15
+
16
+ background: rgba(102, 111, 255, 1);
17
+ opacity: 0.6;
18
+ clear: both;
19
+ `),(l=(h=this.canvas)==null?void 0:h.parentNode)==null||l.appendChild(o)}render(){this.renderTag(),super.render(),this.emit("render")}exportData(){let{tagResult:t}=this;return this.isImgError&&(t=[]),[t,this.basicImgInfo]}}export{R as default};
@@ -0,0 +1,37 @@
1
+ import d from"../../constant/keyCode.js";import{TEXT_ATTRIBUTE_LINE_HEIGHT as c,TEXT_ATTRIBUTE_MAX_LENGTH as u}from"../../constant/tool.js";const h=30,x=164;class M{constructor(t){this.textKeyDown=a=>{switch(a.stopPropagation(),a.keyCode){case d.Enter:this.submitTextarea(),this.appendToContainer();break}};const{container:i,icon:e,color:r,getCurrentSelectedData:o,updateSelectedTextAttribute:n}=t,s=t.width||x;this.container=i,this.getCurrentSelectedData=o,this.updateSelectedTextAttribute=n,this._textAttributeDOM=this.initTextAttributeDOM(),this._iconDOM=this.initIconDOM(e),this._textDOM=this.initTextDOM(s,c),this._textareaDOM=this.initTextareaDOM(s,r),this.appendToContainer()}get isExit(){return this._textAttributeDOM?this.container.contains(this._textAttributeDOM):!1}get isExitTextareaDOM(){return this._textareaDOM?this.container.contains(this._textareaDOM):!1}updateIcon(t){this._iconDOM&&(this._iconDOM.innerHTML=t)}appendToContainer(){!this._textAttributeDOM||!this._textDOM||!this._iconDOM||(this.container.appendChild(this._textAttributeDOM),this._textAttributeDOM.appendChild(this._textDOM),this._textAttributeDOM.appendChild(this._iconDOM))}initTextAttributeDOM(){const t=document.createElement("div");return t.setAttribute("id","textArea"),t}initTextDOM(t,i){const e=document.createElement("span");return e.setAttribute("style",`
2
+ width: ${Math.max(t,h)}px;
3
+ line-height: ${i}px;
4
+ word-break: break-all;
5
+ white-space: pre-line;
6
+ font-style: italic;
7
+ `),e}initIconDOM(t){const i=document.createElement("div");return i.setAttribute("id","annotation_text"),i.innerHTML=t,i.addEventListener("mouseup",e=>{e.stopPropagation(),this.renderTextarea()}),i.addEventListener("mousedown",e=>{e.stopPropagation()}),i.addEventListener("contextmenu",e=>{e.stopPropagation()}),i.setAttribute("style",`
8
+ position: absolute;
9
+ left: -20px;
10
+ top: 4px;
11
+ cursor: pointer;
12
+ z-index: 10
13
+ `),i}initTextareaDOM(t,i){const e=document.createElement("textarea");return e.addEventListener("click",r=>{r.stopPropagation()}),e.addEventListener("mouseup",r=>{r.stopPropagation()}),e.setAttribute("style",`
14
+ background-color: transparent;
15
+ border-radius: 5px;
16
+ border-color: ${i};
17
+ outline: none;
18
+ resize: none;
19
+ width: ${Math.max(t,30)}px;
20
+ `),e.setAttribute("maxLength",`${u}`),e}removeTextDOM(){!this._textAttributeDOM||this._textDOM&&this._textAttributeDOM.removeChild(this._textDOM)}removeIconDOM(){!this._textAttributeDOM||this._iconDOM&&this._textAttributeDOM.removeChild(this._iconDOM)}removeTextareaDOM(){var t,i;this._textareaDOM&&this._textAttributeDOM&&((t=this._textAttributeDOM)==null?void 0:t.contains(this._textareaDOM))&&((i=this._textAttributeDOM)==null||i.removeChild(this._textareaDOM))}submitTextarea(){var t;this._textareaDOM&&(this.updateSelectedTextAttribute((t=this._textareaDOM)==null?void 0:t.value),this.removeTextareaDOM(),this.clearTextAttribute())}clearTextAttribute(){this._textAttributeDOM&&this.container.contains(this._textAttributeDOM)&&this.container.removeChild(this._textAttributeDOM)}renderTextarea(){if(!this._textAttributeDOM||!this._textareaDOM)return;const t=this.getCurrentSelectedData();if(!t)return;const{width:i=x,textAttribute:e,color:r}=t;this._textareaDOM.value=`${e}`,this._textareaDOM.setAttribute("style",`
21
+ background-color: rgba(0,0,0,0.4);
22
+ border-radius: 5px;
23
+ border-color: ${r};
24
+ outline: none;
25
+ resize: none;
26
+ font-style: italic;
27
+ font-weight: 900;
28
+ text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.6);
29
+ width: ${Math.max(i,h)}px;
30
+ `),this._textareaDOM.setAttribute("maxLength",`${u}`),this._textAttributeDOM.appendChild(this._textareaDOM),this.removeIconDOM(),this.removeTextDOM(),this._textareaDOM.focus(),this._textareaDOM.addEventListener("keydown",this.textKeyDown)}update(t,i){var e;const{left:r,top:o,color:n,width:s=x}=i,a=Math.max(s,h);(e=this._textAttributeDOM)==null||e.setAttribute("style",`
31
+ position: absolute;
32
+ width: ${a}px;
33
+ font-size: 14px;
34
+ left:${r}px;
35
+ top: ${o}px;
36
+ color: ${n};
37
+ `),this._textDOM&&(this._textDOM.innerHTML=`${t}`),this._textareaDOM&&(this._textareaDOM.style.width=`${a}px`,this._textareaDOM.style.borderColor=`${n}`)}changeSelected(){this.isExitTextareaDOM&&this.submitTextarea()}}export{M as default};
package/es/index.js ADDED
@@ -0,0 +1 @@
1
+ export{RectOperation}from"./core/toolOperation/rectOperation.js";export{default as TagOperation}from"./core/toolOperation/tagOperation.js";export{default as PointOperation}from"./core/toolOperation/pointOperation.js";export{default as LineToolOperation}from"./core/toolOperation/LineToolOperation.js";export{default as TextToolOperation}from"./core/toolOperation/TextToolOperation.js";export{default as PolygonOperation}from"./core/toolOperation/polygonOperation.js";export{default as MeasureOperation}from"./core/toolOperation/measureOperation.js";export{BasicToolOperation}from"./core/toolOperation/basicToolOperation.js";export{default as ViewOperation}from"./core/toolOperation/ViewOperation.js";export{default as ScribbleTool}from"./core/toolOperation/ScribbleTool.js";export{default as PointCloud2dOperation}from"./core/toolOperation/pointCloud2dOperation.js";import*as t from"./constant/annotation.js";export{t as cAnnotation};import*as e from"./constant/annotationTask.js";export{e as cAnnotationTask};import*as r from"./constant/keyCode.js";export{r as cKeyCode};import*as a from"./constant/style.js";export{a as cStyle};import*as i from"./constant/tool.js";export{i as cTool};export{CLIENT_TOOL_HEAD_TYPE,CLIENT_TOOL_NAME,DEFAULT_FONT,DEFAULT_TEXT_MAX_WIDTH,EAnnotationMode,EAuditStatus,ECheckModel,EDependPattern,EDragTarget,EDrawPointPattern,EFilterToolOperation,ELineColor,ELineTypes,EOperationMode,EPageOperator,EPointCloudName,EPolygonPattern,ERectPattern,EScribblePattern,ESelectedType,ETextType,EThumbnailOption,EToolName,EToolType,EVideoToolName,OPERATION_LIST,SEGMENT_NUMBER,TEXT_ATTRIBUTE_LINE_HEIGHT,TEXT_ATTRIBUTE_MAX_LENGTH,TEXT_TYPE,TOOL_NAME,TOOL_NAME_EN,edgeAdsorptionScope,editStepWidth}from"./constant/tool.js";export{default as TagUtils}from"./utils/tool/TagUtils.js";export{default as uuid}from"./utils/uuid.js";import o from"./utils/tool/EnhanceCommonToolUtils.js";export{default as MarkerUtils}from"./utils/tool/MarkerUtils.js";export{default as RectUtils}from"./utils/tool/RectUtils.js";export{default as AxisUtils}from"./utils/tool/AxisUtils.js";export{default as DrawUtils}from"./utils/tool/DrawUtils.js";export{default as ImgUtils}from"./utils/ImgUtils.js";export{default as MathUtils}from"./utils/MathUtils.js";export{default as AttributeUtils}from"./utils/tool/AttributeUtils.js";export{default as ActionsHistory}from"./utils/ActionsHistory.js";export{default as DblClickEventListener}from"./utils/tool/DblClickEventListener.js";export{default as AnnotationEngine}from"./core/index.js";export{default as UnitUtils}from"./utils/tool/UnitUtils.js";export{default as StyleUtils}from"./utils/tool/StyleUtils.js";export{CanvasScheduler}from"./newCore/CanvasScheduler.js";export{PointCloud}from"./core/pointCloud/index.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,lidar2image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./core/pointCloud/matrix.js";export{PointCloudAnnotation}from"./core/pointCloud/annotation.js";const s=o,l=o;export{s as CommonToolUtils,l as toolUtils};
@@ -0,0 +1 @@
1
+ var o;(function(r){r.NoRotateNotice="noRotateNotice",r.RectErrorSizeNotice="rectErrorSizeNotice",r.TextCheckNumberErrorNotice="textCheckNumberErrorNotice",r.TextCheckEnglishErrorNotice="textCheckEnglishErrorNotice",r.TextCheckCustomErrorNotice="textCheckCustomErrorNotice",r.UpperLimitErrorNotice="UpperLimitErrorNotice",r.LowerLimitErrorNotice="LowerLimitErrorNotice",r.InvalidImage="InvalidImage",r.DisableDelete="DisableDelete",r.ClearPartialData="ClearPartialData",r.MarkerFinish="MarkerFinish",r.LowerLimitPoint="LowerLimitPoint",r.NoRotateInDependence="noRotateInDependence",r.UnableToReannotation="unableToReannotation",r.ForbiddenCreationOutsideBoundary="ForbiddenCreationOutsideBoundary",r.SuccessfulEdgeAdsorption="SuccessfulEdgeAdsorption",r.ForbidAddNewPoint="ForbidAddNewPoint"})(o||(o={}));export{o as EMessage};
@@ -0,0 +1 @@
1
+ import{EMessage as e}from"../constants.js";const t={[e.NoRotateNotice]:"This Image contains data and cannot be rotated",[e.RectErrorSizeNotice]:"The drawing frame size is smaller than the minimum drawing size",[e.TextCheckNumberErrorNotice]:"Please enter in number-only format",[e.TextCheckEnglishErrorNotice]:"Please enter in English only format",[e.TextCheckCustomErrorNotice]:"Please enter in the required format",[e.UpperLimitErrorNotice]:"The number of vertices is not more than",[e.LowerLimitErrorNotice]:"The number of vertices is not less than",[e.InvalidImage]:"Invalid image, please skip this image",[e.DisableDelete]:"Disable delete",[e.ClearPartialData]:"Clear partial data",[e.MarkerFinish]:"ListAnnotation is finished",[e.LowerLimitPoint]:"The maximum number of points has been reached",[e.NoRotateInDependence]:"Disallow rotation in dependent cases",[e.UnableToReannotation]:"Unabled to reannotation",[e.ForbiddenCreationOutsideBoundary]:"Fobid creation outside boundary",[e.SuccessfulEdgeAdsorption]:"Successful edge adsorption",[e.ForbidAddNewPoint]:"Forbid to add new point in rect-polygon"};export{t as default};
@@ -0,0 +1 @@
1
+ import{ELang as e}from"../constant/annotation.js";import o from"./en_US/message.js";import r from"./zh_CN/message.js";class a{}a.getMessagesByLocale=(s,t)=>{switch(t){case e.US:return o[s];case e.Zh:default:return r[s]}};export{a as default};
@@ -0,0 +1 @@
1
+ import{EMessage as u}from"../constants.js";const F={[u.NoRotateNotice]:"\u672C\u56FE\u542B\u6709\u6570\u636E\uFF0C\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C",[u.RectErrorSizeNotice]:"\u7ED8\u5236\u6846\u5C3A\u5BF8\u5C0F\u4E8E\u6700\u5C0F\u7ED8\u5236\u5C3A\u5BF8",[u.TextCheckNumberErrorNotice]:"\u8BF7\u6309\u4EC5\u6570\u5B57\u7684\u683C\u5F0F\u8F93\u5165",[u.TextCheckEnglishErrorNotice]:"\u8BF7\u6309\u4EC5\u82F1\u6587\u7684\u683C\u5F0F\u8F93\u5165",[u.TextCheckCustomErrorNotice]:"\u8BF7\u6309\u8981\u6C42\u7684\u683C\u5F0F\u8F93\u5165",[u.UpperLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u591A\u4E8E",[u.LowerLimitErrorNotice]:"\u9876\u70B9\u6570\u4E0D\u5C11\u4E8E",[u.InvalidImage]:"\u65E0\u6548\u56FE\u7247\uFF0C\u8BF7\u8DF3\u8FC7\u6B64\u56FE",[u.DisableDelete]:"\u8BE5\u6570\u636E\u7981\u6B62\u5220\u9664",[u.ClearPartialData]:"\u5B58\u5728\u90E8\u5206\u6570\u636E\u65E0\u6CD5\u6E05\u9664",[u.MarkerFinish]:"\u5217\u8868\u6807\u6CE8\u5DF2\u5B8C\u6210",[u.LowerLimitPoint]:"\u5DF2\u5230\u8FBE\u6807\u70B9\u6570\u91CF\u4E0A\u9650",[u.NoRotateInDependence]:"\u4F9D\u8D56\u60C5\u51B5\u4E0B\u65E0\u6CD5\u8FDB\u884C\u65CB\u8F6C",[u.UnableToReannotation]:"\u65E0\u6CD5\u8FDB\u884C\u7EED\u6807\u64CD\u4F5C",[u.ForbiddenCreationOutsideBoundary]:"\u8FB9\u754C\u5916\u7981\u6B62\u521B\u5EFA",[u.SuccessfulEdgeAdsorption]:"\u8FB9\u7F18\u5438\u9644\u6210\u529F",[u.ForbidAddNewPoint]:"\u6846\u4F53\u65E0\u6CD5\u6DFB\u52A0\u70B9"};export{F as default};
@@ -0,0 +1 @@
1
+ class a{constructor(e){this.container=e.container}createCanvas(e,t){if(typeof e!="string")return this.container.appendChild(e),e.style.position="absolute",e.style.left="0",e.style.top="0",e;const n=document.createElement("canvas");return n.id=e,t&&t.size&&(n.width=t.size.width,n.height=t.size.height),this.container.appendChild(n),n}destroyCanvas(e){const t=document.getElementById(e);return t&&this.container.removeChild(t),t}}export{a as CanvasScheduler};
@@ -0,0 +1 @@
1
+ import r from"lodash";class h{constructor(e){this.record=[],this.recordIndex=-1,this.minRecordIndex=-1,this.emitHistoryChanged=()=>{this.historyChanged&&(this.constructor.name==="ActionsHistory"?!0:this.record.length>0)&&this.historyChanged(this.undoEnabled,this.redoEnabled)},this.historyChanged=e}get undoEnabled(){return this.recordIndex>this.minRecordIndex}get redoEnabled(){return this.recordIndex<this.record.length-1}pushHistory(e){if(this.recordIndex!==this.record.length-1){const t=this.record.slice(0,Math.min(this.recordIndex+1,this.record.length));this.record=t}this.record.push(r.cloneDeepWith(e)),this.recordIndex+=1,this.emitHistoryChanged()}updateHistory(e){this.record[this.recordIndex]=r.cloneDeep(e)}applyAttribute(e,t,i){e&&this.record.forEach(d=>{const s=d.find(o=>o.id===e);s&&(s[t]=i)})}undo(){if(this.undoEnabled)return this.recordIndex-=1,this.emitHistoryChanged(),r.cloneDeep(this.record[this.recordIndex])||[]}redo(){if(this.redoEnabled)return this.recordIndex+=1,this.emitHistoryChanged(),r.cloneDeep(this.record[this.recordIndex])}init(){this.record=[[]],this.recordIndex=0,this.emitHistoryChanged()}empty(){this.record=[],this.recordIndex=-1,this.emitHistoryChanged()}initRecord(e,t=!1){const i=e.length>0||t;this.record=i?[r.cloneDeep(e)]:[],this.minRecordIndex=i?0:-1,this.recordIndex=0}}export{h as default};
@@ -0,0 +1 @@
1
+ class r{static load(o){return new Promise((s,n)=>{const e=new Image;e.crossOrigin="anonymous",o.startsWith("file")?e.src=encodeURI(o):e.src=o,e.onload=()=>{s(e)},e.onerror=()=>{n(e)}})}}export{r as default};
@@ -0,0 +1,2 @@
1
+ import F from"../_virtual/MathUtilsWorker.js";import{SEGMENT_NUMBER as R,DEFAULT_TEXT_MAX_WIDTH as E,DEFAULT_FONT as I,ELineTypes as T}from"../constant/tool.js";import{createSmoothCurvePointsFromPointList as B}from"./tool/polygonTool.js";import w from"./tool/PolygonUtils.js";import h from"./VectorUtils.js";var C=Object.defineProperty,v=Object.defineProperties,S=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable,_=(e,t,o)=>t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,A=(e,t)=>{for(var o in t||(t={}))U.call(t,o)&&_(e,o,t[o]);if(O)for(var o of O(t))j.call(t,o)&&_(e,o,t[o]);return e},L=(e,t)=>v(e,S(t));class M{static tanAPlusB(t,o){return(t+o)/(1-t*o)}static sinAPlusB(t,o,s,r){return r*t+o*s}static cosAPlusB(t,o,s,r){return o*r-t*s}}const m=class{static getRotate(e){return e+90>=360?e+90-360:e+90}static getLineLength(e,t){return Math.sqrt(Math.pow(t.y-e.y,2)+Math.pow(t.x-e.x,2))}static getTextArea(e,t,o=E,s=I,r){if(typeof t!="string")return{width:0,height:0};const i=e.getContext("2d");i.font=s;let n=0;typeof r=="undefined"&&(r=e&&parseInt(window.getComputedStyle(e).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const a=e&&parseInt(window.getComputedStyle(e).fontSize,10)||parseInt(window.getComputedStyle(document.body).fontSize,10)||0,c=t.split(`
2
+ `);let l=0;for(let f=0;f<c.length;f++){const p=c[f].split("");let g="";for(let y=0;y<p.length;y++){const u=g+p[y],d=i.measureText(u).width;d>o&&y>0?(g=p[y],n+=r,l=o):(g=u,d>l&&(l=d))}f!==c.length-1&&(n+=r)}return{width:l,height:n+a,lineHeight:r,fontHeight:a}}static getLineCenterPoint(e){const[t,o]=e,s=h.getVector(t,o);return{x:t.x+s.x/2,y:t.y+s.y/2}}static getPerpendicularLine(e){if(e.length!==2)return;const[t,o]=e,s={x:o.x+o.y-t.y,y:o.y-(o.x-t.x)};return[o,s]}static getPerpendicularFootOfLine(e,t){if(e.length!==2)return e;const o=this.getPerpendicularLine(e);if(!o)return e;const[s,r]=o;return this.getFootOfPerpendicular(t,s,r).footPoint}static getQuadrangleFromTriangle(e){if(e.length!==3)return e;const[t,o,s]=e,r={x:s.x+t.x-o.x,y:s.y+t.y-o.y};return[t,o,s,r]}static getRectPerpendicularOffset(e,t,o){const[s,r]=o,i=this.getFootOfPerpendicular(e,s,r).footPoint,n=this.getFootOfPerpendicular(t,s,r).footPoint,a={x:i.x-n.x,y:i.y-n.y},c=h.add(t,a);return h.getVector(e,c)}static getArrayIndex(e,t){return e<0?t+e:e>=t?e-t:e}static getPointListFromPointOffset(e,t,o){const s=this.getArrayIndex(t-1,e.length),r=this.getArrayIndex(t+1,e.length),i=this.getArrayIndex(t-2,e.length),n=[...e];n[t]=h.add(n[t],o);const a=this.getFootOfPerpendicular(n[t],n[i],n[s]).footPoint,c=this.getFootOfPerpendicular(n[t],n[r],n[i]).footPoint;return n[s]=a,n[r]=c,n}static getRectCenterPoint(e){const[t,,o]=e;return{x:(t.x+o.x)/2,y:(t.y+o.y)/2}}static rotateRectPointList(e=5,t){const o=this.getRectCenterPoint(t),{PI:s}=Math,r=Math.sin(e*s/180),i=Math.cos(e*s/180);return t.map(n=>{const a=h.getVector(o,n),c=h.len(a),l=a.y/c,f=a.x/c;return{x:c*M.cosAPlusB(l,f,r,i)+o.x,y:c*M.sinAPlusB(l,f,r,i)+o.y}})}static getRectangleByRightAngle(e,t){if(t.length!==2)return t;const o=m.getPerpendicularFootOfLine(t,e);return m.getQuadrangleFromTriangle([...t,o])}static getRadiusFromQuadrangle(e){const[,t,o]=e,s=o.y-t.y,r=t.x-o.x,i=this.getLineLength(t,o),n=s/i,a=Math.acos(n);return r>0?Math.PI*2-a:a}static getCollectionPointByAnnotationDataPromise(e){const t=e.filter(r=>r.type==="point").map(r=>r.annotation),o=e.filter(r=>!!["polygon","line"].includes(r.type)).map(r=>r.type==="polygon"?L(A({},r.annotation),{pointList:w.concatBeginAndEnd(r.annotation.pointList)}):r.annotation),s=new F;return{promise:new Promise(function(i){s.postMessage({points:t,backgroundList:o}),s.onmessage=n=>{i(n.data),s.terminate()}}),close:()=>{s.terminate()}}}static getCollectionPointByAnnotationData(e){const t=[],o=new Set,s=e.filter(n=>n.type==="point").map(n=>n.annotation),r=e.filter(n=>!!["polygon","line"].includes(n.type)).map(n=>n.type==="polygon"?L(A({},n.annotation),{pointList:w.concatBeginAndEnd(n.annotation.pointList)}):n.annotation),i=(n,a)=>{const{dropFoot:c}=w.getClosestPoint(n,a,T.Line,1,{isClose:!1});if(c!==n){const l=`${c.x} + ${c.y}`;o.has(l)||t.push(n),o.add(l)}};return s.forEach(n=>{i(n,r)}),r.forEach(n=>{let a="";a=n.id,r.forEach((c,l)=>{if(c.id===a)return;const f=[...r];f.splice(l,1),c.pointList.forEach(p=>{i(p,f)})})}),{connectionPoints:t}}};let x=m;x.isInRange=(e,t)=>{const o=Math.min(...t),s=Math.max(...t),r=n=>n<=s&&n>=o;return(Array.isArray(e)?e:[e]).every(n=>r(n))},x.withinRange=(e,t)=>{const o=Math.min(...t),s=Math.max(...t);return e>s?s:e<o?o:e},x.calcViewportBoundaries=(e,t=!1,o=R,s=1)=>{if(!e)return{top:0,bottom:0,left:0,right:0};const r=20/s,i=[],n=[];let a=e;t&&(a=B(e,o)),a.forEach(({x:u,y:P})=>{i.push(u),n.push(P)});let c=Math.min(...i),l=Math.max(...i),f=Math.min(...n),p=Math.max(...n);const g=l-c,y=p-f;if(g<r){const u=(r-g)/2;c-=u,l+=u}if(y<r){const u=(r-y)/2;f-=u,p+=u}return{top:f,bottom:p,left:c,right:l}},x.getFootOfPerpendicular=(e,t,o,s=!1,r=!1)=>{let i={x:0,y:0};const n=t.x-o.x,a=t.y-o.y;if(Math.abs(n)<1e-8&&Math.abs(a)<1e-8)return i=t,i;let c=(e.x-t.x)*(t.x-o.x)+(e.y-t.y)*(t.y-o.y);c/=n*n+a*a,i.x=t.x+c*n,i.y=t.y+c*a;const l=m.getLineLength(e,i),f=2,p=Math.min(t.x,o.x),g=Math.max(t.x,o.x),y=Math.min(t.y,o.y),u=Math.max(t.y,o.y),P=!(m.isInRange(e.x,[p,g])||m.isInRange(e.y,[y,u])),d=e.x>g+f||e.x<p-f||e.y>u+f||e.y<y-f;return!r&&(s?P:d)?{footPoint:i,length:Infinity}:{footPoint:i,length:l}};var D=x;export{M as Trigonometric,D as default};
@@ -0,0 +1 @@
1
+ var x=Math.pow;class r{static add(t,a){return{x:t.x+a.x,y:t.y+a.y}}static getVector(t,a){return{x:a.x-t.x,y:a.y-t.y}}static len(t){return Math.sqrt(x(t.x,2)+x(t.y,2))}static dotProduct(t,a){return t.x*a.x+t.y+a.y}}export{r as default};
@@ -0,0 +1 @@
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};
@@ -0,0 +1 @@
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};
@@ -0,0 +1 @@
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};
@@ -0,0 +1 @@
1
+ import{isObject as h}from"lodash";import{EStepType as u,ESortDirection as f}from"../../constant/annotation.js";var v=Object.defineProperty,y=Object.defineProperties,_=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,p=(o,t,e)=>t in o?v(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,g=(o,t)=>{for(var e in t||(t={}))O.call(t,e)&&p(o,e,t[e]);if(d)for(var e of d(t))P.call(t,e)&&p(o,e,t[e]);return o},E=(o,t)=>y(o,_(t));class S{static getStepInfo(t,e){return e==null?void 0:e.filter(r=>r.step===t)[0]}static getCurrentStepInfo(t,e){const r=this.getStepInfo(t,e);return r&&(r.type===u.QUALITY_INSPECTION||r.type===u.MANUAL_CORRECTION)?this.getCurrentStepInfo(r.dataSourceStep,e):r}static getMaxOrder(t){let e=0;return t.forEach(r=>{r.order&&r.order>e&&(e=r.order)}),e}static hotkeyFilter(t){const e=t.target||t.srcElement;if(!e)return!0;const{tagName:r,type:i}=e;if(!r||!i)return!0;let n=!0;return(e.isContentEditable||r==="TEXTAREA"||(r==="INPUT"&&i!=="radio"||r==="TEXTAREA")&&!e.readOnly)&&(n=!1),n}static getNextSelectedRectID(t,e=f.ascend,r){let i=1;e===f.descend&&(i=-1);const n=t.sort((s,c)=>s.x-c.x==0?s.y-c.y:i*(s.x-c.x)),l=n.findIndex(s=>s.id===r),a=n.length;return n[(l+1)%a]}static getNextSelectedRectIDByEvent(t,e,r){const i=e.shiftKey?f.descend:f.ascend;return this.getNextSelectedRectID(t,i,r)}static getRenderResultList(t,e,r=[],i){let n;return[t.filter(a=>i&&i===(a==null?void 0:a.id)?(n=a,!1):!(r.length>0&&!r.includes(a==null?void 0:a.attribute)||this.isDifferSourceID(a==null?void 0:a.sourceID,e))),n]}static getSourceID(t){var e;const r="";return t&&(e=t==null?void 0:t.id)!=null?e:r}static findAllLine(t,e=!0){const r=[],i=[...t];i.length>=3&&e===!0&&i.push(g({},i[0]));for(let n=0;n<i.length;n++)i[n+1]&&r.push({point1:i[n],point2:i[n+1],pointIndex:n});return r}static translateSourceID(t){return(t===void 0||t===0||t==="0")&&(t=""),t}static isDifferSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`!=`${e}`}static isSameSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`==`${e}`}static getNextMarker(t,e=[],r){if((e==null?void 0:e.length)===0)return;let i=e.map((n,l)=>E(g({},n),{index:l}));if(typeof r=="number"&&r>0){const n=e[r];if(n&&t.every(l=>l.label!==n.value))return{label:n.value,index:r};i=[...i.slice(r,e.length),...i.slice(0,r)]}for(let n=0;n<i.length;n++)if(!t.some(l=>l.label===i[n].value))return{label:i[n].value,index:i[n].index}}static getCurrentMarkerIndex(t,e=[]){return e.findIndex(r=>t===r.value)}}S.jsonParser=(o,t={})=>{try{return typeof o=="string"?JSON.parse(o):h(o)?o:t}catch(e){return t}};export{S as default};
@@ -0,0 +1 @@
1
+ import{cloneDeep as D}from"lodash";import{ECuboidPlain as a,ECuboidPosition as p,ECuboidDirection as B,EDragTarget as L,DIAGONAL_POINT as U,ECuboidLineDirection as P,CUBOID_ROW as X,CUBOID_COLUMN as Y}from"../../constant/annotation.js";import v from"./AxisUtils.js";import G from"../VectorUtils.js";import _ from"./LineToolUtils.js";var V=Object.defineProperty,z=Object.defineProperties,Q=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,S=(n,t,i)=>t in n?V(n,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[t]=i,f=(n,t)=>{for(var i in t||(t={}))q.call(t,i)&&S(n,i,t[i]);if(I)for(var i of I(t))J.call(t,i)&&S(n,i,t[i]);return n},w=(n,t)=>z(n,Q(t));function m({tr:n,tl:t,br:i}){return{width:Math.abs(n.x-t.x),height:Math.abs(i.y-n.y),centerPoints:{x:(t.x+i.x)/2,y:(t.y+i.y)/2}}}function x({frontPoints:n,backPoints:t}){const{width:i,height:e,centerPoints:r}=m(n),{width:o,height:s,centerPoints:l}=m(t);return{frontCenter:r,backCenter:l,frontWidth:i,frontHeight:e,backWidth:o,backHeight:s,isLeftSide:l.x<r.x}}function k(n,t){return{tl:{x:Math.min(n.x,t.x),y:Math.min(n.y,t.y)},tr:{x:Math.max(n.x,t.x),y:Math.min(n.y,t.y)},bl:{x:Math.min(n.x,t.x),y:Math.max(n.y,t.y)},br:{x:Math.max(n.x,t.x),y:Math.max(n.y,t.y)}}}function F(n){const t=Object.values(n).reduce((o,s)=>s.x<o?s.x:o,Number.MAX_SAFE_INTEGER),i=Object.values(n).reduce((o,s)=>s.x>o?s.x:o,0),e=Object.values(n).reduce((o,s)=>s.y<o?s.y:o,Number.MAX_SAFE_INTEGER),r=Object.values(n).reduce((o,s)=>s.y>o?s.y:o,0);return{tl:{x:t,y:e},tr:{x:i,y:e},bl:{x:t,y:r},br:{x:i,y:r}}}function N(n){const[t,i]=n;if(X[t.position]===i.position)return P.Row;if(Y[t.position]===i.position)return P.Column}function M({coord:n,points:t}){const{width:i,height:e}=m(t);return{br:n,tr:{x:n.x,y:n.y-e},tl:{x:n.x-i,y:n.y-e},bl:{x:n.x-i,y:n.y}}}function j({coord:n,points:t}){const{width:i,height:e}=m(t);return{bl:n,tr:{x:n.x+i,y:n.y-e},tl:{x:n.x,y:n.y-e},br:{x:n.x+i,y:n.y}}}function H({frontPoints:n,backPoints:t}){const{isLeftSide:i}=x({frontPoints:n,backPoints:t});return i?{top:{p1:n.tl,p2:t.tl},bottom:{p1:n.bl,p2:t.bl}}:{top:{p1:n.tr,p2:t.tr},bottom:{p1:n.br,p2:t.br}}}function R({frontPoints:n,backPoints:t}){const{isLeftSide:i}=x({frontPoints:n,backPoints:t});let e=f({},t);const r=H({frontPoints:n,backPoints:t}),o=_.lineIntersection({pointA:r.bottom.p1,pointB:r.bottom.p2},{pointA:r.top.p1,pointB:r.top.p2});if(i){const s=_.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:n.br,pointB:o});s&&(e=w(f({},t),{br:s,tr:{x:s.x,y:t.tl.y}}))}else{const s=_.lineIntersection({pointA:t.bl,pointB:t.br},{pointA:n.bl,pointB:o});s&&(e=w(f({},t),{bl:s,tl:{x:s.x,y:t.tr.y}}))}return{backPoints:e}}function T({frontPoints:n,backPoints:t}){const{isLeftSide:i,frontHeight:e,backHeight:r}=x({frontPoints:n,backPoints:t});let o=f({},t);return i?o=j({coord:t.bl,points:n}):o=M({coord:t.br,points:n}),e>r&&(o=R({frontPoints:n,backPoints:t}).backPoints),{frontPoints:n,backPoints:o}}function A({frontPoints:n,backPoints:t}){const{isLeftSide:i,frontHeight:e,backHeight:r,frontWidth:o,backWidth:s}=x({frontPoints:n,backPoints:t});let l=f({},n),c=t;return i||s>o?l=j({coord:n.bl,points:t}):l=M({coord:n.br,points:t}),e>r&&(l.tl.y=n.tl.y,l.tr.y=n.tr.y,c=R({backPoints:t,frontPoints:n}).backPoints),o>=s&&Object.keys(l).forEach(u=>{l[u].x=n[u].x}),{frontPoints:l,backPoints:c}}function K({frontPoints:n,backPoints:t}){return[{p1:n.bl,p2:t.bl},{p1:n.tl,p2:t.tl},{p1:n.tr,p2:t.tr},{p1:n.br,p2:t.br}]}function Z(n){const{frontPoints:t,backPoints:i}=n,{isLeftSide:e}=x(n),r=[{p1:t.tl,p2:t.tr,positions:[{plain:a.Front,position:p.TL},{plain:a.Front,position:p.TR}]},{p1:t.tr,p2:t.br,plain:a.Front,positions:[{plain:a.Front,position:p.TR},{plain:a.Front,position:p.BR}]},{p1:t.br,p2:t.bl,plain:a.Front,positions:[{plain:a.Front,position:p.BR},{plain:a.Front,position:p.BL}]},{p1:t.bl,p2:t.tl,plain:a.Front,positions:[{plain:a.Front,position:p.BL},{plain:a.Front,position:p.TL}]}];return e?[...r,{p1:i.tl,p2:i.bl,positions:[{plain:a.Back,position:p.TL},{plain:a.Back,position:p.BL}]}]:[...r,{p1:i.tr,p2:i.br,positions:[{plain:a.Back,position:p.TR},{plain:a.Back,position:p.BR}]}]}function $(n){const{backPoints:t}=n,{isLeftSide:i}=x(n),e=Object.entries(n.frontPoints).map(([r,o])=>({positions:[{plain:a.Front,position:r}],point:o}));return i?[{point:t.tl,positions:[{position:p.TL,plain:a.Back}]},{point:t.bl,positions:[{position:p.BL,plain:a.Back}]},...e]:[{point:t.tr,positions:[{position:p.TR,plain:a.Back}]},{point:t.br,positions:[{position:p.BR,plain:a.Back}]},...e]}function tt(n){const{frontPoints:t,backPoints:i}=n,{backCenter:e,frontCenter:r,frontHeight:o,frontWidth:s,backHeight:l,backWidth:c,isLeftSide:u}=x(n),h=Math.abs(s-c),y=Math.abs(o-l),g=Math.abs(r.x-e.x),O=Math.abs(r.y-e.y),d=g>h,b=O>y;return d||b?b&&!d?[t.tl,i.tl,i.tr,t.tr,t.br,t.bl]:d&&!b?u?[t.tl,t.tr,t.br,t.bl,i.bl,i.tl]:[t.tl,t.tr,i.tr,i.br,t.br,t.bl]:d&&b?u?[i.tl,i.tr,t.tr,t.br,t.bl,i.bl]:[t.tl,i.tl,i.tr,i.br,t.br,t.bl]:[]:[t.tl,t.tr,t.br,t.bl]}function W({offset:n,frontPoints:t,backPoints:i,positions:e}){let r=D(t),o=D(i);if((e==null?void 0:e.length)===2){const s=e.every(b=>b.plain===a.Front),l=!s,c=N([e[0],e[1]]),u=c===P.Row,h=c===P.Column;let y=n;u&&(y={x:0,y:n.y}),h&&(y={y:0,x:n.x}),s&&(e==null||e.forEach(({position:b})=>{const C=r,E=C[b];C[b]={x:E.x+y.x,y:E.y+y.y}}),r=F(r),o=F(o)),l&&Object.keys(o).forEach(b=>{o[b]={x:o[b].x+y.x,y:o[b].y+y.y}});const g=s?T:A,{frontPoints:O,backPoints:d}=g({frontPoints:r,backPoints:o});r=O,o=d}return{frontPoints:r,backPoints:o}}function nt({offset:n,cuboid:t}){const{frontPoints:i,backPoints:e}=t,r=Object.entries(i).reduce((s,[l,c])=>w(f({},s),{[l]:{x:c.x+n.x,y:c.y+n.y}}),{}),o=Object.entries(e).reduce((s,[l,c])=>w(f({},s),{[l]:{x:c.x+n.x,y:c.y+n.y}}),{});return{frontPoints:r,backPoints:o}}function it({offset:n,cuboid:t,positions:i}){const{frontPoints:e,backPoints:r}=t;return W({offset:n,frontPoints:e,backPoints:r,positions:i})}function et({offset:n,cuboid:t,positions:i}){if(!(i==null?void 0:i[0]))return;const{frontPoints:e,backPoints:r}=t,o=i[0],s=o.plain===a.Front,l=s?e:r;let c=l[o.position];const u=l[U[o.position]];if(!c||!u)return;c=G.add(c,n);const h=k(c,u),y=s?T:A;let g={frontPoints:e,backPoints:h};return s&&(g={frontPoints:h,backPoints:r}),y(g)}function ot({offset:n,cuboid:t,dragTarget:i,positions:e}){switch(i){case L.Cuboid:{const r=nt({offset:n,cuboid:t});return f(f({},t),r)}case L.Line:{const r=it({offset:n,cuboid:t,positions:e});return f(f({},t),r)}case L.Point:{const r=et({cuboid:t,offset:n,positions:e});if(r)return f(f({},t),r);break}default:{console.error("No DragTarget");break}}}function rt({direction:n,frontPoints:t,backPoints:i}){if(n&&t&&i){let e=t;switch(n){case B.Back:e=i;break;case B.Left:e={bl:i.bl,br:t.bl,tl:i.tl,tr:t.tl};break;case B.Right:e={bl:i.br,br:t.br,tl:i.tr,tr:t.tr};break;case B.Top:e={bl:i.tl,br:t.tl,tl:i.tr,tr:t.tr};break;default:e=t;break}return v.transformPlain2PointList(e)}}function st({cuboid:n,currentPos:t,zoom:i}){const{frontPoints:e}=n,r={width:40,height:74},o={x:(e.bl.x+e.tl.x)/2,y:(e.bl.y+e.tl.y)/2},s=r.width+10,l=r.height/2,c={x:o.x,y:o.y},u=v.getOffsetCoordinate(c,t,i);return{left:u.x-s,top:u.y-l}}function lt({cuboid:n,currentPos:t,zoom:i,leftOffset:e=16,topOffset:r=2}){const{frontPoints:o}=n,s={x:o.bl.x,y:o.bl.y},l=v.getOffsetCoordinate(s,t,i);return{left:l.x+e,top:l.y+r}}function at({cuboid:n,config:t}){const{minHeight:i,minWidth:e}=t,{width:r,height:o}=m(n.frontPoints);return r>=e&&o>=i}export{T as getBackPointsByFrontPoints,K as getCuboidAllSideLine,x as getCuboidBasicInfo,ot as getCuboidDragMove,tt as getCuboidHoverRange,H as getCuboidShowingSideLine,lt as getCuboidTextAttributeOffset,A as getFrontPointsByBackPoints,Z as getHighlightLines,$ as getHighlightPoints,F as getMaxExternalQuadrilateral,W as getNewPointsAfterOffset,k as getPlainPointsByDiagonalPoints,m as getPlanePointsBasicInfo,rt as getPointListsByDirection,j as getPointsByBottomLeftPoint,M as getPointsByBottomRightPoint,R as getPointsByIntersection,st as getToggleDirectionButtonOffset,at as isCuboidWithInLimits,N as judgeCuboidLineIsRowOrColumn};
@@ -0,0 +1 @@
1
+ import n from"./AxisUtils.js";class m{constructor(e,s){this.rcTime=0,this.mouseDownTime=0,this.onMouseDown=()=>{this.mouseDownTime=new Date().getTime()},this.dom=e,this.isDoubleClick=!1,this.delay=s}getRcTime(){return this.rcTime}getCoord(e){return{x:e.clientX,y:e.clientY}}removeEvent(){!this.dom||(this.dom.removeEventListener("mouseup",this.mouseUp),this.dom.removeEventListener("mousemove",this.mouseMove),this.dom.removeEventListener("dblclick",this.dblclick),this.dom.removeEventListener("mousedown",this.onMouseDown))}addEvent(e,s,c,o){!this.dom||(this.removeEvent(),this.mouseUp=i=>{const t=new Date().getTime(),h=o?o(i):!0;if(t-this.mouseDownTime>this.delay||h!==!0){e(i);return}if(i.button===2)if(this.rcTime===0)setTimeout(()=>{this.rcTime=0},this.delay),this.rcTime=t;else{t-this.rcTime<this.delay&&(c(i),clearTimeout(this.setTimeFun),this.cacheFunction=void 0),this.rcTime=0;return}this.setTimeFun&&clearTimeout(this.setTimeFun),this.clickCoord=this.getCoord(i),this.cacheFunction=()=>e(i),this.setTimeFun=setTimeout(()=>{if(this.isDoubleClick){this.isDoubleClick=!1;return}this.cacheFunction(),this.clickCoord=void 0},this.delay)},this.mouseMove=i=>{const t=this.getCoord(i);this.clickCoord&&!n.getIsInScope(t,this.clickCoord,10)&&(this.cacheFunction&&this.cacheFunction(),this.clickCoord=void 0,this.cacheFunction=null,clearTimeout(this.setTimeFun))},this.dblclick=i=>{this.isDoubleClick=!0,this.clickCoord=void 0,s(i)},this.dom.addEventListener("mouseup",this.mouseUp),this.dom.addEventListener("mousemove",this.mouseMove),this.dom.addEventListener("dblclick",this.dblclick),this.dom.addEventListener("mousedown",this.onMouseDown))}clearRightDblClick(){this.rcTime=0}}export{m as default};
@@ -0,0 +1,3 @@
1
+ import{ELineTypes as P,SEGMENT_NUMBER as p,DEFAULT_FONT as O}from"../../constant/tool.js";import b from"./PolygonUtils.js";import T from"./UnitUtils.js";import S from"./AxisUtils.js";import{getCuboidAllSideLine as D,getPointListsByDirection as W,getCuboidTextAttributeOffset as F}from"./CuboidUtils.js";import M from"./AttributeUtils.js";var U=Object.defineProperty,I=Object.defineProperties,R=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,k=(r,t,i)=>t in r?U(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,m=(r,t)=>{for(var i in t||(t={}))$.call(t,i)&&k(r,i,t[i]);if(v)for(var i of v(t))L.call(t,i)&&k(r,i,t[i]);return r},A=(r,t)=>I(r,R(t));const j=1,B={x:0,y:0},X=0,u="",x=class{static drawLine(r,t,i,e={}){const o=r.getContext("2d"),{color:l=u,thickness:s=1,lineCap:a="round",lineDash:d}=e;o.save(),o.strokeStyle=l,o.lineWidth=s,o.lineCap=a,d&&o.setLineDash(d),o.beginPath(),o.moveTo(t.x,t.y),o.lineTo(i.x+1,i.y+1),o.stroke(),o.restore()}static drawRect(r,t,i={}){const e=r.getContext("2d"),{color:o=u,thickness:l=1,lineCap:s="round",hiddenText:a=!1,lineDash:d}=i;if(e.save(),e.strokeStyle=o,e.lineWidth=l,e.lineCap=s,Array.isArray(d)&&e.setLineDash(d),e.fillStyle=o,e.strokeRect(t.x,t.y,t.width,t.height),a===!1){let n="";if(t.attribute&&(n=`${n} ${t.attribute}`),this.drawText(r,{x:t.x,y:t.y-5},n),t.textAttribute){const c=`${~~t.width} * ${~~t.height}`.length*7,w=0,y=Math.max(20,t.width-c);this.drawText(r,{x:t.x,y:t.y+t.height+20+w},t.textAttribute,{textMaxWidth:y})}}e.restore()}static drawRectWithFill(r,t,i={}){const e=r.getContext("2d"),{color:o=u}=i;e.save(),e.fillStyle=o,e.fillRect(t.x,t.y,t.width,t.height),e.restore()}static drawTagByDom(r,t,i){const e=r;if(!((t==null?void 0:t.length)>0))return;const o=document.createElement("div");return o.innerHTML=t,o.setAttribute("id",i),e==null||e.appendChild(o),o}static drawTag(r,t){var i;const e=r==null?void 0:r.parentNode,o=window.self.document.getElementById("tagToolTag");if(o&&e&&e.contains(o)&&(e==null||e.removeChild(o)),!((t==null?void 0:t.length)>0))return;const l=document.createElement("div");return l.innerHTML=(i=t.reduce((s,a)=>`${s}${a.keyName}: ${a.value.join(" \u3001 ")}
2
+ `,""))!=null?i:"",l.setAttribute("id","tagToolTag"),e==null||e.appendChild(l),l}static drawLineWithPointList(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=u,thickness:l=1,lineCap:s="round",lineType:a=P.Line,lineDash:d,hoverEdgeIndex:n}=i;e.save(),(()=>{e.strokeStyle=o,e.lineWidth=l,e.lineCap=s,Array.isArray(d)?e.setLineDash(d):e.setLineDash([])})(),a===P.Curve?(n!==void 0&&n>-1&&t.push(t[0]),t=b.createSmoothCurvePointsFromPointList([...t],p),n!==void 0&&n>-1&&(t=t.slice((p+1)*n,(p+1)*(n+1)))):n!==void 0&&n>-1&&(t=[...t,t[0]],t=t.slice(n,n+2));const c=[];e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let h=0;h<t.length-1;h++)t[h].specialEdge&&c.push({i1:h,i2:h+1}),e.lineTo(t[h+1].x,t[h+1].y);e.stroke(),e.save(),e.lineWidth=l*.8,e.lineCap="butt",e.strokeStyle="white",e.setLineDash([3,3]),c.forEach(h=>{const g=t[h.i1],C=t[h.i2];e.beginPath(),e.moveTo(g.x,g.y),e.lineTo(C.x,C.y),e.stroke()}),e.restore();const w=4,y=2;return t.forEach(h=>{h.specialPoint&&(this.drawSpecialPoint(r,h,w+y,o),this.drawSpecialPoint(r,h,w,"white"))}),e.restore(),t}static drawCircle(r,t,i,e={}){const o=r.getContext("2d"),{startAngleDeg:l=0,endAngleDeg:s=360,thickness:a=1,color:d=u,fill:n=u}=e,f=T.deg2rad(l),c=T.deg2rad(s);o.save(),o.beginPath(),o.strokeStyle=d,o.fillStyle=n,o.lineWidth=a,o.arc(t.x,t.y,i,f,c,!1),o.stroke(),n&&o.fill(),o.closePath(),o.restore()}static drawCircleWithFill(r,t,i=3,e={}){const o=r.getContext("2d"),{color:l=u}=e;o.save();const s=T.deg2rad(0),a=T.deg2rad(360);o.fillStyle=l,o.beginPath(),o.arc(t.x,t.y,i,s,a,!1),o.fill(),o.restore()}static drawSpecialPoint(r,t,i=6,e){const o=r.getContext("2d"),{x:l,y:s}=t;o.save(),o.beginPath(),o.fillStyle=e;const a=i*1.5,d=a*Math.sqrt(3)/2,n=a/2;o.moveTo(l,s-a),o.lineTo(l-d,s+n),o.lineTo(l+d,s+n),o.closePath(),o.fill(),o.restore()}static drawPolygon(r,t,i={}){const{isClose:e=!1,lineType:o=P.Line}=i;return e===!0&&(t=[...t,t[0]]),o===P.Curve&&(t=b.createSmoothCurvePointsFromPointList([...t])),this.drawLineWithPointList(r,t,A(m({},i),{lineType:P.Line})),t}static drawPolygonWithFill(r,t,i={}){if(t.length<2)return;const e=r.getContext("2d"),{color:o=u,lineType:l=P.Line}=i;e.save(),e.fillStyle=o,e.beginPath(),l===P.Curve&&(t=b.createSmoothCurvePointsFromPointList([...t,t[0]]));const[s,...a]=t;return e.moveTo(s.x,s.y),a.forEach(d=>{e.lineTo(d.x,d.y)}),e.fill(),e.restore(),t}static drawPolygonWithFillAndLine(r,t,i={}){const{strokeColor:e,fillColor:o,thickness:l,lineCap:s,isClose:a,lineType:d}=i,n=this.drawPolygon(r,t,{color:e,thickness:l,lineCap:s,isClose:a,lineType:d});return this.drawPolygonWithFill(r,t,{color:o,lineType:d}),n}static drawPolygonWithKeyPoint(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,l=this.drawPolygon(r,t,i);return l.forEach(s=>{this.drawCircleWithFill(r,s,4,{color:o}),this.drawCircleWithFill(r,s,3,{color:e})}),l}static drawSelectedPolygonWithFillAndLine(r,t,i={}){const{pointColor:e="white",strokeColor:o}=i,l=this.drawPolygonWithFillAndLine(r,t,i);return l.forEach(s=>{this.drawCircleWithFill(r,s,4,{color:o}),this.drawCircleWithFill(r,s,3,{color:e})}),l}static drawText(r,t,i,e={}){if(!i)return;const o=r.getContext("2d"),{color:l=u,font:s=O,shadowColor:a="",shadowBlur:d=0,shadowOffsetX:n=0,shadowOffsetY:f=0,textMaxWidth:c=164,offsetX:w=0,offsetY:y=0,textAlign:h="start",lineHeight:g}=e;o.save(),o.textAlign=h,o.fillStyle=l!=null?l:"white",o.font=s,o.shadowColor=a,o.shadowOffsetX=n,o.shadowOffsetY=f,o.shadowBlur=d,this.wrapText(r,`${i}`,t.x+w,t.y+y,c,g),o.restore()}static wrapText(r,t,i,e,o,l){if(typeof t!="string"||typeof i!="number"||typeof e!="number")return;const s=r.getContext("2d");typeof o=="undefined"&&(o=r&&r.width||300),typeof l=="undefined"&&(l=r&&parseInt(window.getComputedStyle(r).lineHeight,10)||parseInt(window.getComputedStyle(document.body).lineHeight,10));const a=t.split(`
3
+ `);for(let d=0;d<a.length;d++){const n=a[d].split("");let f="";for(let c=0;c<n.length;c++){const w=f+n[c],h=s.measureText(w).width;o||(o=300),h>o&&c>0?(s.fillText(f,i,e),f=n[c],e+=l):f=w}s.fillText(f,i,e),e+=l}}static drawArrow(r,t,i,e={}){const{color:o=u,thickness:l=1,lineCap:s="round",theta:a=30,headLen:d=10}=e,n=Math.atan2(t.y-i.y,t.x-i.x)*180/Math.PI,f=(n+a)*Math.PI/180,c=(n-a)*Math.PI/180,w=d*Math.cos(f),y=d*Math.sin(f),h=d*Math.cos(c),g=d*Math.sin(c);r.save(),r.strokeStyle=o,r.lineWidth=l,r.lineCap=s,r.beginPath(),r.moveTo(i.x+w,i.y+y),r.lineTo(i.x,i.y),r.lineTo(i.x+h,i.y+g),r.stroke(),r.restore()}static drawArrowByCanvas(r,t,i,e={}){const o=r.getContext("2d");this.drawArrow(o,t,i,e)}static drawCuboid(r,t,i={}){const{backPoints:e,direction:o,frontPoints:l}=t,{strokeColor:s,thickness:a,fillColor:d}=i,n={color:s,thickness:a};if(e){const c=S.transformPlain2PointList(e);x.drawPolygon(r,c,A(m({},n),{isClose:!0}));const w=D(t);w==null||w.forEach(y=>{x.drawLine(r,y.p1,y.p2,m({},n))})}const f=S.transformPlain2PointList(l);if(o&&e&&l){const c=W({direction:o,frontPoints:l,backPoints:e});c&&x.drawPolygonWithFill(r,c,{color:d})}x.drawPolygon(r,f,A(m({},n),{isClose:!0}))}static drawCuboidWithText(r,t,i,e){const{strokeColor:o}=i,l=o,{config:s,hiddenText:a,selectedID:d,headerText:n,bottomText:f}=e,{backPoints:c,frontPoints:w,textAttribute:y}=t,h=w.br.x-w.bl.x;x.drawCuboid(r,t,i);let g="";(s==null?void 0:s.isShowOrder)&&t.order&&(t==null?void 0:t.order)>0&&(g=`${t.order}`),t.attribute&&(g=`${g} ${M.getAttributeShowText(t.attribute,s==null?void 0:s.attributeList)}`),!a&&c&&g&&x.drawText(r,{x:c.tl.x,y:c.tl.y-5},n!=null?n:g,{color:o,textMaxWidth:300});const C=F({cuboid:t,currentPos:{x:0,y:0},zoom:1,topOffset:16,leftOffset:0});if(!a&&y&&t.id!==d){const E=Math.max(20,h*.8);x.drawText(r,{x:C.left,y:C.top},f!=null?f:y,{color:l,textMaxWidth:E})}}};let _=x;_.drawImg=(r,t,i={})=>{const e=r.getContext("2d"),{zoom:o=j,currentPos:l=B,rotate:s=X,imgAttribute:a}=i;switch(e.save(),s){case 0:e.translate(l.x,l.y);break;case 90:e.translate(l.x+t.height*o,l.y),e.rotate(90*Math.PI/180);break;case 180:e.translate(l.x+t.width*o,l.y+t.height*o),e.rotate(Math.PI);break;case 270:e.translate(l.x,l.y+t.width*o),e.rotate(270*Math.PI/180);break;default:e.translate(l.x,l.y);break}if(a){const{contrast:d,saturation:n,brightness:f}=a;e.filter=`saturate(${n+100}%) contrast(${d+100}%) brightness(${f+100}%)`}e.drawImage(t,0,0,t.width*o,t.height*o),e.restore()};export{_ as default};
@@ -0,0 +1 @@
1
+ import{EToolName as o,ECheckModel as n}from"../../constant/tool.js";import i from"../../core/toolOperation/ScribbleTool.js";import a from"../../core/toolOperation/cuboidOperation.js";import p from"../../core/toolOperation/pointCloud2dOperation.js";import c from"../../core/toolOperation/checkOperation.js";import l from"../../core/toolOperation/polygonOperation.js";import{RectOperation as m}from"../../core/toolOperation/rectOperation.js";import s from"../../core/toolOperation/tagOperation.js";import O from"../../core/toolOperation/LineToolOperation.js";import u from"../../core/toolOperation/pointOperation.js";import T from"../../core/toolOperation/TextToolOperation.js";import f from"../../core/toolOperation/segmentByRect.js";import j from"./CommonToolUtils.js";const e=t=>{switch(t){case o.Rect:case o.RectTrack:return m;case o.SegmentByRect:return f;case o.Tag:return s;case o.Polygon:return l;case n.Check:return c;case o.Line:return O;case o.Point:return u;case o.Text:return T;case o.ScribbleTool:return i;case o.Cuboid:return a;case o.PointCloudPolygon:return p;default:throw new Error("not match tool")}};class r extends j{}r.getCurrentOperation=e;export{r as default,e as getCurrentOperation};
@@ -0,0 +1 @@
1
+ class x{static getInitImgPos(n,t,h=0,c=1,r=!1){(h===90||h===270)&&(t={width:t.height,height:t.width});const d=n.width*c/t.width,i=n.height*c/t.height;let o=r?1:Math.min(d,i);const e={x:(n.width-t.width*o)/2,y:(n.height-t.height*o)/2},s=t.width*o,w=t.height*o;return r&&(o=1),{zoom:o,currentPos:e,imgInfo:{width:s,height:w}}}static getBasicRecPos(n,t,h,c=.9,r=1,d=!1){if(t&&n){const{x:i,y:o,height:e,width:s}=t;let w=h.height/e;s/e>h.width/h.height&&(w=h.width/s);const l=d?1:w*c*r,f={x:h.width/2,y:h.height/2},g={x:(i+s/2)*l,y:(o+e/2)*l};return{currentPos:{x:f.x-g.x,y:f.y-g.y},innerZoom:l}}return!1}}export{x as default};
@@ -0,0 +1 @@
1
+ import{EToolName as B,ELineTypes as R}from"../../constant/tool.js";import{createSmoothCurvePointsFromPointList as N}from"./polygonTool.js";import M from"./PolygonUtils.js";import O from"../MathUtils.js";var F=Object.defineProperty,S=Object.defineProperties,W=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,E=(t,n,o)=>n in t?F(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,x=(t,n)=>{for(var o in n||(n={}))q.call(n,o)&&E(t,o,n[o]);if(b)for(var o of b(n))V.call(n,o)&&E(t,o,n[o]);return t},C=(t,n)=>S(t,W(n)),D;(function(t){t[t.Create=0]="Create",t[t.Active=1]="Active",t[t.Edit=1]="Edit",t[t.None=2]="None"})(D||(D={}));var I;(function(t){t.ActiveArea="#B3B8FF"})(I||(I={}));const L=16,G=3,f=class{static isInLine(t,n,o,i=3){const{length:r}=O.getFootOfPerpendicular(t,n,o);return r<i}};let p=f;p.setSpecialEdgeStyle=t=>{t.lineCap="butt",t.setLineDash([10,10])},p.setReferenceCtx=t=>{t.lineCap="butt",t.setLineDash([6])},p.calcOptimalIntersection=(t,n,o,i,r)=>{let c,y=Infinity,a;if(t.find((g,e)=>{if(e===0)return;const s=f.isInLine(n.pointA,g,t[e-1]),l=f.isInLine(n.pointB,g,t[e-1]);return s&&l}))return{point:o};if(t.forEach((g,e)=>{if(e===0)return;const s={pointA:t[e-1],pointB:g},l=f.lineIntersection(n,s);if(l&&n){const{onLine2:P,onLine1:h,x:m,y:_}=l,v=f.calcDistance(o,l);if(f.isOnLine(n.pointB.x,n.pointB.y,g.x,g.y,t[e-1].x,t[e-1].y)){if(f.calcDistance(o,l)<i/r){const T=n.pointB,{footPoint:A,length:w}=O.getFootOfPerpendicular(T,s.pointA,s.pointB,!0);if(w!==void 0){const j=f.calcDistance(s.pointA,A),U=f.calcDistance(s.pointB,A);a={point:A,minDistance:w},w===Infinity&&(a.point=j>U?s.pointB:s.pointA)}}return}v<y&&P&&h&&(y=v,c={x:m,y:_})}}),c)return{point:c,minDistance:y};if(a)return a},p.lineIntersection=(t,n)=>{let o=!1,i=!1;const r=f.getAxisDiff(t),c=f.getAxisDiff(n),y=c.y*r.x-c.x*r.y;if(y===0)return!1;let a=t.pointA.y-n.pointA.y,u=t.pointA.x-n.pointA.x;const g=(n.pointB.x-n.pointA.x)*a-(n.pointB.y-n.pointA.y)*u,e=(t.pointB.x-t.pointA.x)*a-(t.pointB.y-t.pointA.y)*u;a=g/y,u=e/y,a>0&&a<1&&(o=!0),u>0&&u<1&&(i=!0);const s=t.pointA.x+a*(t.pointB.x-t.pointA.x),l=t.pointA.y+a*(t.pointB.y-t.pointA.y);return{x:s,y:l,onLine1:o,onLine2:i}},p.getAxisDiff=t=>({x:t.pointB.x-t.pointA.x,y:t.pointB.y-t.pointA.y}),p.calcDistance=(t,n)=>Math.sqrt(Math.pow(Math.abs(t.x-n.x),2)+Math.pow(Math.abs(t.y-n.y),2)),p.drawCurveLine=(t,n,o,i=!0,r=!1,c)=>{const y=N(n,L);t.save(),t.lineCap="round",t.lineJoin="round",t.strokeStyle=o.color,i&&(t.lineWidth=o.lineWidth),r&&f.setReferenceCtx(t),n.forEach((a,u)=>{const g=a==null?void 0:a.specialEdge,e=y.splice(0,L+1);t.save(),t.beginPath(),c===u&&(t.lineWidth=4),e.forEach(({x:s,y:l},P)=>{const h=P>0?"lineTo":"moveTo";g&&f.setSpecialEdgeStyle(t),t[h](s,l)}),t.stroke(),t.restore()}),t.restore()},p.calcTwoPointDistance=(t,n)=>Math.sqrt(Math.pow(t.x-n.x,2)+Math.pow(t.y-n.y,2)),p.pointOverTarget=(t,n,o,i,r,c,y,a,u,g)=>{const e=t;if(!n)return t;if(o===B.Polygon){const s=f.getPolygonPointList(i,r);if(s.length===0||M.isInPolygon(t,s))return e;const P=s.concat(s[0]).map(d=>u(d)),h=u(n),m=u(t),_={pointA:h,pointB:m},v=f.calcOptimalIntersection(P,_,h,y,a);if(v){const d=g(v==null?void 0:v.point);e.x=d.x,e.y=d.y}else return n;return e}if(o===B.Rect){const{x:s,y:l,width:P,height:h}=i;return e.x=O.withinRange(e.x,[s,s+P]),e.y=O.withinRange(e.y,[l,l+h]),e}return e.x=O.withinRange(e.x,[0,c.width]),e.y=O.withinRange(e.y,[0,c.height]),e},p.getPolygonPointList=(t,n)=>{const{pointList:o}=t,{lineType:i}=n;return i===R.Line?o:M.createSmoothCurvePoints(o.reduce((r,c)=>[...r,c.x,c.y],[]),.5,!0,20)},p.isOnLine=(t,n,o,i,r,c)=>Math.abs((a=>(i-n)/(o-t)*(a-t)+n)(r)-c)<1e-6&&r>=t&&r<=o,p.inArea=({top:t,left:n,right:o,bottom:i},{x:r,y:c})=>c>=t&&c<=i&&r>=n&&r<=o,p.getVHPoint=(t,n,o,i)=>{const r=f.getAngle(t,o);return Math.abs(r)<45?C(x({},n),{y:i.y}):C(x({},n),{x:i.x})},p.getAngle=(t,n)=>{const o=n.x-t.x,i=n.y-t.y;return 360*Math.atan(i/o)/(2*Math.PI)};export{I as EColor,D as EStatus,G as POINT_RADIUS,L as SEGMENT_NUMBER,p as default};
@@ -0,0 +1 @@
1
+ import{cloneDeep as c}from"lodash";import f from"./AttributeUtils.js";class u{static getMarkerShowText(t,r=[]){return f.getAttributeShowText(t,r)}}u.getAuxiliaryLineByMarkerList=(o,t)=>{var r;const s=c(o),l=[];let e=s.shift();for(;e;)(r=e.target)==null||r.forEach(n=>{const i=s.find(a=>a.value===n);i&&(e==null?void 0:e[t])&&l.push({start:e[t],end:i[t]})}),e=s.shift();return l},u.getAuxiliaryLineCoord=(o,t)=>{const r=[];return o.forEach(s=>{const{start:l,end:e}=s,n=t.find(a=>a.label===l);if(!n)return;const i=t.find(a=>a.label===e);!i||r.push({start:{x:n.x,y:n.y},end:{x:i.x,y:i.y}})}),r};export{u as default};
@@ -0,0 +1 @@
1
+ import{polygon as S,difference as _,union as j}from"@turf/turf";import{ERotateDirection as B}from"../../constant/annotation.js";import F from"./CommonToolUtils.js";import{ELineTypes as y,SEGMENT_NUMBER as M}from"../../constant/tool.js";import D from"./AxisUtils.js";import C from"../MathUtils.js";import z from"./LineToolUtils.js";var N=Object.defineProperty,b=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,O=(p,t,e)=>t in p?N(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,A=(p,t)=>{for(var e in t||(t={}))R.call(t,e)&&O(p,e,t[e]);if(b)for(var e of b(t))T.call(t,e)&&O(p,e,t[e]);return p};class g{static getHoverPolygonID(t,e,n=3,i=y.Line){let r="",l=Infinity;const o=D.axisArea(t,n);return e.forEach(s=>{s.pointList&&o.forEach(c=>{const u=this.calcPolygonSize(s.pointList);this.isInPolygon(c,s.pointList,i)&&u<l&&(r=s.id,l=u)})}),r}static calcPolygonSize(t=[]){if((t==null?void 0:t.length)<=2)return 0;const e=t.length,n=t.reduce((i,r,l,o)=>{const s=o[(l+1)%e];return i+r.x*s.y-s.x*r.y},0);return Math.abs(n)/2}static isInPolygon(t,e,n=y.Line){let i=0,r,l,o,s;e=[...e],n===y.Curve&&(e=this.createSmoothCurvePoints(e.reduce((u,h)=>[...u,h.x,h.y],[]),.5,!0,20)),[o]=e;const c=e.length;for(r=1;r<=c;r++)s=e[r%c],t.x>Math.min(o.x,s.x)&&t.x<=Math.max(o.x,s.x)&&t.y<=Math.max(o.y,s.y)&&o.x!==s.x&&(l=(t.x-o.x)*(s.y-o.y)/(s.x-o.x)+o.y,(o.y===s.y||t.y<=l)&&i++),o=s;return i%2!=0}static createSmoothCurvePointsFromPointList(t,e=M){return this.createSmoothCurvePoints(t.reduce((i,r)=>[...i,r.x,r.y],[]),.5,!1,e).map((i,r)=>{var l;const o=r/(M+1),s=Math.floor(o),c=(l=t[s])!=null?l:{};return A(s===o?A({},c):{specialEdge:c.specialEdge},i)})}static createSmoothCurvePoints(t,e=.5,n=!1,i=M){if(t.length<4)return t;const r=[],l=t.slice(0);let o,s,c,u,h,m,v,L,P,E,a,d,f;for(n?(l.unshift(t[t.length-1]),l.unshift(t[t.length-2]),l.unshift(t[t.length-1]),l.unshift(t[t.length-2]),l.push(t[0]),l.push(t[1])):(l.unshift(t[1]),l.unshift(t[0]),l.push(t[t.length-2]),l.push(t[t.length-1])),f=2;f<l.length-4;f+=2)for(c=(l[f+2]-l[f-2])*e,u=(l[f+4]-l[f-0])*e,h=(l[f+3]-l[f-1])*e,m=(l[f+5]-l[f+1])*e,d=0;d<=i;d++)a=d/i,v=2*Math.pow(a,3)-3*Math.pow(a,2)+1,L=-(2*Math.pow(a,3))+3*Math.pow(a,2),P=Math.pow(a,3)-2*Math.pow(a,2)+a,E=Math.pow(a,3)-Math.pow(a,2),o=v*l[f]+L*l[f+2]+P*c+E*u,s=v*l[f+1]+L*l[f+3]+P*h+E*m,r.push(o),r.push(s);const I=[];for(let x=0;x<r.length-1;x+=2)I.push({x:r[x],y:r[x+1]});if(n)for(let x=0;x<i+1;x++){const w=I.shift();I.push(w)}return I}static getPolygonByID(t,e){return t.find(n=>n.id===e)}static getPolygonByIDs(t,e){if(e&&(e==null?void 0:e.length)>0)return t.filter(n=>e.includes(n.id))}static getHoverEdgeIndex(t,e,n=y.Line,i=3){let r=[...e];n===y.Curve?r=this.createSmoothCurvePoints(e.reduce((s,c)=>[...s,c.x,c.y],[]),.5,!0,M):n===y.Line&&r.push(r[0]);let l=-1,o=i;for(let s=0;s<r.length-1;s++){const{length:c}=C.getFootOfPerpendicular(t,r[s],r[s+1]);c<o&&(l=s,o=c)}return l===-1?-1:n===y.Curve?Math.floor(l/M):l}static getClosestPoint(t,e,n=y.Line,i=3,r){var l;let o=!1;const s=(l=r==null?void 0:r.isClose)!=null?l:!0;let c="",u=-1,h=Infinity,m=t;const v=20;let L=!1;return e.forEach(P=>{if(!L&&!!P.pointList)switch(n){case y.Line:F.findAllLine(P.pointList,s).forEach((a,d)=>{if(L)return;let{length:f,footPoint:I}=C.getFootOfPerpendicular(t,a.point1,a.point2);const x=C.getLineLength(a.point1,t),w=C.getLineLength(a.point2,t);x<i*2&&(I=a.point1,f=x,L=!0),w<i*2&&(I=a.point2,f=w,L=!0),f<h&&f<i&&(c=P.id,u=d,h=f,m=I,o=!0)});break;case y.Curve:{const E=this.createSmoothCurvePoints(P.pointList.reduce((a,d)=>[...a,d.x,d.y],[]),.5,s,v);for(let a=0;a<E.length-1;a++){const{length:d,footPoint:f}=C.getFootOfPerpendicular(t,E[a],E[a+1]);d<h&&d<i&&(c=P.id,u=Math.floor(a/(v+1)),h=d,m=f,o=!0)}}break}}),{dropFoot:m,closestEdgeIndex:u,closestPolygonID:c,hasClosed:o}}static isPointListInPolygon(t,e,n=y.Line){return t.every(i=>this.isInPolygon(i,e,n))}static isPointListOutSidePolygon(t,e,n=y.Line){return t.some(i=>!this.isInPolygon(i,e,n))}static getPolygonArea(t){let e=0;for(let n=0,i=t.length;n<i;n++){const r=t[n].x,l=t[n===t.length-1?0:n+1].y,o=t[n===t.length-1?0:n+1].x,s=t[n].y;e+=r*l*.5,e-=o*s*.5}return Math.abs(e)}static updatePolygonByRotate(t,e=1,n){let i=1;return t===B.Anticlockwise&&(i=-1),i*=e,C.rotateRectPointList(i,n)}static deletePolygonLastPoint(t,e,n,i){return n===i.length-1?t:[...t,{x:e[0],y:e[1]}]}static concatBeginAndEnd(t){return t.length<1?t:[...t,t[0]]}static segmentPolygonByPolygon(t,e){var n,i;try{let r=S([[...g.concatBeginAndEnd(t.map(o=>[o.x,o.y]))]]);return e.forEach(o=>{const s=S([[...g.concatBeginAndEnd(o.pointList.map(u=>[u.x,u.y]))]]),c=_(r,s);c&&(r=c)}),((i=(n=r==null?void 0:r.geometry)==null?void 0:n.coordinates.map(o=>{var s;return((s=r==null?void 0:r.geometry)==null?void 0:s.type)==="MultiPolygon"?o[0].reduce(g.deletePolygonLastPoint,[]):o.reduce(g.deletePolygonLastPoint,[])}))!=null?i:[]).reduce((o,s)=>{const c=s.length,u=s.filter((h,m)=>{const v=(m+1)%c;return!D.getIsInScope(h,s[v],1)});return u.length<3?o:[...o,u]},[])}catch(r){console.error(r)}}static getPolygonPointList(t,e){const n=e.find(i=>i.id===t);return n&&n.pointList&&n.pointList.length>0?n.pointList:[]}static getWrapPolygonIndex(t,e){return e.findIndex(n=>g.isPointListInPolygon(t,n.pointList))}static clipPolygonFromWrapPolygon(t,e){const n=g.isPolygonClosewise(e),i=g.isPolygonClosewise(t),r=g.getClosePointDistanceFromPolygon(t[0],e),l=e[r];let o=[...e.slice(0,r),l,...t,t[0],...e.slice(r,e.length)];return n===i&&(o=[...e.slice(0,r),l,t[0],...t.reverse(),...e.slice(r,e.length)]),o}static isPolygonClosewise(t){const e=t.length;let n,i,r,l=0,o;if(e<3)return 0;for(n=0;n<e;n++)i=(n+1)%e,r=(n+2)%e,o=(t[i].x-t[n].x)*(t[r].y-t[i].y),o-=(t[i].y-t[n].y)*(t[r].x-t[i].x),o<0?l--:o>0&&l++;return l>0?1:l<0?-1:0}static getClosePointDistanceFromPolygon(t,e){let n=Number.MAX_SAFE_INTEGER,i=-1;return e.forEach((r,l)=>{const o=z.calcDistance(t,r);o<n&&(n=o,i=l)}),i}static combinePolygonWithPolygon(t,e){var n,i;try{const r=S([[...g.concatBeginAndEnd(t.pointList.map(u=>[u.x,u.y]))]]),l=S([[...g.concatBeginAndEnd(e.pointList.map(u=>[u.x,u.y]))]]),o=j(r,l),s=[],c=t;if(((i=(n=o==null?void 0:o.geometry)==null?void 0:n.coordinates)==null?void 0:i.length)===1){s.push(e.id);const u=o==null?void 0:o.geometry.coordinates.map(h=>{var m;return((m=o==null?void 0:o.geometry)==null?void 0:m.type)==="MultiPolygon"?h[0].reduce(g.deletePolygonLastPoint,[]):h.reduce(g.deletePolygonLastPoint,[])})[0];c.pointList=u}return{newPolygon:c,unionList:s}}catch(r){console.error(r)}}}export{g as default};
@@ -0,0 +1 @@
1
+ import p from"./AxisUtils.js";import f from"./CommonToolUtils.js";import{isInPolygon as d}from"./polygonTool.js";var P=Object.defineProperty,_=Object.defineProperties,w=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable,x=(a,t,e)=>t in a?P(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,h=(a,t)=>{for(var e in t||(t={}))O.call(t,e)&&x(a,e,t[e]);if(u)for(var e of u(t))R.call(t,e)&&x(a,e,t[e]);return a},l=(a,t)=>_(a,w(t));class v{static composeResult(t,e,r,n,s){try{const i=JSON.parse(t),o=f.getCurrentStepInfo(e,n),{dataSourceStep:y}=o,g=`step_${o.step}`;if(Object.assign(i,s),i[g]){const c=i[g];return c.result?(c.result=r,JSON.stringify(i)):JSON.stringify(l(h({},i),{[g]:l(h({},i[g]),{result:r})}))}return JSON.stringify(l(h({},i),{[g]:{dataSourceStep:y,toolName:o.tool,result:r}}))}catch(i){return t}}static changeCoordinateByRotate(t,e,r){const{x:n,y:s,width:i,height:o}=t,y=p.changeCoordinateByRotate({x:n,y:s},e,r);switch(e%360){case 90:return l(h({},t),{x:y.x-o,y:y.y,width:o,height:i});case 180:return l(h({},t),{x:y.x-i,y:y.y-o});case 270:return l(h({},t),{x:y.x,y:y.y-i,width:o,height:i});default:return t}}static translateRect2Points(t){const{x:e,y:r,width:n,height:s}=t;return[{x:e,y:r},{x:e+n,y:r},{x:e+n,y:r+s},{x:e,y:r+s}]}static translatePoints2Rect(t,e){if(t.length!==4)return;const{x:r,y:n}=t[0],s=t[1].x-t[0].x,i=t[2].y-t[1].y;return l(h({},e),{x:r,y:n,width:s,height:i})}static getRectPointList(t,e=1){return[{x:t.x*e,y:t.y*e},{x:(t.x+t.width)*e,y:t.y*e},{x:(t.x+t.width)*e,y:(t.y+t.height)*e},{x:t.x*e,y:(t.y+t.height)*e}]}static getRectEdgeList(t,e=1){const r=this.getRectPointList(t,e),n=r.length;return r.map((s,i)=>({begin:s,end:r[(i+1)%n]}))}static isInRect(t,e,r=0,n=1){return t.x>=e.x*n-r&&t.x<=(e.x+e.width)*n+r&&t.y>=e.y*n-r&&t.y<=(e.y+e.height)*n+r}static getRectUnderZoom(t,e=1){const{x:r,y:n,width:s,height:i}=t;return l(h({},t),{x:r*e,y:n*e,width:s*e,height:i*e})}static isRectNotInPolygon(t,e){return this.getRectPointList(t).some(n=>!d(n,e))}}export{v as default};
@@ -0,0 +1,20 @@
1
+ import d from"./DrawUtils.js";import c from"./StyleUtils.js";class p{constructor(t){this._domMap=new Map,this._container=t.container,this._height=t.height}wheelChange(t){t.stopPropagation()}clearTag(t){const o=this._container,a=window.self.document.getElementById(t);a&&o&&o.contains(a)&&(a.removeEventListener("wheel",this.wheelChange),o==null||o.removeChild(a))}render(t){const o=Array.from(this._domMap.keys()),a=t.map(e=>e.id);t.forEach(e=>{const{text:s,textMaxWidth:r,color:n="white",background:h="rgba(0, 0, 0, 0.6)",style:l}=e;if(this._domMap.has(e.id)){const i=this._domMap.get(e.id);i&&(i.innerHTML=s)}else{const i=d.drawTagByDom(this._container,s,e.id);i&&(i.setAttribute("style",`
2
+ position: absolute;
3
+ top: 0;
4
+ right: 0;
5
+ z-index: 20;
6
+ padding: 8px 20px;
7
+ font-size: 15px;
8
+ max-width: ${r}px;
9
+ color: ${n};
10
+ text-align: left;
11
+ line-height: 32px;
12
+ word-break: break-all;
13
+ white-space: pre-wrap;
14
+ background: ${h};
15
+ opacity: 0.9;
16
+ max-height: ${this._height*.8}px;
17
+ overflow-y: scroll;
18
+ clear: both;
19
+ ${c.getStyle2String(l)}
20
+ `),i.addEventListener("wheel",this.wheelChange),this._domMap.set(e.id,i))}}),o.forEach(e=>{a.indexOf(e)===-1&&(this.clearTag(e),this._domMap.delete(e))})}}export{p as default};
@@ -0,0 +1,16 @@
1
+ import n from"../../locales/index.js";import{EMessage as s}from"../../locales/constants.js";const o="bee-invalid-page";class l{static renderInvalidPage(i,t,a){const e=document.createElement("div");return e.setAttribute("style",`
2
+ position: absolute;
3
+ left: 0px;
4
+ top: 0px;
5
+ width: ${t.width}px;
6
+ height: ${t.height}px;
7
+ background: rgba(255, 87, 34, 1);
8
+ overflow: hidden;
9
+ color: white;
10
+ display: flex;
11
+ justify-content: center;
12
+ align-items: center;
13
+ font-size: 30px;
14
+ opacity: 0.7;
15
+ z-index: 30;
16
+ `),e.innerHTML=n.getMessagesByLocale(s.InvalidImage,a),e.className=o,i.appendChild(e),e}}export{l as default};
@@ -0,0 +1 @@
1
+ class d{static getStrokeAndFill(e,i=!0,r={}){const{isSelected:s=!1,isHover:l=!1}=r;return s?{stroke:i?e.validSelected.stroke:e.invalidSelected.stroke,fill:i?e.validSelected.fill:e.invalidSelected.fill}:l?{stroke:i?e.validHover.stroke:e.invalidHover.stroke,fill:i?e.validHover.fill:e.invalidHover.fill}:{stroke:i?e.valid.stroke:e.invalid.stroke,fill:i?e.valid.fill:e.invalid.fill}}static getStyle2String(e){if(!!e)return Object.entries(e).reduce((i,r)=>`${i} ${r[0]}: ${r[1]};`,"")}}export{d as default};
@@ -0,0 +1 @@
1
+ import a from"../uuid.js";var p=Object.defineProperty,o=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,f=(l,t,e)=>t in l?p(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,c=(l,t)=>{for(var e in t||(t={}))m.call(t,e)&&f(l,e,t[e]);if(o)for(var e of o(t))v.call(t,e)&&f(l,e,t[e]);return l};class y{static getTagKeyName(t,e){var r,i;if(!!e)return(i=(r=e.find(u=>u.value===t))==null?void 0:r.key)!=null?i:""}static getTagName([t="",e=""],r){if(!!r){for(const i of r)if(i.value===t){if(!i.subSelected)return console.error("\u6807\u7B7E\u89E3\u6790\u9519\u8BEF",t,e),"";for(const u of i.subSelected)if(u.value===e)return u.key}}}static getTagNameList(t,e){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((r,i)=>{const[u,n]=i;if(n&&n.length>0){const s=n.split(";"),g={keyName:this.getTagKeyName(u,e),value:s.map(d=>this.getTagName([u,d],e))};return[...r,g]}return r},[]).filter(r=>r)}static getTagnameListWithoutConfig(t){return Object.keys(t).length<=0?[]:Object.entries(t).reduce((e,r)=>{const[i,u]=r,n=u.split(";"),s={keyName:i,value:n};return[...e,s]},[]).filter(e=>e)}static judgeResultIsInInputList(t,e,r){return!t||!e||!r?!1:r.filter(u=>{if(u.value===t&&u.subSelected){const n=e==null?void 0:e.split(";");return(u==null?void 0:u.subSelected.filter(s=>n.indexOf(s.value)>-1).length)>0}return!1}).length>0}static getDefaultResultByConfig(t){return t.reduce((e,r)=>(r.subSelected&&r.subSelected.forEach(i=>{var u;if(i.isDefault){const n=(u=e[r.value])!=null?u:"";let s=[];n.length>0&&(s=n.split(";")),s.push(i.value),e[r.value]=s.join(";")}}),e),{})}static getDefaultTagResult(t,e){const r=this.getDefaultResultByConfig(t);return e.length>0?e.map(i=>({id:a(),sourceID:i.id,result:c({},r)})):[{id:a(),sourceID:"",result:c({},r)}]}}export{y as default};
@@ -0,0 +1 @@
1
+ class a{static deg2rad(t){return t*Math.PI/180}static rad2deg(t){return t*180/Math.PI}}export{a as default};
@@ -0,0 +1 @@
1
+ import{EGrowthMode as p}from"../../constant/annotation.js";import Z from"../MathUtils.js";const e=[1,5,10,20,30,50,80,100].concat(Array.from({length:9}).map((t,n)=>(n+2)*100));class m{}m.zoomChanged=(t,n,f=p.Linear)=>{switch(f){case p.Intelligence:{const o=Math.max(...e),r=Math.min(...e),c=e.slice(0,e.length).findIndex((a,g)=>t>=a&&(t<e[g+1]||a===o));let s;if(c===-1)t>=r&&t<=o?s=n?o:r:s=n?r:t;else{const a=n?c+1:c-(e.includes(t)?1:0);s=e[Z.withinRange(a,[0,e.length-1])]}return s}default:{const o=n?2:1/2;return t*o}}},m.wheelChangePos=(t,n,f,o,r={})=>{const{zoom:c=1,innerZoom:s=1,basicZoom:a=1,zoomMax:g=1e3,rotate:y=0}=r,{x:u,y:x}=o,d=parseFloat((c+1/10).toFixed(1))/5;if(t&&n){let{width:h,height:l}=t;[90,270].includes(y)&&(h=t.height,l=t.width);const L=h*s,E=l*s,w=n.x-u,M=n.y-x,U=w/L,X=M/E;let i=c+f*d;i=Z.withinRange(i,[a,g]);const Y=h*i*U,j=l*i*X,C=u+(w-Y),F=x+(M-j);return{zoom:i,currentPos:{x:C,y:F},imgInfo:{width:h*i,height:l*i},ratio:d}}return null};export{m as default};
@@ -0,0 +1 @@
1
+ import{ELineTypes as g,SEGMENT_NUMBER as E}from"../../constant/tool.js";var C=Object.defineProperty,I=Object.defineProperties,L=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,P=(e,t,l)=>t in e?C(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,b=(e,t)=>{for(var l in t||(t={}))N.call(t,l)&&P(e,l,t[l]);if(O)for(var l of O(t))S.call(t,l)&&P(e,l,t[l]);return e},D=(e,t)=>I(e,L(t));function v(e,t=.5,l=!1,s=16){if(e.length<4)return e;const h=[],r=e.slice(0);let f,u,n,y,p,d,w,i,M,m,o,c,a;for(l?(r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.unshift(e[e.length-1]),r.unshift(e[e.length-2]),r.push(e[0]),r.push(e[1])):(r.unshift(e[1]),r.unshift(e[0]),r.push(e[e.length-2]),r.push(e[e.length-1])),a=2;a<r.length-4;a+=2)for(n=(r[a+2]-r[a-2])*t,y=(r[a+4]-r[a-0])*t,p=(r[a+3]-r[a-1])*t,d=(r[a+5]-r[a+1])*t,c=0;c<=s;c++)o=c/s,w=2*Math.pow(o,3)-3*Math.pow(o,2)+1,i=-(2*Math.pow(o,3))+3*Math.pow(o,2),M=Math.pow(o,3)-2*Math.pow(o,2)+o,m=Math.pow(o,3)-Math.pow(o,2),f=w*r[a]+i*r[a+2]+M*n+m*y,u=w*r[a+1]+i*r[a+3]+M*p+m*d,h.push(f),h.push(u);const _=[];for(let x=0;x<h.length-1;x+=2)_.push({x:h[x],y:h[x+1]});if(l)for(let x=0;x<s+1;x++){const j=_.shift();_.push(j)}return _}const R=(e,t=16)=>v(e.reduce((l,s)=>[...l,s.x,s.y],[]),.5,!1,t);function T(e,t,l=g.Line){let s=0,h,r,f,u;t=[...t],l===g.Curve&&(t=v(t.reduce((y,p)=>[...y,p.x,p.y],[]),.5,!0,E)),[f]=t;const n=t.length;for(h=1;h<=n;h++)u=t[h%n],e.x>Math.min(f.x,u.x)&&e.x<=Math.max(f.x,u.x)&&e.y<=Math.max(f.y,u.y)&&f.x!==u.x&&(r=(e.x-f.x)*(u.y-f.y)/(u.x-f.x)+f.y,(f.y===u.y||e.y<=r)&&s++),f=u;return s%2!=0}function U(e,t=1){return e.map(l=>D(b({},l),{x:l.x*t,y:l.y*t}))}export{v as createSmoothCurvePoints,R as createSmoothCurvePointsFromPointList,U as getPolygonPointUnderZoom,T as isInPolygon};
@@ -0,0 +1 @@
1
+ function i(f=8,n=62){const e="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[];let t;if(n=n||e.length,f)for(t=0;t<f;t++)o[t]=e[0|Math.random()*n];else{let r;for(o[8]=o[13]=o[18]=o[23]="-",o[14]="4",t=0;t<36;t++)o[t]||(r=0|Math.random()*16,o[t]=e[t===19?r&3|8:r])}return o.join("")}export{i as default};