@labelbee/lb-annotation 1.19.0-alpha.1 → 1.19.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constant/keyCode.js +1 -1
- package/dist/constant/style.js +1 -1
- package/dist/constant/tool.js +1 -1
- package/dist/core/scheduler.js +1 -1
- package/dist/core/toolOperation/LineToolOperation.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/constant/keyCode.d.ts +5 -0
- package/dist/types/constant/style.d.ts +1 -0
- package/dist/types/constant/tool.d.ts +5 -1
- package/dist/types/core/toolOperation/LineToolOperation.d.ts +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/utils/EventBus.d.ts +4 -4
- package/dist/types/utils/tool/CommonToolUtils.d.ts +20 -0
- package/dist/utils/EventBus.js +1 -0
- package/dist/utils/tool/CommonToolUtils.js +1 -1
- package/es/constant/keyCode.js +1 -1
- package/es/constant/style.js +1 -1
- package/es/constant/tool.js +1 -1
- package/es/core/scheduler.js +1 -1
- package/es/core/toolOperation/LineToolOperation.js +1 -1
- package/es/index.js +1 -1
- package/es/utils/EventBus.js +1 -0
- package/es/utils/tool/CommonToolUtils.js +1 -1
- package/package.json +2 -2
package/dist/constant/keyCode.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var EKeyCode;(function(t){t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.L=76]="L",t[t.R=82]="R",t[t.Z=90]="Z",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.S=83]="S",t[t.Q=81]="Q",t[t.Delete=46]="Delete",t[t.F11=122]="F11",t[t.Space=32]="Space",t[t.Esc=27]="Esc",t[t.Left=37]="Left",t[t.Up=38]="Up",t[t.Right=39]="Right",t[t.Down=40]="Down",t[t.Enter=13]="Enter",t[t.Ctrl=17]="Ctrl",t[t.Alt=18]="Alt",t[t.Shift=16]="Shift",t[t.Tab=9]="Tab",t[t.BackSpace=8]="BackSpace"})(EKeyCode||(EKeyCode={}));var EKeyCode$1=EKeyCode;module.exports=EKeyCode$1;
|
|
1
|
+
"use strict";var EKeyCode;(function(t){t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.I=73]="I",t[t.O=79]="O",t[t.L=76]="L",t[t.R=82]="R",t[t.Z=90]="Z",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.S=83]="S",t[t.Q=81]="Q",t[t.One=49]="One",t[t.Two=50]="Two",t[t.Three=51]="Three",t[t.Delete=46]="Delete",t[t.F11=122]="F11",t[t.Space=32]="Space",t[t.Esc=27]="Esc",t[t.Left=37]="Left",t[t.Up=38]="Up",t[t.Right=39]="Right",t[t.Down=40]="Down",t[t.Enter=13]="Enter",t[t.Ctrl=17]="Ctrl",t[t.Alt=18]="Alt",t[t.Shift=16]="Shift",t[t.Tab=9]="Tab",t[t.BackSpace=8]="BackSpace"})(EKeyCode||(EKeyCode={}));var EKeyCode$1=EKeyCode;module.exports=EKeyCode$1;
|
package/dist/constant/style.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var icon_canvasEdit0=require("../assets/attributeIcon/icon_canvasEdit0.svg.js"),icon_canvasEdit1=require("../assets/attributeIcon/icon_canvasEdit1.svg.js"),icon_canvasEdit2=require("../assets/attributeIcon/icon_canvasEdit2.svg.js"),icon_canvasEdit3=require("../assets/attributeIcon/icon_canvasEdit3.svg.js"),icon_canvasEdit4=require("../assets/attributeIcon/icon_canvasEdit4.svg.js"),icon_canvasEdit5=require("../assets/attributeIcon/icon_canvasEdit5.svg.js"),icon_canvasEdit6=require("../assets/attributeIcon/icon_canvasEdit6.svg.js"),icon_canvasEdit7=require("../assets/attributeIcon/icon_canvasEdit7.svg.js"),icon_canvasEdit8=require("../assets/attributeIcon/icon_canvasEdit8.svg.js"),icon_editLAN=require("../assets/attributeIcon/icon_editLAN.svg.js"),icon_editQING=require("../assets/attributeIcon/icon_editQING.svg.js"),icon_editLV=require("../assets/attributeIcon/icon_editLV.svg.js"),icon_editHUANG=require("../assets/attributeIcon/icon_editHUANG.svg.js"),icon_editFEN=require("../assets/attributeIcon/icon_editFEN.svg.js"),tool=require("./tool.js"),icon_canvasEdit_miss=require("../assets/attributeIcon/icon_canvasEdit_miss.svg.js");const NULL_ICON=icon_canvasEdit0,HEADER_HEIGHT=61,TAB_HEIGHT=80,SEARCH_HEIGHT=62,PADDING=20,TABLE_ROW_HEIGHT=55,PAGINATION_HEIGHT=55,TIPS_HEIGHT=40,FOOTER_HEIGHT=80,SIDERBAR_WIDTH=240,EDIT_STEP_WIDTH=320,THEME_COLOR="rgba(102, 111, 255, 1)",COLORS_ARRAY=["rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"],ICON_ARRAY=[icon_canvasEdit0,icon_canvasEdit6,icon_canvasEdit3,icon_canvasEdit7,icon_canvasEdit2,icon_canvasEdit8,icon_canvasEdit5,icon_canvasEdit1,icon_canvasEdit4],BASE_ICON={1:icon_editLAN,3:icon_editQING,5:icon_editLV,7:icon_editHUANG,9:icon_editFEN},INVALID_COLOR="rgba(255, 51, 51, 1)",INVALID_COLOR_RGBA={r:255,g:51,b:51,a:1},NULL_COLOR="rgba(204, 204, 204, 1)",FILTER_TOOL_COLOR={[tool.EFilterToolOperation.lc]:"rgba(153, 51, 255, 1)",[tool.EFilterToolOperation.rc]:"rgba(51, 153, 255, 1)",[tool.EFilterToolOperation.clc]:"rgba(46, 230, 46, 1)",[tool.EFilterToolOperation.crc]:"rgba(255, 51, 51, 1)"},styleString='{"color":1,"width":2,"borderOpacity":9,"fillOpacity":9,"toolColor":{"1":{"valid":{"stroke":"rgba(0,0,255,0.50)","fill":"rgba(0,0,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(0,15,255,1.00)","fill":"rgba(0,15,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(0,15,255,0.80)","fill":"rgba(0,15,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"3":{"valid":{"stroke":"rgba(0,255,255,0.50)","fill":"rgba(0,255,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(0,212,255,1.00)","fill":"rgba(0,212,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(0,212,255,0.80)","fill":"rgba(0,212,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"5":{"valid":{"stroke":"rgba(0,255,0,0.50)","fill":"rgba(0,255,0,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(149,255,1.00)","fill":"rgba(149,255,0,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(149,255,0,0.80)","fill":"rgba(149,255,0,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"7":{"valid":{"stroke":"rgba(255,255,0,0.50)","fill":"rgba(255,255,0,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(255,230,102,1.00)","fill":"rgba(255,213,0,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(255,230,102,0.80)","fill":"rgba(255,230,102,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"9":{"valid":{"stroke":"rgba(255,0,255,0.50)","fill":"rgba(255,0,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(230,102,255,1.00)","fill":"rgba(213,0,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(230,102,255,0.80)","fill":"rgba(230,102,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}}},"attributeColor":[{"valid":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}}],"lineColor":{"1":"rgba(102, 111, 255, 1 )","3":"rgba(102, 230, 255, 1)","5":"rgba(191, 255, 102, 1)","7":"rgba(255, 230, 102, 1)","9":"rgba(230, 102, 255, 1)"},"attributeLineColor":["rgba(204, 204, 204, 1)","rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"]}';exports.INVALID_ICON=icon_canvasEdit_miss,exports.BASE_ICON=BASE_ICON,exports.COLORS_ARRAY=COLORS_ARRAY,exports.EDIT_STEP_WIDTH=EDIT_STEP_WIDTH,exports.FILTER_TOOL_COLOR=FILTER_TOOL_COLOR,exports.FOOTER_HEIGHT=FOOTER_HEIGHT,exports.HEADER_HEIGHT=HEADER_HEIGHT,exports.ICON_ARRAY=ICON_ARRAY,exports.INVALID_COLOR=INVALID_COLOR,exports.INVALID_COLOR_RGBA=INVALID_COLOR_RGBA,exports.NULL_COLOR=NULL_COLOR,exports.NULL_ICON=NULL_ICON,exports.PADDING=PADDING,exports.PAGINATION_HEIGHT=PAGINATION_HEIGHT,exports.SEARCH_HEIGHT=SEARCH_HEIGHT,exports.SIDERBAR_WIDTH=SIDERBAR_WIDTH,exports.TABLE_ROW_HEIGHT=TABLE_ROW_HEIGHT,exports.TAB_HEIGHT=TAB_HEIGHT,exports.THEME_COLOR=THEME_COLOR,exports.TIPS_HEIGHT=TIPS_HEIGHT,exports.styleString=styleString;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var icon_canvasEdit0=require("../assets/attributeIcon/icon_canvasEdit0.svg.js"),icon_canvasEdit1=require("../assets/attributeIcon/icon_canvasEdit1.svg.js"),icon_canvasEdit2=require("../assets/attributeIcon/icon_canvasEdit2.svg.js"),icon_canvasEdit3=require("../assets/attributeIcon/icon_canvasEdit3.svg.js"),icon_canvasEdit4=require("../assets/attributeIcon/icon_canvasEdit4.svg.js"),icon_canvasEdit5=require("../assets/attributeIcon/icon_canvasEdit5.svg.js"),icon_canvasEdit6=require("../assets/attributeIcon/icon_canvasEdit6.svg.js"),icon_canvasEdit7=require("../assets/attributeIcon/icon_canvasEdit7.svg.js"),icon_canvasEdit8=require("../assets/attributeIcon/icon_canvasEdit8.svg.js"),icon_editLAN=require("../assets/attributeIcon/icon_editLAN.svg.js"),icon_editQING=require("../assets/attributeIcon/icon_editQING.svg.js"),icon_editLV=require("../assets/attributeIcon/icon_editLV.svg.js"),icon_editHUANG=require("../assets/attributeIcon/icon_editHUANG.svg.js"),icon_editFEN=require("../assets/attributeIcon/icon_editFEN.svg.js"),tool=require("./tool.js"),icon_canvasEdit_miss=require("../assets/attributeIcon/icon_canvasEdit_miss.svg.js");const NULL_ICON=icon_canvasEdit0,HEADER_HEIGHT=61,TAB_HEIGHT=80,SEARCH_HEIGHT=62,PADDING=20,TABLE_ROW_HEIGHT=55,PAGINATION_HEIGHT=55,TIPS_HEIGHT=40,FOOTER_HEIGHT=80,SIDERBAR_WIDTH=240,EDIT_STEP_WIDTH=320,THEME_COLOR="rgba(102, 111, 255, 1)",COLORS_ARRAY=["rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"],WHITE_FONT_COLOR_ARRAY=["rgba(128, 12, 249, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)"],ICON_ARRAY=[icon_canvasEdit0,icon_canvasEdit6,icon_canvasEdit3,icon_canvasEdit7,icon_canvasEdit2,icon_canvasEdit8,icon_canvasEdit5,icon_canvasEdit1,icon_canvasEdit4],BASE_ICON={1:icon_editLAN,3:icon_editQING,5:icon_editLV,7:icon_editHUANG,9:icon_editFEN},INVALID_COLOR="rgba(255, 51, 51, 1)",INVALID_COLOR_RGBA={r:255,g:51,b:51,a:1},NULL_COLOR="rgba(204, 204, 204, 1)",FILTER_TOOL_COLOR={[tool.EFilterToolOperation.lc]:"rgba(153, 51, 255, 1)",[tool.EFilterToolOperation.rc]:"rgba(51, 153, 255, 1)",[tool.EFilterToolOperation.clc]:"rgba(46, 230, 46, 1)",[tool.EFilterToolOperation.crc]:"rgba(255, 51, 51, 1)"},styleString='{"color":1,"width":2,"borderOpacity":9,"fillOpacity":9,"toolColor":{"1":{"valid":{"stroke":"rgba(0,0,255,0.50)","fill":"rgba(0,0,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(0,15,255,1.00)","fill":"rgba(0,15,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(0,15,255,0.80)","fill":"rgba(0,15,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"3":{"valid":{"stroke":"rgba(0,255,255,0.50)","fill":"rgba(0,255,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(0,212,255,1.00)","fill":"rgba(0,212,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(0,212,255,0.80)","fill":"rgba(0,212,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"5":{"valid":{"stroke":"rgba(0,255,0,0.50)","fill":"rgba(0,255,0,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(149,255,1.00)","fill":"rgba(149,255,0,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(149,255,0,0.80)","fill":"rgba(149,255,0,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"7":{"valid":{"stroke":"rgba(255,255,0,0.50)","fill":"rgba(255,255,0,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(255,230,102,1.00)","fill":"rgba(255,213,0,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(255,230,102,0.80)","fill":"rgba(255,230,102,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"9":{"valid":{"stroke":"rgba(255,0,255,0.50)","fill":"rgba(255,0,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(230,102,255,1.00)","fill":"rgba(213,0,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(230,102,255,0.80)","fill":"rgba(230,102,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}}},"attributeColor":[{"valid":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}}],"lineColor":{"1":"rgba(102, 111, 255, 1 )","3":"rgba(102, 230, 255, 1)","5":"rgba(191, 255, 102, 1)","7":"rgba(255, 230, 102, 1)","9":"rgba(230, 102, 255, 1)"},"attributeLineColor":["rgba(204, 204, 204, 1)","rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"]}';exports.INVALID_ICON=icon_canvasEdit_miss,exports.BASE_ICON=BASE_ICON,exports.COLORS_ARRAY=COLORS_ARRAY,exports.EDIT_STEP_WIDTH=EDIT_STEP_WIDTH,exports.FILTER_TOOL_COLOR=FILTER_TOOL_COLOR,exports.FOOTER_HEIGHT=FOOTER_HEIGHT,exports.HEADER_HEIGHT=HEADER_HEIGHT,exports.ICON_ARRAY=ICON_ARRAY,exports.INVALID_COLOR=INVALID_COLOR,exports.INVALID_COLOR_RGBA=INVALID_COLOR_RGBA,exports.NULL_COLOR=NULL_COLOR,exports.NULL_ICON=NULL_ICON,exports.PADDING=PADDING,exports.PAGINATION_HEIGHT=PAGINATION_HEIGHT,exports.SEARCH_HEIGHT=SEARCH_HEIGHT,exports.SIDERBAR_WIDTH=SIDERBAR_WIDTH,exports.TABLE_ROW_HEIGHT=TABLE_ROW_HEIGHT,exports.TAB_HEIGHT=TAB_HEIGHT,exports.THEME_COLOR=THEME_COLOR,exports.TIPS_HEIGHT=TIPS_HEIGHT,exports.WHITE_FONT_COLOR_ARRAY=WHITE_FONT_COLOR_ARRAY,exports.styleString=styleString;
|
package/dist/constant/tool.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const editStepWidth=320;exports.EPointCloudName=void 0,function(o){o.PointCloud="pointCloudTool"}(exports.EPointCloudName||(exports.EPointCloudName={})),exports.EVideoToolName=void 0,function(o){o.VideoTextTool="videoTextTool",o.VideoTagTool="videoTagTool",o.VideoClipTool="videoClipTool"}(exports.EVideoToolName||(exports.EVideoToolName={})),exports.EToolType=void 0,function(o){o[o.Rect=0]="Rect",o[o.Tag=1]="Tag"}(exports.EToolType||(exports.EToolType={})),exports.EToolName=void 0,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",o.LLM="LLMTool"}(exports.EToolName||(exports.EToolName={})),exports.ECheckModel=void 0,function(o){o.Check="check"}(exports.ECheckModel||(exports.ECheckModel={})),exports.ERectPattern=void 0,function(o){o[o.nothing=0]="nothing",o[o.RectBG=1]="RectBG",o[o.showOrder=2]="showOrder"}(exports.ERectPattern||(exports.ERectPattern={}));const TOOL_NAME={[exports.EToolName.Rect]:"\u62C9\u6846",[exports.EToolName.Tag]:"\u6807\u7B7E",[exports.EToolName.Point]:"\u6807\u70B9",[exports.EToolName.PointMarker]:"\u5217\u8868\u6807\u70B9",[exports.EToolName.Segmentation]:"\u524D\u666F\u5206\u5272",[exports.EToolName.Filter]:"\u7B5B\u9009",[exports.EToolName.Text]:"\u6587\u672C",[exports.EToolName.Polygon]:"\u591A\u8FB9\u5F62",[exports.EToolName.Line]:"\u7EBF\u6761",[exports.EToolName.LineMarker]:"\u5217\u8868\u7EBF\u6761",[exports.EToolName.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[exports.EToolName.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[exports.EToolName.Face]:"\u4EBA\u8138106\u5DE5\u5177",[exports.EToolName.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[exports.EToolName.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[exports.EToolName.SegmentByRect]:"\u7B97\u6CD5\u5206\u5272\u8F85\u52A9\u5DE5\u5177",[exports.EVideoToolName.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[exports.EVideoToolName.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[exports.EVideoToolName.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[exports.EPointCloudName.PointCloud]:"\u70B9\u4E91",[exports.EToolName.Cuboid]:"\u7ACB\u4F53\u6846",[exports.EToolName.LLM]:"LLM\u6807\u6CE8"},TOOL_NAME_EN={[exports.EToolName.Rect]:"Rect",[exports.EToolName.Tag]:"Tag",[exports.EToolName.Point]:"Point",[exports.EToolName.PointMarker]:"PointMarker",[exports.EToolName.Segmentation]:"Segmentation",[exports.EToolName.Filter]:"Filter",[exports.EToolName.Text]:"Text",[exports.EToolName.Polygon]:"Polygon",[exports.EToolName.Line]:"Line",[exports.EToolName.LineMarker]:"LineMarker",[exports.EToolName.FolderTag]:"FolderTag",[exports.EToolName.RectTrack]:"RectTrack",[exports.EToolName.Face]:"Face",[exports.EToolName.ClientAttribute]:"ClientAttribute",[exports.EToolName.OCRRelation]:"OCRRelation",[exports.EToolName.SegmentByRect]:"SegmentByRect",[exports.EVideoToolName.VideoTextTool]:"VideoTextTool",[exports.EVideoToolName.VideoTagTool]:"VideoTagTool",[exports.EVideoToolName.VideoClipTool]:"VideoClipTool",[exports.EPointCloudName.PointCloud]:"PointCloud",[exports.EToolName.Cuboid]:"Cuboid",[exports.EToolName.LLM]:"LLM"};exports.EDependPattern=void 0,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"}(exports.EDependPattern||(exports.EDependPattern={})),exports.EFilterToolOperation=void 0,function(o){o.lc="leftClick",o.rc="rightClick",o.clc="ctrlLeftClick",o.crc="ctrlRightClick"}(exports.EFilterToolOperation||(exports.EFilterToolOperation={}));const OPERATION_LIST={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};exports.EAnnotationMode=void 0,function(o){o[o.Normal=1]="Normal",o[o.Modify=2]="Modify"}(exports.EAnnotationMode||(exports.EAnnotationMode={})),exports.ELineTypes=void 0,function(o){o[o.Line=0]="Line",o[o.Curve=1]="Curve"}(exports.ELineTypes||(exports.ELineTypes={})),exports.ELineColor=void 0,function(o){o[o.SingleColor=0]="SingleColor",o[o.MultiColor=1]="MultiColor"}(exports.ELineColor||(exports.ELineColor={})),exports.ESelectedType=void 0,function(o){o[o.Form=1]="Form",o[o.Json=2]="Json"}(exports.ESelectedType||(exports.ESelectedType={})),exports.EDragTarget=void 0,function(o){o[o.Point=0]="Point",o[o.Line=1]="Line",o[o.Plane=2]="Plane"}(exports.EDragTarget||(exports.EDragTarget={})),exports.EDrawPointPattern=void 0,function(o){o[o.None=0]="None",o[o.Drawing=1]="Drawing",o[o.Edit=2]="Edit"}(exports.EDrawPointPattern||(exports.EDrawPointPattern={})),exports.EPageOperator=void 0,function(o){o[o.Backward=0]="Backward",o[o.Forward=1]="Forward",o[o.JumpSkip=2]="JumpSkip",o[o.None=3]="None"}(exports.EPageOperator||(exports.EPageOperator={})),exports.EAuditStatus=void 0,function(o){o[o.Wait=0]="Wait",o[o.Pass=1]="Pass",o[o.Fail=2]="Fail",o[o.Loading=3]="Loading"}(exports.EAuditStatus||(exports.EAuditStatus={})),exports.ETextType=void 0,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"}(exports.ETextType||(exports.ETextType={}));const TEXT_TYPE={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},TEXT_ATTRIBUTE_MAX_LENGTH=1e3,TEXT_ATTRIBUTE_LINE_HEIGHT=16,DEFAULT_TEXT_MAX_WIDTH=300,DEFAULT_FONT="normal normal 500 14px Arial";exports.EThumbnailOption=void 0,function(o){o[o.ImgList=1e3]="ImgList",o[o.TrackPrediction=1001]="TrackPrediction",o[o.ImgSearch=1002]="ImgSearch"}(exports.EThumbnailOption||(exports.EThumbnailOption={}));const CLIENT_TOOL_HEAD_TYPE={[exports.EPointCloudName.PointCloud]:"sensebeepc",[exports.EToolName.ClientAttribute]:"sensebeepc-EnumAttributeTool",[exports.EToolName.Face]:"sensebeepc-FacePointsLabellingTool",[exports.EToolName.OCRRelation]:"sensebeepc-OCRRelationTool"},CLIENT_TOOL_NAME={[exports.EPointCloudName.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[exports.EToolName.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[exports.EToolName.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[exports.EToolName.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},SEGMENT_NUMBER=16,edgeAdsorptionScope=10;exports.EPolygonPattern=void 0,function(o){o[o.Normal=0]="Normal",o[o.Rect=1]="Rect"}(exports.EPolygonPattern||(exports.EPolygonPattern={})),exports.EScribblePattern=void 0,function(o){o[o.Scribble=1]="Scribble",o[o.Erase=2]="Erase"}(exports.EScribblePattern||(exports.EScribblePattern={})),exports.EOperationMode=void 0,function(o){o[o.General=1]="General",o[o.MultiMove=2]="MultiMove"}(exports.EOperationMode||(exports.EOperationMode={})),exports.CLIENT_TOOL_HEAD_TYPE=CLIENT_TOOL_HEAD_TYPE,exports.CLIENT_TOOL_NAME=CLIENT_TOOL_NAME,exports.DEFAULT_FONT=DEFAULT_FONT,exports.DEFAULT_TEXT_MAX_WIDTH=DEFAULT_TEXT_MAX_WIDTH,exports.OPERATION_LIST=OPERATION_LIST,exports.SEGMENT_NUMBER=SEGMENT_NUMBER,exports.TEXT_ATTRIBUTE_LINE_HEIGHT=TEXT_ATTRIBUTE_LINE_HEIGHT,exports.TEXT_ATTRIBUTE_MAX_LENGTH=TEXT_ATTRIBUTE_MAX_LENGTH,exports.TEXT_TYPE=TEXT_TYPE,exports.TOOL_NAME=TOOL_NAME,exports.TOOL_NAME_EN=TOOL_NAME_EN,exports.edgeAdsorptionScope=edgeAdsorptionScope,exports.editStepWidth=editStepWidth;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const editStepWidth=320;exports.EPointCloudName=void 0,function(o){o.PointCloud="pointCloudTool"}(exports.EPointCloudName||(exports.EPointCloudName={})),exports.EVideoToolName=void 0,function(o){o.VideoTextTool="videoTextTool",o.VideoTagTool="videoTagTool",o.VideoClipTool="videoClipTool"}(exports.EVideoToolName||(exports.EVideoToolName={})),exports.EAudioToolName=void 0,function(o){o.AudioTextTool="audioTextTool"}(exports.EAudioToolName||(exports.EAudioToolName={})),exports.EToolType=void 0,function(o){o[o.Rect=0]="Rect",o[o.Tag=1]="Tag"}(exports.EToolType||(exports.EToolType={})),exports.EToolName=void 0,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",o.LLM="LLMTool"}(exports.EToolName||(exports.EToolName={})),exports.ECheckModel=void 0,function(o){o.Check="check"}(exports.ECheckModel||(exports.ECheckModel={})),exports.ERectPattern=void 0,function(o){o[o.nothing=0]="nothing",o[o.RectBG=1]="RectBG",o[o.showOrder=2]="showOrder"}(exports.ERectPattern||(exports.ERectPattern={}));const TOOL_NAME={[exports.EToolName.Rect]:"\u62C9\u6846",[exports.EToolName.Tag]:"\u6807\u7B7E",[exports.EToolName.Point]:"\u6807\u70B9",[exports.EToolName.PointMarker]:"\u5217\u8868\u6807\u70B9",[exports.EToolName.Segmentation]:"\u524D\u666F\u5206\u5272",[exports.EToolName.Filter]:"\u7B5B\u9009",[exports.EToolName.Text]:"\u6587\u672C",[exports.EToolName.Polygon]:"\u591A\u8FB9\u5F62",[exports.EToolName.Line]:"\u7EBF\u6761",[exports.EToolName.LineMarker]:"\u5217\u8868\u7EBF\u6761",[exports.EToolName.FolderTag]:"\u6587\u4EF6\u5939\u6807\u7B7E",[exports.EToolName.RectTrack]:"\u62C9\u6846\u8DDF\u8E2A",[exports.EToolName.Face]:"\u4EBA\u8138106\u5DE5\u5177",[exports.EToolName.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[exports.EToolName.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177",[exports.EToolName.SegmentByRect]:"\u7B97\u6CD5\u5206\u5272\u8F85\u52A9\u5DE5\u5177",[exports.EVideoToolName.VideoTextTool]:"\u89C6\u9891\u6587\u672C",[exports.EVideoToolName.VideoTagTool]:"\u89C6\u9891\u6807\u7B7E",[exports.EVideoToolName.VideoClipTool]:"\u89C6\u9891\u622A\u53D6",[exports.EPointCloudName.PointCloud]:"\u70B9\u4E91",[exports.EToolName.Cuboid]:"\u7ACB\u4F53\u6846",[exports.EToolName.LLM]:"LLM\u6807\u6CE8"},TOOL_NAME_EN={[exports.EToolName.Rect]:"Rect",[exports.EToolName.Tag]:"Tag",[exports.EToolName.Point]:"Point",[exports.EToolName.PointMarker]:"PointMarker",[exports.EToolName.Segmentation]:"Segmentation",[exports.EToolName.Filter]:"Filter",[exports.EToolName.Text]:"Text",[exports.EToolName.Polygon]:"Polygon",[exports.EToolName.Line]:"Line",[exports.EToolName.LineMarker]:"LineMarker",[exports.EToolName.FolderTag]:"FolderTag",[exports.EToolName.RectTrack]:"RectTrack",[exports.EToolName.Face]:"Face",[exports.EToolName.ClientAttribute]:"ClientAttribute",[exports.EToolName.OCRRelation]:"OCRRelation",[exports.EToolName.SegmentByRect]:"SegmentByRect",[exports.EVideoToolName.VideoTextTool]:"VideoTextTool",[exports.EVideoToolName.VideoTagTool]:"VideoTagTool",[exports.EVideoToolName.VideoClipTool]:"VideoClipTool",[exports.EPointCloudName.PointCloud]:"PointCloud",[exports.EToolName.Cuboid]:"Cuboid",[exports.EToolName.LLM]:"LLM"};exports.EDependPattern=void 0,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"}(exports.EDependPattern||(exports.EDependPattern={})),exports.EFilterToolOperation=void 0,function(o){o.lc="leftClick",o.rc="rightClick",o.clc="ctrlLeftClick",o.crc="ctrlRightClick"}(exports.EFilterToolOperation||(exports.EFilterToolOperation={}));const OPERATION_LIST={leftClick:"\u9F20\u6807\u5DE6\u952E",rightClick:"\u9F20\u6807\u53F3\u952E",ctrlLeftClick:"ctrl + \u9F20\u6807\u5DE6\u952E",ctrlRightClick:"ctrl + \u9F20\u6807\u53F3\u952E"};exports.EAnnotationMode=void 0,function(o){o[o.Normal=1]="Normal",o[o.Modify=2]="Modify"}(exports.EAnnotationMode||(exports.EAnnotationMode={})),exports.ELineTypes=void 0,function(o){o[o.Line=0]="Line",o[o.Curve=1]="Curve"}(exports.ELineTypes||(exports.ELineTypes={})),exports.ELineColor=void 0,function(o){o[o.SingleColor=0]="SingleColor",o[o.MultiColor=1]="MultiColor"}(exports.ELineColor||(exports.ELineColor={})),exports.ESelectedType=void 0,function(o){o[o.Form=1]="Form",o[o.Json=2]="Json"}(exports.ESelectedType||(exports.ESelectedType={})),exports.EDragTarget=void 0,function(o){o[o.Point=0]="Point",o[o.Line=1]="Line",o[o.Plane=2]="Plane"}(exports.EDragTarget||(exports.EDragTarget={})),exports.EDrawPointPattern=void 0,function(o){o[o.None=0]="None",o[o.Drawing=1]="Drawing",o[o.Edit=2]="Edit"}(exports.EDrawPointPattern||(exports.EDrawPointPattern={})),exports.EPageOperator=void 0,function(o){o[o.Backward=0]="Backward",o[o.Forward=1]="Forward",o[o.JumpSkip=2]="JumpSkip",o[o.None=3]="None"}(exports.EPageOperator||(exports.EPageOperator={})),exports.EAuditStatus=void 0,function(o){o[o.Wait=0]="Wait",o[o.Pass=1]="Pass",o[o.Fail=2]="Fail",o[o.Loading=3]="Loading"}(exports.EAuditStatus||(exports.EAuditStatus={})),exports.ETextType=void 0,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"}(exports.ETextType||(exports.ETextType={}));const TEXT_TYPE={0:"\u4EFB\u610F\u5B57\u7B26",1:"\u5E8F\u53F7",2:"\u4EC5\u82F1\u6587",3:"\u4EC5\u6570\u5B57"},TEXT_ATTRIBUTE_MAX_LENGTH=1e3,TEXT_ATTRIBUTE_LINE_HEIGHT=16,DEFAULT_TEXT_MAX_WIDTH=300,DEFAULT_FONT="normal normal 500 14px Arial";exports.EThumbnailOption=void 0,function(o){o[o.ImgList=1e3]="ImgList",o[o.TrackPrediction=1001]="TrackPrediction",o[o.ImgSearch=1002]="ImgSearch"}(exports.EThumbnailOption||(exports.EThumbnailOption={}));const CLIENT_TOOL_HEAD_TYPE={[exports.EPointCloudName.PointCloud]:"sensebeepc",[exports.EToolName.ClientAttribute]:"sensebeepc-EnumAttributeTool",[exports.EToolName.Face]:"sensebeepc-FacePointsLabellingTool",[exports.EToolName.OCRRelation]:"sensebeepc-OCRRelationTool"},CLIENT_TOOL_NAME={[exports.EPointCloudName.PointCloud]:"\u70B9\u4E91\u5BA2\u6237\u7AEF",[exports.EToolName.ClientAttribute]:"\u5BA2\u6237\u7AEF\u5C5E\u6027\u5DE5\u5177",[exports.EToolName.Face]:"\u4EBA\u8138106\u70B9\u5DE5\u5177",[exports.EToolName.OCRRelation]:"OCR\u5173\u8054\u5173\u7CFB\u5DE5\u5177"},SEGMENT_NUMBER=16,edgeAdsorptionScope=10;exports.EPolygonPattern=void 0,function(o){o[o.Normal=0]="Normal",o[o.Rect=1]="Rect"}(exports.EPolygonPattern||(exports.EPolygonPattern={})),exports.EScribblePattern=void 0,function(o){o[o.Scribble=1]="Scribble",o[o.Erase=2]="Erase"}(exports.EScribblePattern||(exports.EScribblePattern={})),exports.EOperationMode=void 0,function(o){o[o.General=1]="General",o[o.MultiMove=2]="MultiMove"}(exports.EOperationMode||(exports.EOperationMode={})),exports.CLIENT_TOOL_HEAD_TYPE=CLIENT_TOOL_HEAD_TYPE,exports.CLIENT_TOOL_NAME=CLIENT_TOOL_NAME,exports.DEFAULT_FONT=DEFAULT_FONT,exports.DEFAULT_TEXT_MAX_WIDTH=DEFAULT_TEXT_MAX_WIDTH,exports.OPERATION_LIST=OPERATION_LIST,exports.SEGMENT_NUMBER=SEGMENT_NUMBER,exports.TEXT_ATTRIBUTE_LINE_HEIGHT=TEXT_ATTRIBUTE_LINE_HEIGHT,exports.TEXT_ATTRIBUTE_MAX_LENGTH=TEXT_ATTRIBUTE_MAX_LENGTH,exports.TEXT_TYPE=TEXT_TYPE,exports.TOOL_NAME=TOOL_NAME,exports.TOOL_NAME_EN=TOOL_NAME_EN,exports.edgeAdsorptionScope=edgeAdsorptionScope,exports.editStepWidth=editStepWidth;
|
package/dist/core/scheduler.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var defaultConfig=require("../constant/defaultConfig.js"),EnhanceCommonToolUtils=require("../utils/tool/EnhanceCommonToolUtils.js"),basicToolOperation=require("./toolOperation/basicToolOperation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,t,o)=>t in i?__defProp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[t]=o,__spreadValues=(i,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(i,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(i,o,t[o]);return i},__spreadProps=(i,t)=>__defProps(i,__getOwnPropDescs(t));const createEmptyImage=i=>{const t=document.createElement("canvas");t.width=i.width,t.height=i.height;const o=t.getContext("2d");return o?(o.fillStyle="transparent",o.fillRect(0,0,i.width,i.height),t.toDataURL()):""},arraySwap=(i,t,o)=>{const e=i[t];return i[t]=i[o],i[o]=e,i},_HybridToolUtils=class{static isSingleTool(i){return!this.isHybridTool(i)}static isHybridTool(i){return Array.isArray(i)}};let HybridToolUtils=_HybridToolUtils;HybridToolUtils.getTopToolName=i=>_HybridToolUtils.isHybridTool(i)?i[i.length-1]:i;class ToolScheduler{constructor(t){this.toolOperationList=[],this.toolOperationDom=[],this.toolOperationNameList=[];var o,e;this.container=t.container,this.size=t.size,this.imgNode=t.imgNode,this.config=(o=t.config)!=null?o:JSON.stringify(defaultConfig.getConfig(HybridToolUtils.getTopToolName(t.toolName))),this.style=(e=t.style)!=null?e:defaultConfig.styleDefaultConfig,this.proxyMode=t.proxyMode,this.onWheel=this.onWheel.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.init()}setImgNode(t,o){this.toolOperationList.forEach(e=>{e.setImgNode(t,o)})}setImgAttribute(t){this.toolOperationList.forEach(o=>{o.setImgAttribute(t)})}syncAllAttributeListInConfig(t){this.toolOperationList.forEach(o=>{const e=__spreadProps(__spreadValues({},o.config),{attributeList:t});o.setConfig(JSON.stringify(e))})}setSize(t){t.width&&t.height&&this.toolOperationDom.forEach(o=>{o.style.width=`${t.width}px`,o.style.height=`${t.height}px`}),this.toolOperationList.forEach(o=>{o.setSize(t)})}syncPosition(t,o,e,n){this.toolOperationList.forEach(a=>{n!==a&&(a.setCurrentPos(t),a.setZoom(o),a.setImgInfo(e),a.renderBasicCanvas(),a.render())})}get defaultSize(){var t,o;return{width:((t=this.imgNode)==null?void 0:t.width)||this.size.width,height:((o=this.imgNode)==null?void 0:o.height)||this.size.height}}createDom(){const{width:t,height:o}=this.defaultSize,e=window.document.createElement("div");e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.width=`${t}px`,e.style.height=`${o}px`;const n=this.toolOperationList.length+1;return e.style.zIndex=`${n}`,e}getEmptyImage(t,o){const e=createEmptyImage({width:t,height:o}),n=new Image;return n.src=e,n}createOperation(t,o,e){var n;const{width:a,height:l}=this.defaultSize,r=this.createDom(),c=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:o||c,hiddenImg:!!t};e&&Object.assign(h,e);let s;if(!t)s=new basicToolOperation.BasicToolOperation(h),r.style.zIndex="0",s.init();else{const p=EnhanceCommonToolUtils.getCurrentOperation(t);if(!p)return;s=new p(h)}return s==null||s.init(),s.canvas.id=t!=null?t:"basicCanvas",s.on("dragMove",({currentPos:p,zoom:d,imgInfo:u})=>{this.syncPosition(p,d,u,s)}),s.on("renderZoom",(p,d,u)=>{p&&d&&this.syncPosition(d,p,u,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,o=t-1,e=t-2,n=this.toolOperationDom[o],a=this.toolOperationDom[e];if(!(!a||!n))return n.style.zIndex=`${o-1}`,a.style.zIndex=`${o}`,this.toolOperationList[o].clearActiveStatus(),this.toolOperationList[o].clearCursorLine(),this.toolOperationList[o].render(),this.toolOperationList=arraySwap(this.toolOperationList,o,e),this.toolOperationDom=arraySwap(this.toolOperationDom,o,e),this.toolOperationList[o]}getFirstToolOperation(){return this.toolOperationList.length>1?this.toolOperationList[1]:this.toolOperationList[0]}switchToCanvas(t){var o,e,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,c=this.toolOperationDom[l],h=this.toolOperationDom[r];if(!c||!h)return;const s=h.style.zIndex;return h.style.zIndex=`${c.style.zIndex}`,c.style.zIndex=`${s}`,(e=(o=this.toolOperationList[r]).clearActiveStatus)==null||e.call(o),(a=(n=this.toolOperationList[r]).clearCursorLine)==null||a.call(n),this.toolOperationList[r].render(),this.toolOperationList=arraySwap(this.toolOperationList,r,l),this.toolOperationDom=arraySwap(this.toolOperationDom,r,l),this.toolOperationNameList=arraySwap(this.toolOperationNameList,r,l),this.toolOperationList[r]}updateDataByToolName(t,o){const e=this.toolOperationNameList.indexOf(t);e>=0&&this.toolOperationList[e].setResult(o)}clearStatusAndResult(){this.toolOperationList.forEach(t=>{var o;(o=t.clearActiveStatus)==null||o.call(t),t.clearResult()})}destroyAllLayer(){this.toolOperationList.forEach(t=>{t.destroyCanvas(),this.init()})}init(){this.toolOperationList=[],this.toolOperationDom=[],this.eventBinding()}destroy(){this.destroyAllLayer(),this.eventUnBinding()}eventBinding(){this.proxyMode&&(this.container.addEventListener("wheel",this.onWheel),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp))}eventUnBinding(){this.proxyMode&&(this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp))}onWheel(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onWheel(t)}}onMouseDown(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseDown(t)}}onMouseMove(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseMove(t)}}onMouseUp(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseUp(t)}}getCurrentToolName(){return this.toolOperationNameList[this.toolOperationNameList.length-1]}}exports.HybridToolUtils=HybridToolUtils,exports.ToolScheduler=ToolScheduler;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var defaultConfig=require("../constant/defaultConfig.js"),EnhanceCommonToolUtils=require("../utils/tool/EnhanceCommonToolUtils.js"),basicToolOperation=require("./toolOperation/basicToolOperation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,t,o)=>t in i?__defProp(i,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[t]=o,__spreadValues=(i,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(i,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(i,o,t[o]);return i},__spreadProps=(i,t)=>__defProps(i,__getOwnPropDescs(t));const createEmptyImage=i=>{const t=document.createElement("canvas");t.width=i.width,t.height=i.height;const o=t.getContext("2d");return o?(o.fillStyle="transparent",o.fillRect(0,0,i.width,i.height),t.toDataURL()):""},arraySwap=(i,t,o)=>{const e=i[t];return i[t]=i[o],i[o]=e,i},_HybridToolUtils=class{static isSingleTool(i){return!this.isHybridTool(i)}static isHybridTool(i){return Array.isArray(i)}};let HybridToolUtils=_HybridToolUtils;HybridToolUtils.getTopToolName=i=>_HybridToolUtils.isHybridTool(i)?i[i.length-1]:i;class ToolScheduler{constructor(t){this.toolOperationList=[],this.toolOperationDom=[],this.toolOperationNameList=[];var o,e;this.container=t.container,this.size=t.size,this.imgNode=t.imgNode,this.config=(o=t.config)!=null?o:JSON.stringify(defaultConfig.getConfig(HybridToolUtils.getTopToolName(t.toolName))),this.style=(e=t.style)!=null?e:defaultConfig.styleDefaultConfig,this.proxyMode=t.proxyMode,this.onWheel=this.onWheel.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.init()}setImgNode(t,o){this.toolOperationList.forEach(e=>{e.setImgNode(t,o)})}setImgAttribute(t){this.toolOperationList.forEach(o=>{o.setImgAttribute(t)})}syncAllAttributeListInConfig(t){this.toolOperationList.forEach(o=>{const e=__spreadProps(__spreadValues({},o.config),{attributeList:t});o.setConfig(JSON.stringify(e))})}setSize(t){t.width&&t.height&&this.toolOperationDom.forEach(o=>{o.style.width=`${t.width}px`,o.style.height=`${t.height}px`}),this.toolOperationList.forEach(o=>{o.setSize(t)})}syncPosition(t,o,e,n){this.toolOperationList.forEach(a=>{n!==a&&(a.setCurrentPos(t),a.setZoom(o),a.setImgInfo(e),a.renderBasicCanvas(),a.render())})}get defaultSize(){var t,o;return{width:((t=this.imgNode)==null?void 0:t.width)||this.size.width,height:((o=this.imgNode)==null?void 0:o.height)||this.size.height}}createDom(){const{width:t,height:o}=this.defaultSize,e=window.document.createElement("div");e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.width=`${t}px`,e.style.height=`${o}px`;const n=this.toolOperationList.length+1;return e.style.zIndex=`${n}`,e}getEmptyImage(t,o){const e=createEmptyImage({width:t,height:o}),n=new Image;return n.src=e,n}createOperation(t,o,e){var n;const{width:a,height:l}=this.defaultSize,r=this.createDom(),c=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:o||c,hiddenImg:!!t};e&&Object.assign(h,e);let s;if(!t)s=new basicToolOperation.BasicToolOperation(h),r.style.zIndex="0",s.init();else{const p=EnhanceCommonToolUtils.getCurrentOperation(t);if(!p)return;s=new p(h)}return s==null||s.init(),s.canvas.id=t!=null?t:"basicCanvas",s.historyDisabled=!0,s.on("dragMove",({currentPos:p,zoom:d,imgInfo:u})=>{this.syncPosition(p,d,u,s)}),s.on("renderZoom",(p,d,u)=>{p&&d&&this.syncPosition(d,p,u,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,o=t-1,e=t-2,n=this.toolOperationDom[o],a=this.toolOperationDom[e];if(!(!a||!n))return n.style.zIndex=`${o-1}`,a.style.zIndex=`${o}`,this.toolOperationList[o].clearActiveStatus(),this.toolOperationList[o].clearCursorLine(),this.toolOperationList[o].render(),this.toolOperationList=arraySwap(this.toolOperationList,o,e),this.toolOperationDom=arraySwap(this.toolOperationDom,o,e),this.toolOperationList[o]}getFirstToolOperation(){return this.toolOperationList.length>1?this.toolOperationList[1]:this.toolOperationList[0]}switchToCanvas(t){var o,e,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,c=this.toolOperationDom[l],h=this.toolOperationDom[r];if(!c||!h)return;const s=h.style.zIndex;return h.style.zIndex=`${c.style.zIndex}`,c.style.zIndex=`${s}`,(e=(o=this.toolOperationList[r]).clearActiveStatus)==null||e.call(o),(a=(n=this.toolOperationList[r]).clearCursorLine)==null||a.call(n),this.toolOperationList[r].render(),this.toolOperationList=arraySwap(this.toolOperationList,r,l),this.toolOperationDom=arraySwap(this.toolOperationDom,r,l),this.toolOperationNameList=arraySwap(this.toolOperationNameList,r,l),this.toolOperationList[r]}updateDataByToolName(t,o){const e=this.toolOperationNameList.indexOf(t);e>=0&&this.toolOperationList[e].setResult(o)}clearStatusAndResult(){this.toolOperationList.forEach(t=>{var o;(o=t.clearActiveStatus)==null||o.call(t),t.clearResult()})}destroyAllLayer(){this.toolOperationList.forEach(t=>{t.destroyCanvas(),this.init()})}init(){this.toolOperationList=[],this.toolOperationDom=[],this.eventBinding()}destroy(){this.destroyAllLayer(),this.eventUnBinding()}eventBinding(){this.proxyMode&&(this.container.addEventListener("wheel",this.onWheel),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp))}eventUnBinding(){this.proxyMode&&(this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp))}onWheel(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onWheel(t)}}onMouseDown(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseDown(t)}}onMouseMove(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseMove(t)}}onMouseUp(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseUp(t)}}getCurrentToolName(){return this.toolOperationNameList[this.toolOperationNameList.length-1]}}exports.HybridToolUtils=HybridToolUtils,exports.ToolScheduler=ToolScheduler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),tool=require("../../constant/tool.js"),ActionsHistory=require("../../utils/ActionsHistory.js"),uuid=require("../../utils/uuid.js"),keyCode=require("../../constant/keyCode.js"),MathUtils=require("../../utils/MathUtils.js"),basicToolOperation=require("./basicToolOperation.js"),LineToolUtils=require("../../utils/tool/LineToolUtils.js"),polygonTool=require("../../utils/tool/polygonTool.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),CanvasUtils=require("../../utils/tool/CanvasUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),StyleUtils=require("../../utils/tool/StyleUtils.js"),AttributeUtils=require("../../utils/tool/AttributeUtils.js"),textAttributeClass=require("./textAttributeClass.js"),Selection=require("./Selection.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js");function _interopDefaultLegacy(a){return a&&typeof a=="object"&&"default"in a?a:{default:a}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(a,e,t)=>e in a?__defProp(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,__spreadValues=(a,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(a,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(a,t,e[t]);return a},__spreadProps=(a,e)=>__defProps(a,__getOwnPropDescs(e)),EStatus;(function(a){a[a.Create=0]="Create",a[a.Active=1]="Active",a[a.None=2]="None"})(EStatus||(EStatus={}));const SEGMENT_NUMBER=16,LINE_ORDER_OFFSET={x:0,y:20},POINT_RADIUS=3,POINT_ACTIVE_RADIUS=5,INNER_POINT_RADIUS=2;class LineToolOperation extends basicToolOperation.BasicToolOperation{constructor(e){super(e);this.drawActivatedLine=(t,i,s)=>{const n=this.isCreate?___default.default.cloneDeep([{pointList:this.activeLine,order:this.nextOrder(),attribute:this.defaultAttribute,valid:this.isLineValid}]):___default.default.cloneDeep(this.selectedLines),o=this.isActiveLineValid();n.forEach(r=>{if((r==null?void 0:r.pointList)&&(r.pointList=r.pointList.map(l=>Object.assign(l,{actual:{x:l.x,y:l.y}},this.coordUtils.getRenderCoord(l)))),!r.pointList)return;const h=this.getLineColorByAttribute({attribute:r.attribute,valid:r.valid});return this.selectedLines.length>0&&(this.drawLineLength(r.pointList,h),this.renderActiveArea(MathUtils.default.calcViewportBoundaries(r.pointList,this.isCurve,SEGMENT_NUMBER))),this.drawLine(r.pointList,t,h,!0,!0),this.drawLineNumber(r.pointList[0],r.order,h,"",this.defaultAttribute,o),t&&this.isCreate&&this.arc(t,POINT_RADIUS,h),this.cursor&&!this.selectedPoint&&!s&&!this.isShift&&this.arc(this.cursor,POINT_ACTIVE_RADIUS,h),r})},this.drawHoverPoint=t=>{if(!this.isMousedown&&t&&this.selectedID){const i=this.getPointList(this.activeLine),s=this.activeLine.find(o=>LineToolUtils.default.calcDistance(this.coordUtils.getRenderCoord(o),t)<=POINT_ACTIVE_RADIUS);let n;!s&&this.activeLine&&(n=this.findNearestPoint(i,t)),this.hoverPointID=s?s.id:void 0,this.cursor=s||n==null?void 0:n.point}},this.updatedLine={id:"",valid:!1,order:0},this.toolName="lineTool",this.lineList=[],this.activeLine=[],this.coordsInsideActiveArea=!1,this.hoverLineSegmentIndex=-1,this.isShift=!1,this.isReference=!1,this.drawCurveLine=(t,i,s,n=!0,o=!1,r)=>{const h=polygonTool.createSmoothCurvePointsFromPointList(i,SEGMENT_NUMBER);t.save(),t.lineCap="round",t.lineJoin="round",t.strokeStyle=s.color,n&&(t.lineWidth=s.lineWidth),o&&LineToolUtils.default.setReferenceCtx(t),i.forEach(({specialEdge:l},d)=>{const u=h.splice(0,SEGMENT_NUMBER+1);t.save(),t.beginPath(),r===d&&(t.lineWidth=4),u.forEach(({x:c,y:f},v)=>{const L=v>0?"lineTo":"moveTo";l&&LineToolUtils.default.setSpecialEdgeStyle(t),t[L](c,f)}),t.stroke(),t.restore()}),t.restore()},this.drawLine=(t,i,s,n=!1,o=!1)=>{const r=i?t.concat(i):t,h={color:s,lineWidth:o?1:this.lineStyle.lineWidth};this.isCurve?LineToolUtils.default.drawCurveLine(this.ctx,r,h,!n,this.isReference,o?this.hoverLineSegmentIndex:-1):this.drawStraightLine(r,h,o),n&&t.forEach(l=>{var d,u;const c=l.id,f=c&&[this.hoverPointID,(d=this.selectedPoint)==null?void 0:d.id].includes(c)?POINT_ACTIVE_RADIUS:POINT_RADIUS;this.arc(l,f,s),[this.hoverPointID,(u=this.selectedPoint)==null?void 0:u.id].includes(c)||this.arc(l,INNER_POINT_RADIUS,"white")})},this.drawStraightLine=(t,i,s=!1)=>{const{ctx:n}=this;n&&(n.save(),n.lineCap="round",n.lineJoin="round",n.strokeStyle=i.color,n.lineWidth=i.lineWidth,this.isReference&&LineToolUtils.default.setReferenceCtx(n),t.forEach((o,r)=>{if(n.beginPath(),r>0){const h=t[r-1];n.save(),(h==null?void 0:h.specialEdge)&&LineToolUtils.default.setSpecialEdgeStyle(n),s&&this.hoverLineSegmentIndex+1===r&&(n.lineWidth=4),n.moveTo(h.x,h.y),n.lineTo(o.x,o.y),n.stroke(),n.restore()}}),n.restore())},this.drawLines=()=>{try{const t=___default.default.cloneDeep(this.attributeFilteredLines);if(this.isHidden)return;t.forEach(i=>{if(!this.selection.isIdSelected(i.id)&&i.pointList){i.pointList.map(h=>Object.assign(h,{actual:{x:h.x,y:h.y}},this.coordUtils.getRenderCoord(h)));const{order:s,label:n}=i,o=s,r=i&&this.getLineColorByAttribute(i);this.drawLine(i.pointList,void 0,r,!1),this.drawLineNumber(i.pointList[0],o,r,n,i.attribute,i.valid),i.id!==this.textEditingID&&(this.drawLineTextAttribute(i.pointList[1],r,i==null?void 0:i.textAttribute),this.drawLineLength(i.pointList,r))}})}catch(t){console.error(t,"\u7EBF\u6761\u5DE5\u5177\u6570\u636E\u89E3\u6790\u9519\u8BEF"),this.lineList=[],this.clearCanvas()}},this.render=t=>{super.render(),this.drawLines(),this.drawActivatedLine(t,void 0,!1),this.renderTextAttribute(),this.renderCursorLine(this.getLineColor(this.defaultAttribute))},this.moveLineInPolygon=(t,i)=>{var s;if(!Array.isArray(this.activeLine))return!1;((s=this.activeLine)==null?void 0:s.every(o=>this.isInBasicPolygon({x:o.x+t,y:o.y+i})))&&(this.lineDragging=!0,this.moveActiveArea(t,i))},this.getSelectedLinesArea=()=>MathUtils.default.calcViewportBoundaries(this.selectedLines.reduce((t,i)=>(i==null?void 0:i.pointList)?t.concat(...i==null?void 0:i.pointList):t,[])),this.moveLineInRectRange=(t,i,s,n)=>{if(this.selectedLines.length===0)return;const{top:o,left:r,right:h,bottom:l}=this.getSelectedLinesArea(),d=[r,h].map(g=>___default.default.isNumber(g)?g+t:0),u=[o,l].map(g=>___default.default.isNumber(g)?g+i:0),c=r>=0&&h&&MathUtils.default.isInRange(d,s),f=o>=0&&l&&MathUtils.default.isInRange(u,n),v=c?t:0,L=f?i:0;this.lineDragging=!0,this.moveActiveArea(v,L)},this.onRightClick=t=>{if(this.cursor=void 0,this.isCreate){if(this.isLinePointsNotEnough())return;if(LineToolUtils.default.lineLengthSum(this.activeLine||[])<this.minLength)return this.emit("messageInfo",`${index.getMessagesByLocale(constants.EMessage.MinLengthLimitErrorNotice,this.lang)}${this.minLength}`),!0;this.stopLineCreating(!0);return}const i=this.findHoverLine(this.getCoordinate(t));this.setSelectedLineID(i==null?void 0:i.id,t.ctrlKey),this.emit("contextmenu")},this.updateSelectedAttributeAfterHistoryChanged=()=>{if(this.selectedIDs.length>0){const t=this.lineList.find(s=>s.id===this.selectedIDs[0]),i=t==null?void 0:t.attribute;typeof i=="string"&&(this.defaultAttribute=i,this.updateAttribute(i),this.render())}},this.onLeftClick=t=>{const i=this.getCoordinate(t),{lineDragging:s}=this;if(this.lineDragging=!1,this.isSpaceKey)return;if(this.isNone&&t.ctrlKey){const o=this.findHoverLine(i);o&&this.setInvalidLine(o.id);return}if(this.isLinePointsExceed())return;const n=this.getNextPoint(t,i);if(this.isCreate||this.isNone){this.setCreateStatusAndAddPoint(n);return}if(this.isActive){if(s)return;if(this.isMouseCoordOutsideActiveArea()){this.setNoneStatus(!1),this.setCreateStatusAndAddPoint(n);return}if(t.shiftKey){this.updateLineSegmentSpecial(i);return}this.coordsInsideActiveArea&&t.ctrlKey&&this.setInvalidLine(this.selectedID),this.addLinePointToActiveLine()}},this.onDblclick=()=>{},this.onKeyUp=t=>{if(super.onKeyUp(t),this.isShift=!1,this.hoverLineSegmentIndex=-1,!this.selection.triggerKeyboardEvent(t,this.setLineList)){if(t.keyCode===keyCode.Esc){this.stopLineCreating(!1);return}if(this.selectedLine){if(t.key==="Delete"){this.deleteLine();return}if(t.key==="f"){this.setInvalidLine(this.selectedID);return}if(t.key===" "){this.continueToEdit();return}}this.keyboardEventWhileLineCreating(t)}},this.onRightDblClick=t=>{super.onRightDblClick(t);const i=this.getCoordinate(t);if(this.isActive){const s=this.findHoveredPoint(i);if(s){this.deleteSelectedLinePoint(s.id);return}this.deleteSelectedLine(i)}},this.setReference=t=>{this.isReference=t},this.pointsWithinRange=t=>!(this.lowerLimitPointNum&&t<this.lowerLimitPointNum||this.upperLimitPointNum&&t>this.upperLimitPointNum),this.setLineList=t=>{const i=t.length!==this.lineListLen;this.lineList=t,i&&this.emit("updatePageNumber")},this.textChange=t=>{this.config.textConfigurable===!1||!this.selectedID||(this.updateSelectedTextAttribute(t),this.emit("selectedChange"))},this.status=2,this.isMousedown=!1,this.lineDragging=!1,this.isLineValid=!0,this.setConfig(e.config),this.prevAxis={x:0,y:0},this.textEditingID="",this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.actionsHistory=new ActionsHistory,this.selection=new Selection(this),this.dependToolConfig={lineType:tool.ELineTypes.Line}}get selectedLines(){return this.lineList.filter(e=>this.selection.isIdSelected(e.id))}get isLineSelected(){return this.selectedID&&this.activeLine}get selectedLine(){return this.lineList.find(e=>e.id===this.selectedID)}get isCreate(){return this.status===0}get isActive(){return this.selectedLines.length>0}get isNone(){return!this.isCreate&&this.selectedIDs.length===0}get isCurve(){return this.config.lineType===tool.ELineTypes.Curve}get isMultipleColor(){return this.config.lineColor===tool.ELineColor.MultiColor}get imageSize(){return this.rotate%180==0?this.basicImgInfo:{width:this.basicImgInfo.height,height:this.basicImgInfo.width}}get lineListLen(){return this.lineList.length}get edgeAdsorptionEnabled(){return this.edgeAdsorption&&!this.isCurve&&this.lineListLen>0}get attributeConfigurable(){return this.config.attributeConfigurable}get isTextConfigurable(){return this.config.textConfigurable}get isDependPolygon(){return this.dependToolName===tool.EToolName.Polygon}get isDependRect(){return this.dependToolName===tool.EToolName.Rect}get isCurrentAttributeLocked(){return this.attributeLockList.includes(this.defaultAttribute)}get attributeFilteredLines(){return this.attributeLockList.length>0?this.lineList.filter(e=>this.attributeLockList.includes((e==null?void 0:e.attribute)||"")):this.lineList}get selectedIDs(){return this.selection.selectedIDs}get selectedID(){return this.selection.selectedID}get enableOutOfTarget(){return this.config.enableOutOfTarget||this.config.outOfTarget||this.config.drawOutsideTarget}get showOrder(){var e;return(e=this.config.showOrder)!=null?e:this.config.isShowOrder}get edgeAdsorption(){return this.config.edgeAdsorption}get attributeList(){return this.config.attributeList}get lowerLimitPointNum(){return this.config.lowerLimitPointNum}get minLength(){var e;return((e=this.config)==null?void 0:e.minLength)||0}get upperLimitPointNum(){return this.config.upperLimitPointNum}get textCheckType(){return this.config.textCheckType}get customFormat(){return this.config.customFormat}get dataList(){return this.lineList}get hasActiveLine(){return this.activeLine&&this.activeLine.length>0}get viewPortLines(){const e=CanvasUtils.getViewPort(this.canvas,this.currentPos,this.zoom);return this.isHidden?[]:this.attributeFilteredLines.filter(t=>{var i;return(i=t==null?void 0:t.pointList)==null?void 0:i.some(s=>CanvasUtils.inViewPort(s,e))})}get lineStyle(){return{lineWidth:this.style.width,color:this.getLineColor(this.defaultAttribute),opacity:this.style.opacity}}get selectedText(){var e,t;return(t=(e=this.lineList.find(i=>i.id===this.selectedID))==null?void 0:e.textAttribute)!=null?t:""}get currentPageResult(){return this.lineList}updateStatus(e,t=!1){if(e!==this.status){if(t){let i="";this.textCheckType===tool.ETextType.Order&&this.isTextConfigurable&&(i=AttributeUtils.default.getTextAttribute(this.lineList,this.textCheckType)),this.emit("updateText",i)}this.status=e,this.lineStatusChanged()}}isInBasicPolygon(e){var t,i;return polygonTool.isInPolygon(e,((t=this.basicResult)==null?void 0:t.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}getPolygonPointList(){if(!this.basicResult)return[];const{pointList:e}=this.basicResult,{lineType:t}=this.dependToolConfig;return t===tool.ELineTypes.Curve?polygonTool.createSmoothCurvePoints(e.reduce((i,s)=>[...i,s.x,s.y],[]),.5,!0,20):e}getNextCoordByRenderCoord(e){return this.getNextCoordByAbsCoord(this.coordUtils.getAbsCoord(e))}getNextCoordByAbsCoord(e){var t;const i=(t=this.activeLine)==null?void 0:t.slice(-1)[0];return i?this.coordUtils.getNextCoordByDependTool(e,i):e}pointInLine(e,t,i){return e.filter(s=>s).length<2?!1:e.some((s,n)=>{if(n===0)return!1;const o=this.coordUtils.getRenderCoord(e[n-1]),r=this.coordUtils.getRenderCoord(s);return LineToolUtils.default.isInLine(t,o,r,i)})}arc(e,t=POINT_RADIUS,i){var s,n,o,r,h,l;if(this.ctx){const{x:d,y:u}=e;(s=this.ctx)==null||s.save(),(n=this.ctx)==null||n.beginPath(),this.ctx.fillStyle=i||this.lineStyle.color,(o=this.ctx)==null||o.arc(d,u,t,0,360),(r=this.ctx)==null||r.closePath(),(h=this.ctx)==null||h.fill(),(l=this.ctx)==null||l.restore()}}renderActiveArea({top:e,left:t,right:i,bottom:s}){this.ctx&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.strokeStyle="#B3B8FF",this.ctx.rect(t,e,i-t,s-e),this.ctx.stroke(),this.ctx.restore())}addLinePoint(e){var t,i,s,n;this.arc(e),(t=this.activeLine)==null||t.push(__spreadProps(__spreadValues({},e),{id:uuid()})),((i=this.activeLine)==null?void 0:i.length)===1?(s=this.actionsHistory)==null||s.initRecord(this.activeLine):(n=this.actionsHistory)==null||n.pushHistory(this.activeLine),this.render()}setCreateStatusAndAddPoint(e,t=!1){this.updateStatus(0,t),this.addLinePoint(e)}isActiveLineValid(){var e;return this.selectedID?(e=this.lineList.find(t=>t.id===this.selectedID))==null?void 0:e.valid:this.isLineValid}nextOrder(){return this.lineListLen===0?1:this.lineList.slice(-1)[0].order+1}getLineColorByAttribute(e,t=!1){return StyleUtils.getStrokeAndFill(this.getColor(e.attribute),e.valid,{isSelected:t}).stroke}drawLineNumber(e,t=1,i,s="",n,o=!0){var r,h,l;if((this.showOrder||this.attributeConfigurable)&&this.ctx){let d=this.showOrder?t.toString():`${s}`;if(this.attributeConfigurable){const u=n?(l=(h=(r=this.attributeList)==null?void 0:r.find(c=>c.value===n))==null?void 0:h.key)!=null?l:n:"";d=[d,`${!o&&u?"\u65E0\u6548":""}${u}`].filter(c=>c).join("_")}this.drawText(e,d,i)}}drawLineTextAttribute(e,t,i){if(e&&i)return this.drawText(e,i,t,200)}drawLineLength(e,t){var i;if(((i=this.config)==null?void 0:i.showLineLength)&&e){const s=e.reduce((o,r,h)=>h<=0||!e[h-1].actual||!r.actual?o:o+LineToolUtils.default.calcDistance(e[h-1].actual,r.actual),0),n=e[e.length-1];this.drawText(n,`l = ${s.toFixed(2)}`,t)}}drawText(e,t,i,s){var n,o;this.ctx&&((n=this.ctx)==null||n.save(),this.ctx.font="italic bold 14px SourceHanSansCN-Regular",this.ctx.fillStyle=i,this.ctx.strokeStyle=i,this.ctx.shadowColor="rgba(0, 0, 0, 0.6)",this.ctx.shadowOffsetY=2,this.ctx.shadowBlur=4,s?DrawUtils.wrapText(this.canvas,t,e.x-LINE_ORDER_OFFSET.x,e.y-LINE_ORDER_OFFSET.y,s):this.ctx.fillText(t,e.x-LINE_ORDER_OFFSET.x,e.y-LINE_ORDER_OFFSET.y),(o=this.ctx)==null||o.restore())}moveActiveArea(e,t){this.selectedLines.length>0&&(this.selectedLines.forEach(i=>{var s;(s=i.pointList)==null||s.forEach(n=>Object.assign(n,{x:n.x+e,y:n.y+t}))}),this.render()),this.emit("dataUpdated",this.lineList,this.selectedIDs)}findHoveredPoint(e){if(!!this.activeLine)return this.activeLine.find(t=>{const i=this.coordUtils.getRenderCoord(t);return LineToolUtils.default.calcDistance(i,e)<=POINT_ACTIVE_RADIUS})}findHoverLine(e){return ___default.default.cloneDeep(this.lineList).reverse().find(({pointList:i})=>{const s=i?this.getPointList(i):[],n=this.getLineWidthScope();return s.some((o,r)=>{if(r===0)return!1;const h=this.coordUtils.getRenderCoord(o),l=this.coordUtils.getRenderCoord(s[r-1]);return LineToolUtils.default.isInLine(e,h,l,n)})})}getAdsorptionPoint(e){let t,i,s;return ___default.default.cloneDeep(this.lineList).reverse().forEach(({pointList:n,id:o})=>{if(o===this.selectedID||!n||(n==null?void 0:n.length)<2)return;const r=this.findNearestPoint(n,e);if(r){if(r.minDistance===0){t=r.point;return}(i===void 0||r.minDistance<i)&&(t=r.point,i=r.minDistance)}}),s||t}findNearestPoint(e,t,i=7){let s;const n=i;for(let o=1;o<=e.length-1;o++){const r=this.coordUtils.getRenderCoord(e[o]),h=this.coordUtils.getRenderCoord(e[o-1]),{length:l,footPoint:d}=MathUtils.default.getFootOfPerpendicular(t,r,h),u=LineToolUtils.default.calcTwoPointDistance(r,t),c=LineToolUtils.default.calcTwoPointDistance(h,t);if(u<=i*2){s=r,i=0;break}if(c<=i*2){s=h,i=0;break}l<i&&(s=d,i=l)}return s?{point:s,minDistance:n}:void 0}getPointList(e){return this.isCurve?polygonTool.createSmoothCurvePointsFromPointList(e,SEGMENT_NUMBER):e}moveSelectedLine(e){const t=(e.x-this.prevAxis.x)/this.zoom,i=(e.y-this.prevAxis.y)/this.zoom;if(this.enableOutOfTarget){this.lineDragging=!0,this.moveActiveArea(t,i);return}if(this.isDependPolygon){this.moveLineInPolygon(t,i);return}let s=[0,this.imageSize.width],n=[0,this.imageSize.height];if(this.isDependRect){const{x:o,y:r,width:h,height:l}=this.basicResult;s=[o,o+h],n=[r,r+l]}this.moveLineInRectRange(t,i,s,n)}moveSelectPoint(e){if(!this.selectedPoint)return;const t=e.x-this.prevAxis.x,i=e.y-this.prevAxis.y,s=(this.selectedPoint?this.selectedPoint.x:0)+t/this.zoom,n=(this.selectedPoint?this.selectedPoint.y:0)+i/this.zoom,o={x:s,y:n};Object.assign(this.selectedPoint,this.getNextCoordByAbsCoord(o)),this.updateLines(),this.render()}getCoordByConfig(e,t){var i;const s=!!e.shiftKey,n=e.altKey;if(((i=this.activeLine)==null?void 0:i.length)>0&&s){const o=this.activeLine.slice(-1)[0];return LineToolUtils.default.getVHPoint(o,t,this.coordUtils.getAbsCoord(t),this.coordUtils.getRenderCoord(o))}return this.edgeAdsorptionEnabled&&!n?this.getAdsorptionPoint(t):t}getNextPoint(e,t){const i=this.getCoordByConfig(e,t)||t;return this.enableOutOfTarget?this.coordUtils.getAbsCoord(i):this.getNextCoordByRenderCoord(i)}lineHover(){this.render()}mouseMoveHandler(e){const t=this.getCoordinate(e),i=e.which===1;if(this.isCreate){this.hasActiveLine&&this.renderNextPoint(e,t);return}if(this.isNone&&(this.lineHover(),this.edgeAdsorptionEnabled&&!e.altKey)){const s=this.getAdsorptionPoint(t);s&&this.arc(s)}if(this.isActive){if(this.isMousedown&&i){if(this.selectedPoint){this.moveSelectPoint(t);return}if(this.coordsInsideActiveArea){this.moveSelectedLine(t),this.drawActivatedLine(void 0,void 0,!0);return}}this.drawHoverPoint(t),this.render()}}onMouseMove(e){if(super.onMouseMove(e)||this.forbidMouseOperation||!this.imgInfo)return;const t=this.getCoordinate(e);this.mouseMoveHandler(e),this.prevAxis=t}setActiveLine(e){this.activeLine=e?___default.default.cloneDeep(e):void 0}historyChanged(e){const t=`${e}Enabled`;if(this.isCreate){if(this.actionsHistory&&this.actionsHistory[t]){const i=this.actionsHistory&&this.actionsHistory[e]();this.setActiveLine(i),this.render()}return}if(this.history&&this.history[t]){const i=this.history[e](),s=i==null?void 0:i.find(n=>n.id===this.selectedID);this.lineList=i,this.selectedID&&s?this.setActiveLine(s==null?void 0:s.pointList):this.setNoneStatus(),this.render()}this.emit("dataUpdated",this.lineList)}undo(){this.historyChanged("undo"),this.updateSelectedAttributeAfterHistoryChanged()}redo(){this.historyChanged("redo"),this.updateSelectedAttributeAfterHistoryChanged()}isCoordInsideTarget(e){if(this.isDependPolygon)return this.isInBasicPolygon(e);if(this.isDependRect){const{x:t,y:i,width:s,height:n}=this.basicResult,o=[t,t+s],r=[i,i+n];return MathUtils.default.isInRange(e.x,o)&&MathUtils.default.isInRange(e.y,r)}return MathUtils.default.isInRange(e.x,[0,this.imageSize.width])&&MathUtils.default.isInRange(e.y,[0,this.imageSize.height])}getPointInsertIndex(e,t){if(e&&this.activeLine){const i=this.getPointList(this.activeLine);return this.activeLine.length===2?1:this.activeLine.findIndex((s,n)=>{if(n>0){const o=this.activeLine?this.activeLine[n-1]:void 0,r=this.isCurve?i.slice((n-1)*(SEGMENT_NUMBER+1),n*(SEGMENT_NUMBER+1)):[o,s];return this.pointInLine(r,e,t||this.getLineWidthScope())}return!1})}return-1}getLineWidthScope(){return this.lineStyle.lineWidth}isMouseCoordOutsideActiveArea(){return!this.coordsInsideActiveArea&&!this.selectedPoint}isLinePointsExceed(){return this.isCreate&&this.activeLine&&this.upperLimitPointNum&&~~this.upperLimitPointNum<=this.activeLine.length}isLinePointsNotEnough(){var e;return this.activeLine&&((e=this.activeLine)==null?void 0:e.length)<this.lowerLimitPointNum}updateLineSegmentSpecial(e){const t=this.getPointInsertIndex(e,2)-1;if(t>-1){const i=this.activeLine[t];i.specialEdge=!i.specialEdge,this.hoverLineSegmentIndex=-1,this.render()}}addLinePointToActiveLine(){var e;const t=this.getPointInsertIndex(this.cursor),i=this.pointsWithinRange(this.activeLine.length+1);this.cursor&&t>-1&&i&&(this.activeLine.splice(t,0,__spreadProps(__spreadValues({},this.coordUtils.getAbsCoord(this.cursor)),{id:uuid()})),this.updateLines(),(e=this.history)==null||e.pushHistory(this.lineList),this.render(),this.cursor=void 0)}isCoordOnSelectedArea(e){return this.selectedLines.some(t=>LineToolUtils.default.inArea(MathUtils.default.calcViewportBoundaries(t.pointList),this.coordUtils.getAbsCoord(e)))}onMouseDown(e){if(super.onMouseDown(e)||this.forbidMouseOperation||!this.imgInfo)return;const t=this.getCoordinate(e);if(this.isMousedown=!0,this.prevAxis=t,e.which===3){this.cursor=void 0;return}this.selectedPoint=this.findHoveredPoint(t),this.coordsInsideActiveArea=this.selectedLines.length>0?this.isCoordOnSelectedArea(t):!1,this.lineDragging=!1}lineHasChanged(){const e=this.lineList.find(t=>t.id===this.selectedID);return e?JSON.stringify(e.pointList)!==JSON.stringify(this.activeLine):!1}updateLines(){const e=this.lineList.find(t=>t.id===this.selectedID);e&&(e.pointList=___default.default.cloneDeep(this.activeLine),this.updatedLine=e,this.emit("dataUpdated",this.lineList))}onMouseUp(e){const t=()=>{this.isMousedown=!1,this.hoverPointID=void 0,this.cursor=void 0,this.selectedPoint=void 0};if(this.hoverPointID=void 0,super.onMouseUp(e)||this.forbidMouseOperation||!this.imgInfo){t();return}e.which===1&&this.onLeftClick(e),e.which===3&&this.onRightClick(e),t()}isTextValid(e){return AttributeUtils.default.textAttributeValidate(this.textCheckType,this.customFormat,e)}createLineData(){const e=uuid(),t={pointList:___default.default.cloneDeep(this.activeLine),id:e,valid:this.isLineValid,order:this.nextOrder()};return t.attribute=this.defaultAttribute,t}stopLineCreating(e=!0){var t,i,s,n;const o=this.selectedID?!0:!!this.isTextConfigurable;let r;if(e){if(this.selectedID){const h=this.lineList.find(l=>l.id===this.selectedID);r=this.selectedID,h&&(h.pointList=___default.default.cloneWith(this.activeLine),___default.default.isEqual(h.pointList,(t=this.history)==null?void 0:t.pushHistory(this.lineList))||(i=this.history)==null||i.pushHistory(this.lineList))}else if(this.isCreate&&this.activeLine&&this.activeLine.length>1){const h=this.createLineData();r=h.id,this.setLineList([...this.lineList,h]),(s=this.history)==null||s.pushHistory(this.lineList)}}this.setNoneStatus(),o&&(this.activeLine=[],this.setSelectedLineID(r,!1,!1)),(n=this.actionsHistory)==null||n.empty(),this.emit("dataUpdated",this.lineList,this.selectedIDs),this.render()}setNoneStatus(e=!0){e&&this.updateStatus(2),this.activeLine=[],this.setSelectedLineID(void 0),this.isLineValid=!0,this.cursor=void 0}setKeyDownStatus(e,t){this.isShift=t!=null?t:e.keyCode===keyCode.Shift}continueToEdit(){var e,t;((e=this.selectedLine)==null?void 0:e.pointList)&&(this.updateStatus(0),this.cursor=void 0,this.setActiveLine(this.selectedLine.pointList),(t=this.actionsHistory)==null||t.pushHistory(this.activeLine),this.render())}setInvalidLineOnCreating(e){if(this.selectedID&&e.keyCode!==keyCode.Ctrl||!this.isCreate)return;const t=!e.ctrlKey;this.selectedID?this.setInvalidLine(this.selectedID,t,!1):this.isLineValid=t}onKeyDown(e){if(super.onKeyDown(e),this.setKeyDownStatus(e),e.keyCode===keyCode.Z&&!e.ctrlKey&&this.toggleIsHide(),e.keyCode===keyCode.Shift&&this.render(),e.keyCode===keyCode.Tab){e.preventDefault(),this.selectToNextLine(e);return}if(this.isCreate&&this.keyboardEventWhileLineCreating(e),this.config.attributeConfigurable){const t=AttributeUtils.default.getAttributeByKeycode(e.keyCode,this.config.attributeList);t!==void 0&&this.setDefaultAttribute(t)}}selectToNextLine(e){const t=CommonToolUtils.getNextSelectedRectIDByEvent(this.viewPortLines.map(i=>{var s,n,o,r;return __spreadProps(__spreadValues({},i),{x:(n=(s=i.pointList[0])==null?void 0:s.x)!=null?n:0,y:(r=(o=i.pointList[0])==null?void 0:o.y)!=null?r:0})}),e,this.selectedID);t&&this.selection.setSelectedIDs(t.id)}keyboardEventWhileLineCreating(e){!this.isCreate||(e.keyCode===keyCode.Ctrl&&this.setInvalidLineOnCreating(e),[keyCode.Shift,keyCode.Alt].includes(e.keyCode)&&this.renderNextPoint(e,this.prevAxis))}renderNextPoint(e,t){const i=this.coordUtils.getRenderCoord(this.getNextPoint(e,t));this.render(i)}deleteSelectedLine(e){var t;if(this.selectedLine){const i=MathUtils.default.calcViewportBoundaries((t=this.selectedLine)==null?void 0:t.pointList,this.isCurve,SEGMENT_NUMBER,this.zoom);LineToolUtils.default.inArea(i,this.coordUtils.getAbsCoord(e))&&this.deleteLine()}}deleteSelectedLinePoint(e){var t;this.pointsWithinRange(this.activeLine.length-1)&&e&&(this.setActiveLine(this.activeLine.filter(s=>s.id!==e)),this.updateLines(),(t=this.history)==null||t.pushHistory(this.lineList)),this.cursor=void 0,this.render()}deleteLine(){var e;this.lineList=this.lineList.filter(t=>!this.selection.isIdSelected(t.id)),(e=this.history)==null||e.pushHistory(this.lineList),this.setNoneStatus(),this.emit("dataUpdated",this.lineList),this.render()}setInvalidLine(e,t,i=!0){var s;const n=this.lineList.find(o=>o.id===e);n&&(n.valid=t!==void 0?t:!n.valid,(s=this.history)==null||s.pushHistory(this.lineList),this.emit("dataUpdated",this.lineList),i&&this.render())}empty(){var e,t;this.lineList=[],this.setNoneStatus(),this.selectedPoint=void 0,(e=this.actionsHistory)==null||e.empty(),(t=this.history)==null||t.init(),this.emit("dataUpdated",this.lineList),this.render()}setAttribute(e){var t;this.attributeConfigurable&&(this.defaultAttribute=e,this.setLineAttribute("attribute",e),this.selectedIDs.length>0&&((t=this.history)==null||t.pushHistory(this.lineList)))}setTextAttribute(e){var t;this.isTextConfigurable&&(this.setLineAttribute("textAttribute",e),(t=this.history)==null||t.applyAttribute(this.selectedID,"textAttribute",e))}setLineAttribute(e,t){this.selectedIDs.length>0&&(this.lineList.forEach(i=>{this.selection.isIdSelected(i.id)&&(i[e]=t)}),this.render())}updateAttribute(e){this.emit("updateAttribute",e)}updateLineAttributes(e){var t;if(this.attributeConfigurable&&e){const i=(e==null?void 0:e.attribute)||"";this.defaultAttribute=i,this.updateAttribute(i)}if(this.isTextConfigurable&&e){const i=(e==null?void 0:e.textAttribute)||"";this.updateTextAttribute(i)}(t=this.history)==null||t.updateHistory(this.lineList)}lineStatusChanged(){this.emit("lineStatusChanged",{status:this.status,selectedLineID:this.selectedID})}updateTextAttribute(e){if(this.selectedID){const t=this.lineList.find(i=>i.id===this.selectedID);t&&(t.textAttribute=e)}this.emit("updateText",e)}saveData(){this.stopLineCreating(),this.setNoneStatus(),this.render()}setTextEditingID(e){this.textEditingID=e,this.render()}updateAttrWhileIDChanged(e){if(e){const t=this.lineList.find(i=>i.id===e);t&&this.setDefaultAttribute(t.attribute)}}setSelectedLineID(e,t=!1,i=!0){this.selection.setSelectedIDs(e,t),i&&e&&this.updateAttrWhileIDChanged(this.selectedID),this.selectedLine&&this.setActiveLine(this.selectedLine.pointList),this.selectedIDs.length===0&&this.setActiveLine([]),this.emit("dataUpdated",this.lineList,this.selectedIDs)}attributeLockListChange(e){this.attributeLockList=e,this.render()}setResult(e){this.setLineList(e),this.render()}setConfig(e){super.setConfig(e)}toggleIsHide(){this.setIsHidden(!this.isHidden),this.render()}clearCanvas(){super.clearCanvas()}clearResult(){this.setResult([]),this.setSelectedLineID(void 0),this.render()}exportData(){return[this.lineList,this.basicImgInfo]}setDefaultAttribute(e=""){var t;this.attributeConfigurable&&(this.defaultAttribute=e,this.changeStyle(this.defaultAttribute),this.setLineAttribute("attribute",e),this.selectedIDs.length>0&&((t=this.history)==null||t.pushHistory(this.lineList)),this.emit("changeAttributeSidebar"))}getCurrentSelectedData(){var e,t;const i=this.isActiveLineValid(),s=this.defaultAttribute,n=this.getColor(s),o=i?n==null?void 0:n.valid.stroke:n==null?void 0:n.invalid.stroke,r=(t=(e=this.lineList.find(h=>h.id===this.selectedID))==null?void 0:e.textAttribute)!=null?t:"";return{color:o,textAttribute:r}}renderTextAttribute(){var e,t,i,s;if(!this.ctx||!this.selectedLine||this.activeLine&&((e=this.activeLine)==null?void 0:e.length)<2)return;const n=this.isActiveLineValid(),o=this.defaultAttribute,{x:r,y:h}=this.selectedLine.pointList[1],l=this.coordUtils.getRenderCoord({x:r,y:h}),d=this.getColor(o),u=n?d==null?void 0:d.valid.stroke:d==null?void 0:d.invalid.stroke,c=(i=(t=this.lineList.find(f=>f.id===this.selectedID))==null?void 0:t.textAttribute)!=null?i:"";this._textAttributeInstance||(this._textAttributeInstance=new textAttributeClass({container:this.container,icon:this.getTextIconSvg(o),color:u,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributeInstance&&!((s=this._textAttributeInstance)==null?void 0:s.isExit)&&this._textAttributeInstance.appendToContainer(),this._textAttributeInstance.update(`${c}`,{left:l.x,top:l.y,color:u}),this._textAttributeInstance.updateIcon(this.getTextIconSvg(o))}getTextIconSvg(e=""){return AttributeUtils.default.getTextIconSvg(e,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}updateSelectedTextAttribute(e){if(this._textAttributeInstance&&e&&this.selectedID){let t=e;!AttributeUtils.default.textAttributeValidate(this.config.textCheckType,"",t)&&(this.emit("messageError",AttributeUtils.default.getErrorNotice(this.config.textCheckType,this.lang)),t=""),this.setTextAttribute(t),this.emit("updateTextAttribute"),this.render()}}}exports.INNER_POINT_RADIUS=INNER_POINT_RADIUS,exports.LINE_ORDER_OFFSET=LINE_ORDER_OFFSET,exports.POINT_ACTIVE_RADIUS=POINT_ACTIVE_RADIUS,exports.POINT_RADIUS=POINT_RADIUS,exports.SEGMENT_NUMBER=SEGMENT_NUMBER,exports.default=LineToolOperation;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),tool=require("../../constant/tool.js"),ActionsHistory=require("../../utils/ActionsHistory.js"),uuid=require("../../utils/uuid.js"),keyCode=require("../../constant/keyCode.js"),MathUtils=require("../../utils/MathUtils.js"),basicToolOperation=require("./basicToolOperation.js"),LineToolUtils=require("../../utils/tool/LineToolUtils.js"),polygonTool=require("../../utils/tool/polygonTool.js"),CommonToolUtils=require("../../utils/tool/CommonToolUtils.js"),CanvasUtils=require("../../utils/tool/CanvasUtils.js"),DrawUtils=require("../../utils/tool/DrawUtils.js"),StyleUtils=require("../../utils/tool/StyleUtils.js"),AttributeUtils=require("../../utils/tool/AttributeUtils.js"),textAttributeClass=require("./textAttributeClass.js"),Selection=require("./Selection.js"),index=require("../../locales/index.js"),constants=require("../../locales/constants.js");function _interopDefaultLegacy(a){return a&&typeof a=="object"&&"default"in a?a:{default:a}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(a,e,t)=>e in a?__defProp(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,__spreadValues=(a,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(a,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(a,t,e[t]);return a},__spreadProps=(a,e)=>__defProps(a,__getOwnPropDescs(e)),EStatus;(function(a){a[a.Create=0]="Create",a[a.Active=1]="Active",a[a.None=2]="None"})(EStatus||(EStatus={}));const SEGMENT_NUMBER=16,LINE_ORDER_OFFSET={x:0,y:20},POINT_RADIUS=3,POINT_ACTIVE_RADIUS=5,INNER_POINT_RADIUS=2;class LineToolOperation extends basicToolOperation.BasicToolOperation{constructor(e){super(e);this.drawActivatedLine=(t,i,s)=>{const n=this.isCreate?___default.default.cloneDeep([{pointList:this.activeLine,order:this.nextOrder(),attribute:this.defaultAttribute,valid:this.isLineValid}]):___default.default.cloneDeep(this.selectedLines),o=this.isActiveLineValid();n.forEach(r=>{if((r==null?void 0:r.pointList)&&(r.pointList=r.pointList.map(l=>Object.assign(l,{actual:{x:l.x,y:l.y}},this.coordUtils.getRenderCoord(l)))),!r.pointList)return;const h=this.getLineColorByAttribute({attribute:r.attribute,valid:r.valid});return this.selectedLines.length>0&&(this.drawLineLength(r.pointList,h),this.renderActiveArea(MathUtils.default.calcViewportBoundaries(r.pointList,this.isCurve,SEGMENT_NUMBER))),this.drawLine(r.pointList,t,h,!0,!0),r.pointList[0]&&this.drawLineNumber(r.pointList[0],r.order,h,"",this.defaultAttribute,o),t&&this.isCreate&&this.arc(t,POINT_RADIUS,h),this.cursor&&!this.selectedPoint&&!s&&!this.isShift&&this.arc(this.cursor,POINT_ACTIVE_RADIUS,h),r})},this.drawHoverPoint=t=>{if(!this.isMousedown&&t&&this.selectedID){const i=this.getPointList(this.activeLine),s=this.activeLine.find(o=>LineToolUtils.default.calcDistance(this.coordUtils.getRenderCoord(o),t)<=POINT_ACTIVE_RADIUS);let n;!s&&this.activeLine&&(n=this.findNearestPoint(i,t)),this.hoverPointID=s?s.id:void 0,this.cursor=s||n==null?void 0:n.point}},this.updatedLine={id:"",valid:!1,order:0},this.toolName="lineTool",this.lineList=[],this.activeLine=[],this.coordsInsideActiveArea=!1,this.hoverLineSegmentIndex=-1,this.isShift=!1,this.isReference=!1,this.drawCurveLine=(t,i,s,n=!0,o=!1,r)=>{const h=polygonTool.createSmoothCurvePointsFromPointList(i,SEGMENT_NUMBER);t.save(),t.lineCap="round",t.lineJoin="round",t.strokeStyle=s.color,n&&(t.lineWidth=s.lineWidth),o&&LineToolUtils.default.setReferenceCtx(t),i.forEach(({specialEdge:l},d)=>{const u=h.splice(0,SEGMENT_NUMBER+1);t.save(),t.beginPath(),r===d&&(t.lineWidth=4),u.forEach(({x:c,y:f},v)=>{const L=v>0?"lineTo":"moveTo";l&&LineToolUtils.default.setSpecialEdgeStyle(t),t[L](c,f)}),t.stroke(),t.restore()}),t.restore()},this.drawLine=(t,i,s,n=!1,o=!1)=>{const r=i?t.concat(i):t,h={color:s,lineWidth:o?1:this.lineStyle.lineWidth};this.isCurve?LineToolUtils.default.drawCurveLine(this.ctx,r,h,!n,this.isReference,o?this.hoverLineSegmentIndex:-1):this.drawStraightLine(r,h,o),n&&t.forEach(l=>{var d,u;const c=l.id,f=c&&[this.hoverPointID,(d=this.selectedPoint)==null?void 0:d.id].includes(c)?POINT_ACTIVE_RADIUS:POINT_RADIUS;this.arc(l,f,s),[this.hoverPointID,(u=this.selectedPoint)==null?void 0:u.id].includes(c)||this.arc(l,INNER_POINT_RADIUS,"white")})},this.drawStraightLine=(t,i,s=!1)=>{const{ctx:n}=this;n&&(n.save(),n.lineCap="round",n.lineJoin="round",n.strokeStyle=i.color,n.lineWidth=i.lineWidth,this.isReference&&LineToolUtils.default.setReferenceCtx(n),t.forEach((o,r)=>{if(n.beginPath(),r>0){const h=t[r-1];n.save(),(h==null?void 0:h.specialEdge)&&LineToolUtils.default.setSpecialEdgeStyle(n),s&&this.hoverLineSegmentIndex+1===r&&(n.lineWidth=4),n.moveTo(h.x,h.y),n.lineTo(o.x,o.y),n.stroke(),n.restore()}}),n.restore())},this.drawLines=()=>{try{const t=___default.default.cloneDeep(this.attributeFilteredLines);if(this.isHidden)return;t.forEach(i=>{if(!this.selection.isIdSelected(i.id)&&i.pointList){i.pointList.map(h=>Object.assign(h,{actual:{x:h.x,y:h.y}},this.coordUtils.getRenderCoord(h)));const{order:s,label:n}=i,o=s,r=i&&this.getLineColorByAttribute(i);this.drawLine(i.pointList,void 0,r,!1),this.drawLineNumber(i.pointList[0],o,r,n,i.attribute,i.valid),i.id!==this.textEditingID&&(this.drawLineTextAttribute(i.pointList[1],r,i==null?void 0:i.textAttribute),this.drawLineLength(i.pointList,r))}})}catch(t){console.error(t,"\u7EBF\u6761\u5DE5\u5177\u6570\u636E\u89E3\u6790\u9519\u8BEF"),this.lineList=[],this.clearCanvas()}},this.render=t=>{super.render(),this.drawLines(),this.drawActivatedLine(t,void 0,!1),this.renderTextAttribute(),this.renderCursorLine(this.getLineColor(this.defaultAttribute))},this.moveLineInPolygon=(t,i)=>{var s;if(!Array.isArray(this.activeLine))return!1;((s=this.activeLine)==null?void 0:s.every(o=>this.isInBasicPolygon({x:o.x+t,y:o.y+i})))&&(this.lineDragging=!0,this.moveActiveArea(t,i))},this.getSelectedLinesArea=()=>MathUtils.default.calcViewportBoundaries(this.selectedLines.reduce((t,i)=>(i==null?void 0:i.pointList)?t.concat(...i==null?void 0:i.pointList):t,[])),this.moveLineInRectRange=(t,i,s,n)=>{if(this.selectedLines.length===0)return;const{top:o,left:r,right:h,bottom:l}=this.getSelectedLinesArea(),d=[r,h].map(g=>___default.default.isNumber(g)?g+t:0),u=[o,l].map(g=>___default.default.isNumber(g)?g+i:0),c=r>=0&&h&&MathUtils.default.isInRange(d,s),f=o>=0&&l&&MathUtils.default.isInRange(u,n),v=c?t:0,L=f?i:0;this.lineDragging=!0,this.moveActiveArea(v,L)},this.onRightClick=t=>{if(this.cursor=void 0,this.isCreate){if(this.isLinePointsNotEnough())return;if(LineToolUtils.default.lineLengthSum(this.activeLine||[])<this.minLength)return this.emit("messageInfo",`${index.getMessagesByLocale(constants.EMessage.MinLengthLimitErrorNotice,this.lang)}${this.minLength}`),!0;this.stopLineCreating(!0);return}const i=this.findHoverLine(this.getCoordinate(t));this.setSelectedLineID(i==null?void 0:i.id,t.ctrlKey),this.emit("contextmenu")},this.updateSelectedAttributeAfterHistoryChanged=()=>{if(this.selectedIDs.length>0){const t=this.lineList.find(s=>s.id===this.selectedIDs[0]),i=t==null?void 0:t.attribute;typeof i=="string"&&(this.defaultAttribute=i,this.updateAttribute(i),this.render())}},this.onLeftClick=t=>{const i=this.getCoordinate(t),{lineDragging:s}=this;if(this.lineDragging=!1,this.isSpaceKey)return;if(this.isNone&&t.ctrlKey){const o=this.findHoverLine(i);o&&this.setInvalidLine(o.id);return}if(this.isLinePointsExceed())return;const n=this.getNextPoint(t,i);if(this.isCreate||this.isNone){this.setCreateStatusAndAddPoint(n);return}if(this.isActive){if(s)return;if(this.isMouseCoordOutsideActiveArea()){this.setNoneStatus(!1),this.setCreateStatusAndAddPoint(n);return}if(t.shiftKey){this.updateLineSegmentSpecial(i);return}this.coordsInsideActiveArea&&t.ctrlKey&&this.setInvalidLine(this.selectedID),this.addLinePointToActiveLine()}},this.onDblclick=()=>{},this.onKeyUp=t=>{if(super.onKeyUp(t),this.isShift=!1,this.hoverLineSegmentIndex=-1,!this.selection.triggerKeyboardEvent(t,this.setLineList)){if(t.keyCode===keyCode.Esc){this.stopLineCreating(!1);return}if(this.selectedLine){if(t.key==="Delete"){this.deleteLine();return}if(t.key==="f"){this.setInvalidLine(this.selectedID);return}if(t.key===" "){this.continueToEdit();return}}this.keyboardEventWhileLineCreating(t)}},this.onRightDblClick=t=>{super.onRightDblClick(t);const i=this.getCoordinate(t);if(this.isActive){const s=this.findHoveredPoint(i);if(s){this.deleteSelectedLinePoint(s.id);return}this.deleteSelectedLine(i)}},this.setReference=t=>{this.isReference=t},this.pointsWithinRange=t=>!(this.lowerLimitPointNum&&t<this.lowerLimitPointNum||this.upperLimitPointNum&&t>this.upperLimitPointNum),this.setLineList=t=>{const i=t.length!==this.lineListLen;this.lineList=t,i&&this.emit("updatePageNumber")},this.textChange=t=>{this.config.textConfigurable===!1||!this.selectedID||(this.updateSelectedTextAttribute(t),this.emit("selectedChange"))},this.status=2,this.isMousedown=!1,this.lineDragging=!1,this.isLineValid=!0,this.setConfig(e.config),this.prevAxis={x:0,y:0},this.textEditingID="",this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.actionsHistory=new ActionsHistory,this.selection=new Selection(this),this.dependToolConfig={lineType:tool.ELineTypes.Line},this.historyDisabled=!1}get selectedLines(){return this.lineList.filter(e=>this.selection.isIdSelected(e.id))}get isLineSelected(){return this.selectedID&&this.activeLine}get selectedLine(){return this.lineList.find(e=>e.id===this.selectedID)}get isCreate(){return this.status===0}get isActive(){return this.selectedLines.length>0}get isNone(){return!this.isCreate&&this.selectedIDs.length===0}get isCurve(){return this.config.lineType===tool.ELineTypes.Curve}get isMultipleColor(){return this.config.lineColor===tool.ELineColor.MultiColor}get imageSize(){return this.rotate%180==0?this.basicImgInfo:{width:this.basicImgInfo.height,height:this.basicImgInfo.width}}get lineListLen(){return this.lineList.length}get edgeAdsorptionEnabled(){return this.edgeAdsorption&&!this.isCurve&&this.lineListLen>0}get attributeConfigurable(){return this.config.attributeConfigurable}get isTextConfigurable(){return this.config.textConfigurable}get isDependPolygon(){return this.dependToolName===tool.EToolName.Polygon}get isDependRect(){return this.dependToolName===tool.EToolName.Rect}get isCurrentAttributeLocked(){return this.attributeLockList.includes(this.defaultAttribute)}get attributeFilteredLines(){return this.attributeLockList.length>0?this.lineList.filter(e=>this.attributeLockList.includes((e==null?void 0:e.attribute)||"")):this.lineList}get selectedIDs(){return this.selection.selectedIDs}get selectedID(){return this.selection.selectedID}get enableOutOfTarget(){return this.config.enableOutOfTarget||this.config.outOfTarget||this.config.drawOutsideTarget}get showOrder(){var e;return(e=this.config.showOrder)!=null?e:this.config.isShowOrder}get edgeAdsorption(){return this.config.edgeAdsorption}get attributeList(){return this.config.attributeList}get lowerLimitPointNum(){return this.config.lowerLimitPointNum}get minLength(){var e;return((e=this.config)==null?void 0:e.minLength)||0}get upperLimitPointNum(){return this.config.upperLimitPointNum}get textCheckType(){return this.config.textCheckType}get customFormat(){return this.config.customFormat}get dataList(){return this.lineList}get hasActiveLine(){return this.activeLine&&this.activeLine.length>0}get viewPortLines(){const e=CanvasUtils.getViewPort(this.canvas,this.currentPos,this.zoom);return this.isHidden?[]:this.attributeFilteredLines.filter(t=>{var i;return(i=t==null?void 0:t.pointList)==null?void 0:i.some(s=>CanvasUtils.inViewPort(s,e))})}get lineStyle(){return{lineWidth:this.style.width,color:this.getLineColor(this.defaultAttribute),opacity:this.style.opacity}}get selectedText(){var e,t;return(t=(e=this.lineList.find(i=>i.id===this.selectedID))==null?void 0:e.textAttribute)!=null?t:""}get currentPageResult(){return this.lineList}updateStatus(e,t=!1){if(e!==this.status){if(t){let i="";this.textCheckType===tool.ETextType.Order&&this.isTextConfigurable&&(i=AttributeUtils.default.getTextAttribute(this.lineList,this.textCheckType)),this.emit("updateText",i)}this.status=e,this.lineStatusChanged()}}isInBasicPolygon(e){var t,i;return polygonTool.isInPolygon(e,((t=this.basicResult)==null?void 0:t.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}getPolygonPointList(){if(!this.basicResult)return[];const{pointList:e}=this.basicResult,{lineType:t}=this.dependToolConfig;return t===tool.ELineTypes.Curve?polygonTool.createSmoothCurvePoints(e.reduce((i,s)=>[...i,s.x,s.y],[]),.5,!0,20):e}getNextCoordByRenderCoord(e){return this.getNextCoordByAbsCoord(this.coordUtils.getAbsCoord(e))}getNextCoordByAbsCoord(e){var t;const i=(t=this.activeLine)==null?void 0:t.slice(-1)[0];return i?this.coordUtils.getNextCoordByDependTool(e,i):e}pointInLine(e,t,i){return e.filter(s=>s).length<2?!1:e.some((s,n)=>{if(n===0)return!1;const o=this.coordUtils.getRenderCoord(e[n-1]),r=this.coordUtils.getRenderCoord(s);return LineToolUtils.default.isInLine(t,o,r,i)})}arc(e,t=POINT_RADIUS,i){var s,n,o,r,h,l;if(this.ctx){const{x:d,y:u}=e;(s=this.ctx)==null||s.save(),(n=this.ctx)==null||n.beginPath(),this.ctx.fillStyle=i||this.lineStyle.color,(o=this.ctx)==null||o.arc(d,u,t,0,360),(r=this.ctx)==null||r.closePath(),(h=this.ctx)==null||h.fill(),(l=this.ctx)==null||l.restore()}}renderActiveArea({top:e,left:t,right:i,bottom:s}){this.ctx&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.strokeStyle="#B3B8FF",this.ctx.rect(t,e,i-t,s-e),this.ctx.stroke(),this.ctx.restore())}addLinePoint(e){var t,i,s,n;this.arc(e),(t=this.activeLine)==null||t.push(__spreadProps(__spreadValues({},e),{id:uuid()})),((i=this.activeLine)==null?void 0:i.length)===1?(s=this.actionsHistory)==null||s.initRecord(this.activeLine):(n=this.actionsHistory)==null||n.pushHistory(this.activeLine),this.render()}setCreateStatusAndAddPoint(e,t=!1){this.updateStatus(0,t),this.addLinePoint(e)}isActiveLineValid(){var e;return this.selectedID?(e=this.lineList.find(t=>t.id===this.selectedID))==null?void 0:e.valid:this.isLineValid}nextOrder(){return this.lineListLen===0?1:this.lineList.slice(-1)[0].order+1}getLineColorByAttribute(e,t=!1){return StyleUtils.getStrokeAndFill(this.getColor(e.attribute),e.valid,{isSelected:t}).stroke}drawLineNumber(e,t=1,i,s="",n,o=!0){var r,h,l;if((this.showOrder||this.attributeConfigurable)&&this.ctx){let d=this.showOrder?t.toString():`${s}`;if(this.attributeConfigurable){const u=n?(l=(h=(r=this.attributeList)==null?void 0:r.find(c=>c.value===n))==null?void 0:h.key)!=null?l:n:"";d=[d,`${!o&&u?"\u65E0\u6548":""}${u}`].filter(c=>c).join("_")}this.drawText(e,d,i)}}drawLineTextAttribute(e,t,i){if(e&&i)return this.drawText(e,i,t,200)}drawLineLength(e,t){var i;if(((i=this.config)==null?void 0:i.showLineLength)&&e){const s=e.reduce((o,r,h)=>h<=0||!e[h-1].actual||!r.actual?o:o+LineToolUtils.default.calcDistance(e[h-1].actual,r.actual),0),n=e[e.length-1];this.drawText(n,`l = ${s.toFixed(2)}`,t)}}drawText(e,t,i,s){var n,o;this.ctx&&((n=this.ctx)==null||n.save(),this.ctx.font="italic bold 14px SourceHanSansCN-Regular",this.ctx.fillStyle=i,this.ctx.strokeStyle=i,this.ctx.shadowColor="rgba(0, 0, 0, 0.6)",this.ctx.shadowOffsetY=2,this.ctx.shadowBlur=4,s?DrawUtils.wrapText(this.canvas,t,e.x-LINE_ORDER_OFFSET.x,e.y-LINE_ORDER_OFFSET.y,s):this.ctx.fillText(t,e.x-LINE_ORDER_OFFSET.x,e.y-LINE_ORDER_OFFSET.y),(o=this.ctx)==null||o.restore())}moveActiveArea(e,t){this.selectedLines.length>0&&(this.selectedLines.forEach(i=>{var s;(s=i.pointList)==null||s.forEach(n=>Object.assign(n,{x:n.x+e,y:n.y+t}))}),this.render()),this.emit("dataUpdated",this.lineList,this.selectedIDs)}findHoveredPoint(e){if(!!this.activeLine)return this.activeLine.find(t=>{const i=this.coordUtils.getRenderCoord(t);return LineToolUtils.default.calcDistance(i,e)<=POINT_ACTIVE_RADIUS})}findHoverLine(e){return ___default.default.cloneDeep(this.lineList).reverse().find(({pointList:i})=>{const s=i?this.getPointList(i):[],n=this.getLineWidthScope();return s.some((o,r)=>{if(r===0)return!1;const h=this.coordUtils.getRenderCoord(o),l=this.coordUtils.getRenderCoord(s[r-1]);return LineToolUtils.default.isInLine(e,h,l,n)})})}getAdsorptionPoint(e){let t,i,s;return ___default.default.cloneDeep(this.lineList).reverse().forEach(({pointList:n,id:o})=>{if(o===this.selectedID||!n||(n==null?void 0:n.length)<2)return;const r=this.findNearestPoint(n,e);if(r){if(r.minDistance===0){t=r.point;return}(i===void 0||r.minDistance<i)&&(t=r.point,i=r.minDistance)}}),s||t}findNearestPoint(e,t,i=7){let s;const n=i;for(let o=1;o<=e.length-1;o++){const r=this.coordUtils.getRenderCoord(e[o]),h=this.coordUtils.getRenderCoord(e[o-1]),{length:l,footPoint:d}=MathUtils.default.getFootOfPerpendicular(t,r,h),u=LineToolUtils.default.calcTwoPointDistance(r,t),c=LineToolUtils.default.calcTwoPointDistance(h,t);if(u<=i*2){s=r,i=0;break}if(c<=i*2){s=h,i=0;break}l<i&&(s=d,i=l)}return s?{point:s,minDistance:n}:void 0}getPointList(e){return this.isCurve?polygonTool.createSmoothCurvePointsFromPointList(e,SEGMENT_NUMBER):e}moveSelectedLine(e){const t=(e.x-this.prevAxis.x)/this.zoom,i=(e.y-this.prevAxis.y)/this.zoom;if(this.enableOutOfTarget){this.lineDragging=!0,this.moveActiveArea(t,i);return}if(this.isDependPolygon){this.moveLineInPolygon(t,i);return}let s=[0,this.imageSize.width],n=[0,this.imageSize.height];if(this.isDependRect){const{x:o,y:r,width:h,height:l}=this.basicResult;s=[o,o+h],n=[r,r+l]}this.moveLineInRectRange(t,i,s,n)}moveSelectPoint(e){if(!this.selectedPoint)return;const t=e.x-this.prevAxis.x,i=e.y-this.prevAxis.y,s=(this.selectedPoint?this.selectedPoint.x:0)+t/this.zoom,n=(this.selectedPoint?this.selectedPoint.y:0)+i/this.zoom,o={x:s,y:n};Object.assign(this.selectedPoint,this.getNextCoordByAbsCoord(o)),this.updateLines(),this.render()}getCoordByConfig(e,t){var i;const s=!!e.shiftKey,n=e.altKey;if(((i=this.activeLine)==null?void 0:i.length)>0&&s){const o=this.activeLine.slice(-1)[0];return LineToolUtils.default.getVHPoint(o,t,this.coordUtils.getAbsCoord(t),this.coordUtils.getRenderCoord(o))}return this.edgeAdsorptionEnabled&&!n?this.getAdsorptionPoint(t):t}getNextPoint(e,t){const i=this.getCoordByConfig(e,t)||t;return this.enableOutOfTarget?this.coordUtils.getAbsCoord(i):this.getNextCoordByRenderCoord(i)}lineHover(){this.render()}mouseMoveHandler(e){const t=this.getCoordinate(e),i=e.which===1;if(this.isCreate){this.hasActiveLine&&this.renderNextPoint(e,t);return}if(this.isNone&&(this.lineHover(),this.edgeAdsorptionEnabled&&!e.altKey)){const s=this.getAdsorptionPoint(t);s&&this.arc(s)}if(this.isActive){if(this.isMousedown&&i){if(this.selectedPoint){this.moveSelectPoint(t);return}if(this.coordsInsideActiveArea){this.moveSelectedLine(t),this.drawActivatedLine(void 0,void 0,!0);return}}this.drawHoverPoint(t),this.render()}}onMouseMove(e){if(super.onMouseMove(e)||this.forbidMouseOperation||!this.imgInfo)return;const t=this.getCoordinate(e);this.mouseMoveHandler(e),this.prevAxis=t}setActiveLine(e){this.activeLine=e?___default.default.cloneDeep(e):void 0}historyChanged(e){if(this.historyDisabled)return;const t=`${e}Enabled`;if(this.isCreate){if(this.actionsHistory&&this.actionsHistory[t]){const i=this.actionsHistory&&this.actionsHistory[e]();this.setActiveLine(i),this.render()}return}if(this.history&&this.history[t]){const i=this.history[e](),s=i==null?void 0:i.find(n=>n.id===this.selectedID);this.lineList=i,this.selectedID&&s?this.setActiveLine(s==null?void 0:s.pointList):this.setNoneStatus(),this.render()}this.emit("dataUpdated",this.lineList)}undo(){this.historyChanged("undo"),this.updateSelectedAttributeAfterHistoryChanged()}redo(){this.historyChanged("redo"),this.updateSelectedAttributeAfterHistoryChanged()}isCoordInsideTarget(e){if(this.isDependPolygon)return this.isInBasicPolygon(e);if(this.isDependRect){const{x:t,y:i,width:s,height:n}=this.basicResult,o=[t,t+s],r=[i,i+n];return MathUtils.default.isInRange(e.x,o)&&MathUtils.default.isInRange(e.y,r)}return MathUtils.default.isInRange(e.x,[0,this.imageSize.width])&&MathUtils.default.isInRange(e.y,[0,this.imageSize.height])}getPointInsertIndex(e,t){if(e&&this.activeLine){const i=this.getPointList(this.activeLine);return this.activeLine.length===2?1:this.activeLine.findIndex((s,n)=>{if(n>0){const o=this.activeLine?this.activeLine[n-1]:void 0,r=this.isCurve?i.slice((n-1)*(SEGMENT_NUMBER+1),n*(SEGMENT_NUMBER+1)):[o,s];return this.pointInLine(r,e,t||this.getLineWidthScope())}return!1})}return-1}getLineWidthScope(){return this.lineStyle.lineWidth}isMouseCoordOutsideActiveArea(){return!this.coordsInsideActiveArea&&!this.selectedPoint}isLinePointsExceed(){return this.isCreate&&this.activeLine&&this.upperLimitPointNum&&~~this.upperLimitPointNum<=this.activeLine.length}isLinePointsNotEnough(){var e;return this.activeLine&&((e=this.activeLine)==null?void 0:e.length)<this.lowerLimitPointNum}updateLineSegmentSpecial(e){const t=this.getPointInsertIndex(e,2)-1;if(t>-1){const i=this.activeLine[t];i.specialEdge=!i.specialEdge,this.hoverLineSegmentIndex=-1,this.render()}}addLinePointToActiveLine(){var e;const t=this.getPointInsertIndex(this.cursor),i=this.pointsWithinRange(this.activeLine.length+1);this.cursor&&t>-1&&i&&(this.activeLine.splice(t,0,__spreadProps(__spreadValues({},this.coordUtils.getAbsCoord(this.cursor)),{id:uuid()})),this.updateLines(),(e=this.history)==null||e.pushHistory(this.lineList),this.render(),this.cursor=void 0)}isCoordOnSelectedArea(e){return this.selectedLines.some(t=>LineToolUtils.default.inArea(MathUtils.default.calcViewportBoundaries(t.pointList),this.coordUtils.getAbsCoord(e)))}onMouseDown(e){if(super.onMouseDown(e)||this.forbidMouseOperation||!this.imgInfo)return;const t=this.getCoordinate(e);if(this.isMousedown=!0,this.prevAxis=t,e.which===3){this.cursor=void 0;return}this.selectedPoint=this.findHoveredPoint(t),this.coordsInsideActiveArea=this.selectedLines.length>0?this.isCoordOnSelectedArea(t):!1,this.lineDragging=!1}lineHasChanged(){const e=this.lineList.find(t=>t.id===this.selectedID);return e?JSON.stringify(e.pointList)!==JSON.stringify(this.activeLine):!1}updateLines(){const e=this.lineList.find(t=>t.id===this.selectedID);e&&(e.pointList=___default.default.cloneDeep(this.activeLine),this.updatedLine=e,this.emit("dataUpdated",this.lineList))}onMouseUp(e){const t=()=>{this.isMousedown=!1,this.hoverPointID=void 0,this.cursor=void 0,this.selectedPoint=void 0};if(this.hoverPointID=void 0,super.onMouseUp(e)||this.forbidMouseOperation||!this.imgInfo){t();return}e.which===1&&this.onLeftClick(e),e.which===3&&this.onRightClick(e),t()}isTextValid(e){return AttributeUtils.default.textAttributeValidate(this.textCheckType,this.customFormat,e)}createLineData(){const e=uuid(),t={pointList:___default.default.cloneDeep(this.activeLine),id:e,valid:this.isLineValid,order:this.nextOrder()};return t.attribute=this.defaultAttribute,t}stopLineCreating(e=!0){var t,i,s,n;const o=this.selectedID?!0:!!this.isTextConfigurable;let r;if(e){if(this.selectedID){const h=this.lineList.find(l=>l.id===this.selectedID);r=this.selectedID,h&&(h.pointList=___default.default.cloneWith(this.activeLine),___default.default.isEqual(h.pointList,(t=this.history)==null?void 0:t.pushHistory(this.lineList))||(i=this.history)==null||i.pushHistory(this.lineList))}else if(this.isCreate&&this.activeLine&&this.activeLine.length>1){const h=this.createLineData();r=h.id,this.setLineList([...this.lineList,h]),(s=this.history)==null||s.pushHistory(this.lineList)}}o?(this.activeLine=[],this.setSelectedLineID(r,!1,!1)):this.setNoneStatus(),(n=this.actionsHistory)==null||n.empty(),this.render()}setNoneStatus(e=!0){e&&this.updateStatus(2),this.activeLine=[],this.setSelectedLineID(void 0),this.isLineValid=!0,this.cursor=void 0}setKeyDownStatus(e,t){this.isShift=t!=null?t:e.keyCode===keyCode.Shift}continueToEdit(){var e,t;((e=this.selectedLine)==null?void 0:e.pointList)&&(this.updateStatus(0),this.cursor=void 0,this.setActiveLine(this.selectedLine.pointList),(t=this.actionsHistory)==null||t.pushHistory(this.activeLine),this.render())}setInvalidLineOnCreating(e){if(this.selectedID&&e.keyCode!==keyCode.Ctrl||!this.isCreate)return;const t=!e.ctrlKey;this.selectedID?this.setInvalidLine(this.selectedID,t,!1):this.isLineValid=t}onKeyDown(e){if(super.onKeyDown(e),this.setKeyDownStatus(e),e.keyCode===keyCode.Z&&!e.ctrlKey&&this.toggleIsHide(),e.keyCode===keyCode.Shift&&this.render(),e.keyCode===keyCode.Tab){e.preventDefault(),this.selectToNextLine(e);return}if(this.isCreate&&this.keyboardEventWhileLineCreating(e),this.config.attributeConfigurable){const t=AttributeUtils.default.getAttributeByKeycode(e.keyCode,this.config.attributeList);t!==void 0&&this.setDefaultAttribute(t)}}selectToNextLine(e){const t=CommonToolUtils.getNextSelectedRectIDByEvent(this.viewPortLines.map(i=>{var s,n,o,r;return __spreadProps(__spreadValues({},i),{x:(n=(s=i.pointList[0])==null?void 0:s.x)!=null?n:0,y:(r=(o=i.pointList[0])==null?void 0:o.y)!=null?r:0})}),e,this.selectedID);t&&this.selection.setSelectedIDs(t.id)}keyboardEventWhileLineCreating(e){!this.isCreate||(e.keyCode===keyCode.Ctrl&&this.setInvalidLineOnCreating(e),[keyCode.Shift,keyCode.Alt].includes(e.keyCode)&&this.renderNextPoint(e,this.prevAxis))}renderNextPoint(e,t){const i=this.coordUtils.getRenderCoord(this.getNextPoint(e,t));this.render(i)}deleteSelectedLine(e){var t;if(this.selectedLine){const i=MathUtils.default.calcViewportBoundaries((t=this.selectedLine)==null?void 0:t.pointList,this.isCurve,SEGMENT_NUMBER,this.zoom);LineToolUtils.default.inArea(i,this.coordUtils.getAbsCoord(e))&&this.deleteLine()}}deleteSelectedLinePoint(e){var t;this.pointsWithinRange(this.activeLine.length-1)&&e&&(this.setActiveLine(this.activeLine.filter(s=>s.id!==e)),this.updateLines(),(t=this.history)==null||t.pushHistory(this.lineList)),this.cursor=void 0,this.render()}deleteLine(){var e;this.lineList=this.lineList.filter(t=>!this.selection.isIdSelected(t.id)),(e=this.history)==null||e.pushHistory(this.lineList),this.setNoneStatus(),this.emit("dataUpdated",this.lineList),this.render()}setInvalidLine(e,t,i=!0){var s;const n=this.lineList.find(o=>o.id===e);n&&(n.valid=t!==void 0?t:!n.valid,(s=this.history)==null||s.pushHistory(this.lineList),this.emit("dataUpdated",this.lineList),i&&this.render())}empty(){var e,t;this.lineList=[],this.setNoneStatus(),this.selectedPoint=void 0,(e=this.actionsHistory)==null||e.empty(),(t=this.history)==null||t.init(),this.emit("dataUpdated",this.lineList),this.render()}setAttribute(e){var t;this.attributeConfigurable&&(this.defaultAttribute=e,this.setLineAttribute("attribute",e),this.selectedIDs.length>0&&((t=this.history)==null||t.pushHistory(this.lineList)))}setTextAttribute(e){var t;this.isTextConfigurable&&(this.setLineAttribute("textAttribute",e),(t=this.history)==null||t.applyAttribute(this.selectedID,"textAttribute",e))}setLineAttribute(e,t){this.selectedIDs.length>0&&(this.lineList.forEach(i=>{this.selection.isIdSelected(i.id)&&(i[e]=t)}),this.render())}updateAttribute(e){this.emit("updateAttribute",e)}updateLineAttributes(e){var t;if(this.attributeConfigurable&&e){const i=(e==null?void 0:e.attribute)||"";this.defaultAttribute=i,this.updateAttribute(i)}if(this.isTextConfigurable&&e){const i=(e==null?void 0:e.textAttribute)||"";this.updateTextAttribute(i)}(t=this.history)==null||t.updateHistory(this.lineList)}lineStatusChanged(){this.emit("lineStatusChanged",{status:this.status,selectedLineID:this.selectedID})}updateTextAttribute(e){if(this.selectedID){const t=this.lineList.find(i=>i.id===this.selectedID);t&&(t.textAttribute=e)}this.emit("updateText",e)}saveData(){this.stopLineCreating(),this.setNoneStatus(),this.render()}setTextEditingID(e){this.textEditingID=e,this.render()}updateAttrWhileIDChanged(e){if(e){const t=this.lineList.find(i=>i.id===e);t&&this.setDefaultAttribute(t.attribute)}}setSelectedLineID(e,t=!1,i=!0){this.selection.setSelectedIDs(e,t),this.status=1,i&&e&&this.updateAttrWhileIDChanged(this.selectedID),this.selectedLine&&this.setActiveLine(this.selectedLine.pointList),this.selectedIDs.length===0&&this.setActiveLine([]),this.emit("dataUpdated",this.lineList,this.selectedIDs)}attributeLockListChange(e){this.attributeLockList=e,this.render()}setResult(e){this.setLineList(e),this.render()}setConfig(e){super.setConfig(e)}toggleIsHide(){this.setIsHidden(!this.isHidden),this.render()}clearCanvas(){super.clearCanvas()}clearResult(){this.setResult([]),this.setSelectedLineID(void 0),this.render()}exportData(){return[this.lineList,this.basicImgInfo]}setDefaultAttribute(e=""){var t;this.attributeConfigurable&&(this.defaultAttribute=e,this.changeStyle(this.defaultAttribute),this.setLineAttribute("attribute",e),this.selectedIDs.length>0&&((t=this.history)==null||t.pushHistory(this.lineList)),this.emit("changeAttributeSidebar"))}getCurrentSelectedData(){var e,t;const i=this.isActiveLineValid(),s=this.defaultAttribute,n=this.getColor(s),o=i?n==null?void 0:n.valid.stroke:n==null?void 0:n.invalid.stroke,r=(t=(e=this.lineList.find(h=>h.id===this.selectedID))==null?void 0:e.textAttribute)!=null?t:"";return{color:o,textAttribute:r}}renderTextAttribute(){var e,t,i,s;if(!this.ctx||!this.selectedLine||this.activeLine&&((e=this.activeLine)==null?void 0:e.length)<2)return;const n=this.isActiveLineValid(),o=this.defaultAttribute,{x:r,y:h}=this.selectedLine.pointList[1],l=this.coordUtils.getRenderCoord({x:r,y:h}),d=this.getColor(o),u=n?d==null?void 0:d.valid.stroke:d==null?void 0:d.invalid.stroke,c=(i=(t=this.lineList.find(f=>f.id===this.selectedID))==null?void 0:t.textAttribute)!=null?i:"";this._textAttributeInstance||(this._textAttributeInstance=new textAttributeClass({container:this.container,icon:this.getTextIconSvg(o),color:u,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributeInstance&&!((s=this._textAttributeInstance)==null?void 0:s.isExit)&&this._textAttributeInstance.appendToContainer(),this._textAttributeInstance.update(`${c}`,{left:l.x,top:l.y,color:u}),this._textAttributeInstance.updateIcon(this.getTextIconSvg(o))}getTextIconSvg(e=""){return AttributeUtils.default.getTextIconSvg(e,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}updateSelectedTextAttribute(e){if(this._textAttributeInstance&&e&&this.selectedID){let t=e;!AttributeUtils.default.textAttributeValidate(this.config.textCheckType,"",t)&&(this.emit("messageError",AttributeUtils.default.getErrorNotice(this.config.textCheckType,this.lang)),t=""),this.setTextAttribute(t),this.emit("updateTextAttribute"),this.render()}}}exports.INNER_POINT_RADIUS=INNER_POINT_RADIUS,exports.LINE_ORDER_OFFSET=LINE_ORDER_OFFSET,exports.POINT_ACTIVE_RADIUS=POINT_ACTIVE_RADIUS,exports.POINT_RADIUS=POINT_RADIUS,exports.SEGMENT_NUMBER=SEGMENT_NUMBER,exports.default=LineToolOperation;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var rectOperation=require("./core/toolOperation/rectOperation.js"),tagOperation=require("./core/toolOperation/tagOperation.js"),pointOperation=require("./core/toolOperation/pointOperation.js"),LineToolOperation=require("./core/toolOperation/LineToolOperation.js"),TextToolOperation=require("./core/toolOperation/TextToolOperation.js"),polygonOperation=require("./core/toolOperation/polygonOperation.js"),measureOperation=require("./core/toolOperation/measureOperation.js"),pointCloud2DRectOperation=require("./core/toolOperation/pointCloud2DRectOperation.js"),basicToolOperation=require("./core/toolOperation/basicToolOperation.js"),ViewOperation=require("./core/toolOperation/ViewOperation.js"),ScribbleTool=require("./core/toolOperation/ScribbleTool.js"),pointCloud2dOperation=require("./core/toolOperation/pointCloud2dOperation.js"),annotation=require("./constant/annotation.js"),annotationTask=require("./constant/annotationTask.js"),keyCode=require("./constant/keyCode.js"),style=require("./constant/style.js"),tool=require("./constant/tool.js"),TagUtils=require("./utils/tool/TagUtils.js"),uuid=require("./utils/uuid.js"),EnhanceCommonToolUtils=require("./utils/tool/EnhanceCommonToolUtils.js"),MarkerUtils=require("./utils/tool/MarkerUtils.js"),RectUtils=require("./utils/tool/RectUtils.js"),AxisUtils=require("./utils/tool/AxisUtils.js"),DrawUtils=require("./utils/tool/DrawUtils.js"),ImgUtils=require("./utils/ImgUtils.js"),MathUtils=require("./utils/MathUtils.js"),AttributeUtils=require("./utils/tool/AttributeUtils.js"),ActionsHistory=require("./utils/ActionsHistory.js"),DblClickEventListener=require("./utils/tool/DblClickEventListener.js"),index=require("./core/index.js"),UnitUtils=require("./utils/tool/UnitUtils.js"),StyleUtils=require("./utils/tool/StyleUtils.js"),CanvasScheduler=require("./newCore/CanvasScheduler.js"),index$1=require("./core/pointCloud/index.js"),matrix=require("./core/pointCloud/matrix.js"),annotation$1=require("./core/pointCloud/annotation.js");function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}var keyCode__namespace=_interopNamespaceDefaultOnly(keyCode);const CommonToolUtils=EnhanceCommonToolUtils.default,toolUtils=EnhanceCommonToolUtils.default;exports.RectOperation=rectOperation.RectOperation,exports.TagOperation=tagOperation,exports.PointOperation=pointOperation,exports.LineToolOperation=LineToolOperation.default,exports.TextToolOperation=TextToolOperation,exports.PolygonOperation=polygonOperation,exports.MeasureOperation=measureOperation,exports.PointCloud2DRectOperation=pointCloud2DRectOperation,exports.BasicToolOperation=basicToolOperation.BasicToolOperation,exports.ViewOperation=ViewOperation,exports.ScribbleTool=ScribbleTool,exports.PointCloud2dOperation=pointCloud2dOperation,exports.cAnnotation=annotation,exports.cAnnotationTask=annotationTask,exports.cKeyCode=keyCode__namespace,exports.cStyle=style,exports.CLIENT_TOOL_HEAD_TYPE=tool.CLIENT_TOOL_HEAD_TYPE,exports.CLIENT_TOOL_NAME=tool.CLIENT_TOOL_NAME,exports.DEFAULT_FONT=tool.DEFAULT_FONT,exports.DEFAULT_TEXT_MAX_WIDTH=tool.DEFAULT_TEXT_MAX_WIDTH,Object.defineProperty(exports,"EAnnotationMode",{enumerable:!0,get:function(){return tool.EAnnotationMode}}),Object.defineProperty(exports,"EAuditStatus",{enumerable:!0,get:function(){return tool.EAuditStatus}}),Object.defineProperty(exports,"ECheckModel",{enumerable:!0,get:function(){return tool.ECheckModel}}),Object.defineProperty(exports,"EDependPattern",{enumerable:!0,get:function(){return tool.EDependPattern}}),Object.defineProperty(exports,"EDragTarget",{enumerable:!0,get:function(){return tool.EDragTarget}}),Object.defineProperty(exports,"EDrawPointPattern",{enumerable:!0,get:function(){return tool.EDrawPointPattern}}),Object.defineProperty(exports,"EFilterToolOperation",{enumerable:!0,get:function(){return tool.EFilterToolOperation}}),Object.defineProperty(exports,"ELineColor",{enumerable:!0,get:function(){return tool.ELineColor}}),Object.defineProperty(exports,"ELineTypes",{enumerable:!0,get:function(){return tool.ELineTypes}}),Object.defineProperty(exports,"EOperationMode",{enumerable:!0,get:function(){return tool.EOperationMode}}),Object.defineProperty(exports,"EPageOperator",{enumerable:!0,get:function(){return tool.EPageOperator}}),Object.defineProperty(exports,"EPointCloudName",{enumerable:!0,get:function(){return tool.EPointCloudName}}),Object.defineProperty(exports,"EPolygonPattern",{enumerable:!0,get:function(){return tool.EPolygonPattern}}),Object.defineProperty(exports,"ERectPattern",{enumerable:!0,get:function(){return tool.ERectPattern}}),Object.defineProperty(exports,"EScribblePattern",{enumerable:!0,get:function(){return tool.EScribblePattern}}),Object.defineProperty(exports,"ESelectedType",{enumerable:!0,get:function(){return tool.ESelectedType}}),Object.defineProperty(exports,"ETextType",{enumerable:!0,get:function(){return tool.ETextType}}),Object.defineProperty(exports,"EThumbnailOption",{enumerable:!0,get:function(){return tool.EThumbnailOption}}),Object.defineProperty(exports,"EToolName",{enumerable:!0,get:function(){return tool.EToolName}}),Object.defineProperty(exports,"EToolType",{enumerable:!0,get:function(){return tool.EToolType}}),Object.defineProperty(exports,"EVideoToolName",{enumerable:!0,get:function(){return tool.EVideoToolName}}),exports.OPERATION_LIST=tool.OPERATION_LIST,exports.SEGMENT_NUMBER=tool.SEGMENT_NUMBER,exports.TEXT_ATTRIBUTE_LINE_HEIGHT=tool.TEXT_ATTRIBUTE_LINE_HEIGHT,exports.TEXT_ATTRIBUTE_MAX_LENGTH=tool.TEXT_ATTRIBUTE_MAX_LENGTH,exports.TEXT_TYPE=tool.TEXT_TYPE,exports.TOOL_NAME=tool.TOOL_NAME,exports.TOOL_NAME_EN=tool.TOOL_NAME_EN,exports.cTool=tool,exports.edgeAdsorptionScope=tool.edgeAdsorptionScope,exports.editStepWidth=tool.editStepWidth,exports.TagUtils=TagUtils,exports.uuid=uuid,exports.MarkerUtils=MarkerUtils,exports.RectUtils=RectUtils,exports.AxisUtils=AxisUtils.default,exports.DrawUtils=DrawUtils,exports.ImgUtils=ImgUtils,exports.MathUtils=MathUtils.default,exports.AttributeUtils=AttributeUtils.default,exports.ActionsHistory=ActionsHistory,exports.DblClickEventListener=DblClickEventListener,exports.AnnotationEngine=index,exports.UnitUtils=UnitUtils,exports.StyleUtils=StyleUtils,exports.CanvasScheduler=CanvasScheduler.CanvasScheduler,exports.PointCloud=index$1.PointCloud,exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=matrix.getHighlightIndexByPoints,exports.isInImage=matrix.isInImage,exports.lidar2image=matrix.lidar2image,exports.mergeHighlightList=matrix.mergeHighlightList,exports.point2dTo3D=matrix.point2dTo3D,exports.point3DLidar2Image=matrix.point3DLidar2Image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloudAnnotation=annotation$1.PointCloudAnnotation,exports.CommonToolUtils=CommonToolUtils,exports.toolUtils=toolUtils;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var rectOperation=require("./core/toolOperation/rectOperation.js"),tagOperation=require("./core/toolOperation/tagOperation.js"),pointOperation=require("./core/toolOperation/pointOperation.js"),LineToolOperation=require("./core/toolOperation/LineToolOperation.js"),TextToolOperation=require("./core/toolOperation/TextToolOperation.js"),polygonOperation=require("./core/toolOperation/polygonOperation.js"),measureOperation=require("./core/toolOperation/measureOperation.js"),pointCloud2DRectOperation=require("./core/toolOperation/pointCloud2DRectOperation.js"),basicToolOperation=require("./core/toolOperation/basicToolOperation.js"),ViewOperation=require("./core/toolOperation/ViewOperation.js"),ScribbleTool=require("./core/toolOperation/ScribbleTool.js"),pointCloud2dOperation=require("./core/toolOperation/pointCloud2dOperation.js"),annotation=require("./constant/annotation.js"),annotationTask=require("./constant/annotationTask.js"),keyCode=require("./constant/keyCode.js"),style=require("./constant/style.js"),tool=require("./constant/tool.js"),TagUtils=require("./utils/tool/TagUtils.js"),uuid=require("./utils/uuid.js"),EnhanceCommonToolUtils=require("./utils/tool/EnhanceCommonToolUtils.js"),MarkerUtils=require("./utils/tool/MarkerUtils.js"),RectUtils=require("./utils/tool/RectUtils.js"),AxisUtils=require("./utils/tool/AxisUtils.js"),DrawUtils=require("./utils/tool/DrawUtils.js"),ImgUtils=require("./utils/ImgUtils.js"),MathUtils=require("./utils/MathUtils.js"),AttributeUtils=require("./utils/tool/AttributeUtils.js"),ActionsHistory=require("./utils/ActionsHistory.js"),EventBus=require("./utils/EventBus.js"),DblClickEventListener=require("./utils/tool/DblClickEventListener.js"),index=require("./core/index.js"),UnitUtils=require("./utils/tool/UnitUtils.js"),StyleUtils=require("./utils/tool/StyleUtils.js"),CanvasScheduler=require("./newCore/CanvasScheduler.js"),index$1=require("./core/pointCloud/index.js"),matrix=require("./core/pointCloud/matrix.js"),annotation$1=require("./core/pointCloud/annotation.js");function _interopNamespaceDefaultOnly(e){return Object.freeze({__proto__:null,default:e})}var keyCode__namespace=_interopNamespaceDefaultOnly(keyCode);const CommonToolUtils=EnhanceCommonToolUtils.default,toolUtils=EnhanceCommonToolUtils.default;exports.RectOperation=rectOperation.RectOperation,exports.TagOperation=tagOperation,exports.PointOperation=pointOperation,exports.LineToolOperation=LineToolOperation.default,exports.TextToolOperation=TextToolOperation,exports.PolygonOperation=polygonOperation,exports.MeasureOperation=measureOperation,exports.PointCloud2DRectOperation=pointCloud2DRectOperation,exports.BasicToolOperation=basicToolOperation.BasicToolOperation,exports.ViewOperation=ViewOperation,exports.ScribbleTool=ScribbleTool,exports.PointCloud2dOperation=pointCloud2dOperation,exports.cAnnotation=annotation,exports.cAnnotationTask=annotationTask,exports.cKeyCode=keyCode__namespace,exports.cStyle=style,exports.CLIENT_TOOL_HEAD_TYPE=tool.CLIENT_TOOL_HEAD_TYPE,exports.CLIENT_TOOL_NAME=tool.CLIENT_TOOL_NAME,exports.DEFAULT_FONT=tool.DEFAULT_FONT,exports.DEFAULT_TEXT_MAX_WIDTH=tool.DEFAULT_TEXT_MAX_WIDTH,Object.defineProperty(exports,"EAnnotationMode",{enumerable:!0,get:function(){return tool.EAnnotationMode}}),Object.defineProperty(exports,"EAudioToolName",{enumerable:!0,get:function(){return tool.EAudioToolName}}),Object.defineProperty(exports,"EAuditStatus",{enumerable:!0,get:function(){return tool.EAuditStatus}}),Object.defineProperty(exports,"ECheckModel",{enumerable:!0,get:function(){return tool.ECheckModel}}),Object.defineProperty(exports,"EDependPattern",{enumerable:!0,get:function(){return tool.EDependPattern}}),Object.defineProperty(exports,"EDragTarget",{enumerable:!0,get:function(){return tool.EDragTarget}}),Object.defineProperty(exports,"EDrawPointPattern",{enumerable:!0,get:function(){return tool.EDrawPointPattern}}),Object.defineProperty(exports,"EFilterToolOperation",{enumerable:!0,get:function(){return tool.EFilterToolOperation}}),Object.defineProperty(exports,"ELineColor",{enumerable:!0,get:function(){return tool.ELineColor}}),Object.defineProperty(exports,"ELineTypes",{enumerable:!0,get:function(){return tool.ELineTypes}}),Object.defineProperty(exports,"EOperationMode",{enumerable:!0,get:function(){return tool.EOperationMode}}),Object.defineProperty(exports,"EPageOperator",{enumerable:!0,get:function(){return tool.EPageOperator}}),Object.defineProperty(exports,"EPointCloudName",{enumerable:!0,get:function(){return tool.EPointCloudName}}),Object.defineProperty(exports,"EPolygonPattern",{enumerable:!0,get:function(){return tool.EPolygonPattern}}),Object.defineProperty(exports,"ERectPattern",{enumerable:!0,get:function(){return tool.ERectPattern}}),Object.defineProperty(exports,"EScribblePattern",{enumerable:!0,get:function(){return tool.EScribblePattern}}),Object.defineProperty(exports,"ESelectedType",{enumerable:!0,get:function(){return tool.ESelectedType}}),Object.defineProperty(exports,"ETextType",{enumerable:!0,get:function(){return tool.ETextType}}),Object.defineProperty(exports,"EThumbnailOption",{enumerable:!0,get:function(){return tool.EThumbnailOption}}),Object.defineProperty(exports,"EToolName",{enumerable:!0,get:function(){return tool.EToolName}}),Object.defineProperty(exports,"EToolType",{enumerable:!0,get:function(){return tool.EToolType}}),Object.defineProperty(exports,"EVideoToolName",{enumerable:!0,get:function(){return tool.EVideoToolName}}),exports.OPERATION_LIST=tool.OPERATION_LIST,exports.SEGMENT_NUMBER=tool.SEGMENT_NUMBER,exports.TEXT_ATTRIBUTE_LINE_HEIGHT=tool.TEXT_ATTRIBUTE_LINE_HEIGHT,exports.TEXT_ATTRIBUTE_MAX_LENGTH=tool.TEXT_ATTRIBUTE_MAX_LENGTH,exports.TEXT_TYPE=tool.TEXT_TYPE,exports.TOOL_NAME=tool.TOOL_NAME,exports.TOOL_NAME_EN=tool.TOOL_NAME_EN,exports.cTool=tool,exports.edgeAdsorptionScope=tool.edgeAdsorptionScope,exports.editStepWidth=tool.editStepWidth,exports.TagUtils=TagUtils,exports.uuid=uuid,exports.MarkerUtils=MarkerUtils,exports.RectUtils=RectUtils,exports.AxisUtils=AxisUtils.default,exports.DrawUtils=DrawUtils,exports.ImgUtils=ImgUtils,exports.MathUtils=MathUtils.default,exports.AttributeUtils=AttributeUtils.default,exports.ActionsHistory=ActionsHistory,exports.EventBus=EventBus,exports.DblClickEventListener=DblClickEventListener,exports.AnnotationEngine=index,exports.UnitUtils=UnitUtils,exports.StyleUtils=StyleUtils,exports.CanvasScheduler=CanvasScheduler.CanvasScheduler,exports.PointCloud=index$1.PointCloud,exports.createThreeMatrix4=matrix.createThreeMatrix4,exports.getCuboidFromPointCloudBox=matrix.getCuboidFromPointCloudBox,exports.getHighlightIndexByPoints=matrix.getHighlightIndexByPoints,exports.isInImage=matrix.isInImage,exports.lidar2image=matrix.lidar2image,exports.mergeHighlightList=matrix.mergeHighlightList,exports.point2dTo3D=matrix.point2dTo3D,exports.point3DLidar2Image=matrix.point3DLidar2Image,exports.pointCloudLidar2image=matrix.pointCloudLidar2image,exports.rotatePoint=matrix.rotatePoint,exports.transferKitti2Matrix=matrix.transferKitti2Matrix,exports.PointCloudAnnotation=annotation$1.PointCloudAnnotation,exports.CommonToolUtils=CommonToolUtils,exports.toolUtils=toolUtils;
|
|
@@ -7,6 +7,8 @@ declare enum EKeyCode {
|
|
|
7
7
|
F = 70,
|
|
8
8
|
G = 71,
|
|
9
9
|
H = 72,
|
|
10
|
+
I = 73,
|
|
11
|
+
O = 79,
|
|
10
12
|
L = 76,
|
|
11
13
|
R = 82,
|
|
12
14
|
Z = 90,
|
|
@@ -15,6 +17,9 @@ declare enum EKeyCode {
|
|
|
15
17
|
Y = 89,
|
|
16
18
|
S = 83,
|
|
17
19
|
Q = 81,
|
|
20
|
+
One = 49,
|
|
21
|
+
Two = 50,
|
|
22
|
+
Three = 51,
|
|
18
23
|
Delete = 46,
|
|
19
24
|
F11 = 122,
|
|
20
25
|
Space = 32,
|
|
@@ -19,6 +19,7 @@ export declare const EDIT_STEP_WIDTH = 320;
|
|
|
19
19
|
/** bee主色 - 蓝紫:rgba(102, 111, 255, 1) */
|
|
20
20
|
export declare const THEME_COLOR = "rgba(102, 111, 255, 1)";
|
|
21
21
|
export declare const COLORS_ARRAY: string[];
|
|
22
|
+
export declare const WHITE_FONT_COLOR_ARRAY: string[];
|
|
22
23
|
/** svg icon */
|
|
23
24
|
export declare const ICON_ARRAY: any[];
|
|
24
25
|
/** svg base icon */
|
|
@@ -11,6 +11,10 @@ export declare enum EVideoToolName {
|
|
|
11
11
|
/** 视频截取工具 */
|
|
12
12
|
VideoClipTool = "videoClipTool"
|
|
13
13
|
}
|
|
14
|
+
export declare enum EAudioToolName {
|
|
15
|
+
/** 音频综合工具 */
|
|
16
|
+
AudioTextTool = "audioTextTool"
|
|
17
|
+
}
|
|
14
18
|
/** 新:工具type */
|
|
15
19
|
export declare enum EToolType {
|
|
16
20
|
Rect = 0,
|
|
@@ -68,7 +72,7 @@ export declare enum ERectPattern {
|
|
|
68
72
|
'RectBG' = 1,
|
|
69
73
|
'showOrder' = 2
|
|
70
74
|
}
|
|
71
|
-
export type ToolName = EToolName | EVideoToolName | EPointCloudName;
|
|
75
|
+
export type ToolName = typeof EToolName | typeof EVideoToolName | typeof EPointCloudName;
|
|
72
76
|
export type THybridToolName = EToolName | Array<EToolName>;
|
|
73
77
|
export declare const TOOL_NAME: {
|
|
74
78
|
[a: string]: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -26,13 +26,14 @@ import ImgUtils from './utils/ImgUtils';
|
|
|
26
26
|
import MathUtils from './utils/MathUtils';
|
|
27
27
|
import AttributeUtils from './utils/tool/AttributeUtils';
|
|
28
28
|
import ActionsHistory from './utils/ActionsHistory';
|
|
29
|
+
import EventBus from './utils/EventBus';
|
|
29
30
|
import DblClickEventListener from './utils/tool/DblClickEventListener';
|
|
30
31
|
import AnnotationEngine from './core';
|
|
31
32
|
import UnitUtils from './utils/tool/UnitUtils';
|
|
32
33
|
import StyleUtils from './utils/tool/StyleUtils';
|
|
33
34
|
declare const CommonToolUtils: typeof EnhanceCommonToolUtils;
|
|
34
35
|
declare const toolUtils: typeof EnhanceCommonToolUtils;
|
|
35
|
-
export { RectOperation, TagOperation, PointOperation, LineToolOperation, PolygonOperation, TextToolOperation, BasicToolOperation, PointCloud2DRectOperation, MeasureOperation, ViewOperation, PointCloud2dOperation, cAnnotation, cAnnotationTask, cKeyCode, cStyle, cTool, toolUtils, DblClickEventListener, CommonToolUtils, uuid, MarkerUtils, RectUtils, AxisUtils, TagUtils, DrawUtils, ImgUtils, MathUtils, AttributeUtils, AnnotationEngine, ScribbleTool, UnitUtils, StyleUtils, ActionsHistory, };
|
|
36
|
+
export { RectOperation, TagOperation, PointOperation, LineToolOperation, PolygonOperation, TextToolOperation, BasicToolOperation, PointCloud2DRectOperation, MeasureOperation, ViewOperation, PointCloud2dOperation, cAnnotation, cAnnotationTask, cKeyCode, cStyle, cTool, toolUtils, DblClickEventListener, CommonToolUtils, uuid, MarkerUtils, RectUtils, AxisUtils, TagUtils, DrawUtils, ImgUtils, MathUtils, AttributeUtils, AnnotationEngine, ScribbleTool, UnitUtils, StyleUtils, ActionsHistory, EventBus, };
|
|
36
37
|
export * from './newCore';
|
|
37
38
|
export * from './constant/tool';
|
|
38
39
|
export * from './core/pointCloud';
|
|
@@ -9,7 +9,7 @@ declare class EventBus {
|
|
|
9
9
|
* @param eventName 事件名字
|
|
10
10
|
* @param callback 事件回调
|
|
11
11
|
*/
|
|
12
|
-
on(eventName: string, callback: () => void): void;
|
|
12
|
+
on(eventName: string, callback: (...args: any[]) => void): void;
|
|
13
13
|
/**
|
|
14
14
|
* 单独的事件绑定,一个事件仅支持绑定一个函数
|
|
15
15
|
*
|
|
@@ -17,19 +17,19 @@ declare class EventBus {
|
|
|
17
17
|
* @param {() => void} callback
|
|
18
18
|
* @memberof EventBus
|
|
19
19
|
*/
|
|
20
|
-
singleOn(eventName: string, callback: () => void): void;
|
|
20
|
+
singleOn(eventName: string, callback: (...args: any[]) => void): void;
|
|
21
21
|
/**
|
|
22
22
|
* 事件广播
|
|
23
23
|
* @param eventName 事件名字
|
|
24
24
|
* @param callback 事件回调
|
|
25
25
|
*/
|
|
26
|
-
emit(eventName: string): void;
|
|
26
|
+
emit(eventName: string, ...args: any[]): void;
|
|
27
27
|
/**
|
|
28
28
|
* 事件解绑,对某一事件进行事件解绑
|
|
29
29
|
* @param eventName 需要解绑的事件名字
|
|
30
30
|
* @param callback 需要解绑的方法
|
|
31
31
|
*/
|
|
32
|
-
unbind(eventName: string, callback: () => void): void;
|
|
32
|
+
unbind(eventName: string, callback: (...args: any[]) => void): void;
|
|
33
33
|
/**
|
|
34
34
|
* 解绑事件
|
|
35
35
|
* @param eventName
|
|
@@ -22,6 +22,21 @@ export default class CommonToolUtils {
|
|
|
22
22
|
* @returns {*}
|
|
23
23
|
*/
|
|
24
24
|
static getCurrentStepInfo(currentStep: number, stepList: IStepInfo[]): any;
|
|
25
|
+
/**
|
|
26
|
+
* 获取当前步骤的步骤的步骤配置
|
|
27
|
+
*/
|
|
28
|
+
static getCurrentStepToolAndConfig(currentStep: number, stepList: IStepInfo[]): false | {
|
|
29
|
+
tool: any;
|
|
30
|
+
config: any;
|
|
31
|
+
name: string;
|
|
32
|
+
step: number;
|
|
33
|
+
type: number;
|
|
34
|
+
dataSourceStep: number;
|
|
35
|
+
tips: string;
|
|
36
|
+
simpleDocument: string;
|
|
37
|
+
progress: number;
|
|
38
|
+
fileCount: number;
|
|
39
|
+
};
|
|
25
40
|
static jsonParser: (content: any, defaultValue?: any) => any;
|
|
26
41
|
/**
|
|
27
42
|
* 获取结果中最大的order
|
|
@@ -38,6 +53,11 @@ export default class CommonToolUtils {
|
|
|
38
53
|
* @returns {boolean}
|
|
39
54
|
*/
|
|
40
55
|
static hotkeyFilter(event: any): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* 判断是否移动按钮
|
|
58
|
+
* @param keyCode
|
|
59
|
+
*/
|
|
60
|
+
static isMoveKey(keyCode: number): boolean;
|
|
41
61
|
static getNextSelectedRectID(rectList: point[], sort?: ESortDirection, selectedID?: string): point;
|
|
42
62
|
static getNextSelectedRectIDByEvent(pointList: point[], event: KeyboardEvent, selectedID?: string): point;
|
|
43
63
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class EventBus{constructor(){this._events=new Map}on(t,s){const e=this._events.get(t)||[];e.some(n=>n===s)||this._events.set(t,e.concat(s))}singleOn(t,s){this._events.set(t,[s])}emit(t,...s){const e=this._events.get(t);e&&e.forEach(n=>{n&&n(...s)})}unbind(t,s){const e=this._events.get(t);e&&this._events.set(t,e.filter(n=>n!==s))}unbindAll(t){this._events.delete(t)}}var EventBus$1=new EventBus;module.exports=EventBus$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _=require("lodash"),annotation=require("../../constant/annotation.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,t,e)=>t in o?__defProp(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,__spreadValues=(o,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(o,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(o,e,t[e]);return o},__spreadProps=(o,t)=>__defProps(o,__getOwnPropDescs(t));class CommonToolUtils{static getStepInfo(t,e){return e==null?void 0:e.filter(r=>r.step===t)[0]}static getCurrentStepInfo(t,e){const r=this.getStepInfo(t,e);return r&&(r.type===annotation.EStepType.QUALITY_INSPECTION||r.type===annotation.EStepType.MANUAL_CORRECTION)?this.getCurrentStepInfo(r.dataSourceStep,e):r}static getMaxOrder(t){let e=0;return t.forEach(r=>{r.order&&r.order>e&&(e=r.order)}),e}static hotkeyFilter(t){const e=t.target||t.srcElement;if(!e)return!0;const{tagName:r,type:
|
|
1
|
+
"use strict";var _=require("lodash"),annotation=require("../../constant/annotation.js"),keyCode=require("../../constant/keyCode.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,t,e)=>t in o?__defProp(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,__spreadValues=(o,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(o,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(o,e,t[e]);return o},__spreadProps=(o,t)=>__defProps(o,__getOwnPropDescs(t));class CommonToolUtils{static getStepInfo(t,e){return e==null?void 0:e.filter(r=>r.step===t)[0]}static getCurrentStepInfo(t,e){const r=this.getStepInfo(t,e);return r&&(r.type===annotation.EStepType.QUALITY_INSPECTION||r.type===annotation.EStepType.MANUAL_CORRECTION)?this.getCurrentStepInfo(r.dataSourceStep,e):r}static getCurrentStepToolAndConfig(t,e){const r=this.getStepInfo(t,e);if(r){const n=this.getCurrentStepInfo(t,e);return __spreadProps(__spreadValues({},r),{tool:n.tool,config:n.config})}return!1}static getMaxOrder(t){let e=0;return t.forEach(r=>{r.order&&r.order>e&&(e=r.order)}),e}static hotkeyFilter(t){const e=t.target||t.srcElement;if(!e)return!0;const{tagName:r,type:n}=e;if(!r||!n)return!0;let i=!0;return(e.isContentEditable||r==="TEXTAREA"||(r==="INPUT"&&n!=="radio"||r==="TEXTAREA")&&!e.readOnly)&&(i=!1),i}static isMoveKey(t){return[keyCode.Left,keyCode.Right,keyCode.Down,keyCode.Up,keyCode.Space].includes(t)}static getNextSelectedRectID(t,e=annotation.ESortDirection.ascend,r){let n=1;e===annotation.ESortDirection.descend&&(n=-1);const i=t.sort((l,c)=>l.x-c.x==0?l.y-c.y:n*(l.x-c.x)),a=i.findIndex(l=>l.id===r),s=i.length;return i[(a+1)%s]}static getNextSelectedRectIDByEvent(t,e,r){const n=e.shiftKey?annotation.ESortDirection.descend:annotation.ESortDirection.ascend;return this.getNextSelectedRectID(t,n,r)}static getRenderResultList(t,e,r=[],n){const i=[];return[t.filter(s=>n&&n.includes(s.id)?(i.push(s),!1):!(r.length>0&&!r.includes(s==null?void 0:s.attribute)||this.isDifferSourceID(s==null?void 0:s.sourceID,e))),i]}static getSourceID(t){var e;const r="";return t&&(e=t==null?void 0:t.id)!=null?e:r}static findAllLine(t,e=!0){const r=[],n=[...t];n.length>=3&&e===!0&&n.push(__spreadValues({},n[0]));for(let i=0;i<n.length;i++)n[i+1]&&r.push({point1:n[i],point2:n[i+1],pointIndex:i});return r}static translateSourceID(t){return(t===void 0||t===0||t==="0")&&(t=""),t}static isDifferSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`!=`${e}`}static isSameSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`==`${e}`}static getNextMarker(t,e=[],r){if((e==null?void 0:e.length)===0)return;let n=e.map((i,a)=>__spreadProps(__spreadValues({},i),{index:a}));if(typeof r=="number"&&r>0){const i=e[r];if(i&&t.every(a=>a.label!==i.value))return{label:i.value,index:r};n=[...n.slice(r,e.length),...n.slice(0,r)]}for(let i=0;i<n.length;i++)if(!t.some(a=>a.label===n[i].value))return{label:n[i].value,index:n[i].index}}static getCurrentMarkerIndex(t,e=[]){return e.findIndex(r=>t===r.value)}}CommonToolUtils.jsonParser=(o,t={})=>{try{return typeof o=="string"?JSON.parse(o):_.isObject(o)?o:t}catch(e){return t}},module.exports=CommonToolUtils;
|
package/es/constant/keyCode.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var a;(function(t){t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.L=76]="L",t[t.R=82]="R",t[t.Z=90]="Z",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.S=83]="S",t[t.Q=81]="Q",t[t.Delete=46]="Delete",t[t.F11=122]="F11",t[t.Space=32]="Space",t[t.Esc=27]="Esc",t[t.Left=37]="Left",t[t.Up=38]="Up",t[t.Right=39]="Right",t[t.Down=40]="Down",t[t.Enter=13]="Enter",t[t.Ctrl=17]="Ctrl",t[t.Alt=18]="Alt",t[t.Shift=16]="Shift",t[t.Tab=9]="Tab",t[t.BackSpace=8]="BackSpace"})(a||(a={}));var c=a;export{c as default};
|
|
1
|
+
var a;(function(t){t[t.A=65]="A",t[t.B=66]="B",t[t.C=67]="C",t[t.D=68]="D",t[t.E=69]="E",t[t.F=70]="F",t[t.G=71]="G",t[t.H=72]="H",t[t.I=73]="I",t[t.O=79]="O",t[t.L=76]="L",t[t.R=82]="R",t[t.Z=90]="Z",t[t.W=87]="W",t[t.X=88]="X",t[t.Y=89]="Y",t[t.S=83]="S",t[t.Q=81]="Q",t[t.One=49]="One",t[t.Two=50]="Two",t[t.Three=51]="Three",t[t.Delete=46]="Delete",t[t.F11=122]="F11",t[t.Space=32]="Space",t[t.Esc=27]="Esc",t[t.Left=37]="Left",t[t.Up=38]="Up",t[t.Right=39]="Right",t[t.Down=40]="Down",t[t.Enter=13]="Enter",t[t.Ctrl=17]="Ctrl",t[t.Alt=18]="Alt",t[t.Shift=16]="Shift",t[t.Tab=9]="Tab",t[t.BackSpace=8]="BackSpace"})(a||(a={}));var c=a;export{c as default};
|
package/es/constant/style.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import a from"../assets/attributeIcon/icon_canvasEdit0.svg.js";import i from"../assets/attributeIcon/icon_canvasEdit1.svg.js";import l from"../assets/attributeIcon/icon_canvasEdit2.svg.js";import t from"../assets/attributeIcon/icon_canvasEdit3.svg.js";import e from"../assets/attributeIcon/icon_canvasEdit4.svg.js";import b from"../assets/attributeIcon/icon_canvasEdit5.svg.js";import g from"../assets/attributeIcon/icon_canvasEdit6.svg.js";import o from"../assets/attributeIcon/icon_canvasEdit7.svg.js";import s from"../assets/attributeIcon/icon_canvasEdit8.svg.js";import v from"../assets/attributeIcon/icon_editLAN.svg.js";import d from"../assets/attributeIcon/icon_editQING.svg.js";import n from"../assets/attributeIcon/icon_editLV.svg.js";import c from"../assets/attributeIcon/icon_editHUANG.svg.js";import f from"../assets/attributeIcon/icon_editFEN.svg.js";import{EFilterToolOperation as r}from"./tool.js";export{default as INVALID_ICON}from"../assets/attributeIcon/icon_canvasEdit_miss.svg.js";const k=a,H=61,E=80,I=62,_=20,S=55,m=55,O=40,L=80,
|
|
1
|
+
import a from"../assets/attributeIcon/icon_canvasEdit0.svg.js";import i from"../assets/attributeIcon/icon_canvasEdit1.svg.js";import l from"../assets/attributeIcon/icon_canvasEdit2.svg.js";import t from"../assets/attributeIcon/icon_canvasEdit3.svg.js";import e from"../assets/attributeIcon/icon_canvasEdit4.svg.js";import b from"../assets/attributeIcon/icon_canvasEdit5.svg.js";import g from"../assets/attributeIcon/icon_canvasEdit6.svg.js";import o from"../assets/attributeIcon/icon_canvasEdit7.svg.js";import s from"../assets/attributeIcon/icon_canvasEdit8.svg.js";import v from"../assets/attributeIcon/icon_editLAN.svg.js";import d from"../assets/attributeIcon/icon_editQING.svg.js";import n from"../assets/attributeIcon/icon_editLV.svg.js";import c from"../assets/attributeIcon/icon_editHUANG.svg.js";import f from"../assets/attributeIcon/icon_editFEN.svg.js";import{EFilterToolOperation as r}from"./tool.js";export{default as INVALID_ICON}from"../assets/attributeIcon/icon_canvasEdit_miss.svg.js";const k=a,H=61,E=80,I=62,_=20,S=55,m=55,O=40,L=80,T=240,A=320,R="rgba(102, 111, 255, 1)",p=["rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"],u=["rgba(128, 12, 249, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)"],N=[a,g,t,o,l,s,b,i,e],j={1:v,3:d,5:n,7:c,9:f},C="rgba(255, 51, 51, 1)",G={r:255,g:51,b:51,a:1},D="rgba(204, 204, 204, 1)",F={[r.lc]:"rgba(153, 51, 255, 1)",[r.rc]:"rgba(51, 153, 255, 1)",[r.clc]:"rgba(46, 230, 46, 1)",[r.crc]:"rgba(255, 51, 51, 1)"},B='{"color":1,"width":2,"borderOpacity":9,"fillOpacity":9,"toolColor":{"1":{"valid":{"stroke":"rgba(0,0,255,0.50)","fill":"rgba(0,0,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(0,15,255,1.00)","fill":"rgba(0,15,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(0,15,255,0.80)","fill":"rgba(0,15,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"3":{"valid":{"stroke":"rgba(0,255,255,0.50)","fill":"rgba(0,255,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(0,212,255,1.00)","fill":"rgba(0,212,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(0,212,255,0.80)","fill":"rgba(0,212,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"5":{"valid":{"stroke":"rgba(0,255,0,0.50)","fill":"rgba(0,255,0,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(149,255,1.00)","fill":"rgba(149,255,0,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(149,255,0,0.80)","fill":"rgba(149,255,0,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"7":{"valid":{"stroke":"rgba(255,255,0,0.50)","fill":"rgba(255,255,0,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(255,230,102,1.00)","fill":"rgba(255,213,0,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(255,230,102,0.80)","fill":"rgba(255,230,102,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}},"9":{"valid":{"stroke":"rgba(255,0,255,0.50)","fill":"rgba(255,0,255,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validSelected":{"stroke":"rgba(230,102,255,1.00)","fill":"rgba(213,0,255,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,0.80)","fill":"rgba(255,153,102,0.19)"},"validHover":{"stroke":"rgba(230,102,255,0.80)","fill":"rgba(230,102,255,0.51)"},"invalidHover":{"stroke":"rgba(255,153,102,0.50)","fill":"rgba(255,153,102,0.32)"}}},"attributeColor":[{"valid":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(204,204,204,1.00)","fill":"rgba(204,204,204,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(128,12,249,1.00)","fill":"rgba(128,12,249,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(0,255,48,1.00)","fill":"rgba(0,255,48,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,136,247,1.00)","fill":"rgba(255,136,247,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,226,50,1.00)","fill":"rgba(255,226,50,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(153,66,23,1.00)","fill":"rgba(153,66,23,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(2,130,250,1.00)","fill":"rgba(2,130,250,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(255,35,35,1.00)","fill":"rgba(255,35,35,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}},{"valid":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.32)"},"invalid":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.32)"},"validSelected":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.64)"},"invalidSelected":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"},"validHover":{"stroke":"rgba(0,255,234,1.00)","fill":"rgba(0,255,234,0.64)"},"invalidHover":{"stroke":"rgba(255,153,102,1.00)","fill":"rgba(255,153,102,0.64)"}}],"lineColor":{"1":"rgba(102, 111, 255, 1 )","3":"rgba(102, 230, 255, 1)","5":"rgba(191, 255, 102, 1)","7":"rgba(255, 230, 102, 1)","9":"rgba(230, 102, 255, 1)"},"attributeLineColor":["rgba(204, 204, 204, 1)","rgba(128, 12, 249, 1)","rgba(0, 255, 48, 1)","rgba(255, 136, 247, 1)","rgba(255, 226, 50, 1)","rgba(153, 66, 23, 1)","rgba(2, 130, 250, 1)","rgba(255, 35, 35, 1)","rgba(0, 255, 234, 1)"]}';export{j as BASE_ICON,p as COLORS_ARRAY,A as EDIT_STEP_WIDTH,F as FILTER_TOOL_COLOR,L as FOOTER_HEIGHT,H as HEADER_HEIGHT,N as ICON_ARRAY,C as INVALID_COLOR,G as INVALID_COLOR_RGBA,D as NULL_COLOR,k as NULL_ICON,_ as PADDING,m as PAGINATION_HEIGHT,I as SEARCH_HEIGHT,T as SIDERBAR_WIDTH,S as TABLE_ROW_HEIGHT,E as TAB_HEIGHT,R as THEME_COLOR,O as TIPS_HEIGHT,u as WHITE_FONT_COLOR_ARRAY,B as styleString};
|
package/es/constant/tool.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const M=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.AudioTextTool="audioTextTool"})(l||(l={}));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",o.Cuboid="cuboidTool",o.PointCloudPolygon="pointCloudPolygon",o.LLM="LLMTool"})(u||(u={}));var c;(function(o){o.Check="check"})(c||(c={}));var t;(function(o){o[o.nothing=0]="nothing",o[o.RectBG=1]="RectBG",o[o.showOrder=2]="showOrder"})(t||(t={}));const _={[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.LLM]:"LLM\u6807\u6CE8"},b={[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",[u.LLM]:"LLM"};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 C;(function(o){o.lc="leftClick",o.rc="rightClick",o.clc="ctrlLeftClick",o.crc="ctrlRightClick"})(C||(C={}));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 d;(function(o){o[o.Normal=1]="Normal",o[o.Modify=2]="Modify"})(d||(d={}));var T;(function(o){o[o.Line=0]="Line",o[o.Curve=1]="Curve"})(T||(T={}));var F;(function(o){o[o.SingleColor=0]="SingleColor",o[o.MultiColor=1]="MultiColor"})(F||(F={}));var g;(function(o){o[o.Form=1]="Form",o[o.Json=2]="Json"})(g||(g={}));var L;(function(o){o[o.Point=0]="Point",o[o.Line=1]="Line",o[o.Plane=2]="Plane"})(L||(L={}));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,I=16,m=300,V="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 y={[n.PointCloud]:"sensebeepc",[u.ClientAttribute]:"sensebeepc-EnumAttributeTool",[u.Face]:"sensebeepc-FacePointsLabellingTool",[u.OCRRelation]:"sensebeepc-OCRRelationTool"},G={[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"},x=16,P=10;var f;(function(o){o[o.Normal=0]="Normal",o[o.Rect=1]="Rect"})(f||(f={}));var A;(function(o){o[o.Scribble=1]="Scribble",o[o.Erase=2]="Erase"})(A||(A={}));var v;(function(o){o[o.General=1]="General",o[o.MultiMove=2]="MultiMove"})(v||(v={}));export{y as CLIENT_TOOL_HEAD_TYPE,G as CLIENT_TOOL_NAME,V as DEFAULT_FONT,m as DEFAULT_TEXT_MAX_WIDTH,d as EAnnotationMode,l as EAudioToolName,s as EAuditStatus,c as ECheckModel,r as EDependPattern,L as EDragTarget,R as EDrawPointPattern,C as EFilterToolOperation,F as ELineColor,T as ELineTypes,v as EOperationMode,B as EPageOperator,n as EPointCloudName,f as EPolygonPattern,t as ERectPattern,A as EScribblePattern,g as ESelectedType,a as ETextType,k as EThumbnailOption,u as EToolName,e as EToolType,i as EVideoToolName,O as OPERATION_LIST,x as SEGMENT_NUMBER,I as TEXT_ATTRIBUTE_LINE_HEIGHT,h as TEXT_ATTRIBUTE_MAX_LENGTH,S as TEXT_TYPE,_ as TOOL_NAME,b as TOOL_NAME_EN,P as edgeAdsorptionScope,M as editStepWidth};
|
package/es/core/scheduler.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getConfig as L,styleDefaultConfig as y}from"../constant/defaultConfig.js";import{getCurrentOperation as
|
|
1
|
+
import{getConfig as L,styleDefaultConfig as y}from"../constant/defaultConfig.js";import{getCurrentOperation as D}from"../utils/tool/EnhanceCommonToolUtils.js";import{BasicToolOperation as w}from"./toolOperation/basicToolOperation.js";var x=Object.defineProperty,I=Object.defineProperties,M=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable,f=(i,t,o)=>t in i?x(i,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[t]=o,E=(i,t)=>{for(var o in t||(t={}))_.call(t,o)&&f(i,o,t[o]);if(g)for(var o of g(t))b.call(t,o)&&f(i,o,t[o]);return i},N=(i,t)=>I(i,M(t));const T=i=>{const t=document.createElement("canvas");t.width=i.width,t.height=i.height;const o=t.getContext("2d");return o?(o.fillStyle="transparent",o.fillRect(0,0,i.width,i.height),t.toDataURL()):""},d=(i,t,o)=>{const e=i[t];return i[t]=i[o],i[o]=e,i},v=class{static isSingleTool(i){return!this.isHybridTool(i)}static isHybridTool(i){return Array.isArray(i)}};let m=v;m.getTopToolName=i=>v.isHybridTool(i)?i[i.length-1]:i;class S{constructor(t){this.toolOperationList=[],this.toolOperationDom=[],this.toolOperationNameList=[];var o,e;this.container=t.container,this.size=t.size,this.imgNode=t.imgNode,this.config=(o=t.config)!=null?o:JSON.stringify(L(m.getTopToolName(t.toolName))),this.style=(e=t.style)!=null?e:y,this.proxyMode=t.proxyMode,this.onWheel=this.onWheel.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.init()}setImgNode(t,o){this.toolOperationList.forEach(e=>{e.setImgNode(t,o)})}setImgAttribute(t){this.toolOperationList.forEach(o=>{o.setImgAttribute(t)})}syncAllAttributeListInConfig(t){this.toolOperationList.forEach(o=>{const e=N(E({},o.config),{attributeList:t});o.setConfig(JSON.stringify(e))})}setSize(t){t.width&&t.height&&this.toolOperationDom.forEach(o=>{o.style.width=`${t.width}px`,o.style.height=`${t.height}px`}),this.toolOperationList.forEach(o=>{o.setSize(t)})}syncPosition(t,o,e,s){this.toolOperationList.forEach(a=>{s!==a&&(a.setCurrentPos(t),a.setZoom(o),a.setImgInfo(e),a.renderBasicCanvas(),a.render())})}get defaultSize(){var t,o;return{width:((t=this.imgNode)==null?void 0:t.width)||this.size.width,height:((o=this.imgNode)==null?void 0:o.height)||this.size.height}}createDom(){const{width:t,height:o}=this.defaultSize,e=window.document.createElement("div");e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.width=`${t}px`,e.style.height=`${o}px`;const s=this.toolOperationList.length+1;return e.style.zIndex=`${s}`,e}getEmptyImage(t,o){const e=T({width:t,height:o}),s=new Image;return s.src=e,s}createOperation(t,o,e){var s;const{width:a,height:h}=this.defaultSize,r=this.createDom(),c=this.getEmptyImage(a,h),l={container:r,size:this.size,config:(s=this==null?void 0:this.config)!=null?s:"{}",drawOutSideTarget:!1,style:this.style,imgNode:o||c,hiddenImg:!!t};e&&Object.assign(l,e);let n;if(!t)n=new w(l),r.style.zIndex="0",n.init();else{const p=D(t);if(!p)return;n=new p(l)}return n==null||n.init(),n.canvas.id=t!=null?t:"basicCanvas",n.historyDisabled=!0,n.on("dragMove",({currentPos:p,zoom:u,imgInfo:O})=>{this.syncPosition(p,u,O,n)}),n.on("renderZoom",(p,u,O)=>{p&&u&&this.syncPosition(u,p,O,n)}),t?(this.container.appendChild(r),this.toolOperationList.push(n),this.toolOperationNameList.push(t),this.toolOperationDom.push(r),n):(this.container.insertBefore(r,this.container.childNodes[0]),this.toolOperationList.unshift(n),this.toolOperationDom.unshift(r),n)}switchLastTwoCanvas(){if(this.toolOperationDom.length<3){console.error("switchLastTwoCanvas is just used the layer which has 3 canvas");return}const t=this.toolOperationDom.length,o=t-1,e=t-2,s=this.toolOperationDom[o],a=this.toolOperationDom[e];if(!(!a||!s))return s.style.zIndex=`${o-1}`,a.style.zIndex=`${o}`,this.toolOperationList[o].clearActiveStatus(),this.toolOperationList[o].clearCursorLine(),this.toolOperationList[o].render(),this.toolOperationList=d(this.toolOperationList,o,e),this.toolOperationDom=d(this.toolOperationDom,o,e),this.toolOperationList[o]}getFirstToolOperation(){return this.toolOperationList.length>1?this.toolOperationList[1]:this.toolOperationList[0]}switchToCanvas(t){var o,e,s,a;const h=this.toolOperationNameList.indexOf(t);if(h<0||this.toolOperationList.length<1||h>this.toolOperationDom.length-1)return;const r=this.toolOperationDom.length-1,c=this.toolOperationDom[h],l=this.toolOperationDom[r];if(!c||!l)return;const n=l.style.zIndex;return l.style.zIndex=`${c.style.zIndex}`,c.style.zIndex=`${n}`,(e=(o=this.toolOperationList[r]).clearActiveStatus)==null||e.call(o),(a=(s=this.toolOperationList[r]).clearCursorLine)==null||a.call(s),this.toolOperationList[r].render(),this.toolOperationList=d(this.toolOperationList,r,h),this.toolOperationDom=d(this.toolOperationDom,r,h),this.toolOperationNameList=d(this.toolOperationNameList,r,h),this.toolOperationList[r]}updateDataByToolName(t,o){const e=this.toolOperationNameList.indexOf(t);e>=0&&this.toolOperationList[e].setResult(o)}clearStatusAndResult(){this.toolOperationList.forEach(t=>{var o;(o=t.clearActiveStatus)==null||o.call(t),t.clearResult()})}destroyAllLayer(){this.toolOperationList.forEach(t=>{t.destroyCanvas(),this.init()})}init(){this.toolOperationList=[],this.toolOperationDom=[],this.eventBinding()}destroy(){this.destroyAllLayer(),this.eventUnBinding()}eventBinding(){this.proxyMode&&(this.container.addEventListener("wheel",this.onWheel),this.container.addEventListener("mousedown",this.onMouseDown),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseup",this.onMouseUp))}eventUnBinding(){this.proxyMode&&(this.container.removeEventListener("wheel",this.onWheel),this.container.removeEventListener("mousedown",this.onMouseDown),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseup",this.onMouseUp))}onWheel(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onWheel(t)}}onMouseDown(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseDown(t)}}onMouseMove(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseMove(t)}}onMouseUp(t){if(t.preventDefault(),t.stopPropagation(),this.toolOperationList.length!==0){const o=this.toolOperationDom.length-1;this.toolOperationList[o].onMouseUp(t)}}getCurrentToolName(){return this.toolOperationNameList[this.toolOperationNameList.length-1]}}export{m as HybridToolUtils,S as ToolScheduler};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import g from"lodash";import{ELineTypes as P,ELineColor as U,EToolName as _,ETextType as M}from"../../constant/tool.js";import B from"../../utils/ActionsHistory.js";import S from"../../utils/uuid.js";import v from"../../constant/keyCode.js";import L from"../../utils/MathUtils.js";import{BasicToolOperation as j}from"./basicToolOperation.js";import u from"../../utils/tool/LineToolUtils.js";import{createSmoothCurvePointsFromPointList as R,isInPolygon as V,createSmoothCurvePoints as W}from"../../utils/tool/polygonTool.js";import K from"../../utils/tool/CommonToolUtils.js";import N from"../../utils/tool/CanvasUtils.js";import F from"../../utils/tool/DrawUtils.js";import z from"../../utils/tool/StyleUtils.js";import y from"../../utils/tool/AttributeUtils.js";import $ from"./textAttributeClass.js";import J from"./Selection.js";import Y from"../../locales/index.js";import{EMessage as X}from"../../locales/constants.js";var q=Object.defineProperty,G=Object.defineProperties,Z=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable,E=(d,e,t)=>e in d?q(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t,T=(d,e)=>{for(var t in e||(e={}))Q.call(e,t)&&E(d,t,e[t]);if(O)for(var t of O(e))tt.call(e,t)&&E(d,t,e[t]);return d},w=(d,e)=>G(d,Z(e)),k;(function(d){d[d.Create=0]="Create",d[d.Active=1]="Active",d[d.None=2]="None"})(k||(k={}));const p=16,C={x:0,y:20},x=3,m=5,H=2;class et extends j{constructor(e){super(e);this.drawActivatedLine=(t,i,s)=>{const n=this.isCreate?g.cloneDeep([{pointList:this.activeLine,order:this.nextOrder(),attribute:this.defaultAttribute,valid:this.isLineValid}]):g.cloneDeep(this.selectedLines),o=this.isActiveLineValid();n.forEach(r=>{if((r==null?void 0:r.pointList)&&(r.pointList=r.pointList.map(l=>Object.assign(l,{actual:{x:l.x,y:l.y}},this.coordUtils.getRenderCoord(l)))),!r.pointList)return;const h=this.getLineColorByAttribute({attribute:r.attribute,valid:r.valid});return this.selectedLines.length>0&&(this.drawLineLength(r.pointList,h),this.renderActiveArea(L.calcViewportBoundaries(r.pointList,this.isCurve,p))),this.drawLine(r.pointList,t,h,!0,!0),this.drawLineNumber(r.pointList[0],r.order,h,"",this.defaultAttribute,o),t&&this.isCreate&&this.arc(t,x,h),this.cursor&&!this.selectedPoint&&!s&&!this.isShift&&this.arc(this.cursor,m,h),r})},this.drawHoverPoint=t=>{if(!this.isMousedown&&t&&this.selectedID){const i=this.getPointList(this.activeLine),s=this.activeLine.find(o=>u.calcDistance(this.coordUtils.getRenderCoord(o),t)<=m);let n;!s&&this.activeLine&&(n=this.findNearestPoint(i,t)),this.hoverPointID=s?s.id:void 0,this.cursor=s||n==null?void 0:n.point}},this.updatedLine={id:"",valid:!1,order:0},this.toolName="lineTool",this.lineList=[],this.activeLine=[],this.coordsInsideActiveArea=!1,this.hoverLineSegmentIndex=-1,this.isShift=!1,this.isReference=!1,this.drawCurveLine=(t,i,s,n=!0,o=!1,r)=>{const h=R(i,p);t.save(),t.lineCap="round",t.lineJoin="round",t.strokeStyle=s.color,n&&(t.lineWidth=s.lineWidth),o&&u.setReferenceCtx(t),i.forEach(({specialEdge:l},a)=>{const c=h.splice(0,p+1);t.save(),t.beginPath(),r===a&&(t.lineWidth=4),c.forEach(({x:f,y:b},I)=>{const D=I>0?"lineTo":"moveTo";l&&u.setSpecialEdgeStyle(t),t[D](f,b)}),t.stroke(),t.restore()}),t.restore()},this.drawLine=(t,i,s,n=!1,o=!1)=>{const r=i?t.concat(i):t,h={color:s,lineWidth:o?1:this.lineStyle.lineWidth};this.isCurve?u.drawCurveLine(this.ctx,r,h,!n,this.isReference,o?this.hoverLineSegmentIndex:-1):this.drawStraightLine(r,h,o),n&&t.forEach(l=>{var a,c;const f=l.id,b=f&&[this.hoverPointID,(a=this.selectedPoint)==null?void 0:a.id].includes(f)?m:x;this.arc(l,b,s),[this.hoverPointID,(c=this.selectedPoint)==null?void 0:c.id].includes(f)||this.arc(l,H,"white")})},this.drawStraightLine=(t,i,s=!1)=>{const{ctx:n}=this;n&&(n.save(),n.lineCap="round",n.lineJoin="round",n.strokeStyle=i.color,n.lineWidth=i.lineWidth,this.isReference&&u.setReferenceCtx(n),t.forEach((o,r)=>{if(n.beginPath(),r>0){const h=t[r-1];n.save(),(h==null?void 0:h.specialEdge)&&u.setSpecialEdgeStyle(n),s&&this.hoverLineSegmentIndex+1===r&&(n.lineWidth=4),n.moveTo(h.x,h.y),n.lineTo(o.x,o.y),n.stroke(),n.restore()}}),n.restore())},this.drawLines=()=>{try{const t=g.cloneDeep(this.attributeFilteredLines);if(this.isHidden)return;t.forEach(i=>{if(!this.selection.isIdSelected(i.id)&&i.pointList){i.pointList.map(h=>Object.assign(h,{actual:{x:h.x,y:h.y}},this.coordUtils.getRenderCoord(h)));const{order:s,label:n}=i,o=s,r=i&&this.getLineColorByAttribute(i);this.drawLine(i.pointList,void 0,r,!1),this.drawLineNumber(i.pointList[0],o,r,n,i.attribute,i.valid),i.id!==this.textEditingID&&(this.drawLineTextAttribute(i.pointList[1],r,i==null?void 0:i.textAttribute),this.drawLineLength(i.pointList,r))}})}catch(t){console.error(t,"\u7EBF\u6761\u5DE5\u5177\u6570\u636E\u89E3\u6790\u9519\u8BEF"),this.lineList=[],this.clearCanvas()}},this.render=t=>{super.render(),this.drawLines(),this.drawActivatedLine(t,void 0,!1),this.renderTextAttribute(),this.renderCursorLine(this.getLineColor(this.defaultAttribute))},this.moveLineInPolygon=(t,i)=>{var s;if(!Array.isArray(this.activeLine))return!1;((s=this.activeLine)==null?void 0:s.every(o=>this.isInBasicPolygon({x:o.x+t,y:o.y+i})))&&(this.lineDragging=!0,this.moveActiveArea(t,i))},this.getSelectedLinesArea=()=>L.calcViewportBoundaries(this.selectedLines.reduce((t,i)=>(i==null?void 0:i.pointList)?t.concat(...i==null?void 0:i.pointList):t,[])),this.moveLineInRectRange=(t,i,s,n)=>{if(this.selectedLines.length===0)return;const{top:o,left:r,right:h,bottom:l}=this.getSelectedLinesArea(),a=[r,h].map(A=>g.isNumber(A)?A+t:0),c=[o,l].map(A=>g.isNumber(A)?A+i:0),f=r>=0&&h&&L.isInRange(a,s),b=o>=0&&l&&L.isInRange(c,n),I=f?t:0,D=b?i:0;this.lineDragging=!0,this.moveActiveArea(I,D)},this.onRightClick=t=>{if(this.cursor=void 0,this.isCreate){if(this.isLinePointsNotEnough())return;if(u.lineLengthSum(this.activeLine||[])<this.minLength)return this.emit("messageInfo",`${Y.getMessagesByLocale(X.MinLengthLimitErrorNotice,this.lang)}${this.minLength}`),!0;this.stopLineCreating(!0);return}const i=this.findHoverLine(this.getCoordinate(t));this.setSelectedLineID(i==null?void 0:i.id,t.ctrlKey),this.emit("contextmenu")},this.updateSelectedAttributeAfterHistoryChanged=()=>{if(this.selectedIDs.length>0){const t=this.lineList.find(s=>s.id===this.selectedIDs[0]),i=t==null?void 0:t.attribute;typeof i=="string"&&(this.defaultAttribute=i,this.updateAttribute(i),this.render())}},this.onLeftClick=t=>{const i=this.getCoordinate(t),{lineDragging:s}=this;if(this.lineDragging=!1,this.isSpaceKey)return;if(this.isNone&&t.ctrlKey){const o=this.findHoverLine(i);o&&this.setInvalidLine(o.id);return}if(this.isLinePointsExceed())return;const n=this.getNextPoint(t,i);if(this.isCreate||this.isNone){this.setCreateStatusAndAddPoint(n);return}if(this.isActive){if(s)return;if(this.isMouseCoordOutsideActiveArea()){this.setNoneStatus(!1),this.setCreateStatusAndAddPoint(n);return}if(t.shiftKey){this.updateLineSegmentSpecial(i);return}this.coordsInsideActiveArea&&t.ctrlKey&&this.setInvalidLine(this.selectedID),this.addLinePointToActiveLine()}},this.onDblclick=()=>{},this.onKeyUp=t=>{if(super.onKeyUp(t),this.isShift=!1,this.hoverLineSegmentIndex=-1,!this.selection.triggerKeyboardEvent(t,this.setLineList)){if(t.keyCode===v.Esc){this.stopLineCreating(!1);return}if(this.selectedLine){if(t.key==="Delete"){this.deleteLine();return}if(t.key==="f"){this.setInvalidLine(this.selectedID);return}if(t.key===" "){this.continueToEdit();return}}this.keyboardEventWhileLineCreating(t)}},this.onRightDblClick=t=>{super.onRightDblClick(t);const i=this.getCoordinate(t);if(this.isActive){const s=this.findHoveredPoint(i);if(s){this.deleteSelectedLinePoint(s.id);return}this.deleteSelectedLine(i)}},this.setReference=t=>{this.isReference=t},this.pointsWithinRange=t=>!(this.lowerLimitPointNum&&t<this.lowerLimitPointNum||this.upperLimitPointNum&&t>this.upperLimitPointNum),this.setLineList=t=>{const i=t.length!==this.lineListLen;this.lineList=t,i&&this.emit("updatePageNumber")},this.textChange=t=>{this.config.textConfigurable===!1||!this.selectedID||(this.updateSelectedTextAttribute(t),this.emit("selectedChange"))},this.status=2,this.isMousedown=!1,this.lineDragging=!1,this.isLineValid=!0,this.setConfig(e.config),this.prevAxis={x:0,y:0},this.textEditingID="",this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.actionsHistory=new B,this.selection=new J(this),this.dependToolConfig={lineType:P.Line}}get selectedLines(){return this.lineList.filter(e=>this.selection.isIdSelected(e.id))}get isLineSelected(){return this.selectedID&&this.activeLine}get selectedLine(){return this.lineList.find(e=>e.id===this.selectedID)}get isCreate(){return this.status===0}get isActive(){return this.selectedLines.length>0}get isNone(){return!this.isCreate&&this.selectedIDs.length===0}get isCurve(){return this.config.lineType===P.Curve}get isMultipleColor(){return this.config.lineColor===U.MultiColor}get imageSize(){return this.rotate%180==0?this.basicImgInfo:{width:this.basicImgInfo.height,height:this.basicImgInfo.width}}get lineListLen(){return this.lineList.length}get edgeAdsorptionEnabled(){return this.edgeAdsorption&&!this.isCurve&&this.lineListLen>0}get attributeConfigurable(){return this.config.attributeConfigurable}get isTextConfigurable(){return this.config.textConfigurable}get isDependPolygon(){return this.dependToolName===_.Polygon}get isDependRect(){return this.dependToolName===_.Rect}get isCurrentAttributeLocked(){return this.attributeLockList.includes(this.defaultAttribute)}get attributeFilteredLines(){return this.attributeLockList.length>0?this.lineList.filter(e=>this.attributeLockList.includes((e==null?void 0:e.attribute)||"")):this.lineList}get selectedIDs(){return this.selection.selectedIDs}get selectedID(){return this.selection.selectedID}get enableOutOfTarget(){return this.config.enableOutOfTarget||this.config.outOfTarget||this.config.drawOutsideTarget}get showOrder(){var e;return(e=this.config.showOrder)!=null?e:this.config.isShowOrder}get edgeAdsorption(){return this.config.edgeAdsorption}get attributeList(){return this.config.attributeList}get lowerLimitPointNum(){return this.config.lowerLimitPointNum}get minLength(){var e;return((e=this.config)==null?void 0:e.minLength)||0}get upperLimitPointNum(){return this.config.upperLimitPointNum}get textCheckType(){return this.config.textCheckType}get customFormat(){return this.config.customFormat}get dataList(){return this.lineList}get hasActiveLine(){return this.activeLine&&this.activeLine.length>0}get viewPortLines(){const e=N.getViewPort(this.canvas,this.currentPos,this.zoom);return this.isHidden?[]:this.attributeFilteredLines.filter(t=>{var i;return(i=t==null?void 0:t.pointList)==null?void 0:i.some(s=>N.inViewPort(s,e))})}get lineStyle(){return{lineWidth:this.style.width,color:this.getLineColor(this.defaultAttribute),opacity:this.style.opacity}}get selectedText(){var e,t;return(t=(e=this.lineList.find(i=>i.id===this.selectedID))==null?void 0:e.textAttribute)!=null?t:""}get currentPageResult(){return this.lineList}updateStatus(e,t=!1){if(e!==this.status){if(t){let i="";this.textCheckType===M.Order&&this.isTextConfigurable&&(i=y.getTextAttribute(this.lineList,this.textCheckType)),this.emit("updateText",i)}this.status=e,this.lineStatusChanged()}}isInBasicPolygon(e){var t,i;return V(e,((t=this.basicResult)==null?void 0:t.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}getPolygonPointList(){if(!this.basicResult)return[];const{pointList:e}=this.basicResult,{lineType:t}=this.dependToolConfig;return t===P.Curve?W(e.reduce((i,s)=>[...i,s.x,s.y],[]),.5,!0,20):e}getNextCoordByRenderCoord(e){return this.getNextCoordByAbsCoord(this.coordUtils.getAbsCoord(e))}getNextCoordByAbsCoord(e){var t;const i=(t=this.activeLine)==null?void 0:t.slice(-1)[0];return i?this.coordUtils.getNextCoordByDependTool(e,i):e}pointInLine(e,t,i){return e.filter(s=>s).length<2?!1:e.some((s,n)=>{if(n===0)return!1;const o=this.coordUtils.getRenderCoord(e[n-1]),r=this.coordUtils.getRenderCoord(s);return u.isInLine(t,o,r,i)})}arc(e,t=x,i){var s,n,o,r,h,l;if(this.ctx){const{x:a,y:c}=e;(s=this.ctx)==null||s.save(),(n=this.ctx)==null||n.beginPath(),this.ctx.fillStyle=i||this.lineStyle.color,(o=this.ctx)==null||o.arc(a,c,t,0,360),(r=this.ctx)==null||r.closePath(),(h=this.ctx)==null||h.fill(),(l=this.ctx)==null||l.restore()}}renderActiveArea({top:e,left:t,right:i,bottom:s}){this.ctx&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.strokeStyle="#B3B8FF",this.ctx.rect(t,e,i-t,s-e),this.ctx.stroke(),this.ctx.restore())}addLinePoint(e){var t,i,s,n;this.arc(e),(t=this.activeLine)==null||t.push(w(T({},e),{id:S()})),((i=this.activeLine)==null?void 0:i.length)===1?(s=this.actionsHistory)==null||s.initRecord(this.activeLine):(n=this.actionsHistory)==null||n.pushHistory(this.activeLine),this.render()}setCreateStatusAndAddPoint(e,t=!1){this.updateStatus(0,t),this.addLinePoint(e)}isActiveLineValid(){var e;return this.selectedID?(e=this.lineList.find(t=>t.id===this.selectedID))==null?void 0:e.valid:this.isLineValid}nextOrder(){return this.lineListLen===0?1:this.lineList.slice(-1)[0].order+1}getLineColorByAttribute(e,t=!1){return z.getStrokeAndFill(this.getColor(e.attribute),e.valid,{isSelected:t}).stroke}drawLineNumber(e,t=1,i,s="",n,o=!0){var r,h,l;if((this.showOrder||this.attributeConfigurable)&&this.ctx){let a=this.showOrder?t.toString():`${s}`;if(this.attributeConfigurable){const c=n?(l=(h=(r=this.attributeList)==null?void 0:r.find(f=>f.value===n))==null?void 0:h.key)!=null?l:n:"";a=[a,`${!o&&c?"\u65E0\u6548":""}${c}`].filter(f=>f).join("_")}this.drawText(e,a,i)}}drawLineTextAttribute(e,t,i){if(e&&i)return this.drawText(e,i,t,200)}drawLineLength(e,t){var i;if(((i=this.config)==null?void 0:i.showLineLength)&&e){const s=e.reduce((o,r,h)=>h<=0||!e[h-1].actual||!r.actual?o:o+u.calcDistance(e[h-1].actual,r.actual),0),n=e[e.length-1];this.drawText(n,`l = ${s.toFixed(2)}`,t)}}drawText(e,t,i,s){var n,o;this.ctx&&((n=this.ctx)==null||n.save(),this.ctx.font="italic bold 14px SourceHanSansCN-Regular",this.ctx.fillStyle=i,this.ctx.strokeStyle=i,this.ctx.shadowColor="rgba(0, 0, 0, 0.6)",this.ctx.shadowOffsetY=2,this.ctx.shadowBlur=4,s?F.wrapText(this.canvas,t,e.x-C.x,e.y-C.y,s):this.ctx.fillText(t,e.x-C.x,e.y-C.y),(o=this.ctx)==null||o.restore())}moveActiveArea(e,t){this.selectedLines.length>0&&(this.selectedLines.forEach(i=>{var s;(s=i.pointList)==null||s.forEach(n=>Object.assign(n,{x:n.x+e,y:n.y+t}))}),this.render()),this.emit("dataUpdated",this.lineList,this.selectedIDs)}findHoveredPoint(e){if(!!this.activeLine)return this.activeLine.find(t=>{const i=this.coordUtils.getRenderCoord(t);return u.calcDistance(i,e)<=m})}findHoverLine(e){return g.cloneDeep(this.lineList).reverse().find(({pointList:i})=>{const s=i?this.getPointList(i):[],n=this.getLineWidthScope();return s.some((o,r)=>{if(r===0)return!1;const h=this.coordUtils.getRenderCoord(o),l=this.coordUtils.getRenderCoord(s[r-1]);return u.isInLine(e,h,l,n)})})}getAdsorptionPoint(e){let t,i,s;return g.cloneDeep(this.lineList).reverse().forEach(({pointList:n,id:o})=>{if(o===this.selectedID||!n||(n==null?void 0:n.length)<2)return;const r=this.findNearestPoint(n,e);if(r){if(r.minDistance===0){t=r.point;return}(i===void 0||r.minDistance<i)&&(t=r.point,i=r.minDistance)}}),s||t}findNearestPoint(e,t,i=7){let s;const n=i;for(let o=1;o<=e.length-1;o++){const r=this.coordUtils.getRenderCoord(e[o]),h=this.coordUtils.getRenderCoord(e[o-1]),{length:l,footPoint:a}=L.getFootOfPerpendicular(t,r,h),c=u.calcTwoPointDistance(r,t),f=u.calcTwoPointDistance(h,t);if(c<=i*2){s=r,i=0;break}if(f<=i*2){s=h,i=0;break}l<i&&(s=a,i=l)}return s?{point:s,minDistance:n}:void 0}getPointList(e){return this.isCurve?R(e,p):e}moveSelectedLine(e){const t=(e.x-this.prevAxis.x)/this.zoom,i=(e.y-this.prevAxis.y)/this.zoom;if(this.enableOutOfTarget){this.lineDragging=!0,this.moveActiveArea(t,i);return}if(this.isDependPolygon){this.moveLineInPolygon(t,i);return}let s=[0,this.imageSize.width],n=[0,this.imageSize.height];if(this.isDependRect){const{x:o,y:r,width:h,height:l}=this.basicResult;s=[o,o+h],n=[r,r+l]}this.moveLineInRectRange(t,i,s,n)}moveSelectPoint(e){if(!this.selectedPoint)return;const t=e.x-this.prevAxis.x,i=e.y-this.prevAxis.y,s=(this.selectedPoint?this.selectedPoint.x:0)+t/this.zoom,n=(this.selectedPoint?this.selectedPoint.y:0)+i/this.zoom,o={x:s,y:n};Object.assign(this.selectedPoint,this.getNextCoordByAbsCoord(o)),this.updateLines(),this.render()}getCoordByConfig(e,t){var i;const s=!!e.shiftKey,n=e.altKey;if(((i=this.activeLine)==null?void 0:i.length)>0&&s){const o=this.activeLine.slice(-1)[0];return u.getVHPoint(o,t,this.coordUtils.getAbsCoord(t),this.coordUtils.getRenderCoord(o))}return this.edgeAdsorptionEnabled&&!n?this.getAdsorptionPoint(t):t}getNextPoint(e,t){const i=this.getCoordByConfig(e,t)||t;return this.enableOutOfTarget?this.coordUtils.getAbsCoord(i):this.getNextCoordByRenderCoord(i)}lineHover(){this.render()}mouseMoveHandler(e){const t=this.getCoordinate(e),i=e.which===1;if(this.isCreate){this.hasActiveLine&&this.renderNextPoint(e,t);return}if(this.isNone&&(this.lineHover(),this.edgeAdsorptionEnabled&&!e.altKey)){const s=this.getAdsorptionPoint(t);s&&this.arc(s)}if(this.isActive){if(this.isMousedown&&i){if(this.selectedPoint){this.moveSelectPoint(t);return}if(this.coordsInsideActiveArea){this.moveSelectedLine(t),this.drawActivatedLine(void 0,void 0,!0);return}}this.drawHoverPoint(t),this.render()}}onMouseMove(e){if(super.onMouseMove(e)||this.forbidMouseOperation||!this.imgInfo)return;const t=this.getCoordinate(e);this.mouseMoveHandler(e),this.prevAxis=t}setActiveLine(e){this.activeLine=e?g.cloneDeep(e):void 0}historyChanged(e){const t=`${e}Enabled`;if(this.isCreate){if(this.actionsHistory&&this.actionsHistory[t]){const i=this.actionsHistory&&this.actionsHistory[e]();this.setActiveLine(i),this.render()}return}if(this.history&&this.history[t]){const i=this.history[e](),s=i==null?void 0:i.find(n=>n.id===this.selectedID);this.lineList=i,this.selectedID&&s?this.setActiveLine(s==null?void 0:s.pointList):this.setNoneStatus(),this.render()}this.emit("dataUpdated",this.lineList)}undo(){this.historyChanged("undo"),this.updateSelectedAttributeAfterHistoryChanged()}redo(){this.historyChanged("redo"),this.updateSelectedAttributeAfterHistoryChanged()}isCoordInsideTarget(e){if(this.isDependPolygon)return this.isInBasicPolygon(e);if(this.isDependRect){const{x:t,y:i,width:s,height:n}=this.basicResult,o=[t,t+s],r=[i,i+n];return L.isInRange(e.x,o)&&L.isInRange(e.y,r)}return L.isInRange(e.x,[0,this.imageSize.width])&&L.isInRange(e.y,[0,this.imageSize.height])}getPointInsertIndex(e,t){if(e&&this.activeLine){const i=this.getPointList(this.activeLine);return this.activeLine.length===2?1:this.activeLine.findIndex((s,n)=>{if(n>0){const o=this.activeLine?this.activeLine[n-1]:void 0,r=this.isCurve?i.slice((n-1)*(p+1),n*(p+1)):[o,s];return this.pointInLine(r,e,t||this.getLineWidthScope())}return!1})}return-1}getLineWidthScope(){return this.lineStyle.lineWidth}isMouseCoordOutsideActiveArea(){return!this.coordsInsideActiveArea&&!this.selectedPoint}isLinePointsExceed(){return this.isCreate&&this.activeLine&&this.upperLimitPointNum&&~~this.upperLimitPointNum<=this.activeLine.length}isLinePointsNotEnough(){var e;return this.activeLine&&((e=this.activeLine)==null?void 0:e.length)<this.lowerLimitPointNum}updateLineSegmentSpecial(e){const t=this.getPointInsertIndex(e,2)-1;if(t>-1){const i=this.activeLine[t];i.specialEdge=!i.specialEdge,this.hoverLineSegmentIndex=-1,this.render()}}addLinePointToActiveLine(){var e;const t=this.getPointInsertIndex(this.cursor),i=this.pointsWithinRange(this.activeLine.length+1);this.cursor&&t>-1&&i&&(this.activeLine.splice(t,0,w(T({},this.coordUtils.getAbsCoord(this.cursor)),{id:S()})),this.updateLines(),(e=this.history)==null||e.pushHistory(this.lineList),this.render(),this.cursor=void 0)}isCoordOnSelectedArea(e){return this.selectedLines.some(t=>u.inArea(L.calcViewportBoundaries(t.pointList),this.coordUtils.getAbsCoord(e)))}onMouseDown(e){if(super.onMouseDown(e)||this.forbidMouseOperation||!this.imgInfo)return;const t=this.getCoordinate(e);if(this.isMousedown=!0,this.prevAxis=t,e.which===3){this.cursor=void 0;return}this.selectedPoint=this.findHoveredPoint(t),this.coordsInsideActiveArea=this.selectedLines.length>0?this.isCoordOnSelectedArea(t):!1,this.lineDragging=!1}lineHasChanged(){const e=this.lineList.find(t=>t.id===this.selectedID);return e?JSON.stringify(e.pointList)!==JSON.stringify(this.activeLine):!1}updateLines(){const e=this.lineList.find(t=>t.id===this.selectedID);e&&(e.pointList=g.cloneDeep(this.activeLine),this.updatedLine=e,this.emit("dataUpdated",this.lineList))}onMouseUp(e){const t=()=>{this.isMousedown=!1,this.hoverPointID=void 0,this.cursor=void 0,this.selectedPoint=void 0};if(this.hoverPointID=void 0,super.onMouseUp(e)||this.forbidMouseOperation||!this.imgInfo){t();return}e.which===1&&this.onLeftClick(e),e.which===3&&this.onRightClick(e),t()}isTextValid(e){return y.textAttributeValidate(this.textCheckType,this.customFormat,e)}createLineData(){const e=S(),t={pointList:g.cloneDeep(this.activeLine),id:e,valid:this.isLineValid,order:this.nextOrder()};return t.attribute=this.defaultAttribute,t}stopLineCreating(e=!0){var t,i,s,n;const o=this.selectedID?!0:!!this.isTextConfigurable;let r;if(e){if(this.selectedID){const h=this.lineList.find(l=>l.id===this.selectedID);r=this.selectedID,h&&(h.pointList=g.cloneWith(this.activeLine),g.isEqual(h.pointList,(t=this.history)==null?void 0:t.pushHistory(this.lineList))||(i=this.history)==null||i.pushHistory(this.lineList))}else if(this.isCreate&&this.activeLine&&this.activeLine.length>1){const h=this.createLineData();r=h.id,this.setLineList([...this.lineList,h]),(s=this.history)==null||s.pushHistory(this.lineList)}}this.setNoneStatus(),o&&(this.activeLine=[],this.setSelectedLineID(r,!1,!1)),(n=this.actionsHistory)==null||n.empty(),this.emit("dataUpdated",this.lineList,this.selectedIDs),this.render()}setNoneStatus(e=!0){e&&this.updateStatus(2),this.activeLine=[],this.setSelectedLineID(void 0),this.isLineValid=!0,this.cursor=void 0}setKeyDownStatus(e,t){this.isShift=t!=null?t:e.keyCode===v.Shift}continueToEdit(){var e,t;((e=this.selectedLine)==null?void 0:e.pointList)&&(this.updateStatus(0),this.cursor=void 0,this.setActiveLine(this.selectedLine.pointList),(t=this.actionsHistory)==null||t.pushHistory(this.activeLine),this.render())}setInvalidLineOnCreating(e){if(this.selectedID&&e.keyCode!==v.Ctrl||!this.isCreate)return;const t=!e.ctrlKey;this.selectedID?this.setInvalidLine(this.selectedID,t,!1):this.isLineValid=t}onKeyDown(e){if(super.onKeyDown(e),this.setKeyDownStatus(e),e.keyCode===v.Z&&!e.ctrlKey&&this.toggleIsHide(),e.keyCode===v.Shift&&this.render(),e.keyCode===v.Tab){e.preventDefault(),this.selectToNextLine(e);return}if(this.isCreate&&this.keyboardEventWhileLineCreating(e),this.config.attributeConfigurable){const t=y.getAttributeByKeycode(e.keyCode,this.config.attributeList);t!==void 0&&this.setDefaultAttribute(t)}}selectToNextLine(e){const t=K.getNextSelectedRectIDByEvent(this.viewPortLines.map(i=>{var s,n,o,r;return w(T({},i),{x:(n=(s=i.pointList[0])==null?void 0:s.x)!=null?n:0,y:(r=(o=i.pointList[0])==null?void 0:o.y)!=null?r:0})}),e,this.selectedID);t&&this.selection.setSelectedIDs(t.id)}keyboardEventWhileLineCreating(e){!this.isCreate||(e.keyCode===v.Ctrl&&this.setInvalidLineOnCreating(e),[v.Shift,v.Alt].includes(e.keyCode)&&this.renderNextPoint(e,this.prevAxis))}renderNextPoint(e,t){const i=this.coordUtils.getRenderCoord(this.getNextPoint(e,t));this.render(i)}deleteSelectedLine(e){var t;if(this.selectedLine){const i=L.calcViewportBoundaries((t=this.selectedLine)==null?void 0:t.pointList,this.isCurve,p,this.zoom);u.inArea(i,this.coordUtils.getAbsCoord(e))&&this.deleteLine()}}deleteSelectedLinePoint(e){var t;this.pointsWithinRange(this.activeLine.length-1)&&e&&(this.setActiveLine(this.activeLine.filter(s=>s.id!==e)),this.updateLines(),(t=this.history)==null||t.pushHistory(this.lineList)),this.cursor=void 0,this.render()}deleteLine(){var e;this.lineList=this.lineList.filter(t=>!this.selection.isIdSelected(t.id)),(e=this.history)==null||e.pushHistory(this.lineList),this.setNoneStatus(),this.emit("dataUpdated",this.lineList),this.render()}setInvalidLine(e,t,i=!0){var s;const n=this.lineList.find(o=>o.id===e);n&&(n.valid=t!==void 0?t:!n.valid,(s=this.history)==null||s.pushHistory(this.lineList),this.emit("dataUpdated",this.lineList),i&&this.render())}empty(){var e,t;this.lineList=[],this.setNoneStatus(),this.selectedPoint=void 0,(e=this.actionsHistory)==null||e.empty(),(t=this.history)==null||t.init(),this.emit("dataUpdated",this.lineList),this.render()}setAttribute(e){var t;this.attributeConfigurable&&(this.defaultAttribute=e,this.setLineAttribute("attribute",e),this.selectedIDs.length>0&&((t=this.history)==null||t.pushHistory(this.lineList)))}setTextAttribute(e){var t;this.isTextConfigurable&&(this.setLineAttribute("textAttribute",e),(t=this.history)==null||t.applyAttribute(this.selectedID,"textAttribute",e))}setLineAttribute(e,t){this.selectedIDs.length>0&&(this.lineList.forEach(i=>{this.selection.isIdSelected(i.id)&&(i[e]=t)}),this.render())}updateAttribute(e){this.emit("updateAttribute",e)}updateLineAttributes(e){var t;if(this.attributeConfigurable&&e){const i=(e==null?void 0:e.attribute)||"";this.defaultAttribute=i,this.updateAttribute(i)}if(this.isTextConfigurable&&e){const i=(e==null?void 0:e.textAttribute)||"";this.updateTextAttribute(i)}(t=this.history)==null||t.updateHistory(this.lineList)}lineStatusChanged(){this.emit("lineStatusChanged",{status:this.status,selectedLineID:this.selectedID})}updateTextAttribute(e){if(this.selectedID){const t=this.lineList.find(i=>i.id===this.selectedID);t&&(t.textAttribute=e)}this.emit("updateText",e)}saveData(){this.stopLineCreating(),this.setNoneStatus(),this.render()}setTextEditingID(e){this.textEditingID=e,this.render()}updateAttrWhileIDChanged(e){if(e){const t=this.lineList.find(i=>i.id===e);t&&this.setDefaultAttribute(t.attribute)}}setSelectedLineID(e,t=!1,i=!0){this.selection.setSelectedIDs(e,t),i&&e&&this.updateAttrWhileIDChanged(this.selectedID),this.selectedLine&&this.setActiveLine(this.selectedLine.pointList),this.selectedIDs.length===0&&this.setActiveLine([]),this.emit("dataUpdated",this.lineList,this.selectedIDs)}attributeLockListChange(e){this.attributeLockList=e,this.render()}setResult(e){this.setLineList(e),this.render()}setConfig(e){super.setConfig(e)}toggleIsHide(){this.setIsHidden(!this.isHidden),this.render()}clearCanvas(){super.clearCanvas()}clearResult(){this.setResult([]),this.setSelectedLineID(void 0),this.render()}exportData(){return[this.lineList,this.basicImgInfo]}setDefaultAttribute(e=""){var t;this.attributeConfigurable&&(this.defaultAttribute=e,this.changeStyle(this.defaultAttribute),this.setLineAttribute("attribute",e),this.selectedIDs.length>0&&((t=this.history)==null||t.pushHistory(this.lineList)),this.emit("changeAttributeSidebar"))}getCurrentSelectedData(){var e,t;const i=this.isActiveLineValid(),s=this.defaultAttribute,n=this.getColor(s),o=i?n==null?void 0:n.valid.stroke:n==null?void 0:n.invalid.stroke,r=(t=(e=this.lineList.find(h=>h.id===this.selectedID))==null?void 0:e.textAttribute)!=null?t:"";return{color:o,textAttribute:r}}renderTextAttribute(){var e,t,i,s;if(!this.ctx||!this.selectedLine||this.activeLine&&((e=this.activeLine)==null?void 0:e.length)<2)return;const n=this.isActiveLineValid(),o=this.defaultAttribute,{x:r,y:h}=this.selectedLine.pointList[1],l=this.coordUtils.getRenderCoord({x:r,y:h}),a=this.getColor(o),c=n?a==null?void 0:a.valid.stroke:a==null?void 0:a.invalid.stroke,f=(i=(t=this.lineList.find(b=>b.id===this.selectedID))==null?void 0:t.textAttribute)!=null?i:"";this._textAttributeInstance||(this._textAttributeInstance=new $({container:this.container,icon:this.getTextIconSvg(o),color:c,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributeInstance&&!((s=this._textAttributeInstance)==null?void 0:s.isExit)&&this._textAttributeInstance.appendToContainer(),this._textAttributeInstance.update(`${f}`,{left:l.x,top:l.y,color:c}),this._textAttributeInstance.updateIcon(this.getTextIconSvg(o))}getTextIconSvg(e=""){return y.getTextIconSvg(e,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}updateSelectedTextAttribute(e){if(this._textAttributeInstance&&e&&this.selectedID){let t=e;!y.textAttributeValidate(this.config.textCheckType,"",t)&&(this.emit("messageError",y.getErrorNotice(this.config.textCheckType,this.lang)),t=""),this.setTextAttribute(t),this.emit("updateTextAttribute"),this.render()}}}export{H as INNER_POINT_RADIUS,C as LINE_ORDER_OFFSET,m as POINT_ACTIVE_RADIUS,x as POINT_RADIUS,p as SEGMENT_NUMBER,et as default};
|
|
1
|
+
import g from"lodash";import{ELineTypes as P,ELineColor as U,EToolName as _,ETextType as M}from"../../constant/tool.js";import B from"../../utils/ActionsHistory.js";import S from"../../utils/uuid.js";import v from"../../constant/keyCode.js";import L from"../../utils/MathUtils.js";import{BasicToolOperation as j}from"./basicToolOperation.js";import u from"../../utils/tool/LineToolUtils.js";import{createSmoothCurvePointsFromPointList as R,isInPolygon as V,createSmoothCurvePoints as W}from"../../utils/tool/polygonTool.js";import K from"../../utils/tool/CommonToolUtils.js";import N from"../../utils/tool/CanvasUtils.js";import F from"../../utils/tool/DrawUtils.js";import z from"../../utils/tool/StyleUtils.js";import y from"../../utils/tool/AttributeUtils.js";import $ from"./textAttributeClass.js";import J from"./Selection.js";import Y from"../../locales/index.js";import{EMessage as X}from"../../locales/constants.js";var q=Object.defineProperty,G=Object.defineProperties,Z=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable,E=(d,e,t)=>e in d?q(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t,T=(d,e)=>{for(var t in e||(e={}))Q.call(e,t)&&E(d,t,e[t]);if(O)for(var t of O(e))tt.call(e,t)&&E(d,t,e[t]);return d},w=(d,e)=>G(d,Z(e)),k;(function(d){d[d.Create=0]="Create",d[d.Active=1]="Active",d[d.None=2]="None"})(k||(k={}));const p=16,C={x:0,y:20},x=3,m=5,H=2;class et extends j{constructor(e){super(e);this.drawActivatedLine=(t,i,s)=>{const n=this.isCreate?g.cloneDeep([{pointList:this.activeLine,order:this.nextOrder(),attribute:this.defaultAttribute,valid:this.isLineValid}]):g.cloneDeep(this.selectedLines),o=this.isActiveLineValid();n.forEach(r=>{if((r==null?void 0:r.pointList)&&(r.pointList=r.pointList.map(l=>Object.assign(l,{actual:{x:l.x,y:l.y}},this.coordUtils.getRenderCoord(l)))),!r.pointList)return;const h=this.getLineColorByAttribute({attribute:r.attribute,valid:r.valid});return this.selectedLines.length>0&&(this.drawLineLength(r.pointList,h),this.renderActiveArea(L.calcViewportBoundaries(r.pointList,this.isCurve,p))),this.drawLine(r.pointList,t,h,!0,!0),r.pointList[0]&&this.drawLineNumber(r.pointList[0],r.order,h,"",this.defaultAttribute,o),t&&this.isCreate&&this.arc(t,x,h),this.cursor&&!this.selectedPoint&&!s&&!this.isShift&&this.arc(this.cursor,m,h),r})},this.drawHoverPoint=t=>{if(!this.isMousedown&&t&&this.selectedID){const i=this.getPointList(this.activeLine),s=this.activeLine.find(o=>u.calcDistance(this.coordUtils.getRenderCoord(o),t)<=m);let n;!s&&this.activeLine&&(n=this.findNearestPoint(i,t)),this.hoverPointID=s?s.id:void 0,this.cursor=s||n==null?void 0:n.point}},this.updatedLine={id:"",valid:!1,order:0},this.toolName="lineTool",this.lineList=[],this.activeLine=[],this.coordsInsideActiveArea=!1,this.hoverLineSegmentIndex=-1,this.isShift=!1,this.isReference=!1,this.drawCurveLine=(t,i,s,n=!0,o=!1,r)=>{const h=R(i,p);t.save(),t.lineCap="round",t.lineJoin="round",t.strokeStyle=s.color,n&&(t.lineWidth=s.lineWidth),o&&u.setReferenceCtx(t),i.forEach(({specialEdge:l},a)=>{const c=h.splice(0,p+1);t.save(),t.beginPath(),r===a&&(t.lineWidth=4),c.forEach(({x:f,y:b},I)=>{const D=I>0?"lineTo":"moveTo";l&&u.setSpecialEdgeStyle(t),t[D](f,b)}),t.stroke(),t.restore()}),t.restore()},this.drawLine=(t,i,s,n=!1,o=!1)=>{const r=i?t.concat(i):t,h={color:s,lineWidth:o?1:this.lineStyle.lineWidth};this.isCurve?u.drawCurveLine(this.ctx,r,h,!n,this.isReference,o?this.hoverLineSegmentIndex:-1):this.drawStraightLine(r,h,o),n&&t.forEach(l=>{var a,c;const f=l.id,b=f&&[this.hoverPointID,(a=this.selectedPoint)==null?void 0:a.id].includes(f)?m:x;this.arc(l,b,s),[this.hoverPointID,(c=this.selectedPoint)==null?void 0:c.id].includes(f)||this.arc(l,H,"white")})},this.drawStraightLine=(t,i,s=!1)=>{const{ctx:n}=this;n&&(n.save(),n.lineCap="round",n.lineJoin="round",n.strokeStyle=i.color,n.lineWidth=i.lineWidth,this.isReference&&u.setReferenceCtx(n),t.forEach((o,r)=>{if(n.beginPath(),r>0){const h=t[r-1];n.save(),(h==null?void 0:h.specialEdge)&&u.setSpecialEdgeStyle(n),s&&this.hoverLineSegmentIndex+1===r&&(n.lineWidth=4),n.moveTo(h.x,h.y),n.lineTo(o.x,o.y),n.stroke(),n.restore()}}),n.restore())},this.drawLines=()=>{try{const t=g.cloneDeep(this.attributeFilteredLines);if(this.isHidden)return;t.forEach(i=>{if(!this.selection.isIdSelected(i.id)&&i.pointList){i.pointList.map(h=>Object.assign(h,{actual:{x:h.x,y:h.y}},this.coordUtils.getRenderCoord(h)));const{order:s,label:n}=i,o=s,r=i&&this.getLineColorByAttribute(i);this.drawLine(i.pointList,void 0,r,!1),this.drawLineNumber(i.pointList[0],o,r,n,i.attribute,i.valid),i.id!==this.textEditingID&&(this.drawLineTextAttribute(i.pointList[1],r,i==null?void 0:i.textAttribute),this.drawLineLength(i.pointList,r))}})}catch(t){console.error(t,"\u7EBF\u6761\u5DE5\u5177\u6570\u636E\u89E3\u6790\u9519\u8BEF"),this.lineList=[],this.clearCanvas()}},this.render=t=>{super.render(),this.drawLines(),this.drawActivatedLine(t,void 0,!1),this.renderTextAttribute(),this.renderCursorLine(this.getLineColor(this.defaultAttribute))},this.moveLineInPolygon=(t,i)=>{var s;if(!Array.isArray(this.activeLine))return!1;((s=this.activeLine)==null?void 0:s.every(o=>this.isInBasicPolygon({x:o.x+t,y:o.y+i})))&&(this.lineDragging=!0,this.moveActiveArea(t,i))},this.getSelectedLinesArea=()=>L.calcViewportBoundaries(this.selectedLines.reduce((t,i)=>(i==null?void 0:i.pointList)?t.concat(...i==null?void 0:i.pointList):t,[])),this.moveLineInRectRange=(t,i,s,n)=>{if(this.selectedLines.length===0)return;const{top:o,left:r,right:h,bottom:l}=this.getSelectedLinesArea(),a=[r,h].map(A=>g.isNumber(A)?A+t:0),c=[o,l].map(A=>g.isNumber(A)?A+i:0),f=r>=0&&h&&L.isInRange(a,s),b=o>=0&&l&&L.isInRange(c,n),I=f?t:0,D=b?i:0;this.lineDragging=!0,this.moveActiveArea(I,D)},this.onRightClick=t=>{if(this.cursor=void 0,this.isCreate){if(this.isLinePointsNotEnough())return;if(u.lineLengthSum(this.activeLine||[])<this.minLength)return this.emit("messageInfo",`${Y.getMessagesByLocale(X.MinLengthLimitErrorNotice,this.lang)}${this.minLength}`),!0;this.stopLineCreating(!0);return}const i=this.findHoverLine(this.getCoordinate(t));this.setSelectedLineID(i==null?void 0:i.id,t.ctrlKey),this.emit("contextmenu")},this.updateSelectedAttributeAfterHistoryChanged=()=>{if(this.selectedIDs.length>0){const t=this.lineList.find(s=>s.id===this.selectedIDs[0]),i=t==null?void 0:t.attribute;typeof i=="string"&&(this.defaultAttribute=i,this.updateAttribute(i),this.render())}},this.onLeftClick=t=>{const i=this.getCoordinate(t),{lineDragging:s}=this;if(this.lineDragging=!1,this.isSpaceKey)return;if(this.isNone&&t.ctrlKey){const o=this.findHoverLine(i);o&&this.setInvalidLine(o.id);return}if(this.isLinePointsExceed())return;const n=this.getNextPoint(t,i);if(this.isCreate||this.isNone){this.setCreateStatusAndAddPoint(n);return}if(this.isActive){if(s)return;if(this.isMouseCoordOutsideActiveArea()){this.setNoneStatus(!1),this.setCreateStatusAndAddPoint(n);return}if(t.shiftKey){this.updateLineSegmentSpecial(i);return}this.coordsInsideActiveArea&&t.ctrlKey&&this.setInvalidLine(this.selectedID),this.addLinePointToActiveLine()}},this.onDblclick=()=>{},this.onKeyUp=t=>{if(super.onKeyUp(t),this.isShift=!1,this.hoverLineSegmentIndex=-1,!this.selection.triggerKeyboardEvent(t,this.setLineList)){if(t.keyCode===v.Esc){this.stopLineCreating(!1);return}if(this.selectedLine){if(t.key==="Delete"){this.deleteLine();return}if(t.key==="f"){this.setInvalidLine(this.selectedID);return}if(t.key===" "){this.continueToEdit();return}}this.keyboardEventWhileLineCreating(t)}},this.onRightDblClick=t=>{super.onRightDblClick(t);const i=this.getCoordinate(t);if(this.isActive){const s=this.findHoveredPoint(i);if(s){this.deleteSelectedLinePoint(s.id);return}this.deleteSelectedLine(i)}},this.setReference=t=>{this.isReference=t},this.pointsWithinRange=t=>!(this.lowerLimitPointNum&&t<this.lowerLimitPointNum||this.upperLimitPointNum&&t>this.upperLimitPointNum),this.setLineList=t=>{const i=t.length!==this.lineListLen;this.lineList=t,i&&this.emit("updatePageNumber")},this.textChange=t=>{this.config.textConfigurable===!1||!this.selectedID||(this.updateSelectedTextAttribute(t),this.emit("selectedChange"))},this.status=2,this.isMousedown=!1,this.lineDragging=!1,this.isLineValid=!0,this.setConfig(e.config),this.prevAxis={x:0,y:0},this.textEditingID="",this.updateSelectedTextAttribute=this.updateSelectedTextAttribute.bind(this),this.getCurrentSelectedData=this.getCurrentSelectedData.bind(this),this.actionsHistory=new B,this.selection=new J(this),this.dependToolConfig={lineType:P.Line},this.historyDisabled=!1}get selectedLines(){return this.lineList.filter(e=>this.selection.isIdSelected(e.id))}get isLineSelected(){return this.selectedID&&this.activeLine}get selectedLine(){return this.lineList.find(e=>e.id===this.selectedID)}get isCreate(){return this.status===0}get isActive(){return this.selectedLines.length>0}get isNone(){return!this.isCreate&&this.selectedIDs.length===0}get isCurve(){return this.config.lineType===P.Curve}get isMultipleColor(){return this.config.lineColor===U.MultiColor}get imageSize(){return this.rotate%180==0?this.basicImgInfo:{width:this.basicImgInfo.height,height:this.basicImgInfo.width}}get lineListLen(){return this.lineList.length}get edgeAdsorptionEnabled(){return this.edgeAdsorption&&!this.isCurve&&this.lineListLen>0}get attributeConfigurable(){return this.config.attributeConfigurable}get isTextConfigurable(){return this.config.textConfigurable}get isDependPolygon(){return this.dependToolName===_.Polygon}get isDependRect(){return this.dependToolName===_.Rect}get isCurrentAttributeLocked(){return this.attributeLockList.includes(this.defaultAttribute)}get attributeFilteredLines(){return this.attributeLockList.length>0?this.lineList.filter(e=>this.attributeLockList.includes((e==null?void 0:e.attribute)||"")):this.lineList}get selectedIDs(){return this.selection.selectedIDs}get selectedID(){return this.selection.selectedID}get enableOutOfTarget(){return this.config.enableOutOfTarget||this.config.outOfTarget||this.config.drawOutsideTarget}get showOrder(){var e;return(e=this.config.showOrder)!=null?e:this.config.isShowOrder}get edgeAdsorption(){return this.config.edgeAdsorption}get attributeList(){return this.config.attributeList}get lowerLimitPointNum(){return this.config.lowerLimitPointNum}get minLength(){var e;return((e=this.config)==null?void 0:e.minLength)||0}get upperLimitPointNum(){return this.config.upperLimitPointNum}get textCheckType(){return this.config.textCheckType}get customFormat(){return this.config.customFormat}get dataList(){return this.lineList}get hasActiveLine(){return this.activeLine&&this.activeLine.length>0}get viewPortLines(){const e=N.getViewPort(this.canvas,this.currentPos,this.zoom);return this.isHidden?[]:this.attributeFilteredLines.filter(t=>{var i;return(i=t==null?void 0:t.pointList)==null?void 0:i.some(s=>N.inViewPort(s,e))})}get lineStyle(){return{lineWidth:this.style.width,color:this.getLineColor(this.defaultAttribute),opacity:this.style.opacity}}get selectedText(){var e,t;return(t=(e=this.lineList.find(i=>i.id===this.selectedID))==null?void 0:e.textAttribute)!=null?t:""}get currentPageResult(){return this.lineList}updateStatus(e,t=!1){if(e!==this.status){if(t){let i="";this.textCheckType===M.Order&&this.isTextConfigurable&&(i=y.getTextAttribute(this.lineList,this.textCheckType)),this.emit("updateText",i)}this.status=e,this.lineStatusChanged()}}isInBasicPolygon(e){var t,i;return V(e,((t=this.basicResult)==null?void 0:t.pointList)||[],(i=this.dependToolConfig)==null?void 0:i.lineType)}getPolygonPointList(){if(!this.basicResult)return[];const{pointList:e}=this.basicResult,{lineType:t}=this.dependToolConfig;return t===P.Curve?W(e.reduce((i,s)=>[...i,s.x,s.y],[]),.5,!0,20):e}getNextCoordByRenderCoord(e){return this.getNextCoordByAbsCoord(this.coordUtils.getAbsCoord(e))}getNextCoordByAbsCoord(e){var t;const i=(t=this.activeLine)==null?void 0:t.slice(-1)[0];return i?this.coordUtils.getNextCoordByDependTool(e,i):e}pointInLine(e,t,i){return e.filter(s=>s).length<2?!1:e.some((s,n)=>{if(n===0)return!1;const o=this.coordUtils.getRenderCoord(e[n-1]),r=this.coordUtils.getRenderCoord(s);return u.isInLine(t,o,r,i)})}arc(e,t=x,i){var s,n,o,r,h,l;if(this.ctx){const{x:a,y:c}=e;(s=this.ctx)==null||s.save(),(n=this.ctx)==null||n.beginPath(),this.ctx.fillStyle=i||this.lineStyle.color,(o=this.ctx)==null||o.arc(a,c,t,0,360),(r=this.ctx)==null||r.closePath(),(h=this.ctx)==null||h.fill(),(l=this.ctx)==null||l.restore()}}renderActiveArea({top:e,left:t,right:i,bottom:s}){this.ctx&&(this.ctx.save(),this.ctx.beginPath(),this.ctx.strokeStyle="#B3B8FF",this.ctx.rect(t,e,i-t,s-e),this.ctx.stroke(),this.ctx.restore())}addLinePoint(e){var t,i,s,n;this.arc(e),(t=this.activeLine)==null||t.push(w(T({},e),{id:S()})),((i=this.activeLine)==null?void 0:i.length)===1?(s=this.actionsHistory)==null||s.initRecord(this.activeLine):(n=this.actionsHistory)==null||n.pushHistory(this.activeLine),this.render()}setCreateStatusAndAddPoint(e,t=!1){this.updateStatus(0,t),this.addLinePoint(e)}isActiveLineValid(){var e;return this.selectedID?(e=this.lineList.find(t=>t.id===this.selectedID))==null?void 0:e.valid:this.isLineValid}nextOrder(){return this.lineListLen===0?1:this.lineList.slice(-1)[0].order+1}getLineColorByAttribute(e,t=!1){return z.getStrokeAndFill(this.getColor(e.attribute),e.valid,{isSelected:t}).stroke}drawLineNumber(e,t=1,i,s="",n,o=!0){var r,h,l;if((this.showOrder||this.attributeConfigurable)&&this.ctx){let a=this.showOrder?t.toString():`${s}`;if(this.attributeConfigurable){const c=n?(l=(h=(r=this.attributeList)==null?void 0:r.find(f=>f.value===n))==null?void 0:h.key)!=null?l:n:"";a=[a,`${!o&&c?"\u65E0\u6548":""}${c}`].filter(f=>f).join("_")}this.drawText(e,a,i)}}drawLineTextAttribute(e,t,i){if(e&&i)return this.drawText(e,i,t,200)}drawLineLength(e,t){var i;if(((i=this.config)==null?void 0:i.showLineLength)&&e){const s=e.reduce((o,r,h)=>h<=0||!e[h-1].actual||!r.actual?o:o+u.calcDistance(e[h-1].actual,r.actual),0),n=e[e.length-1];this.drawText(n,`l = ${s.toFixed(2)}`,t)}}drawText(e,t,i,s){var n,o;this.ctx&&((n=this.ctx)==null||n.save(),this.ctx.font="italic bold 14px SourceHanSansCN-Regular",this.ctx.fillStyle=i,this.ctx.strokeStyle=i,this.ctx.shadowColor="rgba(0, 0, 0, 0.6)",this.ctx.shadowOffsetY=2,this.ctx.shadowBlur=4,s?F.wrapText(this.canvas,t,e.x-C.x,e.y-C.y,s):this.ctx.fillText(t,e.x-C.x,e.y-C.y),(o=this.ctx)==null||o.restore())}moveActiveArea(e,t){this.selectedLines.length>0&&(this.selectedLines.forEach(i=>{var s;(s=i.pointList)==null||s.forEach(n=>Object.assign(n,{x:n.x+e,y:n.y+t}))}),this.render()),this.emit("dataUpdated",this.lineList,this.selectedIDs)}findHoveredPoint(e){if(!!this.activeLine)return this.activeLine.find(t=>{const i=this.coordUtils.getRenderCoord(t);return u.calcDistance(i,e)<=m})}findHoverLine(e){return g.cloneDeep(this.lineList).reverse().find(({pointList:i})=>{const s=i?this.getPointList(i):[],n=this.getLineWidthScope();return s.some((o,r)=>{if(r===0)return!1;const h=this.coordUtils.getRenderCoord(o),l=this.coordUtils.getRenderCoord(s[r-1]);return u.isInLine(e,h,l,n)})})}getAdsorptionPoint(e){let t,i,s;return g.cloneDeep(this.lineList).reverse().forEach(({pointList:n,id:o})=>{if(o===this.selectedID||!n||(n==null?void 0:n.length)<2)return;const r=this.findNearestPoint(n,e);if(r){if(r.minDistance===0){t=r.point;return}(i===void 0||r.minDistance<i)&&(t=r.point,i=r.minDistance)}}),s||t}findNearestPoint(e,t,i=7){let s;const n=i;for(let o=1;o<=e.length-1;o++){const r=this.coordUtils.getRenderCoord(e[o]),h=this.coordUtils.getRenderCoord(e[o-1]),{length:l,footPoint:a}=L.getFootOfPerpendicular(t,r,h),c=u.calcTwoPointDistance(r,t),f=u.calcTwoPointDistance(h,t);if(c<=i*2){s=r,i=0;break}if(f<=i*2){s=h,i=0;break}l<i&&(s=a,i=l)}return s?{point:s,minDistance:n}:void 0}getPointList(e){return this.isCurve?R(e,p):e}moveSelectedLine(e){const t=(e.x-this.prevAxis.x)/this.zoom,i=(e.y-this.prevAxis.y)/this.zoom;if(this.enableOutOfTarget){this.lineDragging=!0,this.moveActiveArea(t,i);return}if(this.isDependPolygon){this.moveLineInPolygon(t,i);return}let s=[0,this.imageSize.width],n=[0,this.imageSize.height];if(this.isDependRect){const{x:o,y:r,width:h,height:l}=this.basicResult;s=[o,o+h],n=[r,r+l]}this.moveLineInRectRange(t,i,s,n)}moveSelectPoint(e){if(!this.selectedPoint)return;const t=e.x-this.prevAxis.x,i=e.y-this.prevAxis.y,s=(this.selectedPoint?this.selectedPoint.x:0)+t/this.zoom,n=(this.selectedPoint?this.selectedPoint.y:0)+i/this.zoom,o={x:s,y:n};Object.assign(this.selectedPoint,this.getNextCoordByAbsCoord(o)),this.updateLines(),this.render()}getCoordByConfig(e,t){var i;const s=!!e.shiftKey,n=e.altKey;if(((i=this.activeLine)==null?void 0:i.length)>0&&s){const o=this.activeLine.slice(-1)[0];return u.getVHPoint(o,t,this.coordUtils.getAbsCoord(t),this.coordUtils.getRenderCoord(o))}return this.edgeAdsorptionEnabled&&!n?this.getAdsorptionPoint(t):t}getNextPoint(e,t){const i=this.getCoordByConfig(e,t)||t;return this.enableOutOfTarget?this.coordUtils.getAbsCoord(i):this.getNextCoordByRenderCoord(i)}lineHover(){this.render()}mouseMoveHandler(e){const t=this.getCoordinate(e),i=e.which===1;if(this.isCreate){this.hasActiveLine&&this.renderNextPoint(e,t);return}if(this.isNone&&(this.lineHover(),this.edgeAdsorptionEnabled&&!e.altKey)){const s=this.getAdsorptionPoint(t);s&&this.arc(s)}if(this.isActive){if(this.isMousedown&&i){if(this.selectedPoint){this.moveSelectPoint(t);return}if(this.coordsInsideActiveArea){this.moveSelectedLine(t),this.drawActivatedLine(void 0,void 0,!0);return}}this.drawHoverPoint(t),this.render()}}onMouseMove(e){if(super.onMouseMove(e)||this.forbidMouseOperation||!this.imgInfo)return;const t=this.getCoordinate(e);this.mouseMoveHandler(e),this.prevAxis=t}setActiveLine(e){this.activeLine=e?g.cloneDeep(e):void 0}historyChanged(e){if(this.historyDisabled)return;const t=`${e}Enabled`;if(this.isCreate){if(this.actionsHistory&&this.actionsHistory[t]){const i=this.actionsHistory&&this.actionsHistory[e]();this.setActiveLine(i),this.render()}return}if(this.history&&this.history[t]){const i=this.history[e](),s=i==null?void 0:i.find(n=>n.id===this.selectedID);this.lineList=i,this.selectedID&&s?this.setActiveLine(s==null?void 0:s.pointList):this.setNoneStatus(),this.render()}this.emit("dataUpdated",this.lineList)}undo(){this.historyChanged("undo"),this.updateSelectedAttributeAfterHistoryChanged()}redo(){this.historyChanged("redo"),this.updateSelectedAttributeAfterHistoryChanged()}isCoordInsideTarget(e){if(this.isDependPolygon)return this.isInBasicPolygon(e);if(this.isDependRect){const{x:t,y:i,width:s,height:n}=this.basicResult,o=[t,t+s],r=[i,i+n];return L.isInRange(e.x,o)&&L.isInRange(e.y,r)}return L.isInRange(e.x,[0,this.imageSize.width])&&L.isInRange(e.y,[0,this.imageSize.height])}getPointInsertIndex(e,t){if(e&&this.activeLine){const i=this.getPointList(this.activeLine);return this.activeLine.length===2?1:this.activeLine.findIndex((s,n)=>{if(n>0){const o=this.activeLine?this.activeLine[n-1]:void 0,r=this.isCurve?i.slice((n-1)*(p+1),n*(p+1)):[o,s];return this.pointInLine(r,e,t||this.getLineWidthScope())}return!1})}return-1}getLineWidthScope(){return this.lineStyle.lineWidth}isMouseCoordOutsideActiveArea(){return!this.coordsInsideActiveArea&&!this.selectedPoint}isLinePointsExceed(){return this.isCreate&&this.activeLine&&this.upperLimitPointNum&&~~this.upperLimitPointNum<=this.activeLine.length}isLinePointsNotEnough(){var e;return this.activeLine&&((e=this.activeLine)==null?void 0:e.length)<this.lowerLimitPointNum}updateLineSegmentSpecial(e){const t=this.getPointInsertIndex(e,2)-1;if(t>-1){const i=this.activeLine[t];i.specialEdge=!i.specialEdge,this.hoverLineSegmentIndex=-1,this.render()}}addLinePointToActiveLine(){var e;const t=this.getPointInsertIndex(this.cursor),i=this.pointsWithinRange(this.activeLine.length+1);this.cursor&&t>-1&&i&&(this.activeLine.splice(t,0,w(T({},this.coordUtils.getAbsCoord(this.cursor)),{id:S()})),this.updateLines(),(e=this.history)==null||e.pushHistory(this.lineList),this.render(),this.cursor=void 0)}isCoordOnSelectedArea(e){return this.selectedLines.some(t=>u.inArea(L.calcViewportBoundaries(t.pointList),this.coordUtils.getAbsCoord(e)))}onMouseDown(e){if(super.onMouseDown(e)||this.forbidMouseOperation||!this.imgInfo)return;const t=this.getCoordinate(e);if(this.isMousedown=!0,this.prevAxis=t,e.which===3){this.cursor=void 0;return}this.selectedPoint=this.findHoveredPoint(t),this.coordsInsideActiveArea=this.selectedLines.length>0?this.isCoordOnSelectedArea(t):!1,this.lineDragging=!1}lineHasChanged(){const e=this.lineList.find(t=>t.id===this.selectedID);return e?JSON.stringify(e.pointList)!==JSON.stringify(this.activeLine):!1}updateLines(){const e=this.lineList.find(t=>t.id===this.selectedID);e&&(e.pointList=g.cloneDeep(this.activeLine),this.updatedLine=e,this.emit("dataUpdated",this.lineList))}onMouseUp(e){const t=()=>{this.isMousedown=!1,this.hoverPointID=void 0,this.cursor=void 0,this.selectedPoint=void 0};if(this.hoverPointID=void 0,super.onMouseUp(e)||this.forbidMouseOperation||!this.imgInfo){t();return}e.which===1&&this.onLeftClick(e),e.which===3&&this.onRightClick(e),t()}isTextValid(e){return y.textAttributeValidate(this.textCheckType,this.customFormat,e)}createLineData(){const e=S(),t={pointList:g.cloneDeep(this.activeLine),id:e,valid:this.isLineValid,order:this.nextOrder()};return t.attribute=this.defaultAttribute,t}stopLineCreating(e=!0){var t,i,s,n;const o=this.selectedID?!0:!!this.isTextConfigurable;let r;if(e){if(this.selectedID){const h=this.lineList.find(l=>l.id===this.selectedID);r=this.selectedID,h&&(h.pointList=g.cloneWith(this.activeLine),g.isEqual(h.pointList,(t=this.history)==null?void 0:t.pushHistory(this.lineList))||(i=this.history)==null||i.pushHistory(this.lineList))}else if(this.isCreate&&this.activeLine&&this.activeLine.length>1){const h=this.createLineData();r=h.id,this.setLineList([...this.lineList,h]),(s=this.history)==null||s.pushHistory(this.lineList)}}o?(this.activeLine=[],this.setSelectedLineID(r,!1,!1)):this.setNoneStatus(),(n=this.actionsHistory)==null||n.empty(),this.render()}setNoneStatus(e=!0){e&&this.updateStatus(2),this.activeLine=[],this.setSelectedLineID(void 0),this.isLineValid=!0,this.cursor=void 0}setKeyDownStatus(e,t){this.isShift=t!=null?t:e.keyCode===v.Shift}continueToEdit(){var e,t;((e=this.selectedLine)==null?void 0:e.pointList)&&(this.updateStatus(0),this.cursor=void 0,this.setActiveLine(this.selectedLine.pointList),(t=this.actionsHistory)==null||t.pushHistory(this.activeLine),this.render())}setInvalidLineOnCreating(e){if(this.selectedID&&e.keyCode!==v.Ctrl||!this.isCreate)return;const t=!e.ctrlKey;this.selectedID?this.setInvalidLine(this.selectedID,t,!1):this.isLineValid=t}onKeyDown(e){if(super.onKeyDown(e),this.setKeyDownStatus(e),e.keyCode===v.Z&&!e.ctrlKey&&this.toggleIsHide(),e.keyCode===v.Shift&&this.render(),e.keyCode===v.Tab){e.preventDefault(),this.selectToNextLine(e);return}if(this.isCreate&&this.keyboardEventWhileLineCreating(e),this.config.attributeConfigurable){const t=y.getAttributeByKeycode(e.keyCode,this.config.attributeList);t!==void 0&&this.setDefaultAttribute(t)}}selectToNextLine(e){const t=K.getNextSelectedRectIDByEvent(this.viewPortLines.map(i=>{var s,n,o,r;return w(T({},i),{x:(n=(s=i.pointList[0])==null?void 0:s.x)!=null?n:0,y:(r=(o=i.pointList[0])==null?void 0:o.y)!=null?r:0})}),e,this.selectedID);t&&this.selection.setSelectedIDs(t.id)}keyboardEventWhileLineCreating(e){!this.isCreate||(e.keyCode===v.Ctrl&&this.setInvalidLineOnCreating(e),[v.Shift,v.Alt].includes(e.keyCode)&&this.renderNextPoint(e,this.prevAxis))}renderNextPoint(e,t){const i=this.coordUtils.getRenderCoord(this.getNextPoint(e,t));this.render(i)}deleteSelectedLine(e){var t;if(this.selectedLine){const i=L.calcViewportBoundaries((t=this.selectedLine)==null?void 0:t.pointList,this.isCurve,p,this.zoom);u.inArea(i,this.coordUtils.getAbsCoord(e))&&this.deleteLine()}}deleteSelectedLinePoint(e){var t;this.pointsWithinRange(this.activeLine.length-1)&&e&&(this.setActiveLine(this.activeLine.filter(s=>s.id!==e)),this.updateLines(),(t=this.history)==null||t.pushHistory(this.lineList)),this.cursor=void 0,this.render()}deleteLine(){var e;this.lineList=this.lineList.filter(t=>!this.selection.isIdSelected(t.id)),(e=this.history)==null||e.pushHistory(this.lineList),this.setNoneStatus(),this.emit("dataUpdated",this.lineList),this.render()}setInvalidLine(e,t,i=!0){var s;const n=this.lineList.find(o=>o.id===e);n&&(n.valid=t!==void 0?t:!n.valid,(s=this.history)==null||s.pushHistory(this.lineList),this.emit("dataUpdated",this.lineList),i&&this.render())}empty(){var e,t;this.lineList=[],this.setNoneStatus(),this.selectedPoint=void 0,(e=this.actionsHistory)==null||e.empty(),(t=this.history)==null||t.init(),this.emit("dataUpdated",this.lineList),this.render()}setAttribute(e){var t;this.attributeConfigurable&&(this.defaultAttribute=e,this.setLineAttribute("attribute",e),this.selectedIDs.length>0&&((t=this.history)==null||t.pushHistory(this.lineList)))}setTextAttribute(e){var t;this.isTextConfigurable&&(this.setLineAttribute("textAttribute",e),(t=this.history)==null||t.applyAttribute(this.selectedID,"textAttribute",e))}setLineAttribute(e,t){this.selectedIDs.length>0&&(this.lineList.forEach(i=>{this.selection.isIdSelected(i.id)&&(i[e]=t)}),this.render())}updateAttribute(e){this.emit("updateAttribute",e)}updateLineAttributes(e){var t;if(this.attributeConfigurable&&e){const i=(e==null?void 0:e.attribute)||"";this.defaultAttribute=i,this.updateAttribute(i)}if(this.isTextConfigurable&&e){const i=(e==null?void 0:e.textAttribute)||"";this.updateTextAttribute(i)}(t=this.history)==null||t.updateHistory(this.lineList)}lineStatusChanged(){this.emit("lineStatusChanged",{status:this.status,selectedLineID:this.selectedID})}updateTextAttribute(e){if(this.selectedID){const t=this.lineList.find(i=>i.id===this.selectedID);t&&(t.textAttribute=e)}this.emit("updateText",e)}saveData(){this.stopLineCreating(),this.setNoneStatus(),this.render()}setTextEditingID(e){this.textEditingID=e,this.render()}updateAttrWhileIDChanged(e){if(e){const t=this.lineList.find(i=>i.id===e);t&&this.setDefaultAttribute(t.attribute)}}setSelectedLineID(e,t=!1,i=!0){this.selection.setSelectedIDs(e,t),this.status=1,i&&e&&this.updateAttrWhileIDChanged(this.selectedID),this.selectedLine&&this.setActiveLine(this.selectedLine.pointList),this.selectedIDs.length===0&&this.setActiveLine([]),this.emit("dataUpdated",this.lineList,this.selectedIDs)}attributeLockListChange(e){this.attributeLockList=e,this.render()}setResult(e){this.setLineList(e),this.render()}setConfig(e){super.setConfig(e)}toggleIsHide(){this.setIsHidden(!this.isHidden),this.render()}clearCanvas(){super.clearCanvas()}clearResult(){this.setResult([]),this.setSelectedLineID(void 0),this.render()}exportData(){return[this.lineList,this.basicImgInfo]}setDefaultAttribute(e=""){var t;this.attributeConfigurable&&(this.defaultAttribute=e,this.changeStyle(this.defaultAttribute),this.setLineAttribute("attribute",e),this.selectedIDs.length>0&&((t=this.history)==null||t.pushHistory(this.lineList)),this.emit("changeAttributeSidebar"))}getCurrentSelectedData(){var e,t;const i=this.isActiveLineValid(),s=this.defaultAttribute,n=this.getColor(s),o=i?n==null?void 0:n.valid.stroke:n==null?void 0:n.invalid.stroke,r=(t=(e=this.lineList.find(h=>h.id===this.selectedID))==null?void 0:e.textAttribute)!=null?t:"";return{color:o,textAttribute:r}}renderTextAttribute(){var e,t,i,s;if(!this.ctx||!this.selectedLine||this.activeLine&&((e=this.activeLine)==null?void 0:e.length)<2)return;const n=this.isActiveLineValid(),o=this.defaultAttribute,{x:r,y:h}=this.selectedLine.pointList[1],l=this.coordUtils.getRenderCoord({x:r,y:h}),a=this.getColor(o),c=n?a==null?void 0:a.valid.stroke:a==null?void 0:a.invalid.stroke,f=(i=(t=this.lineList.find(b=>b.id===this.selectedID))==null?void 0:t.textAttribute)!=null?i:"";this._textAttributeInstance||(this._textAttributeInstance=new $({container:this.container,icon:this.getTextIconSvg(o),color:c,getCurrentSelectedData:this.getCurrentSelectedData,updateSelectedTextAttribute:this.updateSelectedTextAttribute})),this._textAttributeInstance&&!((s=this._textAttributeInstance)==null?void 0:s.isExit)&&this._textAttributeInstance.appendToContainer(),this._textAttributeInstance.update(`${f}`,{left:l.x,top:l.y,color:c}),this._textAttributeInstance.updateIcon(this.getTextIconSvg(o))}getTextIconSvg(e=""){return y.getTextIconSvg(e,this.config.attributeList,this.config.attributeConfigurable,this.baseIcon)}updateSelectedTextAttribute(e){if(this._textAttributeInstance&&e&&this.selectedID){let t=e;!y.textAttributeValidate(this.config.textCheckType,"",t)&&(this.emit("messageError",y.getErrorNotice(this.config.textCheckType,this.lang)),t=""),this.setTextAttribute(t),this.emit("updateTextAttribute"),this.render()}}}export{H as INNER_POINT_RADIUS,C as LINE_ORDER_OFFSET,m as POINT_ACTIVE_RADIUS,x as POINT_RADIUS,p as SEGMENT_NUMBER,et as default};
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{RectOperation}from"./core/toolOperation/rectOperation.js";export{default as TagOperation}from"./core/toolOperation/tagOperation.js";export{default as PointOperation}from"./core/toolOperation/pointOperation.js";export{default as LineToolOperation}from"./core/toolOperation/LineToolOperation.js";export{default as TextToolOperation}from"./core/toolOperation/TextToolOperation.js";export{default as PolygonOperation}from"./core/toolOperation/polygonOperation.js";export{default as MeasureOperation}from"./core/toolOperation/measureOperation.js";export{default as PointCloud2DRectOperation}from"./core/toolOperation/pointCloud2DRectOperation.js";export{BasicToolOperation}from"./core/toolOperation/basicToolOperation.js";export{default as ViewOperation}from"./core/toolOperation/ViewOperation.js";export{default as ScribbleTool}from"./core/toolOperation/ScribbleTool.js";export{default as PointCloud2dOperation}from"./core/toolOperation/pointCloud2dOperation.js";import*as t from"./constant/annotation.js";export{t as cAnnotation};import*as e from"./constant/annotationTask.js";export{e as cAnnotationTask};import*as r from"./constant/keyCode.js";export{r as cKeyCode};import*as a from"./constant/style.js";export{a as cStyle};import*as i from"./constant/tool.js";export{i as cTool};export{CLIENT_TOOL_HEAD_TYPE,CLIENT_TOOL_NAME,DEFAULT_FONT,DEFAULT_TEXT_MAX_WIDTH,EAnnotationMode,EAuditStatus,ECheckModel,EDependPattern,EDragTarget,EDrawPointPattern,EFilterToolOperation,ELineColor,ELineTypes,EOperationMode,EPageOperator,EPointCloudName,EPolygonPattern,ERectPattern,EScribblePattern,ESelectedType,ETextType,EThumbnailOption,EToolName,EToolType,EVideoToolName,OPERATION_LIST,SEGMENT_NUMBER,TEXT_ATTRIBUTE_LINE_HEIGHT,TEXT_ATTRIBUTE_MAX_LENGTH,TEXT_TYPE,TOOL_NAME,TOOL_NAME_EN,edgeAdsorptionScope,editStepWidth}from"./constant/tool.js";export{default as TagUtils}from"./utils/tool/TagUtils.js";export{default as uuid}from"./utils/uuid.js";import o from"./utils/tool/EnhanceCommonToolUtils.js";export{default as MarkerUtils}from"./utils/tool/MarkerUtils.js";export{default as RectUtils}from"./utils/tool/RectUtils.js";export{default as AxisUtils}from"./utils/tool/AxisUtils.js";export{default as DrawUtils}from"./utils/tool/DrawUtils.js";export{default as ImgUtils}from"./utils/ImgUtils.js";export{default as MathUtils}from"./utils/MathUtils.js";export{default as AttributeUtils}from"./utils/tool/AttributeUtils.js";export{default as ActionsHistory}from"./utils/ActionsHistory.js";export{default as DblClickEventListener}from"./utils/tool/DblClickEventListener.js";export{default as AnnotationEngine}from"./core/index.js";export{default as UnitUtils}from"./utils/tool/UnitUtils.js";export{default as StyleUtils}from"./utils/tool/StyleUtils.js";export{CanvasScheduler}from"./newCore/CanvasScheduler.js";export{PointCloud}from"./core/pointCloud/index.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,getHighlightIndexByPoints,isInImage,lidar2image,mergeHighlightList,point2dTo3D,point3DLidar2Image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./core/pointCloud/matrix.js";export{PointCloudAnnotation}from"./core/pointCloud/annotation.js";const s=o,l=o;export{s as CommonToolUtils,l as toolUtils};
|
|
1
|
+
export{RectOperation}from"./core/toolOperation/rectOperation.js";export{default as TagOperation}from"./core/toolOperation/tagOperation.js";export{default as PointOperation}from"./core/toolOperation/pointOperation.js";export{default as LineToolOperation}from"./core/toolOperation/LineToolOperation.js";export{default as TextToolOperation}from"./core/toolOperation/TextToolOperation.js";export{default as PolygonOperation}from"./core/toolOperation/polygonOperation.js";export{default as MeasureOperation}from"./core/toolOperation/measureOperation.js";export{default as PointCloud2DRectOperation}from"./core/toolOperation/pointCloud2DRectOperation.js";export{BasicToolOperation}from"./core/toolOperation/basicToolOperation.js";export{default as ViewOperation}from"./core/toolOperation/ViewOperation.js";export{default as ScribbleTool}from"./core/toolOperation/ScribbleTool.js";export{default as PointCloud2dOperation}from"./core/toolOperation/pointCloud2dOperation.js";import*as t from"./constant/annotation.js";export{t as cAnnotation};import*as e from"./constant/annotationTask.js";export{e as cAnnotationTask};import*as r from"./constant/keyCode.js";export{r as cKeyCode};import*as a from"./constant/style.js";export{a as cStyle};import*as i from"./constant/tool.js";export{i as cTool};export{CLIENT_TOOL_HEAD_TYPE,CLIENT_TOOL_NAME,DEFAULT_FONT,DEFAULT_TEXT_MAX_WIDTH,EAnnotationMode,EAudioToolName,EAuditStatus,ECheckModel,EDependPattern,EDragTarget,EDrawPointPattern,EFilterToolOperation,ELineColor,ELineTypes,EOperationMode,EPageOperator,EPointCloudName,EPolygonPattern,ERectPattern,EScribblePattern,ESelectedType,ETextType,EThumbnailOption,EToolName,EToolType,EVideoToolName,OPERATION_LIST,SEGMENT_NUMBER,TEXT_ATTRIBUTE_LINE_HEIGHT,TEXT_ATTRIBUTE_MAX_LENGTH,TEXT_TYPE,TOOL_NAME,TOOL_NAME_EN,edgeAdsorptionScope,editStepWidth}from"./constant/tool.js";export{default as TagUtils}from"./utils/tool/TagUtils.js";export{default as uuid}from"./utils/uuid.js";import o from"./utils/tool/EnhanceCommonToolUtils.js";export{default as MarkerUtils}from"./utils/tool/MarkerUtils.js";export{default as RectUtils}from"./utils/tool/RectUtils.js";export{default as AxisUtils}from"./utils/tool/AxisUtils.js";export{default as DrawUtils}from"./utils/tool/DrawUtils.js";export{default as ImgUtils}from"./utils/ImgUtils.js";export{default as MathUtils}from"./utils/MathUtils.js";export{default as AttributeUtils}from"./utils/tool/AttributeUtils.js";export{default as ActionsHistory}from"./utils/ActionsHistory.js";export{default as EventBus}from"./utils/EventBus.js";export{default as DblClickEventListener}from"./utils/tool/DblClickEventListener.js";export{default as AnnotationEngine}from"./core/index.js";export{default as UnitUtils}from"./utils/tool/UnitUtils.js";export{default as StyleUtils}from"./utils/tool/StyleUtils.js";export{CanvasScheduler}from"./newCore/CanvasScheduler.js";export{PointCloud}from"./core/pointCloud/index.js";export{createThreeMatrix4,getCuboidFromPointCloudBox,getHighlightIndexByPoints,isInImage,lidar2image,mergeHighlightList,point2dTo3D,point3DLidar2Image,pointCloudLidar2image,rotatePoint,transferKitti2Matrix}from"./core/pointCloud/matrix.js";export{PointCloudAnnotation}from"./core/pointCloud/annotation.js";const s=o,l=o;export{s as CommonToolUtils,l as toolUtils};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class i{constructor(){this._events=new Map}on(t,e){const s=this._events.get(t)||[];s.some(n=>n===e)||this._events.set(t,s.concat(e))}singleOn(t,e){this._events.set(t,[e])}emit(t,...e){const s=this._events.get(t);s&&s.forEach(n=>{n&&n(...e)})}unbind(t,e){const s=this._events.get(t);s&&this._events.set(t,s.filter(n=>n!==e))}unbindAll(t){this._events.delete(t)}}var v=new i;export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isObject as
|
|
1
|
+
import{isObject as y}from"lodash";import{EStepType as p,ESortDirection as c}from"../../constant/annotation.js";import f from"../../constant/keyCode.js";var _=Object.defineProperty,O=Object.defineProperties,I=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable,S=(o,t,e)=>t in o?_(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,d=(o,t)=>{for(var e in t||(t={}))P.call(t,e)&&S(o,e,t[e]);if(g)for(var e of g(t))E.call(t,e)&&S(o,e,t[e]);return o},h=(o,t)=>O(o,I(t));class v{static getStepInfo(t,e){return e==null?void 0:e.filter(r=>r.step===t)[0]}static getCurrentStepInfo(t,e){const r=this.getStepInfo(t,e);return r&&(r.type===p.QUALITY_INSPECTION||r.type===p.MANUAL_CORRECTION)?this.getCurrentStepInfo(r.dataSourceStep,e):r}static getCurrentStepToolAndConfig(t,e){const r=this.getStepInfo(t,e);if(r){const n=this.getCurrentStepInfo(t,e);return h(d({},r),{tool:n.tool,config:n.config})}return!1}static getMaxOrder(t){let e=0;return t.forEach(r=>{r.order&&r.order>e&&(e=r.order)}),e}static hotkeyFilter(t){const e=t.target||t.srcElement;if(!e)return!0;const{tagName:r,type:n}=e;if(!r||!n)return!0;let i=!0;return(e.isContentEditable||r==="TEXTAREA"||(r==="INPUT"&&n!=="radio"||r==="TEXTAREA")&&!e.readOnly)&&(i=!1),i}static isMoveKey(t){return[f.Left,f.Right,f.Down,f.Up,f.Space].includes(t)}static getNextSelectedRectID(t,e=c.ascend,r){let n=1;e===c.descend&&(n=-1);const i=t.sort((l,u)=>l.x-u.x==0?l.y-u.y:n*(l.x-u.x)),a=i.findIndex(l=>l.id===r),s=i.length;return i[(a+1)%s]}static getNextSelectedRectIDByEvent(t,e,r){const n=e.shiftKey?c.descend:c.ascend;return this.getNextSelectedRectID(t,n,r)}static getRenderResultList(t,e,r=[],n){const i=[];return[t.filter(s=>n&&n.includes(s.id)?(i.push(s),!1):!(r.length>0&&!r.includes(s==null?void 0:s.attribute)||this.isDifferSourceID(s==null?void 0:s.sourceID,e))),i]}static getSourceID(t){var e;const r="";return t&&(e=t==null?void 0:t.id)!=null?e:r}static findAllLine(t,e=!0){const r=[],n=[...t];n.length>=3&&e===!0&&n.push(d({},n[0]));for(let i=0;i<n.length;i++)n[i+1]&&r.push({point1:n[i],point2:n[i+1],pointIndex:i});return r}static translateSourceID(t){return(t===void 0||t===0||t==="0")&&(t=""),t}static isDifferSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`!=`${e}`}static isSameSourceID(t,e){return t=this.translateSourceID(t),e=this.translateSourceID(e),`${t}`==`${e}`}static getNextMarker(t,e=[],r){if((e==null?void 0:e.length)===0)return;let n=e.map((i,a)=>h(d({},i),{index:a}));if(typeof r=="number"&&r>0){const i=e[r];if(i&&t.every(a=>a.label!==i.value))return{label:i.value,index:r};n=[...n.slice(r,e.length),...n.slice(0,r)]}for(let i=0;i<n.length;i++)if(!t.some(a=>a.label===n[i].value))return{label:n[i].value,index:n[i].index}}static getCurrentMarkerIndex(t,e=[]){return e.findIndex(r=>t===r.value)}}v.jsonParser=(o,t={})=>{try{return typeof o=="string"?JSON.parse(o):y(o)?o:t}catch(e){return t}};export{v as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-annotation",
|
|
3
|
-
"version": "1.19.0-alpha.
|
|
3
|
+
"version": "1.19.0-alpha.3",
|
|
4
4
|
"description": "Annotation tool collection",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotation",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"typescript": "^4.2.3"
|
|
95
95
|
},
|
|
96
96
|
"dependencies": {
|
|
97
|
-
"@labelbee/lb-utils": "1.12.0-alpha.
|
|
97
|
+
"@labelbee/lb-utils": "1.12.0-alpha.2",
|
|
98
98
|
"@turf/turf": "5.1.6",
|
|
99
99
|
"color-rgba": "^2.3.0",
|
|
100
100
|
"lodash": "^4.17.20",
|