@labelbee/lb-annotation 1.12.0-alpha.1 → 1.12.0-alpha.2

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.
@@ -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("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIF8oKXtsZXQgdDtjb25zdCBlPW5ldyBBcnJheSgyNTYpLmZpbGwoIiIpLm1hcCgoKT0+bmV3IEFycmF5KDMpLmZpbGwoIiIpKTtmb3IobGV0IGk9MDtpPDIwO2krKyl7Zm9yKHQ9MDt0PDMyO3QrKyllW3RdWzBdPTEyOCs0KnQsZVt0XVsxXT0wLGVbdF1bMl09MDtmb3IoZVszMl1bMF09MjU1LGVbMzJdWzFdPTAsZVszMl1bMl09MCx0PTA7dDw2Mzt0KyspZVszMyt0XVswXT0yNTUsZVszMyt0XVsxXT00KzQqdCxlWzMzK3RdWzJdPTA7Zm9yKGVbOTZdWzBdPTI1NCxlWzk2XVsxXT0yNTUsZVs5Nl1bMl09Mix0PTA7dDw2Mjt0KyspZVs5Nyt0XVswXT0yNTAtNCp0LGVbOTcrdF1bMV09MjU1LGVbOTcrdF1bMl09Nis0KnQ7Zm9yKGVbMTU5XVswXT0xLGVbMTU5XVsxXT0yNTUsZVsxNTldWzJdPTI1NCx0PTA7dDw2NDt0KyspZVsxNjArdF1bMF09MCxlWzE2MCt0XVsxXT0yNTItdCo0LGVbMTYwK3RdWzJdPTI1NTtmb3IodD0wO3Q8MzI7dCsrKWVbMjI0K3RdWzBdPTAsZVsyMjQrdF1bMV09MCxlWzIyNCt0XVsyXT0yNTItNCp0fXJldHVybiBlfWNvbnN0IGQ9XygpO2Z1bmN0aW9uIG0odCxlLGk9MCl7bGV0IGY9MCx1LGMsbixvO2U9Wy4uLmVdLGk9PT0xJiYoZT1jcmVhdGVTbW9vdGhDdXJ2ZVBvaW50cyhlLnJlZHVjZSgocixsKT0+Wy4uLnIsbC54LGwueV0sW10pLC41LCEwLFNFR01FTlRfTlVNQkVSKSksW25dPWU7Y29uc3QgYT1lLmxlbmd0aDtmb3IodT0xO3U8PWE7dSsrKW89ZVt1JWFdLHQueD5NYXRoLm1pbihuLngsby54KSYmdC54PD1NYXRoLm1heChuLngsby54KSYmdC55PD1NYXRoLm1heChuLnksby55KSYmbi54IT09by54JiYoYz0odC54LW4ueCkqKG8ueS1uLnkpLyhvLngtbi54KStuLnksKG4ueT09PW8ueXx8dC55PD1jKSYmZisrKSxuPW87cmV0dXJuIGYlMiE9MH1mdW5jdGlvbiBiKHt6TWluOnQsek1heDplLHBvbHlnb25Qb2ludExpc3Q6aSxhdHRyaWJ1dGU6Zix4OnUseTpjLHo6bixjb2xvckxpc3Q6byx2YWxpZDphfSl7aWYobSh7eDp1LHk6Y30saSkmJm4+PXQmJm48PWUpcmV0dXJuIGE9PT0hMT9bMSwxMDMvMjU1LDEwMi8yNTVdOm9bZl0/b1tmXS5yZ2JhLnNsaWNlKDAsMykubWFwKGw9PmwvMjU1KTpbMSwwLDBdfXJldHVybiBvbm1lc3NhZ2U9ZnVuY3Rpb24oZSl7Y29uc3R7cG9zaXRpb246aSxjb2xvcjpmLGN1Ym9pZExpc3Q6dSxjb2xvckxpc3Q6Y309ZS5kYXRhO2xldCBuPTAsbz0tTnVtYmVyLk1BWF9TQUZFX0lOVEVHRVIsYT1OdW1iZXIuTUFYX1NBRkVfSU5URUdFUjtmb3IobGV0IHI9MDtyPGkubGVuZ3RoO3IrPTMpe2NvbnN0IGw9aVtyKzJdO2wmJihsPGEmJihhPWwpLGw+byYmKG89bCkpfWZvcihsZXQgcj0wO3I8aS5sZW5ndGg7cis9Myl7Y29uc3QgbD1pW3JdLHA9aVtyKzFdLGc9aVtyKzJdLEU9dS5tYXAocz0+Yih7cG9seWdvblBvaW50TGlzdDpzLnBvbHlnb25Qb2ludExpc3Qsek1pbjpzLnpNaW4sek1heDpzLnpNYXgseDpsLHk6cCx6OmcsYXR0cmlidXRlOnMuYXR0cmlidXRlLGNvbG9yTGlzdDpjLHZhbGlkOnMudmFsaWR9KSkuZmlsdGVyKHM9PnMpLnBvcCgpO2lmKEUpe24rKztjb25zdFtzLE0seV09RTtmW3JdPXMsZltyKzFdPU0sZltyKzJdPXl9ZWxzZXtjb25zdCBzPW8tYSxNPU1hdGguZmxvb3IoKGctYSkvcyoyNTUpLHk9ZFtNXSxbQSxDLE5dPXk7ZltyXT1BLzI1NSxmW3IrMV09Qy8yNTUsZltyKzJdPU4vMjU1fX1wb3N0TWVzc2FnZSh7cG9pbnRzOmksY29sb3I6ZixudW06bn0pfSx4LmlzSW5Qb2x5Z29uPW0sT2JqZWN0LmRlZmluZVByb3BlcnR5KHgsIl9fZXNNb2R1bGUiLHt2YWx1ZTohMH0pLHh9KHt9KTsKCg==",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(f){super(f);this.littleEndian=!0}load(f,x,c,u){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(f,function(d){try{x(i.parse(d))}catch(h){u?u(h):console.error(h),i.manager.itemError(f)}},c,u)}parse(f){function x(n,e){const a=n.length,r=new Uint8Array(e);let s=0,t=0,o,p,w;do if(o=n[s++],o<1<<5){if(o++,t+o>e)throw new Error("Output buffer is not large enough");if(s+o>a)throw new Error("Invalid compressed data");do r[t++]=n[s++];while(--o)}else{if(p=o>>5,w=t-((o&31)<<8)-1,s>=a)throw new Error("Invalid compressed data");if(p===7&&(p+=n[s++],s>=a))throw new Error("Invalid compressed data");if(w-=n[s++],t+p+2>e)throw new Error("Output buffer is not large enough");if(w<0)throw new Error("Invalid compressed data");if(w>=t)throw new Error("Invalid compressed data");do r[t++]=r[w++];while(--p+2)}while(s<a);return r}function c(n){const e={},a=n.search(/[\n\r]data\s(\S*)\s/i),r=/[\n\r]data\s(\S*)\s/i.exec(n.slice(a-1));if(e.data=r[1],e.headerLen=r[0].length+a,e.str=n.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 s=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]]=s,s+=e.size[t]*e.count[t]);return e.rowSize=s,e}const u=THREE.LoaderUtils.decodeText(new Uint8Array(f)),i=c(u),l=[],d=[],h=[];let g=-Number.MAX_SAFE_INTEGER,m=Number.MAX_SAFE_INTEGER;if(i.data==="ascii"){const{offset:n}=i,a=u.slice(i.headerLen).split(`
2
+ `);for(let r=0,s=a.length;r<s;r++){if(a[r]==="")continue;const t=a[r].split(" ");let o;if(n.x!==void 0&&(l.push(parseFloat(t[n.x])),l.push(parseFloat(t[n.y])),o=parseFloat(t[n.z]),l.push(o)),this.genColorByCoord){const w=this.genColorByCoord(parseFloat(t[n.x]),parseFloat(t[n.y]),parseFloat(t[n.z])).map(z=>z/255);h.push(...w)}n.normal_x!==void 0&&(d.push(parseFloat(t[n.normal_x])),d.push(parseFloat(t[n.normal_y])),o=parseFloat(t[n.normal_z]),d.push(o)),o&&(o<m&&(m=o),o>g&&(g=o))}}if(i.data==="binary_compressed"){const n=new Uint32Array(f.slice(i.headerLen,i.headerLen+8)),e=n[0],a=n[1],r=x(new Uint8Array(f,i.headerLen+8,e),a),s=new DataView(r.buffer),{offset:t}=i;for(let o=0;o<i.points;o++){let p;if(t.x!==void 0&&(l.push(s.getFloat32(i.points*t.x+i.size[0]*o,this.littleEndian)),l.push(s.getFloat32(i.points*t.y+i.size[1]*o,this.littleEndian)),p=s.getFloat32(i.points*t.z+i.size[2]*o,this.littleEndian),l.push(p)),t.normal_x!==void 0&&(d.push(s.getFloat32(i.points*t.normal_x+i.size[4]*o,this.littleEndian)),d.push(s.getFloat32(i.points*t.normal_y+i.size[5]*o,this.littleEndian)),p=s.getFloat32(i.points*t.normal_z+i.size[6]*o,this.littleEndian),d.push(p)),this.genColorByCoord){const z=this.genColorByCoord(s.getFloat32(i.points*t.x+i.size[0]*o,this.littleEndian),s.getFloat32(i.points*t.y+i.size[0]*o,this.littleEndian),s.getFloat32(i.points*t.z+i.size[0]*o,this.littleEndian)).map(E=>E/255);h.push(...z)}p&&(p<m&&(m=p),p>g&&(g=p))}}if(i.data==="binary"){const n=new DataView(f,i.headerLen),{offset:e}=i;for(let a=0,r=0;a<i.points;a++,r+=i.rowSize){let s;e.x!==void 0&&(l.push(n.getFloat32(r+e.x,this.littleEndian)),l.push(n.getFloat32(r+e.y,this.littleEndian)),s=n.getFloat32(r+e.z,this.littleEndian),l.push(s)),e.normal_x!==void 0&&(d.push(n.getFloat32(r+e.normal_x,this.littleEndian)),d.push(n.getFloat32(r+e.normal_y,this.littleEndian)),s=n.getFloat32(r+e.normal_z,this.littleEndian),d.push(s)),s&&(s<m&&(m=s),s>g&&(g=s))}for(let a=0,r=0;a<i.points;a++,r+=i.rowSize)if(this.genColorByZ){const t=this.genColorByZ({x:n.getFloat32(r+e.x,this.littleEndian),y:n.getFloat32(r+e.y,this.littleEndian),z:n.getFloat32(r+e.z,this.littleEndian),minZ:m,maxZ:g}).map(o=>o/255);h.push(...t)}}const y=new THREE.BufferGeometry;l.length>0&&y.setAttribute("position",new THREE.Float32BufferAttribute(l,3)),d.length>0&&y.setAttribute("normal",new THREE.Float32BufferAttribute(d,3)),h.length>0&&y.setAttribute("color",new THREE.Float32BufferAttribute(h,3)),y.computeBoundingSphere();const F=new THREE.PointsMaterial({size:.01});return h.length>0?F.vertexColors=!0:F.color.setHex(16777215),new THREE.Points(y,F)}genColorByCoord(f,x,c){return c<=0?[128,128,128]:c<5?[255,0,0]:c<10?[0,255,0]:[0,0,255]}genColorByZ({x:f,y:x,z:c,minZ:u,maxZ:i}){const l=i-u,d=Math.floor((c-u)/l*255),h=lbUtils.COLOR_MAP_JET[d];return[h[0],h[1],h[2]]}}exports.PCDLoader=PCDLoader;
@@ -1,11 +1,11 @@
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(u){if(u&&u.__esModule)return u;var t=Object.create(null);return u&&Object.keys(u).forEach(function(e){if(e!=="default"){var i=Object.getOwnPropertyDescriptor(u,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:function(){return u[e]}})}}),t.default=u,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=(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)),__async=(u,t,e)=>new Promise((i,n)=>{var s=o=>{try{r(e.next(o))}catch(c){n(c)}},a=o=>{try{r(e.throw(o))}catch(c){n(c)}},r=o=>o.done?i(o.value):Promise.resolve(o.value).then(s,a);r((e=e.apply(u,t)).next())});const DEFAULT_DISTANCE=30,highlightWorker=new highlightWorker$1({type:"module"});class PointCloud{constructor({container:t,noAppend:e,isOrthographicCamera:i,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=(r,o=16777215)=>{var c;const h=(c=r.id)!=null?c:uuid();this.removeObjectByName(h);const{center:l,width:d,height:x,depth:g,rotation:m}=r,p=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),b=new THREE__namespace.BoxHelper(f,o),C=this.generateBoxArrow(r);p.add(b),p.add(C),p.position.set(l.x,l.y,l.z),p.rotation.set(0,0,m),p.name=h,this.scene.add(p)},this.overridePointShader=r=>{r.vertexShader=`
2
2
  attribute float sizes;
3
3
  attribute float visibility;
4
4
  varying float vVisible;
5
- ${i.vertexShader}`.replace("gl_PointSize = size;",`gl_PointSize = size;
5
+ ${r.vertexShader}`.replace("gl_PointSize = size;",`gl_PointSize = size;
6
6
  vVisible = visibility;
7
- `),i.fragmentShader=`
7
+ `),r.fragmentShader=`
8
8
  varying float vVisible;
9
- ${i.fragmentShader}`.replace("#include <clipping_planes_fragment>",`
9
+ ${r.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=(r,o)=>__async(this,null,function*(){this.clearPointCloud();const c=yield this.cacheInstance.loadPCDFile(r);c.name=this.pointCloudObjectName,this.renderPointCloud(c,o)}),this.loadPCDFileByBox=(r,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:{},p=yield this.filterPointsByBox(__spreadProps(__spreadValues({},o),{width:o.width+x,height:o.height+g,depth:o.depth+m}),d);if(!p){console.error("filter Error");return}this.clearPointCloud();const y=new THREE__namespace.Points(p.geometry,d.material);y.name=this.pointCloudObjectName,this.scene.add(y),this.render()}),l=yield this.cacheInstance.loadPCDFile(r);h(l)}),this.generateRange=r=>{const o=this.createRange(r);this.scene.add(o)},this.generateBoxArrow=({width:r})=>{const o=new THREE__namespace.Vector3(1,0,0),c=new THREE__namespace.Vector3(r/2,0,0),h=2,l=16776960,d=new THREE__namespace.ArrowHelper(o,c,h,l);return d.visible=this.showDirection,d},this.generateBoxTrackID=r=>{if(!r.trackID)return;const o=new THREE__namespace.Texture(this.getTextCanvas(r.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(-r.width/2,0,r.depth/2+.5),h},this.applyZAxisPoints=r=>{this.zAxisLimit=r,this.filterZAxisPoints(),this.render()},this.updatePointSize=r=>{const o=this.scene.getObjectByName(this.pointCloudObjectName);if(!o)return;const c=o.material.size;r?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,i&&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:i,top:n,bottom:s,near:a,far:r}=t;this.camera.left=e,this.camera.right=i,this.camera.top=n,this.camera.bottom=s,this.camera.near=a,this.camera.far=r,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:i,z:n}=this.initCameraPosition;t.position.set(e,i,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 i=e;this.AddBoxToSense(t,i),this.render()}getAllAttributeColor(t){return t.reduce((e,i)=>(e[i.attribute]=lbUtils.toolStyleConverter.getColorFromConfig({attribute:i.attribute},__spreadProps(__spreadValues({},this.config),{attributeConfigurable:!0}),{}),e),{})}generateBoxes(t){t.forEach(e=>{this.generateBox(e)}),this.render()}getOrthographicCamera(t){const{center:e,width:i,height:n}=t,s=10,a=e.x-i/2-s,r=e.x-i/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:r,top:o,bottom:c,near:h,far:l,zoom:d}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e){const{center:i,width:n,height:s,depth:a,rotation:r}=t,o=this.getCameraVector(i,r,{width:n,height:s,depth:a},e);return this.updateCamera(o,i),o}updateOrthoCamera(t,e){const i=this.updateCameraByBox(t,e);return this.camera.zoom=1,this.camera.updateProjectionMatrix(),{cameraPositionVector:i}}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){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=i}if(window.Worker){const{zMin:i,zMax:n,polygonPointList:s}=matrix.getCuboidFromPointCloudBox(t),a=e.geometry.attributes.position.array,r=e.geometry.attributes.color.array,o={boxParams:t,zMin:i,zMax:n,polygonPointList:s,color:r,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,i,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,i);break;case lbUtils.EPerspectiveView.RBT:a=lbUtils.PerspectiveShiftUtils.rightBackTopViewMatrix4(s,i);break}const r=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(r).applyMatrix4(o).applyMatrix4(h).applyMatrix4(c)}createRange(t){this.removeObjectByName(this.rangeObjectName);const i=new THREE__namespace.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),n=new THREE__namespace.BufferGeometry().setFromPoints(i),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 i=new THREE__namespace.PointsMaterial({vertexColors:!0});i.onBeforeCompile=this.overridePointShader,e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=i,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 new Promise(i=>{if(window.Worker){const s=(t?[...t]:[]).map(o=>matrix.getCuboidFromPointCloudBox(o)),a=this.getAllAttributeColor(s),r={cuboidList:s,position:e.geometry.attributes.position.array,color:e.geometry.attributes.color.array,colorList:a};highlightWorker.postMessage(r),highlightWorker.onmessage=o=>{const{color:c}=o.data,h=new THREE__namespace.BufferAttribute(c,3);h.needsUpdate=!0,e.geometry.setAttribute("color",h),i(c),this.render()}}})}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const i=new THREE__namespace.BufferAttribute(t,3);i.needsUpdate=!0,e.geometry.setAttribute("color",i),this.render()}}setShowDirection(t){this.showDirection=t,this.scene.children.forEach(e=>{e.type==="Group"&&e.children.forEach(i=>{i.type==="ArrowHelper"&&(i.visible=t)})}),this.render()}getTextCanvas(t){const e=document.createElement("canvas"),i=e.getContext("2d");return i&&(i.font=`${50}px " bold`,i.fillStyle="white",i.textAlign="center",i.textBaseline="middle",i.fillText(t,e.width/2,e.height/2)),e}getSensesPointZAxisInPolygon(t,e){const i=this.scene.children.find(o=>o.uuid===this.pointsUuid);let n=0,s=0,a=0,r=0;if(i&&(i==null?void 0:i.geometry)){const o=i==null?void 0:i.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),r++,e&&d>=e[0]&&d<=e[1]&&a++)}}return{maxZ:s,minZ:n,count:a,zCount:r}}getBasicCoordinate2Canvas(t){const e=this.containerWidth/2,i=this.containerHeight/2;return{x:t.x*e+e,y:t.y*i+i,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,i=this.containerHeight/2;return new THREE__namespace.Vector3(t.x/e-e/2,-(t.y/i-i/2),1)}getPolygonSidePoints(t){const{center:{x:e,y:i,z:n},height:s,width:a,depth:r}=t,o={x:e+a/2,y:i+s/2,z:n-r/2},c={x:e+a/2,y:i+s/2,z:n+r/2},h={x:e-a/2,y:i+s/2,z:n+r/2},l={x:e-a/2,y:i+s/2,z:n-r/2};return[o,c,h,l]}getPolygonBackPoints(t){const{center:{x:e,y:i,z:n},height:s,width:a,depth:r}=t,o={x:e-a/2,y:i+s/2,z:n+r/2},c={x:e-a/2,y:i+s/2,z:n-r/2},h={x:e-a/2,y:i-s/2,z:n-r/2},l={x:e-a/2,y:i-s/2,z:n+r/2};return[o,c,h,l]}getPolygonTopPoints(t){const{center:{x:e,y:i,z:n},height:s,width:a,depth:r}=t,o={x:e+a/2,y:i+s/2,z:n+r/2},c={x:e+a/2,y:i-s/2,z:n+r/2},h={x:e-a/2,y:i-s/2,z:n+r/2},l={x:e-a/2,y:i+s/2,z:n+r/2};return[o,c,h,l]}getModelTransformationMatrix(t){const{center:{x:e,y:i,z:n},rotation:s}=t,a=new THREE__namespace.Matrix4().makeTranslation(-e,-i,-n),r=new THREE__namespace.Matrix4().makeTranslation(e,i,n),o=new THREE__namespace.Matrix4().makeRotationZ(s);return new THREE__namespace.Matrix4().multiply(r).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 i=this.boxParams2ViewPolygon(t,e),{width:n,height:s}=t,a=new THREE__namespace.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),r=new THREE__namespace.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=r;const o=i.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:i}=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,r=this.containerHeight/i;return{polygon2d:s,zoom:Math.min(a,r)/2}}getNewBoxBySideUpdate(t,e,i,n){const s=new THREE__namespace.Matrix4().makeRotationZ(n.rotation),a=new THREE__namespace.Vector3(-t.x,0,0).applyMatrix4(s);let r=n;return r.center={x:r.center.x+a.x,y:r.center.y+a.y,z:r.center.z-t.z},r=__spreadProps(__spreadValues({},r),{width:r.width+e,height:r.height,depth:r.depth+i}),{newBoxParams:r}}getNewBoxByBackUpdate(t,e,i,n){const s=new THREE__namespace.Matrix4().makeRotationZ(n.rotation),a=new THREE__namespace.Vector3(0,-t.x,0).applyMatrix4(s);let r=n;return r.center={x:r.center.x+a.x,y:r.center.y+a.y,z:r.center.z-t.z},r=__spreadProps(__spreadValues({},r),{width:r.width,height:r.height+e,depth:r.depth+i}),{newBoxParams:r}}getNewBoxBySideUpdateByPoints(t,e,i,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 r=t.map(p=>new THREE__namespace.Vector3(p.x,p.y,p.z)).map(p=>p.applyMatrix4(a)),[o,c,h,l]=r,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-i},width:d,height:n.height,depth:n.depth+e,rotation:n.rotation})}}filterZAxisPoints(t){const e=t||this.scene.children.find(i=>i.uuid===this.pointsUuid);if(e){const{attributes:i}=e.geometry,{position:n}=i,s=[],{count:a}=n;for(let r=0;r<a;r++){const o=n.getZ(r);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=(s,t,e)=>t in s?__defProp(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,__spreadValues=(s,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(s,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(s,e,t[e]);return s},__spreadProps=(s,t)=>__defProps(s,__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}a.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=a=>{var d;if(this.selectedPolygons){const c=this.getPointCloudLineColor(a),h=AxisUtils.default.changePointListByZoom(a.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}),a.isRect===!0&&this.showDirectionLine===!0&&this.renderRectPolygonDirection(h)}};var e,i,o,r,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=(r=t.checkMode)!=null?r:!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,r;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:(r=this.config)==null?void 0:r.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),r=this.currentPolygonListByPattern.map(n=>__spreadProps(__spreadValues({},n),{pointList:AxisUtils.default.changePointListByZoom(n.pointList,this.zoom)}));return PolygonUtils.getHoverPolygonID(i,r,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 r,n,l,a;return __spreadProps(__spreadValues({},o),{x:(n=(r=o.pointList[0])==null?void 0:r.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.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 +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,13 @@ 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, y, z, minZ, maxZ }: {
8
+ x: any;
9
+ y: any;
10
+ z: any;
11
+ minZ: any;
12
+ maxZ: any;
13
+ }): any[];
7
14
  }
8
15
  import { Loader } from "three/src/loaders/Loader";
9
16
  import { BufferGeometry } from "three/src/core/BufferGeometry";
@@ -76,6 +76,9 @@ export declare class PointCloud {
76
76
  * @param color
77
77
  */
78
78
  generateBox(boxParams: IPointCloudBox, color?: number): void;
79
+ getAllAttributeColor(boxes: IPointCloudBox[]): {
80
+ [k: string]: any;
81
+ };
79
82
  AddBoxToSense: (boxParams: IPointCloudBox, color?: number) => void;
80
83
  generateBoxes(boxes: IPointCloudBox[]): void;
81
84
  /**
@@ -92,6 +95,7 @@ export declare class PointCloud {
92
95
  far: number;
93
96
  zoom: number;
94
97
  };
98
+ updateCameraZoom(zoom: number): void;
95
99
  /**
96
100
  * Update Camera position & target
97
101
  * @param boxParams
@@ -140,11 +144,12 @@ export declare class PointCloud {
140
144
  */
141
145
  loadPCDFile: (src: string, radius?: number) => Promise<void>;
142
146
  /**
143
- * It needs to be updated after load PointCLoud's data.
147
+ * It needs to be updated after load PointCloud's data.
144
148
  * @param boxParams
145
149
  * @returns
146
150
  */
147
- highlightOriginPointCloud(boxParams: IPointCloudBox): void;
151
+ highlightOriginPointCloud(pointCloudBoxList?: IPointCloudBox[]): Promise<THREE.BufferAttribute[] | undefined> | undefined;
152
+ updateColor(color: any[]): void;
148
153
  /**
149
154
  * Load PCD File by box
150
155
  * @param src
@@ -34,6 +34,19 @@ export declare function getCuboidFromPointCloudBox(boxParams: IPointCloudBox): {
34
34
  }[];
35
35
  zMax: number;
36
36
  zMin: number;
37
+ attribute: string;
38
+ center: I3DSpaceCoord;
39
+ id: string;
40
+ rotation: number;
41
+ valid: boolean;
42
+ trackID?: number | undefined;
43
+ subAttribute?: {
44
+ [k: string]: string;
45
+ } | undefined;
46
+ count?: number | undefined;
47
+ width: number;
48
+ height: number;
49
+ depth: number;
37
50
  };
38
51
  export declare function pointCloudLidar2image(boxParams: IPointCloudBox, cameraMatrix: {
39
52
  P: [TMatrix14Tuple, TMatrix14Tuple, TMatrix14Tuple];
@@ -50,7 +50,7 @@ declare class PointCloud2dOperation extends PolygonOperation {
50
50
  onKeyUp: () => void;
51
51
  getLineColor(): string;
52
52
  /** 获取当前属性颜色 */
53
- getPointCloudLineColor(attribute?: string): string;
53
+ getPointCloudLineColor(polygon: IPolygonData): string;
54
54
  /**
55
55
  * Add direction
56
56
  * @override
@@ -139,6 +139,7 @@ declare class PolygonOperation extends BasicToolOperation {
139
139
  isPolygonOutSide(selectedPointList: IPolygonPoint[]): boolean;
140
140
  onDragMove(e: MouseEvent): void;
141
141
  onMouseMove(e: MouseEvent): void;
142
+ leftMouseUpdateValid(e: MouseEvent): boolean;
142
143
  leftMouseUp(e: MouseEvent): void;
143
144
  onMouseUp(e: MouseEvent): undefined;
144
145
  dragMouseUp(): void;
@@ -1 +1 @@
1
- import{createBase64WorkerFactory as b}from"./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js";var s=b("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2NsYXNzIEN7c3RhdGljIGdlbkNvbG9yQnlDb29yZChyLHUsbil7cmV0dXJuIG48PTA/WzEyOCwxMjgsMTI4XTpuPDU/WzI1NSwwLDBdOm48MTA/WzAsMjU1LDBdOlswLDAsMjU1XX1zdGF0aWMgZ2V0U3RhbmRhcmRDb2xvckJ5Q29vcmQocix1LG4pe3JldHVybiB0aGlzLmdlbkNvbG9yQnlDb29yZChyLHUsbikubWFwKGk9PmkvMjU1KX19ZnVuY3Rpb24geShzLHIsdT0wKXtsZXQgbj0wLGEsaSx0LG87cj1bLi4ucl0sdT09PTEmJihyPWNyZWF0ZVNtb290aEN1cnZlUG9pbnRzKHIucmVkdWNlKChmLGwpPT5bLi4uZixsLngsbC55XSxbXSksLjUsITAsU0VHTUVOVF9OVU1CRVIpKSxbdF09cjtjb25zdCBlPXIubGVuZ3RoO2ZvcihhPTE7YTw9ZTthKyspbz1yW2ElZV0scy54Pk1hdGgubWluKHQueCxvLngpJiZzLng8PU1hdGgubWF4KHQueCxvLngpJiZzLnk8PU1hdGgubWF4KHQueSxvLnkpJiZ0LnghPT1vLngmJihpPShzLngtdC54KSooby55LXQueSkvKG8ueC10LngpK3QueSwodC55PT09by55fHxzLnk8PWkpJiZuKyspLHQ9bztyZXR1cm4gbiUyIT0wfXJldHVybiBvbm1lc3NhZ2U9ZnVuY3Rpb24ocil7Y29uc3R7ek1pbjp1LHpNYXg6bixwb2x5Z29uUG9pbnRMaXN0OmEscG9zaXRpb246aSxjb2xvcjp0fT1yLmRhdGE7bGV0IG89MDtmb3IobGV0IGU9MDtlPGkubGVuZ3RoO2UrPTMpe2NvbnN0IGY9aVtlXSxsPWlbZSsxXSxkPWlbZSsyXTtpZih5KHt4OmYseTpsfSxhKSYmZD49dSYmZDw9bilvKyssdFtlXT0wLHRbZSsxXT0xLHRbZSsyXT0xO2Vsc2V7Y29uc3RbYyxnLE1dPUMuZ2V0U3RhbmRhcmRDb2xvckJ5Q29vcmQoZixsLGQpO3RbZV09Yyx0W2UrMV09Zyx0W2UrMl09TX19cG9zdE1lc3NhZ2Uoe3BvaW50czppLGNvbG9yOnQsbnVtOm99KX0seC5pc0luUG9seWdvbj15LE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh4LCJfX2VzTW9kdWxlIix7dmFsdWU6ITB9KSx4fSh7fSk7Cgo=",null,!1);export{s as default};
1
+ import{createBase64WorkerFactory as b}from"./_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js";var d=b("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwp2YXIgd29ya2VyX2NvZGU9ZnVuY3Rpb24oeCl7InVzZSBzdHJpY3QiO2Z1bmN0aW9uIF8oKXtsZXQgdDtjb25zdCBlPW5ldyBBcnJheSgyNTYpLmZpbGwoIiIpLm1hcCgoKT0+bmV3IEFycmF5KDMpLmZpbGwoIiIpKTtmb3IobGV0IGk9MDtpPDIwO2krKyl7Zm9yKHQ9MDt0PDMyO3QrKyllW3RdWzBdPTEyOCs0KnQsZVt0XVsxXT0wLGVbdF1bMl09MDtmb3IoZVszMl1bMF09MjU1LGVbMzJdWzFdPTAsZVszMl1bMl09MCx0PTA7dDw2Mzt0KyspZVszMyt0XVswXT0yNTUsZVszMyt0XVsxXT00KzQqdCxlWzMzK3RdWzJdPTA7Zm9yKGVbOTZdWzBdPTI1NCxlWzk2XVsxXT0yNTUsZVs5Nl1bMl09Mix0PTA7dDw2Mjt0KyspZVs5Nyt0XVswXT0yNTAtNCp0LGVbOTcrdF1bMV09MjU1LGVbOTcrdF1bMl09Nis0KnQ7Zm9yKGVbMTU5XVswXT0xLGVbMTU5XVsxXT0yNTUsZVsxNTldWzJdPTI1NCx0PTA7dDw2NDt0KyspZVsxNjArdF1bMF09MCxlWzE2MCt0XVsxXT0yNTItdCo0LGVbMTYwK3RdWzJdPTI1NTtmb3IodD0wO3Q8MzI7dCsrKWVbMjI0K3RdWzBdPTAsZVsyMjQrdF1bMV09MCxlWzIyNCt0XVsyXT0yNTItNCp0fXJldHVybiBlfWNvbnN0IGQ9XygpO2Z1bmN0aW9uIG0odCxlLGk9MCl7bGV0IGY9MCx1LGMsbixvO2U9Wy4uLmVdLGk9PT0xJiYoZT1jcmVhdGVTbW9vdGhDdXJ2ZVBvaW50cyhlLnJlZHVjZSgocixsKT0+Wy4uLnIsbC54LGwueV0sW10pLC41LCEwLFNFR01FTlRfTlVNQkVSKSksW25dPWU7Y29uc3QgYT1lLmxlbmd0aDtmb3IodT0xO3U8PWE7dSsrKW89ZVt1JWFdLHQueD5NYXRoLm1pbihuLngsby54KSYmdC54PD1NYXRoLm1heChuLngsby54KSYmdC55PD1NYXRoLm1heChuLnksby55KSYmbi54IT09by54JiYoYz0odC54LW4ueCkqKG8ueS1uLnkpLyhvLngtbi54KStuLnksKG4ueT09PW8ueXx8dC55PD1jKSYmZisrKSxuPW87cmV0dXJuIGYlMiE9MH1mdW5jdGlvbiBiKHt6TWluOnQsek1heDplLHBvbHlnb25Qb2ludExpc3Q6aSxhdHRyaWJ1dGU6Zix4OnUseTpjLHo6bixjb2xvckxpc3Q6byx2YWxpZDphfSl7aWYobSh7eDp1LHk6Y30saSkmJm4+PXQmJm48PWUpcmV0dXJuIGE9PT0hMT9bMSwxMDMvMjU1LDEwMi8yNTVdOm9bZl0/b1tmXS5yZ2JhLnNsaWNlKDAsMykubWFwKGw9PmwvMjU1KTpbMSwwLDBdfXJldHVybiBvbm1lc3NhZ2U9ZnVuY3Rpb24oZSl7Y29uc3R7cG9zaXRpb246aSxjb2xvcjpmLGN1Ym9pZExpc3Q6dSxjb2xvckxpc3Q6Y309ZS5kYXRhO2xldCBuPTAsbz0tTnVtYmVyLk1BWF9TQUZFX0lOVEVHRVIsYT1OdW1iZXIuTUFYX1NBRkVfSU5URUdFUjtmb3IobGV0IHI9MDtyPGkubGVuZ3RoO3IrPTMpe2NvbnN0IGw9aVtyKzJdO2wmJihsPGEmJihhPWwpLGw+byYmKG89bCkpfWZvcihsZXQgcj0wO3I8aS5sZW5ndGg7cis9Myl7Y29uc3QgbD1pW3JdLHA9aVtyKzFdLGc9aVtyKzJdLEU9dS5tYXAocz0+Yih7cG9seWdvblBvaW50TGlzdDpzLnBvbHlnb25Qb2ludExpc3Qsek1pbjpzLnpNaW4sek1heDpzLnpNYXgseDpsLHk6cCx6OmcsYXR0cmlidXRlOnMuYXR0cmlidXRlLGNvbG9yTGlzdDpjLHZhbGlkOnMudmFsaWR9KSkuZmlsdGVyKHM9PnMpLnBvcCgpO2lmKEUpe24rKztjb25zdFtzLE0seV09RTtmW3JdPXMsZltyKzFdPU0sZltyKzJdPXl9ZWxzZXtjb25zdCBzPW8tYSxNPU1hdGguZmxvb3IoKGctYSkvcyoyNTUpLHk9ZFtNXSxbQSxDLE5dPXk7ZltyXT1BLzI1NSxmW3IrMV09Qy8yNTUsZltyKzJdPU4vMjU1fX1wb3N0TWVzc2FnZSh7cG9pbnRzOmksY29sb3I6ZixudW06bn0pfSx4LmlzSW5Qb2x5Z29uPW0sT2JqZWN0LmRlZmluZVByb3BlcnR5KHgsIl9fZXNNb2R1bGUiLHt2YWx1ZTohMH0pLHh9KHt9KTsKCg==",null,!1);export{d as default};
@@ -1 +1 @@
1
- import a from"../assets/attributeIcon/icon_canvasEdit0.svg.js";import i from"../assets/attributeIcon/icon_canvasEdit1.svg.js";import l from"../assets/attributeIcon/icon_canvasEdit2.svg.js";import t from"../assets/attributeIcon/icon_canvasEdit3.svg.js";import e from"../assets/attributeIcon/icon_canvasEdit4.svg.js";import b from"../assets/attributeIcon/icon_canvasEdit5.svg.js";import g from"../assets/attributeIcon/icon_canvasEdit6.svg.js";import o from"../assets/attributeIcon/icon_canvasEdit7.svg.js";import s from"../assets/attributeIcon/icon_canvasEdit8.svg.js";import v from"../assets/attributeIcon/icon_editLAN.svg.js";import d from"../assets/attributeIcon/icon_editQING.svg.js";import n from"../assets/attributeIcon/icon_editLV.svg.js";import c from"../assets/attributeIcon/icon_editHUANG.svg.js";import f from"../assets/attributeIcon/icon_editFEN.svg.js";import{EFilterToolOperation as r}from"./tool.js";export{default as INVALID_ICON}from"../assets/attributeIcon/icon_canvasEdit_miss.svg.js";const k=a,H=61,E=80,I=62,_=20,S=55,m=55,O=40,p=80,T=240,u=320,L="rgba(102, 111, 255, 1)",A=["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)"],j=[a,g,t,o,l,s,b,i,e],R={1:v,3:d,5:n,7:c,9:f},N="rgba(255, 51, 51, 1)",C="rgba(204, 204, 204, 1)",G={[r.lc]:"rgba(153, 51, 255, 1)",[r.rc]:"rgba(51, 153, 255, 1)",[r.clc]:"rgba(46, 230, 46, 1)",[r.crc]:"rgba(255, 51, 51, 1)"},D='{"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)"]}';export{R as BASE_ICON,A as COLORS_ARRAY,u as EDIT_STEP_WIDTH,G as FILTER_TOOL_COLOR,p as FOOTER_HEIGHT,H as HEADER_HEIGHT,j as ICON_ARRAY,N as INVALID_COLOR,C as NULL_COLOR,k as NULL_ICON,_ as PADDING,m as PAGINATION_HEIGHT,I as SEARCH_HEIGHT,T as SIDERBAR_WIDTH,S as TABLE_ROW_HEIGHT,E as TAB_HEIGHT,L as THEME_COLOR,O as TIPS_HEIGHT,D as styleString};
1
+ import a from"../assets/attributeIcon/icon_canvasEdit0.svg.js";import i from"../assets/attributeIcon/icon_canvasEdit1.svg.js";import l from"../assets/attributeIcon/icon_canvasEdit2.svg.js";import t from"../assets/attributeIcon/icon_canvasEdit3.svg.js";import e from"../assets/attributeIcon/icon_canvasEdit4.svg.js";import b from"../assets/attributeIcon/icon_canvasEdit5.svg.js";import g from"../assets/attributeIcon/icon_canvasEdit6.svg.js";import o from"../assets/attributeIcon/icon_canvasEdit7.svg.js";import s from"../assets/attributeIcon/icon_canvasEdit8.svg.js";import v from"../assets/attributeIcon/icon_editLAN.svg.js";import d from"../assets/attributeIcon/icon_editQING.svg.js";import n from"../assets/attributeIcon/icon_editLV.svg.js";import c from"../assets/attributeIcon/icon_editHUANG.svg.js";import f from"../assets/attributeIcon/icon_editFEN.svg.js";import{EFilterToolOperation as r}from"./tool.js";export{default as INVALID_ICON}from"../assets/attributeIcon/icon_canvasEdit_miss.svg.js";const k=a,H=61,E=80,I=62,_=20,S=55,m=55,O=40,L=80,p=240,T=320,u="rgba(102, 111, 255, 1)",A=["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)"],R=[a,g,t,o,l,s,b,i,e],j={1:v,3:d,5:n,7:c,9:f},N="rgba(255, 51, 51, 1)",C={r:255,g:51,b:51,a:1},G="rgba(204, 204, 204, 1)",D={[r.lc]:"rgba(153, 51, 255, 1)",[r.rc]:"rgba(51, 153, 255, 1)",[r.clc]:"rgba(46, 230, 46, 1)",[r.crc]:"rgba(255, 51, 51, 1)"},B='{"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)"]}';export{j as BASE_ICON,A as COLORS_ARRAY,T as EDIT_STEP_WIDTH,D as FILTER_TOOL_COLOR,L as FOOTER_HEIGHT,H as HEADER_HEIGHT,R as ICON_ARRAY,N as INVALID_COLOR,C as INVALID_COLOR_RGBA,G as NULL_COLOR,k as NULL_ICON,_ as PADDING,m as PAGINATION_HEIGHT,I as SEARCH_HEIGHT,p as SIDERBAR_WIDTH,S as TABLE_ROW_HEIGHT,E as TAB_HEIGHT,u as THEME_COLOR,O as TIPS_HEIGHT,B as styleString};
@@ -1,2 +1,2 @@
1
- import{Loader as z,FileLoader as C,LoaderUtils as E,BufferGeometry as v,Float32BufferAttribute as x,PointsMaterial as _,Points as L}from"three";class b extends z{constructor(d){super(d);this.littleEndian=!0}load(d,m,u,w){const i=this,l=new C(i.manager);l.setPath(i.path),l.setResponseType("arraybuffer"),l.setRequestHeader(i.requestHeader),l.setWithCredentials(i.withCredentials),l.load(d,function(p){try{m(i.parse(p))}catch(h){w?w(h):console.error(h),i.manager.itemError(d)}},u,w)}parse(d){function m(o,t){const a=o.length,n=new Uint8Array(t);let r=0,e=0,s,f,c;do if(s=o[r++],s<1<<5){if(s++,e+s>t)throw new Error("Output buffer is not large enough");if(r+s>a)throw new Error("Invalid compressed data");do n[e++]=o[r++];while(--s)}else{if(f=s>>5,c=e-((s&31)<<8)-1,r>=a)throw new Error("Invalid compressed data");if(f===7&&(f+=o[r++],r>=a))throw new Error("Invalid compressed data");if(c-=o[r++],e+f+2>t)throw new Error("Output buffer is not large enough");if(c<0)throw new Error("Invalid compressed data");if(c>=e)throw new Error("Invalid compressed data");do n[e++]=n[c++];while(--f+2)}while(r<a);return n}function u(o){const t={},a=o.search(/[\n\r]data\s(\S*)\s/i),n=/[\n\r]data\s(\S*)\s/i.exec(o.slice(a-1));if(t.data=n[1],t.headerLen=n[0].length+a,t.str=o.slice(0,t.headerLen),t.str=t.str.replace(/#.*/gi,""),t.version=/version (.*)/i.exec(t.str),t.fields=/fields (.*)/i.exec(t.str),t.size=/size (.*)/i.exec(t.str),t.type=/type (.*)/i.exec(t.str),t.count=/count (.*)/i.exec(t.str),t.width=/width (.*)/i.exec(t.str),t.height=/height (.*)/i.exec(t.str),t.viewpoint=/viewpoint (.*)/i.exec(t.str),t.points=/points (.*)/i.exec(t.str),t.version!==null&&(t.version=parseFloat(t.version[1])),t.fields=t.fields!==null?t.fields[1].split(" "):[],t.type!==null&&(t.type=t.type[1].split(" ")),t.width!==null&&(t.width=parseInt(t.width[1])),t.height!==null&&(t.height=parseInt(t.height[1])),t.viewpoint!==null&&(t.viewpoint=t.viewpoint[1]),t.points!==null&&(t.points=parseInt(t.points[1],10)),t.points===null&&(t.points=t.width*t.height),t.size!==null&&(t.size=t.size[1].split(" ").map(function(e){return parseInt(e,10)})),t.count!==null)t.count=t.count[1].split(" ").map(function(e){return parseInt(e,10)});else{t.count=[];for(let e=0,s=t.fields.length;e<s;e++)t.count.push(1)}t.offset={};let r=0;for(let e=0,s=t.fields.length;e<s;e++)t.data==="ascii"?t.offset[t.fields[e]]=e:(t.offset[t.fields[e]]=r,r+=t.size[e]*t.count[e]);return t.rowSize=r,t}const w=E.decodeText(new Uint8Array(d)),i=u(w),l=[],p=[],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 e=a[n].split(" ");if(o.x!==void 0&&(l.push(parseFloat(e[o.x])),l.push(parseFloat(e[o.y])),l.push(parseFloat(e[o.z]))),this.genColorByCoord){const f=this.genColorByCoord(parseFloat(e[o.x]),parseFloat(e[o.y]),parseFloat(e[o.z])).map(c=>c/255);h.push(...f)}o.normal_x!==void 0&&(p.push(parseFloat(e[o.normal_x])),p.push(parseFloat(e[o.normal_y])),p.push(parseFloat(e[o.normal_z])))}}if(i.data==="binary_compressed"){const o=new Uint32Array(d.slice(i.headerLen,i.headerLen+8)),t=o[0],a=o[1],n=m(new Uint8Array(d,i.headerLen+8,t),a),r=new DataView(n.buffer),{offset:e}=i;for(let s=0;s<i.points;s++)if(e.x!==void 0&&(l.push(r.getFloat32(i.points*e.x+i.size[0]*s,this.littleEndian)),l.push(r.getFloat32(i.points*e.y+i.size[1]*s,this.littleEndian)),l.push(r.getFloat32(i.points*e.z+i.size[2]*s,this.littleEndian))),e.normal_x!==void 0&&(p.push(r.getFloat32(i.points*e.normal_x+i.size[4]*s,this.littleEndian)),p.push(r.getFloat32(i.points*e.normal_y+i.size[5]*s,this.littleEndian)),p.push(r.getFloat32(i.points*e.normal_z+i.size[6]*s,this.littleEndian))),this.genColorByCoord){const c=this.genColorByCoord(r.getFloat32(i.points*e.x+i.size[0]*s,this.littleEndian),r.getFloat32(i.points*e.y+i.size[0]*s,this.littleEndian),r.getFloat32(i.points*e.z+i.size[0]*s,this.littleEndian)).map(F=>F/255);h.push(...c)}}if(i.data==="binary"){const o=new DataView(d,i.headerLen),{offset:t}=i;for(let a=0,n=0;a<i.points;a++,n+=i.rowSize)if(t.x!==void 0&&(l.push(o.getFloat32(n+t.x,this.littleEndian)),l.push(o.getFloat32(n+t.y,this.littleEndian)),l.push(o.getFloat32(n+t.z,this.littleEndian))),t.normal_x!==void 0&&(p.push(o.getFloat32(n+t.normal_x,this.littleEndian)),p.push(o.getFloat32(n+t.normal_y,this.littleEndian)),p.push(o.getFloat32(n+t.normal_z,this.littleEndian))),this.genColorByCoord){const e=this.genColorByCoord(o.getFloat32(n+t.x,this.littleEndian),o.getFloat32(n+t.y,this.littleEndian),o.getFloat32(n+t.z,this.littleEndian)).map(s=>s/255);h.push(...e)}}const g=new v;l.length>0&&g.setAttribute("position",new x(l,3)),p.length>0&&g.setAttribute("normal",new x(p,3)),h.length>0&&g.setAttribute("color",new x(h,3)),g.computeBoundingSphere();const y=new _({size:.01});return h.length>0?y.vertexColors=!0:y.color.setHex(16777215),new L(g,y)}genColorByCoord(d,m,u){return u<=0?[128,128,128]:u<5?[255,0,0]:u<10?[0,255,0]:[0,0,255]}}export{b as PCDLoader};
1
+ import{Loader as v,FileLoader as _,LoaderUtils as b,BufferGeometry as A,Float32BufferAttribute as E,PointsMaterial as L,Points as I}from"three";import{COLOR_MAP_JET as B}from"@labelbee/lb-utils";class S extends v{constructor(f){super(f);this.littleEndian=!0}load(f,x,c,u){const i=this,l=new _(i.manager);l.setPath(i.path),l.setResponseType("arraybuffer"),l.setRequestHeader(i.requestHeader),l.setWithCredentials(i.withCredentials),l.load(f,function(d){try{x(i.parse(d))}catch(h){u?u(h):console.error(h),i.manager.itemError(f)}},c,u)}parse(f){function x(n,e){const a=n.length,r=new Uint8Array(e);let s=0,t=0,o,p,w;do if(o=n[s++],o<1<<5){if(o++,t+o>e)throw new Error("Output buffer is not large enough");if(s+o>a)throw new Error("Invalid compressed data");do r[t++]=n[s++];while(--o)}else{if(p=o>>5,w=t-((o&31)<<8)-1,s>=a)throw new Error("Invalid compressed data");if(p===7&&(p+=n[s++],s>=a))throw new Error("Invalid compressed data");if(w-=n[s++],t+p+2>e)throw new Error("Output buffer is not large enough");if(w<0)throw new Error("Invalid compressed data");if(w>=t)throw new Error("Invalid compressed data");do r[t++]=r[w++];while(--p+2)}while(s<a);return r}function c(n){const e={},a=n.search(/[\n\r]data\s(\S*)\s/i),r=/[\n\r]data\s(\S*)\s/i.exec(n.slice(a-1));if(e.data=r[1],e.headerLen=r[0].length+a,e.str=n.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 s=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]]=s,s+=e.size[t]*e.count[t]);return e.rowSize=s,e}const u=b.decodeText(new Uint8Array(f)),i=c(u),l=[],d=[],h=[];let g=-Number.MAX_SAFE_INTEGER,m=Number.MAX_SAFE_INTEGER;if(i.data==="ascii"){const{offset:n}=i,a=u.slice(i.headerLen).split(`
2
+ `);for(let r=0,s=a.length;r<s;r++){if(a[r]==="")continue;const t=a[r].split(" ");let o;if(n.x!==void 0&&(l.push(parseFloat(t[n.x])),l.push(parseFloat(t[n.y])),o=parseFloat(t[n.z]),l.push(o)),this.genColorByCoord){const w=this.genColorByCoord(parseFloat(t[n.x]),parseFloat(t[n.y]),parseFloat(t[n.z])).map(F=>F/255);h.push(...w)}n.normal_x!==void 0&&(d.push(parseFloat(t[n.normal_x])),d.push(parseFloat(t[n.normal_y])),o=parseFloat(t[n.normal_z]),d.push(o)),o&&(o<m&&(m=o),o>g&&(g=o))}}if(i.data==="binary_compressed"){const n=new Uint32Array(f.slice(i.headerLen,i.headerLen+8)),e=n[0],a=n[1],r=x(new Uint8Array(f,i.headerLen+8,e),a),s=new DataView(r.buffer),{offset:t}=i;for(let o=0;o<i.points;o++){let p;if(t.x!==void 0&&(l.push(s.getFloat32(i.points*t.x+i.size[0]*o,this.littleEndian)),l.push(s.getFloat32(i.points*t.y+i.size[1]*o,this.littleEndian)),p=s.getFloat32(i.points*t.z+i.size[2]*o,this.littleEndian),l.push(p)),t.normal_x!==void 0&&(d.push(s.getFloat32(i.points*t.normal_x+i.size[4]*o,this.littleEndian)),d.push(s.getFloat32(i.points*t.normal_y+i.size[5]*o,this.littleEndian)),p=s.getFloat32(i.points*t.normal_z+i.size[6]*o,this.littleEndian),d.push(p)),this.genColorByCoord){const F=this.genColorByCoord(s.getFloat32(i.points*t.x+i.size[0]*o,this.littleEndian),s.getFloat32(i.points*t.y+i.size[0]*o,this.littleEndian),s.getFloat32(i.points*t.z+i.size[0]*o,this.littleEndian)).map(C=>C/255);h.push(...F)}p&&(p<m&&(m=p),p>g&&(g=p))}}if(i.data==="binary"){const n=new DataView(f,i.headerLen),{offset:e}=i;for(let a=0,r=0;a<i.points;a++,r+=i.rowSize){let s;e.x!==void 0&&(l.push(n.getFloat32(r+e.x,this.littleEndian)),l.push(n.getFloat32(r+e.y,this.littleEndian)),s=n.getFloat32(r+e.z,this.littleEndian),l.push(s)),e.normal_x!==void 0&&(d.push(n.getFloat32(r+e.normal_x,this.littleEndian)),d.push(n.getFloat32(r+e.normal_y,this.littleEndian)),s=n.getFloat32(r+e.normal_z,this.littleEndian),d.push(s)),s&&(s<m&&(m=s),s>g&&(g=s))}for(let a=0,r=0;a<i.points;a++,r+=i.rowSize)if(this.genColorByZ){const t=this.genColorByZ({x:n.getFloat32(r+e.x,this.littleEndian),y:n.getFloat32(r+e.y,this.littleEndian),z:n.getFloat32(r+e.z,this.littleEndian),minZ:m,maxZ:g}).map(o=>o/255);h.push(...t)}}const y=new A;l.length>0&&y.setAttribute("position",new E(l,3)),d.length>0&&y.setAttribute("normal",new E(d,3)),h.length>0&&y.setAttribute("color",new E(h,3)),y.computeBoundingSphere();const z=new L({size:.01});return h.length>0?z.vertexColors=!0:z.color.setHex(16777215),new I(y,z)}genColorByCoord(f,x,c){return c<=0?[128,128,128]:c<5?[255,0,0]:c<10?[0,255,0]:[0,0,255]}genColorByZ({x:f,y:x,z:c,minZ:u,maxZ:i}){const l=i-u,d=Math.floor((c-u)/l*255),h=B[d];return[h[0],h[1],h[2]]}}export{S as PCDLoader};
@@ -1,4 +1,4 @@
1
- import*as c from"three";import{toolStyleConverter as _,PerspectiveShiftUtils as w,EPerspectiveView as g}from"@labelbee/lb-utils";import V from"../../_virtual/highlightWorker.js";import k from"../../_virtual/filterBoxWorker.js";import{isInPolygon as A}from"../../utils/tool/polygonTool.js";import L from"../../utils/uuid.js";import{PCDLoader as S}from"./PCDLoader.js";import{OrbitControls as I}from"./OrbitControls.js";import{PointCloudCache as N}from"./cache.js";import{getCuboidFromPointCloudBox as D}from"./matrix.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,lidar2image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./matrix.js";import"../../constant/tool.js";import"../../constant/annotation.js";import"../../utils/MathUtils.js";import"@turf/turf";import"../../utils/tool/CommonToolUtils.js";import"../../utils/tool/LineToolUtils.js";import"../../utils/tool/DrawUtils.js";import"../../constant/keyCode.js";import"../../locales/index.js";import"../../locales/constants.js";import"lodash";import"../../constant/style.js";import"../../utils/tool/CanvasUtils.js";import"../../utils/tool/ZoomUtils.js";var F=Object.defineProperty,R=Object.defineProperties,E=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,z=(u,t,e)=>t in u?F(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,C=(u,t)=>{for(var e in t||(t={}))W.call(t,e)&&z(u,e,t[e]);if(P)for(var e of P(t))U.call(t,e)&&z(u,e,t[e]);return u},b=(u,t)=>R(u,E(t)),v=(u,t,e)=>new Promise((r,n)=>{var s=o=>{try{i(e.next(o))}catch(h){n(h)}},a=o=>{try{i(e.throw(o))}catch(h){n(h)}},i=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);i((e=e.apply(u,t)).next())});const H=30;new V;class Z{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 h;const l=(h=i.id)!=null?h:L();this.removeObjectByName(l);const{center:m,width:d,height:f,depth:y,rotation:x}=i,p=new c.Group,M=new c.BoxGeometry(d,f,y),B=new c.MeshBasicMaterial({color:"blue"}),j=new c.Mesh(M,B),T=new c.BoxHelper(j,o),O=this.generateBoxArrow(i);p.add(T),p.add(O),p.position.set(m.x,m.y,m.z),p.rotation.set(0,0,x),p.name=l,this.scene.add(p)},this.overridePointShader=i=>{i.vertexShader=`
1
+ import*as c from"three";import{toolStyleConverter as V,PerspectiveShiftUtils as f,EPerspectiveView as g}from"@labelbee/lb-utils";import k from"../../_virtual/highlightWorker.js";import L from"../../_virtual/filterBoxWorker.js";import{isInPolygon as N}from"../../utils/tool/polygonTool.js";import I from"../../utils/uuid.js";import{PCDLoader as S}from"./PCDLoader.js";import{OrbitControls as D}from"./OrbitControls.js";import{PointCloudCache as E}from"./cache.js";import{getCuboidFromPointCloudBox as v}from"./matrix.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,lidar2image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./matrix.js";import"../../constant/tool.js";import"../../constant/annotation.js";import"../../utils/MathUtils.js";import"@turf/turf";import"../../utils/tool/CommonToolUtils.js";import"../../utils/tool/LineToolUtils.js";import"../../utils/tool/DrawUtils.js";import"../../constant/keyCode.js";import"../../locales/index.js";import"../../locales/constants.js";import"lodash";import"../../constant/style.js";import"../../utils/tool/CanvasUtils.js";import"../../utils/tool/ZoomUtils.js";var F=Object.defineProperty,R=Object.defineProperties,U=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable,B=(u,t,e)=>t in u?F(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,C=(u,t)=>{for(var e in t||(t={}))W.call(t,e)&&B(u,e,t[e]);if(z)for(var e of z(t))H.call(t,e)&&B(u,e,t[e]);return u},b=(u,t)=>R(u,U(t)),P=(u,t,e)=>new Promise((r,n)=>{var s=o=>{try{i(e.next(o))}catch(h){n(h)}},a=o=>{try{i(e.throw(o))}catch(h){n(h)}},i=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);i((e=e.apply(u,t)).next())});const Z=30,j=new k({type:"module"});class G{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 h;const l=(h=i.id)!=null?h:I();this.removeObjectByName(l);const{center:m,width:d,height:w,depth:x,rotation:y}=i,p=new c.Group,M=new c.BoxGeometry(d,w,x),O=new c.MeshBasicMaterial({color:"blue"}),T=new c.Mesh(M,O),A=new c.BoxHelper(T,o),_=this.generateBoxArrow(i);p.add(A),p.add(_),p.position.set(m.x,m.y,m.z),p.rotation.set(0,0,y),p.name=l,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 @@ import*as c from"three";import{toolStyleConverter as _,PerspectiveShiftUtils as
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)=>v(this,null,function*(){this.clearPointCloud();const h=yield this.cacheInstance.loadPCDFile(i);h.name=this.pointCloudObjectName,this.renderPointCloud(h,o)}),this.loadPCDFileByBox=(i,o,h)=>v(this,null,function*(){const l=d=>v(this,null,function*(){const{width:f=0,height:y=0,depth:x=0}=h!=null?h:{},p=yield this.filterPointsByBox(b(C({},o),{width:o.width+f,height:o.height+y,depth:o.depth+x}),d);if(!p){console.error("filter Error");return}this.clearPointCloud();const M=new c.Points(p.geometry,d.material);M.name=this.pointCloudObjectName,this.scene.add(M),this.render()}),m=yield this.cacheInstance.loadPCDFile(i);l(m)}),this.generateRange=i=>{const o=this.createRange(i);this.scene.add(o)},this.generateBoxArrow=({width:i})=>{const o=new c.Vector3(1,0,0),h=new c.Vector3(i/2,0,0),l=2,m=16776960,d=new c.ArrowHelper(o,h,l,m);return d.visible=this.showDirection,d},this.generateBoxTrackID=i=>{if(!i.trackID)return;const o=new c.Texture(this.getTextCanvas(i.trackID.toString()));o.needsUpdate=!0;const h=new c.SpriteMaterial({map:o,depthWrite:!1}),l=new c.Sprite(h);return l.scale.set(5,5,5),l.position.set(-i.width/2,0,i.depth/2+.5),l},this.applyZAxisPoints=i=>{this.zAxisLimit=i,this.filterZAxisPoints(),this.render()},this.updatePointSize=i=>{const o=this.scene.getObjectByName(this.pointCloudObjectName);if(!o)return;const h=o.material.size;i?o.material.size=Math.min(h*1.2,10):o.material.size=Math.max(h/1.2,1),this.render()},this.container=t,this.renderer=new c.WebGLRenderer({antialias:!0}),this.backgroundColor=s,this.config=a,r&&n?(this.isOrthographicCamera=!0,this.camera=new c.OrthographicCamera(n.left,n.right,n.top,n.bottom,n.near,n.far)):this.camera=new c.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new c.Scene,this.controls=new I(this.camera,this.renderer.domElement),this.pcdLoader=new S,this.axesHelper=new c.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=N.getInstance()}get DEFAULT_INIT_CAMERA_POSITION(){return new c.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 c.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 c.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=_.getColorFromConfig({attribute:t.attribute},b(C({},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,h=e.y-n/2-s,l=100,m=-100,d=500/l;return{left:a,right:i,top:o,bottom:h,near:l,far:m,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 c.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 c.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}=D(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(h=>{const l=new k;l.postMessage(o),l.onmessage=m=>{const{color:d,position:f,num:y}=m.data,x=new c.BufferGeometry;x.setAttribute("position",new c.Float32BufferAttribute(f,3)),x.setAttribute("color",new c.Float32BufferAttribute(d,3)),x.computeBoundingSphere(),l.terminate(),h({geometry:x,num:y})}})}return Promise.resolve(void 0)}getCameraVector(t,e,r,n=g.Front,s=H){let a=w.frontViewMatrix4(s);switch(n){case g.Front:break;case g.Back:a=w.backViewMatrix4(s);break;case g.Left:a=w.leftViewMatrix4(s);break;case g.Right:a=w.rightViewMatrix4(s);break;case g.Top:a=w.topViewMatrix4(s);break;case g.LFT:a=w.leftFrontTopViewMatrix4(s,r);break;case g.RBT:a=w.rightBackTopViewMatrix4(s,r);break}const i=this.createThreeMatrix4(a),o=new c.Matrix4().makeTranslation(-t.x,-t.y,-t.z),h=new c.Matrix4().makeTranslation(t.x,t.y,t.z),l=new c.Matrix4().makeRotationZ(e);return new c.Vector3(t.x,t.y,t.z).clone().applyMatrix4(i).applyMatrix4(o).applyMatrix4(l).applyMatrix4(h)}createRange(t){this.removeObjectByName(this.rangeObjectName);const r=new c.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),n=new c.BufferGeometry().setFromPoints(r),s=new c.LineBasicMaterial({color:16711680}),a=new c.Line(n,s);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.material.size=1,t.name=this.pointCloudObjectName;const r=new c.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 h=0;h<o.length;h+=3){const l=o[h],m=o[h+1],d=o[h+2];A({x:l,y:m},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 c.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 c.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},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},m={x:e-a/2,y:r+s/2,z:n-i/2};return[o,h,l,m]}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},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},m={x:e-a/2,y:r-s/2,z:n+i/2};return[o,h,l,m]}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},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},m={x:e-a/2,y:r+s/2,z:n+i/2};return[o,h,l,m]}getModelTransformationMatrix(t){const{center:{x:e,y:r,z:n},rotation:s}=t,a=new c.Matrix4().makeTranslation(-e,-r,-n),i=new c.Matrix4().makeTranslation(e,r,n),o=new c.Matrix4().makeRotationZ(s);return new c.Matrix4().multiply(i).multiply(o).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,g.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,g.Back)}boxParams2ViewPolygon(t,e){switch(e){case g.Left:return this.getPolygonSidePoints(t);case g.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 c.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),i=new c.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=i;const o=r.map(m=>new c.Vector3(m.x,m.y,m.z)).map(m=>m.applyMatrix4(this.sideMatrix)),h=this.containerWidth/n,l=this.containerHeight/s;return{polygon2d:o,zoom:Math.min(h,l)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:r}=t,s=this.getPolygonTopPoints(t).map(o=>new c.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 c.Matrix4().makeRotationZ(n.rotation),a=new c.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=b(C({},i),{width:i.width+e,height:i.height,depth:i.depth+r}),{newBoxParams:i}}getNewBoxByBackUpdate(t,e,r,n){const s=new c.Matrix4().makeRotationZ(n.rotation),a=new c.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=b(C({},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 c.Vector3(p.x,p.y,p.z)).map(p=>p.applyMatrix4(a)),[o,h,l,m]=i,d=Math.max(Math.abs(o.x-l.x),Math.abs(o.x-h.x)),y=h.add(m).applyMatrix3(new c.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new c.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new c.Vector3(n.center.x,n.center.y,n.center.z));return{newBoxParams:b(C({},n),{center:{x:n.center.x-y.x,y:n.center.y-y.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 c.Float32BufferAttribute(s,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}export{Z as PointCloud};
11
+ #include <clipping_planes_fragment>`)},this.loadPCDFile=(i,o)=>P(this,null,function*(){this.clearPointCloud();const h=yield this.cacheInstance.loadPCDFile(i);h.name=this.pointCloudObjectName,this.renderPointCloud(h,o)}),this.loadPCDFileByBox=(i,o,h)=>P(this,null,function*(){const l=d=>P(this,null,function*(){const{width:w=0,height:x=0,depth:y=0}=h!=null?h:{},p=yield this.filterPointsByBox(b(C({},o),{width:o.width+w,height:o.height+x,depth:o.depth+y}),d);if(!p){console.error("filter Error");return}this.clearPointCloud();const M=new c.Points(p.geometry,d.material);M.name=this.pointCloudObjectName,this.scene.add(M),this.render()}),m=yield this.cacheInstance.loadPCDFile(i);l(m)}),this.generateRange=i=>{const o=this.createRange(i);this.scene.add(o)},this.generateBoxArrow=({width:i})=>{const o=new c.Vector3(1,0,0),h=new c.Vector3(i/2,0,0),l=2,m=16776960,d=new c.ArrowHelper(o,h,l,m);return d.visible=this.showDirection,d},this.generateBoxTrackID=i=>{if(!i.trackID)return;const o=new c.Texture(this.getTextCanvas(i.trackID.toString()));o.needsUpdate=!0;const h=new c.SpriteMaterial({map:o,depthWrite:!1}),l=new c.Sprite(h);return l.scale.set(5,5,5),l.position.set(-i.width/2,0,i.depth/2+.5),l},this.applyZAxisPoints=i=>{this.zAxisLimit=i,this.filterZAxisPoints(),this.render()},this.updatePointSize=i=>{const o=this.scene.getObjectByName(this.pointCloudObjectName);if(!o)return;const h=o.material.size;i?o.material.size=Math.min(h*1.2,10):o.material.size=Math.max(h/1.2,1),this.render()},this.container=t,this.renderer=new c.WebGLRenderer({antialias:!0}),this.backgroundColor=s,this.config=a,r&&n?(this.isOrthographicCamera=!0,this.camera=new c.OrthographicCamera(n.left,n.right,n.top,n.bottom,n.near,n.far)):this.camera=new c.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new c.Scene,this.controls=new D(this.camera,this.renderer.domElement),this.pcdLoader=new S,this.axesHelper=new c.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=E.getInstance()}get DEFAULT_INIT_CAMERA_POSITION(){return new c.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 c.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 c.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]=V.getColorFromConfig({attribute:r.attribute},b(C({},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,h=e.y-n/2-s,l=100,m=-100,d=500/l;return{left:a,right:i,top:o,bottom:h,near:l,far:m,zoom:d}}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 c.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 c.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}=v(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(h=>{const l=new L;l.postMessage(o),l.onmessage=m=>{const{color:d,position:w,num:x}=m.data,y=new c.BufferGeometry;y.setAttribute("position",new c.Float32BufferAttribute(w,3)),y.setAttribute("color",new c.Float32BufferAttribute(d,3)),y.computeBoundingSphere(),l.terminate(),h({geometry:y,num:x})}})}return Promise.resolve(void 0)}getCameraVector(t,e,r,n=g.Front,s=Z){let a=f.frontViewMatrix4(s);switch(n){case g.Front:break;case g.Back:a=f.backViewMatrix4(s);break;case g.Left:a=f.leftViewMatrix4(s);break;case g.Right:a=f.rightViewMatrix4(s);break;case g.Top:a=f.topViewMatrix4(s);break;case g.LFT:a=f.leftFrontTopViewMatrix4(s,r);break;case g.RBT:a=f.rightBackTopViewMatrix4(s,r);break}const i=this.createThreeMatrix4(a),o=new c.Matrix4().makeTranslation(-t.x,-t.y,-t.z),h=new c.Matrix4().makeTranslation(t.x,t.y,t.z),l=new c.Matrix4().makeRotationZ(e);return new c.Vector3(t.x,t.y,t.z).clone().applyMatrix4(i).applyMatrix4(o).applyMatrix4(l).applyMatrix4(h)}createRange(t){this.removeObjectByName(this.rangeObjectName);const r=new c.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),n=new c.BufferGeometry().setFromPoints(r),s=new c.LineBasicMaterial({color:16711680}),a=new c.Line(n,s);return a.name=this.rangeObjectName,a}renderPointCloud(t,e){t.material.size=1,t.name=this.pointCloudObjectName;const r=new c.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){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(!!e)return new Promise(r=>{if(window.Worker){const s=(t?[...t]:[]).map(o=>v(o)),a=this.getAllAttributeColor(s),i={cuboidList:s,position:e.geometry.attributes.position.array,color:e.geometry.attributes.color.array,colorList:a};j.postMessage(i),j.onmessage=o=>{const{color:h}=o.data,l=new c.BufferAttribute(h,3);l.needsUpdate=!0,e.geometry.setAttribute("color",l),r(h),this.render()}}})}updateColor(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(e){const r=new c.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 h=0;h<o.length;h+=3){const l=o[h],m=o[h+1],d=o[h+2];N({x:l,y:m},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 c.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 c.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},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},m={x:e-a/2,y:r+s/2,z:n-i/2};return[o,h,l,m]}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},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},m={x:e-a/2,y:r-s/2,z:n+i/2};return[o,h,l,m]}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},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},m={x:e-a/2,y:r+s/2,z:n+i/2};return[o,h,l,m]}getModelTransformationMatrix(t){const{center:{x:e,y:r,z:n},rotation:s}=t,a=new c.Matrix4().makeTranslation(-e,-r,-n),i=new c.Matrix4().makeTranslation(e,r,n),o=new c.Matrix4().makeRotationZ(s);return new c.Matrix4().multiply(i).multiply(o).multiply(a)}getBoxSidePolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,g.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,g.Back)}boxParams2ViewPolygon(t,e){switch(e){case g.Left:return this.getPolygonSidePoints(t);case g.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 c.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),i=new c.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(a).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=i;const o=r.map(m=>new c.Vector3(m.x,m.y,m.z)).map(m=>m.applyMatrix4(this.sideMatrix)),h=this.containerWidth/n,l=this.containerHeight/s;return{polygon2d:o,zoom:Math.min(h,l)/2}}getBoxTopPolygon2DCoordinate(t){const{width:e,height:r}=t,s=this.getPolygonTopPoints(t).map(o=>new c.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 c.Matrix4().makeRotationZ(n.rotation),a=new c.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=b(C({},i),{width:i.width+e,height:i.height,depth:i.depth+r}),{newBoxParams:i}}getNewBoxByBackUpdate(t,e,r,n){const s=new c.Matrix4().makeRotationZ(n.rotation),a=new c.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=b(C({},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 c.Vector3(p.x,p.y,p.z)).map(p=>p.applyMatrix4(a)),[o,h,l,m]=i,d=Math.max(Math.abs(o.x-l.x),Math.abs(o.x-h.x)),x=h.add(m).applyMatrix3(new c.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new c.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new c.Vector3(n.center.x,n.center.y,n.center.z));return{newBoxParams:b(C({},n),{center:{x:n.center.x-x.x,y:n.center.y-x.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 c.Float32BufferAttribute(s,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}export{G as PointCloud};
@@ -1 +1 @@
1
- import*as x from"three";import{MatrixUtils as M,PointCloudUtils as d}from"@labelbee/lb-utils";import w from"../../utils/uuid.js";function u(r){return new x.Matrix4().set(...r)}function m(r,t,e){const i=M.transferMatrix34FromKitti2Three(r),n=M.transferMatrix33FromKitti2Three(t),a=M.transferMatrix34FromKitti2Three(e),s=u(i),c=u(n),l=u(a);return{composeMatrix4:l.clone().premultiply(c).premultiply(s),PM:s,RM:c,TM:l}}function y(r,t,e){var i;const n=new x.Vector3(r.x,r.y,(i=r==null?void 0:r.z)!=null?i:1),a=new x.Matrix4().makeRotationZ(e),s=new x.Matrix4().makeTranslation(t.x,t.y,t.z),c=new x.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return n.clone().applyMatrix4(c).applyMatrix4(a).applyMatrix4(s)}function f(r,t){const i=new x.Vector4(r.x,r.y,r.z).applyMatrix4(t);if(i.z<0)return;const n=1/i.z,a=new x.Matrix4().set(n,0,0,0,0,n,0,0,0,0,n,0,0,0,0,1);return i.applyMatrix4(a)}function z(r){const{center:t,width:e,height:i,depth:n,rotation:a}=r,s=[{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 p=y(o,t,a);return{x:p.x,y:p.y}}),c=t.z+n/2,l=t.z-n/2;return{polygonPointList:s,zMax:c,zMin:l}}function T(r,t){const e=d.getAllViewData(r),{P:i,R:n,T:a}=t,{composeMatrix4:s}=m(i,n,a);return e.map(l=>({type:l.type,pointList:l.pointList.map(o=>y(o,r.center,r.rotation)).map(o=>f(o,s)).map(o=>{if(!!o)return{id:w(),x:o==null?void 0:o.x,y:o==null?void 0:o.y}}).filter(o=>o!==void 0)})).filter(l=>l.pointList.length!==0)}export{u as createThreeMatrix4,z as getCuboidFromPointCloudBox,f as lidar2image,T as pointCloudLidar2image,y as rotatePoint,m as transferKitti2Matrix};
1
+ import*as p from"three";import{MatrixUtils as x,PointCloudUtils as w}from"@labelbee/lb-utils";import _ from"../../utils/uuid.js";var g=Object.defineProperty,h=Object.defineProperties,z=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,M=(r,t,e)=>t in r?g(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,P=(r,t)=>{for(var e in t||(t={}))O.call(t,e)&&M(r,e,t[e]);if(m)for(var e of m(t))T.call(t,e)&&M(r,e,t[e]);return r},V=(r,t)=>h(r,z(t));function u(r){return new p.Matrix4().set(...r)}function d(r,t,e){const o=x.transferMatrix34FromKitti2Three(r),n=x.transferMatrix33FromKitti2Three(t),a=x.transferMatrix34FromKitti2Three(e),l=u(o),c=u(n),s=u(a);return{composeMatrix4:s.clone().premultiply(c).premultiply(l),PM:l,RM:c,TM:s}}function y(r,t,e){var o;const n=new p.Vector3(r.x,r.y,(o=r==null?void 0:r.z)!=null?o:1),a=new p.Matrix4().makeRotationZ(e),l=new p.Matrix4().makeTranslation(t.x,t.y,t.z),c=new p.Matrix4().makeTranslation(-t.x,-t.y,-t.z);return n.clone().applyMatrix4(c).applyMatrix4(a).applyMatrix4(l)}function v(r,t){const o=new p.Vector4(r.x,r.y,r.z).applyMatrix4(t);if(o.z<0)return;const n=1/o.z,a=new p.Matrix4().set(n,0,0,0,0,n,0,0,0,0,n,0,0,0,0,1);return o.applyMatrix4(a)}function R(r){const{center:t,width:e,height:o,depth:n,rotation:a}=r,l=[{x:t.x+e/2,y:t.y-o/2},{x:t.x+e/2,y:t.y+o/2},{x:t.x-e/2,y:t.y+o/2},{x:t.x-e/2,y:t.y-o/2}].map(i=>{const f=y(i,t,a);return{x:f.x,y:f.y}}),c=t.z+n/2,s=t.z-n/2;return V(P({},r),{polygonPointList:l,zMax:c,zMin:s})}function b(r,t){const e=w.getAllViewData(r),{P:o,R:n,T:a}=t,{composeMatrix4:l}=d(o,n,a);return e.map(s=>({type:s.type,pointList:s.pointList.map(i=>y(i,r.center,r.rotation)).map(i=>v(i,l)).map(i=>{if(!!i)return{id:_(),x:i==null?void 0:i.x,y:i==null?void 0:i.y}}).filter(i=>i!==void 0)})).filter(s=>s.pointList.length!==0)}export{u as createThreeMatrix4,R as getCuboidFromPointCloudBox,v as lidar2image,b as pointCloudLidar2image,y as rotatePoint,d as transferKitti2Matrix};
@@ -1 +1 @@
1
- import{toolStyleConverter as C}from"@labelbee/lb-utils";import{ESortDirection as _}from"../../constant/annotation.js";import{EPolygonPattern as y}from"../../constant/tool.js";import f from"../../utils/tool/AxisUtils.js";import P from"../../utils/tool/CommonToolUtils.js";import p from"../../utils/tool/DrawUtils.js";import v from"../../utils/tool/PolygonUtils.js";import{polygonConfig as L}from"../../constant/defaultConfig.js";import I from"./polygonOperation.js";var b=Object.defineProperty,w=Object.defineProperties,S=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,A=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,m=(n,t,e)=>t in n?b(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,h=(n,t)=>{for(var e in t||(t={}))A.call(t,e)&&m(n,e,t[e]);if(D)for(var e of D(t))x.call(t,e)&&m(n,e,t[e]);return n},u=(n,t)=>w(n,S(t));class O extends I{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(g=>g.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),g=f.changePointListByZoom(s.pointList,this.zoom,this.currentPos);p.drawSelectedPolygonWithFillAndLine(this.canvas,g,{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(g)}};var e,i,o,r,l,a;this.showDirectionLine=(e=t.showDirectionLine)!=null?e:!0,this.forbidAddNew=(i=t.forbidAddNew)!=null?i:!1,this.pointCloudConfig=(o=P.jsonParser(t.config))!=null?o:{},this.checkMode=(r=t.checkMode)!=null?r:!1,this.forbidAddNew===!1&&t.checkMode===!0&&(this.forbidAddNew=!0),this.config=u(h({},L),{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=P.jsonParser(t);this.pointCloudConfig=i,this.config=u(h({},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 v.getPolygonByIDs(this.polygonList,this.selectedIDs)}getLineColor(){return"rgba(0, 255, 255, 0.5)"}getPointCloudLineColor(t=""){return C.getColorFromConfig({attribute:t},u(h({},this.pointCloudConfig),{attributeConfigurable:!0}),{}).stroke}renderStaticPolygon(){var t;this.isHidden===!1&&((t=this.polygonList)==null||t.forEach(e=>{var i,o,r;if([...this.selectedIDs,this.editPolygonID].includes(e.id))return;const{attribute:l}=e,a=this.getPointCloudLineColor(l),s=f.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);p.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:(r=this.config)==null?void 0:r.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||p.drawLine(this.canvas,t[0],t[1],{color:"white",thickness:3,lineDash:[6]})}get currentPolygonListByPattern(){return this.polygonList.filter(t=>this.pattern===y.Rect?t.isRect===!0:this.pattern===y.Normal?t.isRect!==!0:!0)}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),r=this.currentPolygonListByPattern.map(l=>u(h({},l),{pointList:f.changePointListByZoom(l.pointList,this.zoom)}));return v.getHoverPolygonID(i,r,10,(e=this.config)==null?void 0:e.lineType)}switchToNextPolygon(t=_.ascend){if(this.drawingPointList.length>0)return;const e=this.currentPolygonListByPattern.map(o=>{var r,l,a,s;return u(h({},o),{x:(l=(r=o.pointList[0])==null?void 0:r.x)!=null?l:0,y:(s=(a=o.pointList[0])==null?void 0:a.y)!=null?s:0})}),i=P.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)}}export{O as default};
1
+ import{INVALID_COLOR as C,toolStyleConverter as _}from"@labelbee/lb-utils";import{ESortDirection as L}from"../../constant/annotation.js";import{EPolygonPattern as y}from"../../constant/tool.js";import f from"../../utils/tool/AxisUtils.js";import P from"../../utils/tool/CommonToolUtils.js";import p from"../../utils/tool/DrawUtils.js";import v from"../../utils/tool/PolygonUtils.js";import{polygonConfig as I}from"../../constant/defaultConfig.js";import b from"./polygonOperation.js";var w=Object.defineProperty,S=Object.defineProperties,A=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,m=(s,t,e)=>t in s?w(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,h=(s,t)=>{for(var e in t||(t={}))x.call(t,e)&&m(s,e,t[e]);if(D)for(var e of D(t))O.call(t,e)&&m(s,e,t[e]);return s},u=(s,t)=>S(s,A(t));class j extends b{constructor(t){super(t);this.selectedIDs=[],this.rightMouseUp=a=>{var d;if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}a.ctrlKey&&this.hoverID?this.emit("addSelectedIDs",this.hoverID):this.emit("setSelectedIDs",this.hoverID);const c=(d=this.polygonList.find(g=>g.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),g=f.changePointListByZoom(a.pointList,this.zoom,this.currentPos);p.drawSelectedPolygonWithFillAndLine(this.canvas,g,{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(g)}};var e,i,o,n,r,l;this.showDirectionLine=(e=t.showDirectionLine)!=null?e:!0,this.forbidAddNew=(i=t.forbidAddNew)!=null?i:!1,this.pointCloudConfig=(o=P.jsonParser(t.config))!=null?o:{},this.checkMode=(n=t.checkMode)!=null?n:!1,this.forbidAddNew===!1&&t.checkMode===!0&&(this.forbidAddNew=!0),this.config=u(h({},I),{textConfigurable:!1,attributeConfigurable:!0,attributeList:(l=(r=this.pointCloudConfig)==null?void 0:r.attributeList)!=null?l:[]})}get getSelectedIDs(){return this.selectedIDs}setConfig(t){var e;const i=P.jsonParser(t);this.pointCloudConfig=i,this.config=u(h({},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 v.getPolygonByIDs(this.polygonList,this.selectedIDs)}getLineColor(){return"rgba(0, 255, 255, 0.5)"}getPointCloudLineColor(t){return t.valid===!1?C:_.getColorFromConfig({attribute:t.attribute},u(h({},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 r=this.getPointCloudLineColor(e),l=f.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);p.drawPolygonWithFillAndLine(this.canvas,l,{fillColor:"transparent",strokeColor:r,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(l)}))}renderSelectedPolygon(){var t;(t=this.selectedPolygons)==null||t.forEach(e=>{this.renderSingleSelectedPolygon(e)})}renderRectPolygonDirection(t){t.length<2||p.drawLine(this.canvas,t[0],t[1],{color:"white",thickness:3,lineDash:[6]})}get currentPolygonListByPattern(){return this.polygonList.filter(t=>this.pattern===y.Rect?t.isRect===!0:this.pattern===y.Normal?t.isRect!==!0:!0)}getHoverID(t){var e;const i=this.getCoordinateUnderZoom(t),n=this.currentPolygonListByPattern.map(r=>u(h({},r),{pointList:f.changePointListByZoom(r.pointList,this.zoom)}));return v.getHoverPolygonID(i,n,10,(e=this.config)==null?void 0:e.lineType)}switchToNextPolygon(t=L.ascend){if(this.drawingPointList.length>0)return;const e=this.currentPolygonListByPattern.map(o=>{var n,r,l,a;return u(h({},o),{x:(r=(n=o.pointList[0])==null?void 0:n.x)!=null?r:0,y:(a=(l=o.pointList[0])==null?void 0:l.y)!=null?a:0})}),i=P.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)}}export{j as default};
@@ -1 +1 @@
1
- import{i18n as _}from"@labelbee/lb-utils";import D from"../../utils/MathUtils.js";import z from"../../utils/tool/RectUtils.js";import{ERotateDirection as N,EDragStatus as x,ESortDirection as E,EDragTarget as b,TEXT_ATTRIBUTE_OFFSET as U,DEFAULT_TEXT_OFFSET as k}from"../../constant/annotation.js";import p from"../../constant/keyCode.js";import{EPolygonPattern as w,edgeAdsorptionScope as R,ELineTypes as H,EToolName as O}from"../../constant/tool.js";import C from"../../locales/index.js";import{EMessage as S}from"../../locales/constants.js";import W from"../../utils/ActionsHistory.js";import v from"../../utils/tool/AttributeUtils.js";import c from"../../utils/tool/AxisUtils.js";import B from"../../utils/tool/CanvasUtils.js";import u from"../../utils/tool/CommonToolUtils.js";import P from"../../utils/tool/DrawUtils.js";import y from"../../utils/tool/PolygonUtils.js";import A from"../../utils/tool/StyleUtils.js";import M from"../../utils/uuid.js";import{BasicToolOperation as K}from"./basicToolOperation.js";import $ from"./textAttributeClass.js";var V=Object.defineProperty,X=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable,F=(L,t,e)=>t in L?V(L,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):L[t]=e,f=(L,t)=>{for(var e in t||(t={}))q.call(t,e)&&F(L,e,t[e]);if(Z)for(var e of Z(t))G.call(t,e)&&F(L,e,t[e]);return L},m=(L,t)=>X(L,Y(t));const j=164;class J extends K{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(v.textChange(e,this.selectedID,this.polygonList)),this.emit("selectedChange"),this.render())},this.config=u.jsonParser(t.config),this.drawingPointList=[],this.polygonList=[],this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.drawingHistory=new W,this.isCtrl=!1,this.isAlt=!1,this.isCombined=!1,this.pattern=w.Normal,this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this)}eventBinding(){super.eventBinding(),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseup",this.dragMouseUp),this.dblClickListener.addEvent(this.onMouseUp,this.onLeftDblClick,this.onRightDblClick,this.isAllowDouble)}eventUnbinding(){super.eventUnbinding(),this.container.removeEventListener("mouseup",this.dragMouseUp)}destroy(){super.destroy(),this._textAttributInstance&&this._textAttributInstance.clearTextAttribute()}get selectedPolygon(){return y.getPolygonByID(this.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=>m(f({},t),{pointList:c.changePointListByZoom(t.pointList,this.zoom)}))}get selectedText(){var t;return(t=this.selectedPolygon)==null?void 0:t.textAttribute}get dataList(){return this.polygonList}setPattern(t,e=!1){var i;((i=this.drawingPointList)==null?void 0:i.length)>0&&e===!0||(this.pattern=t)}get currentShowList(){let t=[];const[e,i]=u.getRenderResultList(this.polygonList,u.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=u.getRenderResultList(this.polygonList,u.getSourceID(this.basicResult),[]);return t}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?f(f({},i),t):i)}rotatePolygon(t=1,e=N.Clockwise,i=this.selectedID){if(!i)return;const s=y.getPolygonByID(this.polygonList,i);if(!s)return;const o=y.updatePolygonByRotate(e,t,s==null?void 0:s.pointList);this.setPolygonList(this.setPolygonDataByID({pointList:o},i)),this.render()}addPointInDrawing(t){if(!this.imgInfo||this.forbidAddNewPolygonFuc&&this.forbidAddNewPolygonFuc(t))return;const{upperLimitPointNum:e,edgeAdsorption:i}=this.config;if(e&&this.drawingPointList.length>=e){this.emit("messageInfo",`${C.getMessagesByLocale(S.UpperLimitErrorNotice,this.lang)}${e}`);return}this.deleteSelectedID();const s=this.getCoordinateUnderZoom(t),o=c.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(c.returnClosePointIndex(o,c.changePointListByZoom(this.drawingPointList,this.zoom))===0){this.addDrawingPointToPolygonList();return}const{dropFoot:n}=y.getClosestPoint(o,this.polygonListUnderZoom,this.config.lineType,R),l=c.changePointByZoom(n&&t.altKey===!1&&i?n:o,1/this.zoom);if(this.pattern===w.Rect&&this.drawingPointList.length===2){const h=D.getRectangleByRightAngle(l,this.drawingPointList);if(this.drawingPointList=h,this.config.drawOutsideTarget===!1&&this.imgInfo&&this.isPolygonOutSide(this.drawingPointList)){this.emit("messageInfo",`${C.getMessagesByLocale(S.ForbiddenCreationOutsideBoundary,this.lang)}`),this.drawingPointList=[];return}this.addDrawingPointToPolygonList(!0);return}this.drawingPointList.push(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=x.Wait,this.hoverEdgeIndex=-1,this.hoverPointIndex=-1,this.hoverID=""}clearActiveStatus(){this.clearPolygonDrag(),this.deleteSelectedID()}clearDrawingStatus(){this.drawingPointList=[]}setPolygonList(t){const e=this.polygonList.length;this.polygonList=t,e!==t.length&&this.emit("updatePageNumber")}setSelectedID(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render(),this.emit("selectedChange")}setDefaultAttribute(t=""){const e=this.defaultAttribute;if(this.defaultAttribute=t,e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedID:i}=this;if(i&&(this.selectedPolygon&&(this.selectedPolygon.attribute=t),this.history.pushHistory(this.polygonList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}setPolygonValidAndRender(t){if(!t)return;const e=this.polygonList.map(i=>{var s;if(i.id===t){const o=(s=i==null?void 0:i.valid)!=null?s:!0;return m(f({},i),{valid:!o})}return i});this.setPolygonList(e),this.history.pushHistory(this.polygonList),this.render(),this.emit("updateResult")}addDrawingPointToPolygonList(t){let{lowerLimitPointNum:e=3}=this.config;e<3&&(e=3);let i;if(this.drawingPointList.length<e){this.drawingPointList=[],this.editPolygonID="";return}const s=u.getSourceID(this.basicResult),o=[...this.polygonList];if(this.editPolygonID){const r=o.find(n=>n.id===this.editPolygonID);if(!r)return;r.pointList=this.drawingPointList,this.editPolygonID=""}else{const r=M(8,62);let n={id:r,sourceID:s,valid:!this.isCtrl,textAttribute:"",pointList:this.drawingPointList,attribute:this.defaultAttribute,order:u.getMaxOrder(o.filter(l=>u.isSameSourceID(l.sourceID,s)))+1};if(this.config.textConfigurable){let l="";l=v.getTextAttribute(this.polygonList.filter(h=>u.isSameSourceID(h.sourceID,s)),this.config.textCheckType),n=m(f({},n),{textAttribute:l})}this.pattern===w.Rect&&t===!0&&(n=m(f({},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=>m(f({},o),{pointList:c.changePointListByZoom(o.pointList,this.zoom)}));return y.getHoverPolygonID(i,s,10,(e=this.config)==null?void 0:e.lineType)}getHoverEdgeIndex(t){var e;if(!this.selectedID)return-1;const i=this.selectedPolygon;if(!i)return-1;const s=this.getCoordinateUnderZoom(t),o=c.changePointListByZoom(i.pointList,this.zoom);return y.getHoverEdgeIndex(s,o,(e=this.config)==null?void 0:e.lineType)}getHoverPointIndex(t){if(!this.selectedID)return-1;const e=this.selectedPolygon;if(!e)return-1;const i=this.getCoordinateUnderZoom(t),s=c.changePointListByZoom(e.pointList,this.zoom);return c.returnClosePointIndex(i,s)}deletePolygon(t){var e;if(!t)return;const i=this.polygonList.find(s=>s.id===t);this.emit("deletedObject",{deletedObject:i,id:t}),this.setPolygonList(this.polygonList.filter(s=>s.id!==t)),this.history.pushHistory(this.polygonList),(e=this._textAttributInstance)==null||e.clearTextAttribute(),this.emit("selectedChange"),this.render()}deletePolygonPoint(t){if(!this.selectedID)return;const{selectedPolygon:e}=this;if(!e)return;let{lowerLimitPointNum:i}=this.config;if(i<3&&(i=3),e.pointList.length<=i){this.emit("messageInfo",`${C.getMessagesByLocale(S.LowerLimitErrorNotice,this.lang)}${i}`);return}e==null||e.pointList.splice(t,1),this.history.pushHistory(this.polygonList),this.render()}spaceKeydown(){var t,e,i;if(this.selectedID){if(((t=this.selectedPolygon)==null?void 0:t.isRect)===!0){this.emit("messageInfo",`${C.getMessagesByLocale(S.UnableToReannotation,this.lang)}`);return}this.editPolygonID=this.selectedID,this.drawingPointList=(i=(e=this.selectedPolygon)==null?void 0:e.pointList)!=null?i:[],this.drawingHistory.empty(),this.drawingHistory.initRecord(this.drawingPointList),this.hoverID="",this.deleteSelectedID(),this.render()}}onTabKeyDown(t){t.preventDefault();let e=E.ascend;t.shiftKey&&(e=E.descend),this.switchToNextPolygon(e)}switchToNextPolygon(t){if(this.drawingPointList.length>0)return;const[e,i]=u.getRenderResultList(this.polygonList,u.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let s=[...e];i&&(s=[...s,i]);const o=B.getViewPort(this.canvas,this.currentPos,this.zoom),r=s.map(l=>{var h,g,a,d;return m(f({},l),{x:(g=(h=l.pointList[0])==null?void 0:h.x)!=null?g:0,y:(d=(a=l.pointList[0])==null?void 0:a.y)!=null?d:0})}).filter(l=>B.inViewPort({x:l.x,y:l.y},o)),n=u.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(!u.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case p.Space:this.spaceKeydown();break;case p.Esc:this.drawingPointList=[],this.editPolygonID="";break;case p.F:this.selectedID&&this.setPolygonValidAndRender(this.selectedID);break;case p.Z:if(t.altKey){this.onCombinedExecute();return}this.setIsHidden(!this.isHidden),this.render();break;case p.Delete:this.deletePolygon(this.selectedID),this.render();break;case p.Ctrl:this.isCtrl=!0;break;case p.Alt:this.isAlt===!1&&(t.preventDefault(),this.isAlt=!0,this.render());break;case p.Tab:{this.onTabKeyDown(t);break}case p.X:t.altKey&&this.segment();break;default:{if(this.config.attributeConfigurable){const i=v.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case p.Ctrl:this.isCtrl=!1;break;case p.Alt:{const e=this.isAlt;this.isAlt=!1,e===!0&&this.render();break}}}rightMouseUp(t){if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}this.setSelectedID(this.hoverID);const{selectedPolygon:e}=this;e&&this.setDefaultAttribute(e.attribute)}onLeftDblClick(t){if(this.hoverEdgeIndex>-1){const e=this.getCoordinateUnderZoom(t),{selectedPolygon:i}=this;if(!i)return;if(i.isRect===!0){this.emit("messageInfo",`${C.getMessagesByLocale(S.ForbidAddNewPoint,this.lang)}`),this.clearPolygonDrag();return}const{dropFoot:s}=y.getClosestPoint(e,this.polygonListUnderZoom,this.config.lineType,R);if(!s)return;const{upperLimitPointNum:o}=this.config;if(o&&i.pointList.length>=o){this.emit("messageInfo",`${C.getMessagesByLocale(S.UpperLimitErrorNotice,this.lang)}${o}`),this.clearPolygonDrag();return}i==null||i.pointList.splice(this.hoverEdgeIndex+1,0,c.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=b.Plane;this.dragStatus=x.Start;const l=this.getHoverPointIndex(t),h=this.getHoverEdgeIndex(t);l>-1?(n=b.Point,r=[l]):h>-1&&this.hoverEdgeIndex>-1&&(n=b.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)!==H.Line)return;const e=y.getPolygonPointList(this.selectedID,this.currentShowList),i=this.currentShowList.filter(r=>r.id!==this.selectedID);if(i.length===0||e.length===0)return;const s=y.getWrapPolygonIndex(e,i);let o=[...this.polygonList];if(s===-1){const r=y.segmentPolygonByPolygon(e,i);if(!r)return;const n=r.shift();if(!n)return;let l="",h=!0;const g=u.getSourceID(this.basicResult);let a="";o=this.polygonList.map(d=>{var I,T;return d.id===this.selectedID?(l=d.attribute,h=(I=d==null?void 0:d.valid)!=null?I:!0,a=(T=d==null?void 0:d.textAttribute)!=null?T:"",m(f({},d),{pointList:n})):d}),r.length>0&&r.forEach((d,I)=>{o.push({sourceID:g,id:M(8,62),pointList:d,valid:h,order:u.getMaxOrder(this.currentShowList)+1+I,attribute:l,textAttribute:a})})}else o[s].pointList=y.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",_.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)!==H.Line){this.emit("messageInfo",_.t("CurveModeDoesNotSupportCutting"));return}const s=this.polygonList.find(h=>h.id===this.selectedID),o=this.currentShowList.find(h=>h.id===i);if(!o||!s)return;const r=y.combinePolygonWithPolygon(s,o);if(!r)return;const{newPolygon:n,unionList:l}=r;if(l.length===1&&n){const h=this.polygonList.filter(g=>!l.includes(g.id)).map(g=>g.id===this.selectedID?n:g);this.setPolygonList(h),this.history.pushHistory(h),this.render(),this.emit("messageInfo",_.t("CombineSuccess"))}else this.emit("messageInfo",_.t("CombiningFailedNotify"));this.isCombined=!1}isPolygonOutSide(t){if(this.dependToolName&&this.basicCanvas&&this.basicResult){let n=!1;switch(this.dependToolName){case O.Rect:{n=t.filter(l=>!z.isInRect(l,this.basicResult)).length>0;break}case O.Polygon:{n=y.isPointListOutSidePolygon(t,this.basicResult.pointList,this.config.lineType);break}}return n}if(!this.imgInfo)return!1;const{left:e,top:i,right:s,bottom:o}=D.calcViewportBoundaries(c.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===w.Rect&&(e==null?void 0:e.isRect)===!0&&n&&[b.Line].includes(r)){const a=D.getArrayIndex(n[0]-2,4),d=D.getArrayIndex(n[0]-1,4),I=[s[a],s[d]];h=D.getRectPerpendicularOffset(o,l,I),h={x:h.x/this.zoom,y:h.y/this.zoom}}switch(this.dragStatus=x.Move,r){case b.Plane:i=i.map((a,d)=>m(f({},a),{x:s[d].x+h.x,y:s[d].y+h.y}));break;case b.Point:case b.Line:i=i.map((a,d)=>n&&n.includes(d)?m(f({},a),{x:s[d].x+h.x,y:s[d].y+h.y}):a);break}if(this.pattern===w.Rect&&(e==null?void 0:e.isRect)===!0&&r===b.Point&&n&&(i=D.getPointListFromPointOffset(s,n[0],h)),this.config.drawOutsideTarget===!1&&this.imgInfo&&this.isPolygonOutSide(i))return;const g=this.polygonList.map(a=>{if(a.id===this.selectedID){const d=m(f({},a),{pointList:i});return a.isRect===!0&&this.pattern===w.Normal&&Object.assign(d,{isRect:!1}),d}return a});this.setPolygonList(g),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===x.Move){const{originPolygon:e}=this.dragInfo;this.dragInfo=void 0,this.dragStatus=x.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===x.Start&&(this.dragInfo=void 0,this.dragStatus=x.Wait)}exportData(){const{polygonList:t}=this;return[t,this.basicImgInfo]}getTextIconSvg(t=""){return v.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:j,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;v.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",v.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPolygonList(v.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=j,g=c.getOffsetCoordinate({x:n,y:l},this.currentPos,this.zoom),a=this.getColor(s),d=o?a==null?void 0:a.valid.stroke:a==null?void 0:a.invalid.stroke;this._textAttributInstance||(this._textAttributInstance=new $({width:h,container:this.container,icon:this.getTextIconSvg(s),color:d,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((t=this._textAttributInstance)==null?void 0:t.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${r}`,{left:g.x,top:g.y,color:d,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,g=this.getColor(h),a=A.getStrokeAndFill(g,e.valid),d=c.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);P.drawPolygonWithFillAndLine(this.canvas,d,{fillColor:a.fill,strokeColor:a.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 I=`${(r=v.getAttributeShowText(h,this.config.attributeList))!=null?r:""}`;((n=this.config)==null?void 0:n.isShowOrder)&&(e==null?void 0:e.order)>0&&(I=`${e.order} ${I}`),P.drawText(this.canvas,d[0],I,f({color:a.stroke},k));const T=d[d.length-1];P.drawText(this.canvas,{x:T.x+U.x,y:T.y+U.y},l,f({color:a.stroke},k))}))}renderSelectedPolygon(){var t,e,i;if(this.selectedID){const s=this.selectedPolygon;if(s){const o=this.getColor(s.attribute),r=A.getStrokeAndFill(o,s.valid,{isSelected:!0});P.drawSelectedPolygonWithFillAndLine(this.canvas,c.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=v.getAttributeShowText(s.attribute,this.config.attributeList))!=null?e:""}`;((i=this.config)==null?void 0:i.isShowOrder)&&(s==null?void 0:s.order)>0&&(n=`${s.order} ${n}`),P.drawText(this.canvas,c.changePointByZoom(s.pointList[0],this.zoom,this.currentPos),n,f({color:r.stroke},k)),this.renderTextAttribute()}}}renderHoverPolygon(){var t;if(this.hoverID&&this.hoverID!==this.editPolygonID){const{hoverPolygon:e}=this;if(e){let i="";const s=this.getColor(e.attribute);e.valid?i=s.validHover.fill:i=A.getStrokeAndFill(s,!1,{isHover:!0}).fill,P.drawPolygonWithFill(this.canvas,c.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=A.getStrokeAndFill(o,!this.isCtrl);if(((t=this.drawingPointList)==null?void 0:t.length)>0){let n=[...this.drawingPointList],l=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.pattern===w.Rect&&n.length===2)n=D.getRectangleByRightAngle(l,n);else{if(((e=this.config)==null?void 0:e.edgeAdsorption)&&this.isAlt===!1){const{dropFoot:h}=y.getClosestPoint(l,this.polygonList,(i=this.config)==null?void 0:i.lineType,R/this.zoom);h&&(l=h)}n.push(l)}P.drawSelectedPolygonWithFillAndLine(this.canvas,c.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=A.getStrokeAndFill(o,n.valid,{isSelected:!0}),h=n==null?void 0:n.pointList[this.hoverPointIndex];if(h){const{x:g,y:a}=c.changePointByZoom(h,this.zoom,this.currentPos);P.drawCircleWithFill(this.canvas,{x:g,y:a},5,{color:l.fill})}}if(this.hoverEdgeIndex>-1&&this.selectedID){const n=this.selectedPolygon;if(!n)return;const l=A.getStrokeAndFill(o,n.valid,{isSelected:!0});P.drawLineWithPointList(this.canvas,c.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;P.drawRectWithFill(this.canvas,{x:e+s,y:i-s*4-1,width:o,height:r},{color:"black"}),P.drawText(this.canvas,{x:e,y:i},_.t("ClickAnotherPolygon"),{textAlign:"center",color:"white",offsetX:o/2+s,offsetY:-(r/2+s/2)}),P.drawRect(this.canvas,{x:e-s,y:i-s,width:s*2,height:s*2},{lineDash:[6],color:"white"})}}undo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.undo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.undo();t&&(t.length!==this.polygonList.length&&this.deleteSelectedID(),this.setPolygonList(t),this.render())}redo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.redo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.redo();t&&(t.length!==this.polygonList.length&&this.deleteSelectedID(),this.setPolygonList(t),this.render())}deleteSelectedID(){this.setSelectedID("")}}export{J as default};
1
+ import{i18n as _}from"@labelbee/lb-utils";import D from"../../utils/MathUtils.js";import z from"../../utils/tool/RectUtils.js";import{ERotateDirection as N,EDragStatus as x,ESortDirection as U,EDragTarget as b,TEXT_ATTRIBUTE_OFFSET as E,DEFAULT_TEXT_OFFSET as k}from"../../constant/annotation.js";import p from"../../constant/keyCode.js";import{EPolygonPattern as w,edgeAdsorptionScope as R,ELineTypes as H,EToolName as O}from"../../constant/tool.js";import C from"../../locales/index.js";import{EMessage as S}from"../../locales/constants.js";import W from"../../utils/ActionsHistory.js";import v from"../../utils/tool/AttributeUtils.js";import c from"../../utils/tool/AxisUtils.js";import M from"../../utils/tool/CanvasUtils.js";import u from"../../utils/tool/CommonToolUtils.js";import P from"../../utils/tool/DrawUtils.js";import y from"../../utils/tool/PolygonUtils.js";import A from"../../utils/tool/StyleUtils.js";import B from"../../utils/uuid.js";import{BasicToolOperation as K}from"./basicToolOperation.js";import $ from"./textAttributeClass.js";var V=Object.defineProperty,X=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable,F=(L,t,e)=>t in L?V(L,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):L[t]=e,f=(L,t)=>{for(var e in t||(t={}))q.call(t,e)&&F(L,e,t[e]);if(Z)for(var e of Z(t))G.call(t,e)&&F(L,e,t[e]);return L},m=(L,t)=>X(L,Y(t));const j=164;class J extends K{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(v.textChange(e,this.selectedID,this.polygonList)),this.emit("selectedChange"),this.render())},this.config=u.jsonParser(t.config),this.drawingPointList=[],this.polygonList=[],this.hoverPointIndex=-1,this.hoverEdgeIndex=-1,this.drawingHistory=new W,this.isCtrl=!1,this.isAlt=!1,this.isCombined=!1,this.pattern=w.Normal,this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this)}eventBinding(){super.eventBinding(),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseup",this.dragMouseUp),this.dblClickListener.addEvent(this.onMouseUp,this.onLeftDblClick,this.onRightDblClick,this.isAllowDouble)}eventUnbinding(){super.eventUnbinding(),this.container.removeEventListener("mouseup",this.dragMouseUp)}destroy(){super.destroy(),this._textAttributInstance&&this._textAttributInstance.clearTextAttribute()}get selectedPolygon(){return y.getPolygonByID(this.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=>m(f({},t),{pointList:c.changePointListByZoom(t.pointList,this.zoom)}))}get selectedText(){var t;return(t=this.selectedPolygon)==null?void 0:t.textAttribute}get dataList(){return this.polygonList}setPattern(t,e=!1){var i;((i=this.drawingPointList)==null?void 0:i.length)>0&&e===!0||(this.pattern=t)}get currentShowList(){let t=[];const[e,i]=u.getRenderResultList(this.polygonList,u.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=e,this.isHidden&&(t=[]),i&&t.push(i),t}get currentPageResult(){const[t]=u.getRenderResultList(this.polygonList,u.getSourceID(this.basicResult),[]);return t}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?f(f({},i),t):i)}rotatePolygon(t=1,e=N.Clockwise,i=this.selectedID){if(!i)return;const s=y.getPolygonByID(this.polygonList,i);if(!s)return;const o=y.updatePolygonByRotate(e,t,s==null?void 0:s.pointList);this.setPolygonList(this.setPolygonDataByID({pointList:o},i)),this.render()}addPointInDrawing(t){if(!this.imgInfo||this.forbidAddNewPolygonFuc&&this.forbidAddNewPolygonFuc(t))return;const{upperLimitPointNum:e,edgeAdsorption:i}=this.config;if(e&&this.drawingPointList.length>=e){this.emit("messageInfo",`${C.getMessagesByLocale(S.UpperLimitErrorNotice,this.lang)}${e}`);return}this.deleteSelectedID();const s=this.getCoordinateUnderZoom(t),o=c.changeDrawOutsideTarget(s,{x:0,y:0},this.imgInfo,this.config.drawOutsideTarget,this.basicResult,this.zoom);if(c.returnClosePointIndex(o,c.changePointListByZoom(this.drawingPointList,this.zoom))===0){this.addDrawingPointToPolygonList();return}const{dropFoot:n}=y.getClosestPoint(o,this.polygonListUnderZoom,this.config.lineType,R),l=c.changePointByZoom(n&&t.altKey===!1&&i?n:o,1/this.zoom);if(this.pattern===w.Rect&&this.drawingPointList.length===2){const h=D.getRectangleByRightAngle(l,this.drawingPointList);if(this.drawingPointList=h,this.config.drawOutsideTarget===!1&&this.imgInfo&&this.isPolygonOutSide(this.drawingPointList)){this.emit("messageInfo",`${C.getMessagesByLocale(S.ForbiddenCreationOutsideBoundary,this.lang)}`),this.drawingPointList=[];return}this.addDrawingPointToPolygonList(!0);return}this.drawingPointList.push(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=x.Wait,this.hoverEdgeIndex=-1,this.hoverPointIndex=-1,this.hoverID=""}clearActiveStatus(){this.clearPolygonDrag(),this.deleteSelectedID()}clearDrawingStatus(){this.drawingPointList=[]}setPolygonList(t){const e=this.polygonList.length;this.polygonList=t,e!==t.length&&this.emit("updatePageNumber")}setSelectedID(t){var e,i;const s=this.selectedID;t!==s&&s&&((e=this._textAttributInstance)==null||e.changeSelected()),t||(i=this._textAttributInstance)==null||i.clearTextAttribute(),this.selectedID=t,this.render(),this.emit("selectedChange")}setDefaultAttribute(t=""){const e=this.defaultAttribute;if(this.defaultAttribute=t,e!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedID:i}=this;if(i&&(this.selectedPolygon&&(this.selectedPolygon.attribute=t),this.history.pushHistory(this.polygonList),this.render()),this._textAttributInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(t)){this._textAttributInstance.clearTextAttribute();return}this._textAttributInstance.updateIcon(this.getTextIconSvg(t))}}}setStyle(t){var e;super.setStyle(t),this._textAttributInstance&&this.config.attributeConfigurable===!1&&((e=this._textAttributInstance)==null||e.updateIcon(this.getTextIconSvg()))}setPolygonValidAndRender(t){if(!t)return;const e=this.polygonList.map(i=>{var s;if(i.id===t){const o=(s=i==null?void 0:i.valid)!=null?s:!0;return m(f({},i),{valid:!o})}return i});this.setPolygonList(e),this.history.pushHistory(this.polygonList),this.render(),this.emit("updateResult")}addDrawingPointToPolygonList(t){let{lowerLimitPointNum:e=3}=this.config;e<3&&(e=3);let i;if(this.drawingPointList.length<e){this.drawingPointList=[],this.editPolygonID="";return}const s=u.getSourceID(this.basicResult),o=[...this.polygonList];if(this.editPolygonID){const r=o.find(n=>n.id===this.editPolygonID);if(!r)return;r.pointList=this.drawingPointList,this.editPolygonID=""}else{const r=B(8,62);let n={id:r,sourceID:s,valid:!this.isCtrl,textAttribute:"",pointList:this.drawingPointList,attribute:this.defaultAttribute,order:u.getMaxOrder(o.filter(l=>u.isSameSourceID(l.sourceID,s)))+1};if(this.config.textConfigurable){let l="";l=v.getTextAttribute(this.polygonList.filter(h=>u.isSameSourceID(h.sourceID,s)),this.config.textCheckType),n=m(f({},n),{textAttribute:l})}this.pattern===w.Rect&&t===!0&&(n=m(f({},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=>m(f({},o),{pointList:c.changePointListByZoom(o.pointList,this.zoom)}));return y.getHoverPolygonID(i,s,10,(e=this.config)==null?void 0:e.lineType)}getHoverEdgeIndex(t){var e;if(!this.selectedID)return-1;const i=this.selectedPolygon;if(!i)return-1;const s=this.getCoordinateUnderZoom(t),o=c.changePointListByZoom(i.pointList,this.zoom);return y.getHoverEdgeIndex(s,o,(e=this.config)==null?void 0:e.lineType)}getHoverPointIndex(t){if(!this.selectedID)return-1;const e=this.selectedPolygon;if(!e)return-1;const i=this.getCoordinateUnderZoom(t),s=c.changePointListByZoom(e.pointList,this.zoom);return c.returnClosePointIndex(i,s)}deletePolygon(t){var e;if(!t)return;const i=this.polygonList.find(s=>s.id===t);this.emit("deletedObject",{deletedObject:i,id:t}),this.setPolygonList(this.polygonList.filter(s=>s.id!==t)),this.history.pushHistory(this.polygonList),(e=this._textAttributInstance)==null||e.clearTextAttribute(),this.emit("selectedChange"),this.render()}deletePolygonPoint(t){if(!this.selectedID)return;const{selectedPolygon:e}=this;if(!e)return;let{lowerLimitPointNum:i}=this.config;if(i<3&&(i=3),e.pointList.length<=i){this.emit("messageInfo",`${C.getMessagesByLocale(S.LowerLimitErrorNotice,this.lang)}${i}`);return}e==null||e.pointList.splice(t,1),this.history.pushHistory(this.polygonList),this.render()}spaceKeydown(){var t,e,i;if(this.selectedID){if(((t=this.selectedPolygon)==null?void 0:t.isRect)===!0){this.emit("messageInfo",`${C.getMessagesByLocale(S.UnableToReannotation,this.lang)}`);return}this.editPolygonID=this.selectedID,this.drawingPointList=(i=(e=this.selectedPolygon)==null?void 0:e.pointList)!=null?i:[],this.drawingHistory.empty(),this.drawingHistory.initRecord(this.drawingPointList),this.hoverID="",this.deleteSelectedID(),this.render()}}onTabKeyDown(t){t.preventDefault();let e=U.ascend;t.shiftKey&&(e=U.descend),this.switchToNextPolygon(e)}switchToNextPolygon(t){if(this.drawingPointList.length>0)return;const[e,i]=u.getRenderResultList(this.polygonList,u.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);let s=[...e];i&&(s=[...s,i]);const o=M.getViewPort(this.canvas,this.currentPos,this.zoom),r=s.map(l=>{var h,g,a,d;return m(f({},l),{x:(g=(h=l.pointList[0])==null?void 0:h.x)!=null?g:0,y:(d=(a=l.pointList[0])==null?void 0:a.y)!=null?d:0})}).filter(l=>M.inViewPort({x:l.x,y:l.y},o)),n=u.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(!u.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:e}=t;switch(e){case p.Space:this.spaceKeydown();break;case p.Esc:this.drawingPointList=[],this.editPolygonID="";break;case p.F:this.selectedID&&this.setPolygonValidAndRender(this.selectedID);break;case p.Z:if(t.altKey){this.onCombinedExecute();return}this.setIsHidden(!this.isHidden),this.render();break;case p.Delete:this.deletePolygon(this.selectedID),this.render();break;case p.Ctrl:this.isCtrl=!0;break;case p.Alt:this.isAlt===!1&&(t.preventDefault(),this.isAlt=!0,this.render());break;case p.Tab:{this.onTabKeyDown(t);break}case p.X:t.altKey&&this.segment();break;default:{if(this.config.attributeConfigurable){const i=v.getAttributeByKeycode(e,this.config.attributeList);i!==void 0&&this.setDefaultAttribute(i)}break}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case p.Ctrl:this.isCtrl=!1;break;case p.Alt:{const e=this.isAlt;this.isAlt=!1,e===!0&&this.render();break}}}rightMouseUp(t){if(this.drawingPointList.length>0){this.addDrawingPointToPolygonList();return}this.setSelectedID(this.hoverID);const{selectedPolygon:e}=this;e&&this.setDefaultAttribute(e.attribute)}onLeftDblClick(t){if(this.hoverEdgeIndex>-1){const e=this.getCoordinateUnderZoom(t),{selectedPolygon:i}=this;if(!i)return;if(i.isRect===!0){this.emit("messageInfo",`${C.getMessagesByLocale(S.ForbidAddNewPoint,this.lang)}`),this.clearPolygonDrag();return}const{dropFoot:s}=y.getClosestPoint(e,this.polygonListUnderZoom,this.config.lineType,R);if(!s)return;const{upperLimitPointNum:o}=this.config;if(o&&i.pointList.length>=o){this.emit("messageInfo",`${C.getMessagesByLocale(S.UpperLimitErrorNotice,this.lang)}${o}`),this.clearPolygonDrag();return}i==null||i.pointList.splice(this.hoverEdgeIndex+1,0,c.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=b.Plane;this.dragStatus=x.Start;const l=this.getHoverPointIndex(t),h=this.getHoverEdgeIndex(t);l>-1?(n=b.Point,r=[l]):h>-1&&this.hoverEdgeIndex>-1&&(n=b.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)!==H.Line)return;const e=y.getPolygonPointList(this.selectedID,this.currentShowList),i=this.currentShowList.filter(r=>r.id!==this.selectedID);if(i.length===0||e.length===0)return;const s=y.getWrapPolygonIndex(e,i);let o=[...this.polygonList];if(s===-1){const r=y.segmentPolygonByPolygon(e,i);if(!r)return;const n=r.shift();if(!n)return;let l="",h=!0;const g=u.getSourceID(this.basicResult);let a="";o=this.polygonList.map(d=>{var I,T;return d.id===this.selectedID?(l=d.attribute,h=(I=d==null?void 0:d.valid)!=null?I:!0,a=(T=d==null?void 0:d.textAttribute)!=null?T:"",m(f({},d),{pointList:n})):d}),r.length>0&&r.forEach((d,I)=>{o.push({sourceID:g,id:B(8,62),pointList:d,valid:h,order:u.getMaxOrder(this.currentShowList)+1+I,attribute:l,textAttribute:a})})}else o[s].pointList=y.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",_.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)!==H.Line){this.emit("messageInfo",_.t("CurveModeDoesNotSupportCutting"));return}const s=this.polygonList.find(h=>h.id===this.selectedID),o=this.currentShowList.find(h=>h.id===i);if(!o||!s)return;const r=y.combinePolygonWithPolygon(s,o);if(!r)return;const{newPolygon:n,unionList:l}=r;if(l.length===1&&n){const h=this.polygonList.filter(g=>!l.includes(g.id)).map(g=>g.id===this.selectedID?n:g);this.setPolygonList(h),this.history.pushHistory(h),this.render(),this.emit("messageInfo",_.t("CombineSuccess"))}else this.emit("messageInfo",_.t("CombiningFailedNotify"));this.isCombined=!1}isPolygonOutSide(t){if(this.dependToolName&&this.basicCanvas&&this.basicResult){let n=!1;switch(this.dependToolName){case O.Rect:{n=t.filter(l=>!z.isInRect(l,this.basicResult)).length>0;break}case O.Polygon:{n=y.isPointListOutSidePolygon(t,this.basicResult.pointList,this.config.lineType);break}}return n}if(!this.imgInfo)return!1;const{left:e,top:i,right:s,bottom:o}=D.calcViewportBoundaries(c.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===w.Rect&&(e==null?void 0:e.isRect)===!0&&n&&[b.Line].includes(r)){const a=D.getArrayIndex(n[0]-2,4),d=D.getArrayIndex(n[0]-1,4),I=[s[a],s[d]];h=D.getRectPerpendicularOffset(o,l,I),h={x:h.x/this.zoom,y:h.y/this.zoom}}switch(this.dragStatus=x.Move,r){case b.Plane:i=i.map((a,d)=>m(f({},a),{x:s[d].x+h.x,y:s[d].y+h.y}));break;case b.Point:case b.Line:i=i.map((a,d)=>n&&n.includes(d)?m(f({},a),{x:s[d].x+h.x,y:s[d].y+h.y}):a);break}if(this.pattern===w.Rect&&(e==null?void 0:e.isRect)===!0&&r===b.Point&&n&&(i=D.getPointListFromPointOffset(s,n[0],h)),this.config.drawOutsideTarget===!1&&this.imgInfo&&this.isPolygonOutSide(i))return;const g=this.polygonList.map(a=>{if(a.id===this.selectedID){const d=m(f({},a),{pointList:i});return a.isRect===!0&&this.pattern===w.Normal&&Object.assign(d,{isRect:!1}),d}return a});this.setPolygonList(g),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===x.Move){const{originPolygon:e}=this.dragInfo;this.dragInfo=void 0,this.dragStatus=x.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===x.Start&&(this.dragInfo=void 0,this.dragStatus=x.Wait)}exportData(){const{polygonList:t}=this;return[t,this.basicImgInfo]}getTextIconSvg(t=""){return v.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:j,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributInstance&&t&&this.selectedID){let e=t;v.textAttributeValidate(this.config.textCheckType,"",e)===!1&&(this.emit("messageError",v.getErrorNotice(this.config.textCheckType,this.lang)),e=""),this.setPolygonList(v.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=j,g=c.getOffsetCoordinate({x:n,y:l},this.currentPos,this.zoom),a=this.getColor(s),d=o?a==null?void 0:a.valid.stroke:a==null?void 0:a.invalid.stroke;this._textAttributInstance||(this._textAttributInstance=new $({width:h,container:this.container,icon:this.getTextIconSvg(s),color:d,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributInstance&&!((t=this._textAttributInstance)==null?void 0:t.isExit)&&this._textAttributInstance.appendToContainer(),this._textAttributInstance.update(`${r}`,{left:g.x,top:g.y,color:d,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,g=this.getColor(h),a=A.getStrokeAndFill(g,e.valid),d=c.changePointListByZoom(e.pointList||[],this.zoom,this.currentPos);P.drawPolygonWithFillAndLine(this.canvas,d,{fillColor:a.fill,strokeColor:a.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 I=`${(r=v.getAttributeShowText(h,this.config.attributeList))!=null?r:""}`;((n=this.config)==null?void 0:n.isShowOrder)&&(e==null?void 0:e.order)>0&&(I=`${e.order} ${I}`),P.drawText(this.canvas,d[0],I,f({color:a.stroke},k));const T=d[d.length-1];P.drawText(this.canvas,{x:T.x+E.x,y:T.y+E.y},l,f({color:a.stroke},k))}))}renderSelectedPolygon(){var t,e,i;if(this.selectedID){const s=this.selectedPolygon;if(s){const o=this.getColor(s.attribute),r=A.getStrokeAndFill(o,s.valid,{isSelected:!0});P.drawSelectedPolygonWithFillAndLine(this.canvas,c.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=v.getAttributeShowText(s.attribute,this.config.attributeList))!=null?e:""}`;((i=this.config)==null?void 0:i.isShowOrder)&&(s==null?void 0:s.order)>0&&(n=`${s.order} ${n}`),P.drawText(this.canvas,c.changePointByZoom(s.pointList[0],this.zoom,this.currentPos),n,f({color:r.stroke},k)),this.renderTextAttribute()}}}renderHoverPolygon(){var t;if(this.hoverID&&this.hoverID!==this.editPolygonID){const{hoverPolygon:e}=this;if(e){let i="";const s=this.getColor(e.attribute);e.valid?i=s.validHover.fill:i=A.getStrokeAndFill(s,!1,{isHover:!0}).fill,P.drawPolygonWithFill(this.canvas,c.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=A.getStrokeAndFill(o,!this.isCtrl);if(((t=this.drawingPointList)==null?void 0:t.length)>0){let n=[...this.drawingPointList],l=c.getOriginCoordinateWithOffsetCoordinate(this.coord,this.zoom,this.currentPos);if(this.pattern===w.Rect&&n.length===2)n=D.getRectangleByRightAngle(l,n);else{if(((e=this.config)==null?void 0:e.edgeAdsorption)&&this.isAlt===!1){const{dropFoot:h}=y.getClosestPoint(l,this.polygonList,(i=this.config)==null?void 0:i.lineType,R/this.zoom);h&&(l=h)}n.push(l)}P.drawSelectedPolygonWithFillAndLine(this.canvas,c.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=A.getStrokeAndFill(o,n.valid,{isSelected:!0}),h=n==null?void 0:n.pointList[this.hoverPointIndex];if(h){const{x:g,y:a}=c.changePointByZoom(h,this.zoom,this.currentPos);P.drawCircleWithFill(this.canvas,{x:g,y:a},5,{color:l.fill})}}if(this.hoverEdgeIndex>-1&&this.selectedID){const n=this.selectedPolygon;if(!n)return;const l=A.getStrokeAndFill(o,n.valid,{isSelected:!0});P.drawLineWithPointList(this.canvas,c.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;P.drawRectWithFill(this.canvas,{x:e+s,y:i-s*4-1,width:o,height:r},{color:"black"}),P.drawText(this.canvas,{x:e,y:i},_.t("ClickAnotherPolygon"),{textAlign:"center",color:"white",offsetX:o/2+s,offsetY:-(r/2+s/2)}),P.drawRect(this.canvas,{x:e-s,y:i-s,width:s*2,height:s*2},{lineDash:[6],color:"white"})}}undo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.undo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.undo();t&&(t.length!==this.polygonList.length&&this.deleteSelectedID(),this.setPolygonList(t),this.render())}redo(){if(this.drawingPointList.length>0){const e=this.drawingHistory.redo();if(!e)return;this.drawingPointList=e,this.render();return}const t=this.history.redo();t&&(t.length!==this.polygonList.length&&this.deleteSelectedID(),this.setPolygonList(t),this.render())}deleteSelectedID(){this.setSelectedID("")}}export{J as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-annotation",
3
- "version": "1.12.0-alpha.1",
3
+ "version": "1.12.0-alpha.2",
4
4
  "description": "Annotation tool collection",
5
5
  "keywords": [
6
6
  "annotation",
@@ -92,11 +92,11 @@
92
92
  "typescript": "^4.2.3"
93
93
  },
94
94
  "dependencies": {
95
- "@labelbee/lb-utils": "^1.5.0-alpha.1",
95
+ "@labelbee/lb-utils": "^1.5.0-alpha.2",
96
96
  "@turf/turf": "5.1.6",
97
97
  "color-rgba": "^2.3.0",
98
98
  "lodash": "^4.17.20",
99
99
  "three": ">=0.141.0"
100
100
  },
101
- "gitHead": "71dd3b568e4c7c83660be33120999a33ac88b30f"
101
+ "gitHead": "654b0718638113cc72f29d5285b14fd4761a2882"
102
102
  }