@labelbee/lb-components 1.23.0-alpha.64 → 1.23.0-alpha.66

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"),lbUtils=require("@labelbee/lb-utils"),PointCloud2DSingleView=require("./PointCloud2DSingleView.js"),index$1=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"),_=require("lodash"),index=require("../../utils/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,l,n)=>l in e?__defProp(e,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[l]=n,__spreadValues=(e,l)=>{for(var n in l||(l={}))__hasOwnProp.call(l,n)&&__defNormalProp(e,n,l[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(l))__propIsEnum.call(l,n)&&__defNormalProp(e,n,l[n]);return e},__spreadProps=(e,l)=>__defProps(e,__getOwnPropDescs(l));const EKeyCode=lbAnnotation.cKeyCode.default,ContainerTitle=({showEnlarge:e,isEnlargeTopView:l,data:n,setIsEnlarge:m,setCurIndex:f,curIndex:p=0,index:w,annotations2d:b})=>l?React__default.default.createElement(index$1,{title:n==null?void 0:n.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:()=>{m(!1),f(void 0)}}),React__default.default.createElement("span",null,n==null?void 0:n.calName),React__default.default.createElement("span",{style:{marginLeft:"8px"}},p+1,"/",b==null?void 0:b.length)):React__default.default.createElement(index$1,{title:n==null?void 0:n.calName,onClick:()=>{m(!0),f(w)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),PointCloud2DView=({currentData:e,config:l,thumbnailWidth:n,isEnlargeTopView:m,highlightAttribute:f,loadPCDFileLoading:p,checkMode:w,measureVisible:b})=>{var I;const[d,M]=React.useState([]),{topViewInstance:B,displayPointCloudList:k,polygonList:F,imageSizes:x,selectedIDs:O}=React.useContext(PointCloudContext.PointCloudContext),[P,G]=React.useState(""),[y,L]=React.useState(!1),[s,E]=React.useState(void 0);React.useEffect(()=>{var o;if(!p&&B&&(e==null?void 0:e.mappingImgList)&&((o=e==null?void 0:e.mappingImgList)==null?void 0:o.length)>0){const r={fill:"transparent",color:"green"};let i=[];e==null||e.mappingImgList.forEach(t=>{var v,R,V,A;const z=k.reduce((a,c)=>{var g,u;const h=c.id===P||f===c.attribute,{transferViewData:q,viewRangePointList:C}=(g=lbAnnotation.pointCloudLidar2image(c,t.calib,{createRange:h}))!=null?g:{};if(!q||!C)return[];const X=q.reduce((H,$)=>$.type==="line"?[...H,...$.pointList]:H,[]),Y=__spreadProps(__spreadValues({},index.getBoundingRect(X)),{imageName:t.path});if(!index.isBoundingRectInImage(Y,t.path,x))return a;const K=(u=lbUtils.toolStyleConverter.getColorFromConfig({attribute:c.attribute},__spreadProps(__spreadValues({},l),{attributeConfigurable:!0}),{}))==null?void 0:u.stroke,Z=J({viewDataPointList:q,pointCloudBox:c,defaultViewStyle:r,stroke:K}),U=[...a,...Z];return(C==null?void 0:C.length)>0&&U.unshift({type:"polygon",annotation:__spreadProps(__spreadValues({id:P,pointList:C},r),{stroke:K,fill:"rgba(255, 255, 255, 0.6)"})}),U},[]),T=x[(v=t==null?void 0:t.path)!=null?v:""];T&&_.isNumber((R=t==null?void 0:t.calib)==null?void 0:R.groundHeight)&&F.forEach(a=>{const c=a.pointList.map(u=>{var h;return __spreadProps(__spreadValues({},u),{z:(h=t==null?void 0:t.calib)==null?void 0:h.groundHeight})}),g=lbAnnotation.pointListLidar2Img(c,t==null?void 0:t.calib,T);if(g){const u=lbUtils.toolStyleConverter.getColorFromConfig({attribute:a.attribute},__spreadProps(__spreadValues({},l),{attributeConfigurable:!0}),{});z.push({type:"polygon",annotation:__spreadProps(__spreadValues({id:a.id,pointList:g},r),{stroke:u==null?void 0:u.stroke,fill:O.includes(a.id)?u==null?void 0:u.fill:"rgba(255, 255, 255, 0.6)"})})}}),i.push({annotations:z,url:t==null?void 0:t.url,fallbackUrl:(V=t==null?void 0:t.fallbackUrl)!=null?V:"",calName:(A=t==null?void 0:t.calib)==null?void 0:A.calName,calib:t==null?void 0:t.calib,path:t==null?void 0:t.path})}),M(i)}},[k,e==null?void 0:e.mappingImgList,P,f,p,F,x,O]),React.useEffect(()=>(window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S)}),[s]);const S=o=>{const{keyCode:r}=o;switch(r){case EKeyCode.Esc:y&&L(!1);break;case EKeyCode.Left:j();break;case EKeyCode.Right:N();break}},j=()=>{s===void 0||!y||Number(s)>0&&E(s-1)},N=()=>{s===void 0||!y||Number(s)<(d==null?void 0:d.length)-1&&E(s+1)},J=({viewDataPointList:o,pointCloudBox:r,defaultViewStyle:i,stroke:t})=>o?o.map(v=>({type:v.type,annotation:__spreadProps(__spreadValues({id:r.id,pointList:v.pointList},i),{stroke:t})})):[],Q=!e||!(e==null?void 0:e.mappingImgList)||!(((I=e==null?void 0:e.mappingImgList)==null?void 0:I.length)>0),W=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:()=>j()}),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:()=>N()}),React__default.default.createElement("img",{src:icon_esc,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{L(!1),E(void 0)}}),React__default.default.createElement("span",null,"\u952E\u9000\u51FA"));return(d==null?void 0:d.length)>0?React__default.default.createElement(React__default.default.Fragment,null,d.map((o,r)=>{const i=y&&r===s;return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-2d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:i}),title:React__default.default.createElement(ContainerTitle,{showEnlarge:i,isEnlargeTopView:m,data:o,setIsEnlarge:L,setCurIndex:E,curIndex:s,index:r,annotations2d:d}),titleOnSurface:!i,style:{display:Q?"none":"flex",width:i?"100%":n},key:r,toolbar:W},(o==null?void 0:o.annotations)&&(o==null?void 0:o.url)&&React__default.default.createElement(PointCloud2DSingleView,{key:o.url,currentData:e,view2dData:o,setSelectedID:G,showEnlarge:i,checkMode:w,measureVisible:b}))})):null};var PointCloud2DView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DView);module.exports=PointCloud2DView$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"),lbUtils=require("@labelbee/lb-utils"),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"),_=require("lodash"),index$1=require("../../utils/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,l,n)=>l in e?__defProp(e,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[l]=n,__spreadValues=(e,l)=>{for(var n in l||(l={}))__hasOwnProp.call(l,n)&&__defNormalProp(e,n,l[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(l))__propIsEnum.call(l,n)&&__defNormalProp(e,n,l[n]);return e},__spreadProps=(e,l)=>__defProps(e,__getOwnPropDescs(l));const EKeyCode=lbAnnotation.cKeyCode.default,ContainerTitle=({showEnlarge:e,isEnlargeTopView:l,data:n,setIsEnlarge:m,setCurIndex:f,curIndex:p=0,index:w,annotations2d:b})=>l?React__default.default.createElement(index,{title:n==null?void 0:n.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:()=>{m(!1),f(void 0)}}),React__default.default.createElement("span",null,n==null?void 0:n.calName),React__default.default.createElement("span",{style:{marginLeft:"8px"}},p+1,"/",b==null?void 0:b.length)):React__default.default.createElement(index,{title:n==null?void 0:n.calName,onClick:()=>{m(!0),f(w)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),PointCloud2DView=({currentData:e,config:l,thumbnailWidth:n,isEnlargeTopView:m,highlightAttribute:f,loadPCDFileLoading:p,checkMode:w,measureVisible:b})=>{var I;const[c,B]=React.useState([]),{topViewInstance:G,displayPointCloudList:k,polygonList:F,imageSizes:x,selectedIDs:O}=React.useContext(PointCloudContext.PointCloudContext),[P,J]=React.useState(""),[y,L]=React.useState(!1),[s,E]=React.useState(void 0),S=()=>{var o;if(!p&&G&&(e==null?void 0:e.mappingImgList)&&((o=e==null?void 0:e.mappingImgList)==null?void 0:o.length)>0){const i={fill:"transparent",color:"green"};let r=[];e==null||e.mappingImgList.forEach(t=>{var v,V,A,z;const T=k.reduce((a,d)=>{var g,u;const C=d.id===P||f===d.attribute,{transferViewData:q,viewRangePointList:h}=(g=lbAnnotation.pointCloudLidar2image(d,t.calib,{createRange:C}))!=null?g:{};if(!q||!h)return[];const Y=q.reduce(($,M)=>M.type==="line"?[...$,...M.pointList]:$,[]),Z=__spreadProps(__spreadValues({},index$1.getBoundingRect(Y)),{imageName:t.path});if(!index$1.isBoundingRectInImage(Z,t.path,x))return a;const K=(u=lbUtils.toolStyleConverter.getColorFromConfig({attribute:d.attribute},__spreadProps(__spreadValues({},l),{attributeConfigurable:!0}),{}))==null?void 0:u.stroke,D=Q({viewDataPointList:q,pointCloudBox:d,defaultViewStyle:i,stroke:K}),U=[...a,...D];return(h==null?void 0:h.length)>0&&U.unshift({type:"polygon",annotation:__spreadProps(__spreadValues({id:P,pointList:h},i),{stroke:K,fill:"rgba(255, 255, 255, 0.6)"})}),U},[]),H=x[(v=t==null?void 0:t.path)!=null?v:""];H&&_.isNumber((V=t==null?void 0:t.calib)==null?void 0:V.groundHeight)&&F.forEach(a=>{const d=a.pointList.map(u=>{var C;return __spreadProps(__spreadValues({},u),{z:(C=t==null?void 0:t.calib)==null?void 0:C.groundHeight})}),g=lbAnnotation.pointListLidar2Img(d,t==null?void 0:t.calib,H);if(g){const u=lbUtils.toolStyleConverter.getColorFromConfig({attribute:a.attribute},__spreadProps(__spreadValues({},l),{attributeConfigurable:!0}),{});T.push({type:"polygon",annotation:__spreadProps(__spreadValues({id:a.id,pointList:g},i),{stroke:u==null?void 0:u.stroke,fill:O.includes(a.id)?u==null?void 0:u.fill:"rgba(255, 255, 255, 0.6)"})})}}),r.push({annotations:T,url:t==null?void 0:t.url,fallbackUrl:(A=t==null?void 0:t.fallbackUrl)!=null?A:"",calName:(z=t==null?void 0:t.calib)==null?void 0:z.calName,calib:t==null?void 0:t.calib,path:t==null?void 0:t.path})}),B(r)}};React.useEffect(()=>{window.requestIdleCallback?window.requestIdleCallback(S):setTimeout(S,1)},[k,e==null?void 0:e.mappingImgList,P,f,p,F,x,O]),React.useEffect(()=>(window.addEventListener("keydown",j),()=>{window.removeEventListener("keydown",j)}),[s]);const j=o=>{const{keyCode:i}=o;switch(i){case EKeyCode.Esc:y&&L(!1);break;case EKeyCode.Left:N();break;case EKeyCode.Right:R();break}},N=()=>{s===void 0||!y||Number(s)>0&&E(s-1)},R=()=>{s===void 0||!y||Number(s)<(c==null?void 0:c.length)-1&&E(s+1)},Q=({viewDataPointList:o,pointCloudBox:i,defaultViewStyle:r,stroke:t})=>o?o.map(v=>({type:v.type,annotation:__spreadProps(__spreadValues({id:i.id,pointList:v.pointList},r),{stroke:t})})):[],W=!e||!(e==null?void 0:e.mappingImgList)||!(((I=e==null?void 0:e.mappingImgList)==null?void 0:I.length)>0),X=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:()=>N()}),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:()=>R()}),React__default.default.createElement("img",{src:icon_esc,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{L(!1),E(void 0)}}),React__default.default.createElement("span",null,"\u952E\u9000\u51FA"));return(c==null?void 0:c.length)>0?React__default.default.createElement(React__default.default.Fragment,null,c.map((o,i)=>{const r=y&&i===s;return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-2d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:r}),title:React__default.default.createElement(ContainerTitle,{showEnlarge:r,isEnlargeTopView:m,data:o,setIsEnlarge:L,setCurIndex:E,curIndex:s,index:i,annotations2d:c}),titleOnSurface:!r,style:{display:W?"none":"flex",width:r?"100%":n},key:i,toolbar:X},(o==null?void 0:o.annotations)&&(o==null?void 0:o.url)&&React__default.default.createElement(PointCloud2DSingleView,{key:o.url,currentData:e,view2dData:o,setSelectedID:J,showEnlarge:r,checkMode:w,measureVisible:b}))})):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");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(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}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=(i,n,r)=>n in i?__defProp(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,__spreadValues=(i,n)=>{for(var r in n||(n={}))__hasOwnProp.call(n,r)&&__defNormalProp(i,r,n[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(n))__propIsEnum.call(n,r)&&__defNormalProp(i,r,n[r]);return i},__spreadProps=(i,n)=>__defProps(i,__getOwnPropDescs(n)),__async=(i,n,r)=>new Promise((S,R)=>{var y=u=>{try{g(r.next(u))}catch(b){R(b)}},M=u=>{try{g(r.throw(u))}catch(b){R(b)}},g=u=>u.done?S(u.value):Promise.resolve(u.value).then(y,M);g((r=r.apply(i,n)).next())});const pickRectObject=i=>___default.default.pick(i,["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:i=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:i=>!1,removeRectBySpecifyId:(i,n,r)=>!1,removeRectByPointCloudBoxId:i=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{}}),PointCloudProvider=({children:i})=>{const[n,r]=React.useState([]),[S,R]=React.useState([]),[y,M]=React.useState([]),[g,u]=React.useState([]),[b,ge]=React.useState([]),[m,N]=React.useState([]),[x,O]=React.useState([]),[G,fe]=React.useState(!0),[W,me]=React.useState(2),[Z,ve]=React.useState(!0),[U,he]=React.useState(1),[d,J]=React.useState(),[K,Q]=React.useState(),[X,Y]=React.useState(),[a,$]=React.useState(),[ee,Ce]=React.useState(""),[L,Ie]=React.useState(lbAnnotation.EToolName.Rect),A=React.useRef(new lbAnnotation.ActionsHistory).current,[p,E]=React.useState([]),[te,Pe]=React.useState(""),[B,Se]=React.useState(lbUtils.EPointCloudPattern.Detection),[C,oe]=React.useState(void 0),[H,be]=React.useState([]),[j,xe]=React.useState([]),f=index(),[ne,Re]=React.useState({}),ye=ctx.useDispatch(),we=e=>{const{imgNode:t,path:o}=e;o&&t&&Re(s=>__spreadProps(__spreadValues({},s),{[o]:{width:t.width,height:t.height}}))},q=React.useMemo(()=>m.length===1?m[0]:"",[m]),V=React.useCallback((e,t,o="extId")=>{const s=o||"id",l=new Set(t);return u(c=>{let I=!1;const P=c.filter(D=>{const h=D[s],v=l.has(h)?D.imageName!==e:!0;return v||(I=!0),v});return I?P:c}),!0},[]),ie=React.useCallback(e=>{const t=n.map(o=>o.id);return V(e,t,"extId")},[n,V]),se=React.useCallback(e=>{if(!e)return!1;const t=n.filter(o=>Array.isArray(o.rects)).map(o=>{const{id:s,attribute:l,trackID:c}=o,I=o.rects.find(P=>P.imageName===e);if(I){const P=___default.default.pick(I,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},P),{id:lbAnnotation.uuid(),attribute:l,order:c,extId:s,lineDash:[]})}return null}).filter(o=>o!==null);return t.length?(u(o=>{const s=new Set(o.filter(c=>e===c.imageName).map(c=>c.extId)),l=t.filter(c=>s.has(c.extId)===!1);return l.length?[...o,...l]:o}),!0):!1},[n]),le=React.useMemo(()=>n.filter(t=>Array.isArray(t.rects)&&t.rects.length>0).reduce((t,o)=>{var s;return(s=o.rects)==null||s.forEach(l=>{const{imageName:c}=l;if(!c){console.warn("Missing image name"),console.trace(l,o);return}map.addMapIndirectWeakSetItem(t,c,o.id,o)}),t},new Map),[n]),re=React.useCallback(e=>{u(t=>e(t,pickRectObject))},[pickRectObject]),ae=React.useMemo(()=>g.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,g),e)},new Map),[g]),ce=React.useMemo(()=>n.find(e=>e.id===q),[n,q]),T=React.useMemo(()=>n.filter(e=>!p.includes(e.attribute)),[n,p]),F=React.useMemo(()=>S.filter(e=>!p.includes(e.attribute)),[S,p]),z=React.useMemo(()=>b.filter(e=>e.attribute&&!p.includes(e.attribute)),[b,p]),De=React.useCallback(e=>{const t=n.concat(e);return r(t),t},[n]),Le=React.useCallback(e=>{const t=S.concat(e);return R(t),t},[S]),Ae=React.useCallback(e=>{fe(e!==!1)},[]),w=React.useCallback(e=>{e===void 0&&N([]),typeof e=="string"&&N([e]),Array.isArray(e)&&N(Array.from(new Set(e)))},[]),Be=React.useCallback(e=>{m.includes(e)?w(m.filter(t=>t!==e)):w([...m,e])},[m]),_e=React.useCallback(e=>{const t=pickRectObject(e);u(o=>[...o,t])},[g]),Ve=React.useCallback((e,t=!1)=>{const o=pickRectObject(e);u(s=>s.map(l=>l.id===e.id?t?__spreadValues(__spreadValues({},l),o):o:l))},[g]),ke=React.useCallback(e=>{u(t=>t.filter(o=>!e.find(s=>s.id===o.id)))},[g]),Me=React.useCallback(e=>{x.includes(e)?O([]):O([e])},[x]),Ne=React.useCallback(()=>{if(L===lbAnnotation.EToolName.Rect){const e=n.map(t=>t.id);w(e),d==null||d.pointCloud2dOperation.setSelectedIDs(e)}},[L,n,d,d==null?void 0:d.pointCloud2dOperation]),Oe=React.useCallback(e=>{w(n.filter(t=>t.attribute===e).map(t=>t.id))},[n]),Ee=React.useCallback(e=>{if(p.includes(e))E(p.filter(t=>t!==e));else{const t=p.concat(e);E(t)}},[p]),He=React.useCallback((e=T,t=y,o=F,s=z,l=H)=>{var c;a==null||a.clearAllBox(),a==null||a.clearAllSphere(),d==null||d.updatePolygonList(e,t),d==null||d.updatePointList(o),d==null||d.updateLineList(s),a==null||a.generateBoxes(e),a==null||a.generateSpheres(o),(c=C==null?void 0:C.store)==null||c.updateCurrentSegment(l),de(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},[a,d,C,C==null?void 0:C.store]),je=React.useCallback(()=>{J(void 0),Q(void 0),Y(void 0),$(void 0)},[]),de=React.useCallback((e,t,o)=>__async(void 0,null,function*(){var s,l,c;if(!a)return;const I=a.pointCloudObject;if(!I)return;let P=[],D=[];try{if(t&&A.record.length){const{record:h,recordIndex:v}=A;let ue=v;v>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&t.length===((s=h[v])==null?void 0:s.pointCloudBoxList.length))&&(ue=v-1);let Fe=(l=h[ue])==null?void 0:l.pointCloudBoxList;const pe=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,t,Fe);P=pe.modifiedBoxIds,D=pe.resetAreas}}catch(h){console.error("call calcResetAreasAndBoxIds error",h)}try{const h=yield a.getHighlightIndexByMappingImgList({mappingImgList:o!=null?o:j,points:I.geometry.attributes.position.array}),v=yield a==null?void 0:a.highlightOriginPointCloud(t,h,{modifiedBoxIds:P,resetAreas:D});return v&&((c=d==null?void 0:d.pointCloudInstance)==null||c.updateColor(v)),v}catch(h){console.error("call highlightOriginPointCloud error",h)}}),[a,a==null?void 0:a.pointCloudObject,A]),qe=React.useCallback(e=>{B!==e&&(ye(actionCreators.ChangeSave),Se(e),e===lbUtils.EPointCloudPattern.Detection&&oe(void 0))},[B]),k=React.useMemo(()=>({selectedID:q,pointCloudBoxList:n,pointCloudSphereList:S,displayPointCloudList:T,displaySphereList:F,displayLineList:z,selectedIDs:m,setPointCloudResult:r,setSelectedIDs:w,addPointCloudBox:De,addPointCloudSphere:Le,setPointCloudSphereList:R,valid:G,selectedPointCloudBox:ce,setPointCloudValid:Ae,addSelectedID:Be,addHighlightID:Me,selectedAllBoxes:Ne,topViewInstance:d,setTopViewInstance:J,sideViewInstance:K,setSideViewInstance:Q,backViewInstance:X,setBackViewInstance:Y,mainViewInstance:a,setMainViewInstance:$,polygonList:y,setPolygonList:M,rectList:g,setRectList:u,addRectIn2DView:_e,removeRectIn2DView:ke,updateRectIn2DView:Ve,lineList:b,setLineList:ge,zoom:U,setZoom:he,history:A,toggleAttributesVisible:Ee,hideAttributes:p,setHideAttributes:E,reRender:He,attrPanelLayout:te,setAttrPanelLayout:Pe,syncAllViewPointCloudColor:de,defaultAttribute:ee,setDefaultAttribute:Ce,pointCloudPattern:L,setPointCloudPattern:Ie,selectSpecAttr:Oe,globalPattern:B,setGlobalPattern:qe,ptSegmentInstance:C,setPtSegmentInstance:oe,segmentation:H,setSegmentation:be,clearAllDetectionInstance:je,highlight2DDataList:j,setHighlight2DDataList:xe,cuboidBoxIn2DView:Z,setCuboidBoxIn2DView:ve,imageSizes:ne,cacheImageNodeSize:we,highlightIDs:x,setHighlightIDs:O,removeRectByPointCloudBoxId:ie,removeRectBySpecifyId:V,addRectFromPointCloudBoxByImageName:se,rectRotateSensitivity:W,setRectRotateSensitivity:me,imageNamePointCloudBoxMap:le,linkageImageNameRectMap:ae,updateRectListByReducer:re}),[G,ce,T,F,z,y,g,d,K,X,a,U,te,ee,L,B,C,H,j,Z,ne,x,ie,V,se,W,le,ae,re]);React.useEffect(()=>{var e,t,o;(e=f==null?void 0:f.setPointCloudBoxList)==null||e.call(f,n),(t=f==null?void 0:f.setHighlightIDs)==null||t.call(f,x),(o=f==null?void 0:f.setSelectedIDs)==null||o.call(f,m)},[n,m,x]),React.useEffect(()=>{var e;(e=f==null?void 0:f.setPtCtx)==null||e.call(f,k)},[k]);const Te=()=>{const e=n.filter(l=>p.includes(l.attribute)),{setSelectedIDs:t,reRender:o}=k,s=e.map(l=>l.id);s.length>0&&t(m.filter(l=>!s.includes(l))),o()};return React.useEffect(()=>{var e,t,o,s;Te(),(t=(e=d==null?void 0:d.toolInstance)==null?void 0:e.setHiddenAttributes)==null||t.call(e,p),(s=(o=C==null?void 0:C.store)==null?void 0:o.setHiddenAttributes)==null||s.call(o,p)},[p]),React__default.default.createElement(PointCloudContext.Provider,{value:k},i)};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"),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,u;return e?((u=(c=s.get(e))==null?void 0:c.size)!=null?u:0)>0:!1},[s,e]),r=React.useMemo(()=>o||a,[o,a]),d=ahooks.useLatest(r);return{visible:r,visibleRef:d}},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,linkageImageNameRectMap:d,pointCloudBoxList:c,rectList:u}=React.useContext(PointCloudContext.PointCloudContext),{visible:g,visibleRef:h}=useShownIcon(e.imageName),{syncToPointCloudBoxList:C}=usePointCloudViews.useSyncRectPositionDimensionToPointCloudList(),I=ahooks.useLatest(a),w=ahooks.useLatest(r),k=ahooks.useLatest(()=>C()),m=React.useCallback(n=>{if(!h.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=>{n&&k.current(),m(n)}),x=React.useMemo(()=>{var n;if(!e.is2DView||!g)return null;const l={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:l},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(d),f=React.useCallback(()=>{var n,t;if(!e.is2DView)return;const l=o.current;if(!l){console.warn("invalid image name");return}const L=[...(t=(n=R.current.get(l))==null?void 0:n.keys())!=null?t:[]];let v=!0;L.length&&(v=!1),m(v)},[e.is2DView,m]);return React.useEffect(()=>{f()},[f,c,u]),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
+ "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:s,linkageImageNameRectMap:l}=React.useContext(PointCloudContext.PointCloudContext),a=React.useMemo(()=>e?s.has(e):(console.error("Missing image name"),!1),[e,s]),d=React.useMemo(()=>{var o,f;return e?((f=(o=l.get(e))==null?void 0:o.size)!=null?f:0)>0:!1},[l,e]),m=React.useMemo(()=>a||d,[a,d]),g=ahooks.useLatest(m);return{visible:m,visibleRef:g}},iconSize={width:16,height:16},useDataLinkSwitch=e=>{e.imageName||console.warn("missing imageName");const[s,l]=React.useState(!0),a=ahooks.useLatest(e.imageName),{addRectFromPointCloudBoxByImageName:d,removeRectByPointCloudBoxId:m,linkageImageNameRectMap:g,pointCloudBoxList:o,rectList:f,updateRectListByReducer:k}=React.useContext(PointCloudContext.PointCloudContext),{visible:v,visibleRef:x}=useShownIcon(e.imageName),{syncToPointCloudBoxList:b}=usePointCloudViews.useSyncRectPositionDimensionToPointCloudList(),R=ahooks.useLatest(d),L=ahooks.useLatest(m),B=ahooks.useLatest(()=>b()),h=React.useCallback(t=>{if(!x.current)return;const n=a.current;if(!n){console.warn("invalid image name");return}l(t),t?L.current(n):R.current(n)},[]),y=ahooks.useLatest(t=>{t&&B.current(),h(t)}),E=React.useMemo(()=>{var t;if(!e.is2DView||!v)return null;const i={zIndex:(t=e.zIndex)!=null?t: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:i},s&&React__default.default.createElement("img",{src:icon_link,style:iconSize}),!s&&React__default.default.createElement("img",{src:icon_unlink,style:iconSize}))},[s,e.is2DView,e.zIndex,v]),M=ahooks.useLatest(g),I=React.useCallback(()=>{var t,n;if(!e.is2DView)return;const i=a.current;if(!i){console.warn("invalid image name");return}const r=[...(n=(t=M.current.get(i))==null?void 0:t.keys())!=null?n:[]];let c=!0;r.length&&(c=!1),h(c)},[e.is2DView,h]);return React.useEffect(()=>{I()},[I,o,f]),React.useEffect(()=>{const t=o.map(i=>i.id),n=new Set(t);k((i,C)=>{const r=[],c=[];return i.forEach(u=>{const w=u.extId;w!==void 0&&n.has(w)===!1?r.push(u):c.push(u)}),r.length?[...r.map(u=>C(u)),...c]:i})},[o]),React.useEffect(()=>{const t=n=>{y.current(n)};return lbAnnotation.EventBus.on(BatchSwitchConnectIn2DView.EventBusEvent.switchConnect,t),()=>lbAnnotation.EventBus.unbind(BatchSwitchConnectIn2DView.EventBusEvent.switchConnect,t)},[]),{rendered:E,isLinking:s}};module.exports=useDataLinkSwitch;
@@ -1 +1 @@
1
- import{getClassName as Q}from"../../utils/dom.js";import i,{useState as L,useContext as ae,useEffect as W}from"react";import{PointCloudContainer as ce}from"./PointCloudLayout.js";import{PointCloudContext as de}from"./PointCloudContext.js";import{connect as me}from"react-redux";import{cKeyCode as fe,pointCloudLidar2image as pe,pointListLidar2Img as ge}from"@labelbee/lb-annotation";import{LabelBeeContext as ve}from"../../store/ctx.js";import{a2MapStateToProps as be}from"../../store/annotation/map.js";import{toolStyleConverter as X}from"@labelbee/lb-utils";import ye from"./PointCloud2DSingleView.js";import Y from"./components/TitleButton/index.js";import{LeftOutlined as Ee}from"@ant-design/icons";import he from"classnames";import _e from"../../assets/annotation/common/icon_esc.svg.js";import we from"../../assets/annotation/common/icon_left_squareOutlined.svg.js";import Ce from"../../assets/annotation/common/icon_right_squareOutlined.svg.js";import{isNumber as Pe}from"lodash";import{getBoundingRect as Le,isBoundingRectInImage as xe}from"../../utils/index.js";var Ie=Object.defineProperty,ke=Object.defineProperties,Fe=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,D=(e,n,o)=>n in e?Ie(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,m=(e,n)=>{for(var o in n||(n={}))Oe.call(n,o)&&D(e,o,n[o]);if(Z)for(var o of Z(n))je.call(n,o)&&D(e,o,n[o]);return e},f=(e,n)=>ke(e,Fe(n));const j=fe.default,Ne=({showEnlarge:e,isEnlargeTopView:n,data:o,setIsEnlarge:y,setCurIndex:g,curIndex:E=0,index:x,annotations2d:h})=>n?i.createElement(Y,{title:o==null?void 0:o.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):e?i.createElement("div",{style:{display:"flex",alignItems:"center"}},i.createElement(Ee,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{y(!1),g(void 0)}}),i.createElement("span",null,o==null?void 0:o.calName),i.createElement("span",{style:{marginLeft:"8px"}},E+1,"/",h==null?void 0:h.length)):i.createElement(Y,{title:o==null?void 0:o.calName,onClick:()=>{y(!0),g(x)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),Re=({currentData:e,config:n,thumbnailWidth:o,isEnlargeTopView:y,highlightAttribute:g,loadPCDFileLoading:E,checkMode:x,measureVisible:h})=>{var N;const[p,ee]=L([]),{topViewInstance:te,displayPointCloudList:R,polygonList:S,imageSizes:I,selectedIDs:V}=ae(de),[k,oe]=L(""),[_,F]=L(!1),[u,w]=L(void 0);W(()=>{var l;if(!E&&te&&(e==null?void 0:e.mappingImgList)&&((l=e==null?void 0:e.mappingImgList)==null?void 0:l.length)>0){const r={fill:"transparent",color:"green"};let s=[];e==null||e.mappingImgList.forEach(t=>{var v,K,$,q;const H=R.reduce((c,d)=>{var b,a;const C=d.id===k||g===d.attribute,{transferViewData:O,viewRangePointList:P}=(b=pe(d,t.calib,{createRange:C}))!=null?b:{};if(!O||!P)return[];const re=O.reduce((G,J)=>J.type==="line"?[...G,...J.pointList]:G,[]),se=f(m({},Le(re)),{imageName:t.path});if(!xe(se,t.path,I))return c;const B=(a=X.getColorFromConfig({attribute:d.attribute},f(m({},n),{attributeConfigurable:!0}),{}))==null?void 0:a.stroke,ue=ne({viewDataPointList:O,pointCloudBox:d,defaultViewStyle:r,stroke:B}),M=[...c,...ue];return(P==null?void 0:P.length)>0&&M.unshift({type:"polygon",annotation:f(m({id:k,pointList:P},r),{stroke:B,fill:"rgba(255, 255, 255, 0.6)"})}),M},[]),U=I[(v=t==null?void 0:t.path)!=null?v:""];U&&Pe((K=t==null?void 0:t.calib)==null?void 0:K.groundHeight)&&S.forEach(c=>{const d=c.pointList.map(a=>{var C;return f(m({},a),{z:(C=t==null?void 0:t.calib)==null?void 0:C.groundHeight})}),b=ge(d,t==null?void 0:t.calib,U);if(b){const a=X.getColorFromConfig({attribute:c.attribute},f(m({},n),{attributeConfigurable:!0}),{});H.push({type:"polygon",annotation:f(m({id:c.id,pointList:b},r),{stroke:a==null?void 0:a.stroke,fill:V.includes(c.id)?a==null?void 0:a.fill:"rgba(255, 255, 255, 0.6)"})})}}),s.push({annotations:H,url:t==null?void 0:t.url,fallbackUrl:($=t==null?void 0:t.fallbackUrl)!=null?$:"",calName:(q=t==null?void 0:t.calib)==null?void 0:q.calName,calib:t==null?void 0:t.calib,path:t==null?void 0:t.path})}),ee(s)}},[R,e==null?void 0:e.mappingImgList,k,g,E,S,I,V]),W(()=>(window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}),[u]);const A=l=>{const{keyCode:r}=l;switch(r){case j.Esc:_&&F(!1);break;case j.Left:z();break;case j.Right:T();break}},z=()=>{u===void 0||!_||Number(u)>0&&w(u-1)},T=()=>{u===void 0||!_||Number(u)<(p==null?void 0:p.length)-1&&w(u+1)},ne=({viewDataPointList:l,pointCloudBox:r,defaultViewStyle:s,stroke:t})=>l?l.map(v=>({type:v.type,annotation:f(m({id:r.id,pointList:v.pointList},s),{stroke:t})})):[],ie=!e||!(e==null?void 0:e.mappingImgList)||!(((N=e==null?void 0:e.mappingImgList)==null?void 0:N.length)>0),le=i.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},i.createElement("img",{src:we,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>z()}),i.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),i.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),i.createElement("img",{src:Ce,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>T()}),i.createElement("img",{src:_e,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{F(!1),w(void 0)}}),i.createElement("span",null,"\u952E\u9000\u51FA"));return(p==null?void 0:p.length)>0?i.createElement(i.Fragment,null,p.map((l,r)=>{const s=_&&r===u;return i.createElement(ce,{className:he({[Q("point-cloud-2d-container")]:!0,[Q("point-cloud-container","zoom")]:s}),title:i.createElement(Ne,{showEnlarge:s,isEnlargeTopView:y,data:l,setIsEnlarge:F,setCurIndex:w,curIndex:u,index:r,annotations2d:p}),titleOnSurface:!s,style:{display:ie?"none":"flex",width:s?"100%":o},key:r,toolbar:le},(l==null?void 0:l.annotations)&&(l==null?void 0:l.url)&&i.createElement(ye,{key:l.url,currentData:e,view2dData:l,setSelectedID:oe,showEnlarge:s,checkMode:x,measureVisible:h}))})):null};var Se=me(be,null,null,{context:ve})(Re);export{Se as default};
1
+ import{getClassName as W}from"../../utils/dom.js";import i,{useState as L,useContext as ce,useEffect as X}from"react";import{PointCloudContainer as de}from"./PointCloudLayout.js";import{PointCloudContext as me}from"./PointCloudContext.js";import{connect as fe}from"react-redux";import{cKeyCode as pe,pointCloudLidar2image as ge,pointListLidar2Img as ve}from"@labelbee/lb-annotation";import{LabelBeeContext as be}from"../../store/ctx.js";import{a2MapStateToProps as ye}from"../../store/annotation/map.js";import{toolStyleConverter as Y}from"@labelbee/lb-utils";import Ee from"./PointCloud2DSingleView.js";import Z from"./components/TitleButton/index.js";import{LeftOutlined as we}from"@ant-design/icons";import he from"classnames";import _e from"../../assets/annotation/common/icon_esc.svg.js";import Ce from"../../assets/annotation/common/icon_left_squareOutlined.svg.js";import Pe from"../../assets/annotation/common/icon_right_squareOutlined.svg.js";import{isNumber as Le}from"lodash";import{getBoundingRect as xe,isBoundingRectInImage as Ie}from"../../utils/index.js";var ke=Object.defineProperty,Fe=Object.defineProperties,Oe=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable,ee=(e,n,o)=>n in e?ke(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,m=(e,n)=>{for(var o in n||(n={}))je.call(n,o)&&ee(e,o,n[o]);if(D)for(var o of D(n))Ne.call(n,o)&&ee(e,o,n[o]);return e},f=(e,n)=>Fe(e,Oe(n));const j=pe.default,Re=({showEnlarge:e,isEnlargeTopView:n,data:o,setIsEnlarge:y,setCurIndex:g,curIndex:E=0,index:x,annotations2d:w})=>n?i.createElement(Z,{title:o==null?void 0:o.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):e?i.createElement("div",{style:{display:"flex",alignItems:"center"}},i.createElement(we,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{y(!1),g(void 0)}}),i.createElement("span",null,o==null?void 0:o.calName),i.createElement("span",{style:{marginLeft:"8px"}},E+1,"/",w==null?void 0:w.length)):i.createElement(Z,{title:o==null?void 0:o.calName,onClick:()=>{y(!0),g(x)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),Se=({currentData:e,config:n,thumbnailWidth:o,isEnlargeTopView:y,highlightAttribute:g,loadPCDFileLoading:E,checkMode:x,measureVisible:w})=>{var N;const[p,te]=L([]),{topViewInstance:oe,displayPointCloudList:R,polygonList:S,imageSizes:I,selectedIDs:V}=ce(me),[k,ne]=L(""),[h,F]=L(!1),[u,_]=L(void 0),A=()=>{var l;if(!E&&oe&&(e==null?void 0:e.mappingImgList)&&((l=e==null?void 0:e.mappingImgList)==null?void 0:l.length)>0){const r={fill:"transparent",color:"green"};let s=[];e==null||e.mappingImgList.forEach(t=>{var v,H,K,$;const U=R.reduce((c,d)=>{var b,a;const C=d.id===k||g===d.attribute,{transferViewData:O,viewRangePointList:P}=(b=ge(d,t.calib,{createRange:C}))!=null?b:{};if(!O||!P)return[];const se=O.reduce((J,Q)=>Q.type==="line"?[...J,...Q.pointList]:J,[]),ue=f(m({},xe(se)),{imageName:t.path});if(!Ie(ue,t.path,I))return c;const M=(a=Y.getColorFromConfig({attribute:d.attribute},f(m({},n),{attributeConfigurable:!0}),{}))==null?void 0:a.stroke,ae=ie({viewDataPointList:O,pointCloudBox:d,defaultViewStyle:r,stroke:M}),G=[...c,...ae];return(P==null?void 0:P.length)>0&&G.unshift({type:"polygon",annotation:f(m({id:k,pointList:P},r),{stroke:M,fill:"rgba(255, 255, 255, 0.6)"})}),G},[]),B=I[(v=t==null?void 0:t.path)!=null?v:""];B&&Le((H=t==null?void 0:t.calib)==null?void 0:H.groundHeight)&&S.forEach(c=>{const d=c.pointList.map(a=>{var C;return f(m({},a),{z:(C=t==null?void 0:t.calib)==null?void 0:C.groundHeight})}),b=ve(d,t==null?void 0:t.calib,B);if(b){const a=Y.getColorFromConfig({attribute:c.attribute},f(m({},n),{attributeConfigurable:!0}),{});U.push({type:"polygon",annotation:f(m({id:c.id,pointList:b},r),{stroke:a==null?void 0:a.stroke,fill:V.includes(c.id)?a==null?void 0:a.fill:"rgba(255, 255, 255, 0.6)"})})}}),s.push({annotations:U,url:t==null?void 0:t.url,fallbackUrl:(K=t==null?void 0:t.fallbackUrl)!=null?K:"",calName:($=t==null?void 0:t.calib)==null?void 0:$.calName,calib:t==null?void 0:t.calib,path:t==null?void 0:t.path})}),te(s)}};X(()=>{window.requestIdleCallback?window.requestIdleCallback(A):setTimeout(A,1)},[R,e==null?void 0:e.mappingImgList,k,g,E,S,I,V]),X(()=>(window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}),[u]);const T=l=>{const{keyCode:r}=l;switch(r){case j.Esc:h&&F(!1);break;case j.Left:z();break;case j.Right:q();break}},z=()=>{u===void 0||!h||Number(u)>0&&_(u-1)},q=()=>{u===void 0||!h||Number(u)<(p==null?void 0:p.length)-1&&_(u+1)},ie=({viewDataPointList:l,pointCloudBox:r,defaultViewStyle:s,stroke:t})=>l?l.map(v=>({type:v.type,annotation:f(m({id:r.id,pointList:v.pointList},s),{stroke:t})})):[],le=!e||!(e==null?void 0:e.mappingImgList)||!(((N=e==null?void 0:e.mappingImgList)==null?void 0:N.length)>0),re=i.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},i.createElement("img",{src:Ce,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>z()}),i.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),i.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),i.createElement("img",{src:Pe,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>q()}),i.createElement("img",{src:_e,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{F(!1),_(void 0)}}),i.createElement("span",null,"\u952E\u9000\u51FA"));return(p==null?void 0:p.length)>0?i.createElement(i.Fragment,null,p.map((l,r)=>{const s=h&&r===u;return i.createElement(de,{className:he({[W("point-cloud-2d-container")]:!0,[W("point-cloud-container","zoom")]:s}),title:i.createElement(Re,{showEnlarge:s,isEnlargeTopView:y,data:l,setIsEnlarge:F,setCurIndex:_,curIndex:u,index:r,annotations2d:p}),titleOnSurface:!s,style:{display:le?"none":"flex",width:s?"100%":o},key:r,toolbar:re},(l==null?void 0:l.annotations)&&(l==null?void 0:l.url)&&i.createElement(Ee,{key:l.url,currentData:e,view2dData:l,setSelectedID:ne,showEnlarge:s,checkMode:x,measureVisible:w}))})):null};var Ve=fe(ye,null,null,{context:be})(Se);export{Ve as default};
@@ -1 +1 @@
1
- import{EPointCloudPattern as Y}from"@labelbee/lb-utils";import Be,{useState as r,useRef as it,useMemo as j,useCallback as k,useEffect as $}from"react";import{EPointCloudBoxRenderTrigger as F,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,E=(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)}},G=u=>{try{P(c.throw(u))}catch(C){A(C)}},P=u=>u.done?L(u.value):Promise.resolve(u.value).then(B,G);P((c=c.apply(a,o)).next())});const z=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,G]=r([]),[P,u]=r([]),[C,ke]=r([]),[v,T]=r([]),[_,Z]=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(""),[W,Ze]=r(ee.Rect),q=it(new _e).current,[g,J]=r([]),[pe,We]=r(""),[K,qe]=r(Y.Detection),[D,me]=r(void 0),[Q,Je]=r([]),[U,Ke]=r([]),h=ct(),[fe,Qe]=r({}),Ue=lt(),Xe=n=>{const{imgNode:i,path:t}=n;t&&i&&Qe(d=>Me(E({},d),{[t]:{width:i.width,height:i.height}}))},ge=j(()=>v.length===1?v[0]:"",[v]),N=k((n,i,t="extId")=>{const d=t||"id",l=new Set(i);return u(m=>{let R=!1;const x=m.filter(H=>{const X=H[d],M=l.has(X)?H.imageName!==n:!0;return M||(R=!0),M});return R?x:m}),!0},[]),he=k(n=>{const i=o.map(t=>t.id);return N(n,i,"extId")},[o,N]),Ie=k(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(E({},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]),ve=j(()=>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=k(n=>{u(i=>n(i,z))},[z]),ye=j(()=>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=j(()=>{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&&T([]),typeof e=="string"&&T([e]),Array.isArray(e)&&T(Array.from(new Set(e)))},m=e=>{v.includes(e)?l(v.filter(s=>s!==e)):l([...v,e])},R=e=>{const s=z(e);u(I=>[...I,s])},x=(e,s=!1)=>{const I=z(e);u(y=>y.map(S=>S.id===e.id?s?E(E({},S),I):I:S))},H=e=>{u(s=>s.filter(I=>!e.find(y=>y.id===I.id)))},X=e=>{_.includes(e)?Z([]):Z([e])},M=()=>{if(W===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))J(g.filter(s=>s!==e));else{const s=g.concat(e);J(s)}},tt=(e=Se,s=B,I=be,y=we,S=Q)=>{var V;p==null||p.clearAllBox(),p==null||p.clearAllSphere(),f==null||f.updatePolygonList(e,s),f==null||f.updatePointList(I),f==null||f.updateLineList(y),p==null||p.generateBoxes(e),p==null||p.generateSpheres(I),(V=D==null?void 0:D.store)==null||V.updateCurrentSegment(S),Ce(F.Default,e)},ot=()=>{se(void 0),le(void 0),ce(void 0),de(void 0)},Ce=(e,s,I)=>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&&q.record.length){const{record:b,recordIndex:w}=q;let De=w;w>0&&(e===F.SingleToggleValid||e===F.SingleRotate||e===F.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:I!=null?I:U,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:v,setPointCloudResult:c,setSelectedIDs:l,addPointCloudBox:i,addPointCloudSphere:t,setPointCloudSphereList:A,valid:te,selectedPointCloudBox:n,setPointCloudValid:d,addSelectedID:m,addHighlightID:X,selectedAllBoxes:M,topViewInstance:f,setTopViewInstance:se,sideViewInstance:re,setSideViewInstance:le,backViewInstance:ae,setBackViewInstance:ce,mainViewInstance:p,setMainViewInstance:de,polygonList:B,setPolygonList:G,rectList:P,setRectList:u,addRectIn2DView:R,removeRectIn2DView:H,updateRectIn2DView:x,lineList:C,setLineList:ke,zoom:ie,setZoom:Ge,history:q,toggleAttributesVisible:et,hideAttributes:g,setHideAttributes:J,reRender:tt,attrPanelLayout:pe,setAttrPanelLayout:We,syncAllViewPointCloudColor:Ce,defaultAttribute:ue,setDefaultAttribute:Te,pointCloudPattern:W,setPointCloudPattern:Ze,selectSpecAttr:$e,globalPattern:K,setGlobalPattern:e=>{K!==e&&(Ue(at),qe(e),e===Y.Detection&&me(void 0))},ptSegmentInstance:D,setPtSegmentInstance:me,segmentation:Q,setSegmentation:Je,clearAllDetectionInstance:ot,highlight2DDataList:U,setHighlight2DDataList:Ke,cuboidBoxIn2DView:ne,setCuboidBoxIn2DView:ze,imageSizes:fe,cacheImageNodeSize:Xe,highlightIDs:_,setHighlightIDs:Z,removeRectByPointCloudBoxId:he,removeRectBySpecifyId:N,addRectFromPointCloudBoxByImageName:Ie,rectRotateSensitivity:oe,setRectRotateSensitivity:Ee,imageNamePointCloudBoxMap:ve,linkageImageNameRectMap:ye,updateRectListByReducer:Pe}},[te,v,o,L,B,C,P,f,re,ae,p,ie,g,pe,ue,W,K,D,Q,U,ne,fe,_,he,N,Ie,oe,ve,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,v)},[o,v,_]),$(()=>{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(v.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
+ import{EPointCloudPattern as Q}from"@labelbee/lb-utils";import Se,{useState as r,useRef as st,useMemo as R,useCallback as l,useEffect as U}from"react";import{EPointCloudBoxRenderTrigger as M,calcResetAreasAndBoxIds as rt}from"../../utils/ToolPointCloudBoxRenderHelper.js";import{ActionsHistory as ye,EToolName as X,uuid as lt}from"@labelbee/lb-annotation";import{useDispatch as at}from"../../store/ctx.js";import{ChangeSave as dt}from"../../store/annotation/actionCreators.js";import ct from"../../store/annotatedBox/index.js";import Re from"lodash";import{addMapIndirectWeakSetItem as be}from"./utils/map.js";var ut=Object.defineProperty,pt=Object.defineProperties,mt=Object.getOwnPropertyDescriptors,we=Object.getOwnPropertySymbols,ft=Object.prototype.hasOwnProperty,gt=Object.prototype.propertyIsEnumerable,xe=(a,n,d)=>n in a?ut(a,n,{enumerable:!0,configurable:!0,writable:!0,value:d}):a[n]=d,j=(a,n)=>{for(var d in n||(n={}))ft.call(n,d)&&xe(a,d,n[d]);if(we)for(var d of we(n))gt.call(n,d)&&xe(a,d,n[d]);return a},De=(a,n)=>pt(a,mt(n)),ht=(a,n,d)=>new Promise((b,D)=>{var L=m=>{try{g(d.next(m))}catch(w){D(w)}},E=m=>{try{g(d.throw(m))}catch(w){D(w)}},g=m=>m.done?b(m.value):Promise.resolve(m.value).then(L,E);g((d=d.apply(a,n)).next())});const k=a=>Re.pick(a,["id","attribute","width","height","x","y","imageName"]),Le=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 ye,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:X.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:Q.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:a=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:a=>!1,removeRectBySpecifyId:(a,n,d)=>!1,removeRectByPointCloudBoxId:a=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{}}),vt=({children:a})=>{const[n,d]=r([]),[b,D]=r([]),[L,E]=r([]),[g,m]=r([]),[w,Ae]=r([]),[v,F]=r([]),[x,z]=r([]),[Y,Be]=r(!0),[$,_e]=r(2),[ee,Ve]=r(!0),[te,Ne]=r(1),[p,oe]=r(),[ne,ie]=r(),[se,re]=r(),[c,le]=r(),[ae,Oe]=r(""),[_,He]=r(X.Rect),V=st(new ye).current,[f,G]=r([]),[de,Me]=r(""),[N,je]=r(Q.Detection),[C,ce]=r(void 0),[T,ke]=r([]),[Z,Ee]=r([]),h=ct(),[ue,Fe]=r({}),ze=at(),Ge=e=>{const{imgNode:t,path:o}=e;o&&t&&Fe(i=>De(j({},i),{[o]:{width:t.width,height:t.height}}))},W=R(()=>v.length===1?v[0]:"",[v]),O=l((e,t,o="extId")=>{const i=o||"id",s=new Set(t);return m(u=>{let S=!1;const y=u.filter(B=>{const P=B[i],I=s.has(P)?B.imageName!==e:!0;return I||(S=!0),I});return S?y:u}),!0},[]),pe=l(e=>{const t=n.map(o=>o.id);return O(e,t,"extId")},[n,O]),me=l(e=>{if(!e)return!1;const t=n.filter(o=>Array.isArray(o.rects)).map(o=>{const{id:i,attribute:s,trackID:u}=o,S=o.rects.find(y=>y.imageName===e);if(S){const y=Re.pick(S,["width","height","x","y","imageName"]);return De(j({},y),{id:lt(),attribute:s,order:u,extId:i,lineDash:[]})}return null}).filter(o=>o!==null);return t.length?(m(o=>{const i=new Set(o.filter(u=>e===u.imageName).map(u=>u.extId)),s=t.filter(u=>i.has(u.extId)===!1);return s.length?[...o,...s]:o}),!0):!1},[n]),fe=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:u}=s;if(!u){console.warn("Missing image name"),console.trace(s,o);return}be(t,u,o.id,o)}),t},new Map),[n]),ge=l(e=>{m(t=>e(t,k))},[k]),he=R(()=>g.filter(e=>e.extId!==void 0&&e.id!==void 0).reduce((e,t)=>{const o=t.imageName;return o?(be(e,o,t.extId,t),e):(console.warn("missing image name"),console.log(t,g),e)},new Map),[g]),ve=R(()=>n.find(e=>e.id===W),[n,W]),q=R(()=>n.filter(e=>!f.includes(e.attribute)),[n,f]),J=R(()=>b.filter(e=>!f.includes(e.attribute)),[b,f]),K=R(()=>w.filter(e=>e.attribute&&!f.includes(e.attribute)),[w,f]),Te=l(e=>{const t=n.concat(e);return d(t),t},[n]),Ze=l(e=>{const t=b.concat(e);return D(t),t},[b]),We=l(e=>{Be(e!==!1)},[]),A=l(e=>{e===void 0&&F([]),typeof e=="string"&&F([e]),Array.isArray(e)&&F(Array.from(new Set(e)))},[]),qe=l(e=>{v.includes(e)?A(v.filter(t=>t!==e)):A([...v,e])},[v]),Je=l(e=>{const t=k(e);m(o=>[...o,t])},[g]),Ke=l((e,t=!1)=>{const o=k(e);m(i=>i.map(s=>s.id===e.id?t?j(j({},s),o):o:s))},[g]),Qe=l(e=>{m(t=>t.filter(o=>!e.find(i=>i.id===o.id)))},[g]),Ue=l(e=>{x.includes(e)?z([]):z([e])},[x]),Xe=l(()=>{if(_===X.Rect){const e=n.map(t=>t.id);A(e),p==null||p.pointCloud2dOperation.setSelectedIDs(e)}},[_,n,p,p==null?void 0:p.pointCloud2dOperation]),Ye=l(e=>{A(n.filter(t=>t.attribute===e).map(t=>t.id))},[n]),$e=l(e=>{if(f.includes(e))G(f.filter(t=>t!==e));else{const t=f.concat(e);G(t)}},[f]),et=l((e=q,t=L,o=J,i=K,s=T)=>{var u;c==null||c.clearAllBox(),c==null||c.clearAllSphere(),p==null||p.updatePolygonList(e,t),p==null||p.updatePointList(o),p==null||p.updateLineList(i),c==null||c.generateBoxes(e),c==null||c.generateSpheres(o),(u=C==null?void 0:C.store)==null||u.updateCurrentSegment(s),Ie(M.Default,e)},[c,p,C,C==null?void 0:C.store]),tt=l(()=>{oe(void 0),ie(void 0),re(void 0),le(void 0)},[]),Ie=l((e,t,o)=>ht(void 0,null,function*(){var i,s,u;if(!c)return;const S=c.pointCloudObject;if(!S)return;let y=[],B=[];try{if(t&&V.record.length){const{record:P,recordIndex:I}=V;let Pe=I;I>0&&(e===M.SingleToggleValid||e===M.SingleRotate||e===M.Single&&t.length===((i=P[I])==null?void 0:i.pointCloudBoxList.length))&&(Pe=I-1);let it=(s=P[Pe])==null?void 0:s.pointCloudBoxList;const Ce=rt(e,t,it);y=Ce.modifiedBoxIds,B=Ce.resetAreas}}catch(P){console.error("call calcResetAreasAndBoxIds error",P)}try{const P=yield c.getHighlightIndexByMappingImgList({mappingImgList:o!=null?o:Z,points:S.geometry.attributes.position.array}),I=yield c==null?void 0:c.highlightOriginPointCloud(t,P,{modifiedBoxIds:y,resetAreas:B});return I&&((u=p==null?void 0:p.pointCloudInstance)==null||u.updateColor(I)),I}catch(P){console.error("call highlightOriginPointCloud error",P)}}),[c,c==null?void 0:c.pointCloudObject,V]),ot=l(e=>{N!==e&&(ze(dt),je(e),e===Q.Detection&&ce(void 0))},[N]),H=R(()=>({selectedID:W,pointCloudBoxList:n,pointCloudSphereList:b,displayPointCloudList:q,displaySphereList:J,displayLineList:K,selectedIDs:v,setPointCloudResult:d,setSelectedIDs:A,addPointCloudBox:Te,addPointCloudSphere:Ze,setPointCloudSphereList:D,valid:Y,selectedPointCloudBox:ve,setPointCloudValid:We,addSelectedID:qe,addHighlightID:Ue,selectedAllBoxes:Xe,topViewInstance:p,setTopViewInstance:oe,sideViewInstance:ne,setSideViewInstance:ie,backViewInstance:se,setBackViewInstance:re,mainViewInstance:c,setMainViewInstance:le,polygonList:L,setPolygonList:E,rectList:g,setRectList:m,addRectIn2DView:Je,removeRectIn2DView:Qe,updateRectIn2DView:Ke,lineList:w,setLineList:Ae,zoom:te,setZoom:Ne,history:V,toggleAttributesVisible:$e,hideAttributes:f,setHideAttributes:G,reRender:et,attrPanelLayout:de,setAttrPanelLayout:Me,syncAllViewPointCloudColor:Ie,defaultAttribute:ae,setDefaultAttribute:Oe,pointCloudPattern:_,setPointCloudPattern:He,selectSpecAttr:Ye,globalPattern:N,setGlobalPattern:ot,ptSegmentInstance:C,setPtSegmentInstance:ce,segmentation:T,setSegmentation:ke,clearAllDetectionInstance:tt,highlight2DDataList:Z,setHighlight2DDataList:Ee,cuboidBoxIn2DView:ee,setCuboidBoxIn2DView:Ve,imageSizes:ue,cacheImageNodeSize:Ge,highlightIDs:x,setHighlightIDs:z,removeRectByPointCloudBoxId:pe,removeRectBySpecifyId:O,addRectFromPointCloudBoxByImageName:me,rectRotateSensitivity:$,setRectRotateSensitivity:_e,imageNamePointCloudBoxMap:fe,linkageImageNameRectMap:he,updateRectListByReducer:ge}),[Y,ve,q,J,K,L,g,p,ne,se,c,te,de,ae,_,N,C,T,Z,ee,ue,x,pe,O,me,$,fe,he,ge]);U(()=>{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,x),(o=h==null?void 0:h.setSelectedIDs)==null||o.call(h,v)},[n,v,x]),U(()=>{var e;(e=h==null?void 0:h.setPtCtx)==null||e.call(h,H)},[H]);const nt=()=>{const e=n.filter(s=>f.includes(s.attribute)),{setSelectedIDs:t,reRender:o}=H,i=e.map(s=>s.id);i.length>0&&t(v.filter(s=>!i.includes(s))),o()};return U(()=>{var e,t,o,i;nt(),(t=(e=p==null?void 0:p.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(Le.Provider,{value:H},a)};export{Le as PointCloudContext,vt as PointCloudProvider};
@@ -1 +1 @@
1
- import h,{useState as V,useContext as C,useCallback as R,useMemo as d,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=d(()=>e?i.has(e):(console.error("Missing image name"),!1),[e,i]),r=d(()=>{var l,u;return e?((u=(l=a.get(e))==null?void 0:l.size)!=null?u:0)>0:!1},[a,e]),c=d(()=>s||r,[s,r]),g=o(c);return{visible:c,visibleRef:g}},B={width:16,height:16},$=e=>{e.imageName||console.warn("missing imageName");const[i,a]=V(!0),s=o(e.imageName),{addRectFromPointCloudBoxByImageName:r,removeRectByPointCloudBoxId:c,linkageImageNameRectMap:g,pointCloudBoxList:l,rectList:u}=C(k),{visible:I,visibleRef:y}=T(e.imageName),{syncToPointCloudBoxList:L}=F(),M=o(r),N=o(c),P=o(()=>L()),f=R(n=>{if(!y.current)return;const t=s.current;if(!t){console.warn("invalid image name");return}a(n),n?N.current(t):M.current(t)},[]),D=o(n=>{n&&P.current(),f(n)}),_=d(()=>{var n;if(!e.is2DView||!I)return null;const m={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 h.createElement("div",{style:m},i&&h.createElement("img",{src:j,style:B}),!i&&h.createElement("img",{src:z,style:B}))},[i,e.is2DView,e.zIndex,I]),E=o(g),v=R(()=>{var n,t;if(!e.is2DView)return;const m=s.current;if(!m){console.warn("invalid image name");return}const S=[...(t=(n=E.current.get(m))==null?void 0:n.keys())!=null?t:[]];let w=!0;S.length&&(w=!1),f(w)},[e.is2DView,f]);return b(()=>{v()},[v,l,u]),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
+ import v,{useState as T,useContext as p,useCallback as B,useMemo as h,useEffect as C}from"react";import{useLatest as s}from"ahooks";import{PointCloudContext as y}from"../PointCloudContext.js";import U from"../../../assets/annotation/icon_link.svg.js";import $ from"../../../assets/annotation/icon_unlink.svg.js";import{EventBusEvent as L}from"../../../views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js";import{EventBus as M}from"@labelbee/lb-annotation";import{useSyncRectPositionDimensionToPointCloudList as q}from"./usePointCloudViews.js";const A=e=>{const{imageNamePointCloudBoxMap:o,linkageImageNameRectMap:m}=p(y),r=h(()=>e?o.has(e):(console.error("Missing image name"),!1),[e,o]),d=h(()=>{var a,f;return e?((f=(a=m.get(e))==null?void 0:a.size)!=null?f:0)>0:!1},[m,e]),g=h(()=>r||d,[r,d]),I=s(g);return{visible:g,visibleRef:I}},N={width:16,height:16},G=e=>{e.imageName||console.warn("missing imageName");const[o,m]=T(!0),r=s(e.imageName),{addRectFromPointCloudBoxByImageName:d,removeRectByPointCloudBoxId:g,linkageImageNameRectMap:I,pointCloudBoxList:a,rectList:f,updateRectListByReducer:P}=p(y),{visible:R,visibleRef:D}=A(e.imageName),{syncToPointCloudBoxList:E}=q(),S=s(d),_=s(g),V=s(()=>E()),w=B(n=>{if(!D.current)return;const t=r.current;if(!t){console.warn("invalid image name");return}m(n),n?_.current(t):S.current(t)},[]),j=s(n=>{n&&V.current(),w(n)}),z=h(()=>{var n;if(!e.is2DView||!R)return null;const i={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 v.createElement("div",{style:i},o&&v.createElement("img",{src:U,style:N}),!o&&v.createElement("img",{src:$,style:N}))},[o,e.is2DView,e.zIndex,R]),F=s(I),k=B(()=>{var n,t;if(!e.is2DView)return;const i=r.current;if(!i){console.warn("invalid image name");return}const c=[...(t=(n=F.current.get(i))==null?void 0:n.keys())!=null?t:[]];let l=!0;c.length&&(l=!1),w(l)},[e.is2DView,w]);return C(()=>{k()},[k,a,f]),C(()=>{const n=a.map(i=>i.id),t=new Set(n);P((i,x)=>{const c=[],l=[];return i.forEach(u=>{const b=u.extId;b!==void 0&&t.has(b)===!1?c.push(u):l.push(u)}),c.length?[...c.map(u=>x(u)),...l]:i})},[a]),C(()=>{const n=t=>{j.current(t)};return M.on(L.switchConnect,n),()=>M.unbind(L.switchConnect,n)},[]),{rendered:z,isLinking:o}};export{G as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.64",
3
+ "version": "1.23.0-alpha.66",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "^4.6.2",
46
- "@labelbee/lb-annotation": "1.27.0-alpha.33",
46
+ "@labelbee/lb-annotation": "1.27.0-alpha.34",
47
47
  "@labelbee/lb-utils": "1.19.0-alpha.18",
48
48
  "@labelbee/wavesurfer": "1.0.0",
49
49
  "@types/react-dom": "^18.2.7",