@labelbee/lb-components 1.23.0-alpha.61 → 1.23.0-alpha.62
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/pointCloud2DRectOperationView/index.js +1 -1
- package/dist/components/pointCloudView/PointCloudContext.js +1 -1
- package/dist/components/pointCloudView/hooks/useDataLinkSwitch.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/types/components/pointCloudView/hooks/useDataLinkSwitch.d.ts +0 -2
- package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +3 -0
- package/dist/types/utils/index.d.ts +7 -1
- package/dist/utils/index.js +1 -1
- package/es/components/pointCloud2DRectOperationView/index.js +1 -1
- package/es/components/pointCloudView/PointCloudContext.js +1 -1
- package/es/components/pointCloudView/hooks/useDataLinkSwitch.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/utils/index.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}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=(u,i,l)=>i in u?__defProp(u,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[i]=l,__spreadValues=(u,i)=>{for(var l in i||(i={}))__hasOwnProp.call(i,l)&&__defNormalProp(u,l,i[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(i))__propIsEnum.call(i,l)&&__defNormalProp(u,l,i[l]);return u},__spreadProps=(u,i)=>__defProps(u,__getOwnPropDescs(i)),__async=(u,i,l)=>new Promise((a,d)=>{var m=s=>{try{R(l.next(s))}catch(f){d(f)}},h=s=>{try{R(l.throw(s))}catch(f){d(f)}},R=s=>s.done?a(s.value):Promise.resolve(s.value).then(m,h);R((l=l.apply(u,i)).next())});const PointCloud2DRectOperationView=u=>{var i,l;const{mappingData:a,size:d,config:m,checkMode:h,afterImgOnLoad:R,shouldExcludePointCloudBoxListUpdate:s}=u,f=(i=a==null?void 0:a.url)!=null?i:"",D=(l=a==null?void 0:a.fallbackUrl)!=null?l:"",{pointCloudBoxList:P,setPointCloudResult:x,defaultAttribute:C,rectList:y,addRectIn2DView:q,updateRectIn2DView:B,removeRectIn2DView:M,updateRectListByReducer:z}=React.useContext(PointCloudContext.PointCloudContext),{update2DViewRect:A,remove2DViewRect:F}=usePointCloudViews.usePointCloudViews(),O=React__default.default.useRef(null),n=React.useRef(null),L=ahooks.useMemoizedFn(A),b=ahooks.useMemoizedFn(F),I=React.useRef(null),[U,V]=React.useState(!0),E=React.useMemo(()=>y==null?void 0:y.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,y]),w=ahooks.useLatest(a==null?void 0:a.path),S=e=>{const{boxID:o}=e;if(!s&&o){const r=L==null?void 0:L(e);I.current=r,x(r||[]);return}B(e,!0)},N=e=>{w.current&&q(__spreadProps(__spreadValues({},e),{imageName:w.current}))},j=e=>{if(e.length===0)return;if(!s){const r=e.find(t=>t.boxID);if(r){const t=b==null?void 0:b(r);I.current=t,x(t||[]),_();return}}const o=e.find(r=>r.extId);if(o){const{imageName:r,extId:t}=o,c=b==null?void 0:b({boxID:t,imageName:r});I.current=c,x(c
|
|
1
|
+
"use strict";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}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=(u,i,l)=>i in u?__defProp(u,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[i]=l,__spreadValues=(u,i)=>{for(var l in i||(i={}))__hasOwnProp.call(i,l)&&__defNormalProp(u,l,i[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(i))__propIsEnum.call(i,l)&&__defNormalProp(u,l,i[l]);return u},__spreadProps=(u,i)=>__defProps(u,__getOwnPropDescs(i)),__async=(u,i,l)=>new Promise((a,d)=>{var m=s=>{try{R(l.next(s))}catch(f){d(f)}},h=s=>{try{R(l.throw(s))}catch(f){d(f)}},R=s=>s.done?a(s.value):Promise.resolve(s.value).then(m,h);R((l=l.apply(u,i)).next())});const PointCloud2DRectOperationView=u=>{var i,l;const{mappingData:a,size:d,config:m,checkMode:h,afterImgOnLoad:R,shouldExcludePointCloudBoxListUpdate:s}=u,f=(i=a==null?void 0:a.url)!=null?i:"",D=(l=a==null?void 0:a.fallbackUrl)!=null?l:"",{pointCloudBoxList:P,setPointCloudResult:x,defaultAttribute:C,rectList:y,addRectIn2DView:q,updateRectIn2DView:B,removeRectIn2DView:M,updateRectListByReducer:z}=React.useContext(PointCloudContext.PointCloudContext),{update2DViewRect:A,remove2DViewRect:F}=usePointCloudViews.usePointCloudViews(),O=React__default.default.useRef(null),n=React.useRef(null),L=ahooks.useMemoizedFn(A),b=ahooks.useMemoizedFn(F),I=React.useRef(null),[U,V]=React.useState(!0),E=React.useMemo(()=>y==null?void 0:y.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,y]),w=ahooks.useLatest(a==null?void 0:a.path),S=e=>{const{boxID:o}=e;if(!s&&o){const r=L==null?void 0:L(e);I.current=r,x(r||[]);return}B(e,!0)},N=e=>{w.current&&q(__spreadProps(__spreadValues({},e),{imageName:w.current}))},j=e=>{if(e.length===0)return;if(!s){const r=e.find(t=>t.boxID);if(r){const t=b==null?void 0:b(r);I.current=t,x(t||[]),_();return}}const o=e.find(r=>r.extId);if(o){const{imageName:r,extId:t}=o,c=b==null?void 0:b({boxID:t,imageName:r});c&&(I.current=c,x(c))}M(e)},k=ahooks.useMemoizedFn(()=>{let e=[];return P.forEach(o=>{const{rects:r=[],id:t,attribute:c,trackID:v}=o,p=r.find(J=>J.imageName===w.current),g=t+"_"+w.current;p&&(e=[...e,__spreadProps(__spreadValues({},p),{boxID:t,id:g,attribute:c,order:v})])}),e}),_=ahooks.useMemoizedFn(()=>{var e,o,r;const t=s?[]:k(),c=(e=n.current)==null?void 0:e.selectedRectID;(o=n.current)==null||o.setResult([...t,...E]),c&&((r=n.current)==null||r.setSelectedRectID(c))});return React.useEffect(()=>{if(O.current){const e=new lbAnnotation.PointCloud2DRectOperation({container:O.current,size:d,config:__spreadProps(__spreadValues({},m),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:h});return n.current=e,n.current.init(),n.current.on("updateDragResult",S),n.current.on("afterAddingDrawingRect",N),n.current.on("deleteSelectedRects",j),()=>{var o,r,t,c;(o=n.current)==null||o.unbind("updateDragResult",S),(r=n.current)==null||r.unbind("afterAddingDrawingRect",N),(t=n.current)==null||t.unbind("deleteSelectedRects",j),(c=n.current)==null||c.destroy()}}},[]),React.useEffect(()=>{const e=r=>__async(void 0,null,function*(){try{return yield lbAnnotation.ImgUtils.load(r)}catch(t){return console.error("Error loading image:",t),null}}),o=()=>__async(void 0,null,function*(){var r;V(!0);let t=yield e(f);!t&&D&&(t=yield e(D)),t&&((r=n.current)==null||r.setImgNode(t),R(t)),V(!1)});n.current&&(f||D)&&o()},[f,D]),React.useEffect(()=>{var e;(e=n.current)==null||e.setSize(d)},[d]),React.useEffect(()=>{P!==I.current&&_()},[P]),React.useEffect(()=>{var e,o;const r=E.find(t=>t.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,C),r&&z(t=>{var c;const v=[];let p=null;return t.forEach(g=>{g.id!==n.current.selectedRectID?v.push(g):p=g}),r.extId===void 0&&(p=(c=n.current)==null?void 0:c.selectedRect),[...v,__spreadProps(__spreadValues({},p||{}),{attribute:C})]}),_()},[C]),React.useEffect(()=>{_()},[E]),React.useEffect(()=>{_()},[s]),React.useEffect(()=>{var e,o,r,t;const c=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},v=__spreadProps(__spreadValues({},c),{attributeList:(r=m.attributeList)!=null?r:[]});(t=n.current)==null||t.setConfig(JSON.stringify(v))},[m.attributeList]),React__default.default.createElement(es.Spin,{spinning:U},React__default.default.createElement("div",{ref:O,style:__spreadValues({position:"relative"},d)}))};var PointCloud2DRectOperationView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DRectOperationView);module.exports=PointCloud2DRectOperationView$1;
|
|
@@ -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");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,o,a)=>o in r?__defProp(r,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[o]=a,__spreadValues=(r,o)=>{for(var a in o||(o={}))__hasOwnProp.call(o,a)&&__defNormalProp(r,a,o[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(o))__propIsEnum.call(o,a)&&__defNormalProp(r,a,o[a]);return r},__spreadProps=(r,o)=>__defProps(r,__getOwnPropDescs(o)),__async=(r,o,a)=>new Promise((w,D)=>{var A=c=>{try{P(a.next(c))}catch(x){D(x)}},H=c=>{try{P(a.throw(c))}catch(x){D(x)}},P=c=>c.done?w(c.value):Promise.resolve(c.value).then(A,H);P((a=a.apply(r,o)).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:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:r=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:r=>!1,removeRectBySpecifyId:(r,o,a)=>!1,removeRectByPointCloudBoxId:r=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{}}),PointCloudProvider=({children:r})=>{const[o,a]=React.useState([]),[w,D]=React.useState([]),[A,H]=React.useState([]),[P,c]=React.useState([]),[x,be]=React.useState([]),[h,j]=React.useState([]),[B,k]=React.useState([]),[U,xe]=React.useState(!0),[J,ye]=React.useState(2),[K,Re]=React.useState(!0),[Q,we]=React.useState(1),[f,X]=React.useState(),[Y,$]=React.useState(),[ee,te]=React.useState(),[u,oe]=React.useState(),[ne,Le]=React.useState(""),[q,De]=React.useState(lbAnnotation.EToolName.Rect),F=React.useRef(new lbAnnotation.ActionsHistory).current,[p,T]=React.useState([]),[ie,Ae]=React.useState(""),[z,Be]=React.useState(lbUtils.EPointCloudPattern.Detection),[L,se]=React.useState(void 0),[G,_e]=React.useState([]),[W,Ve]=React.useState([]),m=index(),[re,Ne]=React.useState({}),Me=ctx.useDispatch(),Oe=n=>{const{imgNode:i,path:t}=n;t&&i&&Ne(d=>__spreadProps(__spreadValues({},d),{[t]:{width:i.width,height:i.height}}))},le=React.useMemo(()=>h.length===1?h[0]:"",[h]),N=React.useCallback((n,i,t="extId")=>{const d=t||"id",l=new Set(i);return c(g=>{let y=!1;const R=g.filter(O=>{const Z=O[d],E=l.has(Z)?O.imageName!==n:!0;return E||(y=!0),E});return y?R:g}),!0},[]),ae=React.useCallback(n=>{const i=o.map(t=>t.id);return N(n,i,"extId")},[o,N]),de=React.useCallback(n=>{if(!n)return!1;const i=o.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:d,attribute:l,trackID:g}=t,y=t.rects.find(R=>R.imageName===n);if(y){const R=___default.default.pick(y,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},R),{id:lbAnnotation.uuid(),attribute:l,order:g,extId:d,lineDash:[]})}return null}).filter(t=>t!==null);return i.length?(c(t=>{const d=new Set(t.filter(g=>n===g.imageName).map(g=>g.extId)),l=i.filter(g=>d.has(g.extId)===!1);return l.length?[...t,...l]:t}),!0):!1},[o]),ce=React.useMemo(()=>o.filter(i=>Array.isArray(i.rects)&&i.rects.length>0).reduce((i,t)=>{var d;return(d=t.rects)==null||d.forEach(l=>{const{imageName:g}=l;if(!g){console.warn("Missing image name"),console.trace(l,t);return}map.addMapIndirectWeakSetItem(i,g,t.id,t)}),i},new Map),[o]),ue=React.useCallback(n=>{c(i=>n(i,pickRectObject))},[pickRectObject]),ge=React.useMemo(()=>P.filter(n=>n.extId!==void 0&&n.id!==void 0).reduce((n,i)=>{const t=i.imageName;return t?(map.addMapIndirectWeakSetItem(n,t,i.extId,i),n):(console.warn("missing image name"),console.log(i,P),n)},new Map),[P]),M=React.useMemo(()=>{const n=o.find(e=>e.id===le),i=e=>{const s=o.concat(e);return a(s),s},t=e=>{const s=w.concat(e);return D(s),s},d=e=>{xe(e!==!1)},l=e=>{e===void 0&&j([]),typeof e=="string"&&j([e]),Array.isArray(e)&&j(Array.from(new Set(e)))},g=e=>{h.includes(e)?l(h.filter(s=>s!==e)):l([...h,e])},y=e=>{const s=pickRectObject(e);c(v=>[...v,s])},R=(e,s=!1)=>{const v=pickRectObject(e);c(I=>I.map(S=>S.id===e.id?s?__spreadValues(__spreadValues({},S),v):v:S))},O=e=>{c(s=>s.filter(v=>!e.find(I=>I.id===v.id)))},Z=e=>{B.includes(e)?k([]):k([e])},E=()=>{if(q===lbAnnotation.EToolName.Rect){const e=o.map(s=>s.id);l(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},He=e=>{l(o.filter(s=>s.attribute===e).map(s=>s.id))},fe=o.filter(e=>!p.includes(e.attribute)),pe=w.filter(e=>!p.includes(e.attribute)),me=x.filter(e=>e.attribute&&!p.includes(e.attribute)),je=e=>{if(p.includes(e))T(p.filter(s=>s!==e));else{const s=p.concat(e);T(s)}},ke=(e=fe,s=A,v=pe,I=me,S=G)=>{var V;u==null||u.clearAllBox(),u==null||u.clearAllSphere(),f==null||f.updatePolygonList(e,s),f==null||f.updatePointList(v),f==null||f.updateLineList(I),u==null||u.generateBoxes(e),u==null||u.generateSpheres(v),(V=L==null?void 0:L.store)==null||V.updateCurrentSegment(S),ve(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},qe=()=>{X(void 0),$(void 0),te(void 0),oe(void 0)},ve=(e,s,v)=>__async(void 0,null,function*(){var I,S,V;if(!u)return;const he=u.pointCloudObject;if(!he)return;let Pe=[],Ie=[];try{if(s&&F.record.length){const{record:C,recordIndex:b}=F;let Se=b;b>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&s.length===((I=C[b])==null?void 0:I.pointCloudBoxList.length))&&(Se=b-1);let Fe=(S=C[Se])==null?void 0:S.pointCloudBoxList;const Ce=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,s,Fe);Pe=Ce.modifiedBoxIds,Ie=Ce.resetAreas}}catch(C){console.error("call calcResetAreasAndBoxIds error",C)}try{const C=yield u.getHighlightIndexByMappingImgList({mappingImgList:v!=null?v:W,points:he.geometry.attributes.position.array}),b=yield u==null?void 0:u.highlightOriginPointCloud(s,C,{modifiedBoxIds:Pe,resetAreas:Ie});return b&&((V=f==null?void 0:f.pointCloudInstance)==null||V.updateColor(b)),b}catch(C){console.error("call highlightOriginPointCloud error",C)}});return{selectedID:le,pointCloudBoxList:o,pointCloudSphereList:w,displayPointCloudList:fe,displaySphereList:pe,displayLineList:me,selectedIDs:h,setPointCloudResult:a,setSelectedIDs:l,addPointCloudBox:i,addPointCloudSphere:t,setPointCloudSphereList:D,valid:U,selectedPointCloudBox:n,setPointCloudValid:d,addSelectedID:g,addHighlightID:Z,selectedAllBoxes:E,topViewInstance:f,setTopViewInstance:X,sideViewInstance:Y,setSideViewInstance:$,backViewInstance:ee,setBackViewInstance:te,mainViewInstance:u,setMainViewInstance:oe,polygonList:A,setPolygonList:H,rectList:P,setRectList:c,addRectIn2DView:y,removeRectIn2DView:O,updateRectIn2DView:R,lineList:x,setLineList:be,zoom:Q,setZoom:we,history:F,toggleAttributesVisible:je,hideAttributes:p,setHideAttributes:T,reRender:ke,attrPanelLayout:ie,setAttrPanelLayout:Ae,syncAllViewPointCloudColor:ve,defaultAttribute:ne,setDefaultAttribute:Le,pointCloudPattern:q,setPointCloudPattern:De,selectSpecAttr:He,globalPattern:z,setGlobalPattern:e=>{z!==e&&(Me(actionCreators.ChangeSave),Be(e),e===lbUtils.EPointCloudPattern.Detection&&se(void 0))},ptSegmentInstance:L,setPtSegmentInstance:se,segmentation:G,setSegmentation:_e,clearAllDetectionInstance:qe,highlight2DDataList:W,setHighlight2DDataList:Ve,cuboidBoxIn2DView:K,setCuboidBoxIn2DView:Re,imageSizes:re,cacheImageNodeSize:Oe,highlightIDs:B,setHighlightIDs:k,removeRectByPointCloudBoxId:ae,removeRectBySpecifyId:N,addRectFromPointCloudBoxByImageName:de,rectRotateSensitivity:J,setRectRotateSensitivity:ye,imageNamePointCloudBoxMap:ce,linkageImageNameRectMap:ge,updateRectListByReducer:ue}},[U,h,o,w,A,x,P,f,Y,ee,u,Q,p,ie,ne,q,z,L,G,W,K,re,B,ae,N,de,J,ce,ge,ue]);React.useEffect(()=>{var n,i,t;(n=m==null?void 0:m.setPointCloudBoxList)==null||n.call(m,o),(i=m==null?void 0:m.setHighlightIDs)==null||i.call(m,B),(t=m==null?void 0:m.setSelectedIDs)==null||t.call(m,h)},[o,h,B]),React.useEffect(()=>{var n;(n=m==null?void 0:m.setPtCtx)==null||n.call(m,M)},[M]);const Ee=()=>{const n=o.filter(l=>p.includes(l.attribute)),{setSelectedIDs:i,reRender:t}=M,d=n.map(l=>l.id);d.length>0&&i(h.filter(l=>!d.includes(l))),t()};return React.useEffect(()=>{var n,i,t,d;Ee(),(i=(n=f==null?void 0:f.toolInstance)==null?void 0:n.setHiddenAttributes)==null||i.call(n,p),(d=(t=L==null?void 0:L.store)==null?void 0:t.setHiddenAttributes)==null||d.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");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,o,a)=>o in r?__defProp(r,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[o]=a,__spreadValues=(r,o)=>{for(var a in o||(o={}))__hasOwnProp.call(o,a)&&__defNormalProp(r,a,o[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(o))__propIsEnum.call(o,a)&&__defNormalProp(r,a,o[a]);return r},__spreadProps=(r,o)=>__defProps(r,__getOwnPropDescs(o)),__async=(r,o,a)=>new Promise((w,D)=>{var A=c=>{try{P(a.next(c))}catch(x){D(x)}},j=c=>{try{P(a.throw(c))}catch(x){D(x)}},P=c=>c.done?w(c.value):Promise.resolve(c.value).then(A,j);P((a=a.apply(r,o)).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:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:r=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:r=>!1,removeRectBySpecifyId:(r,o,a)=>!1,removeRectByPointCloudBoxId:r=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{}}),PointCloudProvider=({children:r})=>{const[o,a]=React.useState([]),[w,D]=React.useState([]),[A,j]=React.useState([]),[P,c]=React.useState([]),[x,be]=React.useState([]),[h,k]=React.useState([]),[B,q]=React.useState([]),[U,xe]=React.useState(!0),[J,ye]=React.useState(2),[K,Re]=React.useState(!0),[Q,we]=React.useState(1),[f,X]=React.useState(),[Y,$]=React.useState(),[ee,te]=React.useState(),[u,oe]=React.useState(),[ne,Le]=React.useState(""),[F,De]=React.useState(lbAnnotation.EToolName.Rect),T=React.useRef(new lbAnnotation.ActionsHistory).current,[p,z]=React.useState([]),[ie,Ae]=React.useState(""),[G,Be]=React.useState(lbUtils.EPointCloudPattern.Detection),[L,se]=React.useState(void 0),[W,_e]=React.useState([]),[Z,Ve]=React.useState([]),v=index(),[re,Ne]=React.useState({}),Me=ctx.useDispatch(),Oe=n=>{const{imgNode:i,path:t}=n;t&&i&&Ne(d=>__spreadProps(__spreadValues({},d),{[t]:{width:i.width,height:i.height}}))},le=React.useMemo(()=>h.length===1?h[0]:"",[h]),N=React.useCallback((n,i,t="extId")=>{const d=t||"id",l=new Set(i);return c(g=>{let y=!1;const R=g.filter(O=>{const E=O[d],H=E!==void 0||l.has(E)?O.imageName!==n:!0;return H||(y=!0),H});return y?R:g}),!0},[]),ae=React.useCallback(n=>{const i=o.map(t=>t.id);return N(n,i,"extId")},[o,N]),de=React.useCallback(n=>{if(!n)return!1;const i=o.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:d,attribute:l,trackID:g}=t,y=t.rects.find(R=>R.imageName===n);if(y){const R=___default.default.pick(y,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},R),{id:lbAnnotation.uuid(),attribute:l,order:g,extId:d,lineDash:[]})}return null}).filter(t=>t!==null);return i.length?(c(t=>{const d=new Set(t.filter(g=>n===g.imageName).map(g=>g.extId)),l=i.filter(g=>d.has(g.extId)===!1);return l.length?[...t,...l]:t}),!0):!1},[o]),ce=React.useMemo(()=>o.filter(i=>Array.isArray(i.rects)&&i.rects.length>0).reduce((i,t)=>{var d;return(d=t.rects)==null||d.forEach(l=>{const{imageName:g}=l;if(!g){console.warn("Missing image name"),console.trace(l,t);return}map.addMapIndirectWeakSetItem(i,g,t.id,t)}),i},new Map),[o]),ue=React.useCallback(n=>{c(i=>n(i,pickRectObject))},[pickRectObject]),ge=React.useMemo(()=>P.filter(n=>n.extId!==void 0&&n.id!==void 0).reduce((n,i)=>{const t=i.imageName;return t?(map.addMapIndirectWeakSetItem(n,t,i.extId,i),n):(console.warn("missing image name"),console.log(i,P),n)},new Map),[P]),M=React.useMemo(()=>{const n=o.find(e=>e.id===le),i=e=>{const s=o.concat(e);return a(s),s},t=e=>{const s=w.concat(e);return D(s),s},d=e=>{xe(e!==!1)},l=e=>{e===void 0&&k([]),typeof e=="string"&&k([e]),Array.isArray(e)&&k(Array.from(new Set(e)))},g=e=>{h.includes(e)?l(h.filter(s=>s!==e)):l([...h,e])},y=e=>{const s=pickRectObject(e);c(m=>[...m,s])},R=(e,s=!1)=>{const m=pickRectObject(e);c(I=>I.map(S=>S.id===e.id?s?__spreadValues(__spreadValues({},S),m):m:S))},O=e=>{c(s=>s.filter(m=>!e.find(I=>I.id===m.id)))},E=e=>{B.includes(e)?q([]):q([e])},H=()=>{if(F===lbAnnotation.EToolName.Rect){const e=o.map(s=>s.id);l(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},He=e=>{l(o.filter(s=>s.attribute===e).map(s=>s.id))},fe=o.filter(e=>!p.includes(e.attribute)),pe=w.filter(e=>!p.includes(e.attribute)),ve=x.filter(e=>e.attribute&&!p.includes(e.attribute)),je=e=>{if(p.includes(e))z(p.filter(s=>s!==e));else{const s=p.concat(e);z(s)}},ke=(e=fe,s=A,m=pe,I=ve,S=W)=>{var V;u==null||u.clearAllBox(),u==null||u.clearAllSphere(),f==null||f.updatePolygonList(e,s),f==null||f.updatePointList(m),f==null||f.updateLineList(I),u==null||u.generateBoxes(e),u==null||u.generateSpheres(m),(V=L==null?void 0:L.store)==null||V.updateCurrentSegment(S),me(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},qe=()=>{X(void 0),$(void 0),te(void 0),oe(void 0)},me=(e,s,m)=>__async(void 0,null,function*(){var I,S,V;if(!u)return;const he=u.pointCloudObject;if(!he)return;let Pe=[],Ie=[];try{if(s&&T.record.length){const{record:C,recordIndex:b}=T;let Se=b;b>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&s.length===((I=C[b])==null?void 0:I.pointCloudBoxList.length))&&(Se=b-1);let Fe=(S=C[Se])==null?void 0:S.pointCloudBoxList;const Ce=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,s,Fe);Pe=Ce.modifiedBoxIds,Ie=Ce.resetAreas}}catch(C){console.error("call calcResetAreasAndBoxIds error",C)}try{const C=yield u.getHighlightIndexByMappingImgList({mappingImgList:m!=null?m:Z,points:he.geometry.attributes.position.array}),b=yield u==null?void 0:u.highlightOriginPointCloud(s,C,{modifiedBoxIds:Pe,resetAreas:Ie});return b&&((V=f==null?void 0:f.pointCloudInstance)==null||V.updateColor(b)),b}catch(C){console.error("call highlightOriginPointCloud error",C)}});return{selectedID:le,pointCloudBoxList:o,pointCloudSphereList:w,displayPointCloudList:fe,displaySphereList:pe,displayLineList:ve,selectedIDs:h,setPointCloudResult:a,setSelectedIDs:l,addPointCloudBox:i,addPointCloudSphere:t,setPointCloudSphereList:D,valid:U,selectedPointCloudBox:n,setPointCloudValid:d,addSelectedID:g,addHighlightID:E,selectedAllBoxes:H,topViewInstance:f,setTopViewInstance:X,sideViewInstance:Y,setSideViewInstance:$,backViewInstance:ee,setBackViewInstance:te,mainViewInstance:u,setMainViewInstance:oe,polygonList:A,setPolygonList:j,rectList:P,setRectList:c,addRectIn2DView:y,removeRectIn2DView:O,updateRectIn2DView:R,lineList:x,setLineList:be,zoom:Q,setZoom:we,history:T,toggleAttributesVisible:je,hideAttributes:p,setHideAttributes:z,reRender:ke,attrPanelLayout:ie,setAttrPanelLayout:Ae,syncAllViewPointCloudColor:me,defaultAttribute:ne,setDefaultAttribute:Le,pointCloudPattern:F,setPointCloudPattern:De,selectSpecAttr:He,globalPattern:G,setGlobalPattern:e=>{G!==e&&(Me(actionCreators.ChangeSave),Be(e),e===lbUtils.EPointCloudPattern.Detection&&se(void 0))},ptSegmentInstance:L,setPtSegmentInstance:se,segmentation:W,setSegmentation:_e,clearAllDetectionInstance:qe,highlight2DDataList:Z,setHighlight2DDataList:Ve,cuboidBoxIn2DView:K,setCuboidBoxIn2DView:Re,imageSizes:re,cacheImageNodeSize:Oe,highlightIDs:B,setHighlightIDs:q,removeRectByPointCloudBoxId:ae,removeRectBySpecifyId:N,addRectFromPointCloudBoxByImageName:de,rectRotateSensitivity:J,setRectRotateSensitivity:ye,imageNamePointCloudBoxMap:ce,linkageImageNameRectMap:ge,updateRectListByReducer:ue}},[U,h,o,w,A,x,P,f,Y,ee,u,Q,p,ie,ne,F,G,L,W,Z,K,re,B,ae,N,de,J,ce,ge,ue]);React.useEffect(()=>{var n,i,t;(n=v==null?void 0:v.setPointCloudBoxList)==null||n.call(v,o),(i=v==null?void 0:v.setHighlightIDs)==null||i.call(v,B),(t=v==null?void 0:v.setSelectedIDs)==null||t.call(v,h)},[o,h,B]),React.useEffect(()=>{var n;(n=v==null?void 0:v.setPtCtx)==null||n.call(v,M)},[M]);const Ee=()=>{const n=o.filter(l=>p.includes(l.attribute)),{setSelectedIDs:i,reRender:t}=M,d=n.map(l=>l.id);d.length>0&&i(h.filter(l=>!d.includes(l))),t()};return React.useEffect(()=>{var n,i,t,d;Ee(),(i=(n=f==null?void 0:f.toolInstance)==null?void 0:n.setHiddenAttributes)==null||i.call(n,p),(d=(t=L==null?void 0:L.store)==null?void 0:t.setHiddenAttributes)==null||d.call(t,p)},[p]),React__default.default.createElement(PointCloudContext.Provider,{value:M},r)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var React=require("react"),ahooks=require("ahooks"),PointCloudContext=require("../PointCloudContext.js"),icon_link=require("../../../assets/annotation/icon_link.svg.js"),icon_unlink=require("../../../assets/annotation/icon_unlink.svg.js"),BatchSwitchConnectIn2DView=require("../../../views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.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);const iconSize={width:16,height:16},useDataLinkSwitch=e=>{e.imageName||console.warn("missing imageName");const[i,
|
|
1
|
+
"use strict";var React=require("react"),ahooks=require("ahooks"),PointCloudContext=require("../PointCloudContext.js"),icon_link=require("../../../assets/annotation/icon_link.svg.js"),icon_unlink=require("../../../assets/annotation/icon_unlink.svg.js"),BatchSwitchConnectIn2DView=require("../../../views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js"),lbAnnotation=require("@labelbee/lb-annotation"),usePointCloudViews=require("./usePointCloudViews.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);const useShownIcon=e=>{const{imageNamePointCloudBoxMap:i,linkageImageNameRectMap:s}=React.useContext(PointCloudContext.PointCloudContext),o=React.useMemo(()=>e?i.has(e):(console.error("Missing image name"),!1),[e,i]),a=React.useMemo(()=>{var c,l;return e?((l=(c=s.get(e))==null?void 0:c.size)!=null?l:0)>0:!1},[s,e]),r=React.useMemo(()=>o||a,[o,a]),m=ahooks.useLatest(r);return{visible:r,visibleRef:m}},iconSize={width:16,height:16},useDataLinkSwitch=e=>{e.imageName||console.warn("missing imageName");const[i,s]=React.useState(!0),o=ahooks.useLatest(e.imageName),{addRectFromPointCloudBoxByImageName:a,removeRectByPointCloudBoxId:r,imageNamePointCloudBoxMap:m,linkageImageNameRectMap:c,rectList:l}=React.useContext(PointCloudContext.PointCloudContext),{visible:g,visibleRef:C}=useShownIcon(e.imageName),{syncToPointCloudBoxList:h}=usePointCloudViews.useSyncRectPositionDimensionToPointCloudList(),I=ahooks.useLatest(a),w=ahooks.useLatest(r),k=ahooks.useLatest(()=>{h()}),d=React.useCallback(n=>{if(!C.current)return;const t=o.current;if(!t){console.warn("invalid image name");return}s(n),n?w.current(t):I.current(t)},[]),b=ahooks.useLatest(n=>{console.log(n),d(n),n&&k.current()}),x=React.useMemo(()=>{var n;if(!e.is2DView||!g)return null;const u={zIndex:(n=e.zIndex)!=null?n:999,position:"absolute",top:16,right:16+28+12,background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28};return React__default.default.createElement("div",{style:u},i&&React__default.default.createElement("img",{src:icon_link,style:iconSize}),!i&&React__default.default.createElement("img",{src:icon_unlink,style:iconSize}))},[i,e.is2DView,e.zIndex,g]),R=ahooks.useLatest(c),f=React.useCallback(()=>{var n,t;if(!e.is2DView)return;const u=o.current;if(!u){console.warn("invalid image name");return}const L=[...(t=(n=R.current.get(u))==null?void 0:n.keys())!=null?t:[]];let v=!0;L.length&&(v=!1),d(v)},[e.is2DView,d]);return React.useEffect(()=>{f()},[f]),React.useEffect(()=>{const n=t=>{b.current(t)};return lbAnnotation.EventBus.on(BatchSwitchConnectIn2DView.EventBusEvent.switchConnect,n),()=>lbAnnotation.EventBus.unbind(BatchSwitchConnectIn2DView.EventBusEvent.switchConnect,n)},[]),{rendered:x,isLinking:i}};module.exports=useDataLinkSwitch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),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=(e,t,s)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,__spreadValues=(e,t)=>{for(var s in t||(t={}))__hasOwnProp.call(t,s)&&__defNormalProp(e,s,t[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(t))__propIsEnum.call(t,s)&&__defNormalProp(e,s,t[s]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,s)=>new Promise((a,o)=>{var u=p=>{try{c(s.next(p))}catch(h){o(h)}},P=p=>{try{c(s.throw(p))}catch(h){o(h)}},c=p=>p.done?a(p.value):Promise.resolve(p.value).then(u,P);c((s=s.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,s,a,o)=>{const{x:u,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,p={center:{x:u,y:P,z:c},id:e.id},h=a?__spreadValues(__spreadValues({},a),p):__spreadProps(__spreadValues({},p),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},topViewPolygon2PointCloud=(e,t,s,a,o,u)=>{let P=e.pointList.map(m=>lbUtils.PointCloudUtils.transferCanvas2World(m,t)),c=0,p=1,h={};if(s){const m=s.getSensesPointZAxisInPolygon(P,void 0,u);u&&m.fittedCoordinates.length>0&&(P=m.fittedCoordinates),c=(m.maxZ+m.minZ)/2,p=m.maxZ-m.minZ,h={count:m.zCount}}const[y,b,z]=P,D=lbAnnotation.MathUtils.getLineCenterPoint([y,z]),U=lbAnnotation.MathUtils.getLineLength(y,b),O=lbAnnotation.MathUtils.getLineLength(b,z),I=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(c=a.center.z,p=a.depth);const V={center:{x:D.x,y:D.y,z:c},width:u?O+INTELLIGENT_FIT_MARGIN:O,height:u?U+INTELLIGENT_FIT_MARGIN:U,depth:p,rotation:I,id:e.id},_=__spreadValues(a?__spreadValues(__spreadValues({},a),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),h);o&&Object.assign(_,o);const k=P.map(m=>lbUtils.PointCloudUtils.transferWorld2Canvas(m,t));return{boxParams:_,newPointList:k}},sideViewPoint2PointCloud=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x-a.x,y:s.center.y,z:s.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,s,a)=>{const[o,u,P]=e.pointList,[c,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),D={x:{x:y.x-b.x,y:y.y-b.y}.x,y:0,z:y.y-b.y},U=lbAnnotation.MathUtils.getLineLength(o,u),O=lbAnnotation.MathUtils.getLineLength(c,p),I=U-O,V=lbAnnotation.MathUtils.getLineLength(u,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_,{newBoxParams:m}=a.getNewBoxBySideUpdate(D,k,I,s);return m},backViewPoint2PointCloud=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x,y:s.center.y-a.x,z:s.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,s,a)=>{const[o,u,P]=e.pointList,[c,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),D={x:{x:y.x-b.x,y:y.y-b.y}.x,y:0,z:y.y-b.y},U=lbAnnotation.MathUtils.getLineLength(o,u),O=lbAnnotation.MathUtils.getLineLength(c,p),I=U-O,V=lbAnnotation.MathUtils.getLineLength(u,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_;let{newBoxParams:m}=a.getNewBoxByBackUpdate(D,k,I,s);return m},syncSideViewByPoint=(e,t,s,a,o)=>{var u;if(!s)return;const{toolInstance:P,pointCloudInstance:c}=s;c.loadPCDFile(a,(u=o==null?void 0:o.radius)!=null?u:DEFAULT_RADIUS);const{cameraPositionVector:p}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(p);const{point2d:h,zoom:y}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=y,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:u}=s;u.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=u.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);u.setInitCameraPosition(P);const{polygon2d:c,zoom:p}=u.getBoxSidePolygon2DCoordinate(e);u.camera.zoom=p,u.camera.updateProjectionMatrix(),u.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,s,a,o)=>{var u;if(!s)return;const{toolInstance:P,pointCloudInstance:c}=s;c.loadPCDFile(a,(u=o==null?void 0:o.radius)!=null?u:DEFAULT_RADIUS);const{cameraPositionVector:p}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(p);const{point2d:h,zoom:y}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=y,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:u}=s;u.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=u.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);u.setInitCameraPosition(P);const{polygon2d:c,zoom:p}=u.getBoxBackPolygon2DCoordinate(e);u.camera.zoom=p,u.camera.updateProjectionMatrix(),u.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,s,a)=>{if(!s||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:u}=s,{point2d:P}=u.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(p=>p.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(c),o.setSelectedID(t.id)},synchronizeTopView=(e,t,s,a)=>{var o,u;if(!s||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=s,{polygon2d:p}=c.getBoxTopPolygon2DCoordinate(e),h=[...P.polygonList],y=h.find(b=>b.id===t.id);y?(y.pointList=p,y.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(u=e.valid)!=null?u:!0}),P.setResultAndSelectedID(h,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:s,backViewInstance:a,mainViewInstance:o,addPointCloudBox:u,addPointCloudSphere:P,setSelectedIDs:c,selectedIDs:p,pointCloudBoxList:h,pointCloudSphereList:y,hideAttributes:b,setHighlight2DDataList:z,cuboidBoxIn2DView:D,imageSizes:U,history:O}=e,{addHistory:I,initHistory:V,pushHistoryUnderUpdatePolygon:_}=useHistory.useHistory(),{selectedPolygon:k}=usePolygon.usePolygon(),{getPointCloudSphereByID:m,updatePointCloudSphere:X,selectedSphere:N}=useSphere.useSphere(),{currentData:j,config:L}=ctx.useSelector(n=>{const{stepList:i,step:d,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(d,i).config)}}),A=ctx.useDispatch(),ot=ahooks.useLatest(D),W=n=>{const{enableAutoMap2DRect:i=!1}=L;if(!ot.current||i){const{mappingImgList:d=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:n,mappingImgList:d,imageSizes:U})}},{selectedBox:S,updateSelectedBox:et,updateSelectedBoxes:Z,getPointCloudByID:it}=useSingleBox.useSingleBox({generateRects:W}),Y=S==null?void 0:S.info;if(!t||!s||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,nt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},st=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},rt=({newPoint:n,size:i,zoom:d,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:y})});const f=topViewPoint2PointCloud(n,i,G,void 0,g);c(n.id);const C=P(f);H(PointCloudView.Top,n,f,d,C,L),I({newSphereParams:f})},lt=({polygon:n,size:i,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var f,C,x;const w={attribute:(f=t.toolInstance.defaultAttribute)!=null?f:""};r===!0&&Object.assign(w,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:y})});const T=t==null?void 0:t.toolInstance,B=__spreadValues({},n);let{boxParams:v,newPointList:R}=topViewPolygon2PointCloud(B,i,G,void 0,w,g);v=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[v],stepConfig:L,action:"viewUpdateBox"}))[0],g&&(R==null?void 0:R.length)&&(B.pointList=R);const Q=b.includes(B.attribute);W(v);const E=u(v),q=(C=e==null?void 0:e.polygonList)!=null?C:[];v.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((L==null?void 0:L.secondaryAttributeConfigurable)?(x=L==null?void 0:L.inputList)!=null?x:[]:[]),t==null||t.updatePolygonList(E!=null?E:[],q),Q?c([]):(c(v.id),T.selection.setSelectedIDs(B.id),M({omitView:PointCloudView.Top,polygon:B,boxParams:v,zoom:l,newPointCloudBoxList:E}),g&&synchronizeTopView(v,B,t,o)),I({newBoxParams:v})},dt=n=>{const{boxID:i,imageName:d,width:r,height:l,x:g,y:f}=n,C=h.find(v=>v.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(v=>v.imageName===d))return;const w=C.rects.map(v=>v.imageName===d?__spreadProps(__spreadValues({},v),{width:r,height:l,x:g,y:f}):v),T=__spreadProps(__spreadValues({},C),{rects:w}),B=h.map(v=>v.id===i?T:v);return t==null||t.updatePolygonList(B!=null?B:[]),B},at=n=>{const{boxID:i,imageName:d}=n,r=h.find(C=>C.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(C=>C.imageName!==d),g=__spreadProps(__spreadValues({},r),{rects:l}),f=h.map(C=>C.id===i?g:C);return t==null||t.updatePolygonList(f!=null?f:[]),f},ut=({newSelectedBox:n,newPointCloudList:i,newSelectedSphere:d,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(p.length===0||!g)){if(n||(S==null?void 0:S.info)){const f=n!=null?n:S==null?void 0:S.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(p[0]);const C=g.selectedPolygon;if(p.length===1&&f){M({omitView:PointCloudView.Top,polygon:C,boxParams:f,newPointCloudBoxList:i});return}}if((d||N)&&p.length===1){const f=d!=null?d:N;g.setSelectedID(p[0]);const C=g.selectedPoint;f&&H(PointCloudView.Top,C,f,void 0,r,L)}}},K=(n,i,d)=>{if(Y){let r,l;switch(d){case PointCloudView.Back:r=backViewPolygon2PointCloud;break;case PointCloudView.Side:r=sideViewPolygon2PointCloud;break;default:r=sideViewPolygon2PointCloud;break}if(l=r(n,i,Y,s.pointCloudInstance),o){const{count:w}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:w})}const f=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:L,action:"viewUpdateBox"}))[0],C=l.valid!==f.valid;l=f;const x=et(l);return l=x.find(w=>w.id===l.id),M({omitView:C?void 0:d,polygon:n,boxParams:l,newPointCloudBoxList:x}),x}},$=(n,i,d)=>{if(N){let r,l;switch(d){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}l=r(n,i,N);const g=X(l);return H(d,n,l,void 0,g,L),g}},ct=(n,i)=>{$(n,i,PointCloudView.Side)},pt=(n,i)=>{$(n,i,PointCloudView.Back)},Pt=(n,i)=>{K(n,i,PointCloudView.Side)},gt=(n,i)=>{K(n,i,PointCloudView.Back)},Ct=(n,i)=>{const d=m(n.id),r=topViewPoint2PointCloud(n,i,G,d),l=X(r);H(PointCloudView.Top,n,r,void 0,l,L)},ft=(n,i)=>{if(k){const r=__spreadValues({},n[0].newPolygon);r.pointList=r.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,i)),_(r);return}let d=n.map(({newPolygon:r})=>{const l=it(r.id),{boxParams:g}=topViewPolygon2PointCloud(r,i,t.pointCloudInstance,l);return g});if(d=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:d,stepConfig:L,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=n[0],l=Z(d);M({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=Z(d);r&&e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,r)}},ht=n=>{var i,d,r,l,g;if(S){const f=Number(n.widthDefault),C=Number(n.depthDefault),x=Number(n.heightDefault),w=S==null?void 0:S.info.trackID,B=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(F=>(F==null?void 0:F.trackID)===w),v={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},R=B.pointList.map(F=>lbUtils.PointCloudUtils.transferCanvas2World(F,v)),J=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(R,x,f),Q=J[0],E=J[2],q=lbAnnotation.MathUtils.getLineCenterPoint([Q,E]),xt=S.info.center.z-S.info.depth/2,tt=__spreadProps(__spreadValues({},S.info),{center:{x:q.x,y:q.y,z:xt+C/2},width:f,height:x,depth:C,valid:!0}),vt=Z([tt]);M({omitView:PointCloudView["3D"],polygon:B,boxParams:tt,newPointCloudBoxList:vt})}},H=(n,i,d,r,l,g)=>__async(void 0,null,function*(){const f=j==null?void 0:j.url,C={[PointCloudView.Side]:()=>{syncSideViewByPoint(d,i,s,f,g)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(d,i,a,f,g)},[PointCloudView.Top]:()=>{syncTopViewByPoint(d,i,t,o)}};Object.keys(C).forEach(x=>{x!==n&&C[x]()}),r&&(o==null||o.updateCameraZoom(r)),st(d)}),M=n=>__async(void 0,null,function*(){const{omitView:i,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:g}=n,f=j==null?void 0:j.url;g&&(yield e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single,g));const C={[PointCloudView.Side]:()=>{synchronizeSideView(r,d,s,f)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(r,d,a,f)},[PointCloudView.Top]:()=>{synchronizeTopView(r,d,t,o)}};Object.keys(C).forEach(x=>{x!==i&&C[x]()}),l&&(o==null||o.updateCameraZoom(l)),nt(r)});return{topViewAddSphere:rt,topViewAddBox:lt,topViewSelectedChanged:ut,topViewUpdatePoint:Ct,sideViewUpdatePoint:ct,backViewUpdatePoint:pt,topViewUpdateBox:ft,sideViewUpdateBox:Pt,backViewUpdateBox:gt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(i=j){var d,r,l,g,f,C;if(!(i==null?void 0:i.url)||!o)return;z([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield o.loadPCDFile(i.url,(d=L==null?void 0:L.radius)!=null?d:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],w=[],T=[],B=[];o.updateTopCamera();const v=(l=(r=index.jsonParser(i.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(v),(g=e.sideViewInstance)==null||g.clearAllData(),(f=e.backViewInstance)==null||f.clearAllData(),i.result){if(x=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(x==null?void 0:x.length)>0&&i.isPreResult&&(L==null?void 0:L.lowerLimitPointsNumInBox)>0){x=yield o==null?void 0:o.filterPreResult(i.url,L,x);const R=index.jsonParser(i.result);R[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=x,i.result=JSON.stringify(R),e.setPointCloudResult(x)}T=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),w=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(C=L==null?void 0:L.radius)!=null?C:DEFAULT_RADIUS}),o==null||o.generateBoxes(x),o==null||o.generateSpheres(B),yield e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,x,[])}V({pointCloudBoxList:x,polygonList:T,lineList:w,pointCloudSphereList:B}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:ht,generateRects:W,update2DViewRect:dt,remove2DViewRect:at}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),_=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,t,s)=>t in o?__defProp(o,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[t]=s,__spreadValues=(o,t)=>{for(var s in t||(t={}))__hasOwnProp.call(t,s)&&__defNormalProp(o,s,t[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(t))__propIsEnum.call(t,s)&&__defNormalProp(o,s,t[s]);return o},__spreadProps=(o,t)=>__defProps(o,__getOwnPropDescs(t)),__async=(o,t,s)=>new Promise((c,e)=>{var p=d=>{try{u(s.next(d))}catch(f){e(f)}},P=d=>{try{u(s.throw(d))}catch(f){e(f)}},u=d=>d.done?c(d.value):Promise.resolve(d.value).then(p,P);u((s=s.apply(o,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,t,s,c,e)=>{const{x:p,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,t),{defaultZ:u}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:p,y:P,z:u},id:o.id},f=c?__spreadValues(__spreadValues({},c),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return e&&Object.assign(f,e),f},topViewPolygon2PointCloud=(o,t,s,c,e,p)=>{let P=o.pointList.map(B=>lbUtils.PointCloudUtils.transferCanvas2World(B,t)),u=0,d=1,f={};if(s){const B=s.getSensesPointZAxisInPolygon(P,void 0,p);p&&B.fittedCoordinates.length>0&&(P=B.fittedCoordinates),u=(B.maxZ+B.minZ)/2,d=B.maxZ-B.minZ,f={count:B.zCount}}const[h,L,U]=P,S=lbAnnotation.MathUtils.getLineCenterPoint([h,U]),b=lbAnnotation.MathUtils.getLineLength(h,L),k=lbAnnotation.MathUtils.getLineLength(L,U),V=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);c&&(u=c.center.z,d=c.depth);const R={center:{x:S.x,y:S.y,z:u},width:p?k+INTELLIGENT_FIT_MARGIN:k,height:p?b+INTELLIGENT_FIT_MARGIN:b,depth:d,rotation:V,id:o.id},T=__spreadValues(c?__spreadValues(__spreadValues({},c),R):__spreadProps(__spreadValues({},R),{attribute:"",valid:!0}),f);e&&Object.assign(T,e);const A=P.map(B=>lbUtils.PointCloudUtils.transferWorld2Canvas(B,t));return{boxParams:T,newPointList:A}},sideViewPoint2PointCloud=(o,t,s)=>{const c={x:o.x-t.x,y:o.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x-c.x,y:s.center.y,z:s.center.z-c.y}})},sideViewPolygon2PointCloud=(o,t,s,c)=>{const[e,p,P]=o.pointList,[u,d,f]=t.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([e,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([u,f]),S={x:{x:h.x-L.x,y:h.y-L.y}.x,y:0,z:h.y-L.y},b=lbAnnotation.MathUtils.getLineLength(e,p),k=lbAnnotation.MathUtils.getLineLength(u,d),V=b-k,R=lbAnnotation.MathUtils.getLineLength(p,P),T=lbAnnotation.MathUtils.getLineLength(d,f),A=R-T,{newBoxParams:B}=c.getNewBoxBySideUpdate(S,A,V,s);return B},backViewPoint2PointCloud=(o,t,s)=>{const c={x:o.x-t.x,y:o.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x,y:s.center.y-c.x,z:s.center.z-c.y}})},backViewPolygon2PointCloud=(o,t,s,c)=>{const[e,p,P]=o.pointList,[u,d,f]=t.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([e,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([u,f]),S={x:{x:h.x-L.x,y:h.y-L.y}.x,y:0,z:h.y-L.y},b=lbAnnotation.MathUtils.getLineLength(e,p),k=lbAnnotation.MathUtils.getLineLength(u,d),V=b-k,R=lbAnnotation.MathUtils.getLineLength(p,P),T=lbAnnotation.MathUtils.getLineLength(d,f),A=R-T;let{newBoxParams:B}=c.getNewBoxByBackUpdate(S,A,V,s);return B},syncSideViewByPoint=(o,t,s,c,e)=>{var p;if(!s)return;const{toolInstance:P,pointCloudInstance:u}=s;u.loadPCDFile(c,(p=e==null?void 0:e.radius)!=null?p:DEFAULT_RADIUS);const{cameraPositionVector:d}=u.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);u.setInitCameraPosition(d);const{point2d:f,zoom:h}=u.getSphereSidePoint2DCoordinate(o);u.camera.zoom=h,u.camera.updateProjectionMatrix(),u.render(),P.initPosition(),P.zoomChangeOnCenter(h),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),f),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(o,t,s,c)=>{if(!s)return;const{pointCloud2dOperation:e,pointCloudInstance:p}=s;p.loadPCDFileByBox(c,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=p.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);p.setInitCameraPosition(P);const{polygon2d:u,zoom:d}=p.getBoxSidePolygon2DCoordinate(o);p.camera.zoom=d,p.camera.updateProjectionMatrix(),p.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:t.id,valid:o.valid,pointList:u,textAttribute:"",isRect:!0,attribute:o.attribute}],t.id)},syncBackViewByPoint=(o,t,s,c,e)=>{var p;if(!s)return;const{toolInstance:P,pointCloudInstance:u}=s;u.loadPCDFile(c,(p=e==null?void 0:e.radius)!=null?p:DEFAULT_RADIUS);const{cameraPositionVector:d}=u.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);u.setInitCameraPosition(d);const{point2d:f,zoom:h}=u.getSphereBackPoint2DCoordinate(o);u.camera.zoom=h,u.camera.updateProjectionMatrix(),u.render(),P.initPosition(),P.zoomChangeOnCenter(h),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),f),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(o,t,s,c)=>{if(!s)return;const{pointCloud2dOperation:e,pointCloudInstance:p}=s;p.loadPCDFileByBox(c,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=p.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);p.setInitCameraPosition(P);const{polygon2d:u,zoom:d}=p.getBoxBackPolygon2DCoordinate(o);p.camera.zoom=d,p.camera.updateProjectionMatrix(),p.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:t.id,valid:o.valid,pointList:u,textAttribute:"",isRect:!0,attribute:o.attribute}],t.id)},syncTopViewByPoint=(o,t,s,c)=>{if(!s||!c)return;c.generateSphere(o),c.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),c.render();const{toolInstance:e,pointCloudInstance:p}=s,{point2d:P}=p.getSphereTopPoint2DCoordinate(o),u=[...e.pointList].map(d=>d.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):d);e.setResult(u),e.setSelectedID(t.id)},synchronizeTopView=(o,t,s,c)=>{var e,p;if(!s||!c)return;c.generateBox(o,t.id),c.render();const{pointCloud2dOperation:P,pointCloudInstance:u}=s,{polygon2d:d}=u.getBoxTopPolygon2DCoordinate(o),f=[...P.polygonList],h=f.find(L=>L.id===t.id);h?(h.pointList=d,h.valid=(e=o.valid)!=null?e:!0):f.push({id:t.id,pointList:d,textAttribute:"",isRect:!0,valid:(p=o.valid)!=null?p:!0}),P.setResultAndSelectedID(f,t.id)},usePointCloudViews=()=>{const o=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:s,backViewInstance:c,mainViewInstance:e,addPointCloudBox:p,addPointCloudSphere:P,setSelectedIDs:u,selectedIDs:d,pointCloudBoxList:f,pointCloudSphereList:h,hideAttributes:L,setHighlight2DDataList:U,cuboidBoxIn2DView:S,imageSizes:b,history:k,linkageImageNameRectMap:V}=o,{addHistory:R,initHistory:T,pushHistoryUnderUpdatePolygon:A}=useHistory.useHistory(),{selectedPolygon:B}=usePolygon.usePolygon(),{getPointCloudSphereByID:ot,updatePointCloudSphere:Y,selectedSphere:q}=useSphere.useSphere(),{currentData:j,config:m}=ctx.useSelector(i=>{const{stepList:n,step:a,imgList:r,imgIndex:l}=i.annotation;return{currentData:r[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(a,n).config)}}),z=ctx.useDispatch(),it=ahooks.useLatest(S),nt=React.useCallback(i=>i.filter(a=>{var r,l;return a&&((l=(r=V.get(a.imageName))==null?void 0:r.size)!=null?l:0)===0}),[V]),Z=i=>{const{enableAutoMap2DRect:n=!1}=m;if(!it.current||n){const{mappingImgList:a=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:i,mappingImgList:a,imageSizes:b},{prepareRectsFn:nt})}},{selectedBox:I,updateSelectedBox:st,updateSelectedBoxes:G,getPointCloudByID:rt}=useSingleBox.useSingleBox({generateRects:Z}),K=I==null?void 0:I.info;if(!t||!s||!c)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:J}=t,lt=i=>{e==null||e.generateBox(i),e==null||e.controls.update(),e==null||e.render()},at=i=>{e==null||e.generateSphere(i),e==null||e.controls.update(),e==null||e.render()},dt=({newPoint:i,size:n,zoom:a,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const x=topViewPoint2PointCloud(i,n,J,void 0,g);u(i.id);const C=P(x);H(PointCloudView.Top,i,x,a,C,m),R({newSphereParams:x})},ut=({polygon:i,size:n,imgList:a,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var x,C,v;const D={attribute:(x=t.toolInstance.defaultAttribute)!=null?x:""};r===!0&&Object.assign(D,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:h})});const M=t==null?void 0:t.toolInstance,w=__spreadValues({},i);let{boxParams:y,newPointList:O}=topViewPolygon2PointCloud(w,n,J,void 0,D,g);y=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[y],stepConfig:m,action:"viewUpdateBox"}))[0],g&&(O==null?void 0:O.length)&&(w.pointList=O);const X=L.includes(w.attribute);Z(y);const E=p(y),F=(C=o==null?void 0:o.polygonList)!=null?C:[];y.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((m==null?void 0:m.secondaryAttributeConfigurable)?(v=m==null?void 0:m.inputList)!=null?v:[]:[]),t==null||t.updatePolygonList(E!=null?E:[],F),X?u([]):(u(y.id),M.selection.setSelectedIDs(w.id),N({omitView:PointCloudView.Top,polygon:w,boxParams:y,zoom:l,newPointCloudBoxList:E}),g&&synchronizeTopView(y,w,t,e)),R({newBoxParams:y})},ct=i=>{const{boxID:n,imageName:a,width:r,height:l,x:g,y:x}=i,C=f.find(y=>y.id===n);if(!(C==null?void 0:C.rects)||!C.rects.find(y=>y.imageName===a))return;const D=C.rects.map(y=>y.imageName===a?__spreadProps(__spreadValues({},y),{width:r,height:l,x:g,y:x}):y),M=__spreadProps(__spreadValues({},C),{rects:D}),w=f.map(y=>y.id===n?M:y);return t==null||t.updatePolygonList(w!=null?w:[]),w},pt=i=>{const{boxID:n,imageName:a}=i,r=f.find(C=>C.id===n);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(C=>C.imageName!==a),g=__spreadProps(__spreadValues({},r),{rects:l}),x=f.map(C=>C.id===n?g:C);return t==null||t.updatePolygonList(x!=null?x:[]),x},Pt=({newSelectedBox:i,newPointCloudList:n,newSelectedSphere:a,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(d.length===0||!g)){if(i||(I==null?void 0:I.info)){const x=i!=null?i:I==null?void 0:I.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(d[0]);const C=g.selectedPolygon;if(d.length===1&&x){N({omitView:PointCloudView.Top,polygon:C,boxParams:x,newPointCloudBoxList:n});return}}if((a||q)&&d.length===1){const x=a!=null?a:q;g.setSelectedID(d[0]);const C=g.selectedPoint;x&&H(PointCloudView.Top,C,x,void 0,r,m)}}},$=(i,n,a)=>{if(K){let r,l;switch(a){case PointCloudView.Back:r=backViewPolygon2PointCloud;break;case PointCloudView.Side:r=sideViewPolygon2PointCloud;break;default:r=sideViewPolygon2PointCloud;break}if(l=r(i,n,K,s.pointCloudInstance),e){const{count:D}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:D})}const x=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:m,action:"viewUpdateBox"}))[0],C=l.valid!==x.valid;l=x;const v=st(l);return l=v.find(D=>D.id===l.id),N({omitView:C?void 0:a,polygon:i,boxParams:l,newPointCloudBoxList:v}),v}},tt=(i,n,a)=>{if(q){let r,l;switch(a){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}l=r(i,n,q);const g=Y(l);return H(a,i,l,void 0,g,m),g}},gt=(i,n)=>{tt(i,n,PointCloudView.Side)},Ct=(i,n)=>{tt(i,n,PointCloudView.Back)},ft=(i,n)=>{$(i,n,PointCloudView.Side)},xt=(i,n)=>{$(i,n,PointCloudView.Back)},ht=(i,n)=>{const a=ot(i.id),r=topViewPoint2PointCloud(i,n,J,a),l=Y(r);H(PointCloudView.Top,i,r,void 0,l,m)},vt=(i,n)=>{if(B){const r=__spreadValues({},i[0].newPolygon);r.pointList=r.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,n)),A(r);return}let a=i.map(({newPolygon:r})=>{const l=rt(r.id),{boxParams:g}=topViewPolygon2PointCloud(r,n,t.pointCloudInstance,l);return g});if(a=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:a,stepConfig:m,action:"viewUpdateBox"})),a.length===1){const{newPolygon:r}=i[0],l=G(a);N({polygon:r,boxParams:a[0],newPointCloudBoxList:l})}else{const r=G(a);r&&o.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,r)}},yt=i=>{var n,a,r,l,g;if(I){const x=Number(i.widthDefault),C=Number(i.depthDefault),v=Number(i.heightDefault),D=I==null?void 0:I.info.trackID,w=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(W=>(W==null?void 0:W.trackID)===D),y={width:(r=(a=t==null?void 0:t.toolInstance)==null?void 0:a.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},O=w.pointList.map(W=>lbUtils.PointCloudUtils.transferCanvas2World(W,y)),Q=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(O,v,x),X=Q[0],E=Q[2],F=lbAnnotation.MathUtils.getLineCenterPoint([X,E]),Lt=I.info.center.z-I.info.depth/2,et=__spreadProps(__spreadValues({},I.info),{center:{x:F.x,y:F.y,z:Lt+C/2},width:x,height:v,depth:C,valid:!0}),mt=G([et]);N({omitView:PointCloudView["3D"],polygon:w,boxParams:et,newPointCloudBoxList:mt})}},H=(i,n,a,r,l,g)=>__async(void 0,null,function*(){const x=j==null?void 0:j.url,C={[PointCloudView.Side]:()=>{syncSideViewByPoint(a,n,s,x,g)},[PointCloudView.Back]:()=>{c&&syncBackViewByPoint(a,n,c,x,g)},[PointCloudView.Top]:()=>{syncTopViewByPoint(a,n,t,e)}};Object.keys(C).forEach(v=>{v!==i&&C[v]()}),r&&(e==null||e.updateCameraZoom(r)),at(a)}),N=i=>__async(void 0,null,function*(){const{omitView:n,polygon:a,boxParams:r,zoom:l,newPointCloudBoxList:g}=i,x=j==null?void 0:j.url;g&&(yield o.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single,g));const C={[PointCloudView.Side]:()=>{synchronizeSideView(r,a,s,x)},[PointCloudView.Back]:()=>{c&&synchronizeBackView(r,a,c,x)},[PointCloudView.Top]:()=>{synchronizeTopView(r,a,t,e)}};Object.keys(C).forEach(v=>{v!==n&&C[v]()}),l&&(e==null||e.updateCameraZoom(l)),lt(r)});return{topViewAddSphere:dt,topViewAddBox:ut,topViewSelectedChanged:Pt,topViewUpdatePoint:ht,sideViewUpdatePoint:gt,backViewUpdatePoint:Ct,topViewUpdateBox:vt,sideViewUpdateBox:ft,backViewUpdateBox:xt,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),e==null||e.generateBoxes(i)},initPointCloud3d:i=>{if(!e)return;const n=lbUtils.PointCloudUtils.getDefaultOrthographicParams(i);e.initOrthographicCamera(n),e.initRenderer(),e.render()},updatePointCloudData:(...i)=>__async(void 0,[...i],function*(n=j){var a,r,l,g,x,C;if(!(n==null?void 0:n.url)||!e)return;U([]),actionCreators.SetPointCloudLoading(z,!0),actionCreators.SetLoadPCDFileLoading(z,!0),yield e.loadPCDFile(n.url,(a=m==null?void 0:m.radius)!=null?a:DEFAULT_RADIUS),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let v=[],D=[],M=[],w=[];e.updateTopCamera();const y=(l=(r=index.jsonParser(n.result))==null?void 0:r.valid)!=null?l:!0;if(o.setPointCloudValid(y),(g=o.sideViewInstance)==null||g.clearAllData(),(x=o.backViewInstance)==null||x.clearAllData(),n.result){if(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),(v==null?void 0:v.length)>0&&n.isPreResult&&(m==null?void 0:m.lowerLimitPointsNumInBox)>0){v=yield e==null?void 0:e.filterPreResult(n.url,m,v);const O=index.jsonParser(n.result);O[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=v,n.result=JSON.stringify(O),o.setPointCloudResult(v)}M=lbUtils.PointCloudUtils.getPolygonListFromResultList(n.result),D=lbUtils.PointCloudUtils.getLineListFromResultList(n.result),w=lbUtils.PointCloudUtils.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(C=m==null?void 0:m.radius)!=null?C:DEFAULT_RADIUS}),e==null||e.generateBoxes(v),e==null||e.generateSpheres(w),yield o.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,v,[])}T({pointCloudBoxList:v,polygonList:M,lineList:D,pointCloudSphereList:w}),actionCreators.SetPointCloudLoading(z,!1),actionCreators.SetLoadPCDFileLoading(z,!1)}),updateViewsByDefaultSize:yt,generateRects:Z,update2DViewRect:ct,remove2DViewRect:pt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:t,setPointCloudResult:s}=React.useContext(PointCloudContext.PointCloudContext),c=ahooks.useLatest(o),e=ahooks.useLatest(t);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=c.current,u=e.current;if(u.length===0)return;const d=new Map,f=new Set;if(u.filter(h=>h.extId!==void 0).forEach(h=>{const L=h.extId,U=h.imageName,S=_.pick(h,["x","y","width","height"]);let b=d.get(L);b||(b=new Map,d.set(L,b)),b.set(U,S),f.add(L)}),d.size){const h=P.map(L=>{var U;const S=L.id;if(f.has(S)){const b=__spreadValues({},L);return(U=b.rects)==null||U.forEach(k=>{var V;const R=k.imageName;Object.assign(k,(V=d.get(S))==null?void 0:V.get(R))}),b}return L});s(h)}},[])}};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;
|
|
@@ -15,7 +15,5 @@ export interface UseDataLinkSwitchOptions {
|
|
|
15
15
|
declare const useDataLinkSwitch: (opts: UseDataLinkSwitchOptions) => {
|
|
16
16
|
rendered: React.JSX.Element | null;
|
|
17
17
|
isLinking: boolean;
|
|
18
|
-
swapSwitch: (isLinking: boolean) => void;
|
|
19
|
-
syncIsLinking: () => void;
|
|
20
18
|
};
|
|
21
19
|
export default useDataLinkSwitch;
|
|
@@ -28,6 +28,9 @@ export declare const getRectPointCloudBox: (params: IGetRectPointCloudBoxParams)
|
|
|
28
28
|
width: number;
|
|
29
29
|
height: number;
|
|
30
30
|
} | undefined;
|
|
31
|
+
export interface GeneratePointCloudBoxRectsOptions {
|
|
32
|
+
prepareRectsFn?: (rects: Array<ReturnType<typeof getRectPointCloudBox>>, pointCloudBox: IPointCloudBox) => Array<ReturnType<typeof getRectPointCloudBox>>;
|
|
33
|
+
}
|
|
31
34
|
/**
|
|
32
35
|
* Updates the given point cloud box with rectangles derived from the mapping image list and image sizes.
|
|
33
36
|
*
|
|
@@ -36,6 +39,9 @@ export declare const getRectPointCloudBox: (params: IGetRectPointCloudBoxParams)
|
|
|
36
39
|
* @param {IMappingImg[]} params.mappingImgList - The list of mapping images to process.
|
|
37
40
|
* @param {Object.<string, ISize>} params.imageSizes - An object containing image sizes keyed by image paths.
|
|
38
41
|
*
|
|
42
|
+
* @param {Object=} options - The options
|
|
43
|
+
* @param {Function=} options.prepareRectsFn - The prepare func for rects
|
|
44
|
+
*
|
|
39
45
|
* @returns {void}
|
|
40
46
|
*
|
|
41
47
|
* @description This function processes a list of mapping images to generate rectangles for the provided point cloud box.
|
|
@@ -48,5 +54,5 @@ export declare const generatePointCloudBoxRects: (params: {
|
|
|
48
54
|
imageSizes: {
|
|
49
55
|
[key: string]: ISize;
|
|
50
56
|
};
|
|
51
|
-
}) => void;
|
|
57
|
+
}, options?: GeneratePointCloudBoxRectsOptions) => void;
|
|
52
58
|
export {};
|
package/dist/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,t,e)=>t in n?__defProp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,__spreadValues=(n,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(n,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(n,e,t[e]);return n},__spreadProps=(n,t)=>__defProps(n,__getOwnPropDescs(t));const jsonParser=(n,t={})=>{try{return typeof n=="string"?JSON.parse(n):___default.default.isObject(n)?n:t}catch(e){return t}},classnames=n=>{if(Array.isArray(n))return n.filter(t=>t).join(" ");if(___default.default.isObject(n)){const t=[];return Object.keys(n).forEach(e=>{n[e]&&t.push(e)}),t.join(" ")}return""},getBoundingRect=n=>{let t=Infinity,e=Infinity,r=-Infinity,o=-Infinity;for(const i of n)t=Math.min(t,i.x),e=Math.min(e,i.y),r=Math.max(r,i.x),o=Math.max(o,i.y);return{x:t,y:e,width:r-t,height:o-e}},isBoundingRectInImage=(()=>{const n=(t,e)=>{const r=Math.max(t.x,e.x),o=Math.max(t.y,e.y),i=Math.min(t.x+t.width,e.x+e.width),c=Math.min(t.y+t.height,e.y+e.height),s=i-r,a=c-o;return s>=0&&a>=0?{x:r,y:o,width:s,height:a}:null};return(t,e,r)=>{if(r[e]){const o=r[e].width,i=r[e].height;return n(t,{x:0,y:0,width:o,height:i})!==null}return!1}})(),getRectPointCloudBox=n=>{var t;const{pointCloudBox:e,mappingData:r,imageSizes:o}=n,{transferViewData:i}=(t=lbAnnotation.pointCloudLidar2image(e,r.calib))!=null?t:{};if(!i)return;const c=i.reduce((u,p)=>p.type==="line"?[...u,...p.pointList]:u,[]),s=__spreadProps(__spreadValues({},getBoundingRect(c)),{imageName:r.path});if(isBoundingRectInImage(s,r.path,o))return s},generatePointCloudBoxRects=(n,t)=>{var e;const{pointCloudBox:r,mappingImgList:o,imageSizes:i}=n,s=o.map(a=>getRectPointCloudBox({pointCloudBox:r,mappingData:a,imageSizes:i})).filter(a=>a!==void 0);if(s.length>0){const a=(e=t==null?void 0:t.prepareRectsFn)!=null?e:void 0,u=a?a(s,r):s;Object.assign(r,{rects:u})}};exports.classnames=classnames,exports.generatePointCloudBoxRects=generatePointCloudBoxRects,exports.getBoundingRect=getBoundingRect,exports.getRectPointCloudBox=getRectPointCloudBox,exports.isBoundingRectInImage=isBoundingRectInImage,exports.jsonParser=jsonParser;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemoizedFn as y,useLatest as Z}from"ahooks";import{Spin as ee}from"antd/es";import B,{useContext as te,useRef as z,useState as re,useMemo as ne,useEffect as d}from"react";import{connect as oe}from"react-redux";import{usePointCloudViews as ie}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as le}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as ce}from"../../store/annotation/map.js";import{LabelBeeContext as ue}from"../../store/ctx.js";import{PointCloud2DRectOperation as ae,ImgUtils as se}from"@labelbee/lb-annotation";var de=Object.defineProperty,fe=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,me=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable,J=(u,i,l)=>i in u?de(u,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[i]=l,_=(u,i)=>{for(var l in i||(i={}))me.call(i,l)&&J(u,l,i[l]);if(F)for(var l of F(i))ve.call(i,l)&&J(u,l,i[l]);return u},I=(u,i)=>fe(u,pe(i)),T=(u,i,l)=>new Promise((a,f)=>{var g=s=>{try{R(l.next(s))}catch(p){f(p)}},C=s=>{try{R(l.throw(s))}catch(p){f(p)}},R=s=>s.done?a(s.value):Promise.resolve(s.value).then(g,C);R((l=l.apply(u,i)).next())});const _e=u=>{var i,l;const{mappingData:a,size:f,config:g,checkMode:C,afterImgOnLoad:R,shouldExcludePointCloudBoxListUpdate:s}=u,p=(i=a==null?void 0:a.url)!=null?i:"",w=(l=a==null?void 0:a.fallbackUrl)!=null?l:"",{pointCloudBoxList:O,setPointCloudResult:L,defaultAttribute:V,rectList:S,addRectIn2DView:$,updateRectIn2DView:q,removeRectIn2DView:G,updateRectListByReducer:H}=te(le),{update2DViewRect:K,remove2DViewRect:Q}=ie(),E=B.useRef(null),n=z(null),j=y(K),h=y(Q),P=z(null),[W,U]=re(!0),N=ne(()=>S==null?void 0:S.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,S]),x=Z(a==null?void 0:a.path),A=e=>{const{boxID:o}=e;if(!s&&o){const r=j==null?void 0:j(e);P.current=r,L(r||[]);return}q(e,!0)},k=e=>{x.current&&$(I(_({},e),{imageName:x.current}))},M=e=>{if(e.length===0)return;if(!s){const r=e.find(t=>t.boxID);if(r){const t=h==null?void 0:h(r);P.current=t,L(t||[]),D();return}}const o=e.find(r=>r.extId);if(o){const{imageName:r,extId:t}=o,c=h==null?void 0:h({boxID:t,imageName:r});P.current=c,L(c
|
|
1
|
+
import{useMemoizedFn as y,useLatest as Z}from"ahooks";import{Spin as ee}from"antd/es";import B,{useContext as te,useRef as z,useState as re,useMemo as ne,useEffect as d}from"react";import{connect as oe}from"react-redux";import{usePointCloudViews as ie}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as le}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as ce}from"../../store/annotation/map.js";import{LabelBeeContext as ue}from"../../store/ctx.js";import{PointCloud2DRectOperation as ae,ImgUtils as se}from"@labelbee/lb-annotation";var de=Object.defineProperty,fe=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,me=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable,J=(u,i,l)=>i in u?de(u,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[i]=l,_=(u,i)=>{for(var l in i||(i={}))me.call(i,l)&&J(u,l,i[l]);if(F)for(var l of F(i))ve.call(i,l)&&J(u,l,i[l]);return u},I=(u,i)=>fe(u,pe(i)),T=(u,i,l)=>new Promise((a,f)=>{var g=s=>{try{R(l.next(s))}catch(p){f(p)}},C=s=>{try{R(l.throw(s))}catch(p){f(p)}},R=s=>s.done?a(s.value):Promise.resolve(s.value).then(g,C);R((l=l.apply(u,i)).next())});const _e=u=>{var i,l;const{mappingData:a,size:f,config:g,checkMode:C,afterImgOnLoad:R,shouldExcludePointCloudBoxListUpdate:s}=u,p=(i=a==null?void 0:a.url)!=null?i:"",w=(l=a==null?void 0:a.fallbackUrl)!=null?l:"",{pointCloudBoxList:O,setPointCloudResult:L,defaultAttribute:V,rectList:S,addRectIn2DView:$,updateRectIn2DView:q,removeRectIn2DView:G,updateRectListByReducer:H}=te(le),{update2DViewRect:K,remove2DViewRect:Q}=ie(),E=B.useRef(null),n=z(null),j=y(K),h=y(Q),P=z(null),[W,U]=re(!0),N=ne(()=>S==null?void 0:S.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,S]),x=Z(a==null?void 0:a.path),A=e=>{const{boxID:o}=e;if(!s&&o){const r=j==null?void 0:j(e);P.current=r,L(r||[]);return}q(e,!0)},k=e=>{x.current&&$(I(_({},e),{imageName:x.current}))},M=e=>{if(e.length===0)return;if(!s){const r=e.find(t=>t.boxID);if(r){const t=h==null?void 0:h(r);P.current=t,L(t||[]),D();return}}const o=e.find(r=>r.extId);if(o){const{imageName:r,extId:t}=o,c=h==null?void 0:h({boxID:t,imageName:r});c&&(P.current=c,L(c))}G(e)},X=y(()=>{let e=[];return O.forEach(o=>{const{rects:r=[],id:t,attribute:c,trackID:m}=o,v=r.find(Y=>Y.imageName===x.current),b=t+"_"+x.current;v&&(e=[...e,I(_({},v),{boxID:t,id:b,attribute:c,order:m})])}),e}),D=y(()=>{var e,o,r;const t=s?[]:X(),c=(e=n.current)==null?void 0:e.selectedRectID;(o=n.current)==null||o.setResult([...t,...N]),c&&((r=n.current)==null||r.setSelectedRectID(c))});return d(()=>{if(E.current){const e=new ae({container:E.current,size:f,config:I(_({},g),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:C});return n.current=e,n.current.init(),n.current.on("updateDragResult",A),n.current.on("afterAddingDrawingRect",k),n.current.on("deleteSelectedRects",M),()=>{var o,r,t,c;(o=n.current)==null||o.unbind("updateDragResult",A),(r=n.current)==null||r.unbind("afterAddingDrawingRect",k),(t=n.current)==null||t.unbind("deleteSelectedRects",M),(c=n.current)==null||c.destroy()}}},[]),d(()=>{const e=r=>T(void 0,null,function*(){try{return yield se.load(r)}catch(t){return console.error("Error loading image:",t),null}}),o=()=>T(void 0,null,function*(){var r;U(!0);let t=yield e(p);!t&&w&&(t=yield e(w)),t&&((r=n.current)==null||r.setImgNode(t),R(t)),U(!1)});n.current&&(p||w)&&o()},[p,w]),d(()=>{var e;(e=n.current)==null||e.setSize(f)},[f]),d(()=>{O!==P.current&&D()},[O]),d(()=>{var e,o;const r=N.find(t=>t.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,V),r&&H(t=>{var c;const m=[];let v=null;return t.forEach(b=>{b.id!==n.current.selectedRectID?m.push(b):v=b}),r.extId===void 0&&(v=(c=n.current)==null?void 0:c.selectedRect),[...m,I(_({},v||{}),{attribute:V})]}),D()},[V]),d(()=>{D()},[N]),d(()=>{D()},[s]),d(()=>{var e,o,r,t;const c=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},m=I(_({},c),{attributeList:(r=g.attributeList)!=null?r:[]});(t=n.current)==null||t.setConfig(JSON.stringify(m))},[g.attributeList]),B.createElement(ee,{spinning:W},B.createElement("div",{ref:E,style:_({position:"relative"},f)}))};var ge=oe(ce,null,null,{context:ue})(_e);export{ge as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudPattern as Y}from"@labelbee/lb-utils";import Be,{useState as r,useRef as it,useMemo as
|
|
1
|
+
import{EPointCloudPattern as Y}from"@labelbee/lb-utils";import Be,{useState as r,useRef as it,useMemo as k,useCallback as F,useEffect as $}from"react";import{EPointCloudBoxRenderTrigger as E,calcResetAreasAndBoxIds as st}from"../../utils/ToolPointCloudBoxRenderHelper.js";import{ActionsHistory as _e,EToolName as ee,uuid as rt}from"@labelbee/lb-annotation";import{useDispatch as lt}from"../../store/ctx.js";import{ChangeSave as at}from"../../store/annotation/actionCreators.js";import ct from"../../store/annotatedBox/index.js";import Ve from"lodash";import{addMapIndirectWeakSetItem as Ne}from"./utils/map.js";var dt=Object.defineProperty,ut=Object.defineProperties,pt=Object.getOwnPropertyDescriptors,Oe=Object.getOwnPropertySymbols,mt=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable,He=(a,o,c)=>o in a?dt(a,o,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[o]=c,z=(a,o)=>{for(var c in o||(o={}))mt.call(o,c)&&He(a,c,o[c]);if(Oe)for(var c of Oe(o))ft.call(o,c)&&He(a,c,o[c]);return a},Me=(a,o)=>ut(a,pt(o)),gt=(a,o,c)=>new Promise((L,A)=>{var B=u=>{try{P(c.next(u))}catch(C){A(C)}},T=u=>{try{P(c.throw(u))}catch(C){A(C)}},P=u=>u.done?L(u.value):Promise.resolve(u.value).then(B,T);P((c=c.apply(a,o)).next())});const G=a=>Ve.pick(a,["id","attribute","width","height","x","y","imageName"]),je=Be.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 _e,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:ee.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:Y.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:a=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:a=>!1,removeRectBySpecifyId:(a,o,c)=>!1,removeRectByPointCloudBoxId:a=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{}}),ht=({children:a})=>{const[o,c]=r([]),[L,A]=r([]),[B,T]=r([]),[P,u]=r([]),[C,ke]=r([]),[I,Z]=r([]),[_,W]=r([]),[te,Fe]=r(!0),[oe,Ee]=r(2),[ne,ze]=r(!0),[ie,Ge]=r(1),[f,se]=r(),[re,le]=r(),[ae,ce]=r(),[p,de]=r(),[ue,Te]=r(""),[q,Ze]=r(ee.Rect),J=it(new _e).current,[g,K]=r([]),[pe,We]=r(""),[Q,qe]=r(Y.Detection),[D,me]=r(void 0),[U,Je]=r([]),[X,Ke]=r([]),h=ct(),[fe,Qe]=r({}),Ue=lt(),Xe=n=>{const{imgNode:i,path:t}=n;t&&i&&Qe(d=>Me(z({},d),{[t]:{width:i.width,height:i.height}}))},ge=k(()=>I.length===1?I[0]:"",[I]),N=F((n,i,t="extId")=>{const d=t||"id",l=new Set(i);return u(m=>{let R=!1;const x=m.filter(H=>{const M=H[d],j=M!==void 0||l.has(M)?H.imageName!==n:!0;return j||(R=!0),j});return R?x:m}),!0},[]),he=F(n=>{const i=o.map(t=>t.id);return N(n,i,"extId")},[o,N]),ve=F(n=>{if(!n)return!1;const i=o.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:d,attribute:l,trackID:m}=t,R=t.rects.find(x=>x.imageName===n);if(R){const x=Ve.pick(R,["width","height","x","y","imageName"]);return Me(z({},x),{id:rt(),attribute:l,order:m,extId:d,lineDash:[]})}return null}).filter(t=>t!==null);return i.length?(u(t=>{const d=new Set(t.filter(m=>n===m.imageName).map(m=>m.extId)),l=i.filter(m=>d.has(m.extId)===!1);return l.length?[...t,...l]:t}),!0):!1},[o]),Ie=k(()=>o.filter(i=>Array.isArray(i.rects)&&i.rects.length>0).reduce((i,t)=>{var d;return(d=t.rects)==null||d.forEach(l=>{const{imageName:m}=l;if(!m){console.warn("Missing image name"),console.trace(l,t);return}Ne(i,m,t.id,t)}),i},new Map),[o]),Pe=F(n=>{u(i=>n(i,G))},[G]),ye=k(()=>P.filter(n=>n.extId!==void 0&&n.id!==void 0).reduce((n,i)=>{const t=i.imageName;return t?(Ne(n,t,i.extId,i),n):(console.warn("missing image name"),console.log(i,P),n)},new Map),[P]),O=k(()=>{const n=o.find(e=>e.id===ge),i=e=>{const s=o.concat(e);return c(s),s},t=e=>{const s=L.concat(e);return A(s),s},d=e=>{Fe(e!==!1)},l=e=>{e===void 0&&Z([]),typeof e=="string"&&Z([e]),Array.isArray(e)&&Z(Array.from(new Set(e)))},m=e=>{I.includes(e)?l(I.filter(s=>s!==e)):l([...I,e])},R=e=>{const s=G(e);u(v=>[...v,s])},x=(e,s=!1)=>{const v=G(e);u(y=>y.map(S=>S.id===e.id?s?z(z({},S),v):v:S))},H=e=>{u(s=>s.filter(v=>!e.find(y=>y.id===v.id)))},M=e=>{_.includes(e)?W([]):W([e])},j=()=>{if(q===ee.Rect){const e=o.map(s=>s.id);l(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},$e=e=>{l(o.filter(s=>s.attribute===e).map(s=>s.id))},Se=o.filter(e=>!g.includes(e.attribute)),be=L.filter(e=>!g.includes(e.attribute)),we=C.filter(e=>e.attribute&&!g.includes(e.attribute)),et=e=>{if(g.includes(e))K(g.filter(s=>s!==e));else{const s=g.concat(e);K(s)}},tt=(e=Se,s=B,v=be,y=we,S=U)=>{var V;p==null||p.clearAllBox(),p==null||p.clearAllSphere(),f==null||f.updatePolygonList(e,s),f==null||f.updatePointList(v),f==null||f.updateLineList(y),p==null||p.generateBoxes(e),p==null||p.generateSpheres(v),(V=D==null?void 0:D.store)==null||V.updateCurrentSegment(S),Ce(E.Default,e)},ot=()=>{se(void 0),le(void 0),ce(void 0),de(void 0)},Ce=(e,s,v)=>gt(void 0,null,function*(){var y,S,V;if(!p)return;const Re=p.pointCloudObject;if(!Re)return;let xe=[],Le=[];try{if(s&&J.record.length){const{record:b,recordIndex:w}=J;let De=w;w>0&&(e===E.SingleToggleValid||e===E.SingleRotate||e===E.Single&&s.length===((y=b[w])==null?void 0:y.pointCloudBoxList.length))&&(De=w-1);let nt=(S=b[De])==null?void 0:S.pointCloudBoxList;const Ae=st(e,s,nt);xe=Ae.modifiedBoxIds,Le=Ae.resetAreas}}catch(b){console.error("call calcResetAreasAndBoxIds error",b)}try{const b=yield p.getHighlightIndexByMappingImgList({mappingImgList:v!=null?v:X,points:Re.geometry.attributes.position.array}),w=yield p==null?void 0:p.highlightOriginPointCloud(s,b,{modifiedBoxIds:xe,resetAreas:Le});return w&&((V=f==null?void 0:f.pointCloudInstance)==null||V.updateColor(w)),w}catch(b){console.error("call highlightOriginPointCloud error",b)}});return{selectedID:ge,pointCloudBoxList:o,pointCloudSphereList:L,displayPointCloudList:Se,displaySphereList:be,displayLineList:we,selectedIDs:I,setPointCloudResult:c,setSelectedIDs:l,addPointCloudBox:i,addPointCloudSphere:t,setPointCloudSphereList:A,valid:te,selectedPointCloudBox:n,setPointCloudValid:d,addSelectedID:m,addHighlightID:M,selectedAllBoxes:j,topViewInstance:f,setTopViewInstance:se,sideViewInstance:re,setSideViewInstance:le,backViewInstance:ae,setBackViewInstance:ce,mainViewInstance:p,setMainViewInstance:de,polygonList:B,setPolygonList:T,rectList:P,setRectList:u,addRectIn2DView:R,removeRectIn2DView:H,updateRectIn2DView:x,lineList:C,setLineList:ke,zoom:ie,setZoom:Ge,history:J,toggleAttributesVisible:et,hideAttributes:g,setHideAttributes:K,reRender:tt,attrPanelLayout:pe,setAttrPanelLayout:We,syncAllViewPointCloudColor:Ce,defaultAttribute:ue,setDefaultAttribute:Te,pointCloudPattern:q,setPointCloudPattern:Ze,selectSpecAttr:$e,globalPattern:Q,setGlobalPattern:e=>{Q!==e&&(Ue(at),qe(e),e===Y.Detection&&me(void 0))},ptSegmentInstance:D,setPtSegmentInstance:me,segmentation:U,setSegmentation:Je,clearAllDetectionInstance:ot,highlight2DDataList:X,setHighlight2DDataList:Ke,cuboidBoxIn2DView:ne,setCuboidBoxIn2DView:ze,imageSizes:fe,cacheImageNodeSize:Xe,highlightIDs:_,setHighlightIDs:W,removeRectByPointCloudBoxId:he,removeRectBySpecifyId:N,addRectFromPointCloudBoxByImageName:ve,rectRotateSensitivity:oe,setRectRotateSensitivity:Ee,imageNamePointCloudBoxMap:Ie,linkageImageNameRectMap:ye,updateRectListByReducer:Pe}},[te,I,o,L,B,C,P,f,re,ae,p,ie,g,pe,ue,q,Q,D,U,X,ne,fe,_,he,N,ve,oe,Ie,ye,Pe]);$(()=>{var n,i,t;(n=h==null?void 0:h.setPointCloudBoxList)==null||n.call(h,o),(i=h==null?void 0:h.setHighlightIDs)==null||i.call(h,_),(t=h==null?void 0:h.setSelectedIDs)==null||t.call(h,I)},[o,I,_]),$(()=>{var n;(n=h==null?void 0:h.setPtCtx)==null||n.call(h,O)},[O]);const Ye=()=>{const n=o.filter(l=>g.includes(l.attribute)),{setSelectedIDs:i,reRender:t}=O,d=n.map(l=>l.id);d.length>0&&i(I.filter(l=>!d.includes(l))),t()};return $(()=>{var n,i,t,d;Ye(),(i=(n=f==null?void 0:f.toolInstance)==null?void 0:n.setHiddenAttributes)==null||i.call(n,g),(d=(t=D==null?void 0:D.store)==null?void 0:t.setHiddenAttributes)==null||d.call(t,g)},[g]),Be.createElement(je.Provider,{value:O},a)};export{je as PointCloudContext,ht as PointCloudProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import f,{useState as S,useContext as C,useCallback as R,useMemo as m,useEffect as b}from"react";import{useLatest as o}from"ahooks";import{PointCloudContext as k}from"../PointCloudContext.js";import j from"../../../assets/annotation/icon_link.svg.js";import z from"../../../assets/annotation/icon_unlink.svg.js";import{EventBusEvent as x}from"../../../views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js";import{EventBus as p}from"@labelbee/lb-annotation";import{useSyncRectPositionDimensionToPointCloudList as F}from"./usePointCloudViews.js";const T=e=>{const{imageNamePointCloudBoxMap:i,linkageImageNameRectMap:a}=C(k),s=m(()=>e?i.has(e):(console.error("Missing image name"),!1),[e,i]),r=m(()=>{var l,g;return e?((g=(l=a.get(e))==null?void 0:l.size)!=null?g:0)>0:!1},[a,e]),c=m(()=>s||r,[s,r]),I=o(c);return{visible:c,visibleRef:I}},B={width:16,height:16},$=e=>{e.imageName||console.warn("missing imageName");const[i,a]=S(!0),s=o(e.imageName),{addRectFromPointCloudBoxByImageName:r,removeRectByPointCloudBoxId:c,imageNamePointCloudBoxMap:I,linkageImageNameRectMap:l,rectList:g}=C(k),{visible:h,visibleRef:M}=T(e.imageName),{syncToPointCloudBoxList:N}=F(),y=o(r),P=o(c),L=o(()=>{N()}),d=R(n=>{if(!M.current)return;const t=s.current;if(!t){console.warn("invalid image name");return}a(n),n?P.current(t):y.current(t)},[]),D=o(n=>{console.log(n),d(n),n&&L.current()}),_=m(()=>{var n;if(!e.is2DView||!h)return null;const u={zIndex:(n=e.zIndex)!=null?n:999,position:"absolute",top:16,right:16+28+12,background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28};return f.createElement("div",{style:u},i&&f.createElement("img",{src:j,style:B}),!i&&f.createElement("img",{src:z,style:B}))},[i,e.is2DView,e.zIndex,h]),E=o(l),v=R(()=>{var n,t;if(!e.is2DView)return;const u=s.current;if(!u){console.warn("invalid image name");return}const V=[...(t=(n=E.current.get(u))==null?void 0:n.keys())!=null?t:[]];let w=!0;V.length&&(w=!1),d(w)},[e.is2DView,d]);return b(()=>{v()},[v]),b(()=>{const n=t=>{D.current(t)};return p.on(x.switchConnect,n),()=>p.unbind(x.switchConnect,n)},[]),{rendered:_,isLinking:i}};export{$ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudName as it,TagUtils as Qt,MathUtils as b,getCuboidFromPointCloudBox as Xt}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as V,POINT_CLOUD_DEFAULT_STEP as Yt,DEFAULT_SPHERE_PARAMS as qt}from"@labelbee/lb-utils";import{useContext as Kt}from"react";import{PointCloudContext as $t}from"../PointCloudContext.js";import{useSingleBox as to}from"./useSingleBox.js";import{useSphere as oo}from"./useSphere.js";import{useSelector as eo,useDispatch as no}from"../../../store/ctx.js";import io from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as st}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as rt,generatePointCloudBoxRects as so}from"../../../utils/index.js";import{PreDataProcess as lt,SetPointCloudLoading as mt,SetLoadPCDFileLoading as xt}from"../../../store/annotation/actionCreators.js";import{useHistory as ro}from"./useHistory.js";import{usePolygon as lo}from"./usePolygon.js";import{useLatest as ao}from"ahooks";var co=Object.defineProperty,uo=Object.defineProperties,po=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,go=Object.prototype.hasOwnProperty,fo=Object.prototype.propertyIsEnumerable,vt=(e,t,s)=>t in e?co(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,L=(e,t)=>{for(var s in t||(t={}))go.call(t,s)&&vt(e,s,t[s]);if(ht)for(var s of ht(t))fo.call(t,s)&&vt(e,s,t[s]);return e},R=(e,t)=>uo(e,po(t)),dt=(e,t,s)=>new Promise((a,o)=>{var c=p=>{try{u(s.next(p))}catch(m){o(m)}},g=p=>{try{u(s.throw(p))}catch(m){o(m)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,g);u((s=s.apply(e,t)).next())});const q=5,K=90,Lt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(e,t,s,a,o)=>{const{x:c,y:g}=V.transferCanvas2World(e,t),{defaultZ:u}=qt,p={center:{x:c,y:g,z:u},id:e.id},m=a?L(L({},a),p):R(L({},p),{attribute:"",valid:!0});return o&&Object.assign(m,o),m},ct=(e,t,s,a,o,c)=>{let g=e.pointList.map(w=>V.transferCanvas2World(w,t)),u=0,p=1,m={};if(s){const w=s.getSensesPointZAxisInPolygon(g,void 0,c);c&&w.fittedCoordinates.length>0&&(g=w.fittedCoordinates),u=(w.maxZ+w.minZ)/2,p=w.maxZ-w.minZ,m={count:w.zCount}}const[v,D,F]=g,O=b.getLineCenterPoint([v,F]),A=b.getLineLength(v,D),j=b.getLineLength(D,F),k=b.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const U={center:{x:O.x,y:O.y,z:u},width:c?j+Lt:j,height:c?A+Lt:A,depth:p,rotation:k,id:e.id},T=L(a?L(L({},a),U):R(L({},U),{attribute:"",valid:!0}),m);o&&Object.assign(T,o);const N=g.map(w=>V.transferWorld2Canvas(w,t));return{boxParams:T,newPointList:N}},yt=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return R(L({},s),{center:{x:s.center.x-a.x,y:s.center.y,z:s.center.z-a.y}})},Bt=(e,t,s,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=b.getLineCenterPoint([o,g]),D=b.getLineCenterPoint([u,m]),O={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},A=b.getLineLength(o,c),j=b.getLineLength(u,p),k=A-j,U=b.getLineLength(c,g),T=b.getLineLength(p,m),N=U-T,{newBoxParams:w}=a.getNewBoxBySideUpdate(O,N,k,s);return w},Co=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return R(L({},s),{center:{x:s.center.x,y:s.center.y-a.x,z:s.center.z-a.y}})},Po=(e,t,s,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=b.getLineCenterPoint([o,g]),D=b.getLineCenterPoint([u,m]),O={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},A=b.getLineLength(o,c),j=b.getLineLength(u,p),k=A-j,U=b.getLineLength(c,g),T=b.getLineLength(p,m),N=U-T;let{newBoxParams:w}=a.getNewBoxByBackUpdate(O,N,k,s);return w},bt=(e,t,s,a,o)=>{var c;if(!s)return;const{toolInstance:g,pointCloudInstance:u}=s;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Left);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([R(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=s;c.loadPCDFileByBox(a,e,{width:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Left);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,s,a,o)=>{var c;if(!s)return;const{toolInstance:g,pointCloudInstance:u}=s;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Back);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([R(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Dt=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=s;c.loadPCDFileByBox(a,e,{height:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Back);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},St=(e,t,s,a)=>{if(!s||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,G.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=s,{point2d:g}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?R(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},ut=(e,t,s,a)=>{var o,c;if(!s||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:g,pointCloudInstance:u}=s,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),m=[...g.polygonList],v=m.find(D=>D.id===t.id);v?(v.pointList=p,v.valid=(o=e.valid)!=null?o:!0):m.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),g.setResultAndSelectedID(m,t.id)},mo=()=>{const e=Kt($t),{topViewInstance:t,sideViewInstance:s,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:m,pointCloudSphereList:v,hideAttributes:D,setHighlight2DDataList:F,cuboidBoxIn2DView:O,imageSizes:A,history:j}=e,{addHistory:k,initHistory:U,pushHistoryUnderUpdatePolygon:T}=ro(),{selectedPolygon:N}=lo(),{getPointCloudSphereByID:w,updatePointCloudSphere:pt,selectedSphere:J}=oo(),{currentData:M,config:B}=eo(i=>{const{stepList:n,step:d,imgList:r,imgIndex:l}=i.annotation;return{currentData:r[l],config:rt(io.getCurrentStepInfo(d,n).config)}}),E=no(),_t=ao(O),$=i=>{const{enableAutoMap2DRect:n=!1}=B;if(!_t.current||n){const{mappingImgList:d=[]}=M;so({pointCloudBox:i,mappingImgList:d,imageSizes:A})}},{selectedBox:_,updateSelectedBox:Vt,updateSelectedBoxes:tt,getPointCloudByID:Rt}=to({generateRects:$}),gt=_==null?void 0:_.info;if(!t||!s||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Ot=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},At=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},kt=({newPoint:i,size:n,zoom:d,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const P=at(i,n,ot,void 0,f);u(i.id);const C=g(P);Q(y.Top,i,P,d,C,B),k({newSphereParams:P})},Ut=({polygon:i,size:n,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var P,C,x;const S={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};r===!0&&Object.assign(S,{trackID:V.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:v})});const H=t==null?void 0:t.toolInstance,I=L({},i);let{boxParams:h,newPointList:z}=ct(I,n,ot,void 0,S,f);h=E(lt({tool:it.PointCloud,dataList:[h],stepConfig:B,action:"viewUpdateBox"}))[0],f&&(z==null?void 0:z.length)&&(I.pointList=z);const nt=D.includes(I.attribute);$(h);const Z=c(h),X=(C=e==null?void 0:e.polygonList)!=null?C:[];h.subAttribute=Qt.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(x=B==null?void 0:B.inputList)!=null?x:[]:[]),t==null||t.updatePolygonList(Z!=null?Z:[],X),nt?u([]):(u(h.id),H.selection.setSelectedIDs(I.id),W({omitView:y.Top,polygon:I,boxParams:h,zoom:l,newPointCloudBoxList:Z}),f&&ut(h,I,t,o)),k({newBoxParams:h})},Tt=i=>{const{boxID:n,imageName:d,width:r,height:l,x:f,y:P}=i,C=m.find(h=>h.id===n);if(!(C==null?void 0:C.rects)||!C.rects.find(h=>h.imageName===d))return;const S=C.rects.map(h=>h.imageName===d?R(L({},h),{width:r,height:l,x:f,y:P}):h),H=R(L({},C),{rects:S}),I=m.map(h=>h.id===n?H:h);return t==null||t.updatePolygonList(I!=null?I:[]),I},zt=i=>{const{boxID:n,imageName:d}=i,r=m.find(C=>C.id===n);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(C=>C.imageName!==d),f=R(L({},r),{rects:l}),P=m.map(C=>C.id===n?f:C);return t==null||t.updatePolygonList(P!=null?P:[]),P},jt=({newSelectedBox:i,newPointCloudList:n,newSelectedSphere:d,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(p.length===0||!f)){if(i||(_==null?void 0:_.info)){const P=i!=null?i:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(p[0]);const C=f.selectedPolygon;if(p.length===1&&P){W({omitView:y.Top,polygon:C,boxParams:P,newPointCloudBoxList:n});return}}if((d||J)&&p.length===1){const P=d!=null?d:J;f.setSelectedID(p[0]);const C=f.selectedPoint;P&&Q(y.Top,C,P,void 0,r,B)}}},ft=(i,n,d)=>{if(gt){let r,l;switch(d){case y.Back:r=Po;break;case y.Side:r=Bt;break;default:r=Bt;break}if(l=r(i,n,gt,s.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(Xt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=R(L({},l),{count:S})}const P=E(lt({tool:it.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],C=l.valid!==P.valid;l=P;const x=Vt(l);return l=x.find(S=>S.id===l.id),W({omitView:C?void 0:d,polygon:i,boxParams:l,newPointCloudBoxList:x}),x}},Ct=(i,n,d)=>{if(J){let r,l;switch(d){case y.Back:r=Co;break;case y.Side:r=yt;break;default:r=yt;break}l=r(i,n,J);const f=pt(l);return Q(d,i,l,void 0,f,B),f}},Nt=(i,n)=>{Ct(i,n,y.Side)},Et=(i,n)=>{Ct(i,n,y.Back)},Ht=(i,n)=>{ft(i,n,y.Side)},Ft=(i,n)=>{ft(i,n,y.Back)},Mt=(i,n)=>{const d=w(i.id),r=at(i,n,ot,d),l=pt(r);Q(y.Top,i,r,void 0,l,B)},Wt=(i,n)=>{if(N){const r=L({},i[0].newPolygon);r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,n)),T(r);return}let d=i.map(({newPolygon:r})=>{const l=Rt(r.id),{boxParams:f}=ct(r,n,t.pointCloudInstance,l);return f});if(d=E(lt({tool:it.PointCloud,dataList:d,stepConfig:B,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=i[0],l=tt(d);W({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=tt(d);r&&e.syncAllViewPointCloudColor(st.MultiMove,r)}},Zt=i=>{var n,d,r,l,f;if(_){const P=Number(i.widthDefault),C=Number(i.depthDefault),x=Number(i.heightDefault),S=_==null?void 0:_.info.trackID,I=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===S),h={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},z=I.pointList.map(Y=>V.transferCanvas2World(Y,h)),et=b.getModifiedRectangleCoordinates(z,x,P),nt=et[0],Z=et[2],X=b.getLineCenterPoint([nt,Z]),Gt=_.info.center.z-_.info.depth/2,Pt=R(L({},_.info),{center:{x:X.x,y:X.y,z:Gt+C/2},width:P,height:x,depth:C,valid:!0}),Jt=tt([Pt]);W({omitView:y["3D"],polygon:I,boxParams:Pt,newPointCloudBoxList:Jt})}},Q=(i,n,d,r,l,f)=>dt(void 0,null,function*(){const P=M==null?void 0:M.url,C={[y.Side]:()=>{bt(d,n,s,P,f)},[y.Back]:()=>{a&&It(d,n,a,P,f)},[y.Top]:()=>{St(d,n,t,o)}};Object.keys(C).forEach(x=>{x!==i&&C[x]()}),r&&(o==null||o.updateCameraZoom(r)),At(d)}),W=i=>dt(void 0,null,function*(){const{omitView:n,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:f}=i,P=M==null?void 0:M.url;f&&(yield e.syncAllViewPointCloudColor(st.Single,f));const C={[y.Side]:()=>{wt(r,d,s,P)},[y.Back]:()=>{a&&Dt(r,d,a,P)},[y.Top]:()=>{ut(r,d,t,o)}};Object.keys(C).forEach(x=>{x!==n&&C[x]()}),l&&(o==null||o.updateCameraZoom(l)),Ot(r)});return{topViewAddSphere:kt,topViewAddBox:Ut,topViewSelectedChanged:jt,topViewUpdatePoint:Mt,sideViewUpdatePoint:Nt,backViewUpdatePoint:Et,topViewUpdateBox:Wt,sideViewUpdateBox:Ht,backViewUpdateBox:Ft,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const n=V.getDefaultOrthographicParams(i);o.initOrthographicCamera(n),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>dt(void 0,[...i],function*(n=M){var d,r,l,f,P,C;if(!(n==null?void 0:n.url)||!o)return;F([]),mt(E,!0),xt(E,!0),yield o.loadPCDFile(n.url,(d=B==null?void 0:B.radius)!=null?d:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],S=[],H=[],I=[];o.updateTopCamera();const h=(l=(r=rt(n.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(h),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),n.result){if(x=V.getBoxParamsFromResultList(n.result),(x==null?void 0:x.length)>0&&n.isPreResult&&(B==null?void 0:B.lowerLimitPointsNumInBox)>0){x=yield o==null?void 0:o.filterPreResult(n.url,B,x);const z=rt(n.result);z[Yt].result=x,n.result=JSON.stringify(z),e.setPointCloudResult(x)}H=V.getPolygonListFromResultList(n.result),S=V.getLineListFromResultList(n.result),I=V.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(C=B==null?void 0:B.radius)!=null?C:K}),o==null||o.generateBoxes(x),o==null||o.generateSpheres(I),yield e.syncAllViewPointCloudColor(st.Default,x,[])}U({pointCloudBoxList:x,polygonList:H,lineList:S,pointCloudSphereList:I}),mt(E,!1),xt(E,!1)}),updateViewsByDefaultSize:Zt,generateRects:$,update2DViewRect:Tt,remove2DViewRect:zt}};export{It as syncBackViewByPoint,bt as syncSideViewByPoint,St as syncTopViewByPoint,Dt as synchronizeBackView,wt as synchronizeSideView,ut as synchronizeTopView,at as topViewPoint2PointCloud,ct as topViewPolygon2PointCloud,mo as usePointCloudViews};
|
|
1
|
+
import{EPointCloudName as it,TagUtils as to,MathUtils as w,getCuboidFromPointCloudBox as oo}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as eo,DEFAULT_SPHERE_PARAMS as no}from"@labelbee/lb-utils";import{useContext as xt,useCallback as ht}from"react";import{PointCloudContext as Lt}from"../PointCloudContext.js";import{useSingleBox as io}from"./useSingleBox.js";import{useSphere as so}from"./useSphere.js";import{pick as ro}from"lodash";import{useSelector as lo,useDispatch as ao}from"../../../store/ctx.js";import co from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as st}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as rt,generatePointCloudBoxRects as uo}from"../../../utils/index.js";import{PreDataProcess as lt,SetPointCloudLoading as vt,SetLoadPCDFileLoading as yt}from"../../../store/annotation/actionCreators.js";import{useHistory as po}from"./useHistory.js";import{usePolygon as go}from"./usePolygon.js";import{useLatest as dt}from"ahooks";var fo=Object.defineProperty,Co=Object.defineProperties,Po=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertySymbols,mo=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,bt=(e,t,s)=>t in e?fo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,v=(e,t)=>{for(var s in t||(t={}))mo.call(t,s)&&bt(e,s,t[s]);if(Bt)for(var s of Bt(t))xo.call(t,s)&&bt(e,s,t[s]);return e},k=(e,t)=>Co(e,Po(t)),at=(e,t,s)=>new Promise((u,o)=>{var p=a=>{try{c(s.next(a))}catch(P){o(P)}},g=a=>{try{c(s.throw(a))}catch(P){o(P)}},c=a=>a.done?u(a.value):Promise.resolve(a.value).then(p,g);c((s=s.apply(e,t)).next())});const q=5,K=90,wt=.01,B={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},ct=(e,t,s,u,o)=>{const{x:p,y:g}=O.transferCanvas2World(e,t),{defaultZ:c}=no,a={center:{x:p,y:g,z:c},id:e.id},P=u?v(v({},u),a):k(v({},a),{attribute:"",valid:!0});return o&&Object.assign(P,o),P},ut=(e,t,s,u,o,p)=>{let g=e.pointList.map(I=>O.transferCanvas2World(I,t)),c=0,a=1,P={};if(s){const I=s.getSensesPointZAxisInPolygon(g,void 0,p);p&&I.fittedCoordinates.length>0&&(g=I.fittedCoordinates),c=(I.maxZ+I.minZ)/2,a=I.maxZ-I.minZ,P={count:I.zCount}}const[x,y,A]=g,_=w.getLineCenterPoint([x,A]),S=w.getLineLength(x,y),z=w.getLineLength(y,A),T=w.getRadiusFromQuadrangle(e.pointList);u&&(c=u.center.z,a=u.depth);const U={center:{x:_.x,y:_.y,z:c},width:p?z+wt:z,height:p?S+wt:S,depth:a,rotation:T,id:e.id},j=v(u?v(v({},u),U):k(v({},U),{attribute:"",valid:!0}),P);o&&Object.assign(j,o);const E=g.map(I=>O.transferWorld2Canvas(I,t));return{boxParams:j,newPointList:E}},It=(e,t,s)=>{const u={x:e.x-t.x,y:e.y-t.y};return k(v({},s),{center:{x:s.center.x-u.x,y:s.center.y,z:s.center.z-u.y}})},Dt=(e,t,s,u)=>{const[o,p,g]=e.pointList,[c,a,P]=t.pointList,x=w.getLineCenterPoint([o,g]),y=w.getLineCenterPoint([c,P]),_={x:{x:x.x-y.x,y:x.y-y.y}.x,y:0,z:x.y-y.y},S=w.getLineLength(o,p),z=w.getLineLength(c,a),T=S-z,U=w.getLineLength(p,g),j=w.getLineLength(a,P),E=U-j,{newBoxParams:I}=u.getNewBoxBySideUpdate(_,E,T,s);return I},ho=(e,t,s)=>{const u={x:e.x-t.x,y:e.y-t.y};return k(v({},s),{center:{x:s.center.x,y:s.center.y-u.x,z:s.center.z-u.y}})},Lo=(e,t,s,u)=>{const[o,p,g]=e.pointList,[c,a,P]=t.pointList,x=w.getLineCenterPoint([o,g]),y=w.getLineCenterPoint([c,P]),_={x:{x:x.x-y.x,y:x.y-y.y}.x,y:0,z:x.y-y.y},S=w.getLineLength(o,p),z=w.getLineLength(c,a),T=S-z,U=w.getLineLength(p,g),j=w.getLineLength(a,P),E=U-j;let{newBoxParams:I}=u.getNewBoxByBackUpdate(_,E,T,s);return I},St=(e,t,s,u,o)=>{var p;if(!s)return;const{toolInstance:g,pointCloudInstance:c}=s;c.loadPCDFile(u,(p=o==null?void 0:o.radius)!=null?p:K);const{cameraPositionVector:a}=c.updateOrthoCameraBySphere(e,G.Left);c.setInitCameraPosition(a);const{point2d:P,zoom:x}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=x,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(x),g.setResult([k(v(v({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},_t=(e,t,s,u)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:p}=s;p.loadPCDFileByBox(u,e,{width:q,depth:q});const{cameraPositionVector:g}=p.updateOrthoCamera(e,G.Left);p.setInitCameraPosition(g);const{polygon2d:c,zoom:a}=p.getBoxSidePolygon2DCoordinate(e);p.camera.zoom=a,p.camera.updateProjectionMatrix(),p.render(),o.initPosition(),o.zoomChangeOnCenter(a),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},Rt=(e,t,s,u,o)=>{var p;if(!s)return;const{toolInstance:g,pointCloudInstance:c}=s;c.loadPCDFile(u,(p=o==null?void 0:o.radius)!=null?p:K);const{cameraPositionVector:a}=c.updateOrthoCameraBySphere(e,G.Back);c.setInitCameraPosition(a);const{point2d:P,zoom:x}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=x,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(x),g.setResult([k(v(v({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Vt=(e,t,s,u)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:p}=s;p.loadPCDFileByBox(u,e,{height:q,depth:q});const{cameraPositionVector:g}=p.updateOrthoCamera(e,G.Back);p.setInitCameraPosition(g);const{polygon2d:c,zoom:a}=p.getBoxBackPolygon2DCoordinate(e);p.camera.zoom=a,p.camera.updateProjectionMatrix(),p.render(),o.initPosition(),o.zoomChangeOnCenter(a),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},Ot=(e,t,s,u)=>{if(!s||!u)return;u.generateSphere(e),u.updateCameraBySphere(e,G.Top),u.render();const{toolInstance:o,pointCloudInstance:p}=s,{point2d:g}=p.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(a=>a.id===t.id?k(v(v({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);o.setResult(c),o.setSelectedID(t.id)},pt=(e,t,s,u)=>{var o,p;if(!s||!u)return;u.generateBox(e,t.id),u.render();const{pointCloud2dOperation:g,pointCloudInstance:c}=s,{polygon2d:a}=c.getBoxTopPolygon2DCoordinate(e),P=[...g.polygonList],x=P.find(y=>y.id===t.id);x?(x.pointList=a,x.valid=(o=e.valid)!=null?o:!0):P.push({id:t.id,pointList:a,textAttribute:"",isRect:!0,valid:(p=e.valid)!=null?p:!0}),g.setResultAndSelectedID(P,t.id)},vo=()=>{const e=xt(Lt),{topViewInstance:t,sideViewInstance:s,backViewInstance:u,mainViewInstance:o,addPointCloudBox:p,addPointCloudSphere:g,setSelectedIDs:c,selectedIDs:a,pointCloudBoxList:P,pointCloudSphereList:x,hideAttributes:y,setHighlight2DDataList:A,cuboidBoxIn2DView:_,imageSizes:S,history:z,linkageImageNameRectMap:T}=e,{addHistory:U,initHistory:j,pushHistoryUnderUpdatePolygon:E}=po(),{selectedPolygon:I}=go(),{getPointCloudSphereByID:kt,updatePointCloudSphere:gt,selectedSphere:J}=so(),{currentData:H,config:b}=lo(n=>{const{stepList:i,step:d,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:rt(co.getCurrentStepInfo(d,i).config)}}),M=ao(),At=dt(_),Tt=ht(n=>n.filter(d=>{var r,l;return d&&((l=(r=T.get(d.imageName))==null?void 0:r.size)!=null?l:0)===0}),[T]),$=n=>{const{enableAutoMap2DRect:i=!1}=b;if(!At.current||i){const{mappingImgList:d=[]}=H;uo({pointCloudBox:n,mappingImgList:d,imageSizes:S},{prepareRectsFn:Tt})}},{selectedBox:V,updateSelectedBox:Ut,updateSelectedBoxes:tt,getPointCloudByID:zt}=io({generateRects:$}),ft=V==null?void 0:V.info;if(!t||!s||!u)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,jt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},Nt=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},Et=({newPoint:n,size:i,zoom:d,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:x})});const m=ct(n,i,ot,void 0,f);c(n.id);const C=g(m);Q(B.Top,n,m,d,C,b),U({newSphereParams:m})},Mt=({polygon:n,size:i,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var m,C,h;const R={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};r===!0&&Object.assign(R,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:x})});const F=t==null?void 0:t.toolInstance,D=v({},n);let{boxParams:L,newPointList:N}=ut(D,i,ot,void 0,R,f);L=M(lt({tool:it.PointCloud,dataList:[L],stepConfig:b,action:"viewUpdateBox"}))[0],f&&(N==null?void 0:N.length)&&(D.pointList=N);const nt=y.includes(D.attribute);$(L);const Z=p(L),X=(C=e==null?void 0:e.polygonList)!=null?C:[];L.subAttribute=to.getDefaultResultByConfig((b==null?void 0:b.secondaryAttributeConfigurable)?(h=b==null?void 0:b.inputList)!=null?h:[]:[]),t==null||t.updatePolygonList(Z!=null?Z:[],X),nt?c([]):(c(L.id),F.selection.setSelectedIDs(D.id),W({omitView:B.Top,polygon:D,boxParams:L,zoom:l,newPointCloudBoxList:Z}),f&&pt(L,D,t,o)),U({newBoxParams:L})},Ft=n=>{const{boxID:i,imageName:d,width:r,height:l,x:f,y:m}=n,C=P.find(L=>L.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(L=>L.imageName===d))return;const R=C.rects.map(L=>L.imageName===d?k(v({},L),{width:r,height:l,x:f,y:m}):L),F=k(v({},C),{rects:R}),D=P.map(L=>L.id===i?F:L);return t==null||t.updatePolygonList(D!=null?D:[]),D},Ht=n=>{const{boxID:i,imageName:d}=n,r=P.find(C=>C.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(C=>C.imageName!==d),f=k(v({},r),{rects:l}),m=P.map(C=>C.id===i?f:C);return t==null||t.updatePolygonList(m!=null?m:[]),m},Wt=({newSelectedBox:n,newPointCloudList:i,newSelectedSphere:d,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(a.length===0||!f)){if(n||(V==null?void 0:V.info)){const m=n!=null?n:V==null?void 0:V.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(a[0]);const C=f.selectedPolygon;if(a.length===1&&m){W({omitView:B.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((d||J)&&a.length===1){const m=d!=null?d:J;f.setSelectedID(a[0]);const C=f.selectedPoint;m&&Q(B.Top,C,m,void 0,r,b)}}},Ct=(n,i,d)=>{if(ft){let r,l;switch(d){case B.Back:r=Lo;break;case B.Side:r=Dt;break;default:r=Dt;break}if(l=r(n,i,ft,s.pointCloudInstance),o){const{count:R}=o.getSensesPointZAxisInPolygon(oo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=k(v({},l),{count:R})}const m=M(lt({tool:it.PointCloud,dataList:[l],stepConfig:b,action:"viewUpdateBox"}))[0],C=l.valid!==m.valid;l=m;const h=Ut(l);return l=h.find(R=>R.id===l.id),W({omitView:C?void 0:d,polygon:n,boxParams:l,newPointCloudBoxList:h}),h}},Pt=(n,i,d)=>{if(J){let r,l;switch(d){case B.Back:r=ho;break;case B.Side:r=It;break;default:r=It;break}l=r(n,i,J);const f=gt(l);return Q(d,n,l,void 0,f,b),f}},Zt=(n,i)=>{Pt(n,i,B.Side)},Gt=(n,i)=>{Pt(n,i,B.Back)},Jt=(n,i)=>{Ct(n,i,B.Side)},Qt=(n,i)=>{Ct(n,i,B.Back)},Xt=(n,i)=>{const d=kt(n.id),r=ct(n,i,ot,d),l=gt(r);Q(B.Top,n,r,void 0,l,b)},Yt=(n,i)=>{if(I){const r=v({},n[0].newPolygon);r.pointList=r.pointList.map(l=>O.transferCanvas2World(l,i)),E(r);return}let d=n.map(({newPolygon:r})=>{const l=zt(r.id),{boxParams:f}=ut(r,i,t.pointCloudInstance,l);return f});if(d=M(lt({tool:it.PointCloud,dataList:d,stepConfig:b,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=n[0],l=tt(d);W({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=tt(d);r&&e.syncAllViewPointCloudColor(st.MultiMove,r)}},qt=n=>{var i,d,r,l,f;if(V){const m=Number(n.widthDefault),C=Number(n.depthDefault),h=Number(n.heightDefault),R=V==null?void 0:V.info.trackID,D=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===R),L={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},N=D.pointList.map(Y=>O.transferCanvas2World(Y,L)),et=w.getModifiedRectangleCoordinates(N,h,m),nt=et[0],Z=et[2],X=w.getLineCenterPoint([nt,Z]),Kt=V.info.center.z-V.info.depth/2,mt=k(v({},V.info),{center:{x:X.x,y:X.y,z:Kt+C/2},width:m,height:h,depth:C,valid:!0}),$t=tt([mt]);W({omitView:B["3D"],polygon:D,boxParams:mt,newPointCloudBoxList:$t})}},Q=(n,i,d,r,l,f)=>at(void 0,null,function*(){const m=H==null?void 0:H.url,C={[B.Side]:()=>{St(d,i,s,m,f)},[B.Back]:()=>{u&&Rt(d,i,u,m,f)},[B.Top]:()=>{Ot(d,i,t,o)}};Object.keys(C).forEach(h=>{h!==n&&C[h]()}),r&&(o==null||o.updateCameraZoom(r)),Nt(d)}),W=n=>at(void 0,null,function*(){const{omitView:i,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:f}=n,m=H==null?void 0:H.url;f&&(yield e.syncAllViewPointCloudColor(st.Single,f));const C={[B.Side]:()=>{_t(r,d,s,m)},[B.Back]:()=>{u&&Vt(r,d,u,m)},[B.Top]:()=>{pt(r,d,t,o)}};Object.keys(C).forEach(h=>{h!==i&&C[h]()}),l&&(o==null||o.updateCameraZoom(l)),jt(r)});return{topViewAddSphere:Et,topViewAddBox:Mt,topViewSelectedChanged:Wt,topViewUpdatePoint:Xt,sideViewUpdatePoint:Zt,backViewUpdatePoint:Gt,topViewUpdateBox:Yt,sideViewUpdateBox:Jt,backViewUpdateBox:Qt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const i=O.getDefaultOrthographicParams(n);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>at(void 0,[...n],function*(i=H){var d,r,l,f,m,C;if(!(i==null?void 0:i.url)||!o)return;A([]),vt(M,!0),yt(M,!0),yield o.loadPCDFile(i.url,(d=b==null?void 0:b.radius)!=null?d:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let h=[],R=[],F=[],D=[];o.updateTopCamera();const L=(l=(r=rt(i.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(L),(f=e.sideViewInstance)==null||f.clearAllData(),(m=e.backViewInstance)==null||m.clearAllData(),i.result){if(h=O.getBoxParamsFromResultList(i.result),(h==null?void 0:h.length)>0&&i.isPreResult&&(b==null?void 0:b.lowerLimitPointsNumInBox)>0){h=yield o==null?void 0:o.filterPreResult(i.url,b,h);const N=rt(i.result);N[eo].result=h,i.result=JSON.stringify(N),e.setPointCloudResult(h)}F=O.getPolygonListFromResultList(i.result),R=O.getLineListFromResultList(i.result),D=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(C=b==null?void 0:b.radius)!=null?C:K}),o==null||o.generateBoxes(h),o==null||o.generateSpheres(D),yield e.syncAllViewPointCloudColor(st.Default,h,[])}j({pointCloudBoxList:h,polygonList:F,lineList:R,pointCloudSphereList:D}),vt(M,!1),yt(M,!1)}),updateViewsByDefaultSize:qt,generateRects:$,update2DViewRect:Ft,remove2DViewRect:Ht}},yo=()=>{const{pointCloudBoxList:e,rectList:t,setPointCloudResult:s}=xt(Lt),u=dt(e),o=dt(t);return{syncToPointCloudBoxList:ht(()=>{const g=u.current,c=o.current;if(c.length===0)return;const a=new Map,P=new Set;if(c.filter(x=>x.extId!==void 0).forEach(x=>{const y=x.extId,A=x.imageName,_=ro(x,["x","y","width","height"]);let S=a.get(y);S||(S=new Map,a.set(y,S)),S.set(A,_),P.add(y)}),a.size){const x=g.map(y=>{var A;const _=y.id;if(P.has(_)){const S=v({},y);return(A=S.rects)==null||A.forEach(z=>{var T;const U=z.imageName;Object.assign(z,(T=a.get(_))==null?void 0:T.get(U))}),S}return y});s(x)}},[])}};export{Rt as syncBackViewByPoint,St as syncSideViewByPoint,Ot as syncTopViewByPoint,Vt as synchronizeBackView,_t as synchronizeSideView,pt as synchronizeTopView,ct as topViewPoint2PointCloud,ut as topViewPolygon2PointCloud,vo as usePointCloudViews,yo as useSyncRectPositionDimensionToPointCloudList};
|
package/es/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import f from"lodash";import{pointCloudLidar2image as y}from"@labelbee/lb-annotation";var _=Object.defineProperty,x=Object.defineProperties,O=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))P.call(t,n)&&h(e,n,t[n]);if(g)for(var n of g(t))v.call(t,n)&&h(e,n,t[n]);return e},b=(e,t)=>x(e,O(t));const I=(e,t={})=>{try{return typeof e=="string"?JSON.parse(e):f.isObject(e)?e:t}catch(n){return t}},j=e=>{if(Array.isArray(e))return e.filter(t=>t).join(" ");if(f.isObject(e)){const t=[];return Object.keys(e).forEach(n=>{e[n]&&t.push(n)}),t.join(" ")}return""},m=e=>{let t=Infinity,n=Infinity,r=-Infinity,o=-Infinity;for(const i of e)t=Math.min(t,i.x),n=Math.min(n,i.y),r=Math.max(r,i.x),o=Math.max(o,i.y);return{x:t,y:n,width:r-t,height:o-n}},u=(()=>{const e=(t,n)=>{const r=Math.max(t.x,n.x),o=Math.max(t.y,n.y),i=Math.min(t.x+t.width,n.x+n.width),c=Math.min(t.y+t.height,n.y+n.height),s=i-r,a=c-o;return s>=0&&a>=0?{x:r,y:o,width:s,height:a}:null};return(t,n,r)=>{if(r[n]){const o=r[n].width,i=r[n].height;return e(t,{x:0,y:0,width:o,height:i})!==null}return!1}})(),d=e=>{var t;const{pointCloudBox:n,mappingData:r,imageSizes:o}=e,{transferViewData:i}=(t=y(n,r.calib))!=null?t:{};if(!i)return;const c=i.reduce((p,l)=>l.type==="line"?[...p,...l.pointList]:p,[]),s=b(w({},m(c)),{imageName:r.path});if(u(s,r.path,o))return s},R=(e,t)=>{var n;const{pointCloudBox:r,mappingImgList:o,imageSizes:i}=e,s=o.map(a=>d({pointCloudBox:r,mappingData:a,imageSizes:i})).filter(a=>a!==void 0);if(s.length>0){const a=(n=t==null?void 0:t.prepareRectsFn)!=null?n:void 0,p=a?a(s,r):s;Object.assign(r,{rects:p})}};export{j as classnames,R as generatePointCloudBoxRects,m as getBoundingRect,d as getRectPointCloudBox,u as isBoundingRectInImage,I as jsonParser};
|