@labelbee/lb-components 1.23.0-alpha.125 → 1.23.0-alpha.127

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"),ctx=require("../../../store/ctx.js"),reactRedux=require("react-redux"),index$7=require("../../../constant/index.js"),reducer=require("../../../store/annotation/reducer.js"),index=require("../../../utils/index.js"),index$2=require("../../LLMToolView/sidebar/components/modelAnswerSort/index.js"),reactI18next=require("react-i18next"),annotation=require("../../../hooks/annotation.js"),_=require("lodash"),actionCreators=require("../../../store/annotation/actionCreators.js"),lbAnnotation=require("@labelbee/lb-annotation"),index$3=require("../../LLMToolView/sidebar/index.js"),index$5=require("../../LLMToolView/sidebar/components/textInputBox/index.js"),antd=require("antd"),index$6=require("../../LLMToolView/sidebar/components/answerList/index.js"),index$1=require("../../../store/LLMMultiWheel/index.js"),StepUtils=require("../../../utils/StepUtils.js"),data=require("../../LLMToolView/utils/data.js"),ahooks=require("ahooks"),index$4=require("../../LLMToolView/sidebar/components/answerSort/index.js");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}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=(r,i,u)=>i in r?__defProp(r,i,{enumerable:!0,configurable:!0,writable:!0,value:u}):r[i]=u,__spreadValues=(r,i)=>{for(var u in i||(i={}))__hasOwnProp.call(i,u)&&__defNormalProp(r,u,i[u]);if(__getOwnPropSymbols)for(var u of __getOwnPropSymbols(i))__propIsEnum.call(i,u)&&__defNormalProp(r,u,i[u]);return r},__spreadProps=(r,i)=>__defProps(r,__getOwnPropDescs(i));const EKeyCode=lbAnnotation.cKeyCode.default,sidebarCls=`${index$7.prefix}-sidebar`,initGlobalResult={sort:[],answerSort:{},textAttribute:[]},LLMMultiWheelToolSidebar=r=>{var i,u,F,N,B,W,k;const{annotation:ne,dispatch:b,checkMode:re}=r,{imgIndex:E,imgList:T,stepList:y,step:M,skipBeforePageTurning:q}=ne,[d,oe]=React.useState(),{t:C}=reactI18next.useTranslation(),l=(i=T[E])!=null?i:{},z=index.jsonParser(l==null?void 0:l.result),{toolInstanceRef:v}=annotation.useCustomToolInstance({basicInfo:z}),[D,le]=React.useState(!0),[j,G]=React.useState({}),[h,K]=React.useState(initGlobalResult),$=React.useRef();React.useRef();const[p,I]=React.useState({}),{selectedID:R,setNewAnswerListMap:U,newAnswerListMap:Q}=index$1(),L=React.useMemo(()=>j[R],[R,j]),g=!v.current.valid||re;React.useEffect(()=>{var e;if(y&&M){const t=(e=reducer.getStepConfig(y,M))==null?void 0:e.config;oe(index.jsonParser(t))}},[M,JSON.stringify(y)]),React.useEffect(()=>{!l||E===-1||(v.current.setValid=J,v.current.clearResult=ie,J(),H())},[E,d,l==null?void 0:l.id]);const ie=()=>{var e,t,n,a,c;H((e=l==null?void 0:l.questionList)==null?void 0:e.textList),((t=$.current)==null?void 0:t.clearValue)&&((n=$.current)==null||n.clearValue());const{waitSorts:o}=index$2.getSorts({selectedSort:(c=(a=A())==null?void 0:a.sort)!=null?c:[],initSelected:[],modelList:w?P!=null?P:[]:[]});I(__spreadProps(__spreadValues({},p),{waitSorts:o,newSort:[]}))},J=e=>{var t;const n=e!=null?e:z.valid;_.isBoolean(n)&&(le(n),v.current.valid=n,(t=v.current)==null||t.emit("validUpdated"))},A=()=>{const e=StepUtils.getCurrentStepInfo(M,y);return data.getCurrentResultFromResultList(l==null?void 0:l.result,e.step)},H=ahooks.useMemoizedFn(e=>{var t,n,a,c,o,f,S;const s=A();let x=(t=l==null?void 0:l.questionList)==null?void 0:t.textList;((n=s==null?void 0:s.modelData)==null?void 0:n.length)&&v.current.valid&&(x=s==null?void 0:s.modelData),e&&(x=e,s.sort=[],s.textAttribute=[],s.answerSort=[]);let ee={};x==null||x.forEach((m,me)=>{var te;const ge=data.getRenderDataByResult(d,__spreadProps(__spreadValues({},m),{answerList:(te=m==null?void 0:m.answerList)==null?void 0:te.map((V,we)=>(U(__spreadProps(__spreadValues({},Q),{[`${m.id}-${V.id}`]:V.answer})),__spreadProps(__spreadValues({},V),{order:we+1})))}));ee[m.id]=__spreadProps(__spreadValues({},ge),{order:me+1,id:m.id})});const{waitSorts:Le,newSort:xe}=index$2.getSorts({selectedSort:(c=(a=A())==null?void 0:a.sort)!=null?c:[],modelList:w?P!=null?P:[]:[]});I({waitSorts:Le,newSort:xe}),K({sort:(o=s==null?void 0:s.sort)!=null?o:[],textAttribute:(f=s==null?void 0:s.textAttribute)!=null?f:[],answerSort:(S=s==null?void 0:s.answerSort)!=null?S:[]}),G(ee)});React.useEffect(()=>{ae()},[j,D,h]),React.useEffect(()=>(window.addEventListener("keydown",X),()=>{window.removeEventListener("keydown",X)}),[]);const ae=ahooks.useMemoizedFn(()=>{var e,t;const n=(t=(e=l==null?void 0:l.questionList)==null?void 0:e.textList)==null?void 0:t.map(c=>{var o;const f=(o=j[c.id])!=null?o:{};return{id:c.id,answerList:f.answerList}}),a=__spreadProps(__spreadValues({},h),{modelData:n});v.current.exportData=()=>[[a],{valid:D}],v.current.currentPageResult=__spreadProps(__spreadValues({},a),{toolName:lbAnnotation.EToolName.LLMMultiWheel,valid:D})}),X=e=>{if(e.ctrlKey&&e.keyCode===EKeyCode.Enter){if(q){q(()=>b(actionCreators.PageForward()));return}b(actionCreators.PageForward())}},se=ahooks.useMemoizedFn(({order:e,value:t,key:n})=>{const{answerList:a}=L,c=a==null?void 0:a.map(o=>{var f,S;if((o==null?void 0:o.order)===e){if(n==="textEdit"&&_.isString(t))return U(__spreadProps(__spreadValues({},Q),{[`${R}-${(f=o==null?void 0:o.id)!=null?f:""}`]:t})),__spreadProps(__spreadValues({},o),{newAnswer:t});if(_.isNumber(t))return __spreadProps(__spreadValues({},o),{score:t});if(_.isObject(t)&&n){const s={[t==null?void 0:t.key]:t.value},x=(S=o[n])!=null?S:{};return __spreadProps(__spreadValues({},o),{[n]:__spreadValues(__spreadValues({},x),s)})}}return o});G(o=>__spreadProps(__spreadValues({},o),{[R]:__spreadProps(__spreadValues({},L),{answerList:c})}))}),O=(e,t)=>{K(n=>__spreadProps(__spreadValues({},n),{[e]:t}))},{indicatorScore:Y=[],indicatorDetermine:Z=[],isTextEdit:ue,dialogSort:w=!1,inputList:de=[],tagInputListConfigurable:ce,enableSort:ve=!1}=d||{},P=React.useMemo(()=>{var e,t,n;return w?(n=(t=(e=l==null?void 0:l.questionList)==null?void 0:e.textList)==null?void 0:t.map((a,c)=>__spreadProps(__spreadValues({},a),{title:c+1})))!=null?n:[]:[]},[l,w]);if(React.useMemo(()=>index$3.getLLMIsNoConfig(d),[d]))return React__default.default.createElement(index$3.EmptyConfig,null);const fe=ce&&((u=de.filter(e=>!e.isOverall))==null?void 0:u.length)>0,pe=(Z==null?void 0:Z.length)>0||(Y==null?void 0:Y.length)>0||ue||fe;return React__default.default.createElement("div",{className:`${sidebarCls}`},React__default.default.createElement("div",{className:`${sidebarCls}__content`},React__default.default.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},C("GlobalAnnotation")),w&&React__default.default.createElement(index$4,{waitSortList:(p==null?void 0:p.waitSorts)||[],sortList:(p==null?void 0:p.newSort)||[],setSortList:e=>{const t=e.map(n=>n.map(a=>a.id));O("sort",t),I(__spreadProps(__spreadValues({},p),{newSort:e}))},disabeledAll:g,title:C("SortConversationQuality"),prefixId:"model"}),(d==null?void 0:d.text)&&React__default.default.createElement("div",{style:{padding:"0px 16px",marginTop:"16px"}},React__default.default.createElement(index$5,{textAttribute:(F=h==null?void 0:h.textAttribute)!=null?F:[],textConfig:(d==null?void 0:d.text)&&_.isArray(d.text)?d==null?void 0:d.text:[],setText:e=>O("textAttribute",e),disabeledAll:g})),ve&&React__default.default.createElement(index$2.default,{modelData:(B=(N=l==null?void 0:l.questionList)==null?void 0:N.textList)!=null?B:[],selectedAnswerSort:e=>O("answerSort",e),selectedSort:(k=(W=A())==null?void 0:W.answerSort)!=null?k:[],ref:$,disabeledAll:g}),L&&React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},C("QualifiedAnnotation")),React__default.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"}},React__default.default.createElement(antd.Button,{type:"primary",danger:!0},"\u6B63\u5728\u6807\u6CE8"),React__default.default.createElement("div",{style:{padding:16}},"\u7EC4\uFF1A",L.order)),React__default.default.createElement("div",null,pe&&React__default.default.createElement(index$6,{list:(L==null?void 0:L.answerList)||[],LLMConfig:d,updateValue:se,disabeledAll:g})))),React__default.default.createElement("div",{style:{margin:"24px 16px",display:"flex"}},(T==null?void 0:T.length)-1!==E&&React__default.default.createElement(antd.Button,{type:"primary",style:{marginLeft:"auto"},onClick:()=>{if(q){q(()=>b(actionCreators.PageForward()));return}b(actionCreators.PageForward())},disabled:g},C("Save"))))},mapStateToProps=r=>({annotation:r.annotation});var LLMMultiWheelToolSidebar$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(LLMMultiWheelToolSidebar);module.exports=LLMMultiWheelToolSidebar$1;
1
+ "use strict";var React=require("react"),ctx=require("../../../store/ctx.js"),reactRedux=require("react-redux"),index$7=require("../../../constant/index.js"),reducer=require("../../../store/annotation/reducer.js"),index=require("../../../utils/index.js"),index$2=require("../../LLMToolView/sidebar/components/modelAnswerSort/index.js"),reactI18next=require("react-i18next"),annotation=require("../../../hooks/annotation.js"),_=require("lodash"),actionCreators=require("../../../store/annotation/actionCreators.js"),lbAnnotation=require("@labelbee/lb-annotation"),index$3=require("../../LLMToolView/sidebar/index.js"),index$5=require("../../LLMToolView/sidebar/components/textInputBox/index.js"),antd=require("antd"),index$6=require("../../LLMToolView/sidebar/components/answerList/index.js"),index$1=require("../../../store/LLMMultiWheel/index.js"),StepUtils=require("../../../utils/StepUtils.js"),data=require("../../LLMToolView/utils/data.js"),ahooks=require("ahooks"),index$4=require("../../LLMToolView/sidebar/components/answerSort/index.js");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}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=(r,i,u)=>i in r?__defProp(r,i,{enumerable:!0,configurable:!0,writable:!0,value:u}):r[i]=u,__spreadValues=(r,i)=>{for(var u in i||(i={}))__hasOwnProp.call(i,u)&&__defNormalProp(r,u,i[u]);if(__getOwnPropSymbols)for(var u of __getOwnPropSymbols(i))__propIsEnum.call(i,u)&&__defNormalProp(r,u,i[u]);return r},__spreadProps=(r,i)=>__defProps(r,__getOwnPropDescs(i));const EKeyCode=lbAnnotation.cKeyCode.default,sidebarCls=`${index$7.prefix}-sidebar`,initGlobalResult={sort:[],answerSort:{},textAttribute:[]},LLMMultiWheelToolSidebar=r=>{var i,u,F,N,B,W,k;const{annotation:ne,dispatch:E,checkMode:re}=r,{imgIndex:g,imgList:T,stepList:y,step:M,skipBeforePageTurning:q}=ne,[d,oe]=React.useState(),{t:C}=reactI18next.useTranslation(),l=(i=T[g])!=null?i:{},z=index.jsonParser(l==null?void 0:l.result),{toolInstanceRef:v}=annotation.useCustomToolInstance({basicInfo:z}),[D,le]=React.useState(!0),[j,G]=React.useState({}),[h,K]=React.useState(initGlobalResult),$=React.useRef(),[p,I]=React.useState({}),{selectedID:A,setNewAnswerListMap:U,newAnswerListMap:Q}=index$1(),L=React.useMemo(()=>j[A],[A,j]),w=!v.current.valid||re;React.useEffect(()=>{var e;if(y&&M){const t=(e=reducer.getStepConfig(y,M))==null?void 0:e.config;oe(index.jsonParser(t))}},[M,JSON.stringify(y)]),React.useEffect(()=>{!l||g===-1||(v.current.setValid=J,v.current.clearResult=ie,J(),H())},[g,d,l==null?void 0:l.id]);const ie=()=>{var e,t,n,a,c;H((e=l==null?void 0:l.questionList)==null?void 0:e.textList),((t=$.current)==null?void 0:t.clearValue)&&((n=$.current)==null||n.clearValue());const{waitSorts:o}=index$2.getSorts({selectedSort:(c=(a=P())==null?void 0:a.sort)!=null?c:[],initSelected:[],modelList:S?R!=null?R:[]:[]});I(__spreadProps(__spreadValues({},p),{waitSorts:o,newSort:[]}))},J=e=>{var t;const n=e!=null?e:z.valid;_.isBoolean(n)&&(le(n),v.current.valid=n,(t=v.current)==null||t.emit("validUpdated"))},P=()=>{const e=StepUtils.getCurrentStepInfo(M,y);return data.getCurrentResultFromResultList(l==null?void 0:l.result,e.step)},H=ahooks.useMemoizedFn(e=>{var t,n,a,c,o,f,b;const s=P();let x=(t=l==null?void 0:l.questionList)==null?void 0:t.textList;((n=s==null?void 0:s.modelData)==null?void 0:n.length)&&v.current.valid&&(x=s==null?void 0:s.modelData),e&&(x=e,s.sort=[],s.textAttribute=[],s.answerSort=[]);let ee={};x==null||x.forEach((m,me)=>{var te;const ge=data.getRenderDataByResult(d,__spreadProps(__spreadValues({},m),{answerList:(te=m==null?void 0:m.answerList)==null?void 0:te.map((V,we)=>(U(__spreadProps(__spreadValues({},Q),{[`${m.id}-${V.id}`]:V.answer})),__spreadProps(__spreadValues({},V),{order:we+1})))}));ee[m.id]=__spreadProps(__spreadValues({},ge),{order:me+1,id:m.id})});const{waitSorts:Le,newSort:xe}=index$2.getSorts({selectedSort:(c=(a=P())==null?void 0:a.sort)!=null?c:[],modelList:S?R!=null?R:[]:[]});I({waitSorts:Le,newSort:xe}),K({sort:(o=s==null?void 0:s.sort)!=null?o:[],textAttribute:(f=s==null?void 0:s.textAttribute)!=null?f:[],answerSort:(b=s==null?void 0:s.answerSort)!=null?b:{}}),G(ee)});React.useEffect(()=>{ae()},[j,D,h]),React.useEffect(()=>(window.addEventListener("keydown",X),()=>{window.removeEventListener("keydown",X)}),[]);const ae=ahooks.useMemoizedFn(()=>{var e,t;const n=(t=(e=l==null?void 0:l.questionList)==null?void 0:e.textList)==null?void 0:t.map(c=>{var o;const f=(o=j[c.id])!=null?o:{};return{id:c.id,answerList:f.answerList}}),a=__spreadProps(__spreadValues({},h),{modelData:n});v.current.exportData=()=>[[a],{valid:D}],v.current.currentPageResult=__spreadProps(__spreadValues({},a),{toolName:lbAnnotation.EToolName.LLMMultiWheel,valid:D})}),X=e=>{if(e.ctrlKey&&e.keyCode===EKeyCode.Enter){if(q){q(()=>E(actionCreators.PageForward()));return}E(actionCreators.PageForward())}},se=ahooks.useMemoizedFn(({order:e,value:t,key:n})=>{const{answerList:a}=L,c=a==null?void 0:a.map(o=>{var f,b;if((o==null?void 0:o.order)===e){if(n==="textEdit"&&_.isString(t))return U(__spreadProps(__spreadValues({},Q),{[`${A}-${(f=o==null?void 0:o.id)!=null?f:""}`]:t})),__spreadProps(__spreadValues({},o),{newAnswer:t});if(_.isNumber(t))return __spreadProps(__spreadValues({},o),{score:t});if(_.isObject(t)&&n){const s={[t==null?void 0:t.key]:t.value},x=(b=o[n])!=null?b:{};return __spreadProps(__spreadValues({},o),{[n]:__spreadValues(__spreadValues({},x),s)})}}return o});G(o=>__spreadProps(__spreadValues({},o),{[A]:__spreadProps(__spreadValues({},L),{answerList:c})}))}),O=(e,t)=>{K(n=>__spreadProps(__spreadValues({},n),{[e]:t}))},{indicatorScore:Y=[],indicatorDetermine:Z=[],isTextEdit:ue,dialogSort:S=!1,inputList:de=[],tagInputListConfigurable:ce,enableSort:ve=!1}=d||{},R=React.useMemo(()=>{var e,t,n;return S?(n=(t=(e=l==null?void 0:l.questionList)==null?void 0:e.textList)==null?void 0:t.map((a,c)=>__spreadProps(__spreadValues({},a),{title:c+1})))!=null?n:[]:[]},[l,S]);if(React.useMemo(()=>index$3.getLLMIsNoConfig(d),[d]))return React__default.default.createElement(index$3.EmptyConfig,null);const fe=ce&&((u=de.filter(e=>!e.isOverall))==null?void 0:u.length)>0,pe=(Z==null?void 0:Z.length)>0||(Y==null?void 0:Y.length)>0||ue||fe;return React__default.default.createElement("div",{className:`${sidebarCls}`},React__default.default.createElement("div",{className:`${sidebarCls}__content`},React__default.default.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},C("GlobalAnnotation")),S&&React__default.default.createElement(index$4,{waitSortList:(p==null?void 0:p.waitSorts)||[],sortList:(p==null?void 0:p.newSort)||[],setSortList:e=>{const t=e.map(n=>n.map(a=>a.id));O("sort",t),I(__spreadProps(__spreadValues({},p),{newSort:e}))},disabeledAll:w,title:C("SortConversationQuality"),prefixId:"model"}),(d==null?void 0:d.text)&&React__default.default.createElement("div",{style:{padding:"0px 16px",marginTop:"16px"}},React__default.default.createElement(index$5,{textAttribute:(F=h==null?void 0:h.textAttribute)!=null?F:[],textConfig:(d==null?void 0:d.text)&&_.isArray(d.text)?d==null?void 0:d.text:[],setText:e=>O("textAttribute",e),disabeledAll:w})),ve&&React__default.default.createElement(index$2.default,{modelData:(B=(N=l==null?void 0:l.questionList)==null?void 0:N.textList)!=null?B:[],selectedAnswerSort:e=>O("answerSort",e),selectedSort:(k=(W=P())==null?void 0:W.answerSort)!=null?k:[],ref:$,disabeledAll:w,imgIndex:g}),L&&React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},C("QualifiedAnnotation")),React__default.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"}},React__default.default.createElement(antd.Button,{type:"primary",danger:!0},"\u6B63\u5728\u6807\u6CE8"),React__default.default.createElement("div",{style:{padding:16}},"\u7EC4\uFF1A",L.order)),React__default.default.createElement("div",null,pe&&React__default.default.createElement(index$6,{list:(L==null?void 0:L.answerList)||[],LLMConfig:d,updateValue:se,disabeledAll:w})))),React__default.default.createElement("div",{style:{margin:"24px 16px",display:"flex"}},(T==null?void 0:T.length)-1!==g&&React__default.default.createElement(antd.Button,{type:"primary",style:{marginLeft:"auto"},onClick:()=>{if(q){q(()=>E(actionCreators.PageForward()));return}E(actionCreators.PageForward())},disabled:w},C("Save"))))},mapStateToProps=r=>({annotation:r.annotation});var LLMMultiWheelToolSidebar$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(LLMMultiWheelToolSidebar);module.exports=LLMMultiWheelToolSidebar$1;
@@ -1 +1 @@
1
- "use strict";var React=require("react"),index=require("../../../../../constant/index.js"),antd=require("antd"),reactI18next=require("react-i18next"),icons=require("@ant-design/icons"),index$1=require("../../../../../utils/index.js"),_=require("lodash"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../../../../store/ctx.js");function _interopDefaultLegacy(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}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=(i,c,o)=>c in i?__defProp(i,c,{enumerable:!0,configurable:!0,writable:!0,value:o}):i[c]=o,__spreadValues=(i,c)=>{for(var o in c||(c={}))__hasOwnProp.call(c,o)&&__defNormalProp(i,o,c[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(c))__propIsEnum.call(c,o)&&__defNormalProp(i,o,c[o]);return i},__spreadProps=(i,c)=>__defProps(i,__getOwnPropDescs(c)),EDirection;(function(i){i.Top="Top",i.Right="Right",i.Bottom="Bottom",i.Left="Left"})(EDirection||(EDirection={}));const contentBoxCls=`${index.prefix}-LLMSidebar-contentBox`,SEGMENTATION_OF_KEY="@",Navigation=()=>{const{t:i}=reactI18next.useTranslation();return React__default.default.createElement("div",{className:`${contentBoxCls}__navigation`},React__default.default.createElement("span",null,i("Best")),React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",flex:1,margin:"0px 20px"}},React__default.default.createElement(icons.LeftOutlined,null),React__default.default.createElement("div",{style:{height:0,border:"1px solid #999999",width:"100%"}})),React__default.default.createElement("span",null,i("Worst")))},AnswerSort=i=>{const[,c]=React.useReducer(e=>e+1,0),{sortList:o,setSortList:C,waitSortList:P,disabeledAll:F,header:R,title:q,prefixId:j="answer"}=i,B=`${j}-waitBox`,v=`${j}-sortBox`,{setHoverKey:U}=React.useContext(ctx.LLMContext),[D,h]=React.useState(void 0),[b,k]=React.useState(void 0),[x,K]=React.useState([]),{t:$}=reactI18next.useTranslation();React.useEffect(()=>{K(P)},[P]),React.useEffect(()=>{G()},[JSON.stringify(o)]);const I=({item:e,operation:t,id:n})=>{const r={[`border${D}`]:"2px solid #8C9AFF"};return React__default.default.createElement("div",__spreadValues({key:`${e==null?void 0:e.id}`,color:"#EBEBEB",id:n,className:index$1.classnames({[`${contentBoxCls}__answerTag`]:!0}),style:b===(e==null?void 0:e.id)&&D?r:void 0,draggable:F||!(e==null?void 0:e.id)?"":"true",onMouseMove:()=>{U(e.id)},onMouseLeave:()=>{U(-1)}},t),e==null?void 0:e.title)},L=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),Y=(e,t)=>{const n=lbAnnotation.MathUtils.getLineLength(e,L(t.tl,t.tr)),r=lbAnnotation.MathUtils.getLineLength(e,L(t.tr,t.tr)),s=lbAnnotation.MathUtils.getLineLength(e,L(t.bl,t.br)),d=lbAnnotation.MathUtils.getLineLength(e,L(t.tl,t.bl));return{minDistance:Math.min(n,r,s,d),toTopDistance:n,toRightDistance:r,toBottompDistance:s,toLeftDistance:d}},X=(e,t)=>{const{minDistance:n,toTopDistance:r,toRightDistance:s,toBottompDistance:d,toLeftDistance:u}=Y(e,t);switch(n){case r:h(EDirection.Top);break;case s:h(EDirection.Right);break;case d:h(EDirection.Bottom);break;case u:h(EDirection.Left);break}},G=()=>{const e=document.getElementById(v);if(e==null?void 0:e.childNodes){let t=[];e.childNodes.forEach((n,r)=>{var s;let d=n;((s=n==null?void 0:n.childNodes)==null?void 0:s.length)>1&&(d=n.childNodes[0]);const u=d.getBoundingClientRect()||{},{bottom:a,top:f,left:l,right:p,width:g,height:m,x:S,y:T}=u,M={x:l+g/2,y:f+m/2},A={tl:{x:S,y:T},tr:{x:p,y:f},br:{x:p,y:a},bl:{x:l,y:a}},J=o[r].reduce((Q,w)=>{let E=w;return _.isArray(w)&&w.length>1&&(E=w[0]),E=__spreadProps(__spreadValues({},E),{tagCenterPoint:M,tagVertexPoint:A}),[...Q,E]},[]);t.push(J)}),C(t)}},N=e=>{var t,n,r,s,d,u;const a=e.pageX,f=e.pageY,l={x:a,y:f};let p=o;if((p==null?void 0:p.length)>0){let g=p[0];for(let m=0;m<p.length;m++)if(m>0){const S=(t=p[m][0])==null?void 0:t.tagCenterPoint,T=(n=g[0])==null?void 0:n.tagCenterPoint,M=lbAnnotation.MathUtils.getLineLength(l,S),A=lbAnnotation.MathUtils.getLineLength(l,T);M<A&&(g=o[m])}if(!l.x||!l.y)return;if(y(e.target.id)===((r=g[0])==null?void 0:r.id)){k(void 0);return}k((s=g[0])==null?void 0:s.id),((d=g[0])==null?void 0:d.tagVertexPoint)&&l&&X(l,(u=g[0])==null?void 0:u.tagVertexPoint)}},O=e=>{var t;const{target:n}=e;let r=-1,s=-1,d=-1,u=[],a=_.cloneDeep(o);if(d=a.findIndex(f=>f[0].id===Number(b)),((t=n==null?void 0:n.parentNode)==null?void 0:t.parentNode.id)===v){r=y(n.parentNode.id);const f=y(n.id);u=a[~~r].filter(p=>p.id===~~f);const l=a[~~r].findIndex(p=>p.id===~~f);a[~~r].splice(l,1)}if((n==null?void 0:n.parentNode.id)===v){if(!b)return;r=y(n.id),s=a.findIndex(l=>l[0].id===r);const f=a.find(l=>l[0].id===r);f&&(u=f),a.splice(s,1),d=a.findIndex(l=>l[0].id===~~b)}switch(n.parentNode.id===B&&(r=y(n.id),s=x.findIndex(f=>f.id===r),u=[x[s]],x.splice(s,1)),D){case EDirection.Left:a.splice(d,0,u);break;case EDirection.Right:a.splice(d+1,0,u);break;case EDirection.Top:case EDirection.Bottom:a[d].push(...u);break;default:a.push(u);break}C(a),h(void 0),c()},y=e=>{const t=e.indexOf(SEGMENTATION_OF_KEY);return Number(e.substring(t+1,e.length))},H=R!=null?R:React__default.default.createElement("div",{className:`${contentBoxCls}__title`},React__default.default.createElement("span",null,q!=null?q:$("RankingQualityOfAnswers")),x.length>0&&React__default.default.createElement(antd.Tag,{color:"#FFD9D9",style:{color:"#F26549",marginLeft:8}},$("Unfinished")));return React__default.default.createElement("div",{style:{padding:"0px 16px",marginBottom:"16px",width:"100%"}},H,React__default.default.createElement("div",null,React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement("span",{style:{marginRight:"16px"}},$("ToBeSorted")),React__default.default.createElement("div",{id:B,className:`${contentBoxCls}__answerBox`},x.length>0&&x.map(e=>I({item:e,id:`${B}-waitBoxItem${SEGMENTATION_OF_KEY}${e==null?void 0:e.id}`,operation:{onDrag:N,onDragEnd:O}})))),React__default.default.createElement(Navigation,null),React__default.default.createElement("div",{id:v,className:`${contentBoxCls}__answerBox`},o.map((e,t)=>{var n;return e.length>1?React__default.default.createElement("div",{key:`item-${t}`,id:`${v}${SEGMENTATION_OF_KEY}${t}`,style:{border:"1px dashed #d9d9d9"}},e.map(r=>I({item:r,id:`${v}-sortBoxItem${SEGMENTATION_OF_KEY}${r==null?void 0:r.id}`,operation:{onDrag:N,onDragEnd:O}}))):I({item:e[0],id:`${v}${SEGMENTATION_OF_KEY}${(n=e[0])==null?void 0:n.id}`,operation:{onDrag:N,onDragEnd:O}})}))))};module.exports=AnswerSort;
1
+ "use strict";var React=require("react"),index=require("../../../../../constant/index.js"),antd=require("antd"),reactI18next=require("react-i18next"),icons=require("@ant-design/icons"),index$1=require("../../../../../utils/index.js"),_=require("lodash"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../../../../store/ctx.js");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}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=(r,c,l)=>c in r?__defProp(r,c,{enumerable:!0,configurable:!0,writable:!0,value:l}):r[c]=l,__spreadValues=(r,c)=>{for(var l in c||(c={}))__hasOwnProp.call(c,l)&&__defNormalProp(r,l,c[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(c))__propIsEnum.call(c,l)&&__defNormalProp(r,l,c[l]);return r},__spreadProps=(r,c)=>__defProps(r,__getOwnPropDescs(c)),EDirection;(function(r){r.Top="Top",r.Right="Right",r.Bottom="Bottom",r.Left="Left"})(EDirection||(EDirection={}));const contentBoxCls=`${index.prefix}-LLMSidebar-contentBox`,SEGMENTATION_OF_KEY="@",Navigation=()=>{const{t:r}=reactI18next.useTranslation();return React__default.default.createElement("div",{className:`${contentBoxCls}__navigation`},React__default.default.createElement("span",null,r("Best")),React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",flex:1,margin:"0px 20px"}},React__default.default.createElement(icons.LeftOutlined,null),React__default.default.createElement("div",{style:{height:0,border:"1px solid #999999",width:"100%"}})),React__default.default.createElement("span",null,r("Worst")))},AnswerSort=r=>{const[,c]=React.useReducer(e=>e+1,0),{sortList:l,setSortList:P,waitSortList:R,disabeledAll:K,header:q,title:j,prefixId:U="answer"}=r,E=`${U}-waitBox`,v=`${U}-sortBox`,{setHoverKey:k}=React.useContext(ctx.LLMContext),[D,h]=React.useState(void 0),[b,F]=React.useState(void 0),[x,Y]=React.useState([]),{t:$}=reactI18next.useTranslation();React.useEffect(()=>{Y(R)},[R]);const I=({item:e,operation:t,id:n})=>{const a={[`border${D}`]:"2px solid #8C9AFF"};return React__default.default.createElement("div",__spreadValues({key:`${e==null?void 0:e.id}`,color:"#EBEBEB",id:n,className:index$1.classnames({[`${contentBoxCls}__answerTag`]:!0}),style:b===(e==null?void 0:e.id)&&D?a:void 0,draggable:K||!(e==null?void 0:e.id)?"":"true",onMouseMove:()=>{k(e.id)},onMouseLeave:()=>{k(-1)}},t),e==null?void 0:e.title)},L=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),X=(e,t)=>{const n=lbAnnotation.MathUtils.getLineLength(e,L(t.tl,t.tr)),a=lbAnnotation.MathUtils.getLineLength(e,L(t.tr,t.tr)),s=lbAnnotation.MathUtils.getLineLength(e,L(t.bl,t.br)),d=lbAnnotation.MathUtils.getLineLength(e,L(t.tl,t.bl));return{minDistance:Math.min(n,a,s,d),toTopDistance:n,toRightDistance:a,toBottompDistance:s,toLeftDistance:d}},G=(e,t)=>{const{minDistance:n,toTopDistance:a,toRightDistance:s,toBottompDistance:d,toLeftDistance:u}=X(e,t);switch(n){case a:h(EDirection.Top);break;case s:h(EDirection.Right);break;case d:h(EDirection.Bottom);break;case u:h(EDirection.Left);break}},N=()=>{const e=document.getElementById(v);if(e==null?void 0:e.childNodes){let t=[];e.childNodes.forEach((n,a)=>{var s;let d=n;((s=n==null?void 0:n.childNodes)==null?void 0:s.length)>1&&(d=n.childNodes[0]);const u=d.getBoundingClientRect()||{},{bottom:o,top:f,left:i,right:p,width:g,height:m,x:T,y:M}=u,A={x:i+g/2,y:f+m/2},C={tl:{x:T,y:M},tr:{x:p,y:f},br:{x:p,y:o},bl:{x:i,y:o}},Q=l[a].reduce((W,w)=>{let B=w;return _.isArray(w)&&w.length>1&&(B=w[0]),B=__spreadProps(__spreadValues({},B),{tagCenterPoint:A,tagVertexPoint:C}),[...W,B]},[]);t.push(Q)}),P(t)}},S=e=>{var t,n,a,s,d,u;const o=e.pageX,f=e.pageY,i={x:o,y:f};let p=l;if((p==null?void 0:p.length)>0){let g=p[0];for(let m=0;m<p.length;m++)if(m>0){const T=(t=p[m][0])==null?void 0:t.tagCenterPoint,M=(n=g[0])==null?void 0:n.tagCenterPoint,A=lbAnnotation.MathUtils.getLineLength(i,T),C=lbAnnotation.MathUtils.getLineLength(i,M);A<C&&(g=l[m])}if(!i.x||!i.y)return;if(y(e.target.id)===((a=g[0])==null?void 0:a.id)){F(void 0);return}F((s=g[0])==null?void 0:s.id),((d=g[0])==null?void 0:d.tagVertexPoint)&&i&&(i==null?void 0:i.x)&&(i==null?void 0:i.y)&&G(i,(u=g[0])==null?void 0:u.tagVertexPoint)}},O=e=>{var t;const{target:n}=e;let a=-1,s=-1,d=-1,u=[],o=_.cloneDeep(l);if(d=o.findIndex(f=>f[0].id===Number(b)),((t=n==null?void 0:n.parentNode)==null?void 0:t.parentNode.id)===v){a=y(n.parentNode.id);const f=y(n.id);u=o[~~a].filter(p=>p.id===~~f);const i=o[~~a].findIndex(p=>p.id===~~f);o[~~a].splice(i,1)}if((n==null?void 0:n.parentNode.id)===v){if(!b)return;a=y(n.id),s=o.findIndex(i=>i[0].id===a);const f=o.find(i=>i[0].id===a);f&&(u=f),o.splice(s,1),d=o.findIndex(i=>i[0].id===~~b)}switch(n.parentNode.id===E&&(a=y(n.id),s=x.findIndex(f=>f.id===a),u=[x[s]],x.splice(s,1)),D){case EDirection.Left:o.splice(d,0,u);break;case EDirection.Right:o.splice(d+1,0,u);break;case EDirection.Top:case EDirection.Bottom:o[d].push(...u);break;default:o.push(u);break}P(o),h(void 0),c()},y=e=>{const t=e.indexOf(SEGMENTATION_OF_KEY);return Number(e.substring(t+1,e.length))},H=q!=null?q:React__default.default.createElement("div",{className:`${contentBoxCls}__title`},React__default.default.createElement("span",null,j!=null?j:$("RankingQualityOfAnswers")),x.length>0&&React__default.default.createElement(antd.Tag,{color:"#FFD9D9",style:{color:"#F26549",marginLeft:8}},$("Unfinished")));return React__default.default.createElement("div",{style:{padding:"0px 16px",marginBottom:"16px",width:"100%"}},H,React__default.default.createElement("div",null,React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement("span",{style:{marginRight:"16px"}},$("ToBeSorted")),React__default.default.createElement("div",{id:E,className:`${contentBoxCls}__answerBox`},x.length>0&&x.map(e=>I({item:e,id:`${E}-waitBoxItem${SEGMENTATION_OF_KEY}${e==null?void 0:e.id}`,operation:{onDrag:S,onDragEnd:O,onDragStart:()=>N()}})))),React__default.default.createElement(Navigation,null),React__default.default.createElement("div",{id:v,className:`${contentBoxCls}__answerBox`},l.map((e,t)=>{var n;return e.length>1?React__default.default.createElement("div",{key:`item-${t}`,id:`${v}${SEGMENTATION_OF_KEY}${t}`,style:{border:"1px dashed #d9d9d9"}},e.map(a=>I({item:a,id:`${v}-sortBoxItem${SEGMENTATION_OF_KEY}${a==null?void 0:a.id}`,operation:{onDrag:S,onDragEnd:O,onDragStart:()=>N()}}))):I({item:e[0],id:`${v}${SEGMENTATION_OF_KEY}${(n=e[0])==null?void 0:n.id}`,operation:{onDrag:S,onDragEnd:O,onDragStart:()=>N()}})}))))};module.exports=AnswerSort;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),reactI18next=require("react-i18next"),ahooks=require("ahooks"),index=require("../answerSort/index.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}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=(t,r,s)=>r in t?__defProp(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s,__spreadValues=(t,r)=>{for(var s in r||(r={}))__hasOwnProp.call(r,s)&&__defNormalProp(t,s,r[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(r))__propIsEnum.call(r,s)&&__defNormalProp(t,s,r[s]);return t},__spreadProps=(t,r)=>__defProps(t,__getOwnPropDescs(r));const getSorts=({selectedSort:t,initSelected:r,modelList:s})=>{const a=r!=null?r:t;let p=[];const m=s.filter(i=>!(a&&(a==null?void 0:a.length)>0?a.flat():[]).includes(i.id));return a&&(a==null?void 0:a.length)>0&&(p=a.map(i=>i.map(u=>s.find(w=>w.id===u)))),{waitSorts:m,newSort:p}},ModelAnswerSort=(t,r)=>{const{selectedSort:s,modelData:a,selectedAnswerSort:p,disabeledAll:m}=t,[i,u]=React.useState({waitSorts:{},selecteds:s}),{t:w}=reactI18next.useTranslation(),g=React.useMemo(()=>a.map((l,o)=>__spreadProps(__spreadValues({},l),{title:o+1})),[a]),_=React.useMemo(()=>a.reduce((n,e)=>e.answerList.length>n.length?e.answerList:n,[]).map((n,e)=>({id:n.id,title:`${e+1}`}))||[],[a]);React.useEffect(()=>{s&&S()},[a]);const x=l=>(g.filter(n=>n.answerList.some(e=>e.id===l))||[]).map(n=>__spreadProps(__spreadValues({},n),{id:n.id,title:n.title})),S=l=>{const o=i,n=l!=null?l:s;_.forEach(e=>{const d=x(e.id),c=n==null?void 0:n[e.id],{waitSorts:f,newSort:v}=getSorts({selectedSort:c,modelList:d});o.waitSorts[e.id]=f,o.selecteds[e.id]=v}),u(o)};React.useImperativeHandle(r,()=>({clearValue:()=>S({})}),[a]);const h=(l,o)=>{if(o.some(e=>e.some(d=>d==null?void 0:d.id))){const e=__spreadProps(__spreadValues({},i.selecteds),{[l]:o}),d={};Object.keys(e).forEach(c=>{d[c]=e[c].map(f=>f.map(v=>v.id))}),p(d),u(__spreadProps(__spreadValues({},i),{selecteds:e}))}},{run:y}=ahooks.useDebounceFn(h,{wait:10});return React__default.default.createElement("div",null,React__default.default.createElement("div",{style:{fontWeight:500,fontSize:"16px",width:"100%",lineHeight:"46px",padding:"0px 16px"}},React__default.default.createElement("span",null,w("RankingQualityOfAnswers"))),_.map((l,o)=>{var n,e,d,c;return React__default.default.createElement("div",{key:o,style:{display:"flex"}},React__default.default.createElement("div",{style:{fontSize:"16px",fontWeight:500,width:"80px",lineHeight:"50px",textAlign:"center"}},`${w("Answer")}${o+1}`),React__default.default.createElement(index,{waitSortList:(e=(n=i==null?void 0:i.waitSorts)==null?void 0:n[l.id])!=null?e:[],sortList:(c=(d=i==null?void 0:i.selecteds)==null?void 0:d[l.id])!=null?c:[],setSortList:f=>{y(l.id,f)},disabeledAll:m,header:"",prefixId:`modelAnswer${o}`}))}))};var ModelAnswerSort$1=React.forwardRef(ModelAnswerSort);exports.default=ModelAnswerSort$1,exports.getSorts=getSorts;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),reactI18next=require("react-i18next"),ahooks=require("ahooks"),index=require("../answerSort/index.js"),antd=require("antd"),_=require("lodash");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}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=(t,r,s)=>r in t?__defProp(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s,__spreadValues=(t,r)=>{for(var s in r||(r={}))__hasOwnProp.call(r,s)&&__defNormalProp(t,s,r[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(r))__propIsEnum.call(r,s)&&__defNormalProp(t,s,r[s]);return t},__spreadProps=(t,r)=>__defProps(t,__getOwnPropDescs(r));const getSorts=({selectedSort:t,initSelected:r,modelList:s})=>{const l=r!=null?r:t;let p=[];const m=s.filter(c=>!(l&&(l==null?void 0:l.length)>0?l.flat():[]).includes(c.id));return l&&(l==null?void 0:l.length)>0&&(p=l.map(c=>c.map(i=>s.find(w=>w.id===i)))),{waitSorts:m,newSort:p}},ModelAnswerSort=(t,r)=>{const{selectedSort:s,modelData:l,selectedAnswerSort:p,disabeledAll:m,imgIndex:c}=t,[i,w]=React.useState({waitSorts:{},selecteds:s}),{t:v}=reactI18next.useTranslation(),x=React.useMemo(()=>l.map((a,o)=>__spreadProps(__spreadValues({},a),{title:o+1})),[l,c]),S=React.useMemo(()=>l.reduce((n,e)=>e.answerList.length>n.length?e.answerList:n,[]).map((n,e)=>({id:n.id,title:`${e+1}`}))||[],[l,c]);React.useEffect(()=>{s&&h()},[l,c]);const y=a=>(x.filter(n=>n.answerList.some(e=>e.id===a))||[]).map(n=>__spreadProps(__spreadValues({},n),{id:n.id,title:n.title})),h=a=>{const o=i,n=a!=null?a:s;S.forEach(e=>{const d=y(e.id),u=n==null?void 0:n[e.id],{waitSorts:f,newSort:g}=getSorts({selectedSort:u,modelList:d});o.waitSorts[e.id]=f,o.selecteds[e.id]=g}),w(o)};React.useImperativeHandle(r,()=>({clearValue:()=>h({})}),[l,c]);const O=(a,o)=>{if(o.some(e=>e.some(d=>d==null?void 0:d.id))){const e=__spreadProps(__spreadValues({},i.selecteds),{[a]:o}),d={};Object.keys(e).forEach(u=>{d[u]=e[u].map(f=>f.map(g=>g.id))}),p(d),w(__spreadProps(__spreadValues({},i),{selecteds:e}))}},{run:D}=ahooks.useDebounceFn(O,{wait:0}),P=Object.keys(i.waitSorts).some(a=>S.some(o=>o.id===a)&&_.isArray(i.waitSorts[a])&&i.waitSorts[a].length>0);return React__default.default.createElement("div",null,React__default.default.createElement("div",{style:{fontWeight:500,fontSize:"16px",width:"100%",lineHeight:"46px",padding:"0px 16px"}},React__default.default.createElement("span",null,v("RankingQualityOfAnswers")),P&&React__default.default.createElement(antd.Tag,{color:"#FFD9D9",style:{color:"#F26549",marginLeft:8}},v("Unfinished"))),S.map((a,o)=>{var n,e,d,u;return React__default.default.createElement("div",{key:o,style:{display:"flex"}},React__default.default.createElement("div",{style:{fontSize:"16px",fontWeight:500,width:"80px",lineHeight:"50px",textAlign:"center"}},`${v("Answer")}${o+1}`),React__default.default.createElement(index,{waitSortList:(e=(n=i==null?void 0:i.waitSorts)==null?void 0:n[a.id])!=null?e:[],sortList:(u=(d=i==null?void 0:i.selecteds)==null?void 0:d[a.id])!=null?u:[],setSortList:f=>{D(a.id,f)},disabeledAll:m,header:"",prefixId:`modelAnswer${o}`}))}))};var ModelAnswerSort$1=React.forwardRef(ModelAnswerSort);exports.default=ModelAnswerSort$1,exports.getSorts=getSorts;
@@ -1 +1 @@
1
- "use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),reactI18next=require("react-i18next"),actionCreators=require("../../store/annotation/actionCreators.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,r,l)=>r in i?__defProp(i,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[r]=l,__spreadValues=(i,r)=>{for(var l in r||(r={}))__hasOwnProp.call(r,l)&&__defNormalProp(i,l,r[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(r))__propIsEnum.call(r,l)&&__defNormalProp(i,l,r[l]);return i},__spreadProps=(i,r)=>__defProps(i,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:i,config:r,checkMode:l,configString:_,imgIndex:f,toolInstanceRef:u,setResourceLoading:B})=>{const e=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:E,selectNextBox:L,selectPrevBox:q,updateSelectedBox:C,deleteSelectedPointCloudBoxAndPolygon:I}=useSingleBox.useSingleBox(),{selectedSphere:b,updatePointCloudSphere:O}=useSphere.useSphere(),{clearAllResult:w,updatePointCloudPattern:A}=useStatus.useStatus(),{copySelectedBoxes:j,pasteSelectedBoxes:T,copiedBoxes:$}=useBoxes.useBoxes({config:r,currentData:i}),{updateRotate:g}=useRotate.useRotate({currentData:i}),{updateRotateEdge:D}=useRotateEdge.useRotateEdge({currentData:i}),{updatePointCloudData:v,topViewSelectedChanged:m}=usePointCloudViews.usePointCloudViews({setResourceLoading:B}),{redo:h,undo:x,pushHistoryWithList:N,pushHistoryUnderUpdatePolygon:R,pushHistoryUnderUpdateLine:H}=useHistory.useHistory(),K=ctx.useDispatch(),{syncThreeViewsAttribute:S}=useAttribute.useAttribute(),{syncAllViewsConfig:U,reRenderTopViewRange:z}=useConfig.useConfig(),{selectedPolygon:k}=usePolygon.usePolygon(),{selectedLine:V}=useLine.useLine(),{t:y}=reactI18next.useTranslation(),F=ahooks.useLatest(i),P=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},G=(t,o)=>{var s,a;const{topViewInstance:c,mainViewInstance:n}=e;if(!c)return;const{pointCloud2dOperation:d}=c;switch(t){case"q":{g(e.rectRotateSensitivity);break}case"e":g(-Number(e.rectRotateSensitivity));break;case"g":D(-90);break;case"u":{const p=d.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;A(p);const Y={[lbAnnotation.EToolName.Polygon]:y("PolygonPattern"),[lbAnnotation.EToolName.Rect]:y("RectPattern")};antd.message.success(y("ChangePatternMsg",{pattern:Y[p]})),d.clearActiveStatus(),d.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){q();break}L(),o.preventDefault();break;case"f":E();break;case"arrowup":P({y:-1});break;case"arrowdown":P({y:1});break;case"arrowleft":P({x:-1});break;case"arrowright":P({x:1});break;case"delete":I(F.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const p=lbAnnotation.AttributeUtils.getAttributeByKeycode(o.keyCode,r.attributeList);p!==void 0&&((a=u.current)==null||a.setDefaultAttribute(p))}return}}},M=(t,o)=>{switch(t){case"c":j();break;case"v":T();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?h():x();break}}},W=ahooks.useLatest(t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t)||l===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){M(o,t);return}G(o,t)});return React.useEffect(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>W.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),React.useEffect(()=>{U(r)},[_]),React.useEffect(()=>{(r==null?void 0:r.radius)&&z(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{v==null||v()},[f,e.mainViewInstance]),React.useEffect(()=>{e.setHideAttributes([])},[f]),React.useEffect(()=>{u.current.setDefaultAttribute=t=>{var o,s,a,c;S(t);const n=e.selectedPointCloudBox;if(n){n.attribute=t;const d=K(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[n],stepConfig:r,action:"viewUpdateBox"}));n.valid=d[0].valid;const p=C(n);(a=(s=(o=e==null?void 0:e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:s.setPolygonValidAndRender)==null||a.call(s,n.id,!0,n.valid),e.mainViewInstance&&(m({newSelectedBox:n,newPointCloudList:p}),e.mainViewInstance.generateBoxes(p))}if(k&&R(__spreadProps(__spreadValues({},k),{attribute:t})),V&&H(__spreadProps(__spreadValues({},V),{attribute:t})),b){const d=O(__spreadProps(__spreadValues({},b),{attribute:t}));e.mainViewInstance&&((c=e.mainViewInstance)==null||c.generateSpheres(d),m({newSelectedSphere:b,newSphereList:d}))}},u.current.setSubAttribute=(t,o)=>{var s;const a=e.selectedPointCloudBox;if(a){const c=(s=a==null?void 0:a.subAttribute)!=null?s:{};a.subAttribute=__spreadProps(__spreadValues({},c),{[t]:o}),C(a),e.mainViewInstance&&e.selectedPointCloudBox&&e.mainViewInstance.generateBox(e.selectedPointCloudBox)}},u.current.clearResult=()=>{w==null||w()},u.current.redo=()=>{h()},u.current.undo=()=>{x()},u.current.setValid=t=>{u.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&w()})},u.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},u.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},u.current.asyncData=t=>{setTimeout(()=>{v==null||v(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),React.useEffect(()=>{u.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},u.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),React.useEffect(()=>{u.current.history={pushHistory:t=>{N({pointCloudBoxList:t})},initRecord:()=>{}}},[]),React.useEffect(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||l)return;const s=n=>{S(n)},a=n=>{antd.message.error(n)},c=n=>{antd.message.info(n)};return o.on("syncAttribute",s),o.on("messageError",a),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",a),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var PointCloudListener$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudListener);module.exports=PointCloudListener$1;
1
+ "use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),useUpdatePointCloudColor=require("./hooks/useUpdatePointCloudColor.js"),reactI18next=require("react-i18next"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,r,i)=>r in n?__defProp(n,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[r]=i,__spreadValues=(n,r)=>{for(var i in r||(r={}))__hasOwnProp.call(r,i)&&__defNormalProp(n,i,r[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(r))__propIsEnum.call(r,i)&&__defNormalProp(n,i,r[i]);return n},__spreadProps=(n,r)=>__defProps(n,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:n,config:r,checkMode:i,configString:_,imgIndex:w,toolInstanceRef:a,setResourceLoading:f})=>{const e=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:V,selectNextBox:E,selectPrevBox:B,updateSelectedBox:L,deleteSelectedPointCloudBoxAndPolygon:q}=useSingleBox.useSingleBox(),{selectedSphere:b,updatePointCloudSphere:I}=useSphere.useSphere(),{clearAllResult:P,updatePointCloudPattern:O}=useStatus.useStatus(),{copySelectedBoxes:j,pasteSelectedBoxes:A,copiedBoxes:$}=useBoxes.useBoxes({config:r,currentData:n}),{updateRotate:g}=useRotate.useRotate({currentData:n}),{updateRotateEdge:T}=useRotateEdge.useRotateEdge({currentData:n}),{updatePointCloudData:p,topViewSelectedChanged:D}=usePointCloudViews.usePointCloudViews({setResourceLoading:f}),{redo:h,undo:m,pushHistoryWithList:N,pushHistoryUnderUpdatePolygon:H,pushHistoryUnderUpdateLine:K}=useHistory.useHistory(),{syncThreeViewsAttribute:S}=useAttribute.useAttribute(),{syncAllViewsConfig:U,reRenderTopViewRange:R}=useConfig.useConfig(),{selectedPolygon:k}=usePolygon.usePolygon(),{selectedLine:x}=useLine.useLine(),{t:y}=reactI18next.useTranslation(),{updatePointCloudColor:z}=useUpdatePointCloudColor.useUpdatePointCloudColor(f,r),F=ahooks.useLatest(n),v=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},G=(t,o)=>{var s,u;const{topViewInstance:c,mainViewInstance:l}=e;if(!c)return;const{pointCloud2dOperation:C}=c;switch(t){case"q":{g(e.rectRotateSensitivity);break}case"e":g(-Number(e.rectRotateSensitivity));break;case"g":T(-90);break;case"u":{const d=C.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;O(d);const Y={[lbAnnotation.EToolName.Polygon]:y("PolygonPattern"),[lbAnnotation.EToolName.Rect]:y("RectPattern")};antd.message.success(y("ChangePatternMsg",{pattern:Y[d]})),C.clearActiveStatus(),C.clearDrawingStatus()}break;case"+":l==null||l.updatePointSize({zoomIn:!0});break;case"-":l==null||l.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){B();break}E(),o.preventDefault();break;case"f":V();break;case"arrowup":v({y:-1});break;case"arrowdown":v({y:1});break;case"arrowleft":v({x:-1});break;case"arrowright":v({x:1});break;case"delete":q(F.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const d=lbAnnotation.AttributeUtils.getAttributeByKeycode(o.keyCode,r.attributeList);d!==void 0&&((u=a.current)==null||u.setDefaultAttribute(d))}return}}},M=(t,o)=>{switch(t){case"c":j();break;case"v":A();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?h():m();break}}},W=ahooks.useLatest(t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t)||i===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){M(o,t);return}G(o,t)});return React.useEffect(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>W.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),React.useEffect(()=>{U(r)},[_]),React.useEffect(()=>{(r==null?void 0:r.radius)&&R(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{p==null||p()},[w,e.mainViewInstance]),React.useEffect(()=>{e.setHideAttributes([])},[w]),React.useEffect(()=>{a.current.setDefaultAttribute=t=>{var o;if(S(t),z(t),k&&H(__spreadProps(__spreadValues({},k),{attribute:t})),x&&K(__spreadProps(__spreadValues({},x),{attribute:t})),b){const s=I(__spreadProps(__spreadValues({},b),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),D({newSelectedSphere:b,newSphereList:s}))}},a.current.setSubAttribute=(t,o)=>{var s;const u=e.selectedPointCloudBox;if(u){const c=(s=u==null?void 0:u.subAttribute)!=null?s:{};u.subAttribute=__spreadProps(__spreadValues({},c),{[t]:o}),L(u),e.mainViewInstance&&e.selectedPointCloudBox&&e.mainViewInstance.generateBox(e.selectedPointCloudBox)}},a.current.clearResult=()=>{P==null||P()},a.current.redo=()=>{h()},a.current.undo=()=>{m()},a.current.setValid=t=>{a.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&P()})},a.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},a.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},a.current.asyncData=t=>{setTimeout(()=>{p==null||p(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),React.useEffect(()=>{a.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},a.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),React.useEffect(()=>{a.current.history={pushHistory:t=>{N({pointCloudBoxList:t})},initRecord:()=>{}}},[]),React.useEffect(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||i)return;const s=l=>{S(l)},u=l=>{antd.message.error(l)},c=l=>{antd.message.info(l)};return o.on("syncAttribute",s),o.on("messageError",u),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",u),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var PointCloudListener$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudListener);module.exports=PointCloudListener$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"),_=require("lodash"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,n,t)=>n in o?__defProp(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,__spreadValues=(o,n)=>{for(var t in n||(n={}))__hasOwnProp.call(n,t)&&__defNormalProp(o,t,n[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(n))__propIsEnum.call(n,t)&&__defNormalProp(o,t,n[t]);return o},__spreadProps=(o,n)=>__defProps(o,__getOwnPropDescs(n)),__async=(o,n,t)=>new Promise((u,p)=>{var e=d=>{try{c(t.next(d))}catch(x){p(x)}},P=d=>{try{c(t.throw(d))}catch(x){p(x)}},c=d=>d.done?u(d.value):Promise.resolve(d.value).then(e,P);c((t=t.apply(o,n)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,n,t,u,p)=>{const{x:e,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,n),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:e,y:P,z:c},id:o.id},x=u?__spreadValues(__spreadValues({},u),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},topViewPolygon2PointCloud=(o,n,t,u,p,e)=>{let P=o.pointList.map(B=>lbUtils.PointCloudUtils.transferCanvas2World(B,n)),c=0,d=1,x={};if(t){const B=t.getSensesPointZAxisInPolygon(P,void 0,e);e&&B.fittedCoordinates.length>0&&(P=B.fittedCoordinates),c=(B.maxZ+B.minZ)/2,d=B.maxZ-B.minZ,x={count:B.zCount}}const[f,L,R]=P,S=lbAnnotation.MathUtils.getLineCenterPoint([f,R]),w=lbAnnotation.MathUtils.getLineLength(f,L),V=lbAnnotation.MathUtils.getLineLength(L,R),T=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);u&&(c=u.center.z,d=u.depth);const k={center:{x:S.x,y:S.y,z:c},width:e?V+INTELLIGENT_FIT_MARGIN:V,height:e?w+INTELLIGENT_FIT_MARGIN:w,depth:d,rotation:T,id:o.id},O=__spreadValues(u?__spreadValues(__spreadValues({},u),k):__spreadProps(__spreadValues({},k),{attribute:"",valid:!0}),x);p&&Object.assign(O,p);const M=P.map(B=>lbUtils.PointCloudUtils.transferWorld2Canvas(B,n));return{boxParams:O,newPointList:M}},sideViewPoint2PointCloud=(o,n,t)=>{const u={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-u.x,y:t.center.y,z:t.center.z-u.y}})},sideViewPolygon2PointCloud=(o,n,t,u)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),S={x:{x:f.x-L.x,y:f.y-L.y}.x,y:0,z:f.y-L.y},w=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(d,x),M=k-O,{newBoxParams:B}=u.getNewBoxBySideUpdate(S,M,T,t);return B},backViewPoint2PointCloud=(o,n,t)=>{const u={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x,y:t.center.y-u.x,z:t.center.z-u.y}})},backViewPolygon2PointCloud=(o,n,t,u)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),S={x:{x:f.x-L.x,y:f.y-L.y}.x,y:0,z:f.y-L.y},w=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(d,x),M=k-O;let{newBoxParams:B}=u.getNewBoxByBackUpdate(S,M,T,t);return B},syncSideViewByPoint=(o,n,t,u,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(u,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(d);const{point2d:x,zoom:f}=c.getSphereSidePoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},n),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},synchronizeSideView=(o,n,t,u)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(u,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);e.setInitCameraPosition(P);const{polygon2d:c,zoom:d}=e.getBoxSidePolygon2DCoordinate(o);e.camera.zoom=d,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncBackViewByPoint=(o,n,t,u,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(u,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(d);const{point2d:x,zoom:f}=c.getSphereBackPoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},n),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},synchronizeBackView=(o,n,t,u)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(u,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);e.setInitCameraPosition(P);const{polygon2d:c,zoom:d}=e.getBoxBackPolygon2DCoordinate(o);e.camera.zoom=d,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncTopViewByPoint=(o,n,t,u)=>{if(!t||!u)return;u.generateSphere(o),u.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),u.render();const{toolInstance:p,pointCloudInstance:e}=t,{point2d:P}=e.getSphereTopPoint2DCoordinate(o),c=[...p.pointList].map(d=>d.id===n.id?__spreadProps(__spreadValues(__spreadValues({},n),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):d);p.setResult(c),p.setSelectedID(n.id)},synchronizeTopView=(o,n,t,u)=>{var p,e;if(!t||!u)return;u.generateBox(o,n.id),u.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=t,{polygon2d:d}=c.getBoxTopPolygon2DCoordinate(o),x=[...P.polygonList],f=x.find(L=>L.id===n.id);f?(f.pointList=d,f.valid=(p=o.valid)!=null?p:!0):x.push({id:n.id,pointList:d,textAttribute:"",isRect:!0,valid:(e=o.valid)!=null?e:!0}),P.setResultAndSelectedID(x,n.id)},usePointCloudViews=o=>{const n=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:u,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:d,selectedIDs:x,pointCloudBoxList:f,pointCloudSphereList:L,hideAttributes:R,setHighlight2DDataList:S,cuboidBoxIn2DView:w,imageSizes:V,history:T,linkageImageNameRectMap:k}=n,{addHistory:O,initHistory:M,pushHistoryUnderUpdatePolygon:B}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:nt,updatePointCloudSphere:Y,selectedSphere:F}=useSphere.useSphere(),{currentData:j,config:y}=ctx.useSelector(s=>{const{stepList:i,step:a,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(a,i).config)}}),z=ctx.useDispatch(),it=ahooks.useLatest(w),st=ahooks.useLatest(k),rt=React.useCallback((s,i)=>{const a=st.current,r=i.id;return s.filter(g=>{if(!g)return!1;const C=a.get(g.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),J=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!it.current||i){const{mappingImgList:a=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:a,imageSizes:V},{prepareRectsFn:rt})}},{selectedBox:U,updateSelectedBox:lt,updateSelectedBoxes:Q,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:J}),K=U==null?void 0:U.info;if(!t||!u||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=t,dt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},ut=({newPoint:s,size:i,zoom:a,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:L})});const C=topViewPoint2PointCloud(s,i,X,void 0,g);d(s.id);const h=c(C);W(PointCloudView.Top,s,C,a,h,y),O({newSphereParams:C})},ct=({polygon:s,size:i,imgList:a,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,h,m;const D={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(D,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:L})});const I=t==null?void 0:t.toolInstance,b=__spreadValues({},s);let{boxParams:v,newPointList:A}=topViewPolygon2PointCloud(b,i,X,void 0,D,g);v=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[v],stepConfig:y,action:"viewUpdateBox"}))[0],g&&(A==null?void 0:A.length)&&(b.pointList=A);const N=R.includes(b.attribute);J(v);const H=P(v),Z=(h=n==null?void 0:n.polygonList)!=null?h:[];v.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(m=y==null?void 0:y.inputList)!=null?m:[]:[]),t==null||t.updatePolygonList(H!=null?H:[],Z),N?d([]):(d(v.id),I.selection.setSelectedIDs(b.id),E({omitView:PointCloudView.Top,polygon:b,boxParams:v,zoom:l,newPointCloudBoxList:H}),g&&synchronizeTopView(v,b,t,e)),O({newBoxParams:v})},pt=s=>{const{boxID:i,imageName:a,width:r,height:l,x:g,y:C}=s,h=f.find(v=>v.id===i);if(!(h==null?void 0:h.rects)||!h.rects.find(v=>v.imageName===a))return;const D=h.rects.map(v=>v.imageName===a?__spreadProps(__spreadValues({},v),{width:r,height:l,x:g,y:C}):v),I=__spreadProps(__spreadValues({},h),{rects:D}),b=f.map(v=>v.id===i?I:v);return t==null||t.updatePolygonList(b!=null?b:[]),b},gt=s=>{const{boxID:i,imageName:a}=s,r=f.find(h=>h.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(h=>h.imageName!==a),g=__spreadProps(__spreadValues({},r),{rects:l}),C=f.map(h=>h.id===i?g:h);return t==null||t.updatePolygonList(C!=null?C:[]),C},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:a,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(x.length===0||!g)){if(s||(U==null?void 0:U.info)){const C=s!=null?s:U==null?void 0:U.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(x[0]);const h=g.selectedPolygon;if(x.length===1&&C){E({omitView:PointCloudView.Top,polygon:h,boxParams:C,newPointCloudBoxList:i});return}}if((a||F)&&x.length===1){const C=a!=null?a:F;g.setSelectedID(x[0]);const h=g.selectedPoint;C&&W(PointCloudView.Top,h,C,void 0,r,y)}}},$=(s,i,a)=>{if(K){let r,l;switch(a){case PointCloudView.Back:r=backViewPolygon2PointCloud;break;case PointCloudView.Side:r=sideViewPolygon2PointCloud;break;default:r=sideViewPolygon2PointCloud;break}if(l=r(s,i,K,u.pointCloudInstance),e){const{count:D}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:D})}const C=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:y,action:"viewUpdateBox"}))[0],h=l.valid!==C.valid;l=C;const m=lt(l);return l=m.find(D=>D.id===l.id),E({omitView:h?void 0:a,polygon:s,boxParams:l,newPointCloudBoxList:m}),m}},tt=(s,i,a)=>{if(F){let r,l;switch(a){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}l=r(s,i,F);const g=Y(l);return W(a,s,l,void 0,g,y),g}},Ct=(s,i)=>{tt(s,i,PointCloudView.Side)},ft=(s,i)=>{tt(s,i,PointCloudView.Back)},ht=(s,i)=>{$(s,i,PointCloudView.Side)},xt=(s,i)=>{$(s,i,PointCloudView.Back)},vt=(s,i)=>{const a=nt(s.id),r=topViewPoint2PointCloud(s,i,X,a),l=Y(r);W(PointCloudView.Top,s,r,void 0,l,y)},Lt=(s,i)=>{if(ot){const r=__spreadValues({},s[0].newPolygon);r.pointList=r.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,i)),B(r);return}let a=s.map(({newPolygon:r})=>{const l=at(r.id),{boxParams:g}=topViewPolygon2PointCloud(r,i,t.pointCloudInstance,l);return g});if(a=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:a,stepConfig:y,action:"viewUpdateBox"})),a.length===1){const{newPolygon:r}=s[0],l=Q(a);E({polygon:r,boxParams:a[0],newPointCloudBoxList:l})}else{const r=Q(a);r&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,r)}},yt=s=>{var i,a,r,l,g;if(U){const C=Number(s.widthDefault),h=Number(s.depthDefault),m=Number(s.heightDefault),D=U==null?void 0:U.info.trackID,b=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(G=>(G==null?void 0:G.trackID)===D),v={width:(r=(a=t==null?void 0:t.toolInstance)==null?void 0:a.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},A=b.pointList.map(G=>lbUtils.PointCloudUtils.transferCanvas2World(G,v)),q=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(A,m,C),N=q[0],H=q[2],Z=lbAnnotation.MathUtils.getLineCenterPoint([N,H]),mt=U.info.center.z-U.info.depth/2,et=__spreadProps(__spreadValues({},U.info),{center:{x:Z.x,y:Z.y,z:mt+h/2},width:C,height:m,depth:h,valid:!0}),Bt=Q([et]);E({omitView:PointCloudView["3D"],polygon:b,boxParams:et,newPointCloudBoxList:Bt})}},W=(s,i,a,r,l,g)=>__async(void 0,null,function*(){const C=j==null?void 0:j.url,h={[PointCloudView.Side]:()=>{syncSideViewByPoint(a,i,u,C,g)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(a,i,p,C,g)},[PointCloudView.Top]:()=>{syncTopViewByPoint(a,i,t,e)}};Object.keys(h).forEach(m=>{m!==s&&h[m]()}),r&&(e==null||e.updateCameraZoom(r)),dt(a)}),E=s=>{const{omitView:i,polygon:a,boxParams:r,zoom:l,newPointCloudBoxList:g}=s,C=j==null?void 0:j.url;g&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single,g);const h={[PointCloudView.Side]:()=>{synchronizeSideView(r,a,u,C)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(r,a,p,C)},[PointCloudView.Top]:()=>{synchronizeTopView(r,a,t,e)}};Object.keys(h).forEach(m=>{m!==i&&h[m]()}),l&&(e==null||e.updateCameraZoom(l))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:ht,backViewUpdateBox:xt,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),e==null||e.generateBoxes(s)},initPointCloud3d:s=>{if(!e)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(s);e.initOrthographicCamera(i),e.initRenderer(),e.render()},updatePointCloudData:(...s)=>__async(void 0,[...s],function*(i=j){var a,r,l,g,C,h,m,D;if(!(i==null?void 0:i.url)||!e)return;S([]),actionCreators.SetAnnotationLoading(z,!0),actionCreators.SetLoadPCDFileLoading(z,!0),(a=o==null?void 0:o.setResourceLoading)==null||a.call(o,!0),yield e.loadPCDFile(i.url,(r=y==null?void 0:y.radius)!=null?r:DEFAULT_RADIUS),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let I=[],b=[],v=[],A=[];e.updateTopCamera();const q=(g=(l=index.jsonParser(i.result))==null?void 0:l.valid)!=null?g:!0;if(n.setPointCloudValid(q),(C=n.sideViewInstance)==null||C.clearAllData(),(h=n.backViewInstance)==null||h.clearAllData(),i.result){if(I=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(I==null?void 0:I.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){I=yield e==null?void 0:e.filterPreResult(i.url,y,I);const N=index.jsonParser(i.result);N[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=I,i.result=JSON.stringify(N),n.setPointCloudResult(I)}v=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),b=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),A=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(m=y==null?void 0:y.radius)!=null?m:DEFAULT_RADIUS}),e==null||e.generateBoxes(I),e==null||e.generateSpheres(A),yield n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,I,[])}M({pointCloudBoxList:I,polygonList:v,lineList:b,pointCloudSphereList:A}),actionCreators.SetAnnotationLoading(z,!1),actionCreators.SetLoadPCDFileLoading(z,!1),(D=o==null?void 0:o.setResourceLoading)==null||D.call(o,!1)}),updateViewsByDefaultSize:yt,generateRects:J,update2DViewRect:pt,remove2DViewRect:gt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:n,setPointCloudResult:t}=React.useContext(PointCloudContext.PointCloudContext),u=ahooks.useLatest(o),p=ahooks.useLatest(n);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=u.current,c=p.current;if(c.length===0)return null;const d=new Map,x=new Set;if(c.filter(f=>f.extId!==void 0).forEach(f=>{const L=f.extId,R=f.imageName,S=_.pick(f,["x","y","width","height"]);let w=d.get(L);w||(w=new Map,d.set(L,w)),w.set(R,S),x.add(L)}),d.size){const f=P.map(L=>{var R;const S=L.id;if(x.has(S)){const w=__spreadValues({},L);return(R=w.rects)==null||R.forEach(V=>{var T;const k=V.imageName;Object.assign(V,(T=d.get(S))==null?void 0:T.get(k))}),w}return L});return t(f),f}return null},[])}};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,exports.useSyncRectPositionDimensionToPointCloudList=useSyncRectPositionDimensionToPointCloudList;
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"),_=require("lodash"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,n,t)=>n in o?__defProp(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,__spreadValues=(o,n)=>{for(var t in n||(n={}))__hasOwnProp.call(n,t)&&__defNormalProp(o,t,n[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(n))__propIsEnum.call(n,t)&&__defNormalProp(o,t,n[t]);return o},__spreadProps=(o,n)=>__defProps(o,__getOwnPropDescs(n)),__async=(o,n,t)=>new Promise((u,p)=>{var e=a=>{try{c(t.next(a))}catch(x){p(x)}},P=a=>{try{c(t.throw(a))}catch(x){p(x)}},c=a=>a.done?u(a.value):Promise.resolve(a.value).then(e,P);c((t=t.apply(o,n)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,n,t,u,p)=>{const{x:e,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,n),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,a={center:{x:e,y:P,z:c},id:o.id},x=u?__spreadValues(__spreadValues({},u),a):__spreadProps(__spreadValues({},a),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},topViewPolygon2PointCloud=(o,n,t,u,p,e)=>{let P=o.pointList.map(B=>lbUtils.PointCloudUtils.transferCanvas2World(B,n)),c=0,a=1,x={};if(t){const B=t.getSensesPointZAxisInPolygon(P,void 0,e);e&&B.fittedCoordinates.length>0&&(P=B.fittedCoordinates),c=(B.maxZ+B.minZ)/2,a=B.maxZ-B.minZ,x={count:B.zCount}}const[f,L,R]=P,D=lbAnnotation.MathUtils.getLineCenterPoint([f,R]),w=lbAnnotation.MathUtils.getLineLength(f,L),V=lbAnnotation.MathUtils.getLineLength(L,R),T=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);u&&(c=u.center.z,a=u.depth);const k={center:{x:D.x,y:D.y,z:c},width:e?V+INTELLIGENT_FIT_MARGIN:V,height:e?w+INTELLIGENT_FIT_MARGIN:w,depth:a,rotation:T,id:o.id},O=__spreadValues(u?__spreadValues(__spreadValues({},u),k):__spreadProps(__spreadValues({},k),{attribute:"",valid:!0}),x);p&&Object.assign(O,p);const M=P.map(B=>lbUtils.PointCloudUtils.transferWorld2Canvas(B,n));return{boxParams:O,newPointList:M}},sideViewPoint2PointCloud=(o,n,t)=>{const u={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-u.x,y:t.center.y,z:t.center.z-u.y}})},sideViewPolygon2PointCloud=(o,n,t,u)=>{const[p,e,P]=o.pointList,[c,a,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),D={x:{x:f.x-L.x,y:f.y-L.y}.x,y:0,z:f.y-L.y},w=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,a),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(a,x),M=k-O,{newBoxParams:B}=u.getNewBoxBySideUpdate(D,M,T,t);return B},backViewPoint2PointCloud=(o,n,t)=>{const u={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x,y:t.center.y-u.x,z:t.center.z-u.y}})},backViewPolygon2PointCloud=(o,n,t,u)=>{const[p,e,P]=o.pointList,[c,a,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),D={x:{x:f.x-L.x,y:f.y-L.y}.x,y:0,z:f.y-L.y},w=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,a),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(a,x),M=k-O;let{newBoxParams:B}=u.getNewBoxByBackUpdate(D,M,T,t);return B},syncSideViewByPoint=(o,n,t,u,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(u,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:a}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(a);const{point2d:x,zoom:f}=c.getSphereSidePoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},n),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},synchronizeSideView=(o,n,t,u)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(u,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);e.setInitCameraPosition(P);const{polygon2d:c,zoom:a}=e.getBoxSidePolygon2DCoordinate(o);e.camera.zoom=a,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncBackViewByPoint=(o,n,t,u,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(u,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:a}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(a);const{point2d:x,zoom:f}=c.getSphereBackPoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},n),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},synchronizeBackView=(o,n,t,u)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(u,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);e.setInitCameraPosition(P);const{polygon2d:c,zoom:a}=e.getBoxBackPolygon2DCoordinate(o);e.camera.zoom=a,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncTopViewByPoint=(o,n,t,u)=>{if(!t||!u)return;u.generateSphere(o),u.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),u.render();const{toolInstance:p,pointCloudInstance:e}=t,{point2d:P}=e.getSphereTopPoint2DCoordinate(o),c=[...p.pointList].map(a=>a.id===n.id?__spreadProps(__spreadValues(__spreadValues({},n),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):a);p.setResult(c),p.setSelectedID(n.id)},synchronizeTopView=(o,n,t,u)=>{var p,e;if(!t||!u)return;u.generateBox(o,n.id),u.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=t,{polygon2d:a}=c.getBoxTopPolygon2DCoordinate(o),x=[...P.polygonList],f=x.find(L=>L.id===n.id);f?(f.pointList=a,f.valid=(p=o.valid)!=null?p:!0):x.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(e=o.valid)!=null?e:!0}),P.setResultAndSelectedID(x,n.id)},usePointCloudViews=o=>{const n=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:u,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:a,selectedIDs:x,pointCloudBoxList:f,pointCloudSphereList:L,hideAttributes:R,setHighlight2DDataList:D,cuboidBoxIn2DView:w,imageSizes:V,history:T,linkageImageNameRectMap:k}=n,{addHistory:O,initHistory:M,pushHistoryUnderUpdatePolygon:B}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:nt,updatePointCloudSphere:Y,selectedSphere:W}=useSphere.useSphere(),{currentData:j,config:y}=ctx.useSelector(s=>{const{stepList:i,step:d,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(d,i).config)}}),z=ctx.useDispatch(),it=ahooks.useLatest(w),st=ahooks.useLatest(k),rt=React.useCallback((s,i)=>{const d=st.current,r=i.id;return s.filter(g=>{if(!g)return!1;const C=d.get(g.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),J=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!it.current||i){const{mappingImgList:d=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:d,imageSizes:V},{prepareRectsFn:rt})}},{selectedBox:U,updateSelectedBox:lt,updateSelectedBoxes:Q,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:J}),K=U==null?void 0:U.info;if(!t||!u||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=t,dt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},ut=({newPoint:s,size:i,zoom:d,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:L})});const C=topViewPoint2PointCloud(s,i,X,void 0,g);a(s.id);const h=c(C);q(PointCloudView.Top,s,C,d,h,y),O({newSphereParams:C})},ct=({polygon:s,size:i,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,h,m;const b={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(b,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:L})});const S=t==null?void 0:t.toolInstance,I=__spreadValues({},s);let{boxParams:v,newPointList:A}=topViewPolygon2PointCloud(I,i,X,void 0,b,g);v=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[v],stepConfig:y,action:"viewUpdateBox"}))[0],g&&(A==null?void 0:A.length)&&(I.pointList=A);const E=R.includes(I.attribute);J(v);const F=P(v),Z=(h=n==null?void 0:n.polygonList)!=null?h:[];v.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(m=y==null?void 0:y.inputList)!=null?m:[]:[]),t==null||t.updatePolygonList(F!=null?F:[],Z),E?a([]):(a(v.id),S.selection.setSelectedIDs(I.id),N({omitView:PointCloudView.Top,polygon:I,boxParams:v,zoom:l,newPointCloudBoxList:F}),g&&synchronizeTopView(v,I,t,e)),O({newBoxParams:v})},pt=s=>{const{boxID:i,imageName:d,width:r,height:l,x:g,y:C}=s,h=f.find(v=>v.id===i);if(!(h==null?void 0:h.rects)||!h.rects.find(v=>v.imageName===d))return;const b=h.rects.map(v=>v.imageName===d?__spreadProps(__spreadValues({},v),{width:r,height:l,x:g,y:C}):v),S=__spreadProps(__spreadValues({},h),{rects:b}),I=f.map(v=>v.id===i?S:v);return t==null||t.updatePolygonList(I!=null?I:[]),I},gt=s=>{const{boxID:i,imageName:d}=s,r=f.find(h=>h.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(h=>h.imageName!==d),g=__spreadProps(__spreadValues({},r),{rects:l}),C=f.map(h=>h.id===i?g:h);return t==null||t.updatePolygonList(C!=null?C:[]),C},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:d,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(x.length===0||!g)){if(s||(U==null?void 0:U.info)){const C=s!=null?s:U==null?void 0:U.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(x[0]);const h=g.selectedPolygon;if(x.length===1&&C){N({omitView:PointCloudView.Top,polygon:h,boxParams:C,newPointCloudBoxList:i});return}}if((d||W)&&x.length===1){const C=d!=null?d:W;g.setSelectedID(x[0]);const h=g.selectedPoint;C&&q(PointCloudView.Top,h,C,void 0,r,y)}}},$=(s,i,d)=>{if(K){let r,l;switch(d){case PointCloudView.Back:r=backViewPolygon2PointCloud;break;case PointCloudView.Side:r=sideViewPolygon2PointCloud;break;default:r=sideViewPolygon2PointCloud;break}if(l=r(s,i,K,u.pointCloudInstance),e){const{count:b}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:b})}const C=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:y,action:"viewUpdateBox"}))[0],h=l.valid!==C.valid;l=C;const m=lt(l);return l=m.find(b=>b.id===l.id),N({omitView:h?void 0:d,polygon:s,boxParams:l,newPointCloudBoxList:m}),m}},tt=(s,i,d)=>{if(W){let r,l;switch(d){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}l=r(s,i,W);const g=Y(l);return q(d,s,l,void 0,g,y),g}},Ct=(s,i)=>{tt(s,i,PointCloudView.Side)},ft=(s,i)=>{tt(s,i,PointCloudView.Back)},ht=(s,i)=>{$(s,i,PointCloudView.Side)},xt=(s,i)=>{$(s,i,PointCloudView.Back)},vt=(s,i)=>{const d=nt(s.id),r=topViewPoint2PointCloud(s,i,X,d),l=Y(r);q(PointCloudView.Top,s,r,void 0,l,y)},Lt=(s,i)=>{if(ot){const r=__spreadValues({},s[0].newPolygon);r.pointList=r.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,i)),B(r);return}let d=s.map(({newPolygon:r})=>{const l=at(r.id),{boxParams:g}=topViewPolygon2PointCloud(r,i,t.pointCloudInstance,l);return g});if(d=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:d,stepConfig:y,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=s[0],l=Q(d);N({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=Q(d);r&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,r)}},yt=s=>{var i,d,r,l,g;if(U){const C=Number(s.widthDefault),h=Number(s.depthDefault),m=Number(s.heightDefault),b=U==null?void 0:U.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(G=>(G==null?void 0:G.trackID)===b),v={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},A=I.pointList.map(G=>lbUtils.PointCloudUtils.transferCanvas2World(G,v)),H=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(A,m,C),E=H[0],F=H[2],Z=lbAnnotation.MathUtils.getLineCenterPoint([E,F]),mt=U.info.center.z-U.info.depth/2,et=__spreadProps(__spreadValues({},U.info),{center:{x:Z.x,y:Z.y,z:mt+h/2},width:C,height:m,depth:h,valid:!0}),Bt=Q([et]);N({omitView:PointCloudView["3D"],polygon:I,boxParams:et,newPointCloudBoxList:Bt})}},q=(s,i,d,r,l,g)=>__async(void 0,null,function*(){const C=j==null?void 0:j.url,h={[PointCloudView.Side]:()=>{syncSideViewByPoint(d,i,u,C,g)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(d,i,p,C,g)},[PointCloudView.Top]:()=>{syncTopViewByPoint(d,i,t,e)}};Object.keys(h).forEach(m=>{m!==s&&h[m]()}),r&&(e==null||e.updateCameraZoom(r)),dt(d)}),N=(s,i=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:d,polygon:r,boxParams:l,zoom:g,newPointCloudBoxList:C}=s,h=j==null?void 0:j.url;C&&n.syncAllViewPointCloudColor(i,C);const m={[PointCloudView.Side]:()=>{synchronizeSideView(l,r,u,h)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(l,r,p,h)},[PointCloudView.Top]:()=>{synchronizeTopView(l,r,t,e)}};Object.keys(m).forEach(b=>{b!==d&&m[b]()}),g&&(e==null||e.updateCameraZoom(g))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:ht,backViewUpdateBox:xt,syncPointCloudViews:N,syncPointCloudPoint:q,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),e==null||e.generateBoxes(s)},initPointCloud3d:s=>{if(!e)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(s);e.initOrthographicCamera(i),e.initRenderer(),e.render()},updatePointCloudData:(...s)=>__async(void 0,[...s],function*(i=j){var d,r,l,g,C,h,m,b;if(!(i==null?void 0:i.url)||!e)return;D([]),actionCreators.SetAnnotationLoading(z,!0),actionCreators.SetLoadPCDFileLoading(z,!0),(d=o==null?void 0:o.setResourceLoading)==null||d.call(o,!0),yield e.loadPCDFile(i.url,(r=y==null?void 0:y.radius)!=null?r:DEFAULT_RADIUS),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let S=[],I=[],v=[],A=[];e.updateTopCamera();const H=(g=(l=index.jsonParser(i.result))==null?void 0:l.valid)!=null?g:!0;if(n.setPointCloudValid(H),(C=n.sideViewInstance)==null||C.clearAllData(),(h=n.backViewInstance)==null||h.clearAllData(),i.result){if(S=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(S==null?void 0:S.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){S=yield e==null?void 0:e.filterPreResult(i.url,y,S);const E=index.jsonParser(i.result);E[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=S,i.result=JSON.stringify(E),n.setPointCloudResult(S)}v=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),I=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),A=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(m=y==null?void 0:y.radius)!=null?m:DEFAULT_RADIUS}),e==null||e.generateBoxes(S),e==null||e.generateSpheres(A),yield n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,S,[])}M({pointCloudBoxList:S,polygonList:v,lineList:I,pointCloudSphereList:A}),actionCreators.SetAnnotationLoading(z,!1),actionCreators.SetLoadPCDFileLoading(z,!1),(b=o==null?void 0:o.setResourceLoading)==null||b.call(o,!1)}),updateViewsByDefaultSize:yt,generateRects:J,update2DViewRect:pt,remove2DViewRect:gt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:n,setPointCloudResult:t}=React.useContext(PointCloudContext.PointCloudContext),u=ahooks.useLatest(o),p=ahooks.useLatest(n);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=u.current,c=p.current;if(c.length===0)return null;const a=new Map,x=new Set;if(c.filter(f=>f.extId!==void 0).forEach(f=>{const L=f.extId,R=f.imageName,D=_.pick(f,["x","y","width","height"]);let w=a.get(L);w||(w=new Map,a.set(L,w)),w.set(R,D),x.add(L)}),a.size){const f=P.map(L=>{var R;const D=L.id;if(x.has(D)){const w=__spreadValues({},L);return(R=w.rects)==null||R.forEach(V=>{var T;const k=V.imageName;Object.assign(V,(T=a.get(D))==null?void 0:T.get(k))}),w}return L});return t(f),f}return null},[])}};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,exports.useSyncRectPositionDimensionToPointCloudList=useSyncRectPositionDimensionToPointCloudList;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),ctx=require("../../../store/ctx.js"),useSingleBox=require("./useSingleBox.js"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),actionCreators=require("../../../store/annotation/actionCreators.js"),usePointCloudViews=require("./usePointCloudViews.js"),useSphere=require("./useSphere.js"),useHistory=require("./useHistory.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js");const PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},useUpdatePointCloudColor=(v,d)=>{const l=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:u,selectedIDs:i,pointCloudBoxList:s,mainViewInstance:c,selectedID:g}=l,f=ctx.useDispatch(),{selectedSphere:C}=useSphere.useSphere(),{syncPointCloudViews:p,syncPointCloudPoint:P,generateRects:h}=usePointCloudViews.usePointCloudViews({setResourceLoading:v}),{selectedBox:a,updateSelectedBox:x}=useSingleBox.useSingleBox({generateRects:h}),{pushHistoryWithList:V}=useHistory.useHistory(),q=({newSelectedSphere:n,newSphereList:o})=>{const e=u==null?void 0:u.toolInstance;if((n||C)&&i.length===1){const t=n!=null?n:C;e.setSelectedID(i[0]);const r=e.selectedPoint;t&&(P==null||P(PointCloudView.Top,r,t,void 0,o,d))}},y=({trigger:n,newSelectedBox:o})=>{const e=u==null?void 0:u.toolInstance;if(!(i.length===0||!e)&&(o||(a==null?void 0:a.info))){const t=o!=null?o:a==null?void 0:a.info,r=o;if(t){p==null||p({omitView:PointCloudView.Top,polygon:r,boxParams:t},n);return}}};return{updatePointCloudColor:n=>{if(s.forEach(o=>{var e,t,r;if(o&&i.includes(o.id)){o.attribute=n;const S=f(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[o],stepConfig:d,action:"viewUpdateBox"}));o.valid=S[0].valid,x(o),(r=(t=(e=l==null?void 0:l.topViewInstance)==null?void 0:e.pointCloud2dOperation)==null?void 0:t.setPolygonValidAndRender)==null||r.call(t,o.id,!0,o.valid),q({})}}),c){const o=i&&i.length>1?ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MulitSelect:ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single;l.syncAllViewPointCloudColor(o,s),s.forEach(e=>{y({trigger:o,newSelectedBox:e})}),c.generateBoxes(s)}g||V({pointCloudBoxList:s})}}};exports.useUpdatePointCloudColor=useUpdatePointCloudColor;
@@ -16,6 +16,7 @@ interface IProps {
16
16
  modelData: IModelList[];
17
17
  selectedAnswerSort: (sorts: ISelectAnswerSort) => void;
18
18
  disabeledAll?: boolean;
19
+ imgIndex: number;
19
20
  }
20
21
  export declare const getSorts: ({ selectedSort, initSelected, modelList, }: {
21
22
  selectedSort?: number[][] | undefined;
@@ -6,6 +6,7 @@
6
6
  import { PointCloudAnnotation, PointCloud } from '@labelbee/lb-annotation';
7
7
  import { IPointCloudBox, IPointCloudSphere, IPointUnit, UpdatePolygonByDragList, IDefaultSize, IBasicRect } from '@labelbee/lb-utils';
8
8
  import { ISize } from '@/types/main';
9
+ import { EPointCloudBoxRenderTrigger } from '@/utils/ToolPointCloudBoxRenderHelper';
9
10
  import { IFileItem } from '@/types/data';
10
11
  export declare const topViewPoint2PointCloud: (newPoint: any, size: ISize, pointCloud: PointCloud, selectedPointCloudSphere?: IPointCloudSphere, defaultValue?: {
11
12
  [v: string]: any;
@@ -56,6 +57,19 @@ export declare const synchronizeTopView: (newBoxParams: IPointCloudBox, newPolyg
56
57
  interface IUsePointCloudViewsParams {
57
58
  setResourceLoading?: (loading: boolean) => void;
58
59
  }
60
+ /**
61
+ * Sync views' data from omit view, regenerate and highlight box on 3D-view
62
+ * @param omitView
63
+ * @param polygon
64
+ * @param boxParams
65
+ */
66
+ interface ISyncPointCloudViews {
67
+ omitView?: string;
68
+ polygon: any;
69
+ boxParams: IPointCloudBox;
70
+ zoom?: number;
71
+ newPointCloudBoxList?: IPointCloudBox[];
72
+ }
59
73
  export declare const usePointCloudViews: (params?: IUsePointCloudViewsParams) => {
60
74
  topViewAddSphere: () => void;
61
75
  topViewAddBox: () => void;
@@ -66,6 +80,8 @@ export declare const usePointCloudViews: (params?: IUsePointCloudViewsParams) =>
66
80
  sideViewUpdatePoint?: undefined;
67
81
  backViewUpdatePoint?: undefined;
68
82
  topViewUpdateBox?: undefined;
83
+ syncPointCloudViews?: undefined;
84
+ syncPointCloudPoint?: undefined;
69
85
  pointCloudBoxListUpdated?: undefined;
70
86
  initPointCloud3d?: undefined;
71
87
  updatePointCloudData?: undefined;
@@ -100,6 +116,8 @@ export declare const usePointCloudViews: (params?: IUsePointCloudViewsParams) =>
100
116
  topViewUpdateBox: (updateList: UpdatePolygonByDragList, size: ISize) => void;
101
117
  sideViewUpdateBox: (newPolygon: any, originPolygon: any) => void;
102
118
  backViewUpdateBox: (newPolygon: any, originPolygon: any) => void;
119
+ syncPointCloudViews: (params: ISyncPointCloudViews, trigger?: EPointCloudBoxRenderTrigger) => void;
120
+ syncPointCloudPoint: (omitView: string, point: any, sphereParams: IPointCloudSphere, zoom?: number, newPointCloudSphereList?: IPointCloudSphere[], config?: any) => Promise<void>;
103
121
  pointCloudBoxListUpdated: (newBoxes: IPointCloudBox[]) => void;
104
122
  initPointCloud3d: (size: ISize) => void;
105
123
  updatePointCloudData: (newData?: any) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ declare const useUpdatePointCloudColor: (setResourceLoading: any, config: any) => {
2
+ updatePointCloudColor: (newAttribute: string) => void;
3
+ };
4
+ export { useUpdatePointCloudColor };
@@ -8,7 +8,8 @@ export declare enum EPointCloudBoxRenderTrigger {
8
8
  SingleToggleValid = "SingleToggleValid",
9
9
  SingleRotate = "SingleRotate",
10
10
  MultiPaste = "MultiPaste",
11
- MultiMove = "MultiMove"
11
+ MultiMove = "MultiMove",
12
+ MulitSelect = "MulitSelect"
12
13
  }
13
14
  export declare enum EPointCloudBoxSingleModifiedType {
14
15
  ChangeAttribute = "ChangeAttribute",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation");exports.EPointCloudBoxRenderTrigger=void 0,function(t){t.Default="Default",t.UndoRedo="UndoRedo",t.ClearAll="ClearAll",t.Single="Single",t.SingleDelete="SingleDelete",t.SingleToggleValid="SingleToggleValid",t.SingleRotate="SingleRotate",t.MultiPaste="MultiPaste",t.MultiMove="MultiMove"}(exports.EPointCloudBoxRenderTrigger||(exports.EPointCloudBoxRenderTrigger={})),exports.EPointCloudBoxSingleModifiedType=void 0,function(t){t.ChangeAttribute="ChangeAttribute",t.Move="Move",t.ChangeDepth="ChangeDepth",t.ChangeSize="ChangeSize",t.ToggleValid="ToggleValid"}(exports.EPointCloudBoxSingleModifiedType||(exports.EPointCloudBoxSingleModifiedType={}));const checkRectanglesIntersect=(t,n)=>{const i=getAxes(t).concat(getAxes(n));for(const e of i){const o=projectRectangle(t,e),r=projectRectangle(n,e);if(!projectionsOverlap(o,r))return!1}return!0},getAxes=t=>{const n=[];for(let i=0;i<t.length;i++){const e=t[i],o=t[(i+1)%t.length],r={x:o.x-e.x,y:o.y-e.y},d={x:-r.y,y:r.x};n.push(d)}return n},projectRectangle=(t,n)=>{let i=dotProduct(t[0],n),e=i;for(const o of t){const r=dotProduct(o,n);r<i&&(i=r),r>e&&(e=r)}return{min:i,max:e}},projectionsOverlap=(t,n)=>!(t.max<n.min||n.max<t.min),dotProduct=(t,n)=>t.x*n.x+t.y*n.y,getIntersectingBoxIds=(t,n)=>{const i=[];return n.forEach(e=>{const{polygonPointList:o}=lbAnnotation.getCuboidFromPointCloudBox(e);checkRectanglesIntersect(t,o)&&i.push(e.id)}),i},getAddBoxId=(t,n)=>{const i=t.map(o=>o.id),e=n.map(o=>o.id);return i.find(o=>!e.includes(o))||""},getDeletedBox=(t,n)=>{const i=t.map(e=>e.id);return n.find(e=>!i.includes(e.id))},getValidChangedBox=(t,n)=>t.find(e=>{const o=n.find(r=>r.id===e.id);return o&&o.valid!==e.valid}),getRotationChangedBox=(t,n)=>t.find(e=>{const o=n.find(r=>r.id===e.id);return o&&o.rotation!==e.rotation}),getIntersectingBoxIdsOfBox=(t,n)=>{const{polygonPointList:i}=lbAnnotation.getCuboidFromPointCloudBox(t);return{ids:getIntersectingBoxIds(i,n.filter(o=>o.id!==t.id)),rect:i}},getModifiedBox=(t,n)=>{const i=(e,o)=>e.attribute===o.attribute&&e.center.x===o.center.x&&e.center.y===o.center.y&&e.depth===o.depth&&e.width===o.width&&e.height===o.height;for(const e of t){const o=n.find(r=>r.id===e.id);if(o&&!i(e,o)){let r;if(o.attribute!==e.attribute?r=exports.EPointCloudBoxSingleModifiedType.ChangeAttribute:o.center.x!==e.center.x||o.center.y!==e.center.y?r=exports.EPointCloudBoxSingleModifiedType.Move:o.depth!==e.depth?r=exports.EPointCloudBoxSingleModifiedType.ChangeDepth:(o.width!==e.width||o.height!==e.height)&&(r=exports.EPointCloudBoxSingleModifiedType.ChangeSize),r!==void 0)return{modifiedType:r,box:e}}}},calcResetAreasAndBoxIds=(t,n,i)=>{try{switch(t){case exports.EPointCloudBoxRenderTrigger.Single:if(n.length>i.length){const e=getAddBoxId(n,i);return e?{modifiedBoxIds:[e],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}else{const e=[],o=[],r=getModifiedBox(n,i);if(r&&(e.push(r.box.id),r.modifiedType===exports.EPointCloudBoxSingleModifiedType.ChangeSize||r.modifiedType===exports.EPointCloudBoxSingleModifiedType.Move)){const d=i.find(l=>l.id===r.box.id),{ids:s,rect:c}=getIntersectingBoxIdsOfBox(d,n);e.push(...s),o.push(c)}return{modifiedBoxIds:e,resetAreas:o}}case exports.EPointCloudBoxRenderTrigger.SingleDelete:if(n.length<i.length){const e=getDeletedBox(n,i);if(e){const r=[lbAnnotation.getCuboidFromPointCloudBox(e).polygonPointList],d=[];if(n.length>1){const{ids:s}=getIntersectingBoxIdsOfBox(e,n);s.length&&d.push(...s)}return{modifiedBoxIds:d,resetAreas:r}}return{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.SingleRotate:if(getRotationChangedBox(n,i)){const e=getRotationChangedBox(n,i);if(e){const o=i.find(s=>s.id===e.id),{ids:r,rect:d}=getIntersectingBoxIdsOfBox(o,n);return{modifiedBoxIds:[e.id,...r],resetAreas:[d]}}}return{modifiedBoxIds:[],resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.SingleToggleValid:if(getValidChangedBox(n,i)){const e=getValidChangedBox(n,i);return e?{modifiedBoxIds:[e.id],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.MultiPaste:case exports.EPointCloudBoxRenderTrigger.MultiMove:case exports.EPointCloudBoxRenderTrigger.Default:case exports.EPointCloudBoxRenderTrigger.UndoRedo:case exports.EPointCloudBoxRenderTrigger.ClearAll:default:return{modifiedBoxIds:[],resetAreas:[]}}}catch(e){return console.error("calcResetAreasAndBoxIds error:",e),{modifiedBoxIds:[],resetAreas:[]}}};exports.calcResetAreasAndBoxIds=calcResetAreasAndBoxIds;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation");exports.EPointCloudBoxRenderTrigger=void 0,function(t){t.Default="Default",t.UndoRedo="UndoRedo",t.ClearAll="ClearAll",t.Single="Single",t.SingleDelete="SingleDelete",t.SingleToggleValid="SingleToggleValid",t.SingleRotate="SingleRotate",t.MultiPaste="MultiPaste",t.MultiMove="MultiMove",t.MulitSelect="MulitSelect"}(exports.EPointCloudBoxRenderTrigger||(exports.EPointCloudBoxRenderTrigger={})),exports.EPointCloudBoxSingleModifiedType=void 0,function(t){t.ChangeAttribute="ChangeAttribute",t.Move="Move",t.ChangeDepth="ChangeDepth",t.ChangeSize="ChangeSize",t.ToggleValid="ToggleValid"}(exports.EPointCloudBoxSingleModifiedType||(exports.EPointCloudBoxSingleModifiedType={}));const checkRectanglesIntersect=(t,o)=>{const r=getAxes(t).concat(getAxes(o));for(const e of r){const n=projectRectangle(t,e),i=projectRectangle(o,e);if(!projectionsOverlap(n,i))return!1}return!0},getAxes=t=>{const o=[];for(let r=0;r<t.length;r++){const e=t[r],n=t[(r+1)%t.length],i={x:n.x-e.x,y:n.y-e.y},d={x:-i.y,y:i.x};o.push(d)}return o},projectRectangle=(t,o)=>{let r=dotProduct(t[0],o),e=r;for(const n of t){const i=dotProduct(n,o);i<r&&(r=i),i>e&&(e=i)}return{min:r,max:e}},projectionsOverlap=(t,o)=>!(t.max<o.min||o.max<t.min),dotProduct=(t,o)=>t.x*o.x+t.y*o.y,getIntersectingBoxIds=(t,o)=>{const r=[];return o.forEach(e=>{const{polygonPointList:n}=lbAnnotation.getCuboidFromPointCloudBox(e);checkRectanglesIntersect(t,n)&&r.push(e.id)}),r},getAddBoxId=(t,o)=>{const r=t.map(n=>n.id),e=o.map(n=>n.id);return r.find(n=>!e.includes(n))||""},getDeletedBox=(t,o)=>{const r=t.map(e=>e.id);return o.find(e=>!r.includes(e.id))},getValidChangedBox=(t,o)=>t.find(e=>{const n=o.find(i=>i.id===e.id);return n&&n.valid!==e.valid}),getRotationChangedBox=(t,o)=>t.find(e=>{const n=o.find(i=>i.id===e.id);return n&&n.rotation!==e.rotation}),getIntersectingBoxIdsOfBox=(t,o)=>{const{polygonPointList:r}=lbAnnotation.getCuboidFromPointCloudBox(t);return{ids:getIntersectingBoxIds(r,o.filter(n=>n.id!==t.id)),rect:r}},getModifiedBox=(t,o)=>{const r=(e,n)=>e.attribute===n.attribute&&e.center.x===n.center.x&&e.center.y===n.center.y&&e.depth===n.depth&&e.width===n.width&&e.height===n.height;for(const e of t){const n=o.find(i=>i.id===e.id);if(n&&!r(e,n)){let i;if(n.attribute!==e.attribute?i=exports.EPointCloudBoxSingleModifiedType.ChangeAttribute:n.center.x!==e.center.x||n.center.y!==e.center.y?i=exports.EPointCloudBoxSingleModifiedType.Move:n.depth!==e.depth?i=exports.EPointCloudBoxSingleModifiedType.ChangeDepth:(n.width!==e.width||n.height!==e.height)&&(i=exports.EPointCloudBoxSingleModifiedType.ChangeSize),i!==void 0)return{modifiedType:i,box:e}}}},calcResetAreasAndBoxIds=(t,o,r)=>{try{switch(t){case exports.EPointCloudBoxRenderTrigger.Single:if(o.length>r.length){const e=getAddBoxId(o,r);return e?{modifiedBoxIds:[e],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}else{const e=[],n=[],i=getModifiedBox(o,r);if(i&&(e.push(i.box.id),i.modifiedType===exports.EPointCloudBoxSingleModifiedType.ChangeSize||i.modifiedType===exports.EPointCloudBoxSingleModifiedType.Move)){const d=r.find(l=>l.id===i.box.id),{ids:s,rect:c}=getIntersectingBoxIdsOfBox(d,o);e.push(...s),n.push(c)}return{modifiedBoxIds:e,resetAreas:n}}case exports.EPointCloudBoxRenderTrigger.SingleDelete:if(o.length<r.length){const e=getDeletedBox(o,r);if(e){const i=[lbAnnotation.getCuboidFromPointCloudBox(e).polygonPointList],d=[];if(o.length>1){const{ids:s}=getIntersectingBoxIdsOfBox(e,o);s.length&&d.push(...s)}return{modifiedBoxIds:d,resetAreas:i}}return{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.SingleRotate:if(getRotationChangedBox(o,r)){const e=getRotationChangedBox(o,r);if(e){const n=r.find(s=>s.id===e.id),{ids:i,rect:d}=getIntersectingBoxIdsOfBox(n,o);return{modifiedBoxIds:[e.id,...i],resetAreas:[d]}}}return{modifiedBoxIds:[],resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.SingleToggleValid:if(getValidChangedBox(o,r)){const e=getValidChangedBox(o,r);return e?{modifiedBoxIds:[e.id],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.MulitSelect:return{modifiedBoxIds:getDifference(o,r),resetAreas:[]};case exports.EPointCloudBoxRenderTrigger.MultiPaste:case exports.EPointCloudBoxRenderTrigger.MultiMove:case exports.EPointCloudBoxRenderTrigger.Default:case exports.EPointCloudBoxRenderTrigger.UndoRedo:case exports.EPointCloudBoxRenderTrigger.ClearAll:default:return{modifiedBoxIds:[],resetAreas:[]}}}catch(e){return console.error("calcResetAreasAndBoxIds error:",e),{modifiedBoxIds:[],resetAreas:[]}}},deepEqual=(t,o)=>{if(t===o)return!0;if(typeof t!="object"||typeof o!="object"||t===null||o===null)return!1;const r=Object.keys(t),e=Object.keys(o);if(r.length!==e.length)return!1;for(const n of r)if(!deepEqual(t[n],o[n]))return!1;return!0},getDifference=(t,o)=>{const r=new Map;for(const e of o)r.set(e.id,e);return t.filter(e=>{const n=r.get(e.id);return!n||!deepEqual(e,n)}).map(e=>e.id)};exports.calcResetAreasAndBoxIds=calcResetAreasAndBoxIds;