@labelbee/lb-components 1.12.1 → 1.12.2-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var dom=require("../../utils/dom.js"),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");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}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=(t,a,e)=>a in t?__defProp(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e,__spreadValues=(t,a)=>{for(var e in a||(a={}))__hasOwnProp.call(a,e)&&__defNormalProp(t,e,a[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(a))__propIsEnum.call(a,e)&&__defNormalProp(t,e,a[e]);return t},__spreadProps=(t,a)=>__defProps(t,__getOwnPropDescs(a));const pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:t})=>{const{isActive:a,setTarget3DView:e}=React.useContext(PointCloud3DContext),m=p=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",p)]:!0,active:a});return React__default.default.createElement("span",{onClick:()=>{e(lbUtils.EPerspectiveView[t])},className:m(t.toLocaleLowerCase())})},PointCloud3DSideBar=()=>{const{reset3DView:t,followTopView:a}=React.useContext(PointCloud3DContext),{t:e}=reactI18next.useTranslation();return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},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"}),React__default.default.createElement(antd.Tooltip,{title:e("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{a()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{t()},className:dom.getClassName("point-cloud-3d-view","reset")}))},PointCloud3D=({currentData:t,config:a})=>{const e=React.useContext(PointCloudContext.PointCloudContext),[m,p]=React.useState(!0),u=React.useRef(null),{initPointCloud3d:w}=usePointCloudViews.usePointCloudViews(),c=useSize(u),{t:C}=reactI18next.useTranslation();React.useEffect(()=>{!e.mainViewInstance||w==null||w(c)},[c]);const{selectedBox:s}=useSingleBox.useSingleBox(),{selectedSphere:d}=useSphere.useSphere(),v=o=>{var n,i;const r=s==null?void 0:s.info;if(r){const l=__spreadValues({},r.center);l.x=l.x-.01,l.z=
|
|
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");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}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=(t,a,e)=>a in t?__defProp(t,a,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[a]=e,__spreadValues=(t,a)=>{for(var e in a||(a={}))__hasOwnProp.call(a,e)&&__defNormalProp(t,e,a[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(a))__propIsEnum.call(a,e)&&__defNormalProp(t,e,a[e]);return t},__spreadProps=(t,a)=>__defProps(t,__getOwnPropDescs(a));const pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:t})=>{const{isActive:a,setTarget3DView:e}=React.useContext(PointCloud3DContext),m=p=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",p)]:!0,active:a});return React__default.default.createElement("span",{onClick:()=>{e(lbUtils.EPerspectiveView[t])},className:m(t.toLocaleLowerCase())})},PointCloud3DSideBar=()=>{const{reset3DView:t,followTopView:a}=React.useContext(PointCloud3DContext),{t:e}=reactI18next.useTranslation();return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},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"}),React__default.default.createElement(antd.Tooltip,{title:e("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{a()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{t()},className:dom.getClassName("point-cloud-3d-view","reset")}))},PointCloud3D=({currentData:t,config:a})=>{const e=React.useContext(PointCloudContext.PointCloudContext),[m,p]=React.useState(!0),u=React.useRef(null),{initPointCloud3d:w}=usePointCloudViews.usePointCloudViews(),c=useSize(u),{t:C}=reactI18next.useTranslation();React.useEffect(()=>{!e.mainViewInstance||w==null||w(c)},[c]);const{selectedBox:s}=useSingleBox.useSingleBox(),{selectedSphere:d}=useSphere.useSphere(),v=o=>{var n,i;const r=s==null?void 0:s.info;if(r){const l=__spreadValues({},r.center);l.x=l.x-.01,l.z=1e3;const f=o===lbUtils.EPerspectiveView.Top;(n=e.mainViewInstance)==null||n.updateCameraByBox(r,o,f?l:void 0)}d&&((i=e.mainViewInstance)==null||i.updateCameraBySphere(d,o))},V=()=>{var o;(o=e.mainViewInstance)==null||o.resetCamera()},P=()=>{var o,n;const i=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance.camera;i&&((n=e.mainViewInstance)==null||n.applyCameraTarget(i))};React.useEffect(()=>{if(u.current&&(t==null?void 0:t.url)){let o=e.mainViewInstance;!o&&c.width&&(o=new lbAnnotation.PointCloud({container:u.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(c),config:a}),e.setMainViewInstance(o))}},[c,t]),React.useEffect(()=>{var o;if(u.current&&(t==null?void 0:t.url)&&t.result&&e.mainViewInstance){let n=e.mainViewInstance;const i=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t.result);i.forEach(r=>{var l;const f=(l=lbUtils.toolStyleConverter.getColorFromConfig({attribute:r.attribute},__spreadProps(__spreadValues({},a),{attributeConfigurable:!0}),{}))==null?void 0:l.hex;n==null||n.generateBox(r,f)}),e.setPointCloudResult(i),e.setPointCloudValid((o=index.jsonParser(t.result))==null?void 0:o.valid)}},[t,e.mainViewInstance]),React.useEffect(()=>{var o,n,i,r;if(s){v(lbUtils.EPerspectiveView.Top);const l=(i=(n=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:n.camera.zoom)!=null?i:1;(r=e.mainViewInstance)==null||r.updateCameraZoom(l)}},[s]),React.useEffect(()=>{var o,n,i,r;if(d){v(lbUtils.EPerspectiveView.Top);const l=(i=(n=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:n.camera.zoom)!=null?i:1;(r=e.mainViewInstance)==null||r.updateCameraZoom(l)}},[d]);const _=React.useMemo(()=>({reset3DView:V,setTarget3DView:v,isActive:!!s,followTopView:P}),[s,e.mainViewInstance]),g=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:o=>{var n;(n=e.mainViewInstance)==null||n.updatePointSize({customSize:o})}}),React__default.default.createElement("span",{style:{marginRight:8}},C("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:m,onChange:o=>{var n;p(o),(n=e.mainViewInstance)==null||n.setShowDirection(o)}}));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-3d-container"),title:C("3DView"),toolbar:g},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},React__default.default.createElement(PointCloud3DContext.Provider,{value:_},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:u})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
|
|
@@ -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"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,o,i)=>o in e?__defProp(e,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[o]=i,__spreadValues=(e,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(e,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(e,i,o[i]);return e},__spreadProps=(e,o)=>__defProps(e,__getOwnPropDescs(o)),__async=(e,o,i)=>new Promise((l,t)=>{var a=d=>{try{r(i.next(d))}catch(g){t(g)}},p=d=>{try{r(i.throw(d))}catch(g){t(g)}},r=d=>d.done?l(d.value):Promise.resolve(d.value).then(a,p);r((i=i.apply(e,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,o,i,l,t)=>{const{x:a,y:p}=lbUtils.PointCloudUtils.transferCanvas2World(e,o),{defaultZ:r}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:a,y:p,z:r},id:e.id},g=l?__spreadValues(__spreadValues({},l),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},topViewPolygon2PointCloud=(e,o,i,l,t,a)=>{let p=e.pointList.map(v=>lbUtils.PointCloudUtils.transferCanvas2World(v,o)),r=0,d=1,g={};if(i){const v=i.getSensesPointZAxisInPolygon(p,void 0,a);a&&v.fittedCoordinates.length>0&&(p=v.fittedCoordinates),r=(v.maxZ+v.minZ)/2,d=v.maxZ-v.minZ,g={count:v.zCount}}const[f,x,V]=p,U=lbAnnotation.MathUtils.getLineCenterPoint([f,V]),I=lbAnnotation.MathUtils.getLineLength(f,x),_=lbAnnotation.MathUtils.getLineLength(x,V),D=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);l&&(r=l.center.z,d=l.depth);const b={center:{x:U.x,y:U.y,z:r},width:_,height:I,depth:d,rotation:D,id:e.id},S=__spreadValues(l?__spreadValues(__spreadValues({},l),b):__spreadProps(__spreadValues({},b),{attribute:"",valid:!0}),g);t&&Object.assign(S,t);const O=p.map(v=>lbUtils.PointCloudUtils.transferWorld2Canvas(v,o));return{boxParams:S,newPointList:O}},sideViewPoint2PointCloud=(e,o,i)=>{const l={x:e.x-o.x,y:e.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(e,o,i,l)=>{const[t,a,p]=e.pointList,[r,d,g]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([t,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,g]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},I=lbAnnotation.MathUtils.getLineLength(t,a),_=lbAnnotation.MathUtils.getLineLength(r,d),D=I-_,b=lbAnnotation.MathUtils.getLineLength(a,p),S=lbAnnotation.MathUtils.getLineLength(d,g),O=b-S,{newBoxParams:v}=l.getNewBoxBySideUpdate(U,O,D,i);return v},backViewPoint2PointCloud=(e,o,i)=>{const l={x:e.x-o.x,y:e.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(e,o,i,l)=>{const[t,a,p]=e.pointList,[r,d,g]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([t,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,g]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},I=lbAnnotation.MathUtils.getLineLength(t,a),_=lbAnnotation.MathUtils.getLineLength(r,d),D=I-_,b=lbAnnotation.MathUtils.getLineLength(a,p),S=lbAnnotation.MathUtils.getLineLength(d,g),O=b-S;let{newBoxParams:v}=l.getNewBoxByBackUpdate(U,O,D,i);return v},syncSideViewByPoint=(e,o,i,l,t)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);r.setInitCameraPosition(d);const{point2d:g,zoom:f}=r.getSphereSidePoint2DCoordinate(e);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),g),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),p.setSelectedID(o.id)},synchronizeSideView=(e,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxSidePolygon2DCoordinate(e);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(d),t.setResultAndSelectedID([{id:o.id,valid:e.valid,pointList:r,textAttribute:"",isRect:!0,attribute:e.attribute}],o.id)},syncBackViewByPoint=(e,o,i,l,t)=>{var a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);r.setInitCameraPosition(d);const{point2d:g,zoom:f}=r.getSphereBackPoint2DCoordinate(e);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),g),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),p.setSelectedID(o.id)},synchronizeBackView=(e,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxBackPolygon2DCoordinate(e);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(d),t.setResultAndSelectedID([{id:o.id,valid:e.valid,pointList:r,textAttribute:"",isRect:!0,attribute:e.attribute}],o.id)},syncTopViewByPoint=(e,o,i,l)=>{if(!i||!l)return;l.generateSphere(e),l.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:t,pointCloudInstance:a}=i,{point2d:p}=a.getSphereTopPoint2DCoordinate(e),r=[...t.pointList].map(d=>d.id===o.id?__spreadProps(__spreadValues(__spreadValues({},o),p),{valid:e.valid,textAttribute:"",attribute:e.attribute}):d);t.setResult(r),t.setSelectedID(o.id)},synchronizeTopView=(e,o,i,l)=>{var t;if(!i||!l)return;l.generateBox(e,o.id),l.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=i,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(e),d=[...a.polygonList],g=d.find(f=>f.id===o.id);g?g.pointList=r:d.push({id:o.id,pointList:r,textAttribute:"",isRect:!0,valid:(t=e.valid)!=null?t:!0}),a.setResultAndSelectedID(d,o.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:i,backViewInstance:l,mainViewInstance:t,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:d,pointCloudBoxList:g,pointCloudSphereList:f,hideAttributes:x}=e,{addHistory:V,initHistory:U,pushHistoryUnderUpdatePolygon:I,pushHistoryUnderUpdateLine:_}=useHistory.useHistory(),{selectedPolygon:D}=usePolygon.usePolygon(),{updateSelectedBox:b,updateSelectedBoxes:S,getPointCloudByID:O}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:v,updatePointCloudSphere:H,selectedSphere:T}=useSphere.useSphere(),{currentData:A,config:L}=ctx.useSelector(n=>{const{stepList:s,step:P,imgList:c,imgIndex:u}=n.annotation;return{currentData:c[u],config:index.jsonParser(StepUtils.getCurrentStepInfo(P,s).config)}}),F=ctx.useDispatch(),{selectedBox:k}=useSingleBox.useSingleBox(),{t:G}=reactI18next.useTranslation(),N=k==null?void 0:k.info;if(!o||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:E}=o,Q=n=>{t==null||t.generateBox(n),t==null||t.controls.update(),t==null||t.render()},X=n=>{t==null||t.generateSphere(n),t==null||t.controls.update(),t==null||t.render()},Y=({newPoint:n,size:s,zoom:P,trackConfigurable:c})=>{var u;const C={attribute:(u=o.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:f})});const h=topViewPoint2PointCloud(n,s,E,void 0,C);r(n.id);const y=p(h);M(PointCloudView.Top,n,h,P,y,L),V({newSphereParams:h})},J=({polygon:n,size:s,imgList:P,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var h,y;const m={attribute:(h=o.toolInstance.defaultAttribute)!=null?h:""};c===!0&&Object.assign(m,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:f})});const z=o==null?void 0:o.toolInstance,w=__spreadValues({},n),{boxParams:B,newPointList:j}=topViewPolygon2PointCloud(w,s,E,void 0,m,C);if((L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(G("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),z.deletePolygon(B.id);return}C&&(j==null?void 0:j.length)&&(w.pointList=j);const rt=x.includes(w.attribute),q=a(B),lt=(y=e==null?void 0:e.polygonList)!=null?y:[];o==null||o.updatePolygonList(q!=null?q:[],lt),rt?r([]):(r(B.id),z.selection.setSelectedIDs(w.id),R(PointCloudView.Top,w,B,u,q),C&&synchronizeTopView(B,w,o,t)),V({newBoxParams:B})},K=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:P,newSphereList:c})=>{var u;const C=o==null?void 0:o.toolInstance;if(!(d.length===0||!C)){if(n||(k==null?void 0:k.info)){const h=n!=null?n:k==null?void 0:k.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(d[0]);const y=C.selectedPolygon;if(d.length===1&&h){R(PointCloudView.Top,y,h,void 0,s);return}}if((P||T)&&d.length===1){const h=P!=null?P:T;C.setSelectedID(d[0]);const y=C.selectedPoint;h&&M(PointCloudView.Top,y,h,void 0,c,L)}}},Z=(n,s,P)=>{if(N){let c,u;switch(P){case PointCloudView.Back:c=backViewPolygon2PointCloud;break;case PointCloudView.Side:c=sideViewPolygon2PointCloud;break;default:c=sideViewPolygon2PointCloud;break}if(u=c(n,s,N,i.pointCloudInstance),t){const{count:h}=t.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=__spreadProps(__spreadValues({},u),{count:h})}const C=b(u);return R(P,n,u,void 0,C),C}},W=(n,s,P)=>{if(T){let c,u;switch(P){case PointCloudView.Back:c=backViewPoint2PointCloud;break;case PointCloudView.Side:c=sideViewPoint2PointCloud;break;default:c=sideViewPoint2PointCloud;break}u=c(n,s,T);const C=H(u);return M(P,n,u,void 0,C,L),C}},$=(n,s)=>{W(n,s,PointCloudView.Side)},tt=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},ot=(n,s)=>{Z(n,s,PointCloudView.Back)},it=(n,s)=>{_(n)},nt=(n,s)=>{const P=v(n.id),c=topViewPoint2PointCloud(n,s,E,P),u=H(c);M(PointCloudView.Top,n,c,void 0,u,L)},st=(n,s)=>{if(D){const c=n[0].newPolygon;c.pointList=c.pointList.map(u=>lbUtils.PointCloudUtils.transferCanvas2World(u,s)),I(n[0].newPolygon);return}const P=n.map(({newPolygon:c})=>{const u=O(c.id),{boxParams:C}=topViewPolygon2PointCloud(c,s,o.pointCloudInstance,u);return C});if(P.length===1){const{newPolygon:c}=n[0],u=S(P);R(PointCloudView.Top,c,P[0],void 0,u)}else{const c=S(P);c&&e.syncAllViewPointCloudColor(c)}},M=(n,s,P,c,u,C)=>__async(void 0,null,function*(){const h=A==null?void 0:A.url,y={[PointCloudView.Side]:()=>{syncSideViewByPoint(P,s,i,h,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(P,s,l,h,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(P,s,o,t)}};Object.keys(y).forEach(m=>{m!==n&&y[m]()}),c&&(t==null||t.updateCameraZoom(c)),X(P)}),R=(n,s,P,c,u)=>__async(void 0,null,function*(){const C=A==null?void 0:A.url;u&&(yield e.syncAllViewPointCloudColor(u));const h={[PointCloudView.Side]:()=>{synchronizeSideView(P,s,i,C)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(P,s,l,C)},[PointCloudView.Top]:()=>{synchronizeTopView(P,s,o,t)}};Object.keys(h).forEach(y=>{y!==n&&h[y]()}),c&&(t==null||t.updateCameraZoom(c)),Q(P)});return{topViewAddSphere:Y,topViewAddBox:J,topViewSelectedChanged:K,topViewUpdatePoint:nt,sideViewUpdatePoint:$,backViewUpdatePoint:tt,topViewUpdateBox:st,topViewUpdateLine:it,sideViewUpdateBox:et,backViewUpdateBox:ot,pointCloudBoxListUpdated:n=>{o.updatePolygonList(n),t==null||t.generateBoxes(n)},initPointCloud3d:n=>{if(!t)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=A){var P,c,u,C,h,y;if(!(s==null?void 0:s.url)||!t)return;actionCreators.SetPointCloudLoading(F,!0),yield t.loadPCDFile(s.url,(P=L==null?void 0:L.radius)!=null?P:DEFAULT_RADIUS),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let m=[],z=[],w=[],B=[];s.result&&(m=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),w=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),z=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(m),t==null||t.generateSpheres(B),e.syncAllViewPointCloudColor(m)),U({pointCloudBoxList:m,polygonList:w,lineList:z,pointCloudSphereList:B}),t.updateTopCamera();const j=(u=(c=index.jsonParser(s.result))==null?void 0:c.valid)!=null?u:!0;e.setPointCloudValid(j),(C=e.sideViewInstance)==null||C.clearAllData(),(h=e.backViewInstance)==null||h.clearAllData(),o.updateData(s.url,s.result,{radius:(y=L==null?void 0:L.radius)!=null?y:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(F,!1)})}};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;
|
|
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"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,o,i)=>o in e?__defProp(e,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[o]=i,__spreadValues=(e,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(e,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(e,i,o[i]);return e},__spreadProps=(e,o)=>__defProps(e,__getOwnPropDescs(o)),__async=(e,o,i)=>new Promise((l,t)=>{var d=a=>{try{r(i.next(a))}catch(g){t(g)}},p=a=>{try{r(i.throw(a))}catch(g){t(g)}},r=a=>a.done?l(a.value):Promise.resolve(a.value).then(d,p);r((i=i.apply(e,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,o,i,l,t)=>{const{x:d,y:p}=lbUtils.PointCloudUtils.transferCanvas2World(e,o),{defaultZ:r}=lbUtils.DEFAULT_SPHERE_PARAMS,a={center:{x:d,y:p,z:r},id:e.id},g=l?__spreadValues(__spreadValues({},l),a):__spreadProps(__spreadValues({},a),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},topViewPolygon2PointCloud=(e,o,i,l,t,d)=>{let p=e.pointList.map(v=>lbUtils.PointCloudUtils.transferCanvas2World(v,o)),r=0,a=1,g={};if(i){const v=i.getSensesPointZAxisInPolygon(p,void 0,d);d&&v.fittedCoordinates.length>0&&(p=v.fittedCoordinates),r=(v.maxZ+v.minZ)/2,a=v.maxZ-v.minZ,g={count:v.zCount}}const[f,x,_]=p,U=lbAnnotation.MathUtils.getLineCenterPoint([f,_]),b=lbAnnotation.MathUtils.getLineLength(f,x),I=lbAnnotation.MathUtils.getLineLength(x,_),D=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);l&&(r=l.center.z,a=l.depth);const V={center:{x:U.x,y:U.y,z:r},width:d?I+INTELLIGENT_FIT_MARGIN:I,height:d?b+INTELLIGENT_FIT_MARGIN:b,depth:a,rotation:D,id:e.id},S=__spreadValues(l?__spreadValues(__spreadValues({},l),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),g);t&&Object.assign(S,t);const O=p.map(v=>lbUtils.PointCloudUtils.transferWorld2Canvas(v,o));return{boxParams:S,newPointList:O}},sideViewPoint2PointCloud=(e,o,i)=>{const l={x:e.x-o.x,y:e.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(e,o,i,l)=>{const[t,d,p]=e.pointList,[r,a,g]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([t,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,g]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},b=lbAnnotation.MathUtils.getLineLength(t,d),I=lbAnnotation.MathUtils.getLineLength(r,a),D=b-I,V=lbAnnotation.MathUtils.getLineLength(d,p),S=lbAnnotation.MathUtils.getLineLength(a,g),O=V-S,{newBoxParams:v}=l.getNewBoxBySideUpdate(U,O,D,i);return v},backViewPoint2PointCloud=(e,o,i)=>{const l={x:e.x-o.x,y:e.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(e,o,i,l)=>{const[t,d,p]=e.pointList,[r,a,g]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([t,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,g]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},b=lbAnnotation.MathUtils.getLineLength(t,d),I=lbAnnotation.MathUtils.getLineLength(r,a),D=b-I,V=lbAnnotation.MathUtils.getLineLength(d,p),S=lbAnnotation.MathUtils.getLineLength(a,g),O=V-S;let{newBoxParams:v}=l.getNewBoxByBackUpdate(U,O,D,i);return v},syncSideViewByPoint=(e,o,i,l,t)=>{var d;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:a}=r.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);r.setInitCameraPosition(a);const{point2d:g,zoom:f}=r.getSphereSidePoint2DCoordinate(e);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),g),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),p.setSelectedID(o.id)},synchronizeSideView=(e,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=i;d.loadPCDFileByBox(l,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(p);const{polygon2d:r,zoom:a}=d.getBoxSidePolygon2DCoordinate(e);d.camera.zoom=a,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(a),t.setResultAndSelectedID([{id:o.id,valid:e.valid,pointList:r,textAttribute:"",isRect:!0,attribute:e.attribute}],o.id)},syncBackViewByPoint=(e,o,i,l,t)=>{var d;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:a}=r.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);r.setInitCameraPosition(a);const{point2d:g,zoom:f}=r.getSphereBackPoint2DCoordinate(e);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),g),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),p.setSelectedID(o.id)},synchronizeBackView=(e,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=i;d.loadPCDFileByBox(l,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(p);const{polygon2d:r,zoom:a}=d.getBoxBackPolygon2DCoordinate(e);d.camera.zoom=a,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(a),t.setResultAndSelectedID([{id:o.id,valid:e.valid,pointList:r,textAttribute:"",isRect:!0,attribute:e.attribute}],o.id)},syncTopViewByPoint=(e,o,i,l)=>{if(!i||!l)return;l.generateSphere(e),l.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:t,pointCloudInstance:d}=i,{point2d:p}=d.getSphereTopPoint2DCoordinate(e),r=[...t.pointList].map(a=>a.id===o.id?__spreadProps(__spreadValues(__spreadValues({},o),p),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);t.setResult(r),t.setSelectedID(o.id)},synchronizeTopView=(e,o,i,l)=>{var t;if(!i||!l)return;l.generateBox(e,o.id),l.render();const{pointCloud2dOperation:d,pointCloudInstance:p}=i,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(e),a=[...d.polygonList],g=a.find(f=>f.id===o.id);g?g.pointList=r:a.push({id:o.id,pointList:r,textAttribute:"",isRect:!0,valid:(t=e.valid)!=null?t:!0}),d.setResultAndSelectedID(a,o.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:i,backViewInstance:l,mainViewInstance:t,addPointCloudBox:d,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:a,pointCloudBoxList:g,pointCloudSphereList:f,hideAttributes:x}=e,{addHistory:_,initHistory:U,pushHistoryUnderUpdatePolygon:b,pushHistoryUnderUpdateLine:I}=useHistory.useHistory(),{selectedPolygon:D}=usePolygon.usePolygon(),{updateSelectedBox:V,updateSelectedBoxes:S,getPointCloudByID:O}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:v,updatePointCloudSphere:H,selectedSphere:j}=useSphere.useSphere(),{currentData:k,config:L}=ctx.useSelector(n=>{const{stepList:s,step:P,imgList:c,imgIndex:u}=n.annotation;return{currentData:c[u],config:index.jsonParser(StepUtils.getCurrentStepInfo(P,s).config)}}),N=ctx.useDispatch(),{selectedBox:A}=useSingleBox.useSingleBox(),{t:G}=reactI18next.useTranslation(),F=A==null?void 0:A.info;if(!o||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:E}=o,Q=n=>{t==null||t.generateBox(n),t==null||t.controls.update(),t==null||t.render()},X=n=>{t==null||t.generateSphere(n),t==null||t.controls.update(),t==null||t.render()},Y=({newPoint:n,size:s,zoom:P,trackConfigurable:c})=>{var u;const C={attribute:(u=o.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:f})});const h=topViewPoint2PointCloud(n,s,E,void 0,C);r(n.id);const y=p(h);M(PointCloudView.Top,n,h,P,y,L),_({newSphereParams:h})},J=({polygon:n,size:s,imgList:P,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var h,y;const m={attribute:(h=o.toolInstance.defaultAttribute)!=null?h:""};c===!0&&Object.assign(m,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:f})});const T=o==null?void 0:o.toolInstance,w=__spreadValues({},n),{boxParams:B,newPointList:z}=topViewPolygon2PointCloud(w,s,E,void 0,m,C);if((L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(G("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),T.deletePolygon(B.id);return}C&&(z==null?void 0:z.length)&&(w.pointList=z);const rt=x.includes(w.attribute),q=d(B),lt=(y=e==null?void 0:e.polygonList)!=null?y:[];o==null||o.updatePolygonList(q!=null?q:[],lt),rt?r([]):(r(B.id),T.selection.setSelectedIDs(w.id),R(PointCloudView.Top,w,B,u,q),C&&synchronizeTopView(B,w,o,t)),_({newBoxParams:B})},K=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:P,newSphereList:c})=>{var u;const C=o==null?void 0:o.toolInstance;if(!(a.length===0||!C)){if(n||(A==null?void 0:A.info)){const h=n!=null?n:A==null?void 0:A.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(a[0]);const y=C.selectedPolygon;if(a.length===1&&h){R(PointCloudView.Top,y,h,void 0,s);return}}if((P||j)&&a.length===1){const h=P!=null?P:j;C.setSelectedID(a[0]);const y=C.selectedPoint;h&&M(PointCloudView.Top,y,h,void 0,c,L)}}},Z=(n,s,P)=>{if(F){let c,u;switch(P){case PointCloudView.Back:c=backViewPolygon2PointCloud;break;case PointCloudView.Side:c=sideViewPolygon2PointCloud;break;default:c=sideViewPolygon2PointCloud;break}if(u=c(n,s,F,i.pointCloudInstance),t){const{count:h}=t.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=__spreadProps(__spreadValues({},u),{count:h})}const C=V(u);return R(P,n,u,void 0,C),C}},W=(n,s,P)=>{if(j){let c,u;switch(P){case PointCloudView.Back:c=backViewPoint2PointCloud;break;case PointCloudView.Side:c=sideViewPoint2PointCloud;break;default:c=sideViewPoint2PointCloud;break}u=c(n,s,j);const C=H(u);return M(P,n,u,void 0,C,L),C}},$=(n,s)=>{W(n,s,PointCloudView.Side)},tt=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},ot=(n,s)=>{Z(n,s,PointCloudView.Back)},it=(n,s)=>{I(n)},nt=(n,s)=>{const P=v(n.id),c=topViewPoint2PointCloud(n,s,E,P),u=H(c);M(PointCloudView.Top,n,c,void 0,u,L)},st=(n,s)=>{if(D){const c=n[0].newPolygon;c.pointList=c.pointList.map(u=>lbUtils.PointCloudUtils.transferCanvas2World(u,s)),b(n[0].newPolygon);return}const P=n.map(({newPolygon:c})=>{const u=O(c.id),{boxParams:C}=topViewPolygon2PointCloud(c,s,o.pointCloudInstance,u);return C});if(P.length===1){const{newPolygon:c}=n[0],u=S(P);R(PointCloudView.Top,c,P[0],void 0,u)}else{const c=S(P);c&&e.syncAllViewPointCloudColor(c)}},M=(n,s,P,c,u,C)=>__async(void 0,null,function*(){const h=k==null?void 0:k.url,y={[PointCloudView.Side]:()=>{syncSideViewByPoint(P,s,i,h,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(P,s,l,h,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(P,s,o,t)}};Object.keys(y).forEach(m=>{m!==n&&y[m]()}),c&&(t==null||t.updateCameraZoom(c)),X(P)}),R=(n,s,P,c,u)=>__async(void 0,null,function*(){const C=k==null?void 0:k.url;u&&(yield e.syncAllViewPointCloudColor(u));const h={[PointCloudView.Side]:()=>{synchronizeSideView(P,s,i,C)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(P,s,l,C)},[PointCloudView.Top]:()=>{synchronizeTopView(P,s,o,t)}};Object.keys(h).forEach(y=>{y!==n&&h[y]()}),c&&(t==null||t.updateCameraZoom(c)),Q(P)});return{topViewAddSphere:Y,topViewAddBox:J,topViewSelectedChanged:K,topViewUpdatePoint:nt,sideViewUpdatePoint:$,backViewUpdatePoint:tt,topViewUpdateBox:st,topViewUpdateLine:it,sideViewUpdateBox:et,backViewUpdateBox:ot,pointCloudBoxListUpdated:n=>{o.updatePolygonList(n),t==null||t.generateBoxes(n)},initPointCloud3d:n=>{if(!t)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=k){var P,c,u,C,h,y;if(!(s==null?void 0:s.url)||!t)return;actionCreators.SetPointCloudLoading(N,!0),yield t.loadPCDFile(s.url,(P=L==null?void 0:L.radius)!=null?P:DEFAULT_RADIUS),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let m=[],T=[],w=[],B=[];s.result&&(m=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),w=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),T=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(m),t==null||t.generateSpheres(B),e.syncAllViewPointCloudColor(m)),U({pointCloudBoxList:m,polygonList:w,lineList:T,pointCloudSphereList:B}),t.updateTopCamera();const z=(u=(c=index.jsonParser(s.result))==null?void 0:c.valid)!=null?u:!0;e.setPointCloudValid(z),(C=e.sideViewInstance)==null||C.clearAllData(),(h=e.backViewInstance)==null||h.clearAllData(),o.updateData(s.url,s.result,{radius:(y=L==null?void 0:L.radius)!=null?y:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(N,!1)})}};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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as c}from"../../utils/dom.js";import{PointCloud as D}from"@labelbee/lb-annotation";import{PointCloudUtils as I,toolStyleConverter as N,EPerspectiveView as C}from"@labelbee/lb-utils";import L from"classnames";import n,{useContext as h,useState as k,useRef as R,useEffect as w,useMemo as F}from"react";import{PointCloudContainer as A}from"./PointCloudLayout.js";import{PointCloudContext as M}from"./PointCloudContext.js";import{a2MapStateToProps as U}from"../../store/annotation/map.js";import{connect as Z}from"react-redux";import{jsonParser as q}from"../../utils/index.js";import{useSingleBox as G}from"./hooks/useSingleBox.js";import{useSphere as H}from"./hooks/useSphere.js";import{Switch as J,Tooltip as K}from"antd";import Q from"../../hooks/useSize.js";import{usePointCloudViews as W}from"./hooks/usePointCloudViews.js";import{useTranslation as S}from"react-i18next";import{LabelBeeContext as X}from"../../store/ctx.js";import Y from"./components/PointCloudSizeSlider/index.js";var $=Object.defineProperty,ee=Object.defineProperties,te=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,oe=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable,T=(o,i,e)=>i in o?$(o,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[i]=e,j=(o,i)=>{for(var e in i||(i={}))oe.call(i,e)&&T(o,e,i[e]);if(b)for(var e of b(i))ne.call(i,e)&&T(o,e,i[e]);return o},ie=(o,i)=>ee(o,te(i));const re="LABELBEE-POINTCLOUD",E=n.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),m=({perspectiveView:o})=>{const{isActive:i,setTarget3DView:e}=h(E),f=V=>L({[c("point-cloud-3d-view",V)]:!0,active:i});return n.createElement("span",{onClick:()=>{e(C[o])},className:f(o.toLocaleLowerCase())})},ae=()=>{const{reset3DView:o,followTopView:i}=h(E),{t:e}=S();return n.createElement("div",{className:c("point-cloud-3d-sidebar")},n.createElement(m,{perspectiveView:"Top"}),n.createElement(m,{perspectiveView:"Front"}),n.createElement(m,{perspectiveView:"Left"}),n.createElement(m,{perspectiveView:"Back"}),n.createElement(m,{perspectiveView:"Right"}),n.createElement(m,{perspectiveView:"LFT"}),n.createElement(m,{perspectiveView:"RBT"}),n.createElement(K,{title:e("CameraFollowTopView")},n.createElement("span",{onClick:()=>{i()},className:c("point-cloud-3d-view","followTop")})),n.createElement("span",{onClick:()=>{o()},className:c("point-cloud-3d-view","reset")}))},le=({currentData:o,config:i})=>{const e=h(M),[f,V]=k(!0),p=R(null),{initPointCloud3d:g}=W(),d=Q(p),{t:x}=S();w(()=>{!e.mainViewInstance||g==null||g(d)},[d]);const{selectedBox:u}=G(),{selectedSphere:v}=H(),P=t=>{var r,a;const l=u==null?void 0:u.info;if(l){const s=j({},l.center);s.x=s.x-.01,s.z=
|
|
1
|
+
import{getClassName as c}from"../../utils/dom.js";import{PointCloud as D}from"@labelbee/lb-annotation";import{PointCloudUtils as I,toolStyleConverter as N,EPerspectiveView as C}from"@labelbee/lb-utils";import L from"classnames";import n,{useContext as h,useState as k,useRef as R,useEffect as w,useMemo as F}from"react";import{PointCloudContainer as A}from"./PointCloudLayout.js";import{PointCloudContext as M}from"./PointCloudContext.js";import{a2MapStateToProps as U}from"../../store/annotation/map.js";import{connect as Z}from"react-redux";import{jsonParser as q}from"../../utils/index.js";import{useSingleBox as G}from"./hooks/useSingleBox.js";import{useSphere as H}from"./hooks/useSphere.js";import{Switch as J,Tooltip as K}from"antd";import Q from"../../hooks/useSize.js";import{usePointCloudViews as W}from"./hooks/usePointCloudViews.js";import{useTranslation as S}from"react-i18next";import{LabelBeeContext as X}from"../../store/ctx.js";import Y from"./components/PointCloudSizeSlider/index.js";var $=Object.defineProperty,ee=Object.defineProperties,te=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,oe=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable,T=(o,i,e)=>i in o?$(o,i,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[i]=e,j=(o,i)=>{for(var e in i||(i={}))oe.call(i,e)&&T(o,e,i[e]);if(b)for(var e of b(i))ne.call(i,e)&&T(o,e,i[e]);return o},ie=(o,i)=>ee(o,te(i));const re="LABELBEE-POINTCLOUD",E=n.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),m=({perspectiveView:o})=>{const{isActive:i,setTarget3DView:e}=h(E),f=V=>L({[c("point-cloud-3d-view",V)]:!0,active:i});return n.createElement("span",{onClick:()=>{e(C[o])},className:f(o.toLocaleLowerCase())})},ae=()=>{const{reset3DView:o,followTopView:i}=h(E),{t:e}=S();return n.createElement("div",{className:c("point-cloud-3d-sidebar")},n.createElement(m,{perspectiveView:"Top"}),n.createElement(m,{perspectiveView:"Front"}),n.createElement(m,{perspectiveView:"Left"}),n.createElement(m,{perspectiveView:"Back"}),n.createElement(m,{perspectiveView:"Right"}),n.createElement(m,{perspectiveView:"LFT"}),n.createElement(m,{perspectiveView:"RBT"}),n.createElement(K,{title:e("CameraFollowTopView")},n.createElement("span",{onClick:()=>{i()},className:c("point-cloud-3d-view","followTop")})),n.createElement("span",{onClick:()=>{o()},className:c("point-cloud-3d-view","reset")}))},le=({currentData:o,config:i})=>{const e=h(M),[f,V]=k(!0),p=R(null),{initPointCloud3d:g}=W(),d=Q(p),{t:x}=S();w(()=>{!e.mainViewInstance||g==null||g(d)},[d]);const{selectedBox:u}=G(),{selectedSphere:v}=H(),P=t=>{var r,a;const l=u==null?void 0:u.info;if(l){const s=j({},l.center);s.x=s.x-.01,s.z=1e3;const _=t===C.Top;(r=e.mainViewInstance)==null||r.updateCameraByBox(l,t,_?s:void 0)}v&&((a=e.mainViewInstance)==null||a.updateCameraBySphere(v,t))},O=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},B=()=>{var t,r;const a=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;a&&((r=e.mainViewInstance)==null||r.applyCameraTarget(a))};w(()=>{if(p.current&&(o==null?void 0:o.url)){let t=e.mainViewInstance;!t&&d.width&&(t=new D({container:p.current,isOrthographicCamera:!0,orthographicParams:I.getDefaultOrthographicParams(d),config:i}),e.setMainViewInstance(t))}},[d,o]),w(()=>{var t;if(p.current&&(o==null?void 0:o.url)&&o.result&&e.mainViewInstance){let r=e.mainViewInstance;const a=I.getBoxParamsFromResultList(o.result);a.forEach(l=>{var s;const _=(s=N.getColorFromConfig({attribute:l.attribute},ie(j({},i),{attributeConfigurable:!0}),{}))==null?void 0:s.hex;r==null||r.generateBox(l,_)}),e.setPointCloudResult(a),e.setPointCloudValid((t=q(o.result))==null?void 0:t.valid)}},[o,e.mainViewInstance]),w(()=>{var t,r,a,l;if(u){P(C.Top);const s=(a=(r=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:r.camera.zoom)!=null?a:1;(l=e.mainViewInstance)==null||l.updateCameraZoom(s)}},[u]),w(()=>{var t,r,a,l;if(v){P(C.Top);const s=(a=(r=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:r.camera.zoom)!=null?a:1;(l=e.mainViewInstance)==null||l.updateCameraZoom(s)}},[v]);const y=F(()=>({reset3DView:O,setTarget3DView:P,isActive:!!u,followTopView:B}),[u,e.mainViewInstance]),z=n.createElement(n.Fragment,null,n.createElement(Y,{onChange:t=>{var r;(r=e.mainViewInstance)==null||r.updatePointSize({customSize:t})}}),n.createElement("span",{style:{marginRight:8}},x("ShowArrows")),n.createElement(J,{size:"small",checked:f,onChange:t=>{var r;V(t),(r=e.mainViewInstance)==null||r.setShowDirection(t)}}));return n.createElement(A,{className:c("point-cloud-3d-container"),title:x("3DView"),toolbar:z},n.createElement("div",{className:c("point-cloud-3d-content")},n.createElement(E.Provider,{value:y},n.createElement(ae,null)),n.createElement("div",{className:c("point-cloud-3d-view"),id:re,ref:p})))};var se=Z(U,null,null,{context:X})(le);export{se as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MathUtils as x,getCuboidFromPointCloudBox as At}from"@labelbee/lb-annotation";import{EPerspectiveView as N,PointCloudUtils as w,DEFAULT_SPHERE_PARAMS as Ut}from"@labelbee/lb-utils";import{useContext as kt}from"react";import{PointCloudContext as zt}from"../PointCloudContext.js";import{useSingleBox as st}from"./useSingleBox.js";import{useSphere as jt}from"./useSphere.js";import{useSelector as Tt,useDispatch as Rt}from"../../../store/ctx.js";import Ht from"../../../utils/StepUtils.js";import{jsonParser as rt}from"../../../utils/index.js";import{SetPointCloudLoading as lt}from"../../../store/annotation/actionCreators.js";import{message as Et}from"antd";import{useTranslation as Ft}from"react-i18next";import{useHistory as Nt}from"./useHistory.js";import{usePolygon as Zt}from"./usePolygon.js";var Wt=Object.defineProperty,Mt=Object.defineProperties,Gt=Object.getOwnPropertyDescriptors,dt=Object.getOwnPropertySymbols,Qt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable,at=(o,e,n)=>e in o?Wt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,L=(o,e)=>{for(var n in e||(e={}))Qt.call(e,n)&&at(o,n,e[n]);if(dt)for(var n of dt(e))Xt.call(e,n)&&at(o,n,e[n]);return o},A=(o,e)=>Mt(o,Gt(e)),q=(o,e,n)=>new Promise((l,t)=>{var a=d=>{try{r(n.next(d))}catch(g){t(g)}},p=d=>{try{r(n.throw(d))}catch(g){t(g)}},r=d=>d.done?l(d.value):Promise.resolve(d.value).then(a,p);r((n=n.apply(o,e)).next())});const G=5,Q=90,m={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},J=(o,e,n,l,t)=>{const{x:a,y:p}=w.transferCanvas2World(o,e),{defaultZ:r}=Ut,d={center:{x:a,y:p,z:r},id:o.id},g=l?L(L({},l),d):A(L({},d),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},K=(o,e,n,l,t,a)=>{let p=o.pointList.map(h=>w.transferCanvas2World(h,e)),r=0,d=1,g={};if(n){const h=n.getSensesPointZAxisInPolygon(p,void 0,a);a&&h.fittedCoordinates.length>0&&(p=h.fittedCoordinates),r=(h.maxZ+h.minZ)/2,d=h.maxZ-h.minZ,g={count:h.zCount}}const[y,B,U]=p,O=x.getLineCenterPoint([y,U]),k=x.getLineLength(y,B),z=x.getLineLength(B,U),j=x.getRadiusFromQuadrangle(o.pointList);l&&(r=l.center.z,d=l.depth);const V={center:{x:O.x,y:O.y,z:r},width:z,height:k,depth:d,rotation:j,id:o.id},D=L(l?L(L({},l),V):A(L({},V),{attribute:"",valid:!0}),g);t&&Object.assign(D,t);const T=p.map(h=>w.transferWorld2Canvas(h,e));return{boxParams:D,newPointList:T}},ct=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return A(L({},n),{center:{x:n.center.x-l.x,y:n.center.y,z:n.center.z-l.y}})},ut=(o,e,n,l)=>{const[t,a,p]=o.pointList,[r,d,g]=e.pointList,y=x.getLineCenterPoint([t,p]),B=x.getLineCenterPoint([r,g]),O={x:{x:y.x-B.x,y:y.y-B.y}.x,y:0,z:y.y-B.y},k=x.getLineLength(t,a),z=x.getLineLength(r,d),j=k-z,V=x.getLineLength(a,p),D=x.getLineLength(d,g),T=V-D,{newBoxParams:h}=l.getNewBoxBySideUpdate(O,T,j,n);return h},Yt=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return A(L({},n),{center:{x:n.center.x,y:n.center.y-l.x,z:n.center.z-l.y}})},qt=(o,e,n,l)=>{const[t,a,p]=o.pointList,[r,d,g]=e.pointList,y=x.getLineCenterPoint([t,p]),B=x.getLineCenterPoint([r,g]),O={x:{x:y.x-B.x,y:y.y-B.y}.x,y:0,z:y.y-B.y},k=x.getLineLength(t,a),z=x.getLineLength(r,d),j=k-z,V=x.getLineLength(a,p),D=x.getLineLength(d,g),T=V-D;let{newBoxParams:h}=l.getNewBoxByBackUpdate(O,T,j,n);return h},pt=(o,e,n,l,t)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:Q);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(o,N.Left);r.setInitCameraPosition(d);const{point2d:g,zoom:y}=r.getSphereSidePoint2DCoordinate(o);r.camera.zoom=y,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(y),p.setResult([A(L(L({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),p.setSelectedID(e.id)},ft=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=n;a.loadPCDFileByBox(l,o,{width:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(o,N.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxSidePolygon2DCoordinate(o);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(d),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:r,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},Ct=(o,e,n,l,t)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:Q);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(o,N.Back);r.setInitCameraPosition(d);const{point2d:g,zoom:y}=r.getSphereBackPoint2DCoordinate(o);r.camera.zoom=y,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(y),p.setResult([A(L(L({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),p.setSelectedID(e.id)},gt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=n;a.loadPCDFileByBox(l,o,{height:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(o,N.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxBackPolygon2DCoordinate(o);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(d),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:r,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},Pt=(o,e,n,l)=>{if(!n||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,N.Top),l.render();const{toolInstance:t,pointCloudInstance:a}=n,{point2d:p}=a.getSphereTopPoint2DCoordinate(o),r=[...t.pointList].map(d=>d.id===e.id?A(L(L({},e),p),{valid:o.valid,textAttribute:"",attribute:o.attribute}):d);t.setResult(r),t.setSelectedID(e.id)},$=(o,e,n,l)=>{var t;if(!n||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:a,pointCloudInstance:p}=n,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(o),d=[...a.polygonList],g=d.find(y=>y.id===e.id);g?g.pointList=r:d.push({id:e.id,pointList:r,textAttribute:"",isRect:!0,valid:(t=o.valid)!=null?t:!0}),a.setResultAndSelectedID(d,e.id)},Jt=()=>{const o=kt(zt),{topViewInstance:e,sideViewInstance:n,backViewInstance:l,mainViewInstance:t,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:d,pointCloudBoxList:g,pointCloudSphereList:y,hideAttributes:B}=o,{addHistory:U,initHistory:O,pushHistoryUnderUpdatePolygon:k,pushHistoryUnderUpdateLine:z}=Nt(),{selectedPolygon:j}=Zt(),{updateSelectedBox:V,updateSelectedBoxes:D,getPointCloudByID:T}=st(),{getPointCloudSphereByID:h,updatePointCloudSphere:tt,selectedSphere:Z}=jt(),{currentData:H,config:S}=Tt(i=>{const{stepList:s,step:f,imgList:c,imgIndex:u}=i.annotation;return{currentData:c[u],config:rt(Ht.getCurrentStepInfo(f,s).config)}}),ot=Rt(),{selectedBox:R}=st(),{t:yt}=Ft(),et=R==null?void 0:R.info;if(!e||!n||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=e,mt=i=>{t==null||t.generateBox(i),t==null||t.controls.update(),t==null||t.render()},Lt=i=>{t==null||t.generateSphere(i),t==null||t.controls.update(),t==null||t.render()},ht=({newPoint:i,size:s,zoom:f,trackConfigurable:c})=>{var u;const C={attribute:(u=e.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:w.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:y})});const P=J(i,s,X,void 0,C);r(i.id);const v=p(P);W(m.Top,i,P,f,v,S),U({newSphereParams:P})},vt=({polygon:i,size:s,imgList:f,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var P,v;const I={attribute:(P=e.toolInstance.defaultAttribute)!=null?P:""};c===!0&&Object.assign(I,{trackID:w.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:y})});const E=e==null?void 0:e.toolInstance,_=L({},i),{boxParams:b,newPointList:F}=K(_,s,X,void 0,I,C);if((S==null?void 0:S.lowerLimitPointsNumInBox)&&typeof b.count=="number"&&b.count<S.lowerLimitPointsNumInBox){Et.info(yt("LowerLimitPointsNumInBox",{num:S.lowerLimitPointsNumInBox})),E.deletePolygon(b.id);return}C&&(F==null?void 0:F.length)&&(_.pointList=F);const Ot=B.includes(_.attribute),Y=a(b),Vt=(v=o==null?void 0:o.polygonList)!=null?v:[];e==null||e.updatePolygonList(Y!=null?Y:[],Vt),Ot?r([]):(r(b.id),E.selection.setSelectedIDs(_.id),M(m.Top,_,b,u,Y),C&&$(b,_,e,t)),U({newBoxParams:b})},xt=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:f,newSphereList:c})=>{var u;const C=e==null?void 0:e.toolInstance;if(!(d.length===0||!C)){if(i||(R==null?void 0:R.info)){const P=i!=null?i:R==null?void 0:R.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(d[0]);const v=C.selectedPolygon;if(d.length===1&&P){M(m.Top,v,P,void 0,s);return}}if((f||Z)&&d.length===1){const P=f!=null?f:Z;C.setSelectedID(d[0]);const v=C.selectedPoint;P&&W(m.Top,v,P,void 0,c,S)}}},nt=(i,s,f)=>{if(et){let c,u;switch(f){case m.Back:c=qt;break;case m.Side:c=ut;break;default:c=ut;break}if(u=c(i,s,et,n.pointCloudInstance),t){const{count:P}=t.getSensesPointZAxisInPolygon(At(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=A(L({},u),{count:P})}const C=V(u);return M(f,i,u,void 0,C),C}},it=(i,s,f)=>{if(Z){let c,u;switch(f){case m.Back:c=Yt;break;case m.Side:c=ct;break;default:c=ct;break}u=c(i,s,Z);const C=tt(u);return W(f,i,u,void 0,C,S),C}},Bt=(i,s)=>{it(i,s,m.Side)},St=(i,s)=>{it(i,s,m.Back)},bt=(i,s)=>{nt(i,s,m.Side)},wt=(i,s)=>{nt(i,s,m.Back)},It=(i,s)=>{z(i)},Dt=(i,s)=>{const f=h(i.id),c=J(i,s,X,f),u=tt(c);W(m.Top,i,c,void 0,u,S)},_t=(i,s)=>{if(j){const c=i[0].newPolygon;c.pointList=c.pointList.map(u=>w.transferCanvas2World(u,s)),k(i[0].newPolygon);return}const f=i.map(({newPolygon:c})=>{const u=T(c.id),{boxParams:C}=K(c,s,e.pointCloudInstance,u);return C});if(f.length===1){const{newPolygon:c}=i[0],u=D(f);M(m.Top,c,f[0],void 0,u)}else{const c=D(f);c&&o.syncAllViewPointCloudColor(c)}},W=(i,s,f,c,u,C)=>q(void 0,null,function*(){const P=H==null?void 0:H.url,v={[m.Side]:()=>{pt(f,s,n,P,C)},[m.Back]:()=>{l&&Ct(f,s,l,P,C)},[m.Top]:()=>{Pt(f,s,e,t)}};Object.keys(v).forEach(I=>{I!==i&&v[I]()}),c&&(t==null||t.updateCameraZoom(c)),Lt(f)}),M=(i,s,f,c,u)=>q(void 0,null,function*(){const C=H==null?void 0:H.url;u&&(yield o.syncAllViewPointCloudColor(u));const P={[m.Side]:()=>{ft(f,s,n,C)},[m.Back]:()=>{l&>(f,s,l,C)},[m.Top]:()=>{$(f,s,e,t)}};Object.keys(P).forEach(v=>{v!==i&&P[v]()}),c&&(t==null||t.updateCameraZoom(c)),mt(f)});return{topViewAddSphere:ht,topViewAddBox:vt,topViewSelectedChanged:xt,topViewUpdatePoint:Dt,sideViewUpdatePoint:Bt,backViewUpdatePoint:St,topViewUpdateBox:_t,topViewUpdateLine:It,sideViewUpdateBox:bt,backViewUpdateBox:wt,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),t==null||t.generateBoxes(i)},initPointCloud3d:i=>{if(!t)return;const s=w.getDefaultOrthographicParams(i);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...i)=>q(void 0,[...i],function*(s=H){var f,c,u,C,P,v;if(!(s==null?void 0:s.url)||!t)return;lt(ot,!0),yield t.loadPCDFile(s.url,(f=S==null?void 0:S.radius)!=null?f:Q),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let I=[],E=[],_=[],b=[];s.result&&(I=w.getBoxParamsFromResultList(s.result),_=w.getPolygonListFromResultList(s.result),E=w.getLineListFromResultList(s.result),b=w.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(I),t==null||t.generateSpheres(b),o.syncAllViewPointCloudColor(I)),O({pointCloudBoxList:I,polygonList:_,lineList:E,pointCloudSphereList:b}),t.updateTopCamera();const F=(u=(c=rt(s.result))==null?void 0:c.valid)!=null?u:!0;o.setPointCloudValid(F),(C=o.sideViewInstance)==null||C.clearAllData(),(P=o.backViewInstance)==null||P.clearAllData(),e.updateData(s.url,s.result,{radius:(v=S==null?void 0:S.radius)!=null?v:Q}),lt(ot,!1)})}};export{Ct as syncBackViewByPoint,pt as syncSideViewByPoint,Pt as syncTopViewByPoint,gt as synchronizeBackView,ft as synchronizeSideView,$ as synchronizeTopView,J as topViewPoint2PointCloud,K as topViewPolygon2PointCloud,Jt as usePointCloudViews};
|
|
1
|
+
import{MathUtils as x,getCuboidFromPointCloudBox as Ut}from"@labelbee/lb-annotation";import{EPerspectiveView as F,PointCloudUtils as I,DEFAULT_SPHERE_PARAMS as kt}from"@labelbee/lb-utils";import{useContext as Tt}from"react";import{PointCloudContext as zt}from"../PointCloudContext.js";import{useSingleBox as st}from"./useSingleBox.js";import{useSphere as jt}from"./useSphere.js";import{useSelector as Rt,useDispatch as Et}from"../../../store/ctx.js";import Ht from"../../../utils/StepUtils.js";import{jsonParser as rt}from"../../../utils/index.js";import{SetPointCloudLoading as lt}from"../../../store/annotation/actionCreators.js";import{message as Nt}from"antd";import{useTranslation as Ft}from"react-i18next";import{useHistory as Zt}from"./useHistory.js";import{usePolygon as Wt}from"./usePolygon.js";var Mt=Object.defineProperty,Gt=Object.defineProperties,Qt=Object.getOwnPropertyDescriptors,dt=Object.getOwnPropertySymbols,Xt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable,at=(o,e,n)=>e in o?Mt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,h=(o,e)=>{for(var n in e||(e={}))Xt.call(e,n)&&at(o,n,e[n]);if(dt)for(var n of dt(e))Yt.call(e,n)&&at(o,n,e[n]);return o},k=(o,e)=>Gt(o,Qt(e)),q=(o,e,n)=>new Promise((l,t)=>{var d=a=>{try{r(n.next(a))}catch(g){t(g)}},p=a=>{try{r(n.throw(a))}catch(g){t(g)}},r=a=>a.done?l(a.value):Promise.resolve(a.value).then(d,p);r((n=n.apply(o,e)).next())});const G=5,Q=90,ct=.01,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},J=(o,e,n,l,t)=>{const{x:d,y:p}=I.transferCanvas2World(o,e),{defaultZ:r}=kt,a={center:{x:d,y:p,z:r},id:o.id},g=l?h(h({},l),a):k(h({},a),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},K=(o,e,n,l,t,d)=>{let p=o.pointList.map(m=>I.transferCanvas2World(m,e)),r=0,a=1,g={};if(n){const m=n.getSensesPointZAxisInPolygon(p,void 0,d);d&&m.fittedCoordinates.length>0&&(p=m.fittedCoordinates),r=(m.maxZ+m.minZ)/2,a=m.maxZ-m.minZ,g={count:m.zCount}}const[y,B,T]=p,O=x.getLineCenterPoint([y,T]),V=x.getLineLength(y,B),A=x.getLineLength(B,T),z=x.getRadiusFromQuadrangle(o.pointList);l&&(r=l.center.z,a=l.depth);const U={center:{x:O.x,y:O.y,z:r},width:d?A+ct:A,height:d?V+ct:V,depth:a,rotation:z,id:o.id},_=h(l?h(h({},l),U):k(h({},U),{attribute:"",valid:!0}),g);t&&Object.assign(_,t);const j=p.map(m=>I.transferWorld2Canvas(m,e));return{boxParams:_,newPointList:j}},ut=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return k(h({},n),{center:{x:n.center.x-l.x,y:n.center.y,z:n.center.z-l.y}})},pt=(o,e,n,l)=>{const[t,d,p]=o.pointList,[r,a,g]=e.pointList,y=x.getLineCenterPoint([t,p]),B=x.getLineCenterPoint([r,g]),O={x:{x:y.x-B.x,y:y.y-B.y}.x,y:0,z:y.y-B.y},V=x.getLineLength(t,d),A=x.getLineLength(r,a),z=V-A,U=x.getLineLength(d,p),_=x.getLineLength(a,g),j=U-_,{newBoxParams:m}=l.getNewBoxBySideUpdate(O,j,z,n);return m},qt=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return k(h({},n),{center:{x:n.center.x,y:n.center.y-l.x,z:n.center.z-l.y}})},Jt=(o,e,n,l)=>{const[t,d,p]=o.pointList,[r,a,g]=e.pointList,y=x.getLineCenterPoint([t,p]),B=x.getLineCenterPoint([r,g]),O={x:{x:y.x-B.x,y:y.y-B.y}.x,y:0,z:y.y-B.y},V=x.getLineLength(t,d),A=x.getLineLength(r,a),z=V-A,U=x.getLineLength(d,p),_=x.getLineLength(a,g),j=U-_;let{newBoxParams:m}=l.getNewBoxByBackUpdate(O,j,z,n);return m},ft=(o,e,n,l,t)=>{var d;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:Q);const{cameraPositionVector:a}=r.updateOrthoCameraBySphere(o,F.Left);r.setInitCameraPosition(a);const{point2d:g,zoom:y}=r.getSphereSidePoint2DCoordinate(o);r.camera.zoom=y,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(y),p.setResult([k(h(h({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),p.setSelectedID(e.id)},Ct=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=n;d.loadPCDFileByBox(l,o,{width:G,depth:G});const{cameraPositionVector:p}=d.updateOrthoCamera(o,F.Left);d.setInitCameraPosition(p);const{polygon2d:r,zoom:a}=d.getBoxSidePolygon2DCoordinate(o);d.camera.zoom=a,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(a),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:r,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},gt=(o,e,n,l,t)=>{var d;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:Q);const{cameraPositionVector:a}=r.updateOrthoCameraBySphere(o,F.Back);r.setInitCameraPosition(a);const{point2d:g,zoom:y}=r.getSphereBackPoint2DCoordinate(o);r.camera.zoom=y,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(y),p.setResult([k(h(h({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),p.setSelectedID(e.id)},Pt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=n;d.loadPCDFileByBox(l,o,{height:G,depth:G});const{cameraPositionVector:p}=d.updateOrthoCamera(o,F.Back);d.setInitCameraPosition(p);const{polygon2d:r,zoom:a}=d.getBoxBackPolygon2DCoordinate(o);d.camera.zoom=a,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(a),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:r,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},yt=(o,e,n,l)=>{if(!n||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,F.Top),l.render();const{toolInstance:t,pointCloudInstance:d}=n,{point2d:p}=d.getSphereTopPoint2DCoordinate(o),r=[...t.pointList].map(a=>a.id===e.id?k(h(h({},e),p),{valid:o.valid,textAttribute:"",attribute:o.attribute}):a);t.setResult(r),t.setSelectedID(e.id)},$=(o,e,n,l)=>{var t;if(!n||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:d,pointCloudInstance:p}=n,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(o),a=[...d.polygonList],g=a.find(y=>y.id===e.id);g?g.pointList=r:a.push({id:e.id,pointList:r,textAttribute:"",isRect:!0,valid:(t=o.valid)!=null?t:!0}),d.setResultAndSelectedID(a,e.id)},Kt=()=>{const o=Tt(zt),{topViewInstance:e,sideViewInstance:n,backViewInstance:l,mainViewInstance:t,addPointCloudBox:d,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:a,pointCloudBoxList:g,pointCloudSphereList:y,hideAttributes:B}=o,{addHistory:T,initHistory:O,pushHistoryUnderUpdatePolygon:V,pushHistoryUnderUpdateLine:A}=Zt(),{selectedPolygon:z}=Wt(),{updateSelectedBox:U,updateSelectedBoxes:_,getPointCloudByID:j}=st(),{getPointCloudSphereByID:m,updatePointCloudSphere:tt,selectedSphere:Z}=jt(),{currentData:E,config:S}=Rt(i=>{const{stepList:s,step:f,imgList:c,imgIndex:u}=i.annotation;return{currentData:c[u],config:rt(Ht.getCurrentStepInfo(f,s).config)}}),ot=Et(),{selectedBox:R}=st(),{t:Lt}=Ft(),et=R==null?void 0:R.info;if(!e||!n||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=e,ht=i=>{t==null||t.generateBox(i),t==null||t.controls.update(),t==null||t.render()},mt=i=>{t==null||t.generateSphere(i),t==null||t.controls.update(),t==null||t.render()},vt=({newPoint:i,size:s,zoom:f,trackConfigurable:c})=>{var u;const C={attribute:(u=e.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:I.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:y})});const P=J(i,s,X,void 0,C);r(i.id);const v=p(P);W(L.Top,i,P,f,v,S),T({newSphereParams:P})},xt=({polygon:i,size:s,imgList:f,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var P,v;const w={attribute:(P=e.toolInstance.defaultAttribute)!=null?P:""};c===!0&&Object.assign(w,{trackID:I.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:y})});const H=e==null?void 0:e.toolInstance,D=h({},i),{boxParams:b,newPointList:N}=K(D,s,X,void 0,w,C);if((S==null?void 0:S.lowerLimitPointsNumInBox)&&typeof b.count=="number"&&b.count<S.lowerLimitPointsNumInBox){Nt.info(Lt("LowerLimitPointsNumInBox",{num:S.lowerLimitPointsNumInBox})),H.deletePolygon(b.id);return}C&&(N==null?void 0:N.length)&&(D.pointList=N);const Vt=B.includes(D.attribute),Y=d(b),At=(v=o==null?void 0:o.polygonList)!=null?v:[];e==null||e.updatePolygonList(Y!=null?Y:[],At),Vt?r([]):(r(b.id),H.selection.setSelectedIDs(D.id),M(L.Top,D,b,u,Y),C&&$(b,D,e,t)),T({newBoxParams:b})},Bt=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:f,newSphereList:c})=>{var u;const C=e==null?void 0:e.toolInstance;if(!(a.length===0||!C)){if(i||(R==null?void 0:R.info)){const P=i!=null?i:R==null?void 0:R.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(a[0]);const v=C.selectedPolygon;if(a.length===1&&P){M(L.Top,v,P,void 0,s);return}}if((f||Z)&&a.length===1){const P=f!=null?f:Z;C.setSelectedID(a[0]);const v=C.selectedPoint;P&&W(L.Top,v,P,void 0,c,S)}}},nt=(i,s,f)=>{if(et){let c,u;switch(f){case L.Back:c=Jt;break;case L.Side:c=pt;break;default:c=pt;break}if(u=c(i,s,et,n.pointCloudInstance),t){const{count:P}=t.getSensesPointZAxisInPolygon(Ut(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=k(h({},u),{count:P})}const C=U(u);return M(f,i,u,void 0,C),C}},it=(i,s,f)=>{if(Z){let c,u;switch(f){case L.Back:c=qt;break;case L.Side:c=ut;break;default:c=ut;break}u=c(i,s,Z);const C=tt(u);return W(f,i,u,void 0,C,S),C}},St=(i,s)=>{it(i,s,L.Side)},bt=(i,s)=>{it(i,s,L.Back)},It=(i,s)=>{nt(i,s,L.Side)},wt=(i,s)=>{nt(i,s,L.Back)},_t=(i,s)=>{A(i)},Dt=(i,s)=>{const f=m(i.id),c=J(i,s,X,f),u=tt(c);W(L.Top,i,c,void 0,u,S)},Ot=(i,s)=>{if(z){const c=i[0].newPolygon;c.pointList=c.pointList.map(u=>I.transferCanvas2World(u,s)),V(i[0].newPolygon);return}const f=i.map(({newPolygon:c})=>{const u=j(c.id),{boxParams:C}=K(c,s,e.pointCloudInstance,u);return C});if(f.length===1){const{newPolygon:c}=i[0],u=_(f);M(L.Top,c,f[0],void 0,u)}else{const c=_(f);c&&o.syncAllViewPointCloudColor(c)}},W=(i,s,f,c,u,C)=>q(void 0,null,function*(){const P=E==null?void 0:E.url,v={[L.Side]:()=>{ft(f,s,n,P,C)},[L.Back]:()=>{l&>(f,s,l,P,C)},[L.Top]:()=>{yt(f,s,e,t)}};Object.keys(v).forEach(w=>{w!==i&&v[w]()}),c&&(t==null||t.updateCameraZoom(c)),mt(f)}),M=(i,s,f,c,u)=>q(void 0,null,function*(){const C=E==null?void 0:E.url;u&&(yield o.syncAllViewPointCloudColor(u));const P={[L.Side]:()=>{Ct(f,s,n,C)},[L.Back]:()=>{l&&Pt(f,s,l,C)},[L.Top]:()=>{$(f,s,e,t)}};Object.keys(P).forEach(v=>{v!==i&&P[v]()}),c&&(t==null||t.updateCameraZoom(c)),ht(f)});return{topViewAddSphere:vt,topViewAddBox:xt,topViewSelectedChanged:Bt,topViewUpdatePoint:Dt,sideViewUpdatePoint:St,backViewUpdatePoint:bt,topViewUpdateBox:Ot,topViewUpdateLine:_t,sideViewUpdateBox:It,backViewUpdateBox:wt,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),t==null||t.generateBoxes(i)},initPointCloud3d:i=>{if(!t)return;const s=I.getDefaultOrthographicParams(i);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...i)=>q(void 0,[...i],function*(s=E){var f,c,u,C,P,v;if(!(s==null?void 0:s.url)||!t)return;lt(ot,!0),yield t.loadPCDFile(s.url,(f=S==null?void 0:S.radius)!=null?f:Q),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let w=[],H=[],D=[],b=[];s.result&&(w=I.getBoxParamsFromResultList(s.result),D=I.getPolygonListFromResultList(s.result),H=I.getLineListFromResultList(s.result),b=I.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(w),t==null||t.generateSpheres(b),o.syncAllViewPointCloudColor(w)),O({pointCloudBoxList:w,polygonList:D,lineList:H,pointCloudSphereList:b}),t.updateTopCamera();const N=(u=(c=rt(s.result))==null?void 0:c.valid)!=null?u:!0;o.setPointCloudValid(N),(C=o.sideViewInstance)==null||C.clearAllData(),(P=o.backViewInstance)==null||P.clearAllData(),e.updateData(s.url,s.result,{radius:(v=S==null?void 0:S.radius)!=null?v:Q}),lt(ot,!1)})}};export{gt as syncBackViewByPoint,ft as syncSideViewByPoint,yt as syncTopViewByPoint,Pt as synchronizeBackView,Ct as synchronizeSideView,$ as synchronizeTopView,J as topViewPoint2PointCloud,K as topViewPolygon2PointCloud,Kt as usePointCloudViews};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.2-alpha.2",
|
|
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.16.
|
|
46
|
+
"@labelbee/lb-annotation": "1.16.1-alpha.2",
|
|
47
47
|
"@labelbee/lb-utils": "1.8.0",
|
|
48
48
|
"ahooks": "^3.4.0",
|
|
49
49
|
"classnames": "^2.3.0",
|