@labelbee/lb-components 1.24.0-alpha.19 → 1.24.0-alpha.20
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/components/pointCloudView/PointCloudContext.js +1 -1
- package/dist/components/pointCloudView/PointCloudTopView.js +1 -1
- package/dist/components/pointCloudView/components/UnifyParamsModal/index.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/utils/ToolPointCloudBoxRenderHelper.js +1 -1
- package/es/components/pointCloudView/PointCloudContext.js +1 -1
- package/es/components/pointCloudView/PointCloudTopView.js +1 -1
- package/es/components/pointCloudView/components/UnifyParamsModal/index.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/utils/ToolPointCloudBoxRenderHelper.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),React=require("react"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),actionCreators=require("../../store/annotation/actionCreators.js"),index=require("../../store/annotatedBox/index.js"),_=require("lodash"),map=require("./utils/map.js"),useTimeoutFunc=require("./hooks/useTimeoutFunc.js"),useWindowKeydownListener=require("./hooks/useWindowKeydownListener.js");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,i,d)=>i in r?__defProp(r,i,{enumerable:!0,configurable:!0,writable:!0,value:d}):r[i]=d,__spreadValues=(r,i)=>{for(var d in i||(i={}))__hasOwnProp.call(i,d)&&__defNormalProp(r,d,i[d]);if(__getOwnPropSymbols)for(var d of __getOwnPropSymbols(i))__propIsEnum.call(i,d)&&__defNormalProp(r,d,i[d]);return r},__spreadProps=(r,i)=>__defProps(r,__getOwnPropDescs(i)),__async=(r,i,d)=>new Promise((x,D)=>{var A=u=>{try{P(d.next(u))}catch(R){D(R)}},O=u=>{try{P(d.throw(u))}catch(R){D(R)}},P=u=>u.done?x(u.value):Promise.resolve(u.value).then(A,O);P((d=d.apply(r,i)).next())});const pickRectObject=r=>___default.default.pick(r,["id","attribute","width","height","x","y","imageName"]),PointCloudContext=React__default.default.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new lbAnnotation.ActionsHistory,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:lbAnnotation.EToolName.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:lbUtils.EPointCloudPattern.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:r=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:r=>!1,removeRectBySpecifyId:(r,i,d)=>!1,removeRectByPointCloudBoxId:r=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:useWindowKeydownListener.getEmptyUseWindowKeydownListener(),isLargeStatus:!1,setIsLargeStatus:()=>{}}),PointCloudProvider=({children:r})=>{const[i,d]=React.useState([]),[x,D]=React.useState([]),[A,O]=React.useState([]),[P,u]=React.useState([]),[R,Le]=React.useState([]),[v,N]=React.useState([]),[B,j]=React.useState([]),[U,De]=React.useState(!0),[Z,Ae]=React.useState(2),[J,Be]=React.useState(!0),[Q,_e]=React.useState(1),[f,X]=React.useState(),[Y,$]=React.useState(),[ee,te]=React.useState(),[g,oe]=React.useState(),[ne,Ve]=React.useState(""),[F,Ne]=React.useState(lbAnnotation.EToolName.Rect),q=React.useRef(new lbAnnotation.ActionsHistory).current,[p,T]=React.useState([]),[ie,He]=React.useState(""),[z,Me]=React.useState(lbUtils.EPointCloudPattern.Detection),[L,se]=React.useState(void 0),[W,ke]=React.useState([]),[G,Ee]=React.useState([]),[re,Oe]=React.useState(!1),[ae,le]=React.useState(!1),h=index(),[de,je]=React.useState({}),Fe=ctx.useDispatch(),qe=o=>{const{imgNode:n,path:t}=o;t&&n&&je(l=>__spreadProps(__spreadValues({},l),{[t]:{width:n.width,height:n.height}}))},ce=React.useMemo(()=>v.length===1?v[0]:"",[v]),ue=useWindowKeydownListener.default(),H=React.useCallback((o,n,t="extId")=>{const l=t||"id",a=new Set(n);return u(c=>{let S=!1;const I=c.filter(k=>{const K=k[l],E=a.has(K)?k.imageName!==o:!0;return E||(S=!0),E});return S?I:c}),!0},[]),ge=React.useCallback(o=>{const n=i.map(t=>t.id);return H(o,n,"extId")},[i,H]),fe=React.useCallback(o=>{if(!o)return!1;const n=i.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:l,attribute:a,trackID:c}=t,S=t.rects.find(I=>I.imageName===o);if(S){const I=___default.default.pick(S,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},I),{id:lbAnnotation.uuid(),attribute:a,order:c,extId:l,lineDash:[]})}return null}).filter(t=>t!==null);return n.length?(u(t=>{const l=new Set(t.filter(c=>o===c.imageName).map(c=>c.extId)),a=n.filter(c=>l.has(c.extId)===!1);return a.length?[...t,...a]:t}),!0):!1},[i]),pe=React.useMemo(()=>i.filter(n=>Array.isArray(n.rects)&&n.rects.length>0).reduce((n,t)=>{var l;return(l=t.rects)==null||l.forEach(a=>{const{imageName:c}=a;if(!c){console.warn("Missing image name"),console.trace(a,t);return}map.addMapIndirectWeakSetItem(n,c,t.id,t)}),n},new Map),[i]),he=React.useCallback(o=>{u(n=>o(n,pickRectObject))},[pickRectObject]),me=React.useMemo(()=>P.filter(o=>o.extId!==void 0&&o.id!==void 0).reduce((o,n)=>{const t=n.imageName;return t?(map.addMapIndirectWeakSetItem(o,t,n.extId,n),o):(console.warn("missing image name"),console.log(n,P),o)},new Map),[P]),{fn:Te}=useTimeoutFunc.default(o=>{N(n=>{const t=o,l=new Set(t);let a=!1;const c=n.filter(S=>{const I=l.has(S);return I||(a=!0),I});return a?c:n})},200),ve=React.useCallback(o=>{const n=o.map(t=>t.id);d(o),Te(n)},[]),M=React.useMemo(()=>{const o=i.find(e=>e.id===ce),n=e=>{const s=i.concat(e);return ve(s),s},t=e=>{const s=x.concat(e);return D(s),s},l=e=>{De(e!==!1)},a=e=>{e===void 0&&N([]),typeof e=="string"&&N([e]),Array.isArray(e)&&N(Array.from(new Set(e)))},c=e=>{v.includes(e)?a(v.filter(s=>s!==e)):a([...v,e])},S=e=>{const s=pickRectObject(e);u(m=>[...m,s])},I=(e,s=!1)=>{const m=pickRectObject(e);u(C=>C.map(w=>w.id===e.id?s?__spreadValues(__spreadValues({},w),m):m:w))},k=e=>{u(s=>s.filter(m=>!e.find(C=>C.id===m.id)))},K=e=>{B.includes(e)?j([]):j([e])},E=()=>{if(F===lbAnnotation.EToolName.Rect){const e=i.map(s=>s.id);a(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},We=e=>{a(i.filter(s=>s.attribute===e).map(s=>s.id))},Ie=i.filter(e=>!p.includes(e.attribute)),Pe=x.filter(e=>!p.includes(e.attribute)),Se=R.filter(e=>e.attribute&&!p.includes(e.attribute)),Ge=e=>{if(p.includes(e))T(p.filter(s=>s!==e));else{const s=p.concat(e);T(s)}},Ke=(e=Ie,s=A,m=Pe,C=Se,w=W)=>{var V;g==null||g.clearAllBox(),g==null||g.clearAllSphere(),f==null||f.updatePolygonList(e,s),f==null||f.updatePointList(m),f==null||f.updateLineList(C),g==null||g.generateBoxes(e),g==null||g.generateSpheres(m),(V=L==null?void 0:L.store)==null||V.updateCurrentSegment(w),Ce(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},Ue=()=>{X(void 0),$(void 0),te(void 0),oe(void 0)},Ce=(e,s,m)=>__async(void 0,null,function*(){var C,w,V;if(!g)return;const we=g.pointCloudObject;if(!we)return;let ye=[],be=[];try{if(s&&q.record.length){const{record:y,recordIndex:b}=q;let Re=b;b>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&s.length===((C=y[b])==null?void 0:C.pointCloudBoxList.length))&&(Re=b-1);let Ze=(w=y[Re])==null?void 0:w.pointCloudBoxList;const xe=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,s,Ze);ye=xe.modifiedBoxIds,be=xe.resetAreas}}catch(y){console.error("call calcResetAreasAndBoxIds error",y)}try{const y=yield g.getHighlightIndexByMappingImgList({mappingImgList:m!=null?m:G,points:we.geometry.attributes.position.array}),b=yield g==null?void 0:g.highlightOriginPointCloud(s,y,{modifiedBoxIds:ye,resetAreas:be});return b&&((V=f==null?void 0:f.pointCloudInstance)==null||V.updateColor(b)),b}catch(y){console.error("call highlightOriginPointCloud error",y)}});return{selectedID:ce,pointCloudBoxList:i,pointCloudSphereList:x,displayPointCloudList:Ie,displaySphereList:Pe,displayLineList:Se,selectedIDs:v,setPointCloudResult:ve,setSelectedIDs:a,addPointCloudBox:n,addPointCloudSphere:t,setPointCloudSphereList:D,valid:U,selectedPointCloudBox:o,setPointCloudValid:l,addSelectedID:c,addHighlightID:K,selectedAllBoxes:E,topViewInstance:f,setTopViewInstance:X,sideViewInstance:Y,setSideViewInstance:$,backViewInstance:ee,setBackViewInstance:te,mainViewInstance:g,setMainViewInstance:oe,polygonList:A,setPolygonList:O,rectList:P,setRectList:u,addRectIn2DView:S,removeRectIn2DView:k,updateRectIn2DView:I,lineList:R,setLineList:Le,zoom:Q,setZoom:_e,history:q,toggleAttributesVisible:Ge,hideAttributes:p,setHideAttributes:T,reRender:Ke,attrPanelLayout:ie,setAttrPanelLayout:He,syncAllViewPointCloudColor:Ce,defaultAttribute:ne,setDefaultAttribute:Ve,pointCloudPattern:F,setPointCloudPattern:Ne,selectSpecAttr:We,globalPattern:z,setGlobalPattern:e=>{z!==e&&(Fe(actionCreators.ChangeSave),Me(e),e===lbUtils.EPointCloudPattern.Detection&&se(void 0))},ptSegmentInstance:L,setPtSegmentInstance:se,segmentation:W,setSegmentation:ke,clearAllDetectionInstance:Ue,highlight2DDataList:G,setHighlight2DDataList:Ee,highlight2DLoading:re,setHighlight2DLoading:Oe,cuboidBoxIn2DView:J,setCuboidBoxIn2DView:Be,imageSizes:de,cacheImageNodeSize:qe,highlightIDs:B,setHighlightIDs:j,removeRectByPointCloudBoxId:ge,removeRectBySpecifyId:H,addRectFromPointCloudBoxByImageName:fe,rectRotateSensitivity:Z,setRectRotateSensitivity:Ae,imageNamePointCloudBoxMap:pe,linkageImageNameRectMap:me,updateRectListByReducer:he,windowKeydownListenerHook:ue,isLargeStatus:ae,setIsLargeStatus:le}},[U,v,i,x,A,R,P,f,Y,ee,g,Q,p,ie,ne,F,z,L,W,G,re,J,de,B,ge,H,fe,Z,pe,me,he,ue,ae,le]);React.useEffect(()=>{var o,n,t;(o=h==null?void 0:h.setPointCloudBoxList)==null||o.call(h,i),(n=h==null?void 0:h.setHighlightIDs)==null||n.call(h,B),(t=h==null?void 0:h.setSelectedIDs)==null||t.call(h,v)},[i,v,B]),React.useEffect(()=>{var o;(o=h==null?void 0:h.setPtCtx)==null||o.call(h,M)},[M]);const ze=()=>{const o=i.filter(a=>p.includes(a.attribute)),{setSelectedIDs:n,reRender:t}=M,l=o.map(a=>a.id);l.length>0&&n(v.filter(a=>!l.includes(a))),t()};return React.useEffect(()=>{var o,n,t,l;ze(),(n=(o=f==null?void 0:f.toolInstance)==null?void 0:o.setHiddenAttributes)==null||n.call(o,p),(l=(t=L==null?void 0:L.store)==null?void 0:t.setHiddenAttributes)==null||l.call(t,p)},[p]),React__default.default.createElement(PointCloudContext.Provider,{value:M},r)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),React=require("react"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),actionCreators=require("../../store/annotation/actionCreators.js"),index=require("../../store/annotatedBox/index.js"),_=require("lodash"),map=require("./utils/map.js"),useTimeoutFunc=require("./hooks/useTimeoutFunc.js"),useWindowKeydownListener=require("./hooks/useWindowKeydownListener.js");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,s,d)=>s in r?__defProp(r,s,{enumerable:!0,configurable:!0,writable:!0,value:d}):r[s]=d,__spreadValues=(r,s)=>{for(var d in s||(s={}))__hasOwnProp.call(s,d)&&__defNormalProp(r,d,s[d]);if(__getOwnPropSymbols)for(var d of __getOwnPropSymbols(s))__propIsEnum.call(s,d)&&__defNormalProp(r,d,s[d]);return r},__spreadProps=(r,s)=>__defProps(r,__getOwnPropDescs(s)),__async=(r,s,d)=>new Promise((x,D)=>{var A=u=>{try{S(d.next(u))}catch(R){D(R)}},E=u=>{try{S(d.throw(u))}catch(R){D(R)}},S=u=>u.done?x(u.value):Promise.resolve(u.value).then(A,E);S((d=d.apply(r,s)).next())});const pickRectObject=r=>___default.default.pick(r,["id","attribute","width","height","x","y","imageName"]),PointCloudContext=React__default.default.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new lbAnnotation.ActionsHistory,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:lbAnnotation.EToolName.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:lbUtils.EPointCloudPattern.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:r=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:r=>!1,removeRectBySpecifyId:(r,s,d)=>!1,removeRectByPointCloudBoxId:r=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:useWindowKeydownListener.getEmptyUseWindowKeydownListener(),isLargeStatus:!1,setIsLargeStatus:()=>{}}),PointCloudProvider=({children:r})=>{const[s,d]=React.useState([]),[x,D]=React.useState([]),[A,E]=React.useState([]),[S,u]=React.useState([]),[R,Le]=React.useState([]),[v,K]=React.useState([]),[B,O]=React.useState([]),[U,De]=React.useState(!0),[Z,Ae]=React.useState(2),[J,Be]=React.useState(!0),[Q,_e]=React.useState(1),[f,X]=React.useState(),[Y,$]=React.useState(),[ee,te]=React.useState(),[g,oe]=React.useState(),[ne,Ve]=React.useState(""),[j,Ne]=React.useState(lbAnnotation.EToolName.Rect),F=React.useRef(new lbAnnotation.ActionsHistory).current,[p,q]=React.useState([]),[ie,He]=React.useState(""),[T,Me]=React.useState(lbUtils.EPointCloudPattern.Detection),[L,se]=React.useState(void 0),[z,ke]=React.useState([]),[W,Ee]=React.useState([]),[re,Oe]=React.useState(!1),[ae,le]=React.useState(!1),h=index(),[de,je]=React.useState({}),Fe=ctx.useDispatch(),qe=o=>{const{imgNode:n,path:t}=o;t&&n&&je(l=>__spreadProps(__spreadValues({},l),{[t]:{width:n.width,height:n.height}}))},ce=React.useMemo(()=>v.length===1?v[0]:"",[v]),ue=useWindowKeydownListener.default(),N=React.useCallback((o,n,t="extId")=>{const l=t||"id",a=new Set(n);return u(c=>{let I=!1;const P=c.filter(M=>{const G=M[l],k=a.has(G)?M.imageName!==o:!0;return k||(I=!0),k});return I?P:c}),!0},[]),ge=React.useCallback(o=>{const n=s.map(t=>t.id);return N(o,n,"extId")},[s,N]),fe=React.useCallback(o=>{if(!o)return!1;const n=s.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:l,attribute:a,trackID:c}=t,I=t.rects.find(P=>P.imageName===o);if(I){const P=___default.default.pick(I,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},P),{id:lbAnnotation.uuid(),attribute:a,order:c,extId:l,lineDash:[]})}return null}).filter(t=>t!==null);return n.length?(u(t=>{const l=new Set(t.filter(c=>o===c.imageName).map(c=>c.extId)),a=n.filter(c=>l.has(c.extId)===!1);return a.length?[...t,...a]:t}),!0):!1},[s]),pe=React.useMemo(()=>s.filter(n=>Array.isArray(n.rects)&&n.rects.length>0).reduce((n,t)=>{var l;return(l=t.rects)==null||l.forEach(a=>{const{imageName:c}=a;if(!c){console.warn("Missing image name"),console.trace(a,t);return}map.addMapIndirectWeakSetItem(n,c,t.id,t)}),n},new Map),[s]),he=React.useCallback(o=>{u(n=>o(n,pickRectObject))},[pickRectObject]),me=React.useMemo(()=>S.filter(o=>o.extId!==void 0&&o.id!==void 0).reduce((o,n)=>{const t=n.imageName;return t?(map.addMapIndirectWeakSetItem(o,t,n.extId,n),o):(console.warn("missing image name"),console.log(n,S),o)},new Map),[S]),{fn:Te}=useTimeoutFunc.default(o=>{K(n=>{const t=o,l=new Set(t);let a=!1;const c=n.filter(I=>{const P=l.has(I);return P||(a=!0),P});return a?c:n})},200),ve=React.useCallback(o=>{const n=o.map(t=>t.id);d(o),Te(n)},[]),H=React.useMemo(()=>{const o=s.find(e=>e.id===ce),n=e=>{const i=s.concat(e);return ve(i),i},t=e=>{const i=x.concat(e);return D(i),i},l=e=>{De(e!==!1)},a=e=>{let i=[];e===void 0||e===""?i=[]:typeof e=="string"?i=[e]:Array.isArray(e)&&(i=e.length>1?Array.from(new Set(e)):e),K(i)},c=e=>{v.includes(e)?a(v.filter(i=>i!==e)):a([...v,e])},I=e=>{const i=pickRectObject(e);u(m=>[...m,i])},P=(e,i=!1)=>{const m=pickRectObject(e);u(C=>C.map(w=>w.id===e.id?i?__spreadValues(__spreadValues({},w),m):m:w))},M=e=>{u(i=>i.filter(m=>!e.find(C=>C.id===m.id)))},G=e=>{B.includes(e)?O([]):O([e])},k=()=>{if(j===lbAnnotation.EToolName.Rect){const e=s.map(i=>i.id);a(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},We=e=>{a(s.filter(i=>i.attribute===e).map(i=>i.id))},Pe=s.filter(e=>!p.includes(e.attribute)),Se=x.filter(e=>!p.includes(e.attribute)),Ie=R.filter(e=>e.attribute&&!p.includes(e.attribute)),Ge=e=>{if(p.includes(e))q(p.filter(i=>i!==e));else{const i=p.concat(e);q(i)}},Ke=(e=Pe,i=A,m=Se,C=Ie,w=z)=>{var V;g==null||g.clearAllBox(),g==null||g.clearAllSphere(),f==null||f.updatePolygonList(e,i),f==null||f.updatePointList(m),f==null||f.updateLineList(C),g==null||g.generateBoxes(e),g==null||g.generateSpheres(m),(V=L==null?void 0:L.store)==null||V.updateCurrentSegment(w),Ce(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},Ue=()=>{X(void 0),$(void 0),te(void 0),oe(void 0)},Ce=(e,i,m)=>__async(void 0,null,function*(){var C,w,V;if(!g)return;const we=g.pointCloudObject;if(!we)return;let ye=[],be=[];try{if(i&&F.record.length){const{record:y,recordIndex:b}=F;let Re=b;b>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&i.length===((C=y[b])==null?void 0:C.pointCloudBoxList.length))&&(Re=b-1);let Ze=(w=y[Re])==null?void 0:w.pointCloudBoxList;const xe=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,i,Ze);ye=xe.modifiedBoxIds,be=xe.resetAreas}}catch(y){console.error("call calcResetAreasAndBoxIds error",y)}try{const y=yield g.getHighlightIndexByMappingImgList({mappingImgList:m!=null?m:W,points:we.geometry.attributes.position.array}),b=yield g==null?void 0:g.highlightOriginPointCloud(i,y,{modifiedBoxIds:ye,resetAreas:be});return b&&((V=f==null?void 0:f.pointCloudInstance)==null||V.updateColor(b)),b}catch(y){console.error("call highlightOriginPointCloud error",y)}});return{selectedID:ce,pointCloudBoxList:s,pointCloudSphereList:x,displayPointCloudList:Pe,displaySphereList:Se,displayLineList:Ie,selectedIDs:v,setPointCloudResult:ve,setSelectedIDs:a,addPointCloudBox:n,addPointCloudSphere:t,setPointCloudSphereList:D,valid:U,selectedPointCloudBox:o,setPointCloudValid:l,addSelectedID:c,addHighlightID:G,selectedAllBoxes:k,topViewInstance:f,setTopViewInstance:X,sideViewInstance:Y,setSideViewInstance:$,backViewInstance:ee,setBackViewInstance:te,mainViewInstance:g,setMainViewInstance:oe,polygonList:A,setPolygonList:E,rectList:S,setRectList:u,addRectIn2DView:I,removeRectIn2DView:M,updateRectIn2DView:P,lineList:R,setLineList:Le,zoom:Q,setZoom:_e,history:F,toggleAttributesVisible:Ge,hideAttributes:p,setHideAttributes:q,reRender:Ke,attrPanelLayout:ie,setAttrPanelLayout:He,syncAllViewPointCloudColor:Ce,defaultAttribute:ne,setDefaultAttribute:Ve,pointCloudPattern:j,setPointCloudPattern:Ne,selectSpecAttr:We,globalPattern:T,setGlobalPattern:e=>{T!==e&&(Fe(actionCreators.ChangeSave),Me(e),e===lbUtils.EPointCloudPattern.Detection&&se(void 0))},ptSegmentInstance:L,setPtSegmentInstance:se,segmentation:z,setSegmentation:ke,clearAllDetectionInstance:Ue,highlight2DDataList:W,setHighlight2DDataList:Ee,highlight2DLoading:re,setHighlight2DLoading:Oe,cuboidBoxIn2DView:J,setCuboidBoxIn2DView:Be,imageSizes:de,cacheImageNodeSize:qe,highlightIDs:B,setHighlightIDs:O,removeRectByPointCloudBoxId:ge,removeRectBySpecifyId:N,addRectFromPointCloudBoxByImageName:fe,rectRotateSensitivity:Z,setRectRotateSensitivity:Ae,imageNamePointCloudBoxMap:pe,linkageImageNameRectMap:me,updateRectListByReducer:he,windowKeydownListenerHook:ue,isLargeStatus:ae,setIsLargeStatus:le}},[U,v,s,x,A,R,S,f,Y,ee,g,Q,p,ie,ne,j,T,L,z,W,re,J,de,B,ge,N,fe,Z,pe,me,he,ue,ae,le]);React.useEffect(()=>{var o,n,t;(o=h==null?void 0:h.setPointCloudBoxList)==null||o.call(h,s),(n=h==null?void 0:h.setHighlightIDs)==null||n.call(h,B),(t=h==null?void 0:h.setSelectedIDs)==null||t.call(h,v)},[s,v,B]),React.useEffect(()=>{var o;(o=h==null?void 0:h.setPtCtx)==null||o.call(h,H)},[H]);const ze=()=>{const o=s.filter(a=>p.includes(a.attribute)),{setSelectedIDs:n,reRender:t}=H,l=o.map(a=>a.id);l.length>0&&n(v.filter(a=>!l.includes(a))),t()};return React.useEffect(()=>{var o,n,t,l;ze(),(n=(o=f==null?void 0:f.toolInstance)==null?void 0:o.setHiddenAttributes)==null||n.call(o,p),(l=(t=L==null?void 0:L.store)==null?void 0:t.setHiddenAttributes)==null||l.call(t,p)},[p]),React__default.default.createElement(PointCloudContext.Provider,{value:H},r)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var dom=require("../../utils/dom.js"),index$3=require("../../views/MainView/toolFooter/index.js"),index$4=require("../../views/MainView/toolFooter/ZoomController/index.js"),icons=require("@ant-design/icons"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudInfos=require("./PointCloudInfos.js"),usePolygon=require("./hooks/usePolygon.js"),useSphere=require("./hooks/useSphere.js"),useZoom=require("./hooks/useZoom.js"),antd=require("antd"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index=require("../../utils/index.js"),ToolUtils=require("../../utils/ToolUtils.js"),_=require("lodash"),index$2=require("./components/PointCloudSizeSlider/index.js"),useHistory=require("./hooks/useHistory.js"),index$1=require("./components/TitleButton/index.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,s,l)=>s in o?__defProp(o,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[s]=l,__spreadValues=(o,s)=>{for(var l in s||(s={}))__hasOwnProp.call(s,l)&&__defNormalProp(o,l,s[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(s))__propIsEnum.call(s,l)&&__defNormalProp(o,l,s[l]);return o},__spreadProps=(o,s)=>__defProps(o,__getOwnPropDescs(s));const{EPolygonPattern,EToolName}=lbAnnotation.cTool,{ESortDirection}=lbAnnotation.cAnnotation,EKeyCode=lbAnnotation.cKeyCode.default,TransferCanvas2WorldOffset=(o,s,l=1)=>{const{width:C,height:p}=s,w={x:o.x+C*l/2,y:o.y+p*l/2},x={x:s.width/2,y:s.height/2};return{offsetX:(x.x-w.x)/l,offsetY:-(x.y-w.y)/l}},TopViewToolbar=({currentData:o})=>{var s,l;const{zoom:C,zoomIn:p,zoomOut:w,initialPosition:x}=useZoom.useZoom(),{selectNextBox:L,selectPrevBox:b}=useSingleBox.useSingleBox(),{switchToNextSphere:S}=useSphere.useSphere(),{updateRotate:V}=useRotate.useRotate({currentData:o}),{updateRotateEdge:O}=useRotateEdge.useRotateEdge({currentData:o}),g=React__default.default.useContext(PointCloudContext.PointCloudContext),{topViewInstance:y}=g,f=(l=(s=g==null?void 0:g.topViewInstance)==null?void 0:s.toolScheduler)==null?void 0:l.getCurrentToolName(),e=()=>{V(-Number(g.rectRotateSensitivity))},u=()=>{V(g.rectRotateSensitivity)},v=()=>{O(-90)};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$2,{onChange:T=>{var I;(I=y==null?void 0:y.pointCloudInstance)==null||I.updatePointSize({customSize:T})}}),React__default.default.createElement("span",{onClick:u,className:dom.getClassName("point-cloud","rotate-reserve")}),React__default.default.createElement("span",{onClick:e,className:dom.getClassName("point-cloud","rotate")}),React__default.default.createElement("span",{onClick:v,className:dom.getClassName("point-cloud","rotate-90")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(icons.UpSquareOutlined,{onClick:()=>{if(f===EToolName.Point){S(ESortDirection.descend);return}b(!0)},className:dom.getClassName("point-cloud","prev")}),React__default.default.createElement(icons.DownSquareOutlined,{onClick:()=>{if(f===EToolName.Point){S(ESortDirection.ascend);return}L(!0)},className:dom.getClassName("point-cloud","next")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(index$4.ZoomController,{initialPosition:x,zoomIn:p,zoomOut:w,zoom:C}))},ZAxisSlider=({setZAxisLimit:o,zAxisLimit:s,checkMode:l})=>l?null:React__default.default.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},React__default.default.createElement(antd.Slider,{vertical:!0,step:.5,max:10,min:.5,defaultValue:s,onAfterChange:C=>{o(C)}})),PointCloudTopView=({currentData:o,imgList:s,stepInfo:l,drawLayerSlot:C,checkMode:p,intelligentFit:w,setIsEnlargeTopView:x,isEnlargeTopView:L,onExitZoom:b,highlightAttribute:S})=>{var V,O;const[g,y]=React.useState({zoom:1,currentPos:{x:0,y:0}}),f=React.useRef(null),e=React__default.default.useContext(PointCloudContext.PointCloudContext),u=useSize(f),v=index.jsonParser(l.config),{setZoom:T,syncTopviewToolZoom:I}=useZoom.useZoom(),{hideAttributes:k,setIsLargeStatus:A,clearAllDetectionInstance:Y}=e,{addPolygon:U,deletePolygon:Z}=usePolygon.usePolygon(),{deletePointCloudSphere:z}=useSphere.useSphere(),{deletePointCloudBox:H,changeValidByID:F}=useSingleBox.useSingleBox(),[N,W]=React.useState(10),{t:D}=reactI18next.useTranslation(),m=usePointCloudViews.usePointCloudViews(),{pushHistoryWithList:$}=useHistory.useHistory(),[M,q]=React.useState(!0);React.useLayoutEffect(()=>{if(!e.topViewInstance&&f.current&&(o==null?void 0:o.url)&&(o==null?void 0:o.result)){const n={width:f.current.clientWidth,height:f.current.clientHeight},a=new lbAnnotation.PointCloudAnnotation({container:f.current,size:n,pcdPath:o.url,config:__spreadProps(__spreadValues({},v),{pointCloudPattern:e.pointCloudPattern}),checkMode:p,toolName:ToolUtils.getPointCloudToolList(),proxyMode:p});e.setTopViewInstance(a)}},[o]),React.useEffect(()=>{if(!u||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:n}=e.topViewInstance;n.singleOn("dataUpdated",(t,i)=>{const d=___default.default.cloneDeep(t).map(r=>__spreadProps(__spreadValues({},r),{pointList:lbUtils.PointCloudUtils.pointListTransferCanvas2World(r.pointList,u)}));e.setSelectedIDs(i),e.setLineList(d),$({lineList:d})}),n.singleOn("pointCreated",(t,i)=>{m.topViewAddSphere({newPoint:t,size:u,trackConfigurable:v.trackConfigurable,zoom:i})}),n.singleOn("pointDeleted",t=>{z(t)}),n.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),n.singleOn("updatePointByDrag",(t,i)=>{var d;(d=m.topViewUpdatePoint)==null||d.call(m,t,u)}),n.singleOn("polygonCreated",(t,i)=>{if(n.pattern===EPolygonPattern.Normal||!(o==null?void 0:o.url)){const d=__spreadProps(__spreadValues({},t),{pointList:t.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,u))});U(d),e.setSelectedIDs(k.includes(t.attribute)?"":t.id);return}q(!1),m.topViewAddBox({polygon:t,size:u,imgList:s,trackConfigurable:v.trackConfigurable,zoom:i,intelligentFit:w})}),n.singleOn("deletedObject",({id:t})=>{H(t),Z(t)}),n.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),n.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),n.singleOn("setSelectedIDs",t=>{q(!1),e.setSelectedIDs(t)}),n.singleOn("updatePolygonByDrag",t=>{var i;(i=m.topViewUpdateBox)==null||i.call(m,t,u)});const a=t=>{var i;const d=F(t);d&&e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,d),e.polygonList.find(r=>r.id===t)&&((i=e.topViewInstance)==null||i.toolInstance.setPolygonValidAndRender(t,!0))};return n.on("validUpdate",a),()=>{n.unbind("validUpdate",a)}},[e,u,o,m,e.polygonList,e.lineList,(V=e.topViewInstance)==null?void 0:V.toolInstance]),React.useEffect(()=>{var n,a;if(!(u==null?void 0:u.width)||!e.topViewInstance)return;const t=(a=(n=v==null?void 0:v.attributeList)==null?void 0:n[0])==null?void 0:a.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(u),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:i,toolInstance:d}}=e;d.singleOn("renderZoom",(r,c)=>{const{offsetX:h,offsetY:E}=TransferCanvas2WorldOffset(c,u,r);if(i.camera.zoom=r,c){const{x:P,y:j,z:R}=i.initCameraPosition;i.camera.position.set(P+E,j-h,R)}i.camera.updateProjectionMatrix(),i.render(),T(r),I(c,r,u),y({zoom:r,currentPos:c})}),d.singleOn("dragMove",({currentPos:r,zoom:c})=>{const{offsetX:h,offsetY:E}=TransferCanvas2WorldOffset(r,u,c);i.camera.zoom=c;const{x:P,y:j,z:R}=i.initCameraPosition;i.camera.position.set(P+E,j-h,R),i.render(),I(r,c,u),y({zoom:c,currentPos:r})})},[u,e.topViewInstance,(O=e.topViewInstance)==null?void 0:O.toolInstance]),React.useEffect(()=>{var n,a;(a=(n=e.topViewInstance)==null?void 0:n.pointCloudInstance)==null||a.applyZAxisPoints(N)},[N]),React.useEffect(()=>{var n,a,t,i;m.topViewSelectedChanged({}),(i=(t=(a=(n=e.topViewInstance)==null?void 0:n.toolInstance)==null?void 0:a.selection)==null?void 0:t.hardSetSelectedIDs)==null||i.call(t,e.selectedIDs)},[e.selectedIDs]),React.useEffect(()=>{const{topViewInstance:n,selectedID:a,selectedPointCloudBox:t,zoom:i}=e;if(!n||!a||!t||!M){q(!0);return}const{center:d}=t,{pointCloudInstance:r,toolInstance:c}=n,h=c.polygonList.find(X=>X.id===e.selectedID);if(!h){q(!0);return}const E=lbAnnotation.MathUtils.getRectCenterPoint(h.pointList),P=lbAnnotation.MathUtils.getCurrentPosFromRectCenter(c.size,E,i);c.setCurrentPos(P),c.render();const{x:j,y:R,z:K}=r.initCameraPosition;r.camera.position.set(d.x,d.y,K),r.render(),I(P,i,u),y({zoom:i,currentPos:P})},[e.selectedID]),React.useEffect(()=>(window.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B)}),[]);const B=n=>{const{keyCode:a}=n;a===EKeyCode.Esc&&b()};return React.useEffect(()=>{var n,a,t;(t=(a=(n=e.topViewInstance)==null?void 0:n.pointCloud2dOperation)==null?void 0:a.setHighlightAttribute)==null||t.call(a,S)},[e.topViewInstance,S]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","top-view"),title:L?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{b()}}),React__default.default.createElement("span",null,D("TopView")),React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:p,config:v,style:{display:"flex",position:"initial",margin:"0px 20px"}})):React__default.default.createElement(index$1,{title:D("TopView"),onClick:()=>{A(!0),x(!0)}}),toolbar:React__default.default.createElement(TopViewToolbar,{currentData:o})},React__default.default.createElement("div",{style:{position:"relative",flex:1}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"},ref:f},C==null?void 0:C(g)),!L&&React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:p,config:v}),React__default.default.createElement(ZAxisSlider,{checkMode:p,zAxisLimit:N,setZAxisLimit:W}),React__default.default.createElement(PointCloudInfos.PointCloudValidity,null)))};var PointCloudTopView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudTopView);module.exports=PointCloudTopView$1;
|
|
1
|
+
"use strict";var dom=require("../../utils/dom.js"),index$3=require("../../views/MainView/toolFooter/index.js"),index$4=require("../../views/MainView/toolFooter/ZoomController/index.js"),icons=require("@ant-design/icons"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudInfos=require("./PointCloudInfos.js"),usePolygon=require("./hooks/usePolygon.js"),useSphere=require("./hooks/useSphere.js"),useZoom=require("./hooks/useZoom.js"),antd=require("antd"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index=require("../../utils/index.js"),ToolUtils=require("../../utils/ToolUtils.js"),_=require("lodash"),index$2=require("./components/PointCloudSizeSlider/index.js"),useHistory=require("./hooks/useHistory.js"),index$1=require("./components/TitleButton/index.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,s,l)=>s in o?__defProp(o,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[s]=l,__spreadValues=(o,s)=>{for(var l in s||(s={}))__hasOwnProp.call(s,l)&&__defNormalProp(o,l,s[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(s))__propIsEnum.call(s,l)&&__defNormalProp(o,l,s[l]);return o},__spreadProps=(o,s)=>__defProps(o,__getOwnPropDescs(s));const{EPolygonPattern,EToolName}=lbAnnotation.cTool,{ESortDirection}=lbAnnotation.cAnnotation,EKeyCode=lbAnnotation.cKeyCode.default,TransferCanvas2WorldOffset=(o,s,l=1)=>{const{width:C,height:p}=s,w={x:o.x+C*l/2,y:o.y+p*l/2},x={x:s.width/2,y:s.height/2};return{offsetX:(x.x-w.x)/l,offsetY:-(x.y-w.y)/l}},TopViewToolbar=({currentData:o})=>{var s,l;const{zoom:C,zoomIn:p,zoomOut:w,initialPosition:x}=useZoom.useZoom(),{selectNextBox:L,selectPrevBox:b}=useSingleBox.useSingleBox(),{switchToNextSphere:S}=useSphere.useSphere(),{updateRotate:E}=useRotate.useRotate({currentData:o}),{updateRotateEdge:O}=useRotateEdge.useRotateEdge({currentData:o}),g=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:I}=g,f=(l=(s=g==null?void 0:g.topViewInstance)==null?void 0:s.toolScheduler)==null?void 0:l.getCurrentToolName(),e=()=>{E(-Number(g.rectRotateSensitivity))},u=()=>{E(g.rectRotateSensitivity)},v=()=>{O(-90)};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$2,{onChange:T=>{var y;(y=I==null?void 0:I.pointCloudInstance)==null||y.updatePointSize({customSize:T})}}),React__default.default.createElement("span",{onClick:u,className:dom.getClassName("point-cloud","rotate-reserve")}),React__default.default.createElement("span",{onClick:e,className:dom.getClassName("point-cloud","rotate")}),React__default.default.createElement("span",{onClick:v,className:dom.getClassName("point-cloud","rotate-90")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(icons.UpSquareOutlined,{onClick:()=>{if(f===EToolName.Point){S(ESortDirection.descend);return}b(!0)},className:dom.getClassName("point-cloud","prev")}),React__default.default.createElement(icons.DownSquareOutlined,{onClick:()=>{if(f===EToolName.Point){S(ESortDirection.ascend);return}L(!0)},className:dom.getClassName("point-cloud","next")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(index$4.ZoomController,{initialPosition:x,zoomIn:p,zoomOut:w,zoom:C}))},ZAxisSlider=({setZAxisLimit:o,zAxisLimit:s,checkMode:l})=>l?null:React__default.default.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},React__default.default.createElement(antd.Slider,{vertical:!0,step:.5,max:10,min:.5,defaultValue:s,onAfterChange:C=>{o(C)}})),PointCloudTopView=({currentData:o,imgList:s,stepInfo:l,drawLayerSlot:C,checkMode:p,intelligentFit:w,setIsEnlargeTopView:x,isEnlargeTopView:L,onExitZoom:b,highlightAttribute:S})=>{var E,O;const[g,I]=React.useState({zoom:1,currentPos:{x:0,y:0}}),f=React.useRef(null),e=React.useContext(PointCloudContext.PointCloudContext),u=useSize(f),v=index.jsonParser(l.config),{setZoom:T,syncTopviewToolZoom:y}=useZoom.useZoom(),{hideAttributes:U,setIsLargeStatus:Z,selectedID:z,pointCloudBoxList:H}=e,{addPolygon:F,deletePolygon:W}=usePolygon.usePolygon(),{deletePointCloudSphere:$}=useSphere.useSphere(),{deletePointCloudBox:M,changeValidByID:K}=useSingleBox.useSingleBox(),[B,X]=React.useState(10),{t:D}=reactI18next.useTranslation(),m=usePointCloudViews.usePointCloudViews(),{pushHistoryWithList:Y}=useHistory.useHistory(),[G,q]=React.useState(!0),[N,k]=React.useState(!1);React.useLayoutEffect(()=>{if(!e.topViewInstance&&f.current&&(o==null?void 0:o.url)&&(o==null?void 0:o.result)){const n={width:f.current.clientWidth,height:f.current.clientHeight},r=new lbAnnotation.PointCloudAnnotation({container:f.current,size:n,pcdPath:o.url,config:__spreadProps(__spreadValues({},v),{pointCloudPattern:e.pointCloudPattern}),checkMode:p,toolName:ToolUtils.getPointCloudToolList(),proxyMode:p});e.setTopViewInstance(r)}},[o]),React.useEffect(()=>{N&&z&&(e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single,H),k(!1))},[N]),React.useEffect(()=>{if(!u||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:n}=e.topViewInstance;n.singleOn("dataUpdated",(t,i)=>{const d=___default.default.cloneDeep(t).map(a=>__spreadProps(__spreadValues({},a),{pointList:lbUtils.PointCloudUtils.pointListTransferCanvas2World(a.pointList,u)}));e.setSelectedIDs(i),e.setLineList(d),Y({lineList:d})}),n.singleOn("pointCreated",(t,i)=>{m.topViewAddSphere({newPoint:t,size:u,trackConfigurable:v.trackConfigurable,zoom:i})}),n.singleOn("pointDeleted",t=>{$(t)}),n.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),n.singleOn("updatePointByDrag",(t,i)=>{var d;(d=m.topViewUpdatePoint)==null||d.call(m,t,u)}),n.singleOn("polygonCreated",(t,i)=>{if(n.pattern===EPolygonPattern.Normal||!(o==null?void 0:o.url)){const d=__spreadProps(__spreadValues({},t),{pointList:t.pointList.map(a=>lbUtils.PointCloudUtils.transferCanvas2World(a,u))});F(d),e.setSelectedIDs(U.includes(t.attribute)?"":t.id);return}q(!1),m.topViewAddBox({polygon:t,size:u,imgList:s,trackConfigurable:v.trackConfigurable,zoom:i,intelligentFit:w}),k(!0)}),n.singleOn("deletedObject",({id:t})=>{M(t),W(t)}),n.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),n.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),n.singleOn("setSelectedIDs",t=>{q(!1),e.setSelectedIDs(t)}),n.singleOn("updatePolygonByDrag",t=>{var i;(i=m.topViewUpdateBox)==null||i.call(m,t,u)});const r=t=>{var i;const d=K(t);d&&e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,d),e.polygonList.find(a=>a.id===t)&&((i=e.topViewInstance)==null||i.toolInstance.setPolygonValidAndRender(t,!0))};return n.on("validUpdate",r),()=>{n.unbind("validUpdate",r)}},[e,u,o,m,e.polygonList,e.lineList,(E=e.topViewInstance)==null?void 0:E.toolInstance]),React.useEffect(()=>{var n,r;if(!(u==null?void 0:u.width)||!e.topViewInstance)return;const t=(r=(n=v==null?void 0:v.attributeList)==null?void 0:n[0])==null?void 0:r.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(u),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:i,toolInstance:d}}=e;d.singleOn("renderZoom",(a,c)=>{const{offsetX:h,offsetY:V}=TransferCanvas2WorldOffset(c,u,a);if(i.camera.zoom=a,c){const{x:P,y:j,z:R}=i.initCameraPosition;i.camera.position.set(P+V,j-h,R)}i.camera.updateProjectionMatrix(),i.render(),T(a),y(c,a,u),I({zoom:a,currentPos:c})}),d.singleOn("dragMove",({currentPos:a,zoom:c})=>{const{offsetX:h,offsetY:V}=TransferCanvas2WorldOffset(a,u,c);i.camera.zoom=c;const{x:P,y:j,z:R}=i.initCameraPosition;i.camera.position.set(P+V,j-h,R),i.render(),y(a,c,u),I({zoom:c,currentPos:a})})},[u,e.topViewInstance,(O=e.topViewInstance)==null?void 0:O.toolInstance]),React.useEffect(()=>{var n,r;(r=(n=e.topViewInstance)==null?void 0:n.pointCloudInstance)==null||r.applyZAxisPoints(B)},[B]),React.useEffect(()=>{var n,r,t,i;m.topViewSelectedChanged({}),(i=(t=(r=(n=e.topViewInstance)==null?void 0:n.toolInstance)==null?void 0:r.selection)==null?void 0:t.hardSetSelectedIDs)==null||i.call(t,e.selectedIDs)},[e.selectedIDs]),React.useEffect(()=>{const{topViewInstance:n,selectedID:r,selectedPointCloudBox:t,zoom:i}=e;if(!n||!r||!t||!G){q(!0);return}const{center:d}=t,{pointCloudInstance:a,toolInstance:c}=n,h=c.polygonList.find(Q=>Q.id===e.selectedID);if(!h){q(!0);return}const V=lbAnnotation.MathUtils.getRectCenterPoint(h.pointList),P=lbAnnotation.MathUtils.getCurrentPosFromRectCenter(c.size,V,i);c.setCurrentPos(P),c.render();const{x:j,y:R,z:J}=a.initCameraPosition;a.camera.position.set(d.x,d.y,J),a.render(),y(P,i,u),I({zoom:i,currentPos:P})},[e.selectedID]),React.useEffect(()=>(window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}),[]);const A=n=>{const{keyCode:r}=n;r===EKeyCode.Esc&&b()};return React.useEffect(()=>{var n,r,t;(t=(r=(n=e.topViewInstance)==null?void 0:n.pointCloud2dOperation)==null?void 0:r.setHighlightAttribute)==null||t.call(r,S)},[e.topViewInstance,S]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","top-view"),title:L?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{b()}}),React__default.default.createElement("span",null,D("TopView")),React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:p,config:v,style:{display:"flex",position:"initial",margin:"0px 20px"}})):React__default.default.createElement(index$1,{title:D("TopView"),onClick:()=>{Z(!0),x(!0)}}),toolbar:React__default.default.createElement(TopViewToolbar,{currentData:o})},React__default.default.createElement("div",{style:{position:"relative",flex:1}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"},ref:f},C==null?void 0:C(g)),!L&&React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:p,config:v}),React__default.default.createElement(ZAxisSlider,{checkMode:p,zAxisLimit:B,setZAxisLimit:X}),React__default.default.createElement(PointCloudInfos.PointCloudValidity,null)))};var PointCloudTopView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudTopView);module.exports=PointCloudTopView$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var actionCreators=require("../../../../store/annotation/actionCreators.js"),ctx=require("../../../../store/ctx.js"),antd=require("antd"),React=require("react"),reactI18next=require("react-i18next"),icons=require("@ant-design/icons"),lbUtils=require("@labelbee/lb-utils"),reactRedux=require("react-redux"),useSingleBox=require("../../hooks/useSingleBox.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,a,
|
|
1
|
+
"use strict";var actionCreators=require("../../../../store/annotation/actionCreators.js"),ctx=require("../../../../store/ctx.js"),antd=require("antd"),React=require("react"),reactI18next=require("react-i18next"),icons=require("@ant-design/icons"),lbUtils=require("@labelbee/lb-utils"),reactRedux=require("react-redux"),useSingleBox=require("../../hooks/useSingleBox.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,a,l)=>a in e?__defProp(e,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[a]=l,__spreadValues=(e,a)=>{for(var l in a||(a={}))__hasOwnProp.call(a,l)&&__defNormalProp(e,l,a[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(a))__propIsEnum.call(a,l)&&__defNormalProp(e,l,a[l]);return e},__spreadProps=(e,a)=>__defProps(e,__getOwnPropDescs(a));const layout={labelCol:{span:8},wrapperCol:{span:16}},defaultNumberRules=[{required:!0,message:"\u8BF7\u586B\u5199\u4E00\u4E2A\u6570\u5B57"}],defaultSelectedAttribute=[{required:!0,message:"\u8BF7\u9009\u62E9\u4E3B\u5C5E\u6027"}],DECIMAL_PLACES=2,PrefixTag=({text:e})=>React__default.default.createElement("span",{style:{borderRadius:"4px 0px 0px 4px",padding:"0px 12px",background:"#FAFAFA",border:"1px solid rgb(217 217 217)",borderRight:"0",display:"flex",alignItems:"center",height:32}},e),SizeShow=e=>{const{t:a}=reactI18next.useTranslation(),{size:l,isMax:i,selectedBox:s}=e;if(!l||!s)return null;const m={marginRight:16},b=__spreadValues(__spreadValues({},s),i&&l),{length:r,width:c,height:f}=lbUtils.PointCloudUtils.transferBox2Kitti(b);return React__default.default.createElement("div",null,React__default.default.createElement("span",{style:m},a("Length"),": ",r.toFixed(DECIMAL_PLACES)),React__default.default.createElement("span",{style:m},a("Width"),": ",c.toFixed(DECIMAL_PLACES)),React__default.default.createElement("span",{style:m},a("Height"),": ",f.toFixed(DECIMAL_PLACES)),React__default.default.createElement(antd.Popover,{placement:"rightBottom",content:`\u7EDF\u4E00\u5C3A\u5BF8\u4E3A\u8BE5ID\u7684\u6240\u6709\u6807\u6CE8\u6846${i?"\u4E2D\u6700\u5927\u7684\u5C3A\u5BF8":"\u4EE5\u5F53\u524D\u5E27\u6846\u5C3A\u5BF8\u4E3A\u6807\u51C6"}`},React__default.default.createElement(icons.QuestionCircleOutlined,null)))},sizeOptions=[{value:"current",label:"\u5F53\u524D\u5E27\u5C3A\u5BF8"},{value:"max",label:"\u6700\u5927\u5C3A\u5BF8"}],UnifyParamsModal=({id:e,visible:a,onCancel:l,config:i,imgList:s,imgIndex:m})=>{const b=ctx.useDispatch(),{selectedBox:r}=useSingleBox.useSingleBox(),[c,f]=React.useState(),[p]=antd.Form.useForm(),{t:o}=reactI18next.useTranslation();React.useEffect(()=>{a===!1?(p.resetFields(),f(void 0)):v()},[a]);const _=t=>{var n,u,d,E;if(!e)return;if(!c){antd.message.info("\u8BE5\u8303\u56F4\u4E0D\u5B58\u5728\u66F4\u6539\u6570\u636E, \u8BF7\u66F4\u6539\u7EDF\u4E00\u8303\u56F4");return}const g={attribute:t.attribute};if(i.secondaryAttributeConfigurable){const h={};(n=i.inputList)==null||n.forEach(S=>{const y=t[S.value];if(y!==void 0){const I=Array.isArray(y)?y.join(";"):y;Object.assign(h,{[S.value]:I})}}),Object.keys(h).length>0&&Object.assign(g,{subAttribute:h})}const{UnifySize:x}=t;Object.assign(g,c&&x==="max"?c:{width:(u=r==null?void 0:r.info)==null?void 0:u.width,height:(d=r==null?void 0:r.info)==null?void 0:d.height,depth:(E=r==null?void 0:r.info)==null?void 0:E.depth}),b(actionCreators.BatchUpdateResultByTrackID(e,g,[t.prevPage-1,t.nextPage-1],s)),l()},v=React.useCallback(()=>{var t;const{prevPage:n,nextPage:u}=p.getFieldsValue(["prevPage","nextPage"]),d=s.filter((g,x)=>lbAnnotation.MathUtils.isInRange(x,[n-1,u-1]));if(!((d==null?void 0:d.length)>0)||!(r==null?void 0:r.info)||((t=r==null?void 0:r.info)==null?void 0:t.trackID)===void 0){f(void 0);return}const E=lbUtils.PointCloudUtils.getMaxSizeFromBox({trackID:r.info.trackID,imgList:d});f(E)},[s,r,m]),B=()=>p.submit(),F={width:"200px"},P={marginBottom:"24px",display:"flex",alignItems:"center"};return React__default.default.createElement(antd.Modal,{title:o("UnifyParams"),visible:a,onCancel:l,onOk:B,wrapClassName:"labelbee-custom-modal"},React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement("div",{style:{marginBottom:"20px",color:"#f00"}},o("UnifyParamsTips")),React__default.default.createElement(antd.Form,__spreadProps(__spreadValues({},layout),{form:p,onFinish:_}),React__default.default.createElement(antd.Form.Item,{name:"id",label:o("UnifyTrackID")},e),React__default.default.createElement(antd.Form.Item,{label:o("UnifyAttributeRange"),required:!0},React__default.default.createElement(antd.Form.Item,{style:{display:"inline-block"},rules:defaultNumberRules,name:"prevPage",noStyle:!0,initialValue:1},React__default.default.createElement(antd.InputNumber,{precision:0,min:1,style:{width:"80px"},onChange:()=>v()})),React__default.default.createElement("span",{style:{display:"inline-block",width:"24px",textAlign:"center"}},"-"),React__default.default.createElement(antd.Form.Item,{style:{display:"inline-block"},rules:defaultNumberRules,name:"nextPage",noStyle:!0,initialValue:s.length},React__default.default.createElement(antd.InputNumber,{precision:0,min:1,style:{width:"80px"},onChange:()=>v()})),React__default.default.createElement("span",{style:{display:"inline-block",width:"40x",marginLeft:"10px",textAlign:"center"}},o("Page"))),React__default.default.createElement(antd.Form.Item,{name:"UnifySize",label:o("UnifySize"),required:!0,initialValue:"current"},React__default.default.createElement(antd.Radio.Group,{onChange:t=>{p.setFieldValue("UnifySize",t.target.value)}},sizeOptions.map(t=>{const{value:n,label:u}=t;return React__default.default.createElement(antd.Radio,{value:n,key:n},React__default.default.createElement("div",null,u),React__default.default.createElement(SizeShow,{selectedBox:r==null?void 0:r.info,size:c,isMax:n==="max"}))}))),React__default.default.createElement(antd.Form.Item,{label:o("UnifyTag"),required:!0},React__default.default.createElement("div",{style:P},React__default.default.createElement(PrefixTag,{text:o("Attribute")}),React__default.default.createElement(antd.Form.Item,{name:"attribute",noStyle:!0,rules:defaultSelectedAttribute},React__default.default.createElement(antd.Select,{style:F},i.attributeList.map(t=>React__default.default.createElement(antd.Select.Option,{key:t.value,value:t.value},t.key))))),i.secondaryAttributeConfigurable&&i.inputList.map(t=>{var n;return React__default.default.createElement("div",{key:t.value,style:P},React__default.default.createElement(PrefixTag,{text:t.key}),React__default.default.createElement(antd.Form.Item,{name:t.value,noStyle:!0,required:!1},React__default.default.createElement(antd.Select,{style:F,mode:t.isMulti?"multiple":void 0},(n=t.subSelected)==null?void 0:n.map(u=>React__default.default.createElement(antd.Select.Option,{key:u.value,value:u.value},u.key)))))})))))},mapStateToProps=e=>({imgIndex:e.annotation.imgIndex});var UnifyParamsModal$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(UnifyParamsModal);module.exports=UnifyParamsModal$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((a,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?a(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,a,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=a?__spreadValues(__spreadValues({},a),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},topViewPolygon2PointCloud=(o,n,t,a,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,D=lbAnnotation.MathUtils.getLineCenterPoint([f,R]),w=lbAnnotation.MathUtils.getLineLength(f,L),V=lbAnnotation.MathUtils.getLineLength(L,R),T=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);a&&(c=a.center.z,d=a.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:d,rotation:T,id:o.id},O=__spreadValues(a?__spreadValues(__spreadValues({},a),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 a={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-a.x,y:t.center.y,z:t.center.z-a.y}})},sideViewPolygon2PointCloud=(o,n,t,a)=>{const[p,e,P]=o.pointList,[c,d,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,d),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(d,x),M=k-O,{newBoxParams:B}=a.getNewBoxBySideUpdate(D,M,T,t);return B},backViewPoint2PointCloud=(o,n,t)=>{const a={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x,y:t.center.y-a.x,z:t.center.z-a.y}})},backViewPolygon2PointCloud=(o,n,t,a)=>{const[p,e,P]=o.pointList,[c,d,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,d),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(d,x),M=k-O;let{newBoxParams:B}=a.getNewBoxByBackUpdate(D,M,T,t);return B},syncSideViewByPoint=(o,n,t,a,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(a,(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,a)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(a,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,a,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(a,(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,a)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(a,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,a)=>{if(!t||!a)return;a.generateSphere(o),a.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),a.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,a)=>{var p,e;if(!t||!a)return;a.generateBox(o),a.setHighlightColor(o.id),a.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:a,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:d,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:u,imgList:l,imgIndex:r}=s.annotation;return{currentData:l[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(u,i).config)}}),z=ctx.useDispatch(),it=ahooks.useLatest(w),st=ahooks.useLatest(k),lt=React.useCallback((s,i)=>{const u=st.current,l=i.id;return s.filter(g=>{if(!g)return!1;const C=u.get(g.imageName);return C===void 0?!0:Boolean(C.get(l))})},[]),J=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!it.current||i){const{mappingImgList:u=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:u,imageSizes:V},{prepareRectsFn:lt})}},{selectedBox:U,updateSelectedBox:rt,updateSelectedBoxes:Q,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:J}),K=U==null?void 0:U.info;if(!t||!a||!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:u,trackConfigurable:l})=>{var r;const g={attribute:(r=t.toolInstance.defaultAttribute)!=null?r:""};l===!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);H(PointCloudView.Top,s,C,u,h,y),O({newSphereParams:C})},ct=({polygon:s,size:i,imgList:u,trackConfigurable:l,zoom:r,intelligentFit:g})=>{var C,h,m;const b={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};l===!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?d([]):(d(v.id),S.selection.setSelectedIDs(I.id),N({omitView:PointCloudView.Top,polygon:I,boxParams:v,zoom:r,newPointCloudBoxList:F}),g&&synchronizeTopView(v,I,t,e)),O({newBoxParams:v})},pt=s=>{const{boxID:i,imageName:u,width:l,height:r,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===u))return;const b=h.rects.map(v=>v.imageName===u?__spreadProps(__spreadValues({},v),{width:l,height:r,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:u}=s,l=f.find(h=>h.id===i);if(!(l==null?void 0:l.rects))return;const r=l.rects.filter(h=>h.imageName!==u),g=__spreadProps(__spreadValues({},l),{rects:r}),C=f.map(h=>h.id===i?g:h);return t==null||t.updatePolygonList(C!=null?C:[]),C},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:u,newSphereList:l})=>{var r;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;(r=g==null?void 0:g.selection)==null||r.setSelectedIDs(x[0]);const h=g.selectedPolygon;if(x.length===1&&C){N({omitView:PointCloudView.Top,polygon:h,boxParams:C,newPointCloudBoxList:i});return}}if((u||W)&&x.length===1){const C=u!=null?u:W;g.setSelectedID(x[0]);const h=g.selectedPoint;C&&H(PointCloudView.Top,h,C,void 0,l,y)}}},$=(s,i,u)=>{if(K){let l,r;switch(u){case PointCloudView.Back:l=backViewPolygon2PointCloud;break;case PointCloudView.Side:l=sideViewPolygon2PointCloud;break;default:l=sideViewPolygon2PointCloud;break}if(r=l(s,i,K,a.pointCloudInstance),e){const{count:b}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:b})}const C=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],h=r.valid!==C.valid;r=C;const m=rt(r);return r=m.find(b=>b.id===r.id),N({omitView:h?void 0:u,polygon:s,boxParams:r,newPointCloudBoxList:m}),m}},tt=(s,i,u)=>{if(W){let l,r;switch(u){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}r=l(s,i,W);const g=Y(r);return H(u,s,r,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 u=nt(s.id),l=topViewPoint2PointCloud(s,i,X,u),r=Y(l);H(PointCloudView.Top,s,l,void 0,r,y)},Lt=(s,i)=>{if(ot){const l=__spreadValues({},s[0].newPolygon);l.pointList=l.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,i)),B(l);return}let u=s.map(({newPolygon:l})=>{const r=at(l.id),{boxParams:g}=topViewPolygon2PointCloud(l,i,t.pointCloudInstance,r);return g});if(u=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:u,stepConfig:y,action:"viewUpdateBox"})),u.length===1){const{newPolygon:l}=s[0],r=Q(u);N({polygon:l,boxParams:u[0],newPointCloudBoxList:r})}else{const l=Q(u);l&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,l)}},yt=s=>{var i,u,l,r,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:(l=(u=t==null?void 0:t.toolInstance)==null?void 0:u.basicImgInfo)==null?void 0:l.width,height:(g=(r=t==null?void 0:t.toolInstance)==null?void 0:r.basicImgInfo)==null?void 0:g.height},A=I.pointList.map(G=>lbUtils.PointCloudUtils.transferCanvas2World(G,v)),q=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(A,m,C),E=q[0],F=q[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})}},H=(s,i,u,l,r,g)=>__async(void 0,null,function*(){const C=j==null?void 0:j.url,h={[PointCloudView.Side]:()=>{syncSideViewByPoint(u,i,a,C,g)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(u,i,p,C,g)},[PointCloudView.Top]:()=>{syncTopViewByPoint(u,i,t,e)}};Object.keys(h).forEach(m=>{m!==s&&h[m]()}),l&&(e==null||e.updateCameraZoom(l)),dt(u)}),N=(s,i=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:u,polygon:l,boxParams:r,zoom:g,newPointCloudBoxList:C}=s,h=j==null?void 0:j.url;C&&n.syncAllViewPointCloudColor(i,C);const m={[PointCloudView.Side]:()=>{synchronizeSideView(r,l,a,h)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(r,l,p,h)},[PointCloudView.Top]:()=>{synchronizeTopView(r,l,t,e)}};Object.keys(m).forEach(b=>{b!==u&&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:H,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 u,l,r,g,C,h,m,b;if(!(i==null?void 0:i.url)||!e)return;D([]),actionCreators.SetAnnotationLoading(z,!0),actionCreators.SetLoadPCDFileLoading(z,!0),(u=o==null?void 0:o.setResourceLoading)==null||u.call(o,!0),yield e.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:DEFAULT_RADIUS),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let S=[],I=[],v=[],A=[];e.updateTopCamera();const q=(g=(r=index.jsonParser(i.result))==null?void 0:r.valid)!=null?g:!0;if(n.setPointCloudValid(q),(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),a=ahooks.useLatest(o),p=ahooks.useLatest(n);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=a.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,D=_.pick(f,["x","y","width","height"]);let w=d.get(L);w||(w=new Map,d.set(L,w)),w.set(R,D),x.add(L)}),d.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=d.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;
|
|
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((a,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?a(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,a,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=a?__spreadValues(__spreadValues({},a),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},topViewPolygon2PointCloud=(o,n,t,a,p,e)=>{let P=o.pointList.map(w=>lbUtils.PointCloudUtils.transferCanvas2World(w,n)),c=0,d=1,x={};if(t){const w=t.getSensesPointZAxisInPolygon(P,void 0,e);e&&w.fittedCoordinates.length>0&&(P=w.fittedCoordinates),c=(w.maxZ+w.minZ)/2,d=w.maxZ-w.minZ,x={count:w.zCount}}const[f,v,R]=P,I=lbAnnotation.MathUtils.getLineCenterPoint([f,R]),S=lbAnnotation.MathUtils.getLineLength(f,v),V=lbAnnotation.MathUtils.getLineLength(v,R),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);a&&(c=a.center.z,d=a.depth);const T={center:{x:I.x,y:I.y,z:c},width:e?V+INTELLIGENT_FIT_MARGIN:V,height:e?S+INTELLIGENT_FIT_MARGIN:S,depth:d,rotation:k,id:o.id},A=__spreadValues(a?__spreadValues(__spreadValues({},a),T):__spreadProps(__spreadValues({},T),{attribute:"",valid:!0}),x);p&&Object.assign(A,p);const O=P.map(w=>lbUtils.PointCloudUtils.transferWorld2Canvas(w,n));return{boxParams:A,newPointList:O}},sideViewPoint2PointCloud=(o,n,t)=>{const a={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-a.x,y:t.center.y,z:t.center.z-a.y}})},sideViewPolygon2PointCloud=(o,n,t,a)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),v=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),I={x:{x:f.x-v.x,y:f.y-v.y}.x,y:0,z:f.y-v.y},S=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),k=S-V,T=lbAnnotation.MathUtils.getLineLength(e,P),A=lbAnnotation.MathUtils.getLineLength(d,x),O=T-A,{newBoxParams:w}=a.getNewBoxBySideUpdate(I,O,k,t);return w},backViewPoint2PointCloud=(o,n,t)=>{const a={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x,y:t.center.y-a.x,z:t.center.z-a.y}})},backViewPolygon2PointCloud=(o,n,t,a)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),v=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),I={x:{x:f.x-v.x,y:f.y-v.y}.x,y:0,z:f.y-v.y},S=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),k=S-V,T=lbAnnotation.MathUtils.getLineLength(e,P),A=lbAnnotation.MathUtils.getLineLength(d,x),O=T-A;let{newBoxParams:w}=a.getNewBoxByBackUpdate(I,O,k,t);return w},syncSideViewByPoint=(o,n,t,a,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(a,(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,a)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(a,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,a,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(a,(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,a)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(a,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,a)=>{if(!t||!a)return;a.generateSphere(o),a.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),a.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,a)=>{var p,e;if(!t||!a)return;a.generateBox(o),a.setHighlightColor(o.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=t,{polygon2d:d}=c.getBoxTopPolygon2DCoordinate(o),x=[...P.polygonList],f=x.find(v=>v.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:a,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:d,selectedIDs:x,pointCloudBoxList:f,pointCloudSphereList:v,hideAttributes:R,setHighlight2DDataList:I,cuboidBoxIn2DView:S,imageSizes:V,history:k,linkageImageNameRectMap:T}=n,{addHistory:A,initHistory:O,pushHistoryUnderUpdatePolygon:w}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:nt,updatePointCloudSphere:X,selectedSphere:F}=useSphere.useSphere(),{currentData:E,config:y}=ctx.useSelector(s=>{const{stepList:i,step:u,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:index.jsonParser(StepUtils.getCurrentStepInfo(u,i).config)}}),M=ctx.useDispatch(),it=ahooks.useLatest(S),st=ahooks.useLatest(T),rt=React.useCallback((s,i)=>{const u=st.current,l=i.id;return s.filter(r=>{if(!r)return!1;const h=u.get(r.imageName);return h===void 0?!0:Boolean(h.get(l))})},[]),Z=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!it.current||i){const{mappingImgList:u=[]}=E;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:u,imageSizes:V},{prepareRectsFn:rt})}},{selectedBox:U,updateSelectedBox:lt,updateSelectedBoxes:G,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:Z}),Y=U==null?void 0:U.info;if(!t||!a||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:J}=t,dt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},ut=({newPoint:s,size:i,zoom:u,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const h=topViewPoint2PointCloud(s,i,J,void 0,r);d(s.id);const C=c(h);H(PointCloudView.Top,s,h,u,C,y),A({newSphereParams:h})},ct=({polygon:s,size:i,imgList:u,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var h,C,b;const D={attribute:(h=t.toolInstance.defaultAttribute)!=null?h:""};l===!0&&Object.assign(D,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:v})}),t==null||t.toolInstance;const L=__spreadValues({},s);let{boxParams:B,newPointList:m}=topViewPolygon2PointCloud(L,i,J,void 0,D,r);B=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[B],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(m==null?void 0:m.length)&&(L.pointList=m);const N=R.includes(L.attribute);Z(B);const z=P(B),Q=(C=n==null?void 0:n.polygonList)!=null?C:[];B.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(b=y==null?void 0:y.inputList)!=null?b:[]:[]),t==null||t.updatePolygonList(z!=null?z:[],Q),N?d([]):(d(B.id),r&&synchronizeTopView(B,L,t,e)),A({newBoxParams:B})},pt=s=>{const{boxID:i,imageName:u,width:l,height:g,x:r,y:h}=s,C=f.find(m=>m.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(m=>m.imageName===u))return;const D=C.rects.map(m=>m.imageName===u?__spreadProps(__spreadValues({},m),{width:l,height:g,x:r,y:h}):m),L=__spreadProps(__spreadValues({},C),{rects:D}),B=f.map(m=>m.id===i?L:m);return t==null||t.updatePolygonList(B!=null?B:[]),B},gt=s=>{const{boxID:i,imageName:u}=s,l=f.find(C=>C.id===i);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==u),r=__spreadProps(__spreadValues({},l),{rects:g}),h=f.map(C=>C.id===i?r:C);return t==null||t.updatePolygonList(h!=null?h:[]),h},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:u,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(x.length===0||!r)){if(s||(U==null?void 0:U.info)){const h=s!=null?s:U==null?void 0:U.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(x[0]);const C=r.selectedPolygon;if(x.length===1&&h){q({omitView:PointCloudView.Top,polygon:C,boxParams:h,newPointCloudBoxList:i});return}}if((u||F)&&x.length===1){const h=u!=null?u:F;r.setSelectedID(x[0]);const C=r.selectedPoint;h&&H(PointCloudView.Top,C,h,void 0,l,y)}}},K=(s,i,u,l=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{if(Y){let g,r;switch(u){case PointCloudView.Back:g=backViewPolygon2PointCloud;break;case PointCloudView.Side:g=sideViewPolygon2PointCloud;break;default:g=sideViewPolygon2PointCloud;break}if(r=g(s,i,Y,a.pointCloudInstance),e){const{count:L}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:L})}const C=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],b=r.valid!==C.valid;r=C;const D=lt(r);return r=D.find(L=>L.id===r.id),q({omitView:b?void 0:u,polygon:s,boxParams:r,newPointCloudBoxList:D},l),D}},$=(s,i,u)=>{if(F){let l,g;switch(u){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}g=l(s,i,F);const r=X(g);return H(u,s,g,void 0,r,y),r}},Ct=(s,i)=>{$(s,i,PointCloudView.Side)},ft=(s,i)=>{$(s,i,PointCloudView.Back)},ht=(s,i)=>{K(s,i,PointCloudView.Side,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},xt=(s,i)=>{K(s,i,PointCloudView.Back,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},vt=(s,i)=>{const u=nt(s.id),l=topViewPoint2PointCloud(s,i,J,u),g=X(l);H(PointCloudView.Top,s,l,void 0,g,y)},Lt=(s,i)=>{if(ot){const l=__spreadValues({},s[0].newPolygon);l.pointList=l.pointList.map(g=>lbUtils.PointCloudUtils.transferCanvas2World(g,i)),w(l);return}let u=s.map(({newPolygon:l})=>{const g=at(l.id),{boxParams:r}=topViewPolygon2PointCloud(l,i,t.pointCloudInstance,g);return r});if(u=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:u,stepConfig:y,action:"viewUpdateBox"})),u.length===1){const{newPolygon:l}=s[0],g=G(u);q({polygon:l,boxParams:u[0],newPointCloudBoxList:g},ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)}else{const l=G(u);l&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,l)}},yt=s=>{var i,u,l,g,r;if(U){const h=Number(s.widthDefault),C=Number(s.depthDefault),b=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(W=>(W==null?void 0:W.trackID)===D),m={width:(l=(u=t==null?void 0:t.toolInstance)==null?void 0:u.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},j=B.pointList.map(W=>lbUtils.PointCloudUtils.transferCanvas2World(W,m)),N=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(j,b,h),z=N[0],Q=N[2],tt=lbAnnotation.MathUtils.getLineCenterPoint([z,Q]),mt=U.info.center.z-U.info.depth/2,et=__spreadProps(__spreadValues({},U.info),{center:{x:tt.x,y:tt.y,z:mt+C/2},width:h,height:b,depth:C,valid:!0}),Bt=G([et]);q({omitView:PointCloudView["3D"],polygon:B,boxParams:et,newPointCloudBoxList:Bt})}},H=(s,i,u,l,g,r)=>__async(void 0,null,function*(){const h=E==null?void 0:E.url,C={[PointCloudView.Side]:()=>{syncSideViewByPoint(u,i,a,h,r)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(u,i,p,h,r)},[PointCloudView.Top]:()=>{syncTopViewByPoint(u,i,t,e)}};Object.keys(C).forEach(b=>{b!==s&&C[b]()}),l&&(e==null||e.updateCameraZoom(l)),dt(u)}),q=(s,i=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:u,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:h}=s,C=E==null?void 0:E.url;h&&n.syncAllViewPointCloudColor(i,h);const b={[PointCloudView.Side]:()=>{synchronizeSideView(g,l,a,C)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(g,l,p,C)},[PointCloudView.Top]:()=>{synchronizeTopView(g,l,t,e)}};Object.keys(b).forEach(D=>{D!==u&&b[D]()}),r&&(e==null||e.updateCameraZoom(r))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:ht,backViewUpdateBox:xt,syncPointCloudViews:q,syncPointCloudPoint:H,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=E){var u,l,g,r,h,C,b,D;if(!(i==null?void 0:i.url)||!e)return;I([]),actionCreators.SetAnnotationLoading(M,!0),actionCreators.SetLoadPCDFileLoading(M,!0),(u=o==null?void 0:o.setResourceLoading)==null||u.call(o,!0),yield e.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:DEFAULT_RADIUS),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let L=[],B=[],m=[],j=[];e.updateTopCamera();const N=(r=(g=index.jsonParser(i.result))==null?void 0:g.valid)!=null?r:!0;if(n.setPointCloudValid(N),(h=n.sideViewInstance)==null||h.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(L=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(L==null?void 0:L.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){L=yield e==null?void 0:e.filterPreResult(i.url,y,L);const z=index.jsonParser(i.result);z[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=L,i.result=JSON.stringify(z),n.setPointCloudResult(L)}m=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),B=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),j=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(b=y==null?void 0:y.radius)!=null?b:DEFAULT_RADIUS}),e==null||e.generateBoxes(L),e==null||e.generateSpheres(j),yield n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,L,[])}O({pointCloudBoxList:L,polygonList:m,lineList:B,pointCloudSphereList:j}),actionCreators.SetAnnotationLoading(M,!1),actionCreators.SetLoadPCDFileLoading(M,!1),(D=o==null?void 0:o.setResourceLoading)==null||D.call(o,!1)}),updateViewsByDefaultSize:yt,generateRects:Z,update2DViewRect:pt,remove2DViewRect:gt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:n,setPointCloudResult:t}=React.useContext(PointCloudContext.PointCloudContext),a=ahooks.useLatest(o),p=ahooks.useLatest(n);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=a.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 v=f.extId,R=f.imageName,I=_.pick(f,["x","y","width","height"]);let S=d.get(v);S||(S=new Map,d.set(v,S)),S.set(R,I),x.add(v)}),d.size){const f=P.map(v=>{var R;const I=v.id;if(x.has(I)){const S=__spreadValues({},v);return(R=S.rects)==null||R.forEach(V=>{var k;const T=V.imageName;Object.assign(V,(k=d.get(I))==null?void 0:k.get(T))}),S}return v});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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),_=require("lodash");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,n)=>{const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),_=require("lodash");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,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||r.modifiedType===exports.EPointCloudBoxSingleModifiedType.ChangeDepth)){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.MulitSelect:return{modifiedBoxIds:getDifference(n,i),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:[]}}},getDifference=(t,n)=>{const i=new Map;for(const e of n)i.set(e.id,e);return t.filter(e=>{const o=i.get(e.id);return!o||!_.isEqual(e,o)}).map(e=>e.id)};exports.calcResetAreasAndBoxIds=calcResetAreasAndBoxIds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudPattern as
|
|
1
|
+
import{EPointCloudPattern as X}from"@labelbee/lb-utils";import Oe,{useState as r,useRef as ut,useMemo as k,useCallback as N,useEffect as Y}from"react";import{EPointCloudBoxRenderTrigger as F,calcResetAreasAndBoxIds as gt}from"../../utils/ToolPointCloudBoxRenderHelper.js";import{ActionsHistory as Me,EToolName as $,uuid as ft}from"@labelbee/lb-annotation";import{useDispatch as pt}from"../../store/ctx.js";import{ChangeSave as mt}from"../../store/annotation/actionCreators.js";import ht from"../../store/annotatedBox/index.js";import je from"lodash";import{addMapIndirectWeakSetItem as ke}from"./utils/map.js";import It from"./hooks/useTimeoutFunc.js";import vt,{getEmptyUseWindowKeydownListener as Pt}from"./hooks/useWindowKeydownListener.js";var wt=Object.defineProperty,yt=Object.defineProperties,St=Object.getOwnPropertyDescriptors,Fe=Object.getOwnPropertySymbols,Lt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable,Ee=(d,s,c)=>s in d?wt(d,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):d[s]=c,E=(d,s)=>{for(var c in s||(s={}))Lt.call(s,c)&&Ee(d,c,s[c]);if(Fe)for(var c of Fe(s))Ct.call(s,c)&&Ee(d,c,s[c]);return d},ze=(d,s)=>yt(d,St(s)),Rt=(d,s,c)=>new Promise((x,A)=>{var B=g=>{try{w(c.next(g))}catch(b){A(b)}},G=g=>{try{w(c.throw(g))}catch(b){A(b)}},w=g=>g.done?x(g.value):Promise.resolve(g.value).then(B,G);w((c=c.apply(d,s)).next())});const z=d=>je.pick(d,["id","attribute","width","height","x","y","imageName"]),Ge=Oe.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new Me,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:$.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:X.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:d=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:d=>!1,removeRectBySpecifyId:(d,s,c)=>!1,removeRectByPointCloudBoxId:d=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:Pt(),isLargeStatus:!1,setIsLargeStatus:()=>{}}),bt=({children:d})=>{const[s,c]=r([]),[x,A]=r([]),[B,G]=r([]),[w,g]=r([]),[b,Ke]=r([]),[v,ee]=r([]),[_,K]=r([]),[te,Te]=r(!0),[oe,We]=r(2),[ne,Ze]=r(!0),[ie,Ue]=r(1),[p,se]=r(),[re,le]=r(),[ae,de]=r(),[f,ce]=r(),[ue,qe]=r(""),[T,Je]=r($.Rect),W=ut(new Me).current,[m,Z]=r([]),[ge,Qe]=r(""),[U,Xe]=r(X.Detection),[D,fe]=r(void 0),[q,Ye]=r([]),[J,$e]=r([]),[pe,et]=r(!1),[me,he]=r(!1),h=ht(),[Ie,tt]=r({}),ot=pt(),nt=o=>{const{imgNode:n,path:t}=o;t&&n&&tt(a=>ze(E({},a),{[t]:{width:n.width,height:n.height}}))},ve=k(()=>v.length===1?v[0]:"",[v]),Pe=vt(),H=N((o,n,t="extId")=>{const a=t||"id",l=new Set(n);return g(u=>{let y=!1;const P=u.filter(M=>{const Q=M[a],j=l.has(Q)?M.imageName!==o:!0;return j||(y=!0),j});return y?P:u}),!0},[]),we=N(o=>{const n=s.map(t=>t.id);return H(o,n,"extId")},[s,H]),ye=N(o=>{if(!o)return!1;const n=s.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:a,attribute:l,trackID:u}=t,y=t.rects.find(P=>P.imageName===o);if(y){const P=je.pick(y,["width","height","x","y","imageName"]);return ze(E({},P),{id:ft(),attribute:l,order:u,extId:a,lineDash:[]})}return null}).filter(t=>t!==null);return n.length?(g(t=>{const a=new Set(t.filter(u=>o===u.imageName).map(u=>u.extId)),l=n.filter(u=>a.has(u.extId)===!1);return l.length?[...t,...l]:t}),!0):!1},[s]),Se=k(()=>s.filter(n=>Array.isArray(n.rects)&&n.rects.length>0).reduce((n,t)=>{var a;return(a=t.rects)==null||a.forEach(l=>{const{imageName:u}=l;if(!u){console.warn("Missing image name"),console.trace(l,t);return}ke(n,u,t.id,t)}),n},new Map),[s]),Le=N(o=>{g(n=>o(n,z))},[z]),Ce=k(()=>w.filter(o=>o.extId!==void 0&&o.id!==void 0).reduce((o,n)=>{const t=n.imageName;return t?(ke(o,t,n.extId,n),o):(console.warn("missing image name"),console.log(n,w),o)},new Map),[w]),{fn:it}=It(o=>{ee(n=>{const t=o,a=new Set(t);let l=!1;const u=n.filter(y=>{const P=a.has(y);return P||(l=!0),P});return l?u:n})},200),Re=N(o=>{const n=o.map(t=>t.id);c(o),it(n)},[]),O=k(()=>{const o=s.find(e=>e.id===ve),n=e=>{const i=s.concat(e);return Re(i),i},t=e=>{const i=x.concat(e);return A(i),i},a=e=>{Te(e!==!1)},l=e=>{let i=[];e===void 0||e===""?i=[]:typeof e=="string"?i=[e]:Array.isArray(e)&&(i=e.length>1?Array.from(new Set(e)):e),ee(i)},u=e=>{v.includes(e)?l(v.filter(i=>i!==e)):l([...v,e])},y=e=>{const i=z(e);g(I=>[...I,i])},P=(e,i=!1)=>{const I=z(e);g(S=>S.map(L=>L.id===e.id?i?E(E({},L),I):I:L))},M=e=>{g(i=>i.filter(I=>!e.find(S=>S.id===I.id)))},Q=e=>{_.includes(e)?K([]):K([e])},j=()=>{if(T===$.Rect){const e=s.map(i=>i.id);l(e),p==null||p.pointCloud2dOperation.setSelectedIDs(e)}},rt=e=>{l(s.filter(i=>i.attribute===e).map(i=>i.id))},be=s.filter(e=>!m.includes(e.attribute)),xe=x.filter(e=>!m.includes(e.attribute)),De=b.filter(e=>e.attribute&&!m.includes(e.attribute)),lt=e=>{if(m.includes(e))Z(m.filter(i=>i!==e));else{const i=m.concat(e);Z(i)}},at=(e=be,i=B,I=xe,S=De,L=q)=>{var V;f==null||f.clearAllBox(),f==null||f.clearAllSphere(),p==null||p.updatePolygonList(e,i),p==null||p.updatePointList(I),p==null||p.updateLineList(S),f==null||f.generateBoxes(e),f==null||f.generateSpheres(I),(V=D==null?void 0:D.store)==null||V.updateCurrentSegment(L),Ae(F.Default,e)},dt=()=>{se(void 0),le(void 0),de(void 0),ce(void 0)},Ae=(e,i,I)=>Rt(void 0,null,function*(){var S,L,V;if(!f)return;const Be=f.pointCloudObject;if(!Be)return;let _e=[],Ve=[];try{if(i&&W.record.length){const{record:C,recordIndex:R}=W;let Ne=R;R>0&&(e===F.SingleToggleValid||e===F.SingleRotate||e===F.Single&&i.length===((S=C[R])==null?void 0:S.pointCloudBoxList.length))&&(Ne=R-1);let ct=(L=C[Ne])==null?void 0:L.pointCloudBoxList;const He=gt(e,i,ct);_e=He.modifiedBoxIds,Ve=He.resetAreas}}catch(C){console.error("call calcResetAreasAndBoxIds error",C)}try{const C=yield f.getHighlightIndexByMappingImgList({mappingImgList:I!=null?I:J,points:Be.geometry.attributes.position.array}),R=yield f==null?void 0:f.highlightOriginPointCloud(i,C,{modifiedBoxIds:_e,resetAreas:Ve});return R&&((V=p==null?void 0:p.pointCloudInstance)==null||V.updateColor(R)),R}catch(C){console.error("call highlightOriginPointCloud error",C)}});return{selectedID:ve,pointCloudBoxList:s,pointCloudSphereList:x,displayPointCloudList:be,displaySphereList:xe,displayLineList:De,selectedIDs:v,setPointCloudResult:Re,setSelectedIDs:l,addPointCloudBox:n,addPointCloudSphere:t,setPointCloudSphereList:A,valid:te,selectedPointCloudBox:o,setPointCloudValid:a,addSelectedID:u,addHighlightID:Q,selectedAllBoxes:j,topViewInstance:p,setTopViewInstance:se,sideViewInstance:re,setSideViewInstance:le,backViewInstance:ae,setBackViewInstance:de,mainViewInstance:f,setMainViewInstance:ce,polygonList:B,setPolygonList:G,rectList:w,setRectList:g,addRectIn2DView:y,removeRectIn2DView:M,updateRectIn2DView:P,lineList:b,setLineList:Ke,zoom:ie,setZoom:Ue,history:W,toggleAttributesVisible:lt,hideAttributes:m,setHideAttributes:Z,reRender:at,attrPanelLayout:ge,setAttrPanelLayout:Qe,syncAllViewPointCloudColor:Ae,defaultAttribute:ue,setDefaultAttribute:qe,pointCloudPattern:T,setPointCloudPattern:Je,selectSpecAttr:rt,globalPattern:U,setGlobalPattern:e=>{U!==e&&(ot(mt),Xe(e),e===X.Detection&&fe(void 0))},ptSegmentInstance:D,setPtSegmentInstance:fe,segmentation:q,setSegmentation:Ye,clearAllDetectionInstance:dt,highlight2DDataList:J,setHighlight2DDataList:$e,highlight2DLoading:pe,setHighlight2DLoading:et,cuboidBoxIn2DView:ne,setCuboidBoxIn2DView:Ze,imageSizes:Ie,cacheImageNodeSize:nt,highlightIDs:_,setHighlightIDs:K,removeRectByPointCloudBoxId:we,removeRectBySpecifyId:H,addRectFromPointCloudBoxByImageName:ye,rectRotateSensitivity:oe,setRectRotateSensitivity:We,imageNamePointCloudBoxMap:Se,linkageImageNameRectMap:Ce,updateRectListByReducer:Le,windowKeydownListenerHook:Pe,isLargeStatus:me,setIsLargeStatus:he}},[te,v,s,x,B,b,w,p,re,ae,f,ie,m,ge,ue,T,U,D,q,J,pe,ne,Ie,_,we,H,ye,oe,Se,Ce,Le,Pe,me,he]);Y(()=>{var o,n,t;(o=h==null?void 0:h.setPointCloudBoxList)==null||o.call(h,s),(n=h==null?void 0:h.setHighlightIDs)==null||n.call(h,_),(t=h==null?void 0:h.setSelectedIDs)==null||t.call(h,v)},[s,v,_]),Y(()=>{var o;(o=h==null?void 0:h.setPtCtx)==null||o.call(h,O)},[O]);const st=()=>{const o=s.filter(l=>m.includes(l.attribute)),{setSelectedIDs:n,reRender:t}=O,a=o.map(l=>l.id);a.length>0&&n(v.filter(l=>!a.includes(l))),t()};return Y(()=>{var o,n,t,a;st(),(n=(o=p==null?void 0:p.toolInstance)==null?void 0:o.setHiddenAttributes)==null||n.call(o,m),(a=(t=D==null?void 0:D.store)==null?void 0:t.setHiddenAttributes)==null||a.call(t,m)},[m]),Oe.createElement(Ge.Provider,{value:O},d)};export{Ge as PointCloudContext,bt as PointCloudProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as _}from"../../utils/dom.js";import{FooterDivider as
|
|
1
|
+
import{getClassName as _}from"../../utils/dom.js";import{FooterDivider as K}from"../../views/MainView/toolFooter/index.js";import{ZoomController as Ie}from"../../views/MainView/toolFooter/ZoomController/index.js";import{LeftOutlined as ye,UpSquareOutlined as xe,DownSquareOutlined as he}from"@ant-design/icons";import{cKeyCode as Ve,PointCloudAnnotation as Se,MathUtils as M,cTool as _e,cAnnotation as Ee}from"@labelbee/lb-annotation";import{PointCloudUtils as X}from"@labelbee/lb-utils";import{EPointCloudBoxRenderTrigger as Y}from"../../utils/ToolPointCloudBoxRenderHelper.js";import s,{useState as B,useRef as Le,useContext as q,useLayoutEffect as be,useEffect as P}from"react";import{PointCloudContext as $}from"./PointCloudContext.js";import{useRotate as Oe}from"./hooks/useRotate.js";import{useRotateEdge as je}from"./hooks/useRotateEdge.js";import{useSingleBox as G}from"./hooks/useSingleBox.js";import{PointCloudContainer as Te}from"./PointCloudLayout.js";import{BoxInfos as J,PointCloudValidity as De}from"./PointCloudInfos.js";import{usePolygon as Re}from"./hooks/usePolygon.js";import{useSphere as Q}from"./hooks/useSphere.js";import{useZoom as ee}from"./hooks/useZoom.js";import{Slider as ke}from"antd";import{a2MapStateToProps as Be}from"../../store/annotation/map.js";import{connect as Ae}from"react-redux";import{usePointCloudViews as Ne}from"./hooks/usePointCloudViews.js";import Ue from"../../hooks/useSize.js";import{useTranslation as ze}from"react-i18next";import{LabelBeeContext as Ze}from"../../store/ctx.js";import{jsonParser as He}from"../../utils/index.js";import Fe from"../../utils/ToolUtils.js";import We from"lodash";import Ke from"./components/PointCloudSizeSlider/index.js";import{useHistory as Me}from"./hooks/useHistory.js";import Xe from"./components/TitleButton/index.js";var Ye=Object.defineProperty,qe=Object.defineProperties,$e=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertySymbols,Ge=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,oe=(i,l,r)=>l in i?Ye(i,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[l]=r,U=(i,l)=>{for(var r in l||(l={}))Ge.call(l,r)&&oe(i,r,l[r]);if(te)for(var r of te(l))Je.call(l,r)&&oe(i,r,l[r]);return i},z=(i,l)=>qe(i,$e(l));const{EPolygonPattern:Qe,EToolName:ne}=_e,{ESortDirection:ie}=Ee,et=Ve.default,se=(i,l,r=1)=>{const{width:v,height:m}=l,y={x:i.x+v*r/2,y:i.y+m*r/2},x={x:l.width/2,y:l.height/2};return{offsetX:(x.x-y.x)/r,offsetY:-(x.y-y.y)/r}},tt=({currentData:i})=>{var l,r;const{zoom:v,zoomIn:m,zoomOut:y,initialPosition:x}=ee(),{selectNextBox:O,selectPrevBox:j}=G(),{switchToNextSphere:E}=Q(),{updateRotate:L}=Oe({currentData:i}),{updateRotateEdge:T}=je({currentData:i}),g=q($),{topViewInstance:h}=g,f=(r=(l=g==null?void 0:g.topViewInstance)==null?void 0:l.toolScheduler)==null?void 0:r.getCurrentToolName(),e=()=>{L(-Number(g.rectRotateSensitivity))},d=()=>{L(g.rectRotateSensitivity)},C=()=>{T(-90)};return s.createElement(s.Fragment,null,s.createElement(Ke,{onChange:A=>{var V;(V=h==null?void 0:h.pointCloudInstance)==null||V.updatePointSize({customSize:A})}}),s.createElement("span",{onClick:d,className:_("point-cloud","rotate-reserve")}),s.createElement("span",{onClick:e,className:_("point-cloud","rotate")}),s.createElement("span",{onClick:C,className:_("point-cloud","rotate-90")}),s.createElement(K,null),s.createElement(xe,{onClick:()=>{if(f===ne.Point){E(ie.descend);return}j(!0)},className:_("point-cloud","prev")}),s.createElement(he,{onClick:()=>{if(f===ne.Point){E(ie.ascend);return}O(!0)},className:_("point-cloud","next")}),s.createElement(K,null),s.createElement(Ie,{initialPosition:x,zoomIn:m,zoomOut:y,zoom:v}))},ot=({setZAxisLimit:i,zAxisLimit:l,checkMode:r})=>r?null:s.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},s.createElement(ke,{vertical:!0,step:.5,max:10,min:.5,defaultValue:l,onAfterChange:v=>{i(v)}})),nt=({currentData:i,imgList:l,stepInfo:r,drawLayerSlot:v,checkMode:m,intelligentFit:y,setIsEnlargeTopView:x,isEnlargeTopView:O,onExitZoom:j,highlightAttribute:E})=>{var L,T;const[g,h]=B({zoom:1,currentPos:{x:0,y:0}}),f=Le(null),e=q($),d=Ue(f),C=He(r.config),{setZoom:A,syncTopviewToolZoom:V}=ee(),{hideAttributes:le,setIsLargeStatus:re,selectedID:ae,pointCloudBoxList:ce}=e,{addPolygon:de,deletePolygon:ue}=Re(),{deletePointCloudSphere:pe}=Q(),{deletePointCloudBox:me,changeValidByID:fe}=G(),[N,Ce]=B(10),{t:Z}=ze(),w=Ne(),{pushHistoryWithList:ve}=Me(),[we,D]=B(!0),[H,F]=B(!1);be(()=>{if(!e.topViewInstance&&f.current&&(i==null?void 0:i.url)&&(i==null?void 0:i.result)){const o={width:f.current.clientWidth,height:f.current.clientHeight},a=new Se({container:f.current,size:o,pcdPath:i.url,config:z(U({},C),{pointCloudPattern:e.pointCloudPattern}),checkMode:m,toolName:Fe.getPointCloudToolList(),proxyMode:m});e.setTopViewInstance(a)}},[i]),P(()=>{H&&ae&&(e.syncAllViewPointCloudColor(Y.Single,ce),F(!1))},[H]),P(()=>{if(!d||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:o}=e.topViewInstance;o.singleOn("dataUpdated",(t,n)=>{const u=We.cloneDeep(t).map(c=>z(U({},c),{pointList:X.pointListTransferCanvas2World(c.pointList,d)}));e.setSelectedIDs(n),e.setLineList(u),ve({lineList:u})}),o.singleOn("pointCreated",(t,n)=>{w.topViewAddSphere({newPoint:t,size:d,trackConfigurable:C.trackConfigurable,zoom:n})}),o.singleOn("pointDeleted",t=>{pe(t)}),o.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),o.singleOn("updatePointByDrag",(t,n)=>{var u;(u=w.topViewUpdatePoint)==null||u.call(w,t,d)}),o.singleOn("polygonCreated",(t,n)=>{if(o.pattern===Qe.Normal||!(i==null?void 0:i.url)){const u=z(U({},t),{pointList:t.pointList.map(c=>X.transferCanvas2World(c,d))});de(u),e.setSelectedIDs(le.includes(t.attribute)?"":t.id);return}D(!1),w.topViewAddBox({polygon:t,size:d,imgList:l,trackConfigurable:C.trackConfigurable,zoom:n,intelligentFit:y}),F(!0)}),o.singleOn("deletedObject",({id:t})=>{me(t),ue(t)}),o.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),o.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),o.singleOn("setSelectedIDs",t=>{D(!1),e.setSelectedIDs(t)}),o.singleOn("updatePolygonByDrag",t=>{var n;(n=w.topViewUpdateBox)==null||n.call(w,t,d)});const a=t=>{var n;const u=fe(t);u&&e.syncAllViewPointCloudColor(Y.Default,u),e.polygonList.find(c=>c.id===t)&&((n=e.topViewInstance)==null||n.toolInstance.setPolygonValidAndRender(t,!0))};return o.on("validUpdate",a),()=>{o.unbind("validUpdate",a)}},[e,d,i,w,e.polygonList,e.lineList,(L=e.topViewInstance)==null?void 0:L.toolInstance]),P(()=>{var o,a;if(!(d==null?void 0:d.width)||!e.topViewInstance)return;const t=(a=(o=C==null?void 0:C.attributeList)==null?void 0:o[0])==null?void 0:a.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(d),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:n,toolInstance:u}}=e;u.singleOn("renderZoom",(c,p)=>{const{offsetX:S,offsetY:b}=se(p,d,c);if(n.camera.zoom=c,p){const{x:I,y:R,z:k}=n.initCameraPosition;n.camera.position.set(I+b,R-S,k)}n.camera.updateProjectionMatrix(),n.render(),A(c),V(p,c,d),h({zoom:c,currentPos:p})}),u.singleOn("dragMove",({currentPos:c,zoom:p})=>{const{offsetX:S,offsetY:b}=se(c,d,p);n.camera.zoom=p;const{x:I,y:R,z:k}=n.initCameraPosition;n.camera.position.set(I+b,R-S,k),n.render(),V(c,p,d),h({zoom:p,currentPos:c})})},[d,e.topViewInstance,(T=e.topViewInstance)==null?void 0:T.toolInstance]),P(()=>{var o,a;(a=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null||a.applyZAxisPoints(N)},[N]),P(()=>{var o,a,t,n;w.topViewSelectedChanged({}),(n=(t=(a=(o=e.topViewInstance)==null?void 0:o.toolInstance)==null?void 0:a.selection)==null?void 0:t.hardSetSelectedIDs)==null||n.call(t,e.selectedIDs)},[e.selectedIDs]),P(()=>{const{topViewInstance:o,selectedID:a,selectedPointCloudBox:t,zoom:n}=e;if(!o||!a||!t||!we){D(!0);return}const{center:u}=t,{pointCloudInstance:c,toolInstance:p}=o,S=p.polygonList.find(ge=>ge.id===e.selectedID);if(!S){D(!0);return}const b=M.getRectCenterPoint(S.pointList),I=M.getCurrentPosFromRectCenter(p.size,b,n);p.setCurrentPos(I),p.render();const{x:R,y:k,z:Pe}=c.initCameraPosition;c.camera.position.set(u.x,u.y,Pe),c.render(),V(I,n,d),h({zoom:n,currentPos:I})},[e.selectedID]),P(()=>(window.addEventListener("keydown",W),()=>{window.removeEventListener("keydown",W)}),[]);const W=o=>{const{keyCode:a}=o;a===et.Esc&&j()};return P(()=>{var o,a,t;(t=(a=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:a.setHighlightAttribute)==null||t.call(a,E)},[e.topViewInstance,E]),s.createElement(Te,{className:_("point-cloud-container","top-view"),title:O?s.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},s.createElement(ye,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{j()}}),s.createElement("span",null,Z("TopView")),s.createElement(J,{checkMode:m,config:C,style:{display:"flex",position:"initial",margin:"0px 20px"}})):s.createElement(Xe,{title:Z("TopView"),onClick:()=>{re(!0),x(!0)}}),toolbar:s.createElement(tt,{currentData:i})},s.createElement("div",{style:{position:"relative",flex:1}},s.createElement("div",{style:{width:"100%",height:"100%"},ref:f},v==null?void 0:v(g)),!O&&s.createElement(J,{checkMode:m,config:C}),s.createElement(ot,{checkMode:m,zAxisLimit:N,setZAxisLimit:Ce}),s.createElement(De,null)))};var it=Ae(Be,null,null,{context:Ze})(nt);export{it as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{BatchUpdateResultByTrackID as
|
|
1
|
+
import{BatchUpdateResultByTrackID as q}from"../../../../store/annotation/actionCreators.js";import{LabelBeeContext as V,useDispatch as N}from"../../../../store/ctx.js";import{Form as o,Modal as $,InputNumber as C,Radio as O,Select as v,Popover as G,message as H}from"antd";import e,{useState as K,useEffect as Q,useCallback as W}from"react";import{useTranslation as k}from"react-i18next";import{QuestionCircleOutlined as J}from"@ant-design/icons";import{PointCloudUtils as D}from"@labelbee/lb-utils";import{connect as X}from"react-redux";import{useSingleBox as Y}from"../../hooks/useSingleBox.js";import{MathUtils as Z}from"@labelbee/lb-annotation";var ee=Object.defineProperty,te=Object.defineProperties,ne=Object.getOwnPropertyDescriptors,U=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable,j=(r,n,a)=>n in r?ee(r,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[n]=a,B=(r,n)=>{for(var a in n||(n={}))re.call(n,a)&&j(r,a,n[a]);if(U)for(var a of U(n))ae.call(n,a)&&j(r,a,n[a]);return r},le=(r,n)=>te(r,ne(n));const ie={labelCol:{span:8},wrapperCol:{span:16}},z=[{required:!0,message:"\u8BF7\u586B\u5199\u4E00\u4E2A\u6570\u5B57"}],ue=[{required:!0,message:"\u8BF7\u9009\u62E9\u4E3B\u5C5E\u6027"}],S=2,M=({text:r})=>e.createElement("span",{style:{borderRadius:"4px 0px 0px 4px",padding:"0px 12px",background:"#FAFAFA",border:"1px solid rgb(217 217 217)",borderRight:"0",display:"flex",alignItems:"center",height:32}},r),oe=r=>{const{t:n}=k(),{size:a,isMax:s,selectedBox:m}=r;if(!a||!m)return null;const f={marginRight:16},h=B(B({},m),s&&a),{length:l,width:p,height:E}=D.transferBox2Kitti(h);return e.createElement("div",null,e.createElement("span",{style:f},n("Length"),": ",l.toFixed(S)),e.createElement("span",{style:f},n("Width"),": ",p.toFixed(S)),e.createElement("span",{style:f},n("Height"),": ",E.toFixed(S)),e.createElement(G,{placement:"rightBottom",content:`\u7EDF\u4E00\u5C3A\u5BF8\u4E3A\u8BE5ID\u7684\u6240\u6709\u6807\u6CE8\u6846${s?"\u4E2D\u6700\u5927\u7684\u5C3A\u5BF8":"\u4EE5\u5F53\u524D\u5E27\u6846\u5C3A\u5BF8\u4E3A\u6807\u51C6"}`},e.createElement(J,null)))},se=[{value:"current",label:"\u5F53\u524D\u5E27\u5C3A\u5BF8"},{value:"max",label:"\u6700\u5927\u5C3A\u5BF8"}],ce=({id:r,visible:n,onCancel:a,config:s,imgList:m,imgIndex:f})=>{const h=N(),{selectedBox:l}=Y(),[p,E]=K(),[g]=o.useForm(),{t:c}=k();Q(()=>{n===!1?(g.resetFields(),E(void 0)):F()},[n]);const R=t=>{var i,u,d,y;if(!r)return;if(!p){H.info("\u8BE5\u8303\u56F4\u4E0D\u5B58\u5728\u66F4\u6539\u6570\u636E, \u8BF7\u66F4\u6539\u7EDF\u4E00\u8303\u56F4");return}const b={attribute:t.attribute};if(s.secondaryAttributeConfigurable){const _={};(i=s.inputList)==null||i.forEach(w=>{const x=t[w.value];if(x!==void 0){const T=Array.isArray(x)?x.join(";"):x;Object.assign(_,{[w.value]:T})}}),Object.keys(_).length>0&&Object.assign(b,{subAttribute:_})}const{UnifySize:P}=t;Object.assign(b,p&&P==="max"?p:{width:(u=l==null?void 0:l.info)==null?void 0:u.width,height:(d=l==null?void 0:l.info)==null?void 0:d.height,depth:(y=l==null?void 0:l.info)==null?void 0:y.depth}),h(q(r,b,[t.prevPage-1,t.nextPage-1],m)),a()},F=W(()=>{var t;const{prevPage:i,nextPage:u}=g.getFieldsValue(["prevPage","nextPage"]),d=m.filter((b,P)=>Z.isInRange(P,[i-1,u-1]));if(!((d==null?void 0:d.length)>0)||!(l==null?void 0:l.info)||((t=l==null?void 0:l.info)==null?void 0:t.trackID)===void 0){E(void 0);return}const y=D.getMaxSizeFromBox({trackID:l.info.trackID,imgList:d});E(y)},[m,l,f]),L=()=>g.submit(),A={width:"200px"},I={marginBottom:"24px",display:"flex",alignItems:"center"};return e.createElement($,{title:c("UnifyParams"),visible:n,onCancel:a,onOk:L,wrapClassName:"labelbee-custom-modal"},e.createElement(e.Fragment,null,e.createElement("div",{style:{marginBottom:"20px",color:"#f00"}},c("UnifyParamsTips")),e.createElement(o,le(B({},ie),{form:g,onFinish:R}),e.createElement(o.Item,{name:"id",label:c("UnifyTrackID")},r),e.createElement(o.Item,{label:c("UnifyAttributeRange"),required:!0},e.createElement(o.Item,{style:{display:"inline-block"},rules:z,name:"prevPage",noStyle:!0,initialValue:1},e.createElement(C,{precision:0,min:1,style:{width:"80px"},onChange:()=>F()})),e.createElement("span",{style:{display:"inline-block",width:"24px",textAlign:"center"}},"-"),e.createElement(o.Item,{style:{display:"inline-block"},rules:z,name:"nextPage",noStyle:!0,initialValue:m.length},e.createElement(C,{precision:0,min:1,style:{width:"80px"},onChange:()=>F()})),e.createElement("span",{style:{display:"inline-block",width:"40x",marginLeft:"10px",textAlign:"center"}},c("Page"))),e.createElement(o.Item,{name:"UnifySize",label:c("UnifySize"),required:!0,initialValue:"current"},e.createElement(O.Group,{onChange:t=>{g.setFieldValue("UnifySize",t.target.value)}},se.map(t=>{const{value:i,label:u}=t;return e.createElement(O,{value:i,key:i},e.createElement("div",null,u),e.createElement(oe,{selectedBox:l==null?void 0:l.info,size:p,isMax:i==="max"}))}))),e.createElement(o.Item,{label:c("UnifyTag"),required:!0},e.createElement("div",{style:I},e.createElement(M,{text:c("Attribute")}),e.createElement(o.Item,{name:"attribute",noStyle:!0,rules:ue},e.createElement(v,{style:A},s.attributeList.map(t=>e.createElement(v.Option,{key:t.value,value:t.value},t.key))))),s.secondaryAttributeConfigurable&&s.inputList.map(t=>{var i;return e.createElement("div",{key:t.value,style:I},e.createElement(M,{text:t.key}),e.createElement(o.Item,{name:t.value,noStyle:!0,required:!1},e.createElement(v,{style:A,mode:t.isMulti?"multiple":void 0},(i=t.subSelected)==null?void 0:i.map(u=>e.createElement(v.Option,{key:u.value,value:u.value},u.key)))))})))))},me=r=>({imgIndex:r.annotation.imgIndex});var pe=X(me,null,null,{context:V})(ce);export{pe 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 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 ht}from"react";import{PointCloudContext as xt}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,ho=Object.prototype.hasOwnProperty,xo=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={}))ho.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))xo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((d,p)=>{var o=a=>{try{u(t.next(a))}catch(h){p(h)}},f=a=>{try{u(t.throw(a))}catch(h){p(h)}},u=a=>a.done?d(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,d,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,a={center:{x:o,y:f,z:u},id:e.id},h=d?L(L({},d),a):A(L({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},ct=(e,n,t,d,p,o)=>{let f=e.pointList.map(I=>O.transferCanvas2World(I,n)),u=0,a=1,h={};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,h={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);d&&(u=d.center.z,a=d.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+wt:U,height:o?D+wt:D,depth:a,rotation:N,id:e.id},j=L(d?L(L({},d),z):A(L({},z),{attribute:"",valid:!0}),h);p&&Object.assign(j,p);const M=f.map(I=>O.transferWorld2Canvas(I,n));return{boxParams:j,newPointList:M}},It=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x-d.x,y:t.center.y,z:t.center.z-d.y}})},Dt=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,h]),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,a),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),M=z-j,{newBoxParams:I}=d.getNewBoxBySideUpdate(V,M,N,t);return I},Lo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x,y:t.center.y-d.x,z:t.center.z-d.y}})},vo=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,h]),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,a),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),M=z-j;let{newBoxParams:I}=d.getNewBoxByBackUpdate(V,M,N,t);return I},St=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,X.Left);u.setInitCameraPosition(a);const{point2d:h,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),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{width:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.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,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,X.Back);u.setInitCameraPosition(a);const{point2d:h,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),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{height:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.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,d)=>{if(!t||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,X.Top),d.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,d)=>{var p,o;if(!t||!d)return;d.generateBox(e),d.setHighlightColor(e.id),d.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:a}=u.getBoxTopPolygon2DCoordinate(e),h=[...f.polygonList],P=h.find(v=>v.id===n.id);P?(P.pointList=a,P.valid=(p=e.valid)!=null?p:!0):h.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(h,n.id)},yo=e=>{const n=mt(xt),{topViewInstance:t,sideViewInstance:d,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:a,selectedIDs:h,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:F,config:B}=ao(s=>{const{stepList:i,step:c,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:lt(uo.getCurrentStepInfo(c,i).config)}}),H=co(),Tt=$(D),Ut=$(z),zt=ht((s,i)=>{const c=Ut.current,r=i.id;return s.filter(g=>{if(!g)return!1;const C=c.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:c=[]}=F;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:nt,getPointCloudByID:jt}=so({generateRects:et}),gt=k==null?void 0:k.info;if(!t||!d||!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:c,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);G(y.Top,s,C,c,m,B),j({newSphereParams:C})},Ht=({polygon:s,size:i,imgList:c,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:x,newPointList:E}=ct(R,i,it,void 0,S,g);x=H(dt({tool:st.PointCloud,dataList:[x],stepConfig:B,action:"viewUpdateBox"}))[0],g&&(E==null?void 0:E.length)&&(R.pointList=E);const Z=T.includes(R.attribute);et(x);const Q=f(x),q=(m=n==null?void 0:n.polygonList)!=null?m:[];x.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?a([]):(a(x.id),_.selection.setSelectedIDs(R.id),W({omitView:y.Top,polygon:R,boxParams:x,zoom:l,newPointCloudBoxList:Q}),g&&ut(x,R,t,o)),j({newBoxParams:x})},Ft=s=>{const{boxID:i,imageName:c,width:r,height:l,x:g,y:C}=s,m=P.find(x=>x.id===i);if(!(m==null?void 0:m.rects)||!m.rects.find(x=>x.imageName===c))return;const S=m.rects.map(x=>x.imageName===c?A(L({},x),{width:r,height:l,x:g,y:C}):x),_=A(L({},m),{rects:S}),R=P.map(x=>x.id===i?_:x);return t==null||t.updatePolygonList(R!=null?R:[]),R},Wt=s=>{const{boxID:i,imageName:c}=s,r=P.find(m=>m.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(m=>m.imageName!==c),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:c,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(h.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(h[0]);const m=g.selectedPolygon;if(h.length===1&&C){W({omitView:y.Top,polygon:m,boxParams:C,newPointCloudBoxList:i});return}}if((c||Y)&&h.length===1){const C=c!=null?c:Y;g.setSelectedID(h[0]);const m=g.selectedPoint;C&&G(y.Top,m,C,void 0,r,B)}}},ft=(s,i,c)=>{if(gt){let r,l;switch(c){case y.Back:r=vo;break;case y.Side:r=Dt;break;default:r=Dt;break}if(l=r(s,i,gt,d.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=H(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:c,polygon:s,boxParams:l,newPointCloudBoxList:b}),b}},Ct=(s,i,c)=>{if(Y){let r,l;switch(c){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(c,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 c=At(s.id),r=at(s,i,it,c),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 c=s.map(({newPolygon:r})=>{const l=jt(r.id),{boxParams:g}=ct(r,i,t.pointCloudInstance,l);return g});if(c=H(dt({tool:st.PointCloud,dataList:c,stepConfig:B,action:"viewUpdateBox"})),c.length===1){const{newPolygon:r}=s[0],l=nt(c);W({polygon:r,boxParams:c[0],newPointCloudBoxList:l})}else{const r=nt(c);r&&n.syncAllViewPointCloudColor(rt.MultiMove,r)}},Kt=s=>{var i,c,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),x={width:(r=(c=t==null?void 0:t.toolInstance)==null?void 0:c.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,x)),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,c,r,l,g)=>bt(void 0,null,function*(){const C=F==null?void 0:F.url,m={[y.Side]:()=>{St(c,i,d,C,g)},[y.Back]:()=>{p&&_t(c,i,p,C,g)},[y.Top]:()=>{kt(c,i,t,o)}};Object.keys(m).forEach(b=>{b!==s&&m[b]()}),r&&(o==null||o.updateCameraZoom(r)),Et(c)}),W=(s,i=rt.Default)=>{const{omitView:c,polygon:r,boxParams:l,zoom:g,newPointCloudBoxList:C}=s,m=F==null?void 0:F.url;C&&n.syncAllViewPointCloudColor(i,C);const b={[y.Side]:()=>{Rt(l,r,d,m)},[y.Back]:()=>{p&&Vt(l,r,p,m)},[y.Top]:()=>{ut(l,r,t,o)}};Object.keys(b).forEach(S=>{S!==c&&b[S]()}),g&&(o==null||o.updateCameraZoom(g))};return{topViewAddSphere:Mt,topViewAddBox:Ht,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=F){var c,r,l,g,C,m,b,S;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(H,!0),vt(H,!0),(c=e==null?void 0:e.setResourceLoading)==null||c.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=[],x=[],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(_)}x=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:x,lineList:R,pointCloudSphereList:E}),Lt(H,!1),vt(H,!1),(S=e==null?void 0:e.setResourceLoading)==null||S.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:et,update2DViewRect:Ft,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(xt),d=$(e),p=$(n);return{syncToPointCloudBoxList:ht(()=>{const f=d.current,u=p.current;if(u.length===0)return null;const a=new Map,h=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=a.get(v);D||(D=new Map,a.set(v,D)),D.set(T,V),h.add(v)}),a.size){const P=f.map(v=>{var T;const V=v.id;if(h.has(V)){const D=L({},v);return(T=D.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.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};
|
|
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 ht}from"react";import{PointCloudContext as xt}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 F}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as rt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as lt,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 K}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,ho=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,x=(e,n)=>{for(var t in n||(n={}))ho.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))xo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((d,p)=>{var o=a=>{try{u(t.next(a))}catch(h){p(h)}},f=a=>{try{u(t.throw(a))}catch(h){p(h)}},u=a=>a.done?d(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const $=5,tt=90,It=.01,b={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(e,n,t,d,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,a={center:{x:o,y:f,z:u},id:e.id},h=d?x(x({},d),a):A(x({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},at=(e,n,t,d,p,o)=>{let f=e.pointList.map(D=>O.transferCanvas2World(D,n)),u=0,a=1,h={};if(t){const D=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&D.fittedCoordinates.length>0&&(f=D.fittedCoordinates),u=(D.maxZ+D.minZ)/2,a=D.maxZ-D.minZ,h={count:D.zCount}}const[P,L,T]=f,V=w.getLineCenterPoint([P,T]),R=w.getLineLength(P,L),U=w.getLineLength(L,T),N=w.getRadiusFromQuadrangle(e.pointList);d&&(u=d.center.z,a=d.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+It:U,height:o?R+It:R,depth:a,rotation:N,id:e.id},j=x(d?x(x({},d),z):A(x({},z),{attribute:"",valid:!0}),h);p&&Object.assign(j,p);const E=f.map(D=>O.transferWorld2Canvas(D,n));return{boxParams:j,newPointList:E}},wt=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x-d.x,y:t.center.y,z:t.center.z-d.y}})},Dt=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j,{newBoxParams:D}=d.getNewBoxBySideUpdate(V,E,N,t);return D},Lo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x,y:t.center.y-d.x,z:t.center.z-d.y}})},vo=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j;let{newBoxParams:D}=d.getNewBoxByBackUpdate(V,E,N,t);return D},St=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,X.Left);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{width:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.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,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,X.Back);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{height:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.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,d)=>{if(!t||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,X.Top),d.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(x(x({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},ct=(e,n,t,d)=>{var p,o;if(!t||!d)return;d.generateBox(e),d.setHighlightColor(e.id),d.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:a}=u.getBoxTopPolygon2DCoordinate(e),h=[...f.polygonList],P=h.find(L=>L.id===n.id);P?(P.pointList=a,P.valid=(p=e.valid)!=null?p:!0):h.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(h,n.id)},yo=e=>{const n=mt(xt),{topViewInstance:t,sideViewInstance:d,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:a,selectedIDs:h,pointCloudBoxList:P,pointCloudSphereList:L,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:R,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:E,pushHistoryUnderUpdatePolygon:D}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:ut,selectedSphere:Y}=ro(),{currentData:W,config:y}=ao(s=>{const{stepList:i,step:c,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:rt(uo.getCurrentStepInfo(c,i).config)}}),M=co(),Tt=K(R),Ut=K(z),zt=ht((s,i)=>{const c=Ut.current,l=i.id;return s.filter(r=>{if(!r)return!1;const m=c.get(r.imageName);return m===void 0?!0:Boolean(m.get(l))})},[]),ot=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!Tt.current||i){const{mappingImgList:c=[]}=W;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:et,getPointCloudByID:jt}=so({generateRects:ot}),pt=k==null?void 0:k.info;if(!t||!d||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:nt}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:s,size:i,zoom:c,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:L})});const m=dt(s,i,nt,void 0,r);a(s.id);const C=u(m);J(b.Top,s,m,c,C,y),j({newSphereParams:m})},Ht=({polygon:s,size:i,imgList:c,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var m,C,S;const _={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};l===!0&&Object.assign(_,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:L})}),t==null||t.toolInstance;const v=x({},s);let{boxParams:I,newPointList:B}=at(v,i,nt,void 0,_,r);I=M(lt({tool:st.PointCloud,dataList:[I],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(B==null?void 0:B.length)&&(v.pointList=B);const G=T.includes(v.attribute);ot(I);const H=f(I),it=(C=n==null?void 0:n.polygonList)!=null?C:[];I.subAttribute=oo.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(S=y==null?void 0:y.inputList)!=null?S:[]:[]),t==null||t.updatePolygonList(H!=null?H:[],it),G?a([]):(a(I.id),r&&ct(I,v,t,o)),j({newBoxParams:I})},Ft=s=>{const{boxID:i,imageName:c,width:l,height:g,x:r,y:m}=s,C=P.find(B=>B.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(B=>B.imageName===c))return;const _=C.rects.map(B=>B.imageName===c?A(x({},B),{width:l,height:g,x:r,y:m}):B),v=A(x({},C),{rects:_}),I=P.map(B=>B.id===i?v:B);return t==null||t.updatePolygonList(I!=null?I:[]),I},Wt=s=>{const{boxID:i,imageName:c}=s,l=P.find(C=>C.id===i);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==c),r=A(x({},l),{rects:g}),m=P.map(C=>C.id===i?r:C);return t==null||t.updatePolygonList(m!=null?m:[]),m},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:c,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(h.length===0||!r)){if(s||(k==null?void 0:k.info)){const m=s!=null?s:k==null?void 0:k.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(h[0]);const C=r.selectedPolygon;if(h.length===1&&m){Q({omitView:b.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((c||Y)&&h.length===1){const m=c!=null?c:Y;r.setSelectedID(h[0]);const C=r.selectedPoint;m&&J(b.Top,C,m,void 0,l,y)}}},gt=(s,i,c,l=F.Default)=>{if(pt){let g,r;switch(c){case b.Back:g=vo;break;case b.Side:g=Dt;break;default:g=Dt;break}if(r=g(s,i,pt,d.pointCloudInstance),o){const{count:v}=o.getSensesPointZAxisInPolygon(eo(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=A(x({},r),{count:v})}const C=M(lt({tool:st.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],S=r.valid!==C.valid;r=C;const _=Nt(r);return r=_.find(v=>v.id===r.id),Q({omitView:S?void 0:c,polygon:s,boxParams:r,newPointCloudBoxList:_},l),_}},ft=(s,i,c)=>{if(Y){let l,g;switch(c){case b.Back:l=Lo;break;case b.Side:l=wt;break;default:l=wt;break}g=l(s,i,Y);const r=ut(g);return J(c,s,g,void 0,r,y),r}},Gt=(s,i)=>{ft(s,i,b.Side)},Jt=(s,i)=>{ft(s,i,b.Back)},Qt=(s,i)=>{gt(s,i,b.Side,F.Single)},Xt=(s,i)=>{gt(s,i,b.Back,F.Single)},Yt=(s,i)=>{const c=At(s.id),l=dt(s,i,nt,c),g=ut(l);J(b.Top,s,l,void 0,g,y)},qt=(s,i)=>{if(Ot){const l=x({},s[0].newPolygon);l.pointList=l.pointList.map(g=>O.transferCanvas2World(g,i)),D(l);return}let c=s.map(({newPolygon:l})=>{const g=jt(l.id),{boxParams:r}=at(l,i,t.pointCloudInstance,g);return r});if(c=M(lt({tool:st.PointCloud,dataList:c,stepConfig:y,action:"viewUpdateBox"})),c.length===1){const{newPolygon:l}=s[0],g=et(c);Q({polygon:l,boxParams:c[0],newPointCloudBoxList:g},F.Single)}else{const l=et(c);l&&n.syncAllViewPointCloudColor(F.MultiMove,l)}},Kt=s=>{var i,c,l,g,r;if(k){const m=Number(s.widthDefault),C=Number(s.depthDefault),S=Number(s.heightDefault),_=k==null?void 0:k.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(q=>(q==null?void 0:q.trackID)===_),B={width:(l=(c=t==null?void 0:t.toolInstance)==null?void 0:c.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},Z=I.pointList.map(q=>O.transferCanvas2World(q,B)),G=w.getModifiedRectangleCoordinates(Z,S,m),H=G[0],it=G[2],Ct=w.getLineCenterPoint([H,it]),$t=k.info.center.z-k.info.depth/2,Pt=A(x({},k.info),{center:{x:Ct.x,y:Ct.y,z:$t+C/2},width:m,height:S,depth:C,valid:!0}),to=et([Pt]);Q({omitView:b["3D"],polygon:I,boxParams:Pt,newPointCloudBoxList:to})}},J=(s,i,c,l,g,r)=>bt(void 0,null,function*(){const m=W==null?void 0:W.url,C={[b.Side]:()=>{St(c,i,d,m,r)},[b.Back]:()=>{p&&_t(c,i,p,m,r)},[b.Top]:()=>{kt(c,i,t,o)}};Object.keys(C).forEach(S=>{S!==s&&C[S]()}),l&&(o==null||o.updateCameraZoom(l)),Et(c)}),Q=(s,i=F.Default)=>{const{omitView:c,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:m}=s,C=W==null?void 0:W.url;m&&n.syncAllViewPointCloudColor(i,m);const S={[b.Side]:()=>{Rt(g,l,d,C)},[b.Back]:()=>{p&&Vt(g,l,p,C)},[b.Top]:()=>{ct(g,l,t,o)}};Object.keys(S).forEach(_=>{_!==c&&S[_]()}),r&&(o==null||o.updateCameraZoom(r))};return{topViewAddSphere:Mt,topViewAddBox:Ht,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:Q,syncPointCloudPoint:J,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=W){var c,l,g,r,m,C,S,_;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(M,!0),vt(M,!0),(c=e==null?void 0:e.setResourceLoading)==null||c.call(e,!0),yield o.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:tt),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],I=[],B=[],Z=[];o.updateTopCamera();const G=(r=(g=rt(i.result))==null?void 0:g.valid)!=null?r:!0;if(n.setPointCloudValid(G),(m=n.sideViewInstance)==null||m.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(v=O.getBoxParamsFromResultList(i.result),(v==null?void 0:v.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(i.url,y,v);const H=rt(i.result);H[no].result=v,i.result=JSON.stringify(H),n.setPointCloudResult(v)}B=O.getPolygonListFromResultList(i.result),I=O.getLineListFromResultList(i.result),Z=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(S=y==null?void 0:y.radius)!=null?S:tt}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(Z),yield n.syncAllViewPointCloudColor(F.Default,v,[])}E({pointCloudBoxList:v,polygonList:B,lineList:I,pointCloudSphereList:Z}),Lt(M,!1),vt(M,!1),(_=e==null?void 0:e.setResourceLoading)==null||_.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:ot,update2DViewRect:Ft,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(xt),d=K(e),p=K(n);return{syncToPointCloudBoxList:ht(()=>{const f=d.current,u=p.current;if(u.length===0)return null;const a=new Map,h=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const L=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let R=a.get(L);R||(R=new Map,a.set(L,R)),R.set(T,V),h.add(L)}),a.size){const P=f.map(L=>{var T;const V=L.id;if(h.has(V)){const R=x({},L);return(T=R.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.get(V))==null?void 0:N.get(z))}),R}return L});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCuboidFromPointCloudBox as l}from"@labelbee/lb-annotation";import{isEqual as
|
|
1
|
+
import{getCuboidFromPointCloudBox as l}from"@labelbee/lb-annotation";import{isEqual as I}from"lodash";var r;(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"})(r||(r={}));var d;(function(t){t.ChangeAttribute="ChangeAttribute",t.Move="Move",t.ChangeDepth="ChangeDepth",t.ChangeSize="ChangeSize",t.ToggleValid="ToggleValid"})(d||(d={}));const A=(t,o)=>{const s=u(t).concat(u(o));for(const e of s){const n=g(t,e),i=g(o,e);if(!y(n,i))return!1}return!0},u=t=>{const o=[];for(let s=0;s<t.length;s++){const e=t[s],n=t[(s+1)%t.length],i={x:n.x-e.x,y:n.y-e.y},c={x:-i.y,y:i.x};o.push(c)}return o},g=(t,o)=>{let s=h(t[0],o),e=s;for(const n of t){const i=h(n,o);i<s&&(s=i),i>e&&(e=i)}return{min:s,max:e}},y=(t,o)=>!(t.max<o.min||o.max<t.min),h=(t,o)=>t.x*o.x+t.y*o.y,M=(t,o)=>{const s=[];return o.forEach(e=>{const{polygonPointList:n}=l(e);A(t,n)&&s.push(e.id)}),s},S=(t,o)=>{const s=t.map(n=>n.id),e=o.map(n=>n.id);return s.find(n=>!e.includes(n))||""},v=(t,o)=>{const s=t.map(e=>e.id);return o.find(e=>!s.includes(e.id))},x=(t,o)=>t.find(e=>{const n=o.find(i=>i.id===e.id);return n&&n.valid!==e.valid}),m=(t,o)=>t.find(e=>{const n=o.find(i=>i.id===e.id);return n&&n.rotation!==e.rotation}),f=(t,o)=>{const{polygonPointList:s}=l(t);return{ids:M(s,o.filter(n=>n.id!==t.id)),rect:s}},D=(t,o)=>{const s=(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&&!s(e,n)){let i;if(n.attribute!==e.attribute?i=d.ChangeAttribute:n.center.x!==e.center.x||n.center.y!==e.center.y?i=d.Move:n.depth!==e.depth?i=d.ChangeDepth:(n.width!==e.width||n.height!==e.height)&&(i=d.ChangeSize),i!==void 0)return{modifiedType:i,box:e}}}},C=(t,o,s)=>{try{switch(t){case r.Single:if(o.length>s.length){const e=S(o,s);return e?{modifiedBoxIds:[e],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}else{const e=[],n=[],i=D(o,s);if(i&&(e.push(i.box.id),i.modifiedType===d.ChangeSize||i.modifiedType===d.Move||i.modifiedType===d.ChangeDepth)){const c=s.find(p=>p.id===i.box.id),{ids:a,rect:B}=f(c,o);e.push(...a),n.push(B)}return{modifiedBoxIds:e,resetAreas:n}}case r.SingleDelete:if(o.length<s.length){const e=v(o,s);if(e){const i=[l(e).polygonPointList],c=[];if(o.length>1){const{ids:a}=f(e,o);a.length&&c.push(...a)}return{modifiedBoxIds:c,resetAreas:i}}return{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case r.SingleRotate:if(m(o,s)){const e=m(o,s);if(e){const n=s.find(a=>a.id===e.id),{ids:i,rect:c}=f(n,o);return{modifiedBoxIds:[e.id,...i],resetAreas:[c]}}}return{modifiedBoxIds:[],resetAreas:[]};case r.SingleToggleValid:if(x(o,s)){const e=x(o,s);return e?{modifiedBoxIds:[e.id],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case r.MulitSelect:return{modifiedBoxIds:V(o,s),resetAreas:[]};case r.MultiPaste:case r.MultiMove:case r.Default:case r.UndoRedo:case r.ClearAll:default:return{modifiedBoxIds:[],resetAreas:[]}}}catch(e){return console.error("calcResetAreasAndBoxIds error:",e),{modifiedBoxIds:[],resetAreas:[]}}},V=(t,o)=>{const s=new Map;for(const e of o)s.set(e.id,e);return t.filter(e=>{const n=s.get(e.id);return!n||!I(e,n)}).map(e=>e.id)};export{r as EPointCloudBoxRenderTrigger,d as EPointCloudBoxSingleModifiedType,C as calcResetAreasAndBoxIds};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.24.0-alpha.
|
|
3
|
+
"version": "1.24.0-alpha.20",
|
|
4
4
|
"description": "Provide a complete library of annotation components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"es": "./es/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ant-design/icons": "^4.6.2",
|
|
46
|
-
"@labelbee/lb-annotation": "1.28.0-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.28.0-alpha.9",
|
|
47
47
|
"@labelbee/lb-utils": "1.20.0-alpha.1",
|
|
48
48
|
"@labelbee/wavesurfer": "1.1.0",
|
|
49
49
|
"@types/react-dom": "18.3.1",
|