@labelbee/lb-annotation 1.13.0 → 1.14.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -0
  2. package/dist/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -0
  3. package/dist/assets/attributeIcon/icon_cuboidMore.svg.js +5 -0
  4. package/dist/assets/attributeIcon/icon_cuboidRight.svg.js +5 -0
  5. package/dist/assets/attributeIcon/icon_cuboidTop.svg.js +12 -0
  6. package/dist/constant/annotation.js +1 -1
  7. package/dist/constant/tool.js +1 -1
  8. package/dist/core/pointCloud/annotation.js +1 -1
  9. package/dist/core/pointCloud/index.js +2 -2
  10. package/dist/core/scheduler.js +1 -1
  11. package/dist/core/toolOperation/ViewOperation.js +1 -1
  12. package/dist/core/toolOperation/basicToolOperation.js +1 -1
  13. package/dist/core/toolOperation/cuboidOperation.js +1 -0
  14. package/dist/core/toolOperation/cuboidToggleButtonClass.js +31 -0
  15. package/dist/types/constant/annotation.d.ts +45 -1
  16. package/dist/types/constant/tool.d.ts +6 -1
  17. package/dist/types/core/index.d.ts +1 -2
  18. package/dist/types/core/pointCloud/annotation.d.ts +11 -1
  19. package/dist/types/core/pointCloud/index.d.ts +11 -1
  20. package/dist/types/core/pointCloud/matrix.d.ts +1 -0
  21. package/dist/types/core/pointCloud/segmentation.d.ts +0 -0
  22. package/dist/types/core/scheduler.d.ts +7 -2
  23. package/dist/types/core/toolOperation/ViewOperation.d.ts +3 -2
  24. package/dist/types/core/toolOperation/basicToolOperation.d.ts +11 -1
  25. package/dist/types/core/toolOperation/cuboidOperation.d.ts +155 -0
  26. package/dist/types/core/toolOperation/cuboidToggleButtonClass.d.ts +38 -0
  27. package/dist/types/utils/MathUtils.d.ts +1 -1
  28. package/dist/types/utils/tool/AttributeUtils.d.ts +7 -0
  29. package/dist/types/utils/tool/AxisUtils.d.ts +50 -1
  30. package/dist/types/utils/tool/CuboidUtils.d.ts +267 -0
  31. package/dist/types/utils/tool/DrawUtils.d.ts +12 -0
  32. package/dist/types/utils/tool/EnhanceCommonToolUtils.d.ts +4 -2
  33. package/dist/types/utils/tool/PolygonUtils.d.ts +5 -2
  34. package/dist/utils/MathUtils.js +2 -2
  35. package/dist/utils/tool/AttributeUtils.js +1 -1
  36. package/dist/utils/tool/AxisUtils.js +1 -1
  37. package/dist/utils/tool/CuboidUtils.js +1 -0
  38. package/dist/utils/tool/DrawUtils.js +3 -3
  39. package/dist/utils/tool/EnhanceCommonToolUtils.js +1 -1
  40. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
  41. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
  42. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
  43. package/es/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
  44. package/es/assets/attributeIcon/icon_cuboidFAB.svg.js +5 -0
  45. package/es/assets/attributeIcon/icon_cuboidLeft.svg.js +7 -0
  46. package/es/assets/attributeIcon/icon_cuboidMore.svg.js +5 -0
  47. package/es/assets/attributeIcon/icon_cuboidRight.svg.js +5 -0
  48. package/es/assets/attributeIcon/icon_cuboidTop.svg.js +12 -0
  49. package/es/constant/annotation.js +1 -1
  50. package/es/constant/tool.js +1 -1
  51. package/es/core/pointCloud/annotation.js +1 -1
  52. package/es/core/pointCloud/index.js +2 -2
  53. package/es/core/pointCloud/segmentation.js +50 -0
  54. package/es/core/scheduler.js +1 -1
  55. package/es/core/toolOperation/ViewOperation.js +1 -1
  56. package/es/core/toolOperation/basicToolOperation.js +1 -1
  57. package/es/core/toolOperation/cuboidOperation.js +1 -0
  58. package/es/core/toolOperation/cuboidToggleButtonClass.js +31 -0
  59. package/es/core/toolOperation/scribbleTool2.js +249 -0
  60. package/es/utils/MathUtils.js +2 -2
  61. package/es/utils/tool/AttributeUtils.js +1 -1
  62. package/es/utils/tool/AxisUtils.js +1 -1
  63. package/es/utils/tool/CuboidUtils.js +1 -0
  64. package/es/utils/tool/DrawUtils.js +3 -3
  65. package/es/utils/tool/EnhanceCommonToolUtils.js +1 -1
  66. package/package.json +3 -3
@@ -0,0 +1,12 @@
1
+ var t=`<svg width="25" height="25" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_2295_37199)">
3
+ <path
4
+ d="M5.16087 7.8398C5.00351 8.01726 4.94861 8.22216 4.99615 8.45452L5.23337 15.7654C5.25346 16.1002 5.44096 16.4249 5.72087 16.6098L11.9712 20.5356C12.2511 20.7204 12.6883 20.7277 13.0131 20.5402L18.8587 17.1652C19.1835 16.9777 19.3958 16.5954 19.3757 16.2606L19.1385 8.94971C19.0909 8.71735 19.0434 8.485 18.8659 8.32764C18.8284 8.26269 18.6885 8.17029 18.651 8.10533L12.4382 4.24447C12.1208 3.99471 11.6835 3.98735 11.3587 4.17485L5.51308 7.54985C5.38317 7.62485 5.29077 7.7648 5.16087 7.8398ZM12.1109 12.2276L17.6318 9.04014L17.8367 9.09505L18.0538 16.0711L12.468 19.2961L6.5351 15.62L6.31798 8.64399L12.1109 12.2276Z"
5
+ fill="#2C7EFF" />
6
+ </g>
7
+ <defs>
8
+ <clipPath id="clip0_2295_37199">
9
+ <rect width="18" height="18" fill="white" transform="translate(9 24.5898) rotate(-120)" />
10
+ </clipPath>
11
+ </defs>
12
+ </svg>`;export{t as default};
@@ -1 +1 @@
1
- const I=61,_=40,d=40,O=240;var c;(function(n){n[n.ANNOTATION=1]="ANNOTATION",n[n.QUALITY_INSPECTION=2]="QUALITY_INSPECTION",n[n.PRE_ANNOTATION=3]="PRE_ANNOTATION",n[n.MANUAL_CORRECTION=4]="MANUAL_CORRECTION"})(c||(c={}));const l=1e3;var N;(function(n){n[n.Backward=0]="Backward",n[n.Forward=1]="Forward",n[n.JumpSkip=2]="JumpSkip",n[n.None=3]="None"})(N||(N={}));var i;(function(n){n[n.Start=0]="Start",n[n.Stop=1]="Stop",n[n.Wait=2]="Wait",n[n.Move=3]="Move"})(i||(i={}));var o;(function(n){n[n.Point=0]="Point",n[n.Line=1]="Line",n[n.Plane=2]="Plane"})(o||(o={}));var A;(function(n){n[n.ascend=0]="ascend",n[n.descend=1]="descend"})(A||(A={}));var s;(function(n){n[n.Intelligence=0]="Intelligence",n[n.Linear=1]="Linear"})(s||(s={}));var T;(function(n){n.Zh="zh_CN",n.US="en_US"})(T||(T={}));var f;(function(n){n[n.Clockwise=0]="Clockwise",n[n.Anticlockwise=1]="Anticlockwise"})(f||(f={}));const v={offsetX:-10,offsetY:-10},w={shadowColor:"rgba(0, 0, 0, 1)",shadowOffsetX:1,shadowOffsetY:1,shadowBlur:0},C={x:8,y:26};export{l as ANNOTATION_MAX_SIZE,v as DEFAULT_TEXT_OFFSET,w as DEFAULT_TEXT_SHADOW,i as EDragStatus,o as EDragTarget,s as EGrowthMode,T as ELang,N as EPageOperator,f as ERotateDirection,A as ESortDirection,c as EStepType,C as TEXT_ATTRIBUTE_OFFSET,d as footerHeight,I as headerHeight,O as sidebarWidth,_ as tipsHeight};
1
+ const B=61,R=40,i=40,t=240;var o;(function(n){n[n.ANNOTATION=1]="ANNOTATION",n[n.QUALITY_INSPECTION=2]="QUALITY_INSPECTION",n[n.PRE_ANNOTATION=3]="PRE_ANNOTATION",n[n.MANUAL_CORRECTION=4]="MANUAL_CORRECTION"})(o||(o={}));const v=1e3;var N;(function(n){n[n.Backward=0]="Backward",n[n.Forward=1]="Forward",n[n.JumpSkip=2]="JumpSkip",n[n.None=3]="None"})(N||(N={}));var T;(function(n){n[n.Start=0]="Start",n[n.Stop=1]="Stop",n[n.Wait=2]="Wait",n[n.Move=3]="Move"})(T||(T={}));var f;(function(n){n[n.Point=0]="Point",n[n.Line=1]="Line",n[n.Plane=2]="Plane",n[n.Cuboid=3]="Cuboid"})(f||(f={}));var A;(function(n){n[n.ascend=0]="ascend",n[n.descend=1]="descend"})(A||(A={}));var L;(function(n){n[n.Intelligence=0]="Intelligence",n[n.Linear=1]="Linear"})(L||(L={}));var s;(function(n){n.Zh="zh_CN",n.US="en_US"})(s||(s={}));var I;(function(n){n[n.Clockwise=0]="Clockwise",n[n.Anticlockwise=1]="Anticlockwise"})(I||(I={}));const d={offsetX:-10,offsetY:-10},k={shadowColor:"rgba(0, 0, 0, 1)",shadowOffsetX:1,shadowOffsetY:1,shadowBlur:0},w={x:8,y:26};var O;(function(n){n.Front="front",n.Back="back",n.Side="side"})(O||(O={}));var c;(function(n){n.TL="tl",n.TR="tr",n.BL="bl",n.BR="br"})(c||(c={}));var l;(function(n){n.Front="front",n.Back="back",n.Left="left",n.Right="right",n.Top="top"})(l||(l={}));const U={tl:"br",tr:"bl",br:"tl",bl:"tr"};var _;(function(n){n.Row="row",n.Column="column"})(_||(_={}));const h={[c.TL]:c.TR,[c.TR]:c.TL,[c.BL]:c.BR,[c.BR]:c.BL},C={[c.TL]:c.BL,[c.TR]:c.BR,[c.BL]:c.TL,[c.BR]:c.TR};export{v as ANNOTATION_MAX_SIZE,C as CUBOID_COLUMN,h as CUBOID_ROW,d as DEFAULT_TEXT_OFFSET,k as DEFAULT_TEXT_SHADOW,U as DIAGONAL_POINT,l as ECuboidDirection,_ as ECuboidLineDirection,O as ECuboidPlain,c as ECuboidPosition,T as EDragStatus,f as EDragTarget,L as EGrowthMode,s as ELang,N as EPageOperator,I as ERotateDirection,A as ESortDirection,o as EStepType,w as TEXT_ATTRIBUTE_OFFSET,i as footerHeight,B as headerHeight,t as sidebarWidth,R as tipsHeight};
@@ -1 +1 @@
1
- const A=320;var n;(function(o){o.PointCloud="pointCloudTool"})(n||(n={}));var i;(function(o){o.VideoTextTool="videoTextTool",o.VideoTagTool="videoTagTool",o.VideoClipTool="videoClipTool"})(i||(i={}));var e;(function(o){o[o.Rect=0]="Rect",o[o.Tag=1]="Tag"})(e||(e={}));var u;(function(o){o.Rect="rectTool",o.Tag="tagTool",o.Point="pointTool",o.PointMarker="pointMarkerTool",o.Segmentation="segmentationTool",o.Filter="filterTool",o.Text="textTool",o.Polygon="polygonTool",o.Line="lineTool",o.LineMarker="lineMarkerTool",o.Empty="emptyTool",o.FolderTag="folderTagTool",o.RectTrack="rectTrackTool",o.ScribbleTool="scribbleTool",o.Face="faceTool",o.ClientAttribute="clientAttributeTool",o.OCRRelation="OCRRelationTool",o.SegmentByRect="segmentByRectTool"})(u||(u={}));var l;(function(o){o.Check="check"})(l||(l={}));var c;(function(o){o[o.nothing=0]="nothing",o[o.RectBG=1]="RectBG",o[o.showOrder=2]="showOrder"})(c||(c={}));const M={[u.Rect]:"\u62C9\u6846",[u.Tag]:"\u6807\u7B7E",[u.Point]:"\u6807\u70B9",[u.PointMarker]:"\u5217\u8868\u6807\u70B9",[u.Segmentation]:"\u524D\u666F\u5206\u5272",[u.Filter]:"\u7B5B\u9009",[u.Text]:"\u6587\u672C",[u.Polygon]:"\u591A\u8FB9\u5F62",[u.Line]:"\u7EBF\u6761",[u.LineMarker]:"\u5217\u8868\u7EBF\u6761",[u.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[u.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[u.Face]:"\u4EBA\u8138106\u5DE5\u5177",[u.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[u.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[u.SegmentByRect]:"\u7B97\u6CD5\u5206\u5272\u8F85\u52A9\u5DE5\u5177",[i.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[i.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[i.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[n.PointCloud]:"\u70B9\u4E91"},_={[u.Rect]:"Rect",[u.Tag]:"Tag",[u.Point]:"Point",[u.PointMarker]:"PointMarker",[u.Segmentation]:"Segmentation",[u.Filter]:"Filter",[u.Text]:"Text",[u.Polygon]:"Polygon",[u.Line]:"Line",[u.LineMarker]:"LineMarker",[u.FolderTag]:"FolderTag",[u.RectTrack]:"RectTrack",[u.Face]:"Face",[u.ClientAttribute]:"ClientAttribute",[u.OCRRelation]:"OCRRelation",[u.SegmentByRect]:"SegmentByRect",[i.VideoTextTool]:"VideoTextTool",[i.VideoTagTool]:"VideoTagTool",[i.VideoClipTool]:"VideoClipTool",[n.PointCloud]:"PointCloud"};var r;(function(o){o[o.noDepend=1]="noDepend",o[o.dependOrigin=2]="dependOrigin",o[o.dependShape=3]="dependShape",o[o.dependLine=4]="dependLine",o[o.dependPolygon=5]="dependPolygon",o[o.dependPreShape=101]="dependPreShape",o[o.dependPreLine=102]="dependPreLine",o[o.dependPrePolygon=103]="dependPrePolygon"})(r||(r={}));var t;(function(o){o.lc="leftClick",o.rc="rightClick",o.clc="ctrlLeftClick",o.crc="ctrlRightClick"})(t||(t={}));const O={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};var C;(function(o){o[o.Normal=1]="Normal",o[o.Modify=2]="Modify"})(C||(C={}));var d;(function(o){o[o.Line=0]="Line",o[o.Curve=1]="Curve"})(d||(d={}));var T;(function(o){o[o.SingleColor=0]="SingleColor",o[o.MultiColor=1]="MultiColor"})(T||(T={}));var F;(function(o){o[o.Form=1]="Form",o[o.Json=2]="Json"})(F||(F={}));var g;(function(o){o[o.Point=0]="Point",o[o.Line=1]="Line",o[o.Plane=2]="Plane"})(g||(g={}));var R;(function(o){o[o.None=0]="None",o[o.Drawing=1]="Drawing",o[o.Edit=2]="Edit"})(R||(R={}));var B;(function(o){o[o.Backward=0]="Backward",o[o.Forward=1]="Forward",o[o.JumpSkip=2]="JumpSkip",o[o.None=3]="None"})(B||(B={}));var s;(function(o){o[o.Wait=0]="Wait",o[o.Pass=1]="Pass",o[o.Fail=2]="Fail",o[o.Loading=3]="Loading"})(s||(s={}));var a;(function(o){o[o.AnyString=0]="AnyString",o[o.Order=1]="Order",o[o.EnglishOnly=2]="EnglishOnly",o[o.NumberOnly=3]="NumberOnly",o[o.CustomFormat=4]="CustomFormat"})(a||(a={}));const S={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},h=1e3,b=16,m=300,I="normal normal 500 14px Arial";var k;(function(o){o[o.ImgList=1e3]="ImgList",o[o.TrackPrediction=1001]="TrackPrediction",o[o.ImgSearch=1002]="ImgSearch"})(k||(k={}));const V={[n.PointCloud]:"sensebeepc",[u.ClientAttribute]:"sensebeepc-EnumAttributeTool",[u.Face]:"sensebeepc-FacePointsLabellingTool",[u.OCRRelation]:"sensebeepc-OCRRelationTool"},y={[n.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[u.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[u.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[u.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},G=16,N=10;var f;(function(o){o[o.Normal=0]="Normal",o[o.Rect=1]="Rect"})(f||(f={}));var L;(function(o){o[o.Scribble=1]="Scribble",o[o.Erase=2]="Erase"})(L||(L={}));var v;(function(o){o[o.General=1]="General",o[o.MultiMove=2]="MultiMove"})(v||(v={}));export{V as CLIENT_TOOL_HEAD_TYPE,y as CLIENT_TOOL_NAME,I as DEFAULT_FONT,m as DEFAULT_TEXT_MAX_WIDTH,C as EAnnotationMode,s as EAuditStatus,l as ECheckModel,r as EDependPattern,g as EDragTarget,R as EDrawPointPattern,t as EFilterToolOperation,T as ELineColor,d as ELineTypes,v as EOperationMode,B as EPageOperator,n as EPointCloudName,f as EPolygonPattern,c as ERectPattern,L as EScribblePattern,F as ESelectedType,a as ETextType,k as EThumbnailOption,u as EToolName,e as EToolType,i as EVideoToolName,O as OPERATION_LIST,G as SEGMENT_NUMBER,b as TEXT_ATTRIBUTE_LINE_HEIGHT,h as TEXT_ATTRIBUTE_MAX_LENGTH,S as TEXT_TYPE,M as TOOL_NAME,_ as TOOL_NAME_EN,N as edgeAdsorptionScope,A as editStepWidth};
1
+ const A=320;var n;(function(o){o.PointCloud="pointCloudTool"})(n||(n={}));var i;(function(o){o.VideoTextTool="videoTextTool",o.VideoTagTool="videoTagTool",o.VideoClipTool="videoClipTool"})(i||(i={}));var l;(function(o){o[o.Rect=0]="Rect",o[o.Tag=1]="Tag"})(l||(l={}));var u;(function(o){o.Rect="rectTool",o.Tag="tagTool",o.Point="pointTool",o.PointMarker="pointMarkerTool",o.Segmentation="segmentationTool",o.Filter="filterTool",o.Text="textTool",o.Polygon="polygonTool",o.Line="lineTool",o.LineMarker="lineMarkerTool",o.Empty="emptyTool",o.FolderTag="folderTagTool",o.RectTrack="rectTrackTool",o.ScribbleTool="scribbleTool",o.Face="faceTool",o.ClientAttribute="clientAttributeTool",o.OCRRelation="OCRRelationTool",o.SegmentByRect="segmentByRectTool",o.Cuboid="cuboidTool",o.PointCloudPolygon="pointCloudPolygon"})(u||(u={}));var e;(function(o){o.Check="check"})(e||(e={}));var c;(function(o){o[o.nothing=0]="nothing",o[o.RectBG=1]="RectBG",o[o.showOrder=2]="showOrder"})(c||(c={}));const M={[u.Rect]:"\u62C9\u6846",[u.Tag]:"\u6807\u7B7E",[u.Point]:"\u6807\u70B9",[u.PointMarker]:"\u5217\u8868\u6807\u70B9",[u.Segmentation]:"\u524D\u666F\u5206\u5272",[u.Filter]:"\u7B5B\u9009",[u.Text]:"\u6587\u672C",[u.Polygon]:"\u591A\u8FB9\u5F62",[u.Line]:"\u7EBF\u6761",[u.LineMarker]:"\u5217\u8868\u7EBF\u6761",[u.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[u.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[u.Face]:"\u4EBA\u8138106\u5DE5\u5177",[u.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[u.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[u.SegmentByRect]:"\u7B97\u6CD5\u5206\u5272\u8F85\u52A9\u5DE5\u5177",[i.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[i.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[i.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[n.PointCloud]:"\u70B9\u4E91",[u.Cuboid]:"\u7ACB\u4F53\u6846"},_={[u.Rect]:"Rect",[u.Tag]:"Tag",[u.Point]:"Point",[u.PointMarker]:"PointMarker",[u.Segmentation]:"Segmentation",[u.Filter]:"Filter",[u.Text]:"Text",[u.Polygon]:"Polygon",[u.Line]:"Line",[u.LineMarker]:"LineMarker",[u.FolderTag]:"FolderTag",[u.RectTrack]:"RectTrack",[u.Face]:"Face",[u.ClientAttribute]:"ClientAttribute",[u.OCRRelation]:"OCRRelation",[u.SegmentByRect]:"SegmentByRect",[i.VideoTextTool]:"VideoTextTool",[i.VideoTagTool]:"VideoTagTool",[i.VideoClipTool]:"VideoClipTool",[n.PointCloud]:"PointCloud",[u.Cuboid]:"Cuboid"};var t;(function(o){o[o.noDepend=1]="noDepend",o[o.dependOrigin=2]="dependOrigin",o[o.dependShape=3]="dependShape",o[o.dependLine=4]="dependLine",o[o.dependPolygon=5]="dependPolygon",o[o.dependPreShape=101]="dependPreShape",o[o.dependPreLine=102]="dependPreLine",o[o.dependPrePolygon=103]="dependPrePolygon"})(t||(t={}));var r;(function(o){o.lc="leftClick",o.rc="rightClick",o.clc="ctrlLeftClick",o.crc="ctrlRightClick"})(r||(r={}));const b={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};var C;(function(o){o[o.Normal=1]="Normal",o[o.Modify=2]="Modify"})(C||(C={}));var d;(function(o){o[o.Line=0]="Line",o[o.Curve=1]="Curve"})(d||(d={}));var F;(function(o){o[o.SingleColor=0]="SingleColor",o[o.MultiColor=1]="MultiColor"})(F||(F={}));var T;(function(o){o[o.Form=1]="Form",o[o.Json=2]="Json"})(T||(T={}));var g;(function(o){o[o.Point=0]="Point",o[o.Line=1]="Line",o[o.Plane=2]="Plane"})(g||(g={}));var R;(function(o){o[o.None=0]="None",o[o.Drawing=1]="Drawing",o[o.Edit=2]="Edit"})(R||(R={}));var B;(function(o){o[o.Backward=0]="Backward",o[o.Forward=1]="Forward",o[o.JumpSkip=2]="JumpSkip",o[o.None=3]="None"})(B||(B={}));var s;(function(o){o[o.Wait=0]="Wait",o[o.Pass=1]="Pass",o[o.Fail=2]="Fail",o[o.Loading=3]="Loading"})(s||(s={}));var k;(function(o){o[o.AnyString=0]="AnyString",o[o.Order=1]="Order",o[o.EnglishOnly=2]="EnglishOnly",o[o.NumberOnly=3]="NumberOnly",o[o.CustomFormat=4]="CustomFormat"})(k||(k={}));const O={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},S=1e3,h=16,I=300,m="normal normal 500 14px Arial";var a;(function(o){o[o.ImgList=1e3]="ImgList",o[o.TrackPrediction=1001]="TrackPrediction",o[o.ImgSearch=1002]="ImgSearch"})(a||(a={}));const V={[n.PointCloud]:"sensebeepc",[u.ClientAttribute]:"sensebeepc-EnumAttributeTool",[u.Face]:"sensebeepc-FacePointsLabellingTool",[u.OCRRelation]:"sensebeepc-OCRRelationTool"},y={[n.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[u.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[u.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[u.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},G=16,P=10;var f;(function(o){o[o.Normal=0]="Normal",o[o.Rect=1]="Rect"})(f||(f={}));var L;(function(o){o[o.Scribble=1]="Scribble",o[o.Erase=2]="Erase"})(L||(L={}));var v;(function(o){o[o.General=1]="General",o[o.MultiMove=2]="MultiMove"})(v||(v={}));export{V as CLIENT_TOOL_HEAD_TYPE,y as CLIENT_TOOL_NAME,m as DEFAULT_FONT,I as DEFAULT_TEXT_MAX_WIDTH,C as EAnnotationMode,s as EAuditStatus,e as ECheckModel,t as EDependPattern,g as EDragTarget,R as EDrawPointPattern,r as EFilterToolOperation,F as ELineColor,d as ELineTypes,v as EOperationMode,B as EPageOperator,n as EPointCloudName,f as EPolygonPattern,c as ERectPattern,L as EScribblePattern,T as ESelectedType,k as ETextType,a as EThumbnailOption,u as EToolName,l as EToolType,i as EVideoToolName,b as OPERATION_LIST,G as SEGMENT_NUMBER,h as TEXT_ATTRIBUTE_LINE_HEIGHT,S as TEXT_ATTRIBUTE_MAX_LENGTH,O as TEXT_TYPE,M as TOOL_NAME,_ as TOOL_NAME_EN,P as edgeAdsorptionScope,A as editStepWidth};
@@ -1 +1 @@
1
- import{PointCloudUtils as u}from"@labelbee/lb-utils";import{EPolygonPattern as I}from"../../constant/tool.js";import{CanvasScheduler as D}from"../../newCore/CanvasScheduler.js";import{PointCloud as L}from"./index.js";import S from"../toolOperation/pointCloud2dOperation.js";var b=Object.defineProperty,R=Object.defineProperties,j=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,A=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,O=(e,t,o)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,x=(e,t)=>{for(var o in t||(t={}))A.call(t,o)&&O(e,o,t[o]);if(f)for(var o of f(t))E.call(t,o)&&O(e,o,t[o]);return e},N=(e,t)=>R(e,j(t));const P=e=>{const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const o=t.getContext("2d");return o?(o.fillStyle="black",o.fillRect(0,0,e.width,e.height),t.toDataURL()):""};class T{constructor({size:t,container:o,pcdPath:n,polygonOperationProps:c,config:h,checkMode:v}){this.updatePolygonList=(_,m)=>{let d=_.map(i=>{var r;const{polygon2d:p}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(i);return{id:i.id,sourceID:"",pointList:p,isRect:!0,valid:(r=i.valid)!=null?r:!0,attribute:i.attribute}});m&&(d=d.concat(m.map(i=>{var r;return N(x({},i),{pointList:(r=i==null?void 0:i.pointList)==null?void 0:r.map(p=>u.transferWorld2Canvas(p,this.pointCloud2dOperation.size))})}))),this.pointCloud2dOperation.setResult(d)};const y=this.getDefaultOrthographic(t),w=P(t),g=new Image;g.src=w;const s=new D({container:o}),l=new L({container:o,noAppend:!0,isOrthographicCamera:!0,orthographicParams:y});n&&l.loadPCDFile(n),s.createCanvas(l.renderer.domElement);const C={container:o,size:t,config:JSON.stringify(h),imgNode:g,isAppend:!1,checkMode:v};c&&Object.assign(C,c);const a=new S(C);a.eventBinding(),a.setPattern(I.Rect),s.createCanvas(a.canvas,{size:t}),this.pointCloud2dOperation=a,this.pointCloudInstance=l,this.canvasScheduler=s,this.config=h}updateConfig(t){this.config=t,this.pointCloud2dOperation.setConfig(JSON.stringify(t))}getDefaultOrthographic(t){return{left:-t.width/2,right:t.width/2,top:t.height/2,bottom:-t.height/2,near:100,far:-100}}initSize(t){this.pointCloudInstance.updateTopCamera(),this.pointCloudInstance.setDefaultControls(),this.pointCloudInstance.initRenderer(),this.pointCloudInstance.initOrthographicCamera(this.getDefaultOrthographic(t)),this.pointCloudInstance.render();const o=P(t),n=new Image;n.src=o,n.onload=()=>{this.pointCloud2dOperation.setImgNode(n),this.pointCloud2dOperation.initImgPos()},this.pointCloud2dOperation.setCanvasSize(t)}addPolygonListOnTopView(t){const o=u.getBoxParamsFromResultList(t),n=u.getPolygonListFromResultList(t);this.updatePolygonList(o,n)}updateData(t,o,n){!this.pointCloud2dOperation||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,n==null?void 0:n.radius),this.addPolygonListOnTopView(o))}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}export{T as PointCloudAnnotation};
1
+ import{PointCloudUtils as f}from"@labelbee/lb-utils";import{EToolName as D,EPolygonPattern as L}from"../../constant/tool.js";import{CanvasScheduler as b}from"../../newCore/CanvasScheduler.js";import{PointCloud as T}from"./index.js";import{ToolScheduler as R,HybridToolUtils as j}from"../scheduler.js";var E=Object.defineProperty,B=Object.defineProperties,x=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,A=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable,v=(e,t,o)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,N=(e,t)=>{for(var o in t||(t={}))A.call(t,o)&&v(e,o,t[o]);if(I)for(var o of I(t))F.call(t,o)&&v(e,o,t[o]);return e},U=(e,t)=>B(e,x(t));const y=e=>{const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const o=t.getContext("2d");return o?(o.fillStyle="black",o.fillRect(0,0,e.width,e.height),t.toDataURL()):""};class V{constructor({size:t,container:o,pcdPath:i,polygonOperationProps:m,config:h,checkMode:w,toolName:l}){this.updatePolygonList=(a,p)=>{let r=a.map(n=>{var s;const{polygon2d:C}=this.pointCloudInstance.getBoxTopPolygon2DCoordinate(n);return{id:n.id,sourceID:"",pointList:C,isRect:!0,valid:(s=n.valid)!=null?s:!0,attribute:n.attribute}});p&&(r=r.concat(p.map(n=>{var s;return U(N({},n),{pointList:(s=n==null?void 0:n.pointList)==null?void 0:s.map(C=>f.transferWorld2Canvas(C,this.pointCloud2dOperation.size))})}))),this.pointCloud2dOperation.setResult(r)};const _=this.getDefaultOrthographic(t),S=y(t),d=new Image;d.src=S;const u=new R({container:o,size:t,toolName:l}),P=new b({container:o}),g=new T({container:o,noAppend:!0,isOrthographicCamera:!0,orthographicParams:_});i&&g.loadPCDFile(i),P.createCanvas(g.renderer.domElement);const O={size:t,config:JSON.stringify(h),imgNode:d,checkMode:w};m&&Object.assign(O,m);let c=[];j.isSingleTool(l)?c=[l]:c=l,c.forEach((a,p)=>{let r;if(a===D.PointCloudPolygon){const n=u.createOperation(a,d,O);n.eventBinding(),n.setPattern(L.Rect),this.toolInstance=n,this.toolInstance.eventBinding(),this.pointCloud2dOperation=n}else r=u.createOperation(a,d,h);p===c.length-1&&(this.toolInstance||(this.toolInstance=r,this.toolInstance.eventBinding()))}),this.pointCloudInstance=g,this.canvasScheduler=P,this.toolScheduler=u,this.config=h}updateConfig(t){this.config=t,this.pointCloud2dOperation.setConfig(JSON.stringify(t))}getDefaultOrthographic(t){return{left:-t.width/2,right:t.width/2,top:t.height/2,bottom:-t.height/2,near:100,far:-100}}initSize(t){this.pointCloudInstance.updateTopCamera(),this.pointCloudInstance.setDefaultControls(),this.pointCloudInstance.initRenderer(),this.pointCloudInstance.initOrthographicCamera(this.getDefaultOrthographic(t)),this.pointCloudInstance.render();const o=y(t),i=new Image;i.src=o,i.onload=()=>{this.toolInstance.setImgNode(i),this.toolInstance.initImgPos()},this.pointCloud2dOperation.setCanvasSize(t)}addPolygonListOnTopView(t){const o=f.getBoxParamsFromResultList(t),i=f.getPolygonListFromResultList(t);this.updatePolygonList(o,i)}updateData(t,o,i){!this.pointCloud2dOperation||!this.pointCloudInstance||(this.pointCloudInstance.loadPCDFile(t,i==null?void 0:i.radius),this.addPolygonListOnTopView(o))}switchToCanvas(t){const o=this.toolScheduler.switchToCanvas(t);return o?(o.eventBinding(),this.toolInstance=o,o):this.toolInstance}initAllPosition(){this.pointCloudInstance.updateTopCamera(),this.pointCloud2dOperation.initPosition()}clearAllData(){this.pointCloudInstance.clearPointCloudAndRender(),this.pointCloud2dOperation.clearResult()}}export{V as PointCloudAnnotation};
@@ -1,4 +1,4 @@
1
- import*as a from"three";import{toolStyleConverter as S,PerspectiveShiftUtils as w,EPerspectiveView as g}from"@labelbee/lb-utils";import k from"../../_virtual/highlightWorker.js";import V from"../../_virtual/filterBoxWorker.js";import{isInPolygon as L}from"../../utils/tool/polygonTool.js";import I from"../../utils/uuid.js";import{PCDLoader as N}from"./PCDLoader.js";import{OrbitControls as D}from"./OrbitControls.js";import{PointCloudCache as F}from"./cache.js";import{getCuboidFromPointCloudBox as B}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"lodash";import"../../constant/keyCode.js";import"../../locales/index.js";import"../../locales/constants.js";import"../../constant/style.js";import"../../utils/tool/CanvasUtils.js";import"../../utils/tool/ZoomUtils.js";var E=Object.defineProperty,R=Object.defineProperties,U=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,A=(u,t,e)=>t in u?E(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,P=(u,t)=>{for(var e in t||(t={}))W.call(t,e)&&A(u,e,t[e]);if(T)for(var e of T(t))Z.call(t,e)&&A(u,e,t[e]);return u},M=(u,t)=>R(u,U(t)),z=(u,t,e)=>new Promise((r,n)=>{var s=o=>{try{i(e.next(o))}catch(h){n(h)}},c=o=>{try{i(e.throw(o))}catch(h){n(h)}},i=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,c);i((e=e.apply(u,t)).next())});const H=30,O=new k({type:"module"});class G{constructor({container:t,noAppend:e,isOrthographicCamera:r,orthographicParams:n,backgroundColor:s="#4C4C4C",config:c}){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:d,width:p,height:y,depth:f,rotation:C}=i,m=new a.Group,b=new a.BoxGeometry(p,y,f),x=new a.MeshBasicMaterial({color:"blue"}),v=new a.Mesh(b,x),j=new a.BoxHelper(v,o),_=this.generateBoxArrow(i);m.add(j),m.add(_),m.position.set(d.x,d.y,d.z),m.rotation.set(0,0,C),m.name=l,this.scene.add(m)},this.applyCameraTarget=i=>{if(this.camera.type==="OrthographicCamera"&&i){const o=this.getOrthographicCameraTarget(i);this.updateCameraZoom(i.zoom),this.updateCamera(i.position,o)}},this.overridePointShader=i=>{i.vertexShader=`
1
+ import*as c from"three";import{toolStyleConverter as I,PerspectiveShiftUtils as C,EPerspectiveView as y,PointCloudUtils as S}from"@labelbee/lb-utils";import k from"../../_virtual/highlightWorker.js";import V from"../../_virtual/filterBoxWorker.js";import{isInPolygon as L}from"../../utils/tool/polygonTool.js";import N from"../../utils/uuid.js";import D from"../../utils/MathUtils.js";import{PCDLoader as F}from"./PCDLoader.js";import{OrbitControls as E}from"./OrbitControls.js";import{PointCloudCache as R}from"./cache.js";import{getCuboidFromPointCloudBox as B}from"./matrix.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,lidar2image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./matrix.js";import"../../constant/tool.js";import"../scheduler.js";var W=Object.defineProperty,U=Object.defineProperties,Z=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable,A=(g,t,e)=>t in g?W(g,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):g[t]=e,P=(g,t)=>{for(var e in t||(t={}))H.call(t,e)&&A(g,e,t[e]);if(O)for(var e of O(t))G.call(t,e)&&A(g,e,t[e]);return g},M=(g,t)=>U(g,Z(t)),z=(g,t,e)=>new Promise((r,n)=>{var s=o=>{try{i(e.next(o))}catch(l){n(l)}},a=o=>{try{i(e.throw(o))}catch(l){n(l)}},i=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);i((e=e.apply(g,t)).next())});const $=30,T=new k({type:"module"});class X{constructor({container:t,noAppend:e,isOrthographicCamera:r,orthographicParams:n,backgroundColor:s="#4C4C4C",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 l;const h=(l=i.id)!=null?l:N();this.removeObjectByName(h);const{center:d,width:p,height:u,depth:x,rotation:f}=i,m=new c.Group,b=new c.BoxGeometry(p,u,x),w=new c.MeshBasicMaterial({color:"blue"}),v=new c.Mesh(b,w),_=new c.BoxHelper(v,o),j=this.generateBoxArrow(i);m.add(_),m.add(j),m.position.set(d.x,d.y,d.z),m.rotation.set(0,0,f),m.name=h,this.scene.add(m)},this.applyCameraTarget=i=>{if(this.camera.type==="OrthographicCamera"&&i){const o=this.getOrthographicCameraTarget(i);this.updateCameraZoom(i.zoom),this.updateCamera(i.position,o)}},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 a from"three";import{toolStyleConverter as S,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)=>z(this,null,function*(){this.clearPointCloud(),this.currentPCDSrc=i;const{points:h,color:l}=yield this.cacheInstance.loadPCDFile(i),d=new a.BufferGeometry;d.setAttribute("position",new a.BufferAttribute(h,3)),d.setAttribute("color",new a.BufferAttribute(l,3));const p=new a.Points(d);this.renderPointCloud(p,o)}),this.loadPCDFileByBox=(i,o,h)=>z(this,null,function*(){const l=(y,f)=>z(this,null,function*(){const{width:C=0,height:m=0,depth:b=0}=h!=null?h:{},x=yield this.filterPointsByBox(M(P({},o),{width:o.width+C,height:o.height+m,depth:o.depth+b}),y,f);if(!x){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=i;const v=new a.Points(x.geometry);v.name=this.pointCloudObjectName,this.scene.add(v),this.render()}),{points:d,color:p}=yield this.cacheInstance.loadPCDFile(i);l(d,p)}),this.generateRange=i=>{const o=this.createRange(i);this.scene.add(o)},this.generateBoxArrow=({width:i})=>{const o=new a.Vector3(1,0,0),h=new a.Vector3(i/2,0,0),l=2,d=16776960,p=new a.ArrowHelper(o,h,l,d);return p.visible=this.showDirection,p},this.generateBoxTrackID=i=>{if(!i.trackID)return;const o=new a.Texture(this.getTextCanvas(i.trackID.toString()));o.needsUpdate=!0;const h=new a.SpriteMaterial({map:o,depthWrite:!1}),l=new a.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 a.WebGLRenderer({antialias:!0}),this.backgroundColor=s,this.config=c,r&&n?(this.isOrthographicCamera=!0,this.camera=new a.OrthographicCamera(n.left,n.right,n.top,n.bottom,n.near,n.far)):this.camera=new a.PerspectiveCamera(30,this.containerWidth/this.containerHeight,1,1e3),this.initCamera(),this.scene=new a.Scene,this.controls=new D(this.camera,this.renderer.domElement),this.pcdLoader=new N,this.axesHelper=new a.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=F.getInstance()}get DEFAULT_INIT_CAMERA_POSITION(){return new a.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:c,far:i}=t;this.camera.left=e,this.camera.right=r,this.camera.top=n,this.camera.bottom=s,this.camera.near=c,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 a.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 a.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]=S.getColorFromConfig({attribute:r.attribute},M(P({},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,c=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,d=-100,p=500/l;return{left:c,right:i,top:o,bottom:h,near:l,far:d,zoom:p}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,r){const{center:n,width:s,height:c,depth:i,rotation:o}=t,h=this.getCameraVector(n,o,{width:s,height:c,depth:i},e);return r?(this.updateCamera(r,n),new a.Vector3(r.x,r.y,r.z)):(this.updateCamera(h,n),h)}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 a.Vector3(e.x,e.y,e.z),this.controls.update()}resetCamera(){this.updateCamera(this.DEFAULT_INIT_CAMERA_POSITION,{x:0,y:0,z:0})}getOrthographicCameraTarget(t){const e=new a.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new a.Matrix4().set(...t)}filterPointsByBox(t,e,r){var n,s,c;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=(c=(s=(n=i==null?void 0:i.geometry)==null?void 0:n.attributes)==null?void 0:s.position)==null?void 0:c.array}if(window.Worker){const{zMin:i,zMax:o,polygonPointList:h}=B(t),l=e;r=r!=null?r:new Float32Array([]);const d={boxParams:t,zMin:i,zMax:o,polygonPointList:h,color:r,position:l};return new Promise(p=>{const y=new V;y.postMessage(d),y.onmessage=f=>{const{color:C,position:m,num:b}=f.data,x=new a.BufferGeometry;x.setAttribute("position",new a.Float32BufferAttribute(m,3)),x.setAttribute("color",new a.Float32BufferAttribute(C,3)),x.computeBoundingSphere(),y.terminate(),p({geometry:x,num:b})}})}return Promise.resolve(void 0)}getCameraVector(t,e,r,n=g.Front,s=H){let c=w.frontViewMatrix4(s);switch(n){case g.Front:break;case g.Back:c=w.backViewMatrix4(s);break;case g.Left:c=w.leftViewMatrix4(s);break;case g.Right:c=w.rightViewMatrix4(s);break;case g.Top:c=w.topViewMatrix4(s);break;case g.LFT:c=w.leftFrontTopViewMatrix4(s,r);break;case g.RBT:c=w.rightBackTopViewMatrix4(s,r);break}const i=this.createThreeMatrix4(c),o=new a.Matrix4().makeTranslation(-t.x,-t.y,-t.z),h=new a.Matrix4().makeTranslation(t.x,t.y,t.z),l=new a.Matrix4().makeRotationZ(e);return new a.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 a.EllipseCurve(0,0,t,t,0,2*Math.PI,!1,0).getPoints(50),n=new a.BufferGeometry().setFromPoints(r),s=new a.LineBasicMaterial({color:16711680}),c=new a.Line(n,s);return c.name=this.rangeObjectName,c}renderPointCloud(t,e){t.name=this.pointCloudObjectName;const r=new a.PointsMaterial({vertexColors:!0});r.onBeforeCompile=this.overridePointShader,r.size=1.2,e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=r,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}highlightOriginPointCloud(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(!!e)return this.highlightPCDSrc=this.currentPCDSrc,new Promise(r=>{if(window.Worker){const s=(t?[...t]:[]).map(o=>B(o)),c=this.getAllAttributeColor(s),i={cuboidList:s,position:e.geometry.attributes.position.array,color:e.geometry.attributes.color.array,colorList:c};O.postMessage(i),O.onmessage=o=>{const{color:h}=o.data,l=new a.BufferAttribute(h,3);this.highlightPCDSrc&&(this.cacheInstance.updateColor(this.highlightPCDSrc,h),this.highlightPCDSrc=void 0),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 a.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,c=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],d=o[h+1],p=o[h+2];L({x:l,y:d},t)&&p&&(s=Math.max(p,s),n=Math.min(p,n),i++,e&&p>=e[0]&&p<=e[1]&&c++)}}return{maxZ:s,minZ:n,count:c,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 a.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 a.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:c,depth:i}=t,o={x:e+c/2,y:r+s/2,z:n-i/2},h={x:e+c/2,y:r+s/2,z:n+i/2},l={x:e-c/2,y:r+s/2,z:n+i/2},d={x:e-c/2,y:r+s/2,z:n-i/2};return[o,h,l,d]}getPolygonBackPoints(t){const{center:{x:e,y:r,z:n},height:s,width:c,depth:i}=t,o={x:e-c/2,y:r+s/2,z:n+i/2},h={x:e-c/2,y:r+s/2,z:n-i/2},l={x:e-c/2,y:r-s/2,z:n-i/2},d={x:e-c/2,y:r-s/2,z:n+i/2};return[o,h,l,d]}getPolygonTopPoints(t){const{center:{x:e,y:r,z:n},height:s,width:c,depth:i}=t,o={x:e+c/2,y:r+s/2,z:n+i/2},h={x:e+c/2,y:r-s/2,z:n+i/2},l={x:e-c/2,y:r-s/2,z:n+i/2},d={x:e-c/2,y:r+s/2,z:n+i/2};return[o,h,l,d]}getModelTransformationMatrix(t){const{center:{x:e,y:r,z:n},rotation:s}=t,c=new a.Matrix4().makeTranslation(-e,-r,-n),i=new a.Matrix4().makeTranslation(e,r,n),o=new a.Matrix4().makeRotationZ(s);return new a.Matrix4().multiply(i).multiply(o).multiply(c)}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,c=new a.Matrix4().premultiply(this.camera.matrixWorldInverse).premultiply(this.camera.projectionMatrix),i=new a.Matrix4().premultiply(this.getModelTransformationMatrix(t)).premultiply(c).premultiply(this.basicCoordinate2CanvasMatrix4);this.sideMatrix=i;const o=r.map(d=>new a.Vector3(d.x,d.y,d.z)).map(d=>d.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 a.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)})),c=this.containerWidth/e,i=this.containerHeight/r;return{polygon2d:s,zoom:Math.min(c,i)/2}}getNewBoxBySideUpdate(t,e,r,n){const s=new a.Matrix4().makeRotationZ(n.rotation),c=new a.Vector3(-t.x,0,0).applyMatrix4(s);let i=n;return i.center={x:i.center.x+c.x,y:i.center.y+c.y,z:i.center.z-t.z},i=M(P({},i),{width:i.width+e,height:i.height,depth:i.depth+r}),{newBoxParams:i}}getNewBoxByBackUpdate(t,e,r,n){const s=new a.Matrix4().makeRotationZ(n.rotation),c=new a.Vector3(0,-t.x,0).applyMatrix4(s);let i=n;return i.center={x:i.center.x+c.x,y:i.center.y+c.y,z:i.center.z-t.z},i=M(P({},i),{width:i.width,height:i.height+e,depth:i.depth+r}),{newBoxParams:i}}getNewBoxBySideUpdateByPoints(t,e,r,n){var s;const c=(s=this.sideMatrix)==null?void 0:s.invert();if(!this.sideMatrix||!c){console.error("No sideMatrix");return}this.camera.zoom=1,this.camera.updateProjectionMatrix();const i=t.map(m=>new a.Vector3(m.x,m.y,m.z)).map(m=>m.applyMatrix4(c)),[o,h,l,d]=i,p=Math.max(Math.abs(o.x-l.x),Math.abs(o.x-h.x)),f=h.add(d).applyMatrix3(new a.Matrix3().set(1/2,0,0,0,1/2,0,0,0,1/2)).clone().applyMatrix3(new a.Matrix3().set(-1,0,0,0,-1,0,0,0,-1)).add(new a.Vector3(n.center.x,n.center.y,n.center.z));return{newBoxParams:M(P({},n),{center:{x:n.center.x-f.x,y:n.center.y-f.y,z:n.center.z-r},width:p,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:c}=n;for(let i=0;i<c;i++){const o=n.getZ(i);s.push(o>this.zAxisLimit?0:1)}e.geometry.setAttribute("visibility",new a.Float32BufferAttribute(s,1)),e.geometry.attributes.visibility.needsUpdate=!0}}render(){this.renderer.render(this.scene,this.camera)}}export{G as PointCloud};
11
+ #include <clipping_planes_fragment>`)},this.loadPCDFile=(i,o)=>z(this,null,function*(){this.clearPointCloud(),this.currentPCDSrc=i;const{points:l,color:h}=yield this.cacheInstance.loadPCDFile(i),d=new c.BufferGeometry;d.setAttribute("position",new c.BufferAttribute(l,3)),d.setAttribute("color",new c.BufferAttribute(h,3));const p=new c.Points(d);this.renderPointCloud(p,o)}),this.loadPCDFileByBox=(i,o,l)=>z(this,null,function*(){const h=(u,x)=>z(this,null,function*(){const{width:f=0,height:m=0,depth:b=0}=l!=null?l:{},w=yield this.filterPointsByBox(M(P({},o),{width:o.width+f,height:o.height+m,depth:o.depth+b}),u,x);if(!w){console.error("filter Error");return}this.clearPointCloud(),this.currentPCDSrc=i;const v=new c.Points(w.geometry);v.name=this.pointCloudObjectName,this.scene.add(v),this.render()}),{points:d,color:p}=yield this.cacheInstance.loadPCDFile(i);h(d,p)}),this.generateRange=i=>{const o=this.createRange(i);this.scene.add(o)},this.generateBoxArrow=({width:i})=>{const o=new c.Vector3(1,0,0),l=new c.Vector3(i/2,0,0),h=2,d=16776960,p=new c.ArrowHelper(o,l,h,d);return p.visible=this.showDirection,p},this.generateBoxTrackID=i=>{if(!i.trackID)return;const o=new c.Texture(this.getTextCanvas(i.trackID.toString()));o.needsUpdate=!0;const l=new c.SpriteMaterial({map:o,depthWrite:!1}),h=new c.Sprite(l);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 l=o.material.size;i?o.material.size=Math.min(l*1.2,10):o.material.size=Math.max(l/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 E(this.camera,this.renderer.domElement),this.pcdLoader=new F,this.axesHelper=new c.AxesHelper(1e3),this.scene.add(this.camera),e||t.appendChild(this.renderer.domElement),this.init(),this.cacheInstance=R.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]=I.getColorFromConfig({attribute:r.attribute},M(P({},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,l=e.y-n/2-s,h=100,d=-100,p=500/h;return{left:a,right:i,top:o,bottom:l,near:h,far:d,zoom:p}}updateCameraZoom(t){this.camera.zoom=t,this.camera.updateProjectionMatrix()}updateCameraByBox(t,e,r){const{center:n,width:s,height:a,depth:i,rotation:o}=t,l=this.getCameraVector(n,o,{width:s,height:a,depth:i},e);return r?(this.updateCamera(r,n),new c.Vector3(r.x,r.y,r.z)):(this.updateCamera(l,n),l)}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})}getOrthographicCameraTarget(t){const e=new c.Vector3(0,0,-1).applyQuaternion(t.quaternion);return t.position.clone().add(e)}createThreeMatrix4(t){return new c.Matrix4().set(...t)}filterPointsByBox(t,e,r){var n,s,a;if(!e){const i=this.scene.getObjectByName(this.pointCloudObjectName);if(!i)return console.error("There is no corresponding point cloud object"),Promise.resolve(void 0);e=(a=(s=(n=i==null?void 0:i.geometry)==null?void 0:n.attributes)==null?void 0:s.position)==null?void 0:a.array}if(window.Worker){const{zMin:i,zMax:o,polygonPointList:l}=B(t),h=e;r=r!=null?r:new Float32Array([]);const d={boxParams:t,zMin:i,zMax:o,polygonPointList:l,color:r,position:h};return new Promise(p=>{const u=new V;u.postMessage(d),u.onmessage=x=>{const{color:f,position:m,num:b}=x.data,w=new c.BufferGeometry;w.setAttribute("position",new c.Float32BufferAttribute(m,3)),w.setAttribute("color",new c.Float32BufferAttribute(f,3)),w.computeBoundingSphere(),u.terminate(),p({geometry:w,num:b})}})}return Promise.resolve(void 0)}getCameraVector(t,e,r,n=y.Front,s=$){let a=C.frontViewMatrix4(s);switch(n){case y.Front:break;case y.Back:a=C.backViewMatrix4(s);break;case y.Left:a=C.leftViewMatrix4(s);break;case y.Right:a=C.rightViewMatrix4(s);break;case y.Top:a=C.topViewMatrix4(s);break;case y.LFT:a=C.leftFrontTopViewMatrix4(s,r);break;case y.RBT:a=C.rightBackTopViewMatrix4(s,r);break}const i=this.createThreeMatrix4(a),o=new c.Matrix4().makeTranslation(-t.x,-t.y,-t.z),l=new c.Matrix4().makeTranslation(t.x,t.y,t.z),h=new c.Matrix4().makeRotationZ(e);return new c.Vector3(t.x,t.y,t.z).clone().applyMatrix4(i).applyMatrix4(o).applyMatrix4(h).applyMatrix4(l)}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.name=this.pointCloudObjectName;const r=new c.PointsMaterial({vertexColors:!0});r.onBeforeCompile=this.overridePointShader,r.size=1.2,e&&this.generateRange(e),this.pointsUuid=t.uuid,t.material=r,this.filterZAxisPoints(t),this.scene.add(t),this.render()}clearPointCloud(){this.removeObjectByName(this.pointCloudObjectName)}clearPointCloudAndRender(){this.clearPointCloud(),this.render()}highlightOriginPointCloud(t){const e=this.scene.getObjectByName(this.pointCloudObjectName);if(!!e)return this.highlightPCDSrc=this.currentPCDSrc,new Promise(r=>{if(window.Worker){const s=(t?[...t]:[]).map(o=>B(o)),a=this.getAllAttributeColor(s),i={cuboidList:s,position:e.geometry.attributes.position.array,color:e.geometry.attributes.color.array,colorList:a};T.postMessage(i),T.onmessage=o=>{const{color:l}=o.data,h=new c.BufferAttribute(l,3);this.highlightPCDSrc&&(this.cacheInstance.updateColor(this.highlightPCDSrc,l),this.highlightPCDSrc=void 0),h.needsUpdate=!0,e.geometry.setAttribute("color",h),r(l),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}filterNoise(t){let e=[...t];e.sort((d,p)=>d.z-p.z);const r=Math.floor(e.length*.05),n=e[r];e=e.filter(({z:d})=>d>n.z+.1);const s=.005,a=Math.floor(e.length*(1-s));e=e.slice(0,a),e.sort((d,p)=>d.x-p.x);const i=Math.floor(e.length*s),o=Math.floor(e.length*(1-s));e=e.slice(i,o),e.sort((d,p)=>d.y-p.y);const l=Math.floor(e.length*s),h=Math.floor(e.length*(1-s));return e=e.slice(l,h),e.length>100?e:t}getFittedCoordinates(t,e){const r=[];let n=[...t,t[0]];e.forEach(({x:i,y:o})=>{t.forEach((l,h)=>{const d=n[h+1],p=D.getFootOfPerpendicular({x:i,y:o},l,d,!1,!0).length;(!r[h]||p<r[h].distance)&&(r[h]={distance:p,point:{x:i,y:o}})})}),n=[t[t.length-1],...t,t[0]];const s=[r[r.length-1],...r];return t.map((i,o)=>{const l=n[o],h=n[o+1],d=n[o+2];return S.getIntersectionBySlope({p1:s[o].point,k1:(l.y-h.y)/(l.x-h.x),p2:s[o+1].point,k2:(h.y-d.y)/(h.x-d.x)})})}getSensesPointZAxisInPolygon(t,e,r){const n=this.scene.children.find(p=>p.uuid===this.pointsUuid);let s=0,a=0,i=0,o=0,l=[],h=[];if(!(n==null?void 0:n.geometry))return{maxZ:a,minZ:s,count:i,zCount:o,fittedCoordinates:[]};const d=n==null?void 0:n.geometry.attributes.position.array;for(let p=0;p<d.length;p+=3){const u=d[p],x=d[p+1],f=d[p+2];L({x:u,y:x},t)&&(f||f===0)&&h.push({x:u,y:x,z:f})}return r&&(h=this.filterNoise(h),l=this.getFittedCoordinates(t,h)),h.sort((p,u)=>p.z-u.z),s=h[0].z-.01,a=h[h.length-1].z+.01,o=h.length,e&&(i=h.filter(({z:p})=>p>=e[0]&&p<=e[1]).length),{maxZ:a,minZ:s,count:i,zCount:o,fittedCoordinates:l}}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},l={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},d={x:e-a/2,y:r+s/2,z:n-i/2};return[o,l,h,d]}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},l={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},d={x:e-a/2,y:r-s/2,z:n+i/2};return[o,l,h,d]}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},l={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},d={x:e-a/2,y:r+s/2,z:n+i/2};return[o,l,h,d]}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,y.Left)}getBoxBackPolygon2DCoordinate(t){return this.getBoxPolygon2DCoordinate(t,y.Back)}boxParams2ViewPolygon(t,e){switch(e){case y.Left:return this.getPolygonSidePoints(t);case y.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(d=>new c.Vector3(d.x,d.y,d.z)).map(d=>d.applyMatrix4(this.sideMatrix)),l=this.containerWidth/n,h=this.containerHeight/s;return{polygon2d:o,zoom:Math.min(l,h)/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=M(P({},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=M(P({},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(m=>new c.Vector3(m.x,m.y,m.z)).map(m=>m.applyMatrix4(a)),[o,l,h,d]=i,p=Math.max(Math.abs(o.x-h.x),Math.abs(o.x-l.x)),x=l.add(d).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:M(P({},n),{center:{x:n.center.x-x.x,y:n.center.y-x.y,z:n.center.z-r},width:p,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{X as PointCloud};
@@ -0,0 +1,50 @@
1
+ import * as THREE from 'three';
2
+
3
+ class PointCloudSegmentOperation {
4
+ constructor(props) {
5
+ this.pointer = new THREE.Vector2();
6
+ this.onMouseMove = (e) => {
7
+ const coord = this.getCoordinate(e);
8
+ this.pointer.x = coord.x / this.dom.clientWidth * 2 - 1;
9
+ this.pointer.y = -(coord.y / this.dom.clientHeight) * 2 + 1;
10
+ this.emitRender();
11
+ };
12
+ this.dom = props.dom;
13
+ this.raycaster = new THREE.Raycaster();
14
+ this.dom.addEventListener("pointermove", this.onMouseMove);
15
+ const geometry = new THREE.BufferGeometry();
16
+ const pointsMaterial = new THREE.PointsMaterial({size: 10, color: "red"});
17
+ geometry.setAttribute("position", new THREE.BufferAttribute(new Float32Array([0, 0, 0]), 3));
18
+ this._highlight_Point = new THREE.Points(geometry, pointsMaterial);
19
+ this.emitRender = props.render;
20
+ const geometry2 = new THREE.BufferGeometry();
21
+ const pointsMaterial2 = new THREE.PointsMaterial({size: 5, color: "white"});
22
+ geometry2.setAttribute("position", new THREE.BufferAttribute(new Float32Array([0, 0, 0]), 3));
23
+ this._temp = new THREE.Points(geometry2, pointsMaterial2);
24
+ }
25
+ addMorePoint(scene) {
26
+ scene.add(this._highlight_Point);
27
+ scene.add(this._temp);
28
+ }
29
+ getCoordinate(e) {
30
+ const bounding = this.dom.getBoundingClientRect();
31
+ return {
32
+ x: e.clientX - bounding.left,
33
+ y: e.clientY - bounding.top
34
+ };
35
+ }
36
+ render({camera, scene}) {
37
+ this.raycaster.setFromCamera(this.pointer, camera);
38
+ const intersects = this.raycaster.intersectObjects(scene.children, false);
39
+ console.log("intersects", intersects[0]);
40
+ const default_Point = new THREE.Vector3(0, 0, 0);
41
+ if (intersects.length > 0) {
42
+ const intersect = intersects[0];
43
+ this._highlight_Point.position.copy(intersect.point);
44
+ } else {
45
+ this._highlight_Point.position.copy(default_Point);
46
+ }
47
+ }
48
+ }
49
+
50
+ export { PointCloudSegmentOperation };
@@ -1 +1 @@
1
- import{getConfig as f,styleDefaultConfig as y}from"../constant/defaultConfig.js";import{getCurrentOperation as L}from"../utils/tool/EnhanceCommonToolUtils.js";import{BasicToolOperation as w}from"./toolOperation/basicToolOperation.js";const v=e=>{const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");return i?(i.fillStyle="transparent",i.fillRect(0,0,e.width,e.height),t.toDataURL()):""},m=(e,t,i)=>{const o=e[t];return e[t]=e[i],e[i]=o,e},u=class{static isSingleTool(e){return!this.isHybridTool(e)}static isHybridTool(e){return Array.isArray(e)}};let g=u;g.getTopToolName=e=>u.isHybridTool(e)?e[e.length-1]:e;class T{constructor(t){this.toolOperationList=[],this.toolOperationDom=[];var i,o;this.init(),this.container=t.container,this.size=t.size,this.imgNode=t.imgNode,this.config=(i=t.config)!=null?i:JSON.stringify(f(g.getTopToolName(t.toolName))),this.style=(o=t.style)!=null?o:y}setImgNode(t,i){this.toolOperationList.forEach(o=>{o.setImgNode(t,i)})}setImgAttribute(t){this.toolOperationList.forEach(i=>{i.setImgAttribute(t)})}setSize(t){this.toolOperationList.forEach(i=>{i.setSize(t)})}syncPosition(t,i,o,n){this.toolOperationList.forEach(r=>{n!==r&&(r.setCurrentPos(t),r.setZoom(i),r.setImgInfo(o),r.renderBasicCanvas(),r.render())})}get defaultSize(){var t,i;return{width:((t=this.imgNode)==null?void 0:t.width)||this.size.width,height:((i=this.imgNode)==null?void 0:i.height)||this.size.height}}createDom(){const{width:t,height:i}=this.defaultSize,o=window.document.createElement("div");o.style.position="absolute",o.style.left="0",o.style.top="0",o.style.width=`${t}px`,o.style.height=`${i}px`;const n=this.toolOperationList.length+1;return o.style.zIndex=`${n}`,o}getEmptyImage(t,i){const o=v({width:t,height:i}),n=new Image;return n.src=o,n}createOperation(t,i,o){var n;const{width:r,height:p}=this.defaultSize,l=this.createDom(),O=this.getEmptyImage(r,p),c={container:l,size:this.size,config:(n=this==null?void 0:this.config)!=null?n:"{}",drawOutSideTarget:!1,style:this.style,imgNode:i||O,hiddenImg:!!t};o&&Object.assign(c,o);let s;if(!t)s=new w(c),l.style.zIndex="0",s.init();else{const a=L(t);if(!a)return;s=new a(c)}return s==null||s.init(),s.canvas.id=t!=null?t:"basicCanvas",s.on("dragMove",({currentPos:a,zoom:h,imgInfo:d})=>{this.syncPosition(a,h,d,s)}),s.on("renderZoom",(a,h,d)=>{a&&h&&this.syncPosition(h,a,d,s)}),t?(this.container.appendChild(l),this.toolOperationList.push(s),this.toolOperationDom.push(l),s):(this.container.insertBefore(l,this.container.childNodes[0]),this.toolOperationList.unshift(s),this.toolOperationDom.unshift(l),s)}switchLastTwoCanvas(){if(this.toolOperationDom.length<3){console.error("switchLastTwoCanvas is just used the layer which has 3 canvas");return}const t=this.toolOperationDom.length,i=t-1,o=t-2,n=this.toolOperationDom[i],r=this.toolOperationDom[o];if(!(!r||!n))return n.style.zIndex=`${i-1}`,r.style.zIndex=`${i}`,this.toolOperationList[i].clearActiveStatus(),this.toolOperationList[i].clearCursorLine(),this.toolOperationList[i].render(),this.toolOperationList=m(this.toolOperationList,i,o),this.toolOperationDom=m(this.toolOperationDom,i,o),this.toolOperationList[i]}getFirstToolOperation(){return this.toolOperationList.length>1?this.toolOperationList[1]:this.toolOperationList[0]}destroyAllLayer(){this.toolOperationList.forEach(t=>{t.destroyCanvas(),this.init()})}init(){this.toolOperationList=[],this.toolOperationDom=[]}}export{g as HybridToolUtils,T as ToolScheduler};
1
+ import{getConfig as f,styleDefaultConfig as L}from"../constant/defaultConfig.js";import{getCurrentOperation as y}from"../utils/tool/EnhanceCommonToolUtils.js";import{BasicToolOperation as D}from"./toolOperation/basicToolOperation.js";const v=e=>{const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");return i?(i.fillStyle="transparent",i.fillRect(0,0,e.width,e.height),t.toDataURL()):""},p=(e,t,i)=>{const o=e[t];return e[t]=e[i],e[i]=o,e},g=class{static isSingleTool(e){return!this.isHybridTool(e)}static isHybridTool(e){return Array.isArray(e)}};let u=g;u.getTopToolName=e=>g.isHybridTool(e)?e[e.length-1]:e;class w{constructor(t){this.toolOperationList=[],this.toolOperationDom=[],this.toolOperationNameList=[];var i,o;this.init(),this.container=t.container,this.size=t.size,this.imgNode=t.imgNode,this.config=(i=t.config)!=null?i:JSON.stringify(f(u.getTopToolName(t.toolName))),this.style=(o=t.style)!=null?o:L}setImgNode(t,i){this.toolOperationList.forEach(o=>{o.setImgNode(t,i)})}setImgAttribute(t){this.toolOperationList.forEach(i=>{i.setImgAttribute(t)})}setSize(t){this.toolOperationList.forEach(i=>{i.setSize(t)})}syncPosition(t,i,o,n){this.toolOperationList.forEach(a=>{n!==a&&(a.setCurrentPos(t),a.setZoom(i),a.setImgInfo(o),a.renderBasicCanvas(),a.render())})}get defaultSize(){var t,i;return{width:((t=this.imgNode)==null?void 0:t.width)||this.size.width,height:((i=this.imgNode)==null?void 0:i.height)||this.size.height}}createDom(){const{width:t,height:i}=this.defaultSize,o=window.document.createElement("div");o.style.position="absolute",o.style.left="0",o.style.top="0",o.style.width=`${t}px`,o.style.height=`${i}px`;const n=this.toolOperationList.length+1;return o.style.zIndex=`${n}`,o}getEmptyImage(t,i){const o=v({width:t,height:i}),n=new Image;return n.src=o,n}createOperation(t,i,o){var n;const{width:a,height:l}=this.defaultSize,r=this.createDom(),d=this.getEmptyImage(a,l),h={container:r,size:this.size,config:(n=this==null?void 0:this.config)!=null?n:"{}",drawOutSideTarget:!1,style:this.style,imgNode:i||d,hiddenImg:!!t};o&&Object.assign(h,o);let s;if(!t)s=new D(h),r.style.zIndex="0",s.init();else{const c=y(t);if(!c)return;s=new c(h)}return s==null||s.init(),s.canvas.id=t!=null?t:"basicCanvas",s.on("dragMove",({currentPos:c,zoom:m,imgInfo:O})=>{this.syncPosition(c,m,O,s)}),s.on("renderZoom",(c,m,O)=>{c&&m&&this.syncPosition(m,c,O,s)}),t?(this.container.appendChild(r),this.toolOperationList.push(s),this.toolOperationNameList.push(t),this.toolOperationDom.push(r),s):(this.container.insertBefore(r,this.container.childNodes[0]),this.toolOperationList.unshift(s),this.toolOperationDom.unshift(r),s)}switchLastTwoCanvas(){if(this.toolOperationDom.length<3){console.error("switchLastTwoCanvas is just used the layer which has 3 canvas");return}const t=this.toolOperationDom.length,i=t-1,o=t-2,n=this.toolOperationDom[i],a=this.toolOperationDom[o];if(!(!a||!n))return n.style.zIndex=`${i-1}`,a.style.zIndex=`${i}`,this.toolOperationList[i].clearActiveStatus(),this.toolOperationList[i].clearCursorLine(),this.toolOperationList[i].render(),this.toolOperationList=p(this.toolOperationList,i,o),this.toolOperationDom=p(this.toolOperationDom,i,o),this.toolOperationList[i]}getFirstToolOperation(){return this.toolOperationList.length>1?this.toolOperationList[1]:this.toolOperationList[0]}switchToCanvas(t){var i,o,n,a;const l=this.toolOperationNameList.indexOf(t);if(l<0||this.toolOperationList.length<1||l>this.toolOperationDom.length-1)return;const r=this.toolOperationDom.length-1,d=this.toolOperationDom[l],h=this.toolOperationDom[r];if(!d||!h)return;const s=h.style.zIndex;return h.style.zIndex=`${d.style.zIndex}`,d.style.zIndex=`${s}`,(o=(i=this.toolOperationList[r]).clearActiveStatus)==null||o.call(i),(a=(n=this.toolOperationList[r]).clearCursorLine)==null||a.call(n),this.toolOperationList[r].render(),this.toolOperationList=p(this.toolOperationList,r,l),this.toolOperationDom=p(this.toolOperationDom,r,l),this.toolOperationNameList=p(this.toolOperationNameList,r,l),this.toolOperationList[r]}destroyAllLayer(){this.toolOperationList.forEach(t=>{t.destroyCanvas(),this.init()})}init(){this.toolOperationList=[],this.toolOperationDom=[]}}export{u as HybridToolUtils,w as ToolScheduler};
@@ -1 +1 @@
1
- import E from"lodash";import M from"color-rgba";import c from"../../utils/tool/DrawUtils.js";import S from"../../utils/tool/AxisUtils.js";import Z from"../../utils/tool/RectUtils.js";import F from"../../utils/tool/PolygonUtils.js";import R from"../../utils/MathUtils.js";import W from"../../utils/tool/RenderDomClass.js";import{ELineTypes as C,DEFAULT_FONT as j,SEGMENT_NUMBER as U}from"../../constant/tool.js";import{DEFAULT_TEXT_OFFSET as B,TEXT_ATTRIBUTE_OFFSET as I,DEFAULT_TEXT_SHADOW as H}from"../../constant/annotation.js";import N from"../../utils/tool/ImgPosUtils.js";import{BasicToolOperation as K}from"./basicToolOperation.js";import{pointCloudLidar2image as V}from"../pointCloud/matrix.js";var X=Object.defineProperty,G=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,$=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,z=(x,t,e)=>t in x?X(x,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):x[t]=e,g=(x,t)=>{for(var e in t||(t={}))q.call(t,e)&&z(x,e,t[e]);if($)for(var e of $(t))J.call(t,e)&&z(x,e,t[e]);return x},b=(x,t)=>G(x,Y(t));const Q=3,tt=3,A="#6371FF";class et extends K{constructor(t){super(b(g({},t),{showDefaultCursor:!0}));this.style={},this.annotations=[],this.connectionPoints=[],this.getHoverRectID=o=>{var s,a;const h=this.getCoordinateUnderZoom(o),n=S.changePointByZoom(h,1/this.zoom);if(((s=this.annotations)==null?void 0:s.length)<=0||!((a=this.annotations)==null?void 0:a.length))return;let d="",i=Number.MAX_SAFE_INTEGER;for(let l=0;l<this.annotations.length;l++){const r=this.annotations[l];switch(r.type){case"rect":{const f=r.annotation;if(Z.isInRect(h,f,Q,this.zoom)){const u=f.width*f.height;u<i&&(d=f.id,i=u)}break}case"polygon":{const f=r.annotation;if(F.isInPolygon(n,f.pointList)){const u=F.getPolygonArea(f.pointList);u<i&&(d=f.id,i=u)}break}}}return d};var e;this.style=(e=t.style)!=null?e:{stroke:A,thickness:3},this.annotations=t.annotations,this.loading=!1,this.renderDomInstance=new W({container:this.container,height:this.canvas.height})}clearConnectionPoints(){this.connectionPoints=[],this.render()}checkConnectionPoints(t=this.annotations){var e,o;this.connectPointsStatus&&((o=(e=this.connectPointsStatus).close)==null||o.call(e)),this.emit("connectionPointsStatusUpdate",()=>new Promise(s=>{const{promise:a,close:h}=R.getCollectionPointByAnnotationDataPromise(t);this.connectPointsStatus={close:h},a.then(n=>{this.connectionPoints=n.connectionPoints,this.render(),this.connectPointsStatus=void 0,s({connectionPoints:n.connectionPoints})})}))}setLoading(t){this.loading=t,this.render()}onMouseLeave(){super.onMouseLeave(),this.mouseHoverID=void 0,this.emit("onChange","hover",[])}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return!0;const e=this.mouseHoverID;if(t.button===0){let o=[];e&&(o=[e]),this.emit("onChange","selected",o),this.render()}}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.mouseHoverID,o=this.getHoverRectID(t);if(e!==o){this.mouseHoverID=o;let s=[];o&&(s=[o]),this.emit("onChange","hover",s),this.render()}}updateData(t){this.annotations=t,this.render()}getSpecificStyle(t){const e=E.pick(t,["stroke","thickness","fill","radius"]),o=g(g({},this.style),e);return o.stroke&&Object.assign(o,{color:o.stroke}),o}getFontStyle(t,e){var o,s;const a=(o=t==null?void 0:t.fontSize)!=null?o:14,h=(s=t==null?void 0:t.fontFamily)!=null?s:"Arial";return b(g({},H),{color:e.stroke,font:`normal normal 600 ${a}px ${h}`})}appendOffset({x:t,y:e}){return{x:t+B.offsetX,y:e+B.offsetY}}getRenderText(t,e=!1){let o="",s="";return!t||e===!0?{headerText:o,bottomText:s}:((t==null?void 0:t.order)&&(o=`${t.order}`),(t==null?void 0:t.label)&&(o?o=`${o}_${t.label}`:o=`${t.label}`),(t==null?void 0:t.attribute)&&(o?o=`${o} ${t.attribute}`:o=`${t.attribute}`),(t==null?void 0:t.textAttribute)&&(s=t==null?void 0:t.textAttribute),{headerText:o,bottomText:s})}getReferenceOptions(t){return t?{lineCap:"butt",lineDash:[20,20]}:{}}focusPositionByPointList(t){const e=R.calcViewportBoundaries(t),o={x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top},s=N.getBasicRecPos(this.imgNode,o,this.size,.5);if(s){this.setCurrentPos(s.currentPos),this.setCurrentPosStorage(s.currentPos);const{imgInfo:a}=this,{innerZoom:h}=this.innerPosAndZoom;a&&this.setImgInfo(b(g({},a),{width:a.width/h*s.innerZoom,height:a.height/h*s.innerZoom})),this.setZoom(s.innerZoom),this.render(),this.renderBasicCanvas()}}renderConnectionPoints(){this.connectionPoints.forEach(t=>{const e=S.changePointByZoom(t,this.zoom,this.currentPos);c.drawCircleWithFill(this.canvas,e,4,{color:"#fff"}),c.drawCircleWithFill(this.canvas,e,2,{color:"#000"})})}getRenderStyle(t){const e=this.getSpecificStyle(t.annotation),o=this.getFontStyle(t.annotation,e);return{style:e,fontStyle:o}}renderLine(t){var e,o,s;if(t.type!=="line")return;const{style:a,fontStyle:h}=this.getRenderStyle(t),n=t.annotation;if(!(((e=n==null?void 0:n.pointList)==null?void 0:e.length)>=2))return;const{lineType:d=C.Line}=n,i=S.changePointListByZoom((o=n==null?void 0:n.pointList)!=null?o:[],this.zoom,this.currentPos),l=b(g(g({},a),this.getReferenceOptions(n==null?void 0:n.isReference)),{lineType:d,strokeColor:a.stroke});let r=[];if(n.showKeyPoint?r=c.drawPolygonWithKeyPoint(this.canvas,i,l):r=c.drawPolygon(this.canvas,i,l),(n==null?void 0:n.showDirection)===!0&&((s=n==null?void 0:n.pointList)==null?void 0:s.length)>=2){let v=i[0],m=R.getLineCenterPoint([i[0],i[1]]);if(d===C.Curve){const p=Math.floor(U/2);v=r[p],m=r[p+1]}c.drawArrowByCanvas(this.canvas,v,m,{color:a.stroke,thickness:a.thickness}),c.drawCircle(this.canvas,i[0],a.thickness+6,{color:a.stroke,thickness:a.thickness})}const{headerText:u,bottomText:y}=this.getRenderText(n,n==null?void 0:n.hiddenText);if(u&&c.drawText(this.canvas,this.appendOffset(i[0]),u,h),y){const v=i[i.length-1];c.drawText(this.canvas,this.appendOffset({x:v.x+I.x,y:v.y+I.y}),y,h)}}renderPolygon(t){var e,o,s,a,h;if(t.type!=="polygon")return;const{style:n,fontStyle:d}=this.getRenderStyle(t),i=t.annotation;if(!(((e=i==null?void 0:i.pointList)==null?void 0:e.length)>=3))return;const{lineType:l=C.Line}=i,r=S.changePointListByZoom((o=i==null?void 0:i.pointList)!=null?o:[],this.zoom,this.currentPos);if(i.id===this.mouseHoverID||n.fill){const p=M((a=(s=n==null?void 0:n.fill)!=null?s:n==null?void 0:n.stroke)!=null?a:A),P=`rgba(${p[0]}, ${p[1]}, ${p[2]},${p[3]*.8})`;c.drawPolygonWithFill(this.canvas,r,{color:P,lineType:l})}const f=b(g(b(g({},n),{isClose:!0}),this.getReferenceOptions(i==null?void 0:i.isReference)),{lineType:l,strokeColor:n.stroke});let u=[];if(i.showKeyPoint?u=c.drawPolygonWithKeyPoint(this.canvas,r,f):u=c.drawPolygon(this.canvas,r,f),(i==null?void 0:i.showDirection)===!0&&((h=i==null?void 0:i.pointList)==null?void 0:h.length)>=2){let p=r[0],P=R.getLineCenterPoint([r[0],r[1]]);if(l===C.Curve){const w=Math.floor(U/2);p=u[w],P=u[w+1]}c.drawArrowByCanvas(this.canvas,p,P,{color:n.stroke,thickness:n.thickness}),c.drawCircle(this.canvas,r[0],n.thickness+6,{color:n.stroke,thickness:n.thickness})}const{headerText:v,bottomText:m}=this.getRenderText(i,i==null?void 0:i.hiddenText);if(v&&c.drawText(this.canvas,this.appendOffset(r[0]),v,d),m){const p=r[r.length-1];c.drawText(this.canvas,this.appendOffset({x:p.x+I.x,y:p.y+I.y}),m,d)}}renderBox3d(t){if(t.type!=="box3d")return;const e=t.annotation,o=V(e,e.calib),s={fill:"transparent"},a=E.pick(e,["stroke","thickness"]);o.forEach((h,n)=>{const d=g(b(g({},a),{id:`${t.annotation.id}-${n}`,pointList:h.pointList}),s);switch(h.type){case"line":this.renderLine({type:"line",annotation:d});break;case"polygon":this.renderPolygon({type:"polygon",annotation:d});break}})}render(){try{if(super.render(),this.loading===!0)return;const t=this.annotations.filter(e=>e.type==="text"&&e.annotation.position==="rt").map(e=>e.annotation);this.renderDomInstance.render(t),this.annotations.forEach(e=>{var o,s,a,h,n;const d=this.getSpecificStyle(e.annotation),i=this.getFontStyle(e.annotation,d);switch(e.type){case"rect":{const l=e.annotation,{hiddenText:r=!1,isReference:f,hiddenRectSize:u=!1}=l,{zoom:y}=this,v=S.changeRectByZoom(l,this.zoom,this.currentPos),{x:m,y:p,width:P,height:w}=v;if(l.id===this.mouseHoverID||d.fill){const T=M((s=(o=d==null?void 0:d.fill)!=null?o:d==null?void 0:d.stroke)!=null?s:A),k=`rgba(${T[0]}, ${T[1]}, ${T[2]},${T[3]*.8})`;c.drawRectWithFill(this.canvas,v,{color:k})}c.drawRect(this.canvas,v,g(b(g({},d),{hiddenText:!0}),this.getReferenceOptions(f)));const{headerText:D,bottomText:O}=this.getRenderText(l,l==null?void 0:l.hiddenText);D&&c.drawText(this.canvas,{x:m,y:p-6},D,g({textMaxWidth:300},i));const _=`${Math.round(P/y)} * ${Math.round(w/y)}`,L=_.length*7;if(!r&&!u&&c.drawText(this.canvas,{x:m+P-L,y:p+w+15},_,i),O){const T=20,k=Math.max(20,P-L);c.drawText(this.canvas,{x:m,y:p+w+T},l.textAttribute,g({textMaxWidth:k},i))}break}case"polygon":{this.renderPolygon(e);break}case"line":{this.renderLine(e);break}case"point":{const l=e.annotation,r=S.changePointByZoom(l,this.zoom,this.currentPos),f=(a=d.radius)!=null?a:tt;c.drawCircle(this.canvas,r,f,d);const{headerText:u,bottomText:y}=this.getRenderText(l,l==null?void 0:l.hiddenText);u&&c.drawText(this.canvas,{x:r.x+f/2,y:r.y-f-4},u,g({textAlign:"center"},i)),y&&c.drawText(this.canvas,this.appendOffset({x:r.x+f,y:r.y+f+24}),y,i);break}case"text":{const l=e.annotation,{text:r,x:f,y:u,textMaxWidth:y,color:v="white",background:m="rgba(0, 0, 0, 0.6)",lineHeight:p=25,font:P=j,position:w}=l,D=10,O=10,_=S.changePointByZoom({x:f,y:u},this.zoom,this.currentPos),{width:L,height:T,fontHeight:k=0}=R.getTextArea(this.canvas,l.text,y,P,p);if(w==="rt")break;c.drawRectWithFill(this.canvas,{x:_.x,y:_.y,width:L+O*2,height:T+D*2,id:"",sourceID:"",valid:!0,textAttribute:"",attribute:""},{color:m}),c.drawText(this.canvas,{x:_.x+O,y:_.y+k+D},r,{color:v,lineHeight:p,font:P,textMaxWidth:y});break}case"box3d":{this.renderBox3d(e);break}default:break}(n=(h=e.annotation)==null?void 0:h.renderEnhance)==null||n.call(h,{ctx:this.ctx,canvas:this.canvas,currentPos:this.currentPos,zoom:this.zoom,data:e,toolInstance:this})}),this.renderConnectionPoints()}catch(t){console.error("ViewOperation Render Error",t)}}}export{et as default};
1
+ import $ from"lodash";import M from"color-rgba";import h from"../../utils/tool/DrawUtils.js";import _ from"../../utils/tool/AxisUtils.js";import W from"../../utils/tool/RectUtils.js";import E from"../../utils/tool/PolygonUtils.js";import O from"../../utils/MathUtils.js";import Z from"../../utils/tool/RenderDomClass.js";import{ELineTypes as L,DEFAULT_FONT as j,SEGMENT_NUMBER as U}from"../../constant/tool.js";import{DEFAULT_TEXT_OFFSET as F,TEXT_ATTRIBUTE_OFFSET as A,DEFAULT_TEXT_SHADOW as H}from"../../constant/annotation.js";import N from"../../utils/tool/ImgPosUtils.js";import{BasicToolOperation as K}from"./basicToolOperation.js";import{pointCloudLidar2image as V}from"../pointCloud/matrix.js";import X from"../../utils/tool/AttributeUtils.js";import{getCuboidTextAttributeOffset as G}from"../../utils/tool/CuboidUtils.js";var Y=Object.defineProperty,q=Object.defineProperties,J=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable,z=(w,t,e)=>t in w?Y(w,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):w[t]=e,v=(w,t)=>{for(var e in t||(t={}))Q.call(t,e)&&z(w,e,t[e]);if(B)for(var e of B(t))tt.call(t,e)&&z(w,e,t[e]);return w},S=(w,t)=>q(w,J(t));const et=3,ot=3,I="#6371FF";class nt extends K{constructor(t){super(S(v({},t),{showDefaultCursor:!0}));this.style={},this.annotations=[],this.connectionPoints=[],this.getHoverRectID=o=>{var r,a;const c=this.getCoordinateUnderZoom(o),n=_.changePointByZoom(c,1/this.zoom);if(((r=this.annotations)==null?void 0:r.length)<=0||!((a=this.annotations)==null?void 0:a.length))return;let d="",i=Number.MAX_SAFE_INTEGER;for(let l=0;l<this.annotations.length;l++){const s=this.annotations[l];switch(s.type){case"rect":{const u=s.annotation;if(W.isInRect(c,u,et,this.zoom)){const f=u.width*u.height;f<i&&(d=u.id,i=f)}break}case"polygon":{const u=s.annotation;if(E.isInPolygon(n,u.pointList)){const f=E.getPolygonArea(u.pointList);f<i&&(d=u.id,i=f)}break}}}return d};var e;this.style=(e=t.style)!=null?e:{stroke:I,thickness:3},this.annotations=t.annotations,this.loading=!1,this.renderDomInstance=new Z({container:this.container,height:this.canvas.height})}clearConnectionPoints(){this.connectionPoints=[],this.render()}checkConnectionPoints(t=this.annotations){var e,o;this.connectPointsStatus&&((o=(e=this.connectPointsStatus).close)==null||o.call(e)),this.emit("connectionPointsStatusUpdate",()=>new Promise(r=>{const{promise:a,close:c}=O.getCollectionPointByAnnotationDataPromise(t);this.connectPointsStatus={close:c},a.then(n=>{this.connectionPoints=n.connectionPoints,this.render(),this.connectPointsStatus=void 0,r({connectionPoints:n.connectionPoints})})}))}setLoading(t){this.loading=t,this.render()}onMouseLeave(){super.onMouseLeave(),this.mouseHoverID=void 0,this.emit("onChange","hover",[])}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||!this.imgInfo)return!0;const e=this.mouseHoverID;if(t.button===0){let o=[];e&&(o=[e]),this.emit("onChange","selected",o),this.render()}}onMouseMove(t){if(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)return;const e=this.mouseHoverID,o=this.getHoverRectID(t);if(e!==o){this.mouseHoverID=o;let r=[];o&&(r=[o]),this.emit("onChange","hover",r),this.render()}}updateData(t){this.annotations=t,this.render()}getSpecificStyle(t){const e=$.pick(t,["stroke","thickness","fill","radius"]),o=v(v({},this.style),e);return o.stroke&&Object.assign(o,{color:o.stroke}),o}getFontStyle(t,e){var o,r;const a=(o=t==null?void 0:t.fontSize)!=null?o:14,c=(r=t==null?void 0:t.fontFamily)!=null?r:"Arial";return S(v({},H),{color:e.stroke,font:`normal normal 600 ${a}px ${c}`})}appendOffset({x:t,y:e}){return{x:t+F.offsetX,y:e+F.offsetY}}getRenderText(t,e=!1){let o="",r="";return!t||e===!0?{headerText:o,bottomText:r}:((t==null?void 0:t.order)&&(o=`${t.order}`),(t==null?void 0:t.label)&&(o?o=`${o}_${t.label}`:o=`${t.label}`),(t==null?void 0:t.attribute)&&(o?o=`${o} ${t.attribute}`:o=`${t.attribute}`),(t==null?void 0:t.textAttribute)&&(r=t==null?void 0:t.textAttribute),{headerText:o,bottomText:r})}getReferenceOptions(t){return t?{lineCap:"butt",lineDash:[20,20]}:{}}focusPositionByPointList(t){const e=O.calcViewportBoundaries(t),o={x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top},r=N.getBasicRecPos(this.imgNode,o,this.size,.5);if(r){this.setCurrentPos(r.currentPos),this.setCurrentPosStorage(r.currentPos);const{imgInfo:a}=this,{innerZoom:c}=this.innerPosAndZoom;a&&this.setImgInfo(S(v({},a),{width:a.width/c*r.innerZoom,height:a.height/c*r.innerZoom})),this.setZoom(r.innerZoom),this.render(),this.renderBasicCanvas()}}renderConnectionPoints(){this.connectionPoints.forEach(t=>{const e=_.changePointByZoom(t,this.zoom,this.currentPos);h.drawCircleWithFill(this.canvas,e,4,{color:"#fff"}),h.drawCircleWithFill(this.canvas,e,2,{color:"#000"})})}getRenderStyle(t){const e=this.getSpecificStyle(t.annotation),o=this.getFontStyle(t.annotation,e);return{style:e,fontStyle:o}}renderLine(t){var e,o,r;if(t.type!=="line")return;const{style:a,fontStyle:c}=this.getRenderStyle(t),n=t.annotation;if(!(((e=n==null?void 0:n.pointList)==null?void 0:e.length)>=2))return;const{lineType:d=L.Line}=n,i=_.changePointListByZoom((o=n==null?void 0:n.pointList)!=null?o:[],this.zoom,this.currentPos),l=S(v(v({},a),this.getReferenceOptions(n==null?void 0:n.isReference)),{lineType:d,strokeColor:a.stroke});let s=[];if(n.showKeyPoint?s=h.drawPolygonWithKeyPoint(this.canvas,i,l):s=h.drawPolygon(this.canvas,i,l),(n==null?void 0:n.showDirection)===!0&&((r=n==null?void 0:n.pointList)==null?void 0:r.length)>=2){let g=i[0],y=O.getLineCenterPoint([i[0],i[1]]);if(d===L.Curve){const p=Math.floor(U/2);g=s[p],y=s[p+1]}h.drawArrowByCanvas(this.canvas,g,y,{color:a.stroke,thickness:a.thickness}),h.drawCircle(this.canvas,i[0],a.thickness+6,{color:a.stroke,thickness:a.thickness})}const{headerText:f,bottomText:m}=this.getRenderText(n,n==null?void 0:n.hiddenText);if(f&&h.drawText(this.canvas,this.appendOffset(i[0]),f,c),m){const g=i[i.length-1];h.drawText(this.canvas,this.appendOffset({x:g.x+A.x,y:g.y+A.y}),m,c)}}renderPolygon(t){var e,o,r,a,c;if(t.type!=="polygon")return;const{style:n,fontStyle:d}=this.getRenderStyle(t),i=t.annotation;if(!(((e=i==null?void 0:i.pointList)==null?void 0:e.length)>=3))return;const{lineType:l=L.Line}=i,s=_.changePointListByZoom((o=i==null?void 0:i.pointList)!=null?o:[],this.zoom,this.currentPos);if(i.id===this.mouseHoverID||n.fill){const p=M((a=(r=n==null?void 0:n.fill)!=null?r:n==null?void 0:n.stroke)!=null?a:I),x=`rgba(${p[0]}, ${p[1]}, ${p[2]},${p[3]*.8})`;h.drawPolygonWithFill(this.canvas,s,{color:x,lineType:l})}const u=S(v(S(v({},n),{isClose:!0}),this.getReferenceOptions(i==null?void 0:i.isReference)),{lineType:l,strokeColor:n.stroke});let f=[];if(i.showKeyPoint?f=h.drawPolygonWithKeyPoint(this.canvas,s,u):f=h.drawPolygon(this.canvas,s,u),(i==null?void 0:i.showDirection)===!0&&((c=i==null?void 0:i.pointList)==null?void 0:c.length)>=2){let p=s[0],x=O.getLineCenterPoint([s[0],s[1]]);if(l===L.Curve){const P=Math.floor(U/2);p=f[P],x=f[P+1]}h.drawArrowByCanvas(this.canvas,p,x,{color:n.stroke,thickness:n.thickness}),h.drawCircle(this.canvas,s[0],n.thickness+6,{color:n.stroke,thickness:n.thickness})}const{headerText:g,bottomText:y}=this.getRenderText(i,i==null?void 0:i.hiddenText);if(g&&h.drawText(this.canvas,this.appendOffset(s[0]),g,d),y){const p=s[s.length-1];h.drawText(this.canvas,this.appendOffset({x:p.x+A.x,y:p.y+A.y}),y,d)}}renderSingleCuboid(t){var e,o,r,a;const{style:c}=this.getRenderStyle(t),n=t.annotation,d=M((o=(e=c==null?void 0:c.fill)!=null?e:c==null?void 0:c.stroke)!=null?o:I),i=`rgba(${d[0]}, ${d[1]}, ${d[2]},${d[3]*.8})`,l=c.stroke,s=_.changeCuboidByZoom(n,this.zoom,this.currentPos),u=l,{headerText:f,bottomText:m}=this.getRenderText(n,n==null?void 0:n.hiddenText),{backPoints:g,frontPoints:y,textAttribute:p}=s,x=y.br.x-y.bl.x;h.drawCuboid(this.canvas,s,{strokeColor:l,fillColor:i,thickness:c.thickness});let P="";((r=this.config)==null?void 0:r.isShowOrder)&&s.order&&(s==null?void 0:s.order)>0&&(P=`${s.order}`),s.attribute&&(P=`${P} ${X.getAttributeShowText(s.attribute,(a=this.config)==null?void 0:a.attributeList)}`),f&&g&&h.drawText(this.canvas,{x:g.tl.x,y:g.tl.y-5},P,{color:l,textMaxWidth:300});const b=G({cuboid:n,currentPos:this.currentPos,zoom:this.zoom,topOffset:16,leftOffset:0});if(m){const C=Math.max(20,x*.8);h.drawText(this.canvas,{x:b.left,y:b.top},p,{color:u,textMaxWidth:C})}}renderBox3d(t){if(t.type!=="box3d")return;const e=t.annotation,o=V(e,e.calib),r={fill:"transparent"},a=$.pick(e,["stroke","thickness"]);o.forEach((c,n)=>{const d=v(S(v({},a),{id:`${t.annotation.id}-${n}`,pointList:c.pointList}),r);switch(c.type){case"line":this.renderLine({type:"line",annotation:d});break;case"polygon":this.renderPolygon({type:"polygon",annotation:d});break}})}render(){try{if(super.render(),this.loading===!0)return;const t=this.annotations.filter(e=>e.type==="text"&&e.annotation.position==="rt").map(e=>e.annotation);this.renderDomInstance.render(t),this.annotations.forEach(e=>{var o,r,a,c,n;const d=this.getSpecificStyle(e.annotation),i=this.getFontStyle(e.annotation,d);switch(e.type){case"rect":{const l=e.annotation,{hiddenText:s=!1,isReference:u,hiddenRectSize:f=!1}=l,{zoom:m}=this,g=_.changeRectByZoom(l,this.zoom,this.currentPos),{x:y,y:p,width:x,height:P}=g;if(l.id===this.mouseHoverID||d.fill){const T=M((r=(o=d==null?void 0:d.fill)!=null?o:d==null?void 0:d.stroke)!=null?r:I),D=`rgba(${T[0]}, ${T[1]}, ${T[2]},${T[3]*.8})`;h.drawRectWithFill(this.canvas,g,{color:D})}h.drawRect(this.canvas,g,v(S(v({},d),{hiddenText:!0}),this.getReferenceOptions(u)));const{headerText:b,bottomText:C}=this.getRenderText(l,l==null?void 0:l.hiddenText);b&&h.drawText(this.canvas,{x:y,y:p-6},b,v({textMaxWidth:300},i));const k=`${Math.round(x/m)} * ${Math.round(P/m)}`,R=k.length*7;if(!s&&!f&&h.drawText(this.canvas,{x:y+x-R,y:p+P+15},k,i),C){const T=20,D=Math.max(20,x-R);h.drawText(this.canvas,{x:y,y:p+P+T},l.textAttribute,v({textMaxWidth:D},i))}break}case"polygon":{this.renderPolygon(e);break}case"line":{this.renderLine(e);break}case"point":{const l=e.annotation,s=_.changePointByZoom(l,this.zoom,this.currentPos),u=(a=d.radius)!=null?a:ot;h.drawCircle(this.canvas,s,u,d);const{headerText:f,bottomText:m}=this.getRenderText(l,l==null?void 0:l.hiddenText);f&&h.drawText(this.canvas,{x:s.x+u/2,y:s.y-u-4},f,v({textAlign:"center"},i)),m&&h.drawText(this.canvas,this.appendOffset({x:s.x+u,y:s.y+u+24}),m,i);break}case"text":{const l=e.annotation,{text:s,x:u,y:f,textMaxWidth:m,color:g="white",background:y="rgba(0, 0, 0, 0.6)",lineHeight:p=25,font:x=j,position:P}=l,b=10,C=10,k=_.changePointByZoom({x:u,y:f},this.zoom,this.currentPos),{width:R,height:T,fontHeight:D=0}=O.getTextArea(this.canvas,l.text,m,x,p);if(P==="rt")break;h.drawRectWithFill(this.canvas,{x:k.x,y:k.y,width:R+C*2,height:T+b*2,id:"",sourceID:"",valid:!0,textAttribute:"",attribute:""},{color:y}),h.drawText(this.canvas,{x:k.x+C,y:k.y+D+b},s,{color:g,lineHeight:p,font:x,textMaxWidth:m});break}case"box3d":{this.renderBox3d(e);break}case"cuboid":{this.renderSingleCuboid(e);break}default:break}(n=(c=e.annotation)==null?void 0:c.renderEnhance)==null||n.call(c,{ctx:this.ctx,canvas:this.canvas,currentPos:this.currentPos,zoom:this.zoom,data:e,toolInstance:this})}),this.renderConnectionPoints()}catch(t){console.error("ViewOperation Render Error",t)}}}export{nt as default};
@@ -1 +1 @@
1
- import{isNumber as x}from"lodash";import{styleDefaultConfig as N}from"../../constant/defaultConfig.js";import{EOperationMode as y,EToolName as b}from"../../constant/tool.js";import S from"../../utils/MathUtils.js";import w,{CoordinateUtils as j}from"../../utils/tool/AxisUtils.js";import T from"../../utils/tool/CanvasUtils.js";import P from"../../utils/tool/CommonToolUtils.js";import K from"../../utils/tool/LineToolUtils.js";import{EGrowthMode as W,EDragStatus as G,ELang as H}from"../../constant/annotation.js";import I from"../../constant/keyCode.js";import{COLORS_ARRAY as M,styleString as F,BASE_ICON as V}from"../../constant/style.js";import R from"../../locales/index.js";import{EMessage as k}from"../../locales/constants.js";import Y from"../../utils/ActionsHistory.js";import z from"../../utils/tool/AttributeUtils.js";import $ from"../../utils/tool/DblClickEventListener.js";import g from"../../utils/tool/DrawUtils.js";import E from"../../utils/tool/ImgPosUtils.js";import X from"../../utils/tool/RenderDomUtils.js";import U from"../../utils/tool/ZoomUtils.js";import q from"./eventListener.js";var J=Object.defineProperty,Q=Object.defineProperties,tt=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable,O=(l,t,i)=>t in l?J(l,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):l[t]=i,Z=(l,t)=>{for(var i in t||(t={}))it.call(t,i)&&O(l,i,t[i]);if(B)for(var i of B(t))et.call(t,i)&&O(l,i,t[i]);return l},st=(l,t)=>Q(l,tt(t)),ot=(l,t,i)=>new Promise((e,s)=>{var o=a=>{try{n(i.next(a))}catch(h){s(h)}},r=a=>{try{n(i.throw(a))}catch(h){s(h)}},n=a=>a.done?e(a.value):Promise.resolve(a.value).then(o,r);n((i=i.apply(l,t)).next())});const p={min:.2,max:1e3,ratio:.4};class rt extends q{constructor(t){super();this.isDrag=!1,this.isSpaceKey=!1,this.operationMode=y.General,this.innerZoom=1,this.basicZoom=.01,this.isSpaceClick=!1,this.isDragStart=!1,this.startTime=0,this.initImgPos=()=>ot(this,null,function*(){var c,d;if(!this.imgNode)return;const u=(c=this._imgAttribute)==null?void 0:c.zoomRatio,m=(d=this._imgAttribute)==null?void 0:d.isOriginalSize,{currentPos:f,imgInfo:C,zoom:v}=E.getInitImgPos(this.size,{width:this.imgNode.width,height:this.imgNode.height},this.rotate,u,m);this.setCurrentPos(f),this.currentPosStorage=f,this.setImgInfo(C),this.setZoom(v),this.render(),this.renderBasicCanvas(),this.emit("dependRender"),this.emit("renderZoom",v,f,C)}),this.getCurrentPos=c=>{const{_firstClickCoordinate:d,currentPosStorage:u}=this;try{let m;return d&&u?m={y:u.y+c.y-d.y,x:u.x+c.x-d.x}:m={x:0,y:0},m}catch(m){return console.error(m),{x:0,y:0}}},this.wheelChangePos=(c,d,u)=>{const{currentPos:m,imgNode:f}=this;if(!f){console.error("unable to load image");return}if(this.zoom===this.basicZoom&&d===-1)return;const C=U.wheelChangePos(f,c,d,m,{zoom:u||this.zoom,innerZoom:this.innerZoom,basicZoom:this.basicZoom,zoomMax:p.max,rotate:this.rotate});if(!C)return;const{currentPos:v,ratio:A,zoom:D,imgInfo:_}=C;this.setZoom(D),this.setCurrentPos(v),this.currentPosStorage=v,this.setImgInfo(_),p.ratio=A,this.emit("renderZoom",D,v,_)},this.zoomChanged=(c,d=W.Linear)=>{const u=U.zoomChanged(this.zoom,c,d);this.wheelChangePos(this.getGetCenterCoordinate(),u>this.zoom?1:-1,u),this.render(),this.renderBasicCanvas()},this.zoomChangeOnCenter=c=>{this.wheelChangePos(this.getGetCenterCoordinate(),0,c),this.render(),this.renderBasicCanvas()},this.drawImg=()=>{!this.imgNode||this.hiddenImg===!0||g.drawImg(this.basicCanvas,this.imgNode,{zoom:this.zoom,currentPos:this.currentPos,rotate:this.rotate,imgAttribute:this._imgAttribute})};var i,e,s,o,r,n,a,h,L;this.container=t.container,this.config=P.jsonParser(t.config),this.showDefaultCursor=t.showDefaultCursor||!1,this.destroyCanvas(),this.createCanvas(t.size,t.isAppend),this.imgNode=t.imgNode,this.isImgError=!t.imgNode,this.basicImgInfo={width:(e=(i=t.imgNode)==null?void 0:i.width)!=null?e:0,height:(o=(s=t.imgNode)==null?void 0:s.height)!=null?o:0,valid:!0,rotate:0},this.forbidOperation=(r=t.forbidOperation)!=null?r:!1,this.forbidBasicResultRender=(n=t.forbidBasicResultRender)!=null?n:!1,this.size=t.size,this.currentPos={x:0,y:0},this.zoom=1,this.coord={x:-1,y:-1},this.currentPosStorage={x:0,y:0},this.isShowCursor=!1,this.style={strokeColor:M[4],fillColor:M[4],strokeWidth:2,opacity:1},this.attributeLockList=[],this.history=new Y,this.style=(a=t.style)!=null?a:P.jsonParser(F),this._imgAttribute=(h=t.imgAttribute)!=null?h:{},this.isHidden=!1,this.dragStatus=G.Wait,this.defaultAttribute=(L=t==null?void 0:t.defaultAttribute)!=null?L:"",this.forbidCursorLine=!!t.forbidCursorLine,this.lang=H.Zh,this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onWheel=this.onWheel.bind(this),this.onLeftDblClick=this.onLeftDblClick.bind(this),this.onRightDblClick=this.onRightDblClick.bind(this),this.onClick=this.onClick.bind(this),this.clearImgDrag=this.clearImgDrag.bind(this),this.dblClickListener=new $(this.container,200),this.coordUtils=new j(this),this.coordUtils.setBasicImgInfo(this.basicImgInfo),this.hiddenImg=t.hiddenImg||!1}onContextmenu(t){t.preventDefault()}get ctx(){var t;return this._ctx||((t=this.canvas)==null?void 0:t.getContext("2d"))}get basicCtx(){var t;return(t=this.basicCanvas)==null?void 0:t.getContext("2d")}get rotate(){var t,i;return(i=(t=this.basicImgInfo)==null?void 0:t.rotate)!=null?i:0}get valid(){var t,i;return(i=(t=this.basicImgInfo)==null?void 0:t.valid)!=null?i:!0}get baseIcon(){return V[this.style.color]}get defaultCursor(){return this.showDefaultCursor?"default":"none"}get dataList(){return[]}get innerPosAndZoom(){return{innerZoom:this.innerZoom,currentPosStorage:this.currentPosStorage}}get isShowDefaultCursor(){return this.showDefaultCursor}get isMultiMoveMode(){return this.operationMode===y.MultiMove}get hasMarkerConfig(){return this.config.markerConfigurable===!0&&this.config.markerList&&this.config.markerList.length>0}setZoom(t){this.zoom=t,this.innerZoom=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}setCurrentPos(t){this.currentPos=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}setReferenceData(t){this.referenceData=t}setImgInfo(t){this.imgInfo=t}setCurrentPosStorage(t){this.currentPosStorage=t}setOperationMode(t){this.operationMode=t}recoverOperationMode(){this.operationMode===y.MultiMove&&this.setOperationMode(y.General)}updatePosition(t){const{zoom:i,currentPos:e}=t;this.setZoom(i),this.setCurrentPos(e),this.currentPosStorage=e,this.renderBasicCanvas(),this.render()}setLang(t){this.lang=t}setShowDefaultCursor(t){this.showDefaultCursor=t,this.container.style.cursor=this.defaultCursor}setCustomCursor(t){this.container.style.cursor=t}get forbidMouseOperation(){return this.forbidOperation||this.valid===!1}get pixelRatio(){var t;return T.getPixelRatio((t=this.canvas)==null?void 0:t.getContext("2d"))}init(){this.eventUnbinding(),this.initPosition(),this.eventBinding(),this.render(),this.renderBasicCanvas()}destroy(){this.destroyCanvas(),this.eventUnbinding()}updateCanvasBasicStyle(t,i,e){const s=this.pixelRatio;t.style.position="absolute",t.width=i.width*s,t.height=i.height*s,t.style.width=`${i.width}px`,t.style.height=`${i.height}px`,t.style.left="0",t.style.top="0",t.style.zIndex=`${e} `}createCanvas(t,i=!0){var e,s;const o=this.pixelRatio,r=document.createElement("canvas");this.updateCanvasBasicStyle(r,t,0),this.basicCanvas=r;const n=document.createElement("canvas");this.updateCanvasBasicStyle(n,t,10),i&&(this.container.hasChildNodes()?(this.container.insertBefore(n,this.container.childNodes[0]),this.container.insertBefore(r,this.container.childNodes[0])):(this.container.appendChild(r),this.container.appendChild(n))),this.canvas=n,this.container.style.cursor=this.defaultCursor,(e=this.ctx)==null||e.scale(o,o),(s=this.basicCtx)==null||s.scale(o,o)}destroyCanvas(){this.canvas&&this.container.contains(this.canvas)&&this.container.removeChild(this.canvas),this.basicCanvas&&this.container.contains(this.basicCanvas)&&this.container.removeChild(this.basicCanvas),this.clearInvalidPage(),this.clearImgDrag()}setStyle(t){this.style=t,this.render()}setImgNode(t,i={}){this.imgNode=t,this.setBasicImgInfo(Z({width:t.width,height:t.height,valid:!0,rotate:0},i)),this.isImgError===!0&&(this.isImgError=!1,this.emit("changeAnnotationShow")),typeof i.valid=="boolean"&&this.setValid(i.valid),this.initImgPos(),this.render(),this.renderBasicCanvas()}setErrorImg(){const t=this.isImgError;this.isImgError=!0,this.imgNode=void 0,this.setBasicImgInfo({width:0,height:0,valid:!0,rotate:0}),t===!1&&this.emit("changeAnnotationShow")}setBasicImgInfo(t){this.basicImgInfo=t,this.coordUtils.setBasicImgInfo(t)}setForbidOperation(t){this.forbidOperation=t,this.setShowDefaultCursor(t),this.render()}setForbidCursorLine(t){this.forbidCursorLine=t,this.render()}setIsHidden(t){this.isHidden=t,this.emit("hiddenChange")}setIsShowOrder(t){this.config.isShowOrder=t,this.render()}getCoordinate(t){const i=this.canvas.getBoundingClientRect();return{x:t.clientX-i.left,y:t.clientY-i.top}}getCoordinateUnderZoom(t){const i=this.canvas.getBoundingClientRect();return{x:t.clientX-i.left-this.currentPos.x,y:t.clientY-i.top-this.currentPos.y}}getCoordinateUnderZoomByRotate(t){const{x:i,y:e}=this.getCoordinateUnderZoom(t);return this.basicImgInfo.rotate===90?{x:e,y:this.basicImgInfo.height*this.zoom-i}:this.basicImgInfo.rotate===180?{x:this.basicImgInfo.width*this.zoom-i,y:this.basicImgInfo.height*this.zoom-e}:this.basicImgInfo.rotate===270?{x:this.basicImgInfo.width*this.zoom-e,y:i}:{x:i,y:e}}getGetCenterCoordinate(){return{x:this.size.width/2,y:this.size.height/2}}initPosition(){if(this.basicResult&&this.imgInfo){const{basicResult:t,size:i,imgNode:e,_imgAttribute:s,imgInfo:o,dependToolName:r}=this;if(t&&e&&r){let n=t;switch(r){case b.Polygon:case b.Line:{if(t.pointList){const h=S.calcViewportBoundaries(t.pointList);n={x:h.left,y:h.top,width:h.right-h.left,height:h.bottom-h.top}}break}}const a=E.getBasicRecPos(e,n,i,void 0,s==null?void 0:s.zoomRatio,s==null?void 0:s.isOriginalSize);a&&(this.setCurrentPos(a.currentPos),this.currentPosStorage=this.currentPos,this.setImgInfo(st(Z({},o),{width:o.width/this.innerZoom*a.innerZoom,height:o.height/this.innerZoom*a.innerZoom})),this.setZoom(a.innerZoom),this.render(),this.renderBasicCanvas())}}else this.initImgPos()}undo(){this.history.undo()}redo(){this.history.redo()}clearCanvas(){var t;(t=this.ctx)==null||t.clearRect(0,0,this.size.width,this.size.height)}clearBasicCanvas(){var t;(t=this.basicCtx)==null||t.clearRect(0,0,this.size.width,this.size.height)}eventBinding(){this.dblClickListener.addEvent(()=>{},this.onLeftDblClick,this.onRightDblClick),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseleave",this.onMouseLeave),this.container.addEventListener("click",this.onClick),this.container.addEventListener("wheel",this.onWheel),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.onKeyUp),window.parent.document.addEventListener("contextmenu",this.onContextmenu,!1)}eventUnbinding(){this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.removeEventListener("mouseleave",this.onMouseLeave),this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("click",this.onClick),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),window.parent.document.removeEventListener("contextmenu",this.onContextmenu,!1),this.dblClickListener.removeEvent()}clearImgDrag(){this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime=0,this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1}clearCursorLine(){this.coord={x:-1,y:-1}}onMouseDown(t){if(!this.canvas||this.isImgError)return!0;const i=this.getCoordinate(t);(this.isSpaceKey&&t.button===0||t.button===2)&&(t.stopPropagation(),this._firstClickCoordinate=i,this.currentPosStorage=this.currentPos,this.isSpaceClick=!0,this.isDragStart=!0,this.startTime=new Date().getTime())}onMouseMove(t){if(!this.canvas||this.isImgError)return!0;const i=this.getCoordinate(t);this.isShowCursor&&(this.coord=i);try{if(!i||!x(i==null?void 0:i.x)||!x(i==null?void 0:i.y))throw new Error("coord error");if(this.coord=i,(this.isSpaceClick||this.isDragStart)&&this._firstClickCoordinate){const e=this.getCurrentPos(i);this.setCurrentPos(e),this.isDrag=!0,this.container.style.cursor="grabbing",this.forbidCursorLine=!0,this.renderBasicCanvas(),this.emit("dependRender"),this.emit("dragMove",{currentPos:e,zoom:this.zoom,imgInfo:this.imgInfo})}this.render()}catch(e){console.error(e)}}onMouseUp(t){if(!this.canvas||this.isImgError)return!0;if(this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1,this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime!==0&&this._firstClickCoordinate){const i=new Date().getTime(),e=this.getCoordinate(t);if(i-this.startTime>1e3||this.isSpaceKey===!0||K.calcTwoPointDistance(e,this._firstClickCoordinate)>10)return t.stopPropagation(),this.startTime=0,this.render(),!0}this.startTime=0,this.render()}onMouseLeave(){this.clearImgDrag()}onClick(t){}onLeftDblClick(t){}onRightDblClick(t){this.clearImgDrag()}onKeyDown(t){switch(t.keyCode===I.Alt&&t.preventDefault(),t.keyCode){case I.Space:this.isSpaceKey=!0;break;case I.Z:if(t.ctrlKey)return t.shiftKey?this.redo():this.undo(),!1;break}return!0}onKeyUp(t){switch(t.keyCode){case I.Space:this.isSpaceKey=!1;break}}exportCustomData(){return{}}onWheel(t,i=!0){if(!this.imgNode||!this.coord)return;t.preventDefault(),t.stopPropagation();const e=this.getCoordinate(t),s=t.deltaY||t.wheelDelta;let o=0;s>0&&this.zoom>p.min&&(o=-1),s<0&&this.zoom<p.max&&(o=1),this.wheelChangePos(e,o),this.emit("dependRender"),i&&this.render(),this.renderBasicCanvas()}renderCursorLine(t=(i=>(i=this.style.lineColor[0])!=null?i:"")()){if(!this.ctx||this.forbidCursorLine||this.forbidOperation)return;const{x:i,y:e}=this.coord;g.drawLine(this.canvas,{x:0,y:e},{x:1e4,y:e},{color:t}),g.drawLine(this.canvas,{x:i,y:0},{x:i,y:1e4},{color:t}),g.drawCircleWithFill(this.canvas,{x:i,y:e},1,{color:"white"})}setSize(t){var i;this.size=t,this.container.contains(this.canvas)&&(this.destroyCanvas(),this.createCanvas(t),this.eventUnbinding(),this.init(),((i=this.basicImgInfo)==null?void 0:i.valid)===!1&&this.renderInvalidPage())}setImgAttribute(t){const i=this._imgAttribute;if(this._imgAttribute=t,(i==null?void 0:i.zoomRatio)!==t.zoomRatio||i.isOriginalSize!==t.isOriginalSize){this.initImgPos();return}this.renderBasicCanvas(),this.render()}clearResult(t){}setValid(t){this.basicImgInfo.valid=t,t===!1?(this.renderInvalidPage(),this.clearResult(!1)):this.clearInvalidPage()}setRotate(t){this.basicImgInfo.rotate=t}setBasicResult(t){this.basicResult=t,this.coordUtils.setBasicResult(t),this.initPosition(),this.emit("dependRender")}setDependName(t,i){this.dependToolName=t,this.coordUtils.setDependInfo(t,i)}setAttributeLockList(t){this.attributeLockList=t,this.render()}setConfig(t){this.config=P.jsonParser(t)}setDataInjectionAtCreation(t){this.dataInjectionAtCreation=t}setRenderEnhance(t){this.renderEnhance=t}setCustomRenderStyle(t){this.customRenderStyle=t}updateRotate(){if(this.dependToolName)return this.emit("messageInfo",R.getMessagesByLocale(k.NoRotateInDependence,this.lang)),!1;if(this.dataList.length>0)return this.emit("messageInfo",R.getMessagesByLocale(k.NoRotateNotice,this.lang)),!1;const t=S.getRotate(this.basicImgInfo.rotate);this.basicImgInfo.rotate=t,this.initImgPos(),this.emit("updateResult")}getColor(t="",i=this.config){var e;if((i==null?void 0:i.attributeConfigurable)===!0&&this.style.attributeColor){const r=z.getAttributeIndex(t,(e=i.attributeList)!=null?e:[])+1;return this.style.attributeColor[r]}const{color:s,toolColor:o}=this.style;return o?o[s]:N.toolColor["1"]}getLineColor(t=""){var i,e,s;if(((i=this.config)==null?void 0:i.attributeConfigurable)===!0){const n=z.getAttributeIndex(t,(s=(e=this.config)==null?void 0:e.attributeList)!=null?s:[])+1;return this.style.attributeLineColor?this.style.attributeLineColor[n]:""}const{color:o,lineColor:r}=this.style;return o&&r?r[o]:""}clearInvalidPage(){this._invalidDOM&&this.container&&this.container.contains(this._invalidDOM)&&(this.container.removeChild(this._invalidDOM),this._invalidDOM=void 0)}renderInvalidPage(){!this.container||this._invalidDOM||(this._invalidDOM=X.renderInvalidPage(this.container,this.size,this.lang))}renderBasicCanvas(){if(!this.basicCanvas)return;this.clearBasicCanvas(),this.drawImg();const t=3;if(!this.forbidBasicResultRender&&this.basicResult&&this.dependToolName)switch(this.dependToolName){case b.Rect:{g.drawRect(this.basicCanvas,w.changeRectByZoom(this.basicResult,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}case b.Polygon:{g.drawPolygonWithFillAndLine(this.basicCanvas,w.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{fillColor:"transparent",strokeColor:"rgba(204,204,204,1.00)",isClose:!0,thickness:t});break}case b.Line:{g.drawLineWithPointList(this.basicCanvas,w.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}}}render(){!this.canvas||!this.ctx||!this.imgNode||this.clearCanvas()}changeStyle(t=this.defaultAttribute){this.emit("changeStyle",{attribute:t})}}export{rt as BasicToolOperation};
1
+ import{toolStyleConverter as x}from"@labelbee/lb-utils";import{isNumber as S}from"lodash";import{EOperationMode as I,EToolName as y}from"../../constant/tool.js";import R from"../../utils/MathUtils.js";import w,{CoordinateUtils as j}from"../../utils/tool/AxisUtils.js";import T from"../../utils/tool/CanvasUtils.js";import L from"../../utils/tool/CommonToolUtils.js";import K from"../../utils/tool/LineToolUtils.js";import{EGrowthMode as W,EDragStatus as G,ELang as H}from"../../constant/annotation.js";import p from"../../constant/keyCode.js";import{COLORS_ARRAY as M,styleString as Y,BASE_ICON as F}from"../../constant/style.js";import k from"../../locales/index.js";import{EMessage as z}from"../../locales/constants.js";import V from"../../utils/ActionsHistory.js";import E from"../../utils/tool/AttributeUtils.js";import X from"../../utils/tool/DblClickEventListener.js";import g from"../../utils/tool/DrawUtils.js";import B from"../../utils/tool/ImgPosUtils.js";import $ from"../../utils/tool/RenderDomUtils.js";import U from"../../utils/tool/ZoomUtils.js";import q from"./eventListener.js";var J=Object.defineProperty,Q=Object.defineProperties,tt=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable,Z=(d,t,i)=>t in d?J(d,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):d[t]=i,A=(d,t)=>{for(var i in t||(t={}))it.call(t,i)&&Z(d,i,t[i]);if(O)for(var i of O(t))et.call(t,i)&&Z(d,i,t[i]);return d},st=(d,t)=>Q(d,tt(t)),ot=(d,t,i)=>new Promise((e,s)=>{var o=r=>{try{n(i.next(r))}catch(a){s(a)}},h=r=>{try{n(i.throw(r))}catch(a){s(a)}},n=r=>r.done?e(r.value):Promise.resolve(r.value).then(o,h);n((i=i.apply(d,t)).next())});const P={min:.2,max:1e3,ratio:.4};class rt extends q{constructor(t){super();this.isDrag=!1,this.isSpaceKey=!1,this.operationMode=I.General,this.innerZoom=1,this.basicZoom=.01,this.isSpaceClick=!1,this.isDragStart=!1,this.startTime=0,this.initImgPos=()=>ot(this,null,function*(){var l,c;if(!this.imgNode)return;const u=(l=this._imgAttribute)==null?void 0:l.zoomRatio,m=(c=this._imgAttribute)==null?void 0:c.isOriginalSize,{currentPos:f,imgInfo:b,zoom:v}=B.getInitImgPos(this.size,{width:this.imgNode.width,height:this.imgNode.height},this.rotate,u,m);this.setCurrentPos(f),this.currentPosStorage=f,this.setImgInfo(b),this.setZoom(v),this.render(),this.renderBasicCanvas(),this.emit("dependRender"),this.emit("renderZoom",v,f,b)}),this.getCurrentPos=l=>{const{_firstClickCoordinate:c,currentPosStorage:u}=this;try{let m;return c&&u?m={y:u.y+l.y-c.y,x:u.x+l.x-c.x}:m={x:0,y:0},m}catch(m){return console.error(m),{x:0,y:0}}},this.wheelChangePos=(l,c,u)=>{const{currentPos:m,imgNode:f}=this;if(!f){console.error("unable to load image");return}if(this.zoom===this.basicZoom&&c===-1)return;const b=U.wheelChangePos(f,l,c,m,{zoom:u||this.zoom,innerZoom:this.innerZoom,basicZoom:this.basicZoom,zoomMax:P.max,rotate:this.rotate});if(!b)return;const{currentPos:v,ratio:N,zoom:_,imgInfo:D}=b;this.setZoom(_),this.setCurrentPos(v),this.currentPosStorage=v,this.setImgInfo(D),P.ratio=N,this.emit("renderZoom",_,v,D)},this.zoomChanged=(l,c=W.Linear)=>{const u=U.zoomChanged(this.zoom,l,c);this.wheelChangePos(this.getGetCenterCoordinate(),u>this.zoom?1:-1,u),this.render(),this.renderBasicCanvas()},this.zoomChangeOnCenter=l=>{this.wheelChangePos(this.getGetCenterCoordinate(),0,l),this.render(),this.renderBasicCanvas()},this.drawImg=()=>{!this.imgNode||this.hiddenImg===!0||g.drawImg(this.basicCanvas,this.imgNode,{zoom:this.zoom,currentPos:this.currentPos,rotate:this.rotate,imgAttribute:this._imgAttribute})};var i,e,s,o,h,n,r,a,C;this.container=t.container,this.config=L.jsonParser(t.config),this.showDefaultCursor=t.showDefaultCursor||!1,this.destroyCanvas(),this.createCanvas(t.size,t.isAppend),this.imgNode=t.imgNode,this.isImgError=!t.imgNode,this.basicImgInfo={width:(e=(i=t.imgNode)==null?void 0:i.width)!=null?e:0,height:(o=(s=t.imgNode)==null?void 0:s.height)!=null?o:0,valid:!0,rotate:0},this.forbidOperation=(h=t.forbidOperation)!=null?h:!1,this.forbidBasicResultRender=(n=t.forbidBasicResultRender)!=null?n:!1,this.size=t.size,this.currentPos={x:0,y:0},this.zoom=1,this.coord={x:-1,y:-1},this.currentPosStorage={x:0,y:0},this.isShowCursor=!1,this.style={strokeColor:M[4],fillColor:M[4],strokeWidth:2,opacity:1},this.attributeLockList=[],this.history=new V,this.style=(r=t.style)!=null?r:L.jsonParser(Y),this._imgAttribute=(a=t.imgAttribute)!=null?a:{},this.isHidden=!1,this.dragStatus=G.Wait,this.defaultAttribute=(C=t==null?void 0:t.defaultAttribute)!=null?C:"",this.forbidCursorLine=!!t.forbidCursorLine,this.lang=H.Zh,this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onWheel=this.onWheel.bind(this),this.onLeftDblClick=this.onLeftDblClick.bind(this),this.onRightDblClick=this.onRightDblClick.bind(this),this.onClick=this.onClick.bind(this),this.clearImgDrag=this.clearImgDrag.bind(this),this.dblClickListener=new X(this.container,200),this.coordUtils=new j(this),this.coordUtils.setBasicImgInfo(this.basicImgInfo),this.hiddenImg=t.hiddenImg||!1}onContextmenu(t){t.preventDefault()}get ctx(){var t;return this._ctx||((t=this.canvas)==null?void 0:t.getContext("2d"))}get basicCtx(){var t;return(t=this.basicCanvas)==null?void 0:t.getContext("2d")}get rotate(){var t,i;return(i=(t=this.basicImgInfo)==null?void 0:t.rotate)!=null?i:0}get valid(){var t,i;return(i=(t=this.basicImgInfo)==null?void 0:t.valid)!=null?i:!0}get baseIcon(){return F[this.style.color]}get defaultCursor(){return this.showDefaultCursor?"default":"none"}get dataList(){return[]}get innerPosAndZoom(){return{innerZoom:this.innerZoom,currentPosStorage:this.currentPosStorage}}get isShowDefaultCursor(){return this.showDefaultCursor}get isMultiMoveMode(){return this.operationMode===I.MultiMove}get hasMarkerConfig(){return this.config.markerConfigurable===!0&&this.config.markerList&&this.config.markerList.length>0}setZoom(t){this.zoom=t,this.innerZoom=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}setCurrentPos(t){this.currentPos=t,this.coordUtils.setZoomAndCurrentPos(this.zoom,this.currentPos)}setReferenceData(t){this.referenceData=t}setImgInfo(t){this.imgInfo=t}setCurrentPosStorage(t){this.currentPosStorage=t}setOperationMode(t){this.operationMode=t}recoverOperationMode(){this.operationMode===I.MultiMove&&this.setOperationMode(I.General)}updatePosition(t){const{zoom:i,currentPos:e}=t;this.setZoom(i),this.setCurrentPos(e),this.currentPosStorage=e,this.renderBasicCanvas(),this.render()}setLang(t){this.lang=t}setShowDefaultCursor(t){this.showDefaultCursor=t,this.container.style.cursor=this.defaultCursor}setCustomCursor(t){this.container.style.cursor=t}get forbidMouseOperation(){return this.forbidOperation||this.valid===!1}get pixelRatio(){var t;return T.getPixelRatio((t=this.canvas)==null?void 0:t.getContext("2d"))}init(){this.eventUnbinding(),this.initPosition(),this.eventBinding(),this.render(),this.renderBasicCanvas()}destroy(){this.destroyCanvas(),this.eventUnbinding()}updateCanvasBasicStyle(t,i,e){const s=this.pixelRatio;t.style.position="absolute",t.width=i.width*s,t.height=i.height*s,t.style.width=`${i.width}px`,t.style.height=`${i.height}px`,t.style.left="0",t.style.top="0",t.style.zIndex=`${e} `}createCanvas(t,i=!0){var e,s;const o=this.pixelRatio,h=document.createElement("canvas");this.updateCanvasBasicStyle(h,t,0),this.basicCanvas=h;const n=document.createElement("canvas");this.updateCanvasBasicStyle(n,t,10),i&&(this.container.hasChildNodes()?(this.container.insertBefore(n,this.container.childNodes[0]),this.container.insertBefore(h,this.container.childNodes[0])):(this.container.appendChild(h),this.container.appendChild(n))),this.canvas=n,this.container.style.cursor=this.defaultCursor,(e=this.ctx)==null||e.scale(o,o),(s=this.basicCtx)==null||s.scale(o,o)}destroyCanvas(){this.canvas&&this.container.contains(this.canvas)&&this.container.removeChild(this.canvas),this.basicCanvas&&this.container.contains(this.basicCanvas)&&this.container.removeChild(this.basicCanvas),this.clearInvalidPage(),this.clearImgDrag()}setStyle(t){this.style=t,this.render()}setImgNode(t,i={}){this.imgNode=t,this.setBasicImgInfo(A({width:t.width,height:t.height,valid:!0,rotate:0},i)),this.isImgError===!0&&(this.isImgError=!1,this.emit("changeAnnotationShow")),typeof i.valid=="boolean"&&this.setValid(i.valid),this.initImgPos(),this.render(),this.renderBasicCanvas()}setErrorImg(){const t=this.isImgError;this.isImgError=!0,this.imgNode=void 0,this.setBasicImgInfo({width:0,height:0,valid:!0,rotate:0}),t===!1&&this.emit("changeAnnotationShow")}setBasicImgInfo(t){this.basicImgInfo=t,this.coordUtils.setBasicImgInfo(t)}setForbidOperation(t){this.forbidOperation=t,this.setShowDefaultCursor(t),this.render()}setForbidCursorLine(t){this.forbidCursorLine=t,this.render()}setIsHidden(t){this.isHidden=t,this.emit("hiddenChange")}setDefaultAttribute(t){this.defaultAttribute=t}getCoordinateInOrigin(t){const i=this.canvas.getBoundingClientRect();return{x:(t.clientX-i.left-this.currentPos.x)/this.zoom,y:(t.clientY-i.top-this.currentPos.y)/this.zoom}}getTextIconSvg(t=""){var i;return E.getTextIconSvg(t,(i=this.config)==null?void 0:i.attributeList,this.config.attributeConfigurable,this.baseIcon)}setIsShowOrder(t){this.config.isShowOrder=t,this.render()}getCoordinate(t){const i=this.canvas.getBoundingClientRect();return{x:t.clientX-i.left,y:t.clientY-i.top}}getCoordinateUnderZoom(t){const i=this.canvas.getBoundingClientRect();return{x:t.clientX-i.left-this.currentPos.x,y:t.clientY-i.top-this.currentPos.y}}getCoordinateUnderZoomByRotate(t){const{x:i,y:e}=this.getCoordinateUnderZoom(t);return this.basicImgInfo.rotate===90?{x:e,y:this.basicImgInfo.height*this.zoom-i}:this.basicImgInfo.rotate===180?{x:this.basicImgInfo.width*this.zoom-i,y:this.basicImgInfo.height*this.zoom-e}:this.basicImgInfo.rotate===270?{x:this.basicImgInfo.width*this.zoom-e,y:i}:{x:i,y:e}}getGetCenterCoordinate(){return{x:this.size.width/2,y:this.size.height/2}}initPosition(){if(this.basicResult&&this.imgInfo){const{basicResult:t,size:i,imgNode:e,_imgAttribute:s,imgInfo:o,dependToolName:h}=this;if(t&&e&&h){let n=t;switch(h){case y.Polygon:case y.Line:{if(t.pointList){const a=R.calcViewportBoundaries(t.pointList);n={x:a.left,y:a.top,width:a.right-a.left,height:a.bottom-a.top}}break}}const r=B.getBasicRecPos(e,n,i,void 0,s==null?void 0:s.zoomRatio,s==null?void 0:s.isOriginalSize);r&&(this.setCurrentPos(r.currentPos),this.currentPosStorage=this.currentPos,this.setImgInfo(st(A({},o),{width:o.width/this.innerZoom*r.innerZoom,height:o.height/this.innerZoom*r.innerZoom})),this.setZoom(r.innerZoom),this.render(),this.renderBasicCanvas())}}else this.initImgPos()}undo(){this.history.undo()}redo(){this.history.redo()}clearCanvas(){var t;(t=this.ctx)==null||t.clearRect(0,0,this.size.width,this.size.height)}clearBasicCanvas(){var t;(t=this.basicCtx)==null||t.clearRect(0,0,this.size.width,this.size.height)}eventBinding(){this.dblClickListener.addEvent(()=>{},this.onLeftDblClick,this.onRightDblClick),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mouseleave",this.onMouseLeave),this.container.addEventListener("click",this.onClick),this.container.addEventListener("wheel",this.onWheel),document.addEventListener("keydown",this.onKeyDown),document.addEventListener("keyup",this.onKeyUp),window.parent.document.addEventListener("contextmenu",this.onContextmenu,!1)}eventUnbinding(){this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp),this.container.removeEventListener("mouseleave",this.onMouseLeave),this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("click",this.onClick),document.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("keyup",this.onKeyUp),window.parent.document.removeEventListener("contextmenu",this.onContextmenu,!1),this.dblClickListener.removeEvent()}clearImgDrag(){this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime=0,this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1}clearCursorLine(){this.coord={x:-1,y:-1}}onMouseDown(t){if(!this.canvas||this.isImgError)return!0;const i=this.getCoordinate(t);(this.isSpaceKey&&t.button===0||t.button===2)&&(t.stopPropagation(),this._firstClickCoordinate=i,this.currentPosStorage=this.currentPos,this.isSpaceClick=!0,this.isDragStart=!0,this.startTime=new Date().getTime())}onMouseMove(t){if(!this.canvas||this.isImgError)return!0;const i=this.getCoordinate(t);this.isShowCursor&&(this.coord=i);try{if(!i||!S(i==null?void 0:i.x)||!S(i==null?void 0:i.y))throw new Error("coord error");if(this.coord=i,(this.isSpaceClick||this.isDragStart)&&this._firstClickCoordinate){const e=this.getCurrentPos(i);this.setCurrentPos(e),this.isDrag=!0,this.container.style.cursor="grabbing",this.forbidCursorLine=!0,this.renderBasicCanvas(),this.emit("dependRender"),this.emit("dragMove",{currentPos:e,zoom:this.zoom,imgInfo:this.imgInfo})}this.render()}catch(e){console.error(e)}}onMouseUp(t){if(!this.canvas||this.isImgError)return!0;if(this.container.style.cursor=this.defaultCursor,this.forbidCursorLine=!1,this.isDrag=!1,this.isDragStart=!1,this.isSpaceClick=!1,this.startTime!==0&&this._firstClickCoordinate){const i=new Date().getTime(),e=this.getCoordinate(t);if(i-this.startTime>1e3||this.isSpaceKey===!0||K.calcTwoPointDistance(e,this._firstClickCoordinate)>10)return t.stopPropagation(),this.startTime=0,this.render(),!0}this.startTime=0,this.render()}onMouseLeave(){this.clearImgDrag()}onClick(t){}onLeftDblClick(t){}onRightDblClick(t){this.clearImgDrag()}onKeyDown(t){switch(t.keyCode===p.Alt&&t.preventDefault(),t.keyCode){case p.Space:this.isSpaceKey=!0;break;case p.Z:if(t.ctrlKey)return t.shiftKey?this.redo():this.undo(),!1;break}return!0}onKeyUp(t){switch(t.keyCode){case p.Space:this.isSpaceKey=!1;break}}exportCustomData(){return{}}onWheel(t,i=!0){if(!this.imgNode||!this.coord)return;t.preventDefault(),t.stopPropagation();const e=this.getCoordinate(t),s=t.deltaY||t.wheelDelta;let o=0;s>0&&this.zoom>P.min&&(o=-1),s<0&&this.zoom<P.max&&(o=1),this.wheelChangePos(e,o),this.emit("dependRender"),i&&this.render(),this.renderBasicCanvas()}renderCursorLine(t=(i=>(i=this.style.lineColor[0])!=null?i:"")()){if(!this.ctx||this.forbidCursorLine||this.forbidOperation)return;const{x:i,y:e}=this.coord;g.drawLine(this.canvas,{x:0,y:e},{x:1e4,y:e},{color:t}),g.drawLine(this.canvas,{x:i,y:0},{x:i,y:1e4},{color:t}),g.drawCircleWithFill(this.canvas,{x:i,y:e},1,{color:"white"})}setSize(t){var i;this.size=t,this.container.contains(this.canvas)&&(this.destroyCanvas(),this.createCanvas(t),this.eventUnbinding(),this.init(),((i=this.basicImgInfo)==null?void 0:i.valid)===!1&&this.renderInvalidPage())}setImgAttribute(t){const i=this._imgAttribute;if(this._imgAttribute=t,(i==null?void 0:i.zoomRatio)!==t.zoomRatio||i.isOriginalSize!==t.isOriginalSize){this.initImgPos();return}this.renderBasicCanvas(),this.render()}clearResult(t){}setValid(t){this.basicImgInfo.valid=t,t===!1?(this.renderInvalidPage(),this.clearResult(!1)):this.clearInvalidPage()}setRotate(t){this.basicImgInfo.rotate=t}setBasicResult(t){this.basicResult=t,this.coordUtils.setBasicResult(t),this.initPosition(),this.emit("dependRender")}setDependName(t,i){this.dependToolName=t,this.coordUtils.setDependInfo(t,i)}setAttributeLockList(t){this.attributeLockList=t,this.render()}setConfig(t){this.config=L.jsonParser(t)}setDataInjectionAtCreation(t){this.dataInjectionAtCreation=t}setRenderEnhance(t){this.renderEnhance=t}setCustomRenderStyle(t){this.customRenderStyle=t}updateRotate(){if(this.dependToolName)return this.emit("messageInfo",k.getMessagesByLocale(z.NoRotateInDependence,this.lang)),!1;if(this.dataList.length>0)return this.emit("messageInfo",k.getMessagesByLocale(z.NoRotateNotice,this.lang)),!1;const t=R.getRotate(this.basicImgInfo.rotate);this.basicImgInfo.rotate=t,this.initImgPos(),this.emit("updateResult")}getColor(t="",i=this.config){return x.getColorByConfig({attribute:t,config:i,style:this.style})}getLineColor(t=""){var i,e,s,o,h,n,r,a;if(((i=this.config)==null?void 0:i.attributeConfigurable)===!0){const c=E.getAttributeIndex(t,(s=(e=this.config)==null?void 0:e.attributeList)!=null?s:[])+1;return((n=(h=(o=this.config)==null?void 0:o.attributeList)==null?void 0:h.find(m=>m.value===t))==null?void 0:n.color)?(a=(r=x.getColorByConfig({attribute:t,config:this.config}))==null?void 0:r.valid)==null?void 0:a.stroke:this.style.attributeLineColor?this.style.attributeLineColor[c]:""}const{color:C,lineColor:l}=this.style;return C&&l?l[C]:""}clearInvalidPage(){this._invalidDOM&&this.container&&this.container.contains(this._invalidDOM)&&(this.container.removeChild(this._invalidDOM),this._invalidDOM=void 0)}renderInvalidPage(){!this.container||this._invalidDOM||(this._invalidDOM=$.renderInvalidPage(this.container,this.size,this.lang))}renderBasicCanvas(){if(!this.basicCanvas)return;this.clearBasicCanvas(),this.drawImg();const t=3;if(!this.forbidBasicResultRender&&this.basicResult&&this.dependToolName)switch(this.dependToolName){case y.Rect:{g.drawRect(this.basicCanvas,w.changeRectByZoom(this.basicResult,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}case y.Polygon:{g.drawPolygonWithFillAndLine(this.basicCanvas,w.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{fillColor:"transparent",strokeColor:"rgba(204,204,204,1.00)",isClose:!0,thickness:t});break}case y.Line:{g.drawLineWithPointList(this.basicCanvas,w.changePointListByZoom(this.basicResult.pointList,this.zoom,this.currentPos),{color:"rgba(204,204,204,1.00)",thickness:t});break}}}render(){!this.canvas||!this.ctx||!this.imgNode||this.clearCanvas()}changeStyle(t=this.defaultAttribute){this.emit("changeStyle",{attribute:t})}}export{rt as BasicToolOperation};
@@ -0,0 +1 @@
1
+ import c from"../../utils/tool/CommonToolUtils.js";import l from"../../utils/tool/AxisUtils.js";import H from"../../utils/uuid.js";import{getCuboidHoverRange as U,getPlainPointsByDiagonalPoints as z,getPointsByBottomRightPoint as F,getCuboidDragMove as j,isCuboidWithInLimits as E,getHighlightPoints as W,getCuboidTextAttributeOffset as A,getToggleDirectionButtonOffset as N}from"../../utils/tool/CuboidUtils.js";import Z from"../../utils/tool/PolygonUtils.js";import{EDragStatus as v,EDragTarget as w,ECuboidDirection as K}from"../../constant/annotation.js";import g from"../../utils/tool/AttributeUtils.js";import{DEFAULT_TEXT_MAX_WIDTH as V}from"../../constant/tool.js";import D from"../../constant/keyCode.js";import{BasicToolOperation as X}from"./basicToolOperation.js";import b from"../../utils/tool/DrawUtils.js";import $ from"./cuboidToggleButtonClass.js";import G from"./textAttributeClass.js";import q from"../../locales/index.js";import{EMessage as J}from"../../locales/constants.js";var Q=Object.defineProperty,Y=Object.defineProperties,tt=Object.getOwnPropertyDescriptors,_=Object.getOwnPropertySymbols,it=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable,T=(n,t,i)=>t in n?Q(n,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[t]=i,u=(n,t)=>{for(var i in t||(t={}))it.call(t,i)&&T(n,i,t[i]);if(_)for(var i of _(t))et.call(t,i)&&T(n,i,t[i]);return n},a=(n,t)=>Y(n,tt(t)),k;(function(n){n[n.Ready=1]="Ready",n[n.FirstPoint=2]="FirstPoint",n[n.Cuboid=3]="Cuboid"})(k||(k={}));const ot=164;class st extends X{constructor(t){super(t);this.drawingStatus=1,this.cuboidList=[],this.hoverID="",this.getHoverData=i=>{const e=this.getCoordinateUnderZoom(i),{currentShowList:s}=this;if((s==null?void 0:s.length)>0){const r=s.map(d=>({id:d.id,pointList:l.changePointListByZoom(U(d),this.zoom)})),o=Z.getHoverPolygonID(e,r);if(o)return{hoverID:o,hoverCuboid:s.find(d=>d.id===o)}}return{}},this.textChange=i=>{this.config.textConfigurable===!1||!this.selectedID||(this.setCuboidList(g.textChange(i,this.selectedID,this.cuboidList)),this.emit("selectedChange"),this.render())},this.config=c.jsonParser(t.config),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this)}destroy(){super.destroy(),this._textAttributeInstance&&this._textAttributeInstance.clearTextAttribute()}get currentShowList(){let t=[];const[i,e]=c.getRenderResultList(this.cuboidList,c.getSourceID(this.basicResult),this.attributeLockList,this.selectedID);return t=i,this.isHidden&&(t=[]),e&&t.push(e),t}get selectedCuboid(){return this.cuboidList.find(t=>t.id===this.selectedID)}get dataList(){return this.cuboidList}get isNeedCheckCuboidSize(){var t,i;return((t=this.config)==null?void 0:t.minWidth)>=0&&((i=this.config)==null?void 0:i.minHeight)>=0}getIsHoverSelectedCuboid(t){const i=this.getCoordinateUnderZoom(t),{selectedCuboid:e}=this;return e&&l.isCloseCuboid(i,l.changeCuboidByZoom(e,this.zoom))}isForbiddenMove(t,i){return this.getCoordinateInOrigin(t).y>i.frontPoints.br.y}updateSelectedCuboid(t){this.cuboidList=this.cuboidList.map(i=>i.id===this.selectedID?t:i)}getColorToRender(t,i){const e=this.getColor(t),s=i?e==null?void 0:e.valid.stroke:e==null?void 0:e.invalid.stroke,r=i?e==null?void 0:e.valid.fill:e==null?void 0:e.invalid.fill;return{strokeColor:s,toolColor:e,fillColor:r}}getCurrentSelectedData(){const{selectedCuboid:t}=this;if(!t)return;const{strokeColor:i}=this.getColorToRender(t.attribute,t.valid);return{width:ot,textAttribute:t.textAttribute,color:i}}updateSelectedTextAttribute(t){if(this._textAttributeInstance&&t&&this.selectedID){let i=t;g.textAttributeValidate(this.config.textCheckType,"",i)===!1&&(this.emit("messageError",g.getErrorNotice(this.config.textCheckType,this.lang)),i=""),this.setCuboidList(g.textChange(i,this.selectedID,this.cuboidList)),this.history.pushHistory(this.cuboidList),this.emit("updateTextAttribute"),this.render()}}setResult(t){this.clearDrawingStatus(),this.setCuboidList(t),this.render()}get currentPageResult(){return this.cuboidList}clearResult(){this.setCuboidList([],!0),this.setSelectedID(void 0)}exportData(){const{cuboidList:t}=this;return[t,this.basicImgInfo]}setSelectedID(t){var i,e;const s=this.selectedID;t!==s&&s&&((i=this._textAttributeInstance)==null||i.changeSelected()),t||(e=this._textAttributeInstance)==null||e.clearTextAttribute(),this.selectedID=t,this.emit("selectedChange")}setSelectedIDAndRender(t){this.setSelectedID(t),this.render()}setCuboidValidAndRender(t){if(!t)return;const i=this.cuboidList.map(e=>e.id===t?a(u({},e),{valid:!e.valid}):e);this.setCuboidList(i,!0),this.history.pushHistory(this.cuboidList),this.render()}onRightDblClick(t){super.onRightDblClick(t);const{hoverID:i}=this.getHoverData(t);this.selectedID&&this.selectedID===i&&this.deleteCuboid(i)}setCuboidList(t,i=!1){const e=this.cuboidList.length;this.cuboidList=t,e!==t.length&&this.emit("updatePageNumber"),i&&this.emit("updateResult")}deleteCuboid(t){var i;!t||(this.setCuboidList(this.cuboidList.filter(e=>e.id!==t)),this.history.pushHistory(this.cuboidList),this.setSelectedID(""),(i=this._textAttributeInstance)==null||i.clearTextAttribute(),this.render())}onKeyDown(t){if(!c.hotkeyFilter(t)||super.onKeyDown(t)===!1)return;const{keyCode:i}=t;switch(i){case D.Ctrl:this.drawingCuboid&&(this.drawingCuboid=a(u({},this.drawingCuboid),{valid:!1}),this.render());break;case D.F:this.selectedID&&this.setCuboidValidAndRender(this.selectedID);break;default:if(this.config.attributeConfigurable){const e=g.getAttributeByKeycode(i,this.config.attributeList);e!==void 0&&this.setDefaultAttribute(e)}}}onKeyUp(t){switch(super.onKeyUp(t),t.keyCode){case D.Ctrl:this.drawingCuboid&&(this.drawingCuboid=a(u({},this.drawingCuboid),{valid:!0}),this.render());break}}onMouseDown(t){if(super.onMouseDown(t)||this.forbidMouseOperation||t.ctrlKey===!0)return;const{selectedCuboid:i}=this;if(!i||t.button===2||t.button===0&&this.isSpaceKey===!0||!this.getIsHoverSelectedCuboid(t))return;this.dragStatus=v.Start;const e=this.getCoordinateUnderZoom(t),s={initCuboid:i,dragStartCoord:e},r=l.returnClosePointOrLineInCuboid(e,l.changeCuboidByZoom(i,this.zoom)),o=r==null?void 0:r[0];switch(o==null?void 0:o.type){case"point":this.dragInfo=a(u({},s),{dragTarget:w.Point,positions:o.positions});break;case"line":this.dragInfo=a(u({},s),{dragTarget:w.Line,positions:o.positions});break;default:this.dragInfo=a(u({},s),{dragTarget:w.Cuboid})}}onMouseUp(t){if(super.onMouseUp(t)||this.forbidMouseOperation||!this.imgInfo)return;if(this.dragInfo&&this.dragStatus===v.Move){this.dragInfo=void 0,this.dragStatus=v.Wait,this.history.pushHistory(this.cuboidList),this.emit("updateResult");return}const i=c.getSourceID(this.basicResult);if(t.button===0){if(this.hoverID&&t.ctrlKey&&!this.drawingCuboid){this.setCuboidValidAndRender(this.hoverID);return}if(!this.drawingCuboid){this.createNewDrawingCuboid(t,i);return}if(this.drawingCuboid)switch(this.drawingStatus){case 2:this.closeNewDrawingFrontPlane();break;case 3:this.closeAndCreateNewCuboid();break}}t.button===2&&this.rightMouseUp(t)}onMouseMove(t){var i;if(!(super.onMouseMove(t)||this.forbidMouseOperation||!this.imgInfo)){if(this.selectedID&&this.dragInfo){this.onDragMove(t);return}if(this.drawingCuboid){if(this.drawingFrontPlanesMove(t))return;this.drawingBackPlaneMove(t);return}this.hoverID=(i=this.getHoverData(t).hoverID)!=null?i:"",this.onHoverMove(t)}}drawingFrontPlanesMove(t){if(this.drawingCuboid&&this.firstClickCoord&&this.drawingStatus===2){const i=this.getCoordinateInOrigin(t);return this.drawingCuboid=a(u({},this.drawingCuboid),{frontPoints:z(this.firstClickCoord,i)}),this.render(),!0}}drawingBackPlaneMove(t){if(this.drawingCuboid&&this.firstClickCoord&&this.drawingStatus===3){const i=this.getCoordinateInOrigin(t);if(this.isForbiddenMove(t,this.drawingCuboid))return;this.drawingCuboid=a(u({},this.drawingCuboid),{backPoints:F({coord:i,points:this.drawingCuboid.frontPoints})}),this.render()}}onDragMove(t){if(!this.dragInfo||!this.selectedID)return;const{dragTarget:i,initCuboid:e,dragStartCoord:s,positions:r}=this.dragInfo,o=this.getCoordinateUnderZoom(t),d={x:(o.x-s.x)/this.zoom,y:(o.y-s.y)/this.zoom};this.dragStatus=v.Move;const h=j({offset:d,cuboid:e,dragTarget:i,positions:r});(h==null?void 0:h.backPoints)&&(h==null?void 0:h.backPoints.br.y)>(h==null?void 0:h.frontPoints.br.y)||(h&&this.updateSelectedCuboid(h),this.render())}onHoverMove(t){const{selectedCuboid:i}=this;if(i){const e=this.getCoordinateUnderZoom(t),s=l.returnClosePointOrLineInCuboid(e,l.changeCuboidByZoom(i,this.zoom),{zoom:1/this.zoom,scope:5});this.highlightInfo=s,this.render()}}createNewDrawingCuboid(t,i){if(!this.imgInfo)return;const e=this.getCoordinateInOrigin(t);this.drawingCuboid={attribute:this.defaultAttribute,direction:K.Front,valid:!t.ctrlKey,id:H(8,62),sourceID:i,textAttribute:"",order:c.getMaxOrder(this.cuboidList.filter(s=>c.isSameSourceID(s.sourceID,i)))+1,frontPoints:{tl:e,bl:e,tr:e,br:e}},this.firstClickCoord=u({},e),this.drawingStatus=2}closeNewDrawingFrontPlane(){this.drawingStatus=3}closeAndCreateNewCuboid(){var t,i;!((t=this.drawingCuboid)==null?void 0:t.frontPoints)||!this.drawingCuboid.backPoints||(this.isNeedCheckCuboidSize&&E({cuboid:this.drawingCuboid,config:this.config})===!1?this.emit("messageInfo",q.getMessagesByLocale(J.RectErrorSizeNotice,this.lang)):(this.setCuboidList([...this.cuboidList,this.drawingCuboid]),this.setSelectedID((i=this.drawingCuboid)==null?void 0:i.id),this.history.pushHistory(this.cuboidList)),this.clearDrawingStatus(),this.render())}clearDrawingStatus(){this.drawingCuboid&&(this.drawingCuboid=void 0,this.drawingStatus=1)}rightMouseUp(t){const{hoverID:i,hoverCuboid:e}=this.getHoverData(t);this.setSelectedID(i),e&&this.setDefaultAttribute(e.attribute),this.drawingCuboid&&this.clearDrawingStatus(),this.render()}renderSingleCuboid(t){var i,e,s,r;const o=l.changeCuboidByZoom(t,this.zoom,this.currentPos),d=o.id===this.hoverID,h=o.id===this.selectedID,{strokeColor:f,fillColor:M}=this.getColorToRender(o.attribute,o.valid),O=f,x=(e=(i=this.style)==null?void 0:i.width)!=null?e:2,{hiddenText:y=!1}=this.style,B={color:f,thickness:x},{backPoints:m,frontPoints:L,textAttribute:S}=o,R=L.br.x-L.bl.x;if(b.drawCuboid(this.canvas,o,{strokeColor:f,fillColor:M,thickness:x}),d||h){const p=W(o);p.forEach(I=>{b.drawCircleWithFill(this.canvas,I.point,5,u({},B))}),h&&p.forEach(I=>{b.drawCircleWithFill(this.canvas,I.point,3,{color:"white"})})}let C="";((s=this.config)==null?void 0:s.isShowOrder)&&o.order&&(o==null?void 0:o.order)>0&&(C=`${o.order}`),o.attribute&&(C=`${C} ${g.getAttributeShowText(o.attribute,(r=this.config)==null?void 0:r.attributeList)}`),!y&&m&&b.drawText(this.canvas,{x:m.tl.x,y:m.tl.y-5},C,{color:f,textMaxWidth:300});const P=A({cuboid:t,currentPos:this.currentPos,zoom:this.zoom,topOffset:16,leftOffset:0});if(!y&&S&&t.id!==this.selectedID){const p=Math.max(20,R*.8);b.drawText(this.canvas,{x:P.left,y:P.top},S,{color:O,textMaxWidth:p})}this.renderTextAttribute()}setDefaultAttribute(t){const i=this.defaultAttribute;if(this.defaultAttribute=t!=null?t:"",i!==t){this.changeStyle(t),this.emit("changeAttributeSidebar");const{selectedCuboid:e}=this;if(e&&(this.setCuboidList(this.cuboidList.map(s=>s.id===this.selectedID?a(u({},s),{attribute:this.defaultAttribute}):s)),this.history.pushHistory(this.cuboidList),this.render()),this.drawingCuboid&&(this.drawingCuboid=a(u({},this.drawingCuboid),{attribute:this.defaultAttribute}),this.render()),this._textAttributeInstance){if(this.attributeLockList.length>0&&!this.attributeLockList.includes(this.defaultAttribute)){this._textAttributeInstance.clearTextAttribute();return}this._textAttributeInstance.updateIcon(this.getTextIconSvg(t))}}}renderToggleButton(){const{selectedCuboid:t}=this;if(!this.ctx||this.config.textConfigurable!==!0||!t)return;const{attribute:i,valid:e}=t,{strokeColor:s}=this.getColorToRender(i,e);this.toggleButtonInstance||(this.toggleButtonInstance=new $({container:this.container,cuboidButtonMove:o=>this.updateMouseOperation(o),toggleDirection:o=>this.toggleDirection(o)}));const r=N({cuboid:t,zoom:this.zoom,currentPos:this.currentPos});this.toggleButtonInstance.update({left:r.left,top:r.top,color:s})}renderTextAttribute(){var t;const{selectedCuboid:i}=this;if(!this.ctx||this.config.textConfigurable===!1||!i)return;const{strokeColor:e}=this.getColorToRender(i.attribute,i.valid),{attribute:s,textAttribute:r,frontPoints:o}=i,d=A({cuboid:i,currentPos:this.currentPos,zoom:this.zoom}),h=(o.br.x-o.bl.x)*this.zoom*.8;this._textAttributeInstance||(this._textAttributeInstance=new G({width:V,container:this.container,icon:this.getTextIconSvg(s),color:e,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributeInstance&&!((t=this._textAttributeInstance)==null?void 0:t.isExit)&&this._textAttributeInstance.appendToContainer(),this._textAttributeInstance.update(`${r}`,{left:d.left,top:d.top,color:e,width:h})}renderDrawing(){this.drawingCuboid&&this.renderSingleCuboid(this.drawingCuboid)}renderStatic(){this.cuboidList.forEach(t=>this.renderSingleCuboid(t))}renderSelected(){var t;const{selectedCuboid:i}=this;i?(this.renderSingleCuboid(i),this.renderToggleButton()):((t=this.toggleButtonInstance)==null||t.clearCuboidButtonDOM(),this.toggleButtonInstance=void 0)}updateMouseOperation(t){t==="in"?(this.setForbidCursorLine(!0),this.setForbidOperation(!0),this.setShowDefaultCursor(!0)):(this.setForbidCursorLine(!1),this.setShowDefaultCursor(!1),this.setForbidOperation(!1))}toggleDirection(t){this.cuboidList&&this.selectedCuboid&&(this.setCuboidList(this.cuboidList.map(i=>{var e;return i.id===((e=this.selectedCuboid)==null?void 0:e.id)?a(u({},i),{direction:t}):i})),this.history.pushHistory(this.cuboidList),this.render())}renderHover(){var t;this.dragInfo||(t=this.highlightInfo)==null||t.forEach(i=>{var e,s;const{strokeColor:r}=this.getColorToRender(i.originCuboid.attribute,i.originCuboid.valid),o=8;switch(i.type){case"point":(e=i.points)==null||e.forEach(d=>{b.drawCircleWithFill(this.canvas,l.changePointByZoom(d,this.zoom,this.currentPos),o,{color:r})});break;case"line":{const d=(s=i.points)==null?void 0:s.map(h=>l.changePointByZoom(h,this.zoom,this.currentPos));d&&b.drawLineWithPointList(this.canvas,d,{color:r,thickness:o});break}}})}renderCuboid(){this.renderStatic(),this.renderDrawing(),this.renderSelected(),this.renderHover()}render(){!this.ctx||(super.render(),this.renderCuboid(),this.renderCursorLine(this.getLineColor(this.defaultAttribute)))}undo(){const t=this.history.undo();t&&(t.length!==this.cuboidList.length&&this.setSelectedID(""),this.setCuboidList(t,!0),this.render())}redo(){const t=this.history.redo();t&&(t.length!==this.cuboidList.length&&this.setSelectedID(""),this.setCuboidList(t,!0),this.render())}}export{st as default};
@@ -0,0 +1,31 @@
1
+ import{ECuboidDirection as s}from"../../constant/annotation.js";import c from"../../assets/attributeIcon/icon_cuboidFAB.svg.js";import u from"../../assets/attributeIcon/icon_cuboidMore.svg.js";import a from"../../assets/attributeIcon/icon_cuboidRight.svg.js";import b from"../../assets/attributeIcon/icon_cuboidLeft.svg.js";import h from"../../assets/attributeIcon/icon_cuboidTop.svg.js";const r=[{icon:a,id:"cuboidRight"},{icon:b,id:"cuboidLeft"},{icon:h,id:"cuboidTop"}];class M{constructor(i){const{container:t,cuboidButtonMove:o,toggleDirection:e}=i;this.container=t,this.direction=s.Front,this.isFrontSide=!0,this.cuboidButtonMove=o,this.onToggleDirection=e,this._cuboidButtonDOM=this.initCuboidButtonDOM(),this._cuboidFABDOM=this.initcuboidFABDOM(c),this._cuboidMoreDOM=this.initcuboidMoreDOM(u),this._cuboidMoreListDOM=this.initcuboidMoreListDOM(),this.appendToContainer()}appendToContainer(){!this._cuboidButtonDOM||!this._cuboidFABDOM||!this._cuboidMoreDOM||(this.container.appendChild(this._cuboidButtonDOM),this._cuboidButtonDOM.appendChild(this._cuboidFABDOM),this._cuboidButtonDOM.appendChild(this._cuboidMoreDOM))}initCuboidButtonDOM(){const i=document.createElement("div");return i.setAttribute("id","LABELBEE_CUBOID_BUTTON_BOX"),i.setAttribute("style",`
2
+ width: 40px;
3
+ height: 74px;
4
+ border-radius: 10px;
5
+ background-color: #FFFFFF;
6
+ z-index: 10;
7
+ `),i.addEventListener("mouseover",t=>{t.stopPropagation(),setTimeout(()=>{this.cuboidButtonMove("in")},100)}),i.addEventListener("mouseleave",t=>{t.stopPropagation(),setTimeout(()=>{this.cuboidButtonMove("out")},100)}),i}initcuboidFABDOM(i){const t=document.createElement("div");return t.setAttribute("id","CUBOID_FORWARD_AND_BACK_SWITCH"),t.innerHTML=i,t.addEventListener("mouseup",o=>{o.stopPropagation(),this.isFrontSide=!this.isFrontSide,this.direction=this.isFrontSide?s.Front:s.Back,this.onToggleDirection(this.direction)}),t}initcuboidMoreDOM(i){const t=document.createElement("div");return t.setAttribute("id","CUBOID_MORE_ICON"),t.innerHTML=i,t.addEventListener("mouseup",o=>{this._cuboidButtonDOM&&this._cuboidMoreListDOM&&(this._cuboidButtonDOM.contains(this._cuboidMoreListDOM)?this.clearCuboidMoreListDOM():this._cuboidButtonDOM.appendChild(this._cuboidMoreListDOM)),o.stopPropagation()}),t.addEventListener("mousedown",o=>{o.stopPropagation()}),t.addEventListener("contextmenu",o=>{o.stopPropagation()}),t}initcuboidMoreListDOM(){const i=document.createElement("div");i.setAttribute("id","CUBOID_MORE_LIST_ICON"),i.setAttribute("style",`
8
+ height: 36px;
9
+ border-radius: 10px;
10
+ background-color: #FFFFFF;
11
+ z-index: 10;
12
+ padding: 8px 10px;
13
+ position: absolute;
14
+ bottom: 0px;
15
+ left: 44px;
16
+ display: flex;
17
+ `);let t="";const o="margin-left:4px;margin-right:4px;display:flex;align-items:center;";return r.forEach((e,n)=>{const d=n===r.length-1?"margin-left:0px;margin-right:0px;":"";t+=`<span id=${e.id} key=${n} style=${o}${d}>${e.icon}</span>`}),i.innerHTML=t,i.childNodes.forEach(e=>{e.addEventListener("click",n=>{switch(n.stopPropagation(),e==null?void 0:e.id){case"cuboidLeft":this.onToggleDirection(s.Left);break;case"cuboidRight":this.onToggleDirection(s.Right);break;case"cuboidTop":this.onToggleDirection(s.Top);break}this.clearCuboidMoreListDOM(),this.cuboidButtonMove("out")})}),i}update(i){var t;const{left:o,top:e,color:n}=i;(t=this._cuboidButtonDOM)==null||t.setAttribute("style",`
18
+ position: absolute;
19
+ font-size: 14px;
20
+ left:${o}px;
21
+ top: ${e}px;
22
+ color: ${n};
23
+ width: 41px;
24
+ height: 74px;
25
+ border-radius: 10px;
26
+ background-color: #FFFFFF;
27
+ cursor: pointer;
28
+ text-align: center;
29
+ padding-top: 10px;
30
+ z-index: 10;
31
+ `)}clearCuboidButtonDOM(){this._cuboidButtonDOM&&this.container.contains(this._cuboidButtonDOM)&&this.container.removeChild(this._cuboidButtonDOM)}clearCuboidMoreListDOM(){this._cuboidButtonDOM&&this._cuboidMoreListDOM&&this._cuboidButtonDOM.contains(this._cuboidMoreListDOM)&&this._cuboidButtonDOM.removeChild(this._cuboidMoreListDOM)}}export{M as default};