@labelbee/lb-components 1.23.0-alpha.67 → 1.23.0-alpha.69

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 React=require("react"),ReactDOM=require("react-dom"),index=require("../../audioAnnotate/audioContext/index.js"),audio=require("../../../utils/audio.js"),loop=require("../../../assets/annotation/audio/loop.svg.js"),antd=require("antd"),ahooks=require("ahooks"),index$1=require("../../../utils/index.js"),index_module=require("./index.module.scss.js"),reactI18next=require("react-i18next"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),ReactDOM__default=_interopDefaultLegacy(ReactDOM),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const{Paragraph}=antd.Typography,SubAttributeShowText=({result:e,subAttributeList:t,textStyle:r})=>{const s=lbAnnotation.TagUtils.getTagNameList(e,t);return React__default.default.createElement("div",null,s.map((i,n)=>React__default.default.createElement(Paragraph,{ellipsis:{rows:2},className:index_module.text,key:n,style:__spreadProps(__spreadValues({},r),{marginBottom:0})},`${i.keyName}\uFF1A${i.value.join("\u3001")}`)))},ClipRegion=e=>{const{t}=reactI18next.useTranslation(),{audioClipState:r,setAudioClipState:s}=index.useAudioClipStore(),{clipAttributeList:i,clipAttributeConfigurable:n,clipTextConfigurable:C,selectedRegion:f,clipTextList:b,secondaryAttributeConfigurable:O,subAttributeList:v}=r,m=React.useRef(null),{el:h,region:g,edgeAdsorption:E,clipping:P,instance:x}=e,{attribute:u="",text:S="",id:d,start:w,end:j,subAttribute:_}=g,{id:c}=f,o=audio.getAttributeColor(u,i),p={color:audio.getAttributeFontColor(u,i),backgroundColor:o},a={border:`2px solid ${o}`};if(d===c)a.backgroundColor=audio.updateColorOpacity(o,.6),a.borderLeft=`2px solid ${o}`,a.borderRight=`2px solid ${o}`;else if(x==null||x.setLoop(!1),a.borderLeft=`2px solid ${o}`,a.borderRight=`2px solid ${o}`,P){const l=Object.values(E);l.includes(w)&&(a.borderLeft="3px dashed #fff"),l.includes(j)&&(a.borderRight="3px dashed #fff")}ahooks.useClickAway(()=>{d===c&&s({selectedRegion:{}})},m,["contextmenu"]);const q=d===c&&f.loop,R=React__default.default.createElement("div",{style:a,ref:m,className:index$1.classnames({[index_module.container]:!0})},q&&React__default.default.createElement("div",{className:index_module.loop},React__default.default.createElement("img",{src:loop})),n&&React__default.default.createElement("div",null,React__default.default.createElement("div",{style:p,className:index_module.attribute},audio.getAttributeShowText(u,[{value:"",key:"\u65E0\u5C5E\u6027"},...i])),O&&_&&v&&React__default.default.createElement(SubAttributeShowText,{result:_,subAttributeList:v,textStyle:p})),C&&(b==null?void 0:b.map((l,L)=>{var y,A;return React__default.default.createElement(Paragraph,{ellipsis:{rows:2},className:index_module.text,style:p,key:L},(y=l==null?void 0:l.label)!=null?y:t("textTool"),":",(A=g[l==null?void 0:l.key])!=null?A:"")})));return React__default.default.createElement(React__default.default.Fragment,null,ReactDOM__default.default.createPortal(R,h))};module.exports=ClipRegion;
1
+ "use strict";var React=require("react"),ReactDOM=require("react-dom"),index=require("../../audioAnnotate/audioContext/index.js"),audio=require("../../../utils/audio.js"),loop=require("../../../assets/annotation/audio/loop.svg.js"),antd=require("antd"),ahooks=require("ahooks"),index$1=require("../../../utils/index.js"),index_module=require("./index.module.scss.js"),reactI18next=require("react-i18next");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React),ReactDOM__default=_interopDefaultLegacy(ReactDOM);const{Paragraph}=antd.Typography,ClipRegion=t=>{const{t:b}=reactI18next.useTranslation(),{audioClipState:g,setAudioClipState:m}=index.useAudioClipStore(),{clipAttributeList:a,clipAttributeConfigurable:C,clipTextConfigurable:y,selectedRegion:n,clipTextList:u}=g,d=React.useRef(null),{el:h,region:c,edgeAdsorption:R,clipping:q,instance:f}=t,{attribute:l="",text:j="",id:i,start:A,end:E}=c,{id:s}=n,o=audio.getAttributeColor(l,a),p={color:audio.getAttributeFontColor(l,a),backgroundColor:o},e={border:`2px solid ${o}`};if(i===s)e.backgroundColor=audio.updateColorOpacity(o,.6),e.borderLeft=`2px solid ${o}`,e.borderRight=`2px solid ${o}`;else if(f==null||f.setLoop(!1),e.borderLeft=`2px solid ${o}`,e.borderRight=`2px solid ${o}`,q){const r=Object.values(R);r.includes(A)&&(e.borderLeft="3px dashed #fff"),r.includes(E)&&(e.borderRight="3px dashed #fff")}ahooks.useClickAway(()=>{i===s&&m({selectedRegion:{}})},d,["contextmenu"]);const k=i===s&&n.loop,L=React__default.default.createElement("div",{style:e,ref:d,className:index$1.classnames({[index_module.container]:!0})},k&&React__default.default.createElement("div",{className:index_module.loop},React__default.default.createElement("img",{src:loop})),C&&React__default.default.createElement("div",null,React__default.default.createElement("div",{style:p,className:index_module.attribute},audio.getAttributeShowText(l,[{value:"",key:"\u65E0\u5C5E\u6027"},...a]))),y&&(u==null?void 0:u.map((r,_)=>{var v,x;return React__default.default.createElement(Paragraph,{ellipsis:{rows:2},className:index_module.text,style:p,key:_},(v=r==null?void 0:r.label)!=null?v:b("textTool"),":",(x=c[r==null?void 0:r.key])!=null?x:"")})));return React__default.default.createElement(React__default.default.Fragment,null,ReactDOM__default.default.createPortal(L,h))};module.exports=ClipRegion;
@@ -1 +1 @@
1
- "use strict";var dom=require("../../utils/dom.js"),React=require("react"),index=require("../AnnotationView/index.js"),useSize=require("../../hooks/useSize.js"),useSingleBox=require("./hooks/useSingleBox.js"),useHighlight=require("./hooks/useHighlight.js"),index$2=require("./components/HighlightVisible/index.js"),PointCloudContext=require("./PointCloudContext.js"),useDataLinkSwitch=require("./hooks/useDataLinkSwitch.js"),index$1=require("../pointCloud2DRectOperationView/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__async=(e,u,i)=>new Promise((s,a)=>{var f=t=>{try{o(i.next(t))}catch(n){a(n)}},c=t=>{try{o(i.throw(t))}catch(n){a(n)}},o=t=>t.done?s(t.value):Promise.resolve(t.value).then(f,c);o((i=i.apply(e,u)).next())});const PointCloud2DSingleView=({view2dData:e,setSelectedID:u,currentData:i,showEnlarge:s,checkMode:a=!1,measureVisible:f})=>{var c,o;const t=React.useRef(null),n=React.useRef(),{selectedBox:d}=useSingleBox.useSingleBox(),m=useSize(t),{url:p,fallbackUrl:x,calib:v,path:S}=e,{toggle2dVisible:j,isHighlightVisible:q}=useHighlight.useHighlight({currentData:i}),[P,k]=React.useState(!1),{cuboidBoxIn2DView:h,cacheImageNodeSize:_}=React.useContext(PointCloudContext.PointCloudContext),B=!e,V=React.useMemo(()=>({zIndex:s?-1:101,is2DView:!h,imageName:e.path}),[s,h,e.path]),{rendered:z,isLinking:I}=useDataLinkSwitch(V),b=l=>{g(),_({path:S,imgNode:l})},g=React.useCallback(()=>{var l,C;const y=(l=n.current)==null?void 0:l.toolInstance;if(u(""),!d||!y)return;const r=e.annotations.find(O=>O.annotation.id===d.info.id);let L="";r&&((C=r==null?void 0:r.annotation.pointList)==null?void 0:C.length)>0&&(y.focusPositionByPointList(r==null?void 0:r.annotation.pointList),L=d.info.id,u(L))},[d,n.current,e.annotations]);React.useEffect(()=>{g()},[g]);const R=()=>__async(void 0,null,function*(){k(!0);try{yield j(p,x!=null?x:"",v)}catch(l){console.error("highlightOnClick error:",l)}finally{k(!1)}});return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-2d-image"),ref:t},h?React__default.default.createElement(index,{src:(c=e==null?void 0:e.url)!=null?c:"",fallbackSrc:(o=e==null?void 0:e.fallbackUrl)!=null?o:"",annotations:e.annotations,size:m,ref:n,globalStyle:{display:B?"none":"block"},afterImgOnLoad:b,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f}):React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{shouldExcludePointCloudBoxListUpdate:!I,mappingData:e,size:m,checkMode:a,afterImgOnLoad:b}),!a&&z),v&&React__default.default.createElement(index$2,{visible:q(p),onClick:R,loading:P,style:{position:"absolute",right:16,top:16,zIndex:s?-1:101}}))};module.exports=PointCloud2DSingleView;
1
+ "use strict";var dom=require("../../utils/dom.js"),React=require("react"),index=require("../AnnotationView/index.js"),useSize=require("../../hooks/useSize.js"),useSingleBox=require("./hooks/useSingleBox.js"),useHighlight=require("./hooks/useHighlight.js"),index$2=require("./components/HighlightVisible/index.js"),PointCloudContext=require("./PointCloudContext.js"),useDataLinkSwitch=require("./hooks/useDataLinkSwitch.js"),index$1=require("../pointCloud2DRectOperationView/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__async=(e,u,i)=>new Promise((s,a)=>{var f=t=>{try{o(i.next(t))}catch(n){a(n)}},c=t=>{try{o(i.throw(t))}catch(n){a(n)}},o=t=>t.done?s(t.value):Promise.resolve(t.value).then(f,c);o((i=i.apply(e,u)).next())});const PointCloud2DSingleView=({view2dData:e,setSelectedID:u,currentData:i,showEnlarge:s,checkMode:a=!1,measureVisible:f})=>{var c,o;const t=React.useRef(null),n=React.useRef(),{selectedBox:d}=useSingleBox.useSingleBox(),m=useSize(t),{url:p,fallbackUrl:x,calib:v,path:j}=e,{toggle2dVisible:q,isHighlightVisible:P}=useHighlight.useHighlight({currentData:i}),[_,b]=React.useState(!1),{highlight2DLoading:B,setHighlight2DLoading:k,cuboidBoxIn2DView:h,cacheImageNodeSize:V}=React.useContext(PointCloudContext.PointCloudContext),z=!e,I=React.useMemo(()=>({zIndex:s?-1:101,is2DView:!h,imageName:e.path}),[s,h,e.path]),{rendered:R,isLinking:H}=useDataLinkSwitch(I),C=l=>{g(),V({path:j,imgNode:l})},g=React.useCallback(()=>{var l,L;const y=(l=n.current)==null?void 0:l.toolInstance;if(u(""),!d||!y)return;const r=e.annotations.find(E=>E.annotation.id===d.info.id);let S="";r&&((L=r==null?void 0:r.annotation.pointList)==null?void 0:L.length)>0&&(y.focusPositionByPointList(r==null?void 0:r.annotation.pointList),S=d.info.id,u(S))},[d,n.current,e.annotations]);React.useEffect(()=>{g()},[g]);const O=()=>__async(void 0,null,function*(){b(!0),k(!0);try{yield q(p,x!=null?x:"",v)}catch(l){console.error("highlightOnClick error:",l)}finally{b(!1),k(!1)}});return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-2d-image"),ref:t},h?React__default.default.createElement(index,{src:(c=e==null?void 0:e.url)!=null?c:"",fallbackSrc:(o=e==null?void 0:e.fallbackUrl)!=null?o:"",annotations:e.annotations,size:m,ref:n,globalStyle:{display:z?"none":"block"},afterImgOnLoad:C,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f}):React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{shouldExcludePointCloudBoxListUpdate:!H,mappingData:e,size:m,checkMode:a,afterImgOnLoad:C}),!a&&R),v&&React__default.default.createElement(index$2,{visible:P(p),onClick:O,loading:_,disabled:B,style:{position:"absolute",right:16,top:16,zIndex:s?-1:101}}))};module.exports=PointCloud2DSingleView;
@@ -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(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
+ "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,a)=>n in i?__defProp(i,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[n]=a,__spreadValues=(i,n)=>{for(var a in n||(n={}))__hasOwnProp.call(n,a)&&__defNormalProp(i,a,n[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(n))__propIsEnum.call(n,a)&&__defNormalProp(i,a,n[a]);return i},__spreadProps=(i,n)=>__defProps(i,__getOwnPropDescs(n)),__async=(i,n,a)=>new Promise((S,R)=>{var y=u=>{try{f(a.next(u))}catch(b){R(b)}},M=u=>{try{f(a.throw(u))}catch(b){R(b)}},f=u=>u.done?S(u.value):Promise.resolve(u.value).then(y,M);f((a=a.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:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:i=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:i=>!1,removeRectBySpecifyId:(i,n,a)=>!1,removeRectByPointCloudBoxId:i=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{}}),PointCloudProvider=({children:i})=>{const[n,a]=React.useState([]),[S,R]=React.useState([]),[y,M]=React.useState([]),[f,u]=React.useState([]),[b,pe]=React.useState([]),[h,N]=React.useState([]),[x,O]=React.useState([]),[G,he]=React.useState(!0),[W,me]=React.useState(2),[Z,ve]=React.useState(!0),[U,Ce]=React.useState(1),[c,J]=React.useState(),[K,Q]=React.useState(),[X,Y]=React.useState(),[r,$]=React.useState(),[ee,Ie]=React.useState(""),[L,Pe]=React.useState(lbAnnotation.EToolName.Rect),A=React.useRef(new lbAnnotation.ActionsHistory).current,[g,H]=React.useState([]),[te,Se]=React.useState(""),[B,be]=React.useState(lbUtils.EPointCloudPattern.Detection),[C,oe]=React.useState(void 0),[E,xe]=React.useState([]),[j,Re]=React.useState([]),[ne,ye]=React.useState(!1),p=index(),[ie,we]=React.useState({}),De=ctx.useDispatch(),Le=e=>{const{imgNode:t,path:o}=e;o&&t&&we(s=>__spreadProps(__spreadValues({},s),{[o]:{width:t.width,height:t.height}}))},q=React.useMemo(()=>h.length===1?h[0]:"",[h]),V=React.useCallback((e,t,o="extId")=>{const s=o||"id",l=new Set(t);return u(d=>{let I=!1;const P=d.filter(D=>{const v=D[s],m=l.has(v)?D.imageName!==e:!0;return m||(I=!0),m});return I?P:d}),!0},[]),se=React.useCallback(e=>{const t=n.map(o=>o.id);return V(e,t,"extId")},[n,V]),le=React.useCallback(e=>{if(!e)return!1;const t=n.filter(o=>Array.isArray(o.rects)).map(o=>{const{id:s,attribute:l,trackID:d}=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:d,extId:s,lineDash:[]})}return null}).filter(o=>o!==null);return t.length?(u(o=>{const s=new Set(o.filter(d=>e===d.imageName).map(d=>d.extId)),l=t.filter(d=>s.has(d.extId)===!1);return l.length?[...o,...l]:o}),!0):!1},[n]),ae=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:d}=l;if(!d){console.warn("Missing image name"),console.trace(l,o);return}map.addMapIndirectWeakSetItem(t,d,o.id,o)}),t},new Map),[n]),re=React.useCallback(e=>{u(t=>e(t,pickRectObject))},[pickRectObject]),de=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]),ce=React.useMemo(()=>n.find(e=>e.id===q),[n,q]),T=React.useMemo(()=>n.filter(e=>!g.includes(e.attribute)),[n,g]),F=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]),Ae=React.useCallback(e=>{const t=n.concat(e);return a(t),t},[n]),Be=React.useCallback(e=>{const t=S.concat(e);return R(t),t},[S]),_e=React.useCallback(e=>{he(e!==!1)},[]),w=React.useCallback(e=>{e===void 0&&N([]),typeof e=="string"&&N([e]),Array.isArray(e)&&N(Array.from(new Set(e)))},[]),Ve=React.useCallback(e=>{h.includes(e)?w(h.filter(t=>t!==e)):w([...h,e])},[h]),ke=React.useCallback(e=>{const t=pickRectObject(e);u(o=>[...o,t])},[f]),Me=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))},[f]),Ne=React.useCallback(e=>{u(t=>t.filter(o=>!e.find(s=>s.id===o.id)))},[f]),Oe=React.useCallback(e=>{x.includes(e)?O([]):O([e])},[x]),He=React.useCallback(()=>{if(L===lbAnnotation.EToolName.Rect){const e=n.map(t=>t.id);w(e),c==null||c.pointCloud2dOperation.setSelectedIDs(e)}},[L,n,c,c==null?void 0:c.pointCloud2dOperation]),Ee=React.useCallback(e=>{w(n.filter(t=>t.attribute===e).map(t=>t.id))},[n]),je=React.useCallback(e=>{if(g.includes(e))H(g.filter(t=>t!==e));else{const t=g.concat(e);H(t)}},[g]),qe=React.useCallback((e=T,t=y,o=F,s=z,l=E)=>{var d;r==null||r.clearAllBox(),r==null||r.clearAllSphere(),c==null||c.updatePolygonList(e,t),c==null||c.updatePointList(o),c==null||c.updateLineList(s),r==null||r.generateBoxes(e),r==null||r.generateSpheres(o),(d=C==null?void 0:C.store)==null||d.updateCurrentSegment(l),ue(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},[r,c,C,C==null?void 0:C.store]),Te=React.useCallback(()=>{J(void 0),Q(void 0),Y(void 0),$(void 0)},[]),ue=React.useCallback((e,t,o)=>__async(void 0,null,function*(){var s,l,d;if(!r)return;const I=r.pointCloudObject;if(!I)return;let P=[],D=[];try{if(t&&A.record.length){const{record:v,recordIndex:m}=A;let ge=m;m>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&t.length===((s=v[m])==null?void 0:s.pointCloudBoxList.length))&&(ge=m-1);let Ge=(l=v[ge])==null?void 0:l.pointCloudBoxList;const fe=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,t,Ge);P=fe.modifiedBoxIds,D=fe.resetAreas}}catch(v){console.error("call calcResetAreasAndBoxIds error",v)}try{const v=yield r.getHighlightIndexByMappingImgList({mappingImgList:o!=null?o:j,points:I.geometry.attributes.position.array}),m=yield r==null?void 0:r.highlightOriginPointCloud(t,v,{modifiedBoxIds:P,resetAreas:D});return m&&((d=c==null?void 0:c.pointCloudInstance)==null||d.updateColor(m)),m}catch(v){console.error("call highlightOriginPointCloud error",v)}}),[r,r==null?void 0:r.pointCloudObject,A]),Fe=React.useCallback(e=>{B!==e&&(De(actionCreators.ChangeSave),be(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:h,setPointCloudResult:a,setSelectedIDs:w,addPointCloudBox:Ae,addPointCloudSphere:Be,setPointCloudSphereList:R,valid:G,selectedPointCloudBox:ce,setPointCloudValid:_e,addSelectedID:Ve,addHighlightID:Oe,selectedAllBoxes:He,topViewInstance:c,setTopViewInstance:J,sideViewInstance:K,setSideViewInstance:Q,backViewInstance:X,setBackViewInstance:Y,mainViewInstance:r,setMainViewInstance:$,polygonList:y,setPolygonList:M,rectList:f,setRectList:u,addRectIn2DView:ke,removeRectIn2DView:Ne,updateRectIn2DView:Me,lineList:b,setLineList:pe,zoom:U,setZoom:Ce,history:A,toggleAttributesVisible:je,hideAttributes:g,setHideAttributes:H,reRender:qe,attrPanelLayout:te,setAttrPanelLayout:Se,syncAllViewPointCloudColor:ue,defaultAttribute:ee,setDefaultAttribute:Ie,pointCloudPattern:L,setPointCloudPattern:Pe,selectSpecAttr:Ee,globalPattern:B,setGlobalPattern:Fe,ptSegmentInstance:C,setPtSegmentInstance:oe,segmentation:E,setSegmentation:xe,clearAllDetectionInstance:Te,highlight2DDataList:j,setHighlight2DDataList:Re,highlight2DLoading:ne,setHighlight2DLoading:ye,cuboidBoxIn2DView:Z,setCuboidBoxIn2DView:ve,imageSizes:ie,cacheImageNodeSize:Le,highlightIDs:x,setHighlightIDs:O,removeRectByPointCloudBoxId:se,removeRectBySpecifyId:V,addRectFromPointCloudBoxByImageName:le,rectRotateSensitivity:W,setRectRotateSensitivity:me,imageNamePointCloudBoxMap:ae,linkageImageNameRectMap:de,updateRectListByReducer:re}),[G,ce,T,F,z,y,f,c,K,X,r,U,te,ee,L,B,C,E,j,ne,Z,ie,x,se,V,le,W,ae,de,re]);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,x),(o=p==null?void 0:p.setSelectedIDs)==null||o.call(p,h)},[n,h,x]),React.useEffect(()=>{var e;(e=p==null?void 0:p.setPtCtx)==null||e.call(p,k)},[k]);const ze=()=>{const e=n.filter(l=>g.includes(l.attribute)),{setSelectedIDs:t,reRender:o}=k,s=e.map(l=>l.id);s.length>0&&t(h.filter(l=>!s.includes(l))),o()};return React.useEffect(()=>{var e,t,o,s;ze(),(t=(e=c==null?void 0:c.toolInstance)==null?void 0:e.setHiddenAttributes)==null||t.call(e,g),(s=(o=C==null?void 0:C.store)==null?void 0:o.setHiddenAttributes)==null||s.call(o,g)},[g]),React__default.default.createElement(PointCloudContext.Provider,{value:k},i)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useSingleBox=require("./hooks/useSingleBox.js"),reactI18next=require("react-i18next");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,l)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,__spreadValues=(e,t)=>{for(var l in t||(t={}))__hasOwnProp.call(t,l)&&__defNormalProp(e,l,t[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(t))__propIsEnum.call(t,l)&&__defNormalProp(e,l,t[l]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const DECIMAL_PLACES=2,DEFAULT_BOX_INFO_STYLE={color:"white",backgroundColor:"rgba(153, 153, 153, 0.3)",padding:"8px 10px",zIndex:20,fontSize:12},SizeInfoForView=({perspectiveView:e})=>{const{pointCloudBoxList:t,selectedID:l}=React__default.default.useContext(PointCloudContext.PointCloudContext),u=t.find(a=>a.id===l),n=reactI18next.useTranslation(),{t:i}=n;if(l&&u){const{length:a,width:c,height:r}=lbUtils.PointCloudUtils.transferBox2Kitti(u),f=e===lbUtils.EPerspectiveView.Back?[{label:i("Width"),value:c},{label:i("Height"),value:r}]:[{label:i("Length"),value:a},{label:i("Height"),value:r}];return React__default.default.createElement("div",{style:__spreadProps(__spreadValues({position:"absolute"},DEFAULT_BOX_INFO_STYLE),{bottom:"4%",left:"50%",transform:"translate(-50%, 0)"})},f.map((s,o)=>React__default.default.createElement("span",{key:o,style:{marginRight:o===0?16:0}},`${s.label}: ${s.value.toFixed(DECIMAL_PLACES)}`)))}return null},BoxInfos=({checkMode:e,config:t,style:l})=>{const u=React__default.default.useContext(PointCloudContext.PointCloudContext),{selectedBox:n}=useSingleBox.useSingleBox(),[i,a]=React.useState([]),c=reactI18next.useTranslation(),{t:r,i18n:f}=c,s=l;return React.useEffect(()=>{var o,p;if(!n)return;const{length:b,width:v,height:x,rotation_y:P}=lbUtils.PointCloudUtils.transferBox2Kitti(n.info),{x:g,y:_,z:h}=n.info.center;let d=[{label:"x",value:g==null?void 0:g.toFixed(DECIMAL_PLACES)},{label:"y",value:_==null?void 0:_.toFixed(DECIMAL_PLACES)},{label:"z",value:h==null?void 0:h.toFixed(DECIMAL_PLACES)},{label:r("Length"),value:b==null?void 0:b.toFixed(DECIMAL_PLACES)},{label:r("Width"),value:v==null?void 0:v.toFixed(DECIMAL_PLACES)},{label:r("Height"),value:x==null?void 0:x.toFixed(DECIMAL_PLACES)},{label:r("Rotation_y"),value:(o=lbAnnotation.UnitUtils.rad2deg(P))==null?void 0:o.toFixed(DECIMAL_PLACES)}];(p=u.mainViewInstance)==null||p.filterPointsByBox(n.info).then(m=>{var y,C;if(!m){a(d);return}d.push({label:r("PointCount"),value:`${(C=(y=n.info)==null?void 0:y.count)!=null?C:0}`}),e===!0&&n.info.subAttribute&&t&&lbUtils.PointCloudUtils.getSubAttributeName(n.info.subAttribute,t).forEach(w=>d.push(w)),a(d)})},[n,f.language]),n?React__default.default.createElement("div",{style:l||__spreadProps(__spreadValues({position:"absolute"},DEFAULT_BOX_INFO_STYLE),{right:8,bottom:8})},i.map(o=>s?React__default.default.createElement("div",{key:o.label,style:{margin:"0px 4px"}},`${o.label}: ${o.value}`):React__default.default.createElement("div",{key:o.label},React__default.default.createElement("span",{style:{width:"38px",display:"inline-block",textAlign:"end"}},o.label),": ",React__default.default.createElement("span",null,o.value)))):null},PointCloudValidity=()=>{const e=React__default.default.useContext(PointCloudContext.PointCloudContext),{t}=reactI18next.useTranslation();return e.valid===!1?React__default.default.createElement("div",{style:{position:"absolute",backgroundColor:"rgb(242, 101, 73)",color:"white",opacity:.7,left:0,top:0,fontSize:30,padding:"8px 16px",zIndex:20,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"}},t("Invalid")):null};exports.BoxInfos=BoxInfos,exports.PointCloudValidity=PointCloudValidity,exports.SizeInfoForView=SizeInfoForView;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useSingleBox=require("./hooks/useSingleBox.js"),reactI18next=require("react-i18next");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const DECIMAL_PLACES=2,DEFAULT_BOX_INFO_STYLE={color:"white",backgroundColor:"rgba(153, 153, 153, 0.3)",padding:"8px 10px",zIndex:20,fontSize:12},SizeInfoForView=({perspectiveView:e})=>{const{pointCloudBoxList:t,selectedID:n}=React__default.default.useContext(PointCloudContext.PointCloudContext),u=t.find(a=>a.id===n),l=reactI18next.useTranslation(),{t:i}=l;if(n&&u){const{length:a,width:c,height:r}=lbUtils.PointCloudUtils.transferBox2Kitti(u),f=e===lbUtils.EPerspectiveView.Back?[{label:i("Width"),value:c},{label:i("Height"),value:r}]:[{label:i("Length"),value:a},{label:i("Height"),value:r}];return React__default.default.createElement("div",{style:__spreadProps(__spreadValues({position:"absolute"},DEFAULT_BOX_INFO_STYLE),{bottom:"4%",left:"50%",transform:"translate(-50%, 0)",pointerEvents:"none"})},f.map((s,o)=>React__default.default.createElement("span",{key:o,style:{marginRight:o===0?16:0}},`${s.label}: ${s.value.toFixed(DECIMAL_PLACES)}`)))}return null},BoxInfos=({checkMode:e,config:t,style:n})=>{const u=React__default.default.useContext(PointCloudContext.PointCloudContext),{selectedBox:l}=useSingleBox.useSingleBox(),[i,a]=React.useState([]),c=reactI18next.useTranslation(),{t:r,i18n:f}=c,s=n;return React.useEffect(()=>{var o,p;if(!l)return;const{length:b,width:v,height:x,rotation_y:P}=lbUtils.PointCloudUtils.transferBox2Kitti(l.info),{x:g,y:_,z:h}=l.info.center;let d=[{label:"x",value:g==null?void 0:g.toFixed(DECIMAL_PLACES)},{label:"y",value:_==null?void 0:_.toFixed(DECIMAL_PLACES)},{label:"z",value:h==null?void 0:h.toFixed(DECIMAL_PLACES)},{label:r("Length"),value:b==null?void 0:b.toFixed(DECIMAL_PLACES)},{label:r("Width"),value:v==null?void 0:v.toFixed(DECIMAL_PLACES)},{label:r("Height"),value:x==null?void 0:x.toFixed(DECIMAL_PLACES)},{label:r("Rotation_y"),value:(o=lbAnnotation.UnitUtils.rad2deg(P))==null?void 0:o.toFixed(DECIMAL_PLACES)}];(p=u.mainViewInstance)==null||p.filterPointsByBox(l.info).then(m=>{var y,C;if(!m){a(d);return}d.push({label:r("PointCount"),value:`${(C=(y=l.info)==null?void 0:y.count)!=null?C:0}`}),e===!0&&l.info.subAttribute&&t&&lbUtils.PointCloudUtils.getSubAttributeName(l.info.subAttribute,t).forEach(w=>d.push(w)),a(d)})},[l,f.language]),l?React__default.default.createElement("div",{style:n||__spreadProps(__spreadValues({position:"absolute"},DEFAULT_BOX_INFO_STYLE),{right:8,bottom:8})},i.map(o=>s?React__default.default.createElement("div",{key:o.label,style:{margin:"0px 4px"}},`${o.label}: ${o.value}`):React__default.default.createElement("div",{key:o.label},React__default.default.createElement("span",{style:{width:"38px",display:"inline-block",textAlign:"end"}},o.label),": ",React__default.default.createElement("span",null,o.value)))):null},PointCloudValidity=()=>{const e=React__default.default.useContext(PointCloudContext.PointCloudContext),{t}=reactI18next.useTranslation();return e.valid===!1?React__default.default.createElement("div",{style:{position:"absolute",backgroundColor:"rgb(242, 101, 73)",color:"white",opacity:.7,left:0,top:0,fontSize:30,padding:"8px 16px",zIndex:20,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"}},t("Invalid")):null};exports.BoxInfos=BoxInfos,exports.PointCloudValidity=PointCloudValidity,exports.SizeInfoForView=SizeInfoForView;
@@ -1 +1 @@
1
- "use strict";var React=require("react"),icons=require("@ant-design/icons"),dom=require("../../../../utils/dom.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,t)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,__spreadValues=(e,r)=>{for(var t in r||(r={}))__hasOwnProp.call(r,t)&&__defNormalProp(e,t,r[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(r))__propIsEnum.call(r,t)&&__defNormalProp(e,t,r[t]);return e};const HighlightVisible=({visible:e,style:r,onClick:t,loading:a})=>{const i={background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,fontSize:16};let o=e?icons.EyeFilled:icons.EyeInvisibleFilled;return a&&(o=icons.LoadingOutlined,Object.assign(i,{borderRadius:100})),React__default.default.createElement(o,{className:dom.getClassName("point-cloud-highlight-view"),style:__spreadValues(__spreadValues({},i),r),onClick:a?()=>{}:t})};module.exports=HighlightVisible;
1
+ "use strict";var React=require("react"),icons=require("@ant-design/icons"),dom=require("../../../../utils/dom.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,t)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,__spreadValues=(e,r)=>{for(var t in r||(r={}))__hasOwnProp.call(r,t)&&__defNormalProp(e,t,r[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(r))__propIsEnum.call(r,t)&&__defNormalProp(e,t,r[t]);return e};const HighlightVisible=({visible:e,style:r,onClick:t,loading:a,disabled:o})=>{const l={background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,fontSize:16},s={background:"rgba(0, 0, 0, 0.2)",color:"rgba(255, 255, 255, 0.5)",cursor:"not-allowed"};let i=e?icons.EyeFilled:icons.EyeInvisibleFilled;a&&(i=icons.LoadingOutlined,Object.assign(l,{borderRadius:100}));const n=__spreadValues(__spreadValues({},l),r);return o&&Object.assign(n,s),React__default.default.createElement(i,{disabled:o,className:dom.getClassName("point-cloud-highlight-view"),style:n,onClick:a||o?()=>{}:t})};module.exports=HighlightVisible;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),_=require("lodash"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,t,s)=>t in o?__defProp(o,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[t]=s,__spreadValues=(o,t)=>{for(var s in t||(t={}))__hasOwnProp.call(t,s)&&__defNormalProp(o,s,t[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(t))__propIsEnum.call(t,s)&&__defNormalProp(o,s,t[s]);return o},__spreadProps=(o,t)=>__defProps(o,__getOwnPropDescs(t)),__async=(o,t,s)=>new Promise((c,e)=>{var p=a=>{try{u(s.next(a))}catch(x){e(x)}},g=a=>{try{u(s.throw(a))}catch(x){e(x)}},u=a=>a.done?c(a.value):Promise.resolve(a.value).then(p,g);u((s=s.apply(o,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,t,s,c,e)=>{const{x:p,y:g}=lbUtils.PointCloudUtils.transferCanvas2World(o,t),{defaultZ:u}=lbUtils.DEFAULT_SPHERE_PARAMS,a={center:{x:p,y:g,z:u},id:o.id},x=c?__spreadValues(__spreadValues({},c),a):__spreadProps(__spreadValues({},a),{attribute:"",valid:!0});return e&&Object.assign(x,e),x},topViewPolygon2PointCloud=(o,t,s,c,e,p)=>{let g=o.pointList.map(B=>lbUtils.PointCloudUtils.transferCanvas2World(B,t)),u=0,a=1,x={};if(s){const B=s.getSensesPointZAxisInPolygon(g,void 0,p);p&&B.fittedCoordinates.length>0&&(g=B.fittedCoordinates),u=(B.maxZ+B.minZ)/2,a=B.maxZ-B.minZ,x={count:B.zCount}}const[h,L,U]=g,I=lbAnnotation.MathUtils.getLineCenterPoint([h,U]),b=lbAnnotation.MathUtils.getLineLength(h,L),R=lbAnnotation.MathUtils.getLineLength(L,U),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);c&&(u=c.center.z,a=c.depth);const V={center:{x:I.x,y:I.y,z:u},width:p?R+INTELLIGENT_FIT_MARGIN:R,height:p?b+INTELLIGENT_FIT_MARGIN:b,depth:a,rotation:k,id:o.id},T=__spreadValues(c?__spreadValues(__spreadValues({},c),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),x);e&&Object.assign(T,e);const A=g.map(B=>lbUtils.PointCloudUtils.transferWorld2Canvas(B,t));return{boxParams:T,newPointList:A}},sideViewPoint2PointCloud=(o,t,s)=>{const c={x:o.x-t.x,y:o.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x-c.x,y:s.center.y,z:s.center.z-c.y}})},sideViewPolygon2PointCloud=(o,t,s,c)=>{const[e,p,g]=o.pointList,[u,a,x]=t.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([e,g]),L=lbAnnotation.MathUtils.getLineCenterPoint([u,x]),I={x:{x:h.x-L.x,y:h.y-L.y}.x,y:0,z:h.y-L.y},b=lbAnnotation.MathUtils.getLineLength(e,p),R=lbAnnotation.MathUtils.getLineLength(u,a),k=b-R,V=lbAnnotation.MathUtils.getLineLength(p,g),T=lbAnnotation.MathUtils.getLineLength(a,x),A=V-T,{newBoxParams:B}=c.getNewBoxBySideUpdate(I,A,k,s);return B},backViewPoint2PointCloud=(o,t,s)=>{const c={x:o.x-t.x,y:o.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x,y:s.center.y-c.x,z:s.center.z-c.y}})},backViewPolygon2PointCloud=(o,t,s,c)=>{const[e,p,g]=o.pointList,[u,a,x]=t.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([e,g]),L=lbAnnotation.MathUtils.getLineCenterPoint([u,x]),I={x:{x:h.x-L.x,y:h.y-L.y}.x,y:0,z:h.y-L.y},b=lbAnnotation.MathUtils.getLineLength(e,p),R=lbAnnotation.MathUtils.getLineLength(u,a),k=b-R,V=lbAnnotation.MathUtils.getLineLength(p,g),T=lbAnnotation.MathUtils.getLineLength(a,x),A=V-T;let{newBoxParams:B}=c.getNewBoxByBackUpdate(I,A,k,s);return B},syncSideViewByPoint=(o,t,s,c,e)=>{var p;if(!s)return;const{toolInstance:g,pointCloudInstance:u}=s;u.loadPCDFile(c,(p=e==null?void 0:e.radius)!=null?p:DEFAULT_RADIUS);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);u.setInitCameraPosition(a);const{point2d:x,zoom:h}=u.getSphereSidePoint2DCoordinate(o);u.camera.zoom=h,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(h),g.setResult([__spreadProps(__spreadValues(__spreadValues({},t),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),g.setSelectedID(t.id)},synchronizeSideView=(o,t,s,c)=>{if(!s)return;const{pointCloud2dOperation:e,pointCloudInstance:p}=s;p.loadPCDFileByBox(c,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:g}=p.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);p.setInitCameraPosition(g);const{polygon2d:u,zoom:a}=p.getBoxSidePolygon2DCoordinate(o);p.camera.zoom=a,p.camera.updateProjectionMatrix(),p.render(),e.initPosition(),e.zoomChangeOnCenter(a),e.setResultAndSelectedID([{id:t.id,valid:o.valid,pointList:u,textAttribute:"",isRect:!0,attribute:o.attribute}],t.id)},syncBackViewByPoint=(o,t,s,c,e)=>{var p;if(!s)return;const{toolInstance:g,pointCloudInstance:u}=s;u.loadPCDFile(c,(p=e==null?void 0:e.radius)!=null?p:DEFAULT_RADIUS);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);u.setInitCameraPosition(a);const{point2d:x,zoom:h}=u.getSphereBackPoint2DCoordinate(o);u.camera.zoom=h,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(h),g.setResult([__spreadProps(__spreadValues(__spreadValues({},t),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),g.setSelectedID(t.id)},synchronizeBackView=(o,t,s,c)=>{if(!s)return;const{pointCloud2dOperation:e,pointCloudInstance:p}=s;p.loadPCDFileByBox(c,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:g}=p.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);p.setInitCameraPosition(g);const{polygon2d:u,zoom:a}=p.getBoxBackPolygon2DCoordinate(o);p.camera.zoom=a,p.camera.updateProjectionMatrix(),p.render(),e.initPosition(),e.zoomChangeOnCenter(a),e.setResultAndSelectedID([{id:t.id,valid:o.valid,pointList:u,textAttribute:"",isRect:!0,attribute:o.attribute}],t.id)},syncTopViewByPoint=(o,t,s,c)=>{if(!s||!c)return;c.generateSphere(o),c.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),c.render();const{toolInstance:e,pointCloudInstance:p}=s,{point2d:g}=p.getSphereTopPoint2DCoordinate(o),u=[...e.pointList].map(a=>a.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),g),{valid:o.valid,textAttribute:"",attribute:o.attribute}):a);e.setResult(u),e.setSelectedID(t.id)},synchronizeTopView=(o,t,s,c)=>{var e,p;if(!s||!c)return;c.generateBox(o,t.id),c.render();const{pointCloud2dOperation:g,pointCloudInstance:u}=s,{polygon2d:a}=u.getBoxTopPolygon2DCoordinate(o),x=[...g.polygonList],h=x.find(L=>L.id===t.id);h?(h.pointList=a,h.valid=(e=o.valid)!=null?e:!0):x.push({id:t.id,pointList:a,textAttribute:"",isRect:!0,valid:(p=o.valid)!=null?p:!0}),g.setResultAndSelectedID(x,t.id)},usePointCloudViews=()=>{const o=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:s,backViewInstance:c,mainViewInstance:e,addPointCloudBox:p,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:a,pointCloudBoxList:x,pointCloudSphereList:h,hideAttributes:L,setHighlight2DDataList:U,cuboidBoxIn2DView:I,imageSizes:b,history:R,linkageImageNameRectMap:k}=o,{addHistory:V,initHistory:T,pushHistoryUnderUpdatePolygon:A}=useHistory.useHistory(),{selectedPolygon:B}=usePolygon.usePolygon(),{getPointCloudSphereByID:ot,updatePointCloudSphere:Y,selectedSphere:q}=useSphere.useSphere(),{currentData:j,config:m}=ctx.useSelector(i=>{const{stepList:n,step:d,imgList:r,imgIndex:l}=i.annotation;return{currentData:r[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(d,n).config)}}),M=ctx.useDispatch(),nt=ahooks.useLatest(I),it=ahooks.useLatest(k),st=React.useCallback((i,n)=>{const d=it.current,r=n.id;return i.filter(P=>{if(!P)return!1;const C=d.get(P.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),Z=i=>{const{enableAutoMap2DRect:n=!1}=m;if(!nt.current||n){const{mappingImgList:d=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:i,mappingImgList:d,imageSizes:b},{prepareRectsFn:st})}},{selectedBox:D,updateSelectedBox:rt,updateSelectedBoxes:G,getPointCloudByID:lt}=useSingleBox.useSingleBox({generateRects:Z}),K=D==null?void 0:D.info;if(!t||!s||!c)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:J}=t,at=i=>{e==null||e.generateBox(i),e==null||e.controls.update(),e==null||e.render()},dt=i=>{e==null||e.generateSphere(i),e==null||e.controls.update(),e==null||e.render()},ut=({newPoint:i,size:n,zoom:d,trackConfigurable:r})=>{var l;const P={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(P,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const C=topViewPoint2PointCloud(i,n,J,void 0,P);u(i.id);const f=g(C);H(PointCloudView.Top,i,C,d,f,m),V({newSphereParams:C})},ct=({polygon:i,size:n,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:P})=>{var C,f,v;const S={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(S,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:x,extraSphereList:h})});const z=t==null?void 0:t.toolInstance,w=__spreadValues({},i);let{boxParams:y,newPointList:O}=topViewPolygon2PointCloud(w,n,J,void 0,S,P);y=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[y],stepConfig:m,action:"viewUpdateBox"}))[0],P&&(O==null?void 0:O.length)&&(w.pointList=O);const X=L.includes(w.attribute);Z(y);const E=p(y),F=(f=o==null?void 0:o.polygonList)!=null?f:[];y.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((m==null?void 0:m.secondaryAttributeConfigurable)?(v=m==null?void 0:m.inputList)!=null?v:[]:[]),t==null||t.updatePolygonList(E!=null?E:[],F),X?u([]):(u(y.id),z.selection.setSelectedIDs(w.id),N({omitView:PointCloudView.Top,polygon:w,boxParams:y,zoom:l,newPointCloudBoxList:E}),P&&synchronizeTopView(y,w,t,e)),V({newBoxParams:y})},pt=i=>{const{boxID:n,imageName:d,width:r,height:l,x:P,y:C}=i,f=x.find(y=>y.id===n);if(!(f==null?void 0:f.rects)||!f.rects.find(y=>y.imageName===d))return;const S=f.rects.map(y=>y.imageName===d?__spreadProps(__spreadValues({},y),{width:r,height:l,x:P,y:C}):y),z=__spreadProps(__spreadValues({},f),{rects:S}),w=x.map(y=>y.id===n?z:y);return t==null||t.updatePolygonList(w!=null?w:[]),w},Pt=i=>{const{boxID:n,imageName:d}=i,r=x.find(f=>f.id===n);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(f=>f.imageName!==d),P=__spreadProps(__spreadValues({},r),{rects:l}),C=x.map(f=>f.id===n?P:f);return t==null||t.updatePolygonList(C!=null?C:[]),C},gt=({newSelectedBox:i,newPointCloudList:n,newSelectedSphere:d,newSphereList:r})=>{var l;const P=t==null?void 0:t.toolInstance;if(!(a.length===0||!P)){if(i||(D==null?void 0:D.info)){const C=i!=null?i:D==null?void 0:D.info;(l=P==null?void 0:P.selection)==null||l.setSelectedIDs(a[0]);const f=P.selectedPolygon;if(a.length===1&&C){N({omitView:PointCloudView.Top,polygon:f,boxParams:C,newPointCloudBoxList:n});return}}if((d||q)&&a.length===1){const C=d!=null?d:q;P.setSelectedID(a[0]);const f=P.selectedPoint;C&&H(PointCloudView.Top,f,C,void 0,r,m)}}},$=(i,n,d)=>{if(K){let r,l;switch(d){case PointCloudView.Back:r=backViewPolygon2PointCloud;break;case PointCloudView.Side:r=sideViewPolygon2PointCloud;break;default:r=sideViewPolygon2PointCloud;break}if(l=r(i,n,K,s.pointCloudInstance),e){const{count:S}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:S})}const C=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:m,action:"viewUpdateBox"}))[0],f=l.valid!==C.valid;l=C;const v=rt(l);return l=v.find(S=>S.id===l.id),N({omitView:f?void 0:d,polygon:i,boxParams:l,newPointCloudBoxList:v}),v}},tt=(i,n,d)=>{if(q){let r,l;switch(d){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}l=r(i,n,q);const P=Y(l);return H(d,i,l,void 0,P,m),P}},Ct=(i,n)=>{tt(i,n,PointCloudView.Side)},ft=(i,n)=>{tt(i,n,PointCloudView.Back)},xt=(i,n)=>{$(i,n,PointCloudView.Side)},ht=(i,n)=>{$(i,n,PointCloudView.Back)},vt=(i,n)=>{const d=ot(i.id),r=topViewPoint2PointCloud(i,n,J,d),l=Y(r);H(PointCloudView.Top,i,r,void 0,l,m)},yt=(i,n)=>{if(B){const r=__spreadValues({},i[0].newPolygon);r.pointList=r.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,n)),A(r);return}let d=i.map(({newPolygon:r})=>{const l=lt(r.id),{boxParams:P}=topViewPolygon2PointCloud(r,n,t.pointCloudInstance,l);return P});if(d=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:d,stepConfig:m,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=i[0],l=G(d);N({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=G(d);r&&o.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,r)}},Lt=i=>{var n,d,r,l,P;if(D){const C=Number(i.widthDefault),f=Number(i.depthDefault),v=Number(i.heightDefault),S=D==null?void 0:D.info.trackID,w=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(W=>(W==null?void 0:W.trackID)===S),y={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(P=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:P.height},O=w.pointList.map(W=>lbUtils.PointCloudUtils.transferCanvas2World(W,y)),Q=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(O,v,C),X=Q[0],E=Q[2],F=lbAnnotation.MathUtils.getLineCenterPoint([X,E]),mt=D.info.center.z-D.info.depth/2,et=__spreadProps(__spreadValues({},D.info),{center:{x:F.x,y:F.y,z:mt+f/2},width:C,height:v,depth:f,valid:!0}),Bt=G([et]);N({omitView:PointCloudView["3D"],polygon:w,boxParams:et,newPointCloudBoxList:Bt})}},H=(i,n,d,r,l,P)=>__async(void 0,null,function*(){const C=j==null?void 0:j.url,f={[PointCloudView.Side]:()=>{syncSideViewByPoint(d,n,s,C,P)},[PointCloudView.Back]:()=>{c&&syncBackViewByPoint(d,n,c,C,P)},[PointCloudView.Top]:()=>{syncTopViewByPoint(d,n,t,e)}};Object.keys(f).forEach(v=>{v!==i&&f[v]()}),r&&(e==null||e.updateCameraZoom(r)),dt(d)}),N=i=>__async(void 0,null,function*(){const{omitView:n,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:P}=i,C=j==null?void 0:j.url;P&&(yield o.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single,P));const f={[PointCloudView.Side]:()=>{synchronizeSideView(r,d,s,C)},[PointCloudView.Back]:()=>{c&&synchronizeBackView(r,d,c,C)},[PointCloudView.Top]:()=>{synchronizeTopView(r,d,t,e)}};Object.keys(f).forEach(v=>{v!==n&&f[v]()}),l&&(e==null||e.updateCameraZoom(l)),at(r)});return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:gt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:yt,sideViewUpdateBox:xt,backViewUpdateBox:ht,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),e==null||e.generateBoxes(i)},initPointCloud3d:i=>{if(!e)return;const n=lbUtils.PointCloudUtils.getDefaultOrthographicParams(i);e.initOrthographicCamera(n),e.initRenderer(),e.render()},updatePointCloudData:(...i)=>__async(void 0,[...i],function*(n=j){var d,r,l,P,C,f;if(!(n==null?void 0:n.url)||!e)return;U([]),actionCreators.SetPointCloudLoading(M,!0),actionCreators.SetLoadPCDFileLoading(M,!0),yield e.loadPCDFile(n.url,(d=m==null?void 0:m.radius)!=null?d:DEFAULT_RADIUS),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let v=[],S=[],z=[],w=[];e.updateTopCamera();const y=(l=(r=index.jsonParser(n.result))==null?void 0:r.valid)!=null?l:!0;if(o.setPointCloudValid(y),(P=o.sideViewInstance)==null||P.clearAllData(),(C=o.backViewInstance)==null||C.clearAllData(),n.result){if(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),(v==null?void 0:v.length)>0&&n.isPreResult&&(m==null?void 0:m.lowerLimitPointsNumInBox)>0){v=yield e==null?void 0:e.filterPreResult(n.url,m,v);const O=index.jsonParser(n.result);O[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=v,n.result=JSON.stringify(O),o.setPointCloudResult(v)}z=lbUtils.PointCloudUtils.getPolygonListFromResultList(n.result),S=lbUtils.PointCloudUtils.getLineListFromResultList(n.result),w=lbUtils.PointCloudUtils.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(f=m==null?void 0:m.radius)!=null?f:DEFAULT_RADIUS}),e==null||e.generateBoxes(v),e==null||e.generateSpheres(w),yield o.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,v,[])}T({pointCloudBoxList:v,polygonList:z,lineList:S,pointCloudSphereList:w}),actionCreators.SetPointCloudLoading(M,!1),actionCreators.SetLoadPCDFileLoading(M,!1)}),updateViewsByDefaultSize:Lt,generateRects:Z,update2DViewRect:pt,remove2DViewRect:Pt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:t,setPointCloudResult:s}=React.useContext(PointCloudContext.PointCloudContext),c=ahooks.useLatest(o),e=ahooks.useLatest(t);return{syncToPointCloudBoxList:React.useCallback(()=>{const g=c.current,u=e.current;if(u.length===0)return null;const a=new Map,x=new Set;if(u.filter(h=>h.extId!==void 0).forEach(h=>{const L=h.extId,U=h.imageName,I=_.pick(h,["x","y","width","height"]);let b=a.get(L);b||(b=new Map,a.set(L,b)),b.set(U,I),x.add(L)}),a.size){const h=g.map(L=>{var U;const I=L.id;if(x.has(I)){const b=__spreadValues({},L);return(U=b.rects)==null||U.forEach(R=>{var k;const V=R.imageName;Object.assign(R,(k=a.get(I))==null?void 0:k.get(V))}),b}return L});return s(h),h}return null},[])}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews,exports.useSyncRectPositionDimensionToPointCloudList=useSyncRectPositionDimensionToPointCloudList;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),_=require("lodash"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,n)=>new Promise((c,o)=>{var p=a=>{try{u(n.next(a))}catch(x){o(x)}},g=a=>{try{u(n.throw(a))}catch(x){o(x)}},u=a=>a.done?c(a.value):Promise.resolve(a.value).then(p,g);u((n=n.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,n,c,o)=>{const{x:p,y:g}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:u}=lbUtils.DEFAULT_SPHERE_PARAMS,a={center:{x:p,y:g,z:u},id:e.id},x=c?__spreadValues(__spreadValues({},c),a):__spreadProps(__spreadValues({},a),{attribute:"",valid:!0});return o&&Object.assign(x,o),x},topViewPolygon2PointCloud=(e,t,n,c,o,p)=>{let g=e.pointList.map(B=>lbUtils.PointCloudUtils.transferCanvas2World(B,t)),u=0,a=1,x={};if(n){const B=n.getSensesPointZAxisInPolygon(g,void 0,p);p&&B.fittedCoordinates.length>0&&(g=B.fittedCoordinates),u=(B.maxZ+B.minZ)/2,a=B.maxZ-B.minZ,x={count:B.zCount}}const[h,L,U]=g,I=lbAnnotation.MathUtils.getLineCenterPoint([h,U]),b=lbAnnotation.MathUtils.getLineLength(h,L),V=lbAnnotation.MathUtils.getLineLength(L,U),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);c&&(u=c.center.z,a=c.depth);const R={center:{x:I.x,y:I.y,z:u},width:p?V+INTELLIGENT_FIT_MARGIN:V,height:p?b+INTELLIGENT_FIT_MARGIN:b,depth:a,rotation:k,id:e.id},T=__spreadValues(c?__spreadValues(__spreadValues({},c),R):__spreadProps(__spreadValues({},R),{attribute:"",valid:!0}),x);o&&Object.assign(T,o);const A=g.map(B=>lbUtils.PointCloudUtils.transferWorld2Canvas(B,t));return{boxParams:T,newPointList:A}},sideViewPoint2PointCloud=(e,t,n)=>{const c={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},n),{center:{x:n.center.x-c.x,y:n.center.y,z:n.center.z-c.y}})},sideViewPolygon2PointCloud=(e,t,n,c)=>{const[o,p,g]=e.pointList,[u,a,x]=t.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([o,g]),L=lbAnnotation.MathUtils.getLineCenterPoint([u,x]),I={x:{x:h.x-L.x,y:h.y-L.y}.x,y:0,z:h.y-L.y},b=lbAnnotation.MathUtils.getLineLength(o,p),V=lbAnnotation.MathUtils.getLineLength(u,a),k=b-V,R=lbAnnotation.MathUtils.getLineLength(p,g),T=lbAnnotation.MathUtils.getLineLength(a,x),A=R-T,{newBoxParams:B}=c.getNewBoxBySideUpdate(I,A,k,n);return B},backViewPoint2PointCloud=(e,t,n)=>{const c={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},n),{center:{x:n.center.x,y:n.center.y-c.x,z:n.center.z-c.y}})},backViewPolygon2PointCloud=(e,t,n,c)=>{const[o,p,g]=e.pointList,[u,a,x]=t.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([o,g]),L=lbAnnotation.MathUtils.getLineCenterPoint([u,x]),I={x:{x:h.x-L.x,y:h.y-L.y}.x,y:0,z:h.y-L.y},b=lbAnnotation.MathUtils.getLineLength(o,p),V=lbAnnotation.MathUtils.getLineLength(u,a),k=b-V,R=lbAnnotation.MathUtils.getLineLength(p,g),T=lbAnnotation.MathUtils.getLineLength(a,x),A=R-T;let{newBoxParams:B}=c.getNewBoxByBackUpdate(I,A,k,n);return B},syncSideViewByPoint=(e,t,n,c,o)=>{var p;if(!n)return;const{toolInstance:g,pointCloudInstance:u}=n;u.loadPCDFile(c,(p=o==null?void 0:o.radius)!=null?p:DEFAULT_RADIUS);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);u.setInitCameraPosition(a);const{point2d:x,zoom:h}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=h,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(h),g.setResult([__spreadProps(__spreadValues(__spreadValues({},t),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},synchronizeSideView=(e,t,n,c)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:p}=n;p.loadPCDFileByBox(c,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:g}=p.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);p.setInitCameraPosition(g);const{polygon2d:u,zoom:a}=p.getBoxSidePolygon2DCoordinate(e);p.camera.zoom=a,p.camera.updateProjectionMatrix(),p.render(),o.initPosition(),o.zoomChangeOnCenter(a),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,n,c,o)=>{var p;if(!n)return;const{toolInstance:g,pointCloudInstance:u}=n;u.loadPCDFile(c,(p=o==null?void 0:o.radius)!=null?p:DEFAULT_RADIUS);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);u.setInitCameraPosition(a);const{point2d:x,zoom:h}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=h,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(h),g.setResult([__spreadProps(__spreadValues(__spreadValues({},t),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},synchronizeBackView=(e,t,n,c)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:p}=n;p.loadPCDFileByBox(c,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:g}=p.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);p.setInitCameraPosition(g);const{polygon2d:u,zoom:a}=p.getBoxBackPolygon2DCoordinate(e);p.camera.zoom=a,p.camera.updateProjectionMatrix(),p.render(),o.initPosition(),o.zoomChangeOnCenter(a),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,n,c)=>{if(!n||!c)return;c.generateSphere(e),c.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),c.render();const{toolInstance:o,pointCloudInstance:p}=n,{point2d:g}=p.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(a=>a.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);o.setResult(u),o.setSelectedID(t.id)},synchronizeTopView=(e,t,n,c)=>{var o,p;if(!n||!c)return;c.generateBox(e,t.id),c.render();const{pointCloud2dOperation:g,pointCloudInstance:u}=n,{polygon2d:a}=u.getBoxTopPolygon2DCoordinate(e),x=[...g.polygonList],h=x.find(L=>L.id===t.id);h?(h.pointList=a,h.valid=(o=e.valid)!=null?o:!0):x.push({id:t.id,pointList:a,textAttribute:"",isRect:!0,valid:(p=e.valid)!=null?p:!0}),g.setResultAndSelectedID(x,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:n,backViewInstance:c,mainViewInstance:o,addPointCloudBox:p,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:a,pointCloudBoxList:x,pointCloudSphereList:h,hideAttributes:L,setHighlight2DDataList:U,cuboidBoxIn2DView:I,imageSizes:b,history:V,linkageImageNameRectMap:k}=e,{addHistory:R,initHistory:T,pushHistoryUnderUpdatePolygon:A}=useHistory.useHistory(),{selectedPolygon:B}=usePolygon.usePolygon(),{getPointCloudSphereByID:ot,updatePointCloudSphere:Y,selectedSphere:q}=useSphere.useSphere(),{currentData:j,config:m}=ctx.useSelector(s=>{const{stepList:i,step:d,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:index.jsonParser(StepUtils.getCurrentStepInfo(d,i).config)}}),M=ctx.useDispatch(),it=ahooks.useLatest(I),nt=ahooks.useLatest(k),st=React.useCallback((s,i)=>{const d=nt.current,r=i.id;return s.filter(P=>{if(!P)return!1;const C=d.get(P.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),Z=s=>{const{enableAutoMap2DRect:i=!1}=m;if(!it.current||i){const{mappingImgList:d=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:d,imageSizes:b},{prepareRectsFn:st})}},{selectedBox:D,updateSelectedBox:rt,updateSelectedBoxes:G,getPointCloudByID:lt}=useSingleBox.useSingleBox({generateRects:Z}),K=D==null?void 0:D.info;if(!t||!n||!c)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:J}=t,at=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},dt=({newPoint:s,size:i,zoom:d,trackConfigurable:r})=>{var l;const P={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(P,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const C=topViewPoint2PointCloud(s,i,J,void 0,P);u(s.id);const f=g(C);H(PointCloudView.Top,s,C,d,f,m),R({newSphereParams:C})},ut=({polygon:s,size:i,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:P})=>{var C,f,v;const S={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(S,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:x,extraSphereList:h})});const z=t==null?void 0:t.toolInstance,w=__spreadValues({},s);let{boxParams:y,newPointList:O}=topViewPolygon2PointCloud(w,i,J,void 0,S,P);y=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[y],stepConfig:m,action:"viewUpdateBox"}))[0],P&&(O==null?void 0:O.length)&&(w.pointList=O);const X=L.includes(w.attribute);Z(y);const E=p(y),F=(f=e==null?void 0:e.polygonList)!=null?f:[];y.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((m==null?void 0:m.secondaryAttributeConfigurable)?(v=m==null?void 0:m.inputList)!=null?v:[]:[]),t==null||t.updatePolygonList(E!=null?E:[],F),X?u([]):(u(y.id),z.selection.setSelectedIDs(w.id),N({omitView:PointCloudView.Top,polygon:w,boxParams:y,zoom:l,newPointCloudBoxList:E}),P&&synchronizeTopView(y,w,t,o)),R({newBoxParams:y})},ct=s=>{const{boxID:i,imageName:d,width:r,height:l,x:P,y:C}=s,f=x.find(y=>y.id===i);if(!(f==null?void 0:f.rects)||!f.rects.find(y=>y.imageName===d))return;const S=f.rects.map(y=>y.imageName===d?__spreadProps(__spreadValues({},y),{width:r,height:l,x:P,y:C}):y),z=__spreadProps(__spreadValues({},f),{rects:S}),w=x.map(y=>y.id===i?z:y);return t==null||t.updatePolygonList(w!=null?w:[]),w},pt=s=>{const{boxID:i,imageName:d}=s,r=x.find(f=>f.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(f=>f.imageName!==d),P=__spreadProps(__spreadValues({},r),{rects:l}),C=x.map(f=>f.id===i?P:f);return t==null||t.updatePolygonList(C!=null?C:[]),C},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:d,newSphereList:r})=>{var l;const P=t==null?void 0:t.toolInstance;if(!(a.length===0||!P)){if(s||(D==null?void 0:D.info)){const C=s!=null?s:D==null?void 0:D.info;(l=P==null?void 0:P.selection)==null||l.setSelectedIDs(a[0]);const f=P.selectedPolygon;if(a.length===1&&C){N({omitView:PointCloudView.Top,polygon:f,boxParams:C,newPointCloudBoxList:i});return}}if((d||q)&&a.length===1){const C=d!=null?d:q;P.setSelectedID(a[0]);const f=P.selectedPoint;C&&H(PointCloudView.Top,f,C,void 0,r,m)}}},$=(s,i,d)=>{if(K){let r,l;switch(d){case PointCloudView.Back:r=backViewPolygon2PointCloud;break;case PointCloudView.Side:r=sideViewPolygon2PointCloud;break;default:r=sideViewPolygon2PointCloud;break}if(l=r(s,i,K,n.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:S})}const C=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:m,action:"viewUpdateBox"}))[0],f=l.valid!==C.valid;l=C;const v=rt(l);return l=v.find(S=>S.id===l.id),N({omitView:f?void 0:d,polygon:s,boxParams:l,newPointCloudBoxList:v}),v}},tt=(s,i,d)=>{if(q){let r,l;switch(d){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}l=r(s,i,q);const P=Y(l);return H(d,s,l,void 0,P,m),P}},gt=(s,i)=>{tt(s,i,PointCloudView.Side)},Ct=(s,i)=>{tt(s,i,PointCloudView.Back)},ft=(s,i)=>{$(s,i,PointCloudView.Side)},xt=(s,i)=>{$(s,i,PointCloudView.Back)},ht=(s,i)=>{const d=ot(s.id),r=topViewPoint2PointCloud(s,i,J,d),l=Y(r);H(PointCloudView.Top,s,r,void 0,l,m)},vt=(s,i)=>{if(B){const r=__spreadValues({},s[0].newPolygon);r.pointList=r.pointList.map(l=>lbUtils.PointCloudUtils.transferCanvas2World(l,i)),A(r);return}let d=s.map(({newPolygon:r})=>{const l=lt(r.id),{boxParams:P}=topViewPolygon2PointCloud(r,i,t.pointCloudInstance,l);return P});if(d=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:d,stepConfig:m,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=s[0],l=G(d);N({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=G(d);r&&e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,r)}},yt=s=>{var i,d,r,l,P;if(D){const C=Number(s.widthDefault),f=Number(s.depthDefault),v=Number(s.heightDefault),S=D==null?void 0:D.info.trackID,w=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(W=>(W==null?void 0:W.trackID)===S),y={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(P=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:P.height},O=w.pointList.map(W=>lbUtils.PointCloudUtils.transferCanvas2World(W,y)),Q=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(O,v,C),X=Q[0],E=Q[2],F=lbAnnotation.MathUtils.getLineCenterPoint([X,E]),Lt=D.info.center.z-D.info.depth/2,et=__spreadProps(__spreadValues({},D.info),{center:{x:F.x,y:F.y,z:Lt+f/2},width:C,height:v,depth:f,valid:!0}),mt=G([et]);N({omitView:PointCloudView["3D"],polygon:w,boxParams:et,newPointCloudBoxList:mt})}},H=(s,i,d,r,l,P)=>__async(void 0,null,function*(){const C=j==null?void 0:j.url,f={[PointCloudView.Side]:()=>{syncSideViewByPoint(d,i,n,C,P)},[PointCloudView.Back]:()=>{c&&syncBackViewByPoint(d,i,c,C,P)},[PointCloudView.Top]:()=>{syncTopViewByPoint(d,i,t,o)}};Object.keys(f).forEach(v=>{v!==s&&f[v]()}),r&&(o==null||o.updateCameraZoom(r)),at(d)}),N=s=>{const{omitView:i,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:P}=s,C=j==null?void 0:j.url;P&&e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single,P);const f={[PointCloudView.Side]:()=>{synchronizeSideView(r,d,n,C)},[PointCloudView.Back]:()=>{c&&synchronizeBackView(r,d,c,C)},[PointCloudView.Top]:()=>{synchronizeTopView(r,d,t,o)}};Object.keys(f).forEach(v=>{v!==i&&f[v]()}),l&&(o==null||o.updateCameraZoom(l))};return{topViewAddSphere:dt,topViewAddBox:ut,topViewSelectedChanged:Pt,topViewUpdatePoint:ht,sideViewUpdatePoint:gt,backViewUpdatePoint:Ct,topViewUpdateBox:vt,sideViewUpdateBox:ft,backViewUpdateBox:xt,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>__async(void 0,[...s],function*(i=j){var d,r,l,P,C,f;if(!(i==null?void 0:i.url)||!o)return;U([]),actionCreators.SetPointCloudLoading(M,!0),actionCreators.SetLoadPCDFileLoading(M,!0),yield o.loadPCDFile(i.url,(d=m==null?void 0:m.radius)!=null?d:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],S=[],z=[],w=[];o.updateTopCamera();const y=(l=(r=index.jsonParser(i.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(y),(P=e.sideViewInstance)==null||P.clearAllData(),(C=e.backViewInstance)==null||C.clearAllData(),i.result){if(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(v==null?void 0:v.length)>0&&i.isPreResult&&(m==null?void 0:m.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(i.url,m,v);const O=index.jsonParser(i.result);O[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=v,i.result=JSON.stringify(O),e.setPointCloudResult(v)}z=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),S=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),w=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(f=m==null?void 0:m.radius)!=null?f:DEFAULT_RADIUS}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(w),yield e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,v,[])}T({pointCloudBoxList:v,polygonList:z,lineList:S,pointCloudSphereList:w}),actionCreators.SetPointCloudLoading(M,!1),actionCreators.SetLoadPCDFileLoading(M,!1)}),updateViewsByDefaultSize:yt,generateRects:Z,update2DViewRect:ct,remove2DViewRect:pt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:e,rectList:t,setPointCloudResult:n}=React.useContext(PointCloudContext.PointCloudContext),c=ahooks.useLatest(e),o=ahooks.useLatest(t);return{syncToPointCloudBoxList:React.useCallback(()=>{const g=c.current,u=o.current;if(u.length===0)return null;const a=new Map,x=new Set;if(u.filter(h=>h.extId!==void 0).forEach(h=>{const L=h.extId,U=h.imageName,I=_.pick(h,["x","y","width","height"]);let b=a.get(L);b||(b=new Map,a.set(L,b)),b.set(U,I),x.add(L)}),a.size){const h=g.map(L=>{var U;const I=L.id;if(x.has(I)){const b=__spreadValues({},L);return(U=b.rects)==null||U.forEach(V=>{var k;const R=V.imageName;Object.assign(V,(k=a.get(I))==null?void 0:k.get(R))}),b}return L});return n(h),h}return null},[])}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews,exports.useSyncRectPositionDimensionToPointCloudList=useSyncRectPositionDimensionToPointCloudList;
package/dist/index.css CHANGED
@@ -508,7 +508,6 @@
508
508
  height: 100%;
509
509
  border: 1px solid transparent;
510
510
  font-size: 12px;
511
- overflow-y: auto;
512
511
  }
513
512
  .index-module_container__gTeNm .index-module_loop__FHsHY {
514
513
  position: absolute;
@@ -2580,6 +2579,7 @@
2580
2579
  top: 16px;
2581
2580
  left: 16px;
2582
2581
  z-index: 1000;
2582
+ pointer-events: none;
2583
2583
  }
2584
2584
  .bee-point-cloud-wrapper .bee-point-cloud-container__zoom {
2585
2585
  position: absolute;
@@ -81,6 +81,8 @@ export interface IPointCloudContext extends IPointCloudContextInstances, IPointC
81
81
  clearAllDetectionInstance: () => void;
82
82
  highlight2DDataList: IHighlight2DData[];
83
83
  setHighlight2DDataList: (urlList: IHighlight2DData[]) => void;
84
+ highlight2DLoading: boolean;
85
+ setHighlight2DLoading: (loading: boolean) => void;
84
86
  imageSizes: {
85
87
  [key: string]: ISize;
86
88
  };
@@ -2,10 +2,11 @@
2
2
  * Render Component for highlight.
3
3
  */
4
4
  import React from 'react';
5
- declare const HighlightVisible: ({ visible, style, onClick, loading, }: {
5
+ declare const HighlightVisible: ({ visible, style, onClick, loading, disabled, }: {
6
6
  visible: boolean;
7
7
  loading: boolean;
8
8
  style?: React.CSSProperties | undefined;
9
9
  onClick: () => void;
10
+ disabled?: boolean | undefined;
10
11
  }) => React.JSX.Element;
11
12
  export default HighlightVisible;
@@ -1 +1 @@
1
- import o,{useRef as D}from"react";import I from"react-dom";import{useAudioClipStore as B}from"../../audioAnnotate/audioContext/index.js";import{getAttributeColor as M,getAttributeFontColor as U,updateColorOpacity as V,getAttributeShowText as q}from"../../../utils/audio.js";import z from"../../../assets/annotation/audio/loop.svg.js";import{Typography as G}from"antd";import{useClickAway as H}from"ahooks";import{classnames as J}from"../../../utils/index.js";import n from"./index.module.scss.js";import{useTranslation as K}from"react-i18next";import{TagUtils as Q}from"@labelbee/lb-annotation";var W=Object.defineProperty,X=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable,P=(r,e,t)=>e in r?W(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,te=(r,e)=>{for(var t in e||(e={}))Z.call(e,t)&&P(r,t,e[t]);if(E)for(var t of E(e))ee.call(e,t)&&P(r,t,e[t]);return r},re=(r,e)=>X(r,Y(e));const{Paragraph:h}=G,oe=({result:r,subAttributeList:e,textStyle:t})=>{const u=Q.getTagNameList(r,e);return o.createElement("div",null,u.map((a,c)=>o.createElement(h,{ellipsis:{rows:2},className:n.text,key:c,style:re(te({},t),{marginBottom:0})},`${a.keyName}\uFF1A${a.value.join("\u3001")}`)))},le=r=>{const{t:e}=K(),{audioClipState:t,setAudioClipState:u}=B(),{clipAttributeList:a,clipAttributeConfigurable:c,clipTextConfigurable:w,selectedRegion:b,clipTextList:g,secondaryAttributeConfigurable:j,subAttributeList:v}=t,x=D(null),{el:L,region:y,edgeAdsorption:R,clipping:S,instance:_}=r,{attribute:p="",text:se="",id:d,start:T,end:N,subAttribute:C}=y,{id:m}=b,s=M(p,a),f={color:U(p,a),backgroundColor:s},l={border:`2px solid ${s}`};if(d===m)l.backgroundColor=V(s,.6),l.borderLeft=`2px solid ${s}`,l.borderRight=`2px solid ${s}`;else if(_==null||_.setLoop(!1),l.borderLeft=`2px solid ${s}`,l.borderRight=`2px solid ${s}`,S){const i=Object.values(R);i.includes(T)&&(l.borderLeft="3px dashed #fff"),i.includes(N)&&(l.borderRight="3px dashed #fff")}H(()=>{d===m&&u({selectedRegion:{}})},x,["contextmenu"]);const k=d===m&&b.loop,$=o.createElement("div",{style:l,ref:x,className:J({[n.container]:!0})},k&&o.createElement("div",{className:n.loop},o.createElement("img",{src:z})),c&&o.createElement("div",null,o.createElement("div",{style:f,className:n.attribute},q(p,[{value:"",key:"\u65E0\u5C5E\u6027"},...a])),j&&C&&v&&o.createElement(oe,{result:C,subAttributeList:v,textStyle:f})),w&&(g==null?void 0:g.map((i,F)=>{var A,O;return o.createElement(h,{ellipsis:{rows:2},className:n.text,style:f,key:F},(A=i==null?void 0:i.label)!=null?A:e("textTool"),":",(O=y[i==null?void 0:i.key])!=null?O:"")})));return o.createElement(o.Fragment,null,I.createPortal($,L))};export{le as default};
1
+ import t,{useRef as w}from"react";import N from"react-dom";import{useAudioClipStore as _}from"../../audioAnnotate/audioContext/index.js";import{getAttributeColor as O,getAttributeFontColor as F,updateColorOpacity as P,getAttributeShowText as D}from"../../../utils/audio.js";import I from"../../../assets/annotation/audio/loop.svg.js";import{Typography as M}from"antd";import{useClickAway as q}from"ahooks";import{classnames as z}from"../../../utils/index.js";import r from"./index.module.scss.js";import{useTranslation as B}from"react-i18next";const{Paragraph:G}=M,H=x=>{const{t:C}=B(),{audioClipState:v,setAudioClipState:y}=_(),{clipAttributeList:i,clipAttributeConfigurable:h,clipTextConfigurable:A,selectedRegion:c,clipTextList:d}=v,u=w(null),{el:E,region:p,edgeAdsorption:R,clipping:k,instance:m}=x,{attribute:s="",text:J="",id:a,start:L,end:j}=p,{id:n}=c,o=O(s,i),f={color:F(s,i),backgroundColor:o},e={border:`2px solid ${o}`};if(a===n)e.backgroundColor=P(o,.6),e.borderLeft=`2px solid ${o}`,e.borderRight=`2px solid ${o}`;else if(m==null||m.setLoop(!1),e.borderLeft=`2px solid ${o}`,e.borderRight=`2px solid ${o}`,k){const l=Object.values(R);l.includes(L)&&(e.borderLeft="3px dashed #fff"),l.includes(j)&&(e.borderRight="3px dashed #fff")}q(()=>{a===n&&y({selectedRegion:{}})},u,["contextmenu"]);const T=a===n&&c.loop,S=t.createElement("div",{style:e,ref:u,className:z({[r.container]:!0})},T&&t.createElement("div",{className:r.loop},t.createElement("img",{src:I})),h&&t.createElement("div",null,t.createElement("div",{style:f,className:r.attribute},D(s,[{value:"",key:"\u65E0\u5C5E\u6027"},...i]))),A&&(d==null?void 0:d.map((l,$)=>{var b,g;return t.createElement(G,{ellipsis:{rows:2},className:r.text,style:f,key:$},(b=l==null?void 0:l.label)!=null?b:C("textTool"),":",(g=p[l==null?void 0:l.key])!=null?g:"")})));return t.createElement(t.Fragment,null,N.createPortal(S,E))};export{H as default};
@@ -1 +1 @@
1
- import{getClassName as U}from"../../utils/dom.js";import s,{useRef as P,useState as A,useContext as F,useMemo as T,useCallback as q,useEffect as w}from"react";import G from"../AnnotationView/index.js";import J from"../../hooks/useSize.js";import{useSingleBox as K}from"./hooks/useSingleBox.js";import{useHighlight as M}from"./hooks/useHighlight.js";import Q from"./components/HighlightVisible/index.js";import{PointCloudContext as W}from"./PointCloudContext.js";import X from"./hooks/useDataLinkSwitch.js";import Y from"../pointCloud2DRectOperationView/index.js";var Z=(o,u,e)=>new Promise((a,r)=>{var f=t=>{try{i(e.next(t))}catch(n){r(n)}},d=t=>{try{i(e.throw(t))}catch(n){r(n)}},i=t=>t.done?a(t.value):Promise.resolve(t.value).then(f,d);i((e=e.apply(o,u)).next())});const $=({view2dData:o,setSelectedID:u,currentData:e,showEnlarge:a,checkMode:r=!1,measureVisible:f})=>{var d,i;const t=P(null),n=P(),{selectedBox:m}=K(),g=J(t),{url:k,fallbackUrl:x,calib:b,path:j}=o,{toggle2dVisible:_,isHighlightVisible:v}=M({currentData:e}),[z,C]=A(!1),{cuboidBoxIn2DView:h,cacheImageNodeSize:B}=F(W),I=!o,O=T(()=>({zIndex:a?-1:101,is2DView:!h,imageName:o.path}),[a,h,o.path]),{rendered:R,isLinking:E}=X(O),L=l=>{p(),B({path:j,imgNode:l})},p=q(()=>{var l,S;const y=(l=n.current)==null?void 0:l.toolInstance;if(u(""),!m||!y)return;const c=o.annotations.find(N=>N.annotation.id===m.info.id);let V="";c&&((S=c==null?void 0:c.annotation.pointList)==null?void 0:S.length)>0&&(y.focusPositionByPointList(c==null?void 0:c.annotation.pointList),V=m.info.id,u(V))},[m,n.current,o.annotations]);w(()=>{p()},[p]);const H=()=>Z(void 0,null,function*(){C(!0);try{yield _(k,x!=null?x:"",b)}catch(l){console.error("highlightOnClick error:",l)}finally{C(!1)}});return s.createElement("div",{className:U("point-cloud-2d-image"),ref:t},h?s.createElement(G,{src:(d=o==null?void 0:o.url)!=null?d:"",fallbackSrc:(i=o==null?void 0:o.fallbackUrl)!=null?i:"",annotations:o.annotations,size:g,ref:n,globalStyle:{display:I?"none":"block"},afterImgOnLoad:L,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f}):s.createElement(s.Fragment,null,s.createElement(Y,{shouldExcludePointCloudBoxListUpdate:!E,mappingData:o,size:g,checkMode:r,afterImgOnLoad:L}),!r&&R),b&&s.createElement(Q,{visible:v(k),onClick:H,loading:z,style:{position:"absolute",right:16,top:16,zIndex:a?-1:101}}))};export{$ as default};
1
+ import{getClassName as F}from"../../utils/dom.js";import s,{useRef as j,useState as T,useContext as q,useMemo as w,useCallback as D,useEffect as G}from"react";import J from"../AnnotationView/index.js";import K from"../../hooks/useSize.js";import{useSingleBox as M}from"./hooks/useSingleBox.js";import{useHighlight as Q}from"./hooks/useHighlight.js";import W from"./components/HighlightVisible/index.js";import{PointCloudContext as X}from"./PointCloudContext.js";import Y from"./hooks/useDataLinkSwitch.js";import Z from"../pointCloud2DRectOperationView/index.js";var $=(t,u,i)=>new Promise((a,r)=>{var f=o=>{try{e(i.next(o))}catch(n){r(n)}},d=o=>{try{e(i.throw(o))}catch(n){r(n)}},e=o=>o.done?a(o.value):Promise.resolve(o.value).then(f,d);e((i=i.apply(t,u)).next())});const tt=({view2dData:t,setSelectedID:u,currentData:i,showEnlarge:a,checkMode:r=!1,measureVisible:f})=>{var d,e;const o=j(null),n=j(),{selectedBox:m}=M(),p=K(o),{url:b,fallbackUrl:k,calib:x,path:_}=t,{toggle2dVisible:v,isHighlightVisible:z}=Q({currentData:i}),[B,C]=T(!1),{highlight2DLoading:I,setHighlight2DLoading:L,cuboidBoxIn2DView:h,cacheImageNodeSize:O}=q(X),H=!t,R=w(()=>({zIndex:a?-1:101,is2DView:!h,imageName:t.path}),[a,h,t.path]),{rendered:E,isLinking:N}=Y(R),S=l=>{g(),O({path:_,imgNode:l})},g=D(()=>{var l,y;const V=(l=n.current)==null?void 0:l.toolInstance;if(u(""),!m||!V)return;const c=t.annotations.find(A=>A.annotation.id===m.info.id);let P="";c&&((y=c==null?void 0:c.annotation.pointList)==null?void 0:y.length)>0&&(V.focusPositionByPointList(c==null?void 0:c.annotation.pointList),P=m.info.id,u(P))},[m,n.current,t.annotations]);G(()=>{g()},[g]);const U=()=>$(void 0,null,function*(){C(!0),L(!0);try{yield v(b,k!=null?k:"",x)}catch(l){console.error("highlightOnClick error:",l)}finally{C(!1),L(!1)}});return s.createElement("div",{className:F("point-cloud-2d-image"),ref:o},h?s.createElement(J,{src:(d=t==null?void 0:t.url)!=null?d:"",fallbackSrc:(e=t==null?void 0:t.fallbackUrl)!=null?e:"",annotations:t.annotations,size:p,ref:n,globalStyle:{display:H?"none":"block"},afterImgOnLoad:S,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f}):s.createElement(s.Fragment,null,s.createElement(Z,{shouldExcludePointCloudBoxListUpdate:!N,mappingData:t,size:p,checkMode:r,afterImgOnLoad:S}),!r&&E),x&&s.createElement(W,{visible:z(b),onClick:U,loading:B,disabled:I,style:{position:"absolute",right:16,top:16,zIndex:a?-1:101}}))};export{tt as default};
@@ -1 +1 @@
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
+ import{EPointCloudPattern as Q}from"@labelbee/lb-utils";import ye,{useState as s,useRef as lt,useMemo as R,useCallback as l,useEffect as U}from"react";import{EPointCloudBoxRenderTrigger as M,calcResetAreasAndBoxIds as at}from"../../utils/ToolPointCloudBoxRenderHelper.js";import{ActionsHistory as Re,EToolName as X,uuid as dt}from"@labelbee/lb-annotation";import{useDispatch as ct}from"../../store/ctx.js";import{ChangeSave as ut}from"../../store/annotation/actionCreators.js";import gt from"../../store/annotatedBox/index.js";import be from"lodash";import{addMapIndirectWeakSetItem as we}from"./utils/map.js";var pt=Object.defineProperty,ft=Object.defineProperties,mt=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable,De=(a,n,d)=>n in a?pt(a,n,{enumerable:!0,configurable:!0,writable:!0,value:d}):a[n]=d,j=(a,n)=>{for(var d in n||(n={}))ht.call(n,d)&&De(a,d,n[d]);if(xe)for(var d of xe(n))vt.call(n,d)&&De(a,d,n[d]);return a},Le=(a,n)=>ft(a,mt(n)),It=(a,n,d)=>new Promise((b,D)=>{var L=p=>{try{m(d.next(p))}catch(w){D(w)}},E=p=>{try{m(d.throw(p))}catch(w){D(w)}},m=p=>p.done?b(p.value):Promise.resolve(p.value).then(L,E);m((d=d.apply(a,n)).next())});const k=a=>be.pick(a,["id","attribute","width","height","x","y","imageName"]),Ae=ye.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 Re,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:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},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:()=>{}}),Pt=({children:a})=>{const[n,d]=s([]),[b,D]=s([]),[L,E]=s([]),[m,p]=s([]),[w,Be]=s([]),[v,F]=s([]),[x,z]=s([]),[Y,_e]=s(!0),[$,Ve]=s(2),[ee,Ne]=s(!0),[te,Oe]=s(1),[g,oe]=s(),[ne,ie]=s(),[se,re]=s(),[c,le]=s(),[ae,He]=s(""),[_,Me]=s(X.Rect),V=lt(new Re).current,[f,G]=s([]),[de,je]=s(""),[N,ke]=s(Q.Detection),[C,ce]=s(void 0),[T,Ee]=s([]),[Z,Fe]=s([]),[ue,ze]=s(!1),h=gt(),[ge,Ge]=s({}),Te=ct(),Ze=e=>{const{imgNode:t,path:o}=e;o&&t&&Ge(i=>Le(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",r=new Set(t);return p(u=>{let S=!1;const y=u.filter(B=>{const P=B[i],I=r.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]),fe=l(e=>{if(!e)return!1;const t=n.filter(o=>Array.isArray(o.rects)).map(o=>{const{id:i,attribute:r,trackID:u}=o,S=o.rects.find(y=>y.imageName===e);if(S){const y=be.pick(S,["width","height","x","y","imageName"]);return Le(j({},y),{id:dt(),attribute:r,order:u,extId:i,lineDash:[]})}return null}).filter(o=>o!==null);return t.length?(p(o=>{const i=new Set(o.filter(u=>e===u.imageName).map(u=>u.extId)),r=t.filter(u=>i.has(u.extId)===!1);return r.length?[...o,...r]:o}),!0):!1},[n]),me=R(()=>n.filter(t=>Array.isArray(t.rects)&&t.rects.length>0).reduce((t,o)=>{var i;return(i=o.rects)==null||i.forEach(r=>{const{imageName:u}=r;if(!u){console.warn("Missing image name"),console.trace(r,o);return}we(t,u,o.id,o)}),t},new Map),[n]),he=l(e=>{p(t=>e(t,k))},[k]),ve=R(()=>m.filter(e=>e.extId!==void 0&&e.id!==void 0).reduce((e,t)=>{const o=t.imageName;return o?(we(e,o,t.extId,t),e):(console.warn("missing image name"),console.log(t,m),e)},new Map),[m]),Ie=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]),We=l(e=>{const t=n.concat(e);return d(t),t},[n]),qe=l(e=>{const t=b.concat(e);return D(t),t},[b]),Je=l(e=>{_e(e!==!1)},[]),A=l(e=>{e===void 0&&F([]),typeof e=="string"&&F([e]),Array.isArray(e)&&F(Array.from(new Set(e)))},[]),Ke=l(e=>{v.includes(e)?A(v.filter(t=>t!==e)):A([...v,e])},[v]),Qe=l(e=>{const t=k(e);p(o=>[...o,t])},[m]),Ue=l((e,t=!1)=>{const o=k(e);p(i=>i.map(r=>r.id===e.id?t?j(j({},r),o):o:r))},[m]),Xe=l(e=>{p(t=>t.filter(o=>!e.find(i=>i.id===o.id)))},[m]),Ye=l(e=>{x.includes(e)?z([]):z([e])},[x]),$e=l(()=>{if(_===X.Rect){const e=n.map(t=>t.id);A(e),g==null||g.pointCloud2dOperation.setSelectedIDs(e)}},[_,n,g,g==null?void 0:g.pointCloud2dOperation]),et=l(e=>{A(n.filter(t=>t.attribute===e).map(t=>t.id))},[n]),tt=l(e=>{if(f.includes(e))G(f.filter(t=>t!==e));else{const t=f.concat(e);G(t)}},[f]),ot=l((e=q,t=L,o=J,i=K,r=T)=>{var u;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),(u=C==null?void 0:C.store)==null||u.updateCurrentSegment(r),Pe(M.Default,e)},[c,g,C,C==null?void 0:C.store]),nt=l(()=>{oe(void 0),ie(void 0),re(void 0),le(void 0)},[]),Pe=l((e,t,o)=>It(void 0,null,function*(){var i,r,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 Ce=I;I>0&&(e===M.SingleToggleValid||e===M.SingleRotate||e===M.Single&&t.length===((i=P[I])==null?void 0:i.pointCloudBoxList.length))&&(Ce=I-1);let rt=(r=P[Ce])==null?void 0:r.pointCloudBoxList;const Se=at(e,t,rt);y=Se.modifiedBoxIds,B=Se.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=g==null?void 0:g.pointCloudInstance)==null||u.updateColor(I)),I}catch(P){console.error("call highlightOriginPointCloud error",P)}}),[c,c==null?void 0:c.pointCloudObject,V]),it=l(e=>{N!==e&&(Te(ut),ke(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:We,addPointCloudSphere:qe,setPointCloudSphereList:D,valid:Y,selectedPointCloudBox:Ie,setPointCloudValid:Je,addSelectedID:Ke,addHighlightID:Ye,selectedAllBoxes:$e,topViewInstance:g,setTopViewInstance:oe,sideViewInstance:ne,setSideViewInstance:ie,backViewInstance:se,setBackViewInstance:re,mainViewInstance:c,setMainViewInstance:le,polygonList:L,setPolygonList:E,rectList:m,setRectList:p,addRectIn2DView:Qe,removeRectIn2DView:Xe,updateRectIn2DView:Ue,lineList:w,setLineList:Be,zoom:te,setZoom:Oe,history:V,toggleAttributesVisible:tt,hideAttributes:f,setHideAttributes:G,reRender:ot,attrPanelLayout:de,setAttrPanelLayout:je,syncAllViewPointCloudColor:Pe,defaultAttribute:ae,setDefaultAttribute:He,pointCloudPattern:_,setPointCloudPattern:Me,selectSpecAttr:et,globalPattern:N,setGlobalPattern:it,ptSegmentInstance:C,setPtSegmentInstance:ce,segmentation:T,setSegmentation:Ee,clearAllDetectionInstance:nt,highlight2DDataList:Z,setHighlight2DDataList:Fe,highlight2DLoading:ue,setHighlight2DLoading:ze,cuboidBoxIn2DView:ee,setCuboidBoxIn2DView:Ne,imageSizes:ge,cacheImageNodeSize:Ze,highlightIDs:x,setHighlightIDs:z,removeRectByPointCloudBoxId:pe,removeRectBySpecifyId:O,addRectFromPointCloudBoxByImageName:fe,rectRotateSensitivity:$,setRectRotateSensitivity:Ve,imageNamePointCloudBoxMap:me,linkageImageNameRectMap:ve,updateRectListByReducer:he}),[Y,Ie,q,J,K,L,m,g,ne,se,c,te,de,ae,_,N,C,T,Z,ue,ee,ge,x,pe,O,fe,$,me,ve,he]);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 st=()=>{const e=n.filter(r=>f.includes(r.attribute)),{setSelectedIDs:t,reRender:o}=H,i=e.map(r=>r.id);i.length>0&&t(v.filter(r=>!i.includes(r))),o()};return U(()=>{var e,t,o,i;st(),(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]),ye.createElement(Ae.Provider,{value:H},a)};export{Ae as PointCloudContext,Pt as PointCloudProvider};
@@ -1 +1 @@
1
- import{PointCloudUtils as v,EPerspectiveView as k}from"@labelbee/lb-utils";import r,{useState as D,useEffect as N}from"react";import{PointCloudContext as m}from"./PointCloudContext.js";import{UnitUtils as V}from"@labelbee/lb-annotation";import{useSingleBox as $}from"./hooks/useSingleBox.js";import{useTranslation as x}from"react-i18next";var H=Object.defineProperty,U=Object.defineProperties,R=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,S=(o,e,t)=>e in o?H(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,B=(o,e)=>{for(var t in e||(e={}))T.call(e,t)&&S(o,t,e[t]);if(I)for(var t of I(e))K.call(e,t)&&S(o,t,e[t]);return o},F=(o,e)=>U(o,R(e));const a=2,A={color:"white",backgroundColor:"rgba(153, 153, 153, 0.3)",padding:"8px 10px",zIndex:20,fontSize:12},W=({perspectiveView:o})=>{const{pointCloudBoxList:e,selectedID:t}=r.useContext(m),d=e.find(u=>u.id===t),l=x(),{t:s}=l;if(t&&d){const{length:u,width:f,height:i}=v.transferBox2Kitti(d),b=o===k.Back?[{label:s("Width"),value:f},{label:s("Height"),value:i}]:[{label:s("Length"),value:u},{label:s("Height"),value:i}];return r.createElement("div",{style:F(B({position:"absolute"},A),{bottom:"4%",left:"50%",transform:"translate(-50%, 0)"})},b.map((c,n)=>r.createElement("span",{key:n,style:{marginRight:n===0?16:0}},`${c.label}: ${c.value.toFixed(a)}`)))}return null},M=({checkMode:o,config:e,style:t})=>{const d=r.useContext(m),{selectedBox:l}=$(),[s,u]=D([]),f=x(),{t:i,i18n:b}=f,c=t;return N(()=>{var n,g;if(!l)return;const{length:h,width:_,height:y,rotation_y:L}=v.transferBox2Kitti(l.info),{x:P,y:C,z:w}=l.info.center;let p=[{label:"x",value:P==null?void 0:P.toFixed(a)},{label:"y",value:C==null?void 0:C.toFixed(a)},{label:"z",value:w==null?void 0:w.toFixed(a)},{label:i("Length"),value:h==null?void 0:h.toFixed(a)},{label:i("Width"),value:_==null?void 0:_.toFixed(a)},{label:i("Height"),value:y==null?void 0:y.toFixed(a)},{label:i("Rotation_y"),value:(n=V.rad2deg(L))==null?void 0:n.toFixed(a)}];(g=d.mainViewInstance)==null||g.filterPointsByBox(l.info).then(j=>{var E,O;if(!j){u(p);return}p.push({label:i("PointCount"),value:`${(O=(E=l.info)==null?void 0:E.count)!=null?O:0}`}),o===!0&&l.info.subAttribute&&e&&v.getSubAttributeName(l.info.subAttribute,e).forEach(z=>p.push(z)),u(p)})},[l,b.language]),l?r.createElement("div",{style:t||F(B({position:"absolute"},A),{right:8,bottom:8})},s.map(n=>c?r.createElement("div",{key:n.label,style:{margin:"0px 4px"}},`${n.label}: ${n.value}`):r.createElement("div",{key:n.label},r.createElement("span",{style:{width:"38px",display:"inline-block",textAlign:"end"}},n.label),": ",r.createElement("span",null,n.value)))):null},X=()=>{const o=r.useContext(m),{t:e}=x();return o.valid===!1?r.createElement("div",{style:{position:"absolute",backgroundColor:"rgb(242, 101, 73)",color:"white",opacity:.7,left:0,top:0,fontSize:30,padding:"8px 16px",zIndex:20,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"}},e("Invalid")):null};export{M as BoxInfos,X as PointCloudValidity,W as SizeInfoForView};
1
+ import{PointCloudUtils as v,EPerspectiveView as k}from"@labelbee/lb-utils";import r,{useState as D,useEffect as N}from"react";import{PointCloudContext as m}from"./PointCloudContext.js";import{UnitUtils as V}from"@labelbee/lb-annotation";import{useSingleBox as $}from"./hooks/useSingleBox.js";import{useTranslation as x}from"react-i18next";var H=Object.defineProperty,U=Object.defineProperties,R=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,S=(o,e,t)=>e in o?H(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,B=(o,e)=>{for(var t in e||(e={}))T.call(e,t)&&S(o,t,e[t]);if(I)for(var t of I(e))K.call(e,t)&&S(o,t,e[t]);return o},F=(o,e)=>U(o,R(e));const a=2,A={color:"white",backgroundColor:"rgba(153, 153, 153, 0.3)",padding:"8px 10px",zIndex:20,fontSize:12},W=({perspectiveView:o})=>{const{pointCloudBoxList:e,selectedID:t}=r.useContext(m),d=e.find(u=>u.id===t),l=x(),{t:s}=l;if(t&&d){const{length:u,width:f,height:i}=v.transferBox2Kitti(d),b=o===k.Back?[{label:s("Width"),value:f},{label:s("Height"),value:i}]:[{label:s("Length"),value:u},{label:s("Height"),value:i}];return r.createElement("div",{style:F(B({position:"absolute"},A),{bottom:"4%",left:"50%",transform:"translate(-50%, 0)",pointerEvents:"none"})},b.map((c,n)=>r.createElement("span",{key:n,style:{marginRight:n===0?16:0}},`${c.label}: ${c.value.toFixed(a)}`)))}return null},M=({checkMode:o,config:e,style:t})=>{const d=r.useContext(m),{selectedBox:l}=$(),[s,u]=D([]),f=x(),{t:i,i18n:b}=f,c=t;return N(()=>{var n,g;if(!l)return;const{length:h,width:_,height:y,rotation_y:L}=v.transferBox2Kitti(l.info),{x:P,y:C,z:E}=l.info.center;let p=[{label:"x",value:P==null?void 0:P.toFixed(a)},{label:"y",value:C==null?void 0:C.toFixed(a)},{label:"z",value:E==null?void 0:E.toFixed(a)},{label:i("Length"),value:h==null?void 0:h.toFixed(a)},{label:i("Width"),value:_==null?void 0:_.toFixed(a)},{label:i("Height"),value:y==null?void 0:y.toFixed(a)},{label:i("Rotation_y"),value:(n=V.rad2deg(L))==null?void 0:n.toFixed(a)}];(g=d.mainViewInstance)==null||g.filterPointsByBox(l.info).then(j=>{var w,O;if(!j){u(p);return}p.push({label:i("PointCount"),value:`${(O=(w=l.info)==null?void 0:w.count)!=null?O:0}`}),o===!0&&l.info.subAttribute&&e&&v.getSubAttributeName(l.info.subAttribute,e).forEach(z=>p.push(z)),u(p)})},[l,b.language]),l?r.createElement("div",{style:t||F(B({position:"absolute"},A),{right:8,bottom:8})},s.map(n=>c?r.createElement("div",{key:n.label,style:{margin:"0px 4px"}},`${n.label}: ${n.value}`):r.createElement("div",{key:n.label},r.createElement("span",{style:{width:"38px",display:"inline-block",textAlign:"end"}},n.label),": ",r.createElement("span",null,n.value)))):null},X=()=>{const o=r.useContext(m),{t:e}=x();return o.valid===!1?r.createElement("div",{style:{position:"absolute",backgroundColor:"rgb(242, 101, 73)",color:"white",opacity:.7,left:0,top:0,fontSize:30,padding:"8px 16px",zIndex:20,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"}},e("Invalid")):null};export{M as BoxInfos,X as PointCloudValidity,W as SizeInfoForView};
@@ -1 +1 @@
1
- import c from"react";import{EyeFilled as d,EyeInvisibleFilled as p,LoadingOutlined as f}from"@ant-design/icons";import{getClassName as u}from"../../../../utils/dom.js";var m=Object.defineProperty,l=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,n=(t,e,r)=>e in t?m(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,s=(t,e)=>{for(var r in e||(e={}))_.call(e,r)&&n(t,r,e[r]);if(l)for(var r of l(e))g.call(e,r)&&n(t,r,e[r]);return t};const y=({visible:t,style:e,onClick:r,loading:o})=>{const i={background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,fontSize:16};let a=t?d:p;return o&&(a=f,Object.assign(i,{borderRadius:100})),c.createElement(a,{className:u("point-cloud-highlight-view"),style:s(s({},i),e),onClick:o?()=>{}:r})};export{y as default};
1
+ import u from"react";import{EyeFilled as f,EyeInvisibleFilled as g,LoadingOutlined as m}from"@ant-design/icons";import{getClassName as _}from"../../../../utils/dom.js";var b=Object.defineProperty,s=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,c=(t,e,r)=>e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,d=(t,e)=>{for(var r in e||(e={}))y.call(e,r)&&c(t,r,e[r]);if(s)for(var r of s(e))O.call(e,r)&&c(t,r,e[r]);return t};const h=({visible:t,style:e,onClick:r,loading:a,disabled:o})=>{const l={background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,fontSize:16},p={background:"rgba(0, 0, 0, 0.2)",color:"rgba(255, 255, 255, 0.5)",cursor:"not-allowed"};let i=t?f:g;a&&(i=m,Object.assign(l,{borderRadius:100}));const n=d(d({},l),e);return o&&Object.assign(n,p),u.createElement(i,{disabled:o,className:_("point-cloud-highlight-view"),style:n,onClick:a||o?()=>{}:r})};export{h as default};
@@ -1 +1 @@
1
- import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as k,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as xt,useCallback as ht}from"react";import{PointCloudContext as Lt}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as rt}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as lt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as dt,SetPointCloudLoading as vt,SetLoadPCDFileLoading as yt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as q}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,Bt=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,ho=Object.prototype.propertyIsEnumerable,bt=(e,t,s)=>t in e?Co(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,v=(e,t)=>{for(var s in t||(t={}))xo.call(t,s)&&bt(e,s,t[s]);if(Bt)for(var s of Bt(t))ho.call(t,s)&&bt(e,s,t[s]);return e},O=(e,t)=>Po(e,mo(t)),at=(e,t,s)=>new Promise((u,o)=>{var p=d=>{try{c(s.next(d))}catch(m){o(m)}},f=d=>{try{c(s.throw(d))}catch(m){o(m)}},c=d=>d.done?u(d.value):Promise.resolve(d.value).then(p,f);c((s=s.apply(e,t)).next())});const K=5,$=90,wt=.01,B={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},ct=(e,t,s,u,o)=>{const{x:p,y:f}=k.transferCanvas2World(e,t),{defaultZ:c}=io,d={center:{x:p,y:f,z:c},id:e.id},m=u?v(v({},u),d):O(v({},d),{attribute:"",valid:!0});return o&&Object.assign(m,o),m},ut=(e,t,s,u,o,p)=>{let f=e.pointList.map(I=>k.transferCanvas2World(I,t)),c=0,d=1,m={};if(s){const I=s.getSensesPointZAxisInPolygon(f,void 0,p);p&&I.fittedCoordinates.length>0&&(f=I.fittedCoordinates),c=(I.maxZ+I.minZ)/2,d=I.maxZ-I.minZ,m={count:I.zCount}}const[x,y,A]=f,R=w.getLineCenterPoint([x,A]),S=w.getLineLength(x,y),U=w.getLineLength(y,A),z=w.getRadiusFromQuadrangle(e.pointList);u&&(c=u.center.z,d=u.depth);const T={center:{x:R.x,y:R.y,z:c},width:p?U+wt:U,height:p?S+wt:S,depth:d,rotation:z,id:e.id},N=v(u?v(v({},u),T):O(v({},T),{attribute:"",valid:!0}),m);o&&Object.assign(N,o);const E=f.map(I=>k.transferWorld2Canvas(I,t));return{boxParams:N,newPointList:E}},It=(e,t,s)=>{const u={x:e.x-t.x,y:e.y-t.y};return O(v({},s),{center:{x:s.center.x-u.x,y:s.center.y,z:s.center.z-u.y}})},Dt=(e,t,s,u)=>{const[o,p,f]=e.pointList,[c,d,m]=t.pointList,x=w.getLineCenterPoint([o,f]),y=w.getLineCenterPoint([c,m]),R={x:{x:x.x-y.x,y:x.y-y.y}.x,y:0,z:x.y-y.y},S=w.getLineLength(o,p),U=w.getLineLength(c,d),z=S-U,T=w.getLineLength(p,f),N=w.getLineLength(d,m),E=T-N,{newBoxParams:I}=u.getNewBoxBySideUpdate(R,E,z,s);return I},Lo=(e,t,s)=>{const u={x:e.x-t.x,y:e.y-t.y};return O(v({},s),{center:{x:s.center.x,y:s.center.y-u.x,z:s.center.z-u.y}})},vo=(e,t,s,u)=>{const[o,p,f]=e.pointList,[c,d,m]=t.pointList,x=w.getLineCenterPoint([o,f]),y=w.getLineCenterPoint([c,m]),R={x:{x:x.x-y.x,y:x.y-y.y}.x,y:0,z:x.y-y.y},S=w.getLineLength(o,p),U=w.getLineLength(c,d),z=S-U,T=w.getLineLength(p,f),N=w.getLineLength(d,m),E=T-N;let{newBoxParams:I}=u.getNewBoxByBackUpdate(R,E,z,s);return I},St=(e,t,s,u,o)=>{var p;if(!s)return;const{toolInstance:f,pointCloudInstance:c}=s;c.loadPCDFile(u,(p=o==null?void 0:o.radius)!=null?p:$);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(e,G.Left);c.setInitCameraPosition(d);const{point2d:m,zoom:x}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=x,c.camera.updateProjectionMatrix(),c.render(),f.initPosition(),f.zoomChangeOnCenter(x),f.setResult([O(v(v({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(t.id)},Rt=(e,t,s,u)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:p}=s;p.loadPCDFileByBox(u,e,{width:K,depth:K});const{cameraPositionVector:f}=p.updateOrthoCamera(e,G.Left);p.setInitCameraPosition(f);const{polygon2d:c,zoom:d}=p.getBoxSidePolygon2DCoordinate(e);p.camera.zoom=d,p.camera.updateProjectionMatrix(),p.render(),o.initPosition(),o.zoomChangeOnCenter(d),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},_t=(e,t,s,u,o)=>{var p;if(!s)return;const{toolInstance:f,pointCloudInstance:c}=s;c.loadPCDFile(u,(p=o==null?void 0:o.radius)!=null?p:$);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(e,G.Back);c.setInitCameraPosition(d);const{point2d:m,zoom:x}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=x,c.camera.updateProjectionMatrix(),c.render(),f.initPosition(),f.zoomChangeOnCenter(x),f.setResult([O(v(v({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(t.id)},Vt=(e,t,s,u)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:p}=s;p.loadPCDFileByBox(u,e,{height:K,depth:K});const{cameraPositionVector:f}=p.updateOrthoCamera(e,G.Back);p.setInitCameraPosition(f);const{polygon2d:c,zoom:d}=p.getBoxBackPolygon2DCoordinate(e);p.camera.zoom=d,p.camera.updateProjectionMatrix(),p.render(),o.initPosition(),o.zoomChangeOnCenter(d),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},kt=(e,t,s,u)=>{if(!s||!u)return;u.generateSphere(e),u.updateCameraBySphere(e,G.Top),u.render();const{toolInstance:o,pointCloudInstance:p}=s,{point2d:f}=p.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(d=>d.id===t.id?O(v(v({},t),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):d);o.setResult(c),o.setSelectedID(t.id)},pt=(e,t,s,u)=>{var o,p;if(!s||!u)return;u.generateBox(e,t.id),u.render();const{pointCloud2dOperation:f,pointCloudInstance:c}=s,{polygon2d:d}=c.getBoxTopPolygon2DCoordinate(e),m=[...f.polygonList],x=m.find(y=>y.id===t.id);x?(x.pointList=d,x.valid=(o=e.valid)!=null?o:!0):m.push({id:t.id,pointList:d,textAttribute:"",isRect:!0,valid:(p=e.valid)!=null?p:!0}),f.setResultAndSelectedID(m,t.id)},yo=()=>{const e=xt(Lt),{topViewInstance:t,sideViewInstance:s,backViewInstance:u,mainViewInstance:o,addPointCloudBox:p,addPointCloudSphere:f,setSelectedIDs:c,selectedIDs:d,pointCloudBoxList:m,pointCloudSphereList:x,hideAttributes:y,setHighlight2DDataList:A,cuboidBoxIn2DView:R,imageSizes:S,history:U,linkageImageNameRectMap:z}=e,{addHistory:T,initHistory:N,pushHistoryUnderUpdatePolygon:E}=go(),{selectedPolygon:I}=fo(),{getPointCloudSphereByID:Ot,updatePointCloudSphere:gt,selectedSphere:J}=ro(),{currentData:H,config:b}=ao(i=>{const{stepList:n,step:a,imgList:r,imgIndex:l}=i.annotation;return{currentData:r[l],config:lt(uo.getCurrentStepInfo(a,n).config)}}),M=co(),At=q(R),Tt=q(z),Ut=ht((i,n)=>{const a=Tt.current,r=n.id;return i.filter(g=>{if(!g)return!1;const C=a.get(g.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),tt=i=>{const{enableAutoMap2DRect:n=!1}=b;if(!At.current||n){const{mappingImgList:a=[]}=H;po({pointCloudBox:i,mappingImgList:a,imageSizes:S},{prepareRectsFn:Ut})}},{selectedBox:V,updateSelectedBox:zt,updateSelectedBoxes:ot,getPointCloudByID:Nt}=so({generateRects:tt}),ft=V==null?void 0:V.info;if(!t||!s||!u)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:et}=t,jt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},Et=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:i,size:n,zoom:a,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:k.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:x})});const C=ct(i,n,et,void 0,g);c(i.id);const P=f(C);Q(B.Top,i,C,a,P,b),T({newSphereParams:C})},Ft=({polygon:i,size:n,imgList:a,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,P,h;const _={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(_,{trackID:k.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:x})});const F=t==null?void 0:t.toolInstance,D=v({},i);let{boxParams:L,newPointList:j}=ut(D,n,et,void 0,_,g);L=M(dt({tool:st.PointCloud,dataList:[L],stepConfig:b,action:"viewUpdateBox"}))[0],g&&(j==null?void 0:j.length)&&(D.pointList=j);const it=y.includes(D.attribute);tt(L);const Z=p(L),X=(P=e==null?void 0:e.polygonList)!=null?P:[];L.subAttribute=oo.getDefaultResultByConfig((b==null?void 0:b.secondaryAttributeConfigurable)?(h=b==null?void 0:b.inputList)!=null?h:[]:[]),t==null||t.updatePolygonList(Z!=null?Z:[],X),it?c([]):(c(L.id),F.selection.setSelectedIDs(D.id),W({omitView:B.Top,polygon:D,boxParams:L,zoom:l,newPointCloudBoxList:Z}),g&&pt(L,D,t,o)),T({newBoxParams:L})},Ht=i=>{const{boxID:n,imageName:a,width:r,height:l,x:g,y:C}=i,P=m.find(L=>L.id===n);if(!(P==null?void 0:P.rects)||!P.rects.find(L=>L.imageName===a))return;const _=P.rects.map(L=>L.imageName===a?O(v({},L),{width:r,height:l,x:g,y:C}):L),F=O(v({},P),{rects:_}),D=m.map(L=>L.id===n?F:L);return t==null||t.updatePolygonList(D!=null?D:[]),D},Wt=i=>{const{boxID:n,imageName:a}=i,r=m.find(P=>P.id===n);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(P=>P.imageName!==a),g=O(v({},r),{rects:l}),C=m.map(P=>P.id===n?g:P);return t==null||t.updatePolygonList(C!=null?C:[]),C},Zt=({newSelectedBox:i,newPointCloudList:n,newSelectedSphere:a,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(d.length===0||!g)){if(i||(V==null?void 0:V.info)){const C=i!=null?i:V==null?void 0:V.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(d[0]);const P=g.selectedPolygon;if(d.length===1&&C){W({omitView:B.Top,polygon:P,boxParams:C,newPointCloudBoxList:n});return}}if((a||J)&&d.length===1){const C=a!=null?a:J;g.setSelectedID(d[0]);const P=g.selectedPoint;C&&Q(B.Top,P,C,void 0,r,b)}}},Ct=(i,n,a)=>{if(ft){let r,l;switch(a){case B.Back:r=vo;break;case B.Side:r=Dt;break;default:r=Dt;break}if(l=r(i,n,ft,s.pointCloudInstance),o){const{count:_}=o.getSensesPointZAxisInPolygon(eo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(v({},l),{count:_})}const C=M(dt({tool:st.PointCloud,dataList:[l],stepConfig:b,action:"viewUpdateBox"}))[0],P=l.valid!==C.valid;l=C;const h=zt(l);return l=h.find(_=>_.id===l.id),W({omitView:P?void 0:a,polygon:i,boxParams:l,newPointCloudBoxList:h}),h}},Pt=(i,n,a)=>{if(J){let r,l;switch(a){case B.Back:r=Lo;break;case B.Side:r=It;break;default:r=It;break}l=r(i,n,J);const g=gt(l);return Q(a,i,l,void 0,g,b),g}},Gt=(i,n)=>{Pt(i,n,B.Side)},Jt=(i,n)=>{Pt(i,n,B.Back)},Qt=(i,n)=>{Ct(i,n,B.Side)},Xt=(i,n)=>{Ct(i,n,B.Back)},Yt=(i,n)=>{const a=Ot(i.id),r=ct(i,n,et,a),l=gt(r);Q(B.Top,i,r,void 0,l,b)},qt=(i,n)=>{if(I){const r=v({},i[0].newPolygon);r.pointList=r.pointList.map(l=>k.transferCanvas2World(l,n)),E(r);return}let a=i.map(({newPolygon:r})=>{const l=Nt(r.id),{boxParams:g}=ut(r,n,t.pointCloudInstance,l);return g});if(a=M(dt({tool:st.PointCloud,dataList:a,stepConfig:b,action:"viewUpdateBox"})),a.length===1){const{newPolygon:r}=i[0],l=ot(a);W({polygon:r,boxParams:a[0],newPointCloudBoxList:l})}else{const r=ot(a);r&&e.syncAllViewPointCloudColor(rt.MultiMove,r)}},Kt=i=>{var n,a,r,l,g;if(V){const C=Number(i.widthDefault),P=Number(i.depthDefault),h=Number(i.heightDefault),_=V==null?void 0:V.info.trackID,D=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===_),L={width:(r=(a=t==null?void 0:t.toolInstance)==null?void 0:a.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},j=D.pointList.map(Y=>k.transferCanvas2World(Y,L)),nt=w.getModifiedRectangleCoordinates(j,h,C),it=nt[0],Z=nt[2],X=w.getLineCenterPoint([it,Z]),$t=V.info.center.z-V.info.depth/2,mt=O(v({},V.info),{center:{x:X.x,y:X.y,z:$t+P/2},width:C,height:h,depth:P,valid:!0}),to=ot([mt]);W({omitView:B["3D"],polygon:D,boxParams:mt,newPointCloudBoxList:to})}},Q=(i,n,a,r,l,g)=>at(void 0,null,function*(){const C=H==null?void 0:H.url,P={[B.Side]:()=>{St(a,n,s,C,g)},[B.Back]:()=>{u&&_t(a,n,u,C,g)},[B.Top]:()=>{kt(a,n,t,o)}};Object.keys(P).forEach(h=>{h!==i&&P[h]()}),r&&(o==null||o.updateCameraZoom(r)),Et(a)}),W=i=>at(void 0,null,function*(){const{omitView:n,polygon:a,boxParams:r,zoom:l,newPointCloudBoxList:g}=i,C=H==null?void 0:H.url;g&&(yield e.syncAllViewPointCloudColor(rt.Single,g));const P={[B.Side]:()=>{Rt(r,a,s,C)},[B.Back]:()=>{u&&Vt(r,a,u,C)},[B.Top]:()=>{pt(r,a,t,o)}};Object.keys(P).forEach(h=>{h!==n&&P[h]()}),l&&(o==null||o.updateCameraZoom(l)),jt(r)});return{topViewAddSphere:Mt,topViewAddBox:Ft,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const n=k.getDefaultOrthographicParams(i);o.initOrthographicCamera(n),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>at(void 0,[...i],function*(n=H){var a,r,l,g,C,P;if(!(n==null?void 0:n.url)||!o)return;A([]),vt(M,!0),yt(M,!0),yield o.loadPCDFile(n.url,(a=b==null?void 0:b.radius)!=null?a:$),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let h=[],_=[],F=[],D=[];o.updateTopCamera();const L=(l=(r=lt(n.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(L),(g=e.sideViewInstance)==null||g.clearAllData(),(C=e.backViewInstance)==null||C.clearAllData(),n.result){if(h=k.getBoxParamsFromResultList(n.result),(h==null?void 0:h.length)>0&&n.isPreResult&&(b==null?void 0:b.lowerLimitPointsNumInBox)>0){h=yield o==null?void 0:o.filterPreResult(n.url,b,h);const j=lt(n.result);j[no].result=h,n.result=JSON.stringify(j),e.setPointCloudResult(h)}F=k.getPolygonListFromResultList(n.result),_=k.getLineListFromResultList(n.result),D=k.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(P=b==null?void 0:b.radius)!=null?P:$}),o==null||o.generateBoxes(h),o==null||o.generateSpheres(D),yield e.syncAllViewPointCloudColor(rt.Default,h,[])}N({pointCloudBoxList:h,polygonList:F,lineList:_,pointCloudSphereList:D}),vt(M,!1),yt(M,!1)}),updateViewsByDefaultSize:Kt,generateRects:tt,update2DViewRect:Ht,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:t,setPointCloudResult:s}=xt(Lt),u=q(e),o=q(t);return{syncToPointCloudBoxList:ht(()=>{const f=u.current,c=o.current;if(c.length===0)return null;const d=new Map,m=new Set;if(c.filter(x=>x.extId!==void 0).forEach(x=>{const y=x.extId,A=x.imageName,R=lo(x,["x","y","width","height"]);let S=d.get(y);S||(S=new Map,d.set(y,S)),S.set(A,R),m.add(y)}),d.size){const x=f.map(y=>{var A;const R=y.id;if(m.has(R)){const S=v({},y);return(A=S.rects)==null||A.forEach(U=>{var z;const T=U.imageName;Object.assign(U,(z=d.get(R))==null?void 0:z.get(T))}),S}return y});return s(x),x}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,pt as synchronizeTopView,ct as topViewPoint2PointCloud,ut as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
1
+ import{EPointCloudName as st,TagUtils as to,MathUtils as w,getCuboidFromPointCloudBox as oo}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as k,POINT_CLOUD_DEFAULT_STEP as eo,DEFAULT_SPHERE_PARAMS as no}from"@labelbee/lb-utils";import{useContext as mt,useCallback as xt}from"react";import{PointCloudContext as ht}from"../PointCloudContext.js";import{useSingleBox as io}from"./useSingleBox.js";import{useSphere as so}from"./useSphere.js";import{pick as ro}from"lodash";import{useSelector as lo,useDispatch as ao}from"../../../store/ctx.js";import co from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as rt}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as lt,generatePointCloudBoxRects as uo}from"../../../utils/index.js";import{PreDataProcess as dt,SetPointCloudLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as po}from"./useHistory.js";import{usePolygon as go}from"./usePolygon.js";import{useLatest as q}from"ahooks";var fo=Object.defineProperty,Co=Object.defineProperties,Po=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,mo=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Bt=(o,t,i)=>t in o?fo(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,v=(o,t)=>{for(var i in t||(t={}))mo.call(t,i)&&Bt(o,i,t[i]);if(yt)for(var i of yt(t))xo.call(t,i)&&Bt(o,i,t[i]);return o},O=(o,t)=>Co(o,Po(t)),bt=(o,t,i)=>new Promise((u,e)=>{var p=d=>{try{c(i.next(d))}catch(m){e(m)}},f=d=>{try{c(i.throw(d))}catch(m){e(m)}},c=d=>d.done?u(d.value):Promise.resolve(d.value).then(p,f);c((i=i.apply(o,t)).next())});const K=5,$=90,wt=.01,B={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(o,t,i,u,e)=>{const{x:p,y:f}=k.transferCanvas2World(o,t),{defaultZ:c}=no,d={center:{x:p,y:f,z:c},id:o.id},m=u?v(v({},u),d):O(v({},d),{attribute:"",valid:!0});return e&&Object.assign(m,e),m},ct=(o,t,i,u,e,p)=>{let f=o.pointList.map(I=>k.transferCanvas2World(I,t)),c=0,d=1,m={};if(i){const I=i.getSensesPointZAxisInPolygon(f,void 0,p);p&&I.fittedCoordinates.length>0&&(f=I.fittedCoordinates),c=(I.maxZ+I.minZ)/2,d=I.maxZ-I.minZ,m={count:I.zCount}}const[x,y,A]=f,R=w.getLineCenterPoint([x,A]),S=w.getLineLength(x,y),U=w.getLineLength(y,A),z=w.getRadiusFromQuadrangle(o.pointList);u&&(c=u.center.z,d=u.depth);const T={center:{x:R.x,y:R.y,z:c},width:p?U+wt:U,height:p?S+wt:S,depth:d,rotation:z,id:o.id},N=v(u?v(v({},u),T):O(v({},T),{attribute:"",valid:!0}),m);e&&Object.assign(N,e);const E=f.map(I=>k.transferWorld2Canvas(I,t));return{boxParams:N,newPointList:E}},It=(o,t,i)=>{const u={x:o.x-t.x,y:o.y-t.y};return O(v({},i),{center:{x:i.center.x-u.x,y:i.center.y,z:i.center.z-u.y}})},Dt=(o,t,i,u)=>{const[e,p,f]=o.pointList,[c,d,m]=t.pointList,x=w.getLineCenterPoint([e,f]),y=w.getLineCenterPoint([c,m]),R={x:{x:x.x-y.x,y:x.y-y.y}.x,y:0,z:x.y-y.y},S=w.getLineLength(e,p),U=w.getLineLength(c,d),z=S-U,T=w.getLineLength(p,f),N=w.getLineLength(d,m),E=T-N,{newBoxParams:I}=u.getNewBoxBySideUpdate(R,E,z,i);return I},ho=(o,t,i)=>{const u={x:o.x-t.x,y:o.y-t.y};return O(v({},i),{center:{x:i.center.x,y:i.center.y-u.x,z:i.center.z-u.y}})},Lo=(o,t,i,u)=>{const[e,p,f]=o.pointList,[c,d,m]=t.pointList,x=w.getLineCenterPoint([e,f]),y=w.getLineCenterPoint([c,m]),R={x:{x:x.x-y.x,y:x.y-y.y}.x,y:0,z:x.y-y.y},S=w.getLineLength(e,p),U=w.getLineLength(c,d),z=S-U,T=w.getLineLength(p,f),N=w.getLineLength(d,m),E=T-N;let{newBoxParams:I}=u.getNewBoxByBackUpdate(R,E,z,i);return I},St=(o,t,i,u,e)=>{var p;if(!i)return;const{toolInstance:f,pointCloudInstance:c}=i;c.loadPCDFile(u,(p=e==null?void 0:e.radius)!=null?p:$);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(o,G.Left);c.setInitCameraPosition(d);const{point2d:m,zoom:x}=c.getSphereSidePoint2DCoordinate(o);c.camera.zoom=x,c.camera.updateProjectionMatrix(),c.render(),f.initPosition(),f.zoomChangeOnCenter(x),f.setResult([O(v(v({},t),m),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(t.id)},Rt=(o,t,i,u)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:p}=i;p.loadPCDFileByBox(u,o,{width:K,depth:K});const{cameraPositionVector:f}=p.updateOrthoCamera(o,G.Left);p.setInitCameraPosition(f);const{polygon2d:c,zoom:d}=p.getBoxSidePolygon2DCoordinate(o);p.camera.zoom=d,p.camera.updateProjectionMatrix(),p.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:t.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],t.id)},_t=(o,t,i,u,e)=>{var p;if(!i)return;const{toolInstance:f,pointCloudInstance:c}=i;c.loadPCDFile(u,(p=e==null?void 0:e.radius)!=null?p:$);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(o,G.Back);c.setInitCameraPosition(d);const{point2d:m,zoom:x}=c.getSphereBackPoint2DCoordinate(o);c.camera.zoom=x,c.camera.updateProjectionMatrix(),c.render(),f.initPosition(),f.zoomChangeOnCenter(x),f.setResult([O(v(v({},t),m),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(t.id)},Vt=(o,t,i,u)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:p}=i;p.loadPCDFileByBox(u,o,{height:K,depth:K});const{cameraPositionVector:f}=p.updateOrthoCamera(o,G.Back);p.setInitCameraPosition(f);const{polygon2d:c,zoom:d}=p.getBoxBackPolygon2DCoordinate(o);p.camera.zoom=d,p.camera.updateProjectionMatrix(),p.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:t.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],t.id)},kt=(o,t,i,u)=>{if(!i||!u)return;u.generateSphere(o),u.updateCameraBySphere(o,G.Top),u.render();const{toolInstance:e,pointCloudInstance:p}=i,{point2d:f}=p.getSphereTopPoint2DCoordinate(o),c=[...e.pointList].map(d=>d.id===t.id?O(v(v({},t),f),{valid:o.valid,textAttribute:"",attribute:o.attribute}):d);e.setResult(c),e.setSelectedID(t.id)},ut=(o,t,i,u)=>{var e,p;if(!i||!u)return;u.generateBox(o,t.id),u.render();const{pointCloud2dOperation:f,pointCloudInstance:c}=i,{polygon2d:d}=c.getBoxTopPolygon2DCoordinate(o),m=[...f.polygonList],x=m.find(y=>y.id===t.id);x?(x.pointList=d,x.valid=(e=o.valid)!=null?e:!0):m.push({id:t.id,pointList:d,textAttribute:"",isRect:!0,valid:(p=o.valid)!=null?p:!0}),f.setResultAndSelectedID(m,t.id)},vo=()=>{const o=mt(ht),{topViewInstance:t,sideViewInstance:i,backViewInstance:u,mainViewInstance:e,addPointCloudBox:p,addPointCloudSphere:f,setSelectedIDs:c,selectedIDs:d,pointCloudBoxList:m,pointCloudSphereList:x,hideAttributes:y,setHighlight2DDataList:A,cuboidBoxIn2DView:R,imageSizes:S,history:U,linkageImageNameRectMap:z}=o,{addHistory:T,initHistory:N,pushHistoryUnderUpdatePolygon:E}=po(),{selectedPolygon:I}=go(),{getPointCloudSphereByID:Ot,updatePointCloudSphere:pt,selectedSphere:J}=so(),{currentData:H,config:b}=lo(s=>{const{stepList:n,step:a,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:lt(co.getCurrentStepInfo(a,n).config)}}),M=ao(),At=q(R),Tt=q(z),Ut=xt((s,n)=>{const a=Tt.current,r=n.id;return s.filter(g=>{if(!g)return!1;const C=a.get(g.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),tt=s=>{const{enableAutoMap2DRect:n=!1}=b;if(!At.current||n){const{mappingImgList:a=[]}=H;uo({pointCloudBox:s,mappingImgList:a,imageSizes:S},{prepareRectsFn:Ut})}},{selectedBox:V,updateSelectedBox:zt,updateSelectedBoxes:ot,getPointCloudByID:Nt}=io({generateRects:tt}),gt=V==null?void 0:V.info;if(!t||!i||!u)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:et}=t,jt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},Et=({newPoint:s,size:n,zoom:a,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:k.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:x})});const C=at(s,n,et,void 0,g);c(s.id);const P=f(C);Q(B.Top,s,C,a,P,b),T({newSphereParams:C})},Mt=({polygon:s,size:n,imgList:a,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,P,h;const _={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(_,{trackID:k.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:x})});const F=t==null?void 0:t.toolInstance,D=v({},s);let{boxParams:L,newPointList:j}=ct(D,n,et,void 0,_,g);L=M(dt({tool:st.PointCloud,dataList:[L],stepConfig:b,action:"viewUpdateBox"}))[0],g&&(j==null?void 0:j.length)&&(D.pointList=j);const it=y.includes(D.attribute);tt(L);const Z=p(L),X=(P=o==null?void 0:o.polygonList)!=null?P:[];L.subAttribute=to.getDefaultResultByConfig((b==null?void 0:b.secondaryAttributeConfigurable)?(h=b==null?void 0:b.inputList)!=null?h:[]:[]),t==null||t.updatePolygonList(Z!=null?Z:[],X),it?c([]):(c(L.id),F.selection.setSelectedIDs(D.id),W({omitView:B.Top,polygon:D,boxParams:L,zoom:l,newPointCloudBoxList:Z}),g&&ut(L,D,t,e)),T({newBoxParams:L})},Ft=s=>{const{boxID:n,imageName:a,width:r,height:l,x:g,y:C}=s,P=m.find(L=>L.id===n);if(!(P==null?void 0:P.rects)||!P.rects.find(L=>L.imageName===a))return;const _=P.rects.map(L=>L.imageName===a?O(v({},L),{width:r,height:l,x:g,y:C}):L),F=O(v({},P),{rects:_}),D=m.map(L=>L.id===n?F:L);return t==null||t.updatePolygonList(D!=null?D:[]),D},Ht=s=>{const{boxID:n,imageName:a}=s,r=m.find(P=>P.id===n);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(P=>P.imageName!==a),g=O(v({},r),{rects:l}),C=m.map(P=>P.id===n?g:P);return t==null||t.updatePolygonList(C!=null?C:[]),C},Wt=({newSelectedBox:s,newPointCloudList:n,newSelectedSphere:a,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(d.length===0||!g)){if(s||(V==null?void 0:V.info)){const C=s!=null?s:V==null?void 0:V.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(d[0]);const P=g.selectedPolygon;if(d.length===1&&C){W({omitView:B.Top,polygon:P,boxParams:C,newPointCloudBoxList:n});return}}if((a||J)&&d.length===1){const C=a!=null?a:J;g.setSelectedID(d[0]);const P=g.selectedPoint;C&&Q(B.Top,P,C,void 0,r,b)}}},ft=(s,n,a)=>{if(gt){let r,l;switch(a){case B.Back:r=Lo;break;case B.Side:r=Dt;break;default:r=Dt;break}if(l=r(s,n,gt,i.pointCloudInstance),e){const{count:_}=e.getSensesPointZAxisInPolygon(oo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(v({},l),{count:_})}const C=M(dt({tool:st.PointCloud,dataList:[l],stepConfig:b,action:"viewUpdateBox"}))[0],P=l.valid!==C.valid;l=C;const h=zt(l);return l=h.find(_=>_.id===l.id),W({omitView:P?void 0:a,polygon:s,boxParams:l,newPointCloudBoxList:h}),h}},Ct=(s,n,a)=>{if(J){let r,l;switch(a){case B.Back:r=ho;break;case B.Side:r=It;break;default:r=It;break}l=r(s,n,J);const g=pt(l);return Q(a,s,l,void 0,g,b),g}},Zt=(s,n)=>{Ct(s,n,B.Side)},Gt=(s,n)=>{Ct(s,n,B.Back)},Jt=(s,n)=>{ft(s,n,B.Side)},Qt=(s,n)=>{ft(s,n,B.Back)},Xt=(s,n)=>{const a=Ot(s.id),r=at(s,n,et,a),l=pt(r);Q(B.Top,s,r,void 0,l,b)},Yt=(s,n)=>{if(I){const r=v({},s[0].newPolygon);r.pointList=r.pointList.map(l=>k.transferCanvas2World(l,n)),E(r);return}let a=s.map(({newPolygon:r})=>{const l=Nt(r.id),{boxParams:g}=ct(r,n,t.pointCloudInstance,l);return g});if(a=M(dt({tool:st.PointCloud,dataList:a,stepConfig:b,action:"viewUpdateBox"})),a.length===1){const{newPolygon:r}=s[0],l=ot(a);W({polygon:r,boxParams:a[0],newPointCloudBoxList:l})}else{const r=ot(a);r&&o.syncAllViewPointCloudColor(rt.MultiMove,r)}},qt=s=>{var n,a,r,l,g;if(V){const C=Number(s.widthDefault),P=Number(s.depthDefault),h=Number(s.heightDefault),_=V==null?void 0:V.info.trackID,D=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===_),L={width:(r=(a=t==null?void 0:t.toolInstance)==null?void 0:a.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},j=D.pointList.map(Y=>k.transferCanvas2World(Y,L)),nt=w.getModifiedRectangleCoordinates(j,h,C),it=nt[0],Z=nt[2],X=w.getLineCenterPoint([it,Z]),Kt=V.info.center.z-V.info.depth/2,Pt=O(v({},V.info),{center:{x:X.x,y:X.y,z:Kt+P/2},width:C,height:h,depth:P,valid:!0}),$t=ot([Pt]);W({omitView:B["3D"],polygon:D,boxParams:Pt,newPointCloudBoxList:$t})}},Q=(s,n,a,r,l,g)=>bt(void 0,null,function*(){const C=H==null?void 0:H.url,P={[B.Side]:()=>{St(a,n,i,C,g)},[B.Back]:()=>{u&&_t(a,n,u,C,g)},[B.Top]:()=>{kt(a,n,t,e)}};Object.keys(P).forEach(h=>{h!==s&&P[h]()}),r&&(e==null||e.updateCameraZoom(r)),jt(a)}),W=s=>{const{omitView:n,polygon:a,boxParams:r,zoom:l,newPointCloudBoxList:g}=s,C=H==null?void 0:H.url;g&&o.syncAllViewPointCloudColor(rt.Single,g);const P={[B.Side]:()=>{Rt(r,a,i,C)},[B.Back]:()=>{u&&Vt(r,a,u,C)},[B.Top]:()=>{ut(r,a,t,e)}};Object.keys(P).forEach(h=>{h!==n&&P[h]()}),l&&(e==null||e.updateCameraZoom(l))};return{topViewAddSphere:Et,topViewAddBox:Mt,topViewSelectedChanged:Wt,topViewUpdatePoint:Xt,sideViewUpdatePoint:Zt,backViewUpdatePoint:Gt,topViewUpdateBox:Yt,sideViewUpdateBox:Jt,backViewUpdateBox:Qt,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),e==null||e.generateBoxes(s)},initPointCloud3d:s=>{if(!e)return;const n=k.getDefaultOrthographicParams(s);e.initOrthographicCamera(n),e.initRenderer(),e.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(n=H){var a,r,l,g,C,P;if(!(n==null?void 0:n.url)||!e)return;A([]),Lt(M,!0),vt(M,!0),yield e.loadPCDFile(n.url,(a=b==null?void 0:b.radius)!=null?a:$),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let h=[],_=[],F=[],D=[];e.updateTopCamera();const L=(l=(r=lt(n.result))==null?void 0:r.valid)!=null?l:!0;if(o.setPointCloudValid(L),(g=o.sideViewInstance)==null||g.clearAllData(),(C=o.backViewInstance)==null||C.clearAllData(),n.result){if(h=k.getBoxParamsFromResultList(n.result),(h==null?void 0:h.length)>0&&n.isPreResult&&(b==null?void 0:b.lowerLimitPointsNumInBox)>0){h=yield e==null?void 0:e.filterPreResult(n.url,b,h);const j=lt(n.result);j[eo].result=h,n.result=JSON.stringify(j),o.setPointCloudResult(h)}F=k.getPolygonListFromResultList(n.result),_=k.getLineListFromResultList(n.result),D=k.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(P=b==null?void 0:b.radius)!=null?P:$}),e==null||e.generateBoxes(h),e==null||e.generateSpheres(D),yield o.syncAllViewPointCloudColor(rt.Default,h,[])}N({pointCloudBoxList:h,polygonList:F,lineList:_,pointCloudSphereList:D}),Lt(M,!1),vt(M,!1)}),updateViewsByDefaultSize:qt,generateRects:tt,update2DViewRect:Ft,remove2DViewRect:Ht}},yo=()=>{const{pointCloudBoxList:o,rectList:t,setPointCloudResult:i}=mt(ht),u=q(o),e=q(t);return{syncToPointCloudBoxList:xt(()=>{const f=u.current,c=e.current;if(c.length===0)return null;const d=new Map,m=new Set;if(c.filter(x=>x.extId!==void 0).forEach(x=>{const y=x.extId,A=x.imageName,R=ro(x,["x","y","width","height"]);let S=d.get(y);S||(S=new Map,d.set(y,S)),S.set(A,R),m.add(y)}),d.size){const x=f.map(y=>{var A;const R=y.id;if(m.has(R)){const S=v({},y);return(A=S.rects)==null||A.forEach(U=>{var z;const T=U.imageName;Object.assign(U,(z=d.get(R))==null?void 0:z.get(T))}),S}return y});return i(x),x}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ut as synchronizeTopView,at as topViewPoint2PointCloud,ct as topViewPolygon2PointCloud,vo as usePointCloudViews,yo as useSyncRectPositionDimensionToPointCloudList};
package/es/index.css CHANGED
@@ -508,7 +508,6 @@
508
508
  height: 100%;
509
509
  border: 1px solid transparent;
510
510
  font-size: 12px;
511
- overflow-y: auto;
512
511
  }
513
512
  .index-module_container__gTeNm .index-module_loop__FHsHY {
514
513
  position: absolute;
@@ -2580,6 +2579,7 @@
2580
2579
  top: 16px;
2581
2580
  left: 16px;
2582
2581
  z-index: 1000;
2582
+ pointer-events: none;
2583
2583
  }
2584
2584
  .bee-point-cloud-wrapper .bee-point-cloud-container__zoom {
2585
2585
  position: absolute;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.67",
3
+ "version": "1.23.0-alpha.69",
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.35",
46
+ "@labelbee/lb-annotation": "1.27.0-alpha.37",
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",