@labelbee/lb-components 1.23.0-alpha.72 → 1.23.0-alpha.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var dom=require("../../utils/dom.js"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),reactRedux=require("react-redux"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),map=require("../../store/annotation/map.js"),PointCloud2DSingleView=require("./PointCloud2DSingleView.js"),index=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons"),classNames=require("classnames"),icon_esc=require("../../assets/annotation/common/icon_esc.svg.js"),icon_left_squareOutlined=require("../../assets/annotation/common/icon_left_squareOutlined.svg.js"),icon_right_squareOutlined=require("../../assets/annotation/common/icon_right_squareOutlined.svg.js"),_2DViewWorker=require("../../_virtual/2DViewWorker.js"),ahooks=require("ahooks");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames);const EKeyCode=lbAnnotation.cKeyCode.default,ContainerTitle=({showEnlarge:e,isEnlargeTopView:g,data:
|
|
1
|
+
"use strict";var dom=require("../../utils/dom.js"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),reactRedux=require("react-redux"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),map=require("../../store/annotation/map.js"),PointCloud2DSingleView=require("./PointCloud2DSingleView.js"),index=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons"),classNames=require("classnames"),icon_esc=require("../../assets/annotation/common/icon_esc.svg.js"),icon_left_squareOutlined=require("../../assets/annotation/common/icon_left_squareOutlined.svg.js"),icon_right_squareOutlined=require("../../assets/annotation/common/icon_right_squareOutlined.svg.js"),_2DViewWorker=require("../../_virtual/2DViewWorker.js"),ahooks=require("ahooks");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames);const EKeyCode=lbAnnotation.cKeyCode.default,ContainerTitle=({showEnlarge:e,isEnlargeTopView:g,data:a,setIsEnlarge:u,setCurIndex:s,curIndex:c=0,index:f,annotations2d:d})=>g?React__default.default.createElement(index,{title:a==null?void 0:a.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):e?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{u(!1),s(void 0)}}),React__default.default.createElement("span",null,a==null?void 0:a.calName),React__default.default.createElement("span",{style:{marginLeft:"8px"}},c+1,"/",d==null?void 0:d.length)):React__default.default.createElement(index,{title:a==null?void 0:a.calName,onClick:()=>{u(!0),s(f)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),PointCloud2DView=({currentData:e,config:g,thumbnailWidth:a,isEnlargeTopView:u,highlightAttribute:s,loadPCDFileLoading:c,checkMode:f,measureVisible:d})=>{var x;const[r,w]=React.useState([]),{topViewInstance:L,displayPointCloudList:y,polygonList:C,imageSizes:h,selectedIDs:k,windowKeydownListenerHook:v}=React.useContext(PointCloudContext.PointCloudContext),[_,F]=React.useState(""),[m,P]=React.useState(!1),[l,p]=React.useState(void 0),E=React.useCallback(t=>{P(t),lbAnnotation.EventBus.emit("2d-image:enlarge",t)},[]),i=React.useRef();React.useEffect(()=>{var t;if(!c&&L&&(e==null?void 0:e.mappingImgList)&&((t=e==null?void 0:e.mappingImgList)==null?void 0:t.length)>0)return i.current&&i.current.terminate(),i.current=new _2DViewWorker,i.current.onmessage=n=>{var o;const N=n.data;w(N),(o=i.current)==null||o.terminate()},i.current.postMessage({currentData:e,displayPointCloudList:y,selectedID:_,highlightAttribute:s,imageSizes:h,config:g,polygonList:C,selectedIDs:k}),()=>{var n;(n=i.current)==null||n.terminate()}},[y,e==null?void 0:e.mappingImgList,_,s,c,C,h,k]);const I=ahooks.useLatest(t=>{if(!m)return;const n=()=>{t.stopImmediatePropagation()};switch(t.keyCode){case EKeyCode.Esc:{E(!1),n();break}case EKeyCode.Left:{b(),n();break}case EKeyCode.Right:{q(),n();break}case EKeyCode.Up:case EKeyCode.Down:case EKeyCode.Q:case EKeyCode.E:case EKeyCode.G:case EKeyCode.F:case EKeyCode.Tab:{n();break}}t.shiftKey&&t.keyCode===EKeyCode.Tab&&n()}),b=()=>{l===void 0||!m||Number(l)>0&&p(l-1)},q=()=>{l===void 0||!m||Number(l)<(r==null?void 0:r.length)-1&&p(l+1)};React.useEffect(()=>{const t=o=>I.current(o);return v.preappendEventListener(t)},[v,v.preappendEventListener]);const j=!e||!(e==null?void 0:e.mappingImgList)||!(((x=e==null?void 0:e.mappingImgList)==null?void 0:x.length)>0),S=React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},React__default.default.createElement("img",{src:icon_left_squareOutlined,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>b()}),React__default.default.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),React__default.default.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),React__default.default.createElement("img",{src:icon_right_squareOutlined,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>q()}),React__default.default.createElement("img",{src:icon_esc,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{E(!1),p(void 0)}}),React__default.default.createElement("span",null,"\u952E\u9000\u51FA"));return(r==null?void 0:r.length)>0?React__default.default.createElement(React__default.default.Fragment,null,r.map((t,n)=>{const o=m&&n===l;return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-2d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:o}),title:React__default.default.createElement(ContainerTitle,{showEnlarge:o,isEnlargeTopView:u,data:t,setIsEnlarge:E,setCurIndex:p,curIndex:l,index:n,annotations2d:r}),titleOnSurface:!o,style:{display:j?"none":"flex",width:o?"100%":a},key:n,toolbar:S},(t==null?void 0:t.annotations)&&(t==null?void 0:t.url)&&React__default.default.createElement(PointCloud2DSingleView,{key:t.url,currentData:e,view2dData:t,setSelectedID:F,showEnlarge:o,checkMode:f,measureVisible:d}))})):null};var PointCloud2DView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DView);module.exports=PointCloud2DView$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"),useTimeoutFunc=require("./hooks/useTimeoutFunc.js"),useWindowKeydownListener=require("./hooks/useWindowKeydownListener.js");function _interopDefaultLegacy(l){return l&&typeof l=="object"&&"default"in l?l:{default:l}}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=(l,n,d)=>n in l?__defProp(l,n,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[n]=d,__spreadValues=(l,n)=>{for(var d in n||(n={}))__hasOwnProp.call(n,d)&&__defNormalProp(l,d,n[d]);if(__getOwnPropSymbols)for(var d of __getOwnPropSymbols(n))__propIsEnum.call(n,d)&&__defNormalProp(l,d,n[d]);return l},__spreadProps=(l,n)=>__defProps(l,__getOwnPropDescs(n)),__async=(l,n,d)=>new Promise((S,y)=>{var R=c=>{try{f(d.next(c))}catch(b){y(b)}},N=c=>{try{f(d.throw(c))}catch(b){y(b)}},f=c=>c.done?S(c.value):Promise.resolve(c.value).then(R,N);f((d=d.apply(l,n)).next())});const pickRectObject=l=>___default.default.pick(l,["id","attribute","width","height","x","y","imageName"]),PointCloudContext=React__default.default.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new lbAnnotation.ActionsHistory,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:lbAnnotation.EToolName.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:lbUtils.EPointCloudPattern.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:l=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:l=>!1,removeRectBySpecifyId:(l,n,d)=>!1,removeRectByPointCloudBoxId:l=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:useWindowKeydownListener.getEmptyUseWindowKeydownListener()}),PointCloudProvider=({children:l})=>{const[n,d]=React.useState([]),[S,y]=React.useState([]),[R,N]=React.useState([]),[f,c]=React.useState([]),[b,me]=React.useState([]),[h,D]=React.useState([]),[w,H]=React.useState([]),[W,ve]=React.useState(!0),[K,Ce]=React.useState(2),[G,Ie]=React.useState(!0),[U,Pe]=React.useState(1),[u,Z]=React.useState(),[J,Q]=React.useState(),[X,Y]=React.useState(),[a,$]=React.useState(),[ee,Se]=React.useState(""),[A,be]=React.useState(lbAnnotation.EToolName.Rect),B=React.useRef(new lbAnnotation.ActionsHistory).current,[g,O]=React.useState([]),[te,we]=React.useState(""),[k,ye]=React.useState(lbUtils.EPointCloudPattern.Detection),[P,oe]=React.useState(void 0),[E,Re]=React.useState([]),[j,xe]=React.useState([]),[ne,Le]=React.useState(!1),p=index(),[ie,De]=React.useState({}),Ae=ctx.useDispatch(),Be=e=>{const{imgNode:t,path:o}=e;o&&t&&De(i=>__spreadProps(__spreadValues({},i),{[o]:{width:t.width,height:t.height}}))},q=React.useMemo(()=>h.length===1?h[0]:"",[h]),se=useWindowKeydownListener.default(),V=React.useCallback((e,t,o="extId")=>{const i=o||"id",s=new Set(t);return c(r=>{let C=!1;const m=r.filter(L=>{const I=L[i],v=s.has(I)?L.imageName!==e:!0;return v||(C=!0),v});return C?m:r}),!0},[]),le=React.useCallback(e=>{const t=n.map(o=>o.id);return V(e,t,"extId")},[n,V]),re=React.useCallback(e=>{if(!e)return!1;const t=n.filter(o=>Array.isArray(o.rects)).map(o=>{const{id:i,attribute:s,trackID:r}=o,C=o.rects.find(m=>m.imageName===e);if(C){const m=___default.default.pick(C,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},m),{id:lbAnnotation.uuid(),attribute:s,order:r,extId:i,lineDash:[]})}return null}).filter(o=>o!==null);return t.length?(c(o=>{const i=new Set(o.filter(r=>e===r.imageName).map(r=>r.extId)),s=t.filter(r=>i.has(r.extId)===!1);return s.length?[...o,...s]:o}),!0):!1},[n]),ae=React.useMemo(()=>n.filter(t=>Array.isArray(t.rects)&&t.rects.length>0).reduce((t,o)=>{var i;return(i=o.rects)==null||i.forEach(s=>{const{imageName:r}=s;if(!r){console.warn("Missing image name"),console.trace(s,o);return}map.addMapIndirectWeakSetItem(t,r,o.id,o)}),t},new Map),[n]),de=React.useCallback(e=>{c(t=>e(t,pickRectObject))},[pickRectObject]),ue=React.useMemo(()=>f.filter(e=>e.extId!==void 0&&e.id!==void 0).reduce((e,t)=>{const o=t.imageName;return o?(map.addMapIndirectWeakSetItem(e,o,t.extId,t),e):(console.warn("missing image name"),console.log(t,f),e)},new Map),[f]),{fn:_e}=useTimeoutFunc.default(e=>{D(t=>{const o=e,i=new Set(o);let s=!1;const r=t.filter(C=>{const m=i.has(C);return m||(s=!0),m});return s?r:t})},200),ce=React.useCallback(e=>{const t=e.map(o=>o.id);d(e),_e(t)},[]),ge=React.useMemo(()=>n.find(e=>e.id===q),[n,q]),F=React.useMemo(()=>n.filter(e=>!g.includes(e.attribute)),[n,g]),T=React.useMemo(()=>S.filter(e=>!g.includes(e.attribute)),[S,g]),z=React.useMemo(()=>b.filter(e=>e.attribute&&!g.includes(e.attribute)),[b,g]),ke=React.useCallback(e=>{const t=n.concat(e);return ce(t),t},[n]),Ve=React.useCallback(e=>{const t=S.concat(e);return y(t),t},[S]),Me=React.useCallback(e=>{ve(e!==!1)},[]),x=React.useCallback(e=>{e===void 0&&D([]),typeof e=="string"&&D([e]),Array.isArray(e)&&D(Array.from(new Set(e)))},[]),Ne=React.useCallback(e=>{h.includes(e)?x(h.filter(t=>t!==e)):x([...h,e])},[h]),He=React.useCallback(e=>{const t=pickRectObject(e);c(o=>[...o,t])},[f]),Oe=React.useCallback((e,t=!1)=>{const o=pickRectObject(e);c(i=>i.map(s=>s.id===e.id?t?__spreadValues(__spreadValues({},s),o):o:s))},[f]),Ee=React.useCallback(e=>{c(t=>t.filter(o=>!e.find(i=>i.id===o.id)))},[f]),je=React.useCallback(e=>{w.includes(e)?H([]):H([e])},[w]),qe=React.useCallback(()=>{if(A===lbAnnotation.EToolName.Rect){const e=n.map(t=>t.id);x(e),u==null||u.pointCloud2dOperation.setSelectedIDs(e)}},[A,n,u,u==null?void 0:u.pointCloud2dOperation]),Fe=React.useCallback(e=>{x(n.filter(t=>t.attribute===e).map(t=>t.id))},[n]),Te=React.useCallback(e=>{if(g.includes(e))O(g.filter(t=>t!==e));else{const t=g.concat(e);O(t)}},[g]),ze=React.useCallback((e=F,t=R,o=T,i=z,s=E)=>{var r;a==null||a.clearAllBox(),a==null||a.clearAllSphere(),u==null||u.updatePolygonList(e,t),u==null||u.updatePointList(o),u==null||u.updateLineList(i),a==null||a.generateBoxes(e),a==null||a.generateSpheres(o),(r=P==null?void 0:P.store)==null||r.updateCurrentSegment(s),fe(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},[a,u,P,P==null?void 0:P.store]),We=React.useCallback(()=>{Z(void 0),Q(void 0),Y(void 0),$(void 0)},[]),fe=React.useCallback((e,t,o)=>__async(void 0,null,function*(){var i,s,r;if(!a)return;const C=a.pointCloudObject;if(!C)return;let m=[],L=[];try{if(t&&B.record.length){const{record:I,recordIndex:v}=B;let pe=v;v>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&t.length===((i=I[v])==null?void 0:i.pointCloudBoxList.length))&&(pe=v-1);let Ue=(s=I[pe])==null?void 0:s.pointCloudBoxList;const he=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,t,Ue);m=he.modifiedBoxIds,L=he.resetAreas}}catch(I){console.error("call calcResetAreasAndBoxIds error",I)}try{const I=yield a.getHighlightIndexByMappingImgList({mappingImgList:o!=null?o:j,points:C.geometry.attributes.position.array}),v=yield a==null?void 0:a.highlightOriginPointCloud(t,I,{modifiedBoxIds:m,resetAreas:L});return v&&((r=u==null?void 0:u.pointCloudInstance)==null||r.updateColor(v)),v}catch(I){console.error("call highlightOriginPointCloud error",I)}}),[a,a==null?void 0:a.pointCloudObject,B]),Ke=React.useCallback(e=>{k!==e&&(Ae(actionCreators.ChangeSave),ye(e),e===lbUtils.EPointCloudPattern.Detection&&oe(void 0))},[k]),M=React.useMemo(()=>({selectedID:q,pointCloudBoxList:n,pointCloudSphereList:S,displayPointCloudList:F,displaySphereList:T,displayLineList:z,selectedIDs:h,setPointCloudResult:ce,setSelectedIDs:x,addPointCloudBox:ke,addPointCloudSphere:Ve,setPointCloudSphereList:y,valid:W,selectedPointCloudBox:ge,setPointCloudValid:Me,addSelectedID:Ne,addHighlightID:je,selectedAllBoxes:qe,topViewInstance:u,setTopViewInstance:Z,sideViewInstance:J,setSideViewInstance:Q,backViewInstance:X,setBackViewInstance:Y,mainViewInstance:a,setMainViewInstance:$,polygonList:R,setPolygonList:N,rectList:f,setRectList:c,addRectIn2DView:He,removeRectIn2DView:Ee,updateRectIn2DView:Oe,lineList:b,setLineList:me,zoom:U,setZoom:Pe,history:B,toggleAttributesVisible:Te,hideAttributes:g,setHideAttributes:O,reRender:ze,attrPanelLayout:te,setAttrPanelLayout:we,syncAllViewPointCloudColor:fe,defaultAttribute:ee,setDefaultAttribute:Se,pointCloudPattern:A,setPointCloudPattern:be,selectSpecAttr:Fe,globalPattern:k,setGlobalPattern:Ke,ptSegmentInstance:P,setPtSegmentInstance:oe,segmentation:E,setSegmentation:Re,clearAllDetectionInstance:We,highlight2DDataList:j,setHighlight2DDataList:xe,highlight2DLoading:ne,setHighlight2DLoading:Le,cuboidBoxIn2DView:G,setCuboidBoxIn2DView:Ie,imageSizes:ie,cacheImageNodeSize:Be,highlightIDs:w,setHighlightIDs:H,removeRectByPointCloudBoxId:le,removeRectBySpecifyId:V,addRectFromPointCloudBoxByImageName:re,rectRotateSensitivity:K,setRectRotateSensitivity:Ce,imageNamePointCloudBoxMap:ae,linkageImageNameRectMap:ue,updateRectListByReducer:de,windowKeydownListenerHook:se}),[W,ge,F,T,z,R,f,u,J,X,a,U,te,ee,A,k,P,E,j,ne,G,ie,w,le,V,re,K,ae,ue,de,se]);React.useEffect(()=>{var e,t,o;(e=p==null?void 0:p.setPointCloudBoxList)==null||e.call(p,n),(t=p==null?void 0:p.setHighlightIDs)==null||t.call(p,w),(o=p==null?void 0:p.setSelectedIDs)==null||o.call(p,h)},[n,h,w]),React.useEffect(()=>{var e;(e=p==null?void 0:p.setPtCtx)==null||e.call(p,M)},[M]);const Ge=()=>{const e=n.filter(s=>g.includes(s.attribute)),{setSelectedIDs:t,reRender:o}=M,i=e.map(s=>s.id);i.length>0&&t(h.filter(s=>!i.includes(s))),o()};return React.useEffect(()=>{var e,t,o,i;Ge(),(t=(e=u==null?void 0:u.toolInstance)==null?void 0:e.setHiddenAttributes)==null||t.call(e,g),(i=(o=P==null?void 0:P.store)==null?void 0:o.setHiddenAttributes)==null||i.call(o,g)},[g]),React__default.default.createElement(PointCloudContext.Provider,{value:M},l)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),React=require("react"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),actionCreators=require("../../store/annotation/actionCreators.js"),index=require("../../store/annotatedBox/index.js"),_=require("lodash"),map=require("./utils/map.js"),useTimeoutFunc=require("./hooks/useTimeoutFunc.js"),useWindowKeydownListener=require("./hooks/useWindowKeydownListener.js");function _interopDefaultLegacy(l){return l&&typeof l=="object"&&"default"in l?l:{default:l}}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=(l,n,d)=>n in l?__defProp(l,n,{enumerable:!0,configurable:!0,writable:!0,value:d}):l[n]=d,__spreadValues=(l,n)=>{for(var d in n||(n={}))__hasOwnProp.call(n,d)&&__defNormalProp(l,d,n[d]);if(__getOwnPropSymbols)for(var d of __getOwnPropSymbols(n))__propIsEnum.call(n,d)&&__defNormalProp(l,d,n[d]);return l},__spreadProps=(l,n)=>__defProps(l,__getOwnPropDescs(n)),__async=(l,n,d)=>new Promise((S,y)=>{var R=c=>{try{f(d.next(c))}catch(b){y(b)}},H=c=>{try{f(d.throw(c))}catch(b){y(b)}},f=c=>c.done?S(c.value):Promise.resolve(c.value).then(R,H);f((d=d.apply(l,n)).next())});const pickRectObject=l=>___default.default.pick(l,["id","attribute","width","height","x","y","imageName"]),PointCloudContext=React__default.default.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new lbAnnotation.ActionsHistory,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:lbAnnotation.EToolName.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:lbUtils.EPointCloudPattern.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:l=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:l=>!1,removeRectBySpecifyId:(l,n,d)=>!1,removeRectByPointCloudBoxId:l=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:useWindowKeydownListener.getEmptyUseWindowKeydownListener()}),PointCloudProvider=({children:l})=>{const[n,d]=React.useState([]),[S,y]=React.useState([]),[R,H]=React.useState([]),[f,c]=React.useState([]),[b,me]=React.useState([]),[h,D]=React.useState([]),[w,O]=React.useState([]),[W,ve]=React.useState(!0),[K,Ce]=React.useState(2),[G,Ie]=React.useState(!0),[U,Pe]=React.useState(1),[u,Z]=React.useState(),[J,Q]=React.useState(),[X,Y]=React.useState(),[a,$]=React.useState(),[ee,Se]=React.useState(""),[A,be]=React.useState(lbAnnotation.EToolName.Rect),B=React.useRef(new lbAnnotation.ActionsHistory).current,[g,E]=React.useState([]),[te,we]=React.useState(""),[k,ye]=React.useState(lbUtils.EPointCloudPattern.Detection),[P,oe]=React.useState(void 0),[j,Re]=React.useState([]),[V,xe]=React.useState([]),[ne,Le]=React.useState(!1),p=index(),[ie,De]=React.useState({}),Ae=ctx.useDispatch(),Be=e=>{const{imgNode:t,path:o}=e;o&&t&&De(i=>__spreadProps(__spreadValues({},i),{[o]:{width:t.width,height:t.height}}))},q=React.useMemo(()=>h.length===1?h[0]:"",[h]),se=useWindowKeydownListener.default(),M=React.useCallback((e,t,o="extId")=>{const i=o||"id",s=new Set(t);return c(r=>{let C=!1;const m=r.filter(L=>{const I=L[i],v=s.has(I)?L.imageName!==e:!0;return v||(C=!0),v});return C?m:r}),!0},[]),le=React.useCallback(e=>{const t=n.map(o=>o.id);return M(e,t,"extId")},[n,M]),re=React.useCallback(e=>{if(!e)return!1;const t=n.filter(o=>Array.isArray(o.rects)).map(o=>{const{id:i,attribute:s,trackID:r}=o,C=o.rects.find(m=>m.imageName===e);if(C){const m=___default.default.pick(C,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},m),{id:lbAnnotation.uuid(),attribute:s,order:r,extId:i,lineDash:[]})}return null}).filter(o=>o!==null);return t.length?(c(o=>{const i=new Set(o.filter(r=>e===r.imageName).map(r=>r.extId)),s=t.filter(r=>i.has(r.extId)===!1);return s.length?[...o,...s]:o}),!0):!1},[n]),ae=React.useMemo(()=>n.filter(t=>Array.isArray(t.rects)&&t.rects.length>0).reduce((t,o)=>{var i;return(i=o.rects)==null||i.forEach(s=>{const{imageName:r}=s;if(!r){console.warn("Missing image name"),console.trace(s,o);return}map.addMapIndirectWeakSetItem(t,r,o.id,o)}),t},new Map),[n]),de=React.useCallback(e=>{c(t=>e(t,pickRectObject))},[pickRectObject]),ue=React.useMemo(()=>f.filter(e=>e.extId!==void 0&&e.id!==void 0).reduce((e,t)=>{const o=t.imageName;return o?(map.addMapIndirectWeakSetItem(e,o,t.extId,t),e):(console.warn("missing image name"),console.log(t,f),e)},new Map),[f]),{fn:_e}=useTimeoutFunc.default(e=>{D(t=>{const o=e,i=new Set(o);let s=!1;const r=t.filter(C=>{const m=i.has(C);return m||(s=!0),m});return s?r:t})},200),ce=React.useCallback(e=>{const t=e.map(o=>o.id);d(e),_e(t)},[]),ge=React.useMemo(()=>n.find(e=>e.id===q),[n,q]),F=React.useMemo(()=>n.filter(e=>!g.includes(e.attribute)),[n,g]),T=React.useMemo(()=>S.filter(e=>!g.includes(e.attribute)),[S,g]),z=React.useMemo(()=>b.filter(e=>e.attribute&&!g.includes(e.attribute)),[b,g]),ke=React.useCallback(e=>{const t=n.concat(e);return ce(t),t},[n]),Ve=React.useCallback(e=>{const t=S.concat(e);return y(t),t},[S]),Me=React.useCallback(e=>{ve(e!==!1)},[]),x=React.useCallback(e=>{e===void 0&&D([]),typeof e=="string"&&D([e]),Array.isArray(e)&&D(Array.from(new Set(e)))},[]),Ne=React.useCallback(e=>{h.includes(e)?x(h.filter(t=>t!==e)):x([...h,e])},[h]),He=React.useCallback(e=>{const t=pickRectObject(e);c(o=>[...o,t])},[f]),Oe=React.useCallback((e,t=!1)=>{const o=pickRectObject(e);c(i=>i.map(s=>s.id===e.id?t?__spreadValues(__spreadValues({},s),o):o:s))},[f]),Ee=React.useCallback(e=>{c(t=>t.filter(o=>!e.find(i=>i.id===o.id)))},[f]),je=React.useCallback(e=>{w.includes(e)?O([]):O([e])},[w]),qe=React.useCallback(()=>{if(A===lbAnnotation.EToolName.Rect){const e=n.map(t=>t.id);x(e),u==null||u.pointCloud2dOperation.setSelectedIDs(e)}},[A,n,u,u==null?void 0:u.pointCloud2dOperation]),Fe=React.useCallback(e=>{x(n.filter(t=>t.attribute===e).map(t=>t.id))},[n]),Te=React.useCallback(e=>{if(g.includes(e))E(g.filter(t=>t!==e));else{const t=g.concat(e);E(t)}},[g]),ze=React.useCallback((e=F,t=R,o=T,i=z,s=j)=>{var r;a==null||a.clearAllBox(),a==null||a.clearAllSphere(),u==null||u.updatePolygonList(e,t),u==null||u.updatePointList(o),u==null||u.updateLineList(i),a==null||a.generateBoxes(e),a==null||a.generateSpheres(o),(r=P==null?void 0:P.store)==null||r.updateCurrentSegment(s),fe(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},[a,u,P,P==null?void 0:P.store]),We=React.useCallback(()=>{Z(void 0),Q(void 0),Y(void 0),$(void 0)},[]),fe=React.useCallback((e,t,o)=>__async(void 0,null,function*(){var i,s,r;if(!a)return;const C=a.pointCloudObject;if(!C)return;let m=[],L=[];try{if(t&&B.record.length){const{record:I,recordIndex:v}=B;let pe=v;v>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&t.length===((i=I[v])==null?void 0:i.pointCloudBoxList.length))&&(pe=v-1);let Ue=(s=I[pe])==null?void 0:s.pointCloudBoxList;const he=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,t,Ue);m=he.modifiedBoxIds,L=he.resetAreas}}catch(I){console.error("call calcResetAreasAndBoxIds error",I)}try{const I=yield a.getHighlightIndexByMappingImgList({mappingImgList:o!=null?o:V,points:C.geometry.attributes.position.array}),v=yield a==null?void 0:a.highlightOriginPointCloud(t,I,{modifiedBoxIds:m,resetAreas:L});return v&&((r=u==null?void 0:u.pointCloudInstance)==null||r.updateColor(v)),v}catch(I){console.error("call highlightOriginPointCloud error",I)}}),[a,a==null?void 0:a.pointCloudObject,B,V]),Ke=React.useCallback(e=>{k!==e&&(Ae(actionCreators.ChangeSave),ye(e),e===lbUtils.EPointCloudPattern.Detection&&oe(void 0))},[k]),N=React.useMemo(()=>({selectedID:q,pointCloudBoxList:n,pointCloudSphereList:S,displayPointCloudList:F,displaySphereList:T,displayLineList:z,selectedIDs:h,setPointCloudResult:ce,setSelectedIDs:x,addPointCloudBox:ke,addPointCloudSphere:Ve,setPointCloudSphereList:y,valid:W,selectedPointCloudBox:ge,setPointCloudValid:Me,addSelectedID:Ne,addHighlightID:je,selectedAllBoxes:qe,topViewInstance:u,setTopViewInstance:Z,sideViewInstance:J,setSideViewInstance:Q,backViewInstance:X,setBackViewInstance:Y,mainViewInstance:a,setMainViewInstance:$,polygonList:R,setPolygonList:H,rectList:f,setRectList:c,addRectIn2DView:He,removeRectIn2DView:Ee,updateRectIn2DView:Oe,lineList:b,setLineList:me,zoom:U,setZoom:Pe,history:B,toggleAttributesVisible:Te,hideAttributes:g,setHideAttributes:E,reRender:ze,attrPanelLayout:te,setAttrPanelLayout:we,syncAllViewPointCloudColor:fe,defaultAttribute:ee,setDefaultAttribute:Se,pointCloudPattern:A,setPointCloudPattern:be,selectSpecAttr:Fe,globalPattern:k,setGlobalPattern:Ke,ptSegmentInstance:P,setPtSegmentInstance:oe,segmentation:j,setSegmentation:Re,clearAllDetectionInstance:We,highlight2DDataList:V,setHighlight2DDataList:xe,highlight2DLoading:ne,setHighlight2DLoading:Le,cuboidBoxIn2DView:G,setCuboidBoxIn2DView:Ie,imageSizes:ie,cacheImageNodeSize:Be,highlightIDs:w,setHighlightIDs:O,removeRectByPointCloudBoxId:le,removeRectBySpecifyId:M,addRectFromPointCloudBoxByImageName:re,rectRotateSensitivity:K,setRectRotateSensitivity:Ce,imageNamePointCloudBoxMap:ae,linkageImageNameRectMap:ue,updateRectListByReducer:de,windowKeydownListenerHook:se}),[W,ge,F,T,z,R,f,u,J,X,a,U,te,ee,A,k,P,j,V,ne,G,ie,w,le,M,re,K,ae,ue,de,se]);React.useEffect(()=>{var e,t,o;(e=p==null?void 0:p.setPointCloudBoxList)==null||e.call(p,n),(t=p==null?void 0:p.setHighlightIDs)==null||t.call(p,w),(o=p==null?void 0:p.setSelectedIDs)==null||o.call(p,h)},[n,h,w]),React.useEffect(()=>{var e;(e=p==null?void 0:p.setPtCtx)==null||e.call(p,N)},[N]);const Ge=()=>{const e=n.filter(s=>g.includes(s.attribute)),{setSelectedIDs:t,reRender:o}=N,i=e.map(s=>s.id);i.length>0&&t(h.filter(s=>!i.includes(s))),o()};return React.useEffect(()=>{var e,t,o,i;Ge(),(t=(e=u==null?void 0:u.toolInstance)==null?void 0:e.setHiddenAttributes)==null||t.call(e,g),(i=(o=P==null?void 0:P.store)==null?void 0:o.setHiddenAttributes)==null||i.call(o,g)},[g]),React__default.default.createElement(PointCloudContext.Provider,{value:N},l)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as _}from"../../utils/dom.js";import t,{useState as
|
|
1
|
+
import{getClassName as _}from"../../utils/dom.js";import t,{useState as E,useContext as z,useCallback as D,useRef as $,useEffect as j}from"react";import{PointCloudContainer as q}from"./PointCloudLayout.js";import{PointCloudContext as M}from"./PointCloudContext.js";import{connect as W}from"react-redux";import{cKeyCode as G,EventBus as H}from"@labelbee/lb-annotation";import{LabelBeeContext as Q}from"../../store/ctx.js";import{a2MapStateToProps as U}from"../../store/annotation/map.js";import J from"./PointCloud2DSingleView.js";import S from"./components/TitleButton/index.js";import{LeftOutlined as X}from"@ant-design/icons";import Y from"classnames";import Z from"../../assets/annotation/common/icon_esc.svg.js";import ee from"../../assets/annotation/common/icon_left_squareOutlined.svg.js";import te from"../../assets/annotation/common/icon_right_squareOutlined.svg.js";import ne from"../../_virtual/2DViewWorker.js";import{useLatest as oe}from"ahooks";const i=G.default,ie=({showEnlarge:n,isEnlargeTopView:v,data:l,setIsEnlarge:u,setCurIndex:m,curIndex:p=0,index:x,annotations2d:d})=>v?t.createElement(S,{title:l==null?void 0:l.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):n?t.createElement("div",{style:{display:"flex",alignItems:"center"}},t.createElement(X,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{u(!1),m(void 0)}}),t.createElement("span",null,l==null?void 0:l.calName),t.createElement("span",{style:{marginLeft:"8px"}},p+1,"/",d==null?void 0:d.length)):t.createElement(S,{title:l==null?void 0:l.calName,onClick:()=>{u(!0),m(x)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),se=({currentData:n,config:v,thumbnailWidth:l,isEnlargeTopView:u,highlightAttribute:m,loadPCDFileLoading:p,checkMode:x,measureVisible:d})=>{var k;const[c,N]=E([]),{topViewInstance:R,displayPointCloudList:h,polygonList:b,imageSizes:w,selectedIDs:F,windowKeydownListenerHook:y}=z(M),[L,T]=E(""),[g,A]=E(!1),[r,f]=E(void 0),C=D(e=>{A(e),H.emit("2d-image:enlarge",e)},[]),a=$();j(()=>{var e;if(!p&&R&&(n==null?void 0:n.mappingImgList)&&((e=n==null?void 0:n.mappingImgList)==null?void 0:e.length)>0)return a.current&&a.current.terminate(),a.current=new ne,a.current.onmessage=o=>{var s;const O=o.data;N(O),(s=a.current)==null||s.terminate()},a.current.postMessage({currentData:n,displayPointCloudList:h,selectedID:L,highlightAttribute:m,imageSizes:w,config:v,polygonList:b,selectedIDs:F}),()=>{var o;(o=a.current)==null||o.terminate()}},[h,n==null?void 0:n.mappingImgList,L,m,p,b,w,F]);const V=oe(e=>{if(!g)return;const o=()=>{e.stopImmediatePropagation()};switch(e.keyCode){case i.Esc:{C(!1),o();break}case i.Left:{I(),o();break}case i.Right:{P(),o();break}case i.Up:case i.Down:case i.Q:case i.E:case i.G:case i.F:case i.Tab:{o();break}}e.shiftKey&&e.keyCode===i.Tab&&o()}),I=()=>{r===void 0||!g||Number(r)>0&&f(r-1)},P=()=>{r===void 0||!g||Number(r)<(c==null?void 0:c.length)-1&&f(r+1)};j(()=>{const e=s=>V.current(s);return y.preappendEventListener(e)},[y,y.preappendEventListener]);const K=!n||!(n==null?void 0:n.mappingImgList)||!(((k=n==null?void 0:n.mappingImgList)==null?void 0:k.length)>0),B=t.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},t.createElement("img",{src:ee,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>I()}),t.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),t.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),t.createElement("img",{src:te,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>P()}),t.createElement("img",{src:Z,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{C(!1),f(void 0)}}),t.createElement("span",null,"\u952E\u9000\u51FA"));return(c==null?void 0:c.length)>0?t.createElement(t.Fragment,null,c.map((e,o)=>{const s=g&&o===r;return t.createElement(q,{className:Y({[_("point-cloud-2d-container")]:!0,[_("point-cloud-container","zoom")]:s}),title:t.createElement(ie,{showEnlarge:s,isEnlargeTopView:u,data:e,setIsEnlarge:C,setCurIndex:f,curIndex:r,index:o,annotations2d:c}),titleOnSurface:!s,style:{display:K?"none":"flex",width:s?"100%":l},key:o,toolbar:B},(e==null?void 0:e.annotations)&&(e==null?void 0:e.url)&&t.createElement(J,{key:e.url,currentData:n,view2dData:e,setSelectedID:T,showEnlarge:s,checkMode:x,measureVisible:d}))})):null};var le=W(U,null,null,{context:Q})(se);export{le as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudPattern as J}from"@labelbee/lb-utils";import Se,{useState as r,useRef as ct,useMemo as R,useCallback as a,useEffect as Q}from"react";import{EPointCloudBoxRenderTrigger as
|
|
1
|
+
import{EPointCloudPattern as J}from"@labelbee/lb-utils";import Se,{useState as r,useRef as ct,useMemo as R,useCallback as a,useEffect as Q}from"react";import{EPointCloudBoxRenderTrigger as k,calcResetAreasAndBoxIds as ut}from"../../utils/ToolPointCloudBoxRenderHelper.js";import{ActionsHistory as be,EToolName as X,uuid as gt}from"@labelbee/lb-annotation";import{useDispatch as pt}from"../../store/ctx.js";import{ChangeSave as ft}from"../../store/annotation/actionCreators.js";import mt from"../../store/annotatedBox/index.js";import Le from"lodash";import{addMapIndirectWeakSetItem as xe}from"./utils/map.js";import ht from"./hooks/useTimeoutFunc.js";import It,{getEmptyUseWindowKeydownListener as vt}from"./hooks/useWindowKeydownListener.js";var Pt=Object.defineProperty,wt=Object.defineProperties,yt=Object.getOwnPropertyDescriptors,De=Object.getOwnPropertySymbols,Ct=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,Ae=(d,n,u)=>n in d?Pt(d,n,{enumerable:!0,configurable:!0,writable:!0,value:u}):d[n]=u,F=(d,n)=>{for(var u in n||(n={}))Ct.call(n,u)&&Ae(d,u,n[u]);if(De)for(var u of De(n))Rt.call(n,u)&&Ae(d,u,n[u]);return d},Be=(d,n)=>wt(d,yt(n)),St=(d,n,u)=>new Promise((S,x)=>{var D=p=>{try{m(u.next(p))}catch(b){x(b)}},z=p=>{try{m(u.throw(p))}catch(b){x(b)}},m=p=>p.done?S(p.value):Promise.resolve(p.value).then(D,z);m((u=u.apply(d,n)).next())});const E=d=>Le.pick(d,["id","attribute","width","height","x","y","imageName"]),_e=Se.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 be,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:X.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:J.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:d=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:d=>!1,removeRectBySpecifyId:(d,n,u)=>!1,removeRectByPointCloudBoxId:d=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:vt()}),bt=({children:d})=>{const[n,u]=r([]),[S,x]=r([]),[D,z]=r([]),[m,p]=r([]),[b,Ve]=r([]),[I,_]=r([]),[L,K]=r([]),[Y,Ne]=r(!0),[$,He]=r(2),[ee,Oe]=r(!0),[te,je]=r(1),[g,oe]=r(),[ne,ie]=r(),[se,re]=r(),[c,le]=r(),[ae,Me]=r(""),[V,ke]=r(X.Rect),N=ct(new be).current,[f,T]=r([]),[de,Fe]=r(""),[H,Ee]=r(J.Detection),[C,ce]=r(void 0),[W,ze]=r([]),[O,Ke]=r([]),[ue,Te]=r(!1),h=mt(),[ge,We]=r({}),Ge=pt(),Ze=e=>{const{imgNode:t,path:o}=e;o&&t&&We(i=>Be(F({},i),{[o]:{width:t.width,height:t.height}}))},G=R(()=>I.length===1?I[0]:"",[I]),pe=It(),j=a((e,t,o="extId")=>{const i=o||"id",s=new Set(t);return p(l=>{let w=!1;const v=l.filter(B=>{const y=B[i],P=s.has(y)?B.imageName!==e:!0;return P||(w=!0),P});return w?v:l}),!0},[]),fe=a(e=>{const t=n.map(o=>o.id);return j(e,t,"extId")},[n,j]),me=a(e=>{if(!e)return!1;const t=n.filter(o=>Array.isArray(o.rects)).map(o=>{const{id:i,attribute:s,trackID:l}=o,w=o.rects.find(v=>v.imageName===e);if(w){const v=Le.pick(w,["width","height","x","y","imageName"]);return Be(F({},v),{id:gt(),attribute:s,order:l,extId:i,lineDash:[]})}return null}).filter(o=>o!==null);return t.length?(p(o=>{const i=new Set(o.filter(l=>e===l.imageName).map(l=>l.extId)),s=t.filter(l=>i.has(l.extId)===!1);return s.length?[...o,...s]:o}),!0):!1},[n]),he=R(()=>n.filter(t=>Array.isArray(t.rects)&&t.rects.length>0).reduce((t,o)=>{var i;return(i=o.rects)==null||i.forEach(s=>{const{imageName:l}=s;if(!l){console.warn("Missing image name"),console.trace(s,o);return}xe(t,l,o.id,o)}),t},new Map),[n]),Ie=a(e=>{p(t=>e(t,E))},[E]),ve=R(()=>m.filter(e=>e.extId!==void 0&&e.id!==void 0).reduce((e,t)=>{const o=t.imageName;return o?(xe(e,o,t.extId,t),e):(console.warn("missing image name"),console.log(t,m),e)},new Map),[m]),{fn:Ue}=ht(e=>{_(t=>{const o=e,i=new Set(o);let s=!1;const l=t.filter(w=>{const v=i.has(w);return v||(s=!0),v});return s?l:t})},200),Pe=a(e=>{const t=e.map(o=>o.id);u(e),Ue(t)},[]),we=R(()=>n.find(e=>e.id===G),[n,G]),Z=R(()=>n.filter(e=>!f.includes(e.attribute)),[n,f]),U=R(()=>S.filter(e=>!f.includes(e.attribute)),[S,f]),q=R(()=>b.filter(e=>e.attribute&&!f.includes(e.attribute)),[b,f]),qe=a(e=>{const t=n.concat(e);return Pe(t),t},[n]),Je=a(e=>{const t=S.concat(e);return x(t),t},[S]),Qe=a(e=>{Ne(e!==!1)},[]),A=a(e=>{e===void 0&&_([]),typeof e=="string"&&_([e]),Array.isArray(e)&&_(Array.from(new Set(e)))},[]),Xe=a(e=>{I.includes(e)?A(I.filter(t=>t!==e)):A([...I,e])},[I]),Ye=a(e=>{const t=E(e);p(o=>[...o,t])},[m]),$e=a((e,t=!1)=>{const o=E(e);p(i=>i.map(s=>s.id===e.id?t?F(F({},s),o):o:s))},[m]),et=a(e=>{p(t=>t.filter(o=>!e.find(i=>i.id===o.id)))},[m]),tt=a(e=>{L.includes(e)?K([]):K([e])},[L]),ot=a(()=>{if(V===X.Rect){const e=n.map(t=>t.id);A(e),g==null||g.pointCloud2dOperation.setSelectedIDs(e)}},[V,n,g,g==null?void 0:g.pointCloud2dOperation]),nt=a(e=>{A(n.filter(t=>t.attribute===e).map(t=>t.id))},[n]),it=a(e=>{if(f.includes(e))T(f.filter(t=>t!==e));else{const t=f.concat(e);T(t)}},[f]),st=a((e=Z,t=D,o=U,i=q,s=W)=>{var l;c==null||c.clearAllBox(),c==null||c.clearAllSphere(),g==null||g.updatePolygonList(e,t),g==null||g.updatePointList(o),g==null||g.updateLineList(i),c==null||c.generateBoxes(e),c==null||c.generateSpheres(o),(l=C==null?void 0:C.store)==null||l.updateCurrentSegment(s),ye(k.Default,e)},[c,g,C,C==null?void 0:C.store]),rt=a(()=>{oe(void 0),ie(void 0),re(void 0),le(void 0)},[]),ye=a((e,t,o)=>St(void 0,null,function*(){var i,s,l;if(!c)return;const w=c.pointCloudObject;if(!w)return;let v=[],B=[];try{if(t&&N.record.length){const{record:y,recordIndex:P}=N;let Ce=P;P>0&&(e===k.SingleToggleValid||e===k.SingleRotate||e===k.Single&&t.length===((i=y[P])==null?void 0:i.pointCloudBoxList.length))&&(Ce=P-1);let dt=(s=y[Ce])==null?void 0:s.pointCloudBoxList;const Re=ut(e,t,dt);v=Re.modifiedBoxIds,B=Re.resetAreas}}catch(y){console.error("call calcResetAreasAndBoxIds error",y)}try{const y=yield c.getHighlightIndexByMappingImgList({mappingImgList:o!=null?o:O,points:w.geometry.attributes.position.array}),P=yield c==null?void 0:c.highlightOriginPointCloud(t,y,{modifiedBoxIds:v,resetAreas:B});return P&&((l=g==null?void 0:g.pointCloudInstance)==null||l.updateColor(P)),P}catch(y){console.error("call highlightOriginPointCloud error",y)}}),[c,c==null?void 0:c.pointCloudObject,N,O]),lt=a(e=>{H!==e&&(Ge(ft),Ee(e),e===J.Detection&&ce(void 0))},[H]),M=R(()=>({selectedID:G,pointCloudBoxList:n,pointCloudSphereList:S,displayPointCloudList:Z,displaySphereList:U,displayLineList:q,selectedIDs:I,setPointCloudResult:Pe,setSelectedIDs:A,addPointCloudBox:qe,addPointCloudSphere:Je,setPointCloudSphereList:x,valid:Y,selectedPointCloudBox:we,setPointCloudValid:Qe,addSelectedID:Xe,addHighlightID:tt,selectedAllBoxes:ot,topViewInstance:g,setTopViewInstance:oe,sideViewInstance:ne,setSideViewInstance:ie,backViewInstance:se,setBackViewInstance:re,mainViewInstance:c,setMainViewInstance:le,polygonList:D,setPolygonList:z,rectList:m,setRectList:p,addRectIn2DView:Ye,removeRectIn2DView:et,updateRectIn2DView:$e,lineList:b,setLineList:Ve,zoom:te,setZoom:je,history:N,toggleAttributesVisible:it,hideAttributes:f,setHideAttributes:T,reRender:st,attrPanelLayout:de,setAttrPanelLayout:Fe,syncAllViewPointCloudColor:ye,defaultAttribute:ae,setDefaultAttribute:Me,pointCloudPattern:V,setPointCloudPattern:ke,selectSpecAttr:nt,globalPattern:H,setGlobalPattern:lt,ptSegmentInstance:C,setPtSegmentInstance:ce,segmentation:W,setSegmentation:ze,clearAllDetectionInstance:rt,highlight2DDataList:O,setHighlight2DDataList:Ke,highlight2DLoading:ue,setHighlight2DLoading:Te,cuboidBoxIn2DView:ee,setCuboidBoxIn2DView:Oe,imageSizes:ge,cacheImageNodeSize:Ze,highlightIDs:L,setHighlightIDs:K,removeRectByPointCloudBoxId:fe,removeRectBySpecifyId:j,addRectFromPointCloudBoxByImageName:me,rectRotateSensitivity:$,setRectRotateSensitivity:He,imageNamePointCloudBoxMap:he,linkageImageNameRectMap:ve,updateRectListByReducer:Ie,windowKeydownListenerHook:pe}),[Y,we,Z,U,q,D,m,g,ne,se,c,te,de,ae,V,H,C,W,O,ue,ee,ge,L,fe,j,me,$,he,ve,Ie,pe]);Q(()=>{var e,t,o;(e=h==null?void 0:h.setPointCloudBoxList)==null||e.call(h,n),(t=h==null?void 0:h.setHighlightIDs)==null||t.call(h,L),(o=h==null?void 0:h.setSelectedIDs)==null||o.call(h,I)},[n,I,L]),Q(()=>{var e;(e=h==null?void 0:h.setPtCtx)==null||e.call(h,M)},[M]);const at=()=>{const e=n.filter(s=>f.includes(s.attribute)),{setSelectedIDs:t,reRender:o}=M,i=e.map(s=>s.id);i.length>0&&t(I.filter(s=>!i.includes(s))),o()};return Q(()=>{var e,t,o,i;at(),(t=(e=g==null?void 0:g.toolInstance)==null?void 0:e.setHiddenAttributes)==null||t.call(e,f),(i=(o=C==null?void 0:C.store)==null?void 0:o.setHiddenAttributes)==null||i.call(o,f)},[f]),Se.createElement(_e.Provider,{value:M},d)};export{_e as PointCloudContext,bt as PointCloudProvider};
|