@labelbee/lb-components 1.24.0-alpha.21 → 1.24.0-alpha.23

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 ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),util=require("./util.js"),useUpdateRectList=require("./useUpdateRectList.js"),_=require("lodash"),useToolStyle=require("../../hooks/useToolStyle.js"),index=require("../../store/toolConfig/index.js");function _interopDefaultLegacy(c){return c&&typeof c=="object"&&"default"in c?c:{default:c}}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=(c,l,s)=>l in c?__defProp(c,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):c[l]=s,__spreadValues=(c,l)=>{for(var s in l||(l={}))__hasOwnProp.call(l,s)&&__defNormalProp(c,s,l[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(l))__propIsEnum.call(l,s)&&__defNormalProp(c,s,l[s]);return c},__spreadProps=(c,l)=>__defProps(c,__getOwnPropDescs(l)),__async=(c,l,s)=>new Promise((f,p)=>{var I=a=>{try{D(s.next(a))}catch(R){p(R)}},S=a=>{try{D(s.throw(a))}catch(R){p(R)}},D=a=>a.done?f(a.value):Promise.resolve(a.value).then(I,S);D((s=s.apply(c,l)).next())});const PointCloud2DRectOperationView=c=>{var l,s;const{mappingData:f,size:p,config:I,checkMode:S,afterImgOnLoad:D,shouldExcludePointCloudBoxListUpdate:a}=c,{selectBoxVisibleSwitch:R}=index(),L=(l=f==null?void 0:f.url)!=null?l:"",b=(s=f==null?void 0:f.fallbackUrl)!=null?s:"",{pointCloudBoxList:E,setPointCloudResult:O,defaultAttribute:V,rectList:q,addRectIn2DView:W,updateRectIn2DView:X,removeRectIn2DView:Y,updateRectListByReducer:ee,selectedIDs:v,setSelectedIDs:j,selectedID:C}=React.useContext(PointCloudContext.PointCloudContext),{value:U}=useToolStyle.useToolStyleContext(),te=ahooks.useLatest(v),{update2DViewRect:re,remove2DViewRect:ne}=usePointCloudViews.usePointCloudViews(),k=React__default.default.useRef(null),n=React.useRef(null),A=ahooks.useMemoizedFn(re),w=ahooks.useMemoizedFn(ne),x=React.useRef(null),[oe,F]=React.useState(!0),[T,H]=React.useState(""),[ue,B]=React.useState(!1),[ie,y]=React.useState(!0),g=React.useMemo(()=>q==null?void 0:q.filter(e=>e.imageName===(f==null?void 0:f.path)),[f==null?void 0:f.path,q]),Z=React.useRef(g),P=ahooks.useLatest(f==null?void 0:f.path),N=React.useCallback(e=>__async(void 0,null,function*(){try{const o=te.current.slice(0),t=yield Promise.resolve(e());if(!t||t.length===0)return t;if(o.length){const r=new Set(o),u=t.filter(i=>r.has(i.id)).map(i=>i.id);j(u)}return t}catch(o){}}),[j]),J=e=>{const{boxID:o}=e;if(y(!1),!a&&o){N(()=>{const t=A==null?void 0:A(e);return t?(x.current=t,O(t),t):null});return}X(e,!0)},$=e=>{P.current&&W(__spreadProps(__spreadValues({},e),{imageName:P.current}))},G=e=>{if(e.length===0)return;if(!a){const t=e.find(r=>r.boxID);if(t){N(()=>{const r=w==null?void 0:w(t);return r?(x.current=r,O(r),m(),r):null});return}}const o=e.find(t=>t.extId);o&&N(()=>{const{imageName:t,extId:r}=o,u=w==null?void 0:w({boxID:r,imageName:t});return u?(x.current=u,O(u),u):null}),Y(e)},ce=ahooks.useMemoizedFn(()=>{let e=[];return E.forEach(o=>{const{rects:t=[],id:r,attribute:u,trackID:i}=o,d=t.find(z=>z.imageName===P.current),h=r+"_"+P.current;d&&(e=[...e,__spreadProps(__spreadValues({},d),{boxID:r,id:h,attribute:u,order:i})])}),e}),m=useUpdateRectList.useUpdateRectList(()=>{var e,o,t,r,u;const i=a?[]:ce(),d=(e=n.current)==null?void 0:e.selectedRectID,h=v.slice(0),z=R?util.selectSpecifiedRectsFromTopViewSelectedIds(h,i,g):[...i,...g];let Q=[];!R&&(v==null?void 0:v.length)&&(Q=i.filter(M=>d?v.includes(M.boxID)&&!d.includes(M.boxID):v.includes(M.boxID))),(o=n.current)==null||o.setHighLightRectList(Q),(t=n.current)==null||t.setResult(z),T?((r=n.current)==null||r.setSelectedRectID(T),H("")):ue&&d&&((u=n.current)==null||u.setSelectedRectID(d),B(!1))}),K=({targetId:e,id:o})=>{y(!1),j(e),H(o)};return React.useEffect(()=>{if(k.current){const e=new lbAnnotation.PointCloud2DRectOperation({container:k.current,size:p,config:__spreadProps(__spreadValues({},I),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:S});return n.current=e,n.current.init(),n.current.on("updateDragResult",J),n.current.on("afterAddingDrawingRect",$),n.current.on("deleteSelectedRects",G),n.current.on("onRightClick",K),()=>{var o,t,r,u,i;(o=n.current)==null||o.unbind("updateDragResult",J),(t=n.current)==null||t.unbind("afterAddingDrawingRect",$),(r=n.current)==null||r.unbind("deleteSelectedRects",G),(u=n.current)==null||u.unbind("onRightClick",K),(i=n.current)==null||i.destroy()}}},[]),React.useEffect(()=>{const e=t=>__async(void 0,null,function*(){try{return yield lbAnnotation.ImgUtils.load(t)}catch(r){return console.error("Error loading image:",r),null}}),o=()=>__async(void 0,null,function*(){var t;F(!0);let r=yield e(L);!r&&b&&(r=yield e(b)),r&&((t=n.current)==null||t.setImgNode(r),D(r)),F(!1)});n.current&&(L||b)&&o()},[L,b]),React.useEffect(()=>{var e;(e=n.current)==null||e.setSize(p)},[p]),React.useEffect(()=>{E!==x.current&&m()},[E]),React.useEffect(()=>{var e,o;const t=g.find(r=>r.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,V),t&&ee(r=>{var u;const i=[];let d=null;return r.forEach(h=>{h.id!==n.current.selectedRectID?i.push(h):d=h}),t.extId===void 0&&(d=(u=n.current)==null?void 0:u.selectedRect),[...i,__spreadProps(__spreadValues({},d||{}),{attribute:V})]}),B(!0),m()},[V]),React.useEffect(()=>{const e=Z.current;___default.default.isEqual(e,g)||(B(!0),m(),Z.current=g)},[g]),React.useEffect(()=>{m()},[a]),React.useEffect(()=>{var e,o,t,r;const u=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},i=__spreadProps(__spreadValues({},u),{attributeList:(t=I.attributeList)!=null?t:[]});(r=n.current)==null||r.setConfig(JSON.stringify(i))},[I.attributeList]),React.useEffect(()=>{var e;(e=n.current)==null||e.setEnableAddRect(v.length===0),m()},[v]),ahooks.useDebounceEffect(()=>{if(!C||!ie){y(!0),a&&(n.current.setHoverRectID(""),n.current.render());return}const{rectList:e,size:o,zoom:t,imgNode:r}=n.current,u=e.find(d=>d.boxID===C||d.extId===C),i=lbUtils.ImgPosUtils.getBasicRecPos(r,u,o,.5);if(!i){y(!0);return}a&&n.current.setHoverRectID(u.id),n.current.setCurrentPos(i.currentPos),n.current.setZoom(i.innerZoom),n.current.renderBasicCanvas(),n.current.render()},[C],{wait:200}),React.useEffect(()=>{const{hiddenText:e}=U||{};if(e===void 0)return;const o=n.current;if(!o)return;const t=__spreadValues(__spreadValues({},o.style),U);o.setStyle(t)},[U]),React.useEffect(()=>{m()},[R]),React__default.default.createElement(es.Spin,{spinning:oe},React__default.default.createElement("div",{ref:k,style:__spreadValues({position:"relative"},p)}))};var PointCloud2DRectOperationView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DRectOperationView);module.exports=PointCloud2DRectOperationView$1;
1
+ "use strict";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),util=require("./util.js"),useUpdateRectList=require("./useUpdateRectList.js"),_=require("lodash"),useToolStyle=require("../../hooks/useToolStyle.js"),index=require("../../store/toolConfig/index.js");function _interopDefaultLegacy(s){return s&&typeof s=="object"&&"default"in s?s:{default:s}}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=(s,c,l)=>c in s?__defProp(s,c,{enumerable:!0,configurable:!0,writable:!0,value:l}):s[c]=l,__spreadValues=(s,c)=>{for(var l in c||(c={}))__hasOwnProp.call(c,l)&&__defNormalProp(s,l,c[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(c))__propIsEnum.call(c,l)&&__defNormalProp(s,l,c[l]);return s},__spreadProps=(s,c)=>__defProps(s,__getOwnPropDescs(c)),__async=(s,c,l)=>new Promise((f,p)=>{var h=a=>{try{D(l.next(a))}catch(R){p(R)}},S=a=>{try{D(l.throw(a))}catch(R){p(R)}},D=a=>a.done?f(a.value):Promise.resolve(a.value).then(h,S);D((l=l.apply(s,c)).next())});const PointCloud2DRectOperationView=s=>{var c,l;const{mappingData:f,size:p,config:h,checkMode:S,afterImgOnLoad:D,shouldExcludePointCloudBoxListUpdate:a}=s,{selectBoxVisibleSwitch:R}=index(),L=(c=f==null?void 0:f.url)!=null?c:"",b=(l=f==null?void 0:f.fallbackUrl)!=null?l:"",{pointCloudBoxList:E,setPointCloudResult:O,defaultAttribute:q,rectList:V,addRectIn2DView:W,updateRectIn2DView:X,removeRectIn2DView:Y,updateRectListByReducer:ee,selectedIDs:v,setSelectedIDs:j,selectedID:C}=React.useContext(PointCloudContext.PointCloudContext),{value:U}=useToolStyle.useToolStyleContext(),te=ahooks.useLatest(v),{update2DViewRect:re,remove2DViewRect:ne}=usePointCloudViews.usePointCloudViews(),k=React__default.default.useRef(null),n=React.useRef(null),M=ahooks.useMemoizedFn(re),y=ahooks.useMemoizedFn(ne),x=React.useRef(null),[oe,F]=React.useState(!0),[T,H]=React.useState(""),[ue,B]=React.useState(!1),[ie,w]=React.useState(!0),g=React.useMemo(()=>V==null?void 0:V.filter(e=>e.imageName===(f==null?void 0:f.path)),[f==null?void 0:f.path,V]),Z=React.useRef(g),P=ahooks.useLatest(f==null?void 0:f.path),N=React.useCallback(e=>__async(void 0,null,function*(){try{const o=te.current.slice(0),t=yield Promise.resolve(e());if(!t||t.length===0)return t;if(o.length){const r=new Set(o),u=t.filter(i=>r.has(i.id)).map(i=>i.id);j(u)}return t}catch(o){}}),[j]),J=e=>{const{boxID:o}=e;if(w(!1),!a&&o){N(()=>{const t=M==null?void 0:M(e);return t?(x.current=t,O(t),t):null});return}X(e,!0)},$=e=>{P.current&&W(__spreadProps(__spreadValues({},e),{imageName:P.current}))},G=e=>{if(e.length===0)return;if(!a){const t=e.find(r=>r.boxID);if(t){N(()=>{const r=y==null?void 0:y(t);return r?(x.current=r,O(r),m(),r):null});return}}const o=e.find(t=>t.extId);o&&N(()=>{const{imageName:t,extId:r}=o,u=y==null?void 0:y({boxID:r,imageName:t});return u?(x.current=u,O(u),u):null}),Y(e)},se=ahooks.useMemoizedFn(()=>{let e=[];return E.forEach(o=>{const{rects:t=[],id:r,attribute:u,trackID:i}=o,d=t.find(A=>A.imageName===P.current),I=r+"_"+P.current;d&&(e=[...e,__spreadProps(__spreadValues({},d),{boxID:r,id:I,attribute:u,order:i})])}),e}),m=useUpdateRectList.useUpdateRectList(()=>{var e,o,t,r,u;const i=a?[]:se(),d=(e=n.current)==null?void 0:e.selectedRectID,I=v.slice(0),A=R?util.selectSpecifiedRectsFromTopViewSelectedIds(I,i,g):[...i,...g];let Q=[];!R&&(v==null?void 0:v.length)&&(Q=i.filter(z=>d?v.includes(z.boxID)&&!d.includes(z.boxID):v.includes(z.boxID))),(o=n.current)==null||o.setHighLightRectList(Q),(t=n.current)==null||t.setResult(A),T?((r=n.current)==null||r.setSelectedRectID(T),H("")):ue&&d&&((u=n.current)==null||u.setSelectedRectID(d),B(!1))}),K=({targetId:e,id:o})=>{w(!1),requestAnimationFrame(()=>{ce(e),H(o)})},ce=e=>{(Array.isArray(v)?v:[]).includes(e)||j(e)};return React.useEffect(()=>{if(k.current){const e=new lbAnnotation.PointCloud2DRectOperation({container:k.current,size:p,config:__spreadProps(__spreadValues({},h),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:S});return n.current=e,n.current.init(),n.current.on("updateDragResult",J),n.current.on("afterAddingDrawingRect",$),n.current.on("deleteSelectedRects",G),n.current.on("onRightClick",K),()=>{var o,t,r,u,i;(o=n.current)==null||o.unbind("updateDragResult",J),(t=n.current)==null||t.unbind("afterAddingDrawingRect",$),(r=n.current)==null||r.unbind("deleteSelectedRects",G),(u=n.current)==null||u.unbind("onRightClick",K),(i=n.current)==null||i.destroy()}}},[]),React.useEffect(()=>{const e=t=>__async(void 0,null,function*(){try{return yield lbAnnotation.ImgUtils.load(t)}catch(r){return console.error("Error loading image:",r),null}}),o=()=>__async(void 0,null,function*(){var t;F(!0);let r=yield e(L);!r&&b&&(r=yield e(b)),r&&((t=n.current)==null||t.setImgNode(r),D(r)),F(!1)});n.current&&(L||b)&&o()},[L,b]),React.useEffect(()=>{var e;(e=n.current)==null||e.setSize(p)},[p]),React.useEffect(()=>{E!==x.current&&m()},[E]),React.useEffect(()=>{var e,o;const t=g.find(r=>r.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,q),t&&ee(r=>{var u;const i=[];let d=null;return r.forEach(I=>{I.id!==n.current.selectedRectID?i.push(I):d=I}),t.extId===void 0&&(d=(u=n.current)==null?void 0:u.selectedRect),[...i,__spreadProps(__spreadValues({},d||{}),{attribute:q})]}),B(!0),m()},[q]),React.useEffect(()=>{const e=Z.current;___default.default.isEqual(e,g)||(B(!0),m(),Z.current=g)},[g]),React.useEffect(()=>{m()},[a]),React.useEffect(()=>{var e,o,t,r;const u=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},i=__spreadProps(__spreadValues({},u),{attributeList:(t=h.attributeList)!=null?t:[]});(r=n.current)==null||r.setConfig(JSON.stringify(i))},[h.attributeList]),React.useEffect(()=>{var e;(e=n.current)==null||e.setEnableAddRect(v.length===0),m()},[v]),ahooks.useDebounceEffect(()=>{if(!C||!ie){w(!0),a&&(n.current.setHoverRectID(""),n.current.render());return}const{rectList:e,size:o,zoom:t,imgNode:r}=n.current,u=e.find(d=>d.boxID===C||d.extId===C),i=lbUtils.ImgPosUtils.getBasicRecPos(r,u,o,.5);if(!i){w(!0);return}a&&n.current.setHoverRectID(u.id),n.current.setCurrentPos(i.currentPos),n.current.setZoom(i.innerZoom),n.current.renderBasicCanvas(),n.current.render()},[C],{wait:200}),React.useEffect(()=>{const{hiddenText:e}=U||{};if(e===void 0)return;const o=n.current;if(!o)return;const t=__spreadValues(__spreadValues({},o.style),U);o.setStyle(t)},[U]),React.useEffect(()=>{m()},[R]),React__default.default.createElement(es.Spin,{spinning:oe},React__default.default.createElement("div",{ref:k,style:__spreadValues({position:"relative"},p)}))};var PointCloud2DRectOperationView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DRectOperationView);module.exports=PointCloud2DRectOperationView$1;
@@ -1 +1 @@
1
- "use strict";var dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),classNames=require("classnames"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),index=require("../../utils/index.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index$1=require("./components/PointCloudSizeSlider/index.js"),index$2=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons"),useToolStyle=require("../../hooks/useToolStyle.js"),usePointCloudAttribute=require("./hooks/usePointCloudAttribute.js");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,i,a)=>i in n?__defProp(n,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[i]=a,__spreadValues=(n,i)=>{for(var a in i||(i={}))__hasOwnProp.call(i,a)&&__defNormalProp(n,a,i[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(i))__propIsEnum.call(i,a)&&__defNormalProp(n,a,i[a]);return n};const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:n})=>{const{isActive:i,setTarget3DView:a}=React.useContext(PointCloud3DContext),m=d=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",d)]:!0,active:i});return React__default.default.createElement("span",{onClick:()=>{a(lbUtils.EPerspectiveView[n])},className:m(n.toLocaleLowerCase())})},PointCloud3DSideBar=({isEnlarge:n})=>{const{reset3DView:i,followTopView:a}=React.useContext(PointCloud3DContext),{t:m}=reactI18next.useTranslation(),d=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Top"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Front"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Left"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Back"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Right"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"LFT"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"RBT"})),e=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Tooltip,{title:m("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{a()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{i()},className:dom.getClassName("point-cloud-3d-view","reset")}));return n?React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebarZoom")},e,d):React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},d,e)},PointCloud3D=({currentData:n,config:i,highlightAttribute:a,setResourceLoading:m})=>{var d;const e=React.useContext(PointCloudContext.PointCloudContext),{setIsLargeStatus:P}=e,[y,B]=React.useState(!0),[f,V]=React.useState(!1),v=React.useRef(null),{initPointCloud3d:x,generateRects:L}=usePointCloudViews.usePointCloudViews(),p=useSize(v),{t:g}=reactI18next.useTranslation(),{value:I}=useToolStyle.useToolStyleContext(),{hiddenText:h}=I||{},{updatePointCloudAttribute:N}=usePointCloudAttribute.usePointCloudAttribute(m,i),{updateSelectedBox:q}=useSingleBox.useSingleBox({generateRects:L});React.useEffect(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(h,e.pointCloudBoxList)},[I]),React.useEffect(()=>{!e.mainViewInstance||x==null||x(p)},[p]);const{selectedBox:c}=useSingleBox.useSingleBox(),{selectedSphere:w}=useSphere.useSphere(),[j,_]=React.useState(!0),E=t=>{var o,l;const s=c==null?void 0:c.info;if(s){const r=__spreadValues({},s.center);r.x=r.x-.01,r.z=1e3;const u=t===lbUtils.EPerspectiveView.Top;(o=e.mainViewInstance)==null||o.updateCameraByBox(s,t,u?r:void 0)}w&&((l=e.mainViewInstance)==null||l.updateCameraBySphere(w,t))},D=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},R=()=>{var t,o;const l=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;l&&((o=e.mainViewInstance)==null||o.applyCameraTarget(l))};React.useEffect(()=>{if(v.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&p.width&&(t=new lbAnnotation.PointCloud({container:v.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(p),config:i,hiddenText:h}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:_}),e.setMainViewInstance(t))}},[p,n]),React.useEffect(()=>{var t,o;if(v.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let l=e.mainViewInstance;const s=lbUtils.PointCloudUtils.getRectParamsFromResultList(n.result),r=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),u=r.find(C=>C.id===e.selectedID);u&&((t=e.topViewInstance)==null||t.updatePolygonList(r,void 0),N(u.attribute),q(u),e.setSelectedIDs(u.id)),e.setPointCloudValid((o=index.jsonParser(n.result))==null?void 0:o.valid),e.setPointCloudResult(r),e.setRectList(s),l.generateBoxes(r)}},[n.result,e.mainViewInstance]),React.useEffect(()=>{var t,o,l,s,r,u,C;const b=(t=c==null?void 0:c.info)==null?void 0:t.id;if(!j){_(!0);return}if(b!==void 0){E(lbUtils.EPerspectiveView.Top);const z=(s=(l=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:l.camera.zoom)!=null?s:1;(r=e.mainViewInstance)==null||r.updateCameraZoom(z)}(u=e.mainViewInstance)==null||u.setHighlightColor(b),(C=e.mainViewInstance)==null||C.render()},[(d=c==null?void 0:c.info)==null?void 0:d.id]),React.useEffect(()=>{var t,o,l,s;if(w){E(lbUtils.EPerspectiveView.Top);const r=(l=(o=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:o.camera.zoom)!=null?l:1;(s=e.mainViewInstance)==null||s.updateCameraZoom(r)}},[w]),React.useEffect(()=>(window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S)}),[]);const S=t=>{if(t.keyCode===EKeyCode.Esc){V(!1);return}},T=React.useMemo(()=>({reset3DView:D,setTarget3DView:E,isActive:!!c,followTopView:R}),[c,e.mainViewInstance]);React.useEffect(()=>{var t,o,l;const s=e.pointCloudBoxList.filter(r=>r.attribute===a);(s==null?void 0:s.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(o=e.mainViewInstance)==null||o.highlightBoxes(s)),s.length===0&&((l=e.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[a,e.mainViewInstance]);const k=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:t=>{var o;(o=e.mainViewInstance)==null||o.updatePointSize({customSize:t})}}),React__default.default.createElement("span",{style:{marginRight:8}},g("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:y,onChange:t=>{var o;B(t),(o=e.mainViewInstance)==null||o.setShowDirection(t)}}),f&&React__default.default.createElement(PointCloud3DContext.Provider,{value:T},React__default.default.createElement(PointCloud3DSideBar,{isEnlarge:f})));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-3d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:f}),title:f?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{P(!1),V(!1)}}),g("3DView")):React__default.default.createElement(index$2,{title:g("3DView"),onClick:()=>{P(!0),V(!0)}}),toolbar:k},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},!f&&React__default.default.createElement(PointCloud3DContext.Provider,{value:T},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:v})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
1
+ "use strict";var dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),classNames=require("classnames"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),index=require("../../utils/index.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index$1=require("./components/PointCloudSizeSlider/index.js"),index$2=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons"),useToolStyle=require("../../hooks/useToolStyle.js"),usePointCloudAttribute=require("./hooks/usePointCloudAttribute.js");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,i,a)=>i in n?__defProp(n,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[i]=a,__spreadValues=(n,i)=>{for(var a in i||(i={}))__hasOwnProp.call(i,a)&&__defNormalProp(n,a,i[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(i))__propIsEnum.call(i,a)&&__defNormalProp(n,a,i[a]);return n};const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:n})=>{const{isActive:i,setTarget3DView:a}=React.useContext(PointCloud3DContext),m=d=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",d)]:!0,active:i});return React__default.default.createElement("span",{onClick:()=>{a(lbUtils.EPerspectiveView[n])},className:m(n.toLocaleLowerCase())})},PointCloud3DSideBar=({isEnlarge:n})=>{const{reset3DView:i,followTopView:a}=React.useContext(PointCloud3DContext),{t:m}=reactI18next.useTranslation(),d=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Top"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Front"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Left"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Back"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Right"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"LFT"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"RBT"})),e=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Tooltip,{title:m("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{a()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{i()},className:dom.getClassName("point-cloud-3d-view","reset")}));return n?React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebarZoom")},e,d):React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},d,e)},PointCloud3D=({currentData:n,config:i,highlightAttribute:a,setResourceLoading:m})=>{var d;const e=React.useContext(PointCloudContext.PointCloudContext),{setIsLargeStatus:P}=e,[y,B]=React.useState(!0),[f,V]=React.useState(!1),v=React.useRef(null),{initPointCloud3d:x,generateRects:L}=usePointCloudViews.usePointCloudViews(),p=useSize(v),{t:g}=reactI18next.useTranslation(),{value:I}=useToolStyle.useToolStyleContext(),{hiddenText:h}=I||{},{updatePointCloudAttribute:N}=usePointCloudAttribute.usePointCloudAttribute(m,i),{updateSelectedBox:q}=useSingleBox.useSingleBox({generateRects:L});React.useEffect(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(h,e.pointCloudBoxList)},[I]),React.useEffect(()=>{!e.mainViewInstance||x==null||x(p)},[p]);const{selectedBox:c}=useSingleBox.useSingleBox(),{selectedSphere:w}=useSphere.useSphere(),[j,_]=React.useState(!0),E=t=>{var o,l;const s=c==null?void 0:c.info;if(s){const r=__spreadValues({},s.center);r.x=r.x-.01,r.z=1e3;const u=t===lbUtils.EPerspectiveView.Top;(o=e.mainViewInstance)==null||o.updateCameraByBox(s,t,u?r:void 0)}w&&((l=e.mainViewInstance)==null||l.updateCameraBySphere(w,t))},D=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},R=()=>{var t,o;const l=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;l&&((o=e.mainViewInstance)==null||o.applyCameraTarget(l))};React.useEffect(()=>{if(v.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&p.width&&(t=new lbAnnotation.PointCloud({container:v.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(p),config:i,hiddenText:h,view:"3DView"}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:_}),e.setMainViewInstance(t))}},[p,n]),React.useEffect(()=>{var t,o;if(v.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let l=e.mainViewInstance;const s=lbUtils.PointCloudUtils.getRectParamsFromResultList(n.result),r=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),u=r.find(C=>C.id===e.selectedID);u&&((t=e.topViewInstance)==null||t.updatePolygonList(r,void 0),N(u.attribute),q(u),e.setSelectedIDs(u.id)),e.setPointCloudValid((o=index.jsonParser(n.result))==null?void 0:o.valid),e.setPointCloudResult(r),e.setRectList(s),l.generateBoxes(r)}},[n.result,e.mainViewInstance]),React.useEffect(()=>{var t,o,l,s,r,u,C;const b=(t=c==null?void 0:c.info)==null?void 0:t.id;if(!j){_(!0);return}if(b!==void 0){E(lbUtils.EPerspectiveView.Top);const z=(s=(l=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:l.camera.zoom)!=null?s:1;(r=e.mainViewInstance)==null||r.updateCameraZoom(z)}(u=e.mainViewInstance)==null||u.setHighlightColor(b),(C=e.mainViewInstance)==null||C.render()},[(d=c==null?void 0:c.info)==null?void 0:d.id]),React.useEffect(()=>{var t,o,l,s;if(w){E(lbUtils.EPerspectiveView.Top);const r=(l=(o=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:o.camera.zoom)!=null?l:1;(s=e.mainViewInstance)==null||s.updateCameraZoom(r)}},[w]),React.useEffect(()=>(window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S)}),[]);const S=t=>{if(t.keyCode===EKeyCode.Esc){V(!1);return}},T=React.useMemo(()=>({reset3DView:D,setTarget3DView:E,isActive:!!c,followTopView:R}),[c,e.mainViewInstance]);React.useEffect(()=>{var t,o,l;const s=e.pointCloudBoxList.filter(r=>r.attribute===a);(s==null?void 0:s.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(o=e.mainViewInstance)==null||o.highlightBoxes(s)),s.length===0&&((l=e.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[a,e.mainViewInstance]);const k=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:t=>{var o;(o=e.mainViewInstance)==null||o.updatePointSize({customSize:t})}}),React__default.default.createElement("span",{style:{marginRight:8}},g("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:y,onChange:t=>{var o;B(t),(o=e.mainViewInstance)==null||o.setShowDirection(t)}}),f&&React__default.default.createElement(PointCloud3DContext.Provider,{value:T},React__default.default.createElement(PointCloud3DSideBar,{isEnlarge:f})));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-3d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:f}),title:f?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{P(!1),V(!1)}}),g("3DView")):React__default.default.createElement(index$2,{title:g("3DView"),onClick:()=>{P(!0),V(!0)}}),toolbar:k},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},!f&&React__default.default.createElement(PointCloud3DContext.Provider,{value:T},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:v})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
@@ -1 +1 @@
1
- "use strict";var dom=require("../../utils/dom.js"),index$3=require("../../views/MainView/toolFooter/index.js"),index$4=require("../../views/MainView/toolFooter/ZoomController/index.js"),icons=require("@ant-design/icons"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudInfos=require("./PointCloudInfos.js"),usePolygon=require("./hooks/usePolygon.js"),useSphere=require("./hooks/useSphere.js"),useZoom=require("./hooks/useZoom.js"),antd=require("antd"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index=require("../../utils/index.js"),ToolUtils=require("../../utils/ToolUtils.js"),_=require("lodash"),index$2=require("./components/PointCloudSizeSlider/index.js"),useHistory=require("./hooks/useHistory.js"),index$1=require("./components/TitleButton/index.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,s,l)=>s in o?__defProp(o,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[s]=l,__spreadValues=(o,s)=>{for(var l in s||(s={}))__hasOwnProp.call(s,l)&&__defNormalProp(o,l,s[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(s))__propIsEnum.call(s,l)&&__defNormalProp(o,l,s[l]);return o},__spreadProps=(o,s)=>__defProps(o,__getOwnPropDescs(s));const{EPolygonPattern,EToolName}=lbAnnotation.cTool,{ESortDirection}=lbAnnotation.cAnnotation,EKeyCode=lbAnnotation.cKeyCode.default,TransferCanvas2WorldOffset=(o,s,l=1)=>{const{width:C,height:p}=s,w={x:o.x+C*l/2,y:o.y+p*l/2},x={x:s.width/2,y:s.height/2};return{offsetX:(x.x-w.x)/l,offsetY:-(x.y-w.y)/l}},TopViewToolbar=({currentData:o})=>{var s,l;const{zoom:C,zoomIn:p,zoomOut:w,initialPosition:x}=useZoom.useZoom(),{selectNextBox:L,selectPrevBox:b}=useSingleBox.useSingleBox(),{switchToNextSphere:S}=useSphere.useSphere(),{updateRotate:E}=useRotate.useRotate({currentData:o}),{updateRotateEdge:O}=useRotateEdge.useRotateEdge({currentData:o}),g=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:I}=g,f=(l=(s=g==null?void 0:g.topViewInstance)==null?void 0:s.toolScheduler)==null?void 0:l.getCurrentToolName(),e=()=>{E(-Number(g.rectRotateSensitivity))},u=()=>{E(g.rectRotateSensitivity)},v=()=>{O(-90)};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$2,{onChange:T=>{var y;(y=I==null?void 0:I.pointCloudInstance)==null||y.updatePointSize({customSize:T})}}),React__default.default.createElement("span",{onClick:u,className:dom.getClassName("point-cloud","rotate-reserve")}),React__default.default.createElement("span",{onClick:e,className:dom.getClassName("point-cloud","rotate")}),React__default.default.createElement("span",{onClick:v,className:dom.getClassName("point-cloud","rotate-90")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(icons.UpSquareOutlined,{onClick:()=>{if(f===EToolName.Point){S(ESortDirection.descend);return}b(!0)},className:dom.getClassName("point-cloud","prev")}),React__default.default.createElement(icons.DownSquareOutlined,{onClick:()=>{if(f===EToolName.Point){S(ESortDirection.ascend);return}L(!0)},className:dom.getClassName("point-cloud","next")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(index$4.ZoomController,{initialPosition:x,zoomIn:p,zoomOut:w,zoom:C}))},ZAxisSlider=({setZAxisLimit:o,zAxisLimit:s,checkMode:l})=>l?null:React__default.default.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},React__default.default.createElement(antd.Slider,{vertical:!0,step:.5,max:10,min:.5,defaultValue:s,onAfterChange:C=>{o(C)}})),PointCloudTopView=({currentData:o,imgList:s,stepInfo:l,drawLayerSlot:C,checkMode:p,intelligentFit:w,setIsEnlargeTopView:x,isEnlargeTopView:L,onExitZoom:b,highlightAttribute:S})=>{var E,O;const[g,I]=React.useState({zoom:1,currentPos:{x:0,y:0}}),f=React.useRef(null),e=React.useContext(PointCloudContext.PointCloudContext),u=useSize(f),v=index.jsonParser(l.config),{setZoom:T,syncTopviewToolZoom:y}=useZoom.useZoom(),{hideAttributes:U,setIsLargeStatus:Z,selectedID:z,pointCloudBoxList:H}=e,{addPolygon:F,deletePolygon:W}=usePolygon.usePolygon(),{deletePointCloudSphere:$}=useSphere.useSphere(),{deletePointCloudBox:M,changeValidByID:K}=useSingleBox.useSingleBox(),[B,X]=React.useState(10),{t:D}=reactI18next.useTranslation(),m=usePointCloudViews.usePointCloudViews(),{pushHistoryWithList:Y}=useHistory.useHistory(),[G,q]=React.useState(!0),[N,k]=React.useState(!1);React.useLayoutEffect(()=>{if(!e.topViewInstance&&f.current&&(o==null?void 0:o.url)&&(o==null?void 0:o.result)){const n={width:f.current.clientWidth,height:f.current.clientHeight},r=new lbAnnotation.PointCloudAnnotation({container:f.current,size:n,pcdPath:o.url,config:__spreadProps(__spreadValues({},v),{pointCloudPattern:e.pointCloudPattern}),checkMode:p,toolName:ToolUtils.getPointCloudToolList(),proxyMode:p});e.setTopViewInstance(r)}},[o]),React.useEffect(()=>{N&&z&&(e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single,H),k(!1))},[N]),React.useEffect(()=>{if(!u||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:n}=e.topViewInstance;n.singleOn("dataUpdated",(t,i)=>{const d=___default.default.cloneDeep(t).map(a=>__spreadProps(__spreadValues({},a),{pointList:lbUtils.PointCloudUtils.pointListTransferCanvas2World(a.pointList,u)}));e.setSelectedIDs(i),e.setLineList(d),Y({lineList:d})}),n.singleOn("pointCreated",(t,i)=>{m.topViewAddSphere({newPoint:t,size:u,trackConfigurable:v.trackConfigurable,zoom:i})}),n.singleOn("pointDeleted",t=>{$(t)}),n.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),n.singleOn("updatePointByDrag",(t,i)=>{var d;(d=m.topViewUpdatePoint)==null||d.call(m,t,u)}),n.singleOn("polygonCreated",(t,i)=>{if(n.pattern===EPolygonPattern.Normal||!(o==null?void 0:o.url)){const d=__spreadProps(__spreadValues({},t),{pointList:t.pointList.map(a=>lbUtils.PointCloudUtils.transferCanvas2World(a,u))});F(d),e.setSelectedIDs(U.includes(t.attribute)?"":t.id);return}q(!1),m.topViewAddBox({polygon:t,size:u,imgList:s,trackConfigurable:v.trackConfigurable,zoom:i,intelligentFit:w}),k(!0)}),n.singleOn("deletedObject",({id:t})=>{M(t),W(t)}),n.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),n.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),n.singleOn("setSelectedIDs",t=>{q(!1),e.setSelectedIDs(t)}),n.singleOn("updatePolygonByDrag",t=>{var i;(i=m.topViewUpdateBox)==null||i.call(m,t,u)});const r=t=>{var i;const d=K(t);d&&e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,d),e.polygonList.find(a=>a.id===t)&&((i=e.topViewInstance)==null||i.toolInstance.setPolygonValidAndRender(t,!0))};return n.on("validUpdate",r),()=>{n.unbind("validUpdate",r)}},[e,u,o,m,e.polygonList,e.lineList,(E=e.topViewInstance)==null?void 0:E.toolInstance]),React.useEffect(()=>{var n,r;if(!(u==null?void 0:u.width)||!e.topViewInstance)return;const t=(r=(n=v==null?void 0:v.attributeList)==null?void 0:n[0])==null?void 0:r.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(u),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:i,toolInstance:d}}=e;d.singleOn("renderZoom",(a,c)=>{const{offsetX:h,offsetY:V}=TransferCanvas2WorldOffset(c,u,a);if(i.camera.zoom=a,c){const{x:P,y:j,z:R}=i.initCameraPosition;i.camera.position.set(P+V,j-h,R)}i.camera.updateProjectionMatrix(),i.render(),T(a),y(c,a,u),I({zoom:a,currentPos:c})}),d.singleOn("dragMove",({currentPos:a,zoom:c})=>{const{offsetX:h,offsetY:V}=TransferCanvas2WorldOffset(a,u,c);i.camera.zoom=c;const{x:P,y:j,z:R}=i.initCameraPosition;i.camera.position.set(P+V,j-h,R),i.render(),y(a,c,u),I({zoom:c,currentPos:a})})},[u,e.topViewInstance,(O=e.topViewInstance)==null?void 0:O.toolInstance]),React.useEffect(()=>{var n,r;(r=(n=e.topViewInstance)==null?void 0:n.pointCloudInstance)==null||r.applyZAxisPoints(B)},[B]),React.useEffect(()=>{var n,r,t,i;m.topViewSelectedChanged({}),(i=(t=(r=(n=e.topViewInstance)==null?void 0:n.toolInstance)==null?void 0:r.selection)==null?void 0:t.hardSetSelectedIDs)==null||i.call(t,e.selectedIDs)},[e.selectedIDs]),React.useEffect(()=>{const{topViewInstance:n,selectedID:r,selectedPointCloudBox:t,zoom:i}=e;if(!n||!r||!t||!G){q(!0);return}const{center:d}=t,{pointCloudInstance:a,toolInstance:c}=n,h=c.polygonList.find(Q=>Q.id===e.selectedID);if(!h){q(!0);return}const V=lbAnnotation.MathUtils.getRectCenterPoint(h.pointList),P=lbAnnotation.MathUtils.getCurrentPosFromRectCenter(c.size,V,i);c.setCurrentPos(P),c.render();const{x:j,y:R,z:J}=a.initCameraPosition;a.camera.position.set(d.x,d.y,J),a.render(),y(P,i,u),I({zoom:i,currentPos:P})},[e.selectedID]),React.useEffect(()=>(window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}),[]);const A=n=>{const{keyCode:r}=n;r===EKeyCode.Esc&&b()};return React.useEffect(()=>{var n,r,t;(t=(r=(n=e.topViewInstance)==null?void 0:n.pointCloud2dOperation)==null?void 0:r.setHighlightAttribute)==null||t.call(r,S)},[e.topViewInstance,S]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","top-view"),title:L?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{b()}}),React__default.default.createElement("span",null,D("TopView")),React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:p,config:v,style:{display:"flex",position:"initial",margin:"0px 20px"}})):React__default.default.createElement(index$1,{title:D("TopView"),onClick:()=>{Z(!0),x(!0)}}),toolbar:React__default.default.createElement(TopViewToolbar,{currentData:o})},React__default.default.createElement("div",{style:{position:"relative",flex:1}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"},ref:f},C==null?void 0:C(g)),!L&&React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:p,config:v}),React__default.default.createElement(ZAxisSlider,{checkMode:p,zAxisLimit:B,setZAxisLimit:X}),React__default.default.createElement(PointCloudInfos.PointCloudValidity,null)))};var PointCloudTopView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudTopView);module.exports=PointCloudTopView$1;
1
+ "use strict";var dom=require("../../utils/dom.js"),index$3=require("../../views/MainView/toolFooter/index.js"),index$4=require("../../views/MainView/toolFooter/ZoomController/index.js"),icons=require("@ant-design/icons"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudInfos=require("./PointCloudInfos.js"),usePolygon=require("./hooks/usePolygon.js"),useSphere=require("./hooks/useSphere.js"),useZoom=require("./hooks/useZoom.js"),antd=require("antd"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index=require("../../utils/index.js"),ToolUtils=require("../../utils/ToolUtils.js"),_=require("lodash"),index$2=require("./components/PointCloudSizeSlider/index.js"),useHistory=require("./hooks/useHistory.js"),index$1=require("./components/TitleButton/index.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,s,l)=>s in o?__defProp(o,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[s]=l,__spreadValues=(o,s)=>{for(var l in s||(s={}))__hasOwnProp.call(s,l)&&__defNormalProp(o,l,s[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(s))__propIsEnum.call(s,l)&&__defNormalProp(o,l,s[l]);return o},__spreadProps=(o,s)=>__defProps(o,__getOwnPropDescs(s));const{EPolygonPattern,EToolName}=lbAnnotation.cTool,{ESortDirection}=lbAnnotation.cAnnotation,EKeyCode=lbAnnotation.cKeyCode.default,TransferCanvas2WorldOffset=(o,s,l=1)=>{const{width:C,height:p}=s,w={x:o.x+C*l/2,y:o.y+p*l/2},x={x:s.width/2,y:s.height/2};return{offsetX:(x.x-w.x)/l,offsetY:-(x.y-w.y)/l}},TopViewToolbar=({currentData:o})=>{var s,l;const{zoom:C,zoomIn:p,zoomOut:w,initialPosition:x}=useZoom.useZoom(),{selectNextBox:L,selectPrevBox:b}=useSingleBox.useSingleBox(),{switchToNextSphere:S}=useSphere.useSphere(),{updateRotate:V}=useRotate.useRotate({currentData:o}),{updateRotateEdge:O}=useRotateEdge.useRotateEdge({currentData:o}),g=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:I}=g,f=(l=(s=g==null?void 0:g.topViewInstance)==null?void 0:s.toolScheduler)==null?void 0:l.getCurrentToolName(),e=()=>{V(-Number(g.rectRotateSensitivity))},u=()=>{V(g.rectRotateSensitivity)},v=()=>{O(-90)};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$2,{onChange:T=>{var y;(y=I==null?void 0:I.pointCloudInstance)==null||y.updatePointSize({customSize:T})}}),React__default.default.createElement("span",{onClick:u,className:dom.getClassName("point-cloud","rotate-reserve")}),React__default.default.createElement("span",{onClick:e,className:dom.getClassName("point-cloud","rotate")}),React__default.default.createElement("span",{onClick:v,className:dom.getClassName("point-cloud","rotate-90")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(icons.UpSquareOutlined,{onClick:()=>{if(f===EToolName.Point){S(ESortDirection.descend);return}b(!0)},className:dom.getClassName("point-cloud","prev")}),React__default.default.createElement(icons.DownSquareOutlined,{onClick:()=>{if(f===EToolName.Point){S(ESortDirection.ascend);return}L(!0)},className:dom.getClassName("point-cloud","next")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(index$4.ZoomController,{initialPosition:x,zoomIn:p,zoomOut:w,zoom:C}))},ZAxisSlider=({setZAxisLimit:o,zAxisLimit:s,checkMode:l})=>l?null:React__default.default.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},React__default.default.createElement(antd.Slider,{vertical:!0,step:.5,max:10,min:.5,defaultValue:s,onAfterChange:C=>{o(C)}})),PointCloudTopView=({currentData:o,imgList:s,stepInfo:l,drawLayerSlot:C,checkMode:p,intelligentFit:w,setIsEnlargeTopView:x,isEnlargeTopView:L,onExitZoom:b,highlightAttribute:S})=>{var V,O;const[g,I]=React.useState({zoom:1,currentPos:{x:0,y:0}}),f=React.useRef(null),e=React.useContext(PointCloudContext.PointCloudContext),u=useSize(f),v=index.jsonParser(l.config),{setZoom:T,syncTopviewToolZoom:y}=useZoom.useZoom(),{hideAttributes:U,setIsLargeStatus:Z,selectedID:z,pointCloudBoxList:H}=e,{addPolygon:F,deletePolygon:W}=usePolygon.usePolygon(),{deletePointCloudSphere:$}=useSphere.useSphere(),{deletePointCloudBox:M,changeValidByID:K}=useSingleBox.useSingleBox(),[B,X]=React.useState(10),{t:D}=reactI18next.useTranslation(),m=usePointCloudViews.usePointCloudViews(),{pushHistoryWithList:Y}=useHistory.useHistory(),[G,q]=React.useState(!0),[N,k]=React.useState(!1);React.useLayoutEffect(()=>{if(!e.topViewInstance&&f.current&&(o==null?void 0:o.url)&&(o==null?void 0:o.result)){const n={width:f.current.clientWidth,height:f.current.clientHeight},r=new lbAnnotation.PointCloudAnnotation({container:f.current,size:n,pcdPath:o.url,config:__spreadProps(__spreadValues({},v),{pointCloudPattern:e.pointCloudPattern}),checkMode:p,toolName:ToolUtils.getPointCloudToolList(),proxyMode:p,view:"topView"});e.setTopViewInstance(r)}},[o]),React.useEffect(()=>{N&&z&&(e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single,H),k(!1))},[N]),React.useEffect(()=>{if(!u||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:n}=e.topViewInstance;n.singleOn("dataUpdated",(t,i)=>{const d=___default.default.cloneDeep(t).map(a=>__spreadProps(__spreadValues({},a),{pointList:lbUtils.PointCloudUtils.pointListTransferCanvas2World(a.pointList,u)}));e.setSelectedIDs(i),e.setLineList(d),Y({lineList:d})}),n.singleOn("pointCreated",(t,i)=>{m.topViewAddSphere({newPoint:t,size:u,trackConfigurable:v.trackConfigurable,zoom:i})}),n.singleOn("pointDeleted",t=>{$(t)}),n.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),n.singleOn("updatePointByDrag",(t,i)=>{var d;(d=m.topViewUpdatePoint)==null||d.call(m,t,u)}),n.singleOn("polygonCreated",(t,i)=>{if(n.pattern===EPolygonPattern.Normal||!(o==null?void 0:o.url)){const d=__spreadProps(__spreadValues({},t),{pointList:t.pointList.map(a=>lbUtils.PointCloudUtils.transferCanvas2World(a,u))});F(d),e.setSelectedIDs(U.includes(t.attribute)?"":t.id);return}q(!1),m.topViewAddBox({polygon:t,size:u,imgList:s,trackConfigurable:v.trackConfigurable,zoom:i,intelligentFit:w}),k(!0)}),n.singleOn("deletedObject",({id:t})=>{M(t),W(t)}),n.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),n.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),n.singleOn("setSelectedIDs",t=>{q(!1),e.setSelectedIDs(t)}),n.singleOn("updatePolygonByDrag",t=>{var i;(i=m.topViewUpdateBox)==null||i.call(m,t,u)});const r=t=>{var i;const d=K(t);d&&e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,d),e.polygonList.find(a=>a.id===t)&&((i=e.topViewInstance)==null||i.toolInstance.setPolygonValidAndRender(t,!0))};return n.on("validUpdate",r),()=>{n.unbind("validUpdate",r)}},[e,u,o,m,e.polygonList,e.lineList,(V=e.topViewInstance)==null?void 0:V.toolInstance]),React.useEffect(()=>{var n,r;if(!(u==null?void 0:u.width)||!e.topViewInstance)return;const t=(r=(n=v==null?void 0:v.attributeList)==null?void 0:n[0])==null?void 0:r.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(u),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:i,toolInstance:d}}=e;d.singleOn("renderZoom",(a,c)=>{const{offsetX:h,offsetY:E}=TransferCanvas2WorldOffset(c,u,a);if(i.camera.zoom=a,c){const{x:P,y:j,z:R}=i.initCameraPosition;i.camera.position.set(P+E,j-h,R)}i.camera.updateProjectionMatrix(),i.render(),T(a),y(c,a,u),I({zoom:a,currentPos:c})}),d.singleOn("dragMove",({currentPos:a,zoom:c})=>{const{offsetX:h,offsetY:E}=TransferCanvas2WorldOffset(a,u,c);i.camera.zoom=c;const{x:P,y:j,z:R}=i.initCameraPosition;i.camera.position.set(P+E,j-h,R),i.render(),y(a,c,u),I({zoom:c,currentPos:a})})},[u,e.topViewInstance,(O=e.topViewInstance)==null?void 0:O.toolInstance]),React.useEffect(()=>{var n,r;(r=(n=e.topViewInstance)==null?void 0:n.pointCloudInstance)==null||r.applyZAxisPoints(B)},[B]),React.useEffect(()=>{var n,r,t,i;m.topViewSelectedChanged({}),(i=(t=(r=(n=e.topViewInstance)==null?void 0:n.toolInstance)==null?void 0:r.selection)==null?void 0:t.hardSetSelectedIDs)==null||i.call(t,e.selectedIDs)},[e.selectedIDs]),React.useEffect(()=>{const{topViewInstance:n,selectedID:r,selectedPointCloudBox:t,zoom:i}=e;if(!n||!r||!t||!G){q(!0);return}const{center:d}=t,{pointCloudInstance:a,toolInstance:c}=n,h=c.polygonList.find(Q=>Q.id===e.selectedID);if(!h){q(!0);return}const E=lbAnnotation.MathUtils.getRectCenterPoint(h.pointList),P=lbAnnotation.MathUtils.getCurrentPosFromRectCenter(c.size,E,i);c.setCurrentPos(P),c.render();const{x:j,y:R,z:J}=a.initCameraPosition;a.camera.position.set(d.x,d.y,J),a.render(),y(P,i,u),I({zoom:i,currentPos:P})},[e.selectedID]),React.useEffect(()=>(window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}),[]);const A=n=>{const{keyCode:r}=n;r===EKeyCode.Esc&&b()};return React.useEffect(()=>{var n,r,t;(t=(r=(n=e.topViewInstance)==null?void 0:n.pointCloud2dOperation)==null?void 0:r.setHighlightAttribute)==null||t.call(r,S)},[e.topViewInstance,S]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","top-view"),title:L?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{b()}}),React__default.default.createElement("span",null,D("TopView")),React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:p,config:v,style:{display:"flex",position:"initial",margin:"0px 20px"}})):React__default.default.createElement(index$1,{title:D("TopView"),onClick:()=>{Z(!0),x(!0)}}),toolbar:React__default.default.createElement(TopViewToolbar,{currentData:o})},React__default.default.createElement("div",{style:{position:"relative",flex:1}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"},ref:f},C==null?void 0:C(g)),!L&&React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:p,config:v}),React__default.default.createElement(ZAxisSlider,{checkMode:p,zAxisLimit:B,setZAxisLimit:X}),React__default.default.createElement(PointCloudInfos.PointCloudValidity,null)))};var PointCloudTopView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudTopView);module.exports=PointCloudTopView$1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),_=require("lodash"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,n,t)=>n in o?__defProp(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,__spreadValues=(o,n)=>{for(var t in n||(n={}))__hasOwnProp.call(n,t)&&__defNormalProp(o,t,n[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(n))__propIsEnum.call(n,t)&&__defNormalProp(o,t,n[t]);return o},__spreadProps=(o,n)=>__defProps(o,__getOwnPropDescs(n)),__async=(o,n,t)=>new Promise((a,p)=>{var e=d=>{try{c(t.next(d))}catch(x){p(x)}},P=d=>{try{c(t.throw(d))}catch(x){p(x)}},c=d=>d.done?a(d.value):Promise.resolve(d.value).then(e,P);c((t=t.apply(o,n)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,n,t,a,p)=>{const{x:e,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,n),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:e,y:P,z:c},id:o.id},x=a?__spreadValues(__spreadValues({},a),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},topViewPolygon2PointCloud=(o,n,t,a,p,e)=>{let P=o.pointList.map(w=>lbUtils.PointCloudUtils.transferCanvas2World(w,n)),c=0,d=1,x={};if(t){const w=t.getSensesPointZAxisInPolygon(P,void 0,e);e&&w.fittedCoordinates.length>0&&(P=w.fittedCoordinates),c=(w.maxZ+w.minZ)/2,d=w.maxZ-w.minZ,x={count:w.zCount}}const[f,v,R]=P,I=lbAnnotation.MathUtils.getLineCenterPoint([f,R]),S=lbAnnotation.MathUtils.getLineLength(f,v),V=lbAnnotation.MathUtils.getLineLength(v,R),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);a&&(c=a.center.z,d=a.depth);const T={center:{x:I.x,y:I.y,z:c},width:e?V+INTELLIGENT_FIT_MARGIN:V,height:e?S+INTELLIGENT_FIT_MARGIN:S,depth:d,rotation:k,id:o.id},A=__spreadValues(a?__spreadValues(__spreadValues({},a),T):__spreadProps(__spreadValues({},T),{attribute:"",valid:!0}),x);p&&Object.assign(A,p);const O=P.map(w=>lbUtils.PointCloudUtils.transferWorld2Canvas(w,n));return{boxParams:A,newPointList:O}},sideViewPoint2PointCloud=(o,n,t)=>{const a={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-a.x,y:t.center.y,z:t.center.z-a.y}})},sideViewPolygon2PointCloud=(o,n,t,a)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),v=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),I={x:{x:f.x-v.x,y:f.y-v.y}.x,y:0,z:f.y-v.y},S=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),k=S-V,T=lbAnnotation.MathUtils.getLineLength(e,P),A=lbAnnotation.MathUtils.getLineLength(d,x),O=T-A,{newBoxParams:w}=a.getNewBoxBySideUpdate(I,O,k,t);return w},backViewPoint2PointCloud=(o,n,t)=>{const a={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x,y:t.center.y-a.x,z:t.center.z-a.y}})},backViewPolygon2PointCloud=(o,n,t,a)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),v=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),I={x:{x:f.x-v.x,y:f.y-v.y}.x,y:0,z:f.y-v.y},S=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),k=S-V,T=lbAnnotation.MathUtils.getLineLength(e,P),A=lbAnnotation.MathUtils.getLineLength(d,x),O=T-A;let{newBoxParams:w}=a.getNewBoxByBackUpdate(I,O,k,t);return w},syncSideViewByPoint=(o,n,t,a,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(a,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(d);const{point2d:x,zoom:f}=c.getSphereSidePoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},n),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},synchronizeSideView=(o,n,t,a)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(a,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);e.setInitCameraPosition(P);const{polygon2d:c,zoom:d}=e.getBoxSidePolygon2DCoordinate(o);e.camera.zoom=d,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncBackViewByPoint=(o,n,t,a,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(a,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(d);const{point2d:x,zoom:f}=c.getSphereBackPoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},n),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},synchronizeBackView=(o,n,t,a)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(a,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);e.setInitCameraPosition(P);const{polygon2d:c,zoom:d}=e.getBoxBackPolygon2DCoordinate(o);e.camera.zoom=d,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncTopViewByPoint=(o,n,t,a)=>{if(!t||!a)return;a.generateSphere(o),a.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:p,pointCloudInstance:e}=t,{point2d:P}=e.getSphereTopPoint2DCoordinate(o),c=[...p.pointList].map(d=>d.id===n.id?__spreadProps(__spreadValues(__spreadValues({},n),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):d);p.setResult(c),p.setSelectedID(n.id)},synchronizeTopView=(o,n,t,a)=>{var p,e;if(!t||!a)return;a.generateBox(o),a.setHighlightColor(o.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=t,{polygon2d:d}=c.getBoxTopPolygon2DCoordinate(o),x=[...P.polygonList],f=x.find(v=>v.id===n.id);f?(f.pointList=d,f.valid=(p=o.valid)!=null?p:!0):x.push({id:n.id,pointList:d,textAttribute:"",isRect:!0,valid:(e=o.valid)!=null?e:!0}),P.setResultAndSelectedID(x,n.id)},usePointCloudViews=o=>{const n=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:a,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:d,selectedIDs:x,pointCloudBoxList:f,pointCloudSphereList:v,hideAttributes:R,setHighlight2DDataList:I,cuboidBoxIn2DView:S,imageSizes:V,history:k,linkageImageNameRectMap:T}=n,{addHistory:A,initHistory:O,pushHistoryUnderUpdatePolygon:w}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:nt,updatePointCloudSphere:X,selectedSphere:F}=useSphere.useSphere(),{currentData:E,config:y}=ctx.useSelector(s=>{const{stepList:i,step:u,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:index.jsonParser(StepUtils.getCurrentStepInfo(u,i).config)}}),M=ctx.useDispatch(),it=ahooks.useLatest(S),st=ahooks.useLatest(T),rt=React.useCallback((s,i)=>{const u=st.current,l=i.id;return s.filter(r=>{if(!r)return!1;const h=u.get(r.imageName);return h===void 0?!0:Boolean(h.get(l))})},[]),Z=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!it.current||i){const{mappingImgList:u=[]}=E;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:u,imageSizes:V},{prepareRectsFn:rt})}},{selectedBox:U,updateSelectedBox:lt,updateSelectedBoxes:G,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:Z}),Y=U==null?void 0:U.info;if(!t||!a||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:J}=t,dt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},ut=({newPoint:s,size:i,zoom:u,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const h=topViewPoint2PointCloud(s,i,J,void 0,r);d(s.id);const C=c(h);H(PointCloudView.Top,s,h,u,C,y),A({newSphereParams:h})},ct=({polygon:s,size:i,imgList:u,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var h,C,b;const D={attribute:(h=t.toolInstance.defaultAttribute)!=null?h:""};l===!0&&Object.assign(D,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:v})}),t==null||t.toolInstance;const L=__spreadValues({},s);let{boxParams:B,newPointList:m}=topViewPolygon2PointCloud(L,i,J,void 0,D,r);B=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[B],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(m==null?void 0:m.length)&&(L.pointList=m);const N=R.includes(L.attribute);Z(B);const z=P(B),Q=(C=n==null?void 0:n.polygonList)!=null?C:[];B.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(b=y==null?void 0:y.inputList)!=null?b:[]:[]),t==null||t.updatePolygonList(z!=null?z:[],Q),N?d([]):(d(B.id),r&&synchronizeTopView(B,L,t,e)),A({newBoxParams:B})},pt=s=>{const{boxID:i,imageName:u,width:l,height:g,x:r,y:h}=s,C=f.find(m=>m.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(m=>m.imageName===u))return;const D=C.rects.map(m=>m.imageName===u?__spreadProps(__spreadValues({},m),{width:l,height:g,x:r,y:h}):m),L=__spreadProps(__spreadValues({},C),{rects:D}),B=f.map(m=>m.id===i?L:m);return t==null||t.updatePolygonList(B!=null?B:[]),B},gt=s=>{const{boxID:i,imageName:u}=s,l=f.find(C=>C.id===i);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==u),r=__spreadProps(__spreadValues({},l),{rects:g}),h=f.map(C=>C.id===i?r:C);return t==null||t.updatePolygonList(h!=null?h:[]),h},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:u,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(x.length===0||!r)){if(s||(U==null?void 0:U.info)){const h=s!=null?s:U==null?void 0:U.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(x[0]);const C=r.selectedPolygon;if(x.length===1&&h){q({omitView:PointCloudView.Top,polygon:C,boxParams:h,newPointCloudBoxList:i});return}}if((u||F)&&x.length===1){const h=u!=null?u:F;r.setSelectedID(x[0]);const C=r.selectedPoint;h&&H(PointCloudView.Top,C,h,void 0,l,y)}}},K=(s,i,u,l=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{if(Y){let g,r;switch(u){case PointCloudView.Back:g=backViewPolygon2PointCloud;break;case PointCloudView.Side:g=sideViewPolygon2PointCloud;break;default:g=sideViewPolygon2PointCloud;break}if(r=g(s,i,Y,a.pointCloudInstance),e){const{count:L}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:L})}const C=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],b=r.valid!==C.valid;r=C;const D=lt(r);return r=D.find(L=>L.id===r.id),q({omitView:b?void 0:u,polygon:s,boxParams:r,newPointCloudBoxList:D},l),D}},$=(s,i,u)=>{if(F){let l,g;switch(u){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}g=l(s,i,F);const r=X(g);return H(u,s,g,void 0,r,y),r}},Ct=(s,i)=>{$(s,i,PointCloudView.Side)},ft=(s,i)=>{$(s,i,PointCloudView.Back)},ht=(s,i)=>{K(s,i,PointCloudView.Side,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},xt=(s,i)=>{K(s,i,PointCloudView.Back,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},vt=(s,i)=>{const u=nt(s.id),l=topViewPoint2PointCloud(s,i,J,u),g=X(l);H(PointCloudView.Top,s,l,void 0,g,y)},Lt=(s,i)=>{if(ot){const l=__spreadValues({},s[0].newPolygon);l.pointList=l.pointList.map(g=>lbUtils.PointCloudUtils.transferCanvas2World(g,i)),w(l);return}let u=s.map(({newPolygon:l})=>{const g=at(l.id),{boxParams:r}=topViewPolygon2PointCloud(l,i,t.pointCloudInstance,g);return r});if(u=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:u,stepConfig:y,action:"viewUpdateBox"})),u.length===1){const{newPolygon:l}=s[0],g=G(u);q({polygon:l,boxParams:u[0],newPointCloudBoxList:g},ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)}else{const l=G(u);l&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,l)}},yt=s=>{var i,u,l,g,r;if(U){const h=Number(s.widthDefault),C=Number(s.depthDefault),b=Number(s.heightDefault),D=U==null?void 0:U.info.trackID,B=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(W=>(W==null?void 0:W.trackID)===D),m={width:(l=(u=t==null?void 0:t.toolInstance)==null?void 0:u.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},j=B.pointList.map(W=>lbUtils.PointCloudUtils.transferCanvas2World(W,m)),N=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(j,b,h),z=N[0],Q=N[2],tt=lbAnnotation.MathUtils.getLineCenterPoint([z,Q]),mt=U.info.center.z-U.info.depth/2,et=__spreadProps(__spreadValues({},U.info),{center:{x:tt.x,y:tt.y,z:mt+C/2},width:h,height:b,depth:C,valid:!0}),Bt=G([et]);q({omitView:PointCloudView["3D"],polygon:B,boxParams:et,newPointCloudBoxList:Bt})}},H=(s,i,u,l,g,r)=>__async(void 0,null,function*(){const h=E==null?void 0:E.url,C={[PointCloudView.Side]:()=>{syncSideViewByPoint(u,i,a,h,r)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(u,i,p,h,r)},[PointCloudView.Top]:()=>{syncTopViewByPoint(u,i,t,e)}};Object.keys(C).forEach(b=>{b!==s&&C[b]()}),l&&(e==null||e.updateCameraZoom(l)),dt(u)}),q=(s,i=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:u,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:h}=s,C=E==null?void 0:E.url;h&&n.syncAllViewPointCloudColor(i,h);const b={[PointCloudView.Side]:()=>{synchronizeSideView(g,l,a,C)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(g,l,p,C)},[PointCloudView.Top]:()=>{synchronizeTopView(g,l,t,e)}};Object.keys(b).forEach(D=>{D!==u&&b[D]()}),r&&(e==null||e.updateCameraZoom(r))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:ht,backViewUpdateBox:xt,syncPointCloudViews:q,syncPointCloudPoint:H,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),e==null||e.generateBoxes(s)},initPointCloud3d:s=>{if(!e)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(s);e.initOrthographicCamera(i),e.initRenderer(),e.render()},updatePointCloudData:(...s)=>__async(void 0,[...s],function*(i=E){var u,l,g,r,h,C,b,D;if(!(i==null?void 0:i.url)||!e)return;I([]),actionCreators.SetAnnotationLoading(M,!0),actionCreators.SetLoadPCDFileLoading(M,!0),(u=o==null?void 0:o.setResourceLoading)==null||u.call(o,!0),yield e.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:DEFAULT_RADIUS),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let L=[],B=[],m=[],j=[];e.updateTopCamera();const N=(r=(g=index.jsonParser(i.result))==null?void 0:g.valid)!=null?r:!0;if(n.setPointCloudValid(N),(h=n.sideViewInstance)==null||h.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(L=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(L==null?void 0:L.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){L=yield e==null?void 0:e.filterPreResult(i.url,y,L);const z=index.jsonParser(i.result);z[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=L,i.result=JSON.stringify(z),n.setPointCloudResult(L)}m=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),B=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),j=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(b=y==null?void 0:y.radius)!=null?b:DEFAULT_RADIUS}),e==null||e.generateBoxes(L),e==null||e.generateSpheres(j),yield n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,L,[])}O({pointCloudBoxList:L,polygonList:m,lineList:B,pointCloudSphereList:j}),actionCreators.SetAnnotationLoading(M,!1),actionCreators.SetLoadPCDFileLoading(M,!1),(D=o==null?void 0:o.setResourceLoading)==null||D.call(o,!1)}),updateViewsByDefaultSize:yt,generateRects:Z,update2DViewRect:pt,remove2DViewRect:gt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:n,setPointCloudResult:t}=React.useContext(PointCloudContext.PointCloudContext),a=ahooks.useLatest(o),p=ahooks.useLatest(n);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=a.current,c=p.current;if(c.length===0)return null;const d=new Map,x=new Set;if(c.filter(f=>f.extId!==void 0).forEach(f=>{const v=f.extId,R=f.imageName,I=_.pick(f,["x","y","width","height"]);let S=d.get(v);S||(S=new Map,d.set(v,S)),S.set(R,I),x.add(v)}),d.size){const f=P.map(v=>{var R;const I=v.id;if(x.has(I)){const S=__spreadValues({},v);return(R=S.rects)==null||R.forEach(V=>{var k;const T=V.imageName;Object.assign(V,(k=d.get(I))==null?void 0:k.get(T))}),S}return v});return t(f),f}return null},[])}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews,exports.useSyncRectPositionDimensionToPointCloudList=useSyncRectPositionDimensionToPointCloudList;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),_=require("lodash"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,n,t)=>n in o?__defProp(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,__spreadValues=(o,n)=>{for(var t in n||(n={}))__hasOwnProp.call(n,t)&&__defNormalProp(o,t,n[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(n))__propIsEnum.call(n,t)&&__defNormalProp(o,t,n[t]);return o},__spreadProps=(o,n)=>__defProps(o,__getOwnPropDescs(n)),__async=(o,n,t)=>new Promise((a,p)=>{var e=d=>{try{c(t.next(d))}catch(x){p(x)}},P=d=>{try{c(t.throw(d))}catch(x){p(x)}},c=d=>d.done?a(d.value):Promise.resolve(d.value).then(e,P);c((t=t.apply(o,n)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,n,t,a,p)=>{const{x:e,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,n),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:e,y:P,z:c},id:o.id},x=a?__spreadValues(__spreadValues({},a),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},topViewPolygon2PointCloud=(o,n,t,a,p,e)=>{let P=o.pointList.map(w=>lbUtils.PointCloudUtils.transferCanvas2World(w,n)),c=0,d=1,x={};if(t){const w=t.getSensesPointZAxisInPolygon(P,void 0,e);e&&w.fittedCoordinates.length>0&&(P=w.fittedCoordinates),c=(w.maxZ+w.minZ)/2,d=w.maxZ-w.minZ,x={count:w.zCount}}const[f,v,R]=P,I=lbAnnotation.MathUtils.getLineCenterPoint([f,R]),S=lbAnnotation.MathUtils.getLineLength(f,v),V=lbAnnotation.MathUtils.getLineLength(v,R),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);a&&(c=a.center.z,d=a.depth);const T={center:{x:I.x,y:I.y,z:c},width:e?V+INTELLIGENT_FIT_MARGIN:V,height:e?S+INTELLIGENT_FIT_MARGIN:S,depth:d,rotation:k,id:o.id},A=__spreadValues(a?__spreadValues(__spreadValues({},a),T):__spreadProps(__spreadValues({},T),{attribute:"",valid:!0}),x);p&&Object.assign(A,p);const O=P.map(w=>lbUtils.PointCloudUtils.transferWorld2Canvas(w,n));return{boxParams:A,newPointList:O}},sideViewPoint2PointCloud=(o,n,t)=>{const a={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-a.x,y:t.center.y,z:t.center.z-a.y}})},sideViewPolygon2PointCloud=(o,n,t,a)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),v=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),I={x:{x:f.x-v.x,y:f.y-v.y}.x,y:0,z:f.y-v.y},S=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),k=S-V,T=lbAnnotation.MathUtils.getLineLength(e,P),A=lbAnnotation.MathUtils.getLineLength(d,x),O=T-A,{newBoxParams:w}=a.getNewBoxBySideUpdate(I,O,k,t);return w},backViewPoint2PointCloud=(o,n,t)=>{const a={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x,y:t.center.y-a.x,z:t.center.z-a.y}})},backViewPolygon2PointCloud=(o,n,t,a)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),v=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),I={x:{x:f.x-v.x,y:f.y-v.y}.x,y:0,z:f.y-v.y},S=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),k=S-V,T=lbAnnotation.MathUtils.getLineLength(e,P),A=lbAnnotation.MathUtils.getLineLength(d,x),O=T-A;let{newBoxParams:w}=a.getNewBoxByBackUpdate(I,O,k,t);return w},syncSideViewByPoint=(o,n,t,a,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(a,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(d);const{point2d:x,zoom:f}=c.getSphereSidePoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},n),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},synchronizeSideView=(o,n,t,a)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(a,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);e.setInitCameraPosition(P);const{polygon2d:c,zoom:d}=e.getBoxSidePolygon2DCoordinate(o);e.camera.zoom=d,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncBackViewByPoint=(o,n,t,a,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(a,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(d);const{point2d:x,zoom:f}=c.getSphereBackPoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},n),x),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},synchronizeBackView=(o,n,t,a)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(a,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);e.setInitCameraPosition(P);const{polygon2d:c,zoom:d}=e.getBoxBackPolygon2DCoordinate(o);e.camera.zoom=d,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncTopViewByPoint=(o,n,t,a)=>{if(!t||!a)return;a.generateSphere(o),a.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:p,pointCloudInstance:e}=t,{point2d:P}=e.getSphereTopPoint2DCoordinate(o),c=[...p.pointList].map(d=>d.id===n.id?__spreadProps(__spreadValues(__spreadValues({},n),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):d);p.setResult(c),p.setSelectedID(n.id)},synchronizeTopView=(o,n,t,a)=>{var p,e;if(!t||!a)return;a.generateBox(o),a.setHighlightColor(o.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=t,{polygon2d:d}=c.getBoxTopPolygon2DCoordinate(o),x=[...P.polygonList],f=x.find(v=>v.id===n.id);f?(f.pointList=d,f.valid=(p=o.valid)!=null?p:!0):x.push({id:n.id,pointList:d,textAttribute:"",isRect:!0,valid:(e=o.valid)!=null?e:!0}),P.setResultAndSelectedID(x,n.id)},usePointCloudViews=o=>{const n=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:a,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:d,selectedIDs:x,pointCloudBoxList:f,pointCloudSphereList:v,hideAttributes:R,setHighlight2DDataList:I,cuboidBoxIn2DView:S,imageSizes:V,history:k,linkageImageNameRectMap:T}=n,{addHistory:A,initHistory:O,pushHistoryUnderUpdatePolygon:w}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:nt,updatePointCloudSphere:X,selectedSphere:F}=useSphere.useSphere(),{currentData:E,config:y}=ctx.useSelector(s=>{const{stepList:i,step:u,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:index.jsonParser(StepUtils.getCurrentStepInfo(u,i).config)}}),M=ctx.useDispatch(),it=ahooks.useLatest(S),st=ahooks.useLatest(T),rt=React.useCallback((s,i)=>{const u=st.current,l=i.id;return s.filter(r=>{if(!r)return!1;const h=u.get(r.imageName);return h===void 0?!0:Boolean(h.get(l))})},[]),Z=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!it.current||i){const{mappingImgList:u=[]}=E;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:u,imageSizes:V},{prepareRectsFn:rt})}},{selectedBox:U,updateSelectedBox:lt,updateSelectedBoxes:G,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:Z}),Y=U==null?void 0:U.info;if(!t||!a||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:J}=t,dt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},ut=({newPoint:s,size:i,zoom:u,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const h=topViewPoint2PointCloud(s,i,J,void 0,r);d(s.id);const C=c(h);H(PointCloudView.Top,s,h,u,C,y),A({newSphereParams:h})},ct=({polygon:s,size:i,imgList:u,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var h,C,b;const D={attribute:(h=t.toolInstance.defaultAttribute)!=null?h:""};l===!0&&Object.assign(D,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:v})}),t==null||t.toolInstance;const L=__spreadValues({},s);let{boxParams:B,newPointList:m}=topViewPolygon2PointCloud(L,i,J,void 0,D,r);B=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[B],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(m==null?void 0:m.length)&&(L.pointList=m);const N=R.includes(L.attribute);Z(B);const z=P(B),Q=(C=n==null?void 0:n.polygonList)!=null?C:[];B.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(b=y==null?void 0:y.inputList)!=null?b:[]:[]),t==null||t.updatePolygonList(z!=null?z:[],Q,!1),N?d([]):(d(B.id),r&&synchronizeTopView(B,L,t,e)),A({newBoxParams:B})},pt=s=>{const{boxID:i,imageName:u,width:l,height:g,x:r,y:h}=s,C=f.find(m=>m.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(m=>m.imageName===u))return;const D=C.rects.map(m=>m.imageName===u?__spreadProps(__spreadValues({},m),{width:l,height:g,x:r,y:h}):m),L=__spreadProps(__spreadValues({},C),{rects:D}),B=f.map(m=>m.id===i?L:m);return t==null||t.updatePolygonList(B!=null?B:[]),B},gt=s=>{const{boxID:i,imageName:u}=s,l=f.find(C=>C.id===i);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==u),r=__spreadProps(__spreadValues({},l),{rects:g}),h=f.map(C=>C.id===i?r:C);return t==null||t.updatePolygonList(h!=null?h:[]),h},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:u,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(x.length===0||!r)){if(s||(U==null?void 0:U.info)){const h=s!=null?s:U==null?void 0:U.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(x[0]);const C=r.selectedPolygon;if(x.length===1&&h){q({omitView:PointCloudView.Top,polygon:C,boxParams:h,newPointCloudBoxList:i});return}}if((u||F)&&x.length===1){const h=u!=null?u:F;r.setSelectedID(x[0]);const C=r.selectedPoint;h&&H(PointCloudView.Top,C,h,void 0,l,y)}}},K=(s,i,u,l=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{if(Y){let g,r;switch(u){case PointCloudView.Back:g=backViewPolygon2PointCloud;break;case PointCloudView.Side:g=sideViewPolygon2PointCloud;break;default:g=sideViewPolygon2PointCloud;break}if(r=g(s,i,Y,a.pointCloudInstance),e){const{count:L}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:L})}const C=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],b=r.valid!==C.valid;r=C;const D=lt(r);return r=D.find(L=>L.id===r.id),q({omitView:b?void 0:u,polygon:s,boxParams:r,newPointCloudBoxList:D},l),D}},$=(s,i,u)=>{if(F){let l,g;switch(u){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}g=l(s,i,F);const r=X(g);return H(u,s,g,void 0,r,y),r}},Ct=(s,i)=>{$(s,i,PointCloudView.Side)},ft=(s,i)=>{$(s,i,PointCloudView.Back)},ht=(s,i)=>{K(s,i,PointCloudView.Side,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},xt=(s,i)=>{K(s,i,PointCloudView.Back,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},vt=(s,i)=>{const u=nt(s.id),l=topViewPoint2PointCloud(s,i,J,u),g=X(l);H(PointCloudView.Top,s,l,void 0,g,y)},Lt=(s,i)=>{if(ot){const l=__spreadValues({},s[0].newPolygon);l.pointList=l.pointList.map(g=>lbUtils.PointCloudUtils.transferCanvas2World(g,i)),w(l);return}let u=s.map(({newPolygon:l})=>{const g=at(l.id),{boxParams:r}=topViewPolygon2PointCloud(l,i,t.pointCloudInstance,g);return r});if(u=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:u,stepConfig:y,action:"viewUpdateBox"})),u.length===1){const{newPolygon:l}=s[0],g=G(u);q({polygon:l,boxParams:u[0],newPointCloudBoxList:g},ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)}else{const l=G(u);l&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,l)}},yt=s=>{var i,u,l,g,r;if(U){const h=Number(s.widthDefault),C=Number(s.depthDefault),b=Number(s.heightDefault),D=U==null?void 0:U.info.trackID,B=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(W=>(W==null?void 0:W.trackID)===D),m={width:(l=(u=t==null?void 0:t.toolInstance)==null?void 0:u.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},j=B.pointList.map(W=>lbUtils.PointCloudUtils.transferCanvas2World(W,m)),N=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(j,b,h),z=N[0],Q=N[2],tt=lbAnnotation.MathUtils.getLineCenterPoint([z,Q]),mt=U.info.center.z-U.info.depth/2,et=__spreadProps(__spreadValues({},U.info),{center:{x:tt.x,y:tt.y,z:mt+C/2},width:h,height:b,depth:C,valid:!0}),Bt=G([et]);q({omitView:PointCloudView["3D"],polygon:B,boxParams:et,newPointCloudBoxList:Bt})}},H=(s,i,u,l,g,r)=>__async(void 0,null,function*(){const h=E==null?void 0:E.url,C={[PointCloudView.Side]:()=>{syncSideViewByPoint(u,i,a,h,r)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(u,i,p,h,r)},[PointCloudView.Top]:()=>{syncTopViewByPoint(u,i,t,e)}};Object.keys(C).forEach(b=>{b!==s&&C[b]()}),l&&(e==null||e.updateCameraZoom(l)),dt(u)}),q=(s,i=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:u,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:h}=s,C=E==null?void 0:E.url;h&&n.syncAllViewPointCloudColor(i,h);const b={[PointCloudView.Side]:()=>{synchronizeSideView(g,l,a,C)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(g,l,p,C)},[PointCloudView.Top]:()=>{synchronizeTopView(g,l,t,e)}};Object.keys(b).forEach(D=>{D!==u&&b[D]()}),r&&(e==null||e.updateCameraZoom(r))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:ht,backViewUpdateBox:xt,syncPointCloudViews:q,syncPointCloudPoint:H,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),e==null||e.generateBoxes(s)},initPointCloud3d:s=>{if(!e)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(s);e.initOrthographicCamera(i),e.initRenderer(),e.render()},updatePointCloudData:(...s)=>__async(void 0,[...s],function*(i=E){var u,l,g,r,h,C,b,D;if(!(i==null?void 0:i.url)||!e)return;I([]),actionCreators.SetAnnotationLoading(M,!0),actionCreators.SetLoadPCDFileLoading(M,!0),(u=o==null?void 0:o.setResourceLoading)==null||u.call(o,!0),yield e.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:DEFAULT_RADIUS),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let L=[],B=[],m=[],j=[];e.updateTopCamera();const N=(r=(g=index.jsonParser(i.result))==null?void 0:g.valid)!=null?r:!0;if(n.setPointCloudValid(N),(h=n.sideViewInstance)==null||h.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(L=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(L==null?void 0:L.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){L=yield e==null?void 0:e.filterPreResult(i.url,y,L);const z=index.jsonParser(i.result);z[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=L,i.result=JSON.stringify(z),n.setPointCloudResult(L)}m=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),B=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),j=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(b=y==null?void 0:y.radius)!=null?b:DEFAULT_RADIUS}),e==null||e.generateBoxes(L),e==null||e.generateSpheres(j),yield n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,L,[])}O({pointCloudBoxList:L,polygonList:m,lineList:B,pointCloudSphereList:j}),actionCreators.SetAnnotationLoading(M,!1),actionCreators.SetLoadPCDFileLoading(M,!1),(D=o==null?void 0:o.setResourceLoading)==null||D.call(o,!1)}),updateViewsByDefaultSize:yt,generateRects:Z,update2DViewRect:pt,remove2DViewRect:gt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:n,setPointCloudResult:t}=React.useContext(PointCloudContext.PointCloudContext),a=ahooks.useLatest(o),p=ahooks.useLatest(n);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=a.current,c=p.current;if(c.length===0)return null;const d=new Map,x=new Set;if(c.filter(f=>f.extId!==void 0).forEach(f=>{const v=f.extId,R=f.imageName,I=_.pick(f,["x","y","width","height"]);let S=d.get(v);S||(S=new Map,d.set(v,S)),S.set(R,I),x.add(v)}),d.size){const f=P.map(v=>{var R;const I=v.id;if(x.has(I)){const S=__spreadValues({},v);return(R=S.rects)==null||R.forEach(V=>{var k;const T=V.imageName;Object.assign(V,(k=d.get(I))==null?void 0:k.get(T))}),S}return v});return t(f),f}return null},[])}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews,exports.useSyncRectPositionDimensionToPointCloudList=useSyncRectPositionDimensionToPointCloudList;
@@ -1 +1 @@
1
- import{useLatest as oe,useMemoizedFn as Z,useDebounceEffect as Ie}from"ahooks";import{Spin as he}from"antd/es";import q,{useContext as De,useRef as J,useState as O,useMemo as _e,useCallback as be,useEffect as p}from"react";import{connect as Ce}from"react-redux";import{usePointCloudViews as we}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as xe}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as ye}from"../../store/annotation/map.js";import{LabelBeeContext as Pe}from"../../store/ctx.js";import{PointCloud2DRectOperation as Se,ImgUtils as Le}from"@labelbee/lb-annotation";import{ImgPosUtils as Oe}from"@labelbee/lb-utils";import{selectSpecifiedRectsFromTopViewSelectedIds as Ve}from"./util.js";import{useUpdateRectList as Ee}from"./useUpdateRectList.js";import je from"lodash";import{useToolStyleContext as Be}from"../../hooks/useToolStyle.js";import Ne from"../../store/toolConfig/index.js";var ke=Object.defineProperty,Ue=Object.defineProperties,ze=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,Ae=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable,le=(a,c,s)=>c in a?ke(a,c,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[c]=s,v=(a,c)=>{for(var s in c||(c={}))Ae.call(c,s)&&le(a,s,c[s]);if(ie)for(var s of ie(c))Me.call(c,s)&&le(a,s,c[s]);return a},C=(a,c)=>Ue(a,ze(c)),$=(a,c,s)=>new Promise((f,g)=>{var _=u=>{try{b(s.next(u))}catch(R){g(R)}},V=u=>{try{b(s.throw(u))}catch(R){g(R)}},b=u=>u.done?f(u.value):Promise.resolve(u.value).then(_,V);b((s=s.apply(a,c)).next())});const Te=a=>{var c,s;const{mappingData:f,size:g,config:_,checkMode:V,afterImgOnLoad:b,shouldExcludePointCloudBoxListUpdate:u}=a,{selectBoxVisibleSwitch:R}=Ne(),E=(c=f==null?void 0:f.url)!=null?c:"",w=(s=f==null?void 0:f.fallbackUrl)!=null?s:"",{pointCloudBoxList:j,setPointCloudResult:B,defaultAttribute:N,rectList:k,addRectIn2DView:ce,updateRectIn2DView:se,removeRectIn2DView:ue,updateRectListByReducer:de,selectedIDs:m,setSelectedIDs:U,selectedID:x}=De(xe),{value:z}=Be(),ae=oe(m),{update2DViewRect:fe,remove2DViewRect:pe}=we(),A=q.useRef(null),n=J(null),G=Z(fe),y=Z(pe),P=J(null),[me,K]=O(!0),[Q,W]=O(""),[ve,M]=O(!1),[ge,S]=O(!0),I=_e(()=>k==null?void 0:k.filter(e=>e.imageName===(f==null?void 0:f.path)),[f==null?void 0:f.path,k]),X=J(I),L=oe(f==null?void 0:f.path),T=be(e=>$(void 0,null,function*(){try{const o=ae.current.slice(0),t=yield Promise.resolve(e());if(!t||t.length===0)return t;if(o.length){const r=new Set(o),i=t.filter(l=>r.has(l.id)).map(l=>l.id);U(i)}return t}catch(o){}}),[U]),Y=e=>{const{boxID:o}=e;if(S(!1),!u&&o){T(()=>{const t=G==null?void 0:G(e);return t?(P.current=t,B(t),t):null});return}se(e,!0)},ee=e=>{L.current&&ce(C(v({},e),{imageName:L.current}))},te=e=>{if(e.length===0)return;if(!u){const t=e.find(r=>r.boxID);if(t){T(()=>{const r=y==null?void 0:y(t);return r?(P.current=r,B(r),h(),r):null});return}}const o=e.find(t=>t.extId);o&&T(()=>{const{imageName:t,extId:r}=o,i=y==null?void 0:y({boxID:r,imageName:t});return i?(P.current=i,B(i),i):null}),ue(e)},Re=Z(()=>{let e=[];return j.forEach(o=>{const{rects:t=[],id:r,attribute:i,trackID:l}=o,d=t.find(F=>F.imageName===L.current),D=r+"_"+L.current;d&&(e=[...e,C(v({},d),{boxID:r,id:D,attribute:i,order:l})])}),e}),h=Ee(()=>{var e,o,t,r,i;const l=u?[]:Re(),d=(e=n.current)==null?void 0:e.selectedRectID,D=m.slice(0),F=R?Ve(D,l,I):[...l,...I];let ne=[];!R&&(m==null?void 0:m.length)&&(ne=l.filter(H=>d?m.includes(H.boxID)&&!d.includes(H.boxID):m.includes(H.boxID))),(o=n.current)==null||o.setHighLightRectList(ne),(t=n.current)==null||t.setResult(F),Q?((r=n.current)==null||r.setSelectedRectID(Q),W("")):ve&&d&&((i=n.current)==null||i.setSelectedRectID(d),M(!1))}),re=({targetId:e,id:o})=>{S(!1),U(e),W(o)};return p(()=>{if(A.current){const e=new Se({container:A.current,size:g,config:C(v({},_),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:V});return n.current=e,n.current.init(),n.current.on("updateDragResult",Y),n.current.on("afterAddingDrawingRect",ee),n.current.on("deleteSelectedRects",te),n.current.on("onRightClick",re),()=>{var o,t,r,i,l;(o=n.current)==null||o.unbind("updateDragResult",Y),(t=n.current)==null||t.unbind("afterAddingDrawingRect",ee),(r=n.current)==null||r.unbind("deleteSelectedRects",te),(i=n.current)==null||i.unbind("onRightClick",re),(l=n.current)==null||l.destroy()}}},[]),p(()=>{const e=t=>$(void 0,null,function*(){try{return yield Le.load(t)}catch(r){return console.error("Error loading image:",r),null}}),o=()=>$(void 0,null,function*(){var t;K(!0);let r=yield e(E);!r&&w&&(r=yield e(w)),r&&((t=n.current)==null||t.setImgNode(r),b(r)),K(!1)});n.current&&(E||w)&&o()},[E,w]),p(()=>{var e;(e=n.current)==null||e.setSize(g)},[g]),p(()=>{j!==P.current&&h()},[j]),p(()=>{var e,o;const t=I.find(r=>r.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,N),t&&de(r=>{var i;const l=[];let d=null;return r.forEach(D=>{D.id!==n.current.selectedRectID?l.push(D):d=D}),t.extId===void 0&&(d=(i=n.current)==null?void 0:i.selectedRect),[...l,C(v({},d||{}),{attribute:N})]}),M(!0),h()},[N]),p(()=>{const e=X.current;je.isEqual(e,I)||(M(!0),h(),X.current=I)},[I]),p(()=>{h()},[u]),p(()=>{var e,o,t,r;const i=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},l=C(v({},i),{attributeList:(t=_.attributeList)!=null?t:[]});(r=n.current)==null||r.setConfig(JSON.stringify(l))},[_.attributeList]),p(()=>{var e;(e=n.current)==null||e.setEnableAddRect(m.length===0),h()},[m]),Ie(()=>{if(!x||!ge){S(!0),u&&(n.current.setHoverRectID(""),n.current.render());return}const{rectList:e,size:o,zoom:t,imgNode:r}=n.current,i=e.find(d=>d.boxID===x||d.extId===x),l=Oe.getBasicRecPos(r,i,o,.5);if(!l){S(!0);return}u&&n.current.setHoverRectID(i.id),n.current.setCurrentPos(l.currentPos),n.current.setZoom(l.innerZoom),n.current.renderBasicCanvas(),n.current.render()},[x],{wait:200}),p(()=>{const{hiddenText:e}=z||{};if(e===void 0)return;const o=n.current;if(!o)return;const t=v(v({},o.style),z);o.setStyle(t)},[z]),p(()=>{h()},[R]),q.createElement(he,{spinning:me},q.createElement("div",{ref:A,style:v({position:"relative"},g)}))};var Fe=Ce(ye,null,null,{context:Pe})(Te);export{Fe as default};
1
+ import{useLatest as oe,useMemoizedFn as q,useDebounceEffect as he}from"ahooks";import{Spin as De}from"antd/es";import Z,{useContext as _e,useRef as J,useState as O,useMemo as be,useCallback as Ce,useEffect as p}from"react";import{connect as we}from"react-redux";import{usePointCloudViews as ye}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as xe}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as Pe}from"../../store/annotation/map.js";import{LabelBeeContext as Se}from"../../store/ctx.js";import{PointCloud2DRectOperation as Le,ImgUtils as Oe}from"@labelbee/lb-annotation";import{ImgPosUtils as Ve}from"@labelbee/lb-utils";import{selectSpecifiedRectsFromTopViewSelectedIds as Ee}from"./util.js";import{useUpdateRectList as je}from"./useUpdateRectList.js";import Be from"lodash";import{useToolStyleContext as Ne}from"../../hooks/useToolStyle.js";import ke from"../../store/toolConfig/index.js";var Ue=Object.defineProperty,Ae=Object.defineProperties,ze=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,Me=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable,ce=(a,l,s)=>l in a?Ue(a,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[l]=s,v=(a,l)=>{for(var s in l||(l={}))Me.call(l,s)&&ce(a,s,l[s]);if(ie)for(var s of ie(l))Te.call(l,s)&&ce(a,s,l[s]);return a},C=(a,l)=>Ae(a,ze(l)),$=(a,l,s)=>new Promise((f,g)=>{var _=u=>{try{b(s.next(u))}catch(R){g(R)}},V=u=>{try{b(s.throw(u))}catch(R){g(R)}},b=u=>u.done?f(u.value):Promise.resolve(u.value).then(_,V);b((s=s.apply(a,l)).next())});const Fe=a=>{var l,s;const{mappingData:f,size:g,config:_,checkMode:V,afterImgOnLoad:b,shouldExcludePointCloudBoxListUpdate:u}=a,{selectBoxVisibleSwitch:R}=ke(),E=(l=f==null?void 0:f.url)!=null?l:"",w=(s=f==null?void 0:f.fallbackUrl)!=null?s:"",{pointCloudBoxList:j,setPointCloudResult:B,defaultAttribute:N,rectList:k,addRectIn2DView:le,updateRectIn2DView:se,removeRectIn2DView:ue,updateRectListByReducer:de,selectedIDs:m,setSelectedIDs:U,selectedID:y}=_e(xe),{value:A}=Ne(),ae=oe(m),{update2DViewRect:fe,remove2DViewRect:pe}=ye(),z=Z.useRef(null),n=J(null),G=q(fe),x=q(pe),P=J(null),[me,K]=O(!0),[Q,W]=O(""),[ve,M]=O(!1),[ge,S]=O(!0),I=be(()=>k==null?void 0:k.filter(e=>e.imageName===(f==null?void 0:f.path)),[f==null?void 0:f.path,k]),X=J(I),L=oe(f==null?void 0:f.path),T=Ce(e=>$(void 0,null,function*(){try{const o=ae.current.slice(0),t=yield Promise.resolve(e());if(!t||t.length===0)return t;if(o.length){const r=new Set(o),i=t.filter(c=>r.has(c.id)).map(c=>c.id);U(i)}return t}catch(o){}}),[U]),Y=e=>{const{boxID:o}=e;if(S(!1),!u&&o){T(()=>{const t=G==null?void 0:G(e);return t?(P.current=t,B(t),t):null});return}se(e,!0)},ee=e=>{L.current&&le(C(v({},e),{imageName:L.current}))},te=e=>{if(e.length===0)return;if(!u){const t=e.find(r=>r.boxID);if(t){T(()=>{const r=x==null?void 0:x(t);return r?(P.current=r,B(r),h(),r):null});return}}const o=e.find(t=>t.extId);o&&T(()=>{const{imageName:t,extId:r}=o,i=x==null?void 0:x({boxID:r,imageName:t});return i?(P.current=i,B(i),i):null}),ue(e)},Re=q(()=>{let e=[];return j.forEach(o=>{const{rects:t=[],id:r,attribute:i,trackID:c}=o,d=t.find(F=>F.imageName===L.current),D=r+"_"+L.current;d&&(e=[...e,C(v({},d),{boxID:r,id:D,attribute:i,order:c})])}),e}),h=je(()=>{var e,o,t,r,i;const c=u?[]:Re(),d=(e=n.current)==null?void 0:e.selectedRectID,D=m.slice(0),F=R?Ee(D,c,I):[...c,...I];let ne=[];!R&&(m==null?void 0:m.length)&&(ne=c.filter(H=>d?m.includes(H.boxID)&&!d.includes(H.boxID):m.includes(H.boxID))),(o=n.current)==null||o.setHighLightRectList(ne),(t=n.current)==null||t.setResult(F),Q?((r=n.current)==null||r.setSelectedRectID(Q),W("")):ve&&d&&((i=n.current)==null||i.setSelectedRectID(d),M(!1))}),re=({targetId:e,id:o})=>{S(!1),requestAnimationFrame(()=>{Ie(e),W(o)})},Ie=e=>{(Array.isArray(m)?m:[]).includes(e)||U(e)};return p(()=>{if(z.current){const e=new Le({container:z.current,size:g,config:C(v({},_),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:V});return n.current=e,n.current.init(),n.current.on("updateDragResult",Y),n.current.on("afterAddingDrawingRect",ee),n.current.on("deleteSelectedRects",te),n.current.on("onRightClick",re),()=>{var o,t,r,i,c;(o=n.current)==null||o.unbind("updateDragResult",Y),(t=n.current)==null||t.unbind("afterAddingDrawingRect",ee),(r=n.current)==null||r.unbind("deleteSelectedRects",te),(i=n.current)==null||i.unbind("onRightClick",re),(c=n.current)==null||c.destroy()}}},[]),p(()=>{const e=t=>$(void 0,null,function*(){try{return yield Oe.load(t)}catch(r){return console.error("Error loading image:",r),null}}),o=()=>$(void 0,null,function*(){var t;K(!0);let r=yield e(E);!r&&w&&(r=yield e(w)),r&&((t=n.current)==null||t.setImgNode(r),b(r)),K(!1)});n.current&&(E||w)&&o()},[E,w]),p(()=>{var e;(e=n.current)==null||e.setSize(g)},[g]),p(()=>{j!==P.current&&h()},[j]),p(()=>{var e,o;const t=I.find(r=>r.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,N),t&&de(r=>{var i;const c=[];let d=null;return r.forEach(D=>{D.id!==n.current.selectedRectID?c.push(D):d=D}),t.extId===void 0&&(d=(i=n.current)==null?void 0:i.selectedRect),[...c,C(v({},d||{}),{attribute:N})]}),M(!0),h()},[N]),p(()=>{const e=X.current;Be.isEqual(e,I)||(M(!0),h(),X.current=I)},[I]),p(()=>{h()},[u]),p(()=>{var e,o,t,r;const i=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},c=C(v({},i),{attributeList:(t=_.attributeList)!=null?t:[]});(r=n.current)==null||r.setConfig(JSON.stringify(c))},[_.attributeList]),p(()=>{var e;(e=n.current)==null||e.setEnableAddRect(m.length===0),h()},[m]),he(()=>{if(!y||!ge){S(!0),u&&(n.current.setHoverRectID(""),n.current.render());return}const{rectList:e,size:o,zoom:t,imgNode:r}=n.current,i=e.find(d=>d.boxID===y||d.extId===y),c=Ve.getBasicRecPos(r,i,o,.5);if(!c){S(!0);return}u&&n.current.setHoverRectID(i.id),n.current.setCurrentPos(c.currentPos),n.current.setZoom(c.innerZoom),n.current.renderBasicCanvas(),n.current.render()},[y],{wait:200}),p(()=>{const{hiddenText:e}=A||{};if(e===void 0)return;const o=n.current;if(!o)return;const t=v(v({},o.style),A);o.setStyle(t)},[A]),p(()=>{h()},[R]),Z.createElement(De,{spinning:me},Z.createElement("div",{ref:z,style:v({position:"relative"},g)}))};var He=we(Pe,null,null,{context:Se})(Fe);export{He as default};
@@ -1 +1 @@
1
- import{getClassName as u}from"../../utils/dom.js";import{cKeyCode as ee,PointCloud as te}from"@labelbee/lb-annotation";import{PointCloudUtils as T,EPerspectiveView as E}from"@labelbee/lb-utils";import O from"classnames";import o,{useContext as b,useState as y,useRef as oe,useEffect as p,useMemo as ne}from"react";import{PointCloudContainer as ie}from"./PointCloudLayout.js";import{PointCloudContext as le}from"./PointCloudContext.js";import{a2MapStateToProps as se}from"../../store/annotation/map.js";import{connect as re}from"react-redux";import{jsonParser as ae}from"../../utils/index.js";import{useSingleBox as A}from"./hooks/useSingleBox.js";import{useSphere as ce}from"./hooks/useSphere.js";import{Switch as de,Tooltip as ue}from"antd";import me from"../../hooks/useSize.js";import{usePointCloudViews as pe}from"./hooks/usePointCloudViews.js";import{useTranslation as F}from"react-i18next";import{LabelBeeContext as we}from"../../store/ctx.js";import ve from"./components/PointCloudSizeSlider/index.js";import fe from"./components/TitleButton/index.js";import{LeftOutlined as Ce}from"@ant-design/icons";import{useToolStyleContext as Ve}from"../../hooks/useToolStyle.js";import{usePointCloudAttribute as ge}from"./hooks/usePointCloudAttribute.js";var Ie=Object.defineProperty,H=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,U=(n,l,s)=>l in n?Ie(n,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[l]=s,he=(n,l)=>{for(var s in l||(l={}))Pe.call(l,s)&&U(n,s,l[s]);if(H)for(var s of H(l))Ee.call(l,s)&&U(n,s,l[s]);return n};const xe=ee.default,_e="LABELBEE-POINTCLOUD",h=o.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),v=({perspectiveView:n})=>{const{isActive:l,setTarget3DView:s}=b(h),f=w=>O({[u("point-cloud-3d-view",w)]:!0,active:l});return o.createElement("span",{onClick:()=>{s(E[n])},className:f(n.toLocaleLowerCase())})},K=({isEnlarge:n})=>{const{reset3DView:l,followTopView:s}=b(h),{t:f}=F(),w=o.createElement(o.Fragment,null,o.createElement(v,{perspectiveView:"Top"}),o.createElement(v,{perspectiveView:"Front"}),o.createElement(v,{perspectiveView:"Left"}),o.createElement(v,{perspectiveView:"Back"}),o.createElement(v,{perspectiveView:"Right"}),o.createElement(v,{perspectiveView:"LFT"}),o.createElement(v,{perspectiveView:"RBT"})),e=o.createElement(o.Fragment,null,o.createElement(ue,{title:f("CameraFollowTopView")},o.createElement("span",{onClick:()=>{s()},className:u("point-cloud-3d-view","followTop")})),o.createElement("span",{onClick:()=>{l()},className:u("point-cloud-3d-view","reset")}));return n?o.createElement("div",{className:u("point-cloud-3d-sidebarZoom")},e,w):o.createElement("div",{className:u("point-cloud-3d-sidebar")},w,e)},Se=({currentData:n,config:l,highlightAttribute:s,setResourceLoading:f})=>{var w;const e=b(le),{setIsLargeStatus:B}=e,[M,Z]=y(!0),[C,x]=y(!1),V=oe(null),{initPointCloud3d:L,generateRects:q}=pe(),g=me(V),{t:_}=F(),{value:j}=Ve(),{hiddenText:D}=j||{},{updatePointCloudAttribute:G}=ge(f,l),{updateSelectedBox:J}=A({generateRects:q});p(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(D,e.pointCloudBoxList)},[j]),p(()=>{!e.mainViewInstance||L==null||L(g)},[g]);const{selectedBox:m}=A(),{selectedSphere:I}=ce(),[Q,z]=y(!0),S=t=>{var i,r;const a=m==null?void 0:m.info;if(a){const c=he({},a.center);c.x=c.x-.01,c.z=1e3;const d=t===E.Top;(i=e.mainViewInstance)==null||i.updateCameraByBox(a,t,d?c:void 0)}I&&((r=e.mainViewInstance)==null||r.updateCameraBySphere(I,t))},W=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},X=()=>{var t,i;const r=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;r&&((i=e.mainViewInstance)==null||i.applyCameraTarget(r))};p(()=>{if(V.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&g.width&&(t=new te({container:V.current,isOrthographicCamera:!0,orthographicParams:T.getDefaultOrthographicParams(g),config:l,hiddenText:D}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:z}),e.setMainViewInstance(t))}},[g,n]),p(()=>{var t,i;if(V.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let r=e.mainViewInstance;const a=T.getRectParamsFromResultList(n.result),c=T.getBoxParamsFromResultList(n.result),d=c.find(P=>P.id===e.selectedID);d&&((t=e.topViewInstance)==null||t.updatePolygonList(c,void 0),G(d.attribute),J(d),e.setSelectedIDs(d.id)),e.setPointCloudValid((i=ae(n.result))==null?void 0:i.valid),e.setPointCloudResult(c),e.setRectList(a),r.generateBoxes(c)}},[n.result,e.mainViewInstance]),p(()=>{var t,i,r,a,c,d,P;const R=(t=m==null?void 0:m.info)==null?void 0:t.id;if(!Q){z(!0);return}if(R!==void 0){S(E.Top);const $=(a=(r=(i=e.topViewInstance)==null?void 0:i.pointCloudInstance)==null?void 0:r.camera.zoom)!=null?a:1;(c=e.mainViewInstance)==null||c.updateCameraZoom($)}(d=e.mainViewInstance)==null||d.setHighlightColor(R),(P=e.mainViewInstance)==null||P.render()},[(w=m==null?void 0:m.info)==null?void 0:w.id]),p(()=>{var t,i,r,a;if(I){S(E.Top);const c=(r=(i=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?r:1;(a=e.mainViewInstance)==null||a.updateCameraZoom(c)}},[I]),p(()=>(window.addEventListener("keydown",k),()=>{window.removeEventListener("keydown",k)}),[]);const k=t=>{if(t.keyCode===xe.Esc){x(!1);return}},N=ne(()=>({reset3DView:W,setTarget3DView:S,isActive:!!m,followTopView:X}),[m,e.mainViewInstance]);p(()=>{var t,i,r;const a=e.pointCloudBoxList.filter(c=>c.attribute===s);(a==null?void 0:a.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(i=e.mainViewInstance)==null||i.highlightBoxes(a)),a.length===0&&((r=e.mainViewInstance)==null||r.clearHighlightBoxesAndRender())},[s,e.mainViewInstance]);const Y=o.createElement(o.Fragment,null,o.createElement(ve,{onChange:t=>{var i;(i=e.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),o.createElement("span",{style:{marginRight:8}},_("ShowArrows")),o.createElement(de,{size:"small",checked:M,onChange:t=>{var i;Z(t),(i=e.mainViewInstance)==null||i.setShowDirection(t)}}),C&&o.createElement(h.Provider,{value:N},o.createElement(K,{isEnlarge:C})));return o.createElement(ie,{className:O({[u("point-cloud-3d-container")]:!0,[u("point-cloud-container","zoom")]:C}),title:C?o.createElement("div",{style:{display:"flex",alignItems:"center"}},o.createElement(Ce,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{B(!1),x(!1)}}),_("3DView")):o.createElement(fe,{title:_("3DView"),onClick:()=>{B(!0),x(!0)}}),toolbar:Y},o.createElement("div",{className:u("point-cloud-3d-content")},!C&&o.createElement(h.Provider,{value:N},o.createElement(K,null)),o.createElement("div",{className:u("point-cloud-3d-view"),id:_e,ref:V})))};var Te=re(se,null,null,{context:we})(Se);export{Te as default};
1
+ import{getClassName as u}from"../../utils/dom.js";import{cKeyCode as ee,PointCloud as te}from"@labelbee/lb-annotation";import{PointCloudUtils as T,EPerspectiveView as E}from"@labelbee/lb-utils";import O from"classnames";import o,{useContext as b,useState as y,useRef as oe,useEffect as p,useMemo as ne}from"react";import{PointCloudContainer as ie}from"./PointCloudLayout.js";import{PointCloudContext as le}from"./PointCloudContext.js";import{a2MapStateToProps as se}from"../../store/annotation/map.js";import{connect as re}from"react-redux";import{jsonParser as ae}from"../../utils/index.js";import{useSingleBox as A}from"./hooks/useSingleBox.js";import{useSphere as ce}from"./hooks/useSphere.js";import{Switch as de,Tooltip as ue}from"antd";import me from"../../hooks/useSize.js";import{usePointCloudViews as pe}from"./hooks/usePointCloudViews.js";import{useTranslation as F}from"react-i18next";import{LabelBeeContext as we}from"../../store/ctx.js";import ve from"./components/PointCloudSizeSlider/index.js";import fe from"./components/TitleButton/index.js";import{LeftOutlined as Ce}from"@ant-design/icons";import{useToolStyleContext as Ve}from"../../hooks/useToolStyle.js";import{usePointCloudAttribute as ge}from"./hooks/usePointCloudAttribute.js";var Ie=Object.defineProperty,H=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,U=(n,l,s)=>l in n?Ie(n,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[l]=s,he=(n,l)=>{for(var s in l||(l={}))Pe.call(l,s)&&U(n,s,l[s]);if(H)for(var s of H(l))Ee.call(l,s)&&U(n,s,l[s]);return n};const xe=ee.default,_e="LABELBEE-POINTCLOUD",h=o.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),v=({perspectiveView:n})=>{const{isActive:l,setTarget3DView:s}=b(h),f=w=>O({[u("point-cloud-3d-view",w)]:!0,active:l});return o.createElement("span",{onClick:()=>{s(E[n])},className:f(n.toLocaleLowerCase())})},K=({isEnlarge:n})=>{const{reset3DView:l,followTopView:s}=b(h),{t:f}=F(),w=o.createElement(o.Fragment,null,o.createElement(v,{perspectiveView:"Top"}),o.createElement(v,{perspectiveView:"Front"}),o.createElement(v,{perspectiveView:"Left"}),o.createElement(v,{perspectiveView:"Back"}),o.createElement(v,{perspectiveView:"Right"}),o.createElement(v,{perspectiveView:"LFT"}),o.createElement(v,{perspectiveView:"RBT"})),e=o.createElement(o.Fragment,null,o.createElement(ue,{title:f("CameraFollowTopView")},o.createElement("span",{onClick:()=>{s()},className:u("point-cloud-3d-view","followTop")})),o.createElement("span",{onClick:()=>{l()},className:u("point-cloud-3d-view","reset")}));return n?o.createElement("div",{className:u("point-cloud-3d-sidebarZoom")},e,w):o.createElement("div",{className:u("point-cloud-3d-sidebar")},w,e)},Se=({currentData:n,config:l,highlightAttribute:s,setResourceLoading:f})=>{var w;const e=b(le),{setIsLargeStatus:B}=e,[M,Z]=y(!0),[C,x]=y(!1),V=oe(null),{initPointCloud3d:L,generateRects:q}=pe(),g=me(V),{t:_}=F(),{value:j}=Ve(),{hiddenText:D}=j||{},{updatePointCloudAttribute:G}=ge(f,l),{updateSelectedBox:J}=A({generateRects:q});p(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(D,e.pointCloudBoxList)},[j]),p(()=>{!e.mainViewInstance||L==null||L(g)},[g]);const{selectedBox:m}=A(),{selectedSphere:I}=ce(),[Q,z]=y(!0),S=t=>{var i,r;const a=m==null?void 0:m.info;if(a){const c=he({},a.center);c.x=c.x-.01,c.z=1e3;const d=t===E.Top;(i=e.mainViewInstance)==null||i.updateCameraByBox(a,t,d?c:void 0)}I&&((r=e.mainViewInstance)==null||r.updateCameraBySphere(I,t))},W=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},X=()=>{var t,i;const r=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;r&&((i=e.mainViewInstance)==null||i.applyCameraTarget(r))};p(()=>{if(V.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&g.width&&(t=new te({container:V.current,isOrthographicCamera:!0,orthographicParams:T.getDefaultOrthographicParams(g),config:l,hiddenText:D,view:"3DView"}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:z}),e.setMainViewInstance(t))}},[g,n]),p(()=>{var t,i;if(V.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let r=e.mainViewInstance;const a=T.getRectParamsFromResultList(n.result),c=T.getBoxParamsFromResultList(n.result),d=c.find(P=>P.id===e.selectedID);d&&((t=e.topViewInstance)==null||t.updatePolygonList(c,void 0),G(d.attribute),J(d),e.setSelectedIDs(d.id)),e.setPointCloudValid((i=ae(n.result))==null?void 0:i.valid),e.setPointCloudResult(c),e.setRectList(a),r.generateBoxes(c)}},[n.result,e.mainViewInstance]),p(()=>{var t,i,r,a,c,d,P;const R=(t=m==null?void 0:m.info)==null?void 0:t.id;if(!Q){z(!0);return}if(R!==void 0){S(E.Top);const $=(a=(r=(i=e.topViewInstance)==null?void 0:i.pointCloudInstance)==null?void 0:r.camera.zoom)!=null?a:1;(c=e.mainViewInstance)==null||c.updateCameraZoom($)}(d=e.mainViewInstance)==null||d.setHighlightColor(R),(P=e.mainViewInstance)==null||P.render()},[(w=m==null?void 0:m.info)==null?void 0:w.id]),p(()=>{var t,i,r,a;if(I){S(E.Top);const c=(r=(i=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?r:1;(a=e.mainViewInstance)==null||a.updateCameraZoom(c)}},[I]),p(()=>(window.addEventListener("keydown",k),()=>{window.removeEventListener("keydown",k)}),[]);const k=t=>{if(t.keyCode===xe.Esc){x(!1);return}},N=ne(()=>({reset3DView:W,setTarget3DView:S,isActive:!!m,followTopView:X}),[m,e.mainViewInstance]);p(()=>{var t,i,r;const a=e.pointCloudBoxList.filter(c=>c.attribute===s);(a==null?void 0:a.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(i=e.mainViewInstance)==null||i.highlightBoxes(a)),a.length===0&&((r=e.mainViewInstance)==null||r.clearHighlightBoxesAndRender())},[s,e.mainViewInstance]);const Y=o.createElement(o.Fragment,null,o.createElement(ve,{onChange:t=>{var i;(i=e.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),o.createElement("span",{style:{marginRight:8}},_("ShowArrows")),o.createElement(de,{size:"small",checked:M,onChange:t=>{var i;Z(t),(i=e.mainViewInstance)==null||i.setShowDirection(t)}}),C&&o.createElement(h.Provider,{value:N},o.createElement(K,{isEnlarge:C})));return o.createElement(ie,{className:O({[u("point-cloud-3d-container")]:!0,[u("point-cloud-container","zoom")]:C}),title:C?o.createElement("div",{style:{display:"flex",alignItems:"center"}},o.createElement(Ce,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{B(!1),x(!1)}}),_("3DView")):o.createElement(fe,{title:_("3DView"),onClick:()=>{B(!0),x(!0)}}),toolbar:Y},o.createElement("div",{className:u("point-cloud-3d-content")},!C&&o.createElement(h.Provider,{value:N},o.createElement(K,null)),o.createElement("div",{className:u("point-cloud-3d-view"),id:_e,ref:V})))};var Te=re(se,null,null,{context:we})(Se);export{Te as default};
@@ -1 +1 @@
1
- import{getClassName as _}from"../../utils/dom.js";import{FooterDivider as K}from"../../views/MainView/toolFooter/index.js";import{ZoomController as Ie}from"../../views/MainView/toolFooter/ZoomController/index.js";import{LeftOutlined as ye,UpSquareOutlined as xe,DownSquareOutlined as he}from"@ant-design/icons";import{cKeyCode as Ve,PointCloudAnnotation as Se,MathUtils as M,cTool as _e,cAnnotation as Ee}from"@labelbee/lb-annotation";import{PointCloudUtils as X}from"@labelbee/lb-utils";import{EPointCloudBoxRenderTrigger as Y}from"../../utils/ToolPointCloudBoxRenderHelper.js";import s,{useState as B,useRef as Le,useContext as q,useLayoutEffect as be,useEffect as P}from"react";import{PointCloudContext as $}from"./PointCloudContext.js";import{useRotate as Oe}from"./hooks/useRotate.js";import{useRotateEdge as je}from"./hooks/useRotateEdge.js";import{useSingleBox as G}from"./hooks/useSingleBox.js";import{PointCloudContainer as Te}from"./PointCloudLayout.js";import{BoxInfos as J,PointCloudValidity as De}from"./PointCloudInfos.js";import{usePolygon as Re}from"./hooks/usePolygon.js";import{useSphere as Q}from"./hooks/useSphere.js";import{useZoom as ee}from"./hooks/useZoom.js";import{Slider as ke}from"antd";import{a2MapStateToProps as Be}from"../../store/annotation/map.js";import{connect as Ae}from"react-redux";import{usePointCloudViews as Ne}from"./hooks/usePointCloudViews.js";import Ue from"../../hooks/useSize.js";import{useTranslation as ze}from"react-i18next";import{LabelBeeContext as Ze}from"../../store/ctx.js";import{jsonParser as He}from"../../utils/index.js";import Fe from"../../utils/ToolUtils.js";import We from"lodash";import Ke from"./components/PointCloudSizeSlider/index.js";import{useHistory as Me}from"./hooks/useHistory.js";import Xe from"./components/TitleButton/index.js";var Ye=Object.defineProperty,qe=Object.defineProperties,$e=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertySymbols,Ge=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,oe=(i,l,r)=>l in i?Ye(i,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[l]=r,U=(i,l)=>{for(var r in l||(l={}))Ge.call(l,r)&&oe(i,r,l[r]);if(te)for(var r of te(l))Je.call(l,r)&&oe(i,r,l[r]);return i},z=(i,l)=>qe(i,$e(l));const{EPolygonPattern:Qe,EToolName:ne}=_e,{ESortDirection:ie}=Ee,et=Ve.default,se=(i,l,r=1)=>{const{width:v,height:m}=l,y={x:i.x+v*r/2,y:i.y+m*r/2},x={x:l.width/2,y:l.height/2};return{offsetX:(x.x-y.x)/r,offsetY:-(x.y-y.y)/r}},tt=({currentData:i})=>{var l,r;const{zoom:v,zoomIn:m,zoomOut:y,initialPosition:x}=ee(),{selectNextBox:O,selectPrevBox:j}=G(),{switchToNextSphere:E}=Q(),{updateRotate:L}=Oe({currentData:i}),{updateRotateEdge:T}=je({currentData:i}),g=q($),{topViewInstance:h}=g,f=(r=(l=g==null?void 0:g.topViewInstance)==null?void 0:l.toolScheduler)==null?void 0:r.getCurrentToolName(),e=()=>{L(-Number(g.rectRotateSensitivity))},d=()=>{L(g.rectRotateSensitivity)},C=()=>{T(-90)};return s.createElement(s.Fragment,null,s.createElement(Ke,{onChange:A=>{var V;(V=h==null?void 0:h.pointCloudInstance)==null||V.updatePointSize({customSize:A})}}),s.createElement("span",{onClick:d,className:_("point-cloud","rotate-reserve")}),s.createElement("span",{onClick:e,className:_("point-cloud","rotate")}),s.createElement("span",{onClick:C,className:_("point-cloud","rotate-90")}),s.createElement(K,null),s.createElement(xe,{onClick:()=>{if(f===ne.Point){E(ie.descend);return}j(!0)},className:_("point-cloud","prev")}),s.createElement(he,{onClick:()=>{if(f===ne.Point){E(ie.ascend);return}O(!0)},className:_("point-cloud","next")}),s.createElement(K,null),s.createElement(Ie,{initialPosition:x,zoomIn:m,zoomOut:y,zoom:v}))},ot=({setZAxisLimit:i,zAxisLimit:l,checkMode:r})=>r?null:s.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},s.createElement(ke,{vertical:!0,step:.5,max:10,min:.5,defaultValue:l,onAfterChange:v=>{i(v)}})),nt=({currentData:i,imgList:l,stepInfo:r,drawLayerSlot:v,checkMode:m,intelligentFit:y,setIsEnlargeTopView:x,isEnlargeTopView:O,onExitZoom:j,highlightAttribute:E})=>{var L,T;const[g,h]=B({zoom:1,currentPos:{x:0,y:0}}),f=Le(null),e=q($),d=Ue(f),C=He(r.config),{setZoom:A,syncTopviewToolZoom:V}=ee(),{hideAttributes:le,setIsLargeStatus:re,selectedID:ae,pointCloudBoxList:ce}=e,{addPolygon:de,deletePolygon:ue}=Re(),{deletePointCloudSphere:pe}=Q(),{deletePointCloudBox:me,changeValidByID:fe}=G(),[N,Ce]=B(10),{t:Z}=ze(),w=Ne(),{pushHistoryWithList:ve}=Me(),[we,D]=B(!0),[H,F]=B(!1);be(()=>{if(!e.topViewInstance&&f.current&&(i==null?void 0:i.url)&&(i==null?void 0:i.result)){const o={width:f.current.clientWidth,height:f.current.clientHeight},a=new Se({container:f.current,size:o,pcdPath:i.url,config:z(U({},C),{pointCloudPattern:e.pointCloudPattern}),checkMode:m,toolName:Fe.getPointCloudToolList(),proxyMode:m});e.setTopViewInstance(a)}},[i]),P(()=>{H&&ae&&(e.syncAllViewPointCloudColor(Y.Single,ce),F(!1))},[H]),P(()=>{if(!d||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:o}=e.topViewInstance;o.singleOn("dataUpdated",(t,n)=>{const u=We.cloneDeep(t).map(c=>z(U({},c),{pointList:X.pointListTransferCanvas2World(c.pointList,d)}));e.setSelectedIDs(n),e.setLineList(u),ve({lineList:u})}),o.singleOn("pointCreated",(t,n)=>{w.topViewAddSphere({newPoint:t,size:d,trackConfigurable:C.trackConfigurable,zoom:n})}),o.singleOn("pointDeleted",t=>{pe(t)}),o.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),o.singleOn("updatePointByDrag",(t,n)=>{var u;(u=w.topViewUpdatePoint)==null||u.call(w,t,d)}),o.singleOn("polygonCreated",(t,n)=>{if(o.pattern===Qe.Normal||!(i==null?void 0:i.url)){const u=z(U({},t),{pointList:t.pointList.map(c=>X.transferCanvas2World(c,d))});de(u),e.setSelectedIDs(le.includes(t.attribute)?"":t.id);return}D(!1),w.topViewAddBox({polygon:t,size:d,imgList:l,trackConfigurable:C.trackConfigurable,zoom:n,intelligentFit:y}),F(!0)}),o.singleOn("deletedObject",({id:t})=>{me(t),ue(t)}),o.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),o.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),o.singleOn("setSelectedIDs",t=>{D(!1),e.setSelectedIDs(t)}),o.singleOn("updatePolygonByDrag",t=>{var n;(n=w.topViewUpdateBox)==null||n.call(w,t,d)});const a=t=>{var n;const u=fe(t);u&&e.syncAllViewPointCloudColor(Y.Default,u),e.polygonList.find(c=>c.id===t)&&((n=e.topViewInstance)==null||n.toolInstance.setPolygonValidAndRender(t,!0))};return o.on("validUpdate",a),()=>{o.unbind("validUpdate",a)}},[e,d,i,w,e.polygonList,e.lineList,(L=e.topViewInstance)==null?void 0:L.toolInstance]),P(()=>{var o,a;if(!(d==null?void 0:d.width)||!e.topViewInstance)return;const t=(a=(o=C==null?void 0:C.attributeList)==null?void 0:o[0])==null?void 0:a.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(d),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:n,toolInstance:u}}=e;u.singleOn("renderZoom",(c,p)=>{const{offsetX:S,offsetY:b}=se(p,d,c);if(n.camera.zoom=c,p){const{x:I,y:R,z:k}=n.initCameraPosition;n.camera.position.set(I+b,R-S,k)}n.camera.updateProjectionMatrix(),n.render(),A(c),V(p,c,d),h({zoom:c,currentPos:p})}),u.singleOn("dragMove",({currentPos:c,zoom:p})=>{const{offsetX:S,offsetY:b}=se(c,d,p);n.camera.zoom=p;const{x:I,y:R,z:k}=n.initCameraPosition;n.camera.position.set(I+b,R-S,k),n.render(),V(c,p,d),h({zoom:p,currentPos:c})})},[d,e.topViewInstance,(T=e.topViewInstance)==null?void 0:T.toolInstance]),P(()=>{var o,a;(a=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null||a.applyZAxisPoints(N)},[N]),P(()=>{var o,a,t,n;w.topViewSelectedChanged({}),(n=(t=(a=(o=e.topViewInstance)==null?void 0:o.toolInstance)==null?void 0:a.selection)==null?void 0:t.hardSetSelectedIDs)==null||n.call(t,e.selectedIDs)},[e.selectedIDs]),P(()=>{const{topViewInstance:o,selectedID:a,selectedPointCloudBox:t,zoom:n}=e;if(!o||!a||!t||!we){D(!0);return}const{center:u}=t,{pointCloudInstance:c,toolInstance:p}=o,S=p.polygonList.find(ge=>ge.id===e.selectedID);if(!S){D(!0);return}const b=M.getRectCenterPoint(S.pointList),I=M.getCurrentPosFromRectCenter(p.size,b,n);p.setCurrentPos(I),p.render();const{x:R,y:k,z:Pe}=c.initCameraPosition;c.camera.position.set(u.x,u.y,Pe),c.render(),V(I,n,d),h({zoom:n,currentPos:I})},[e.selectedID]),P(()=>(window.addEventListener("keydown",W),()=>{window.removeEventListener("keydown",W)}),[]);const W=o=>{const{keyCode:a}=o;a===et.Esc&&j()};return P(()=>{var o,a,t;(t=(a=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:a.setHighlightAttribute)==null||t.call(a,E)},[e.topViewInstance,E]),s.createElement(Te,{className:_("point-cloud-container","top-view"),title:O?s.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},s.createElement(ye,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{j()}}),s.createElement("span",null,Z("TopView")),s.createElement(J,{checkMode:m,config:C,style:{display:"flex",position:"initial",margin:"0px 20px"}})):s.createElement(Xe,{title:Z("TopView"),onClick:()=>{re(!0),x(!0)}}),toolbar:s.createElement(tt,{currentData:i})},s.createElement("div",{style:{position:"relative",flex:1}},s.createElement("div",{style:{width:"100%",height:"100%"},ref:f},v==null?void 0:v(g)),!O&&s.createElement(J,{checkMode:m,config:C}),s.createElement(ot,{checkMode:m,zAxisLimit:N,setZAxisLimit:Ce}),s.createElement(De,null)))};var it=Ae(Be,null,null,{context:Ze})(nt);export{it as default};
1
+ import{getClassName as _}from"../../utils/dom.js";import{FooterDivider as K}from"../../views/MainView/toolFooter/index.js";import{ZoomController as Ie}from"../../views/MainView/toolFooter/ZoomController/index.js";import{LeftOutlined as ye,UpSquareOutlined as xe,DownSquareOutlined as Ve}from"@ant-design/icons";import{cKeyCode as he,PointCloudAnnotation as Se,MathUtils as M,cTool as _e,cAnnotation as Ee}from"@labelbee/lb-annotation";import{PointCloudUtils as X}from"@labelbee/lb-utils";import{EPointCloudBoxRenderTrigger as Y}from"../../utils/ToolPointCloudBoxRenderHelper.js";import s,{useState as B,useRef as Le,useContext as q,useLayoutEffect as be,useEffect as P}from"react";import{PointCloudContext as $}from"./PointCloudContext.js";import{useRotate as Oe}from"./hooks/useRotate.js";import{useRotateEdge as je}from"./hooks/useRotateEdge.js";import{useSingleBox as G}from"./hooks/useSingleBox.js";import{PointCloudContainer as Te}from"./PointCloudLayout.js";import{BoxInfos as J,PointCloudValidity as De}from"./PointCloudInfos.js";import{usePolygon as Re}from"./hooks/usePolygon.js";import{useSphere as Q}from"./hooks/useSphere.js";import{useZoom as ee}from"./hooks/useZoom.js";import{Slider as ke}from"antd";import{a2MapStateToProps as Be}from"../../store/annotation/map.js";import{connect as Ae}from"react-redux";import{usePointCloudViews as Ne}from"./hooks/usePointCloudViews.js";import Ue from"../../hooks/useSize.js";import{useTranslation as ze}from"react-i18next";import{LabelBeeContext as Ze}from"../../store/ctx.js";import{jsonParser as He}from"../../utils/index.js";import Fe from"../../utils/ToolUtils.js";import We from"lodash";import Ke from"./components/PointCloudSizeSlider/index.js";import{useHistory as Me}from"./hooks/useHistory.js";import Xe from"./components/TitleButton/index.js";var Ye=Object.defineProperty,qe=Object.defineProperties,$e=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertySymbols,Ge=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,oe=(i,l,r)=>l in i?Ye(i,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[l]=r,U=(i,l)=>{for(var r in l||(l={}))Ge.call(l,r)&&oe(i,r,l[r]);if(te)for(var r of te(l))Je.call(l,r)&&oe(i,r,l[r]);return i},z=(i,l)=>qe(i,$e(l));const{EPolygonPattern:Qe,EToolName:ne}=_e,{ESortDirection:ie}=Ee,et=he.default,se=(i,l,r=1)=>{const{width:v,height:m}=l,y={x:i.x+v*r/2,y:i.y+m*r/2},x={x:l.width/2,y:l.height/2};return{offsetX:(x.x-y.x)/r,offsetY:-(x.y-y.y)/r}},tt=({currentData:i})=>{var l,r;const{zoom:v,zoomIn:m,zoomOut:y,initialPosition:x}=ee(),{selectNextBox:O,selectPrevBox:j}=G(),{switchToNextSphere:E}=Q(),{updateRotate:L}=Oe({currentData:i}),{updateRotateEdge:T}=je({currentData:i}),g=q($),{topViewInstance:V}=g,f=(r=(l=g==null?void 0:g.topViewInstance)==null?void 0:l.toolScheduler)==null?void 0:r.getCurrentToolName(),e=()=>{L(-Number(g.rectRotateSensitivity))},d=()=>{L(g.rectRotateSensitivity)},C=()=>{T(-90)};return s.createElement(s.Fragment,null,s.createElement(Ke,{onChange:A=>{var h;(h=V==null?void 0:V.pointCloudInstance)==null||h.updatePointSize({customSize:A})}}),s.createElement("span",{onClick:d,className:_("point-cloud","rotate-reserve")}),s.createElement("span",{onClick:e,className:_("point-cloud","rotate")}),s.createElement("span",{onClick:C,className:_("point-cloud","rotate-90")}),s.createElement(K,null),s.createElement(xe,{onClick:()=>{if(f===ne.Point){E(ie.descend);return}j(!0)},className:_("point-cloud","prev")}),s.createElement(Ve,{onClick:()=>{if(f===ne.Point){E(ie.ascend);return}O(!0)},className:_("point-cloud","next")}),s.createElement(K,null),s.createElement(Ie,{initialPosition:x,zoomIn:m,zoomOut:y,zoom:v}))},ot=({setZAxisLimit:i,zAxisLimit:l,checkMode:r})=>r?null:s.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},s.createElement(ke,{vertical:!0,step:.5,max:10,min:.5,defaultValue:l,onAfterChange:v=>{i(v)}})),nt=({currentData:i,imgList:l,stepInfo:r,drawLayerSlot:v,checkMode:m,intelligentFit:y,setIsEnlargeTopView:x,isEnlargeTopView:O,onExitZoom:j,highlightAttribute:E})=>{var L,T;const[g,V]=B({zoom:1,currentPos:{x:0,y:0}}),f=Le(null),e=q($),d=Ue(f),C=He(r.config),{setZoom:A,syncTopviewToolZoom:h}=ee(),{hideAttributes:le,setIsLargeStatus:re,selectedID:ae,pointCloudBoxList:ce}=e,{addPolygon:de,deletePolygon:ue}=Re(),{deletePointCloudSphere:pe}=Q(),{deletePointCloudBox:me,changeValidByID:fe}=G(),[N,Ce]=B(10),{t:Z}=ze(),w=Ne(),{pushHistoryWithList:ve}=Me(),[we,D]=B(!0),[H,F]=B(!1);be(()=>{if(!e.topViewInstance&&f.current&&(i==null?void 0:i.url)&&(i==null?void 0:i.result)){const o={width:f.current.clientWidth,height:f.current.clientHeight},a=new Se({container:f.current,size:o,pcdPath:i.url,config:z(U({},C),{pointCloudPattern:e.pointCloudPattern}),checkMode:m,toolName:Fe.getPointCloudToolList(),proxyMode:m,view:"topView"});e.setTopViewInstance(a)}},[i]),P(()=>{H&&ae&&(e.syncAllViewPointCloudColor(Y.Single,ce),F(!1))},[H]),P(()=>{if(!d||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:o}=e.topViewInstance;o.singleOn("dataUpdated",(t,n)=>{const u=We.cloneDeep(t).map(c=>z(U({},c),{pointList:X.pointListTransferCanvas2World(c.pointList,d)}));e.setSelectedIDs(n),e.setLineList(u),ve({lineList:u})}),o.singleOn("pointCreated",(t,n)=>{w.topViewAddSphere({newPoint:t,size:d,trackConfigurable:C.trackConfigurable,zoom:n})}),o.singleOn("pointDeleted",t=>{pe(t)}),o.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),o.singleOn("updatePointByDrag",(t,n)=>{var u;(u=w.topViewUpdatePoint)==null||u.call(w,t,d)}),o.singleOn("polygonCreated",(t,n)=>{if(o.pattern===Qe.Normal||!(i==null?void 0:i.url)){const u=z(U({},t),{pointList:t.pointList.map(c=>X.transferCanvas2World(c,d))});de(u),e.setSelectedIDs(le.includes(t.attribute)?"":t.id);return}D(!1),w.topViewAddBox({polygon:t,size:d,imgList:l,trackConfigurable:C.trackConfigurable,zoom:n,intelligentFit:y}),F(!0)}),o.singleOn("deletedObject",({id:t})=>{me(t),ue(t)}),o.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),o.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),o.singleOn("setSelectedIDs",t=>{D(!1),e.setSelectedIDs(t)}),o.singleOn("updatePolygonByDrag",t=>{var n;(n=w.topViewUpdateBox)==null||n.call(w,t,d)});const a=t=>{var n;const u=fe(t);u&&e.syncAllViewPointCloudColor(Y.Default,u),e.polygonList.find(c=>c.id===t)&&((n=e.topViewInstance)==null||n.toolInstance.setPolygonValidAndRender(t,!0))};return o.on("validUpdate",a),()=>{o.unbind("validUpdate",a)}},[e,d,i,w,e.polygonList,e.lineList,(L=e.topViewInstance)==null?void 0:L.toolInstance]),P(()=>{var o,a;if(!(d==null?void 0:d.width)||!e.topViewInstance)return;const t=(a=(o=C==null?void 0:C.attributeList)==null?void 0:o[0])==null?void 0:a.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(d),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:n,toolInstance:u}}=e;u.singleOn("renderZoom",(c,p)=>{const{offsetX:S,offsetY:b}=se(p,d,c);if(n.camera.zoom=c,p){const{x:I,y:R,z:k}=n.initCameraPosition;n.camera.position.set(I+b,R-S,k)}n.camera.updateProjectionMatrix(),n.render(),A(c),h(p,c,d),V({zoom:c,currentPos:p})}),u.singleOn("dragMove",({currentPos:c,zoom:p})=>{const{offsetX:S,offsetY:b}=se(c,d,p);n.camera.zoom=p;const{x:I,y:R,z:k}=n.initCameraPosition;n.camera.position.set(I+b,R-S,k),n.render(),h(c,p,d),V({zoom:p,currentPos:c})})},[d,e.topViewInstance,(T=e.topViewInstance)==null?void 0:T.toolInstance]),P(()=>{var o,a;(a=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null||a.applyZAxisPoints(N)},[N]),P(()=>{var o,a,t,n;w.topViewSelectedChanged({}),(n=(t=(a=(o=e.topViewInstance)==null?void 0:o.toolInstance)==null?void 0:a.selection)==null?void 0:t.hardSetSelectedIDs)==null||n.call(t,e.selectedIDs)},[e.selectedIDs]),P(()=>{const{topViewInstance:o,selectedID:a,selectedPointCloudBox:t,zoom:n}=e;if(!o||!a||!t||!we){D(!0);return}const{center:u}=t,{pointCloudInstance:c,toolInstance:p}=o,S=p.polygonList.find(ge=>ge.id===e.selectedID);if(!S){D(!0);return}const b=M.getRectCenterPoint(S.pointList),I=M.getCurrentPosFromRectCenter(p.size,b,n);p.setCurrentPos(I),p.render();const{x:R,y:k,z:Pe}=c.initCameraPosition;c.camera.position.set(u.x,u.y,Pe),c.render(),h(I,n,d),V({zoom:n,currentPos:I})},[e.selectedID]),P(()=>(window.addEventListener("keydown",W),()=>{window.removeEventListener("keydown",W)}),[]);const W=o=>{const{keyCode:a}=o;a===et.Esc&&j()};return P(()=>{var o,a,t;(t=(a=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:a.setHighlightAttribute)==null||t.call(a,E)},[e.topViewInstance,E]),s.createElement(Te,{className:_("point-cloud-container","top-view"),title:O?s.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},s.createElement(ye,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{j()}}),s.createElement("span",null,Z("TopView")),s.createElement(J,{checkMode:m,config:C,style:{display:"flex",position:"initial",margin:"0px 20px"}})):s.createElement(Xe,{title:Z("TopView"),onClick:()=>{re(!0),x(!0)}}),toolbar:s.createElement(tt,{currentData:i})},s.createElement("div",{style:{position:"relative",flex:1}},s.createElement("div",{style:{width:"100%",height:"100%"},ref:f},v==null?void 0:v(g)),!O&&s.createElement(J,{checkMode:m,config:C}),s.createElement(ot,{checkMode:m,zAxisLimit:N,setZAxisLimit:Ce}),s.createElement(De,null)))};var it=Ae(Be,null,null,{context:Ze})(nt);export{it as default};
@@ -1 +1 @@
1
- import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as X,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as mt,useCallback as ht}from"react";import{PointCloudContext as xt}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as F}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as rt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as lt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as K}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,ho=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,x=(e,n)=>{for(var t in n||(n={}))ho.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))xo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((d,p)=>{var o=a=>{try{u(t.next(a))}catch(h){p(h)}},f=a=>{try{u(t.throw(a))}catch(h){p(h)}},u=a=>a.done?d(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const $=5,tt=90,It=.01,b={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(e,n,t,d,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,a={center:{x:o,y:f,z:u},id:e.id},h=d?x(x({},d),a):A(x({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},at=(e,n,t,d,p,o)=>{let f=e.pointList.map(D=>O.transferCanvas2World(D,n)),u=0,a=1,h={};if(t){const D=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&D.fittedCoordinates.length>0&&(f=D.fittedCoordinates),u=(D.maxZ+D.minZ)/2,a=D.maxZ-D.minZ,h={count:D.zCount}}const[P,L,T]=f,V=w.getLineCenterPoint([P,T]),R=w.getLineLength(P,L),U=w.getLineLength(L,T),N=w.getRadiusFromQuadrangle(e.pointList);d&&(u=d.center.z,a=d.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+It:U,height:o?R+It:R,depth:a,rotation:N,id:e.id},j=x(d?x(x({},d),z):A(x({},z),{attribute:"",valid:!0}),h);p&&Object.assign(j,p);const E=f.map(D=>O.transferWorld2Canvas(D,n));return{boxParams:j,newPointList:E}},wt=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x-d.x,y:t.center.y,z:t.center.z-d.y}})},Dt=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j,{newBoxParams:D}=d.getNewBoxBySideUpdate(V,E,N,t);return D},Lo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x,y:t.center.y-d.x,z:t.center.z-d.y}})},vo=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j;let{newBoxParams:D}=d.getNewBoxByBackUpdate(V,E,N,t);return D},St=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,X.Left);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{width:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,X.Back);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{height:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Back);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxBackPolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},kt=(e,n,t,d)=>{if(!t||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,X.Top),d.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(x(x({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},ct=(e,n,t,d)=>{var p,o;if(!t||!d)return;d.generateBox(e),d.setHighlightColor(e.id),d.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:a}=u.getBoxTopPolygon2DCoordinate(e),h=[...f.polygonList],P=h.find(L=>L.id===n.id);P?(P.pointList=a,P.valid=(p=e.valid)!=null?p:!0):h.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(h,n.id)},yo=e=>{const n=mt(xt),{topViewInstance:t,sideViewInstance:d,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:a,selectedIDs:h,pointCloudBoxList:P,pointCloudSphereList:L,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:R,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:E,pushHistoryUnderUpdatePolygon:D}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:ut,selectedSphere:Y}=ro(),{currentData:W,config:y}=ao(s=>{const{stepList:i,step:c,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:rt(uo.getCurrentStepInfo(c,i).config)}}),M=co(),Tt=K(R),Ut=K(z),zt=ht((s,i)=>{const c=Ut.current,l=i.id;return s.filter(r=>{if(!r)return!1;const m=c.get(r.imageName);return m===void 0?!0:Boolean(m.get(l))})},[]),ot=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!Tt.current||i){const{mappingImgList:c=[]}=W;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:et,getPointCloudByID:jt}=so({generateRects:ot}),pt=k==null?void 0:k.info;if(!t||!d||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:nt}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:s,size:i,zoom:c,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:L})});const m=dt(s,i,nt,void 0,r);a(s.id);const C=u(m);J(b.Top,s,m,c,C,y),j({newSphereParams:m})},Ht=({polygon:s,size:i,imgList:c,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var m,C,S;const _={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};l===!0&&Object.assign(_,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:L})}),t==null||t.toolInstance;const v=x({},s);let{boxParams:I,newPointList:B}=at(v,i,nt,void 0,_,r);I=M(lt({tool:st.PointCloud,dataList:[I],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(B==null?void 0:B.length)&&(v.pointList=B);const G=T.includes(v.attribute);ot(I);const H=f(I),it=(C=n==null?void 0:n.polygonList)!=null?C:[];I.subAttribute=oo.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(S=y==null?void 0:y.inputList)!=null?S:[]:[]),t==null||t.updatePolygonList(H!=null?H:[],it),G?a([]):(a(I.id),r&&ct(I,v,t,o)),j({newBoxParams:I})},Ft=s=>{const{boxID:i,imageName:c,width:l,height:g,x:r,y:m}=s,C=P.find(B=>B.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(B=>B.imageName===c))return;const _=C.rects.map(B=>B.imageName===c?A(x({},B),{width:l,height:g,x:r,y:m}):B),v=A(x({},C),{rects:_}),I=P.map(B=>B.id===i?v:B);return t==null||t.updatePolygonList(I!=null?I:[]),I},Wt=s=>{const{boxID:i,imageName:c}=s,l=P.find(C=>C.id===i);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==c),r=A(x({},l),{rects:g}),m=P.map(C=>C.id===i?r:C);return t==null||t.updatePolygonList(m!=null?m:[]),m},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:c,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(h.length===0||!r)){if(s||(k==null?void 0:k.info)){const m=s!=null?s:k==null?void 0:k.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(h[0]);const C=r.selectedPolygon;if(h.length===1&&m){Q({omitView:b.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((c||Y)&&h.length===1){const m=c!=null?c:Y;r.setSelectedID(h[0]);const C=r.selectedPoint;m&&J(b.Top,C,m,void 0,l,y)}}},gt=(s,i,c,l=F.Default)=>{if(pt){let g,r;switch(c){case b.Back:g=vo;break;case b.Side:g=Dt;break;default:g=Dt;break}if(r=g(s,i,pt,d.pointCloudInstance),o){const{count:v}=o.getSensesPointZAxisInPolygon(eo(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=A(x({},r),{count:v})}const C=M(lt({tool:st.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],S=r.valid!==C.valid;r=C;const _=Nt(r);return r=_.find(v=>v.id===r.id),Q({omitView:S?void 0:c,polygon:s,boxParams:r,newPointCloudBoxList:_},l),_}},ft=(s,i,c)=>{if(Y){let l,g;switch(c){case b.Back:l=Lo;break;case b.Side:l=wt;break;default:l=wt;break}g=l(s,i,Y);const r=ut(g);return J(c,s,g,void 0,r,y),r}},Gt=(s,i)=>{ft(s,i,b.Side)},Jt=(s,i)=>{ft(s,i,b.Back)},Qt=(s,i)=>{gt(s,i,b.Side,F.Single)},Xt=(s,i)=>{gt(s,i,b.Back,F.Single)},Yt=(s,i)=>{const c=At(s.id),l=dt(s,i,nt,c),g=ut(l);J(b.Top,s,l,void 0,g,y)},qt=(s,i)=>{if(Ot){const l=x({},s[0].newPolygon);l.pointList=l.pointList.map(g=>O.transferCanvas2World(g,i)),D(l);return}let c=s.map(({newPolygon:l})=>{const g=jt(l.id),{boxParams:r}=at(l,i,t.pointCloudInstance,g);return r});if(c=M(lt({tool:st.PointCloud,dataList:c,stepConfig:y,action:"viewUpdateBox"})),c.length===1){const{newPolygon:l}=s[0],g=et(c);Q({polygon:l,boxParams:c[0],newPointCloudBoxList:g},F.Single)}else{const l=et(c);l&&n.syncAllViewPointCloudColor(F.MultiMove,l)}},Kt=s=>{var i,c,l,g,r;if(k){const m=Number(s.widthDefault),C=Number(s.depthDefault),S=Number(s.heightDefault),_=k==null?void 0:k.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(q=>(q==null?void 0:q.trackID)===_),B={width:(l=(c=t==null?void 0:t.toolInstance)==null?void 0:c.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},Z=I.pointList.map(q=>O.transferCanvas2World(q,B)),G=w.getModifiedRectangleCoordinates(Z,S,m),H=G[0],it=G[2],Ct=w.getLineCenterPoint([H,it]),$t=k.info.center.z-k.info.depth/2,Pt=A(x({},k.info),{center:{x:Ct.x,y:Ct.y,z:$t+C/2},width:m,height:S,depth:C,valid:!0}),to=et([Pt]);Q({omitView:b["3D"],polygon:I,boxParams:Pt,newPointCloudBoxList:to})}},J=(s,i,c,l,g,r)=>bt(void 0,null,function*(){const m=W==null?void 0:W.url,C={[b.Side]:()=>{St(c,i,d,m,r)},[b.Back]:()=>{p&&_t(c,i,p,m,r)},[b.Top]:()=>{kt(c,i,t,o)}};Object.keys(C).forEach(S=>{S!==s&&C[S]()}),l&&(o==null||o.updateCameraZoom(l)),Et(c)}),Q=(s,i=F.Default)=>{const{omitView:c,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:m}=s,C=W==null?void 0:W.url;m&&n.syncAllViewPointCloudColor(i,m);const S={[b.Side]:()=>{Rt(g,l,d,C)},[b.Back]:()=>{p&&Vt(g,l,p,C)},[b.Top]:()=>{ct(g,l,t,o)}};Object.keys(S).forEach(_=>{_!==c&&S[_]()}),r&&(o==null||o.updateCameraZoom(r))};return{topViewAddSphere:Mt,topViewAddBox:Ht,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:Q,syncPointCloudPoint:J,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=W){var c,l,g,r,m,C,S,_;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(M,!0),vt(M,!0),(c=e==null?void 0:e.setResourceLoading)==null||c.call(e,!0),yield o.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:tt),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],I=[],B=[],Z=[];o.updateTopCamera();const G=(r=(g=rt(i.result))==null?void 0:g.valid)!=null?r:!0;if(n.setPointCloudValid(G),(m=n.sideViewInstance)==null||m.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(v=O.getBoxParamsFromResultList(i.result),(v==null?void 0:v.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(i.url,y,v);const H=rt(i.result);H[no].result=v,i.result=JSON.stringify(H),n.setPointCloudResult(v)}B=O.getPolygonListFromResultList(i.result),I=O.getLineListFromResultList(i.result),Z=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(S=y==null?void 0:y.radius)!=null?S:tt}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(Z),yield n.syncAllViewPointCloudColor(F.Default,v,[])}E({pointCloudBoxList:v,polygonList:B,lineList:I,pointCloudSphereList:Z}),Lt(M,!1),vt(M,!1),(_=e==null?void 0:e.setResourceLoading)==null||_.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:ot,update2DViewRect:Ft,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(xt),d=K(e),p=K(n);return{syncToPointCloudBoxList:ht(()=>{const f=d.current,u=p.current;if(u.length===0)return null;const a=new Map,h=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const L=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let R=a.get(L);R||(R=new Map,a.set(L,R)),R.set(T,V),h.add(L)}),a.size){const P=f.map(L=>{var T;const V=L.id;if(h.has(V)){const R=x({},L);return(T=R.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.get(V))==null?void 0:N.get(z))}),R}return L});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
1
+ import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as X,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as mt,useCallback as ht}from"react";import{PointCloudContext as xt}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as F}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as rt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as lt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as K}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,ho=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,x=(e,n)=>{for(var t in n||(n={}))ho.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))xo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((d,p)=>{var o=a=>{try{u(t.next(a))}catch(h){p(h)}},f=a=>{try{u(t.throw(a))}catch(h){p(h)}},u=a=>a.done?d(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const $=5,tt=90,It=.01,b={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(e,n,t,d,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,a={center:{x:o,y:f,z:u},id:e.id},h=d?x(x({},d),a):A(x({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},at=(e,n,t,d,p,o)=>{let f=e.pointList.map(D=>O.transferCanvas2World(D,n)),u=0,a=1,h={};if(t){const D=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&D.fittedCoordinates.length>0&&(f=D.fittedCoordinates),u=(D.maxZ+D.minZ)/2,a=D.maxZ-D.minZ,h={count:D.zCount}}const[P,L,T]=f,V=w.getLineCenterPoint([P,T]),R=w.getLineLength(P,L),U=w.getLineLength(L,T),N=w.getRadiusFromQuadrangle(e.pointList);d&&(u=d.center.z,a=d.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+It:U,height:o?R+It:R,depth:a,rotation:N,id:e.id},j=x(d?x(x({},d),z):A(x({},z),{attribute:"",valid:!0}),h);p&&Object.assign(j,p);const E=f.map(D=>O.transferWorld2Canvas(D,n));return{boxParams:j,newPointList:E}},wt=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x-d.x,y:t.center.y,z:t.center.z-d.y}})},Dt=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j,{newBoxParams:D}=d.getNewBoxBySideUpdate(V,E,N,t);return D},Lo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x,y:t.center.y-d.x,z:t.center.z-d.y}})},vo=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j;let{newBoxParams:D}=d.getNewBoxByBackUpdate(V,E,N,t);return D},St=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,X.Left);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{width:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,X.Back);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{height:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Back);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxBackPolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},kt=(e,n,t,d)=>{if(!t||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,X.Top),d.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(x(x({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},ct=(e,n,t,d)=>{var p,o;if(!t||!d)return;d.generateBox(e),d.setHighlightColor(e.id),d.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:a}=u.getBoxTopPolygon2DCoordinate(e),h=[...f.polygonList],P=h.find(L=>L.id===n.id);P?(P.pointList=a,P.valid=(p=e.valid)!=null?p:!0):h.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(h,n.id)},yo=e=>{const n=mt(xt),{topViewInstance:t,sideViewInstance:d,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:a,selectedIDs:h,pointCloudBoxList:P,pointCloudSphereList:L,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:R,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:E,pushHistoryUnderUpdatePolygon:D}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:ut,selectedSphere:Y}=ro(),{currentData:W,config:y}=ao(s=>{const{stepList:i,step:c,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:rt(uo.getCurrentStepInfo(c,i).config)}}),M=co(),Tt=K(R),Ut=K(z),zt=ht((s,i)=>{const c=Ut.current,l=i.id;return s.filter(r=>{if(!r)return!1;const m=c.get(r.imageName);return m===void 0?!0:Boolean(m.get(l))})},[]),ot=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!Tt.current||i){const{mappingImgList:c=[]}=W;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:et,getPointCloudByID:jt}=so({generateRects:ot}),pt=k==null?void 0:k.info;if(!t||!d||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:nt}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:s,size:i,zoom:c,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:L})});const m=dt(s,i,nt,void 0,r);a(s.id);const C=u(m);J(b.Top,s,m,c,C,y),j({newSphereParams:m})},Ht=({polygon:s,size:i,imgList:c,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var m,C,S;const _={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};l===!0&&Object.assign(_,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:L})}),t==null||t.toolInstance;const v=x({},s);let{boxParams:I,newPointList:B}=at(v,i,nt,void 0,_,r);I=M(lt({tool:st.PointCloud,dataList:[I],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(B==null?void 0:B.length)&&(v.pointList=B);const G=T.includes(v.attribute);ot(I);const H=f(I),it=(C=n==null?void 0:n.polygonList)!=null?C:[];I.subAttribute=oo.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(S=y==null?void 0:y.inputList)!=null?S:[]:[]),t==null||t.updatePolygonList(H!=null?H:[],it,!1),G?a([]):(a(I.id),r&&ct(I,v,t,o)),j({newBoxParams:I})},Ft=s=>{const{boxID:i,imageName:c,width:l,height:g,x:r,y:m}=s,C=P.find(B=>B.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(B=>B.imageName===c))return;const _=C.rects.map(B=>B.imageName===c?A(x({},B),{width:l,height:g,x:r,y:m}):B),v=A(x({},C),{rects:_}),I=P.map(B=>B.id===i?v:B);return t==null||t.updatePolygonList(I!=null?I:[]),I},Wt=s=>{const{boxID:i,imageName:c}=s,l=P.find(C=>C.id===i);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==c),r=A(x({},l),{rects:g}),m=P.map(C=>C.id===i?r:C);return t==null||t.updatePolygonList(m!=null?m:[]),m},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:c,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(h.length===0||!r)){if(s||(k==null?void 0:k.info)){const m=s!=null?s:k==null?void 0:k.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(h[0]);const C=r.selectedPolygon;if(h.length===1&&m){Q({omitView:b.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((c||Y)&&h.length===1){const m=c!=null?c:Y;r.setSelectedID(h[0]);const C=r.selectedPoint;m&&J(b.Top,C,m,void 0,l,y)}}},gt=(s,i,c,l=F.Default)=>{if(pt){let g,r;switch(c){case b.Back:g=vo;break;case b.Side:g=Dt;break;default:g=Dt;break}if(r=g(s,i,pt,d.pointCloudInstance),o){const{count:v}=o.getSensesPointZAxisInPolygon(eo(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=A(x({},r),{count:v})}const C=M(lt({tool:st.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],S=r.valid!==C.valid;r=C;const _=Nt(r);return r=_.find(v=>v.id===r.id),Q({omitView:S?void 0:c,polygon:s,boxParams:r,newPointCloudBoxList:_},l),_}},ft=(s,i,c)=>{if(Y){let l,g;switch(c){case b.Back:l=Lo;break;case b.Side:l=wt;break;default:l=wt;break}g=l(s,i,Y);const r=ut(g);return J(c,s,g,void 0,r,y),r}},Gt=(s,i)=>{ft(s,i,b.Side)},Jt=(s,i)=>{ft(s,i,b.Back)},Qt=(s,i)=>{gt(s,i,b.Side,F.Single)},Xt=(s,i)=>{gt(s,i,b.Back,F.Single)},Yt=(s,i)=>{const c=At(s.id),l=dt(s,i,nt,c),g=ut(l);J(b.Top,s,l,void 0,g,y)},qt=(s,i)=>{if(Ot){const l=x({},s[0].newPolygon);l.pointList=l.pointList.map(g=>O.transferCanvas2World(g,i)),D(l);return}let c=s.map(({newPolygon:l})=>{const g=jt(l.id),{boxParams:r}=at(l,i,t.pointCloudInstance,g);return r});if(c=M(lt({tool:st.PointCloud,dataList:c,stepConfig:y,action:"viewUpdateBox"})),c.length===1){const{newPolygon:l}=s[0],g=et(c);Q({polygon:l,boxParams:c[0],newPointCloudBoxList:g},F.Single)}else{const l=et(c);l&&n.syncAllViewPointCloudColor(F.MultiMove,l)}},Kt=s=>{var i,c,l,g,r;if(k){const m=Number(s.widthDefault),C=Number(s.depthDefault),S=Number(s.heightDefault),_=k==null?void 0:k.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(q=>(q==null?void 0:q.trackID)===_),B={width:(l=(c=t==null?void 0:t.toolInstance)==null?void 0:c.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},Z=I.pointList.map(q=>O.transferCanvas2World(q,B)),G=w.getModifiedRectangleCoordinates(Z,S,m),H=G[0],it=G[2],Ct=w.getLineCenterPoint([H,it]),$t=k.info.center.z-k.info.depth/2,Pt=A(x({},k.info),{center:{x:Ct.x,y:Ct.y,z:$t+C/2},width:m,height:S,depth:C,valid:!0}),to=et([Pt]);Q({omitView:b["3D"],polygon:I,boxParams:Pt,newPointCloudBoxList:to})}},J=(s,i,c,l,g,r)=>bt(void 0,null,function*(){const m=W==null?void 0:W.url,C={[b.Side]:()=>{St(c,i,d,m,r)},[b.Back]:()=>{p&&_t(c,i,p,m,r)},[b.Top]:()=>{kt(c,i,t,o)}};Object.keys(C).forEach(S=>{S!==s&&C[S]()}),l&&(o==null||o.updateCameraZoom(l)),Et(c)}),Q=(s,i=F.Default)=>{const{omitView:c,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:m}=s,C=W==null?void 0:W.url;m&&n.syncAllViewPointCloudColor(i,m);const S={[b.Side]:()=>{Rt(g,l,d,C)},[b.Back]:()=>{p&&Vt(g,l,p,C)},[b.Top]:()=>{ct(g,l,t,o)}};Object.keys(S).forEach(_=>{_!==c&&S[_]()}),r&&(o==null||o.updateCameraZoom(r))};return{topViewAddSphere:Mt,topViewAddBox:Ht,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:Q,syncPointCloudPoint:J,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=W){var c,l,g,r,m,C,S,_;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(M,!0),vt(M,!0),(c=e==null?void 0:e.setResourceLoading)==null||c.call(e,!0),yield o.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:tt),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],I=[],B=[],Z=[];o.updateTopCamera();const G=(r=(g=rt(i.result))==null?void 0:g.valid)!=null?r:!0;if(n.setPointCloudValid(G),(m=n.sideViewInstance)==null||m.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(v=O.getBoxParamsFromResultList(i.result),(v==null?void 0:v.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(i.url,y,v);const H=rt(i.result);H[no].result=v,i.result=JSON.stringify(H),n.setPointCloudResult(v)}B=O.getPolygonListFromResultList(i.result),I=O.getLineListFromResultList(i.result),Z=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(S=y==null?void 0:y.radius)!=null?S:tt}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(Z),yield n.syncAllViewPointCloudColor(F.Default,v,[])}E({pointCloudBoxList:v,polygonList:B,lineList:I,pointCloudSphereList:Z}),Lt(M,!1),vt(M,!1),(_=e==null?void 0:e.setResourceLoading)==null||_.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:ot,update2DViewRect:Ft,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(xt),d=K(e),p=K(n);return{syncToPointCloudBoxList:ht(()=>{const f=d.current,u=p.current;if(u.length===0)return null;const a=new Map,h=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const L=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let R=a.get(L);R||(R=new Map,a.set(L,R)),R.set(T,V),h.add(L)}),a.size){const P=f.map(L=>{var T;const V=L.id;if(h.has(V)){const R=x({},L);return(T=R.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.get(V))==null?void 0:N.get(z))}),R}return L});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.24.0-alpha.21",
3
+ "version": "1.24.0-alpha.23",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "^4.6.2",
46
- "@labelbee/lb-annotation": "1.28.0-alpha.10",
46
+ "@labelbee/lb-annotation": "1.28.0-alpha.12",
47
47
  "@labelbee/lb-utils": "1.20.0-alpha.1",
48
48
  "@labelbee/wavesurfer": "1.1.0",
49
49
  "@types/react-dom": "18.3.1",