@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.
- package/dist/_virtual/2DViewWorker.js +1 -1
- package/dist/components/LLMMultiWheelView/sidebar/index.js +1 -1
- package/dist/components/LLMToolView/sidebar/components/answerSort/index.js +1 -1
- package/dist/components/LLMToolView/sidebar/components/modelAnswerSort/index.js +1 -1
- package/dist/components/pointCloudView/PointCloudListener.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/components/pointCloudView/hooks/useUpdatePointCloudColor.js +1 -0
- package/dist/types/components/LLMToolView/sidebar/components/modelAnswerSort/index.d.ts +1 -0
- package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +18 -0
- package/dist/types/components/pointCloudView/hooks/useUpdatePointCloudColor.d.ts +4 -0
- package/dist/types/utils/ToolPointCloudBoxRenderHelper.d.ts +2 -1
- package/dist/utils/ToolPointCloudBoxRenderHelper.js +1 -1
- package/es/_virtual/2DViewWorker.js +1 -1
- package/es/components/LLMMultiWheelView/sidebar/index.js +1 -1
- package/es/components/LLMToolView/sidebar/components/answerSort/index.js +1 -1
- package/es/components/LLMToolView/sidebar/components/modelAnswerSort/index.js +1 -1
- package/es/components/pointCloudView/PointCloudListener.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/hooks/useUpdatePointCloudColor.js +1 -0
- package/es/utils/ToolPointCloudBoxRenderHelper.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import l,{useState as
|
|
1
|
+
import l,{useState as M,useRef as Dt,useMemo as G,useEffect as V}from"react";import{LabelBeeContext as It}from"../../../store/ctx.js";import{connect as Ot}from"react-redux";import{prefix as Vt}from"../../../constant/index.js";import{getStepConfig as Nt}from"../../../store/annotation/reducer.js";import{jsonParser as ut}from"../../../utils/index.js";import Bt,{getSorts as dt}from"../../LLMToolView/sidebar/components/modelAnswerSort/index.js";import{useTranslation as $t}from"react-i18next";import{useCustomToolInstance as Wt}from"../../../hooks/annotation.js";import{isBoolean as Ft,isString as qt,isNumber as kt,isObject as Gt,isArray as Kt}from"lodash";import{PageForward as N}from"../../../store/annotation/actionCreators.js";import{cKeyCode as zt,EToolName as Ut}from"@labelbee/lb-annotation";import{getLLMIsNoConfig as Qt,EmptyConfig as Jt}from"../../LLMToolView/sidebar/index.js";import Ht from"../../LLMToolView/sidebar/components/textInputBox/index.js";import{Button as ct}from"antd";import Xt from"../../LLMToolView/sidebar/components/answerList/index.js";import Yt from"../../../store/LLMMultiWheel/index.js";import Zt from"../../../utils/StepUtils.js";import{getCurrentResultFromResultList as te,getRenderDataByResult as ee}from"../../LLMToolView/utils/data.js";import{useMemoizedFn as K}from"ahooks";import ne from"../../LLMToolView/sidebar/components/answerSort/index.js";var oe=Object.defineProperty,re=Object.defineProperties,le=Object.getOwnPropertyDescriptors,pt=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,mt=(c,s,p)=>s in c?oe(c,s,{enumerable:!0,configurable:!0,writable:!0,value:p}):c[s]=p,i=(c,s)=>{for(var p in s||(s={}))ie.call(s,p)&&mt(c,p,s[p]);if(pt)for(var p of pt(s))se.call(s,p)&&mt(c,p,s[p]);return c},a=(c,s)=>re(c,le(s));const ae=zt.default,ft=`${Vt}-sidebar`,ue={sort:[],answerSort:{},textAttribute:[]},de=c=>{var s,p,z,U,Q,J,H;const{annotation:vt,dispatch:C,checkMode:Lt}=c,{imgIndex:S,imgList:B,stepList:A,step:h,skipBeforePageTurning:j}=vt,[m,xt]=M(),{t:T}=$t(),r=(s=B[S])!=null?s:{},X=ut(r==null?void 0:r.result),{toolInstanceRef:v}=Wt({basicInfo:X}),[$,gt]=M(!0),[R,Y]=M({}),[P,Z]=M(ue),W=Dt(),[x,F]=M({}),{selectedID:D,setNewAnswerListMap:tt,newAnswerListMap:et}=Yt(),g=G(()=>R[D],[D,R]),b=!v.current.valid||Lt;V(()=>{var t;if(A&&h){const e=(t=Nt(A,h))==null?void 0:t.config;xt(ut(e))}},[h,JSON.stringify(A)]),V(()=>{!r||S===-1||(v.current.setValid=nt,v.current.clearResult=wt,nt(),ot())},[S,m,r==null?void 0:r.id]);const wt=()=>{var t,e,n,u,f;ot((t=r==null?void 0:r.questionList)==null?void 0:t.textList),((e=W.current)==null?void 0:e.clearValue)&&((n=W.current)==null||n.clearValue());const{waitSorts:o}=dt({selectedSort:(f=(u=I())==null?void 0:u.sort)!=null?f:[],initSelected:[],modelList:E?O!=null?O:[]:[]});F(a(i({},x),{waitSorts:o,newSort:[]}))},nt=t=>{var e;const n=t!=null?t:X.valid;Ft(n)&&(gt(n),v.current.valid=n,(e=v.current)==null||e.emit("validUpdated"))},I=()=>{const t=Zt.getCurrentStepInfo(h,A);return te(r==null?void 0:r.result,t.step)},ot=K(t=>{var e,n,u,f,o,L,y;const d=I();let w=(e=r==null?void 0:r.questionList)==null?void 0:e.textList;((n=d==null?void 0:d.modelData)==null?void 0:n.length)&&v.current.valid&&(w=d==null?void 0:d.modelData),t&&(w=t,d.sort=[],d.textAttribute=[],d.answerSort=[]);let st={};w==null||w.forEach((_,Tt)=>{var at;const Rt=ee(m,a(i({},_),{answerList:(at=_==null?void 0:_.answerList)==null?void 0:at.map((k,Pt)=>(tt(a(i({},et),{[`${_.id}-${k.id}`]:k.answer})),a(i({},k),{order:Pt+1})))}));st[_.id]=a(i({},Rt),{order:Tt+1,id:_.id})});const{waitSorts:ht,newSort:jt}=dt({selectedSort:(f=(u=I())==null?void 0:u.sort)!=null?f:[],modelList:E?O!=null?O:[]:[]});F({waitSorts:ht,newSort:jt}),Z({sort:(o=d==null?void 0:d.sort)!=null?o:[],textAttribute:(L=d==null?void 0:d.textAttribute)!=null?L:[],answerSort:(y=d==null?void 0:d.answerSort)!=null?y:{}}),Y(st)});V(()=>{_t()},[R,$,P]),V(()=>(window.addEventListener("keydown",rt),()=>{window.removeEventListener("keydown",rt)}),[]);const _t=K(()=>{var t,e;const n=(e=(t=r==null?void 0:r.questionList)==null?void 0:t.textList)==null?void 0:e.map(f=>{var o;const L=(o=R[f.id])!=null?o:{};return{id:f.id,answerList:L.answerList}}),u=a(i({},P),{modelData:n});v.current.exportData=()=>[[u],{valid:$}],v.current.currentPageResult=a(i({},u),{toolName:Ut.LLMMultiWheel,valid:$})}),rt=t=>{if(t.ctrlKey&&t.keyCode===ae.Enter){if(j){j(()=>C(N()));return}C(N())}},St=K(({order:t,value:e,key:n})=>{const{answerList:u}=g,f=u==null?void 0:u.map(o=>{var L,y;if((o==null?void 0:o.order)===t){if(n==="textEdit"&&qt(e))return tt(a(i({},et),{[`${D}-${(L=o==null?void 0:o.id)!=null?L:""}`]:e})),a(i({},o),{newAnswer:e});if(kt(e))return a(i({},o),{score:e});if(Gt(e)&&n){const d={[e==null?void 0:e.key]:e.value},w=(y=o[n])!=null?y:{};return a(i({},o),{[n]:i(i({},w),d)})}}return o});Y(o=>a(i({},o),{[D]:a(i({},g),{answerList:f})}))}),q=(t,e)=>{Z(n=>a(i({},n),{[t]:e}))},{indicatorScore:lt=[],indicatorDetermine:it=[],isTextEdit:bt,dialogSort:E=!1,inputList:Et=[],tagInputListConfigurable:yt,enableSort:Mt=!1}=m||{},O=G(()=>{var t,e,n;return E?(n=(e=(t=r==null?void 0:r.questionList)==null?void 0:t.textList)==null?void 0:e.map((u,f)=>a(i({},u),{title:f+1})))!=null?n:[]:[]},[r,E]);if(G(()=>Qt(m),[m]))return l.createElement(Jt,null);const Ct=yt&&((p=Et.filter(t=>!t.isOverall))==null?void 0:p.length)>0,At=(it==null?void 0:it.length)>0||(lt==null?void 0:lt.length)>0||bt||Ct;return l.createElement("div",{className:`${ft}`},l.createElement("div",{className:`${ft}__content`},l.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},T("GlobalAnnotation")),E&&l.createElement(ne,{waitSortList:(x==null?void 0:x.waitSorts)||[],sortList:(x==null?void 0:x.newSort)||[],setSortList:t=>{const e=t.map(n=>n.map(u=>u.id));q("sort",e),F(a(i({},x),{newSort:t}))},disabeledAll:b,title:T("SortConversationQuality"),prefixId:"model"}),(m==null?void 0:m.text)&&l.createElement("div",{style:{padding:"0px 16px",marginTop:"16px"}},l.createElement(Ht,{textAttribute:(z=P==null?void 0:P.textAttribute)!=null?z:[],textConfig:(m==null?void 0:m.text)&&Kt(m.text)?m==null?void 0:m.text:[],setText:t=>q("textAttribute",t),disabeledAll:b})),Mt&&l.createElement(Bt,{modelData:(Q=(U=r==null?void 0:r.questionList)==null?void 0:U.textList)!=null?Q:[],selectedAnswerSort:t=>q("answerSort",t),selectedSort:(H=(J=I())==null?void 0:J.answerSort)!=null?H:[],ref:W,disabeledAll:b,imgIndex:S}),g&&l.createElement(l.Fragment,null,l.createElement("div",{style:{fontSize:"18px",fontWeight:500,padding:"0px 16px",marginTop:"16px"}},T("QualifiedAnnotation")),l.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center"}},l.createElement(ct,{type:"primary",danger:!0},"\u6B63\u5728\u6807\u6CE8"),l.createElement("div",{style:{padding:16}},"\u7EC4\uFF1A",g.order)),l.createElement("div",null,At&&l.createElement(Xt,{list:(g==null?void 0:g.answerList)||[],LLMConfig:m,updateValue:St,disabeledAll:b})))),l.createElement("div",{style:{margin:"24px 16px",display:"flex"}},(B==null?void 0:B.length)-1!==S&&l.createElement(ct,{type:"primary",style:{marginLeft:"auto"},onClick:()=>{if(j){j(()=>C(N()));return}C(N())},disabled:b},T("Save"))))},ce=c=>({annotation:c.annotation});var pe=Ot(ce,null,null,{context:It})(de);export{pe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import s,{useReducer as
|
|
1
|
+
import s,{useReducer as ie,useContext as ae,useState as F,useEffect as se}from"react";import{prefix as le}from"../../../../../constant/index.js";import{Tag as de}from"antd";import{useTranslation as W}from"react-i18next";import{LeftOutlined as ce}from"@ant-design/icons";import{classnames as pe}from"../../../../../utils/index.js";import{isArray as ue,cloneDeep as fe}from"lodash";import{MathUtils as y}from"@labelbee/lb-annotation";import{LLMContext as ge}from"../../../../../store/ctx.js";var me=Object.defineProperty,ve=Object.defineProperties,xe=Object.getOwnPropertyDescriptors,q=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable,z=(i,p,l)=>p in i?me(i,p,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[p]=l,J=(i,p)=>{for(var l in p||(p={}))he.call(p,l)&&z(i,l,p[l]);if(q)for(var l of q(p))_e.call(p,l)&&z(i,l,p[l]);return i},ye=(i,p)=>ve(i,xe(p)),m;(function(i){i.Top="Top",i.Right="Right",i.Bottom="Bottom",i.Left="Left"})(m||(m={}));const w=`${le}-LLMSidebar-contentBox`,B="@",be=()=>{const{t:i}=W();return s.createElement("div",{className:`${w}__navigation`},s.createElement("span",null,i("Best")),s.createElement("div",{style:{display:"flex",alignItems:"center",flex:1,margin:"0px 20px"}},s.createElement(ce,null),s.createElement("div",{style:{height:0,border:"1px solid #999999",width:"100%"}})),s.createElement("span",null,i("Worst")))},Le=i=>{const[,p]=ie(e=>e+1,0),{sortList:l,setSortList:K,waitSortList:U,disabeledAll:V,header:Y,title:X,prefixId:G="answer"}=i,N=`${G}-waitBox`,x=`${G}-sortBox`,{setHoverKey:H}=ae(ge),[O,b]=F(void 0),[E,Q]=F(void 0),[_,Z]=F([]),{t:S}=W();se(()=>{Z(U)},[U]);const T=({item:e,operation:t,id:n})=>{const o={[`border${O}`]:"2px solid #8C9AFF"};return s.createElement("div",J({key:`${e==null?void 0:e.id}`,color:"#EBEBEB",id:n,className:pe({[`${w}__answerTag`]:!0}),style:E===(e==null?void 0:e.id)&&O?o:void 0,draggable:V||!(e==null?void 0:e.id)?"":"true",onMouseMove:()=>{H(e.id)},onMouseLeave:()=>{H(-1)}},t),e==null?void 0:e.title)},D=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),ee=(e,t)=>{const n=y.getLineLength(e,D(t.tl,t.tr)),o=y.getLineLength(e,D(t.tr,t.tr)),d=y.getLineLength(e,D(t.bl,t.br)),c=y.getLineLength(e,D(t.tl,t.bl));return{minDistance:Math.min(n,o,d,c),toTopDistance:n,toRightDistance:o,toBottompDistance:d,toLeftDistance:c}},te=(e,t)=>{const{minDistance:n,toTopDistance:o,toRightDistance:d,toBottompDistance:c,toLeftDistance:u}=ee(e,t);switch(n){case o:b(m.Top);break;case d:b(m.Right);break;case c:b(m.Bottom);break;case u:b(m.Left);break}},C=()=>{const e=document.getElementById(x);if(e==null?void 0:e.childNodes){let t=[];e.childNodes.forEach((n,o)=>{var d;let c=n;((d=n==null?void 0:n.childNodes)==null?void 0:d.length)>1&&(c=n.childNodes[0]);const u=c.getBoundingClientRect()||{},{bottom:a,top:f,left:r,right:g,width:v,height:h,x:R,y:M}=u,j={x:r+v/2,y:f+h/2},k={tl:{x:R,y:M},tr:{x:g,y:f},br:{x:g,y:a},bl:{x:r,y:a}},oe=l[o].reduce((re,$)=>{let I=$;return ue($)&&$.length>1&&(I=$[0]),I=ye(J({},I),{tagCenterPoint:j,tagVertexPoint:k}),[...re,I]},[]);t.push(oe)}),K(t)}},P=e=>{var t,n,o,d,c,u;const a=e.pageX,f=e.pageY,r={x:a,y:f};let g=l;if((g==null?void 0:g.length)>0){let v=g[0];for(let h=0;h<g.length;h++)if(h>0){const R=(t=g[h][0])==null?void 0:t.tagCenterPoint,M=(n=v[0])==null?void 0:n.tagCenterPoint,j=y.getLineLength(r,R),k=y.getLineLength(r,M);j<k&&(v=l[h])}if(!r.x||!r.y)return;if(L(e.target.id)===((o=v[0])==null?void 0:o.id)){Q(void 0);return}Q((d=v[0])==null?void 0:d.id),((c=v[0])==null?void 0:c.tagVertexPoint)&&r&&(r==null?void 0:r.x)&&(r==null?void 0:r.y)&&te(r,(u=v[0])==null?void 0:u.tagVertexPoint)}},A=e=>{var t;const{target:n}=e;let o=-1,d=-1,c=-1,u=[],a=fe(l);if(c=a.findIndex(f=>f[0].id===Number(E)),((t=n==null?void 0:n.parentNode)==null?void 0:t.parentNode.id)===x){o=L(n.parentNode.id);const f=L(n.id);u=a[~~o].filter(g=>g.id===~~f);const r=a[~~o].findIndex(g=>g.id===~~f);a[~~o].splice(r,1)}if((n==null?void 0:n.parentNode.id)===x){if(!E)return;o=L(n.id),d=a.findIndex(r=>r[0].id===o);const f=a.find(r=>r[0].id===o);f&&(u=f),a.splice(d,1),c=a.findIndex(r=>r[0].id===~~E)}switch(n.parentNode.id===N&&(o=L(n.id),d=_.findIndex(f=>f.id===o),u=[_[d]],_.splice(d,1)),O){case m.Left:a.splice(c,0,u);break;case m.Right:a.splice(c+1,0,u);break;case m.Top:case m.Bottom:a[c].push(...u);break;default:a.push(u);break}K(a),b(void 0),p()},L=e=>{const t=e.indexOf(B);return Number(e.substring(t+1,e.length))},ne=Y!=null?Y:s.createElement("div",{className:`${w}__title`},s.createElement("span",null,X!=null?X:S("RankingQualityOfAnswers")),_.length>0&&s.createElement(de,{color:"#FFD9D9",style:{color:"#F26549",marginLeft:8}},S("Unfinished")));return s.createElement("div",{style:{padding:"0px 16px",marginBottom:"16px",width:"100%"}},ne,s.createElement("div",null,s.createElement("div",{style:{display:"flex",alignItems:"center"}},s.createElement("span",{style:{marginRight:"16px"}},S("ToBeSorted")),s.createElement("div",{id:N,className:`${w}__answerBox`},_.length>0&&_.map(e=>T({item:e,id:`${N}-waitBoxItem${B}${e==null?void 0:e.id}`,operation:{onDrag:P,onDragEnd:A,onDragStart:()=>C()}})))),s.createElement(be,null),s.createElement("div",{id:x,className:`${w}__answerBox`},l.map((e,t)=>{var n;return e.length>1?s.createElement("div",{key:`item-${t}`,id:`${x}${B}${t}`,style:{border:"1px dashed #d9d9d9"}},e.map(o=>T({item:o,id:`${x}-sortBoxItem${B}${o==null?void 0:o.id}`,operation:{onDrag:P,onDragEnd:A,onDragStart:()=>C()}}))):T({item:e[0],id:`${x}${B}${(n=e[0])==null?void 0:n.id}`,operation:{onDrag:P,onDragEnd:A,onDragStart:()=>C()}})}))))};export{Le as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import p,{forwardRef as V,useState as $,useMemo as y,useEffect as F,useImperativeHandle as M}from"react";import{useTranslation as R}from"react-i18next";import{useDebounceFn as T}from"ahooks";import H from"../answerSort/index.js";import{Tag as W}from"antd";import{isArray as z}from"lodash";var N=Object.defineProperty,Q=Object.defineProperties,U=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable,D=(l,t,r)=>t in l?N(l,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):l[t]=r,S=(l,t)=>{for(var r in t||(t={}))k.call(t,r)&&D(l,r,t[r]);if(A)for(var r of A(t))q.call(t,r)&&D(l,r,t[r]);return l},v=(l,t)=>Q(l,U(t));const E=({selectedSort:l,initSelected:t,modelList:r})=>{const a=t!=null?t:l;let f=[];const g=r.filter(c=>!(a&&(a==null?void 0:a.length)>0?a.flat():[]).includes(c.id));return a&&(a==null?void 0:a.length)>0&&(f=a.map(c=>c.map(i=>r.find(w=>w.id===i)))),{waitSorts:g,newSort:f}},B=(l,t)=>{const{selectedSort:r,modelData:a,selectedAnswerSort:f,disabeledAll:g,imgIndex:c}=l,[i,w]=$({waitSorts:{},selecteds:r}),{t:_}=R(),P=y(()=>a.map((s,n)=>v(S({},s),{title:n+1})),[a,c]),h=y(()=>a.reduce((o,e)=>e.answerList.length>o.length?e.answerList:o,[]).map((o,e)=>({id:o.id,title:`${e+1}`}))||[],[a,c]);F(()=>{r&&O()},[a,c]);const L=s=>(P.filter(o=>o.answerList.some(e=>e.id===s))||[]).map(o=>v(S({},o),{id:o.id,title:o.title})),O=s=>{const n=i,o=s!=null?s:r;h.forEach(e=>{const d=L(e.id),u=o==null?void 0:o[e.id],{waitSorts:m,newSort:x}=E({selectedSort:u,modelList:d});n.waitSorts[e.id]=m,n.selecteds[e.id]=x}),w(n)};M(t,()=>({clearValue:()=>O({})}),[a,c]);const b=(s,n)=>{if(n.some(e=>e.some(d=>d==null?void 0:d.id))){const e=v(S({},i.selecteds),{[s]:n}),d={};Object.keys(e).forEach(u=>{d[u]=e[u].map(m=>m.map(x=>x.id))}),f(d),w(v(S({},i),{selecteds:e}))}},{run:j}=T(b,{wait:0}),I=Object.keys(i.waitSorts).some(s=>h.some(n=>n.id===s)&&z(i.waitSorts[s])&&i.waitSorts[s].length>0);return p.createElement("div",null,p.createElement("div",{style:{fontWeight:500,fontSize:"16px",width:"100%",lineHeight:"46px",padding:"0px 16px"}},p.createElement("span",null,_("RankingQualityOfAnswers")),I&&p.createElement(W,{color:"#FFD9D9",style:{color:"#F26549",marginLeft:8}},_("Unfinished"))),h.map((s,n)=>{var o,e,d,u;return p.createElement("div",{key:n,style:{display:"flex"}},p.createElement("div",{style:{fontSize:"16px",fontWeight:500,width:"80px",lineHeight:"50px",textAlign:"center"}},`${_("Answer")}${n+1}`),p.createElement(H,{waitSortList:(e=(o=i==null?void 0:i.waitSorts)==null?void 0:o[s.id])!=null?e:[],sortList:(u=(d=i==null?void 0:i.selecteds)==null?void 0:d[s.id])!=null?u:[],setSortList:m=>{j(s.id,m)},disabeledAll:g,header:"",prefixId:`modelAnswer${n}`}))}))};var C=V(B);export{C as default,E as getSorts};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudContext as
|
|
1
|
+
import{PointCloudContext as re}from"./PointCloudContext.js";import{useRotate as se}from"./hooks/useRotate.js";import{useRotateEdge as ne}from"./hooks/useRotateEdge.js";import{useBoxes as ie}from"./hooks/useBoxes.js";import{useSingleBox as ae}from"./hooks/useSingleBox.js";import{useSphere as ue}from"./hooks/useSphere.js";import{useContext as le,useEffect as d}from"react";import{CommonToolUtils as ce,AttributeUtils as de,EToolName as f,cTool as pe}from"@labelbee/lb-annotation";import{message as g}from"antd";import{connect as me}from"react-redux";import{a2MapStateToProps as be}from"../../store/annotation/map.js";import{useStatus as fe}from"./hooks/useStatus.js";import{usePointCloudViews as Pe}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as ye}from"../../store/ctx.js";import{useHistory as ve}from"./hooks/useHistory.js";import{useAttribute as we}from"./hooks/useAttribute.js";import{useConfig as Ce}from"./hooks/useConfig.js";import{usePolygon as he}from"./hooks/usePolygon.js";import{useLine as ge}from"./hooks/useLine.js";import{useUpdatePointCloudColor as Se}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as ke}from"react-i18next";import{useLatest as j}from"ahooks";var xe=Object.defineProperty,_e=Object.defineProperties,Ve=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,A=(n,r,a)=>r in n?xe(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,P=(n,r)=>{for(var a in r||(r={}))Be.call(r,a)&&A(n,a,r[a]);if(I)for(var a of I(r))Le.call(r,a)&&A(n,a,r[a]);return n},y=(n,r)=>_e(n,Ve(r));const{EPolygonPattern:Oe}=pe,je=({currentData:n,config:r,checkMode:a,configString:E,imgIndex:S,toolInstanceRef:i,setResourceLoading:k})=>{const e=le(re),{changeSelectedBoxValid:T,selectNextBox:D,selectPrevBox:H,updateSelectedBox:K,deleteSelectedPointCloudBoxAndPolygon:N}=ae(),{selectedSphere:v,updatePointCloudSphere:U}=ue(),{clearAllResult:w,updatePointCloudPattern:z}=fe(),{copySelectedBoxes:R,pasteSelectedBoxes:F,copiedBoxes:Ae}=ie({config:r,currentData:n}),{updateRotate:x}=se({currentData:n}),{updateRotateEdge:q}=ne({currentData:n}),{updatePointCloudData:m,topViewSelectedChanged:G}=Pe({setResourceLoading:k}),{redo:_,undo:V,pushHistoryWithList:M,pushHistoryUnderUpdatePolygon:W,pushHistoryUnderUpdateLine:Y}=ve(),{syncThreeViewsAttribute:B}=we(),{syncAllViewsConfig:$,reRenderTopViewRange:J}=Ce(),{selectedPolygon:L}=he(),{selectedLine:O}=ge(),{t:C}=ke(),{updatePointCloudColor:Q}=Se(k,r),X=j(n),b=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},Z=(t,o)=>{var s,u;const{topViewInstance:c,mainViewInstance:l}=e;if(!c)return;const{pointCloud2dOperation:h}=c;switch(t){case"q":{x(e.rectRotateSensitivity);break}case"e":x(-Number(e.rectRotateSensitivity));break;case"g":q(-90);break;case"u":{const p=h.pattern===Oe.Normal?f.Rect:f.Polygon;z(p);const oe={[f.Polygon]:C("PolygonPattern"),[f.Rect]:C("RectPattern")};g.success(C("ChangePatternMsg",{pattern:oe[p]})),h.clearActiveStatus(),h.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){H();break}D(),o.preventDefault();break;case"f":T();break;case"arrowup":b({y:-1});break;case"arrowdown":b({y:1});break;case"arrowleft":b({x:-1});break;case"arrowright":b({x:1});break;case"delete":N(X.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const p=de.getAttributeByKeycode(o.keyCode,r.attributeList);p!==void 0&&((u=i.current)==null||u.setDefaultAttribute(p))}return}}},ee=(t,o)=>{switch(t){case"c":R();break;case"v":F();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?_():V();break}}},te=j(t=>{if(!ce.hotkeyFilter(t)||a===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){ee(o,t);return}Z(o,t)});return d(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>te.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),d(()=>{$(r)},[E]),d(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),d(()=>{m==null||m()},[S,e.mainViewInstance]),d(()=>{e.setHideAttributes([])},[S]),d(()=>{i.current.setDefaultAttribute=t=>{var o;if(B(t),Q(t),L&&W(y(P({},L),{attribute:t})),O&&Y(y(P({},O),{attribute:t})),v){const s=U(y(P({},v),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),G({newSelectedSphere:v,newSphereList:s}))}},i.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=y(P({},c),{[t]:o}),K(u),e.mainViewInstance&&e.selectedPointCloudBox&&e.mainViewInstance.generateBox(e.selectedPointCloudBox)}},i.current.clearResult=()=>{w==null||w()},i.current.redo=()=>{_()},i.current.undo=()=>{V()},i.current.setValid=t=>{i.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&w()})},i.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)},i.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},i.current.asyncData=t=>{setTimeout(()=>{m==null||m(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),d(()=>{i.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},i.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),d(()=>{i.current.history={pushHistory:t=>{M({pointCloudBoxList:t})},initRecord:()=>{}}},[]),d(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||a)return;const s=l=>{B(l)},u=l=>{g.error(l)},c=l=>{g.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 Ie=me(be,null,null,{context:ye})(je);export{Ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as Q,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as mt,useCallback as xt}from"react";import{PointCloudContext as ht}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as rt}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as lt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as dt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as $}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,ho=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,L=(e,n)=>{for(var t in n||(n={}))xo.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))ho.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((c,p)=>{var o=a=>{try{u(t.next(a))}catch(x){p(x)}},f=a=>{try{u(t.throw(a))}catch(x){p(x)}},u=a=>a.done?c(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const tt=5,ot=90,wt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(e,n,t,c,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,a={center:{x:o,y:f,z:u},id:e.id},x=c?L(L({},c),a):A(L({},a),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},ct=(e,n,t,c,p,o)=>{let f=e.pointList.map(I=>O.transferCanvas2World(I,n)),u=0,a=1,x={};if(t){const I=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&I.fittedCoordinates.length>0&&(f=I.fittedCoordinates),u=(I.maxZ+I.minZ)/2,a=I.maxZ-I.minZ,x={count:I.zCount}}const[P,v,T]=f,_=w.getLineCenterPoint([P,T]),D=w.getLineLength(P,v),U=w.getLineLength(v,T),N=w.getRadiusFromQuadrangle(e.pointList);c&&(u=c.center.z,a=c.depth);const z={center:{x:_.x,y:_.y,z:u},width:o?U+wt:U,height:o?D+wt:D,depth:a,rotation:N,id:e.id},j=L(c?L(L({},c),z):A(L({},z),{attribute:"",valid:!0}),x);p&&Object.assign(j,p);const M=f.map(I=>O.transferWorld2Canvas(I,n));return{boxParams:j,newPointList:M}},It=(e,n,t)=>{const c={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x-c.x,y:t.center.y,z:t.center.z-c.y}})},Dt=(e,n,t,c)=>{const[p,o,f]=e.pointList,[u,a,x]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,x]),_={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,a),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(a,x),M=z-j,{newBoxParams:I}=c.getNewBoxBySideUpdate(_,M,N,t);return I},Lo=(e,n,t)=>{const c={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x,y:t.center.y-c.x,z:t.center.z-c.y}})},vo=(e,n,t,c)=>{const[p,o,f]=e.pointList,[u,a,x]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,x]),_={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,a),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(a,x),M=z-j;let{newBoxParams:I}=c.getNewBoxByBackUpdate(_,M,N,t);return I},St=(e,n,t,c,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(c,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,Q.Left);u.setInitCameraPosition(a);const{point2d:x,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,c)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(c,e,{width:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,Q.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,c,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(c,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,Q.Back);u.setInitCameraPosition(a);const{point2d:x,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,c)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(c,e,{height:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,Q.Back);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxBackPolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},kt=(e,n,t,c)=>{if(!t||!c)return;c.generateSphere(e),c.updateCameraBySphere(e,Q.Top),c.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(L(L({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},ut=(e,n,t,c)=>{var p,o;if(!t||!c)return;c.generateBox(e,n.id),c.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:a}=u.getBoxTopPolygon2DCoordinate(e),x=[...f.polygonList],P=x.find(v=>v.id===n.id);P?(P.pointList=a,P.valid=(p=e.valid)!=null?p:!0):x.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(x,n.id)},yo=e=>{const n=mt(ht),{topViewInstance:t,sideViewInstance:c,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:a,selectedIDs:x,pointCloudBoxList:P,pointCloudSphereList:v,hideAttributes:T,setHighlight2DDataList:_,cuboidBoxIn2DView:D,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:M,pushHistoryUnderUpdatePolygon:I}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:pt,selectedSphere:X}=ro(),{currentData:H,config:B}=ao(s=>{const{stepList:i,step:d,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:lt(uo.getCurrentStepInfo(d,i).config)}}),F=co(),Tt=$(D),Ut=$(z),zt=xt((s,i)=>{const d=Ut.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))})},[]),et=s=>{const{enableAutoMap2DRect:i=!1}=B;if(!Tt.current||i){const{mappingImgList:d=[]}=H;po({pointCloudBox:s,mappingImgList:d,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:nt,getPointCloudByID:jt}=so({generateRects:et}),gt=k==null?void 0:k.info;if(!t||!c||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:it}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({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:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const C=at(s,i,it,void 0,g);a(s.id);const m=u(C);Y(y.Top,s,C,d,m,B),j({newSphereParams:C})},Ft=({polygon:s,size:i,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,m,b;const V={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(V,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:v})});const R=t==null?void 0:t.toolInstance,S=L({},s);let{boxParams:h,newPointList:E}=ct(S,i,it,void 0,V,g);h=F(dt({tool:st.PointCloud,dataList:[h],stepConfig:B,action:"viewUpdateBox"}))[0],g&&(E==null?void 0:E.length)&&(S.pointList=E);const W=T.includes(S.attribute);et(h);const J=f(h),q=(m=n==null?void 0:n.polygonList)!=null?m:[];h.subAttribute=oo.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(b=B==null?void 0:B.inputList)!=null?b:[]:[]),t==null||t.updatePolygonList(J!=null?J:[],q),W?a([]):(a(h.id),R.selection.setSelectedIDs(S.id),Z({omitView:y.Top,polygon:S,boxParams:h,zoom:l,newPointCloudBoxList:J}),g&&ut(h,S,t,o)),j({newBoxParams:h})},Ht=s=>{const{boxID:i,imageName:d,width:r,height:l,x:g,y:C}=s,m=P.find(h=>h.id===i);if(!(m==null?void 0:m.rects)||!m.rects.find(h=>h.imageName===d))return;const V=m.rects.map(h=>h.imageName===d?A(L({},h),{width:r,height:l,x:g,y:C}):h),R=A(L({},m),{rects:V}),S=P.map(h=>h.id===i?R:h);return t==null||t.updatePolygonList(S!=null?S:[]),S},Wt=s=>{const{boxID:i,imageName:d}=s,r=P.find(m=>m.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(m=>m.imageName!==d),g=A(L({},r),{rects:l}),C=P.map(m=>m.id===i?g:m);return t==null||t.updatePolygonList(C!=null?C:[]),C},Zt=({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||(k==null?void 0:k.info)){const C=s!=null?s:k==null?void 0:k.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(x[0]);const m=g.selectedPolygon;if(x.length===1&&C){Z({omitView:y.Top,polygon:m,boxParams:C,newPointCloudBoxList:i});return}}if((d||X)&&x.length===1){const C=d!=null?d:X;g.setSelectedID(x[0]);const m=g.selectedPoint;C&&Y(y.Top,m,C,void 0,r,B)}}},ft=(s,i,d)=>{if(gt){let r,l;switch(d){case y.Back:r=vo;break;case y.Side:r=Dt;break;default:r=Dt;break}if(l=r(s,i,gt,c.pointCloudInstance),o){const{count:V}=o.getSensesPointZAxisInPolygon(eo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=A(L({},l),{count:V})}const C=F(dt({tool:st.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],m=l.valid!==C.valid;l=C;const b=Nt(l);return l=b.find(V=>V.id===l.id),Z({omitView:m?void 0:d,polygon:s,boxParams:l,newPointCloudBoxList:b}),b}},Ct=(s,i,d)=>{if(X){let r,l;switch(d){case y.Back:r=Lo;break;case y.Side:r=It;break;default:r=It;break}l=r(s,i,X);const g=pt(l);return Y(d,s,l,void 0,g,B),g}},Gt=(s,i)=>{Ct(s,i,y.Side)},Jt=(s,i)=>{Ct(s,i,y.Back)},Qt=(s,i)=>{ft(s,i,y.Side)},Xt=(s,i)=>{ft(s,i,y.Back)},Yt=(s,i)=>{const d=At(s.id),r=at(s,i,it,d),l=pt(r);Y(y.Top,s,r,void 0,l,B)},qt=(s,i)=>{if(Ot){const r=L({},s[0].newPolygon);r.pointList=r.pointList.map(l=>O.transferCanvas2World(l,i)),I(r);return}let d=s.map(({newPolygon:r})=>{const l=jt(r.id),{boxParams:g}=ct(r,i,t.pointCloudInstance,l);return g});if(d=F(dt({tool:st.PointCloud,dataList:d,stepConfig:B,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=s[0],l=nt(d);Z({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=nt(d);r&&n.syncAllViewPointCloudColor(rt.MultiMove,r)}},Kt=s=>{var i,d,r,l,g;if(k){const C=Number(s.widthDefault),m=Number(s.depthDefault),b=Number(s.heightDefault),V=k==null?void 0:k.info.trackID,S=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(K=>(K==null?void 0:K.trackID)===V),h={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},E=S.pointList.map(K=>O.transferCanvas2World(K,h)),G=w.getModifiedRectangleCoordinates(E,b,C),W=G[0],J=G[2],q=w.getLineCenterPoint([W,J]),$t=k.info.center.z-k.info.depth/2,Pt=A(L({},k.info),{center:{x:q.x,y:q.y,z:$t+m/2},width:C,height:b,depth:m,valid:!0}),to=nt([Pt]);Z({omitView:y["3D"],polygon:S,boxParams:Pt,newPointCloudBoxList:to})}},Y=(s,i,d,r,l,g)=>bt(void 0,null,function*(){const C=H==null?void 0:H.url,m={[y.Side]:()=>{St(d,i,c,C,g)},[y.Back]:()=>{p&&_t(d,i,p,C,g)},[y.Top]:()=>{kt(d,i,t,o)}};Object.keys(m).forEach(b=>{b!==s&&m[b]()}),r&&(o==null||o.updateCameraZoom(r)),Et(d)}),Z=s=>{const{omitView:i,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:g}=s,C=H==null?void 0:H.url;g&&n.syncAllViewPointCloudColor(rt.Single,g);const m={[y.Side]:()=>{Rt(r,d,c,C)},[y.Back]:()=>{p&&Vt(r,d,p,C)},[y.Top]:()=>{ut(r,d,t,o)}};Object.keys(m).forEach(b=>{b!==i&&m[b]()}),l&&(o==null||o.updateCameraZoom(l))};return{topViewAddSphere:Mt,topViewAddBox:Ft,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=H){var d,r,l,g,C,m,b,V;if(!(i==null?void 0:i.url)||!o)return;_([]),Lt(F,!0),vt(F,!0),(d=e==null?void 0:e.setResourceLoading)==null||d.call(e,!0),yield o.loadPCDFile(i.url,(r=B==null?void 0:B.radius)!=null?r:ot),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let R=[],S=[],h=[],E=[];o.updateTopCamera();const G=(g=(l=lt(i.result))==null?void 0:l.valid)!=null?g:!0;if(n.setPointCloudValid(G),(C=n.sideViewInstance)==null||C.clearAllData(),(m=n.backViewInstance)==null||m.clearAllData(),i.result){if(R=O.getBoxParamsFromResultList(i.result),(R==null?void 0:R.length)>0&&i.isPreResult&&(B==null?void 0:B.lowerLimitPointsNumInBox)>0){R=yield o==null?void 0:o.filterPreResult(i.url,B,R);const W=lt(i.result);W[no].result=R,i.result=JSON.stringify(W),n.setPointCloudResult(R)}h=O.getPolygonListFromResultList(i.result),S=O.getLineListFromResultList(i.result),E=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(b=B==null?void 0:B.radius)!=null?b:ot}),o==null||o.generateBoxes(R),o==null||o.generateSpheres(E),yield n.syncAllViewPointCloudColor(rt.Default,R,[])}M({pointCloudBoxList:R,polygonList:h,lineList:S,pointCloudSphereList:E}),Lt(F,!1),vt(F,!1),(V=e==null?void 0:e.setResourceLoading)==null||V.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:et,update2DViewRect:Ht,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(ht),c=$(e),p=$(n);return{syncToPointCloudBoxList:xt(()=>{const f=c.current,u=p.current;if(u.length===0)return null;const a=new Map,x=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const v=P.extId,T=P.imageName,_=lo(P,["x","y","width","height"]);let D=a.get(v);D||(D=new Map,a.set(v,D)),D.set(T,_),x.add(v)}),a.size){const P=f.map(v=>{var T;const _=v.id;if(x.has(_)){const D=L({},v);return(T=D.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.get(_))==null?void 0:N.get(z))}),D}return v});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ut as synchronizeTopView,at as topViewPoint2PointCloud,ct as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
|
|
1
|
+
import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as X,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as mt,useCallback as xt}from"react";import{PointCloudContext as ht}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as rt}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as lt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as dt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as $}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,ho=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,L=(e,n)=>{for(var t in n||(n={}))xo.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))ho.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((c,p)=>{var o=d=>{try{u(t.next(d))}catch(x){p(x)}},f=d=>{try{u(t.throw(d))}catch(x){p(x)}},u=d=>d.done?c(d.value):Promise.resolve(d.value).then(o,f);u((t=t.apply(e,n)).next())});const tt=5,ot=90,wt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(e,n,t,c,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,d={center:{x:o,y:f,z:u},id:e.id},x=c?L(L({},c),d):A(L({},d),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},ct=(e,n,t,c,p,o)=>{let f=e.pointList.map(I=>O.transferCanvas2World(I,n)),u=0,d=1,x={};if(t){const I=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&I.fittedCoordinates.length>0&&(f=I.fittedCoordinates),u=(I.maxZ+I.minZ)/2,d=I.maxZ-I.minZ,x={count:I.zCount}}const[P,v,T]=f,V=w.getLineCenterPoint([P,T]),D=w.getLineLength(P,v),U=w.getLineLength(v,T),N=w.getRadiusFromQuadrangle(e.pointList);c&&(u=c.center.z,d=c.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+wt:U,height:o?D+wt:D,depth:d,rotation:N,id:e.id},j=L(c?L(L({},c),z):A(L({},z),{attribute:"",valid:!0}),x);p&&Object.assign(j,p);const M=f.map(I=>O.transferWorld2Canvas(I,n));return{boxParams:j,newPointList:M}},It=(e,n,t)=>{const c={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x-c.x,y:t.center.y,z:t.center.z-c.y}})},Dt=(e,n,t,c)=>{const[p,o,f]=e.pointList,[u,d,x]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,x]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,d),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(d,x),M=z-j,{newBoxParams:I}=c.getNewBoxBySideUpdate(V,M,N,t);return I},Lo=(e,n,t)=>{const c={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x,y:t.center.y-c.x,z:t.center.z-c.y}})},vo=(e,n,t,c)=>{const[p,o,f]=e.pointList,[u,d,x]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,x]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,d),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(d,x),M=z-j;let{newBoxParams:I}=c.getNewBoxByBackUpdate(V,M,N,t);return I},St=(e,n,t,c,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(c,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:d}=u.updateOrthoCameraBySphere(e,X.Left);u.setInitCameraPosition(d);const{point2d:x,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,c)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(c,e,{width:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:d}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=d,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,c,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(c,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:d}=u.updateOrthoCameraBySphere(e,X.Back);u.setInitCameraPosition(d);const{point2d:x,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,c)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(c,e,{height:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Back);o.setInitCameraPosition(f);const{polygon2d:u,zoom:d}=o.getBoxBackPolygon2DCoordinate(e);o.camera.zoom=d,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},kt=(e,n,t,c)=>{if(!t||!c)return;c.generateSphere(e),c.updateCameraBySphere(e,X.Top),c.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(d=>d.id===n.id?A(L(L({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):d);p.setResult(u),p.setSelectedID(n.id)},ut=(e,n,t,c)=>{var p,o;if(!t||!c)return;c.generateBox(e,n.id),c.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:d}=u.getBoxTopPolygon2DCoordinate(e),x=[...f.polygonList],P=x.find(v=>v.id===n.id);P?(P.pointList=d,P.valid=(p=e.valid)!=null?p:!0):x.push({id:n.id,pointList:d,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(x,n.id)},yo=e=>{const n=mt(ht),{topViewInstance:t,sideViewInstance:c,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:d,selectedIDs:x,pointCloudBoxList:P,pointCloudSphereList:v,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:D,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:M,pushHistoryUnderUpdatePolygon:I}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:pt,selectedSphere:Y}=ro(),{currentData:H,config:B}=ao(s=>{const{stepList:i,step:a,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:lt(uo.getCurrentStepInfo(a,i).config)}}),F=co(),Tt=$(D),Ut=$(z),zt=xt((s,i)=>{const a=Ut.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))})},[]),et=s=>{const{enableAutoMap2DRect:i=!1}=B;if(!Tt.current||i){const{mappingImgList:a=[]}=H;po({pointCloudBox:s,mappingImgList:a,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:nt,getPointCloudByID:jt}=so({generateRects:et}),gt=k==null?void 0:k.info;if(!t||!c||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:it}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({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:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const C=at(s,i,it,void 0,g);d(s.id);const m=u(C);G(y.Top,s,C,a,m,B),j({newSphereParams:C})},Ft=({polygon:s,size:i,imgList:a,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,m,b;const S={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(S,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:v})});const _=t==null?void 0:t.toolInstance,R=L({},s);let{boxParams:h,newPointList:E}=ct(R,i,it,void 0,S,g);h=F(dt({tool:st.PointCloud,dataList:[h],stepConfig:B,action:"viewUpdateBox"}))[0],g&&(E==null?void 0:E.length)&&(R.pointList=E);const Z=T.includes(R.attribute);et(h);const Q=f(h),q=(m=n==null?void 0:n.polygonList)!=null?m:[];h.subAttribute=oo.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(b=B==null?void 0:B.inputList)!=null?b:[]:[]),t==null||t.updatePolygonList(Q!=null?Q:[],q),Z?d([]):(d(h.id),_.selection.setSelectedIDs(R.id),W({omitView:y.Top,polygon:R,boxParams:h,zoom:l,newPointCloudBoxList:Q}),g&&ut(h,R,t,o)),j({newBoxParams:h})},Ht=s=>{const{boxID:i,imageName:a,width:r,height:l,x:g,y:C}=s,m=P.find(h=>h.id===i);if(!(m==null?void 0:m.rects)||!m.rects.find(h=>h.imageName===a))return;const S=m.rects.map(h=>h.imageName===a?A(L({},h),{width:r,height:l,x:g,y:C}):h),_=A(L({},m),{rects:S}),R=P.map(h=>h.id===i?_:h);return t==null||t.updatePolygonList(R!=null?R:[]),R},Wt=s=>{const{boxID:i,imageName:a}=s,r=P.find(m=>m.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(m=>m.imageName!==a),g=A(L({},r),{rects:l}),C=P.map(m=>m.id===i?g:m);return t==null||t.updatePolygonList(C!=null?C:[]),C},Zt=({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||(k==null?void 0:k.info)){const C=s!=null?s:k==null?void 0:k.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(x[0]);const m=g.selectedPolygon;if(x.length===1&&C){W({omitView:y.Top,polygon:m,boxParams:C,newPointCloudBoxList:i});return}}if((a||Y)&&x.length===1){const C=a!=null?a:Y;g.setSelectedID(x[0]);const m=g.selectedPoint;C&&G(y.Top,m,C,void 0,r,B)}}},ft=(s,i,a)=>{if(gt){let r,l;switch(a){case y.Back:r=vo;break;case y.Side:r=Dt;break;default:r=Dt;break}if(l=r(s,i,gt,c.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(eo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=A(L({},l),{count:S})}const C=F(dt({tool:st.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],m=l.valid!==C.valid;l=C;const b=Nt(l);return l=b.find(S=>S.id===l.id),W({omitView:m?void 0:a,polygon:s,boxParams:l,newPointCloudBoxList:b}),b}},Ct=(s,i,a)=>{if(Y){let r,l;switch(a){case y.Back:r=Lo;break;case y.Side:r=It;break;default:r=It;break}l=r(s,i,Y);const g=pt(l);return G(a,s,l,void 0,g,B),g}},Gt=(s,i)=>{Ct(s,i,y.Side)},Jt=(s,i)=>{Ct(s,i,y.Back)},Qt=(s,i)=>{ft(s,i,y.Side)},Xt=(s,i)=>{ft(s,i,y.Back)},Yt=(s,i)=>{const a=At(s.id),r=at(s,i,it,a),l=pt(r);G(y.Top,s,r,void 0,l,B)},qt=(s,i)=>{if(Ot){const r=L({},s[0].newPolygon);r.pointList=r.pointList.map(l=>O.transferCanvas2World(l,i)),I(r);return}let a=s.map(({newPolygon:r})=>{const l=jt(r.id),{boxParams:g}=ct(r,i,t.pointCloudInstance,l);return g});if(a=F(dt({tool:st.PointCloud,dataList:a,stepConfig:B,action:"viewUpdateBox"})),a.length===1){const{newPolygon:r}=s[0],l=nt(a);W({polygon:r,boxParams:a[0],newPointCloudBoxList:l})}else{const r=nt(a);r&&n.syncAllViewPointCloudColor(rt.MultiMove,r)}},Kt=s=>{var i,a,r,l,g;if(k){const C=Number(s.widthDefault),m=Number(s.depthDefault),b=Number(s.heightDefault),S=k==null?void 0:k.info.trackID,R=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(K=>(K==null?void 0:K.trackID)===S),h={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},E=R.pointList.map(K=>O.transferCanvas2World(K,h)),J=w.getModifiedRectangleCoordinates(E,b,C),Z=J[0],Q=J[2],q=w.getLineCenterPoint([Z,Q]),$t=k.info.center.z-k.info.depth/2,Pt=A(L({},k.info),{center:{x:q.x,y:q.y,z:$t+m/2},width:C,height:b,depth:m,valid:!0}),to=nt([Pt]);W({omitView:y["3D"],polygon:R,boxParams:Pt,newPointCloudBoxList:to})}},G=(s,i,a,r,l,g)=>bt(void 0,null,function*(){const C=H==null?void 0:H.url,m={[y.Side]:()=>{St(a,i,c,C,g)},[y.Back]:()=>{p&&_t(a,i,p,C,g)},[y.Top]:()=>{kt(a,i,t,o)}};Object.keys(m).forEach(b=>{b!==s&&m[b]()}),r&&(o==null||o.updateCameraZoom(r)),Et(a)}),W=(s,i=rt.Default)=>{const{omitView:a,polygon:r,boxParams:l,zoom:g,newPointCloudBoxList:C}=s,m=H==null?void 0:H.url;C&&n.syncAllViewPointCloudColor(i,C);const b={[y.Side]:()=>{Rt(l,r,c,m)},[y.Back]:()=>{p&&Vt(l,r,p,m)},[y.Top]:()=>{ut(l,r,t,o)}};Object.keys(b).forEach(S=>{S!==a&&b[S]()}),g&&(o==null||o.updateCameraZoom(g))};return{topViewAddSphere:Mt,topViewAddBox:Ft,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:W,syncPointCloudPoint:G,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=H){var a,r,l,g,C,m,b,S;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(F,!0),vt(F,!0),(a=e==null?void 0:e.setResourceLoading)==null||a.call(e,!0),yield o.loadPCDFile(i.url,(r=B==null?void 0:B.radius)!=null?r:ot),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let _=[],R=[],h=[],E=[];o.updateTopCamera();const J=(g=(l=lt(i.result))==null?void 0:l.valid)!=null?g:!0;if(n.setPointCloudValid(J),(C=n.sideViewInstance)==null||C.clearAllData(),(m=n.backViewInstance)==null||m.clearAllData(),i.result){if(_=O.getBoxParamsFromResultList(i.result),(_==null?void 0:_.length)>0&&i.isPreResult&&(B==null?void 0:B.lowerLimitPointsNumInBox)>0){_=yield o==null?void 0:o.filterPreResult(i.url,B,_);const Z=lt(i.result);Z[no].result=_,i.result=JSON.stringify(Z),n.setPointCloudResult(_)}h=O.getPolygonListFromResultList(i.result),R=O.getLineListFromResultList(i.result),E=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(b=B==null?void 0:B.radius)!=null?b:ot}),o==null||o.generateBoxes(_),o==null||o.generateSpheres(E),yield n.syncAllViewPointCloudColor(rt.Default,_,[])}M({pointCloudBoxList:_,polygonList:h,lineList:R,pointCloudSphereList:E}),Lt(F,!1),vt(F,!1),(S=e==null?void 0:e.setResourceLoading)==null||S.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:et,update2DViewRect:Ht,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(ht),c=$(e),p=$(n);return{syncToPointCloudBoxList:xt(()=>{const f=c.current,u=p.current;if(u.length===0)return null;const d=new Map,x=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const v=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let D=d.get(v);D||(D=new Map,d.set(v,D)),D.set(T,V),x.add(v)}),d.size){const P=f.map(v=>{var T;const V=v.id;if(x.has(V)){const D=L({},v);return(T=D.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=d.get(V))==null?void 0:N.get(z))}),D}return v});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ut as synchronizeTopView,at as topViewPoint2PointCloud,ct as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useContext as w}from"react";import{useDispatch as D}from"../../../store/ctx.js";import{useSingleBox as b}from"./useSingleBox.js";import{PointCloudContext as T}from"../PointCloudContext.js";import{EPointCloudName as R}from"@labelbee/lb-annotation";import{PreDataProcess as E}from"../../../store/annotation/actionCreators.js";import{usePointCloudViews as H}from"./usePointCloudViews.js";import{useSphere as L}from"./useSphere.js";import{useHistory as _}from"./useHistory.js";import{EPointCloudBoxRenderTrigger as f}from"../../../utils/ToolPointCloudBoxRenderHelper.js";const P={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},k=(v,a)=>{const r=w(T),{topViewInstance:d,selectedIDs:e,pointCloudBoxList:l,mainViewInstance:c,selectedID:g}=r,h=D(),{selectedSphere:p}=L(),{syncPointCloudViews:C,syncPointCloudPoint:m,generateRects:V}=H({setResourceLoading:v}),{selectedBox:u,updateSelectedBox:j}=b({generateRects:V}),{pushHistoryWithList:x}=_(),y=({newSelectedSphere:n,newSphereList:o})=>{const t=d==null?void 0:d.toolInstance;if((n||p)&&e.length===1){const i=n!=null?n:p;t.setSelectedID(e[0]);const s=t.selectedPoint;i&&(m==null||m(P.Top,s,i,void 0,o,a))}},I=({trigger:n,newSelectedBox:o})=>{const t=d==null?void 0:d.toolInstance;if(!(e.length===0||!t)&&(o||(u==null?void 0:u.info))){const i=o!=null?o:u==null?void 0:u.info,s=o;if(i){C==null||C({omitView:P.Top,polygon:s,boxParams:i},n);return}}};return{updatePointCloudColor:n=>{if(l.forEach(o=>{var t,i,s;if(o&&e.includes(o.id)){o.attribute=n;const S=h(E({tool:R.PointCloud,dataList:[o],stepConfig:a,action:"viewUpdateBox"}));o.valid=S[0].valid,j(o),(s=(i=(t=r==null?void 0:r.topViewInstance)==null?void 0:t.pointCloud2dOperation)==null?void 0:i.setPolygonValidAndRender)==null||s.call(i,o.id,!0,o.valid),y({})}}),c){const o=e&&e.length>1?f.MulitSelect:f.Single;r.syncAllViewPointCloudColor(o,l),l.forEach(t=>{I({trigger:o,newSelectedBox:t})}),c.generateBoxes(l)}g||x({pointCloudBoxList:l})}}};export{k as useUpdatePointCloudColor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCuboidFromPointCloudBox as l}from"@labelbee/lb-annotation";var i;(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"})(i||(i={}));var d;(function(t){t.ChangeAttribute="ChangeAttribute",t.Move="Move",t.ChangeDepth="ChangeDepth",t.ChangeSize="ChangeSize",t.ToggleValid="ToggleValid"})(d||(d={}));const
|
|
1
|
+
import{getCuboidFromPointCloudBox as l}from"@labelbee/lb-annotation";var i;(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"})(i||(i={}));var d;(function(t){t.ChangeAttribute="ChangeAttribute",t.Move="Move",t.ChangeDepth="ChangeDepth",t.ChangeSize="ChangeSize",t.ToggleValid="ToggleValid"})(d||(d={}));const A=(t,n)=>{const o=u(t).concat(u(n));for(const e of o){const s=g(t,e),r=g(n,e);if(!y(s,r))return!1}return!0},u=t=>{const n=[];for(let o=0;o<t.length;o++){const e=t[o],s=t[(o+1)%t.length],r={x:s.x-e.x,y:s.y-e.y},c={x:-r.y,y:r.x};n.push(c)}return n},g=(t,n)=>{let o=h(t[0],n),e=o;for(const s of t){const r=h(s,n);r<o&&(o=r),r>e&&(e=r)}return{min:o,max:e}},y=(t,n)=>!(t.max<n.min||n.max<t.min),h=(t,n)=>t.x*n.x+t.y*n.y,M=(t,n)=>{const o=[];return n.forEach(e=>{const{polygonPointList:s}=l(e);A(t,s)&&o.push(e.id)}),o},S=(t,n)=>{const o=t.map(s=>s.id),e=n.map(s=>s.id);return o.find(s=>!e.includes(s))||""},v=(t,n)=>{const o=t.map(e=>e.id);return n.find(e=>!o.includes(e.id))},x=(t,n)=>t.find(e=>{const s=n.find(r=>r.id===e.id);return s&&s.valid!==e.valid}),B=(t,n)=>t.find(e=>{const s=n.find(r=>r.id===e.id);return s&&s.rotation!==e.rotation}),f=(t,n)=>{const{polygonPointList:o}=l(t);return{ids:M(o,n.filter(s=>s.id!==t.id)),rect:o}},D=(t,n)=>{const o=(e,s)=>e.attribute===s.attribute&&e.center.x===s.center.x&&e.center.y===s.center.y&&e.depth===s.depth&&e.width===s.width&&e.height===s.height;for(const e of t){const s=n.find(r=>r.id===e.id);if(s&&!o(e,s)){let r;if(s.attribute!==e.attribute?r=d.ChangeAttribute:s.center.x!==e.center.x||s.center.y!==e.center.y?r=d.Move:s.depth!==e.depth?r=d.ChangeDepth:(s.width!==e.width||s.height!==e.height)&&(r=d.ChangeSize),r!==void 0)return{modifiedType:r,box:e}}}},C=(t,n,o)=>{try{switch(t){case i.Single:if(n.length>o.length){const e=S(n,o);return e?{modifiedBoxIds:[e],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}else{const e=[],s=[],r=D(n,o);if(r&&(e.push(r.box.id),r.modifiedType===d.ChangeSize||r.modifiedType===d.Move)){const c=o.find(I=>I.id===r.box.id),{ids:a,rect:m}=f(c,n);e.push(...a),s.push(m)}return{modifiedBoxIds:e,resetAreas:s}}case i.SingleDelete:if(n.length<o.length){const e=v(n,o);if(e){const r=[l(e).polygonPointList],c=[];if(n.length>1){const{ids:a}=f(e,n);a.length&&c.push(...a)}return{modifiedBoxIds:c,resetAreas:r}}return{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case i.SingleRotate:if(B(n,o)){const e=B(n,o);if(e){const s=o.find(a=>a.id===e.id),{ids:r,rect:c}=f(s,n);return{modifiedBoxIds:[e.id,...r],resetAreas:[c]}}}return{modifiedBoxIds:[],resetAreas:[]};case i.SingleToggleValid:if(x(n,o)){const e=x(n,o);return e?{modifiedBoxIds:[e.id],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case i.MulitSelect:return{modifiedBoxIds:k(n,o),resetAreas:[]};case i.MultiPaste:case i.MultiMove:case i.Default:case i.UndoRedo:case i.ClearAll:default:return{modifiedBoxIds:[],resetAreas:[]}}}catch(e){return console.error("calcResetAreasAndBoxIds error:",e),{modifiedBoxIds:[],resetAreas:[]}}},p=(t,n)=>{if(t===n)return!0;if(typeof t!="object"||typeof n!="object"||t===null||n===null)return!1;const o=Object.keys(t),e=Object.keys(n);if(o.length!==e.length)return!1;for(const s of o)if(!p(t[s],n[s]))return!1;return!0},k=(t,n)=>{const o=new Map;for(const e of n)o.set(e.id,e);return t.filter(e=>{const s=o.get(e.id);return!s||!p(e,s)}).map(e=>e.id)};export{i as EPointCloudBoxRenderTrigger,d as EPointCloudBoxSingleModifiedType,C as calcResetAreasAndBoxIds};
|