@labelbee/lb-annotation 1.12.0-alpha.0 → 1.12.0-alpha.10

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 (37) hide show
  1. package/dist/_virtual/filterBoxWorker.js +1 -1
  2. package/dist/_virtual/highlightWorker.js +1 -1
  3. package/dist/constant/style.js +1 -1
  4. package/dist/core/pointCloud/PCDLoader.js +2 -2
  5. package/dist/core/pointCloud/annotation.js +1 -1
  6. package/dist/core/pointCloud/cache.js +1 -1
  7. package/dist/core/pointCloud/index.js +2 -2
  8. package/dist/core/pointCloud/matrix.js +1 -1
  9. package/dist/core/toolOperation/pointCloud2dOperation.js +1 -1
  10. package/dist/core/toolOperation/pointOperation.js +1 -1
  11. package/dist/core/toolOperation/polygonOperation.js +1 -1
  12. package/dist/types/constant/style.d.ts +6 -0
  13. package/dist/types/core/pointCloud/PCDLoader.d.ts +1 -0
  14. package/dist/types/core/pointCloud/cache.d.ts +11 -1
  15. package/dist/types/core/pointCloud/index.d.ts +15 -3
  16. package/dist/types/core/pointCloud/matrix.d.ts +13 -0
  17. package/dist/types/core/toolOperation/pointCloud2dOperation.d.ts +1 -1
  18. package/dist/types/core/toolOperation/pointOperation.d.ts +5 -0
  19. package/dist/types/core/toolOperation/polygonOperation.d.ts +1 -0
  20. package/dist/types/utils/ActionsHistory.d.ts +1 -1
  21. package/dist/types/utils/tool/MarkerUtils.d.ts +18 -0
  22. package/dist/utils/ImgUtils.js +1 -1
  23. package/dist/utils/tool/MarkerUtils.js +1 -1
  24. package/es/_virtual/filterBoxWorker.js +1 -1
  25. package/es/_virtual/highlightWorker.js +1 -1
  26. package/es/constant/style.js +1 -1
  27. package/es/core/pointCloud/PCDLoader.js +2 -2
  28. package/es/core/pointCloud/annotation.js +1 -1
  29. package/es/core/pointCloud/cache.js +1 -1
  30. package/es/core/pointCloud/index.js +2 -2
  31. package/es/core/pointCloud/matrix.js +1 -1
  32. package/es/core/toolOperation/pointCloud2dOperation.js +1 -1
  33. package/es/core/toolOperation/pointOperation.js +1 -1
  34. package/es/core/toolOperation/polygonOperation.js +1 -1
  35. package/es/utils/ImgUtils.js +1 -1
  36. package/es/utils/tool/MarkerUtils.js +1 -1
  37. package/package.json +3 -3
@@ -1 +1 @@
1
- "use strict";var _rollupPluginWebWorkerLoader__helper__browser__createBase64WorkerFactory=require("./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js"),WorkerFactory=_rollupPluginWebWorkerLoader__helper__browser__createBase64WorkerFactory.createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oZil7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIGMoaSxzLGw9MCl7bGV0IHg9MCx1LG8sdCxlO3M9Wy4uLnNdLGw9PT0xJiYocz1jcmVhdGVTbW9vdGhDdXJ2ZVBvaW50cyhzLnJlZHVjZSgoYSxuKT0+Wy4uLmEsbi54LG4ueV0sW10pLC41LCEwLFNFR01FTlRfTlVNQkVSKSksW3RdPXM7Y29uc3Qgcj1zLmxlbmd0aDtmb3IodT0xO3U8PXI7dSsrKWU9c1t1JXJdLGkueD5NYXRoLm1pbih0LngsZS54KSYmaS54PD1NYXRoLm1heCh0LngsZS54KSYmaS55PD1NYXRoLm1heCh0LnksZS55KSYmdC54IT09ZS54JiYobz0oaS54LXQueCkqKGUueS10LnkpLyhlLngtdC54KSt0LnksKHQueT09PWUueXx8aS55PD1vKSYmeCsrKSx0PWU7cmV0dXJuIHglMiE9MH1yZXR1cm4gb25tZXNzYWdlPWZ1bmN0aW9uKHMpe2NvbnN0e3pNaW46bCx6TWF4OngscG9seWdvblBvaW50TGlzdDp1LHBvc2l0aW9uOm8sY29sb3I6dH09cy5kYXRhLGU9W10scj1bXTtsZXQgYT0wO2ZvcihsZXQgbj0wO248by5sZW5ndGg7bis9Myl7Y29uc3QgaD1vW25dLE09b1tuKzFdLHk9b1tuKzJdO2Moe3g6aCx5Ok19LHUpJiZ5Pj1sJiZ5PD14JiYoZS5wdXNoKGgpLGUucHVzaChNKSxlLnB1c2goeSksci5wdXNoKHRbbl0pLHIucHVzaCh0W24rMV0pLHIucHVzaCh0W24rMl0pLGErKyl9dGhpcy5wb3N0TWVzc2FnZSh7cG9zaXRpb246ZSxjb2xvcjpyLG51bTphfSl9LGYuaXNJblBvbHlnb249YyxPYmplY3QuZGVmaW5lUHJvcGVydHkoZiwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSksZn0oe30pOwoK",null,!1);module.exports=WorkerFactory;
1
+ "use strict";var _rollupPluginWebWorkerLoader__helper__browser__createBase64WorkerFactory=require("./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js"),WorkerFactory=_rollupPluginWebWorkerLoader__helper__browser__createBase64WorkerFactory.createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIE0odCl7Y29uc3QgZT0tNyxzPTMsZj1zLWU7cmV0dXJuIHQ8ZSYmKHQ9ZSksdD5zJiYodD1zKSxNYXRoLmZsb29yKCh0LWUpL2YqMjU1KX1mdW5jdGlvbiBtKCl7bGV0IHQ7Y29uc3QgZT1uZXcgQXJyYXkoMjU2KS5maWxsKCIiKS5tYXAoKCk9Pm5ldyBBcnJheSgzKS5maWxsKCIiKSk7Zm9yKGxldCBzPTA7czwyMDtzKyspe2Zvcih0PTA7dDwzMjt0KyspZVt0XVswXT0xMjgrNCp0LGVbdF1bMV09MCxlW3RdWzJdPTA7Zm9yKGVbMzJdWzBdPTI1NSxlWzMyXVsxXT0wLGVbMzJdWzJdPTAsdD0wO3Q8NjM7dCsrKWVbMzMrdF1bMF09MjU1LGVbMzMrdF1bMV09NCs0KnQsZVszMyt0XVsyXT0wO2ZvcihlWzk2XVswXT0yNTQsZVs5Nl1bMV09MjU1LGVbOTZdWzJdPTIsdD0wO3Q8NjI7dCsrKWVbOTcrdF1bMF09MjUwLTQqdCxlWzk3K3RdWzFdPTI1NSxlWzk3K3RdWzJdPTYrNCp0O2ZvcihlWzE1OV1bMF09MSxlWzE1OV1bMV09MjU1LGVbMTU5XVsyXT0yNTQsdD0wO3Q8NjQ7dCsrKWVbMTYwK3RdWzBdPTAsZVsxNjArdF1bMV09MjUyLXQqNCxlWzE2MCt0XVsyXT0yNTU7Zm9yKHQ9MDt0PDMyO3QrKyllWzIyNCt0XVswXT0wLGVbMjI0K3RdWzFdPTAsZVsyMjQrdF1bMl09MjUyLTQqdH1yZXR1cm4gZX1jb25zdCBkPW0oKTtmdW5jdGlvbiBoKHQsZSxzPTApe2xldCBmPTAsbCx1LG4sbztlPVsuLi5lXSxzPT09MSYmKGU9Y3JlYXRlU21vb3RoQ3VydmVQb2ludHMoZS5yZWR1Y2UoKGEscik9PlsuLi5hLHIueCxyLnldLFtdKSwuNSwhMCxTRUdNRU5UX05VTUJFUikpLFtuXT1lO2NvbnN0IGk9ZS5sZW5ndGg7Zm9yKGw9MTtsPD1pO2wrKylvPWVbbCVpXSx0Lng+TWF0aC5taW4obi54LG8ueCkmJnQueDw9TWF0aC5tYXgobi54LG8ueCkmJnQueTw9TWF0aC5tYXgobi55LG8ueSkmJm4ueCE9PW8ueCYmKHU9KHQueC1uLngpKihvLnktbi55KS8oby54LW4ueCkrbi55LChuLnk9PT1vLnl8fHQueTw9dSkmJmYrKyksbj1vO3JldHVybiBmJTIhPTB9cmV0dXJuIG9ubWVzc2FnZT1mdW5jdGlvbihlKXtjb25zdHt6TWluOnMsek1heDpmLHBvbHlnb25Qb2ludExpc3Q6bCxwb3NpdGlvbjp1LGNvbG9yOm59PWUuZGF0YSxvPVtdLGk9W107bGV0IGE9MDtmb3IobGV0IHI9MDtyPHUubGVuZ3RoO3IrPTMpe2NvbnN0IHA9dVtyXSx5PXVbcisxXSxjPXVbcisyXTtpZihoKHt4OnAseX0sbCkmJmM+PXMmJmM8PWYpe2lmKG8ucHVzaChwKSxvLnB1c2goeSksby5wdXNoKGMpLG4ubGVuZ3RoPT09MCl7Y29uc3QgZz1NKGMpLHc9ZFtnXSxbQyxfLEVdPXc7aS5wdXNoKEMvMjU1KSxpLnB1c2goXy8yNTUpLGkucHVzaChFLzI1NSl9ZWxzZSBpLnB1c2gobltyXSksaS5wdXNoKG5bcisxXSksaS5wdXNoKG5bcisyXSk7YSsrfX10aGlzLnBvc3RNZXNzYWdlKHtwb3NpdGlvbjpvLGNvbG9yOmksbnVtOmF9KX0seC5pc0luUG9seWdvbj1oLE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh4LCJfX2VzTW9kdWxlIix7dmFsdWU6ITB9KSx4fSh7fSk7Cgo=",null,!1);module.exports=WorkerFactory;
@@ -1 +1 @@
1
- "use strict";var _rollupPluginWebWorkerLoader__helper__browser__createBase64WorkerFactory=require("./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js"),WorkerFactory=_rollupPluginWebWorkerLoader__helper__browser__createBase64WorkerFactory.createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2NsYXNzIEN7c3RhdGljIGdlbkNvbG9yQnlDb29yZChyLHUsbil7cmV0dXJuIG48PTA/WzEyOCwxMjgsMTI4XTpuPDU/WzI1NSwwLDBdOm48MTA/WzAsMjU1LDBdOlswLDAsMjU1XX1zdGF0aWMgZ2V0U3RhbmRhcmRDb2xvckJ5Q29vcmQocix1LG4pe3JldHVybiB0aGlzLmdlbkNvbG9yQnlDb29yZChyLHUsbikubWFwKGk9PmkvMjU1KX19ZnVuY3Rpb24geShzLHIsdT0wKXtsZXQgbj0wLGEsaSx0LG87cj1bLi4ucl0sdT09PTEmJihyPWNyZWF0ZVNtb290aEN1cnZlUG9pbnRzKHIucmVkdWNlKChmLGwpPT5bLi4uZixsLngsbC55XSxbXSksLjUsITAsU0VHTUVOVF9OVU1CRVIpKSxbdF09cjtjb25zdCBlPXIubGVuZ3RoO2ZvcihhPTE7YTw9ZTthKyspbz1yW2ElZV0scy54Pk1hdGgubWluKHQueCxvLngpJiZzLng8PU1hdGgubWF4KHQueCxvLngpJiZzLnk8PU1hdGgubWF4KHQueSxvLnkpJiZ0LnghPT1vLngmJihpPShzLngtdC54KSooby55LXQueSkvKG8ueC10LngpK3QueSwodC55PT09by55fHxzLnk8PWkpJiZuKyspLHQ9bztyZXR1cm4gbiUyIT0wfXJldHVybiBvbm1lc3NhZ2U9ZnVuY3Rpb24ocil7Y29uc3R7ek1pbjp1LHpNYXg6bixwb2x5Z29uUG9pbnRMaXN0OmEscG9zaXRpb246aSxjb2xvcjp0fT1yLmRhdGE7bGV0IG89MDtmb3IobGV0IGU9MDtlPGkubGVuZ3RoO2UrPTMpe2NvbnN0IGY9aVtlXSxsPWlbZSsxXSxkPWlbZSsyXTtpZih5KHt4OmYseTpsfSxhKSYmZD49dSYmZDw9bilvKyssdFtlXT0wLHRbZSsxXT0xLHRbZSsyXT0xO2Vsc2V7Y29uc3RbYyxnLE1dPUMuZ2V0U3RhbmRhcmRDb2xvckJ5Q29vcmQoZixsLGQpO3RbZV09Yyx0W2UrMV09Zyx0W2UrMl09TX19cG9zdE1lc3NhZ2Uoe3BvaW50czppLGNvbG9yOnQsbnVtOm99KX0seC5pc0luUG9seWdvbj15LE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh4LCJfX2VzTW9kdWxlIix7dmFsdWU6ITB9KSx4fSh7fSk7Cgo=",null,!1);module.exports=WorkerFactory;
1
+ "use strict";var _rollupPluginWebWorkerLoader__helper__browser__createBase64WorkerFactory=require("./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js"),WorkerFactory=_rollupPluginWebWorkerLoader__helper__browser__createBase64WorkerFactory.createBase64WorkerFactory("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIGcodCl7Y29uc3QgZT0tNyxvPTMsaT1vLWU7cmV0dXJuIHQ8ZSYmKHQ9ZSksdD5vJiYodD1vKSxNYXRoLmZsb29yKCh0LWUpL2kqMjU1KX1mdW5jdGlvbiBwKCl7bGV0IHQ7Y29uc3QgZT1uZXcgQXJyYXkoMjU2KS5maWxsKCIiKS5tYXAoKCk9Pm5ldyBBcnJheSgzKS5maWxsKCIiKSk7Zm9yKGxldCBvPTA7bzwyMDtvKyspe2Zvcih0PTA7dDwzMjt0KyspZVt0XVswXT0xMjgrNCp0LGVbdF1bMV09MCxlW3RdWzJdPTA7Zm9yKGVbMzJdWzBdPTI1NSxlWzMyXVsxXT0wLGVbMzJdWzJdPTAsdD0wO3Q8NjM7dCsrKWVbMzMrdF1bMF09MjU1LGVbMzMrdF1bMV09NCs0KnQsZVszMyt0XVsyXT0wO2ZvcihlWzk2XVswXT0yNTQsZVs5Nl1bMV09MjU1LGVbOTZdWzJdPTIsdD0wO3Q8NjI7dCsrKWVbOTcrdF1bMF09MjUwLTQqdCxlWzk3K3RdWzFdPTI1NSxlWzk3K3RdWzJdPTYrNCp0O2ZvcihlWzE1OV1bMF09MSxlWzE1OV1bMV09MjU1LGVbMTU5XVsyXT0yNTQsdD0wO3Q8NjQ7dCsrKWVbMTYwK3RdWzBdPTAsZVsxNjArdF1bMV09MjUyLXQqNCxlWzE2MCt0XVsyXT0yNTU7Zm9yKHQ9MDt0PDMyO3QrKyllWzIyNCt0XVswXT0wLGVbMjI0K3RdWzFdPTAsZVsyMjQrdF1bMl09MjUyLTQqdH1yZXR1cm4gZX1jb25zdCBDPXAoKTtmdW5jdGlvbiBtKHQsZSxvPTApe2xldCBpPTAscyxhLHIsbjtlPVsuLi5lXSxvPT09MSYmKGU9Y3JlYXRlU21vb3RoQ3VydmVQb2ludHMoZS5yZWR1Y2UoKGMsbCk9PlsuLi5jLGwueCxsLnldLFtdKSwuNSwhMCxTRUdNRU5UX05VTUJFUikpLFtyXT1lO2NvbnN0IHU9ZS5sZW5ndGg7Zm9yKHM9MTtzPD11O3MrKyluPWVbcyV1XSx0Lng+TWF0aC5taW4oci54LG4ueCkmJnQueDw9TWF0aC5tYXgoci54LG4ueCkmJnQueTw9TWF0aC5tYXgoci55LG4ueSkmJnIueCE9PW4ueCYmKGE9KHQueC1yLngpKihuLnktci55KS8obi54LXIueCkrci55LChyLnk9PT1uLnl8fHQueTw9YSkmJmkrKykscj1uO3JldHVybiBpJTIhPTB9ZnVuY3Rpb24gYih7ek1pbjp0LHpNYXg6ZSxwb2x5Z29uUG9pbnRMaXN0Om8sYXR0cmlidXRlOmkseDpzLHk6YSx6OnIsY29sb3JMaXN0Om4sdmFsaWQ6dX0pe2lmKG0oe3g6cyx5OmF9LG8pJiZyPj10JiZyPD1lKXJldHVybiB1PT09ITE/WzEsMTAzLzI1NSwxMDIvMjU1XTpuW2ldP25baV0ucmdiYS5zbGljZSgwLDMpLm1hcChsPT5sLzI1NSk6WzEsMCwwXX1yZXR1cm4gb25tZXNzYWdlPWZ1bmN0aW9uKGUpe2NvbnN0e3Bvc2l0aW9uOm8sY29sb3I6aSxjdWJvaWRMaXN0OnMsY29sb3JMaXN0OmF9PWUuZGF0YTtsZXQgcj0wO2ZvcihsZXQgbj0wO248by5sZW5ndGg7bis9Myl7Y29uc3QgdT1vW25dLGM9b1tuKzFdLGw9b1tuKzJdLGQ9cy5tYXAoZj0+Yih7cG9seWdvblBvaW50TGlzdDpmLnBvbHlnb25Qb2ludExpc3Qsek1pbjpmLnpNaW4sek1heDpmLnpNYXgseDp1LHk6Yyx6OmwsYXR0cmlidXRlOmYuYXR0cmlidXRlLGNvbG9yTGlzdDphLHZhbGlkOmYudmFsaWR9KSkuZmlsdGVyKGY9PmYpLnBvcCgpO2lmKGQpe3IrKztjb25zdFtmLHksTV09ZDtpW25dPWYsaVtuKzFdPXksaVtuKzJdPU19ZWxzZXtjb25zdCBmPWcobCkseT1DW2ZdLFtNLHcsX109eTtpW25dPU0vMjU1LGlbbisxXT13LzI1NSxpW24rMl09Xy8yNTV9fXBvc3RNZXNzYWdlKHtwb2ludHM6byxjb2xvcjppLG51bTpyfSl9LHguaXNJblBvbHlnb249bSxPYmplY3QuZGVmaW5lUHJvcGVydHkoeCwiX19lc01vZHVsZSIse3ZhbHVlOiEwfSkseH0oe30pOwoK",null,!1);module.exports=WorkerFactory;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var icon_canvasEdit0=require("../assets/attributeIcon/icon_canvasEdit0.svg.js"),icon_canvasEdit1=require("../assets/attributeIcon/icon_canvasEdit1.svg.js"),icon_canvasEdit2=require("../assets/attributeIcon/icon_canvasEdit2.svg.js"),icon_canvasEdit3=require("../assets/attributeIcon/icon_canvasEdit3.svg.js"),icon_canvasEdit4=require("../assets/attributeIcon/icon_canvasEdit4.svg.js"),icon_canvasEdit5=require("../assets/attributeIcon/icon_canvasEdit5.svg.js"),icon_canvasEdit6=require("../assets/attributeIcon/icon_canvasEdit6.svg.js"),icon_canvasEdit7=require("../assets/attributeIcon/icon_canvasEdit7.svg.js"),icon_canvasEdit8=require("../assets/attributeIcon/icon_canvasEdit8.svg.js"),icon_editLAN=require("../assets/attributeIcon/icon_editLAN.svg.js"),icon_editQING=require("../assets/attributeIcon/icon_editQING.svg.js"),icon_editLV=require("../assets/attributeIcon/icon_editLV.svg.js"),icon_editHUANG=require("../assets/attributeIcon/icon_editHUANG.svg.js"),icon_editFEN=require("../assets/attributeIcon/icon_editFEN.svg.js"),tool=require("./tool.js"),icon_canvasEdit_miss=require("../assets/attributeIcon/icon_canvasEdit_miss.svg.js");const NULL_ICON=icon_canvasEdit0,HEADER_HEIGHT=61,TAB_HEIGHT=80,SEARCH_HEIGHT=62,PADDING=20,TABLE_ROW_HEIGHT=55,PAGINATION_HEIGHT=55,TIPS_HEIGHT=40,FOOTER_HEIGHT=80,SIDERBAR_WIDTH=240,EDIT_STEP_WIDTH=320,THEME_COLOR="rgba(102, 111, 255, 1)",COLORS_ARRAY=["rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"],ICON_ARRAY=[icon_canvasEdit0,icon_canvasEdit6,icon_canvasEdit3,icon_canvasEdit7,icon_canvasEdit2,icon_canvasEdit8,icon_canvasEdit5,icon_canvasEdit1,icon_canvasEdit4],BASE_ICON={1:icon_editLAN,3:icon_editQING,5:icon_editLV,7:icon_editHUANG,9:icon_editFEN},INVALID_COLOR="rgba(255, 51, 51, 1)",NULL_COLOR="rgba(204, 204, 204, 1)",FILTER_TOOL_COLOR={[tool.EFilterToolOperation.lc]:"rgba(153, 51, 255, 1)",[tool.EFilterToolOperation.rc]:"rgba(51, 153, 255, 1)",[tool.EFilterToolOperation.clc]:"rgba(46, 230, 46, 1)",[tool.EFilterToolOperation.crc]:"rgba(255, 51, 51, 1)"},styleString='{"color":1,"width":2,"borderOpacity":9,"fillOpacity":9,"toolColor":{"1":{"valid":{"stroke":"rgba(0,0,255,0.50)","fill":"rgba(0,0,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(0,15,255,1.00)","fill":"rgba(0,15,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(0,15,255,0.80)","fill":"rgba(0,15,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"3":{"valid":{"stroke":"rgba(0,255,255,0.50)","fill":"rgba(0,255,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(0,212,255,1.00)","fill":"rgba(0,212,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(0,212,255,0.80)","fill":"rgba(0,212,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"5":{"valid":{"stroke":"rgba(0,255,0,0.50)","fill":"rgba(0,255,0,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(149,255,1.00)","fill":"rgba(149,255,0,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(149,255,0,0.80)","fill":"rgba(149,255,0,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"7":{"valid":{"stroke":"rgba(255,255,0,0.50)","fill":"rgba(255,255,0,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(255,230,102,1.00)","fill":"rgba(255,213,0,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(255,230,102,0.80)","fill":"rgba(255,230,102,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"9":{"valid":{"stroke":"rgba(255,0,255,0.50)","fill":"rgba(255,0,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(230,102,255,1.00)","fill":"rgba(213,0,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(230,102,255,0.80)","fill":"rgba(230,102,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}}},"attributeColor":[{"valid":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}}],"lineColor":{"1":"rgba(102, 111, 255, 1 )","3":"rgba(102, 230, 255, 1)","5":"rgba(191, 255, 102, 1)","7":"rgba(255, 230, 102, 1)","9":"rgba(230, 102, 255, 1)"},"attributeLineColor":["rgba(204, 204, 204, 1)","rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"]}';exports.INVALID_ICON=icon_canvasEdit_miss,exports.BASE_ICON=BASE_ICON,exports.COLORS_ARRAY=COLORS_ARRAY,exports.EDIT_STEP_WIDTH=EDIT_STEP_WIDTH,exports.FILTER_TOOL_COLOR=FILTER_TOOL_COLOR,exports.FOOTER_HEIGHT=FOOTER_HEIGHT,exports.HEADER_HEIGHT=HEADER_HEIGHT,exports.ICON_ARRAY=ICON_ARRAY,exports.INVALID_COLOR=INVALID_COLOR,exports.NULL_COLOR=NULL_COLOR,exports.NULL_ICON=NULL_ICON,exports.PADDING=PADDING,exports.PAGINATION_HEIGHT=PAGINATION_HEIGHT,exports.SEARCH_HEIGHT=SEARCH_HEIGHT,exports.SIDERBAR_WIDTH=SIDERBAR_WIDTH,exports.TABLE_ROW_HEIGHT=TABLE_ROW_HEIGHT,exports.TAB_HEIGHT=TAB_HEIGHT,exports.THEME_COLOR=THEME_COLOR,exports.TIPS_HEIGHT=TIPS_HEIGHT,exports.styleString=styleString;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var icon_canvasEdit0=require("../assets/attributeIcon/icon_canvasEdit0.svg.js"),icon_canvasEdit1=require("../assets/attributeIcon/icon_canvasEdit1.svg.js"),icon_canvasEdit2=require("../assets/attributeIcon/icon_canvasEdit2.svg.js"),icon_canvasEdit3=require("../assets/attributeIcon/icon_canvasEdit3.svg.js"),icon_canvasEdit4=require("../assets/attributeIcon/icon_canvasEdit4.svg.js"),icon_canvasEdit5=require("../assets/attributeIcon/icon_canvasEdit5.svg.js"),icon_canvasEdit6=require("../assets/attributeIcon/icon_canvasEdit6.svg.js"),icon_canvasEdit7=require("../assets/attributeIcon/icon_canvasEdit7.svg.js"),icon_canvasEdit8=require("../assets/attributeIcon/icon_canvasEdit8.svg.js"),icon_editLAN=require("../assets/attributeIcon/icon_editLAN.svg.js"),icon_editQING=require("../assets/attributeIcon/icon_editQING.svg.js"),icon_editLV=require("../assets/attributeIcon/icon_editLV.svg.js"),icon_editHUANG=require("../assets/attributeIcon/icon_editHUANG.svg.js"),icon_editFEN=require("../assets/attributeIcon/icon_editFEN.svg.js"),tool=require("./tool.js"),icon_canvasEdit_miss=require("../assets/attributeIcon/icon_canvasEdit_miss.svg.js");const NULL_ICON=icon_canvasEdit0,HEADER_HEIGHT=61,TAB_HEIGHT=80,SEARCH_HEIGHT=62,PADDING=20,TABLE_ROW_HEIGHT=55,PAGINATION_HEIGHT=55,TIPS_HEIGHT=40,FOOTER_HEIGHT=80,SIDERBAR_WIDTH=240,EDIT_STEP_WIDTH=320,THEME_COLOR="rgba(102, 111, 255, 1)",COLORS_ARRAY=["rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"],ICON_ARRAY=[icon_canvasEdit0,icon_canvasEdit6,icon_canvasEdit3,icon_canvasEdit7,icon_canvasEdit2,icon_canvasEdit8,icon_canvasEdit5,icon_canvasEdit1,icon_canvasEdit4],BASE_ICON={1:icon_editLAN,3:icon_editQING,5:icon_editLV,7:icon_editHUANG,9:icon_editFEN},INVALID_COLOR="rgba(255, 51, 51, 1)",INVALID_COLOR_RGBA={r:255,g:51,b:51,a:1},NULL_COLOR="rgba(204, 204, 204, 1)",FILTER_TOOL_COLOR={[tool.EFilterToolOperation.lc]:"rgba(153, 51, 255, 1)",[tool.EFilterToolOperation.rc]:"rgba(51, 153, 255, 1)",[tool.EFilterToolOperation.clc]:"rgba(46, 230, 46, 1)",[tool.EFilterToolOperation.crc]:"rgba(255, 51, 51, 1)"},styleString='{"color":1,"width":2,"borderOpacity":9,"fillOpacity":9,"toolColor":{"1":{"valid":{"stroke":"rgba(0,0,255,0.50)","fill":"rgba(0,0,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(0,15,255,1.00)","fill":"rgba(0,15,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(0,15,255,0.80)","fill":"rgba(0,15,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"3":{"valid":{"stroke":"rgba(0,255,255,0.50)","fill":"rgba(0,255,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(0,212,255,1.00)","fill":"rgba(0,212,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(0,212,255,0.80)","fill":"rgba(0,212,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"5":{"valid":{"stroke":"rgba(0,255,0,0.50)","fill":"rgba(0,255,0,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(149,255,1.00)","fill":"rgba(149,255,0,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(149,255,0,0.80)","fill":"rgba(149,255,0,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"7":{"valid":{"stroke":"rgba(255,255,0,0.50)","fill":"rgba(255,255,0,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(255,230,102,1.00)","fill":"rgba(255,213,0,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(255,230,102,0.80)","fill":"rgba(255,230,102,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"9":{"valid":{"stroke":"rgba(255,0,255,0.50)","fill":"rgba(255,0,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(230,102,255,1.00)","fill":"rgba(213,0,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(230,102,255,0.80)","fill":"rgba(230,102,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}}},"attributeColor":[{"valid":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}}],"lineColor":{"1":"rgba(102, 111, 255, 1 )","3":"rgba(102, 230, 255, 1)","5":"rgba(191, 255, 102, 1)","7":"rgba(255, 230, 102, 1)","9":"rgba(230, 102, 255, 1)"},"attributeLineColor":["rgba(204, 204, 204, 1)","rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"]}';exports.INVALID_ICON=icon_canvasEdit_miss,exports.BASE_ICON=BASE_ICON,exports.COLORS_ARRAY=COLORS_ARRAY,exports.EDIT_STEP_WIDTH=EDIT_STEP_WIDTH,exports.FILTER_TOOL_COLOR=FILTER_TOOL_COLOR,exports.FOOTER_HEIGHT=FOOTER_HEIGHT,exports.HEADER_HEIGHT=HEADER_HEIGHT,exports.ICON_ARRAY=ICON_ARRAY,exports.INVALID_COLOR=INVALID_COLOR,exports.INVALID_COLOR_RGBA=INVALID_COLOR_RGBA,exports.NULL_COLOR=NULL_COLOR,exports.NULL_ICON=NULL_ICON,exports.PADDING=PADDING,exports.PAGINATION_HEIGHT=PAGINATION_HEIGHT,exports.SEARCH_HEIGHT=SEARCH_HEIGHT,exports.SIDERBAR_WIDTH=SIDERBAR_WIDTH,exports.TABLE_ROW_HEIGHT=TABLE_ROW_HEIGHT,exports.TAB_HEIGHT=TAB_HEIGHT,exports.THEME_COLOR=THEME_COLOR,exports.TIPS_HEIGHT=TIPS_HEIGHT,exports.styleString=styleString;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three");class PCDLoader extends THREE.Loader{constructor(p){super(p);this.littleEndian=!0}load(p,m,f,w){const i=this,l=new THREE.FileLoader(i.manager);l.setPath(i.path),l.setResponseType("arraybuffer"),l.setRequestHeader(i.requestHeader),l.setWithCredentials(i.withCredentials),l.load(p,function(d){try{m(i.parse(d))}catch(h){w?w(h):console.error(h),i.manager.itemError(p)}},f,w)}parse(p){function m(o,e){const a=o.length,n=new Uint8Array(e);let r=0,t=0,s,u,c;do if(s=o[r++],s<1<<5){if(s++,t+s>e)throw new Error("Output buffer is not large enough");if(r+s>a)throw new Error("Invalid compressed data");do n[t++]=o[r++];while(--s)}else{if(u=s>>5,c=t-((s&31)<<8)-1,r>=a)throw new Error("Invalid compressed data");if(u===7&&(u+=o[r++],r>=a))throw new Error("Invalid compressed data");if(c-=o[r++],t+u+2>e)throw new Error("Output buffer is not large enough");if(c<0)throw new Error("Invalid compressed data");if(c>=t)throw new Error("Invalid compressed data");do n[t++]=n[c++];while(--u+2)}while(r<a);return n}function f(o){const e={},a=o.search(/[\n\r]data\s(\S*)\s/i),n=/[\n\r]data\s(\S*)\s/i.exec(o.slice(a-1));if(e.data=n[1],e.headerLen=n[0].length+a,e.str=o.slice(0,e.headerLen),e.str=e.str.replace(/#.*/gi,""),e.version=/version (.*)/i.exec(e.str),e.fields=/fields (.*)/i.exec(e.str),e.size=/size (.*)/i.exec(e.str),e.type=/type (.*)/i.exec(e.str),e.count=/count (.*)/i.exec(e.str),e.width=/width (.*)/i.exec(e.str),e.height=/height (.*)/i.exec(e.str),e.viewpoint=/viewpoint (.*)/i.exec(e.str),e.points=/points (.*)/i.exec(e.str),e.version!==null&&(e.version=parseFloat(e.version[1])),e.fields=e.fields!==null?e.fields[1].split(" "):[],e.type!==null&&(e.type=e.type[1].split(" ")),e.width!==null&&(e.width=parseInt(e.width[1])),e.height!==null&&(e.height=parseInt(e.height[1])),e.viewpoint!==null&&(e.viewpoint=e.viewpoint[1]),e.points!==null&&(e.points=parseInt(e.points[1],10)),e.points===null&&(e.points=e.width*e.height),e.size!==null&&(e.size=e.size[1].split(" ").map(function(t){return parseInt(t,10)})),e.count!==null)e.count=e.count[1].split(" ").map(function(t){return parseInt(t,10)});else{e.count=[];for(let t=0,s=e.fields.length;t<s;t++)e.count.push(1)}e.offset={};let r=0;for(let t=0,s=e.fields.length;t<s;t++)e.data==="ascii"?e.offset[e.fields[t]]=t:(e.offset[e.fields[t]]=r,r+=e.size[t]*e.count[t]);return e.rowSize=r,e}const w=THREE.LoaderUtils.decodeText(new Uint8Array(p)),i=f(w),l=[],d=[],h=[];if(i.data==="ascii"){const{offset:o}=i,a=w.slice(i.headerLen).split(`
2
- `);for(let n=0,r=a.length;n<r;n++){if(a[n]==="")continue;const t=a[n].split(" ");if(o.x!==void 0&&(l.push(parseFloat(t[o.x])),l.push(parseFloat(t[o.y])),l.push(parseFloat(t[o.z]))),this.genColorByCoord){const u=this.genColorByCoord(parseFloat(t[o.x]),parseFloat(t[o.y]),parseFloat(t[o.z])).map(c=>c/255);h.push(...u)}o.normal_x!==void 0&&(d.push(parseFloat(t[o.normal_x])),d.push(parseFloat(t[o.normal_y])),d.push(parseFloat(t[o.normal_z])))}}if(i.data==="binary_compressed"){const o=new Uint32Array(p.slice(i.headerLen,i.headerLen+8)),e=o[0],a=o[1],n=m(new Uint8Array(p,i.headerLen+8,e),a),r=new DataView(n.buffer),{offset:t}=i;for(let s=0;s<i.points;s++)if(t.x!==void 0&&(l.push(r.getFloat32(i.points*t.x+i.size[0]*s,this.littleEndian)),l.push(r.getFloat32(i.points*t.y+i.size[1]*s,this.littleEndian)),l.push(r.getFloat32(i.points*t.z+i.size[2]*s,this.littleEndian))),t.normal_x!==void 0&&(d.push(r.getFloat32(i.points*t.normal_x+i.size[4]*s,this.littleEndian)),d.push(r.getFloat32(i.points*t.normal_y+i.size[5]*s,this.littleEndian)),d.push(r.getFloat32(i.points*t.normal_z+i.size[6]*s,this.littleEndian))),this.genColorByCoord){const c=this.genColorByCoord(r.getFloat32(i.points*t.x+i.size[0]*s,this.littleEndian),r.getFloat32(i.points*t.y+i.size[0]*s,this.littleEndian),r.getFloat32(i.points*t.z+i.size[0]*s,this.littleEndian)).map(x=>x/255);h.push(...c)}}if(i.data==="binary"){const o=new DataView(p,i.headerLen),{offset:e}=i;for(let a=0,n=0;a<i.points;a++,n+=i.rowSize)if(e.x!==void 0&&(l.push(o.getFloat32(n+e.x,this.littleEndian)),l.push(o.getFloat32(n+e.y,this.littleEndian)),l.push(o.getFloat32(n+e.z,this.littleEndian))),e.normal_x!==void 0&&(d.push(o.getFloat32(n+e.normal_x,this.littleEndian)),d.push(o.getFloat32(n+e.normal_y,this.littleEndian)),d.push(o.getFloat32(n+e.normal_z,this.littleEndian))),this.genColorByCoord){const t=this.genColorByCoord(o.getFloat32(n+e.x,this.littleEndian),o.getFloat32(n+e.y,this.littleEndian),o.getFloat32(n+e.z,this.littleEndian)).map(s=>s/255);h.push(...t)}}const g=new THREE.BufferGeometry;l.length>0&&g.setAttribute("position",new THREE.Float32BufferAttribute(l,3)),d.length>0&&g.setAttribute("normal",new THREE.Float32BufferAttribute(d,3)),h.length>0&&g.setAttribute("color",new THREE.Float32BufferAttribute(h,3)),g.computeBoundingSphere();const y=new THREE.PointsMaterial({size:.01});return h.length>0?y.vertexColors=!0:y.color.setHex(16777215),new THREE.Points(g,y)}genColorByCoord(p,m,f){return f<=0?[128,128,128]:f<5?[255,0,0]:f<10?[0,255,0]:[0,0,255]}}exports.PCDLoader=PCDLoader;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils");class PCDLoader extends THREE.Loader{constructor(a){super(a);this.littleEndian=!0}load(a,c,h,g){const i=this,l=new THREE.FileLoader(i.manager);l.setPath(i.path),l.setResponseType("arraybuffer"),l.setRequestHeader(i.requestHeader),l.setWithCredentials(i.withCredentials),l.load(a,function(d){try{c(i.parse(d))}catch(u){g?g(u):console.error(u),i.manager.itemError(a)}},h,g)}parse(a){function c(s,e){const p=s.length,n=new Uint8Array(e);let r=0,t=0,o,w,f;do if(o=s[r++],o<1<<5){if(o++,t+o>e)throw new Error("Output buffer is not large enough");if(r+o>p)throw new Error("Invalid compressed data");do n[t++]=s[r++];while(--o)}else{if(w=o>>5,f=t-((o&31)<<8)-1,r>=p)throw new Error("Invalid compressed data");if(w===7&&(w+=s[r++],r>=p))throw new Error("Invalid compressed data");if(f-=s[r++],t+w+2>e)throw new Error("Output buffer is not large enough");if(f<0)throw new Error("Invalid compressed data");if(f>=t)throw new Error("Invalid compressed data");do n[t++]=n[f++];while(--w+2)}while(r<p);return n}function h(s){const e={},p=s.search(/[\n\r]data\s(\S*)\s/i),n=/[\n\r]data\s(\S*)\s/i.exec(s.slice(p-1));if(e.data=n[1],e.headerLen=n[0].length+p,e.str=s.slice(0,e.headerLen),e.str=e.str.replace(/#.*/gi,""),e.version=/version (.*)/i.exec(e.str),e.fields=/fields (.*)/i.exec(e.str),e.size=/size (.*)/i.exec(e.str),e.type=/type (.*)/i.exec(e.str),e.count=/count (.*)/i.exec(e.str),e.width=/width (.*)/i.exec(e.str),e.height=/height (.*)/i.exec(e.str),e.viewpoint=/viewpoint (.*)/i.exec(e.str),e.points=/points (.*)/i.exec(e.str),e.version!==null&&(e.version=parseFloat(e.version[1])),e.fields=e.fields!==null?e.fields[1].split(" "):[],e.type!==null&&(e.type=e.type[1].split(" ")),e.width!==null&&(e.width=parseInt(e.width[1])),e.height!==null&&(e.height=parseInt(e.height[1])),e.viewpoint!==null&&(e.viewpoint=e.viewpoint[1]),e.points!==null&&(e.points=parseInt(e.points[1],10)),e.points===null&&(e.points=e.width*e.height),e.size!==null&&(e.size=e.size[1].split(" ").map(function(t){return parseInt(t,10)})),e.count!==null)e.count=e.count[1].split(" ").map(function(t){return parseInt(t,10)});else{e.count=[];for(let t=0,o=e.fields.length;t<o;t++)e.count.push(1)}e.offset={};let r=0;for(let t=0,o=e.fields.length;t<o;t++)e.data==="ascii"?e.offset[e.fields[t]]=t:(e.offset[e.fields[t]]=r,r+=e.size[t]*e.count[t]);return e.rowSize=r,e}const g=THREE.LoaderUtils.decodeText(new Uint8Array(a)),i=h(g),l=[],d=[],u=[];if(i.data==="ascii"){const{offset:s}=i,p=g.slice(i.headerLen).split(`
2
+ `);for(let n=0,r=p.length;n<r;n++){if(p[n]==="")continue;const t=p[n].split(" ");if(s.x!==void 0&&(l.push(parseFloat(t[s.x])),l.push(parseFloat(t[s.y])),l.push(parseFloat(t[s.z]))),this.genColorByZ){const w=this.genColorByZ(parseFloat(t[s.x]),parseFloat(t[s.y]),parseFloat(t[s.z])).map(f=>f/255);u.push(...w)}s.normal_x!==void 0&&(d.push(parseFloat(t[s.normal_x])),d.push(parseFloat(t[s.normal_y])),d.push(parseFloat(t[s.normal_z])))}}if(i.data==="binary_compressed"){const s=new Uint32Array(a.slice(i.headerLen,i.headerLen+8)),e=s[0],p=s[1],n=c(new Uint8Array(a,i.headerLen+8,e),p),r=new DataView(n.buffer),{offset:t}=i;for(let o=0;o<i.points;o++)if(t.x!==void 0&&(l.push(r.getFloat32(i.points*t.x+i.size[0]*o,this.littleEndian)),l.push(r.getFloat32(i.points*t.y+i.size[1]*o,this.littleEndian)),l.push(r.getFloat32(i.points*t.z+i.size[2]*o,this.littleEndian))),t.normal_x!==void 0&&(d.push(r.getFloat32(i.points*t.normal_x+i.size[4]*o,this.littleEndian)),d.push(r.getFloat32(i.points*t.normal_y+i.size[5]*o,this.littleEndian)),d.push(r.getFloat32(i.points*t.normal_z+i.size[6]*o,this.littleEndian))),this.genColorByZ){const f=this.genColorByZ(r.getFloat32(i.points*t.x+i.size[0]*o,this.littleEndian),r.getFloat32(i.points*t.y+i.size[0]*o,this.littleEndian),r.getFloat32(i.points*t.z+i.size[0]*o,this.littleEndian)).map(F=>F/255);u.push(...f)}}if(i.data==="binary"){const s=new DataView(a,i.headerLen),{offset:e}=i;for(let p=0,n=0;p<i.points;p++,n+=i.rowSize)if(e.x!==void 0&&(l.push(s.getFloat32(n+e.x,this.littleEndian)),l.push(s.getFloat32(n+e.y,this.littleEndian)),l.push(s.getFloat32(n+e.z,this.littleEndian))),e.normal_x!==void 0&&(d.push(s.getFloat32(n+e.normal_x,this.littleEndian)),d.push(s.getFloat32(n+e.normal_y,this.littleEndian)),d.push(s.getFloat32(n+e.normal_z,this.littleEndian))),this.genColorByZ){const t=this.genColorByZ(s.getFloat32(n+e.x,this.littleEndian),s.getFloat32(n+e.y,this.littleEndian),s.getFloat32(n+e.z,this.littleEndian)).map(o=>o/255);u.push(...t)}}const x=new THREE.BufferGeometry;l.length>0&&x.setAttribute("position",new THREE.Float32BufferAttribute(l,3)),d.length>0&&x.setAttribute("normal",new THREE.Float32BufferAttribute(d,3)),u.length>0&&x.setAttribute("color",new THREE.Float32BufferAttribute(u,3)),x.computeBoundingSphere();const y=new THREE.PointsMaterial({size:.01});return u.length>0?y.vertexColors=!0:y.color.setHex(16777215),new THREE.Points(x,y)}genColorByCoord(a,c,h){return h<=0?[128,128,128]:h<5?[255,0,0]:h<10?[0,255,0]:[0,0,255]}genColorByZ(a,c,h){const g=getIndex(h),i=lbUtils.COLOR_MAP_JET[g];return[i[0],i[1],i[2]]}}function getIndex(m){const a=-7,c=3,h=c-a;return m<a&&(m=a),m>c&&(m=c),Math.floor((m-a)/h*255)}exports.PCDLoader=PCDLoader;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),tool=require("../../constant/tool.js"),CanvasScheduler=require("../../newCore/CanvasScheduler.js"),index=require("./index.js"),pointCloud2dOperation=require("../toolOperation/pointCloud2dOperation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,t,e)=>t in o?__defProp(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,__spreadValues=(o,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(o,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(o,e,t[e]);return o},__spreadProps=(o,t)=>__defProps(o,__getOwnPropDescs(t));const createEmptyImage=o=>{const t=document.createElement("canvas");t.width=o.width,t.height=o.height;const e=t.getContext("2d");return e?(e.fillStyle="black",e.fillRect(0,0,o.width,o.height),t.toDataURL()):""};class PointCloudAnnotation{constructor({size:t,container:e,pcdPath:n,polygonOperationProps:c,config:s,checkMode:P}){this.updatePolygonList=(_,v)=>{let u=_.map(i=>{var a;const{polygon2d:p}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(i);return{id:i.id,sourceID:"",pointList:p,isRect:!0,valid:(a=i.valid)!=null?a:!0,attribute:i.attribute}});v&&(u=u.concat(v.map(i=>{var a;return __spreadProps(__spreadValues({},i),{pointList:(a=i==null?void 0:i.pointList)==null?void 0:a.map(p=>lbUtils.PointCloudUtils.transferWorld2Canvas(p,this.pointCloud2dOperation.size))})}))),this.pointCloud2dOperation.setResult(u)};var h,C;const f=this.getDefaultOrthographic(t),m=createEmptyImage(t),g=new Image;g.src=m;const l=new CanvasScheduler.CanvasScheduler({container:e}),d=new index.PointCloud({container:e,noAppend:!0,isOrthographicCamera:!0,orthographicParams:f});n&&d.loadPCDFile(n),l.createCanvas(d.renderer.domElement);const O={container:e,size:t,config:JSON.stringify(s),imgNode:g,isAppend:!1,checkMode:P};c&&Object.assign(O,c);const r=new pointCloud2dOperation(O);r.eventBinding(),r.setPattern(tool.EPolygonPattern.Rect),r.setDefaultAttribute((C=(h=s==null?void 0:s.attributeList)==null?void 0:h[0])==null?void 0:C.value),l.createCanvas(r.canvas,{size:t}),this.pointCloud2dOperation=r,this.pointCloudInstance=d,this.canvasScheduler=l,this.config=s}updateConfig(t){this.config=t,this.pointCloud2dOperation.setConfig(JSON.stringify(t))}getDefaultOrthographic(t){return{left:-t.width/2,right:t.width/2,top:t.height/2,bottom:-t.height/2,near:100,far:-100}}initSize(t){this.pointCloudInstance.updateTopCamera(),this.pointCloudInstance.setDefaultControls(),this.pointCloudInstance.initRenderer(),this.pointCloudInstance.initOrthographicCamera(this.getDefaultOrthographic(t)),this.pointCloudInstance.render();const e=createEmptyImage(t),n=new Image;n.src=e,n.onload=()=>{this.pointCloud2dOperation.setImgNode(n),this.pointCloud2dOperation.initImgPos()},this.pointCloud2dOperation.setCanvasSize(t)}addPolygonListOnTopView(t){const e=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t),n=lbUtils.PointCloudUtils.getPolygonListFromResultList(t);this.updatePolygonList(e,n)}updateData(t,e,n){!this.pointCloud2dOperation||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,n==null?void 0:n.radius),this.addPolygonListOnTopView(e))}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}exports.PointCloudAnnotation=PointCloudAnnotation;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),tool=require("../../constant/tool.js"),CanvasScheduler=require("../../newCore/CanvasScheduler.js"),index=require("./index.js"),pointCloud2dOperation=require("../toolOperation/pointCloud2dOperation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,o)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,__spreadValues=(e,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(e,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(e,o,t[o]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const createEmptyImage=e=>{const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const o=t.getContext("2d");return o?(o.fillStyle="black",o.fillRect(0,0,e.width,e.height),t.toDataURL()):""};class PointCloudAnnotation{constructor({size:t,container:o,pcdPath:n,polygonOperationProps:u,config:c,checkMode:O}){this.updatePolygonList=(m,C)=>{let d=m.map(i=>{var r;const{polygon2d:p}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(i);return{id:i.id,sourceID:"",pointList:p,isRect:!0,valid:(r=i.valid)!=null?r:!0,attribute:i.attribute}});C&&(d=d.concat(C.map(i=>{var r;return __spreadProps(__spreadValues({},i),{pointList:(r=i==null?void 0:i.pointList)==null?void 0:r.map(p=>lbUtils.PointCloudUtils.transferWorld2Canvas(p,this.pointCloud2dOperation.size))})}))),this.pointCloud2dOperation.setResult(d)};const P=this.getDefaultOrthographic(t),f=createEmptyImage(t),h=new Image;h.src=f;const s=new CanvasScheduler.CanvasScheduler({container:o}),l=new index.PointCloud({container:o,noAppend:!0,isOrthographicCamera:!0,orthographicParams:P});n&&l.loadPCDFile(n),s.createCanvas(l.renderer.domElement);const g={container:o,size:t,config:JSON.stringify(c),imgNode:h,isAppend:!1,checkMode:O};u&&Object.assign(g,u);const a=new pointCloud2dOperation(g);a.eventBinding(),a.setPattern(tool.EPolygonPattern.Rect),s.createCanvas(a.canvas,{size:t}),this.pointCloud2dOperation=a,this.pointCloudInstance=l,this.canvasScheduler=s,this.config=c}updateConfig(t){this.config=t,this.pointCloud2dOperation.setConfig(JSON.stringify(t))}getDefaultOrthographic(t){return{left:-t.width/2,right:t.width/2,top:t.height/2,bottom:-t.height/2,near:100,far:-100}}initSize(t){this.pointCloudInstance.updateTopCamera(),this.pointCloudInstance.setDefaultControls(),this.pointCloudInstance.initRenderer(),this.pointCloudInstance.initOrthographicCamera(this.getDefaultOrthographic(t)),this.pointCloudInstance.render();const o=createEmptyImage(t),n=new Image;n.src=o,n.onload=()=>{this.pointCloud2dOperation.setImgNode(n),this.pointCloud2dOperation.initImgPos()},this.pointCloud2dOperation.setCanvasSize(t)}addPolygonListOnTopView(t){const o=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t),n=lbUtils.PointCloudUtils.getPolygonListFromResultList(t);this.updatePolygonList(o,n)}updateData(t,o,n){!this.pointCloud2dOperation||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,n==null?void 0:n.radius),this.addPolygonListOnTopView(o))}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}exports.PointCloudAnnotation=PointCloudAnnotation;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var PCDLoader=require("./PCDLoader.js");class PointCloudCache{constructor(){this.MAX_SIZE=50,this.cacheList=[],this.loadPCDFile=e=>new Promise((s,a)=>{var i;const n=(i=this.pointsMap.get(e))==null?void 0:i.clone();if(n){s(n);return}if(this.cacheList.length>this.MAX_SIZE){const t=this.cacheList.shift();t&&this.pointsMap.delete(t.src)}this.cacheList.push({src:e}),this.pcdLoader.load(e,t=>{this.pointsMap.set(e,t.clone()),s(t)},()=>{},t=>{a(t)})}),this.pcdLoader=new PCDLoader.PCDLoader,this.pointsMap=new Map}static getInstance(){return this.instance==null&&(this.instance=new PointCloudCache),this.instance}}exports.PointCloudCache=PointCloudCache;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var PCDLoader=require("./PCDLoader.js");class PointCloudCache{constructor(){this.MAX_SIZE=50,this.cacheList=[],this.loadPCDFile=t=>new Promise((s,n)=>{const o=this.pointsMap.get(t),i=this.colorMap.get(t);if(o&&i){s({points:o,color:i});return}if(this.cacheList.length>this.MAX_SIZE){const e=this.cacheList.shift();e&&this.pointsMap.delete(e.src)}this.cacheList.push({src:t}),this.pcdLoader.load(t,e=>{const r=e.geometry.attributes.position.array,a=e.geometry.attributes.color.array;this.pointsMap.set(t,r),this.colorMap.set(t,a),s({points:r,color:a})},()=>{},e=>{n(e)})}),this.pcdLoader=new PCDLoader.PCDLoader,this.pointsMap=new Map,this.colorMap=new Map}static getInstance(){return this.instance==null&&(this.instance=new PointCloudCache),this.instance}updateColor(t,s){this.colorMap.set(t,s)}}exports.PointCloudCache=PointCloudCache;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils"),highlightWorker=require("../../_virtual/highlightWorker.js"),filterBoxWorker=require("../../_virtual/filterBoxWorker.js"),polygonTool=require("../../utils/tool/polygonTool.js"),uuid=require("../../utils/uuid.js"),PCDLoader=require("./PCDLoader.js"),OrbitControls=require("./OrbitControls.js"),cache=require("./cache.js"),matrix=require("./matrix.js");require("../../constant/tool.js"),require("../../constant/annotation.js"),require("../../utils/MathUtils.js"),require("@turf/turf"),require("../../utils/tool/CommonToolUtils.js"),require("../../utils/tool/LineToolUtils.js"),require("../../utils/tool/DrawUtils.js"),require("../../constant/keyCode.js"),require("../../locales/index.js"),require("../../locales/constants.js"),require("lodash"),require("../../constant/style.js"),require("../../utils/tool/CanvasUtils.js"),require("../../utils/tool/ZoomUtils.js");function _interopNamespace(p){if(p&&p.__esModule)return p;var t=Object.create(null);return p&&Object.keys(p).forEach(function(e){if(e!=="default"){var r=Object.getOwnPropertyDescriptor(p,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:function(){return p[e]}})}}),t.default=p,Object.freeze(t)}var THREE__namespace=_interopNamespace(THREE),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(p,t,e)=>t in p?__defProp(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e,__spreadValues=(p,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(p,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(p,e,t[e]);return p},__spreadProps=(p,t)=>__defProps(p,__getOwnPropDescs(t)),__async=(p,t,e)=>new Promise((r,n)=>{var s=o=>{try{i(e.next(o))}catch(c){n(c)}},a=o=>{try{i(e.throw(o))}catch(c){n(c)}},i=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);i((e=e.apply(p,t)).next())});const DEFAULT_DISTANCE=30;new highlightWorker;class PointCloud{constructor({container:t,noAppend:e,isOrthographicCamera:r,orthographicParams:n,backgroundColor:s="black",config:a}){this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.showDirection=!0,this.AddBoxToSense=(i,o=16777215)=>{var c;const h=(c=i.id)!=null?c:uuid();this.removeObjectByName(h);const{center:l,width:d,height:x,depth:g,rotation:m}=i,u=new THREE__namespace.Group,y=new THREE__namespace.BoxGeometry(d,x,g),w=new THREE__namespace.MeshBasicMaterial({color:"blue"}),f=new THREE__namespace.Mesh(y,w),v=new THREE__namespace.BoxHelper(f,o),P=this.generateBoxArrow(i);u.add(v),u.add(P),u.position.set(l.x,l.y,l.z),u.rotation.set(0,0,m),u.name=h,this.scene.add(u)},this.overridePointShader=i=>{i.vertexShader=`
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils"),highlightWorker$1=require("../../_virtual/highlightWorker.js"),filterBoxWorker=require("../../_virtual/filterBoxWorker.js"),polygonTool=require("../../utils/tool/polygonTool.js"),uuid=require("../../utils/uuid.js"),PCDLoader=require("./PCDLoader.js"),OrbitControls=require("./OrbitControls.js"),cache=require("./cache.js"),matrix=require("./matrix.js");require("../../constant/tool.js"),require("../../constant/annotation.js"),require("../../utils/MathUtils.js"),require("@turf/turf"),require("../../utils/tool/CommonToolUtils.js"),require("../../utils/tool/LineToolUtils.js"),require("../../utils/tool/DrawUtils.js"),require("../../constant/keyCode.js"),require("../../locales/index.js"),require("../../locales/constants.js"),require("lodash"),require("../../constant/style.js"),require("../../utils/tool/CanvasUtils.js"),require("../../utils/tool/ZoomUtils.js");function _interopNamespace(d){if(d&&d.__esModule)return d;var t=Object.create(null);return d&&Object.keys(d).forEach(function(e){if(e!=="default"){var r=Object.getOwnPropertyDescriptor(d,e);Object.defineProperty(t,e,r.get?r:{enumerable:!0,get:function(){return d[e]}})}}),t.default=d,Object.freeze(t)}var THREE__namespace=_interopNamespace(THREE),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(d,t,e)=>t in d?__defProp(d,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[t]=e,__spreadValues=(d,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(d,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(d,e,t[e]);return d},__spreadProps=(d,t)=>__defProps(d,__getOwnPropDescs(t)),__async=(d,t,e)=>new Promise((r,n)=>{var s=o=>{try{i(e.next(o))}catch(c){n(c)}},a=o=>{try{i(e.throw(o))}catch(c){n(c)}},i=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);i((e=e.apply(d,t)).next())});const DEFAULT_DISTANCE=30,highlightWorker=new highlightWorker$1({type:"module"});class PointCloud{constructor({container:t,noAppend:e,isOrthographicCamera:r,orthographicParams:n,backgroundColor:s="black",config:a}){this.zAxisLimit=10,this.initCameraPosition=this.DEFAULT_INIT_CAMERA_POSITION,this.isOrthographicCamera=!1,this.pointsUuid="",this.pointCloudObjectName="pointCloud",this.rangeObjectName="range",this.showDirection=!0,this.AddBoxToSense=(i,o=16777215)=>{var c;const h=(c=i.id)!=null?c:uuid();this.removeObjectByName(h);const{center:l,width:u,height:m,depth:x,rotation:y}=i,p=new THREE__namespace.Group,w=new THREE__namespace.BoxGeometry(u,m,x),g=new THREE__namespace.MeshBasicMaterial({color:"blue"}),f=new THREE__namespace.Mesh(w,g),C=new THREE__namespace.BoxHelper(f,o),P=this.generateBoxArrow(i);p.add(C),p.add(P),p.position.set(l.x,l.y,l.z),p.rotation.set(0,0,y),p.name=h,this.scene.add(p)},this.overridePointShader=i=>{i.vertexShader=`
2
2
  attribute float sizes;
3
3
  attribute float visibility;
4
4
  varying float vVisible;
@@ -8,4 +8,4 @@
8
8
  varying float vVisible;
9
9
  ${i.fragmentShader}`.replace("#include <clipping_planes_fragment>",`
10
10
  if (vVisible < 0.5) discard;
11
- #include <clipping_planes_fragment>`)},this.loadPCDFile=(i,o)=>__async(this,null,function*(){this.clearPointCloud();const c=yield this.cacheInstance.loadPCDFile(i);c.name=this.pointCloudObjectName,this.renderPointCloud(c,o)}),this.loadPCDFileByBox=(i,o,c)=>__async(this,null,function*(){const h=d=>__async(this,null,function*(){const{width:x=0,height:g=0,depth:m=0}=c!=null?c:{},u=yield this.filterPointsByBox(__spreadProps(__spreadValues({},o),{width:o.width+x,height:o.height+g,depth:o.depth+m}),d);if(!u){console.error("filter Error");return}this.clearPointCloud();const y=new THREE__namespace.Points(u.geometry,d.material);y.name=this.pointCloudObjectName,this.scene.add(y),this.render()}),l=yield this.cacheInstance.loadPCDFile(i);h(l)}),this.generateRange=i=>{const o=this.createRange(i);this.scene.add(o)},this.generateBoxArrow=({width:i})=>{const o=new THREE__namespace.Vector3(1,0,0),c=new THREE__namespace.Vector3(i/2,0,0),h=2,l=16776960,d=new THREE__namespace.ArrowHelper(o,c,h,l);return d.visible=this.showDirection,d},this.generateBoxTrackID=i=>{if(!i.trackID)return;const o=new THREE__namespace.Texture(this.getTextCanvas(i.trackID.toString()));o.needsUpdate=!0;const c=new THREE__namespace.SpriteMaterial({map:o,depthWrite:!1}),h=new THREE__namespace.Sprite(c);return h.scale.set(5,5,5),h.position.set(-i.width/2,0,i.depth/2+.5),h},this.applyZAxisPoints=i=>{this.zAxisLimit=i,this.filterZAxisPoints(),this.render()},this.updatePointSize=i=>{const o=this.scene.getObjectByName(this.pointCloudObjectName);if(!o)return;const c=o.material.size;i?o.material.size=Math.min(c*1.2,10):o.material.size=Math.max(c/1.2,1),this.render()},this.container=t,this.renderer=new THREE__namespace.WebGLRenderer({antialias:!0}),this.backgroundColor=s,this.config=a,r&&n?(this.isOrthographicCamera=!0,this.camera=new THREE__namespace.OrthographicCamera(n.left,n.right,n.top,n.bottom,n.near,n.far)):this.camera=new THREE__namespace.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new THREE__namespace.Scene,this.controls=new OrbitControls.OrbitControls(this.camera,this.renderer.domElement),this.pcdLoader=new PCDLoader.PCDLoader,this.axesHelper=new THREE__namespace.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=cache.PointCloudCache.getInstance()}get DEFAULT_INIT_CAMERA_POSITION(){return new THREE__namespace.Vector3(-1,0,10)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){this.config=t}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:r,top:n,bottom:s,near:a,far:i}=t;this.camera.left=e,this.camera.right=r,this.camera.top=n,this.camera.bottom=s,this.camera.near=a,this.camera.far=i,this.camera.updateProjectionMatrix()}initPerspectiveCamera(){this.camera.type==="PerspectiveCamera"&&(this.camera.fov=30,this.camera.aspect=this.containerWidth/this.containerHeight,this.camera.near=1,this.camera.far=1e3,this.camera.updateProjectionMatrix())}initCamera(){const{camera:t}=this;if(this.isOrthographicCamera){const{x:e,y:r,z:n}=this.initCameraPosition;t.position.set(e,r,n)}else t.position.set(-1,0,500);t.up.set(0,0,1)}initControls(){const{controls:t}=this;t.addEventListener("change",()=>{this.render()}),this.setDefaultControls()}setDefaultControls(){const{controls:t}=this,e=[0,0,0];t.target=new THREE__namespace.Vector3(...e),t.addEventListener("change",()=>{this.render()}),t.maxPolarAngle=Math.PI/2,t.update()}initRenderer(){const{renderer:t}=this;t.setPixelRatio(window.devicePixelRatio),t.setSize(this.containerWidth,this.containerHeight)}init(){const{scene:t}=this;t.background=new THREE__namespace.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t){const e=this.scene.getObjectByName(t);e&&e.removeFromParent()}generateBox(t,e=16777215){var r,n,s,a,i;let o=e;((r=this.config)==null?void 0:r.attributeList)&&((s=(n=this.config)==null?void 0:n.attributeList)==null?void 0:s.length)>0&&t.attribute&&(o=(i=(a=lbUtils.toolStyleConverter.getColorFromConfig({attribute:t.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{}))==null?void 0:a.hex)!=null?i:e),this.AddBoxToSense(t,o),this.render()}generateBoxes(t){t.forEach(e=>{this.generateBox(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:r,height:n}=t,s=10,a=e.x-r/2-s,i=e.x-r/2+s,o=e.y+n/2+s,c=e.y-n/2-s,h=100,l=-100,d=500/h;return{left:a,right:i,top:o,bottom:c,near:h,far:l,zoom:d}}updateCameraByBox(t,e){const{center:r,width:n,height:s,depth:a,rotation:i}=t,o=this.getCameraVector(r,i,{width:n,height:s,depth:a},e);return this.updateCamera(o,r),o}updateOrthoCamera(t,e){const r=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:r}}updateTopCamera(){this.setInitCameraPosition(this.DEFAULT_INIT_CAMERA_POSITION),this.camera.zoom=1,this.initCamera(),this.setDefaultControls(),this.camera.updateProjectionMatrix(),this.render()}updateCamera(t,e){this.camera.position.set(t.x,t.y,t.z),this.controls.target=new THREE__namespace.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera({x:-1,y:0,z:500},{x:0,y:0,z:0})}createThreeMatrix4(t){return new THREE__namespace.Matrix4().set(...t)}filterPointsByBox(t,e){if(!e){const r=this.scene.getObjectByName(this.pointCloudObjectName);if(!r)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=r}if(window.Worker){const{zMin:r,zMax:n,polygonPointList:s}=matrix.getCuboidFromPointCloudBox(t),a=e.geometry.attributes.position.array,i=e.geometry.attributes.color.array,o={boxParams:t,zMin:r,zMax:n,polygonPointList:s,color:i,position:a};return new Promise(c=>{const h=new filterBoxWorker;h.postMessage(o),h.onmessage=l=>{const{color:d,position:x,num:g}=l.data,m=new THREE__namespace.BufferGeometry;m.setAttribute("position",new THREE__namespace.Float32BufferAttribute(x,3)),m.setAttribute("color",new THREE__namespace.Float32BufferAttribute(d,3)),m.computeBoundingSphere(),h.terminate(),c({geometry:m,num:g})}})}return Promise.resolve(void 0)}getCameraVector(t,e,r,n=lbUtils.EPerspectiveView.Front,s=DEFAULT_DISTANCE){let a=lbUtils.PerspectiveShiftUtils.frontViewMatrix4(s);switch(n){case lbUtils.EPerspectiveView.Front:break;case lbUtils.EPerspectiveView.Back:a=lbUtils.PerspectiveShiftUtils.backViewMatrix4(s);break;case lbUtils.EPerspectiveView.Left:a=lbUtils.PerspectiveShiftUtils.leftViewMatrix4(s);break;case lbUtils.EPerspectiveView.Right:a=lbUtils.PerspectiveShiftUtils.rightViewMatrix4(s);break;case lbUtils.EPerspectiveView.Top:a=lbUtils.PerspectiveShiftUtils.topViewMatrix4(s);break;case lbUtils.EPerspectiveView.LFT:a=lbUtils.PerspectiveShiftUtils.leftFrontTopViewMatrix4(s,r);break;case lbUtils.EPerspectiveView.RBT:a=lbUtils.PerspectiveShiftUtils.rightBackTopViewMatrix4(s,r);break}const i=this.createThreeMatrix4(a),o=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z),c=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),h=new THREE__namespace.Matrix4().makeRotationZ(e);return new THREE__namespace.Vector3(t.x,t.y,t.z).clone().applyMatrix4(i).applyMatrix4(o).applyMatrix4(h).applyMatrix4(c)}createRange(t){this.removeObjectByName(this.rangeObjectName);const r=new THREE__namespace.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),n=new THREE__namespace.BufferGeometry().setFromPoints(r),s=new THREE__namespace.LineBasicMaterial({color:16711680}),a=new THREE__namespace.Line(n,s);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.material.size=1,t.name=this.pointCloudObjectName;const r=new THREE__namespace.PointsMaterial({vertexColors:!0});r.onBeforeCompile=this.overridePointShader,e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=r,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}highlightOriginPointCloud(t){}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(r=>{r.type==="ArrowHelper"&&(r.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),r=e.getContext("2d");return r&&(r.font=`${50}px " bold`,r.fillStyle="white",r.textAlign="center",r.textBaseline="middle",r.fillText(t,e.width/2,e.height/2)),e}getSensesPointZAxisInPolygon(t,e){const r=this.scene.children.find(o=>o.uuid===this.pointsUuid);let n=0,s=0,a=0,i=0;if(r&&(r==null?void 0:r.geometry)){const o=r==null?void 0:r.geometry.attributes.position.array;for(let c=0;c<o.length;c+=3){const h=o[c],l=o[c+1],d=o[c+2];polygonTool.isInPolygon({x:h,y:l},t)&&d&&(s=Math.max(d,s),n=Math.min(d,n),i++,e&&d>=e[0]&&d<=e[1]&&a++)}}return{maxZ:s,minZ:n,count:a,zCount:i}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,r=this.containerHeight/2;return{x:t.x*e+e,y:t.y*r+r,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new THREE__namespace.Matrix4().set(t,0,0,t,0,e,0,e,0,0,1,0,0,0,0,1)}getCanvas2BasicCoordinate(t){const e=this.containerWidth/2,r=this.containerHeight/2;return new THREE__namespace.Vector3(t.x/e-e/2,-(t.y/r-r/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e+a/2,y:r+s/2,z:n-i/2},c={x:e+a/2,y:r+s/2,z:n+i/2},h={x:e-a/2,y:r+s/2,z:n+i/2},l={x:e-a/2,y:r+s/2,z:n-i/2};return[o,c,h,l]}getPolygonBackPoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e-a/2,y:r+s/2,z:n+i/2},c={x:e-a/2,y:r+s/2,z:n-i/2},h={x:e-a/2,y:r-s/2,z:n-i/2},l={x:e-a/2,y:r-s/2,z:n+i/2};return[o,c,h,l]}getPolygonTopPoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e+a/2,y:r+s/2,z:n+i/2},c={x:e+a/2,y:r-s/2,z:n+i/2},h={x:e-a/2,y:r-s/2,z:n+i/2},l={x:e-a/2,y:r+s/2,z:n+i/2};return[o,c,h,l]}getModelTransformationMatrix(t){const{center:{x:e,y:r,z:n},rotation:s}=t,a=new THREE__namespace.Matrix4().makeTranslation(-e,-r,-n),i=new THREE__namespace.Matrix4().makeTranslation(e,r,n),o=new THREE__namespace.Matrix4().makeRotationZ(s);return new THREE__namespace.Matrix4().multiply(i).multiply(o).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Back)}boxParams2ViewPolygon(t,e){switch(e){case lbUtils.EPerspectiveView.Left:return this.getPolygonSidePoints(t);case lbUtils.EPerspectiveView.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const r=this.boxParams2ViewPolygon(t,e),{width:n,height:s}=t,a=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),i=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=i;const o=r.map(l=>new THREE__namespace.Vector3(l.x,l.y,l.z)).map(l=>l.applyMatrix4(this.sideMatrix)),c=this.containerWidth/n,h=this.containerHeight/s;return{polygon2d:o,zoom:Math.min(c,h)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:r}=t,s=this.getPolygonTopPoints(t).map(o=>new THREE__namespace.Vector3(o.x,o.y,o.z)).map(o=>o.applyMatrix4(this.getModelTransformationMatrix(t))).map(o=>({x:o.y,y:o.x})).map(o=>({x:-(o.x-this.containerWidth/2),y:-(o.y-this.containerHeight/2)})),a=this.containerWidth/e,i=this.containerHeight/r;return{polygon2d:s,zoom:Math.min(a,i)/2}}getNewBoxBySideUpdate(t,e,r,n){const s=new THREE__namespace.Matrix4().makeRotationZ(n.rotation),a=new THREE__namespace.Vector3(-t.x,0,0).applyMatrix4(s);let i=n;return i.center={x:i.center.x+a.x,y:i.center.y+a.y,z:i.center.z-t.z},i=__spreadProps(__spreadValues({},i),{width:i.width+e,height:i.height,depth:i.depth+r}),{newBoxParams:i}}getNewBoxByBackUpdate(t,e,r,n){const s=new THREE__namespace.Matrix4().makeRotationZ(n.rotation),a=new THREE__namespace.Vector3(0,-t.x,0).applyMatrix4(s);let i=n;return i.center={x:i.center.x+a.x,y:i.center.y+a.y,z:i.center.z-t.z},i=__spreadProps(__spreadValues({},i),{width:i.width,height:i.height+e,depth:i.depth+r}),{newBoxParams:i}}getNewBoxBySideUpdateByPoints(t,e,r,n){var s;const a=(s=this.sideMatrix)==null?void 0:s.invert();if(!this.sideMatrix||!a){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const i=t.map(u=>new THREE__namespace.Vector3(u.x,u.y,u.z)).map(u=>u.applyMatrix4(a)),[o,c,h,l]=i,d=Math.max(Math.abs(o.x-h.x),Math.abs(o.x-c.x)),g=c.add(l).applyMatrix3(new THREE__namespace.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new THREE__namespace.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new THREE__namespace.Vector3(n.center.x,n.center.y,n.center.z));return{newBoxParams:__spreadProps(__spreadValues({},n),{center:{x:n.center.x-g.x,y:n.center.y-g.y,z:n.center.z-r},width:d,height:n.height,depth:n.depth+e,rotation:n.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(r=>r.uuid===this.pointsUuid);if(e){const{attributes:r}=e.geometry,{position:n}=r,s=[],{count:a}=n;for(let i=0;i<a;i++){const o=n.getZ(i);s.push(o>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new THREE__namespace.Float32BufferAttribute(s,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.lidar2image=matrix.lidar2image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloud=PointCloud;
11
+ #include <clipping_planes_fragment>`)},this.loadPCDFile=(i,o)=>__async(this,null,function*(){this.clearPointCloud(),this.currentPCDSrc=i;const{points:c,color:h}=yield this.cacheInstance.loadPCDFile(i),l=new THREE__namespace.BufferGeometry;l.setAttribute("position",new THREE__namespace.BufferAttribute(c,3)),l.setAttribute("color",new THREE__namespace.BufferAttribute(h,3));const u=new THREE__namespace.Points(l);this.renderPointCloud(u,o)}),this.loadPCDFileByBox=(i,o,c)=>__async(this,null,function*(){const h=(m,x)=>__async(this,null,function*(){const{width:y=0,height:p=0,depth:w=0}=c!=null?c:{},g=yield this.filterPointsByBox(__spreadProps(__spreadValues({},o),{width:o.width+y,height:o.height+p,depth:o.depth+w}),m,x);if(!g){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=i;const f=new THREE__namespace.Points(g.geometry);f.name=this.pointCloudObjectName,this.scene.add(f),this.render()}),{points:l,color:u}=yield this.cacheInstance.loadPCDFile(i);h(l,u)}),this.generateRange=i=>{const o=this.createRange(i);this.scene.add(o)},this.generateBoxArrow=({width:i})=>{const o=new THREE__namespace.Vector3(1,0,0),c=new THREE__namespace.Vector3(i/2,0,0),h=2,l=16776960,u=new THREE__namespace.ArrowHelper(o,c,h,l);return u.visible=this.showDirection,u},this.generateBoxTrackID=i=>{if(!i.trackID)return;const o=new THREE__namespace.Texture(this.getTextCanvas(i.trackID.toString()));o.needsUpdate=!0;const c=new THREE__namespace.SpriteMaterial({map:o,depthWrite:!1}),h=new THREE__namespace.Sprite(c);return h.scale.set(5,5,5),h.position.set(-i.width/2,0,i.depth/2+.5),h},this.applyZAxisPoints=i=>{this.zAxisLimit=i,this.filterZAxisPoints(),this.render()},this.updatePointSize=i=>{const o=this.scene.getObjectByName(this.pointCloudObjectName);if(!o)return;const c=o.material.size;i?o.material.size=Math.min(c*1.2,10):o.material.size=Math.max(c/1.2,1),this.render()},this.container=t,this.renderer=new THREE__namespace.WebGLRenderer({antialias:!0}),this.backgroundColor=s,this.config=a,r&&n?(this.isOrthographicCamera=!0,this.camera=new THREE__namespace.OrthographicCamera(n.left,n.right,n.top,n.bottom,n.near,n.far)):this.camera=new THREE__namespace.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new THREE__namespace.Scene,this.controls=new OrbitControls.OrbitControls(this.camera,this.renderer.domElement),this.pcdLoader=new PCDLoader.PCDLoader,this.axesHelper=new THREE__namespace.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=cache.PointCloudCache.getInstance()}get DEFAULT_INIT_CAMERA_POSITION(){return new THREE__namespace.Vector3(-.01,0,10)}get containerWidth(){return this.container.clientWidth}get containerHeight(){return this.container.clientHeight}setInitCameraPosition(t){this.initCameraPosition=t}setConfig(t){this.config=t}initOrthographicCamera(t){if(this.camera.type!=="OrthographicCamera")return;const{left:e,right:r,top:n,bottom:s,near:a,far:i}=t;this.camera.left=e,this.camera.right=r,this.camera.top=n,this.camera.bottom=s,this.camera.near=a,this.camera.far=i,this.camera.updateProjectionMatrix()}initPerspectiveCamera(){this.camera.type==="PerspectiveCamera"&&(this.camera.fov=30,this.camera.aspect=this.containerWidth/this.containerHeight,this.camera.near=1,this.camera.far=1e3,this.camera.updateProjectionMatrix())}initCamera(){const{camera:t}=this;if(this.isOrthographicCamera){const{x:e,y:r,z:n}=this.initCameraPosition;t.position.set(e,r,n)}else t.position.set(-1,0,500);t.up.set(0,0,1)}initControls(){const{controls:t}=this;t.addEventListener("change",()=>{this.render()}),this.setDefaultControls()}setDefaultControls(){const{controls:t}=this,e=[0,0,0];t.target=new THREE__namespace.Vector3(...e),t.addEventListener("change",()=>{this.render()}),t.maxPolarAngle=Math.PI/2,t.update()}initRenderer(){const{renderer:t}=this;t.setPixelRatio(window.devicePixelRatio),t.setSize(this.containerWidth,this.containerHeight)}init(){const{scene:t}=this;t.background=new THREE__namespace.Color(this.backgroundColor),this.initControls(),this.initRenderer()}removeObjectByName(t){const e=this.scene.getObjectByName(t);e&&e.removeFromParent()}generateBox(t,e=16777215){const r=e;this.AddBoxToSense(t,r),this.render()}getAllAttributeColor(t){return t.reduce((e,r)=>(e[r.attribute]=lbUtils.toolStyleConverter.getColorFromConfig({attribute:r.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{}),e),{})}generateBoxes(t){t.forEach(e=>{this.generateBox(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:r,height:n}=t,s=10,a=e.x-r/2-s,i=e.x-r/2+s,o=e.y+n/2+s,c=e.y-n/2-s,h=100,l=-100,u=500/h;return{left:a,right:i,top:o,bottom:c,near:h,far:l,zoom:u}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e){const{center:r,width:n,height:s,depth:a,rotation:i}=t,o=this.getCameraVector(r,i,{width:n,height:s,depth:a},e);return this.updateCamera(o,r),o}updateOrthoCamera(t,e){const r=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:r}}updateTopCamera(){this.setInitCameraPosition(this.DEFAULT_INIT_CAMERA_POSITION),this.camera.zoom=1,this.initCamera(),this.setDefaultControls(),this.camera.updateProjectionMatrix(),this.render()}updateCamera(t,e){this.camera.position.set(t.x,t.y,t.z),this.controls.target=new THREE__namespace.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera(this.DEFAULT_INIT_CAMERA_POSITION,{x:0,y:0,z:0})}createThreeMatrix4(t){return new THREE__namespace.Matrix4().set(...t)}filterPointsByBox(t,e,r){var n,s,a;if(!e){const i=this.scene.getObjectByName(this.pointCloudObjectName);if(!i)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(a=(s=(n=i==null?void 0:i.geometry)==null?void 0:n.attributes)==null?void 0:s.position)==null?void 0:a.array}if(window.Worker){const{zMin:i,zMax:o,polygonPointList:c}=matrix.getCuboidFromPointCloudBox(t),h=e;r=r!=null?r:new Float32Array([]);const l={boxParams:t,zMin:i,zMax:o,polygonPointList:c,color:r,position:h};return new Promise(u=>{const m=new filterBoxWorker;m.postMessage(l),m.onmessage=x=>{const{color:y,position:p,num:w}=x.data,g=new THREE__namespace.BufferGeometry;g.setAttribute("position",new THREE__namespace.Float32BufferAttribute(p,3)),g.setAttribute("color",new THREE__namespace.Float32BufferAttribute(y,3)),g.computeBoundingSphere(),m.terminate(),u({geometry:g,num:w})}})}return Promise.resolve(void 0)}getCameraVector(t,e,r,n=lbUtils.EPerspectiveView.Front,s=DEFAULT_DISTANCE){let a=lbUtils.PerspectiveShiftUtils.frontViewMatrix4(s);switch(n){case lbUtils.EPerspectiveView.Front:break;case lbUtils.EPerspectiveView.Back:a=lbUtils.PerspectiveShiftUtils.backViewMatrix4(s);break;case lbUtils.EPerspectiveView.Left:a=lbUtils.PerspectiveShiftUtils.leftViewMatrix4(s);break;case lbUtils.EPerspectiveView.Right:a=lbUtils.PerspectiveShiftUtils.rightViewMatrix4(s);break;case lbUtils.EPerspectiveView.Top:a=lbUtils.PerspectiveShiftUtils.topViewMatrix4(s);break;case lbUtils.EPerspectiveView.LFT:a=lbUtils.PerspectiveShiftUtils.leftFrontTopViewMatrix4(s,r);break;case lbUtils.EPerspectiveView.RBT:a=lbUtils.PerspectiveShiftUtils.rightBackTopViewMatrix4(s,r);break}const i=this.createThreeMatrix4(a),o=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z),c=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),h=new THREE__namespace.Matrix4().makeRotationZ(e);return new THREE__namespace.Vector3(t.x,t.y,t.z).clone().applyMatrix4(i).applyMatrix4(o).applyMatrix4(h).applyMatrix4(c)}createRange(t){this.removeObjectByName(this.rangeObjectName);const r=new THREE__namespace.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),n=new THREE__namespace.BufferGeometry().setFromPoints(r),s=new THREE__namespace.LineBasicMaterial({color:16711680}),a=new THREE__namespace.Line(n,s);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const r=new THREE__namespace.PointsMaterial({vertexColors:!0});r.onBeforeCompile=this.overridePointShader,r.size=1.2,e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=r,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}highlightOriginPointCloud(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(!!e)return this.highlightPCDSrc=this.currentPCDSrc,new Promise(r=>{if(window.Worker){const s=(t?[...t]:[]).map(o=>matrix.getCuboidFromPointCloudBox(o)),a=this.getAllAttributeColor(s),i={cuboidList:s,position:e.geometry.attributes.position.array,color:e.geometry.attributes.color.array,colorList:a};highlightWorker.postMessage(i),highlightWorker.onmessage=o=>{const{color:c}=o.data,h=new THREE__namespace.BufferAttribute(c,3);this.highlightPCDSrc&&(this.cacheInstance.updateColor(this.highlightPCDSrc,c),this.highlightPCDSrc=void 0),h.needsUpdate=!0,e.geometry.setAttribute("color",h),r(c),this.render()}}})}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const r=new THREE__namespace.BufferAttribute(t,3);r.needsUpdate=!0,e.geometry.setAttribute("color",r),this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(r=>{r.type==="ArrowHelper"&&(r.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),r=e.getContext("2d");return r&&(r.font=`${50}px " bold`,r.fillStyle="white",r.textAlign="center",r.textBaseline="middle",r.fillText(t,e.width/2,e.height/2)),e}getSensesPointZAxisInPolygon(t,e){const r=this.scene.children.find(o=>o.uuid===this.pointsUuid);let n=0,s=0,a=0,i=0;if(r&&(r==null?void 0:r.geometry)){const o=r==null?void 0:r.geometry.attributes.position.array;for(let c=0;c<o.length;c+=3){const h=o[c],l=o[c+1],u=o[c+2];polygonTool.isInPolygon({x:h,y:l},t)&&u&&(s=Math.max(u,s),n=Math.min(u,n),i++,e&&u>=e[0]&&u<=e[1]&&a++)}}return{maxZ:s,minZ:n,count:a,zCount:i}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,r=this.containerHeight/2;return{x:t.x*e+e,y:t.y*r+r,z:t.z}}get basicCoordinate2CanvasMatrix4(){const t=this.containerWidth/2,e=this.containerHeight/2;return new THREE__namespace.Matrix4().set(t,0,0,t,0,e,0,e,0,0,1,0,0,0,0,1)}getCanvas2BasicCoordinate(t){const e=this.containerWidth/2,r=this.containerHeight/2;return new THREE__namespace.Vector3(t.x/e-e/2,-(t.y/r-r/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e+a/2,y:r+s/2,z:n-i/2},c={x:e+a/2,y:r+s/2,z:n+i/2},h={x:e-a/2,y:r+s/2,z:n+i/2},l={x:e-a/2,y:r+s/2,z:n-i/2};return[o,c,h,l]}getPolygonBackPoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e-a/2,y:r+s/2,z:n+i/2},c={x:e-a/2,y:r+s/2,z:n-i/2},h={x:e-a/2,y:r-s/2,z:n-i/2},l={x:e-a/2,y:r-s/2,z:n+i/2};return[o,c,h,l]}getPolygonTopPoints(t){const{center:{x:e,y:r,z:n},height:s,width:a,depth:i}=t,o={x:e+a/2,y:r+s/2,z:n+i/2},c={x:e+a/2,y:r-s/2,z:n+i/2},h={x:e-a/2,y:r-s/2,z:n+i/2},l={x:e-a/2,y:r+s/2,z:n+i/2};return[o,c,h,l]}getModelTransformationMatrix(t){const{center:{x:e,y:r,z:n},rotation:s}=t,a=new THREE__namespace.Matrix4().makeTranslation(-e,-r,-n),i=new THREE__namespace.Matrix4().makeTranslation(e,r,n),o=new THREE__namespace.Matrix4().makeRotationZ(s);return new THREE__namespace.Matrix4().multiply(i).multiply(o).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,lbUtils.EPerspectiveView.Back)}boxParams2ViewPolygon(t,e){switch(e){case lbUtils.EPerspectiveView.Left:return this.getPolygonSidePoints(t);case lbUtils.EPerspectiveView.Back:return this.getPolygonBackPoints(t);default:return this.getPolygonTopPoints(t)}}getBoxPolygon2DCoordinate(t,e){const r=this.boxParams2ViewPolygon(t,e),{width:n,height:s}=t,a=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),i=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=i;const o=r.map(l=>new THREE__namespace.Vector3(l.x,l.y,l.z)).map(l=>l.applyMatrix4(this.sideMatrix)),c=this.containerWidth/n,h=this.containerHeight/s;return{polygon2d:o,zoom:Math.min(c,h)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:r}=t,s=this.getPolygonTopPoints(t).map(o=>new THREE__namespace.Vector3(o.x,o.y,o.z)).map(o=>o.applyMatrix4(this.getModelTransformationMatrix(t))).map(o=>({x:o.y,y:o.x})).map(o=>({x:-(o.x-this.containerWidth/2),y:-(o.y-this.containerHeight/2)})),a=this.containerWidth/e,i=this.containerHeight/r;return{polygon2d:s,zoom:Math.min(a,i)/2}}getNewBoxBySideUpdate(t,e,r,n){const s=new THREE__namespace.Matrix4().makeRotationZ(n.rotation),a=new THREE__namespace.Vector3(-t.x,0,0).applyMatrix4(s);let i=n;return i.center={x:i.center.x+a.x,y:i.center.y+a.y,z:i.center.z-t.z},i=__spreadProps(__spreadValues({},i),{width:i.width+e,height:i.height,depth:i.depth+r}),{newBoxParams:i}}getNewBoxByBackUpdate(t,e,r,n){const s=new THREE__namespace.Matrix4().makeRotationZ(n.rotation),a=new THREE__namespace.Vector3(0,-t.x,0).applyMatrix4(s);let i=n;return i.center={x:i.center.x+a.x,y:i.center.y+a.y,z:i.center.z-t.z},i=__spreadProps(__spreadValues({},i),{width:i.width,height:i.height+e,depth:i.depth+r}),{newBoxParams:i}}getNewBoxBySideUpdateByPoints(t,e,r,n){var s;const a=(s=this.sideMatrix)==null?void 0:s.invert();if(!this.sideMatrix||!a){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const i=t.map(p=>new THREE__namespace.Vector3(p.x,p.y,p.z)).map(p=>p.applyMatrix4(a)),[o,c,h,l]=i,u=Math.max(Math.abs(o.x-h.x),Math.abs(o.x-c.x)),x=c.add(l).applyMatrix3(new THREE__namespace.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new THREE__namespace.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new THREE__namespace.Vector3(n.center.x,n.center.y,n.center.z));return{newBoxParams:__spreadProps(__spreadValues({},n),{center:{x:n.center.x-x.x,y:n.center.y-x.y,z:n.center.z-r},width:u,height:n.height,depth:n.depth+e,rotation:n.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(r=>r.uuid===this.pointsUuid);if(e){const{attributes:r}=e.geometry,{position:n}=r,s=[],{count:a}=n;for(let i=0;i<a;i++){const o=n.getZ(i);s.push(o>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new THREE__namespace.Float32BufferAttribute(s,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.lidar2image=matrix.lidar2image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloud=PointCloud;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils"),uuid=require("../../utils/uuid.js");function _interopNamespace(r){if(r&&r.__esModule)return r;var t=Object.create(null);return r&&Object.keys(r).forEach(function(i){if(i!=="default"){var e=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(t,i,e.get?e:{enumerable:!0,get:function(){return r[i]}})}}),t.default=r,Object.freeze(t)}var THREE__namespace=_interopNamespace(THREE);function createThreeMatrix4(r){return new THREE__namespace.Matrix4().set(...r)}function transferKitti2Matrix(r,t,i){const e=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r),o=lbUtils.MatrixUtils.transferMatrix33FromKitti2Three(t),a=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(i),l=createThreeMatrix4(e),c=createThreeMatrix4(o),s=createThreeMatrix4(a);return{composeMatrix4:s.clone().premultiply(c).premultiply(l),PM:l,RM:c,TM:s}}function rotatePoint(r,t,i){var e;const o=new THREE__namespace.Vector3(r.x,r.y,(e=r==null?void 0:r.z)!=null?e:1),a=new THREE__namespace.Matrix4().makeRotationZ(i),l=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),c=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return o.clone().applyMatrix4(c).applyMatrix4(a).applyMatrix4(l)}function lidar2image(r,t){const e=new THREE__namespace.Vector4(r.x,r.y,r.z).applyMatrix4(t);if(e.z<0)return;const o=1/e.z,a=new THREE__namespace.Matrix4().set(o,0,0,0,0,o,0,0,0,0,o,0,0,0,0,1);return e.applyMatrix4(a)}function getCuboidFromPointCloudBox(r){const{center:t,width:i,height:e,depth:o,rotation:a}=r,l=[{x:t.x+i/2,y:t.y-e/2},{x:t.x+i/2,y:t.y+e/2},{x:t.x-i/2,y:t.y+e/2},{x:t.x-i/2,y:t.y-e/2}].map(n=>{const u=rotatePoint(n,t,a);return{x:u.x,y:u.y}}),c=t.z+o/2,s=t.z-o/2;return{polygonPointList:l,zMax:c,zMin:s}}function pointCloudLidar2image(r,t){const i=lbUtils.PointCloudUtils.getAllViewData(r),{P:e,R:o,T:a}=t,{composeMatrix4:l}=transferKitti2Matrix(e,o,a);return i.map(s=>({type:s.type,pointList:s.pointList.map(n=>rotatePoint(n,r.center,r.rotation)).map(n=>lidar2image(n,l)).map(n=>{if(!!n)return{id:uuid(),x:n==null?void 0:n.x,y:n==null?void 0:n.y}}).filter(n=>n!==void 0)})).filter(s=>s.pointList.length!==0)}exports.createThreeMatrix4=createThreeMatrix4,exports.getCuboidFromPointCloudBox=getCuboidFromPointCloudBox,exports.lidar2image=lidar2image,exports.pointCloudLidar2image=pointCloudLidar2image,exports.rotatePoint=rotatePoint,exports.transferKitti2Matrix=transferKitti2Matrix;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var THREE=require("three"),lbUtils=require("@labelbee/lb-utils"),uuid=require("../../utils/uuid.js");function _interopNamespace(r){if(r&&r.__esModule)return r;var t=Object.create(null);return r&&Object.keys(r).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return r[e]}})}}),t.default=r,Object.freeze(t)}var THREE__namespace=_interopNamespace(THREE),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,t,e)=>t in r?__defProp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues=(r,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(r,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(r,e,t[e]);return r},__spreadProps=(r,t)=>__defProps(r,__getOwnPropDescs(t));function createThreeMatrix4(r){return new THREE__namespace.Matrix4().set(...r)}function transferKitti2Matrix(r,t,e){const i=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(r),a=lbUtils.MatrixUtils.transferMatrix33FromKitti2Three(t),n=lbUtils.MatrixUtils.transferMatrix34FromKitti2Three(e),l=createThreeMatrix4(i),c=createThreeMatrix4(a),s=createThreeMatrix4(n);return{composeMatrix4:s.clone().premultiply(c).premultiply(l),PM:l,RM:c,TM:s}}function rotatePoint(r,t,e){var i;const a=new THREE__namespace.Vector3(r.x,r.y,(i=r==null?void 0:r.z)!=null?i:1),n=new THREE__namespace.Matrix4().makeRotationZ(e),l=new THREE__namespace.Matrix4().makeTranslation(t.x,t.y,t.z),c=new THREE__namespace.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return a.clone().applyMatrix4(c).applyMatrix4(n).applyMatrix4(l)}function lidar2image(r,t){const i=new THREE__namespace.Vector4(r.x,r.y,r.z).applyMatrix4(t);if(i.z<0)return;const a=1/i.z,n=new THREE__namespace.Matrix4().set(a,0,0,0,0,a,0,0,0,0,a,0,0,0,0,1);return i.applyMatrix4(n)}function getCuboidFromPointCloudBox(r){const{center:t,width:e,height:i,depth:a,rotation:n}=r,l=[{x:t.x+e/2,y:t.y-i/2},{x:t.x+e/2,y:t.y+i/2},{x:t.x-e/2,y:t.y+i/2},{x:t.x-e/2,y:t.y-i/2}].map(o=>{const u=rotatePoint(o,t,n);return{x:u.x,y:u.y}}),c=t.z+a/2,s=t.z-a/2;return __spreadProps(__spreadValues({},r),{polygonPointList:l,zMax:c,zMin:s})}function pointCloudLidar2image(r,t){const e=lbUtils.PointCloudUtils.getAllViewData(r),{P:i,R:a,T:n}=t,{composeMatrix4:l}=transferKitti2Matrix(i,a,n);return e.map(s=>({type:s.type,pointList:s.pointList.map(o=>rotatePoint(o,r.center,r.rotation)).map(o=>lidar2image(o,l)).map(o=>{if(!!o)return{id:uuid(),x:o==null?void 0:o.x,y:o==null?void 0:o.y}}).filter(o=>o!==void 0)})).filter(s=>s.pointList.length!==0)}exports.createThreeMatrix4=createThreeMatrix4,exports.getCuboidFromPointCloudBox=getCuboidFromPointCloudBox,exports.lidar2image=lidar2image,exports.pointCloudLidar2image=pointCloudLidar2image,exports.rotatePoint=rotatePoint,exports.transferKitti2Matrix=transferKitti2Matrix;
@@ -1 +1 @@
1
- "use strict";var lbUtils=require("@labelbee/lb-utils"),annotation=require("../../constant/annotation.js"),tool=require("../../constant/tool.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),defaultConfig=require("../../constant/defaultConfig.js"),polygonOperation=require("./polygonOperation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,t,e)=>t in r?__defProp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues=(r,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(r,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(r,e,t[e]);return r},__spreadProps=(r,t)=>__defProps(r,__getOwnPropDescs(t));class PointCloud2dOperation extends polygonOperation{constructor(t){super(t);this.selectedIDs=[],this.rightMouseUp=s=>{var d;if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}s.ctrlKey&&this.hoverID?this.emit("addSelectedIDs",this.hoverID):this.emit("setSelectedIDs",this.hoverID);const c=(d=this.polygonList.find(h=>h.id===this.hoverID))==null?void 0:d.attribute;c&&c!==this.defaultAttribute&&this.emit("syncAttribute",c)},this.onKeyDown=()=>{},this.onKeyUp=()=>{},this.renderSingleSelectedPolygon=s=>{var d;if(this.selectedPolygons){const c=this.getPointCloudLineColor(s.attribute),h=AxisUtils.default.changePointListByZoom(s.pointList,this.zoom,this.currentPos);DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,h,{fillColor:"transparent",strokeColor:c,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(d=this.config)==null?void 0:d.lineType}),s.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(h)}};var e,i,o,n,l,a;this.showDirectionLine=(e=t.showDirectionLine)!=null?e:!0,this.forbidAddNew=(i=t.forbidAddNew)!=null?i:!1,this.pointCloudConfig=(o=CommonToolUtils.jsonParser(t.config))!=null?o:{},this.checkMode=(n=t.checkMode)!=null?n:!1,this.forbidAddNew===!1&&t.checkMode===!0&&(this.forbidAddNew=!0),this.config=__spreadProps(__spreadValues({},defaultConfig.polygonConfig),{textConfigurable:!1,attributeConfigurable:!0,attributeList:(a=(l=this.pointCloudConfig)==null?void 0:l.attributeList)!=null?a:[]})}get getSelectedIDs(){return this.selectedIDs}setConfig(t){var e;const i=CommonToolUtils.jsonParser(t);this.pointCloudConfig=i,this.config=__spreadProps(__spreadValues({},this.config),{attributeList:(e=i==null?void 0:i.attributeList)!=null?e:[]})}dragMouseDown(t){this.checkMode||super.dragMouseDown(t)}deletePolygon(t){this.checkMode||super.deletePolygon(t)}deletePolygonPoint(t){this.checkMode||super.deletePolygonPoint(t)}setSelectedIDs(t){this.selectedIDs=t,this.setSelectedID(this.selectedIDs.length===1?this.selectedIDs[0]:""),this.render()}deleteSelectedID(){super.deleteSelectedID(),this.selectedIDs=[],this.emit("deleteSelectedIDs")}get selectedPolygons(){return PolygonUtils.getPolygonByIDs(this.polygonList,this.selectedIDs)}getLineColor(){return"rgba(0, 255, 255, 0.5)"}getPointCloudLineColor(t=""){return lbUtils.toolStyleConverter.getColorFromConfig({attribute:t},__spreadProps(__spreadValues({},this.pointCloudConfig),{attributeConfigurable:!0}),{}).stroke}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.polygonList)==null||t.forEach(e=>{var i,o,n;if([...this.selectedIDs,this.editPolygonID].includes(e.id))return;const{attribute:l}=e,a=this.getPointCloudLineColor(l),s=AxisUtils.default.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);DrawUtils.drawPolygonWithFillAndLine(this.canvas,s,{fillColor:"transparent",strokeColor:a,pointColor:"white",thickness:(o=(i=this.style)==null?void 0:i.width)!=null?o:2,lineCap:"round",isClose:!0,lineType:(n=this.config)==null?void 0:n.lineType}),e.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(s)}))}renderSelectedPolygon(){var t;(t=this.selectedPolygons)==null||t.forEach(e=>{this.renderSingleSelectedPolygon(e)})}renderRectPolygonDirection(t){t.length<2||DrawUtils.drawLine(this.canvas,t[0],t[1],{color:"white",thickness:3,lineDash:[6]})}get currentPolygonListByPattern(){return this.polygonList.filter(t=>this.pattern===tool.EPolygonPattern.Rect?t.isRect===!0:this.pattern===tool.EPolygonPattern.Normal?t.isRect!==!0:!0)}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),n=this.currentPolygonListByPattern.map(l=>__spreadProps(__spreadValues({},l),{pointList:AxisUtils.default.changePointListByZoom(l.pointList,this.zoom)}));return PolygonUtils.getHoverPolygonID(i,n,10,(e=this.config)==null?void 0:e.lineType)}switchToNextPolygon(t=annotation.ESortDirection.ascend){if(this.drawingPointList.length>0)return;const e=this.currentPolygonListByPattern.map(o=>{var n,l,a,s;return __spreadProps(__spreadValues({},o),{x:(l=(n=o.pointList[0])==null?void 0:n.x)!=null?l:0,y:(s=(a=o.pointList[0])==null?void 0:a.y)!=null?s:0})}),i=CommonToolUtils.getNextSelectedRectID(e,t,this.selectedID);if(i)return this.setSelectedIDs([i.id]),this.render(),[i.id]}setSelectedIdAfterAddingDrawing(t){this.drawingPointList.length!==0&&this.setSelectedID(t)}setSelectedID(t){var e,i;const o=this.selectedID;t!==o&&o&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.selectedIDs=t?[t]:[],this.render()}addPointInDrawing(t){this.forbidAddNew||super.addPointInDrawing(t)}setCanvasSize(t){var e,i;const o=this.pixelRatio;this.size=t,this.setImgInfo(t),this.updateCanvasBasicStyle(this.basicCanvas,t,0),this.updateCanvasBasicStyle(this.canvas,t,10),(e=this.ctx)==null||e.scale(o,o),(i=this.basicCtx)==null||i.scale(o,o),this.initImgPos(),this.renderBasicCanvas(),this.render()}setPolygonValidAndRender(t,e=!1){if(e){super.setPolygonValidAndRender(t);return}this.emit("validUpdate",t)}}module.exports=PointCloud2dOperation;
1
+ "use strict";var lbUtils=require("@labelbee/lb-utils"),annotation=require("../../constant/annotation.js"),tool=require("../../constant/tool.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),defaultConfig=require("../../constant/defaultConfig.js"),polygonOperation=require("./polygonOperation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,t,e)=>t in r?__defProp(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,__spreadValues=(r,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(r,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(r,e,t[e]);return r},__spreadProps=(r,t)=>__defProps(r,__getOwnPropDescs(t));class PointCloud2dOperation extends polygonOperation{constructor(t){super(t);this.selectedIDs=[],this.rightMouseUp=a=>{var d;if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}if(!this.hoverID)return;if(a.ctrlKey){this.emit("addSelectedIDs",this.hoverID);return}this.emit("setSelectedIDs",this.hoverID);const c=(d=this.polygonList.find(u=>u.id===this.hoverID))==null?void 0:d.attribute;c&&c!==this.defaultAttribute&&this.emit("syncAttribute",c)},this.onKeyDown=()=>{},this.onKeyUp=()=>{},this.renderSingleSelectedPolygon=a=>{var d;if(this.selectedPolygons){const c=this.getPointCloudLineColor(a),u=AxisUtils.default.changePointListByZoom(a.pointList,this.zoom,this.currentPos);DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,u,{fillColor:"transparent",strokeColor:c,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(d=this.config)==null?void 0:d.lineType}),a.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(u)}};var e,i,o,s,n,l;this.showDirectionLine=(e=t.showDirectionLine)!=null?e:!0,this.forbidAddNew=(i=t.forbidAddNew)!=null?i:!1,this.pointCloudConfig=(o=CommonToolUtils.jsonParser(t.config))!=null?o:{},this.checkMode=(s=t.checkMode)!=null?s:!1,this.forbidAddNew===!1&&t.checkMode===!0&&(this.forbidAddNew=!0),this.config=__spreadProps(__spreadValues({},defaultConfig.polygonConfig),{textConfigurable:!1,attributeConfigurable:!0,attributeList:(l=(n=this.pointCloudConfig)==null?void 0:n.attributeList)!=null?l:[]})}get getSelectedIDs(){return this.selectedIDs}setConfig(t){var e;const i=CommonToolUtils.jsonParser(t);this.pointCloudConfig=i,this.config=__spreadProps(__spreadValues({},this.config),{attributeList:(e=i==null?void 0:i.attributeList)!=null?e:[]})}dragMouseDown(t){this.checkMode||super.dragMouseDown(t)}deletePolygon(t){this.checkMode||super.deletePolygon(t)}deletePolygonPoint(t){this.checkMode||super.deletePolygonPoint(t)}setSelectedIDs(t){this.selectedIDs=t,this.setSelectedID(this.selectedIDs.length===1?this.selectedIDs[0]:""),this.render()}deleteSelectedID(){super.deleteSelectedID(),this.selectedIDs=[],this.emit("deleteSelectedIDs")}get selectedPolygons(){return PolygonUtils.getPolygonByIDs(this.polygonList,this.selectedIDs)}getLineColor(){return"rgba(0, 255, 255, 0.5)"}getPointCloudLineColor(t){return t.valid===!1?lbUtils.INVALID_COLOR:lbUtils.toolStyleConverter.getColorFromConfig({attribute:t.attribute},__spreadProps(__spreadValues({},this.pointCloudConfig),{attributeConfigurable:!0}),{}).stroke}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.polygonList)==null||t.forEach(e=>{var i,o,s;if([...this.selectedIDs,this.editPolygonID].includes(e.id))return;const n=this.getPointCloudLineColor(e),l=AxisUtils.default.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);DrawUtils.drawPolygonWithFillAndLine(this.canvas,l,{fillColor:"transparent",strokeColor:n,pointColor:"white",thickness:(o=(i=this.style)==null?void 0:i.width)!=null?o:2,lineCap:"round",isClose:!0,lineType:(s=this.config)==null?void 0:s.lineType}),e.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(l)}))}renderSelectedPolygon(){var t;(t=this.selectedPolygons)==null||t.forEach(e=>{this.renderSingleSelectedPolygon(e)})}renderRectPolygonDirection(t){t.length<2||DrawUtils.drawLine(this.canvas,t[0],t[1],{color:"white",thickness:3,lineDash:[6]})}get currentPolygonListByPattern(){return this.polygonList.filter(t=>this.pattern===tool.EPolygonPattern.Rect?t.isRect===!0:this.pattern===tool.EPolygonPattern.Normal?t.isRect!==!0:!0)}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),s=this.currentPolygonListByPattern.map(n=>__spreadProps(__spreadValues({},n),{pointList:AxisUtils.default.changePointListByZoom(n.pointList,this.zoom)}));return PolygonUtils.getHoverPolygonID(i,s,10,(e=this.config)==null?void 0:e.lineType)}switchToNextPolygon(t=annotation.ESortDirection.ascend){if(this.drawingPointList.length>0)return;const e=this.currentPolygonListByPattern.map(o=>{var s,n,l,a;return __spreadProps(__spreadValues({},o),{x:(n=(s=o.pointList[0])==null?void 0:s.x)!=null?n:0,y:(a=(l=o.pointList[0])==null?void 0:l.y)!=null?a:0})}),i=CommonToolUtils.getNextSelectedRectID(e,t,this.selectedID);if(i)return this.setSelectedIDs([i.id]),this.render(),[i.id]}setSelectedIdAfterAddingDrawing(t){this.drawingPointList.length!==0&&this.setSelectedID(t)}setSelectedID(t){var e,i;const o=this.selectedID;t!==o&&o&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render()}addPointInDrawing(t){this.forbidAddNew||super.addPointInDrawing(t)}setCanvasSize(t){var e,i;const o=this.pixelRatio;this.size=t,this.setImgInfo(t),this.updateCanvasBasicStyle(this.basicCanvas,t,0),this.updateCanvasBasicStyle(this.canvas,t,10),(e=this.ctx)==null||e.scale(o,o),(i=this.basicCtx)==null||i.scale(o,o),this.initImgPos(),this.renderBasicCanvas(),this.render()}setPolygonValidAndRender(t,e=!1){if(e){super.setPolygonValidAndRender(t);return}this.emit("validUpdate",t)}}module.exports=PointCloud2dOperation;
@@ -1 +1 @@
1
- "use strict";var tool=require("../../constant/tool.js"),RectUtils=require("../../utils/tool/RectUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),MarkerUtils=require("../../utils/tool/MarkerUtils.js"),MathUtils=require("../../utils/MathUtils.js"),annotation=require("../../constant/annotation.js"),keyCode=require("../../constant/keyCode.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js"),AttributeUtils=require("../../utils/tool/AttributeUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),StyleUtils=require("../../utils/tool/StyleUtils.js"),uuid=require("../../utils/uuid.js"),basicToolOperation=require("./basicToolOperation.js"),textAttributeClass=require("./textAttributeClass.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__pow=Math.pow,__defNormalProp=(u,t,e)=>t in u?__defProp(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,__spreadValues=(u,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(u,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(u,e,t[e]);return u},__spreadProps=(u,t)=>__defProps(u,__getOwnPropDescs(t));const TEXTAREA_WIDTH=200;class PointOperation extends basicToolOperation.BasicToolOperation{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,s=this.currentPageResult.find(r=>r.label===i);s&&(this.setSelectedID(s.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(s.attribute)),this.emit("markIndexChange")},this.textChange=e=>{this.config.textConfigurable!==!0||!this.selectedID||(this.setPointList(AttributeUtils.default.textChange(e,this.selectedID,this.pointList)),this.emit("selectedChange"),this.render())},this.isMinDistance=e=>{const i=AxisUtils.default.changePointByZoom(e,this.zoom);return this.pointList.some(s=>{const r=AxisUtils.default.changePointByZoom(s,this.zoom);return MathUtils.default.getLineLength(r,i)<.2})},this.config=CommonToolUtils.jsonParser(t.config),this.pointList=[],this.markerIndex=0,this.setStyle(t.style),this.createPoint=this.createPoint.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.setSelectedID=this.setSelectedID.bind(this)}get dataList(){return this.pointList}get drawOutsideTarget(){var t;return(t=this.config.drawOutsideTarget)!=null?t:this.config.drawPointOut}setNextMarker(t=this.pointList){if(this.hasMarkerConfig){const e=CommonToolUtils.getNextMarker(this.getCurrentPageResult(t),this.config.markerList);e&&this.setMarkerIndexAndSelect(e.index)}}setResult(t){this.clearActiveStatus(),this.setPointList(t),this.setNextMarker(t),this.recoverOperationMode(),this.render()}setPointList(t,e=!1){const i=this.pointList.length;this.pointList=t,i!==t.length&&this.emit("updatePageNumber"),e&&this.emit("updateResult")}setConfig(t,e=!1){this.config=CommonToolUtils.jsonParser(t),e===!0&&this.clearResult()}clearResult(){this.setPointList([]),this.setSelectedID(void 0),this.history.pushHistory([]),this.hoverID="",this.render()}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.pointList.forEach(s=>{s.id===i&&(s.attribute=t)}),this.history.pushHistory(this.pointList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}get selectedText(){var t;return(t=this.pointList.find(e=>e.id===this.selectedID))==null?void 0:t.textAttribute}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}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")}getTextIconSvg(t=""){return AttributeUtils.default.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}clearActiveStatus(){this.hoverID=void 0,this.dragStatus=annotation.EDragStatus.Wait,this.setSelectedID(void 0)}setBasicResult(t){super.setBasicResult(t),this.setNextMarker(),this.clearActiveStatus()}onDragMoveAll(t){var e,i;!((i=(e=this.dragInfo)==null?void 0:e.originPointList)==null?void 0:i.length)||(this.setPointList(this.dragInfo.originPointList.map(s=>__spreadProps(__spreadValues({},s),{x:s.x+t.x/this.zoom,y:s.y+t.y/this.zoom}))),this.render())}onMouseDown(t){if(!(super.onMouseDown(t)||this.forbidMouseOperation)){if(t.button===0&&!this.hoverID){this.recoverOperationMode(),this.createPoint(t),this.render();return}if((this.hoverID===this.selectedID||this.isMultiMoveMode&&this.hoverID)&&t.button===0){this.dragStatus=annotation.EDragStatus.Start,this.isMultiMoveMode&&(this.dragInfo={dragStartCoord:this.getCoordinateUnderZoom(t),originPointList:this.pointList});return}return this.render(),!0}}onMouseMove(t){super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo||(this.hoverID=this.getHoverId(),(this.dragStatus===annotation.EDragStatus.Start||this.dragStatus===annotation.EDragStatus.Move)&&this.onDragMove(t),this.hoverID&&this.render())}onMouseUp(t){if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return!0;t.button===2&&this.rightMouseUp(),this.dragStatus===annotation.EDragStatus.Move&&(this.history.pushHistory(this.pointList),this.dragInfo=void 0),this.dragStatus=annotation.EDragStatus.Wait,this.render()}onDragMove(t){var e,i;if(!this.imgInfo)return;this.dragStatus=annotation.EDragStatus.Move;const s=this.getCoordinateUnderZoom(t);if(this.isMultiMoveMode&&this.dragInfo){const o={x:s.x-this.dragInfo.dragStartCoord.x,y:s.y-this.dragInfo.dragStartCoord.y};this.onDragMoveAll(o);return}const r=AxisUtils.default.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.drawOutsideTarget,this.basicResult,this.zoom),h=this.drawOutsideTarget?AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos):AxisUtils.default.changePointByZoom(r,1/this.zoom);this.drawOutsideTarget===!1&&this.dependToolName===tool.EToolName.Polygon&&((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&!PolygonUtils.isInPolygon(h,this.basicResult.pointList)||(this.pointList.forEach(o=>{o.id===this.selectedID&&(o.x=h.x,o.y=h.y)}),this.render())}onKeyDown(t){if(!CommonToolUtils.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case keyCode.Delete:this.deletePoint();break;case keyCode.Tab:{this.onTabKeyDown(t);break}case keyCode.Z:this.setIsHidden(!this.isHidden),this.render();break;default:{if(this.config.attributeConfigurable){const i=AttributeUtils.default.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}createPoint(t){var e,i,s,r;if(!this.imgInfo)return;const{upperLimit:h}=this.config;if(h&&this.currentPageResult.length>=h){this.emit("messageInfo",`${index.getMessagesByLocale(constants.EMessage.LowerLimitPoint,this.lang)}`);return}const o=CommonToolUtils.getSourceID(this.basicResult),c=this.getCoordinateUnderZoom(t);let l=AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.config.edgeAdsorption&&this.referenceData&&[tool.EToolName.Polygon,tool.EToolName.Line].includes((e=this.referenceData)==null?void 0:e.toolName)){const g=((i=this.referenceData)==null?void 0:i.toolName)===tool.EToolName.Polygon,{dropFoot:f,hasClosed:v}=PolygonUtils.getClosestPoint(l,this.referenceData.result,(r=(s=this.referenceData.config)==null?void 0:s.lineType)!=null?r:tool.ELineTypes.Line,tool.edgeAdsorptionScope/this.zoom,{isClose:g});f&&(l=f),v&&this.emit("messageSuccess",`${index.getMessagesByLocale(constants.EMessage.SuccessfulEdgeAdsorption,this.lang)}`)}if(this.drawOutsideTarget===!1){if(this.dependToolName&&this.basicCanvas){let a=!1;switch(this.dependToolName){case tool.EToolName.Rect:{a=!RectUtils.isInRect(l,this.basicResult);break}case tool.EToolName.Polygon:{a=!PolygonUtils.isInPolygon(l,this.basicResult.pointList);break}}if(a)return}if(c.x<0||c.y<0||c.x>this.imgInfo.width||c.y>this.imgInfo.height)return}if(this.isMinDistance(l))return;let n=__spreadProps(__spreadValues({},l),{attribute:this.defaultAttribute,valid:!t.ctrlKey,id:uuid(8,62),sourceID:o,textAttribute:"",order:CommonToolUtils.getMaxOrder(this.pointList.filter(a=>CommonToolUtils.isSameSourceID(a.sourceID,o)))+1});if(this.config.textConfigurable){let a="";a=AttributeUtils.default.getTextAttribute(this.pointList.filter(g=>CommonToolUtils.isSameSourceID(g.sourceID,o)),this.config.textCheckType),n=__spreadProps(__spreadValues({},n),{textAttribute:a})}if(this.hasMarkerConfig){const a=CommonToolUtils.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(a)n=__spreadProps(__spreadValues({},n),{label:a.label}),this.markerIndex=a.index,this.emit("markIndexChange");else{this.emit("messageInfo",index.getMessagesByLocale(constants.EMessage.MarkerFinish,this.lang));return}}this.hoverID=n.id;const d=[...this.pointList,n];this.setPointList(d),this.history.pushHistory(d),this.setSelectedID(n.id)}isInPoint(t,e,i=this.zoom){return(this.style.width+2)/i>=Math.sqrt(__pow(t.x-e.x,2)+__pow(t.y-e.y,2))}getHoverId(){var t;const e=AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos),i=(t=this.pointList)==null?void 0:t.find(s=>this.isInPoint(e,s));return i==null?void 0:i.id}rightMouseUp(){if(this.recoverOperationMode(),this.selectedID===this.hoverID){const e=this.pointList.filter(i=>i.id!==this.selectedID);this.setPointList(e),this.history.pushHistory(e),this.setSelectedID(""),this.hoverID="";return}const t=this.pointList.find(e=>e.id===this.hoverID);if(this.setSelectedID(this.hoverID),this.setDefaultAttribute(t==null?void 0:t.attribute),(t==null?void 0:t.label)&&this.hasMarkerConfig){const e=CommonToolUtils.getCurrentMarkerIndex(t.label,this.config.markerList);e>=0&&(this.setMarkerIndex(e),this.emit("markIndexChange"))}}onTabKeyDown(t){if(t.preventDefault(),this.dragStatus===annotation.EDragStatus.Move||this.dragStatus===annotation.EDragStatus.Start)return;let e=annotation.ESortDirection.ascend;t.shiftKey&&(e=annotation.ESortDirection.descend);const[i,s]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let r=[...i];s&&(r=[...r,s]);const h=CommonToolUtils.getNextSelectedRectID(r,e,this.selectedID);h&&this.setSelectedID(h.id)}get currentPageResult(){const[t]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=CommonToolUtils.getRenderResultList(t,CommonToolUtils.getSourceID(this.basicResult),[]);return e}exportData(){const{pointList:t}=this;return[t,this.basicImgInfo]}deletePoint(){var t;this.selectedID&&(this.setPointList(this.pointList.filter(e=>e.id!==this.selectedID)),this.history.pushHistory(this.pointList),(t=this._textAttributInstance)==null||t.clearTextAttribute(),this.emit("selectedChange"),this.render())}undoAndRedo(t){var e,i;if(this.dragStatus===annotation.EDragStatus.Move||this.dragStatus===annotation.EDragStatus.Start)return;const s=(i=(e=this.history)[t])==null?void 0:i.call(e);(s==null?void 0:s.some(r=>r.id===this.selectedID))||this.setSelectedID(""),s&&(this.setPointList(s,!0),this.render())}undo(){this.undoAndRedo("undo")}redo(){this.undoAndRedo("redo")}getCurrentSelectedData(){var t;if(!this.selectedID)return;const e=(t=this.pointList)==null?void 0:t.find(r=>r.id===this.selectedID),i=this.getColor(e==null?void 0:e.attribute),s=(e==null?void 0:e.valid)?i==null?void 0:i.valid.stroke:i==null?void 0:i.invalid.stroke;return this.dragStatus=annotation.EDragStatus.Wait,{width:TEXTAREA_WIDTH*this.zoom*.6,textAttribute:(e==null?void 0:e.textAttribute)||"",color:s}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;AttributeUtils.default.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",AttributeUtils.default.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPointList(AttributeUtils.default.textChange(e,this.selectedID,this.pointList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t,e;const i=(t=this.pointList)==null?void 0:t.find(g=>g.id===this.selectedID);if(!this.ctx||this.config.textConfigurable!==!0||!i)return;const{x:s,y:r,attribute:h,valid:o}=i,c=TEXTAREA_WIDTH*this.zoom*.6,l=AxisUtils.default.getOffsetCoordinate({x:s,y:r},this.currentPos,this.zoom),n=this.getColor(h),d=o?n==null?void 0:n.valid.stroke:n==null?void 0:n.invalid.stroke,a=4;this._textAttributInstance||(this._textAttributInstance=new textAttributeClass({width:c,container:this.container,icon:this.getTextIconSvg(h),color:d,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((e=this._textAttributInstance)==null?void 0:e.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${i.textAttribute}`,{left:l.x,top:l.y+a,color:d,width:c})}renderPoint(t,e=!1){var i,s,r;const{textAttribute:h="",attribute:o}=t,c=e||t.id===this.selectedID,l=this.getColor(o),n=AxisUtils.default.changePointByZoom(t,this.zoom,this.currentPos),{width:d=2,hiddenText:a=!1}=this.style,g=StyleUtils.getStrokeAndFill(l,t.valid,{isSelected:c||t.id===this.hoverID});DrawUtils.drawCircle(this.canvas,n,d,{startAngleDeg:0,endAngleDeg:360,thickness:1,color:g.stroke,fill:g.fill});let f="";(((i=this.config)==null?void 0:i.isShowOrder)||((s=this.config)==null?void 0:s.showOrder))&&t.order&&(t==null?void 0:t.order)>0&&(f=`${t.order}`),t.label&&this.hasMarkerConfig&&(f=`${CommonToolUtils.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${MarkerUtils.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&(f=`${f} ${AttributeUtils.default.getAttributeShowText(t.attribute,(r=this.config)==null?void 0:r.attributeList)}`),a||DrawUtils.drawText(this.canvas,{x:n.x+d/2,y:n.y-d-4},f,{textAlign:"center",color:g.stroke}),c?this.renderTextAttribute():a||DrawUtils.drawText(this.canvas,{x:n.x+d,y:n.y+d+24},h,__spreadValues({color:g.stroke},annotation.DEFAULT_TEXT_OFFSET))}renderMultiSelectedPoint(){!this.isMultiMoveMode||this.pointList.forEach(t=>{this.renderPoint(t,!0)})}renderPointList(){switch(this.operationMode){case tool.EOperationMode.MultiMove:this.renderMultiSelectedPoint();break;default:{const[t,e]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);this.isHidden||t.forEach(i=>{this.renderPoint(i)}),e&&this.renderPoint(e)}}}renderTop(){var t,e,i;const s=this.getLineColor(this.defaultAttribute);if(this.renderCursorLine(s),this.config.edgeAdsorption&&this.referenceData){let r=AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);const h=((t=this.referenceData)==null?void 0:t.toolName)===tool.EToolName.Polygon,{dropFoot:o}=PolygonUtils.getClosestPoint(r,this.referenceData.result,(i=(e=this.referenceData.config)==null?void 0:e.lineType)!=null?i:tool.ELineTypes.Line,tool.edgeAdsorptionScope/this.zoom,{isClose:h});o&&r!==o&&r!==o&&(r=o,DrawUtils.drawCircle(this.canvas,AxisUtils.default.changePointByZoom(r,this.zoom,this.currentPos),5,{color:"white",fill:"white"}),DrawUtils.drawCircle(this.canvas,AxisUtils.default.changePointByZoom(r,this.zoom,this.currentPos),3,{fill:s,color:s}))}}render(){!this.ctx||(super.render(),this.renderPointList(),this.renderTop())}}module.exports=PointOperation;
1
+ "use strict";var tool=require("../../constant/tool.js"),RectUtils=require("../../utils/tool/RectUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),MarkerUtils=require("../../utils/tool/MarkerUtils.js"),MathUtils=require("../../utils/MathUtils.js"),annotation=require("../../constant/annotation.js"),keyCode=require("../../constant/keyCode.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js"),AttributeUtils=require("../../utils/tool/AttributeUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),StyleUtils=require("../../utils/tool/StyleUtils.js"),uuid=require("../../utils/uuid.js"),basicToolOperation=require("./basicToolOperation.js"),textAttributeClass=require("./textAttributeClass.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__pow=Math.pow,__defNormalProp=(c,t,e)=>t in c?__defProp(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e,__spreadValues=(c,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(c,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(c,e,t[e]);return c},__spreadProps=(c,t)=>__defProps(c,__getOwnPropDescs(t));const TEXTAREA_WIDTH=200;class PointOperation extends basicToolOperation.BasicToolOperation{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,s=this.currentPageResult.find(r=>r.label===i);s&&(this.setSelectedID(s.id),this.config.attributeConfigurable===!0&&this.setDefaultAttribute(s.attribute)),this.emit("markIndexChange")},this.textChange=e=>{this.config.textConfigurable!==!0||!this.selectedID||(this.setPointList(AttributeUtils.default.textChange(e,this.selectedID,this.pointList)),this.emit("selectedChange"),this.render())},this.isMinDistance=e=>{const i=AxisUtils.default.changePointByZoom(e,this.zoom);return this.pointList.some(s=>{const r=AxisUtils.default.changePointByZoom(s,this.zoom);return MathUtils.default.getLineLength(r,i)<.2})},this.config=CommonToolUtils.jsonParser(t.config),this.pointList=[],this.markerIndex=0,this.setStyle(t.style),this.createPoint=this.createPoint.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.setSelectedID=this.setSelectedID.bind(this)}get dataList(){return this.pointList}get drawOutsideTarget(){var t;return(t=this.config.drawOutsideTarget)!=null?t:this.config.drawPointOut}setNextMarker(t=this.pointList){if(this.hasMarkerConfig){const e=CommonToolUtils.getNextMarker(this.getCurrentPageResult(t),this.config.markerList);e&&this.setMarkerIndexAndSelect(e.index)}}setResult(t){this.clearActiveStatus(),this.setPointList(t),this.setNextMarker(t),this.recoverOperationMode(),this.render()}setPointList(t,e=!1){const i=this.pointList.length;this.pointList=t,i!==t.length&&this.emit("updatePageNumber"),e&&this.emit("updateResult")}setConfig(t,e=!1){this.config=CommonToolUtils.jsonParser(t),e===!0&&this.clearResult()}clearResult(){this.setPointList([]),this.setSelectedID(void 0),this.history.pushHistory([]),this.hoverID="",this.render()}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.pointList.forEach(s=>{s.id===i&&(s.attribute=t)}),this.history.pushHistory(this.pointList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}get selectedText(){var t;return(t=this.pointList.find(e=>e.id===this.selectedID))==null?void 0:t.textAttribute}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}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")}getTextIconSvg(t=""){return AttributeUtils.default.getTextIconSvg(t,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}clearActiveStatus(){this.hoverID=void 0,this.dragStatus=annotation.EDragStatus.Wait,this.setSelectedID(void 0)}setBasicResult(t){super.setBasicResult(t),this.setNextMarker(),this.clearActiveStatus()}onDragMoveAll(t){var e,i;!((i=(e=this.dragInfo)==null?void 0:e.originPointList)==null?void 0:i.length)||(this.setPointList(this.dragInfo.originPointList.map(s=>__spreadProps(__spreadValues({},s),{x:s.x+t.x/this.zoom,y:s.y+t.y/this.zoom}))),this.render())}onMouseDown(t){if(!(super.onMouseDown(t)||this.forbidMouseOperation)){if(t.button===0&&!this.hoverID){this.recoverOperationMode(),this.createPoint(t),this.render();return}if((this.hoverID===this.selectedID||this.isMultiMoveMode&&this.hoverID)&&t.button===0){this.dragStatus=annotation.EDragStatus.Start,this.isMultiMoveMode&&(this.dragInfo={dragStartCoord:this.getCoordinateUnderZoom(t),originPointList:this.pointList});return}return this.render(),!0}}onMouseMove(t){super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo||(this.hoverID=this.getHoverId(),(this.dragStatus===annotation.EDragStatus.Start||this.dragStatus===annotation.EDragStatus.Move)&&this.onDragMove(t),this.hoverID&&this.render())}onMouseUp(t){if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return!0;t.button===2&&this.rightMouseUp(),this.dragStatus===annotation.EDragStatus.Move&&(this.history.pushHistory(this.pointList),this.dragInfo=void 0),this.dragStatus=annotation.EDragStatus.Wait,this.render()}onDragMove(t){var e,i;if(!this.imgInfo)return;this.dragStatus=annotation.EDragStatus.Move;const s=this.getCoordinateUnderZoom(t);if(this.isMultiMoveMode&&this.dragInfo){const n={x:s.x-this.dragInfo.dragStartCoord.x,y:s.y-this.dragInfo.dragStartCoord.y};this.onDragMoveAll(n);return}const r=AxisUtils.default.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.drawOutsideTarget,this.basicResult,this.zoom),h=this.drawOutsideTarget?AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos):AxisUtils.default.changePointByZoom(r,1/this.zoom);this.drawOutsideTarget===!1&&this.dependToolName===tool.EToolName.Polygon&&((i=(e=this.basicResult)==null?void 0:e.pointList)==null?void 0:i.length)>0&&!PolygonUtils.isInPolygon(h,this.basicResult.pointList)||(this.pointList.forEach(n=>{n.id===this.selectedID&&(n.x=h.x,n.y=h.y)}),this.render())}onKeyDown(t){if(!CommonToolUtils.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case keyCode.Delete:this.deletePoint();break;case keyCode.Tab:{this.onTabKeyDown(t);break}case keyCode.Z:this.setIsHidden(!this.isHidden),this.render();break;default:{if(this.config.attributeConfigurable){const i=AttributeUtils.default.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}createPoint(t){var e,i,s,r;if(!this.imgInfo)return;const{upperLimit:h}=this.config;if(h&&this.currentPageResult.length>=h){this.emit("messageInfo",`${index.getMessagesByLocale(constants.EMessage.LowerLimitPoint,this.lang)}`);return}const n=CommonToolUtils.getSourceID(this.basicResult),d=this.getCoordinateUnderZoom(t);let l=AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.config.edgeAdsorption&&this.referenceData&&[tool.EToolName.Polygon,tool.EToolName.Line].includes((e=this.referenceData)==null?void 0:e.toolName)){const g=((i=this.referenceData)==null?void 0:i.toolName)===tool.EToolName.Polygon,{dropFoot:f,hasClosed:v}=PolygonUtils.getClosestPoint(l,this.referenceData.result,(r=(s=this.referenceData.config)==null?void 0:s.lineType)!=null?r:tool.ELineTypes.Line,tool.edgeAdsorptionScope/this.zoom,{isClose:g});f&&(l=f),v&&this.emit("messageSuccess",`${index.getMessagesByLocale(constants.EMessage.SuccessfulEdgeAdsorption,this.lang)}`)}if(this.drawOutsideTarget===!1){if(this.dependToolName&&this.basicCanvas){let a=!1;switch(this.dependToolName){case tool.EToolName.Rect:{a=!RectUtils.isInRect(l,this.basicResult);break}case tool.EToolName.Polygon:{a=!PolygonUtils.isInPolygon(l,this.basicResult.pointList);break}}if(a)return}if(d.x<0||d.y<0||d.x>this.imgInfo.width||d.y>this.imgInfo.height)return}if(this.isMinDistance(l))return;let o=__spreadProps(__spreadValues({},l),{attribute:this.defaultAttribute,valid:!t.ctrlKey,id:uuid(8,62),sourceID:n,textAttribute:"",order:CommonToolUtils.getMaxOrder(this.pointList.filter(a=>CommonToolUtils.isSameSourceID(a.sourceID,n)))+1});if(this.config.textConfigurable){let a="";a=AttributeUtils.default.getTextAttribute(this.pointList.filter(g=>CommonToolUtils.isSameSourceID(g.sourceID,n)),this.config.textCheckType),o=__spreadProps(__spreadValues({},o),{textAttribute:a})}if(this.hasMarkerConfig){const a=CommonToolUtils.getNextMarker(this.currentPageResult,this.config.markerList,this.markerIndex);if(a)o=__spreadProps(__spreadValues({},o),{label:a.label}),this.markerIndex=a.index,this.emit("markIndexChange");else{this.emit("messageInfo",index.getMessagesByLocale(constants.EMessage.MarkerFinish,this.lang));return}}this.hoverID=o.id;const u=[...this.pointList,o];this.setPointList(u),this.history.pushHistory(u),this.setSelectedID(o.id)}isInPoint(t,e,i=this.zoom){return(this.style.width+2)/i>=Math.sqrt(__pow(t.x-e.x,2)+__pow(t.y-e.y,2))}getHoverId(){var t;const e=AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos),i=(t=this.pointList)==null?void 0:t.find(s=>this.isInPoint(e,s));return i==null?void 0:i.id}rightMouseUp(){if(this.recoverOperationMode(),this.selectedID===this.hoverID){const e=this.pointList.filter(i=>i.id!==this.selectedID);this.setPointList(e),this.history.pushHistory(e),this.setSelectedID(""),this.hoverID="";return}const t=this.pointList.find(e=>e.id===this.hoverID);if(this.setSelectedID(this.hoverID),this.setDefaultAttribute(t==null?void 0:t.attribute),(t==null?void 0:t.label)&&this.hasMarkerConfig){const e=CommonToolUtils.getCurrentMarkerIndex(t.label,this.config.markerList);e>=0&&(this.setMarkerIndex(e),this.emit("markIndexChange"))}}onTabKeyDown(t){if(t.preventDefault(),this.dragStatus===annotation.EDragStatus.Move||this.dragStatus===annotation.EDragStatus.Start)return;let e=annotation.ESortDirection.ascend;t.shiftKey&&(e=annotation.ESortDirection.descend);const[i,s]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let r=[...i];s&&(r=[...r,s]);const h=CommonToolUtils.getNextSelectedRectID(r,e,this.selectedID);h&&this.setSelectedID(h.id)}get currentPageResult(){const[t]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),[]);return t}getCurrentPageResult(t){const[e]=CommonToolUtils.getRenderResultList(t,CommonToolUtils.getSourceID(this.basicResult),[]);return e}exportData(){const{pointList:t}=this;return[t,this.basicImgInfo]}deletePoint(){var t;this.selectedID&&(this.setPointList(this.pointList.filter(e=>e.id!==this.selectedID)),this.history.pushHistory(this.pointList),(t=this._textAttributInstance)==null||t.clearTextAttribute(),this.emit("selectedChange"),this.render())}undoAndRedo(t){var e,i;if(this.dragStatus===annotation.EDragStatus.Move||this.dragStatus===annotation.EDragStatus.Start)return;const s=(i=(e=this.history)[t])==null?void 0:i.call(e);(s==null?void 0:s.some(r=>r.id===this.selectedID))||this.setSelectedID(""),s&&(this.setPointList(s,!0),this.render())}undo(){this.undoAndRedo("undo")}redo(){this.undoAndRedo("redo")}getCurrentSelectedData(){var t;if(!this.selectedID)return;const e=(t=this.pointList)==null?void 0:t.find(r=>r.id===this.selectedID),i=this.getColor(e==null?void 0:e.attribute),s=(e==null?void 0:e.valid)?i==null?void 0:i.valid.stroke:i==null?void 0:i.invalid.stroke;return this.dragStatus=annotation.EDragStatus.Wait,{width:TEXTAREA_WIDTH*this.zoom*.6,textAttribute:(e==null?void 0:e.textAttribute)||"",color:s}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;AttributeUtils.default.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",AttributeUtils.default.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPointList(AttributeUtils.default.textChange(e,this.selectedID,this.pointList)),this.emit("updateTextAttribute"),this.render()}}renderTextAttribute(){var t,e;const i=(t=this.pointList)==null?void 0:t.find(g=>g.id===this.selectedID);if(!this.ctx||this.config.textConfigurable!==!0||!i)return;const{x:s,y:r,attribute:h,valid:n}=i,d=TEXTAREA_WIDTH*this.zoom*.6,l=AxisUtils.default.getOffsetCoordinate({x:s,y:r},this.currentPos,this.zoom),o=this.getColor(h),u=n?o==null?void 0:o.valid.stroke:o==null?void 0:o.invalid.stroke,a=4;this._textAttributInstance||(this._textAttributInstance=new textAttributeClass({width:d,container:this.container,icon:this.getTextIconSvg(h),color:u,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((e=this._textAttributInstance)==null?void 0:e.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${i.textAttribute}`,{left:l.x,top:l.y+a,color:u,width:d})}renderPoint(t,e=!1){var i,s,r;const{textAttribute:h="",attribute:n}=t,d=e||t.id===this.selectedID,l=this.getColor(n),o=AxisUtils.default.changePointByZoom(t,this.zoom,this.currentPos),{width:u=2,hiddenText:a=!1}=this.style,g=StyleUtils.getStrokeAndFill(l,t.valid,{isSelected:d||t.id===this.hoverID});DrawUtils.drawCircle(this.canvas,o,u,{startAngleDeg:0,endAngleDeg:360,thickness:1,color:g.stroke,fill:g.fill});let f="";(((i=this.config)==null?void 0:i.isShowOrder)||((s=this.config)==null?void 0:s.showOrder))&&t.order&&(t==null?void 0:t.order)>0&&(f=`${t.order}`),t.label&&this.hasMarkerConfig&&(f=`${CommonToolUtils.getCurrentMarkerIndex(t.label,this.config.markerList)+1}_${MarkerUtils.getMarkerShowText(t.label,this.config.markerList)}`),t.attribute&&(f=`${f} ${AttributeUtils.default.getAttributeShowText(t.attribute,(r=this.config)==null?void 0:r.attributeList)}`),a||DrawUtils.drawText(this.canvas,{x:o.x+u/2,y:o.y-u-4},f,{textAlign:"center",color:g.stroke}),d?this.renderTextAttribute():a||DrawUtils.drawText(this.canvas,{x:o.x+u,y:o.y+u+24},h,__spreadValues({color:g.stroke},annotation.DEFAULT_TEXT_OFFSET))}renderMultiSelectedPoint(){!this.isMultiMoveMode||this.pointList.forEach(t=>{this.renderPoint(t,!0)})}renderPointList(){switch(this.operationMode){case tool.EOperationMode.MultiMove:this.renderMultiSelectedPoint();break;default:{const[t,e]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);this.isHidden||t.forEach(i=>{this.renderPoint(i)}),e&&this.renderPoint(e)}}}renderAuxiliaryLine(){var t;if(!this.config.markerConfigurable||!((t=this.config.markerList)==null?void 0:t.length))return;const[e,i]=CommonToolUtils.getRenderResultList(this.pointList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID),s=e;if(i&&s.push(i),s.length<2)return;const r=MarkerUtils.getAuxiliaryLineByMarkerList(this.config.markerList,"value");MarkerUtils.getAuxiliaryLineCoord(r,s).forEach(n=>{const{start:d,end:l}=n,o=AxisUtils.default.changePointListByZoom([d,l],this.zoom,this.currentPos);DrawUtils.drawLine(this.canvas,o[0],o[1],{color:"#C5C5C5"})})}renderTop(){var t,e,i;const s=this.getLineColor(this.defaultAttribute);if(this.renderCursorLine(s),this.config.edgeAdsorption&&this.referenceData){let r=AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);const h=((t=this.referenceData)==null?void 0:t.toolName)===tool.EToolName.Polygon,{dropFoot:n}=PolygonUtils.getClosestPoint(r,this.referenceData.result,(i=(e=this.referenceData.config)==null?void 0:e.lineType)!=null?i:tool.ELineTypes.Line,tool.edgeAdsorptionScope/this.zoom,{isClose:h});n&&r!==n&&r!==n&&(r=n,DrawUtils.drawCircle(this.canvas,AxisUtils.default.changePointByZoom(r,this.zoom,this.currentPos),5,{color:"white",fill:"white"}),DrawUtils.drawCircle(this.canvas,AxisUtils.default.changePointByZoom(r,this.zoom,this.currentPos),3,{fill:s,color:s}))}}render(){!this.ctx||(super.render(),this.renderAuxiliaryLine(),this.renderPointList(),this.renderTop())}}module.exports=PointOperation;
@@ -1 +1 @@
1
- "use strict";var lbUtils=require("@labelbee/lb-utils"),MathUtils=require("../../utils/MathUtils.js"),RectUtils=require("../../utils/tool/RectUtils.js"),annotation=require("../../constant/annotation.js"),keyCode=require("../../constant/keyCode.js"),tool=require("../../constant/tool.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js"),ActionsHistory=require("../../utils/ActionsHistory.js"),AttributeUtils=require("../../utils/tool/AttributeUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CanvasUtils=require("../../utils/tool/CanvasUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),StyleUtils=require("../../utils/tool/StyleUtils.js"),uuid=require("../../utils/uuid.js"),basicToolOperation=require("./basicToolOperation.js"),textAttributeClass=require("./textAttributeClass.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(g,t,e)=>t in g?__defProp(g,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):g[t]=e,__spreadValues=(g,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(g,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(g,e,t[e]);return g},__spreadProps=(g,t)=>__defProps(g,__getOwnPropDescs(t));const TEXT_MAX_WIDTH=164;class PolygonOperation extends basicToolOperation.BasicToolOperation{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(AttributeUtils.default.textChange(e,this.selectedID,this.polygonList)),this.emit("selectedChange"),this.render())},this.config=CommonToolUtils.jsonParser(t.config),this.drawingPointList=[],this.polygonList=[],this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.drawingHistory=new ActionsHistory,this.isCtrl=!1,this.isAlt=!1,this.isCombined=!1,this.pattern=tool.EPolygonPattern.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 PolygonUtils.getPolygonByID(this.polygonList,this.selectedID)}get hoverPolygon(){return this.polygonList.find(t=>t.id===this.hoverID&&t.id!==this.selectedID)}get polygonListUnderZoom(){return this.polygonList.map(t=>__spreadProps(__spreadValues({},t),{pointList:AxisUtils.default.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]=CommonToolUtils.getRenderResultList(this.polygonList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=CommonToolUtils.getRenderResultList(this.polygonList,CommonToolUtils.getSourceID(this.basicResult),[]);return t}setResultAndSelectedID(t,e){this.setPolygonList(t),e&&(this.selectedID=e),this.render()}setResult(t){this.clearActiveStatus(),this.setPolygonList(t),this.render()}setPolygonDataByID(t,e){return this.polygonList.map(i=>i.id===e?__spreadValues(__spreadValues({},i),t):i)}rotatePolygon(t=1,e=annotation.ERotateDirection.Clockwise,i=this.selectedID){if(!i)return;const s=PolygonUtils.getPolygonByID(this.polygonList,i);if(!s)return;const o=PolygonUtils.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",`${index.getMessagesByLocale(constants.EMessage.UpperLimitErrorNotice,this.lang)}${e}`);return}this.deleteSelectedID();const s=this.getCoordinateUnderZoom(t),o=AxisUtils.default.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(AxisUtils.default.returnClosePointIndex(o,AxisUtils.default.changePointListByZoom(this.drawingPointList,this.zoom))===0){this.addDrawingPointToPolygonList();return}const{dropFoot:n}=PolygonUtils.getClosestPoint(o,this.polygonListUnderZoom,this.config.lineType,tool.edgeAdsorptionScope),l=AxisUtils.default.changePointByZoom(n&&t.altKey===!1&&i?n:o,1/this.zoom);if(this.pattern===tool.EPolygonPattern.Rect&&this.drawingPointList.length===2){const h=MathUtils.default.getRectangleByRightAngle(l,this.drawingPointList);if(this.drawingPointList=h,this.config.drawOutsideTarget===!1&&this.imgInfo&&this.isPolygonOutSide(this.drawingPointList)){this.emit("messageInfo",`${index.getMessagesByLocale(constants.EMessage.ForbiddenCreationOutsideBoundary,this.lang)}`),this.drawingPointList=[];return}this.addDrawingPointToPolygonList(!0);return}this.drawingPointList.push(l),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=annotation.EDragStatus.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 __spreadProps(__spreadValues({},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=CommonToolUtils.getSourceID(this.basicResult),o=[...this.polygonList];if(this.editPolygonID){const r=o.find(n=>n.id===this.editPolygonID);if(!r)return;r.pointList=this.drawingPointList,this.editPolygonID=""}else{const r=uuid(8,62);let n={id:r,sourceID:s,valid:!this.isCtrl,textAttribute:"",pointList:this.drawingPointList,attribute:this.defaultAttribute,order:CommonToolUtils.getMaxOrder(o.filter(l=>CommonToolUtils.isSameSourceID(l.sourceID,s)))+1};if(this.config.textConfigurable){let l="";l=AttributeUtils.default.getTextAttribute(this.polygonList.filter(h=>CommonToolUtils.isSameSourceID(h.sourceID,s)),this.config.textCheckType),n=__spreadProps(__spreadValues({},n),{textAttribute:l})}this.pattern===tool.EPolygonPattern.Rect&&t===!0&&(n=__spreadProps(__spreadValues({},n),{isRect:!0})),o.push(n),i=n,this.setSelectedIdAfterAddingDrawing(r)}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=>__spreadProps(__spreadValues({},o),{pointList:AxisUtils.default.changePointListByZoom(o.pointList,this.zoom)}));return PolygonUtils.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=AxisUtils.default.changePointListByZoom(i.pointList,this.zoom);return PolygonUtils.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=AxisUtils.default.changePointListByZoom(e.pointList,this.zoom);return AxisUtils.default.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",`${index.getMessagesByLocale(constants.EMessage.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",`${index.getMessagesByLocale(constants.EMessage.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=annotation.ESortDirection.ascend;t.shiftKey&&(e=annotation.ESortDirection.descend),this.switchToNextPolygon(e)}switchToNextPolygon(t){if(this.drawingPointList.length>0)return;const[e,i]=CommonToolUtils.getRenderResultList(this.polygonList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let s=[...e];i&&(s=[...s,i]);const o=CanvasUtils.getViewPort(this.canvas,this.currentPos,this.zoom),r=s.map(l=>{var h,c,d,a;return __spreadProps(__spreadValues({},l),{x:(c=(h=l.pointList[0])==null?void 0:h.x)!=null?c:0,y:(a=(d=l.pointList[0])==null?void 0:d.y)!=null?a:0})}).filter(l=>CanvasUtils.inViewPort({x:l.x,y:l.y},o)),n=CommonToolUtils.getNextSelectedRectID(r,t,this.selectedID);if(n){this.setSelectedID(n.id);const{selectedPolygon:l}=this;l&&this.setDefaultAttribute(l.attribute)}this.render()}onKeyDown(t){if(!CommonToolUtils.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case keyCode.Space:this.spaceKeydown();break;case keyCode.Esc:this.drawingPointList=[],this.editPolygonID="";break;case keyCode.F:this.selectedID&&this.setPolygonValidAndRender(this.selectedID);break;case keyCode.Z:if(t.altKey){this.onCombinedExecute();return}this.setIsHidden(!this.isHidden),this.render();break;case keyCode.Delete:this.deletePolygon(this.selectedID),this.render();break;case keyCode.Ctrl:this.isCtrl=!0;break;case keyCode.Alt:this.isAlt===!1&&(t.preventDefault(),this.isAlt=!0,this.render());break;case keyCode.Tab:{this.onTabKeyDown(t);break}case keyCode.X:t.altKey&&this.segment();break;default:{if(this.config.attributeConfigurable){const i=AttributeUtils.default.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case keyCode.Ctrl:this.isCtrl=!1;break;case keyCode.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",`${index.getMessagesByLocale(constants.EMessage.ForbidAddNewPoint,this.lang)}`),this.clearPolygonDrag();return}const{dropFoot:s}=PolygonUtils.getClosestPoint(e,this.polygonListUnderZoom,this.config.lineType,tool.edgeAdsorptionScope);if(!s)return;const{upperLimitPointNum:o}=this.config;if(o&&i.pointList.length>=o){this.emit("messageInfo",`${index.getMessagesByLocale(constants.EMessage.UpperLimitErrorNotice,this.lang)}${o}`),this.clearPolygonDrag();return}i==null||i.pointList.splice(this.hoverEdgeIndex+1,0,AxisUtils.default.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 r=[0],n=annotation.EDragTarget.Plane;this.dragStatus=annotation.EDragStatus.Start;const l=this.getHoverPointIndex(t),h=this.getHoverEdgeIndex(t);l>-1?(n=annotation.EDragTarget.Point,r=[l]):h>-1&&this.hoverEdgeIndex>-1&&(n=annotation.EDragTarget.Line,r=[h,(h+1)%s.length]),this.dragInfo={dragStartCoord:o,dragTarget:n,initPointList:s,changePointIndex:r,originPolygon:this.selectedPolygon}}segment(){var t;if(!this.selectedID||((t=this.config)==null?void 0:t.lineType)!==tool.ELineTypes.Line)return;const e=PolygonUtils.getPolygonPointList(this.selectedID,this.currentShowList),i=this.currentShowList.filter(r=>r.id!==this.selectedID);if(i.length===0||e.length===0)return;const s=PolygonUtils.getWrapPolygonIndex(e,i);let o=[...this.polygonList];if(s===-1){const r=PolygonUtils.segmentPolygonByPolygon(e,i);if(!r)return;const n=r.shift();if(!n)return;let l="",h=!0;const c=CommonToolUtils.getSourceID(this.basicResult);let d="";o=this.polygonList.map(a=>{var u,f;return a.id===this.selectedID?(l=a.attribute,h=(u=a==null?void 0:a.valid)!=null?u:!0,d=(f=a==null?void 0:a.textAttribute)!=null?f:"",__spreadProps(__spreadValues({},a),{pointList:n})):a}),r.length>0&&r.forEach((a,u)=>{o.push({sourceID:c,id:uuid(8,62),pointList:a,valid:h,order:CommonToolUtils.getMaxOrder(this.currentShowList)+1+u,attribute:l,textAttribute:d})})}else o[s].pointList=PolygonUtils.clipPolygonFromWrapPolygon(e,o[s].pointList),o=o.filter(r=>r.id!==this.selectedID);this.setPolygonList(o),this.history.pushHistory(o),this.render()}onCombinedExecute(){if(!this.selectedID){this.emit("messageInfo",lbUtils.i18n.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)!==tool.ELineTypes.Line){this.emit("messageInfo",lbUtils.i18n.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 r=PolygonUtils.combinePolygonWithPolygon(s,o);if(!r)return;const{newPolygon:n,unionList:l}=r;if(l.length===1&&n){const h=this.polygonList.filter(c=>!l.includes(c.id)).map(c=>c.id===this.selectedID?n:c);this.setPolygonList(h),this.history.pushHistory(h),this.render(),this.emit("messageInfo",lbUtils.i18n.t("CombineSuccess"))}else this.emit("messageInfo",lbUtils.i18n.t("CombiningFailedNotify"));this.isCombined=!1}isPolygonOutSide(t){if(this.dependToolName&&this.basicCanvas&&this.basicResult){let n=!1;switch(this.dependToolName){case tool.EToolName.Rect:{n=t.filter(l=>!RectUtils.isInRect(l,this.basicResult)).length>0;break}case tool.EToolName.Polygon:{n=PolygonUtils.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}=MathUtils.default.calcViewportBoundaries(AxisUtils.default.changePointListByZoom(t,this.zoom)),r=1e-5;return e<0||i<0||s>this.imgInfo.width+r||o>this.imgInfo.height+r}onDragMove(t){if(!this.dragInfo||!this.selectedID)return;const{selectedPolygon:e}=this;let i=e==null?void 0:e.pointList;if(!i)return;const{initPointList:s,dragStartCoord:o,dragTarget:r,changePointIndex:n}=this.dragInfo,l=this.getCoordinateUnderZoom(t);let h={x:(l.x-o.x)/this.zoom,y:(l.y-o.y)/this.zoom};if(this.pattern===tool.EPolygonPattern.Rect&&(e==null?void 0:e.isRect)===!0&&n&&[annotation.EDragTarget.Line].includes(r)){const d=MathUtils.default.getArrayIndex(n[0]-2,4),a=MathUtils.default.getArrayIndex(n[0]-1,4),u=[s[d],s[a]];h=MathUtils.default.getRectPerpendicularOffset(o,l,u),h={x:h.x/this.zoom,y:h.y/this.zoom}}switch(this.dragStatus=annotation.EDragStatus.Move,r){case annotation.EDragTarget.Plane:i=i.map((d,a)=>__spreadProps(__spreadValues({},d),{x:s[a].x+h.x,y:s[a].y+h.y}));break;case annotation.EDragTarget.Point:case annotation.EDragTarget.Line:i=i.map((d,a)=>n&&n.includes(a)?__spreadProps(__spreadValues({},d),{x:s[a].x+h.x,y:s[a].y+h.y}):d);break}if(this.pattern===tool.EPolygonPattern.Rect&&(e==null?void 0:e.isRect)===!0&&r===annotation.EDragTarget.Point&&n&&(i=MathUtils.default.getPointListFromPointOffset(s,n[0],h)),this.config.drawOutsideTarget===!1&&this.imgInfo&&this.isPolygonOutSide(i))return;const c=this.polygonList.map(d=>{if(d.id===this.selectedID){const a=__spreadProps(__spreadValues({},d),{pointList:i});return d.isRect===!0&&this.pattern===tool.EPolygonPattern.Normal&&Object.assign(a,{isRect:!1}),a}return d});this.setPolygonList(c),this.render()}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;if(this.selectedID&&this.dragInfo){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())}leftMouseUp(t){const e=this.getHoverID(t);if(this.drawingPointList.length===0&&t.ctrlKey===!0&&e){this.setPolygonValidAndRender(e);return}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===annotation.EDragStatus.Move){const{originPolygon:e}=this.dragInfo;this.dragInfo=void 0,this.dragStatus=annotation.EDragStatus.Wait,this.history.pushHistory(this.polygonList),this.emit("updateResult"),this.emit("updatePolygonByDrag",{newPolygon:this.selectedPolygon,originPolygon:e});return}switch(t.button){case 0:{this.leftMouseUp(t);break}case 2:{this.rightMouseUp(t);break}}this.render()}}dragMouseUp(){this.dragStatus===annotation.EDragStatus.Start&&(this.dragInfo=void 0,this.dragStatus=annotation.EDragStatus.Wait)}exportData(){const{polygonList:t}=this;return[t,this.basicImgInfo]}getTextIconSvg(t=""){return AttributeUtils.default.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:TEXT_MAX_WIDTH,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;AttributeUtils.default.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",AttributeUtils.default.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPolygonList(AttributeUtils.default.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:r}=e,{x:n,y:l}=i[i.length-1],h=TEXT_MAX_WIDTH,c=AxisUtils.default.getOffsetCoordinate({x:n,y:l},this.currentPos,this.zoom),d=this.getColor(s),a=o?d==null?void 0:d.valid.stroke:d==null?void 0:d.invalid.stroke;this._textAttributInstance||(this._textAttributInstance=new textAttributeClass({width:h,container:this.container,icon:this.getTextIconSvg(s),color:a,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((t=this._textAttributInstance)==null?void 0:t.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${r}`,{left:c.x,top:c.y,color:a,width:h})}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.polygonList)==null||t.forEach(e=>{var i,s,o,r,n;if([this.selectedID,this.editPolygonID].includes(e.id))return;const{textAttribute:l,attribute:h}=e,c=this.getColor(h),d=StyleUtils.getStrokeAndFill(c,e.valid),a=AxisUtils.default.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);DrawUtils.drawPolygonWithFillAndLine(this.canvas,a,{fillColor:d.fill,strokeColor:d.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 u=`${(r=AttributeUtils.default.getAttributeShowText(h,this.config.attributeList))!=null?r:""}`;((n=this.config)==null?void 0:n.isShowOrder)&&(e==null?void 0:e.order)>0&&(u=`${e.order} ${u}`),DrawUtils.drawText(this.canvas,a[0],u,__spreadValues({color:d.stroke},annotation.DEFAULT_TEXT_OFFSET));const f=a[a.length-1];DrawUtils.drawText(this.canvas,{x:f.x+annotation.TEXT_ATTRIBUTE_OFFSET.x,y:f.y+annotation.TEXT_ATTRIBUTE_OFFSET.y},l,__spreadValues({color:d.stroke},annotation.DEFAULT_TEXT_OFFSET))}))}renderSelectedPolygon(){var t,e,i;if(this.selectedID){const s=this.selectedPolygon;if(s){const o=this.getColor(s.attribute),r=StyleUtils.getStrokeAndFill(o,s.valid,{isSelected:!0});DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,AxisUtils.default.changePointListByZoom(s.pointList,this.zoom,this.currentPos),{fillColor:r.fill,strokeColor:r.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(t=this.config)==null?void 0:t.lineType});let n=`${(e=AttributeUtils.default.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}`),DrawUtils.drawText(this.canvas,AxisUtils.default.changePointByZoom(s.pointList[0],this.zoom,this.currentPos),n,__spreadValues({color:r.stroke},annotation.DEFAULT_TEXT_OFFSET)),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=StyleUtils.getStrokeAndFill(s,!1,{isHover:!0}).fill,DrawUtils.drawPolygonWithFill(this.canvas,AxisUtils.default.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),r=StyleUtils.getStrokeAndFill(o,!this.isCtrl);if(((t=this.drawingPointList)==null?void 0:t.length)>0){let n=[...this.drawingPointList],l=AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.pattern===tool.EPolygonPattern.Rect&&n.length===2)n=MathUtils.default.getRectangleByRightAngle(l,n);else{if(((e=this.config)==null?void 0:e.edgeAdsorption)&&this.isAlt===!1){const{dropFoot:h}=PolygonUtils.getClosestPoint(l,this.polygonList,(i=this.config)==null?void 0:i.lineType,tool.edgeAdsorptionScope/this.zoom);h&&(l=h)}n.push(l)}DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,AxisUtils.default.changePointListByZoom(n,this.zoom,this.currentPos),{fillColor:r.fill,strokeColor:r.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 l=StyleUtils.getStrokeAndFill(o,n.valid,{isSelected:!0}),h=n==null?void 0:n.pointList[this.hoverPointIndex];if(h){const{x:c,y:d}=AxisUtils.default.changePointByZoom(h,this.zoom,this.currentPos);DrawUtils.drawCircleWithFill(this.canvas,{x:c,y:d},5,{color:l.fill})}}if(this.hoverEdgeIndex>-1&&this.selectedID){const n=this.selectedPolygon;if(!n)return;const l=StyleUtils.getStrokeAndFill(o,n.valid,{isSelected:!0});DrawUtils.drawLineWithPointList(this.canvas,AxisUtils.default.changePointListByZoom(n.pointList,this.zoom,this.currentPos),{color:l.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,r=32;DrawUtils.drawRectWithFill(this.canvas,{x:e+s,y:i-s*4-1,width:o,height:r},{color:"black"}),DrawUtils.drawText(this.canvas,{x:e,y:i},lbUtils.i18n.t("ClickAnotherPolygon"),{textAlign:"center",color:"white",offsetX:o/2+s,offsetY:-(r/2+s/2)}),DrawUtils.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("")}}module.exports=PolygonOperation;
1
+ "use strict";var lbUtils=require("@labelbee/lb-utils"),MathUtils=require("../../utils/MathUtils.js"),RectUtils=require("../../utils/tool/RectUtils.js"),annotation=require("../../constant/annotation.js"),keyCode=require("../../constant/keyCode.js"),tool=require("../../constant/tool.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js"),ActionsHistory=require("../../utils/ActionsHistory.js"),AttributeUtils=require("../../utils/tool/AttributeUtils.js"),AxisUtils=require("../../utils/tool/AxisUtils.js"),CanvasUtils=require("../../utils/tool/CanvasUtils.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),PolygonUtils=require("../../utils/tool/PolygonUtils.js"),StyleUtils=require("../../utils/tool/StyleUtils.js"),uuid=require("../../utils/uuid.js"),basicToolOperation=require("./basicToolOperation.js"),textAttributeClass=require("./textAttributeClass.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(g,t,e)=>t in g?__defProp(g,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):g[t]=e,__spreadValues=(g,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(g,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(g,e,t[e]);return g},__spreadProps=(g,t)=>__defProps(g,__getOwnPropDescs(t));const TEXT_MAX_WIDTH=164;class PolygonOperation extends basicToolOperation.BasicToolOperation{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(AttributeUtils.default.textChange(e,this.selectedID,this.polygonList)),this.emit("selectedChange"),this.render())},this.config=CommonToolUtils.jsonParser(t.config),this.drawingPointList=[],this.polygonList=[],this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.drawingHistory=new ActionsHistory,this.isCtrl=!1,this.isAlt=!1,this.isCombined=!1,this.pattern=tool.EPolygonPattern.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 PolygonUtils.getPolygonByID(this.polygonList,this.selectedID)}get hoverPolygon(){return this.polygonList.find(t=>t.id===this.hoverID&&t.id!==this.selectedID)}get polygonListUnderZoom(){return this.polygonList.map(t=>__spreadProps(__spreadValues({},t),{pointList:AxisUtils.default.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]=CommonToolUtils.getRenderResultList(this.polygonList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=CommonToolUtils.getRenderResultList(this.polygonList,CommonToolUtils.getSourceID(this.basicResult),[]);return t}setResultAndSelectedID(t,e){this.setPolygonList(t),e&&(this.selectedID=e),this.render()}setResult(t){this.clearActiveStatus(),this.setPolygonList(t),this.render()}setPolygonDataByID(t,e){return this.polygonList.map(i=>i.id===e?__spreadValues(__spreadValues({},i),t):i)}rotatePolygon(t=1,e=annotation.ERotateDirection.Clockwise,i=this.selectedID){if(!i)return;const s=PolygonUtils.getPolygonByID(this.polygonList,i);if(!s)return;const o=PolygonUtils.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",`${index.getMessagesByLocale(constants.EMessage.UpperLimitErrorNotice,this.lang)}${e}`);return}this.deleteSelectedID();const s=this.getCoordinateUnderZoom(t),o=AxisUtils.default.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(AxisUtils.default.returnClosePointIndex(o,AxisUtils.default.changePointListByZoom(this.drawingPointList,this.zoom))===0){this.addDrawingPointToPolygonList();return}const{dropFoot:n}=PolygonUtils.getClosestPoint(o,this.polygonListUnderZoom,this.config.lineType,tool.edgeAdsorptionScope),l=AxisUtils.default.changePointByZoom(n&&t.altKey===!1&&i?n:o,1/this.zoom);if(this.pattern===tool.EPolygonPattern.Rect&&this.drawingPointList.length===2){const h=MathUtils.default.getRectangleByRightAngle(l,this.drawingPointList);if(this.drawingPointList=h,this.config.drawOutsideTarget===!1&&this.imgInfo&&this.isPolygonOutSide(this.drawingPointList)){this.emit("messageInfo",`${index.getMessagesByLocale(constants.EMessage.ForbiddenCreationOutsideBoundary,this.lang)}`),this.drawingPointList=[];return}this.addDrawingPointToPolygonList(!0);return}this.drawingPointList.push(l),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=annotation.EDragStatus.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 __spreadProps(__spreadValues({},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=CommonToolUtils.getSourceID(this.basicResult),o=[...this.polygonList];if(this.editPolygonID){const r=o.find(n=>n.id===this.editPolygonID);if(!r)return;r.pointList=this.drawingPointList,this.editPolygonID=""}else{const r=uuid(8,62);let n={id:r,sourceID:s,valid:!this.isCtrl,textAttribute:"",pointList:this.drawingPointList,attribute:this.defaultAttribute,order:CommonToolUtils.getMaxOrder(o.filter(l=>CommonToolUtils.isSameSourceID(l.sourceID,s)))+1};if(this.config.textConfigurable){let l="";l=AttributeUtils.default.getTextAttribute(this.polygonList.filter(h=>CommonToolUtils.isSameSourceID(h.sourceID,s)),this.config.textCheckType),n=__spreadProps(__spreadValues({},n),{textAttribute:l})}this.pattern===tool.EPolygonPattern.Rect&&t===!0&&(n=__spreadProps(__spreadValues({},n),{isRect:!0})),o.push(n),i=n,this.setSelectedIdAfterAddingDrawing(r)}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=>__spreadProps(__spreadValues({},o),{pointList:AxisUtils.default.changePointListByZoom(o.pointList,this.zoom)}));return PolygonUtils.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=AxisUtils.default.changePointListByZoom(i.pointList,this.zoom);return PolygonUtils.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=AxisUtils.default.changePointListByZoom(e.pointList,this.zoom);return AxisUtils.default.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",`${index.getMessagesByLocale(constants.EMessage.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",`${index.getMessagesByLocale(constants.EMessage.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=annotation.ESortDirection.ascend;t.shiftKey&&(e=annotation.ESortDirection.descend),this.switchToNextPolygon(e)}switchToNextPolygon(t){if(this.drawingPointList.length>0)return;const[e,i]=CommonToolUtils.getRenderResultList(this.polygonList,CommonToolUtils.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let s=[...e];i&&(s=[...s,i]);const o=CanvasUtils.getViewPort(this.canvas,this.currentPos,this.zoom),r=s.map(l=>{var h,c,d,a;return __spreadProps(__spreadValues({},l),{x:(c=(h=l.pointList[0])==null?void 0:h.x)!=null?c:0,y:(a=(d=l.pointList[0])==null?void 0:d.y)!=null?a:0})}).filter(l=>CanvasUtils.inViewPort({x:l.x,y:l.y},o)),n=CommonToolUtils.getNextSelectedRectID(r,t,this.selectedID);if(n){this.setSelectedID(n.id);const{selectedPolygon:l}=this;l&&this.setDefaultAttribute(l.attribute)}this.render()}onKeyDown(t){if(!CommonToolUtils.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case keyCode.Space:this.spaceKeydown();break;case keyCode.Esc:this.drawingPointList=[],this.editPolygonID="";break;case keyCode.F:this.selectedID&&this.setPolygonValidAndRender(this.selectedID);break;case keyCode.Z:if(t.altKey){this.onCombinedExecute();return}this.setIsHidden(!this.isHidden),this.render();break;case keyCode.Delete:this.deletePolygon(this.selectedID),this.render();break;case keyCode.Ctrl:this.isCtrl=!0;break;case keyCode.Alt:this.isAlt===!1&&(t.preventDefault(),this.isAlt=!0,this.render());break;case keyCode.Tab:{this.onTabKeyDown(t);break}case keyCode.X:t.altKey&&this.segment();break;default:{if(this.config.attributeConfigurable){const i=AttributeUtils.default.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case keyCode.Ctrl:this.isCtrl=!1;break;case keyCode.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",`${index.getMessagesByLocale(constants.EMessage.ForbidAddNewPoint,this.lang)}`),this.clearPolygonDrag();return}const{dropFoot:s}=PolygonUtils.getClosestPoint(e,this.polygonListUnderZoom,this.config.lineType,tool.edgeAdsorptionScope);if(!s)return;const{upperLimitPointNum:o}=this.config;if(o&&i.pointList.length>=o){this.emit("messageInfo",`${index.getMessagesByLocale(constants.EMessage.UpperLimitErrorNotice,this.lang)}${o}`),this.clearPolygonDrag();return}i==null||i.pointList.splice(this.hoverEdgeIndex+1,0,AxisUtils.default.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 r=[0],n=annotation.EDragTarget.Plane;this.dragStatus=annotation.EDragStatus.Start;const l=this.getHoverPointIndex(t),h=this.getHoverEdgeIndex(t);l>-1?(n=annotation.EDragTarget.Point,r=[l]):h>-1&&this.hoverEdgeIndex>-1&&(n=annotation.EDragTarget.Line,r=[h,(h+1)%s.length]),this.dragInfo={dragStartCoord:o,dragTarget:n,initPointList:s,changePointIndex:r,originPolygon:this.selectedPolygon}}segment(){var t;if(!this.selectedID||((t=this.config)==null?void 0:t.lineType)!==tool.ELineTypes.Line)return;const e=PolygonUtils.getPolygonPointList(this.selectedID,this.currentShowList),i=this.currentShowList.filter(r=>r.id!==this.selectedID);if(i.length===0||e.length===0)return;const s=PolygonUtils.getWrapPolygonIndex(e,i);let o=[...this.polygonList];if(s===-1){const r=PolygonUtils.segmentPolygonByPolygon(e,i);if(!r)return;const n=r.shift();if(!n)return;let l="",h=!0;const c=CommonToolUtils.getSourceID(this.basicResult);let d="";o=this.polygonList.map(a=>{var u,f;return a.id===this.selectedID?(l=a.attribute,h=(u=a==null?void 0:a.valid)!=null?u:!0,d=(f=a==null?void 0:a.textAttribute)!=null?f:"",__spreadProps(__spreadValues({},a),{pointList:n})):a}),r.length>0&&r.forEach((a,u)=>{o.push({sourceID:c,id:uuid(8,62),pointList:a,valid:h,order:CommonToolUtils.getMaxOrder(this.currentShowList)+1+u,attribute:l,textAttribute:d})})}else o[s].pointList=PolygonUtils.clipPolygonFromWrapPolygon(e,o[s].pointList),o=o.filter(r=>r.id!==this.selectedID);this.setPolygonList(o),this.history.pushHistory(o),this.render()}onCombinedExecute(){if(!this.selectedID){this.emit("messageInfo",lbUtils.i18n.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)!==tool.ELineTypes.Line){this.emit("messageInfo",lbUtils.i18n.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 r=PolygonUtils.combinePolygonWithPolygon(s,o);if(!r)return;const{newPolygon:n,unionList:l}=r;if(l.length===1&&n){const h=this.polygonList.filter(c=>!l.includes(c.id)).map(c=>c.id===this.selectedID?n:c);this.setPolygonList(h),this.history.pushHistory(h),this.render(),this.emit("messageInfo",lbUtils.i18n.t("CombineSuccess"))}else this.emit("messageInfo",lbUtils.i18n.t("CombiningFailedNotify"));this.isCombined=!1}isPolygonOutSide(t){if(this.dependToolName&&this.basicCanvas&&this.basicResult){let n=!1;switch(this.dependToolName){case tool.EToolName.Rect:{n=t.filter(l=>!RectUtils.isInRect(l,this.basicResult)).length>0;break}case tool.EToolName.Polygon:{n=PolygonUtils.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}=MathUtils.default.calcViewportBoundaries(AxisUtils.default.changePointListByZoom(t,this.zoom)),r=1e-5;return e<0||i<0||s>this.imgInfo.width+r||o>this.imgInfo.height+r}onDragMove(t){if(!this.dragInfo||!this.selectedID)return;const{selectedPolygon:e}=this;let i=e==null?void 0:e.pointList;if(!i)return;const{initPointList:s,dragStartCoord:o,dragTarget:r,changePointIndex:n}=this.dragInfo,l=this.getCoordinateUnderZoom(t);let h={x:(l.x-o.x)/this.zoom,y:(l.y-o.y)/this.zoom};if(this.pattern===tool.EPolygonPattern.Rect&&(e==null?void 0:e.isRect)===!0&&n&&[annotation.EDragTarget.Line].includes(r)){const d=MathUtils.default.getArrayIndex(n[0]-2,4),a=MathUtils.default.getArrayIndex(n[0]-1,4),u=[s[d],s[a]];h=MathUtils.default.getRectPerpendicularOffset(o,l,u),h={x:h.x/this.zoom,y:h.y/this.zoom}}switch(this.dragStatus=annotation.EDragStatus.Move,r){case annotation.EDragTarget.Plane:i=i.map((d,a)=>__spreadProps(__spreadValues({},d),{x:s[a].x+h.x,y:s[a].y+h.y}));break;case annotation.EDragTarget.Point:case annotation.EDragTarget.Line:i=i.map((d,a)=>n&&n.includes(a)?__spreadProps(__spreadValues({},d),{x:s[a].x+h.x,y:s[a].y+h.y}):d);break}if(this.pattern===tool.EPolygonPattern.Rect&&(e==null?void 0:e.isRect)===!0&&r===annotation.EDragTarget.Point&&n&&(i=MathUtils.default.getPointListFromPointOffset(s,n[0],h)),this.config.drawOutsideTarget===!1&&this.imgInfo&&this.isPolygonOutSide(i))return;const c=this.polygonList.map(d=>{if(d.id===this.selectedID){const a=__spreadProps(__spreadValues({},d),{pointList:i});return d.isRect===!0&&this.pattern===tool.EPolygonPattern.Normal&&Object.assign(a,{isRect:!1}),a}return d});this.setPolygonList(c),this.render()}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;if(this.selectedID&&this.dragInfo){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===annotation.EDragStatus.Move){const{originPolygon:e}=this.dragInfo;this.dragInfo=void 0,this.dragStatus=annotation.EDragStatus.Wait,this.history.pushHistory(this.polygonList),this.emit("updateResult"),this.emit("updatePolygonByDrag",{newPolygon:this.selectedPolygon,originPolygon:e});return}switch(t.button){case 0:{this.leftMouseUp(t);break}case 2:{this.rightMouseUp(t);break}}this.render()}}dragMouseUp(){this.dragStatus===annotation.EDragStatus.Start&&(this.dragInfo=void 0,this.dragStatus=annotation.EDragStatus.Wait)}exportData(){const{polygonList:t}=this;return[t,this.basicImgInfo]}getTextIconSvg(t=""){return AttributeUtils.default.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:TEXT_MAX_WIDTH,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;AttributeUtils.default.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",AttributeUtils.default.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPolygonList(AttributeUtils.default.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:r}=e,{x:n,y:l}=i[i.length-1],h=TEXT_MAX_WIDTH,c=AxisUtils.default.getOffsetCoordinate({x:n,y:l},this.currentPos,this.zoom),d=this.getColor(s),a=o?d==null?void 0:d.valid.stroke:d==null?void 0:d.invalid.stroke;this._textAttributInstance||(this._textAttributInstance=new textAttributeClass({width:h,container:this.container,icon:this.getTextIconSvg(s),color:a,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((t=this._textAttributInstance)==null?void 0:t.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${r}`,{left:c.x,top:c.y,color:a,width:h})}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.polygonList)==null||t.forEach(e=>{var i,s,o,r,n;if([this.selectedID,this.editPolygonID].includes(e.id))return;const{textAttribute:l,attribute:h}=e,c=this.getColor(h),d=StyleUtils.getStrokeAndFill(c,e.valid),a=AxisUtils.default.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);DrawUtils.drawPolygonWithFillAndLine(this.canvas,a,{fillColor:d.fill,strokeColor:d.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 u=`${(r=AttributeUtils.default.getAttributeShowText(h,this.config.attributeList))!=null?r:""}`;((n=this.config)==null?void 0:n.isShowOrder)&&(e==null?void 0:e.order)>0&&(u=`${e.order} ${u}`),DrawUtils.drawText(this.canvas,a[0],u,__spreadValues({color:d.stroke},annotation.DEFAULT_TEXT_OFFSET));const f=a[a.length-1];DrawUtils.drawText(this.canvas,{x:f.x+annotation.TEXT_ATTRIBUTE_OFFSET.x,y:f.y+annotation.TEXT_ATTRIBUTE_OFFSET.y},l,__spreadValues({color:d.stroke},annotation.DEFAULT_TEXT_OFFSET))}))}renderSelectedPolygon(){var t,e,i;if(this.selectedID){const s=this.selectedPolygon;if(s){const o=this.getColor(s.attribute),r=StyleUtils.getStrokeAndFill(o,s.valid,{isSelected:!0});DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,AxisUtils.default.changePointListByZoom(s.pointList,this.zoom,this.currentPos),{fillColor:r.fill,strokeColor:r.stroke,pointColor:"white",thickness:2,lineCap:"round",isClose:!0,lineType:(t=this.config)==null?void 0:t.lineType});let n=`${(e=AttributeUtils.default.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}`),DrawUtils.drawText(this.canvas,AxisUtils.default.changePointByZoom(s.pointList[0],this.zoom,this.currentPos),n,__spreadValues({color:r.stroke},annotation.DEFAULT_TEXT_OFFSET)),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=StyleUtils.getStrokeAndFill(s,!1,{isHover:!0}).fill,DrawUtils.drawPolygonWithFill(this.canvas,AxisUtils.default.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),r=StyleUtils.getStrokeAndFill(o,!this.isCtrl);if(((t=this.drawingPointList)==null?void 0:t.length)>0){let n=[...this.drawingPointList],l=AxisUtils.default.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.pattern===tool.EPolygonPattern.Rect&&n.length===2)n=MathUtils.default.getRectangleByRightAngle(l,n);else{if(((e=this.config)==null?void 0:e.edgeAdsorption)&&this.isAlt===!1){const{dropFoot:h}=PolygonUtils.getClosestPoint(l,this.polygonList,(i=this.config)==null?void 0:i.lineType,tool.edgeAdsorptionScope/this.zoom);h&&(l=h)}n.push(l)}DrawUtils.drawSelectedPolygonWithFillAndLine(this.canvas,AxisUtils.default.changePointListByZoom(n,this.zoom,this.currentPos),{fillColor:r.fill,strokeColor:r.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 l=StyleUtils.getStrokeAndFill(o,n.valid,{isSelected:!0}),h=n==null?void 0:n.pointList[this.hoverPointIndex];if(h){const{x:c,y:d}=AxisUtils.default.changePointByZoom(h,this.zoom,this.currentPos);DrawUtils.drawCircleWithFill(this.canvas,{x:c,y:d},5,{color:l.fill})}}if(this.hoverEdgeIndex>-1&&this.selectedID){const n=this.selectedPolygon;if(!n)return;const l=StyleUtils.getStrokeAndFill(o,n.valid,{isSelected:!0});DrawUtils.drawLineWithPointList(this.canvas,AxisUtils.default.changePointListByZoom(n.pointList,this.zoom,this.currentPos),{color:l.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,r=32;DrawUtils.drawRectWithFill(this.canvas,{x:e+s,y:i-s*4-1,width:o,height:r},{color:"black"}),DrawUtils.drawText(this.canvas,{x:e,y:i},lbUtils.i18n.t("ClickAnotherPolygon"),{textAlign:"center",color:"white",offsetX:o/2+s,offsetY:-(r/2+s/2)}),DrawUtils.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("")}}module.exports=PolygonOperation;
@@ -27,6 +27,12 @@ export declare const BASE_ICON: {
27
27
  };
28
28
  /** 无效色 - 红:rgba(255, 51, 51, 1) */
29
29
  export declare const INVALID_COLOR = "rgba(255, 51, 51, 1)";
30
+ export declare const INVALID_COLOR_RGBA: {
31
+ r: number;
32
+ g: number;
33
+ b: number;
34
+ a: number;
35
+ };
30
36
  export declare const NULL_COLOR = "rgba(204, 204, 204, 1)";
31
37
  export { NULL_ICON, INVALID_ICON };
32
38
  /**
@@ -4,6 +4,7 @@ export class PCDLoader extends Loader {
4
4
  load(url: any, onLoad: any, onProgress: any, onError: any): void;
5
5
  parse(data: any): Points<BufferGeometry, PointsMaterial>;
6
6
  genColorByCoord(x: any, y: any, z: any): number[];
7
+ genColorByZ(x: any, y: any, z: any): any[];
7
8
  }
8
9
  import { Loader } from "three/src/loaders/Loader";
9
10
  import { BufferGeometry } from "three/src/core/BufferGeometry";