@labelbee/lb-components 1.24.0-alpha.1 → 1.24.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
- package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
- package/dist/components/pointCloudView/PointCloudListener.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/components/pointCloudView/hooks/useUpdatePointCloudColor.js +1 -1
- package/es/components/pointCloud2DRectOperationView/index.js +1 -1
- package/es/components/pointCloudView/PointCloud3DView.js +1 -1
- package/es/components/pointCloudView/PointCloudListener.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/hooks/useUpdatePointCloudColor.js +1 -1
- package/package.json +2 -2
|
@@ -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"),util=require("./util.js"),useUpdateRectList=require("./useUpdateRectList.js"),_=require("lodash"),useToolStyle=require("../../hooks/useToolStyle.js"),index=require("../../store/toolConfig/index.js");function _interopDefaultLegacy(
|
|
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 +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");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,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,a,i)=>a in n?__defProp(n,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[a]=i,__spreadValues=(n,a)=>{for(var i in a||(a={}))__hasOwnProp.call(a,i)&&__defNormalProp(n,i,a[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(a))__propIsEnum.call(a,i)&&__defNormalProp(n,i,a[i]);return n},__spreadProps=(n,a)=>__defProps(n,__getOwnPropDescs(a));const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:n})=>{const{isActive:a,setTarget3DView:i}=React.useContext(PointCloud3DContext),d=
|
|
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");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,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,a,i)=>a in n?__defProp(n,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[a]=i,__spreadValues=(n,a)=>{for(var i in a||(a={}))__hasOwnProp.call(a,i)&&__defNormalProp(n,i,a[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(a))__propIsEnum.call(a,i)&&__defNormalProp(n,i,a[i]);return n},__spreadProps=(n,a)=>__defProps(n,__getOwnPropDescs(a));const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:n})=>{const{isActive:a,setTarget3DView:i}=React.useContext(PointCloud3DContext),d=e=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",e)]:!0,active:a});return React__default.default.createElement("span",{onClick:()=>{i(lbUtils.EPerspectiveView[n])},className:d(n.toLocaleLowerCase())})},PointCloud3DSideBar=({isEnlarge:n})=>{const{reset3DView:a,followTopView:i}=React.useContext(PointCloud3DContext),{t:d}=reactI18next.useTranslation(),e=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"})),p=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Tooltip,{title:d("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{i()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{a()},className:dom.getClassName("point-cloud-3d-view","reset")}));return n?React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebarZoom")},p,e):React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},e,p)},PointCloud3D=({currentData:n,config:a,highlightAttribute:i})=>{var d;const e=React.useContext(PointCloudContext.PointCloudContext),[p,y]=React.useState(!0),[m,g]=React.useState(!1),f=React.useRef(null),{initPointCloud3d:P}=usePointCloudViews.usePointCloudViews(),v=useSize(f),{t:V}=reactI18next.useTranslation(),{value:x}=useToolStyle.useToolStyleContext(),{hiddenText:_}=x||{};React.useEffect(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(_,e.pointCloudBoxList)},[x]),React.useEffect(()=>{!e.mainViewInstance||P==null||P(v)},[v]);const{selectedBox:u}=useSingleBox.useSingleBox(),{selectedSphere:w}=useSphere.useSphere(),[b,h]=React.useState(!0),E=t=>{var o,l;const r=u==null?void 0:u.info;if(r){const s=__spreadValues({},r.center);s.x=s.x-.01,s.z=1e3;const c=t===lbUtils.EPerspectiveView.Top;(o=e.mainViewInstance)==null||o.updateCameraByBox(r,t,c?s:void 0)}w&&((l=e.mainViewInstance)==null||l.updateCameraBySphere(w,t))},N=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},B=()=>{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(f.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&v.width&&(t=new lbAnnotation.PointCloud({container:f.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(v),config:a,hiddenText:_}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:h}),e.setMainViewInstance(t))}},[v,n]),React.useEffect(()=>{var t;if(f.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let o=e.mainViewInstance;const l=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result);l.forEach(s=>{var c;const C=(c=lbUtils.toolStyleConverter.getColorFromConfig({attribute:s.attribute},__spreadProps(__spreadValues({},a),{attributeConfigurable:!0}),{}))==null?void 0:c.hex;o==null||o.addBoxToSense(s,C)}),o.render(),e.setPointCloudResult(l);const r=lbUtils.PointCloudUtils.getRectParamsFromResultList(n.result);e.setRectList(r),e.setPointCloudValid((t=index.jsonParser(n.result))==null?void 0:t.valid)}},[n,e.mainViewInstance]),React.useEffect(()=>{var t,o,l,r,s,c,C;const T=(t=u==null?void 0:u.info)==null?void 0:t.id;if(!b){h(!0);return}if(T!==void 0){E(lbUtils.EPerspectiveView.Top);const q=(r=(l=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:l.camera.zoom)!=null?r:1;(s=e.mainViewInstance)==null||s.updateCameraZoom(q)}(c=e.mainViewInstance)==null||c.setHighlightColor(T),(C=e.mainViewInstance)==null||C.render()},[(d=u==null?void 0:u.info)==null?void 0:d.id]),React.useEffect(()=>{var t,o,l,r;if(w){E(lbUtils.EPerspectiveView.Top);const s=(l=(o=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:o.camera.zoom)!=null?l:1;(r=e.mainViewInstance)==null||r.updateCameraZoom(s)}},[w]),React.useEffect(()=>(window.addEventListener("keydown",I),()=>{window.removeEventListener("keydown",I)}),[]);const I=t=>{if(t.keyCode===EKeyCode.Esc){g(!1);return}},S=React.useMemo(()=>({reset3DView:N,setTarget3DView:E,isActive:!!u,followTopView:B}),[u,e.mainViewInstance]);React.useEffect(()=>{var t,o,l;const r=e.pointCloudBoxList.filter(s=>s.attribute===i);(r==null?void 0:r.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(o=e.mainViewInstance)==null||o.highlightBoxes(r)),r.length===0&&((l=e.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[i,e.mainViewInstance]);const L=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}},V("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:p,onChange:t=>{var o;y(t),(o=e.mainViewInstance)==null||o.setShowDirection(t)}}),m&&React__default.default.createElement(PointCloud3DContext.Provider,{value:S},React__default.default.createElement(PointCloud3DSideBar,{isEnlarge:m})));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-3d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:m}),title:m?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{g(!1)}}),V("3DView")):React__default.default.createElement(index$2,{title:V("3DView"),onClick:()=>{g(!0)}}),toolbar:L},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},!m&&React__default.default.createElement(PointCloud3DContext.Provider,{value:S},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:f})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),useUpdatePointCloudColor=require("./hooks/useUpdatePointCloudColor.js"),reactI18next=require("react-i18next"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,r,i)=>r in n?__defProp(n,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[r]=i,__spreadValues=(n,r)=>{for(var i in r||(r={}))__hasOwnProp.call(r,i)&&__defNormalProp(n,i,r[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(r))__propIsEnum.call(r,i)&&__defNormalProp(n,i,r[i]);return n},__spreadProps=(n,r)=>__defProps(n,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:n,config:r,checkMode:i,configString:
|
|
1
|
+
"use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),useUpdatePointCloudColor=require("./hooks/useUpdatePointCloudColor.js"),reactI18next=require("react-i18next"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,r,i)=>r in n?__defProp(n,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[r]=i,__spreadValues=(n,r)=>{for(var i in r||(r={}))__hasOwnProp.call(r,i)&&__defNormalProp(n,i,r[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(r))__propIsEnum.call(r,i)&&__defNormalProp(n,i,r[i]);return n},__spreadProps=(n,r)=>__defProps(n,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:n,config:r,checkMode:i,configString:V,imgIndex:C,toolInstanceRef:a,setResourceLoading:f})=>{const e=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:_,selectNextBox:E,selectPrevBox:B,updateSelectedBox:L,deleteSelectedPointCloudBoxAndPolygon:q}=useSingleBox.useSingleBox(),{selectedSphere:b,updatePointCloudSphere:I}=useSphere.useSphere(),{clearAllResult:P,updatePointCloudPattern:O}=useStatus.useStatus(),{copySelectedBoxes:j,pasteSelectedBoxes:A,copiedBoxes:$}=useBoxes.useBoxes({config:r,currentData:n}),{updateRotate:g}=useRotate.useRotate({currentData:n}),{updateRotateEdge:T}=useRotateEdge.useRotateEdge({currentData:n}),{updatePointCloudData:p,topViewSelectedChanged:D}=usePointCloudViews.usePointCloudViews({setResourceLoading:f}),{redo:h,undo:m,pushHistoryWithList:H,pushHistoryUnderUpdatePolygon:N,pushHistoryUnderUpdateLine:K}=useHistory.useHistory(),{syncThreeViewsAttribute:S}=useAttribute.useAttribute(),{syncAllViewsConfig:U,reRenderTopViewRange:R}=useConfig.useConfig(),{selectedPolygon:k}=usePolygon.usePolygon(),{selectedLine:x}=useLine.useLine(),{t:y}=reactI18next.useTranslation(),{updatePointCloudColor:z}=useUpdatePointCloudColor.useUpdatePointCloudColor(f,r),F=ahooks.useLatest(n),v=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},G=(t,o)=>{var s,u;const{topViewInstance:c,mainViewInstance:l}=e;if(!c)return;const{pointCloud2dOperation:w}=c;switch(t){case"q":{g(e.rectRotateSensitivity);break}case"e":g(-Number(e.rectRotateSensitivity));break;case"g":T(-90);break;case"u":{const d=w.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;O(d);const Y={[lbAnnotation.EToolName.Polygon]:y("PolygonPattern"),[lbAnnotation.EToolName.Rect]:y("RectPattern")};antd.message.success(y("ChangePatternMsg",{pattern:Y[d]})),w.clearActiveStatus(),w.clearDrawingStatus()}break;case"+":l==null||l.updatePointSize({zoomIn:!0});break;case"-":l==null||l.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){B();break}E(),o.preventDefault();break;case"f":_();break;case"arrowup":v({y:-1});break;case"arrowdown":v({y:1});break;case"arrowleft":v({x:-1});break;case"arrowright":v({x:1});break;case"delete":q(F.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const d=lbAnnotation.AttributeUtils.getAttributeByKeycode(o.keyCode,r.attributeList);d!==void 0&&((u=a.current)==null||u.setDefaultAttribute(d))}return}}},M=(t,o)=>{switch(t){case"c":j();break;case"v":A();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?h():m();break}}},W=ahooks.useLatest(t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t)||i===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){M(o,t);return}G(o,t)});return React.useEffect(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>W.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),React.useEffect(()=>{U(r)},[V]),React.useEffect(()=>{(r==null?void 0:r.radius)&&R(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{p==null||p()},[C,e.mainViewInstance]),React.useEffect(()=>{e.setHideAttributes([])},[C]),React.useEffect(()=>{a.current.setDefaultAttribute=t=>{var o;if(S(t),z(t),k&&N(__spreadProps(__spreadValues({},k),{attribute:t})),x&&K(__spreadProps(__spreadValues({},x),{attribute:t})),b){const s=I(__spreadProps(__spreadValues({},b),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),D({newSelectedSphere:b,newSphereList:s}))}},a.current.setSubAttribute=(t,o)=>{var s;const u=e.selectedPointCloudBox;if(u){const c=(s=u==null?void 0:u.subAttribute)!=null?s:{};u.subAttribute=__spreadProps(__spreadValues({},c),{[t]:o}),L(u),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(u.id),e.mainViewInstance.render())}},a.current.clearResult=()=>{P==null||P()},a.current.redo=()=>{h()},a.current.undo=()=>{m()},a.current.setValid=t=>{a.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&P()})},a.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},a.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},a.current.asyncData=t=>{setTimeout(()=>{p==null||p(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),React.useEffect(()=>{a.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},a.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),React.useEffect(()=>{a.current.history={pushHistory:t=>{H({pointCloudBoxList:t})},initRecord:()=>{}}},[]),React.useEffect(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||i)return;const s=l=>{S(l)},u=l=>{antd.message.error(l)},c=l=>{antd.message.info(l)};return o.on("syncAttribute",s),o.on("messageError",u),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",u),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var PointCloudListener$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudListener);module.exports=PointCloudListener$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((u,p)=>{var e=a=>{try{c(t.next(a))}catch(x){p(x)}},P=a=>{try{c(t.throw(a))}catch(x){p(x)}},c=a=>a.done?u(a.value):Promise.resolve(a.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,u,p)=>{const{x:e,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,n),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,a={center:{x:e,y:P,z:c},id:o.id},x=u?__spreadValues(__spreadValues({},u),a):__spreadProps(__spreadValues({},a),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},topViewPolygon2PointCloud=(o,n,t,u,p,e)=>{let P=o.pointList.map(B=>lbUtils.PointCloudUtils.transferCanvas2World(B,n)),c=0,a=1,x={};if(t){const B=t.getSensesPointZAxisInPolygon(P,void 0,e);e&&B.fittedCoordinates.length>0&&(P=B.fittedCoordinates),c=(B.maxZ+B.minZ)/2,a=B.maxZ-B.minZ,x={count:B.zCount}}const[f,L,R]=P,D=lbAnnotation.MathUtils.getLineCenterPoint([f,R]),w=lbAnnotation.MathUtils.getLineLength(f,L),V=lbAnnotation.MathUtils.getLineLength(L,R),T=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);u&&(c=u.center.z,a=u.depth);const k={center:{x:D.x,y:D.y,z:c},width:e?V+INTELLIGENT_FIT_MARGIN:V,height:e?w+INTELLIGENT_FIT_MARGIN:w,depth:a,rotation:T,id:o.id},O=__spreadValues(u?__spreadValues(__spreadValues({},u),k):__spreadProps(__spreadValues({},k),{attribute:"",valid:!0}),x);p&&Object.assign(O,p);const M=P.map(B=>lbUtils.PointCloudUtils.transferWorld2Canvas(B,n));return{boxParams:O,newPointList:M}},sideViewPoint2PointCloud=(o,n,t)=>{const u={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-u.x,y:t.center.y,z:t.center.z-u.y}})},sideViewPolygon2PointCloud=(o,n,t,u)=>{const[p,e,P]=o.pointList,[c,a,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),D={x:{x:f.x-L.x,y:f.y-L.y}.x,y:0,z:f.y-L.y},w=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,a),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(a,x),M=k-O,{newBoxParams:B}=u.getNewBoxBySideUpdate(D,M,T,t);return B},backViewPoint2PointCloud=(o,n,t)=>{const u={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x,y:t.center.y-u.x,z:t.center.z-u.y}})},backViewPolygon2PointCloud=(o,n,t,u)=>{const[p,e,P]=o.pointList,[c,a,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),D={x:{x:f.x-L.x,y:f.y-L.y}.x,y:0,z:f.y-L.y},w=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,a),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(a,x),M=k-O;let{newBoxParams:B}=u.getNewBoxByBackUpdate(D,M,T,t);return B},syncSideViewByPoint=(o,n,t,u,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(u,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:a}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(a);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,u)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(u,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);e.setInitCameraPosition(P);const{polygon2d:c,zoom:a}=e.getBoxSidePolygon2DCoordinate(o);e.camera.zoom=a,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncBackViewByPoint=(o,n,t,u,p)=>{var e;if(!t)return;const{toolInstance:P,pointCloudInstance:c}=t;c.loadPCDFile(u,(e=p==null?void 0:p.radius)!=null?e:DEFAULT_RADIUS);const{cameraPositionVector:a}=c.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(a);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,u)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:e}=t;e.loadPCDFileByBox(u,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=e.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);e.setInitCameraPosition(P);const{polygon2d:c,zoom:a}=e.getBoxBackPolygon2DCoordinate(o);e.camera.zoom=a,e.camera.updateProjectionMatrix(),e.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},syncTopViewByPoint=(o,n,t,u)=>{if(!t||!u)return;u.generateSphere(o),u.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),u.render();const{toolInstance:p,pointCloudInstance:e}=t,{point2d:P}=e.getSphereTopPoint2DCoordinate(o),c=[...p.pointList].map(a=>a.id===n.id?__spreadProps(__spreadValues(__spreadValues({},n),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):a);p.setResult(c),p.setSelectedID(n.id)},synchronizeTopView=(o,n,t,u)=>{var p,e;if(!t||!u)return;u.generateBox(o),u.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=t,{polygon2d:a}=c.getBoxTopPolygon2DCoordinate(o),x=[...P.polygonList],f=x.find(L=>L.id===n.id);f?(f.pointList=a,f.valid=(p=o.valid)!=null?p:!0):x.push({id:n.id,pointList:a,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:u,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:a,selectedIDs:x,pointCloudBoxList:f,pointCloudSphereList:L,hideAttributes:R,setHighlight2DDataList:D,cuboidBoxIn2DView:w,imageSizes:V,history:T,linkageImageNameRectMap:k}=n,{addHistory:O,initHistory:M,pushHistoryUnderUpdatePolygon:B}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:nt,updatePointCloudSphere:Y,selectedSphere:W}=useSphere.useSphere(),{currentData:j,config:y}=ctx.useSelector(s=>{const{stepList:i,step:d,imgList:l,imgIndex:r}=s.annotation;return{currentData:l[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(d,i).config)}}),z=ctx.useDispatch(),it=ahooks.useLatest(w),st=ahooks.useLatest(k),lt=React.useCallback((s,i)=>{const d=st.current,l=i.id;return s.filter(g=>{if(!g)return!1;const C=d.get(g.imageName);return C===void 0?!0:Boolean(C.get(l))})},[]),J=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!it.current||i){const{mappingImgList:d=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:d,imageSizes:V},{prepareRectsFn:lt})}},{selectedBox:U,updateSelectedBox:rt,updateSelectedBoxes:Q,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:J}),K=U==null?void 0:U.info;if(!t||!u||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=t,dt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},ut=({newPoint:s,size:i,zoom:d,trackConfigurable:l})=>{var r;const g={attribute:(r=t.toolInstance.defaultAttribute)!=null?r:""};l===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:L})});const C=topViewPoint2PointCloud(s,i,X,void 0,g);a(s.id);const h=c(C);q(PointCloudView.Top,s,C,d,h,y),O({newSphereParams:C})},ct=({polygon:s,size:i,imgList:d,trackConfigurable:l,zoom:r,intelligentFit:g})=>{var C,h,m;const b={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};l===!0&&Object.assign(b,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:L})});const S=t==null?void 0:t.toolInstance,I=__spreadValues({},s);let{boxParams:v,newPointList:A}=topViewPolygon2PointCloud(I,i,X,void 0,b,g);v=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[v],stepConfig:y,action:"viewUpdateBox"}))[0],g&&(A==null?void 0:A.length)&&(I.pointList=A);const E=R.includes(I.attribute);J(v);const F=P(v),Z=(h=n==null?void 0:n.polygonList)!=null?h:[];v.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(m=y==null?void 0:y.inputList)!=null?m:[]:[]),t==null||t.updatePolygonList(F!=null?F:[],Z),E?a([]):(a(v.id),S.selection.setSelectedIDs(I.id),N({omitView:PointCloudView.Top,polygon:I,boxParams:v,zoom:r,newPointCloudBoxList:F}),g&&synchronizeTopView(v,I,t,e)),O({newBoxParams:v})},pt=s=>{const{boxID:i,imageName:d,width:l,height:r,x:g,y:C}=s,h=f.find(v=>v.id===i);if(!(h==null?void 0:h.rects)||!h.rects.find(v=>v.imageName===d))return;const b=h.rects.map(v=>v.imageName===d?__spreadProps(__spreadValues({},v),{width:l,height:r,x:g,y:C}):v),S=__spreadProps(__spreadValues({},h),{rects:b}),I=f.map(v=>v.id===i?S:v);return t==null||t.updatePolygonList(I!=null?I:[]),I},gt=s=>{const{boxID:i,imageName:d}=s,l=f.find(h=>h.id===i);if(!(l==null?void 0:l.rects))return;const r=l.rects.filter(h=>h.imageName!==d),g=__spreadProps(__spreadValues({},l),{rects:r}),C=f.map(h=>h.id===i?g:h);return t==null||t.updatePolygonList(C!=null?C:[]),C},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:d,newSphereList:l})=>{var r;const g=t==null?void 0:t.toolInstance;if(!(x.length===0||!g)){if(s||(U==null?void 0:U.info)){const C=s!=null?s:U==null?void 0:U.info;(r=g==null?void 0:g.selection)==null||r.setSelectedIDs(x[0]);const h=g.selectedPolygon;if(x.length===1&&C){N({omitView:PointCloudView.Top,polygon:h,boxParams:C,newPointCloudBoxList:i});return}}if((d||W)&&x.length===1){const C=d!=null?d:W;g.setSelectedID(x[0]);const h=g.selectedPoint;C&&q(PointCloudView.Top,h,C,void 0,l,y)}}},$=(s,i,d)=>{if(K){let l,r;switch(d){case PointCloudView.Back:l=backViewPolygon2PointCloud;break;case PointCloudView.Side:l=sideViewPolygon2PointCloud;break;default:l=sideViewPolygon2PointCloud;break}if(r=l(s,i,K,u.pointCloudInstance),e){const{count:b}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:b})}const C=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],h=r.valid!==C.valid;r=C;const m=rt(r);return r=m.find(b=>b.id===r.id),N({omitView:h?void 0:d,polygon:s,boxParams:r,newPointCloudBoxList:m}),m}},tt=(s,i,d)=>{if(W){let l,r;switch(d){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}r=l(s,i,W);const g=Y(r);return q(d,s,r,void 0,g,y),g}},Ct=(s,i)=>{tt(s,i,PointCloudView.Side)},ft=(s,i)=>{tt(s,i,PointCloudView.Back)},ht=(s,i)=>{$(s,i,PointCloudView.Side)},xt=(s,i)=>{$(s,i,PointCloudView.Back)},vt=(s,i)=>{const d=nt(s.id),l=topViewPoint2PointCloud(s,i,X,d),r=Y(l);q(PointCloudView.Top,s,l,void 0,r,y)},Lt=(s,i)=>{if(ot){const l=__spreadValues({},s[0].newPolygon);l.pointList=l.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,i)),B(l);return}let d=s.map(({newPolygon:l})=>{const r=at(l.id),{boxParams:g}=topViewPolygon2PointCloud(l,i,t.pointCloudInstance,r);return g});if(d=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:d,stepConfig:y,action:"viewUpdateBox"})),d.length===1){const{newPolygon:l}=s[0],r=Q(d);N({polygon:l,boxParams:d[0],newPointCloudBoxList:r})}else{const l=Q(d);l&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,l)}},yt=s=>{var i,d,l,r,g;if(U){const C=Number(s.widthDefault),h=Number(s.depthDefault),m=Number(s.heightDefault),b=U==null?void 0:U.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(G=>(G==null?void 0:G.trackID)===b),v={width:(l=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:l.width,height:(g=(r=t==null?void 0:t.toolInstance)==null?void 0:r.basicImgInfo)==null?void 0:g.height},A=I.pointList.map(G=>lbUtils.PointCloudUtils.transferCanvas2World(G,v)),H=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(A,m,C),E=H[0],F=H[2],Z=lbAnnotation.MathUtils.getLineCenterPoint([E,F]),mt=U.info.center.z-U.info.depth/2,et=__spreadProps(__spreadValues({},U.info),{center:{x:Z.x,y:Z.y,z:mt+h/2},width:C,height:m,depth:h,valid:!0}),Bt=Q([et]);N({omitView:PointCloudView["3D"],polygon:I,boxParams:et,newPointCloudBoxList:Bt})}},q=(s,i,d,l,r,g)=>__async(void 0,null,function*(){const C=j==null?void 0:j.url,h={[PointCloudView.Side]:()=>{syncSideViewByPoint(d,i,u,C,g)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(d,i,p,C,g)},[PointCloudView.Top]:()=>{syncTopViewByPoint(d,i,t,e)}};Object.keys(h).forEach(m=>{m!==s&&h[m]()}),l&&(e==null||e.updateCameraZoom(l)),dt(d)}),N=(s,i=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:d,polygon:l,boxParams:r,zoom:g,newPointCloudBoxList:C}=s,h=j==null?void 0:j.url;C&&n.syncAllViewPointCloudColor(i,C);const m={[PointCloudView.Side]:()=>{synchronizeSideView(r,l,u,h)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(r,l,p,h)},[PointCloudView.Top]:()=>{synchronizeTopView(r,l,t,e)}};Object.keys(m).forEach(b=>{b!==d&&m[b]()}),g&&(e==null||e.updateCameraZoom(g))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:ht,backViewUpdateBox:xt,syncPointCloudViews:N,syncPointCloudPoint:q,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=j){var d,l,r,g,C,h,m,b;if(!(i==null?void 0:i.url)||!e)return;D([]),actionCreators.SetAnnotationLoading(z,!0),actionCreators.SetLoadPCDFileLoading(z,!0),(d=o==null?void 0:o.setResourceLoading)==null||d.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 S=[],I=[],v=[],A=[];e.updateTopCamera();const H=(g=(r=index.jsonParser(i.result))==null?void 0:r.valid)!=null?g:!0;if(n.setPointCloudValid(H),(C=n.sideViewInstance)==null||C.clearAllData(),(h=n.backViewInstance)==null||h.clearAllData(),i.result){if(S=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(S==null?void 0:S.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){S=yield e==null?void 0:e.filterPreResult(i.url,y,S);const E=index.jsonParser(i.result);E[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=S,i.result=JSON.stringify(E),n.setPointCloudResult(S)}v=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),I=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),A=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(m=y==null?void 0:y.radius)!=null?m:DEFAULT_RADIUS}),e==null||e.generateBoxes(S),e==null||e.generateSpheres(A),yield n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,S,[])}M({pointCloudBoxList:S,polygonList:v,lineList:I,pointCloudSphereList:A}),actionCreators.SetAnnotationLoading(z,!1),actionCreators.SetLoadPCDFileLoading(z,!1),(b=o==null?void 0:o.setResourceLoading)==null||b.call(o,!1)}),updateViewsByDefaultSize:yt,generateRects:J,update2DViewRect:pt,remove2DViewRect:gt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:n,setPointCloudResult:t}=React.useContext(PointCloudContext.PointCloudContext),u=ahooks.useLatest(o),p=ahooks.useLatest(n);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=u.current,c=p.current;if(c.length===0)return null;const a=new Map,x=new Set;if(c.filter(f=>f.extId!==void 0).forEach(f=>{const L=f.extId,R=f.imageName,D=_.pick(f,["x","y","width","height"]);let w=a.get(L);w||(w=new Map,a.set(L,w)),w.set(R,D),x.add(L)}),a.size){const f=P.map(L=>{var R;const D=L.id;if(x.has(D)){const w=__spreadValues({},L);return(R=w.rects)==null||R.forEach(V=>{var T;const k=V.imageName;Object.assign(V,(T=a.get(D))==null?void 0:T.get(k))}),w}return L});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(B=>lbUtils.PointCloudUtils.transferCanvas2World(B,n)),c=0,d=1,x={};if(t){const B=t.getSensesPointZAxisInPolygon(P,void 0,e);e&&B.fittedCoordinates.length>0&&(P=B.fittedCoordinates),c=(B.maxZ+B.minZ)/2,d=B.maxZ-B.minZ,x={count:B.zCount}}const[f,L,R]=P,D=lbAnnotation.MathUtils.getLineCenterPoint([f,R]),w=lbAnnotation.MathUtils.getLineLength(f,L),V=lbAnnotation.MathUtils.getLineLength(L,R),T=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);a&&(c=a.center.z,d=a.depth);const k={center:{x:D.x,y:D.y,z:c},width:e?V+INTELLIGENT_FIT_MARGIN:V,height:e?w+INTELLIGENT_FIT_MARGIN:w,depth:d,rotation:T,id:o.id},O=__spreadValues(a?__spreadValues(__spreadValues({},a),k):__spreadProps(__spreadValues({},k),{attribute:"",valid:!0}),x);p&&Object.assign(O,p);const M=P.map(B=>lbUtils.PointCloudUtils.transferWorld2Canvas(B,n));return{boxParams:O,newPointList:M}},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]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),D={x:{x:f.x-L.x,y:f.y-L.y}.x,y:0,z:f.y-L.y},w=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(d,x),M=k-O,{newBoxParams:B}=a.getNewBoxBySideUpdate(D,M,T,t);return B},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]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),D={x:{x:f.x-L.x,y:f.y-L.y}.x,y:0,z:f.y-L.y},w=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),T=w-V,k=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(d,x),M=k-O;let{newBoxParams:B}=a.getNewBoxByBackUpdate(D,M,T,t);return B},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(L=>L.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:L,hideAttributes:R,setHighlight2DDataList:D,cuboidBoxIn2DView:w,imageSizes:V,history:T,linkageImageNameRectMap:k}=n,{addHistory:O,initHistory:M,pushHistoryUnderUpdatePolygon:B}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:nt,updatePointCloudSphere:Y,selectedSphere:W}=useSphere.useSphere(),{currentData:j,config:y}=ctx.useSelector(s=>{const{stepList:i,step:u,imgList:l,imgIndex:r}=s.annotation;return{currentData:l[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(u,i).config)}}),z=ctx.useDispatch(),it=ahooks.useLatest(w),st=ahooks.useLatest(k),lt=React.useCallback((s,i)=>{const u=st.current,l=i.id;return s.filter(g=>{if(!g)return!1;const C=u.get(g.imageName);return C===void 0?!0:Boolean(C.get(l))})},[]),J=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!it.current||i){const{mappingImgList:u=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:u,imageSizes:V},{prepareRectsFn:lt})}},{selectedBox:U,updateSelectedBox:rt,updateSelectedBoxes:Q,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:J}),K=U==null?void 0:U.info;if(!t||!a||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=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 r;const g={attribute:(r=t.toolInstance.defaultAttribute)!=null?r:""};l===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:L})});const C=topViewPoint2PointCloud(s,i,X,void 0,g);d(s.id);const h=c(C);H(PointCloudView.Top,s,C,u,h,y),O({newSphereParams:C})},ct=({polygon:s,size:i,imgList:u,trackConfigurable:l,zoom:r,intelligentFit:g})=>{var C,h,m;const b={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};l===!0&&Object.assign(b,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:L})});const S=t==null?void 0:t.toolInstance,I=__spreadValues({},s);let{boxParams:v,newPointList:A}=topViewPolygon2PointCloud(I,i,X,void 0,b,g);v=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[v],stepConfig:y,action:"viewUpdateBox"}))[0],g&&(A==null?void 0:A.length)&&(I.pointList=A);const E=R.includes(I.attribute);J(v);const F=P(v),Z=(h=n==null?void 0:n.polygonList)!=null?h:[];v.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(m=y==null?void 0:y.inputList)!=null?m:[]:[]),t==null||t.updatePolygonList(F!=null?F:[],Z),E?d([]):(d(v.id),S.selection.setSelectedIDs(I.id),N({omitView:PointCloudView.Top,polygon:I,boxParams:v,zoom:r,newPointCloudBoxList:F}),g&&synchronizeTopView(v,I,t,e)),O({newBoxParams:v})},pt=s=>{const{boxID:i,imageName:u,width:l,height:r,x:g,y:C}=s,h=f.find(v=>v.id===i);if(!(h==null?void 0:h.rects)||!h.rects.find(v=>v.imageName===u))return;const b=h.rects.map(v=>v.imageName===u?__spreadProps(__spreadValues({},v),{width:l,height:r,x:g,y:C}):v),S=__spreadProps(__spreadValues({},h),{rects:b}),I=f.map(v=>v.id===i?S:v);return t==null||t.updatePolygonList(I!=null?I:[]),I},gt=s=>{const{boxID:i,imageName:u}=s,l=f.find(h=>h.id===i);if(!(l==null?void 0:l.rects))return;const r=l.rects.filter(h=>h.imageName!==u),g=__spreadProps(__spreadValues({},l),{rects:r}),C=f.map(h=>h.id===i?g:h);return t==null||t.updatePolygonList(C!=null?C:[]),C},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:u,newSphereList:l})=>{var r;const g=t==null?void 0:t.toolInstance;if(!(x.length===0||!g)){if(s||(U==null?void 0:U.info)){const C=s!=null?s:U==null?void 0:U.info;(r=g==null?void 0:g.selection)==null||r.setSelectedIDs(x[0]);const h=g.selectedPolygon;if(x.length===1&&C){N({omitView:PointCloudView.Top,polygon:h,boxParams:C,newPointCloudBoxList:i});return}}if((u||W)&&x.length===1){const C=u!=null?u:W;g.setSelectedID(x[0]);const h=g.selectedPoint;C&&H(PointCloudView.Top,h,C,void 0,l,y)}}},$=(s,i,u)=>{if(K){let l,r;switch(u){case PointCloudView.Back:l=backViewPolygon2PointCloud;break;case PointCloudView.Side:l=sideViewPolygon2PointCloud;break;default:l=sideViewPolygon2PointCloud;break}if(r=l(s,i,K,a.pointCloudInstance),e){const{count:b}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:b})}const C=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],h=r.valid!==C.valid;r=C;const m=rt(r);return r=m.find(b=>b.id===r.id),N({omitView:h?void 0:u,polygon:s,boxParams:r,newPointCloudBoxList:m}),m}},tt=(s,i,u)=>{if(W){let l,r;switch(u){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}r=l(s,i,W);const g=Y(r);return H(u,s,r,void 0,g,y),g}},Ct=(s,i)=>{tt(s,i,PointCloudView.Side)},ft=(s,i)=>{tt(s,i,PointCloudView.Back)},ht=(s,i)=>{$(s,i,PointCloudView.Side)},xt=(s,i)=>{$(s,i,PointCloudView.Back)},vt=(s,i)=>{const u=nt(s.id),l=topViewPoint2PointCloud(s,i,X,u),r=Y(l);H(PointCloudView.Top,s,l,void 0,r,y)},Lt=(s,i)=>{if(ot){const l=__spreadValues({},s[0].newPolygon);l.pointList=l.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,i)),B(l);return}let u=s.map(({newPolygon:l})=>{const r=at(l.id),{boxParams:g}=topViewPolygon2PointCloud(l,i,t.pointCloudInstance,r);return g});if(u=z(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:u,stepConfig:y,action:"viewUpdateBox"})),u.length===1){const{newPolygon:l}=s[0],r=Q(u);N({polygon:l,boxParams:u[0],newPointCloudBoxList:r})}else{const l=Q(u);l&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,l)}},yt=s=>{var i,u,l,r,g;if(U){const C=Number(s.widthDefault),h=Number(s.depthDefault),m=Number(s.heightDefault),b=U==null?void 0:U.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(G=>(G==null?void 0:G.trackID)===b),v={width:(l=(u=t==null?void 0:t.toolInstance)==null?void 0:u.basicImgInfo)==null?void 0:l.width,height:(g=(r=t==null?void 0:t.toolInstance)==null?void 0:r.basicImgInfo)==null?void 0:g.height},A=I.pointList.map(G=>lbUtils.PointCloudUtils.transferCanvas2World(G,v)),q=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(A,m,C),E=q[0],F=q[2],Z=lbAnnotation.MathUtils.getLineCenterPoint([E,F]),mt=U.info.center.z-U.info.depth/2,et=__spreadProps(__spreadValues({},U.info),{center:{x:Z.x,y:Z.y,z:mt+h/2},width:C,height:m,depth:h,valid:!0}),Bt=Q([et]);N({omitView:PointCloudView["3D"],polygon:I,boxParams:et,newPointCloudBoxList:Bt})}},H=(s,i,u,l,r,g)=>__async(void 0,null,function*(){const C=j==null?void 0:j.url,h={[PointCloudView.Side]:()=>{syncSideViewByPoint(u,i,a,C,g)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(u,i,p,C,g)},[PointCloudView.Top]:()=>{syncTopViewByPoint(u,i,t,e)}};Object.keys(h).forEach(m=>{m!==s&&h[m]()}),l&&(e==null||e.updateCameraZoom(l)),dt(u)}),N=(s,i=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:u,polygon:l,boxParams:r,zoom:g,newPointCloudBoxList:C}=s,h=j==null?void 0:j.url;C&&n.syncAllViewPointCloudColor(i,C);const m={[PointCloudView.Side]:()=>{synchronizeSideView(r,l,a,h)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(r,l,p,h)},[PointCloudView.Top]:()=>{synchronizeTopView(r,l,t,e)}};Object.keys(m).forEach(b=>{b!==u&&m[b]()}),g&&(e==null||e.updateCameraZoom(g))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:ht,backViewUpdateBox:xt,syncPointCloudViews:N,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=j){var u,l,r,g,C,h,m,b;if(!(i==null?void 0:i.url)||!e)return;D([]),actionCreators.SetAnnotationLoading(z,!0),actionCreators.SetLoadPCDFileLoading(z,!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 S=[],I=[],v=[],A=[];e.updateTopCamera();const q=(g=(r=index.jsonParser(i.result))==null?void 0:r.valid)!=null?g:!0;if(n.setPointCloudValid(q),(C=n.sideViewInstance)==null||C.clearAllData(),(h=n.backViewInstance)==null||h.clearAllData(),i.result){if(S=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(S==null?void 0:S.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){S=yield e==null?void 0:e.filterPreResult(i.url,y,S);const E=index.jsonParser(i.result);E[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=S,i.result=JSON.stringify(E),n.setPointCloudResult(S)}v=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),I=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),A=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(m=y==null?void 0:y.radius)!=null?m:DEFAULT_RADIUS}),e==null||e.generateBoxes(S),e==null||e.generateSpheres(A),yield n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,S,[])}M({pointCloudBoxList:S,polygonList:v,lineList:I,pointCloudSphereList:A}),actionCreators.SetAnnotationLoading(z,!1),actionCreators.SetLoadPCDFileLoading(z,!1),(b=o==null?void 0:o.setResourceLoading)==null||b.call(o,!1)}),updateViewsByDefaultSize:yt,generateRects:J,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 L=f.extId,R=f.imageName,D=_.pick(f,["x","y","width","height"]);let w=d.get(L);w||(w=new Map,d.set(L,w)),w.set(R,D),x.add(L)}),d.size){const f=P.map(L=>{var R;const D=L.id;if(x.has(D)){const w=__spreadValues({},L);return(R=w.rects)==null||R.forEach(V=>{var T;const k=V.imageName;Object.assign(V,(T=d.get(D))==null?void 0:T.get(k))}),w}return L});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
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),ctx=require("../../../store/ctx.js"),useSingleBox=require("./useSingleBox.js"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),actionCreators=require("../../../store/annotation/actionCreators.js"),usePointCloudViews=require("./usePointCloudViews.js"),useSphere=require("./useSphere.js"),useHistory=require("./useHistory.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js");const PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},useUpdatePointCloudColor=(v,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),ctx=require("../../../store/ctx.js"),useSingleBox=require("./useSingleBox.js"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),actionCreators=require("../../../store/annotation/actionCreators.js"),usePointCloudViews=require("./usePointCloudViews.js"),useSphere=require("./useSphere.js"),useHistory=require("./useHistory.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js");const PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},useUpdatePointCloudColor=(v,c)=>{const s=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:u,selectedIDs:i,pointCloudBoxList:l,mainViewInstance:d,selectedID:g}=s,f=ctx.useDispatch(),{selectedSphere:C}=useSphere.useSphere(),{syncPointCloudViews:p,syncPointCloudPoint:P,generateRects:h}=usePointCloudViews.usePointCloudViews({setResourceLoading:v}),{selectedBox:a,updateSelectedBox:x}=useSingleBox.useSingleBox({generateRects:h}),{pushHistoryWithList:V}=useHistory.useHistory(),q=({newSelectedSphere:n,newSphereList:o})=>{const e=u==null?void 0:u.toolInstance;if((n||C)&&i.length===1){const t=n!=null?n:C;e.setSelectedID(i[0]);const r=e.selectedPoint;t&&(P==null||P(PointCloudView.Top,r,t,void 0,o,c))}},y=({trigger:n,newSelectedBox:o})=>{const e=u==null?void 0:u.toolInstance;if(!(i.length===0||!e)&&(o||(a==null?void 0:a.info))){const t=o!=null?o:a==null?void 0:a.info,r=o;if(t){p==null||p({omitView:PointCloudView.Top,polygon:r,boxParams:t},n);return}}};return{updatePointCloudColor:n=>{if(l.forEach(o=>{var e,t,r;if(o&&i.includes(o.id)){o.attribute=n;const S=f(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[o],stepConfig:c,action:"viewUpdateBox"}));o.valid=S[0].valid,x(o),(r=(t=(e=s==null?void 0:s.topViewInstance)==null?void 0:e.pointCloud2dOperation)==null?void 0:t.setPolygonValidAndRender)==null||r.call(t,o.id,!0,o.valid),q({})}}),d){const o=i&&i.length>1?ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MulitSelect:ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single;s.syncAllViewPointCloudColor(o,l);let e;i&&i.length===1&&(e=l.find(t=>t.id===i[0]),y({trigger:o,newSelectedBox:e})),d.generateBoxes(l),e&&(d.setHighlightColor(e.id),d.render())}g||V({pointCloudBoxList:l})}}};exports.useUpdatePointCloudColor=useUpdatePointCloudColor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLatest as oe,useMemoizedFn as
|
|
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 +1 @@
|
|
|
1
|
-
import{getClassName as d}from"../../utils/dom.js";import{cKeyCode as
|
|
1
|
+
import{getClassName as d}from"../../utils/dom.js";import{cKeyCode as Q,PointCloud as W}from"@labelbee/lb-annotation";import{PointCloudUtils as T,toolStyleConverter as X,EPerspectiveView as h}from"@labelbee/lb-utils";import k from"classnames";import o,{useContext as b,useState as y,useRef as Y,useEffect as u,useMemo as $}from"react";import{PointCloudContainer as ee}from"./PointCloudLayout.js";import{PointCloudContext as te}from"./PointCloudContext.js";import{a2MapStateToProps as oe}from"../../store/annotation/map.js";import{connect as ne}from"react-redux";import{jsonParser as ie}from"../../utils/index.js";import{useSingleBox as le}from"./hooks/useSingleBox.js";import{useSphere as re}from"./hooks/useSphere.js";import{Switch as ae,Tooltip as se}from"antd";import ce from"../../hooks/useSize.js";import{usePointCloudViews as de}from"./hooks/usePointCloudViews.js";import{useTranslation as R}from"react-i18next";import{LabelBeeContext as me}from"../../store/ctx.js";import ue from"./components/PointCloudSizeSlider/index.js";import pe from"./components/TitleButton/index.js";import{LeftOutlined as ve}from"@ant-design/icons";import{useToolStyleContext as we}from"../../hooks/useToolStyle.js";var fe=Object.defineProperty,Ce=Object.defineProperties,Ve=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,ge=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,A=(n,l,r)=>l in n?fe(n,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[l]=r,H=(n,l)=>{for(var r in l||(l={}))ge.call(l,r)&&A(n,r,l[r]);if(F)for(var r of F(l))Pe.call(l,r)&&A(n,r,l[r]);return n},_e=(n,l)=>Ce(n,Ve(l));const he=Q.default,Ee="LABELBEE-POINTCLOUD",E=o.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),v=({perspectiveView:n})=>{const{isActive:l,setTarget3DView:r}=b(E),w=e=>k({[d("point-cloud-3d-view",e)]:!0,active:l});return o.createElement("span",{onClick:()=>{r(h[n])},className:w(n.toLocaleLowerCase())})},U=({isEnlarge:n})=>{const{reset3DView:l,followTopView:r}=b(E),{t:w}=R(),e=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"})),g=o.createElement(o.Fragment,null,o.createElement(se,{title:w("CameraFollowTopView")},o.createElement("span",{onClick:()=>{r()},className:d("point-cloud-3d-view","followTop")})),o.createElement("span",{onClick:()=>{l()},className:d("point-cloud-3d-view","reset")}));return n?o.createElement("div",{className:d("point-cloud-3d-sidebarZoom")},g,e):o.createElement("div",{className:d("point-cloud-3d-sidebar")},e,g)},Ie=({currentData:n,config:l,highlightAttribute:r})=>{var w;const e=b(te),[g,K]=y(!0),[f,I]=y(!1),C=Y(null),{initPointCloud3d:B}=de(),V=ce(C),{t:x}=R(),{value:L}=we(),{hiddenText:j}=L||{};u(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(j,e.pointCloudBoxList)},[L]),u(()=>{!e.mainViewInstance||B==null||B(V)},[V]);const{selectedBox:m}=le(),{selectedSphere:P}=re(),[M,O]=y(!0),S=t=>{var i,a;const s=m==null?void 0:m.info;if(s){const c=H({},s.center);c.x=c.x-.01,c.z=1e3;const p=t===h.Top;(i=e.mainViewInstance)==null||i.updateCameraByBox(s,t,p?c:void 0)}P&&((a=e.mainViewInstance)==null||a.updateCameraBySphere(P,t))},Z=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},q=()=>{var t,i;const a=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;a&&((i=e.mainViewInstance)==null||i.applyCameraTarget(a))};u(()=>{if(C.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&V.width&&(t=new W({container:C.current,isOrthographicCamera:!0,orthographicParams:T.getDefaultOrthographicParams(V),config:l,hiddenText:j}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:O}),e.setMainViewInstance(t))}},[V,n]),u(()=>{var t;if(C.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let i=e.mainViewInstance;const a=T.getBoxParamsFromResultList(n.result);a.forEach(c=>{var p;const _=(p=X.getColorFromConfig({attribute:c.attribute},_e(H({},l),{attributeConfigurable:!0}),{}))==null?void 0:p.hex;i==null||i.addBoxToSense(c,_)}),i.render(),e.setPointCloudResult(a);const s=T.getRectParamsFromResultList(n.result);e.setRectList(s),e.setPointCloudValid((t=ie(n.result))==null?void 0:t.valid)}},[n,e.mainViewInstance]),u(()=>{var t,i,a,s,c,p,_;const N=(t=m==null?void 0:m.info)==null?void 0:t.id;if(!M){O(!0);return}if(N!==void 0){S(h.Top);const J=(s=(a=(i=e.topViewInstance)==null?void 0:i.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?s:1;(c=e.mainViewInstance)==null||c.updateCameraZoom(J)}(p=e.mainViewInstance)==null||p.setHighlightColor(N),(_=e.mainViewInstance)==null||_.render()},[(w=m==null?void 0:m.info)==null?void 0:w.id]),u(()=>{var t,i,a,s;if(P){S(h.Top);const c=(a=(i=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?a:1;(s=e.mainViewInstance)==null||s.updateCameraZoom(c)}},[P]),u(()=>(window.addEventListener("keydown",D),()=>{window.removeEventListener("keydown",D)}),[]);const D=t=>{if(t.keyCode===he.Esc){I(!1);return}},z=$(()=>({reset3DView:Z,setTarget3DView:S,isActive:!!m,followTopView:q}),[m,e.mainViewInstance]);u(()=>{var t,i,a;const s=e.pointCloudBoxList.filter(c=>c.attribute===r);(s==null?void 0:s.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(i=e.mainViewInstance)==null||i.highlightBoxes(s)),s.length===0&&((a=e.mainViewInstance)==null||a.clearHighlightBoxesAndRender())},[r,e.mainViewInstance]);const G=o.createElement(o.Fragment,null,o.createElement(ue,{onChange:t=>{var i;(i=e.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),o.createElement("span",{style:{marginRight:8}},x("ShowArrows")),o.createElement(ae,{size:"small",checked:g,onChange:t=>{var i;K(t),(i=e.mainViewInstance)==null||i.setShowDirection(t)}}),f&&o.createElement(E.Provider,{value:z},o.createElement(U,{isEnlarge:f})));return o.createElement(ee,{className:k({[d("point-cloud-3d-container")]:!0,[d("point-cloud-container","zoom")]:f}),title:f?o.createElement("div",{style:{display:"flex",alignItems:"center"}},o.createElement(ve,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{I(!1)}}),x("3DView")):o.createElement(pe,{title:x("3DView"),onClick:()=>{I(!0)}}),toolbar:G},o.createElement("div",{className:d("point-cloud-3d-content")},!f&&o.createElement(E.Provider,{value:z},o.createElement(U,null)),o.createElement("div",{className:d("point-cloud-3d-view"),id:Ee,ref:C})))};var xe=ne(oe,null,null,{context:me})(Ie);export{xe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudContext as re}from"./PointCloudContext.js";import{useRotate as se}from"./hooks/useRotate.js";import{useRotateEdge as ne}from"./hooks/useRotateEdge.js";import{useBoxes as ie}from"./hooks/useBoxes.js";import{useSingleBox as ae}from"./hooks/useSingleBox.js";import{useSphere as ue}from"./hooks/useSphere.js";import{useContext as le,useEffect as d}from"react";import{CommonToolUtils as ce,AttributeUtils as de,EToolName as f,cTool as pe}from"@labelbee/lb-annotation";import{message as g}from"antd";import{connect as me}from"react-redux";import{a2MapStateToProps as be}from"../../store/annotation/map.js";import{useStatus as fe}from"./hooks/useStatus.js";import{usePointCloudViews as Pe}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as ye}from"../../store/ctx.js";import{useHistory as ve}from"./hooks/useHistory.js";import{useAttribute as we}from"./hooks/useAttribute.js";import{useConfig as Ce}from"./hooks/useConfig.js";import{usePolygon as he}from"./hooks/usePolygon.js";import{useLine as ge}from"./hooks/useLine.js";import{useUpdatePointCloudColor as Se}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as ke}from"react-i18next";import{useLatest as
|
|
1
|
+
import{PointCloudContext as re}from"./PointCloudContext.js";import{useRotate as se}from"./hooks/useRotate.js";import{useRotateEdge as ne}from"./hooks/useRotateEdge.js";import{useBoxes as ie}from"./hooks/useBoxes.js";import{useSingleBox as ae}from"./hooks/useSingleBox.js";import{useSphere as ue}from"./hooks/useSphere.js";import{useContext as le,useEffect as d}from"react";import{CommonToolUtils as ce,AttributeUtils as de,EToolName as f,cTool as pe}from"@labelbee/lb-annotation";import{message as g}from"antd";import{connect as me}from"react-redux";import{a2MapStateToProps as be}from"../../store/annotation/map.js";import{useStatus as fe}from"./hooks/useStatus.js";import{usePointCloudViews as Pe}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as ye}from"../../store/ctx.js";import{useHistory as ve}from"./hooks/useHistory.js";import{useAttribute as we}from"./hooks/useAttribute.js";import{useConfig as Ce}from"./hooks/useConfig.js";import{usePolygon as he}from"./hooks/usePolygon.js";import{useLine as ge}from"./hooks/useLine.js";import{useUpdatePointCloudColor as Se}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as ke}from"react-i18next";import{useLatest as O}from"ahooks";var xe=Object.defineProperty,Ve=Object.defineProperties,_e=Object.getOwnPropertyDescriptors,j=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,A=(n,r,a)=>r in n?xe(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,P=(n,r)=>{for(var a in r||(r={}))Be.call(r,a)&&A(n,a,r[a]);if(j)for(var a of j(r))Ie.call(r,a)&&A(n,a,r[a]);return n},y=(n,r)=>Ve(n,_e(r));const{EPolygonPattern:Le}=pe,Oe=({currentData:n,config:r,checkMode:a,configString:E,imgIndex:S,toolInstanceRef:i,setResourceLoading:k})=>{const e=le(re),{changeSelectedBoxValid:T,selectNextBox:D,selectPrevBox:H,updateSelectedBox:K,deleteSelectedPointCloudBoxAndPolygon:N}=ae(),{selectedSphere:v,updatePointCloudSphere:U}=ue(),{clearAllResult:w,updatePointCloudPattern:z}=fe(),{copySelectedBoxes:R,pasteSelectedBoxes:F,copiedBoxes:Ae}=ie({config:r,currentData:n}),{updateRotate:x}=se({currentData:n}),{updateRotateEdge:q}=ne({currentData:n}),{updatePointCloudData:m,topViewSelectedChanged:G}=Pe({setResourceLoading:k}),{redo:V,undo:_,pushHistoryWithList:M,pushHistoryUnderUpdatePolygon:W,pushHistoryUnderUpdateLine:Y}=ve(),{syncThreeViewsAttribute:B}=we(),{syncAllViewsConfig:$,reRenderTopViewRange:J}=Ce(),{selectedPolygon:I}=he(),{selectedLine:L}=ge(),{t:C}=ke(),{updatePointCloudColor:Q}=Se(k,r),X=O(n),b=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},Z=(t,o)=>{var s,u;const{topViewInstance:c,mainViewInstance:l}=e;if(!c)return;const{pointCloud2dOperation:h}=c;switch(t){case"q":{x(e.rectRotateSensitivity);break}case"e":x(-Number(e.rectRotateSensitivity));break;case"g":q(-90);break;case"u":{const p=h.pattern===Le.Normal?f.Rect:f.Polygon;z(p);const oe={[f.Polygon]:C("PolygonPattern"),[f.Rect]:C("RectPattern")};g.success(C("ChangePatternMsg",{pattern:oe[p]})),h.clearActiveStatus(),h.clearDrawingStatus()}break;case"+":l==null||l.updatePointSize({zoomIn:!0});break;case"-":l==null||l.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){H();break}D(),o.preventDefault();break;case"f":T();break;case"arrowup":b({y:-1});break;case"arrowdown":b({y:1});break;case"arrowleft":b({x:-1});break;case"arrowright":b({x:1});break;case"delete":N(X.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const p=de.getAttributeByKeycode(o.keyCode,r.attributeList);p!==void 0&&((u=i.current)==null||u.setDefaultAttribute(p))}return}}},ee=(t,o)=>{switch(t){case"c":R();break;case"v":F();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?V():_();break}}},te=O(t=>{if(!ce.hotkeyFilter(t)||a===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){ee(o,t);return}Z(o,t)});return d(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>te.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),d(()=>{$(r)},[E]),d(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),d(()=>{m==null||m()},[S,e.mainViewInstance]),d(()=>{e.setHideAttributes([])},[S]),d(()=>{i.current.setDefaultAttribute=t=>{var o;if(B(t),Q(t),I&&W(y(P({},I),{attribute:t})),L&&Y(y(P({},L),{attribute:t})),v){const s=U(y(P({},v),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),G({newSelectedSphere:v,newSphereList:s}))}},i.current.setSubAttribute=(t,o)=>{var s;const u=e.selectedPointCloudBox;if(u){const c=(s=u==null?void 0:u.subAttribute)!=null?s:{};u.subAttribute=y(P({},c),{[t]:o}),K(u),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(u.id),e.mainViewInstance.render())}},i.current.clearResult=()=>{w==null||w()},i.current.redo=()=>{V()},i.current.undo=()=>{_()},i.current.setValid=t=>{i.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&w()})},i.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},i.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},i.current.asyncData=t=>{setTimeout(()=>{m==null||m(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),d(()=>{i.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},i.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),d(()=>{i.current.history={pushHistory:t=>{M({pointCloudBoxList:t})},initRecord:()=>{}}},[]),d(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||a)return;const s=l=>{B(l)},u=l=>{g.error(l)},c=l=>{g.info(l)};return o.on("syncAttribute",s),o.on("messageError",u),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",u),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var je=me(be,null,null,{context:ye})(Oe);export{je 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 xt}from"react";import{PointCloudContext as ht}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as rt}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as lt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as dt,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 $}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,ho=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,L=(e,n)=>{for(var t in n||(n={}))xo.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))ho.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((c,p)=>{var o=d=>{try{u(t.next(d))}catch(x){p(x)}},f=d=>{try{u(t.throw(d))}catch(x){p(x)}},u=d=>d.done?c(d.value):Promise.resolve(d.value).then(o,f);u((t=t.apply(e,n)).next())});const tt=5,ot=90,wt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(e,n,t,c,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,d={center:{x:o,y:f,z:u},id:e.id},x=c?L(L({},c),d):A(L({},d),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},ct=(e,n,t,c,p,o)=>{let f=e.pointList.map(I=>O.transferCanvas2World(I,n)),u=0,d=1,x={};if(t){const I=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&I.fittedCoordinates.length>0&&(f=I.fittedCoordinates),u=(I.maxZ+I.minZ)/2,d=I.maxZ-I.minZ,x={count:I.zCount}}const[P,v,T]=f,V=w.getLineCenterPoint([P,T]),D=w.getLineLength(P,v),U=w.getLineLength(v,T),N=w.getRadiusFromQuadrangle(e.pointList);c&&(u=c.center.z,d=c.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+wt:U,height:o?D+wt:D,depth:d,rotation:N,id:e.id},j=L(c?L(L({},c),z):A(L({},z),{attribute:"",valid:!0}),x);p&&Object.assign(j,p);const M=f.map(I=>O.transferWorld2Canvas(I,n));return{boxParams:j,newPointList:M}},It=(e,n,t)=>{const c={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x-c.x,y:t.center.y,z:t.center.z-c.y}})},Dt=(e,n,t,c)=>{const[p,o,f]=e.pointList,[u,d,x]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,x]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,d),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(d,x),M=z-j,{newBoxParams:I}=c.getNewBoxBySideUpdate(V,M,N,t);return I},Lo=(e,n,t)=>{const c={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x,y:t.center.y-c.x,z:t.center.z-c.y}})},vo=(e,n,t,c)=>{const[p,o,f]=e.pointList,[u,d,x]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,x]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,d),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(d,x),M=z-j;let{newBoxParams:I}=c.getNewBoxByBackUpdate(V,M,N,t);return I},St=(e,n,t,c,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(c,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:d}=u.updateOrthoCameraBySphere(e,X.Left);u.setInitCameraPosition(d);const{point2d:x,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,c)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(c,e,{width:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:d}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=d,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,c,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(c,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:d}=u.updateOrthoCameraBySphere(e,X.Back);u.setInitCameraPosition(d);const{point2d:x,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,c)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(c,e,{height:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Back);o.setInitCameraPosition(f);const{polygon2d:u,zoom:d}=o.getBoxBackPolygon2DCoordinate(e);o.camera.zoom=d,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},kt=(e,n,t,c)=>{if(!t||!c)return;c.generateSphere(e),c.updateCameraBySphere(e,X.Top),c.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(d=>d.id===n.id?A(L(L({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):d);p.setResult(u),p.setSelectedID(n.id)},ut=(e,n,t,c)=>{var p,o;if(!t||!c)return;c.generateBox(e),c.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:d}=u.getBoxTopPolygon2DCoordinate(e),x=[...f.polygonList],P=x.find(v=>v.id===n.id);P?(P.pointList=d,P.valid=(p=e.valid)!=null?p:!0):x.push({id:n.id,pointList:d,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(x,n.id)},yo=e=>{const n=mt(ht),{topViewInstance:t,sideViewInstance:c,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:d,selectedIDs:x,pointCloudBoxList:P,pointCloudSphereList:v,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:D,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:M,pushHistoryUnderUpdatePolygon:I}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:pt,selectedSphere:Y}=ro(),{currentData:H,config:B}=ao(s=>{const{stepList:i,step:a,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:lt(uo.getCurrentStepInfo(a,i).config)}}),F=co(),Tt=$(D),Ut=$(z),zt=xt((s,i)=>{const a=Ut.current,r=i.id;return s.filter(g=>{if(!g)return!1;const C=a.get(g.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),et=s=>{const{enableAutoMap2DRect:i=!1}=B;if(!Tt.current||i){const{mappingImgList:a=[]}=H;po({pointCloudBox:s,mappingImgList:a,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:nt,getPointCloudByID:jt}=so({generateRects:et}),gt=k==null?void 0:k.info;if(!t||!c||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:it}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:s,size:i,zoom:a,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const C=at(s,i,it,void 0,g);d(s.id);const m=u(C);G(y.Top,s,C,a,m,B),j({newSphereParams:C})},Ft=({polygon:s,size:i,imgList:a,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,m,b;const S={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(S,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:v})});const _=t==null?void 0:t.toolInstance,R=L({},s);let{boxParams:h,newPointList:E}=ct(R,i,it,void 0,S,g);h=F(dt({tool:st.PointCloud,dataList:[h],stepConfig:B,action:"viewUpdateBox"}))[0],g&&(E==null?void 0:E.length)&&(R.pointList=E);const Z=T.includes(R.attribute);et(h);const Q=f(h),q=(m=n==null?void 0:n.polygonList)!=null?m:[];h.subAttribute=oo.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(b=B==null?void 0:B.inputList)!=null?b:[]:[]),t==null||t.updatePolygonList(Q!=null?Q:[],q),Z?d([]):(d(h.id),_.selection.setSelectedIDs(R.id),W({omitView:y.Top,polygon:R,boxParams:h,zoom:l,newPointCloudBoxList:Q}),g&&ut(h,R,t,o)),j({newBoxParams:h})},Ht=s=>{const{boxID:i,imageName:a,width:r,height:l,x:g,y:C}=s,m=P.find(h=>h.id===i);if(!(m==null?void 0:m.rects)||!m.rects.find(h=>h.imageName===a))return;const S=m.rects.map(h=>h.imageName===a?A(L({},h),{width:r,height:l,x:g,y:C}):h),_=A(L({},m),{rects:S}),R=P.map(h=>h.id===i?_:h);return t==null||t.updatePolygonList(R!=null?R:[]),R},Wt=s=>{const{boxID:i,imageName:a}=s,r=P.find(m=>m.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(m=>m.imageName!==a),g=A(L({},r),{rects:l}),C=P.map(m=>m.id===i?g:m);return t==null||t.updatePolygonList(C!=null?C:[]),C},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:a,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(x.length===0||!g)){if(s||(k==null?void 0:k.info)){const C=s!=null?s:k==null?void 0:k.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(x[0]);const m=g.selectedPolygon;if(x.length===1&&C){W({omitView:y.Top,polygon:m,boxParams:C,newPointCloudBoxList:i});return}}if((a||Y)&&x.length===1){const C=a!=null?a:Y;g.setSelectedID(x[0]);const m=g.selectedPoint;C&&G(y.Top,m,C,void 0,r,B)}}},ft=(s,i,a)=>{if(gt){let r,l;switch(a){case y.Back:r=vo;break;case y.Side:r=Dt;break;default:r=Dt;break}if(l=r(s,i,gt,c.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(eo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=A(L({},l),{count:S})}const C=F(dt({tool:st.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],m=l.valid!==C.valid;l=C;const b=Nt(l);return l=b.find(S=>S.id===l.id),W({omitView:m?void 0:a,polygon:s,boxParams:l,newPointCloudBoxList:b}),b}},Ct=(s,i,a)=>{if(Y){let r,l;switch(a){case y.Back:r=Lo;break;case y.Side:r=It;break;default:r=It;break}l=r(s,i,Y);const g=pt(l);return G(a,s,l,void 0,g,B),g}},Gt=(s,i)=>{Ct(s,i,y.Side)},Jt=(s,i)=>{Ct(s,i,y.Back)},Qt=(s,i)=>{ft(s,i,y.Side)},Xt=(s,i)=>{ft(s,i,y.Back)},Yt=(s,i)=>{const a=At(s.id),r=at(s,i,it,a),l=pt(r);G(y.Top,s,r,void 0,l,B)},qt=(s,i)=>{if(Ot){const r=L({},s[0].newPolygon);r.pointList=r.pointList.map(l=>O.transferCanvas2World(l,i)),I(r);return}let a=s.map(({newPolygon:r})=>{const l=jt(r.id),{boxParams:g}=ct(r,i,t.pointCloudInstance,l);return g});if(a=F(dt({tool:st.PointCloud,dataList:a,stepConfig:B,action:"viewUpdateBox"})),a.length===1){const{newPolygon:r}=s[0],l=nt(a);W({polygon:r,boxParams:a[0],newPointCloudBoxList:l})}else{const r=nt(a);r&&n.syncAllViewPointCloudColor(rt.MultiMove,r)}},Kt=s=>{var i,a,r,l,g;if(k){const C=Number(s.widthDefault),m=Number(s.depthDefault),b=Number(s.heightDefault),S=k==null?void 0:k.info.trackID,R=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(K=>(K==null?void 0:K.trackID)===S),h={width:(r=(a=t==null?void 0:t.toolInstance)==null?void 0:a.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},E=R.pointList.map(K=>O.transferCanvas2World(K,h)),J=w.getModifiedRectangleCoordinates(E,b,C),Z=J[0],Q=J[2],q=w.getLineCenterPoint([Z,Q]),$t=k.info.center.z-k.info.depth/2,Pt=A(L({},k.info),{center:{x:q.x,y:q.y,z:$t+m/2},width:C,height:b,depth:m,valid:!0}),to=nt([Pt]);W({omitView:y["3D"],polygon:R,boxParams:Pt,newPointCloudBoxList:to})}},G=(s,i,a,r,l,g)=>bt(void 0,null,function*(){const C=H==null?void 0:H.url,m={[y.Side]:()=>{St(a,i,c,C,g)},[y.Back]:()=>{p&&_t(a,i,p,C,g)},[y.Top]:()=>{kt(a,i,t,o)}};Object.keys(m).forEach(b=>{b!==s&&m[b]()}),r&&(o==null||o.updateCameraZoom(r)),Et(a)}),W=(s,i=rt.Default)=>{const{omitView:a,polygon:r,boxParams:l,zoom:g,newPointCloudBoxList:C}=s,m=H==null?void 0:H.url;C&&n.syncAllViewPointCloudColor(i,C);const b={[y.Side]:()=>{Rt(l,r,c,m)},[y.Back]:()=>{p&&Vt(l,r,p,m)},[y.Top]:()=>{ut(l,r,t,o)}};Object.keys(b).forEach(S=>{S!==a&&b[S]()}),g&&(o==null||o.updateCameraZoom(g))};return{topViewAddSphere:Mt,topViewAddBox:Ft,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:W,syncPointCloudPoint:G,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=H){var a,r,l,g,C,m,b,S;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(F,!0),vt(F,!0),(a=e==null?void 0:e.setResourceLoading)==null||a.call(e,!0),yield o.loadPCDFile(i.url,(r=B==null?void 0:B.radius)!=null?r:ot),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let _=[],R=[],h=[],E=[];o.updateTopCamera();const J=(g=(l=lt(i.result))==null?void 0:l.valid)!=null?g:!0;if(n.setPointCloudValid(J),(C=n.sideViewInstance)==null||C.clearAllData(),(m=n.backViewInstance)==null||m.clearAllData(),i.result){if(_=O.getBoxParamsFromResultList(i.result),(_==null?void 0:_.length)>0&&i.isPreResult&&(B==null?void 0:B.lowerLimitPointsNumInBox)>0){_=yield o==null?void 0:o.filterPreResult(i.url,B,_);const Z=lt(i.result);Z[no].result=_,i.result=JSON.stringify(Z),n.setPointCloudResult(_)}h=O.getPolygonListFromResultList(i.result),R=O.getLineListFromResultList(i.result),E=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(b=B==null?void 0:B.radius)!=null?b:ot}),o==null||o.generateBoxes(_),o==null||o.generateSpheres(E),yield n.syncAllViewPointCloudColor(rt.Default,_,[])}M({pointCloudBoxList:_,polygonList:h,lineList:R,pointCloudSphereList:E}),Lt(F,!1),vt(F,!1),(S=e==null?void 0:e.setResourceLoading)==null||S.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:et,update2DViewRect:Ht,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(ht),c=$(e),p=$(n);return{syncToPointCloudBoxList:xt(()=>{const f=c.current,u=p.current;if(u.length===0)return null;const d=new Map,x=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const v=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let D=d.get(v);D||(D=new Map,d.set(v,D)),D.set(T,V),x.add(v)}),d.size){const P=f.map(v=>{var T;const V=v.id;if(x.has(V)){const D=L({},v);return(T=D.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=d.get(V))==null?void 0:N.get(z))}),D}return v});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ut as synchronizeTopView,at as topViewPoint2PointCloud,ct as topViewPolygon2PointCloud,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 rt}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as lt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as dt,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 $}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,L=(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 tt=5,ot=90,wt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(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?L(L({},d),a):A(L({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},ct=(e,n,t,d,p,o)=>{let f=e.pointList.map(I=>O.transferCanvas2World(I,n)),u=0,a=1,h={};if(t){const I=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&I.fittedCoordinates.length>0&&(f=I.fittedCoordinates),u=(I.maxZ+I.minZ)/2,a=I.maxZ-I.minZ,h={count:I.zCount}}const[P,v,T]=f,V=w.getLineCenterPoint([P,T]),D=w.getLineLength(P,v),U=w.getLineLength(v,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+wt:U,height:o?D+wt:D,depth:a,rotation:N,id:e.id},j=L(d?L(L({},d),z):A(L({},z),{attribute:"",valid:!0}),h);p&&Object.assign(j,p);const M=f.map(I=>O.transferWorld2Canvas(I,n));return{boxParams:j,newPointList:M}},It=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(L({},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]),v=w.getLineCenterPoint([u,h]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,a),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),M=z-j,{newBoxParams:I}=d.getNewBoxBySideUpdate(V,M,N,t);return I},Lo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(L({},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]),v=w.getLineCenterPoint([u,h]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,a),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),M=z-j;let{newBoxParams:I}=d.getNewBoxByBackUpdate(V,M,N,t);return I},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:ot);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(L(L({},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:tt,depth:tt});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:ot);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(L(L({},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:tt,depth:tt});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(L(L({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},ut=(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(v=>v.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:v,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:D,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:M,pushHistoryUnderUpdatePolygon:I}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:pt,selectedSphere:Y}=ro(),{currentData:F,config:B}=ao(s=>{const{stepList:i,step:c,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:lt(uo.getCurrentStepInfo(c,i).config)}}),H=co(),Tt=$(D),Ut=$(z),zt=ht((s,i)=>{const c=Ut.current,r=i.id;return s.filter(g=>{if(!g)return!1;const C=c.get(g.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),et=s=>{const{enableAutoMap2DRect:i=!1}=B;if(!Tt.current||i){const{mappingImgList:c=[]}=F;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:nt,getPointCloudByID:jt}=so({generateRects:et}),gt=k==null?void 0:k.info;if(!t||!d||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:it}=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:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const C=at(s,i,it,void 0,g);a(s.id);const m=u(C);G(y.Top,s,C,c,m,B),j({newSphereParams:C})},Ht=({polygon:s,size:i,imgList:c,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,m,b;const S={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(S,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:v})});const _=t==null?void 0:t.toolInstance,R=L({},s);let{boxParams:x,newPointList:E}=ct(R,i,it,void 0,S,g);x=H(dt({tool:st.PointCloud,dataList:[x],stepConfig:B,action:"viewUpdateBox"}))[0],g&&(E==null?void 0:E.length)&&(R.pointList=E);const Z=T.includes(R.attribute);et(x);const Q=f(x),q=(m=n==null?void 0:n.polygonList)!=null?m:[];x.subAttribute=oo.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(b=B==null?void 0:B.inputList)!=null?b:[]:[]),t==null||t.updatePolygonList(Q!=null?Q:[],q),Z?a([]):(a(x.id),_.selection.setSelectedIDs(R.id),W({omitView:y.Top,polygon:R,boxParams:x,zoom:l,newPointCloudBoxList:Q}),g&&ut(x,R,t,o)),j({newBoxParams:x})},Ft=s=>{const{boxID:i,imageName:c,width:r,height:l,x:g,y:C}=s,m=P.find(x=>x.id===i);if(!(m==null?void 0:m.rects)||!m.rects.find(x=>x.imageName===c))return;const S=m.rects.map(x=>x.imageName===c?A(L({},x),{width:r,height:l,x:g,y:C}):x),_=A(L({},m),{rects:S}),R=P.map(x=>x.id===i?_:x);return t==null||t.updatePolygonList(R!=null?R:[]),R},Wt=s=>{const{boxID:i,imageName:c}=s,r=P.find(m=>m.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(m=>m.imageName!==c),g=A(L({},r),{rects:l}),C=P.map(m=>m.id===i?g:m);return t==null||t.updatePolygonList(C!=null?C:[]),C},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:c,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(h.length===0||!g)){if(s||(k==null?void 0:k.info)){const C=s!=null?s:k==null?void 0:k.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(h[0]);const m=g.selectedPolygon;if(h.length===1&&C){W({omitView:y.Top,polygon:m,boxParams:C,newPointCloudBoxList:i});return}}if((c||Y)&&h.length===1){const C=c!=null?c:Y;g.setSelectedID(h[0]);const m=g.selectedPoint;C&&G(y.Top,m,C,void 0,r,B)}}},ft=(s,i,c)=>{if(gt){let r,l;switch(c){case y.Back:r=vo;break;case y.Side:r=Dt;break;default:r=Dt;break}if(l=r(s,i,gt,d.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(eo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=A(L({},l),{count:S})}const C=H(dt({tool:st.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],m=l.valid!==C.valid;l=C;const b=Nt(l);return l=b.find(S=>S.id===l.id),W({omitView:m?void 0:c,polygon:s,boxParams:l,newPointCloudBoxList:b}),b}},Ct=(s,i,c)=>{if(Y){let r,l;switch(c){case y.Back:r=Lo;break;case y.Side:r=It;break;default:r=It;break}l=r(s,i,Y);const g=pt(l);return G(c,s,l,void 0,g,B),g}},Gt=(s,i)=>{Ct(s,i,y.Side)},Jt=(s,i)=>{Ct(s,i,y.Back)},Qt=(s,i)=>{ft(s,i,y.Side)},Xt=(s,i)=>{ft(s,i,y.Back)},Yt=(s,i)=>{const c=At(s.id),r=at(s,i,it,c),l=pt(r);G(y.Top,s,r,void 0,l,B)},qt=(s,i)=>{if(Ot){const r=L({},s[0].newPolygon);r.pointList=r.pointList.map(l=>O.transferCanvas2World(l,i)),I(r);return}let c=s.map(({newPolygon:r})=>{const l=jt(r.id),{boxParams:g}=ct(r,i,t.pointCloudInstance,l);return g});if(c=H(dt({tool:st.PointCloud,dataList:c,stepConfig:B,action:"viewUpdateBox"})),c.length===1){const{newPolygon:r}=s[0],l=nt(c);W({polygon:r,boxParams:c[0],newPointCloudBoxList:l})}else{const r=nt(c);r&&n.syncAllViewPointCloudColor(rt.MultiMove,r)}},Kt=s=>{var i,c,r,l,g;if(k){const C=Number(s.widthDefault),m=Number(s.depthDefault),b=Number(s.heightDefault),S=k==null?void 0:k.info.trackID,R=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(K=>(K==null?void 0:K.trackID)===S),x={width:(r=(c=t==null?void 0:t.toolInstance)==null?void 0:c.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},E=R.pointList.map(K=>O.transferCanvas2World(K,x)),J=w.getModifiedRectangleCoordinates(E,b,C),Z=J[0],Q=J[2],q=w.getLineCenterPoint([Z,Q]),$t=k.info.center.z-k.info.depth/2,Pt=A(L({},k.info),{center:{x:q.x,y:q.y,z:$t+m/2},width:C,height:b,depth:m,valid:!0}),to=nt([Pt]);W({omitView:y["3D"],polygon:R,boxParams:Pt,newPointCloudBoxList:to})}},G=(s,i,c,r,l,g)=>bt(void 0,null,function*(){const C=F==null?void 0:F.url,m={[y.Side]:()=>{St(c,i,d,C,g)},[y.Back]:()=>{p&&_t(c,i,p,C,g)},[y.Top]:()=>{kt(c,i,t,o)}};Object.keys(m).forEach(b=>{b!==s&&m[b]()}),r&&(o==null||o.updateCameraZoom(r)),Et(c)}),W=(s,i=rt.Default)=>{const{omitView:c,polygon:r,boxParams:l,zoom:g,newPointCloudBoxList:C}=s,m=F==null?void 0:F.url;C&&n.syncAllViewPointCloudColor(i,C);const b={[y.Side]:()=>{Rt(l,r,d,m)},[y.Back]:()=>{p&&Vt(l,r,p,m)},[y.Top]:()=>{ut(l,r,t,o)}};Object.keys(b).forEach(S=>{S!==c&&b[S]()}),g&&(o==null||o.updateCameraZoom(g))};return{topViewAddSphere:Mt,topViewAddBox:Ht,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:W,syncPointCloudPoint:G,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=F){var c,r,l,g,C,m,b,S;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(H,!0),vt(H,!0),(c=e==null?void 0:e.setResourceLoading)==null||c.call(e,!0),yield o.loadPCDFile(i.url,(r=B==null?void 0:B.radius)!=null?r:ot),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let _=[],R=[],x=[],E=[];o.updateTopCamera();const J=(g=(l=lt(i.result))==null?void 0:l.valid)!=null?g:!0;if(n.setPointCloudValid(J),(C=n.sideViewInstance)==null||C.clearAllData(),(m=n.backViewInstance)==null||m.clearAllData(),i.result){if(_=O.getBoxParamsFromResultList(i.result),(_==null?void 0:_.length)>0&&i.isPreResult&&(B==null?void 0:B.lowerLimitPointsNumInBox)>0){_=yield o==null?void 0:o.filterPreResult(i.url,B,_);const Z=lt(i.result);Z[no].result=_,i.result=JSON.stringify(Z),n.setPointCloudResult(_)}x=O.getPolygonListFromResultList(i.result),R=O.getLineListFromResultList(i.result),E=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(b=B==null?void 0:B.radius)!=null?b:ot}),o==null||o.generateBoxes(_),o==null||o.generateSpheres(E),yield n.syncAllViewPointCloudColor(rt.Default,_,[])}M({pointCloudBoxList:_,polygonList:x,lineList:R,pointCloudSphereList:E}),Lt(H,!1),vt(H,!1),(S=e==null?void 0:e.setResourceLoading)==null||S.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:et,update2DViewRect:Ft,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(xt),d=$(e),p=$(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 v=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let D=a.get(v);D||(D=new Map,a.set(v,D)),D.set(T,V),h.add(v)}),a.size){const P=f.map(v=>{var T;const V=v.id;if(h.has(V)){const D=L({},v);return(T=D.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.get(V))==null?void 0:N.get(z))}),D}return v});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ut as synchronizeTopView,at as topViewPoint2PointCloud,ct as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as w}from"react";import{useDispatch as D}from"../../../store/ctx.js";import{useSingleBox as b}from"./useSingleBox.js";import{PointCloudContext as T}from"../PointCloudContext.js";import{EPointCloudName as
|
|
1
|
+
import{useContext as w}from"react";import{useDispatch as D}from"../../../store/ctx.js";import{useSingleBox as b}from"./useSingleBox.js";import{PointCloudContext as T}from"../PointCloudContext.js";import{EPointCloudName as H}from"@labelbee/lb-annotation";import{PreDataProcess as R}from"../../../store/annotation/actionCreators.js";import{usePointCloudViews as E}from"./usePointCloudViews.js";import{useSphere as L}from"./useSphere.js";import{useHistory as _}from"./useHistory.js";import{EPointCloudBoxRenderTrigger as m}from"../../../utils/ToolPointCloudBoxRenderHelper.js";const P={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},k=(g,c)=>{const r=w(T),{topViewInstance:d,selectedIDs:n,pointCloudBoxList:s,mainViewInstance:u,selectedID:v}=r,h=D(),{selectedSphere:p}=L(),{syncPointCloudViews:C,syncPointCloudPoint:f,generateRects:V}=E({setResourceLoading:g}),{selectedBox:a,updateSelectedBox:j}=b({generateRects:V}),{pushHistoryWithList:x}=_(),y=({newSelectedSphere:e,newSphereList:o})=>{const t=d==null?void 0:d.toolInstance;if((e||p)&&n.length===1){const i=e!=null?e:p;t.setSelectedID(n[0]);const l=t.selectedPoint;i&&(f==null||f(P.Top,l,i,void 0,o,c))}},I=({trigger:e,newSelectedBox:o})=>{const t=d==null?void 0:d.toolInstance;if(!(n.length===0||!t)&&(o||(a==null?void 0:a.info))){const i=o!=null?o:a==null?void 0:a.info,l=o;if(i){C==null||C({omitView:P.Top,polygon:l,boxParams:i},e);return}}};return{updatePointCloudColor:e=>{if(s.forEach(o=>{var t,i,l;if(o&&n.includes(o.id)){o.attribute=e;const S=h(R({tool:H.PointCloud,dataList:[o],stepConfig:c,action:"viewUpdateBox"}));o.valid=S[0].valid,j(o),(l=(i=(t=r==null?void 0:r.topViewInstance)==null?void 0:t.pointCloud2dOperation)==null?void 0:i.setPolygonValidAndRender)==null||l.call(i,o.id,!0,o.valid),y({})}}),u){const o=n&&n.length>1?m.MulitSelect:m.Single;r.syncAllViewPointCloudColor(o,s);let t;n&&n.length===1&&(t=s.find(i=>i.id===n[0]),I({trigger:o,newSelectedBox:t})),u.generateBoxes(s),t&&(u.setHighlightColor(t.id),u.render())}v||x({pointCloudBoxList:s})}}};export{k as useUpdatePointCloudColor};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.24.0-alpha.
|
|
3
|
+
"version": "1.24.0-alpha.3",
|
|
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.
|
|
46
|
+
"@labelbee/lb-annotation": "1.28.0-alpha.2",
|
|
47
47
|
"@labelbee/lb-utils": "1.19.0",
|
|
48
48
|
"@labelbee/wavesurfer": "1.1.0",
|
|
49
49
|
"@types/react-dom": "^18.2.7",
|