@labelbee/lb-components 1.16.0-alpha.4 → 1.16.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var React=require("react"),index$3=require("../audioPlayer/index.js"),dom=require("../../utils/dom.js"),index$4=require("../predictTracking/previewResult/index.js"),es=require("antd/es"),antd=require("antd"),index$5=require("../../constant/index.js"),lbAnnotation=require("@labelbee/lb-annotation"),index_module=require("./index.module.scss.js"),index$2=require("./tagResultShow/index.js"),index$1=require("./audioContext/index.js"),index$6=require("./textInput/index.js"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),index=require("../../utils/index.js"),annotation=require("../../hooks/annotation.js"),index$7=require("../../views/MainView/sidebar/index.js"),index$8=require("./audioSide/labelSidebar/index.js"),index$9=require("./audioSide/clipSidebar/index.js"),tag=require("../../assets/annotation/audio/tag.svg.js"),tagA=require("../../assets/annotation/audio/tagA.svg.js"),clip=require("../../assets/annotation/audio/clip.svg.js"),clipA=require("../../assets/annotation/audio/clipA.svg.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,n,l)=>n in e?__defProp(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,__spreadValues=(e,n)=>{for(var l in n||(n={}))__hasOwnProp.call(n,l)&&__defNormalProp(e,l,n[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(n))__propIsEnum.call(n,l)&&__defNormalProp(e,l,n[l]);return e},__spreadProps=(e,n)=>__defProps(e,__getOwnPropDescs(n));const{EAudioToolName}=lbAnnotation.cTool,EKeyCode=lbAnnotation.cKeyCode.default,{Sider,Content}=es.Layout,layoutCls=`${index$5.prefix}-layout`,ToggleAudioOption=({setSideTab:e,sideTab:n})=>{const l=[{tab:"tag",commonSvg:tag,selectedSvg:tagA},{tab:"clip",commonSvg:clip,selectedSvg:clipA}];return React__default.default.createElement("div",{className:index_module.toggleAudioOption},l.map((f,p)=>{const{tab:s,selectedSvg:m,commonSvg:S}=f;return React__default.default.createElement("div",{key:p,className:index_module.option},React__default.default.createElement("img",{className:index_module.icon,src:n===s?m:S,onClick:()=>{n!==s&&e(s)}}))}))},AudioTextToolTextarea=({result:e,inputDisabled:n,updateText:l,configList:f,autofocus:p,preContext:s,isCheck:m,clipAttributeConfigurable:S,clipTextConfigurable:R,textConfigurable:v,updateRegion:b,clipAttributeList:u})=>React__default.default.createElement("div",{className:index_module.textareaContainer},React__default.default.createElement("div",{className:index_module.textareaContent},React__default.default.createElement(index$6.default,{isCheck:m,result:e==null?void 0:e.value,textInputDisabled:n,textID:(e==null?void 0:e.id)||0,updateText:l,configList:f,autofocus:!n&&p,preContext:s,regions:e==null?void 0:e.regions,clipAttributeConfigurable:S,clipTextConfigurable:R,textConfigurable:v,updateRegion:b,clipAttributeList:u}))),AudioSideBar=e=>{var n,l;const{sider:f,config:p,result:s,updateTagResult:m,updateRegion:S,isEdit:R,tagConfigurable:v,clipConfigurable:b}=e;let u=(p==null?void 0:p.inputList)||[],o=(n=s==null?void 0:s.tag)!=null?n:{},U=(l=s==null?void 0:s.regions)!=null?l:[];const[k,x]=React.useState([]),[y,E]=React.useState("tag");React.useEffect(()=>{if(!v&&b){E("clip");return}E("tag")},[v,b]),React.useEffect(()=>(window.addEventListener("keydown",j),()=>{window.removeEventListener("keydown",j)}));const j=i=>{if(v&&b)switch(i.keyCode){case EKeyCode.L:E("tag");break;case EKeyCode.X:E("clip");break}if(y==="tag"){if(!lbAnnotation.CommonToolUtils.hotkeyFilter(i))return;lbAnnotation.CommonToolUtils.isMoveKey(i==null?void 0:i.keyCode)&&i.preventDefault();let t=i.keyCode;if(t&&(t<=57&&t>=49||t<=105&&t>=97)){t>57?t=t-97:t=t-49;const d=k.slice();u.length===1?(O(0,t),x([0,t]),setTimeout(()=>{x([])},500)):d.length===1?(O(d[0],t),x([d[0],t]),setTimeout(()=>{x([])},500)):x([t])}}},O=(i,t)=>{if(i<u.length&&u[i].subSelected&&t<u[i].subSelected.length){const d=u[i].value,V=u[i].isMulti;let C=u[i].subSelected[t].value,w=0;const A=o;for(const _ in o)if(_===u[i].value){if(w++,V===!0){const P=A[_].split(";").filter(D=>D!==""),I=P.indexOf(C);I===-1?P.push(C):P.splice(I,1),C=P.join(";")}C===""?delete A[_]:A[_]=C}w===0&&Object.assign(o,{[d]:C}),m(o)}},h=i=>{delete o[i],m(o)},q=v&&b&&React__default.default.createElement(ToggleAudioOption,{setSideTab:E,sideTab:y}),N=y==="tag"&&React__default.default.createElement(index$8.default,{labelInfoSet:v?u:[],labelSelectedList:k,setLabel:O,tagResult:o,clearResult:h,isEdit:R,withPanelTab:!1}),L=y==="clip"&&React__default.default.createElement(index$9,{regions:U,updateRegion:S,useAudioClipStore:index$1.useAudioClipStore});return f?typeof f=="function"?React__default.default.createElement("div",{className:`${index$7.sidebarCls}`},f({toggleAudioOption:q,labelSidebar:N,clipSidebar:L})):f:React__default.default.createElement("div",{className:`${index$7.sidebarCls}`},React__default.default.createElement("div",{className:`${index$7.sidebarCls}__content`},q,N,L))},AudioAnnotate=e=>{var n,l,f,p,s,m,S,R;const v=(l=(n=e.style)==null?void 0:n.sider)==null?void 0:l.width,{step:b,stepList:u,audioContext:o,sider:U,drawLayerSlot:k,imgList:x,imgIndex:y,currentData:E,config:j,stepInfo:O}=e,h=lbAnnotation.CommonToolUtils.getCurrentStepToolAndConfig(b,u),q=index.jsonParser(E.result),{toolInstanceRef:N}=annotation.useCustomToolInstance({basicInfo:q}),[L,i]=React.useState(!0),[t,d]=React.useState(null),[V,C]=React.useState(!1);React.useEffect(()=>{i(!0),C(!0)},[y]),React.useEffect(()=>{L===!1&&Y()},[L]),React.useEffect(()=>{N.current.exportData=()=>[[t],{}],N.current.clearResult=le},[t]);const w=React.useMemo(()=>{const a=q[`step_${b}`];return(a==null?void 0:a.result)||[]},[j,q]),{tagConfigurable:A,textConfigurable:_=!0,clipConfigurable:P=!1,clipAttributeConfigurable:I=!1,clipAttributeList:D=[],clipTextConfigurable:M=!1,inputList:X=[],configList:z=[]}=React.useMemo(()=>{if(h)return lbAnnotation.CommonToolUtils.jsonParser(h==null?void 0:h.config)},[h]),G={clipConfigurable:P,clipAttributeConfigurable:I,clipAttributeList:D,clipTextConfigurable:M},K=o?o==null?void 0:o.valid:!0,H=(p=(f=lbAnnotation.CommonToolUtils.jsonParser(E.result))==null?void 0:f.duration)!=null?p:0,J=K?H:0,Q=!K||L||![_,M].includes(!0);let F={};if(y!==-1&&(x==null?void 0:x.length)){const a=(s=x[y])==null?void 0:s.preResult,r=(o==null?void 0:o.isEdit)?o==null?void 0:o.stepConfig.loadPreStep:O.loadPreStep;if(a&&r){const c=lbAnnotation.CommonToolUtils.jsonParser(a),g=(S=(m=c==null?void 0:c.config)==null?void 0:m.context)!=null?S:{};Object.keys(g).forEach(T=>{T&&g[T]&&(F[T]={visible:!0,content:g[T],type:T})})}}const Y=()=>{(w==null?void 0:w.length)>0?d(w[0]):d({id:lbAnnotation.uuid(),sourceID:"",value:W(),tag:Z(),regions:[]})},W=(a=!0)=>{const r={};let c=j.configList||[];return c.length>0&&c.forEach(g=>{r[g.key]=a&&g.default||""}),r},Z=()=>lbAnnotation.TagUtils.getDefaultResultByConfig(j.inputList||[]),ee=({duration:a,hasError:r})=>{console.log("onloaded"),i(!1)},te=a=>{d(r=>__spreadProps(__spreadValues({},r),{regions:((r==null?void 0:r.regions)||[]).filter(c=>c.id!==a)}))},B=a=>{d(r=>{var c;const g=(c=r==null?void 0:r.regions)!=null?c:[],{id:T}=a;return g.find($=>$.id===T)?__spreadProps(__spreadValues({},r),{regions:g.map($=>T===$.id?__spreadValues(__spreadValues({},$),a):$)}):__spreadProps(__spreadValues({},r),{regions:[...g,a]})})},ne=(a,r)=>{d(c=>__spreadProps(__spreadValues({},c),{value:__spreadProps(__spreadValues({},c.value),{[r]:a})}))},oe=a=>{d(r=>__spreadProps(__spreadValues({},r),{tag:a}))},le=()=>{d(a=>__spreadProps(__spreadValues({},a),{value:W(),tag:{},regions:[]}))};return React__default.default.createElement(index$1.AudioClipProvider,null,React__default.default.createElement(antd.Spin,{spinning:L,wrapperClassName:"audio-tool-spinner"},React__default.default.createElement(es.Layout,{className:dom.getClassName("layout","container"),style:{height:"100%"}},e==null?void 0:e.leftSider,React__default.default.createElement(Content,{className:`${layoutCls}__content`},React__default.default.createElement("div",{className:index_module.containerWrapper},React__default.default.createElement("div",{className:index_module.audioWrapper},A&&React__default.default.createElement(index$2,{result:t==null?void 0:t.tag,labelInfoSet:X,hasPromptLayer:!!(o==null?void 0:o.promptLayer)}),o==null?void 0:o.promptLayer,React__default.default.createElement(index$3.AudioPlayer,__spreadValues({context:{isEdit:o==null?void 0:o.isEdit,count:J,toolName:EAudioToolName.AudioTextTool,imgIndex:y},drawLayerSlot:k,fileData:E,onLoaded:ee,invalid:!K,updateRegion:B,removeRegion:te,regions:t==null?void 0:t.regions,activeToolPanel:o==null?void 0:o.activeToolPanel,footer:e.footer},G))),(_||M)&&React__default.default.createElement(AudioTextToolTextarea,{preContext:F,result:t,inputDisabled:Q,updateText:ne,updateRegion:B,configList:z,autofocus:V,textConfigurable:_,clipTextConfigurable:M,clipAttributeList:D,clipAttributeConfigurable:I}))),React__default.default.createElement(Sider,{className:`${layoutCls}__side`,width:v!=null?v:240,style:(R=e.style)==null?void 0:R.sider},React__default.default.createElement(AudioSideBar,{sider:U,config:j,result:t,updateTagResult:oe,updateRegion:B,isEdit:o==null?void 0:o.isEdit,tagConfigurable:A,clipConfigurable:P})),React__default.default.createElement(index$4,null))))};var AudioAnnotate$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(AudioAnnotate);module.exports=AudioAnnotate$1;
1
+ "use strict";var React=require("react"),index$3=require("../audioPlayer/index.js"),dom=require("../../utils/dom.js"),index$4=require("../predictTracking/previewResult/index.js"),es=require("antd/es"),antd=require("antd"),index$5=require("../../constant/index.js"),lbAnnotation=require("@labelbee/lb-annotation"),index_module=require("./index.module.scss.js"),index$2=require("./tagResultShow/index.js"),index$1=require("./audioContext/index.js"),index$6=require("./textInput/index.js"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),index=require("../../utils/index.js"),annotation=require("../../hooks/annotation.js"),index$7=require("../../views/MainView/sidebar/index.js"),index$8=require("./audioSide/labelSidebar/index.js"),index$9=require("./audioSide/clipSidebar/index.js"),tag=require("../../assets/annotation/audio/tag.svg.js"),tagA=require("../../assets/annotation/audio/tagA.svg.js"),clip=require("../../assets/annotation/audio/clip.svg.js"),clipA=require("../../assets/annotation/audio/clipA.svg.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,n,a)=>n in e?__defProp(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a,__spreadValues=(e,n)=>{for(var a in n||(n={}))__hasOwnProp.call(n,a)&&__defNormalProp(e,a,n[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(n))__propIsEnum.call(n,a)&&__defNormalProp(e,a,n[a]);return e},__spreadProps=(e,n)=>__defProps(e,__getOwnPropDescs(n));const{EAudioToolName}=lbAnnotation.cTool,EKeyCode=lbAnnotation.cKeyCode.default,{Sider,Content}=es.Layout,layoutCls=`${index$5.prefix}-layout`,ToggleAudioOption=({setSideTab:e,sideTab:n})=>{const a=[{tab:"tag",commonSvg:tag,selectedSvg:tagA},{tab:"clip",commonSvg:clip,selectedSvg:clipA}];return React__default.default.createElement("div",{className:index_module.toggleAudioOption},a.map((f,p)=>{const{tab:u,selectedSvg:m,commonSvg:S}=f;return React__default.default.createElement("div",{key:p,className:index_module.option},React__default.default.createElement("img",{className:index_module.icon,src:n===u?m:S,onClick:()=>{n!==u&&e(u)}}))}))},AudioTextToolTextarea=({result:e,inputDisabled:n,updateText:a,configList:f,autofocus:p,preContext:u,isCheck:m,clipAttributeConfigurable:S,clipTextConfigurable:P,textConfigurable:v,updateRegion:b,clipAttributeList:d})=>React__default.default.createElement("div",{className:index_module.textareaContainer},React__default.default.createElement("div",{className:index_module.textareaContent},React__default.default.createElement(index$6.default,{isCheck:m,result:e==null?void 0:e.value,textInputDisabled:n,textID:(e==null?void 0:e.id)||0,updateText:a,configList:f,autofocus:!n&&p,preContext:u,regions:e==null?void 0:e.regions,clipAttributeConfigurable:S,clipTextConfigurable:P,textConfigurable:v,updateRegion:b,clipAttributeList:d}))),AudioSideBar=e=>{var n,a;const{sider:f,config:p,result:u,updateTagResult:m,updateRegion:S,isEdit:P,tagConfigurable:v,clipConfigurable:b}=e;let d=(p==null?void 0:p.inputList)||[],o=(n=u==null?void 0:u.tag)!=null?n:{},U=(a=u==null?void 0:u.regions)!=null?a:[];const[k,x]=React.useState([]),[y,E]=React.useState("tag");React.useEffect(()=>{if(!v&&b){E("clip");return}E("tag")},[v,b]),React.useEffect(()=>(window.addEventListener("keydown",j),()=>{window.removeEventListener("keydown",j)}));const j=i=>{if(v&&b)switch(i.keyCode){case EKeyCode.L:E("tag");break;case EKeyCode.X:E("clip");break}if(y==="tag"){if(!lbAnnotation.CommonToolUtils.hotkeyFilter(i))return;lbAnnotation.CommonToolUtils.isMoveKey(i==null?void 0:i.keyCode)&&i.preventDefault();let t=i.keyCode;if(t&&(t<=57&&t>=49||t<=105&&t>=97)){t>57?t=t-97:t=t-49;const s=k.slice();d.length===1?(N(0,t),x([0,t]),setTimeout(()=>{x([])},500)):s.length===1?(N(s[0],t),x([s[0],t]),setTimeout(()=>{x([])},500)):x([t])}}},N=(i,t)=>{if(i<d.length&&d[i].subSelected&&t<d[i].subSelected.length){const s=d[i].value,V=d[i].isMulti;let C=d[i].subSelected[t].value,A=0;const O=o;for(const _ in o)if(_===d[i].value){if(A++,V===!0){const L=O[_].split(";").filter(D=>D!==""),I=L.indexOf(C);I===-1?L.push(C):L.splice(I,1),C=L.join(";")}C===""?delete O[_]:O[_]=C}A===0&&Object.assign(o,{[s]:C}),m(o)}},h=i=>{delete o[i],m(o)},q=v&&b&&React__default.default.createElement(ToggleAudioOption,{setSideTab:E,sideTab:y}),w=y==="tag"&&React__default.default.createElement(index$8.default,{labelInfoSet:v?d:[],labelSelectedList:k,setLabel:N,tagResult:o,clearResult:h,isEdit:P,withPanelTab:!1}),R=y==="clip"&&React__default.default.createElement(index$9,{regions:U,updateRegion:S,useAudioClipStore:index$1.useAudioClipStore});return f?typeof f=="function"?React__default.default.createElement("div",{className:`${index$7.sidebarCls}`},f({toggleAudioOption:q,labelSidebar:w,clipSidebar:R})):f:React__default.default.createElement("div",{className:`${index$7.sidebarCls}`},React__default.default.createElement("div",{className:`${index$7.sidebarCls}__content`},q,w,R))},AudioAnnotate=e=>{var n,a,f,p,u,m,S,P;const v=(a=(n=e.style)==null?void 0:n.sider)==null?void 0:a.width,{step:b,stepList:d,audioContext:o,sider:U,drawLayerSlot:k,imgList:x,imgIndex:y,currentData:E,config:j,stepInfo:N}=e,h=lbAnnotation.CommonToolUtils.getCurrentStepToolAndConfig(b,d),q=index.jsonParser(E.result),{toolInstanceRef:w}=annotation.useCustomToolInstance({basicInfo:q}),[R,i]=React.useState(!0),[t,s]=React.useState(null),[V,C]=React.useState(!1);React.useEffect(()=>{i(!0),C(!0)},[y]),React.useEffect(()=>{R===!1&&Y()},[R]),React.useEffect(()=>{w.current.exportData=()=>[[t],{}],w.current.setResult=le,w.current.clearResult=ae},[t]);const A=React.useMemo(()=>{const l=q[`step_${b}`];return(l==null?void 0:l.result)||[]},[j,q]),{tagConfigurable:O,textConfigurable:_=!0,clipConfigurable:L=!1,clipAttributeConfigurable:I=!1,clipAttributeList:D=[],clipTextConfigurable:M=!1,inputList:X=[],configList:z=[]}=React.useMemo(()=>{if(h)return lbAnnotation.CommonToolUtils.jsonParser(h==null?void 0:h.config)},[h]),G={clipConfigurable:L,clipAttributeConfigurable:I,clipAttributeList:D,clipTextConfigurable:M},K=o?o==null?void 0:o.valid:!0,H=(p=(f=lbAnnotation.CommonToolUtils.jsonParser(E.result))==null?void 0:f.duration)!=null?p:0,J=K?H:0,Q=!K||R||![_,M].includes(!0);let F={};if(y!==-1&&(x==null?void 0:x.length)){const l=(u=x[y])==null?void 0:u.preResult,r=(o==null?void 0:o.isEdit)?o==null?void 0:o.stepConfig.loadPreStep:N.loadPreStep;if(l&&r){const c=lbAnnotation.CommonToolUtils.jsonParser(l),g=(S=(m=c==null?void 0:c.config)==null?void 0:m.context)!=null?S:{};Object.keys(g).forEach(T=>{T&&g[T]&&(F[T]={visible:!0,content:g[T],type:T})})}}const Y=()=>{(A==null?void 0:A.length)>0?s(A[0]):s({id:lbAnnotation.uuid(),sourceID:"",value:W(),tag:Z(),regions:[]})},W=(l=!0)=>{const r={};let c=j.configList||[];return c.length>0&&c.forEach(g=>{r[g.key]=l&&g.default||""}),r},Z=()=>lbAnnotation.TagUtils.getDefaultResultByConfig(j.inputList||[]),ee=({duration:l,hasError:r})=>{i(!1)},te=l=>{s(r=>__spreadProps(__spreadValues({},r),{regions:((r==null?void 0:r.regions)||[]).filter(c=>c.id!==l)}))},B=l=>{s(r=>{var c;const g=(c=r==null?void 0:r.regions)!=null?c:[],{id:T}=l;return g.find($=>$.id===T)?__spreadProps(__spreadValues({},r),{regions:g.map($=>T===$.id?__spreadValues(__spreadValues({},$),l):$)}):__spreadProps(__spreadValues({},r),{regions:[...g,l]})})},ne=(l,r)=>{s(c=>__spreadProps(__spreadValues({},c),{value:__spreadProps(__spreadValues({},c.value),{[r]:l})}))},oe=l=>{s(r=>__spreadProps(__spreadValues({},r),{tag:l}))},le=l=>{s(l)},ae=()=>{s(l=>__spreadProps(__spreadValues({},l),{value:W(),tag:{},regions:[]}))};return React__default.default.createElement(index$1.AudioClipProvider,null,React__default.default.createElement(antd.Spin,{spinning:R,wrapperClassName:"audio-tool-spinner"},React__default.default.createElement(es.Layout,{className:dom.getClassName("layout","container"),style:{height:"100%"}},e==null?void 0:e.leftSider,React__default.default.createElement(Content,{className:`${layoutCls}__content`},React__default.default.createElement("div",{className:index_module.containerWrapper},React__default.default.createElement("div",{className:index_module.audioWrapper},O&&React__default.default.createElement(index$2,{result:t==null?void 0:t.tag,labelInfoSet:X,hasPromptLayer:!!(o==null?void 0:o.promptLayer)}),o==null?void 0:o.promptLayer,React__default.default.createElement(index$3.AudioPlayer,__spreadValues({context:{isEdit:o==null?void 0:o.isEdit,count:J,toolName:EAudioToolName.AudioTextTool,imgIndex:y},drawLayerSlot:k,fileData:E,onLoaded:ee,invalid:!K,updateRegion:B,removeRegion:te,regions:t==null?void 0:t.regions,activeToolPanel:o==null?void 0:o.activeToolPanel,footer:e.footer},G))),(_||M)&&React__default.default.createElement(AudioTextToolTextarea,{preContext:F,result:t,inputDisabled:Q,updateText:ne,updateRegion:B,configList:z,autofocus:V,textConfigurable:_,clipTextConfigurable:M,clipAttributeList:D,clipAttributeConfigurable:I}))),React__default.default.createElement(Sider,{className:`${layoutCls}__side`,width:v!=null?v:240,style:(P=e.style)==null?void 0:P.sider},React__default.default.createElement(AudioSideBar,{sider:U,config:j,result:t,updateTagResult:oe,updateRegion:B,isEdit:o==null?void 0:o.isEdit,tagConfigurable:O,clipConfigurable:L})),React__default.default.createElement(index$4,null))))};var AudioAnnotate$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(AudioAnnotate);module.exports=AudioAnnotate$1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,i)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,__spreadValues=(e,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(e,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(e,i,t[i]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,i)=>new Promise((a,o)=>{var d=u=>{try{c(i.next(u))}catch(h){o(h)}},P=u=>{try{c(i.throw(u))}catch(h){o(h)}},c=u=>u.done?a(u.value):Promise.resolve(u.value).then(d,P);c((i=i.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,i,a,o)=>{const{x:d,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,u={center:{x:d,y:P,z:c},id:e.id},h=a?__spreadValues(__spreadValues({},a),u):__spreadProps(__spreadValues({},u),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},topViewPolygon2PointCloud=(e,t,i,a,o,d)=>{let P=e.pointList.map(L=>lbUtils.PointCloudUtils.transferCanvas2World(L,t)),c=0,u=1,h={};if(i){const L=i.getSensesPointZAxisInPolygon(P,void 0,d);d&&L.fittedCoordinates.length>0&&(P=L.fittedCoordinates),c=(L.maxZ+L.minZ)/2,u=L.maxZ-L.minZ,h={count:L.zCount}}const[v,b,T]=P,V=lbAnnotation.MathUtils.getLineCenterPoint([v,T]),_=lbAnnotation.MathUtils.getLineLength(v,b),U=lbAnnotation.MathUtils.getLineLength(b,T),z=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(c=a.center.z,u=a.depth);const O={center:{x:V.x,y:V.y,z:c},width:d?U+INTELLIGENT_FIT_MARGIN:U,height:d?_+INTELLIGENT_FIT_MARGIN:_,depth:u,rotation:z,id:e.id},k=__spreadValues(a?__spreadValues(__spreadValues({},a),O):__spreadProps(__spreadValues({},O),{attribute:"",valid:!0}),h);o&&Object.assign(k,o);const A=P.map(L=>lbUtils.PointCloudUtils.transferWorld2Canvas(L,t));return{boxParams:k,newPointList:A}},sideViewPoint2PointCloud=(e,t,i)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-a.x,y:i.center.y,z:i.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,i,a)=>{const[o,d,P]=e.pointList,[c,u,h]=t.pointList,v=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),V={x:{x:v.x-b.x,y:v.y-b.y}.x,y:0,z:v.y-b.y},_=lbAnnotation.MathUtils.getLineLength(o,d),U=lbAnnotation.MathUtils.getLineLength(c,u),z=_-U,O=lbAnnotation.MathUtils.getLineLength(d,P),k=lbAnnotation.MathUtils.getLineLength(u,h),A=O-k,{newBoxParams:L}=a.getNewBoxBySideUpdate(V,A,z,i);return L},backViewPoint2PointCloud=(e,t,i)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-a.x,z:i.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,i,a)=>{const[o,d,P]=e.pointList,[c,u,h]=t.pointList,v=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),V={x:{x:v.x-b.x,y:v.y-b.y}.x,y:0,z:v.y-b.y},_=lbAnnotation.MathUtils.getLineLength(o,d),U=lbAnnotation.MathUtils.getLineLength(c,u),z=_-U,O=lbAnnotation.MathUtils.getLineLength(d,P),k=lbAnnotation.MathUtils.getLineLength(u,h),A=O-k;let{newBoxParams:L}=a.getNewBoxByBackUpdate(V,A,z,i);return L},syncSideViewByPoint=(e,t,i,a,o)=>{var d;if(!i)return;const{toolInstance:P,pointCloudInstance:c}=i;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(u);const{point2d:h,zoom:v}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=v,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(v),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,i,a)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=i;d.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxSidePolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,i,a,o)=>{var d;if(!i)return;const{toolInstance:P,pointCloudInstance:c}=i;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(u);const{point2d:h,zoom:v}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=v,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(v),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,i,a)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=i;d.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxBackPolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,i,a)=>{if(!i||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:d}=i,{point2d:P}=d.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},synchronizeTopView=(e,t,i,a)=>{var o,d;if(!i||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=i,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),h=[...P.polygonList],v=h.find(b=>b.id===t.id);v?(v.pointList=u,v.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(d=e.valid)!=null?d:!0}),P.setResultAndSelectedID(h,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:i,backViewInstance:a,mainViewInstance:o,addPointCloudBox:d,addPointCloudSphere:P,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:h,pointCloudSphereList:v,hideAttributes:b,setHighlight2DDataList:T,cuboidBoxIn2DView:V,imageSizes:_}=e,{addHistory:U,initHistory:z,pushHistoryUnderUpdatePolygon:O,pushHistoryUnderUpdateLine:k}=useHistory.useHistory(),{selectedPolygon:A}=usePolygon.usePolygon(),{getPointCloudSphereByID:L,updatePointCloudSphere:X,selectedSphere:q}=useSphere.useSphere(),{currentData:j,config:m}=ctx.useSelector(n=>{const{stepList:s,step:p,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,s).config)}}),R=ctx.useDispatch(),W=n=>{if(!V){const{mappingImgList:s=[]}=j,p=s.map(r=>index.getRectPointCloudBox({pointCloudBox:n,mappingData:r,imageSizes:_}));Object.assign(n,{rects:p.filter(r=>r!==void 0)})}},{selectedBox:S,updateSelectedBox:ot,updateSelectedBoxes:Z,getPointCloudByID:et}=useSingleBox.useSingleBox({generateRects:W}),{t:nt}=reactI18next.useTranslation(),Y=S==null?void 0:S.info;if(!t||!i||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,it=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},st=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},rt=({newPoint:n,size:s,zoom:p,trackConfigurable:r})=>{var l;const C={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const g=topViewPoint2PointCloud(n,s,G,void 0,C);c(n.id);const f=P(g);H(PointCloudView.Top,n,g,p,f,m),U({newSphereParams:g})},lt=({polygon:n,size:s,imgList:p,trackConfigurable:r,zoom:l,intelligentFit:C})=>{var g,f;const x={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};r===!0&&Object.assign(x,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:v})});const B=t==null?void 0:t.toolInstance,w=__spreadValues({},n);let{boxParams:y,newPointList:D}=topViewPolygon2PointCloud(w,s,G,void 0,x,C);if(y=R(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[y],stepConfig:m,action:"viewUpdateBox"}))[0],(m==null?void 0:m.lowerLimitPointsNumInBox)&&typeof y.count=="number"&&y.count<m.lowerLimitPointsNumInBox){antd.message.info(nt("LowerLimitPointsNumInBox",{num:m.lowerLimitPointsNumInBox})),B.deletePolygon(y.id);return}C&&(D==null?void 0:D.length)&&(w.pointList=D);const I=b.includes(w.attribute);W(y);const N=d(y),Q=(f=e==null?void 0:e.polygonList)!=null?f:[];t==null||t.updatePolygonList(N!=null?N:[],Q),I?c([]):(c(y.id),B.selection.setSelectedIDs(w.id),E({omitView:PointCloudView.Top,polygon:w,boxParams:y,zoom:l,newPointCloudBoxList:N}),C&&synchronizeTopView(y,w,t,o)),U({newBoxParams:y})},at=n=>{const{boxID:s,imageName:p,width:r,height:l,x:C,y:g}=n,f=h.find(x=>x.id===s);if(f==null?void 0:f.rects){const{rects:x=[]}=f,B=x.find(w=>w.imageName===p);if(B){let w=x;const y=__spreadProps(__spreadValues({},B),{width:r,height:l,x:C,y:g});w=x.map(I=>I===B?y:I);const D=__spreadProps(__spreadValues({},f),{rects:w}),M=h.map(I=>I===f?D:I);return t==null||t.updatePolygonList(M!=null?M:[]),M}}},dt=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:r})=>{var l;const C=t==null?void 0:t.toolInstance;if(!(u.length===0||!C)){if(n||(S==null?void 0:S.info)){const g=n!=null?n:S==null?void 0:S.info;(l=C==null?void 0:C.selection)==null||l.setSelectedIDs(u[0]);const f=C.selectedPolygon;if(u.length===1&&g){E({omitView:PointCloudView.Top,polygon:f,boxParams:g,newPointCloudBoxList:s});return}}if((p||q)&&u.length===1){const g=p!=null?p:q;C.setSelectedID(u[0]);const f=C.selectedPoint;g&&H(PointCloudView.Top,f,g,void 0,r,m)}}},J=(n,s,p)=>{if(Y){let r,l;switch(p){case PointCloudView.Back:r=backViewPolygon2PointCloud;break;case PointCloudView.Side:r=sideViewPolygon2PointCloud;break;default:r=sideViewPolygon2PointCloud;break}l=r(n,s,Y,i.pointCloudInstance);const g=R(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:m,action:"viewUpdateBox"}))[0],f=l.valid!==g.valid;if(l=g,o){const{count:B}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:B})}const x=ot(l);return l=x.find(B=>B.id===l.id),E({omitView:f?void 0:p,polygon:n,boxParams:l,newPointCloudBoxList:x}),x}},K=(n,s,p)=>{if(q){let r,l;switch(p){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}l=r(n,s,q);const C=X(l);return H(p,n,l,void 0,C,m),C}},ct=(n,s)=>{K(n,s,PointCloudView.Side)},ut=(n,s)=>{K(n,s,PointCloudView.Back)},pt=(n,s)=>{J(n,s,PointCloudView.Side)},Pt=(n,s)=>{J(n,s,PointCloudView.Back)},Ct=(n,s)=>{k(n)},gt=(n,s)=>{const p=L(n.id),r=topViewPoint2PointCloud(n,s,G,p),l=X(r);H(PointCloudView.Top,n,r,void 0,l,m)},ht=(n,s)=>{if(A){const r=n[0].newPolygon;r.pointList=r.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,s)),O(n[0].newPolygon);return}let p=n.map(({newPolygon:r})=>{const l=et(r.id),{boxParams:C}=topViewPolygon2PointCloud(r,s,t.pointCloudInstance,l);return C});if(p=R(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:p,stepConfig:m,action:"viewUpdateBox"})),p.length===1){const{newPolygon:r}=n[0],l=Z(p);E({polygon:r,boxParams:p[0],newPointCloudBoxList:l})}else{const r=Z(p);r&&e.syncAllViewPointCloudColor(r)}},ft=n=>{var s,p,r,l,C;if(S){const g=Number(n.widthDefault),f=Number(n.depthDefault),x=Number(n.heightDefault),B=S==null?void 0:S.info.trackID,y=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(F=>(F==null?void 0:F.trackID)===B),D={width:(r=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:r.width,height:(C=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:C.height},M=y.pointList.map(F=>lbUtils.PointCloudUtils.transferCanvas2World(F,D)),I=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(M,x,g),N=I[0],Q=I[2],$=lbAnnotation.MathUtils.getLineCenterPoint([N,Q]),xt=S.info.center.z-S.info.depth/2,tt=__spreadProps(__spreadValues({},S.info),{center:{x:$.x,y:$.y,z:xt+f/2},width:g,height:x,depth:f,valid:!0}),vt=Z([tt]);E({omitView:PointCloudView["3D"],polygon:y,boxParams:tt,newPointCloudBoxList:vt})}},H=(n,s,p,r,l,C)=>__async(void 0,null,function*(){const g=j==null?void 0:j.url,f={[PointCloudView.Side]:()=>{syncSideViewByPoint(p,s,i,g,C)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(p,s,a,g,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(p,s,t,o)}};Object.keys(f).forEach(x=>{x!==n&&f[x]()}),r&&(o==null||o.updateCameraZoom(r)),st(p)}),E=n=>__async(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:r,zoom:l,newPointCloudBoxList:C}=n,g=j==null?void 0:j.url;C&&(yield e.syncAllViewPointCloudColor(C));const f={[PointCloudView.Side]:()=>{synchronizeSideView(r,p,i,g)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(r,p,a,g)},[PointCloudView.Top]:()=>{synchronizeTopView(r,p,t,o)}};Object.keys(f).forEach(x=>{x!==s&&f[x]()}),l&&(o==null||o.updateCameraZoom(l)),it(r)});return{topViewAddSphere:rt,topViewAddBox:lt,topViewSelectedChanged:dt,topViewUpdatePoint:gt,sideViewUpdatePoint:ct,backViewUpdatePoint:ut,topViewUpdateBox:ht,topViewUpdateLine:Ct,sideViewUpdateBox:pt,backViewUpdateBox:Pt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=j){var p,r,l,C,g,f;if(!(s==null?void 0:s.url)||!o)return;T([]),actionCreators.SetPointCloudLoading(R,!0),actionCreators.SetLoadPCDFileLoading(R,!0),yield o.loadPCDFile(s.url,(p=m==null?void 0:m.radius)!=null?p:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],B=[],w=[],y=[];o.updateTopCamera();const D=(l=(r=index.jsonParser(s.result))==null?void 0:r.valid)!=null?l:!0;e.setPointCloudValid(D),(C=e.sideViewInstance)==null||C.clearAllData(),(g=e.backViewInstance)==null||g.clearAllData(),t.updateData(s.url,s.result,{radius:(f=m==null?void 0:m.radius)!=null?f:DEFAULT_RADIUS}),s.result&&(x=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),w=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),B=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),y=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),o==null||o.generateBoxes(x),o==null||o.generateSpheres(y),yield e.syncAllViewPointCloudColor(x,[])),z({pointCloudBoxList:x,polygonList:w,lineList:B,pointCloudSphereList:y}),actionCreators.SetPointCloudLoading(R,!1),actionCreators.SetLoadPCDFileLoading(R,!1)}),updateViewsByDefaultSize:ft,generateRects:W,update2DViewRect:at}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,i)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,__spreadValues=(e,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(e,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(e,i,t[i]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,i)=>new Promise((a,o)=>{var d=u=>{try{c(i.next(u))}catch(h){o(h)}},P=u=>{try{c(i.throw(u))}catch(h){o(h)}},c=u=>u.done?a(u.value):Promise.resolve(u.value).then(d,P);c((i=i.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,i,a,o)=>{const{x:d,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,u={center:{x:d,y:P,z:c},id:e.id},h=a?__spreadValues(__spreadValues({},a),u):__spreadProps(__spreadValues({},u),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},topViewPolygon2PointCloud=(e,t,i,a,o,d)=>{let P=e.pointList.map(L=>lbUtils.PointCloudUtils.transferCanvas2World(L,t)),c=0,u=1,h={};if(i){const L=i.getSensesPointZAxisInPolygon(P,void 0,d);d&&L.fittedCoordinates.length>0&&(P=L.fittedCoordinates),c=(L.maxZ+L.minZ)/2,u=L.maxZ-L.minZ,h={count:L.zCount}}const[v,b,T]=P,V=lbAnnotation.MathUtils.getLineCenterPoint([v,T]),_=lbAnnotation.MathUtils.getLineLength(v,b),D=lbAnnotation.MathUtils.getLineLength(b,T),A=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(c=a.center.z,u=a.depth);const O={center:{x:V.x,y:V.y,z:c},width:d?D+INTELLIGENT_FIT_MARGIN:D,height:d?_+INTELLIGENT_FIT_MARGIN:_,depth:u,rotation:A,id:e.id},k=__spreadValues(a?__spreadValues(__spreadValues({},a),O):__spreadProps(__spreadValues({},O),{attribute:"",valid:!0}),h);o&&Object.assign(k,o);const z=P.map(L=>lbUtils.PointCloudUtils.transferWorld2Canvas(L,t));return{boxParams:k,newPointList:z}},sideViewPoint2PointCloud=(e,t,i)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-a.x,y:i.center.y,z:i.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,i,a)=>{const[o,d,P]=e.pointList,[c,u,h]=t.pointList,v=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),V={x:{x:v.x-b.x,y:v.y-b.y}.x,y:0,z:v.y-b.y},_=lbAnnotation.MathUtils.getLineLength(o,d),D=lbAnnotation.MathUtils.getLineLength(c,u),A=_-D,O=lbAnnotation.MathUtils.getLineLength(d,P),k=lbAnnotation.MathUtils.getLineLength(u,h),z=O-k,{newBoxParams:L}=a.getNewBoxBySideUpdate(V,z,A,i);return L},backViewPoint2PointCloud=(e,t,i)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-a.x,z:i.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,i,a)=>{const[o,d,P]=e.pointList,[c,u,h]=t.pointList,v=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),V={x:{x:v.x-b.x,y:v.y-b.y}.x,y:0,z:v.y-b.y},_=lbAnnotation.MathUtils.getLineLength(o,d),D=lbAnnotation.MathUtils.getLineLength(c,u),A=_-D,O=lbAnnotation.MathUtils.getLineLength(d,P),k=lbAnnotation.MathUtils.getLineLength(u,h),z=O-k;let{newBoxParams:L}=a.getNewBoxByBackUpdate(V,z,A,i);return L},syncSideViewByPoint=(e,t,i,a,o)=>{var d;if(!i)return;const{toolInstance:P,pointCloudInstance:c}=i;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(u);const{point2d:h,zoom:v}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=v,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(v),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,i,a)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=i;d.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxSidePolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,i,a,o)=>{var d;if(!i)return;const{toolInstance:P,pointCloudInstance:c}=i;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(u);const{point2d:h,zoom:v}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=v,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(v),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,i,a)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=i;d.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxBackPolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,i,a)=>{if(!i||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:d}=i,{point2d:P}=d.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},synchronizeTopView=(e,t,i,a)=>{var o,d;if(!i||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=i,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),h=[...P.polygonList],v=h.find(b=>b.id===t.id);v?(v.pointList=u,v.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(d=e.valid)!=null?d:!0}),P.setResultAndSelectedID(h,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:i,backViewInstance:a,mainViewInstance:o,addPointCloudBox:d,addPointCloudSphere:P,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:h,pointCloudSphereList:v,hideAttributes:b,setHighlight2DDataList:T,cuboidBoxIn2DView:V,imageSizes:_}=e,{addHistory:D,initHistory:A,pushHistoryUnderUpdatePolygon:O}=useHistory.useHistory(),{selectedPolygon:k}=usePolygon.usePolygon(),{getPointCloudSphereByID:z,updatePointCloudSphere:L,selectedSphere:q}=useSphere.useSphere(),{currentData:j,config:m}=ctx.useSelector(n=>{const{stepList:s,step:p,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,s).config)}}),R=ctx.useDispatch(),W=n=>{if(!V){const{mappingImgList:s=[]}=j,p=s.map(r=>index.getRectPointCloudBox({pointCloudBox:n,mappingData:r,imageSizes:_}));Object.assign(n,{rects:p.filter(r=>r!==void 0)})}},{selectedBox:S,updateSelectedBox:tt,updateSelectedBoxes:Z,getPointCloudByID:ot}=useSingleBox.useSingleBox({generateRects:W}),{t:et}=reactI18next.useTranslation(),X=S==null?void 0:S.info;if(!t||!i||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,nt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},it=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},st=({newPoint:n,size:s,zoom:p,trackConfigurable:r})=>{var l;const C={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const g=topViewPoint2PointCloud(n,s,G,void 0,C);c(n.id);const f=P(g);H(PointCloudView.Top,n,g,p,f,m),D({newSphereParams:g})},rt=({polygon:n,size:s,imgList:p,trackConfigurable:r,zoom:l,intelligentFit:C})=>{var g,f;const x={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};r===!0&&Object.assign(x,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:v})});const B=t==null?void 0:t.toolInstance,w=__spreadValues({},n);let{boxParams:y,newPointList:U}=topViewPolygon2PointCloud(w,s,G,void 0,x,C);if(y=R(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[y],stepConfig:m,action:"viewUpdateBox"}))[0],(m==null?void 0:m.lowerLimitPointsNumInBox)&&typeof y.count=="number"&&y.count<m.lowerLimitPointsNumInBox){antd.message.info(et("LowerLimitPointsNumInBox",{num:m.lowerLimitPointsNumInBox})),B.deletePolygon(y.id);return}C&&(U==null?void 0:U.length)&&(w.pointList=U);const I=b.includes(w.attribute);W(y);const N=d(y),Q=(f=e==null?void 0:e.polygonList)!=null?f:[];t==null||t.updatePolygonList(N!=null?N:[],Q),I?c([]):(c(y.id),B.selection.setSelectedIDs(w.id),E({omitView:PointCloudView.Top,polygon:w,boxParams:y,zoom:l,newPointCloudBoxList:N}),C&&synchronizeTopView(y,w,t,o)),D({newBoxParams:y})},lt=n=>{const{boxID:s,imageName:p,width:r,height:l,x:C,y:g}=n,f=h.find(x=>x.id===s);if(f==null?void 0:f.rects){const{rects:x=[]}=f,B=x.find(w=>w.imageName===p);if(B){let w=x;const y=__spreadProps(__spreadValues({},B),{width:r,height:l,x:C,y:g});w=x.map(I=>I===B?y:I);const U=__spreadProps(__spreadValues({},f),{rects:w}),M=h.map(I=>I===f?U:I);return t==null||t.updatePolygonList(M!=null?M:[]),M}}},at=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:r})=>{var l;const C=t==null?void 0:t.toolInstance;if(!(u.length===0||!C)){if(n||(S==null?void 0:S.info)){const g=n!=null?n:S==null?void 0:S.info;(l=C==null?void 0:C.selection)==null||l.setSelectedIDs(u[0]);const f=C.selectedPolygon;if(u.length===1&&g){E({omitView:PointCloudView.Top,polygon:f,boxParams:g,newPointCloudBoxList:s});return}}if((p||q)&&u.length===1){const g=p!=null?p:q;C.setSelectedID(u[0]);const f=C.selectedPoint;g&&H(PointCloudView.Top,f,g,void 0,r,m)}}},Y=(n,s,p)=>{if(X){let r,l;switch(p){case PointCloudView.Back:r=backViewPolygon2PointCloud;break;case PointCloudView.Side:r=sideViewPolygon2PointCloud;break;default:r=sideViewPolygon2PointCloud;break}l=r(n,s,X,i.pointCloudInstance);const g=R(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:m,action:"viewUpdateBox"}))[0],f=l.valid!==g.valid;if(l=g,o){const{count:B}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:B})}const x=tt(l);return l=x.find(B=>B.id===l.id),E({omitView:f?void 0:p,polygon:n,boxParams:l,newPointCloudBoxList:x}),x}},J=(n,s,p)=>{if(q){let r,l;switch(p){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}l=r(n,s,q);const C=L(l);return H(p,n,l,void 0,C,m),C}},dt=(n,s)=>{J(n,s,PointCloudView.Side)},ct=(n,s)=>{J(n,s,PointCloudView.Back)},ut=(n,s)=>{Y(n,s,PointCloudView.Side)},pt=(n,s)=>{Y(n,s,PointCloudView.Back)},Pt=(n,s)=>{const p=z(n.id),r=topViewPoint2PointCloud(n,s,G,p),l=L(r);H(PointCloudView.Top,n,r,void 0,l,m)},Ct=(n,s)=>{if(k){const r=n[0].newPolygon;r.pointList=r.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,s)),O(n[0].newPolygon);return}let p=n.map(({newPolygon:r})=>{const l=ot(r.id),{boxParams:C}=topViewPolygon2PointCloud(r,s,t.pointCloudInstance,l);return C});if(p=R(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:p,stepConfig:m,action:"viewUpdateBox"})),p.length===1){const{newPolygon:r}=n[0],l=Z(p);E({polygon:r,boxParams:p[0],newPointCloudBoxList:l})}else{const r=Z(p);r&&e.syncAllViewPointCloudColor(r)}},gt=n=>{var s,p,r,l,C;if(S){const g=Number(n.widthDefault),f=Number(n.depthDefault),x=Number(n.heightDefault),B=S==null?void 0:S.info.trackID,y=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(F=>(F==null?void 0:F.trackID)===B),U={width:(r=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:r.width,height:(C=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:C.height},M=y.pointList.map(F=>lbUtils.PointCloudUtils.transferCanvas2World(F,U)),I=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(M,x,g),N=I[0],Q=I[2],K=lbAnnotation.MathUtils.getLineCenterPoint([N,Q]),ht=S.info.center.z-S.info.depth/2,$=__spreadProps(__spreadValues({},S.info),{center:{x:K.x,y:K.y,z:ht+f/2},width:g,height:x,depth:f,valid:!0}),ft=Z([$]);E({omitView:PointCloudView["3D"],polygon:y,boxParams:$,newPointCloudBoxList:ft})}},H=(n,s,p,r,l,C)=>__async(void 0,null,function*(){const g=j==null?void 0:j.url,f={[PointCloudView.Side]:()=>{syncSideViewByPoint(p,s,i,g,C)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(p,s,a,g,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(p,s,t,o)}};Object.keys(f).forEach(x=>{x!==n&&f[x]()}),r&&(o==null||o.updateCameraZoom(r)),it(p)}),E=n=>__async(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:r,zoom:l,newPointCloudBoxList:C}=n,g=j==null?void 0:j.url;C&&(yield e.syncAllViewPointCloudColor(C));const f={[PointCloudView.Side]:()=>{synchronizeSideView(r,p,i,g)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(r,p,a,g)},[PointCloudView.Top]:()=>{synchronizeTopView(r,p,t,o)}};Object.keys(f).forEach(x=>{x!==s&&f[x]()}),l&&(o==null||o.updateCameraZoom(l)),nt(r)});return{topViewAddSphere:st,topViewAddBox:rt,topViewSelectedChanged:at,topViewUpdatePoint:Pt,sideViewUpdatePoint:dt,backViewUpdatePoint:ct,topViewUpdateBox:Ct,sideViewUpdateBox:ut,backViewUpdateBox:pt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=j){var p,r,l,C,g,f;if(!(s==null?void 0:s.url)||!o)return;T([]),actionCreators.SetPointCloudLoading(R,!0),actionCreators.SetLoadPCDFileLoading(R,!0),yield o.loadPCDFile(s.url,(p=m==null?void 0:m.radius)!=null?p:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],B=[],w=[],y=[];o.updateTopCamera();const U=(l=(r=index.jsonParser(s.result))==null?void 0:r.valid)!=null?l:!0;e.setPointCloudValid(U),(C=e.sideViewInstance)==null||C.clearAllData(),(g=e.backViewInstance)==null||g.clearAllData(),t.updateData(s.url,s.result,{radius:(f=m==null?void 0:m.radius)!=null?f:DEFAULT_RADIUS}),s.result&&(x=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),w=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),B=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),y=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),o==null||o.generateBoxes(x),o==null||o.generateSpheres(y),yield e.syncAllViewPointCloudColor(x,[])),A({pointCloudBoxList:x,polygonList:w,lineList:B,pointCloudSphereList:y}),actionCreators.SetPointCloudLoading(R,!1),actionCreators.SetLoadPCDFileLoading(R,!1)}),updateViewsByDefaultSize:gt,generateRects:W,update2DViewRect:lt}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
package/dist/index.css CHANGED
@@ -220,7 +220,7 @@
220
220
  }
221
221
 
222
222
  .audio-tool-spinner {
223
- height: 100%;
223
+ height: calc(100vh - 60px);
224
224
  }
225
225
  .audio-tool-spinner .ant-spin-container {
226
226
  height: 100%;
@@ -4,7 +4,7 @@
4
4
  * @createdate 2022-08-17
5
5
  */
6
6
  import { PointCloudAnnotation, PointCloud } from '@labelbee/lb-annotation';
7
- import { IPointCloudBox, IPointCloudSphere, IPointUnit, UpdatePolygonByDragList, ILine, IDefaultSize, IBasicRect } from '@labelbee/lb-utils';
7
+ import { IPointCloudBox, IPointCloudSphere, IPointUnit, UpdatePolygonByDragList, IDefaultSize, IBasicRect } from '@labelbee/lb-utils';
8
8
  import { ISize } from '@/types/main';
9
9
  import { IFileItem } from '@/types/data';
10
10
  export declare const topViewPoint2PointCloud: (newPoint: any, size: ISize, pointCloud: PointCloud, selectedPointCloudSphere?: IPointCloudSphere, defaultValue?: {
@@ -63,7 +63,6 @@ export declare const usePointCloudViews: () => {
63
63
  sideViewUpdatePoint?: undefined;
64
64
  backViewUpdatePoint?: undefined;
65
65
  topViewUpdateBox?: undefined;
66
- topViewUpdateLine?: undefined;
67
66
  pointCloudBoxListUpdated?: undefined;
68
67
  initPointCloud3d?: undefined;
69
68
  updatePointCloudData?: undefined;
@@ -95,7 +94,6 @@ export declare const usePointCloudViews: () => {
95
94
  sideViewUpdatePoint: (newPoint: IPointUnit, originPoint: IPointUnit) => void;
96
95
  backViewUpdatePoint: (newPoint: IPointUnit, originPoint: IPointUnit) => void;
97
96
  topViewUpdateBox: (updateList: UpdatePolygonByDragList, size: ISize) => void;
98
- topViewUpdateLine: (updateList: ILine, size: ISize) => void;
99
97
  sideViewUpdateBox: (newPolygon: any, originPolygon: any) => void;
100
98
  backViewUpdateBox: (newPolygon: any, originPolygon: any) => void;
101
99
  pointCloudBoxListUpdated: (newBoxes: IPointCloudBox[]) => void;
@@ -8,7 +8,7 @@ export interface ICustomToolInstance {
8
8
  clearResult: () => void;
9
9
  on: () => void;
10
10
  unbind: () => void;
11
- setResult: () => void;
11
+ setResult: (result: any) => void;
12
12
  setValid: (valid: boolean) => void;
13
13
  history: {
14
14
  initRecord: (action: any) => void;
@@ -1 +1 @@
1
- import i,{useState as F,useEffect as W,useMemo as ee}from"react";import{AudioPlayer as Se}from"../audioPlayer/index.js";import{getClassName as xe}from"../../utils/dom.js";import Ee from"../predictTracking/previewResult/index.js";import{Layout as te}from"antd/es";import{Spin as _e}from"antd";import{prefix as Ce}from"../../constant/index.js";import{cKeyCode as je,CommonToolUtils as D,uuid as Te,TagUtils as Pe,cTool as Le}from"@labelbee/lb-annotation";import w from"./index.module.scss.js";import Re from"./tagResultShow/index.js";import{AudioClipProvider as he,useAudioClipStore as we}from"./audioContext/index.js";import Ae from"./textInput/index.js";import{connect as Oe}from"react-redux";import{a2MapStateToProps as Ie}from"../../store/annotation/map.js";import{LabelBeeContext as Ne}from"../../store/ctx.js";import{jsonParser as ke}from"../../utils/index.js";import{useCustomToolInstance as $e}from"../../hooks/annotation.js";import{sidebarCls as Q}from"../../views/MainView/sidebar/index.js";import De from"./audioSide/labelSidebar/index.js";import Me from"./audioSide/clipSidebar/index.js";import Ve from"../../assets/annotation/audio/tag.svg.js";import Ke from"../../assets/annotation/audio/tagA.svg.js";import Be from"../../assets/annotation/audio/clip.svg.js";import Fe from"../../assets/annotation/audio/clipA.svg.js";var We=Object.defineProperty,Ue=Object.defineProperties,Xe=Object.getOwnPropertyDescriptors,oe=Object.getOwnPropertySymbols,qe=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,ne=(e,o,l)=>o in e?We(e,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[o]=l,v=(e,o)=>{for(var l in o||(o={}))qe.call(o,l)&&ne(e,l,o[l]);if(oe)for(var l of oe(o))ze.call(o,l)&&ne(e,l,o[l]);return e},A=(e,o)=>Ue(e,Xe(o));const{EAudioToolName:Ge}=Le,ie=je.default,{Sider:He,Content:Je}=te,le=`${Ce}-layout`,Qe=({setSideTab:e,sideTab:o})=>{const l=[{tab:"tag",commonSvg:Ve,selectedSvg:Ke},{tab:"clip",commonSvg:Be,selectedSvg:Fe}];return i.createElement("div",{className:w.toggleAudioOption},l.map((m,b)=>{const{tab:u,selectedSvg:y,commonSvg:C}=m;return i.createElement("div",{key:b,className:w.option},i.createElement("img",{className:w.icon,src:o===u?y:C,onClick:()=>{o!==u&&e(u)}}))}))},Ye=({result:e,inputDisabled:o,updateText:l,configList:m,autofocus:b,preContext:u,isCheck:y,clipAttributeConfigurable:C,clipTextConfigurable:O,textConfigurable:p,updateRegion:S,clipAttributeList:c})=>i.createElement("div",{className:w.textareaContainer},i.createElement("div",{className:w.textareaContent},i.createElement(Ae,{isCheck:y,result:e==null?void 0:e.value,textInputDisabled:o,textID:(e==null?void 0:e.id)||0,updateText:l,configList:m,autofocus:!o&&b,preContext:u,regions:e==null?void 0:e.regions,clipAttributeConfigurable:C,clipTextConfigurable:O,textConfigurable:p,updateRegion:S,clipAttributeList:c}))),Ze=e=>{var o,l;const{sider:m,config:b,result:u,updateTagResult:y,updateRegion:C,isEdit:O,tagConfigurable:p,clipConfigurable:S}=e;let c=(b==null?void 0:b.inputList)||[],n=(o=u==null?void 0:u.tag)!=null?o:{},z=(l=u==null?void 0:u.regions)!=null?l:[];const[U,x]=F([]),[E,_]=F("tag");W(()=>{if(!p&&S){_("clip");return}_("tag")},[p,S]),W(()=>(window.addEventListener("keydown",L),()=>{window.removeEventListener("keydown",L)}));const L=r=>{if(p&&S)switch(r.keyCode){case ie.L:_("tag");break;case ie.X:_("clip");break}if(E==="tag"){if(!D.hotkeyFilter(r))return;D.isMoveKey(r==null?void 0:r.keyCode)&&r.preventDefault();let t=r.keyCode;if(t&&(t<=57&&t>=49||t<=105&&t>=97)){t>57?t=t-97:t=t-49;const d=U.slice();c.length===1?(M(0,t),x([0,t]),setTimeout(()=>{x([])},500)):d.length===1?(M(d[0],t),x([d[0],t]),setTimeout(()=>{x([])},500)):x([t])}}},M=(r,t)=>{if(r<c.length&&c[r].subSelected&&t<c[r].subSelected.length){const d=c[r].value,G=c[r].isMulti;let j=c[r].subSelected[t].value,k=0;const $=n;for(const T in n)if(T===c[r].value){if(k++,G===!0){const h=$[T].split(";").filter(X=>X!==""),K=h.indexOf(j);K===-1?h.push(j):h.splice(K,1),j=h.join(";")}j===""?delete $[T]:$[T]=j}k===0&&Object.assign(n,{[d]:j}),y(n)}},I=r=>{delete n[r],y(n)},N=p&&S&&i.createElement(Qe,{setSideTab:_,sideTab:E}),V=E==="tag"&&i.createElement(De,{labelInfoSet:p?c:[],labelSelectedList:U,setLabel:M,tagResult:n,clearResult:I,isEdit:O,withPanelTab:!1}),R=E==="clip"&&i.createElement(Me,{regions:z,updateRegion:C,useAudioClipStore:we});return m?typeof m=="function"?i.createElement("div",{className:`${Q}`},m({toggleAudioOption:N,labelSidebar:V,clipSidebar:R})):m:i.createElement("div",{className:`${Q}`},i.createElement("div",{className:`${Q}__content`},N,V,R))},et=e=>{var o,l,m,b,u,y,C,O;const p=(l=(o=e.style)==null?void 0:o.sider)==null?void 0:l.width,{step:S,stepList:c,audioContext:n,sider:z,drawLayerSlot:U,imgList:x,imgIndex:E,currentData:_,config:L,stepInfo:M}=e,I=D.getCurrentStepToolAndConfig(S,c),N=ke(_.result),{toolInstanceRef:V}=$e({basicInfo:N}),[R,r]=F(!0),[t,d]=F(null),[G,j]=F(!1);W(()=>{r(!0),j(!0)},[E]),W(()=>{R===!1&&fe()},[R]),W(()=>{V.current.exportData=()=>[[t],{}],V.current.clearResult=ye},[t]);const k=ee(()=>{const s=N[`step_${S}`];return(s==null?void 0:s.result)||[]},[L,N]),{tagConfigurable:$,textConfigurable:T=!0,clipConfigurable:h=!1,clipAttributeConfigurable:K=!1,clipAttributeList:X=[],clipTextConfigurable:q=!1,inputList:se=[],configList:re=[]}=ee(()=>{if(I)return D.jsonParser(I==null?void 0:I.config)},[I]),ae={clipConfigurable:h,clipAttributeConfigurable:K,clipAttributeList:X,clipTextConfigurable:q},H=n?n==null?void 0:n.valid:!0,ue=(b=(m=D.jsonParser(_.result))==null?void 0:m.duration)!=null?b:0,ce=H?ue:0,de=!H||R||![T,q].includes(!0);let Y={};if(E!==-1&&(x==null?void 0:x.length)){const s=(u=x[E])==null?void 0:u.preResult,a=(n==null?void 0:n.isEdit)?n==null?void 0:n.stepConfig.loadPreStep:M.loadPreStep;if(s&&a){const f=D.jsonParser(s),g=(C=(y=f==null?void 0:f.config)==null?void 0:y.context)!=null?C:{};Object.keys(g).forEach(P=>{P&&g[P]&&(Y[P]={visible:!0,content:g[P],type:P})})}}const fe=()=>{(k==null?void 0:k.length)>0?d(k[0]):d({id:Te(),sourceID:"",value:Z(),tag:me(),regions:[]})},Z=(s=!0)=>{const a={};let f=L.configList||[];return f.length>0&&f.forEach(g=>{a[g.key]=s&&g.default||""}),a},me=()=>Pe.getDefaultResultByConfig(L.inputList||[]),pe=({duration:s,hasError:a})=>{console.log("onloaded"),r(!1)},ge=s=>{d(a=>A(v({},a),{regions:((a==null?void 0:a.regions)||[]).filter(f=>f.id!==s)}))},J=s=>{d(a=>{var f;const g=(f=a==null?void 0:a.regions)!=null?f:[],{id:P}=s;return g.find(B=>B.id===P)?A(v({},a),{regions:g.map(B=>P===B.id?v(v({},B),s):B)}):A(v({},a),{regions:[...g,s]})})},ve=(s,a)=>{d(f=>A(v({},f),{value:A(v({},f.value),{[a]:s})}))},be=s=>{d(a=>A(v({},a),{tag:s}))},ye=()=>{d(s=>A(v({},s),{value:Z(),tag:{},regions:[]}))};return i.createElement(he,null,i.createElement(_e,{spinning:R,wrapperClassName:"audio-tool-spinner"},i.createElement(te,{className:xe("layout","container"),style:{height:"100%"}},e==null?void 0:e.leftSider,i.createElement(Je,{className:`${le}__content`},i.createElement("div",{className:w.containerWrapper},i.createElement("div",{className:w.audioWrapper},$&&i.createElement(Re,{result:t==null?void 0:t.tag,labelInfoSet:se,hasPromptLayer:!!(n==null?void 0:n.promptLayer)}),n==null?void 0:n.promptLayer,i.createElement(Se,v({context:{isEdit:n==null?void 0:n.isEdit,count:ce,toolName:Ge.AudioTextTool,imgIndex:E},drawLayerSlot:U,fileData:_,onLoaded:pe,invalid:!H,updateRegion:J,removeRegion:ge,regions:t==null?void 0:t.regions,activeToolPanel:n==null?void 0:n.activeToolPanel,footer:e.footer},ae))),(T||q)&&i.createElement(Ye,{preContext:Y,result:t,inputDisabled:de,updateText:ve,updateRegion:J,configList:re,autofocus:G,textConfigurable:T,clipTextConfigurable:q,clipAttributeList:X,clipAttributeConfigurable:K}))),i.createElement(He,{className:`${le}__side`,width:p!=null?p:240,style:(O=e.style)==null?void 0:O.sider},i.createElement(Ze,{sider:z,config:L,result:t,updateTagResult:be,updateRegion:J,isEdit:n==null?void 0:n.isEdit,tagConfigurable:$,clipConfigurable:h})),i.createElement(Ee,null))))};var tt=Oe(Ie,null,null,{context:Ne})(et);export{tt as default};
1
+ import i,{useState as F,useEffect as W,useMemo as ee}from"react";import{AudioPlayer as xe}from"../audioPlayer/index.js";import{getClassName as Ee}from"../../utils/dom.js";import _e from"../predictTracking/previewResult/index.js";import{Layout as te}from"antd/es";import{Spin as Ce}from"antd";import{prefix as je}from"../../constant/index.js";import{cKeyCode as Re,CommonToolUtils as M,uuid as Te,TagUtils as Pe,cTool as Le}from"@labelbee/lb-annotation";import w from"./index.module.scss.js";import he from"./tagResultShow/index.js";import{AudioClipProvider as we,useAudioClipStore as Ae}from"./audioContext/index.js";import Oe from"./textInput/index.js";import{connect as Ie}from"react-redux";import{a2MapStateToProps as Ne}from"../../store/annotation/map.js";import{LabelBeeContext as ke}from"../../store/ctx.js";import{jsonParser as $e}from"../../utils/index.js";import{useCustomToolInstance as De}from"../../hooks/annotation.js";import{sidebarCls as Q}from"../../views/MainView/sidebar/index.js";import Me from"./audioSide/labelSidebar/index.js";import Ve from"./audioSide/clipSidebar/index.js";import Ke from"../../assets/annotation/audio/tag.svg.js";import Be from"../../assets/annotation/audio/tagA.svg.js";import Fe from"../../assets/annotation/audio/clip.svg.js";import We from"../../assets/annotation/audio/clipA.svg.js";var Ue=Object.defineProperty,Xe=Object.defineProperties,qe=Object.getOwnPropertyDescriptors,oe=Object.getOwnPropertySymbols,ze=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable,ne=(e,o,s)=>o in e?Ue(e,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[o]=s,v=(e,o)=>{for(var s in o||(o={}))ze.call(o,s)&&ne(e,s,o[s]);if(oe)for(var s of oe(o))Ge.call(o,s)&&ne(e,s,o[s]);return e},A=(e,o)=>Xe(e,qe(o));const{EAudioToolName:He}=Le,ie=Re.default,{Sider:Je,Content:Qe}=te,le=`${je}-layout`,Ye=({setSideTab:e,sideTab:o})=>{const s=[{tab:"tag",commonSvg:Ke,selectedSvg:Be},{tab:"clip",commonSvg:Fe,selectedSvg:We}];return i.createElement("div",{className:w.toggleAudioOption},s.map((m,b)=>{const{tab:c,selectedSvg:y,commonSvg:C}=m;return i.createElement("div",{key:b,className:w.option},i.createElement("img",{className:w.icon,src:o===c?y:C,onClick:()=>{o!==c&&e(c)}}))}))},Ze=({result:e,inputDisabled:o,updateText:s,configList:m,autofocus:b,preContext:c,isCheck:y,clipAttributeConfigurable:C,clipTextConfigurable:O,textConfigurable:p,updateRegion:S,clipAttributeList:d})=>i.createElement("div",{className:w.textareaContainer},i.createElement("div",{className:w.textareaContent},i.createElement(Oe,{isCheck:y,result:e==null?void 0:e.value,textInputDisabled:o,textID:(e==null?void 0:e.id)||0,updateText:s,configList:m,autofocus:!o&&b,preContext:c,regions:e==null?void 0:e.regions,clipAttributeConfigurable:C,clipTextConfigurable:O,textConfigurable:p,updateRegion:S,clipAttributeList:d}))),et=e=>{var o,s;const{sider:m,config:b,result:c,updateTagResult:y,updateRegion:C,isEdit:O,tagConfigurable:p,clipConfigurable:S}=e;let d=(b==null?void 0:b.inputList)||[],n=(o=c==null?void 0:c.tag)!=null?o:{},z=(s=c==null?void 0:c.regions)!=null?s:[];const[U,x]=F([]),[E,_]=F("tag");W(()=>{if(!p&&S){_("clip");return}_("tag")},[p,S]),W(()=>(window.addEventListener("keydown",P),()=>{window.removeEventListener("keydown",P)}));const P=r=>{if(p&&S)switch(r.keyCode){case ie.L:_("tag");break;case ie.X:_("clip");break}if(E==="tag"){if(!M.hotkeyFilter(r))return;M.isMoveKey(r==null?void 0:r.keyCode)&&r.preventDefault();let t=r.keyCode;if(t&&(t<=57&&t>=49||t<=105&&t>=97)){t>57?t=t-97:t=t-49;const u=U.slice();d.length===1?(V(0,t),x([0,t]),setTimeout(()=>{x([])},500)):u.length===1?(V(u[0],t),x([u[0],t]),setTimeout(()=>{x([])},500)):x([t])}}},V=(r,t)=>{if(r<d.length&&d[r].subSelected&&t<d[r].subSelected.length){const u=d[r].value,G=d[r].isMulti;let j=d[r].subSelected[t].value,$=0;const D=n;for(const R in n)if(R===d[r].value){if($++,G===!0){const h=D[R].split(";").filter(X=>X!==""),K=h.indexOf(j);K===-1?h.push(j):h.splice(K,1),j=h.join(";")}j===""?delete D[R]:D[R]=j}$===0&&Object.assign(n,{[u]:j}),y(n)}},I=r=>{delete n[r],y(n)},N=p&&S&&i.createElement(Ye,{setSideTab:_,sideTab:E}),k=E==="tag"&&i.createElement(Me,{labelInfoSet:p?d:[],labelSelectedList:U,setLabel:V,tagResult:n,clearResult:I,isEdit:O,withPanelTab:!1}),L=E==="clip"&&i.createElement(Ve,{regions:z,updateRegion:C,useAudioClipStore:Ae});return m?typeof m=="function"?i.createElement("div",{className:`${Q}`},m({toggleAudioOption:N,labelSidebar:k,clipSidebar:L})):m:i.createElement("div",{className:`${Q}`},i.createElement("div",{className:`${Q}__content`},N,k,L))},tt=e=>{var o,s,m,b,c,y,C,O;const p=(s=(o=e.style)==null?void 0:o.sider)==null?void 0:s.width,{step:S,stepList:d,audioContext:n,sider:z,drawLayerSlot:U,imgList:x,imgIndex:E,currentData:_,config:P,stepInfo:V}=e,I=M.getCurrentStepToolAndConfig(S,d),N=$e(_.result),{toolInstanceRef:k}=De({basicInfo:N}),[L,r]=F(!0),[t,u]=F(null),[G,j]=F(!1);W(()=>{r(!0),j(!0)},[E]),W(()=>{L===!1&&fe()},[L]),W(()=>{k.current.exportData=()=>[[t],{}],k.current.setResult=ye,k.current.clearResult=Se},[t]);const $=ee(()=>{const l=N[`step_${S}`];return(l==null?void 0:l.result)||[]},[P,N]),{tagConfigurable:D,textConfigurable:R=!0,clipConfigurable:h=!1,clipAttributeConfigurable:K=!1,clipAttributeList:X=[],clipTextConfigurable:q=!1,inputList:se=[],configList:re=[]}=ee(()=>{if(I)return M.jsonParser(I==null?void 0:I.config)},[I]),ae={clipConfigurable:h,clipAttributeConfigurable:K,clipAttributeList:X,clipTextConfigurable:q},H=n?n==null?void 0:n.valid:!0,ue=(b=(m=M.jsonParser(_.result))==null?void 0:m.duration)!=null?b:0,ce=H?ue:0,de=!H||L||![R,q].includes(!0);let Y={};if(E!==-1&&(x==null?void 0:x.length)){const l=(c=x[E])==null?void 0:c.preResult,a=(n==null?void 0:n.isEdit)?n==null?void 0:n.stepConfig.loadPreStep:V.loadPreStep;if(l&&a){const f=M.jsonParser(l),g=(C=(y=f==null?void 0:f.config)==null?void 0:y.context)!=null?C:{};Object.keys(g).forEach(T=>{T&&g[T]&&(Y[T]={visible:!0,content:g[T],type:T})})}}const fe=()=>{($==null?void 0:$.length)>0?u($[0]):u({id:Te(),sourceID:"",value:Z(),tag:me(),regions:[]})},Z=(l=!0)=>{const a={};let f=P.configList||[];return f.length>0&&f.forEach(g=>{a[g.key]=l&&g.default||""}),a},me=()=>Pe.getDefaultResultByConfig(P.inputList||[]),pe=({duration:l,hasError:a})=>{r(!1)},ge=l=>{u(a=>A(v({},a),{regions:((a==null?void 0:a.regions)||[]).filter(f=>f.id!==l)}))},J=l=>{u(a=>{var f;const g=(f=a==null?void 0:a.regions)!=null?f:[],{id:T}=l;return g.find(B=>B.id===T)?A(v({},a),{regions:g.map(B=>T===B.id?v(v({},B),l):B)}):A(v({},a),{regions:[...g,l]})})},ve=(l,a)=>{u(f=>A(v({},f),{value:A(v({},f.value),{[a]:l})}))},be=l=>{u(a=>A(v({},a),{tag:l}))},ye=l=>{u(l)},Se=()=>{u(l=>A(v({},l),{value:Z(),tag:{},regions:[]}))};return i.createElement(we,null,i.createElement(Ce,{spinning:L,wrapperClassName:"audio-tool-spinner"},i.createElement(te,{className:Ee("layout","container"),style:{height:"100%"}},e==null?void 0:e.leftSider,i.createElement(Qe,{className:`${le}__content`},i.createElement("div",{className:w.containerWrapper},i.createElement("div",{className:w.audioWrapper},D&&i.createElement(he,{result:t==null?void 0:t.tag,labelInfoSet:se,hasPromptLayer:!!(n==null?void 0:n.promptLayer)}),n==null?void 0:n.promptLayer,i.createElement(xe,v({context:{isEdit:n==null?void 0:n.isEdit,count:ce,toolName:He.AudioTextTool,imgIndex:E},drawLayerSlot:U,fileData:_,onLoaded:pe,invalid:!H,updateRegion:J,removeRegion:ge,regions:t==null?void 0:t.regions,activeToolPanel:n==null?void 0:n.activeToolPanel,footer:e.footer},ae))),(R||q)&&i.createElement(Ze,{preContext:Y,result:t,inputDisabled:de,updateText:ve,updateRegion:J,configList:re,autofocus:G,textConfigurable:R,clipTextConfigurable:q,clipAttributeList:X,clipAttributeConfigurable:K}))),i.createElement(Je,{className:`${le}__side`,width:p!=null?p:240,style:(O=e.style)==null?void 0:O.sider},i.createElement(et,{sider:z,config:P,result:t,updateTagResult:be,updateRegion:J,isEdit:n==null?void 0:n.isEdit,tagConfigurable:D,clipConfigurable:h})),i.createElement(_e,null))))};var ot=Ie(Ne,null,null,{context:ke})(tt);export{ot as default};
@@ -1 +1 @@
1
- import{EPointCloudName as nt,MathUtils as B,getCuboidFromPointCloudBox as Qt}from"@labelbee/lb-annotation";import{EPerspectiveView as Q,PointCloudUtils as V,DEFAULT_SPHERE_PARAMS as Xt}from"@labelbee/lb-utils";import{useContext as Yt}from"react";import{PointCloudContext as qt}from"../PointCloudContext.js";import{useSingleBox as Jt}from"./useSingleBox.js";import{useSphere as Kt}from"./useSphere.js";import{useSelector as $t,useDispatch as to}from"../../../store/ctx.js";import oo from"../../../utils/StepUtils.js";import{jsonParser as Ct,getRectPointCloudBox as eo}from"../../../utils/index.js";import{PreDataProcess as it,SetPointCloudLoading as Pt,SetLoadPCDFileLoading as mt}from"../../../store/annotation/actionCreators.js";import{message as no}from"antd";import{useTranslation as io}from"react-i18next";import{useHistory as so}from"./useHistory.js";import{usePolygon as ro}from"./usePolygon.js";var lo=Object.defineProperty,ao=Object.defineProperties,co=Object.getOwnPropertyDescriptors,xt=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,ht=(e,t,i)=>t in e?lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,L=(e,t)=>{for(var i in t||(t={}))uo.call(t,i)&&ht(e,i,t[i]);if(xt)for(var i of xt(t))po.call(t,i)&&ht(e,i,t[i]);return e},O=(e,t)=>ao(e,co(t)),st=(e,t,i)=>new Promise((d,o)=>{var a=u=>{try{c(i.next(u))}catch(P){o(P)}},g=u=>{try{c(i.throw(u))}catch(P){o(P)}},c=u=>u.done?d(u.value):Promise.resolve(u.value).then(a,g);c((i=i.apply(e,t)).next())});const J=5,K=90,Lt=.01,v={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},rt=(e,t,i,d,o)=>{const{x:a,y:g}=V.transferCanvas2World(e,t),{defaultZ:c}=Xt,u={center:{x:a,y:g,z:c},id:e.id},P=d?L(L({},d),u):O(L({},u),{attribute:"",valid:!0});return o&&Object.assign(P,o),P},lt=(e,t,i,d,o,a)=>{let g=e.pointList.map(w=>V.transferCanvas2World(w,t)),c=0,u=1,P={};if(i){const w=i.getSensesPointZAxisInPolygon(g,void 0,a);a&&w.fittedCoordinates.length>0&&(g=w.fittedCoordinates),c=(w.maxZ+w.minZ)/2,u=w.maxZ-w.minZ,P={count:w.zCount}}const[h,D,F]=g,z=B.getLineCenterPoint([h,F]),R=B.getLineLength(h,D),k=B.getLineLength(D,F),N=B.getRadiusFromQuadrangle(e.pointList);d&&(c=d.center.z,u=d.depth);const T={center:{x:z.x,y:z.y,z:c},width:a?k+Lt:k,height:a?R+Lt:R,depth:u,rotation:N,id:e.id},j=L(d?L(L({},d),T):O(L({},T),{attribute:"",valid:!0}),P);o&&Object.assign(j,o);const E=g.map(w=>V.transferWorld2Canvas(w,t));return{boxParams:j,newPointList:E}},yt=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x-d.x,y:i.center.y,z:i.center.z-d.y}})},vt=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,P]=t.pointList,h=B.getLineCenterPoint([o,g]),D=B.getLineCenterPoint([c,P]),z={x:{x:h.x-D.x,y:h.y-D.y}.x,y:0,z:h.y-D.y},R=B.getLineLength(o,a),k=B.getLineLength(c,u),N=R-k,T=B.getLineLength(a,g),j=B.getLineLength(u,P),E=T-j,{newBoxParams:w}=d.getNewBoxBySideUpdate(z,E,N,i);return w},go=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x,y:i.center.y-d.x,z:i.center.z-d.y}})},fo=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,P]=t.pointList,h=B.getLineCenterPoint([o,g]),D=B.getLineCenterPoint([c,P]),z={x:{x:h.x-D.x,y:h.y-D.y}.x,y:0,z:h.y-D.y},R=B.getLineLength(o,a),k=B.getLineLength(c,u),N=R-k,T=B.getLineLength(a,g),j=B.getLineLength(u,P),E=T-j;let{newBoxParams:w}=d.getNewBoxByBackUpdate(z,E,N,i);return w},Bt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,Q.Left);c.setInitCameraPosition(u);const{point2d:P,zoom:h}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=h,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(h),g.setResult([O(L(L({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{width:J,depth:J});const{cameraPositionVector:g}=a.updateOrthoCamera(e,Q.Left);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxSidePolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,Q.Back);c.setInitCameraPosition(u);const{point2d:P,zoom:h}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=h,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(h),g.setResult([O(L(L({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},It=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{height:J,depth:J});const{cameraPositionVector:g}=a.updateOrthoCamera(e,Q.Back);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxBackPolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},St=(e,t,i,d)=>{if(!i||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,Q.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=i,{point2d:g}=a.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},dt=(e,t,i,d)=>{var o,a;if(!i||!d)return;d.generateBox(e,t.id),d.render();const{pointCloud2dOperation:g,pointCloudInstance:c}=i,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),P=[...g.polygonList],h=P.find(D=>D.id===t.id);h?(h.pointList=u,h.valid=(o=e.valid)!=null?o:!0):P.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(a=e.valid)!=null?a:!0}),g.setResultAndSelectedID(P,t.id)},Co=()=>{const e=Yt(qt),{topViewInstance:t,sideViewInstance:i,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:g,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:P,pointCloudSphereList:h,hideAttributes:D,setHighlight2DDataList:F,cuboidBoxIn2DView:z,imageSizes:R}=e,{addHistory:k,initHistory:N,pushHistoryUnderUpdatePolygon:T,pushHistoryUnderUpdateLine:j}=so(),{selectedPolygon:E}=ro(),{getPointCloudSphereByID:w,updatePointCloudSphere:at,selectedSphere:X}=Kt(),{currentData:W,config:b}=$t(n=>{const{stepList:s,step:p,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:Ct(oo.getCurrentStepInfo(p,s).config)}}),H=to(),$=n=>{if(!z){const{mappingImgList:s=[]}=W,p=s.map(r=>eo({pointCloudBox:n,mappingData:r,imageSizes:R}));Object.assign(n,{rects:p.filter(r=>r!==void 0)})}},{selectedBox:_,updateSelectedBox:Dt,updateSelectedBoxes:tt,getPointCloudByID:_t}=Jt({generateRects:$}),{t:Vt}=io(),ct=_==null?void 0:_.info;if(!t||!i||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Ot=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},Ut=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},kt=({newPoint:n,size:s,zoom:p,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const C=rt(n,s,ot,void 0,f);c(n.id);const m=g(C);Y(v.Top,n,C,p,m,b),k({newSphereParams:C})},At=({polygon:n,size:s,imgList:p,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var C,m;const x={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(x,{trackID:V.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:h})});const I=t==null?void 0:t.toolInstance,S=L({},n);let{boxParams:y,newPointList:A}=lt(S,s,ot,void 0,x,f);if(y=H(it({tool:nt.PointCloud,dataList:[y],stepConfig:b,action:"viewUpdateBox"}))[0],(b==null?void 0:b.lowerLimitPointsNumInBox)&&typeof y.count=="number"&&y.count<b.lowerLimitPointsNumInBox){no.info(Vt("LowerLimitPointsNumInBox",{num:b.lowerLimitPointsNumInBox})),I.deletePolygon(y.id);return}f&&(A==null?void 0:A.length)&&(S.pointList=A);const U=D.includes(S.attribute);$(y);const G=a(y),et=(m=e==null?void 0:e.polygonList)!=null?m:[];t==null||t.updatePolygonList(G!=null?G:[],et),U?c([]):(c(y.id),I.selection.setSelectedIDs(S.id),M({omitView:v.Top,polygon:S,boxParams:y,zoom:l,newPointCloudBoxList:G}),f&&dt(y,S,t,o)),k({newBoxParams:y})},zt=n=>{const{boxID:s,imageName:p,width:r,height:l,x:f,y:C}=n,m=P.find(x=>x.id===s);if(m==null?void 0:m.rects){const{rects:x=[]}=m,I=x.find(S=>S.imageName===p);if(I){let S=x;const y=O(L({},I),{width:r,height:l,x:f,y:C});S=x.map(U=>U===I?y:U);const A=O(L({},m),{rects:S}),Z=P.map(U=>U===m?A:U);return t==null||t.updatePolygonList(Z!=null?Z:[]),Z}}},Rt=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(u.length===0||!f)){if(n||(_==null?void 0:_.info)){const C=n!=null?n:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(u[0]);const m=f.selectedPolygon;if(u.length===1&&C){M({omitView:v.Top,polygon:m,boxParams:C,newPointCloudBoxList:s});return}}if((p||X)&&u.length===1){const C=p!=null?p:X;f.setSelectedID(u[0]);const m=f.selectedPoint;C&&Y(v.Top,m,C,void 0,r,b)}}},ut=(n,s,p)=>{if(ct){let r,l;switch(p){case v.Back:r=fo;break;case v.Side:r=vt;break;default:r=vt;break}l=r(n,s,ct,i.pointCloudInstance);const C=H(it({tool:nt.PointCloud,dataList:[l],stepConfig:b,action:"viewUpdateBox"}))[0],m=l.valid!==C.valid;if(l=C,o){const{count:I}=o.getSensesPointZAxisInPolygon(Qt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:I})}const x=Dt(l);return l=x.find(I=>I.id===l.id),M({omitView:m?void 0:p,polygon:n,boxParams:l,newPointCloudBoxList:x}),x}},pt=(n,s,p)=>{if(X){let r,l;switch(p){case v.Back:r=go;break;case v.Side:r=yt;break;default:r=yt;break}l=r(n,s,X);const f=at(l);return Y(p,n,l,void 0,f,b),f}},Tt=(n,s)=>{pt(n,s,v.Side)},jt=(n,s)=>{pt(n,s,v.Back)},Nt=(n,s)=>{ut(n,s,v.Side)},Et=(n,s)=>{ut(n,s,v.Back)},Ht=(n,s)=>{j(n)},Ft=(n,s)=>{const p=w(n.id),r=rt(n,s,ot,p),l=at(r);Y(v.Top,n,r,void 0,l,b)},Wt=(n,s)=>{if(E){const r=n[0].newPolygon;r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,s)),T(n[0].newPolygon);return}let p=n.map(({newPolygon:r})=>{const l=_t(r.id),{boxParams:f}=lt(r,s,t.pointCloudInstance,l);return f});if(p=H(it({tool:nt.PointCloud,dataList:p,stepConfig:b,action:"viewUpdateBox"})),p.length===1){const{newPolygon:r}=n[0],l=tt(p);M({polygon:r,boxParams:p[0],newPointCloudBoxList:l})}else{const r=tt(p);r&&e.syncAllViewPointCloudColor(r)}},Zt=n=>{var s,p,r,l,f;if(_){const C=Number(n.widthDefault),m=Number(n.depthDefault),x=Number(n.heightDefault),I=_==null?void 0:_.info.trackID,y=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(q=>(q==null?void 0:q.trackID)===I),A={width:(r=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},Z=y.pointList.map(q=>V.transferCanvas2World(q,A)),U=B.getModifiedRectangleCoordinates(Z,x,C),G=U[0],et=U[2],gt=B.getLineCenterPoint([G,et]),Mt=_.info.center.z-_.info.depth/2,ft=O(L({},_.info),{center:{x:gt.x,y:gt.y,z:Mt+m/2},width:C,height:x,depth:m,valid:!0}),Gt=tt([ft]);M({omitView:v["3D"],polygon:y,boxParams:ft,newPointCloudBoxList:Gt})}},Y=(n,s,p,r,l,f)=>st(void 0,null,function*(){const C=W==null?void 0:W.url,m={[v.Side]:()=>{Bt(p,s,i,C,f)},[v.Back]:()=>{d&&bt(p,s,d,C,f)},[v.Top]:()=>{St(p,s,t,o)}};Object.keys(m).forEach(x=>{x!==n&&m[x]()}),r&&(o==null||o.updateCameraZoom(r)),Ut(p)}),M=n=>st(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:r,zoom:l,newPointCloudBoxList:f}=n,C=W==null?void 0:W.url;f&&(yield e.syncAllViewPointCloudColor(f));const m={[v.Side]:()=>{wt(r,p,i,C)},[v.Back]:()=>{d&&It(r,p,d,C)},[v.Top]:()=>{dt(r,p,t,o)}};Object.keys(m).forEach(x=>{x!==s&&m[x]()}),l&&(o==null||o.updateCameraZoom(l)),Ot(r)});return{topViewAddSphere:kt,topViewAddBox:At,topViewSelectedChanged:Rt,topViewUpdatePoint:Ft,sideViewUpdatePoint:Tt,backViewUpdatePoint:jt,topViewUpdateBox:Wt,topViewUpdateLine:Ht,sideViewUpdateBox:Nt,backViewUpdateBox:Et,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const s=V.getDefaultOrthographicParams(n);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>st(void 0,[...n],function*(s=W){var p,r,l,f,C,m;if(!(s==null?void 0:s.url)||!o)return;F([]),Pt(H,!0),mt(H,!0),yield o.loadPCDFile(s.url,(p=b==null?void 0:b.radius)!=null?p:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],I=[],S=[],y=[];o.updateTopCamera();const A=(l=(r=Ct(s.result))==null?void 0:r.valid)!=null?l:!0;e.setPointCloudValid(A),(f=e.sideViewInstance)==null||f.clearAllData(),(C=e.backViewInstance)==null||C.clearAllData(),t.updateData(s.url,s.result,{radius:(m=b==null?void 0:b.radius)!=null?m:K}),s.result&&(x=V.getBoxParamsFromResultList(s.result),S=V.getPolygonListFromResultList(s.result),I=V.getLineListFromResultList(s.result),y=V.getSphereParamsFromResultList(s.result),o==null||o.generateBoxes(x),o==null||o.generateSpheres(y),yield e.syncAllViewPointCloudColor(x,[])),N({pointCloudBoxList:x,polygonList:S,lineList:I,pointCloudSphereList:y}),Pt(H,!1),mt(H,!1)}),updateViewsByDefaultSize:Zt,generateRects:$,update2DViewRect:zt}};export{bt as syncBackViewByPoint,Bt as syncSideViewByPoint,St as syncTopViewByPoint,It as synchronizeBackView,wt as synchronizeSideView,dt as synchronizeTopView,rt as topViewPoint2PointCloud,lt as topViewPolygon2PointCloud,Co as usePointCloudViews};
1
+ import{EPointCloudName as nt,MathUtils as w,getCuboidFromPointCloudBox as Mt}from"@labelbee/lb-annotation";import{EPerspectiveView as Q,PointCloudUtils as V,DEFAULT_SPHERE_PARAMS as Gt}from"@labelbee/lb-utils";import{useContext as Qt}from"react";import{PointCloudContext as Xt}from"../PointCloudContext.js";import{useSingleBox as Yt}from"./useSingleBox.js";import{useSphere as qt}from"./useSphere.js";import{useSelector as Jt,useDispatch as Kt}from"../../../store/ctx.js";import $t from"../../../utils/StepUtils.js";import{jsonParser as ft,getRectPointCloudBox as to}from"../../../utils/index.js";import{PreDataProcess as it,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{message as oo}from"antd";import{useTranslation as eo}from"react-i18next";import{useHistory as no}from"./useHistory.js";import{usePolygon as io}from"./usePolygon.js";var so=Object.defineProperty,ro=Object.defineProperties,lo=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,ao=Object.prototype.hasOwnProperty,co=Object.prototype.propertyIsEnumerable,xt=(e,t,i)=>t in e?so(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,y=(e,t)=>{for(var i in t||(t={}))ao.call(t,i)&&xt(e,i,t[i]);if(mt)for(var i of mt(t))co.call(t,i)&&xt(e,i,t[i]);return e},O=(e,t)=>ro(e,lo(t)),st=(e,t,i)=>new Promise((d,o)=>{var a=u=>{try{c(i.next(u))}catch(P){o(P)}},g=u=>{try{c(i.throw(u))}catch(P){o(P)}},c=u=>u.done?d(u.value):Promise.resolve(u.value).then(a,g);c((i=i.apply(e,t)).next())});const J=5,K=90,ht=.01,v={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},rt=(e,t,i,d,o)=>{const{x:a,y:g}=V.transferCanvas2World(e,t),{defaultZ:c}=Gt,u={center:{x:a,y:g,z:c},id:e.id},P=d?y(y({},d),u):O(y({},u),{attribute:"",valid:!0});return o&&Object.assign(P,o),P},lt=(e,t,i,d,o,a)=>{let g=e.pointList.map(B=>V.transferCanvas2World(B,t)),c=0,u=1,P={};if(i){const B=i.getSensesPointZAxisInPolygon(g,void 0,a);a&&B.fittedCoordinates.length>0&&(g=B.fittedCoordinates),c=(B.maxZ+B.minZ)/2,u=B.maxZ-B.minZ,P={count:B.zCount}}const[h,D,F]=g,R=w.getLineCenterPoint([h,F]),z=w.getLineLength(h,D),A=w.getLineLength(D,F),N=w.getRadiusFromQuadrangle(e.pointList);d&&(c=d.center.z,u=d.depth);const T={center:{x:R.x,y:R.y,z:c},width:a?A+ht:A,height:a?z+ht:z,depth:u,rotation:N,id:e.id},j=y(d?y(y({},d),T):O(y({},T),{attribute:"",valid:!0}),P);o&&Object.assign(j,o);const E=g.map(B=>V.transferWorld2Canvas(B,t));return{boxParams:j,newPointList:E}},yt=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(y({},i),{center:{x:i.center.x-d.x,y:i.center.y,z:i.center.z-d.y}})},Lt=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,P]=t.pointList,h=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([c,P]),R={x:{x:h.x-D.x,y:h.y-D.y}.x,y:0,z:h.y-D.y},z=w.getLineLength(o,a),A=w.getLineLength(c,u),N=z-A,T=w.getLineLength(a,g),j=w.getLineLength(u,P),E=T-j,{newBoxParams:B}=d.getNewBoxBySideUpdate(R,E,N,i);return B},uo=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(y({},i),{center:{x:i.center.x,y:i.center.y-d.x,z:i.center.z-d.y}})},po=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,P]=t.pointList,h=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([c,P]),R={x:{x:h.x-D.x,y:h.y-D.y}.x,y:0,z:h.y-D.y},z=w.getLineLength(o,a),A=w.getLineLength(c,u),N=z-A,T=w.getLineLength(a,g),j=w.getLineLength(u,P),E=T-j;let{newBoxParams:B}=d.getNewBoxByBackUpdate(R,E,N,i);return B},vt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,Q.Left);c.setInitCameraPosition(u);const{point2d:P,zoom:h}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=h,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(h),g.setResult([O(y(y({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{width:J,depth:J});const{cameraPositionVector:g}=a.updateOrthoCamera(e,Q.Left);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxSidePolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},wt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,Q.Back);c.setInitCameraPosition(u);const{point2d:P,zoom:h}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=h,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(h),g.setResult([O(y(y({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},bt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{height:J,depth:J});const{cameraPositionVector:g}=a.updateOrthoCamera(e,Q.Back);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxBackPolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,i,d)=>{if(!i||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,Q.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=i,{point2d:g}=a.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?O(y(y({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},dt=(e,t,i,d)=>{var o,a;if(!i||!d)return;d.generateBox(e,t.id),d.render();const{pointCloud2dOperation:g,pointCloudInstance:c}=i,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),P=[...g.polygonList],h=P.find(D=>D.id===t.id);h?(h.pointList=u,h.valid=(o=e.valid)!=null?o:!0):P.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(a=e.valid)!=null?a:!0}),g.setResultAndSelectedID(P,t.id)},go=()=>{const e=Qt(Xt),{topViewInstance:t,sideViewInstance:i,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:g,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:P,pointCloudSphereList:h,hideAttributes:D,setHighlight2DDataList:F,cuboidBoxIn2DView:R,imageSizes:z}=e,{addHistory:A,initHistory:N,pushHistoryUnderUpdatePolygon:T}=no(),{selectedPolygon:j}=io(),{getPointCloudSphereByID:E,updatePointCloudSphere:B,selectedSphere:X}=qt(),{currentData:W,config:b}=Jt(n=>{const{stepList:s,step:p,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:ft($t.getCurrentStepInfo(p,s).config)}}),H=Kt(),$=n=>{if(!R){const{mappingImgList:s=[]}=W,p=s.map(r=>to({pointCloudBox:n,mappingData:r,imageSizes:z}));Object.assign(n,{rects:p.filter(r=>r!==void 0)})}},{selectedBox:_,updateSelectedBox:St,updateSelectedBoxes:tt,getPointCloudByID:Dt}=Yt({generateRects:$}),{t:_t}=eo(),at=_==null?void 0:_.info;if(!t||!i||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},Ot=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},kt=({newPoint:n,size:s,zoom:p,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const C=rt(n,s,ot,void 0,f);c(n.id);const m=g(C);Y(v.Top,n,C,p,m,b),A({newSphereParams:C})},At=({polygon:n,size:s,imgList:p,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var C,m;const x={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(x,{trackID:V.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:h})});const I=t==null?void 0:t.toolInstance,S=y({},n);let{boxParams:L,newPointList:U}=lt(S,s,ot,void 0,x,f);if(L=H(it({tool:nt.PointCloud,dataList:[L],stepConfig:b,action:"viewUpdateBox"}))[0],(b==null?void 0:b.lowerLimitPointsNumInBox)&&typeof L.count=="number"&&L.count<b.lowerLimitPointsNumInBox){oo.info(_t("LowerLimitPointsNumInBox",{num:b.lowerLimitPointsNumInBox})),I.deletePolygon(L.id);return}f&&(U==null?void 0:U.length)&&(S.pointList=U);const k=D.includes(S.attribute);$(L);const G=a(L),et=(m=e==null?void 0:e.polygonList)!=null?m:[];t==null||t.updatePolygonList(G!=null?G:[],et),k?c([]):(c(L.id),I.selection.setSelectedIDs(S.id),M({omitView:v.Top,polygon:S,boxParams:L,zoom:l,newPointCloudBoxList:G}),f&&dt(L,S,t,o)),A({newBoxParams:L})},Ut=n=>{const{boxID:s,imageName:p,width:r,height:l,x:f,y:C}=n,m=P.find(x=>x.id===s);if(m==null?void 0:m.rects){const{rects:x=[]}=m,I=x.find(S=>S.imageName===p);if(I){let S=x;const L=O(y({},I),{width:r,height:l,x:f,y:C});S=x.map(k=>k===I?L:k);const U=O(y({},m),{rects:S}),Z=P.map(k=>k===m?U:k);return t==null||t.updatePolygonList(Z!=null?Z:[]),Z}}},Rt=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(u.length===0||!f)){if(n||(_==null?void 0:_.info)){const C=n!=null?n:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(u[0]);const m=f.selectedPolygon;if(u.length===1&&C){M({omitView:v.Top,polygon:m,boxParams:C,newPointCloudBoxList:s});return}}if((p||X)&&u.length===1){const C=p!=null?p:X;f.setSelectedID(u[0]);const m=f.selectedPoint;C&&Y(v.Top,m,C,void 0,r,b)}}},ct=(n,s,p)=>{if(at){let r,l;switch(p){case v.Back:r=po;break;case v.Side:r=Lt;break;default:r=Lt;break}l=r(n,s,at,i.pointCloudInstance);const C=H(it({tool:nt.PointCloud,dataList:[l],stepConfig:b,action:"viewUpdateBox"}))[0],m=l.valid!==C.valid;if(l=C,o){const{count:I}=o.getSensesPointZAxisInPolygon(Mt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(y({},l),{count:I})}const x=St(l);return l=x.find(I=>I.id===l.id),M({omitView:m?void 0:p,polygon:n,boxParams:l,newPointCloudBoxList:x}),x}},ut=(n,s,p)=>{if(X){let r,l;switch(p){case v.Back:r=uo;break;case v.Side:r=yt;break;default:r=yt;break}l=r(n,s,X);const f=B(l);return Y(p,n,l,void 0,f,b),f}},zt=(n,s)=>{ut(n,s,v.Side)},Tt=(n,s)=>{ut(n,s,v.Back)},jt=(n,s)=>{ct(n,s,v.Side)},Nt=(n,s)=>{ct(n,s,v.Back)},Et=(n,s)=>{const p=E(n.id),r=rt(n,s,ot,p),l=B(r);Y(v.Top,n,r,void 0,l,b)},Ht=(n,s)=>{if(j){const r=n[0].newPolygon;r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,s)),T(n[0].newPolygon);return}let p=n.map(({newPolygon:r})=>{const l=Dt(r.id),{boxParams:f}=lt(r,s,t.pointCloudInstance,l);return f});if(p=H(it({tool:nt.PointCloud,dataList:p,stepConfig:b,action:"viewUpdateBox"})),p.length===1){const{newPolygon:r}=n[0],l=tt(p);M({polygon:r,boxParams:p[0],newPointCloudBoxList:l})}else{const r=tt(p);r&&e.syncAllViewPointCloudColor(r)}},Ft=n=>{var s,p,r,l,f;if(_){const C=Number(n.widthDefault),m=Number(n.depthDefault),x=Number(n.heightDefault),I=_==null?void 0:_.info.trackID,L=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(q=>(q==null?void 0:q.trackID)===I),U={width:(r=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},Z=L.pointList.map(q=>V.transferCanvas2World(q,U)),k=w.getModifiedRectangleCoordinates(Z,x,C),G=k[0],et=k[2],pt=w.getLineCenterPoint([G,et]),Wt=_.info.center.z-_.info.depth/2,gt=O(y({},_.info),{center:{x:pt.x,y:pt.y,z:Wt+m/2},width:C,height:x,depth:m,valid:!0}),Zt=tt([gt]);M({omitView:v["3D"],polygon:L,boxParams:gt,newPointCloudBoxList:Zt})}},Y=(n,s,p,r,l,f)=>st(void 0,null,function*(){const C=W==null?void 0:W.url,m={[v.Side]:()=>{vt(p,s,i,C,f)},[v.Back]:()=>{d&&wt(p,s,d,C,f)},[v.Top]:()=>{It(p,s,t,o)}};Object.keys(m).forEach(x=>{x!==n&&m[x]()}),r&&(o==null||o.updateCameraZoom(r)),Ot(p)}),M=n=>st(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:r,zoom:l,newPointCloudBoxList:f}=n,C=W==null?void 0:W.url;f&&(yield e.syncAllViewPointCloudColor(f));const m={[v.Side]:()=>{Bt(r,p,i,C)},[v.Back]:()=>{d&&bt(r,p,d,C)},[v.Top]:()=>{dt(r,p,t,o)}};Object.keys(m).forEach(x=>{x!==s&&m[x]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(r)});return{topViewAddSphere:kt,topViewAddBox:At,topViewSelectedChanged:Rt,topViewUpdatePoint:Et,sideViewUpdatePoint:zt,backViewUpdatePoint:Tt,topViewUpdateBox:Ht,sideViewUpdateBox:jt,backViewUpdateBox:Nt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const s=V.getDefaultOrthographicParams(n);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>st(void 0,[...n],function*(s=W){var p,r,l,f,C,m;if(!(s==null?void 0:s.url)||!o)return;F([]),Ct(H,!0),Pt(H,!0),yield o.loadPCDFile(s.url,(p=b==null?void 0:b.radius)!=null?p:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],I=[],S=[],L=[];o.updateTopCamera();const U=(l=(r=ft(s.result))==null?void 0:r.valid)!=null?l:!0;e.setPointCloudValid(U),(f=e.sideViewInstance)==null||f.clearAllData(),(C=e.backViewInstance)==null||C.clearAllData(),t.updateData(s.url,s.result,{radius:(m=b==null?void 0:b.radius)!=null?m:K}),s.result&&(x=V.getBoxParamsFromResultList(s.result),S=V.getPolygonListFromResultList(s.result),I=V.getLineListFromResultList(s.result),L=V.getSphereParamsFromResultList(s.result),o==null||o.generateBoxes(x),o==null||o.generateSpheres(L),yield e.syncAllViewPointCloudColor(x,[])),N({pointCloudBoxList:x,polygonList:S,lineList:I,pointCloudSphereList:L}),Ct(H,!1),Pt(H,!1)}),updateViewsByDefaultSize:Ft,generateRects:$,update2DViewRect:Ut}};export{wt as syncBackViewByPoint,vt as syncSideViewByPoint,It as syncTopViewByPoint,bt as synchronizeBackView,Bt as synchronizeSideView,dt as synchronizeTopView,rt as topViewPoint2PointCloud,lt as topViewPolygon2PointCloud,go as usePointCloudViews};
package/es/index.css CHANGED
@@ -220,7 +220,7 @@
220
220
  }
221
221
 
222
222
  .audio-tool-spinner {
223
- height: 100%;
223
+ height: calc(100vh - 60px);
224
224
  }
225
225
  .audio-tool-spinner .ant-spin-container {
226
226
  height: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.16.0-alpha.4",
3
+ "version": "1.16.0-alpha.6",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "^4.6.2",
46
- "@labelbee/lb-annotation": "1.19.0-alpha.2",
46
+ "@labelbee/lb-annotation": "1.19.0-alpha.3",
47
47
  "@labelbee/lb-utils": "1.12.0-alpha.2",
48
48
  "@labelbee/wavesurfer": "1.0.0-alpha.3",
49
49
  "@types/react-dom": "^18.2.7",