@labelbee/lb-components 1.24.0-alpha.61 → 1.24.0-alpha.62
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/pointCloudView/PointCloud3DView.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/components/pointCloudView/index.js +1 -1
- package/dist/store/annotation/reducer.js +1 -1
- package/dist/types/store/annotation/reducer.d.ts +2 -2
- package/dist/types/utils/index.d.ts +11 -0
- package/dist/utils/index.js +1 -1
- package/es/components/pointCloudView/PointCloud3DView.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/index.js +1 -1
- package/es/store/annotation/reducer.js +1 -1
- package/es/utils/index.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),classNames=require("classnames"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),index=require("../../utils/index.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index$1=require("./components/PointCloudSizeSlider/index.js"),index$2=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons"),useToolStyle=require("../../hooks/useToolStyle.js"),usePointCloudAttribute=require("./hooks/usePointCloudAttribute.js");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,
|
|
1
|
+
"use strict";var dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),classNames=require("classnames"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),index=require("../../utils/index.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index$1=require("./components/PointCloudSizeSlider/index.js"),index$2=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons"),useToolStyle=require("../../hooks/useToolStyle.js"),usePointCloudAttribute=require("./hooks/usePointCloudAttribute.js");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,a,l)=>a in n?__defProp(n,a,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[a]=l,__spreadValues=(n,a)=>{for(var l in a||(a={}))__hasOwnProp.call(a,l)&&__defNormalProp(n,l,a[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(a))__propIsEnum.call(a,l)&&__defNormalProp(n,l,a[l]);return n};const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:n})=>{const{isActive:a,setTarget3DView:l}=React.useContext(PointCloud3DContext),m=c=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",c)]:!0,active:a});return React__default.default.createElement("span",{onClick:()=>{l(lbUtils.EPerspectiveView[n])},className:m(n.toLocaleLowerCase())})},PointCloud3DSideBar=({isEnlarge:n})=>{const{reset3DView:a,followTopView:l}=React.useContext(PointCloud3DContext),{t:m}=reactI18next.useTranslation(),c=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Top"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Front"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Left"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Back"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Right"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"LFT"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"RBT"})),e=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Tooltip,{title:m("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{l()},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")},e,c):React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},c,e)},PointCloud3D=({currentData:n,config:a,highlightAttribute:l,setResourceLoading:m})=>{var c;const e=React.useContext(PointCloudContext.PointCloudContext),{setIsLargeStatus:E}=e,[b,B]=React.useState(!0),[f,C]=React.useState(!1),v=React.useRef(null),{initPointCloud3d:P,generateRects:L}=usePointCloudViews.usePointCloudViews(),p=useSize(v),{t:V}=reactI18next.useTranslation(),{value:x}=useToolStyle.useToolStyleContext(),{hiddenText:I}=x||{},{updatePointCloudAttribute:N}=usePointCloudAttribute.usePointCloudAttribute(m,a),{updateSelectedBox:q}=useSingleBox.useSingleBox({generateRects:L});React.useEffect(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(I,e.pointCloudBoxList)},[x]),React.useEffect(()=>{!e.mainViewInstance||P==null||P(p)},[p]);const{selectedBox:u}=useSingleBox.useSingleBox(),{selectedSphere:w}=useSphere.useSphere(),[j,h]=React.useState(!0),g=t=>{var o,s;const i=u==null?void 0:u.info;if(i){const r=__spreadValues({},i.center);r.x=r.x-.01,r.z=1e3;const d=t===lbUtils.EPerspectiveView.Top;(o=e.mainViewInstance)==null||o.updateCameraByBox(i,t,d?r:void 0)}w&&((s=e.mainViewInstance)==null||s.updateCameraBySphere(w,t))},D=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},R=()=>{var t,o;const s=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;s&&((o=e.mainViewInstance)==null||o.applyCameraTarget(s))};React.useEffect(()=>{if(v.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&p.width&&(t=new lbAnnotation.PointCloud({container:v.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(p),config:a,hiddenText:I,view:"3DView"}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:h}),e.setMainViewInstance(t))}},[p,n]),React.useEffect(()=>{var t;if(v.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let o=e.mainViewInstance;const s=lbUtils.PointCloudUtils.getRectParamsFromResultList(n.result),i=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),r=i.find(d=>d.id===e.selectedID);r&&((t=e.topViewInstance)==null||t.updatePolygonList(i,void 0),N(r.attribute),q(r),e.setSelectedIDs(r.id)),e.setPointCloudValid(index.resolveFileItemValid(n.result,n.preResult)),e.setPointCloudResult(i),e.setRectList(s),o.generateBoxes(i)}},[n.result,e.mainViewInstance]),React.useEffect(()=>{var t,o,s,i,r,d,T;const y=(t=u==null?void 0:u.info)==null?void 0:t.id;if(!j){h(!0);return}if(y!==void 0){g(lbUtils.EPerspectiveView.Top);const z=(i=(s=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:s.camera.zoom)!=null?i:1;(r=e.mainViewInstance)==null||r.updateCameraZoom(z)}(d=e.mainViewInstance)==null||d.setHighlightColor(y),(T=e.mainViewInstance)==null||T.render()},[(c=u==null?void 0:u.info)==null?void 0:c.id]),React.useEffect(()=>{var t,o,s,i;if(w){g(lbUtils.EPerspectiveView.Top);const r=(s=(o=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:o.camera.zoom)!=null?s:1;(i=e.mainViewInstance)==null||i.updateCameraZoom(r)}},[w]),React.useEffect(()=>(window.addEventListener("keydown",_),()=>{window.removeEventListener("keydown",_)}),[]);const _=t=>{if(t.keyCode===EKeyCode.Esc){C(!1);return}},S=React.useMemo(()=>({reset3DView:D,setTarget3DView:g,isActive:!!u,followTopView:R}),[u,e.mainViewInstance]);React.useEffect(()=>{var t,o,s;const i=e.pointCloudBoxList.filter(r=>r.attribute===l);(i==null?void 0:i.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(o=e.mainViewInstance)==null||o.highlightBoxes(i)),i.length===0&&((s=e.mainViewInstance)==null||s.clearHighlightBoxesAndRender())},[l,e.mainViewInstance]);const k=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:t=>{var o;(o=e.mainViewInstance)==null||o.updatePointSize({customSize:t})}}),React__default.default.createElement("span",{style:{marginRight:8}},V("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:b,onChange:t=>{var o;B(t),(o=e.mainViewInstance)==null||o.setShowDirection(t)}}),f&&React__default.default.createElement(PointCloud3DContext.Provider,{value:S},React__default.default.createElement(PointCloud3DSideBar,{isEnlarge:f})));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-3d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:f}),title:f?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{E(!1),C(!1)}}),V("3DView")):React__default.default.createElement(index$2,{title:V("3DView"),onClick:()=>{E(!0),C(!0)}}),toolbar:k},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},!f&&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:v})))};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"),_=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,v,U]=P,D=lbAnnotation.MathUtils.getLineCenterPoint([f,U]),S=lbAnnotation.MathUtils.getLineLength(f,v),V=lbAnnotation.MathUtils.getLineLength(v,U),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);a&&(c=a.center.z,d=a.depth);const T={center:{x:D.x,y:D.y,z:c},width:e?V+INTELLIGENT_FIT_MARGIN:V,height:e?S+INTELLIGENT_FIT_MARGIN:S,depth:d,rotation:k,id:o.id},O=__spreadValues(a?__spreadValues(__spreadValues({},a),T):__spreadProps(__spreadValues({},T),{attribute:"",valid:!0}),x);p&&Object.assign(O,p);const A=P.map(b=>lbUtils.PointCloudUtils.transferWorld2Canvas(b,n));return{boxParams:O,newPointList:A}},sideViewPoint2PointCloud=(o,n,t)=>{const a={x:o.x-n.x,y:o.y-n.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-a.x,y:t.center.y,z:t.center.z-a.y}})},sideViewPolygon2PointCloud=(o,n,t,a)=>{const[p,e,P]=o.pointList,[c,d,x]=n.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),v=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),D={x:{x:f.x-v.x,y:f.y-v.y}.x,y:0,z:f.y-v.y},S=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),k=S-V,T=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(d,x),A=T-O,{newBoxParams:b}=a.getNewBoxBySideUpdate(D,A,k,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]),v=lbAnnotation.MathUtils.getLineCenterPoint([c,x]),D={x:{x:f.x-v.x,y:f.y-v.y}.x,y:0,z:f.y-v.y},S=lbAnnotation.MathUtils.getLineLength(p,e),V=lbAnnotation.MathUtils.getLineLength(c,d),k=S-V,T=lbAnnotation.MathUtils.getLineLength(e,P),O=lbAnnotation.MathUtils.getLineLength(d,x),A=T-O;let{newBoxParams:b}=a.getNewBoxByBackUpdate(D,A,k,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(v=>v.id===n.id);f?(f.pointList=d,f.valid=(p=o.valid)!=null?p:!0):x.push({id:n.id,pointList:d,textAttribute:"",isRect:!0,valid:(e=o.valid)!=null?e:!0}),P.setResultAndSelectedID(x,n.id)},usePointCloudViews=o=>{const n=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:a,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:d,selectedIDs:x,pointCloudBoxList:f,pointCloudSphereList:v,hideAttributes:U,setHighlight2DDataList:D,cuboidBoxIn2DView:S,imageSizes:V,history:k,linkageImageNameRectMap:T}=n,{addHistory:O,initHistory:A,pushHistoryUnderUpdatePolygon:b}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:nt,updatePointCloudSphere:Y,selectedSphere:Z}=useSphere.useSphere(),{currentData:E,config:y}=ctx.useSelector(s=>{const{stepList:i,step:u,imgList:r,imgIndex:g}=s.annotation;return{currentData:r[g],config:index.jsonParser(StepUtils.getCurrentStepInfo(u,i).config)}}),M=ctx.useDispatch(),it=ahooks.useLatest(S),st=ahooks.useLatest(T),lt=React.useCallback((s,i)=>{const u=st.current,r=i.id;return s.filter(l=>{if(!l)return!1;const h=u.get(l.imageName);return h===void 0?!0:Boolean(h.get(r))})},[]),J=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!it.current||i){const{mappingImgList:u=[]}=E;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:u,imageSizes:V},{prepareRectsFn:lt})}},{selectedBox:R,updateSelectedBox:rt,updateSelectedBoxes:Q,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:J}),K=R==null?void 0:R.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:r})=>{var g;const l={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};r===!0&&Object.assign(l,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const h=topViewPoint2PointCloud(s,i,X,void 0,l);d(s.id);const C=c(h);H(PointCloudView.Top,s,h,u,C,y),O({newSphereParams:h})},ct=({polygon:s,size:i,imgList:u,trackConfigurable:r,zoom:g,intelligentFit:l})=>{var h,C,w;const I={attribute:(h=t.toolInstance.defaultAttribute)!=null?h:""};r===!0&&Object.assign(I,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:v})}),t==null||t.toolInstance;const L=__spreadValues({},s);let{boxParams:B,newPointList:m}=topViewPolygon2PointCloud(L,i,X,void 0,I,l);B=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[B],stepConfig:y,action:"viewUpdateBox"}))[0],l&&(m==null?void 0:m.length)&&(L.pointList=m);const z=U.includes(L.attribute);J(B);const j=P(B),F=(C=n==null?void 0:n.polygonList)!=null?C:[];B.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(w=y==null?void 0:y.inputList)!=null?w:[]:[]),t==null||t.updatePolygonList(j!=null?j:[],F,!1),z?d([]):(d(B.id),l&&synchronizeTopView(B,L,t,e)),O({newBoxParams:B})},pt=s=>{const{boxID:i,imageName:u,width:r,height:g,x:l,y:h}=s,C=f.find(m=>m.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(m=>m.imageName===u))return;const I=C.rects.map(m=>m.imageName===u?__spreadProps(__spreadValues({},m),{width:r,height:g,x:l,y:h}):m),L=__spreadProps(__spreadValues({},C),{rects:I}),B=f.map(m=>m.id===i?L:m);return t==null||t.updatePolygonList(B!=null?B:[]),B},gt=s=>{const{boxID:i,imageName:u}=s,r=f.find(C=>C.id===i);if(!(r==null?void 0:r.rects))return;const g=r.rects.filter(C=>C.imageName!==u),l=__spreadProps(__spreadValues({},r),{rects:g}),h=f.map(C=>C.id===i?l:C);return t==null||t.updatePolygonList(h!=null?h:[]),h},Pt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:u,newSphereList:r})=>{var g;const l=t==null?void 0:t.toolInstance;if(!(x.length===0||!l)){if(s||(R==null?void 0:R.info)){const h=s!=null?s:R==null?void 0:R.info;(g=l==null?void 0:l.selection)==null||g.setSelectedIDs(x[0]);const C=l.selectedPolygon;if(x.length===1&&h){q({omitView:PointCloudView.Top,polygon:C,boxParams:h,newPointCloudBoxList:i});return}}if((u||Z)&&x.length===1){const h=u!=null?u:Z;l.setSelectedID(x[0]);const C=l.selectedPoint;h&&H(PointCloudView.Top,C,h,void 0,r,y)}}},$=(s,i,u,r=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{if(K){let g,l;switch(u){case PointCloudView.Back:g=backViewPolygon2PointCloud;break;case PointCloudView.Side:g=sideViewPolygon2PointCloud;break;default:g=sideViewPolygon2PointCloud;break}if(l=g(s,i,K,a.pointCloudInstance),e){const{count:L}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:L})}const C=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:y,action:"viewUpdateBox"}))[0],w=l.valid!==C.valid;l=C;const I=rt(l);return l=I.find(L=>L.id===l.id),q({omitView:w?void 0:u,polygon:s,boxParams:l,newPointCloudBoxList:I},r),I}},tt=(s,i,u)=>{if(Z){let r,g;switch(u){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}g=r(s,i,Z);const l=Y(g);return H(u,s,g,void 0,l,y),l}},Ct=(s,i)=>{tt(s,i,PointCloudView.Side)},ft=(s,i)=>{tt(s,i,PointCloudView.Back)},ht=(s,i)=>{$(s,i,PointCloudView.Side,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},xt=(s,i)=>{$(s,i,PointCloudView.Back,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},vt=(s,i)=>{const u=nt(s.id),r=topViewPoint2PointCloud(s,i,X,u),g=Y(r);H(PointCloudView.Top,s,r,void 0,g,y)},Lt=(s,i)=>{if(ot){const r=__spreadValues({},s[0].newPolygon);r.pointList=r.pointList.map(g=>lbUtils.PointCloudUtils.transferCanvas2World(g,i)),b(r);return}let u=s.map(({newPolygon:r})=>{const g=at(r.id),{boxParams:l}=topViewPolygon2PointCloud(r,i,t.pointCloudInstance,g);return l});if(u=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:u,stepConfig:y,action:"viewUpdateBox"})),u.length===1){const{newPolygon:r}=s[0],g=Q(u);q({polygon:r,boxParams:u[0],newPointCloudBoxList:g},ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)}else{const r=Q(u);r&&n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,r)}},yt=s=>{var i,u,r,g,l;if(R){const h=Number(s.widthDefault),C=Number(s.depthDefault),w=Number(s.heightDefault),I=R==null?void 0:R.info.trackID,B=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(G=>(G==null?void 0:G.trackID)===I),m={width:(r=(u=t==null?void 0:t.toolInstance)==null?void 0:u.basicImgInfo)==null?void 0:r.width,height:(l=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:l.height},N=B.pointList.map(G=>lbUtils.PointCloudUtils.transferCanvas2World(G,m)),z=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(N,w,h),j=z[0],F=z[2],W=lbAnnotation.MathUtils.getLineCenterPoint([j,F]),mt=R.info.center.z-R.info.depth/2,et=__spreadProps(__spreadValues({},R.info),{center:{x:W.x,y:W.y,z:mt+C/2},width:h,height:w,depth:C,valid:!0}),Bt=Q([et]);q({omitView:PointCloudView["3D"],polygon:B,boxParams:et,newPointCloudBoxList:Bt})}},H=(s,i,u,r,g,l)=>__async(void 0,null,function*(){const h=E==null?void 0:E.url,C={[PointCloudView.Side]:()=>{syncSideViewByPoint(u,i,a,h,l)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(u,i,p,h,l)},[PointCloudView.Top]:()=>{syncTopViewByPoint(u,i,t,e)}};Object.keys(C).forEach(w=>{w!==s&&C[w]()}),r&&(e==null||e.updateCameraZoom(r)),dt(u)}),q=(s,i=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:u,polygon:r,boxParams:g,zoom:l,newPointCloudBoxList:h}=s,C=E==null?void 0:E.url;h&&n.syncAllViewPointCloudColor(i,h);const w={[PointCloudView.Side]:()=>{synchronizeSideView(g,r,a,C)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(g,r,p,C)},[PointCloudView.Top]:()=>{synchronizeTopView(g,r,t,e)}};Object.keys(w).forEach(I=>{I!==u&&w[I]()}),l&&(e==null||e.updateCameraZoom(l))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:ht,backViewUpdateBox:xt,syncPointCloudViews:q,syncPointCloudPoint:H,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),e==null||e.generateBoxes(s)},initPointCloud3d:s=>{if(!e)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(s);e.initOrthographicCamera(i),e.initRenderer(),e.render()},updatePointCloudData:(...s)=>__async(void 0,[...s],function*(i=E){var u,r,g,l,h,C,w,I;if(!(i==null?void 0:i.url)||!e)return;D([]),actionCreators.SetAnnotationLoading(M,!0),actionCreators.SetLoadPCDFileLoading(M,!0),(u=o==null?void 0:o.setResourceLoading)==null||u.call(o,!0),yield e.loadPCDFile(i.url,(r=y==null?void 0:y.radius)!=null?r:DEFAULT_RADIUS,y==null?void 0:y.tipScopeList),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let L=[],B=[],m=[],N=[];e.updateTopCamera();const z=index.jsonParser(i.result),j=index.jsonParser(i.preResult),F=(l=(g=z==null?void 0:z.valid)!=null?g:j==null?void 0:j.valid)!=null?l:!0;if(n.setPointCloudValid(F),(h=n.sideViewInstance)==null||h.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(L=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(L==null?void 0:L.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){L=yield e==null?void 0:e.filterPreResult(i.url,y,L);const W=index.jsonParser(i.result);W[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=L,i.result=JSON.stringify(W),n.setPointCloudResult(L)}m=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),B=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),N=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(w=y==null?void 0:y.radius)!=null?w:DEFAULT_RADIUS}),e==null||e.generateBoxes(L),e==null||e.generateSpheres(N),yield n.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,L,[])}A({pointCloudBoxList:L,polygonList:m,lineList:B,pointCloudSphereList:N}),actionCreators.SetAnnotationLoading(M,!1),actionCreators.SetLoadPCDFileLoading(M,!1),(I=o==null?void 0:o.setResourceLoading)==null||I.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 v=f.extId,U=f.imageName,D=_.pick(f,["x","y","width","height"]);let S=d.get(v);S||(S=new Map,d.set(v,S)),S.set(U,D),x.add(v)}),d.size){const f=P.map(v=>{var U;const D=v.id;if(x.has(D)){const S=__spreadValues({},v);return(U=S.rects)==null||U.forEach(V=>{var k;const T=V.imageName;Object.assign(V,(k=d.get(D))==null?void 0:k.get(T))}),S}return v});return t(f),f}return null},[])}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews,exports.useSyncRectPositionDimensionToPointCloudList=useSyncRectPositionDimensionToPointCloudList;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),_=require("lodash"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,i,t)=>i in o?__defProp(o,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[i]=t,__spreadValues=(o,i)=>{for(var t in i||(i={}))__hasOwnProp.call(i,t)&&__defNormalProp(o,t,i[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(i))__propIsEnum.call(i,t)&&__defNormalProp(o,t,i[t]);return o},__spreadProps=(o,i)=>__defProps(o,__getOwnPropDescs(i)),__async=(o,i,t)=>new Promise((a,p)=>{var e=d=>{try{c(t.next(d))}catch(h){p(h)}},P=d=>{try{c(t.throw(d))}catch(h){p(h)}},c=d=>d.done?a(d.value):Promise.resolve(d.value).then(e,P);c((t=t.apply(o,i)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,i,t,a,p)=>{const{x:e,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,i),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:e,y:P,z:c},id:o.id},h=a?__spreadValues(__spreadValues({},a),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},topViewPolygon2PointCloud=(o,i,t,a,p,e)=>{let P=o.pointList.map(b=>lbUtils.PointCloudUtils.transferCanvas2World(b,i)),c=0,d=1,h={};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,h={count:b.zCount}}const[f,L,U]=P,D=lbAnnotation.MathUtils.getLineCenterPoint([f,U]),w=lbAnnotation.MathUtils.getLineLength(f,L),V=lbAnnotation.MathUtils.getLineLength(L,U),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);a&&(c=a.center.z,d=a.depth);const T={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:k,id:o.id},A=__spreadValues(a?__spreadValues(__spreadValues({},a),T):__spreadProps(__spreadValues({},T),{attribute:"",valid:!0}),h);p&&Object.assign(A,p);const O=P.map(b=>lbUtils.PointCloudUtils.transferWorld2Canvas(b,i));return{boxParams:A,newPointList:O}},sideViewPoint2PointCloud=(o,i,t)=>{const a={x:o.x-i.x,y:o.y-i.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x-a.x,y:t.center.y,z:t.center.z-a.y}})},sideViewPolygon2PointCloud=(o,i,t,a)=>{const[p,e,P]=o.pointList,[c,d,h]=i.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),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),k=w-V,T=lbAnnotation.MathUtils.getLineLength(e,P),A=lbAnnotation.MathUtils.getLineLength(d,h),O=T-A,{newBoxParams:b}=a.getNewBoxBySideUpdate(D,O,k,t);return b},backViewPoint2PointCloud=(o,i,t)=>{const a={x:o.x-i.x,y:o.y-i.y};return __spreadProps(__spreadValues({},t),{center:{x:t.center.x,y:t.center.y-a.x,z:t.center.z-a.y}})},backViewPolygon2PointCloud=(o,i,t,a)=>{const[p,e,P]=o.pointList,[c,d,h]=i.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([p,P]),L=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),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),k=w-V,T=lbAnnotation.MathUtils.getLineLength(e,P),A=lbAnnotation.MathUtils.getLineLength(d,h),O=T-A;let{newBoxParams:b}=a.getNewBoxByBackUpdate(D,O,k,t);return b},syncSideViewByPoint=(o,i,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:h,zoom:f}=c.getSphereSidePoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},i),h),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(i.id)},synchronizeSideView=(o,i,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:i.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],i.id)},syncBackViewByPoint=(o,i,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:h,zoom:f}=c.getSphereBackPoint2DCoordinate(o);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},i),h),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(i.id)},synchronizeBackView=(o,i,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:i.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],i.id)},syncTopViewByPoint=(o,i,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===i.id?__spreadProps(__spreadValues(__spreadValues({},i),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):d);p.setResult(c),p.setSelectedID(i.id)},synchronizeTopView=(o,i,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),h=[...P.polygonList],f=h.find(L=>L.id===i.id);f?(f.pointList=d,f.valid=(p=o.valid)!=null?p:!0):h.push({id:i.id,pointList:d,textAttribute:"",isRect:!0,valid:(e=o.valid)!=null?e:!0}),P.setResultAndSelectedID(h,i.id)},usePointCloudViews=o=>{const i=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:a,backViewInstance:p,mainViewInstance:e,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:d,selectedIDs:h,pointCloudBoxList:f,pointCloudSphereList:L,hideAttributes:U,setHighlight2DDataList:D,cuboidBoxIn2DView:w,imageSizes:V,history:k,linkageImageNameRectMap:T}=i,{addHistory:A,initHistory:O,pushHistoryUnderUpdatePolygon:b}=useHistory.useHistory(),{selectedPolygon:ot}=usePolygon.usePolygon(),{getPointCloudSphereByID:it,updatePointCloudSphere:X,selectedSphere:H}=useSphere.useSphere(),{currentData:z,config:y}=ctx.useSelector(s=>{const{stepList:n,step:u,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:index.jsonParser(StepUtils.getCurrentStepInfo(u,n).config)}}),M=ctx.useDispatch(),nt=ahooks.useLatest(w),st=ahooks.useLatest(T),rt=React.useCallback((s,n)=>{const u=st.current,l=n.id;return s.filter(r=>{if(!r)return!1;const x=u.get(r.imageName);return x===void 0?!0:Boolean(x.get(l))})},[]),Z=s=>{const{enableAutoMap2DRect:n=!1}=y;if(!nt.current||n){const{mappingImgList:u=[]}=z;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:u,imageSizes:V},{prepareRectsFn:rt})}},{selectedBox:R,updateSelectedBox:lt,updateSelectedBoxes:G,getPointCloudByID:at}=useSingleBox.useSingleBox({generateRects:Z}),Y=R==null?void 0:R.info;if(!t||!a||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:J}=t,dt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},ut=({newPoint:s,size:n,zoom:u,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:L})});const x=topViewPoint2PointCloud(s,n,J,void 0,r);d(s.id);const C=c(x);E(PointCloudView.Top,s,x,u,C,y),A({newSphereParams:x})},ct=({polygon:s,size:n,imgList:u,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var x,C,v;const S={attribute:(x=t.toolInstance.defaultAttribute)!=null?x:""};l===!0&&Object.assign(S,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:L})}),t==null||t.toolInstance;const I=__spreadValues({},s);let{boxParams:m,newPointList:B}=topViewPolygon2PointCloud(I,n,J,void 0,S,r);m=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[m],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(B==null?void 0:B.length)&&(I.pointList=B);const q=U.includes(I.attribute);Z(m);const F=P(m),Q=(C=i==null?void 0:i.polygonList)!=null?C:[];m.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(v=y==null?void 0:y.inputList)!=null?v:[]:[]),t==null||t.updatePolygonList(F!=null?F:[],Q,!1),q?d([]):(d(m.id),r&&synchronizeTopView(m,I,t,e)),A({newBoxParams:m})},pt=s=>{const{boxID:n,imageName:u,width:l,height:g,x:r,y:x}=s,C=f.find(B=>B.id===n);if(!(C==null?void 0:C.rects)||!C.rects.find(B=>B.imageName===u))return;const S=C.rects.map(B=>B.imageName===u?__spreadProps(__spreadValues({},B),{width:l,height:g,x:r,y:x}):B),I=__spreadProps(__spreadValues({},C),{rects:S}),m=f.map(B=>B.id===n?I:B);return t==null||t.updatePolygonList(m!=null?m:[]),m},gt=s=>{const{boxID:n,imageName:u}=s,l=f.find(C=>C.id===n);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==u),r=__spreadProps(__spreadValues({},l),{rects:g}),x=f.map(C=>C.id===n?r:C);return t==null||t.updatePolygonList(x!=null?x:[]),x},Pt=({newSelectedBox:s,newPointCloudList:n,newSelectedSphere:u,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(h.length===0||!r)){if(s||(R==null?void 0:R.info)){const x=s!=null?s:R==null?void 0:R.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(h[0]);const C=r.selectedPolygon;if(h.length===1&&x){N({omitView:PointCloudView.Top,polygon:C,boxParams:x,newPointCloudBoxList:n});return}}if((u||H)&&h.length===1){const x=u!=null?u:H;r.setSelectedID(h[0]);const C=r.selectedPoint;x&&E(PointCloudView.Top,C,x,void 0,l,y)}}},K=(s,n,u,l=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{if(Y){let g,r;switch(u){case PointCloudView.Back:g=backViewPolygon2PointCloud;break;case PointCloudView.Side:g=sideViewPolygon2PointCloud;break;default:g=sideViewPolygon2PointCloud;break}if(r=g(s,n,Y,a.pointCloudInstance),e){const{count:I}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:I})}const C=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],v=r.valid!==C.valid;r=C;const S=lt(r);return r=S.find(I=>I.id===r.id),N({omitView:v?void 0:u,polygon:s,boxParams:r,newPointCloudBoxList:S},l),S}},$=(s,n,u)=>{if(H){let l,g;switch(u){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}g=l(s,n,H);const r=X(g);return E(u,s,g,void 0,r,y),r}},Ct=(s,n)=>{$(s,n,PointCloudView.Side)},ft=(s,n)=>{$(s,n,PointCloudView.Back)},xt=(s,n)=>{K(s,n,PointCloudView.Side,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},ht=(s,n)=>{K(s,n,PointCloudView.Back,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},vt=(s,n)=>{const u=it(s.id),l=topViewPoint2PointCloud(s,n,J,u),g=X(l);E(PointCloudView.Top,s,l,void 0,g,y)},Lt=(s,n)=>{if(ot){const l=__spreadValues({},s[0].newPolygon);l.pointList=l.pointList.map(g=>lbUtils.PointCloudUtils.transferCanvas2World(g,n)),b(l);return}let u=s.map(({newPolygon:l})=>{const g=at(l.id),{boxParams:r}=topViewPolygon2PointCloud(l,n,t.pointCloudInstance,g);return r});if(u=M(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:u,stepConfig:y,action:"viewUpdateBox"})),u.length===1){const{newPolygon:l}=s[0],g=G(u);N({polygon:l,boxParams:u[0],newPointCloudBoxList:g},ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)}else{const l=G(u);l&&i.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,l)}},yt=s=>{var n,u,l,g,r;if(R){const x=Number(s.widthDefault),C=Number(s.depthDefault),v=Number(s.heightDefault),S=R==null?void 0:R.info.trackID,m=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(W=>(W==null?void 0:W.trackID)===S),B={width:(l=(u=t==null?void 0:t.toolInstance)==null?void 0:u.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},j=m.pointList.map(W=>lbUtils.PointCloudUtils.transferCanvas2World(W,B)),q=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(j,v,x),F=q[0],Q=q[2],tt=lbAnnotation.MathUtils.getLineCenterPoint([F,Q]),mt=R.info.center.z-R.info.depth/2,et=__spreadProps(__spreadValues({},R.info),{center:{x:tt.x,y:tt.y,z:mt+C/2},width:x,height:v,depth:C,valid:!0}),Bt=G([et]);N({omitView:PointCloudView["3D"],polygon:m,boxParams:et,newPointCloudBoxList:Bt})}},E=(s,n,u,l,g,r)=>__async(void 0,null,function*(){const x=z==null?void 0:z.url,C={[PointCloudView.Side]:()=>{syncSideViewByPoint(u,n,a,x,r)},[PointCloudView.Back]:()=>{p&&syncBackViewByPoint(u,n,p,x,r)},[PointCloudView.Top]:()=>{syncTopViewByPoint(u,n,t,e)}};Object.keys(C).forEach(v=>{v!==s&&C[v]()}),l&&(e==null||e.updateCameraZoom(l)),dt(u)}),N=(s,n=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:u,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:x}=s,C=z==null?void 0:z.url;x&&i.syncAllViewPointCloudColor(n,x);const v={[PointCloudView.Side]:()=>{synchronizeSideView(g,l,a,C)},[PointCloudView.Back]:()=>{p&&synchronizeBackView(g,l,p,C)},[PointCloudView.Top]:()=>{synchronizeTopView(g,l,t,e)}};Object.keys(v).forEach(S=>{S!==u&&v[S]()}),r&&(e==null||e.updateCameraZoom(r))};return{topViewAddSphere:ut,topViewAddBox:ct,topViewSelectedChanged:Pt,topViewUpdatePoint:vt,sideViewUpdatePoint:Ct,backViewUpdatePoint:ft,topViewUpdateBox:Lt,sideViewUpdateBox:xt,backViewUpdateBox:ht,syncPointCloudViews:N,syncPointCloudPoint:E,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),e==null||e.generateBoxes(s)},initPointCloud3d:s=>{if(!e)return;const n=lbUtils.PointCloudUtils.getDefaultOrthographicParams(s);e.initOrthographicCamera(n),e.initRenderer(),e.render()},updatePointCloudData:(...s)=>__async(void 0,[...s],function*(n=z){var u,l,g,r,x,C;if(!(n==null?void 0:n.url)||!e)return;D([]),actionCreators.SetAnnotationLoading(M,!0),actionCreators.SetLoadPCDFileLoading(M,!0),(u=o==null?void 0:o.setResourceLoading)==null||u.call(o,!0),yield e.loadPCDFile(n.url,(l=y==null?void 0:y.radius)!=null?l:DEFAULT_RADIUS,y==null?void 0:y.tipScopeList),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let v=[],S=[],I=[],m=[];e.updateTopCamera();const B=index.resolveFileItemValid(n.result,n.preResult);if(i.setPointCloudValid(B),(g=i.sideViewInstance)==null||g.clearAllData(),(r=i.backViewInstance)==null||r.clearAllData(),n.result){if(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),(v==null?void 0:v.length)>0&&n.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){v=yield e==null?void 0:e.filterPreResult(n.url,y,v);const j=index.jsonParser(n.result);j[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=v,n.result=JSON.stringify(j),i.setPointCloudResult(v)}I=lbUtils.PointCloudUtils.getPolygonListFromResultList(n.result),S=lbUtils.PointCloudUtils.getLineListFromResultList(n.result),m=lbUtils.PointCloudUtils.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(x=y==null?void 0:y.radius)!=null?x:DEFAULT_RADIUS}),e==null||e.generateBoxes(v),e==null||e.generateSpheres(m),yield i.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,v,[])}O({pointCloudBoxList:v,polygonList:I,lineList:S,pointCloudSphereList:m}),actionCreators.SetAnnotationLoading(M,!1),actionCreators.SetLoadPCDFileLoading(M,!1),(C=o==null?void 0:o.setResourceLoading)==null||C.call(o,!1)}),updateViewsByDefaultSize:yt,generateRects:Z,update2DViewRect:pt,remove2DViewRect:gt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:o,rectList:i,setPointCloudResult:t}=React.useContext(PointCloudContext.PointCloudContext),a=ahooks.useLatest(o),p=ahooks.useLatest(i);return{syncToPointCloudBoxList:React.useCallback(()=>{const P=a.current,c=p.current;if(c.length===0)return null;const d=new Map,h=new Set;if(c.filter(f=>f.extId!==void 0).forEach(f=>{const L=f.extId,U=f.imageName,D=_.pick(f,["x","y","width","height"]);let w=d.get(L);w||(w=new Map,d.set(L,w)),w.set(U,D),h.add(L)}),d.size){const f=P.map(L=>{var U;const D=L.id;if(h.has(D)){const w=__spreadValues({},L);return(U=w.rects)==null||U.forEach(V=>{var k;const T=V.imageName;Object.assign(V,(k=d.get(D))==null?void 0:k.get(T))}),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";var dom=require("../../utils/dom.js"),React=require("react"),PointCloud3DView=require("./PointCloud3DView.js"),PointCloudBackView=require("./PointCloudBackView.js"),PointCloudTopView=require("./PointCloudTopView.js"),PointCloudSideView=require("./PointCloudSideView.js"),PointCloud2DView=require("./PointCloud2DView.js"),PointCloudListener=require("./PointCloudListener.js"),PointCloudSegmentListener=require("./PointCloudSegmentListener.js"),PointCloudSegment=require("./PointCloudSegment.js"),PointCloudSegmentStatus=require("./PointCloudSegmentStatus.js"),PointCloudSegmentToolbar=require("./PointCloudSegmentToolbar.js"),PointCloudSegment2DView=require("./PointCloudSegment2DView.js"),reactRedux=require("react-redux"),ctx=require("../../store/ctx.js"),index$1=require("../../views/MainView/toolFooter/AnnotatedAttributes/index.js"),PointCloudContext=require("./PointCloudContext.js"),lbUtils=require("@labelbee/lb-utils"),annotation=require("../../hooks/annotation.js"),index=require("../../utils/index.js"),map=require("../../store/annotation/map.js"),classNames=require("classnames"),index$2=require("./components/sideAndBackOverView/index.js"),actionCreators=require("../../store/annotation/actionCreators.js"),DynamicResizer=require("../DynamicResizer/DynamicResizer.js");function _interopDefaultLegacy(
|
|
1
|
+
"use strict";var dom=require("../../utils/dom.js"),React=require("react"),PointCloud3DView=require("./PointCloud3DView.js"),PointCloudBackView=require("./PointCloudBackView.js"),PointCloudTopView=require("./PointCloudTopView.js"),PointCloudSideView=require("./PointCloudSideView.js"),PointCloud2DView=require("./PointCloud2DView.js"),PointCloudListener=require("./PointCloudListener.js"),PointCloudSegmentListener=require("./PointCloudSegmentListener.js"),PointCloudSegment=require("./PointCloudSegment.js"),PointCloudSegmentStatus=require("./PointCloudSegmentStatus.js"),PointCloudSegmentToolbar=require("./PointCloudSegmentToolbar.js"),PointCloudSegment2DView=require("./PointCloudSegment2DView.js"),reactRedux=require("react-redux"),ctx=require("../../store/ctx.js"),index$1=require("../../views/MainView/toolFooter/AnnotatedAttributes/index.js"),PointCloudContext=require("./PointCloudContext.js"),lbUtils=require("@labelbee/lb-utils"),annotation=require("../../hooks/annotation.js"),index=require("../../utils/index.js"),map=require("../../store/annotation/map.js"),classNames=require("classnames"),index$2=require("./components/sideAndBackOverView/index.js"),actionCreators=require("../../store/annotation/actionCreators.js"),DynamicResizer=require("../DynamicResizer/DynamicResizer.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames);const PointCloudView=o=>{const{currentData:n,imgList:S,drawLayerSlot:f,checkMode:a,intelligentFit:V,imgIndex:b,config:x,measureVisible:q,setResourceLoading:p,stepInfo:t,setBatchSetValid:g}=o,e=React.useContext(PointCloudContext.PointCloudContext),{globalPattern:v,setGlobalPattern:w,selectedIDs:P,isLargeStatus:u,setIsLargeStatus:j}=e,D=ctx.useDispatch(),C=React.useRef(null),L=React.useRef(null),[N,y]=React.useState(0),[i,h]=React.useState(!1),R=(P==null?void 0:P.length)>0&&i,I=index.jsonParser(n.result),{toolInstanceRef:s,clearToolInstance:A}=annotation.useCustomToolInstance({basicInfo:I});if(React.useEffect(()=>{s.current.setPointCloudGlobalPattern=l=>{l!==v&&(w(l),e.clearAllDetectionInstance(),A())}},[v]),React.useEffect(()=>{var l;if(actionCreators.SetLoadPCDFileLoading(D,!0),n){const{boxParamsList:r,polygonList:d,lineList:c,sphereParamsList:m,segmentation:B,rectList:_}=lbUtils.PointCloudUtils.parsePointCloudCurrentResult((l=n==null?void 0:n.result)!=null?l:"");e.setPointCloudResult(r),e.setPolygonList(d),e.setLineList(c),e.setPointCloudSphereList(m),e.setRectList(_),e.setSegmentation(B),e.setPointCloudValid(index.resolveFileItemValid(n==null?void 0:n.result,n==null?void 0:n.preResult))}},[b]),React.useEffect(()=>{var l;if(C.current){const r=((l=C.current)==null?void 0:l.offsetHeight)-233;y(r)}},[L.current]),React.useEffect(()=>{s.current.exportData=()=>[e.pointCloudBoxList,{valid:e.valid}],s.current.exportCustomData=()=>{var l,r,d,c,m;return{resultPolygon:(l=e.polygonList)!=null?l:[],resultLine:(r=e.lineList)!=null?r:[],resultPoint:(d=e.pointCloudSphereList)!=null?d:[],resultRect:(c=e.rectList)!=null?c:[],segmentation:(m=e.segmentation)!=null?m:[]}}},[e.pointCloudBoxList,e.rectList,e.valid,e.polygonList,e.lineList,e.pointCloudSphereList,e.ptSegmentInstance,e.segmentation]),S.length===0)return null;if(v===lbUtils.EPointCloudPattern.Segmentation)return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(PointCloudSegmentListener,{checkMode:a,toolInstanceRef:s}),React__default.default.createElement(PointCloudSegmentToolbar,null),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-layout")},React__default.default.createElement(PointCloudSegment,{checkMode:a}),React__default.default.createElement(PointCloudSegment2DView,null)),React__default.default.createElement(PointCloudSegmentStatus,{config:x}),f==null?void 0:f({direct:!0}));let E=React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","left-bottom")},React__default.default.createElement(PointCloudBackView,{checkMode:a}),React__default.default.createElement(PointCloudSideView,{checkMode:a}));return i&&(E=React__default.default.createElement(index$2,{selectAndEnlarge:R,checkMode:a})),React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(PointCloudListener,{checkMode:a,toolInstanceRef:s,setResourceLoading:p,isBatchSetValid:!!g}),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-layout"),onContextMenu:l=>l.preventDefault()},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-wrapper")},React__default.default.createElement(index$1.AnnotatedAttributesPanelFixedLeft,null),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-content"),ref:L},React__default.default.createElement(DynamicResizer,{direction:"horizontal",localKey:"leftAllViewid:"+(t==null?void 0:t.id)+"taskID:"+(t==null?void 0:t.taskID)+"step:"+(t==null?void 0:t.step)+"type:"+(t==null?void 0:t.type),defaultWidth:360,minLeftWidth:244,minRightWidth:"50%",disabled:u},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container",u?"left-large":"left-noLarge")},React__default.default.createElement(PointCloud3DView,{setResourceLoading:p}),E),React__default.default.createElement("div",{className:classNames__default.default({[dom.getClassName("point-cloud-container","right")]:!0,[dom.getClassName("point-cloud-container","rightZoom")]:i}),ref:C},React__default.default.createElement(DynamicResizer,{localKey:"rightAllViewid:"+(t==null?void 0:t.id)+"taskID:"+(t==null?void 0:t.taskID)+"step:"+(t==null?void 0:t.step)+"type:"+(t==null?void 0:t.type),defaultHeight:300,minTopHeight:N,minBottomHeight:160,disabled:u},React__default.default.createElement(PointCloudTopView,{drawLayerSlot:f,checkMode:a,intelligentFit:V,setIsEnlargeTopView:h,onExitZoom:()=>{j(!1),h(!1)},isEnlargeTopView:i}),React__default.default.createElement("div",{className:classNames__default.default({[dom.getClassName("point-cloud-container",u?"right-bottom-large":"right-bottom-noLarge")]:!i,[dom.getClassName("point-cloud-container","right-bottom-floatLeft")]:i})},React__default.default.createElement(PointCloud2DView,{isEnlargeTopView:i,thumbnailWidth:i?300:455,checkMode:a,measureVisible:q})))))),React__default.default.createElement(index$1.AnnotatedAttributesPanelFixedRight,null))),e.visibleBatchSetValid&&(g==null?void 0:g({valid:e.valid,isModal:!0,visibleModal:e.visibleBatchSetValid,onClose:()=>e.setBatchSetValidModal(!1),singleSetQuestionImg:()=>e.setPointCloudValid(!e.valid)})))};var PointCloudView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudView);module.exports=PointCloudView$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$2=require("../../components/customResizeHook/index.js"),index$1=require("../../constant/index.js"),styleString=require("../../constant/styleString.js"),Actions=require("../Actions.js"),index=require("../../utils/index.js"),AnnotationDataUtils=require("../../utils/AnnotationDataUtils.js"),ConfigUtils=require("../../utils/ConfigUtils.js"),data=require("../../utils/data.js"),StepUtils=require("../../utils/StepUtils.js"),ToolUtils=require("../../utils/ToolUtils.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),antd=require("antd"),es=require("antd/es"),_=require("lodash"),actionCreators=require("./actionCreators.js"),ToolType=require("../../data/enums/ToolType.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,l)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[t]=l,__spreadValues=(e,t)=>{for(var l in t||(t={}))__hasOwnProp.call(t,l)&&__defNormalProp(e,l,t[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(t))__propIsEnum.call(t,l)&&__defNormalProp(e,l,t[l]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,l)=>new Promise((g,u)=>{var S=A=>{try{O(l.next(A))}catch(m){u(m)}},p=A=>{try{O(l.throw(A))}catch(m){u(m)}},O=A=>A.done?g(A.value):Promise.resolve(A.value).then(S,p);O((l=l.apply(e,t)).next())});const getStepConfig=(e,t)=>e.find(l=>l.step===t),initialState={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:"",confirmPageTurning:!1},getTotalPage=e=>{const{imgList:t,imgPageSize:l}=e;return Math.ceil(t.length/l)},calcStepProgress=(e,t)=>e.reduce((l,g)=>{if(g){const u=g.result;if(index.jsonParser(u)[`step_${t}`])return l+1}return l},0)/e.length,updateToolInstance=(e,t)=>{const{step:l,stepList:g}=e,u=StepUtils.getCurrentStepInfo(l,g),S=ConfigUtils.ConfigUtils.jsonParser(u.config);if(ToolUtils.isVideoTool(u==null?void 0:u.tool)||ToolUtils.isAudioTool(u==null?void 0:u.tool)||ToolUtils.isPointCloudTool(u==null?void 0:u.tool)||[ToolType.EToolName.LLM,ToolType.EToolName.NLP,ToolType.EToolName.LLMMultiWheel].includes(u==null?void 0:u.tool))return;const p=document.getElementById("toolContainer");if(!p)throw"Not exist dom named id-toolContainer";const O=index$2.getFormatSize({width:window.innerWidth,height:window.innerHeight}),A=new lbAnnotation.AnnotationEngine({container:p,toolName:u.tool,size:O,imgNode:t,config:S,style:JSON.parse(styleString)});return{toolInstance:A==null?void 0:A.toolInstance,annotationEngine:A}},LoadFileAndFileData=(e,t)=>(l,g)=>__async(void 0,null,function*(){var u,S;const{stepList:p,step:O}=g().annotation,A=StepUtils.currentToolIsVideo(O,p),m=StepUtils.currentToolIsPointCloud(O,p),D=[ToolType.EToolName.LLM,ToolType.EToolName.LLMMultiWheel].includes((u=StepUtils.getCurrentStepInfo(O,p))==null?void 0:u.tool),y=((S=StepUtils.getCurrentStepInfo(O,p))==null?void 0:S.tool)===ToolType.EToolName.NLP,P=StepUtils.currentToolIsAudio(O,p);if(actionCreators.SetAnnotationLoading(l,!0),yield l(TryGetFileDataByAPI(e)),A){l(AfterVideoLoaded(e));return}if(m||D||P||y){l(AfterCommonLoaded(e));return}l(AfterImageLoaded(e,t))}),TryGetFileDataByAPI=e=>(t,l)=>__async(void 0,null,function*(){const{getFileData:g,imgList:u}=l().annotation;if(g){const S=yield g(u[e],e);t({type:Actions.ANNOTATION_ACTIONS.SET_FILE_DATA,payload:{fileData:S,index:e}})}}),AfterVideoLoaded=e=>t=>{t({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e}})},AfterCommonLoaded=e=>t=>{actionCreators.SetAnnotationLoading(t,!1),t({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e}})},AfterImageLoaded=(e,t)=>(l,g)=>{var u;const{toolInstance:S,imgList:p}=g().annotation,O=(u=p==null?void 0:p[e])==null?void 0:u.url;lbAnnotation.ImgUtils.load(O).then(A=>{actionCreators.SetAnnotationLoading(l,!1),l({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{imgNode:A,nextIndex:e,nextBasicIndex:t}})}).catch(()=>{actionCreators.SetAnnotationLoading(l,!1),S==null||S.setErrorImg(),l({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e,nextBasicIndex:t}})})},composeResultByToolInstance=({toolInstance:e,imgList:t,imgIndex:l,stepList:g,step:u=1})=>{var S,p,O,A;const m=((S=t[l])==null?void 0:S.result)||"",[D,y,P]=(p=e==null?void 0:e.exportData())!=null?p:[],x=(A=(O=e==null?void 0:e.exportCustomData)==null?void 0:O.call(e))!=null?A:{},B=data.composeResultWithBasicImgInfo(m,y),w=data.composeResult(B,{step:u,stepList:g},{rect:D},x);return t.map((U,F)=>F===l?__spreadValues(__spreadProps(__spreadValues({},U),{result:w}),P):__spreadValues({},U))},annotationReducer=(e=__spreadValues({},initialState),t)=>{var l,g,u,S,p,O,A,m,D,y,P,x,B,w,U,F,G,V,q,k,H,z,K,W,$,X,Y,J,Z;switch(t.type){case Actions.ANNOTATION_ACTIONS.INIT_ALL_STATE:return __spreadValues(__spreadValues({},e),initialState);case Actions.ANNOTATION_ACTIONS.UPDATE_TOOL_INSTANCE:return __spreadProps(__spreadValues({},e),{toolInstance:t.payload.toolInstance});case Actions.ANNOTATION_ACTIONS.UPDATE_IMG_LIST:return __spreadProps(__spreadValues({},e),{imgList:t.payload.imgList});case Actions.ANNOTATION_ACTIONS.CALC_STEP_PROGRESS:{const{imgList:n,step:o}=e,s=calcStepProgress(n,o);return __spreadProps(__spreadValues({},e),{stepProgress:s})}case Actions.ANNOTATION_ACTIONS.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:o,step:s,stepList:i,toolInstance:a,onSubmit:r,resultList:I}=e;if(!a||!n[o])return e;const T=((l=n[o])==null?void 0:l.result)||"",[,d,c]=(g=a==null?void 0:a.exportData())!=null?g:[],N=(S=(u=a==null?void 0:a.exportCustomData)==null?void 0:u.call(a))!=null?S:{},f=data.composeResultWithBasicImgInfo(T,d),L=data.composeResult(f,{step:s,stepList:i},{rect:I},N),E=e.imgList.map((v,C)=>{if(C===o){const h=AnnotationDataUtils.dataCorrection(L,T,s,i);return __spreadValues(__spreadProps(__spreadValues({},v),{result:h}),c)}return v});if(((p=t.payload)==null?void 0:p.submitType)===index$1.ESubmitType.SyncImgList)return __spreadProps(__spreadValues({},e),{imgList:E});const R=calcStepProgress(E,s);return __spreadProps(__spreadValues({},e),{stepProgress:R,imgList:E})}case Actions.ANNOTATION_ACTIONS.SAVE_RESULT:{const{imgList:n,imgIndex:o,onSave:s}=e;return s==null||s(n[o],o,n),__spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.SUBMIT_RESULT:{const{imgList:n,basicIndex:o,resultList:s,toolInstance:i,basicResultList:a}=e;if(!i)return e;const[r]=(O=i==null?void 0:i.exportData())!=null?O:[];let I=r;if((a==null?void 0:a.length)>0){const T=(A=a[o])==null?void 0:A.id,d=r.map(c=>__spreadProps(__spreadValues({},c),{sourceID:T}));I=___default.default.cloneDeep(s).filter(c=>c.sourceID!==T),I.push(...d)}return __spreadProps(__spreadValues({},e),{resultList:I,imgList:n})}case Actions.ANNOTATION_ACTIONS.SET_BASIC_INDEX:{const{toolInstance:n,step:o,imgList:s,imgIndex:i,stepList:a,annotationEngine:r,resultList:I,basicResultList:T}=e;if(!n||!r)return e;const d=t.payload.basicIndex,c=(m=T[d])==null?void 0:m.id,N=index.jsonParser((D=s[i])==null?void 0:D.result),f=(I||[]).filter(h=>h.sourceID===c),L=getStepConfig(a,o),{dataSourceStep:E,tool:R}=L,v=getStepConfig(a,E);let C=[];return E&&R&&(C=(y=N[`step_${E}`])==null?void 0:y.result,(C==null?void 0:C.length)>0?(r==null||r.setBasicInfo(v.tool,C[d]),r==null||r.launchOperation()):(r==null||r.setBasicInfo(v.tool),r==null||r.forbidOperation(),es.message.info(lbUtils.i18n.t("NoDependency")))),n==null||n.setResult(f),n==null||n.history.initRecord(f,!0),__spreadProps(__spreadValues({},e),{basicIndex:d})}case Actions.ANNOTATION_ACTIONS.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=t.payload;return __spreadProps(__spreadValues({},e),{triggerEventAfterIndexChanged:!!n})}case Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA:{const{imgList:n,step:o,toolInstance:s,annotationEngine:i,stepList:a}=e;if(!s)return __spreadProps(__spreadValues({},e),{imgIndex:t.payload.nextIndex});const r=StepUtils.getCurrentStepInfo(o,a),{nextIndex:I,imgNode:T,nextBasicIndex:d,imgError:c}=t.payload,N=d!=null?d:0,f=index.jsonParser((P=n[I])==null?void 0:P.result),L=f[`step_${r.step}`],E=!L,R={rotate:(x=f.rotate)!=null?x:0,valid:(B=f.valid)!=null?B:!0};T&&c!==!0?i==null||i.setImgNode(T,R):s==null||s.setValid(R.valid);const v=getStepConfig(a,r.step),{dataSourceStep:C,tool:h}=v,Q=getStepConfig(a,C),M=C&&h,b=(U=(w=f[`step_${C}`])==null?void 0:w.result)!=null?U:[],j=AnnotationDataUtils.getInitialResultList(L==null?void 0:L.result,s,v,b,E);i==null||i.launchOperation();const ee=[ToolType.EToolName.Cuboid,ToolType.EToolName.ScribbleTool].includes(h);if(M&&((b==null?void 0:b.length)>0?i==null||i.setBasicInfo(Q.tool,b[N]):(i==null||i.setBasicInfo(Q.tool),i==null||i.forbidOperation(),es.message.info(lbUtils.i18n.t("NoDependency")))),r.tool!=="check"&&(ee||M)){const te=(G=(F=b[N])==null?void 0:F.id)!=null?G:"",ne=M?j.filter(oe=>lbAnnotation.CommonToolUtils.isSameSourceID(oe.sourceID,te)):j;(V=s==null?void 0:s.history)==null||V.initRecord(j,!0),s==null||s.setResult(ne)}return __spreadProps(__spreadValues({},e),{imgIndex:I,basicIndex:N,basicResultList:b,resultList:j})}case Actions.ANNOTATION_ACTIONS.UPDATE_ANNOTATION_CONFIG:return __spreadProps(__spreadValues({},e),{config:(q=t.payload.config)!=null?q:"{}"});case Actions.ANNOTATION_ACTIONS.SET_TASK_STEP_LIST:{const{stepList:n}=t.payload;return __spreadProps(__spreadValues({},e),{stepList:n})}case Actions.ANNOTATION_ACTIONS.SET_TASK_CONFIG:{const{stepList:n,step:o}=t.payload;return __spreadProps(__spreadValues({},e),{stepList:n,step:o})}case Actions.ANNOTATION_ACTIONS.INIT_TOOL:{const{imgNode:n}=e,o=updateToolInstance(e,n);if(o){const{toolInstance:s,annotationEngine:i}=o;return __spreadProps(__spreadValues({},e),{toolInstance:s,annotationEngine:i})}return __spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.SET_TOOL:{const n=(k=t.payload)==null?void 0:k.instance;return n?__spreadProps(__spreadValues({},e),{toolInstance:n}):__spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.UPDATE_ON_SUBMIT:return __spreadProps(__spreadValues({},e),{onSubmit:t.payload.onSubmit});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_SAVE:return __spreadProps(__spreadValues({},e),{onSave:t.payload.onSave});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_PAGE_CHANGE:return __spreadProps(__spreadValues({},e),{onPageChange:t.payload.onPageChange});case Actions.ANNOTATION_ACTIONS.SET_PREDICT_RESULT:return __spreadProps(__spreadValues({},e),{predictionResult:t.payload.result});case Actions.ANNOTATION_ACTIONS.SET_PREDICT_RESULT_VISIBLE:return __spreadProps(__spreadValues({},e),{predictionResultVisible:t.payload.visible});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_STEP_CHANGE:return __spreadProps(__spreadValues({},e),{onStepChange:t.payload.onStepChange});case Actions.ANNOTATION_ACTIONS.UPDATE_GET_FILE_DATA:return __spreadProps(__spreadValues({},e),{getFileData:t.payload.getFileData});case Actions.ANNOTATION_ACTIONS.UPDATE_PAGE_SIZE:return __spreadProps(__spreadValues({},e),{pageSize:t.payload.pageSize});case Actions.ANNOTATION_ACTIONS.UPDATE_LOAD_FILE_LIST:return __spreadProps(__spreadValues({},e),{loadFileList:t.payload.loadFileList});case Actions.ANNOTATION_ACTIONS.UPDATE_BEFORE_ROTATE:return __spreadProps(__spreadValues({},e),{beforeRotate:t.payload.beforeRotate});case Actions.ANNOTATION_ACTIONS.UPDATE_PRE_DATA_PROCESS:return __spreadProps(__spreadValues({},e),{preDataProcess:t.payload.preDataProcess});case Actions.ANNOTATION_ACTIONS.UPDATE_IMG_INDEX_BY_EXTERNAL:return __spreadProps(__spreadValues({},e),{getImgIndexByExternal:t.payload.getImgIndexByExternal});case Actions.ANNOTATION_ACTIONS.SKIP_BEFORE_PAGE_TURNING:return __spreadProps(__spreadValues({},e),{skipBeforePageTurning:t.payload.skipBeforePageTurning});case Actions.ANNOTATION_ACTIONS.SET_FILE_DATA:{const{fileData:n,index:o}=t.payload,{imgList:s}=e,i=[...s];return i[o]=__spreadValues(__spreadValues({},i[o]),n),__spreadProps(__spreadValues({},e),{imgList:i})}case Actions.ANNOTATION_ACTIONS.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:o}=e;return o&&o()===!1||(H=n==null?void 0:n.updateRotate)==null||H.call(n),e}case Actions.ANNOTATION_ACTIONS.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=e,o=(z=n==null?void 0:n.valid)!=null?z:!0;return antd.Modal.destroyAll(),antd.Modal.confirm({content:lbUtils.i18n.t(o?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!o)},okText:lbUtils.i18n.t("Confirm"),cancelText:lbUtils.i18n.t("Cancel")}),e}case Actions.ANNOTATION_ACTIONS.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:o,imgList:s,step:i,stepList:a}=e;if(!n)return e;if(o===0||o>=s.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),e;const r=s[o-1].result;if(!r)return e;const I=StepUtils.getCurrentStepInfo(i,a),T=(K=I==null?void 0:I.step)!=null?K:i,d=(W=n==null?void 0:n.valid)!=null?W:!0,c=AnnotationDataUtils.copyResultChange({copyResult:r,step:T,currentResult:($=s[o].result)!=null?$:"",preMappingImgList:(X=s[o-1].mappingImgList)!=null?X:[],mappingImgList:(Y=s[o].mappingImgList)!=null?Y:[],valid:d});s[o]=__spreadProps(__spreadValues({},s[o]),{result:c});const f=index.jsonParser(c)[`step_${i}`],L=(f==null?void 0:f.result)||[];return n==null||n.setResult(L),n==null||n.history.pushHistory(L),(J=n==null?void 0:n.asyncData)==null||J.call(n,s[o]),__spreadProps(__spreadValues({},e),{imgList:[...s]})}case Actions.ANNOTATION_ACTIONS.SET_STEP:{const{stepList:n,annotationEngine:o}=e,{toStep:s}=t.payload;if(o){const i=getStepConfig(n,s);return o==null||o.setToolName(i.tool,i.config),__spreadProps(__spreadValues({},e),{step:s,toolInstance:o==null?void 0:o.toolInstance})}return __spreadProps(__spreadValues({},e),{step:s})}case Actions.ANNOTATION_ACTIONS.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=t.payload;return __spreadProps(__spreadValues({},e),{loadPCDFileLoading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_LOADING:{const{loading:n}=t.payload;return __spreadProps(__spreadValues({},e),{loading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=t.payload;return __spreadProps(__spreadValues({},e),{pointCloudLoading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_CHECK_MODE:{const{checkMode:n}=t.payload;return __spreadProps(__spreadValues({},e),{checkMode:!!n})}case Actions.ANNOTATION_ACTIONS.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=t.payload;return __spreadProps(__spreadValues({},e),{highlightAttribute:n})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:o,rangeIndex:s,imgList:i}=t.payload,{imgIndex:a,onSubmit:r}=e,I=[],T=i.map((d,c)=>{if(lbAnnotation.MathUtils.isInRange(c,s)){const N=__spreadProps(__spreadValues({},d),{result:lbUtils.PointCloudUtils.batchUpdateTrackID({id:n,newID:o,result:d.result})});return I.push({imgIndex:c,newInfo:N}),N}return d});return r&&r([T[a]],index$1.ESubmitType.BatchUpdateTrackID,a,T,{updateImgList:I}),__spreadProps(__spreadValues({},e),{imgList:T})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const n=t,{id:o,newData:s,rangeIndex:i,imgList:a}=n.payload,{imgIndex:r,onSubmit:I}=e,T=[],d=a.map((c,N)=>{if(lbAnnotation.MathUtils.isInRange(N,i)){const f=__spreadProps(__spreadValues({},c),{result:lbUtils.PointCloudUtils.batchUpdateResultByTrackID({id:o,newData:s,result:c.result})});return T.push({imgIndex:N,newInfo:f}),f}return c});return I&&I([d[r]],index$1.ESubmitType.BatchUpdateTrackID,r,d,{updateImgList:T}),__spreadProps(__spreadValues({},e),{imgList:d})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:o,stepList:s,step:i,predictionResult:a}=e,r={};a.forEach(c=>{const{index:N}=c;r[N]=___default.default.pick(c,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const I=`step_${i}`,T=[],d=o.map((c,N)=>{if(r[N]){const f=c.result==="{}"?index.jsonParser(data.composeResult("",{step:i,stepList:s},{rect:[]},{})):index.jsonParser(c.result);f[I].result.push(r[N]);const L=__spreadProps(__spreadValues({},c),{result:JSON.stringify(f)});return T.push({imgIndex:N,newInfo:L}),L}return c});return n==null||n(d,index$1.ESubmitType.BatchUpdateImgList,-1,d,{updateImgList:T}),__spreadProps(__spreadValues({},e),{imgList:d})}case Actions.ANNOTATION_ACTIONS.CHANGE_PAGE_CHECK:{const{toolInstance:n,step:o,stepList:s}=e;if(!n)return e;const[i]=(Z=n==null?void 0:n.exportData())!=null?Z:[],a=getStepConfig(s,o),r=ConfigUtils.ConfigUtils.jsonParser(a.config),I=i.some(T=>(T==null?void 0:T.result)&&Object.keys(T.result).length>0);return __spreadProps(__spreadValues({},e),{confirmPageTurning:r.showConfirm&&!I})}default:return e}};exports.LoadFileAndFileData=LoadFileAndFileData,exports.annotationReducer=annotationReducer,exports.composeResultByToolInstance=composeResultByToolInstance,exports.getStepConfig=getStepConfig,exports.getTotalPage=getTotalPage;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$2=require("../../components/customResizeHook/index.js"),index$1=require("../../constant/index.js"),styleString=require("../../constant/styleString.js"),Actions=require("../Actions.js"),index=require("../../utils/index.js"),AnnotationDataUtils=require("../../utils/AnnotationDataUtils.js"),ConfigUtils=require("../../utils/ConfigUtils.js"),data=require("../../utils/data.js"),StepUtils=require("../../utils/StepUtils.js"),ToolUtils=require("../../utils/ToolUtils.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),antd=require("antd"),es=require("antd/es"),_=require("lodash"),actionCreators=require("./actionCreators.js"),ToolType=require("../../data/enums/ToolType.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,n,l)=>n in e?__defProp(e,n,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[n]=l,__spreadValues=(e,n)=>{for(var l in n||(n={}))__hasOwnProp.call(n,l)&&__defNormalProp(e,l,n[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(n))__propIsEnum.call(n,l)&&__defNormalProp(e,l,n[l]);return e},__spreadProps=(e,n)=>__defProps(e,__getOwnPropDescs(n)),__async=(e,n,l)=>new Promise((g,u)=>{var S=A=>{try{O(l.next(A))}catch(m){u(m)}},p=A=>{try{O(l.throw(A))}catch(m){u(m)}},O=A=>A.done?g(A.value):Promise.resolve(A.value).then(S,p);O((l=l.apply(e,n)).next())});const getStepConfig=(e,n)=>e.find(l=>l.step===n),initialState={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:"",confirmPageTurning:!1},getTotalPage=e=>{const{imgList:n,imgPageSize:l}=e;return Math.ceil(n.length/l)},calcStepProgress=(e,n)=>e.reduce((l,g)=>{if(g){const u=g.result;if(index.jsonParser(u)[`step_${n}`])return l+1}return l},0)/e.length,updateToolInstance=(e,n)=>{const{step:l,stepList:g}=e,u=StepUtils.getCurrentStepInfo(l,g),S=ConfigUtils.ConfigUtils.jsonParser(u.config);if(ToolUtils.isVideoTool(u==null?void 0:u.tool)||ToolUtils.isAudioTool(u==null?void 0:u.tool)||ToolUtils.isPointCloudTool(u==null?void 0:u.tool)||[ToolType.EToolName.LLM,ToolType.EToolName.NLP,ToolType.EToolName.LLMMultiWheel].includes(u==null?void 0:u.tool))return;const p=document.getElementById("toolContainer");if(!p)throw"Not exist dom named id-toolContainer";const O=index$2.getFormatSize({width:window.innerWidth,height:window.innerHeight}),A=new lbAnnotation.AnnotationEngine({container:p,toolName:u.tool,size:O,imgNode:n,config:S,style:JSON.parse(styleString)});return{toolInstance:A==null?void 0:A.toolInstance,annotationEngine:A}},LoadFileAndFileData=(e,n)=>(l,g)=>__async(void 0,null,function*(){var u,S;const{stepList:p,step:O}=g().annotation,A=StepUtils.currentToolIsVideo(O,p),m=StepUtils.currentToolIsPointCloud(O,p),D=[ToolType.EToolName.LLM,ToolType.EToolName.LLMMultiWheel].includes((u=StepUtils.getCurrentStepInfo(O,p))==null?void 0:u.tool),y=((S=StepUtils.getCurrentStepInfo(O,p))==null?void 0:S.tool)===ToolType.EToolName.NLP,P=StepUtils.currentToolIsAudio(O,p);if(actionCreators.SetAnnotationLoading(l,!0),yield l(TryGetFileDataByAPI(e)),A){l(AfterVideoLoaded(e));return}if(m||D||P||y){l(AfterCommonLoaded(e));return}l(AfterImageLoaded(e,n))}),TryGetFileDataByAPI=e=>(n,l)=>__async(void 0,null,function*(){const{getFileData:g,imgList:u}=l().annotation;if(g){const S=yield g(u[e],e);n({type:Actions.ANNOTATION_ACTIONS.SET_FILE_DATA,payload:{fileData:S,index:e}})}}),AfterVideoLoaded=e=>n=>{n({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e}})},AfterCommonLoaded=e=>n=>{actionCreators.SetAnnotationLoading(n,!1),n({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e}})},AfterImageLoaded=(e,n)=>(l,g)=>{var u;const{toolInstance:S,imgList:p}=g().annotation,O=(u=p==null?void 0:p[e])==null?void 0:u.url;lbAnnotation.ImgUtils.load(O).then(A=>{actionCreators.SetAnnotationLoading(l,!1),l({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{imgNode:A,nextIndex:e,nextBasicIndex:n}})}).catch(()=>{actionCreators.SetAnnotationLoading(l,!1),S==null||S.setErrorImg(),l({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e,nextBasicIndex:n}})})},composeResultByToolInstance=({toolInstance:e,imgList:n,imgIndex:l,stepList:g,step:u=1})=>{var S,p,O,A;const m=((S=n[l])==null?void 0:S.result)||"",[D,y,P]=(p=e==null?void 0:e.exportData())!=null?p:[],x=(A=(O=e==null?void 0:e.exportCustomData)==null?void 0:O.call(e))!=null?A:{},B=data.composeResultWithBasicImgInfo(m,y),w=data.composeResult(B,{step:u,stepList:g},{rect:D},x);return n.map((U,F)=>F===l?__spreadValues(__spreadProps(__spreadValues({},U),{result:w}),P):__spreadValues({},U))},annotationReducer=(e=__spreadValues({},initialState),n)=>{var l,g,u,S,p,O,A,m,D,y,P,x,B,w,U,F,G,V,q,k,H,z,K,W,$,X,Y,J,Z,Q;switch(n.type){case Actions.ANNOTATION_ACTIONS.INIT_ALL_STATE:return __spreadValues(__spreadValues({},e),initialState);case Actions.ANNOTATION_ACTIONS.UPDATE_TOOL_INSTANCE:return __spreadProps(__spreadValues({},e),{toolInstance:n.payload.toolInstance});case Actions.ANNOTATION_ACTIONS.UPDATE_IMG_LIST:return __spreadProps(__spreadValues({},e),{imgList:n.payload.imgList});case Actions.ANNOTATION_ACTIONS.CALC_STEP_PROGRESS:{const{imgList:t,step:o}=e,s=calcStepProgress(t,o);return __spreadProps(__spreadValues({},e),{stepProgress:s})}case Actions.ANNOTATION_ACTIONS.SUBMIT_FILE_DATA:{const{imgList:t,imgIndex:o,step:s,stepList:i,toolInstance:a,onSubmit:r,resultList:T}=e;if(!a||!t[o])return e;const d=((l=t[o])==null?void 0:l.result)||"",[,I,c]=(g=a==null?void 0:a.exportData())!=null?g:[],N=(S=(u=a==null?void 0:a.exportCustomData)==null?void 0:u.call(a))!=null?S:{},f=data.composeResultWithBasicImgInfo(d,I),L=data.composeResult(f,{step:s,stepList:i},{rect:T},N),E=e.imgList.map((v,C)=>{if(C===o){const h=AnnotationDataUtils.dataCorrection(L,d,s,i);return __spreadValues(__spreadProps(__spreadValues({},v),{result:h}),c)}return v});if(((p=n.payload)==null?void 0:p.submitType)===index$1.ESubmitType.SyncImgList)return __spreadProps(__spreadValues({},e),{imgList:E});const R=calcStepProgress(E,s);return __spreadProps(__spreadValues({},e),{stepProgress:R,imgList:E})}case Actions.ANNOTATION_ACTIONS.SAVE_RESULT:{const{imgList:t,imgIndex:o,onSave:s}=e;return s==null||s(t[o],o,t),__spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.SUBMIT_RESULT:{const{imgList:t,basicIndex:o,resultList:s,toolInstance:i,basicResultList:a}=e;if(!i)return e;const[r]=(O=i==null?void 0:i.exportData())!=null?O:[];let T=r;if((a==null?void 0:a.length)>0){const d=(A=a[o])==null?void 0:A.id,I=r.map(c=>__spreadProps(__spreadValues({},c),{sourceID:d}));T=___default.default.cloneDeep(s).filter(c=>c.sourceID!==d),T.push(...I)}return __spreadProps(__spreadValues({},e),{resultList:T,imgList:t})}case Actions.ANNOTATION_ACTIONS.SET_BASIC_INDEX:{const{toolInstance:t,step:o,imgList:s,imgIndex:i,stepList:a,annotationEngine:r,resultList:T,basicResultList:d}=e;if(!t||!r)return e;const I=n.payload.basicIndex,c=(m=d[I])==null?void 0:m.id,N=index.jsonParser((D=s[i])==null?void 0:D.result),f=(T||[]).filter(h=>h.sourceID===c),L=getStepConfig(a,o),{dataSourceStep:E,tool:R}=L,v=getStepConfig(a,E);let C=[];return E&&R&&(C=(y=N[`step_${E}`])==null?void 0:y.result,(C==null?void 0:C.length)>0?(r==null||r.setBasicInfo(v.tool,C[I]),r==null||r.launchOperation()):(r==null||r.setBasicInfo(v.tool),r==null||r.forbidOperation(),es.message.info(lbUtils.i18n.t("NoDependency")))),t==null||t.setResult(f),t==null||t.history.initRecord(f,!0),__spreadProps(__spreadValues({},e),{basicIndex:I})}case Actions.ANNOTATION_ACTIONS.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:t}=n.payload;return __spreadProps(__spreadValues({},e),{triggerEventAfterIndexChanged:!!t})}case Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA:{const{imgList:t,step:o,toolInstance:s,annotationEngine:i,stepList:a}=e;if(!s)return __spreadProps(__spreadValues({},e),{imgIndex:n.payload.nextIndex});const r=StepUtils.getCurrentStepInfo(o,a),{nextIndex:T,imgNode:d,nextBasicIndex:I,imgError:c}=n.payload,N=I!=null?I:0,f=index.jsonParser((P=t[T])==null?void 0:P.result),L=f[`step_${r.step}`],E=!L,R={rotate:(x=f.rotate)!=null?x:0,valid:index.resolveFileItemValid((B=t[T])==null?void 0:B.result,(w=t[T])==null?void 0:w.preResult)};d&&c!==!0?i==null||i.setImgNode(d,R):s==null||s.setValid(R.valid);const v=getStepConfig(a,r.step),{dataSourceStep:C,tool:h}=v,ee=getStepConfig(a,C),M=C&&h,b=(F=(U=f[`step_${C}`])==null?void 0:U.result)!=null?F:[],j=AnnotationDataUtils.getInitialResultList(L==null?void 0:L.result,s,v,b,E);i==null||i.launchOperation();const te=[ToolType.EToolName.Cuboid,ToolType.EToolName.ScribbleTool].includes(h);if(M&&((b==null?void 0:b.length)>0?i==null||i.setBasicInfo(ee.tool,b[N]):(i==null||i.setBasicInfo(ee.tool),i==null||i.forbidOperation(),es.message.info(lbUtils.i18n.t("NoDependency")))),r.tool!=="check"&&(te||M)){const ne=(V=(G=b[N])==null?void 0:G.id)!=null?V:"",oe=M?j.filter(se=>lbAnnotation.CommonToolUtils.isSameSourceID(se.sourceID,ne)):j;(q=s==null?void 0:s.history)==null||q.initRecord(j,!0),s==null||s.setResult(oe)}return __spreadProps(__spreadValues({},e),{imgIndex:T,basicIndex:N,basicResultList:b,resultList:j})}case Actions.ANNOTATION_ACTIONS.UPDATE_ANNOTATION_CONFIG:return __spreadProps(__spreadValues({},e),{config:(k=n.payload.config)!=null?k:"{}"});case Actions.ANNOTATION_ACTIONS.SET_TASK_STEP_LIST:{const{stepList:t}=n.payload;return __spreadProps(__spreadValues({},e),{stepList:t})}case Actions.ANNOTATION_ACTIONS.SET_TASK_CONFIG:{const{stepList:t,step:o}=n.payload;return __spreadProps(__spreadValues({},e),{stepList:t,step:o})}case Actions.ANNOTATION_ACTIONS.INIT_TOOL:{const{imgNode:t}=e,o=updateToolInstance(e,t);if(o){const{toolInstance:s,annotationEngine:i}=o;return __spreadProps(__spreadValues({},e),{toolInstance:s,annotationEngine:i})}return __spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.SET_TOOL:{const t=(H=n.payload)==null?void 0:H.instance;return t?__spreadProps(__spreadValues({},e),{toolInstance:t}):__spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.UPDATE_ON_SUBMIT:return __spreadProps(__spreadValues({},e),{onSubmit:n.payload.onSubmit});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_SAVE:return __spreadProps(__spreadValues({},e),{onSave:n.payload.onSave});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_PAGE_CHANGE:return __spreadProps(__spreadValues({},e),{onPageChange:n.payload.onPageChange});case Actions.ANNOTATION_ACTIONS.SET_PREDICT_RESULT:return __spreadProps(__spreadValues({},e),{predictionResult:n.payload.result});case Actions.ANNOTATION_ACTIONS.SET_PREDICT_RESULT_VISIBLE:return __spreadProps(__spreadValues({},e),{predictionResultVisible:n.payload.visible});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_STEP_CHANGE:return __spreadProps(__spreadValues({},e),{onStepChange:n.payload.onStepChange});case Actions.ANNOTATION_ACTIONS.UPDATE_GET_FILE_DATA:return __spreadProps(__spreadValues({},e),{getFileData:n.payload.getFileData});case Actions.ANNOTATION_ACTIONS.UPDATE_PAGE_SIZE:return __spreadProps(__spreadValues({},e),{pageSize:n.payload.pageSize});case Actions.ANNOTATION_ACTIONS.UPDATE_LOAD_FILE_LIST:return __spreadProps(__spreadValues({},e),{loadFileList:n.payload.loadFileList});case Actions.ANNOTATION_ACTIONS.UPDATE_BEFORE_ROTATE:return __spreadProps(__spreadValues({},e),{beforeRotate:n.payload.beforeRotate});case Actions.ANNOTATION_ACTIONS.UPDATE_PRE_DATA_PROCESS:return __spreadProps(__spreadValues({},e),{preDataProcess:n.payload.preDataProcess});case Actions.ANNOTATION_ACTIONS.UPDATE_IMG_INDEX_BY_EXTERNAL:return __spreadProps(__spreadValues({},e),{getImgIndexByExternal:n.payload.getImgIndexByExternal});case Actions.ANNOTATION_ACTIONS.SKIP_BEFORE_PAGE_TURNING:return __spreadProps(__spreadValues({},e),{skipBeforePageTurning:n.payload.skipBeforePageTurning});case Actions.ANNOTATION_ACTIONS.SET_FILE_DATA:{const{fileData:t,index:o}=n.payload,{imgList:s}=e,i=[...s];return i[o]=__spreadValues(__spreadValues({},i[o]),t),__spreadProps(__spreadValues({},e),{imgList:i})}case Actions.ANNOTATION_ACTIONS.UPDATE_ROTATE:{const{toolInstance:t,beforeRotate:o}=e;return o&&o()===!1||(z=t==null?void 0:t.updateRotate)==null||z.call(t),e}case Actions.ANNOTATION_ACTIONS.UPDATE_ANNOTATION_VALID:{const{toolInstance:t}=e,o=(K=t==null?void 0:t.valid)!=null?K:!0;return antd.Modal.destroyAll(),antd.Modal.confirm({content:lbUtils.i18n.t(o?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{t==null||t.setValid(!o)},okText:lbUtils.i18n.t("Confirm"),cancelText:lbUtils.i18n.t("Cancel")}),e}case Actions.ANNOTATION_ACTIONS.COPY_BACKWARD_RESULT:{const{toolInstance:t,imgIndex:o,imgList:s,step:i,stepList:a}=e;if(!t)return e;if(o===0||o>=s.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),e;const r=s[o-1].result;if(!r)return e;const T=StepUtils.getCurrentStepInfo(i,a),d=(W=T==null?void 0:T.step)!=null?W:i,I=($=t==null?void 0:t.valid)!=null?$:!0,c=AnnotationDataUtils.copyResultChange({copyResult:r,step:d,currentResult:(X=s[o].result)!=null?X:"",preMappingImgList:(Y=s[o-1].mappingImgList)!=null?Y:[],mappingImgList:(J=s[o].mappingImgList)!=null?J:[],valid:I});s[o]=__spreadProps(__spreadValues({},s[o]),{result:c});const f=index.jsonParser(c)[`step_${i}`],L=(f==null?void 0:f.result)||[];return t==null||t.setResult(L),t==null||t.history.pushHistory(L),(Z=t==null?void 0:t.asyncData)==null||Z.call(t,s[o]),__spreadProps(__spreadValues({},e),{imgList:[...s]})}case Actions.ANNOTATION_ACTIONS.SET_STEP:{const{stepList:t,annotationEngine:o}=e,{toStep:s}=n.payload;if(o){const i=getStepConfig(t,s);return o==null||o.setToolName(i.tool,i.config),__spreadProps(__spreadValues({},e),{step:s,toolInstance:o==null?void 0:o.toolInstance})}return __spreadProps(__spreadValues({},e),{step:s})}case Actions.ANNOTATION_ACTIONS.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:t}=n.payload;return __spreadProps(__spreadValues({},e),{loadPCDFileLoading:!!t})}case Actions.ANNOTATION_ACTIONS.SET_LOADING:{const{loading:t}=n.payload;return __spreadProps(__spreadValues({},e),{loading:!!t})}case Actions.ANNOTATION_ACTIONS.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:t}=n.payload;return __spreadProps(__spreadValues({},e),{pointCloudLoading:!!t})}case Actions.ANNOTATION_ACTIONS.SET_CHECK_MODE:{const{checkMode:t}=n.payload;return __spreadProps(__spreadValues({},e),{checkMode:!!t})}case Actions.ANNOTATION_ACTIONS.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:t}=n.payload;return __spreadProps(__spreadValues({},e),{highlightAttribute:t})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_TRACK_ID:{const{id:t,newID:o,rangeIndex:s,imgList:i}=n.payload,{imgIndex:a,onSubmit:r}=e,T=[],d=i.map((I,c)=>{if(lbAnnotation.MathUtils.isInRange(c,s)){const N=__spreadProps(__spreadValues({},I),{result:lbUtils.PointCloudUtils.batchUpdateTrackID({id:t,newID:o,result:I.result})});return T.push({imgIndex:c,newInfo:N}),N}return I});return r&&r([d[a]],index$1.ESubmitType.BatchUpdateTrackID,a,d,{updateImgList:T}),__spreadProps(__spreadValues({},e),{imgList:d})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const t=n,{id:o,newData:s,rangeIndex:i,imgList:a}=t.payload,{imgIndex:r,onSubmit:T}=e,d=[],I=a.map((c,N)=>{if(lbAnnotation.MathUtils.isInRange(N,i)){const f=__spreadProps(__spreadValues({},c),{result:lbUtils.PointCloudUtils.batchUpdateResultByTrackID({id:o,newData:s,result:c.result})});return d.push({imgIndex:N,newInfo:f}),f}return c});return T&&T([I[r]],index$1.ESubmitType.BatchUpdateTrackID,r,I,{updateImgList:d}),__spreadProps(__spreadValues({},e),{imgList:I})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:t,imgList:o,stepList:s,step:i,predictionResult:a}=e,r={};a.forEach(c=>{const{index:N}=c;r[N]=___default.default.pick(c,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const T=`step_${i}`,d=[],I=o.map((c,N)=>{if(r[N]){const f=c.result==="{}"?index.jsonParser(data.composeResult("",{step:i,stepList:s},{rect:[]},{})):index.jsonParser(c.result);f[T].result.push(r[N]);const L=__spreadProps(__spreadValues({},c),{result:JSON.stringify(f)});return d.push({imgIndex:N,newInfo:L}),L}return c});return t==null||t(I,index$1.ESubmitType.BatchUpdateImgList,-1,I,{updateImgList:d}),__spreadProps(__spreadValues({},e),{imgList:I})}case Actions.ANNOTATION_ACTIONS.CHANGE_PAGE_CHECK:{const{toolInstance:t,step:o,stepList:s}=e;if(!t)return e;const[i]=(Q=t==null?void 0:t.exportData())!=null?Q:[],a=getStepConfig(s,o),r=ConfigUtils.ConfigUtils.jsonParser(a.config),T=i.some(d=>(d==null?void 0:d.result)&&Object.keys(d.result).length>0);return __spreadProps(__spreadValues({},e),{confirmPageTurning:r.showConfirm&&!T})}default:return e}};exports.LoadFileAndFileData=LoadFileAndFileData,exports.annotationReducer=annotationReducer,exports.composeResultByToolInstance=composeResultByToolInstance,exports.getStepConfig=getStepConfig,exports.getTotalPage=getTotalPage;
|
|
@@ -48,11 +48,11 @@ export declare const annotationReducer: (state: {
|
|
|
48
48
|
triggerEventAfterIndexChanged: boolean;
|
|
49
49
|
skipBeforePageTurning?: ((pageTurning: Function) => void) | undefined;
|
|
50
50
|
beforeRotate?: (() => boolean) | undefined;
|
|
51
|
-
pointCloudLoading: boolean;
|
|
51
|
+
pointCloudLoading: boolean;
|
|
52
|
+
checkMode: boolean; /**
|
|
52
53
|
* 获取当前文件列表的总页数
|
|
53
54
|
* @param state
|
|
54
55
|
*/
|
|
55
|
-
checkMode: boolean;
|
|
56
56
|
predictionResult: import("./types").IPointCloudBoxWithIndex[];
|
|
57
57
|
predictionResultVisible: boolean;
|
|
58
58
|
highlightAttribute: string;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { IBasicRect, ICoordinate, IPointCloudBox, ISize } from '@labelbee/lb-utils';
|
|
2
2
|
import { IMappingImg } from '@/types/data';
|
|
3
3
|
export declare const jsonParser: (content: any, defaultValue?: any) => any;
|
|
4
|
+
/**
|
|
5
|
+
* Resolve the effective `valid` flag for a file item.
|
|
6
|
+
*
|
|
7
|
+
* Priority: result.valid → preResult.valid → true (default)
|
|
8
|
+
*
|
|
9
|
+
* When a page only has pre-annotation data (result is empty), `result.valid`
|
|
10
|
+
* is undefined, so we fall back to `preResult.valid`. A final `?? true`
|
|
11
|
+
* prevents passing `undefined` into setPointCloudValid / basicImgInfo.valid,
|
|
12
|
+
* which would silently coerce to `true` and override a correct `false` value.
|
|
13
|
+
*/
|
|
14
|
+
export declare const resolveFileItemValid: (result?: string, preResult?: string) => boolean;
|
|
4
15
|
export declare const getNewNode: <T>(newNode: T, oldNode: T) => T;
|
|
5
16
|
export declare const classnames: (className: {
|
|
6
17
|
[key: string]: boolean;
|
package/dist/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,t,e)=>t in n?__defProp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,__spreadValues=(n,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(n,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(n,e,t[e]);return n},__spreadProps=(n,t)=>__defProps(n,__getOwnPropDescs(t));const jsonParser=(n,t={})=>{try{return typeof n=="string"?JSON.parse(n):___default.default.isObject(n)?n:t}catch(e){return t}},classnames=n=>{if(Array.isArray(n))return n.filter(t=>t).join(" ");if(___default.default.isObject(n)){const t=[];return Object.keys(n).forEach(e=>{n[e]&&t.push(e)}),t.join(" ")}return""},getBoundingRect=n=>{let t=Infinity,e=Infinity,r=-Infinity,o=-Infinity;for(const i of n)t=Math.min(t,i.x),e=Math.min(e,i.y),r=Math.max(r,i.x),o=Math.max(o,i.y);return{x:t,y:e,width:r-t,height:o-e}},isBoundingRectInImage=(()=>{const n=(t,e)=>{const r=Math.max(t.x,e.x),o=Math.max(t.y,e.y),i=Math.min(t.x+t.width,e.x+e.width),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _=require("lodash"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,t,e)=>t in n?__defProp(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,__spreadValues=(n,t)=>{for(var e in t||(t={}))__hasOwnProp.call(t,e)&&__defNormalProp(n,e,t[e]);if(__getOwnPropSymbols)for(var e of __getOwnPropSymbols(t))__propIsEnum.call(t,e)&&__defNormalProp(n,e,t[e]);return n},__spreadProps=(n,t)=>__defProps(n,__getOwnPropDescs(t));const jsonParser=(n,t={})=>{try{return typeof n=="string"?JSON.parse(n):___default.default.isObject(n)?n:t}catch(e){return t}},resolveFileItemValid=(n,t)=>{var e,r;const o=jsonParser(n),i=jsonParser(t);return(r=(e=o==null?void 0:o.valid)!=null?e:i==null?void 0:i.valid)!=null?r:!0},classnames=n=>{if(Array.isArray(n))return n.filter(t=>t).join(" ");if(___default.default.isObject(n)){const t=[];return Object.keys(n).forEach(e=>{n[e]&&t.push(e)}),t.join(" ")}return""},getBoundingRect=n=>{let t=Infinity,e=Infinity,r=-Infinity,o=-Infinity;for(const i of n)t=Math.min(t,i.x),e=Math.min(e,i.y),r=Math.max(r,i.x),o=Math.max(o,i.y);return{x:t,y:e,width:r-t,height:o-e}},isBoundingRectInImage=(()=>{const n=(t,e)=>{const r=Math.max(t.x,e.x),o=Math.max(t.y,e.y),i=Math.min(t.x+t.width,e.x+e.width),l=Math.min(t.y+t.height,e.y+e.height),s=i-r,a=l-o;return s>=0&&a>=0?{x:r,y:o,width:s,height:a}:null};return(t,e,r)=>{if(r[e]){const o=r[e].width,i=r[e].height;return n(t,{x:0,y:0,width:o,height:i})!==null}return!1}})(),getRectPointCloudBox=n=>{var t;const{pointCloudBox:e,mappingData:r,imageSizes:o}=n,{transferViewData:i}=(t=lbAnnotation.pointCloudLidar2image(e,r.calib))!=null?t:{};if(!i)return;const l=i.reduce((c,u)=>u.type==="line"?[...c,...u.pointList]:c,[]),s=__spreadProps(__spreadValues({},getBoundingRect(l)),{imageName:r.path});if(isBoundingRectInImage(s,r.path,o))return s},generatePointCloudBoxRects=(n,t)=>{var e;const{pointCloudBox:r,mappingImgList:o,imageSizes:i}=n,s=o.map(a=>getRectPointCloudBox({pointCloudBox:r,mappingData:a,imageSizes:i})).filter(a=>a!==void 0);if(s.length>0){const a=(e=t==null?void 0:t.prepareRectsFn)!=null?e:void 0,c=a?a(s,r):s;c.length>0&&Object.assign(r,{rects:c})}};exports.classnames=classnames,exports.generatePointCloudBoxRects=generatePointCloudBoxRects,exports.getBoundingRect=getBoundingRect,exports.getRectPointCloudBox=getRectPointCloudBox,exports.isBoundingRectInImage=isBoundingRectInImage,exports.jsonParser=jsonParser,exports.resolveFileItemValid=resolveFileItemValid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as
|
|
1
|
+
import{getClassName as d}from"../../utils/dom.js";import{cKeyCode as ee,PointCloud as te}from"@labelbee/lb-annotation";import{PointCloudUtils as S,EPerspectiveView as P}from"@labelbee/lb-utils";import O from"classnames";import o,{useContext as T,useState as y,useRef as oe,useEffect as m,useMemo as ne}from"react";import{PointCloudContainer as ie}from"./PointCloudLayout.js";import{PointCloudContext as le}from"./PointCloudContext.js";import{a2MapStateToProps as se}from"../../store/annotation/map.js";import{connect as re}from"react-redux";import{resolveFileItemValid as ae}from"../../utils/index.js";import{useSingleBox as A}from"./hooks/useSingleBox.js";import{useSphere as ce}from"./hooks/useSphere.js";import{Switch as de,Tooltip as ue}from"antd";import me from"../../hooks/useSize.js";import{usePointCloudViews as pe}from"./hooks/usePointCloudViews.js";import{useTranslation as F}from"react-i18next";import{LabelBeeContext as we}from"../../store/ctx.js";import ve from"./components/PointCloudSizeSlider/index.js";import fe from"./components/TitleButton/index.js";import{LeftOutlined as Ce}from"@ant-design/icons";import{useToolStyleContext as Ve}from"../../hooks/useToolStyle.js";import{usePointCloudAttribute as ge}from"./hooks/usePointCloudAttribute.js";var Ie=Object.defineProperty,H=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,U=(n,s,r)=>s in n?Ie(n,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[s]=r,he=(n,s)=>{for(var r in s||(s={}))Pe.call(s,r)&&U(n,r,s[r]);if(H)for(var r of H(s))Ee.call(s,r)&&U(n,r,s[r]);return n};const xe=ee.default,_e="LABELBEE-POINTCLOUD",E=o.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),w=({perspectiveView:n})=>{const{isActive:s,setTarget3DView:r}=T(E),f=p=>O({[d("point-cloud-3d-view",p)]:!0,active:s});return o.createElement("span",{onClick:()=>{r(P[n])},className:f(n.toLocaleLowerCase())})},K=({isEnlarge:n})=>{const{reset3DView:s,followTopView:r}=T(E),{t:f}=F(),p=o.createElement(o.Fragment,null,o.createElement(w,{perspectiveView:"Top"}),o.createElement(w,{perspectiveView:"Front"}),o.createElement(w,{perspectiveView:"Left"}),o.createElement(w,{perspectiveView:"Back"}),o.createElement(w,{perspectiveView:"Right"}),o.createElement(w,{perspectiveView:"LFT"}),o.createElement(w,{perspectiveView:"RBT"})),e=o.createElement(o.Fragment,null,o.createElement(ue,{title:f("CameraFollowTopView")},o.createElement("span",{onClick:()=>{r()},className:d("point-cloud-3d-view","followTop")})),o.createElement("span",{onClick:()=>{s()},className:d("point-cloud-3d-view","reset")}));return n?o.createElement("div",{className:d("point-cloud-3d-sidebarZoom")},e,p):o.createElement("div",{className:d("point-cloud-3d-sidebar")},p,e)},Se=({currentData:n,config:s,highlightAttribute:r,setResourceLoading:f})=>{var p;const e=T(le),{setIsLargeStatus:b}=e,[M,Z]=y(!0),[C,h]=y(!1),V=oe(null),{initPointCloud3d:B,generateRects:q}=pe(),g=me(V),{t:x}=F(),{value:L}=Ve(),{hiddenText:j}=L||{},{updatePointCloudAttribute:G}=ge(f,s),{updateSelectedBox:J}=A({generateRects:q});m(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(j,e.pointCloudBoxList)},[L]),m(()=>{!e.mainViewInstance||B==null||B(g)},[g]);const{selectedBox:u}=A(),{selectedSphere:I}=ce(),[Q,D]=y(!0),_=t=>{var i,a;const l=u==null?void 0:u.info;if(l){const c=he({},l.center);c.x=c.x-.01,c.z=1e3;const v=t===P.Top;(i=e.mainViewInstance)==null||i.updateCameraByBox(l,t,v?c:void 0)}I&&((a=e.mainViewInstance)==null||a.updateCameraBySphere(I,t))},W=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},X=()=>{var t,i;const a=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;a&&((i=e.mainViewInstance)==null||i.applyCameraTarget(a))};m(()=>{if(V.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&g.width&&(t=new te({container:V.current,isOrthographicCamera:!0,orthographicParams:S.getDefaultOrthographicParams(g),config:s,hiddenText:j,view:"3DView"}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:D}),e.setMainViewInstance(t))}},[g,n]),m(()=>{var t;if(V.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let i=e.mainViewInstance;const a=S.getRectParamsFromResultList(n.result),l=S.getBoxParamsFromResultList(n.result),c=l.find(v=>v.id===e.selectedID);c&&((t=e.topViewInstance)==null||t.updatePolygonList(l,void 0),G(c.attribute),J(c),e.setSelectedIDs(c.id)),e.setPointCloudValid(ae(n.result,n.preResult)),e.setPointCloudResult(l),e.setRectList(a),i.generateBoxes(l)}},[n.result,e.mainViewInstance]),m(()=>{var t,i,a,l,c,v,k;const N=(t=u==null?void 0:u.info)==null?void 0:t.id;if(!Q){D(!0);return}if(N!==void 0){_(P.Top);const $=(l=(a=(i=e.topViewInstance)==null?void 0:i.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?l:1;(c=e.mainViewInstance)==null||c.updateCameraZoom($)}(v=e.mainViewInstance)==null||v.setHighlightColor(N),(k=e.mainViewInstance)==null||k.render()},[(p=u==null?void 0:u.info)==null?void 0:p.id]),m(()=>{var t,i,a,l;if(I){_(P.Top);const c=(a=(i=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?a:1;(l=e.mainViewInstance)==null||l.updateCameraZoom(c)}},[I]),m(()=>(window.addEventListener("keydown",z),()=>{window.removeEventListener("keydown",z)}),[]);const z=t=>{if(t.keyCode===xe.Esc){h(!1);return}},R=ne(()=>({reset3DView:W,setTarget3DView:_,isActive:!!u,followTopView:X}),[u,e.mainViewInstance]);m(()=>{var t,i,a;const l=e.pointCloudBoxList.filter(c=>c.attribute===r);(l==null?void 0:l.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(i=e.mainViewInstance)==null||i.highlightBoxes(l)),l.length===0&&((a=e.mainViewInstance)==null||a.clearHighlightBoxesAndRender())},[r,e.mainViewInstance]);const Y=o.createElement(o.Fragment,null,o.createElement(ve,{onChange:t=>{var i;(i=e.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),o.createElement("span",{style:{marginRight:8}},x("ShowArrows")),o.createElement(de,{size:"small",checked:M,onChange:t=>{var i;Z(t),(i=e.mainViewInstance)==null||i.setShowDirection(t)}}),C&&o.createElement(E.Provider,{value:R},o.createElement(K,{isEnlarge:C})));return o.createElement(ie,{className:O({[d("point-cloud-3d-container")]:!0,[d("point-cloud-container","zoom")]:C}),title:C?o.createElement("div",{style:{display:"flex",alignItems:"center"}},o.createElement(Ce,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{b(!1),h(!1)}}),x("3DView")):o.createElement(fe,{title:x("3DView"),onClick:()=>{b(!0),h(!0)}}),toolbar:Y},o.createElement("div",{className:d("point-cloud-3d-content")},!C&&o.createElement(E.Provider,{value:R},o.createElement(K,null)),o.createElement("div",{className:d("point-cloud-3d-view"),id:_e,ref:V})))};var Te=re(se,null,null,{context:we})(Se);export{Te as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudName as rt,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as q,PointCloudUtils as k,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 lo}from"./useSphere.js";import{pick as ro}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as W}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as tt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as dt,SetAnnotationLoading as vt,SetLoadPCDFileLoading as Lt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as ot}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,ho=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,x=(e,n)=>{for(var t in n||(n={}))ho.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))xo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((d,p)=>{var o=a=>{try{u(t.next(a))}catch(h){p(h)}},f=a=>{try{u(t.throw(a))}catch(h){p(h)}},u=a=>a.done?d(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const et=5,nt=90,It=.01,b={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(e,n,t,d,p)=>{const{x:o,y:f}=k.transferCanvas2World(e,n),{defaultZ:u}=io,a={center:{x:o,y:f,z:u},id:e.id},h=d?x(x({},d),a):A(x({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},ct=(e,n,t,d,p,o)=>{let f=e.pointList.map(S=>k.transferCanvas2World(S,n)),u=0,a=1,h={};if(t){const S=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&S.fittedCoordinates.length>0&&(f=S.fittedCoordinates),u=(S.maxZ+S.minZ)/2,a=S.maxZ-S.minZ,h={count:S.zCount}}const[P,v,T]=f,V=w.getLineCenterPoint([P,T]),R=w.getLineLength(P,v),U=w.getLineLength(v,T),j=w.getRadiusFromQuadrangle(e.pointList);d&&(u=d.center.z,a=d.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+It:U,height:o?R+It:R,depth:a,rotation:j,id:e.id},N=x(d?x(x({},d),z):A(x({},z),{attribute:"",valid:!0}),h);p&&Object.assign(N,p);const E=f.map(S=>k.transferWorld2Canvas(S,n));return{boxParams:N,newPointList:E}},wt=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x-d.x,y:t.center.y,z:t.center.z-d.y}})},St=(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},R=w.getLineLength(p,o),U=w.getLineLength(u,a),j=R-U,z=w.getLineLength(o,f),N=w.getLineLength(a,h),E=z-N,{newBoxParams:S}=d.getNewBoxBySideUpdate(V,E,j,t);return S},vo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x,y:t.center.y-d.x,z:t.center.z-d.y}})},Lo=(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},R=w.getLineLength(p,o),U=w.getLineLength(u,a),j=R-U,z=w.getLineLength(o,f),N=w.getLineLength(a,h),E=z-N;let{newBoxParams:S}=d.getNewBoxByBackUpdate(V,E,j,t);return S},Dt=(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:nt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,q.Left);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{width:et,depth:et});const{cameraPositionVector:f}=o.updateOrthoCamera(e,q.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:nt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,q.Back);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{height:et,depth:et});const{cameraPositionVector:f}=o.updateOrthoCamera(e,q.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)},Ot=(e,n,t,d)=>{if(!t||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,q.Top),d.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(x(x({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},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:R,imageSizes:U,history:j,linkageImageNameRectMap:z}=n,{addHistory:N,initHistory:E,pushHistoryUnderUpdatePolygon:S}=go(),{selectedPolygon:kt}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:pt,selectedSphere:K}=lo(),{currentData:Z,config:y}=ao(s=>{const{stepList:i,step:c,imgList:r,imgIndex:g}=s.annotation;return{currentData:r[g],config:tt(uo.getCurrentStepInfo(c,i).config)}}),M=co(),Tt=ot(R),Ut=ot(z),zt=ht((s,i)=>{const c=Ut.current,r=i.id;return s.filter(l=>{if(!l)return!1;const m=c.get(l.imageName);return m===void 0?!0:Boolean(m.get(r))})},[]),it=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!Tt.current||i){const{mappingImgList:c=[]}=Z;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:O,updateSelectedBox:jt,updateSelectedBoxes:st,getPointCloudByID:Nt}=so({generateRects:it}),gt=O==null?void 0:O.info;if(!t||!d||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:lt}=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 g;const l={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};r===!0&&Object.assign(l,{trackID:k.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const m=at(s,i,lt,void 0,l);a(s.id);const C=u(m);J(b.Top,s,m,c,C,y),N({newSphereParams:m})},Ht=({polygon:s,size:i,imgList:c,trackConfigurable:r,zoom:g,intelligentFit:l})=>{var m,C,D;const _={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};r===!0&&Object.assign(_,{trackID:k.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:v})}),t==null||t.toolInstance;const L=x({},s);let{boxParams:I,newPointList:B}=ct(L,i,lt,void 0,_,l);I=M(dt({tool:rt.PointCloud,dataList:[I],stepConfig:y,action:"viewUpdateBox"}))[0],l&&(B==null?void 0:B.length)&&(L.pointList=B);const H=T.includes(L.attribute);it(I);const F=f(I),X=(C=n==null?void 0:n.polygonList)!=null?C:[];I.subAttribute=oo.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(D=y==null?void 0:y.inputList)!=null?D:[]:[]),t==null||t.updatePolygonList(F!=null?F:[],X,!1),H?a([]):(a(I.id),l&&ut(I,L,t,o)),N({newBoxParams:I})},Ft=s=>{const{boxID:i,imageName:c,width:r,height:g,x:l,y:m}=s,C=P.find(B=>B.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(B=>B.imageName===c))return;const _=C.rects.map(B=>B.imageName===c?A(x({},B),{width:r,height:g,x:l,y:m}):B),L=A(x({},C),{rects:_}),I=P.map(B=>B.id===i?L:B);return t==null||t.updatePolygonList(I!=null?I:[]),I},Wt=s=>{const{boxID:i,imageName:c}=s,r=P.find(C=>C.id===i);if(!(r==null?void 0:r.rects))return;const g=r.rects.filter(C=>C.imageName!==c),l=A(x({},r),{rects:g}),m=P.map(C=>C.id===i?l:C);return t==null||t.updatePolygonList(m!=null?m:[]),m},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:c,newSphereList:r})=>{var g;const l=t==null?void 0:t.toolInstance;if(!(h.length===0||!l)){if(s||(O==null?void 0:O.info)){const m=s!=null?s:O==null?void 0:O.info;(g=l==null?void 0:l.selection)==null||g.setSelectedIDs(h[0]);const C=l.selectedPolygon;if(h.length===1&&m){Q({omitView:b.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((c||K)&&h.length===1){const m=c!=null?c:K;l.setSelectedID(h[0]);const C=l.selectedPoint;m&&J(b.Top,C,m,void 0,r,y)}}},ft=(s,i,c,r=W.Default)=>{if(gt){let g,l;switch(c){case b.Back:g=Lo;break;case b.Side:g=St;break;default:g=St;break}if(l=g(s,i,gt,d.pointCloudInstance),o){const{count:L}=o.getSensesPointZAxisInPolygon(eo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=A(x({},l),{count:L})}const C=M(dt({tool:rt.PointCloud,dataList:[l],stepConfig:y,action:"viewUpdateBox"}))[0],D=l.valid!==C.valid;l=C;const _=jt(l);return l=_.find(L=>L.id===l.id),Q({omitView:D?void 0:c,polygon:s,boxParams:l,newPointCloudBoxList:_},r),_}},Ct=(s,i,c)=>{if(K){let r,g;switch(c){case b.Back:r=vo;break;case b.Side:r=wt;break;default:r=wt;break}g=r(s,i,K);const l=pt(g);return J(c,s,g,void 0,l,y),l}},Gt=(s,i)=>{Ct(s,i,b.Side)},Jt=(s,i)=>{Ct(s,i,b.Back)},Qt=(s,i)=>{ft(s,i,b.Side,W.Single)},Xt=(s,i)=>{ft(s,i,b.Back,W.Single)},Yt=(s,i)=>{const c=At(s.id),r=at(s,i,lt,c),g=pt(r);J(b.Top,s,r,void 0,g,y)},qt=(s,i)=>{if(kt){const r=x({},s[0].newPolygon);r.pointList=r.pointList.map(g=>k.transferCanvas2World(g,i)),S(r);return}let c=s.map(({newPolygon:r})=>{const g=Nt(r.id),{boxParams:l}=ct(r,i,t.pointCloudInstance,g);return l});if(c=M(dt({tool:rt.PointCloud,dataList:c,stepConfig:y,action:"viewUpdateBox"})),c.length===1){const{newPolygon:r}=s[0],g=st(c);Q({polygon:r,boxParams:c[0],newPointCloudBoxList:g},W.Single)}else{const r=st(c);r&&n.syncAllViewPointCloudColor(W.MultiMove,r)}},Kt=s=>{var i,c,r,g,l;if(O){const m=Number(s.widthDefault),C=Number(s.depthDefault),D=Number(s.heightDefault),_=O==null?void 0:O.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find($=>($==null?void 0:$.trackID)===_),B={width:(r=(c=t==null?void 0:t.toolInstance)==null?void 0:c.basicImgInfo)==null?void 0:r.width,height:(l=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:l.height},G=I.pointList.map($=>k.transferCanvas2World($,B)),H=w.getModifiedRectangleCoordinates(G,D,m),F=H[0],X=H[2],Y=w.getLineCenterPoint([F,X]),$t=O.info.center.z-O.info.depth/2,Pt=A(x({},O.info),{center:{x:Y.x,y:Y.y,z:$t+C/2},width:m,height:D,depth:C,valid:!0}),to=st([Pt]);Q({omitView:b["3D"],polygon:I,boxParams:Pt,newPointCloudBoxList:to})}},J=(s,i,c,r,g,l)=>bt(void 0,null,function*(){const m=Z==null?void 0:Z.url,C={[b.Side]:()=>{Dt(c,i,d,m,l)},[b.Back]:()=>{p&&_t(c,i,p,m,l)},[b.Top]:()=>{Ot(c,i,t,o)}};Object.keys(C).forEach(D=>{D!==s&&C[D]()}),r&&(o==null||o.updateCameraZoom(r)),Et(c)}),Q=(s,i=W.Default)=>{const{omitView:c,polygon:r,boxParams:g,zoom:l,newPointCloudBoxList:m}=s,C=Z==null?void 0:Z.url;m&&n.syncAllViewPointCloudColor(i,m);const D={[b.Side]:()=>{Rt(g,r,d,C)},[b.Back]:()=>{p&&Vt(g,r,p,C)},[b.Top]:()=>{ut(g,r,t,o)}};Object.keys(D).forEach(_=>{_!==c&&D[_]()}),l&&(o==null||o.updateCameraZoom(l))};return{topViewAddSphere:Mt,topViewAddBox:Ht,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:Q,syncPointCloudPoint:J,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=k.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=Z){var c,r,g,l,m,C,D,_;if(!(i==null?void 0:i.url)||!o)return;V([]),vt(M,!0),Lt(M,!0),(c=e==null?void 0:e.setResourceLoading)==null||c.call(e,!0),yield o.loadPCDFile(i.url,(r=y==null?void 0:y.radius)!=null?r:nt,y==null?void 0:y.tipScopeList),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let L=[],I=[],B=[],G=[];o.updateTopCamera();const H=tt(i.result),F=tt(i.preResult),X=(l=(g=H==null?void 0:H.valid)!=null?g:F==null?void 0:F.valid)!=null?l:!0;if(n.setPointCloudValid(X),(m=n.sideViewInstance)==null||m.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(L=k.getBoxParamsFromResultList(i.result),(L==null?void 0:L.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){L=yield o==null?void 0:o.filterPreResult(i.url,y,L);const Y=tt(i.result);Y[no].result=L,i.result=JSON.stringify(Y),n.setPointCloudResult(L)}B=k.getPolygonListFromResultList(i.result),I=k.getLineListFromResultList(i.result),G=k.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(D=y==null?void 0:y.radius)!=null?D:nt}),o==null||o.generateBoxes(L),o==null||o.generateSpheres(G),yield n.syncAllViewPointCloudColor(W.Default,L,[])}E({pointCloudBoxList:L,polygonList:B,lineList:I,pointCloudSphereList:G}),vt(M,!1),Lt(M,!1),(_=e==null?void 0:e.setResourceLoading)==null||_.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:it,update2DViewRect:Ft,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(xt),d=ot(e),p=ot(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=ro(P,["x","y","width","height"]);let R=a.get(v);R||(R=new Map,a.set(v,R)),R.set(T,V),h.add(v)}),a.size){const P=f.map(v=>{var T;const V=v.id;if(h.has(V)){const R=x({},v);return(T=R.rects)==null||T.forEach(U=>{var j;const z=U.imageName;Object.assign(U,(j=a.get(V))==null?void 0:j.get(z))}),R}return v});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,Dt as syncSideViewByPoint,Ot 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 J,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as Pt,useCallback as mt}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 F}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as xt,generatePointCloudBoxRects as po,resolveFileItemValid as go}from"../../../utils/index.js";import{PreDataProcess as rt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as fo}from"./useHistory.js";import{usePolygon as Co}from"./usePolygon.js";import{useLatest as K}from"ahooks";var Po=Object.defineProperty,mo=Object.defineProperties,ho=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,Lo=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Po(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))Lo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>mo(e,ho(n)),bt=(e,n,t)=>new Promise((d,p)=>{var o=a=>{try{u(t.next(a))}catch(h){p(h)}},f=a=>{try{u(t.throw(a))}catch(h){p(h)}},u=a=>a.done?d(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const $=5,tt=90,It=.01,b={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},lt=(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},dt=(e,n,t,d,p,o)=>{let f=e.pointList.map(S=>O.transferCanvas2World(S,n)),u=0,a=1,h={};if(t){const S=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&S.fittedCoordinates.length>0&&(f=S.fittedCoordinates),u=(S.maxZ+S.minZ)/2,a=S.maxZ-S.minZ,h={count:S.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+It:U,height:o?D+It: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 E=f.map(S=>O.transferWorld2Canvas(S,n));return{boxParams:j,newPointList:E}},wt=(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}})},St=(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),E=z-j,{newBoxParams:S}=d.getNewBoxBySideUpdate(V,E,N,t);return S},vo=(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}})},yo=(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),E=z-j;let{newBoxParams:S}=d.getNewBoxByBackUpdate(V,E,N,t);return S},Dt=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,J.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:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,J.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,J.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:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,J.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,J.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)},at=(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)},Bo=e=>{const n=Pt(ht),{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:E,pushHistoryUnderUpdatePolygon:S}=fo(),{selectedPolygon:Ot}=Co(),{getPointCloudSphereByID:At,updatePointCloudSphere:ct,selectedSphere:Q}=ro(),{currentData:H,config:y}=ao(s=>{const{stepList:i,step:c,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:xt(uo.getCurrentStepInfo(c,i).config)}}),M=co(),Tt=K(D),Ut=K(z),zt=mt((s,i)=>{const c=Ut.current,l=i.id;return s.filter(r=>{if(!r)return!1;const m=c.get(r.imageName);return m===void 0?!0:Boolean(m.get(l))})},[]),ot=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!Tt.current||i){const{mappingImgList:c=[]}=H;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:et,getPointCloudByID:jt}=so({generateRects:ot}),ut=k==null?void 0:k.info;if(!t||!d||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:nt}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:s,size:i,zoom:c,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const m=lt(s,i,nt,void 0,r);a(s.id);const C=u(m);W(b.Top,s,m,c,C,y),j({newSphereParams:m})},Ft=({polygon:s,size:i,imgList:c,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var m,C,x;const R={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};l===!0&&Object.assign(R,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:v})}),t==null||t.toolInstance;const _=L({},s);let{boxParams:B,newPointList:I}=dt(_,i,nt,void 0,R,r);B=M(rt({tool:st.PointCloud,dataList:[B],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(I==null?void 0:I.length)&&(_.pointList=I);const X=T.includes(_.attribute);ot(B);const Y=f(B),it=(C=n==null?void 0:n.polygonList)!=null?C:[];B.subAttribute=oo.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(x=y==null?void 0:y.inputList)!=null?x:[]:[]),t==null||t.updatePolygonList(Y!=null?Y:[],it,!1),X?a([]):(a(B.id),r&&at(B,_,t,o)),j({newBoxParams:B})},Ht=s=>{const{boxID:i,imageName:c,width:l,height:g,x:r,y:m}=s,C=P.find(I=>I.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(I=>I.imageName===c))return;const R=C.rects.map(I=>I.imageName===c?A(L({},I),{width:l,height:g,x:r,y:m}):I),_=A(L({},C),{rects:R}),B=P.map(I=>I.id===i?_:I);return t==null||t.updatePolygonList(B!=null?B:[]),B},Wt=s=>{const{boxID:i,imageName:c}=s,l=P.find(C=>C.id===i);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==c),r=A(L({},l),{rects:g}),m=P.map(C=>C.id===i?r:C);return t==null||t.updatePolygonList(m!=null?m:[]),m},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:c,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(h.length===0||!r)){if(s||(k==null?void 0:k.info)){const m=s!=null?s:k==null?void 0:k.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(h[0]);const C=r.selectedPolygon;if(h.length===1&&m){Z({omitView:b.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((c||Q)&&h.length===1){const m=c!=null?c:Q;r.setSelectedID(h[0]);const C=r.selectedPoint;m&&W(b.Top,C,m,void 0,l,y)}}},pt=(s,i,c,l=F.Default)=>{if(ut){let g,r;switch(c){case b.Back:g=yo;break;case b.Side:g=St;break;default:g=St;break}if(r=g(s,i,ut,d.pointCloudInstance),o){const{count:_}=o.getSensesPointZAxisInPolygon(eo(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=A(L({},r),{count:_})}const C=M(rt({tool:st.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],x=r.valid!==C.valid;r=C;const R=Nt(r);return r=R.find(_=>_.id===r.id),Z({omitView:x?void 0:c,polygon:s,boxParams:r,newPointCloudBoxList:R},l),R}},gt=(s,i,c)=>{if(Q){let l,g;switch(c){case b.Back:l=vo;break;case b.Side:l=wt;break;default:l=wt;break}g=l(s,i,Q);const r=ct(g);return W(c,s,g,void 0,r,y),r}},Gt=(s,i)=>{gt(s,i,b.Side)},Jt=(s,i)=>{gt(s,i,b.Back)},Qt=(s,i)=>{pt(s,i,b.Side,F.Single)},Xt=(s,i)=>{pt(s,i,b.Back,F.Single)},Yt=(s,i)=>{const c=At(s.id),l=lt(s,i,nt,c),g=ct(l);W(b.Top,s,l,void 0,g,y)},qt=(s,i)=>{if(Ot){const l=L({},s[0].newPolygon);l.pointList=l.pointList.map(g=>O.transferCanvas2World(g,i)),S(l);return}let c=s.map(({newPolygon:l})=>{const g=jt(l.id),{boxParams:r}=dt(l,i,t.pointCloudInstance,g);return r});if(c=M(rt({tool:st.PointCloud,dataList:c,stepConfig:y,action:"viewUpdateBox"})),c.length===1){const{newPolygon:l}=s[0],g=et(c);Z({polygon:l,boxParams:c[0],newPointCloudBoxList:g},F.Single)}else{const l=et(c);l&&n.syncAllViewPointCloudColor(F.MultiMove,l)}},Kt=s=>{var i,c,l,g,r;if(k){const m=Number(s.widthDefault),C=Number(s.depthDefault),x=Number(s.heightDefault),R=k==null?void 0:k.info.trackID,B=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(q=>(q==null?void 0:q.trackID)===R),I={width:(l=(c=t==null?void 0:t.toolInstance)==null?void 0:c.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},G=B.pointList.map(q=>O.transferCanvas2World(q,I)),X=w.getModifiedRectangleCoordinates(G,x,m),Y=X[0],it=X[2],ft=w.getLineCenterPoint([Y,it]),$t=k.info.center.z-k.info.depth/2,Ct=A(L({},k.info),{center:{x:ft.x,y:ft.y,z:$t+C/2},width:m,height:x,depth:C,valid:!0}),to=et([Ct]);Z({omitView:b["3D"],polygon:B,boxParams:Ct,newPointCloudBoxList:to})}},W=(s,i,c,l,g,r)=>bt(void 0,null,function*(){const m=H==null?void 0:H.url,C={[b.Side]:()=>{Dt(c,i,d,m,r)},[b.Back]:()=>{p&&_t(c,i,p,m,r)},[b.Top]:()=>{kt(c,i,t,o)}};Object.keys(C).forEach(x=>{x!==s&&C[x]()}),l&&(o==null||o.updateCameraZoom(l)),Et(c)}),Z=(s,i=F.Default)=>{const{omitView:c,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:m}=s,C=H==null?void 0:H.url;m&&n.syncAllViewPointCloudColor(i,m);const x={[b.Side]:()=>{Rt(g,l,d,C)},[b.Back]:()=>{p&&Vt(g,l,p,C)},[b.Top]:()=>{at(g,l,t,o)}};Object.keys(x).forEach(R=>{R!==c&&x[R]()}),r&&(o==null||o.updateCameraZoom(r))};return{topViewAddSphere:Mt,topViewAddBox:Ft,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:Z,syncPointCloudPoint:W,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 c,l,g,r,m,C;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(M,!0),vt(M,!0),(c=e==null?void 0:e.setResourceLoading)==null||c.call(e,!0),yield o.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:tt,y==null?void 0:y.tipScopeList),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],R=[],_=[],B=[];o.updateTopCamera();const I=go(i.result,i.preResult);if(n.setPointCloudValid(I),(g=n.sideViewInstance)==null||g.clearAllData(),(r=n.backViewInstance)==null||r.clearAllData(),i.result){if(x=O.getBoxParamsFromResultList(i.result),(x==null?void 0:x.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){x=yield o==null?void 0:o.filterPreResult(i.url,y,x);const G=xt(i.result);G[no].result=x,i.result=JSON.stringify(G),n.setPointCloudResult(x)}_=O.getPolygonListFromResultList(i.result),R=O.getLineListFromResultList(i.result),B=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(m=y==null?void 0:y.radius)!=null?m:tt}),o==null||o.generateBoxes(x),o==null||o.generateSpheres(B),yield n.syncAllViewPointCloudColor(F.Default,x,[])}E({pointCloudBoxList:x,polygonList:_,lineList:R,pointCloudSphereList:B}),Lt(M,!1),vt(M,!1),(C=e==null?void 0:e.setResourceLoading)==null||C.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:ot,update2DViewRect:Ht,remove2DViewRect:Wt}},bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=Pt(ht),d=K(e),p=K(n);return{syncToPointCloudBoxList:mt(()=>{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,Dt as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,at as synchronizeTopView,lt as topViewPoint2PointCloud,dt as topViewPolygon2PointCloud,Bo as usePointCloudViews,bo as useSyncRectPositionDimensionToPointCloudList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as i}from"../../utils/dom.js";import e,{useContext as K,useRef as b,useState as w,useEffect as f}from"react";import O from"./PointCloud3DView.js";import Z from"./PointCloudBackView.js";import Q from"./PointCloudTopView.js";import U from"./PointCloudSideView.js";import $ from"./PointCloud2DView.js";import q from"./PointCloudListener.js";import J from"./PointCloudSegmentListener.js";import X from"./PointCloudSegment.js";import Y from"./PointCloudSegmentStatus.js";import tt from"./PointCloudSegmentToolbar.js";import et from"./PointCloudSegment2DView.js";import{connect as ot}from"react-redux";import{LabelBeeContext as nt,useDispatch as it}from"../../store/ctx.js";import{AnnotatedAttributesPanelFixedLeft as lt,AnnotatedAttributesPanelFixedRight as rt}from"../../views/MainView/toolFooter/AnnotatedAttributes/index.js";import{PointCloudContext as at}from"./PointCloudContext.js";import{PointCloudUtils as st,EPointCloudPattern as ut}from"@labelbee/lb-utils";import{useCustomToolInstance as
|
|
1
|
+
import{getClassName as i}from"../../utils/dom.js";import e,{useContext as K,useRef as b,useState as w,useEffect as f}from"react";import O from"./PointCloud3DView.js";import Z from"./PointCloudBackView.js";import Q from"./PointCloudTopView.js";import U from"./PointCloudSideView.js";import $ from"./PointCloud2DView.js";import q from"./PointCloudListener.js";import J from"./PointCloudSegmentListener.js";import X from"./PointCloudSegment.js";import Y from"./PointCloudSegmentStatus.js";import tt from"./PointCloudSegmentToolbar.js";import et from"./PointCloudSegment2DView.js";import{connect as ot}from"react-redux";import{LabelBeeContext as nt,useDispatch as it}from"../../store/ctx.js";import{AnnotatedAttributesPanelFixedLeft as lt,AnnotatedAttributesPanelFixedRight as rt}from"../../views/MainView/toolFooter/AnnotatedAttributes/index.js";import{PointCloudContext as at}from"./PointCloudContext.js";import{PointCloudUtils as st,EPointCloudPattern as ut}from"@labelbee/lb-utils";import{useCustomToolInstance as dt}from"../../hooks/annotation.js";import{jsonParser as mt,resolveFileItemValid as ct}from"../../utils/index.js";import{a2MapStateToProps as pt}from"../../store/annotation/map.js";import j from"classnames";import ft from"./components/sideAndBackOverView/index.js";import{SetLoadPCDFileLoading as gt}from"../../store/annotation/actionCreators.js";import x from"../DynamicResizer/DynamicResizer.js";const Ct=D=>{const{currentData:l,imgList:y,drawLayerSlot:g,checkMode:r,intelligentFit:I,imgIndex:R,config:A,measureVisible:B,setResourceLoading:L,stepInfo:o,setBatchSetValid:C}=D,t=K(at),{globalPattern:P,setGlobalPattern:k,selectedIDs:h,isLargeStatus:d,setIsLargeStatus:T}=t,N=it(),v=b(null),S=b(null),[_,F]=w(0),[a,E]=w(!1),M=(h==null?void 0:h.length)>0&&a,H=mt(l.result),{toolInstanceRef:u,clearToolInstance:z}=dt({basicInfo:H});if(f(()=>{u.current.setPointCloudGlobalPattern=n=>{n!==P&&(k(n),t.clearAllDetectionInstance(),z())}},[P]),f(()=>{var n;if(gt(N,!0),l){const{boxParamsList:s,polygonList:m,lineList:c,sphereParamsList:p,segmentation:W,rectList:G}=st.parsePointCloudCurrentResult((n=l==null?void 0:l.result)!=null?n:"");t.setPointCloudResult(s),t.setPolygonList(m),t.setLineList(c),t.setPointCloudSphereList(p),t.setRectList(G),t.setSegmentation(W),t.setPointCloudValid(ct(l==null?void 0:l.result,l==null?void 0:l.preResult))}},[R]),f(()=>{var n;if(v.current){const s=((n=v.current)==null?void 0:n.offsetHeight)-233;F(s)}},[S.current]),f(()=>{u.current.exportData=()=>[t.pointCloudBoxList,{valid:t.valid}],u.current.exportCustomData=()=>{var n,s,m,c,p;return{resultPolygon:(n=t.polygonList)!=null?n:[],resultLine:(s=t.lineList)!=null?s:[],resultPoint:(m=t.pointCloudSphereList)!=null?m:[],resultRect:(c=t.rectList)!=null?c:[],segmentation:(p=t.segmentation)!=null?p:[]}}},[t.pointCloudBoxList,t.rectList,t.valid,t.polygonList,t.lineList,t.pointCloudSphereList,t.ptSegmentInstance,t.segmentation]),y.length===0)return null;if(P===ut.Segmentation)return e.createElement(e.Fragment,null,e.createElement(J,{checkMode:r,toolInstanceRef:u}),e.createElement(tt,null),e.createElement("div",{className:i("point-cloud-layout")},e.createElement(X,{checkMode:r}),e.createElement(et,null)),e.createElement(Y,{config:A}),g==null?void 0:g({direct:!0}));let V=e.createElement("div",{className:i("point-cloud-container","left-bottom")},e.createElement(Z,{checkMode:r}),e.createElement(U,{checkMode:r}));return a&&(V=e.createElement(ft,{selectAndEnlarge:M,checkMode:r})),e.createElement(e.Fragment,null,e.createElement(q,{checkMode:r,toolInstanceRef:u,setResourceLoading:L,isBatchSetValid:!!C}),e.createElement("div",{className:i("point-cloud-layout"),onContextMenu:n=>n.preventDefault()},e.createElement("div",{className:i("point-cloud-wrapper")},e.createElement(lt,null),e.createElement("div",{className:i("point-cloud-content"),ref:S},e.createElement(x,{direction:"horizontal",localKey:"leftAllViewid:"+(o==null?void 0:o.id)+"taskID:"+(o==null?void 0:o.taskID)+"step:"+(o==null?void 0:o.step)+"type:"+(o==null?void 0:o.type),defaultWidth:360,minLeftWidth:244,minRightWidth:"50%",disabled:d},e.createElement("div",{className:i("point-cloud-container",d?"left-large":"left-noLarge")},e.createElement(O,{setResourceLoading:L}),V),e.createElement("div",{className:j({[i("point-cloud-container","right")]:!0,[i("point-cloud-container","rightZoom")]:a}),ref:v},e.createElement(x,{localKey:"rightAllViewid:"+(o==null?void 0:o.id)+"taskID:"+(o==null?void 0:o.taskID)+"step:"+(o==null?void 0:o.step)+"type:"+(o==null?void 0:o.type),defaultHeight:300,minTopHeight:_,minBottomHeight:160,disabled:d},e.createElement(Q,{drawLayerSlot:g,checkMode:r,intelligentFit:I,setIsEnlargeTopView:E,onExitZoom:()=>{T(!1),E(!1)},isEnlargeTopView:a}),e.createElement("div",{className:j({[i("point-cloud-container",d?"right-bottom-large":"right-bottom-noLarge")]:!a,[i("point-cloud-container","right-bottom-floatLeft")]:a})},e.createElement($,{isEnlargeTopView:a,thumbnailWidth:a?300:455,checkMode:r,measureVisible:B})))))),e.createElement(rt,null))),t.visibleBatchSetValid&&(C==null?void 0:C({valid:t.valid,isModal:!0,visibleModal:t.visibleBatchSetValid,onClose:()=>t.setBatchSetValidModal(!1),singleSetQuestionImg:()=>t.setPointCloudValid(!t.valid)})))};var Pt=ot(pt,null,null,{context:nt})(Ct);export{Pt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getFormatSize as Ct}from"../../components/customResizeHook/index.js";import{ESubmitType as W}from"../../constant/index.js";import ht from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as r}from"../Actions.js";import{jsonParser as j}from"../../utils/index.js";import Y from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as pt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as gt,composeResult as J}from"../../utils/data.js";import h from"../../utils/StepUtils.js";import q from"../../utils/ToolUtils.js";import{MathUtils as _t,CommonToolUtils as Ot,AnnotationEngine as bt,ImgUtils as Nt}from"@labelbee/lb-annotation";import{PointCloudUtils as It,i18n as M}from"@labelbee/lb-utils";import{Modal as mt}from"antd";import{message as ft}from"antd/es";import Tt from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as O}from"../../data/enums/ToolType.js";var Ut=Object.defineProperty,Bt=Object.defineProperties,xt=Object.getOwnPropertyDescriptors,Lt=Object.getOwnPropertySymbols,wt=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable,Et=(t,e,u)=>e in t?Ut(t,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[e]=u,o=(t,e)=>{for(var u in e||(e={}))wt.call(e,u)&&Et(t,u,e[u]);if(Lt)for(var u of Lt(e))Ft.call(e,u)&&Et(t,u,e[u]);return t},l=(t,e)=>Bt(t,xt(e)),At=(t,e,u)=>new Promise((A,d)=>{var S=f=>{try{E(u.next(f))}catch(y){d(y)}},L=f=>{try{E(u.throw(f))}catch(y){d(y)}},E=f=>f.done?A(f.value):Promise.resolve(f.value).then(S,L);E((u=u.apply(t,e)).next())});const b=(t,e)=>t.find(u=>u.step===e),St={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:"",confirmPageTurning:!1},jt=t=>{const{imgList:e,imgPageSize:u}=t;return Math.ceil(e.length/u)},Dt=(t,e)=>t.reduce((u,A)=>{if(A){const d=A.result;if(j(d)[`step_${e}`])return u+1}return u},0)/t.length,Gt=(t,e)=>{const{step:u,stepList:A}=t,d=h.getCurrentStepInfo(u,A),S=pt.jsonParser(d.config);if(q.isVideoTool(d==null?void 0:d.tool)||q.isAudioTool(d==null?void 0:d.tool)||q.isPointCloudTool(d==null?void 0:d.tool)||[O.LLM,O.NLP,O.LLMMultiWheel].includes(d==null?void 0:d.tool))return;const L=document.getElementById("toolContainer");if(!L)throw"Not exist dom named id-toolContainer";const E=Ct({width:window.innerWidth,height:window.innerHeight}),f=new bt({container:L,toolName:d.tool,size:E,imgNode:e,config:S,style:JSON.parse(ht)});return{toolInstance:f==null?void 0:f.toolInstance,annotationEngine:f}},Mt=(t,e)=>(u,A)=>At(void 0,null,function*(){var d,S;const{stepList:L,step:E}=A().annotation,f=h.currentToolIsVideo(E,L),y=h.currentToolIsPointCloud(E,L),N=[O.LLM,O.LLMMultiWheel].includes((d=h.getCurrentStepInfo(E,L))==null?void 0:d.tool),U=((S=h.getCurrentStepInfo(E,L))==null?void 0:S.tool)===O.NLP,B=h.currentToolIsAudio(E,L);if($(u,!0),yield u(Vt(t)),f){u(kt(t));return}if(y||N||B||U){u(Ht(t));return}u(zt(t,e))}),Vt=t=>(e,u)=>At(void 0,null,function*(){const{getFileData:A,imgList:d}=u().annotation;if(A){const S=yield A(d[t],t);e({type:r.SET_FILE_DATA,payload:{fileData:S,index:t}})}}),kt=t=>e=>{e({type:r.LOAD_FILE_DATA,payload:{nextIndex:t}})},Ht=t=>e=>{$(e,!1),e({type:r.LOAD_FILE_DATA,payload:{nextIndex:t}})},zt=(t,e)=>(u,A)=>{var d;const{toolInstance:S,imgList:L}=A().annotation,E=(d=L==null?void 0:L[t])==null?void 0:d.url;Nt.load(E).then(f=>{$(u,!1),u({type:r.LOAD_FILE_DATA,payload:{imgNode:f,nextIndex:t,nextBasicIndex:e}})}).catch(()=>{$(u,!1),S==null||S.setErrorImg(),u({type:r.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:e}})})},Kt=({toolInstance:t,imgList:e,imgIndex:u,stepList:A,step:d=1})=>{var S,L,E,f;const y=((S=e[u])==null?void 0:S.result)||"",[N,U,B]=(L=t==null?void 0:t.exportData())!=null?L:[],V=(f=(E=t==null?void 0:t.exportCustomData)==null?void 0:E.call(t))!=null?f:{},k=gt(y,U),H=J(k,{step:d,stepList:A},{rect:N},V);return e.map((G,z)=>z===u?o(l(o({},G),{result:H}),B):o({},G))},Wt=(t=o({},St),e)=>{var u,A,d,S,L,E,f,y,N,U,B,V,k,H,G,z,Z,Q,tt,et,nt,ot,st,lt,it,rt,ut,at,ct;switch(e.type){case r.INIT_ALL_STATE:return o(o({},t),St);case r.UPDATE_TOOL_INSTANCE:return l(o({},t),{toolInstance:e.payload.toolInstance});case r.UPDATE_IMG_LIST:return l(o({},t),{imgList:e.payload.imgList});case r.CALC_STEP_PROGRESS:{const{imgList:n,step:s}=t,i=Dt(n,s);return l(o({},t),{stepProgress:i})}case r.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:s,step:i,stepList:a,toolInstance:p,onSubmit:c,resultList:m}=t;if(!p||!n[s])return t;const _=((u=n[s])==null?void 0:u.result)||"",[,I,g]=(A=p==null?void 0:p.exportData())!=null?A:[],T=(S=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?S:{},D=gt(_,I),v=J(D,{step:i,stepList:a},{rect:m},T),R=t.imgList.map((C,P)=>{if(P===s){const w=Y.dataCorrection(v,_,i,a);return o(l(o({},C),{result:w}),g)}return C});if(((L=e.payload)==null?void 0:L.submitType)===W.SyncImgList)return l(o({},t),{imgList:R});const x=Dt(R,i);return l(o({},t),{stepProgress:x,imgList:R})}case r.SAVE_RESULT:{const{imgList:n,imgIndex:s,onSave:i}=t;return i==null||i(n[s],s,n),o({},t)}case r.SUBMIT_RESULT:{const{imgList:n,basicIndex:s,resultList:i,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(E=a==null?void 0:a.exportData())!=null?E:[];let m=c;if((p==null?void 0:p.length)>0){const _=(f=p[s])==null?void 0:f.id,I=c.map(g=>l(o({},g),{sourceID:_}));m=Tt.cloneDeep(i).filter(g=>g.sourceID!==_),m.push(...I)}return l(o({},t),{resultList:m,imgList:n})}case r.SET_BASIC_INDEX:{const{toolInstance:n,step:s,imgList:i,imgIndex:a,stepList:p,annotationEngine:c,resultList:m,basicResultList:_}=t;if(!n||!c)return t;const I=e.payload.basicIndex,g=(y=_[I])==null?void 0:y.id,T=j((N=i[a])==null?void 0:N.result),D=(m||[]).filter(w=>w.sourceID===g),v=b(p,s),{dataSourceStep:R,tool:x}=v,C=b(p,R);let P=[];return R&&x&&(P=(U=T[`step_${R}`])==null?void 0:U.result,(P==null?void 0:P.length)>0?(c==null||c.setBasicInfo(C.tool,P[I]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),ft.info(M.t("NoDependency")))),n==null||n.setResult(D),n==null||n.history.initRecord(D,!0),l(o({},t),{basicIndex:I})}case r.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=e.payload;return l(o({},t),{triggerEventAfterIndexChanged:!!n})}case r.LOAD_FILE_DATA:{const{imgList:n,step:s,toolInstance:i,annotationEngine:a,stepList:p}=t;if(!i)return l(o({},t),{imgIndex:e.payload.nextIndex});const c=h.getCurrentStepInfo(s,p),{nextIndex:m,imgNode:_,nextBasicIndex:I,imgError:g}=e.payload,T=I!=null?I:0,D=j((B=n[m])==null?void 0:B.result),v=D[`step_${c.step}`],R=!v,x={rotate:(V=D.rotate)!=null?V:0,valid:(k=D.valid)!=null?k:!0};_&&g!==!0?a==null||a.setImgNode(_,x):i==null||i.setValid(x.valid);const C=b(p,c.step),{dataSourceStep:P,tool:w}=C,dt=b(p,P),X=P&&w,F=(G=(H=D[`step_${P}`])==null?void 0:H.result)!=null?G:[],K=Y.getInitialResultList(v==null?void 0:v.result,i,C,F,R);a==null||a.launchOperation();const vt=[O.Cuboid,O.ScribbleTool].includes(w);if(X&&((F==null?void 0:F.length)>0?a==null||a.setBasicInfo(dt.tool,F[T]):(a==null||a.setBasicInfo(dt.tool),a==null||a.forbidOperation(),ft.info(M.t("NoDependency")))),c.tool!=="check"&&(vt||X)){const yt=(Z=(z=F[T])==null?void 0:z.id)!=null?Z:"",Pt=X?K.filter(Rt=>Ot.isSameSourceID(Rt.sourceID,yt)):K;(Q=i==null?void 0:i.history)==null||Q.initRecord(K,!0),i==null||i.setResult(Pt)}return l(o({},t),{imgIndex:m,basicIndex:T,basicResultList:F,resultList:K})}case r.UPDATE_ANNOTATION_CONFIG:return l(o({},t),{config:(tt=e.payload.config)!=null?tt:"{}"});case r.SET_TASK_STEP_LIST:{const{stepList:n}=e.payload;return l(o({},t),{stepList:n})}case r.SET_TASK_CONFIG:{const{stepList:n,step:s}=e.payload;return l(o({},t),{stepList:n,step:s})}case r.INIT_TOOL:{const{imgNode:n}=t,s=Gt(t,n);if(s){const{toolInstance:i,annotationEngine:a}=s;return l(o({},t),{toolInstance:i,annotationEngine:a})}return o({},t)}case r.SET_TOOL:{const n=(et=e.payload)==null?void 0:et.instance;return n?l(o({},t),{toolInstance:n}):o({},t)}case r.UPDATE_ON_SUBMIT:return l(o({},t),{onSubmit:e.payload.onSubmit});case r.UPDATE_ON_SAVE:return l(o({},t),{onSave:e.payload.onSave});case r.UPDATE_ON_PAGE_CHANGE:return l(o({},t),{onPageChange:e.payload.onPageChange});case r.SET_PREDICT_RESULT:return l(o({},t),{predictionResult:e.payload.result});case r.SET_PREDICT_RESULT_VISIBLE:return l(o({},t),{predictionResultVisible:e.payload.visible});case r.UPDATE_ON_STEP_CHANGE:return l(o({},t),{onStepChange:e.payload.onStepChange});case r.UPDATE_GET_FILE_DATA:return l(o({},t),{getFileData:e.payload.getFileData});case r.UPDATE_PAGE_SIZE:return l(o({},t),{pageSize:e.payload.pageSize});case r.UPDATE_LOAD_FILE_LIST:return l(o({},t),{loadFileList:e.payload.loadFileList});case r.UPDATE_BEFORE_ROTATE:return l(o({},t),{beforeRotate:e.payload.beforeRotate});case r.UPDATE_PRE_DATA_PROCESS:return l(o({},t),{preDataProcess:e.payload.preDataProcess});case r.UPDATE_IMG_INDEX_BY_EXTERNAL:return l(o({},t),{getImgIndexByExternal:e.payload.getImgIndexByExternal});case r.SKIP_BEFORE_PAGE_TURNING:return l(o({},t),{skipBeforePageTurning:e.payload.skipBeforePageTurning});case r.SET_FILE_DATA:{const{fileData:n,index:s}=e.payload,{imgList:i}=t,a=[...i];return a[s]=o(o({},a[s]),n),l(o({},t),{imgList:a})}case r.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:s}=t;return s&&s()===!1||(nt=n==null?void 0:n.updateRotate)==null||nt.call(n),t}case r.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=t,s=(ot=n==null?void 0:n.valid)!=null?ot:!0;return mt.destroyAll(),mt.confirm({content:M.t(s?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!s)},okText:M.t("Confirm"),cancelText:M.t("Cancel")}),t}case r.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:s,imgList:i,step:a,stepList:p}=t;if(!n)return t;if(s===0||s>=i.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const c=i[s-1].result;if(!c)return t;const m=h.getCurrentStepInfo(a,p),_=(st=m==null?void 0:m.step)!=null?st:a,I=(lt=n==null?void 0:n.valid)!=null?lt:!0,g=Y.copyResultChange({copyResult:c,step:_,currentResult:(it=i[s].result)!=null?it:"",preMappingImgList:(rt=i[s-1].mappingImgList)!=null?rt:[],mappingImgList:(ut=i[s].mappingImgList)!=null?ut:[],valid:I});i[s]=l(o({},i[s]),{result:g});const D=j(g)[`step_${a}`],v=(D==null?void 0:D.result)||[];return n==null||n.setResult(v),n==null||n.history.pushHistory(v),(at=n==null?void 0:n.asyncData)==null||at.call(n,i[s]),l(o({},t),{imgList:[...i]})}case r.SET_STEP:{const{stepList:n,annotationEngine:s}=t,{toStep:i}=e.payload;if(s){const a=b(n,i);return s==null||s.setToolName(a.tool,a.config),l(o({},t),{step:i,toolInstance:s==null?void 0:s.toolInstance})}return l(o({},t),{step:i})}case r.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=e.payload;return l(o({},t),{loadPCDFileLoading:!!n})}case r.SET_LOADING:{const{loading:n}=e.payload;return l(o({},t),{loading:!!n})}case r.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=e.payload;return l(o({},t),{pointCloudLoading:!!n})}case r.SET_CHECK_MODE:{const{checkMode:n}=e.payload;return l(o({},t),{checkMode:!!n})}case r.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=e.payload;return l(o({},t),{highlightAttribute:n})}case r.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:s,rangeIndex:i,imgList:a}=e.payload,{imgIndex:p,onSubmit:c}=t,m=[],_=a.map((I,g)=>{if(_t.isInRange(g,i)){const T=l(o({},I),{result:It.batchUpdateTrackID({id:n,newID:s,result:I.result})});return m.push({imgIndex:g,newInfo:T}),T}return I});return c&&c([_[p]],W.BatchUpdateTrackID,p,_,{updateImgList:m}),l(o({},t),{imgList:_})}case r.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const n=e,{id:s,newData:i,rangeIndex:a,imgList:p}=n.payload,{imgIndex:c,onSubmit:m}=t,_=[],I=p.map((g,T)=>{if(_t.isInRange(T,a)){const D=l(o({},g),{result:It.batchUpdateResultByTrackID({id:s,newData:i,result:g.result})});return _.push({imgIndex:T,newInfo:D}),D}return g});return m&&m([I[c]],W.BatchUpdateTrackID,c,I,{updateImgList:_}),l(o({},t),{imgList:I})}case r.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:s,stepList:i,step:a,predictionResult:p}=t,c={};p.forEach(g=>{const{index:T}=g;c[T]=Tt.pick(g,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const m=`step_${a}`,_=[],I=s.map((g,T)=>{if(c[T]){const D=g.result==="{}"?j(J("",{step:a,stepList:i},{rect:[]},{})):j(g.result);D[m].result.push(c[T]);const v=l(o({},g),{result:JSON.stringify(D)});return _.push({imgIndex:T,newInfo:v}),v}return g});return n==null||n(I,W.BatchUpdateImgList,-1,I,{updateImgList:_}),l(o({},t),{imgList:I})}case r.CHANGE_PAGE_CHECK:{const{toolInstance:n,step:s,stepList:i}=t;if(!n)return t;const[a]=(ct=n==null?void 0:n.exportData())!=null?ct:[],p=b(i,s),c=pt.jsonParser(p.config),m=a.some(_=>(_==null?void 0:_.result)&&Object.keys(_.result).length>0);return l(o({},t),{confirmPageTurning:c.showConfirm&&!m})}default:return t}};export{Mt as LoadFileAndFileData,Wt as annotationReducer,Kt as composeResultByToolInstance,b as getStepConfig,jt as getTotalPage};
|
|
1
|
+
import{getFormatSize as ht}from"../../components/customResizeHook/index.js";import{ESubmitType as W}from"../../constant/index.js";import Ot from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as r}from"../Actions.js";import{jsonParser as j,resolveFileItemValid as bt}from"../../utils/index.js";import Y from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as gt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as _t,composeResult as J}from"../../utils/data.js";import h from"../../utils/StepUtils.js";import q from"../../utils/ToolUtils.js";import{MathUtils as It,CommonToolUtils as Nt,AnnotationEngine as Ut,ImgUtils as Bt}from"@labelbee/lb-annotation";import{PointCloudUtils as mt,i18n as M}from"@labelbee/lb-utils";import{Modal as ft}from"antd";import{message as Tt}from"antd/es";import Lt from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as O}from"../../data/enums/ToolType.js";var xt=Object.defineProperty,wt=Object.defineProperties,Ft=Object.getOwnPropertyDescriptors,Et=Object.getOwnPropertySymbols,jt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,At=(t,n,u)=>n in t?xt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[n]=u,o=(t,n)=>{for(var u in n||(n={}))jt.call(n,u)&&At(t,u,n[u]);if(Et)for(var u of Et(n))Gt.call(n,u)&&At(t,u,n[u]);return t},s=(t,n)=>wt(t,Ft(n)),St=(t,n,u)=>new Promise((A,d)=>{var S=f=>{try{E(u.next(f))}catch(y){d(y)}},L=f=>{try{E(u.throw(f))}catch(y){d(y)}},E=f=>f.done?A(f.value):Promise.resolve(f.value).then(S,L);E((u=u.apply(t,n)).next())});const b=(t,n)=>t.find(u=>u.step===n),Dt={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:"",confirmPageTurning:!1},Mt=t=>{const{imgList:n,imgPageSize:u}=t;return Math.ceil(n.length/u)},vt=(t,n)=>t.reduce((u,A)=>{if(A){const d=A.result;if(j(d)[`step_${n}`])return u+1}return u},0)/t.length,Vt=(t,n)=>{const{step:u,stepList:A}=t,d=h.getCurrentStepInfo(u,A),S=gt.jsonParser(d.config);if(q.isVideoTool(d==null?void 0:d.tool)||q.isAudioTool(d==null?void 0:d.tool)||q.isPointCloudTool(d==null?void 0:d.tool)||[O.LLM,O.NLP,O.LLMMultiWheel].includes(d==null?void 0:d.tool))return;const L=document.getElementById("toolContainer");if(!L)throw"Not exist dom named id-toolContainer";const E=ht({width:window.innerWidth,height:window.innerHeight}),f=new Ut({container:L,toolName:d.tool,size:E,imgNode:n,config:S,style:JSON.parse(Ot)});return{toolInstance:f==null?void 0:f.toolInstance,annotationEngine:f}},kt=(t,n)=>(u,A)=>St(void 0,null,function*(){var d,S;const{stepList:L,step:E}=A().annotation,f=h.currentToolIsVideo(E,L),y=h.currentToolIsPointCloud(E,L),N=[O.LLM,O.LLMMultiWheel].includes((d=h.getCurrentStepInfo(E,L))==null?void 0:d.tool),U=((S=h.getCurrentStepInfo(E,L))==null?void 0:S.tool)===O.NLP,B=h.currentToolIsAudio(E,L);if($(u,!0),yield u(Ht(t)),f){u(zt(t));return}if(y||N||B||U){u(Kt(t));return}u(Wt(t,n))}),Ht=t=>(n,u)=>St(void 0,null,function*(){const{getFileData:A,imgList:d}=u().annotation;if(A){const S=yield A(d[t],t);n({type:r.SET_FILE_DATA,payload:{fileData:S,index:t}})}}),zt=t=>n=>{n({type:r.LOAD_FILE_DATA,payload:{nextIndex:t}})},Kt=t=>n=>{$(n,!1),n({type:r.LOAD_FILE_DATA,payload:{nextIndex:t}})},Wt=(t,n)=>(u,A)=>{var d;const{toolInstance:S,imgList:L}=A().annotation,E=(d=L==null?void 0:L[t])==null?void 0:d.url;Bt.load(E).then(f=>{$(u,!1),u({type:r.LOAD_FILE_DATA,payload:{imgNode:f,nextIndex:t,nextBasicIndex:n}})}).catch(()=>{$(u,!1),S==null||S.setErrorImg(),u({type:r.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:n}})})},$t=({toolInstance:t,imgList:n,imgIndex:u,stepList:A,step:d=1})=>{var S,L,E,f;const y=((S=n[u])==null?void 0:S.result)||"",[N,U,B]=(L=t==null?void 0:t.exportData())!=null?L:[],V=(f=(E=t==null?void 0:t.exportCustomData)==null?void 0:E.call(t))!=null?f:{},k=_t(y,U),H=J(k,{step:d,stepList:A},{rect:N},V);return n.map((G,z)=>z===u?o(s(o({},G),{result:H}),B):o({},G))},Xt=(t=o({},Dt),n)=>{var u,A,d,S,L,E,f,y,N,U,B,V,k,H,G,z,Z,Q,tt,et,nt,ot,lt,st,it,rt,ut,at,ct,dt;switch(n.type){case r.INIT_ALL_STATE:return o(o({},t),Dt);case r.UPDATE_TOOL_INSTANCE:return s(o({},t),{toolInstance:n.payload.toolInstance});case r.UPDATE_IMG_LIST:return s(o({},t),{imgList:n.payload.imgList});case r.CALC_STEP_PROGRESS:{const{imgList:e,step:l}=t,i=vt(e,l);return s(o({},t),{stepProgress:i})}case r.SUBMIT_FILE_DATA:{const{imgList:e,imgIndex:l,step:i,stepList:a,toolInstance:p,onSubmit:c,resultList:I}=t;if(!p||!e[l])return t;const _=((u=e[l])==null?void 0:u.result)||"",[,m,g]=(A=p==null?void 0:p.exportData())!=null?A:[],T=(S=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?S:{},D=_t(_,m),v=J(D,{step:i,stepList:a},{rect:I},T),R=t.imgList.map((C,P)=>{if(P===l){const w=Y.dataCorrection(v,_,i,a);return o(s(o({},C),{result:w}),g)}return C});if(((L=n.payload)==null?void 0:L.submitType)===W.SyncImgList)return s(o({},t),{imgList:R});const x=vt(R,i);return s(o({},t),{stepProgress:x,imgList:R})}case r.SAVE_RESULT:{const{imgList:e,imgIndex:l,onSave:i}=t;return i==null||i(e[l],l,e),o({},t)}case r.SUBMIT_RESULT:{const{imgList:e,basicIndex:l,resultList:i,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(E=a==null?void 0:a.exportData())!=null?E:[];let I=c;if((p==null?void 0:p.length)>0){const _=(f=p[l])==null?void 0:f.id,m=c.map(g=>s(o({},g),{sourceID:_}));I=Lt.cloneDeep(i).filter(g=>g.sourceID!==_),I.push(...m)}return s(o({},t),{resultList:I,imgList:e})}case r.SET_BASIC_INDEX:{const{toolInstance:e,step:l,imgList:i,imgIndex:a,stepList:p,annotationEngine:c,resultList:I,basicResultList:_}=t;if(!e||!c)return t;const m=n.payload.basicIndex,g=(y=_[m])==null?void 0:y.id,T=j((N=i[a])==null?void 0:N.result),D=(I||[]).filter(w=>w.sourceID===g),v=b(p,l),{dataSourceStep:R,tool:x}=v,C=b(p,R);let P=[];return R&&x&&(P=(U=T[`step_${R}`])==null?void 0:U.result,(P==null?void 0:P.length)>0?(c==null||c.setBasicInfo(C.tool,P[m]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),Tt.info(M.t("NoDependency")))),e==null||e.setResult(D),e==null||e.history.initRecord(D,!0),s(o({},t),{basicIndex:m})}case r.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:e}=n.payload;return s(o({},t),{triggerEventAfterIndexChanged:!!e})}case r.LOAD_FILE_DATA:{const{imgList:e,step:l,toolInstance:i,annotationEngine:a,stepList:p}=t;if(!i)return s(o({},t),{imgIndex:n.payload.nextIndex});const c=h.getCurrentStepInfo(l,p),{nextIndex:I,imgNode:_,nextBasicIndex:m,imgError:g}=n.payload,T=m!=null?m:0,D=j((B=e[I])==null?void 0:B.result),v=D[`step_${c.step}`],R=!v,x={rotate:(V=D.rotate)!=null?V:0,valid:bt((k=e[I])==null?void 0:k.result,(H=e[I])==null?void 0:H.preResult)};_&&g!==!0?a==null||a.setImgNode(_,x):i==null||i.setValid(x.valid);const C=b(p,c.step),{dataSourceStep:P,tool:w}=C,pt=b(p,P),X=P&&w,F=(z=(G=D[`step_${P}`])==null?void 0:G.result)!=null?z:[],K=Y.getInitialResultList(v==null?void 0:v.result,i,C,F,R);a==null||a.launchOperation();const yt=[O.Cuboid,O.ScribbleTool].includes(w);if(X&&((F==null?void 0:F.length)>0?a==null||a.setBasicInfo(pt.tool,F[T]):(a==null||a.setBasicInfo(pt.tool),a==null||a.forbidOperation(),Tt.info(M.t("NoDependency")))),c.tool!=="check"&&(yt||X)){const Pt=(Q=(Z=F[T])==null?void 0:Z.id)!=null?Q:"",Rt=X?K.filter(Ct=>Nt.isSameSourceID(Ct.sourceID,Pt)):K;(tt=i==null?void 0:i.history)==null||tt.initRecord(K,!0),i==null||i.setResult(Rt)}return s(o({},t),{imgIndex:I,basicIndex:T,basicResultList:F,resultList:K})}case r.UPDATE_ANNOTATION_CONFIG:return s(o({},t),{config:(et=n.payload.config)!=null?et:"{}"});case r.SET_TASK_STEP_LIST:{const{stepList:e}=n.payload;return s(o({},t),{stepList:e})}case r.SET_TASK_CONFIG:{const{stepList:e,step:l}=n.payload;return s(o({},t),{stepList:e,step:l})}case r.INIT_TOOL:{const{imgNode:e}=t,l=Vt(t,e);if(l){const{toolInstance:i,annotationEngine:a}=l;return s(o({},t),{toolInstance:i,annotationEngine:a})}return o({},t)}case r.SET_TOOL:{const e=(nt=n.payload)==null?void 0:nt.instance;return e?s(o({},t),{toolInstance:e}):o({},t)}case r.UPDATE_ON_SUBMIT:return s(o({},t),{onSubmit:n.payload.onSubmit});case r.UPDATE_ON_SAVE:return s(o({},t),{onSave:n.payload.onSave});case r.UPDATE_ON_PAGE_CHANGE:return s(o({},t),{onPageChange:n.payload.onPageChange});case r.SET_PREDICT_RESULT:return s(o({},t),{predictionResult:n.payload.result});case r.SET_PREDICT_RESULT_VISIBLE:return s(o({},t),{predictionResultVisible:n.payload.visible});case r.UPDATE_ON_STEP_CHANGE:return s(o({},t),{onStepChange:n.payload.onStepChange});case r.UPDATE_GET_FILE_DATA:return s(o({},t),{getFileData:n.payload.getFileData});case r.UPDATE_PAGE_SIZE:return s(o({},t),{pageSize:n.payload.pageSize});case r.UPDATE_LOAD_FILE_LIST:return s(o({},t),{loadFileList:n.payload.loadFileList});case r.UPDATE_BEFORE_ROTATE:return s(o({},t),{beforeRotate:n.payload.beforeRotate});case r.UPDATE_PRE_DATA_PROCESS:return s(o({},t),{preDataProcess:n.payload.preDataProcess});case r.UPDATE_IMG_INDEX_BY_EXTERNAL:return s(o({},t),{getImgIndexByExternal:n.payload.getImgIndexByExternal});case r.SKIP_BEFORE_PAGE_TURNING:return s(o({},t),{skipBeforePageTurning:n.payload.skipBeforePageTurning});case r.SET_FILE_DATA:{const{fileData:e,index:l}=n.payload,{imgList:i}=t,a=[...i];return a[l]=o(o({},a[l]),e),s(o({},t),{imgList:a})}case r.UPDATE_ROTATE:{const{toolInstance:e,beforeRotate:l}=t;return l&&l()===!1||(ot=e==null?void 0:e.updateRotate)==null||ot.call(e),t}case r.UPDATE_ANNOTATION_VALID:{const{toolInstance:e}=t,l=(lt=e==null?void 0:e.valid)!=null?lt:!0;return ft.destroyAll(),ft.confirm({content:M.t(l?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{e==null||e.setValid(!l)},okText:M.t("Confirm"),cancelText:M.t("Cancel")}),t}case r.COPY_BACKWARD_RESULT:{const{toolInstance:e,imgIndex:l,imgList:i,step:a,stepList:p}=t;if(!e)return t;if(l===0||l>=i.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const c=i[l-1].result;if(!c)return t;const I=h.getCurrentStepInfo(a,p),_=(st=I==null?void 0:I.step)!=null?st:a,m=(it=e==null?void 0:e.valid)!=null?it:!0,g=Y.copyResultChange({copyResult:c,step:_,currentResult:(rt=i[l].result)!=null?rt:"",preMappingImgList:(ut=i[l-1].mappingImgList)!=null?ut:[],mappingImgList:(at=i[l].mappingImgList)!=null?at:[],valid:m});i[l]=s(o({},i[l]),{result:g});const D=j(g)[`step_${a}`],v=(D==null?void 0:D.result)||[];return e==null||e.setResult(v),e==null||e.history.pushHistory(v),(ct=e==null?void 0:e.asyncData)==null||ct.call(e,i[l]),s(o({},t),{imgList:[...i]})}case r.SET_STEP:{const{stepList:e,annotationEngine:l}=t,{toStep:i}=n.payload;if(l){const a=b(e,i);return l==null||l.setToolName(a.tool,a.config),s(o({},t),{step:i,toolInstance:l==null?void 0:l.toolInstance})}return s(o({},t),{step:i})}case r.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:e}=n.payload;return s(o({},t),{loadPCDFileLoading:!!e})}case r.SET_LOADING:{const{loading:e}=n.payload;return s(o({},t),{loading:!!e})}case r.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:e}=n.payload;return s(o({},t),{pointCloudLoading:!!e})}case r.SET_CHECK_MODE:{const{checkMode:e}=n.payload;return s(o({},t),{checkMode:!!e})}case r.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:e}=n.payload;return s(o({},t),{highlightAttribute:e})}case r.BATCH_UPDATE_TRACK_ID:{const{id:e,newID:l,rangeIndex:i,imgList:a}=n.payload,{imgIndex:p,onSubmit:c}=t,I=[],_=a.map((m,g)=>{if(It.isInRange(g,i)){const T=s(o({},m),{result:mt.batchUpdateTrackID({id:e,newID:l,result:m.result})});return I.push({imgIndex:g,newInfo:T}),T}return m});return c&&c([_[p]],W.BatchUpdateTrackID,p,_,{updateImgList:I}),s(o({},t),{imgList:_})}case r.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const e=n,{id:l,newData:i,rangeIndex:a,imgList:p}=e.payload,{imgIndex:c,onSubmit:I}=t,_=[],m=p.map((g,T)=>{if(It.isInRange(T,a)){const D=s(o({},g),{result:mt.batchUpdateResultByTrackID({id:l,newData:i,result:g.result})});return _.push({imgIndex:T,newInfo:D}),D}return g});return I&&I([m[c]],W.BatchUpdateTrackID,c,m,{updateImgList:_}),s(o({},t),{imgList:m})}case r.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:e,imgList:l,stepList:i,step:a,predictionResult:p}=t,c={};p.forEach(g=>{const{index:T}=g;c[T]=Lt.pick(g,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const I=`step_${a}`,_=[],m=l.map((g,T)=>{if(c[T]){const D=g.result==="{}"?j(J("",{step:a,stepList:i},{rect:[]},{})):j(g.result);D[I].result.push(c[T]);const v=s(o({},g),{result:JSON.stringify(D)});return _.push({imgIndex:T,newInfo:v}),v}return g});return e==null||e(m,W.BatchUpdateImgList,-1,m,{updateImgList:_}),s(o({},t),{imgList:m})}case r.CHANGE_PAGE_CHECK:{const{toolInstance:e,step:l,stepList:i}=t;if(!e)return t;const[a]=(dt=e==null?void 0:e.exportData())!=null?dt:[],p=b(i,l),c=gt.jsonParser(p.config),I=a.some(_=>(_==null?void 0:_.result)&&Object.keys(_.result).length>0);return s(o({},t),{confirmPageTurning:c.showConfirm&&!I})}default:return t}};export{kt as LoadFileAndFileData,Xt as annotationReducer,$t as composeResultByToolInstance,b as getStepConfig,Mt as getTotalPage};
|
package/es/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import f from"lodash";import{pointCloudLidar2image as
|
|
1
|
+
import f from"lodash";import{pointCloudLidar2image as _}from"@labelbee/lb-annotation";var v=Object.defineProperty,x=Object.defineProperties,O=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,b=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,w=(e,t)=>{for(var n in t||(t={}))b.call(t,n)&&h(e,n,t[n]);if(g)for(var n of g(t))P.call(t,n)&&h(e,n,t[n]);return e},I=(e,t)=>x(e,O(t));const p=(e,t={})=>{try{return typeof e=="string"?JSON.parse(e):f.isObject(e)?e:t}catch(n){return t}},j=(e,t)=>{var n,r;const o=p(e),i=p(t);return(r=(n=o==null?void 0:o.valid)!=null?n:i==null?void 0:i.valid)!=null?r:!0},R=e=>{if(Array.isArray(e))return e.filter(t=>t).join(" ");if(f.isObject(e)){const t=[];return Object.keys(e).forEach(n=>{e[n]&&t.push(n)}),t.join(" ")}return""},m=e=>{let t=Infinity,n=Infinity,r=-Infinity,o=-Infinity;for(const i of e)t=Math.min(t,i.x),n=Math.min(n,i.y),r=Math.max(r,i.x),o=Math.max(o,i.y);return{x:t,y:n,width:r-t,height:o-n}},d=(()=>{const e=(t,n)=>{const r=Math.max(t.x,n.x),o=Math.max(t.y,n.y),i=Math.min(t.x+t.width,n.x+n.width),l=Math.min(t.y+t.height,n.y+n.height),s=i-r,a=l-o;return s>=0&&a>=0?{x:r,y:o,width:s,height:a}:null};return(t,n,r)=>{if(r[n]){const o=r[n].width,i=r[n].height;return e(t,{x:0,y:0,width:o,height:i})!==null}return!1}})(),y=e=>{var t;const{pointCloudBox:n,mappingData:r,imageSizes:o}=e,{transferViewData:i}=(t=_(n,r.calib))!=null?t:{};if(!i)return;const l=i.reduce((c,u)=>u.type==="line"?[...c,...u.pointList]:c,[]),s=I(w({},m(l)),{imageName:r.path});if(d(s,r.path,o))return s},M=(e,t)=>{var n;const{pointCloudBox:r,mappingImgList:o,imageSizes:i}=e,s=o.map(a=>y({pointCloudBox:r,mappingData:a,imageSizes:i})).filter(a=>a!==void 0);if(s.length>0){const a=(n=t==null?void 0:t.prepareRectsFn)!=null?n:void 0,c=a?a(s,r):s;c.length>0&&Object.assign(r,{rects:c})}};export{R as classnames,M as generatePointCloudBoxRects,m as getBoundingRect,y as getRectPointCloudBox,d as isBoundingRectInImage,p as jsonParser,j as resolveFileItemValid};
|