@labelbee/lb-components 1.24.0-alpha.62 → 1.24.0-alpha.63
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/_virtual/2DViewWorker.js +1 -1
- package/dist/components/pointCloudView/PointCloudListener.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +2 -0
- package/dist/types/hooks/annotation.d.ts +3 -1
- package/dist/types/views/MainView/sidebar/GeneralOperation/ActionsConfirm.d.ts +3 -0
- package/dist/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
- package/dist/views/MainView/sidebar/GeneralOperation/index.js +1 -1
- package/es/_virtual/2DViewWorker.js +1 -1
- package/es/components/pointCloudView/PointCloudListener.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
- package/es/views/MainView/sidebar/GeneralOperation/index.js +1 -1
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),useUpdatePointCloudColor=require("./hooks/useUpdatePointCloudColor.js"),reactI18next=require("react-i18next"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(a,r,
|
|
1
|
+
"use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),useUpdatePointCloudColor=require("./hooks/useUpdatePointCloudColor.js"),reactI18next=require("react-i18next"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(a,r,n)=>r in a?__defProp(a,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[r]=n,__spreadValues=(a,r)=>{for(var n in r||(r={}))__hasOwnProp.call(r,n)&&__defNormalProp(a,n,r[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(r))__propIsEnum.call(r,n)&&__defNormalProp(a,n,r[n]);return a},__spreadProps=(a,r)=>__defProps(a,__getOwnPropDescs(r)),__async=(a,r,n)=>new Promise((h,d)=>{var i=e=>{try{p(n.next(e))}catch(v){d(v)}},y=e=>{try{p(n.throw(e))}catch(v){d(v)}},p=e=>e.done?h(e.value):Promise.resolve(e.value).then(i,y);p((n=n.apply(a,r)).next())});const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:a,config:r,checkMode:n,configString:h,imgIndex:d,toolInstanceRef:i,setResourceLoading:y,isBatchSetValid:p})=>{const e=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:v,selectNextBox:E,selectPrevBox:L,updateSelectedBox:B,deleteSelectedPointCloudBoxAndPolygon:I}=useSingleBox.useSingleBox(),{selectedSphere:b,updatePointCloudSphere:q}=useSphere.useSphere(),{clearAllResult:m,updatePointCloudPattern:A}=useStatus.useStatus(),{copySelectedBoxes:O,pasteSelectedBoxes:T,copiedBoxes:J}=useBoxes.useBoxes({config:r,currentData:a}),{updateRotate:f}=useRotate.useRotate({currentData:a}),{updateRotateEdge:j}=useRotateEdge.useRotateEdge({currentData:a}),{updatePointCloudData:w,restorePreResult:S,topViewSelectedChanged:D}=usePointCloudViews.usePointCloudViews({setResourceLoading:y}),{redo:g,undo:x,pushHistoryWithList:H,pushHistoryUnderUpdatePolygon:N,pushHistoryUnderUpdateLine:R}=useHistory.useHistory(),{syncThreeViewsAttribute:k}=useAttribute.useAttribute(),{syncAllViewsConfig:K,reRenderTopViewRange:U,reRenderTopViewTipScopeList:z}=useConfig.useConfig(),{selectedPolygon:V}=usePolygon.usePolygon(),{selectedLine:_}=useLine.useLine(),{t:P}=reactI18next.useTranslation(),{updatePointCloudColor:F}=useUpdatePointCloudColor.useUpdatePointCloudColor(y,r),M=ahooks.useLatest(a),C=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},G=(t,o)=>{const{topViewInstance:s,mainViewInstance:u}=e;if(!s)return;const{pointCloud2dOperation:l}=s;switch(t){case"q":{f(e.rectRotateSensitivity);break}case"e":f(-Number(e.rectRotateSensitivity));break;case"g":j(-90);break;case"u":{const c=l.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;A(c);const $={[lbAnnotation.EToolName.Polygon]:P("PolygonPattern"),[lbAnnotation.EToolName.Rect]:P("RectPattern")};antd.message.success(P("ChangePatternMsg",{pattern:$[c]})),l.clearActiveStatus(),l.clearDrawingStatus()}break;case"+":u==null||u.updatePointSize({zoomIn:!0});break;case"-":u==null||u.updatePointSize({zoomIn:!1});break;case"v":p?(antd.Modal.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){L();break}E(),o.preventDefault();break;case"f":v();break;case"arrowup":C({y:-1});break;case"arrowdown":C({y:1});break;case"arrowleft":C({x:-1});break;case"arrowright":C({x:1});break;case"delete":I(M.current);break}},W=(t,o)=>{switch(t){case"c":O();break;case"v":T();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?g():x();break}}},Y=ahooks.useLatest(t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t)||n===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){W(o,t);return}G(o,t)});return React.useEffect(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(l=>Y.current(l))},[e,e.topViewInstance,e.windowKeydownListenerHook]),React.useEffect(()=>{K(r)},[h]),React.useEffect(()=>{(r==null?void 0:r.radius)&&U(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{(r==null?void 0:r.tipScopeList)&&z(r==null?void 0:r.tipScopeList)},[r==null?void 0:r.tipScopeList]),React.useEffect(()=>{w==null||w()},[d,e.mainViewInstance]),React.useEffect(()=>{e.setHideAttributes([])},[d]),React.useEffect(()=>{i.current.setAttrChangeTrigger=t=>{var o;(o=e.topViewInstance)==null||o.toolInstance.setAttrChangeTrigger(t)},i.current.setDefaultAttribute=t=>{var o;if(k(t),F(t),V&&N(__spreadProps(__spreadValues({},V),{attribute:t})),_&&R(__spreadProps(__spreadValues({},_),{attribute:t})),b){const s=q(__spreadProps(__spreadValues({},b),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),D({newSelectedSphere:b,newSphereList:s}))}},i.current.setSubAttribute=(t,o)=>{var s;const u=e.selectedPointCloudBox;if(u){const l=(s=u==null?void 0:u.subAttribute)!=null?s:{};u.subAttribute=__spreadProps(__spreadValues({},l),{[t]:o}),B(u),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(u.id),e.mainViewInstance.render())}},i.current.clearResult=t=>__async(void 0,null,function*(){if(t==null?void 0:t.keepPreResult){try{(yield S==null?void 0:S())||antd.message.error(P("ClearKeepPreAnnotationFailed"))}catch(o){antd.message.error(P("ClearKeepPreAnnotationFailed"))}return}m==null||m()}),i.current.redo=()=>{g()},i.current.undo=()=>{x()},i.current.setValid=t=>{i.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t)})},i.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},i.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},i.current.asyncData=t=>{setTimeout(()=>{w==null||w(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),React.useEffect(()=>{i.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},i.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),React.useEffect(()=>{i.current.history={pushHistory:t=>{H({pointCloudBoxList:t})},initRecord:()=>{}}},[]),React.useEffect(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||n)return;const s=c=>{k(c)},u=c=>{antd.message.error(c)},l=c=>{antd.message.info(c)};return o.on("syncAttribute",s),o.on("messageError",u),o.on("messageInfo",l),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",u),o.unbind("messageInfo",l)}},[e.topViewInstance]),null};var PointCloudListener$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudListener);module.exports=PointCloudListener$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),_=require("lodash"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,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
|
+
"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");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,i,o)=>i in e?__defProp(e,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[i]=o,__spreadValues=(e,i)=>{for(var o in i||(i={}))__hasOwnProp.call(i,o)&&__defNormalProp(e,o,i[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(i))__propIsEnum.call(i,o)&&__defNormalProp(e,o,i[o]);return e},__spreadProps=(e,i)=>__defProps(e,__getOwnPropDescs(i)),__async=(e,i,o)=>new Promise((u,P)=>{var t=d=>{try{c(o.next(d))}catch(v){P(v)}},C=d=>{try{c(o.throw(d))}catch(v){P(v)}},c=d=>d.done?u(d.value):Promise.resolve(d.value).then(t,C);c((o=o.apply(e,i)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,i,o,u,P)=>{const{x:t,y:C}=lbUtils.PointCloudUtils.transferCanvas2World(e,i),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:t,y:C,z:c},id:e.id},v=u?__spreadValues(__spreadValues({},u),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return P&&Object.assign(v,P),v},topViewPolygon2PointCloud=(e,i,o,u,P,t)=>{let C=e.pointList.map(w=>lbUtils.PointCloudUtils.transferCanvas2World(w,i)),c=0,d=1,v={};if(o){const w=o.getSensesPointZAxisInPolygon(C,void 0,t);t&&w.fittedCoordinates.length>0&&(C=w.fittedCoordinates),c=(w.maxZ+w.minZ)/2,d=w.maxZ-w.minZ,v={count:w.zCount}}const[L,m,V]=C,R=lbAnnotation.MathUtils.getLineCenterPoint([L,V]),D=lbAnnotation.MathUtils.getLineLength(L,m),T=lbAnnotation.MathUtils.getLineLength(m,V),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);u&&(c=u.center.z,d=u.depth);const A={center:{x:R.x,y:R.y,z:c},width:t?T+INTELLIGENT_FIT_MARGIN:T,height:t?D+INTELLIGENT_FIT_MARGIN:D,depth:d,rotation:k,id:e.id},E=__spreadValues(u?__spreadValues(__spreadValues({},u),A):__spreadProps(__spreadValues({},A),{attribute:"",valid:!0}),v);P&&Object.assign(E,P);const j=C.map(w=>lbUtils.PointCloudUtils.transferWorld2Canvas(w,i));return{boxParams:E,newPointList:j}},sideViewPoint2PointCloud=(e,i,o)=>{const u={x:e.x-i.x,y:e.y-i.y};return __spreadProps(__spreadValues({},o),{center:{x:o.center.x-u.x,y:o.center.y,z:o.center.z-u.y}})},sideViewPolygon2PointCloud=(e,i,o,u)=>{const[P,t,C]=e.pointList,[c,d,v]=i.pointList,L=lbAnnotation.MathUtils.getLineCenterPoint([P,C]),m=lbAnnotation.MathUtils.getLineCenterPoint([c,v]),R={x:{x:L.x-m.x,y:L.y-m.y}.x,y:0,z:L.y-m.y},D=lbAnnotation.MathUtils.getLineLength(P,t),T=lbAnnotation.MathUtils.getLineLength(c,d),k=D-T,A=lbAnnotation.MathUtils.getLineLength(t,C),E=lbAnnotation.MathUtils.getLineLength(d,v),j=A-E,{newBoxParams:w}=u.getNewBoxBySideUpdate(R,j,k,o);return w},backViewPoint2PointCloud=(e,i,o)=>{const u={x:e.x-i.x,y:e.y-i.y};return __spreadProps(__spreadValues({},o),{center:{x:o.center.x,y:o.center.y-u.x,z:o.center.z-u.y}})},backViewPolygon2PointCloud=(e,i,o,u)=>{const[P,t,C]=e.pointList,[c,d,v]=i.pointList,L=lbAnnotation.MathUtils.getLineCenterPoint([P,C]),m=lbAnnotation.MathUtils.getLineCenterPoint([c,v]),R={x:{x:L.x-m.x,y:L.y-m.y}.x,y:0,z:L.y-m.y},D=lbAnnotation.MathUtils.getLineLength(P,t),T=lbAnnotation.MathUtils.getLineLength(c,d),k=D-T,A=lbAnnotation.MathUtils.getLineLength(t,C),E=lbAnnotation.MathUtils.getLineLength(d,v),j=A-E;let{newBoxParams:w}=u.getNewBoxByBackUpdate(R,j,k,o);return w},syncSideViewByPoint=(e,i,o,u,P)=>{var t;if(!o)return;const{toolInstance:C,pointCloudInstance:c}=o;c.loadPCDFile(u,(t=P==null?void 0:P.radius)!=null?t:DEFAULT_RADIUS);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(d);const{point2d:v,zoom:L}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=L,c.camera.updateProjectionMatrix(),c.render(),C.initPosition(),C.zoomChangeOnCenter(L),C.setResult([__spreadProps(__spreadValues(__spreadValues({},i),v),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),C.setSelectedID(i.id)},synchronizeSideView=(e,i,o,u)=>{if(!o)return;const{pointCloud2dOperation:P,pointCloudInstance:t}=o;t.loadPCDFileByBox(u,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:C}=t.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);t.setInitCameraPosition(C);const{polygon2d:c,zoom:d}=t.getBoxSidePolygon2DCoordinate(e);t.camera.zoom=d,t.camera.updateProjectionMatrix(),t.render(),P.initPosition(),P.zoomChangeOnCenter(d),P.setResultAndSelectedID([{id:i.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],i.id)},syncBackViewByPoint=(e,i,o,u,P)=>{var t;if(!o)return;const{toolInstance:C,pointCloudInstance:c}=o;c.loadPCDFile(u,(t=P==null?void 0:P.radius)!=null?t:DEFAULT_RADIUS);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(d);const{point2d:v,zoom:L}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=L,c.camera.updateProjectionMatrix(),c.render(),C.initPosition(),C.zoomChangeOnCenter(L),C.setResult([__spreadProps(__spreadValues(__spreadValues({},i),v),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),C.setSelectedID(i.id)},synchronizeBackView=(e,i,o,u)=>{if(!o)return;const{pointCloud2dOperation:P,pointCloudInstance:t}=o;t.loadPCDFileByBox(u,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:C}=t.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);t.setInitCameraPosition(C);const{polygon2d:c,zoom:d}=t.getBoxBackPolygon2DCoordinate(e);t.camera.zoom=d,t.camera.updateProjectionMatrix(),t.render(),P.initPosition(),P.zoomChangeOnCenter(d),P.setResultAndSelectedID([{id:i.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],i.id)},syncTopViewByPoint=(e,i,o,u)=>{if(!o||!u)return;u.generateSphere(e),u.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),u.render();const{toolInstance:P,pointCloudInstance:t}=o,{point2d:C}=t.getSphereTopPoint2DCoordinate(e),c=[...P.pointList].map(d=>d.id===i.id?__spreadProps(__spreadValues(__spreadValues({},i),C),{valid:e.valid,textAttribute:"",attribute:e.attribute}):d);P.setResult(c),P.setSelectedID(i.id)},synchronizeTopView=(e,i,o,u)=>{var P,t;if(!o||!u)return;u.generateBox(e),u.setHighlightColor(e.id),u.render();const{pointCloud2dOperation:C,pointCloudInstance:c}=o,{polygon2d:d}=c.getBoxTopPolygon2DCoordinate(e),v=[...C.polygonList],L=v.find(m=>m.id===i.id);L?(L.pointList=d,L.valid=(P=e.valid)!=null?P:!0):v.push({id:i.id,pointList:d,textAttribute:"",isRect:!0,valid:(t=e.valid)!=null?t:!0}),C.setResultAndSelectedID(v,i.id)},usePointCloudViews=e=>{const i=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:u,backViewInstance:P,mainViewInstance:t,addPointCloudBox:C,addPointCloudSphere:c,setSelectedIDs:d,selectedIDs:v,pointCloudBoxList:L,pointCloudSphereList:m,hideAttributes:V,setHighlight2DDataList:R,cuboidBoxIn2DView:D,imageSizes:T,history:k,linkageImageNameRectMap:A}=i,{addHistory:E,initHistory:j,pushHistoryUnderUpdatePolygon:w,pushHistoryWithList:ot}=useHistory.useHistory(),{selectedPolygon:it}=usePolygon.usePolygon(),{getPointCloudSphereByID:nt,updatePointCloudSphere:X,selectedSphere:q}=useSphere.useSphere(),{currentData:I,config:x}=ctx.useSelector(s=>{const{stepList:n,step:a,imgList:r,imgIndex:p}=s.annotation;return{currentData:r[p],config:index.jsonParser(StepUtils.getCurrentStepInfo(a,n).config)}}),N=ctx.useDispatch(),st=ahooks.useLatest(D),lt=ahooks.useLatest(A),rt=React.useCallback((s,n)=>{const a=lt.current,r=n.id;return s.filter(l=>{if(!l)return!1;const f=a.get(l.imageName);return f===void 0?!0:Boolean(f.get(r))})},[]),Z=s=>{const{enableAutoMap2DRect:n=!1}=x;if(!st.current||n){const{mappingImgList:a=[]}=I;index.generatePointCloudBoxRects({pointCloudBox:s,mappingImgList:a,imageSizes:T},{prepareRectsFn:rt})}},{selectedBox:U,updateSelectedBox:at,updateSelectedBoxes:G,getPointCloudByID:dt}=useSingleBox.useSingleBox({generateRects:Z}),Y=U==null?void 0:U.info;if(!o||!u||!P)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{},restorePreResult:()=>__async(void 0,null,function*(){return!1})};const{pointCloudInstance:J}=o,ut=s=>{t==null||t.generateSphere(s),t==null||t.controls.update(),t==null||t.render()},ct=({newPoint:s,size:n,zoom:a,trackConfigurable:r})=>{var p;const l={attribute:(p=o.toolInstance.defaultAttribute)!=null?p:""};r===!0&&Object.assign(l,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:m})});const f=topViewPoint2PointCloud(s,n,J,void 0,l);d(s.id);const g=c(f);F(PointCloudView.Top,s,f,a,g,x),E({newSphereParams:f})},pt=({polygon:s,size:n,imgList:a,trackConfigurable:r,zoom:p,intelligentFit:l})=>{var f,g,h;const b={attribute:(f=o.toolInstance.defaultAttribute)!=null?f:""};r===!0&&Object.assign(b,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:L,extraSphereList:m})}),o==null||o.toolInstance;const y=__spreadValues({},s);let{boxParams:B,newPointList:S}=topViewPolygon2PointCloud(y,n,J,void 0,b,l);B=N(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[B],stepConfig:x,action:"viewUpdateBox"}))[0],l&&(S==null?void 0:S.length)&&(y.pointList=S);const z=V.includes(y.attribute);Z(B);const M=C(B),Q=(g=i==null?void 0:i.polygonList)!=null?g:[];B.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((x==null?void 0:x.secondaryAttributeConfigurable)?(h=x==null?void 0:x.inputList)!=null?h:[]:[]),o==null||o.updatePolygonList(M!=null?M:[],Q,!1),z?d([]):(d(B.id),l&&synchronizeTopView(B,y,o,t)),E({newBoxParams:B})},Pt=s=>{const{boxID:n,imageName:a,width:r,height:p,x:l,y:f}=s,g=L.find(S=>S.id===n);if(!(g==null?void 0:g.rects)||!g.rects.find(S=>S.imageName===a))return;const b=g.rects.map(S=>S.imageName===a?__spreadProps(__spreadValues({},S),{width:r,height:p,x:l,y:f}):S),y=__spreadProps(__spreadValues({},g),{rects:b}),B=L.map(S=>S.id===n?y:S);return o==null||o.updatePolygonList(B!=null?B:[]),B},gt=s=>{const{boxID:n,imageName:a}=s,r=L.find(g=>g.id===n);if(!(r==null?void 0:r.rects))return;const p=r.rects.filter(g=>g.imageName!==a),l=__spreadProps(__spreadValues({},r),{rects:p}),f=L.map(g=>g.id===n?l:g);return o==null||o.updatePolygonList(f!=null?f:[]),f},Ct=({newSelectedBox:s,newPointCloudList:n,newSelectedSphere:a,newSphereList:r})=>{var p;const l=o==null?void 0:o.toolInstance;if(!(v.length===0||!l)){if(s||(U==null?void 0:U.info)){const f=s!=null?s:U==null?void 0:U.info;(p=l==null?void 0:l.selection)==null||p.setSelectedIDs(v[0]);const g=l.selectedPolygon;if(v.length===1&&f){H({omitView:PointCloudView.Top,polygon:g,boxParams:f,newPointCloudBoxList:n});return}}if((a||q)&&v.length===1){const f=a!=null?a:q;l.setSelectedID(v[0]);const g=l.selectedPoint;f&&F(PointCloudView.Top,g,f,void 0,r,x)}}},K=(s,n,a,r=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{if(Y){let p,l;switch(a){case PointCloudView.Back:p=backViewPolygon2PointCloud;break;case PointCloudView.Side:p=sideViewPolygon2PointCloud;break;default:p=sideViewPolygon2PointCloud;break}if(l=p(s,n,Y,u.pointCloudInstance),t){const{count:y}=t.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=__spreadProps(__spreadValues({},l),{count:y})}const g=N(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[l],stepConfig:x,action:"viewUpdateBox"}))[0],h=l.valid!==g.valid;l=g;const b=at(l);return l=b.find(y=>y.id===l.id),H({omitView:h?void 0:a,polygon:s,boxParams:l,newPointCloudBoxList:b},r),b}},$=(s,n,a)=>{if(q){let r,p;switch(a){case PointCloudView.Back:r=backViewPoint2PointCloud;break;case PointCloudView.Side:r=sideViewPoint2PointCloud;break;default:r=sideViewPoint2PointCloud;break}p=r(s,n,q);const l=X(p);return F(a,s,p,void 0,l,x),l}},ft=(s,n)=>{$(s,n,PointCloudView.Side)},Lt=(s,n)=>{$(s,n,PointCloudView.Back)},ht=(s,n)=>{K(s,n,PointCloudView.Side,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},vt=(s,n)=>{K(s,n,PointCloudView.Back,ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)},xt=(s,n)=>{const a=nt(s.id),r=topViewPoint2PointCloud(s,n,J,a),p=X(r);F(PointCloudView.Top,s,r,void 0,p,x)},yt=(s,n)=>{if(it){const r=__spreadValues({},s[0].newPolygon);r.pointList=r.pointList.map(p=>lbUtils.PointCloudUtils.transferCanvas2World(p,n)),w(r);return}let a=s.map(({newPolygon:r})=>{const p=dt(r.id),{boxParams:l}=topViewPolygon2PointCloud(r,n,o.pointCloudInstance,p);return l});if(a=N(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:a,stepConfig:x,action:"viewUpdateBox"})),a.length===1){const{newPolygon:r}=s[0],p=G(a);H({polygon:r,boxParams:a[0],newPointCloudBoxList:p},ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single)}else{const r=G(a);r&&i.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiMove,r)}},mt=s=>{var n,a,r,p,l;if(U){const f=Number(s.widthDefault),g=Number(s.depthDefault),h=Number(s.heightDefault),b=U==null?void 0:U.info.trackID,B=((n=o==null?void 0:o.toolInstance)==null?void 0:n.polygonList).find(W=>(W==null?void 0:W.trackID)===b),S={width:(r=(a=o==null?void 0:o.toolInstance)==null?void 0:a.basicImgInfo)==null?void 0:r.width,height:(l=(p=o==null?void 0:o.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:l.height},O=B.pointList.map(W=>lbUtils.PointCloudUtils.transferCanvas2World(W,S)),z=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(O,h,f),M=z[0],Q=z[2],tt=lbAnnotation.MathUtils.getLineCenterPoint([M,Q]),Bt=U.info.center.z-U.info.depth/2,et=__spreadProps(__spreadValues({},U.info),{center:{x:tt.x,y:tt.y,z:Bt+g/2},width:f,height:h,depth:g,valid:!0}),St=G([et]);H({omitView:PointCloudView["3D"],polygon:B,boxParams:et,newPointCloudBoxList:St})}},F=(s,n,a,r,p,l)=>__async(void 0,null,function*(){const f=I==null?void 0:I.url,g={[PointCloudView.Side]:()=>{syncSideViewByPoint(a,n,u,f,l)},[PointCloudView.Back]:()=>{P&&syncBackViewByPoint(a,n,P,f,l)},[PointCloudView.Top]:()=>{syncTopViewByPoint(a,n,o,t)}};Object.keys(g).forEach(h=>{h!==s&&g[h]()}),r&&(t==null||t.updateCameraZoom(r)),ut(a)}),H=(s,n=ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default)=>{const{omitView:a,polygon:r,boxParams:p,zoom:l,newPointCloudBoxList:f}=s,g=I==null?void 0:I.url;f&&i.syncAllViewPointCloudColor(n,f);const h={[PointCloudView.Side]:()=>{synchronizeSideView(p,r,u,g)},[PointCloudView.Back]:()=>{P&&synchronizeBackView(p,r,P,g)},[PointCloudView.Top]:()=>{synchronizeTopView(p,r,o,t)}};Object.keys(h).forEach(b=>{b!==a&&h[b]()}),l&&(t==null||t.updateCameraZoom(l))};return{topViewAddSphere:ct,topViewAddBox:pt,topViewSelectedChanged:Ct,topViewUpdatePoint:xt,sideViewUpdatePoint:ft,backViewUpdatePoint:Lt,topViewUpdateBox:yt,sideViewUpdateBox:ht,backViewUpdateBox:vt,syncPointCloudViews:H,syncPointCloudPoint:F,pointCloudBoxListUpdated:s=>{o.updatePolygonList(s),t==null||t.generateBoxes(s)},initPointCloud3d:s=>{if(!t)return;const n=lbUtils.PointCloudUtils.getDefaultOrthographicParams(s);t.initOrthographicCamera(n),t.initRenderer(),t.render()},updatePointCloudData:(...s)=>__async(void 0,[...s],function*(n=I){var a,r,p,l,f,g;if(!(n==null?void 0:n.url)||!t)return;R([]),actionCreators.SetAnnotationLoading(N,!0),actionCreators.SetLoadPCDFileLoading(N,!0),(a=e==null?void 0:e.setResourceLoading)==null||a.call(e,!0),yield t.loadPCDFile(n.url,(r=x==null?void 0:x.radius)!=null?r:DEFAULT_RADIUS,x==null?void 0:x.tipScopeList),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let h=[],b=[],y=[],B=[];t.updateTopCamera();const S=index.resolveFileItemValid(n.result,n.preResult);if(i.setPointCloudValid(S),(p=i.sideViewInstance)==null||p.clearAllData(),(l=i.backViewInstance)==null||l.clearAllData(),n.result){if(h=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),(h==null?void 0:h.length)>0&&n.isPreResult&&(x==null?void 0:x.lowerLimitPointsNumInBox)>0){h=yield t==null?void 0:t.filterPreResult(n.url,x,h);const O=index.jsonParser(n.result);O[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=h,n.result=JSON.stringify(O),i.setPointCloudResult(h)}y=lbUtils.PointCloudUtils.getPolygonListFromResultList(n.result),b=lbUtils.PointCloudUtils.getLineListFromResultList(n.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(n.result),o.updateData(n.url,n.result,{radius:(f=x==null?void 0:x.radius)!=null?f:DEFAULT_RADIUS}),t==null||t.generateBoxes(h),t==null||t.generateSpheres(B),yield i.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,h,[])}j({pointCloudBoxList:h,polygonList:y,lineList:b,pointCloudSphereList:B}),actionCreators.SetAnnotationLoading(N,!1),actionCreators.SetLoadPCDFileLoading(N,!1),(g=e==null?void 0:e.setResourceLoading)==null||g.call(e,!1)}),restorePreResult:()=>__async(void 0,null,function*(){var s,n,a,r,p,l;if(!(I==null?void 0:I.url)||!t)return!1;const f=(s=index.jsonParser(I.preResult))==null?void 0:s[lbUtils.POINT_CLOUD_DEFAULT_STEP];if(!f)return!1;const g=index.jsonParser(I.result||"{}");g[lbUtils.POINT_CLOUD_DEFAULT_STEP]=___default.default.cloneDeep(f);let h=JSON.stringify(g);const b=I.url;actionCreators.SetAnnotationLoading(N,!0),(n=e==null?void 0:e.setResourceLoading)==null||n.call(e,!0);try{R([]),d(void 0),t.clearAllBox(),t.clearAllSphere();let y=[],B=[],S=[],O=[];if(i.setPointCloudValid(index.resolveFileItemValid(h,I.preResult)),(a=i.sideViewInstance)==null||a.clearAllData(),(r=i.backViewInstance)==null||r.clearAllData(),y=lbUtils.PointCloudUtils.getBoxParamsFromResultList(h),(y==null?void 0:y.length)>0&&(x==null?void 0:x.lowerLimitPointsNumInBox)>0){y=yield t==null?void 0:t.filterPreResult(b,x,y);const M=index.jsonParser(h);M[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=y,h=JSON.stringify(M),i.setPointCloudResult(y)}S=lbUtils.PointCloudUtils.getPolygonListFromResultList(h),B=lbUtils.PointCloudUtils.getLineListFromResultList(h),O=lbUtils.PointCloudUtils.getSphereParamsFromResultList(h);const{rectList:z}=lbUtils.PointCloudUtils.parsePointCloudCurrentResult(h);return i.setPointCloudResult(y),i.setPolygonList(S),i.setLineList(B),i.setPointCloudSphereList(O),i.setRectList(z),o.updateData(b,h,{radius:(p=x==null?void 0:x.radius)!=null?p:DEFAULT_RADIUS}),t.generateBoxes(y),t.generateSpheres(O),yield i.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,y,[]),ot({pointCloudBoxList:y,polygonList:S,lineList:B,pointCloudSphereList:O}),!0}finally{actionCreators.SetAnnotationLoading(N,!1),(l=e==null?void 0:e.setResourceLoading)==null||l.call(e,!1)}}),updateViewsByDefaultSize:mt,generateRects:Z,update2DViewRect:Pt,remove2DViewRect:gt}},useSyncRectPositionDimensionToPointCloudList=()=>{const{pointCloudBoxList:e,rectList:i,setPointCloudResult:o}=React.useContext(PointCloudContext.PointCloudContext),u=ahooks.useLatest(e),P=ahooks.useLatest(i);return{syncToPointCloudBoxList:React.useCallback(()=>{const C=u.current,c=P.current;if(c.length===0)return null;const d=new Map,v=new Set;if(c.filter(L=>L.extId!==void 0).forEach(L=>{const m=L.extId,V=L.imageName,R=_.pick(L,["x","y","width","height"]);let D=d.get(m);D||(D=new Map,d.set(m,D)),D.set(V,R),v.add(m)}),d.size){const L=C.map(m=>{var V;const R=m.id;if(v.has(R)){const D=__spreadValues({},m);return(V=D.rects)==null||V.forEach(T=>{var k;const A=T.imageName;Object.assign(T,(k=d.get(R))==null?void 0:k.get(A))}),D}return m});return o(L),L}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;
|
|
@@ -76,6 +76,7 @@ export declare const usePointCloudViews: (params?: IUsePointCloudViewsParams) =>
|
|
|
76
76
|
topViewSelectedChanged: () => void;
|
|
77
77
|
sideViewUpdateBox: () => void;
|
|
78
78
|
backViewUpdateBox: () => void;
|
|
79
|
+
restorePreResult: () => Promise<boolean>;
|
|
79
80
|
topViewUpdatePoint?: undefined;
|
|
80
81
|
sideViewUpdatePoint?: undefined;
|
|
81
82
|
backViewUpdatePoint?: undefined;
|
|
@@ -121,6 +122,7 @@ export declare const usePointCloudViews: (params?: IUsePointCloudViewsParams) =>
|
|
|
121
122
|
pointCloudBoxListUpdated: (newBoxes: IPointCloudBox[]) => void;
|
|
122
123
|
initPointCloud3d: (size: ISize) => void;
|
|
123
124
|
updatePointCloudData: (newData?: any) => Promise<void>;
|
|
125
|
+
restorePreResult: () => Promise<boolean>;
|
|
124
126
|
updateViewsByDefaultSize: (defaultSize: IDefaultSize) => void;
|
|
125
127
|
generateRects: (boxParams: IPointCloudBox) => void;
|
|
126
128
|
update2DViewRect: (params: IBasicRect & {
|
|
@@ -5,7 +5,9 @@ export interface ICustomToolInstance {
|
|
|
5
5
|
exportData: () => [any, {}];
|
|
6
6
|
exportCustomData: () => {};
|
|
7
7
|
singleOn: (eventName: string, callback: (...args: any[]) => void) => void;
|
|
8
|
-
clearResult: (
|
|
8
|
+
clearResult: (options?: {
|
|
9
|
+
keepPreResult?: boolean;
|
|
10
|
+
}) => void | Promise<void>;
|
|
9
11
|
on: (eventName: string, callback: (...args: any[]) => void) => void;
|
|
10
12
|
unbind: () => void;
|
|
11
13
|
setResult: (result: any) => void;
|
|
@@ -9,6 +9,9 @@ export interface IOperationConfig {
|
|
|
9
9
|
forbidConfirm?: boolean;
|
|
10
10
|
forbidOperation?: boolean;
|
|
11
11
|
content?: React.ReactElement;
|
|
12
|
+
/** Explicit extra UI under Popconfirm title; only rendered when set (opt-in). */
|
|
13
|
+
confirmExtra?: React.ReactElement;
|
|
14
|
+
onConfirmVisibleChange?: (visible: boolean) => void;
|
|
12
15
|
}
|
|
13
16
|
declare const ActionsConfirm: React.FC<{
|
|
14
17
|
allOperation: IOperationConfig[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var React=require("react"),antd=require("antd"),reactI18next=require("react-i18next"),index=require("../../../../constant/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);const forbidStyle={color:"#CCCCCC"},PopconfirmTitle=({info:e})=>{const{t}=reactI18next.useTranslation()
|
|
1
|
+
"use strict";var React=require("react"),antd=require("antd"),reactI18next=require("react-i18next"),index=require("../../../../constant/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);const forbidStyle={color:"#CCCCCC"},PopconfirmTitle=({info:e})=>{const{t}=reactI18next.useTranslation(),l=e.key.startsWith("sure")?React__default.default.createElement("div",{key:e.key},`${t("ConfirmTo")}${e.name.slice(0)}\uFF1F`,(e==null?void 0:e.content)?e.content:""):React__default.default.createElement("span",null,e.name);return e.confirmExtra?React__default.default.createElement("div",null,l,e.confirmExtra):l},ActionIcon=({icon:e})=>typeof e=="string"?React__default.default.createElement("img",{width:23,height:25,src:e}):e,ShowIcon=({isHover:e,info:t})=>{const l=!!t.forbidOperation,a=t.key===e&&!l;let n={color:a?"#666fff":""};return l&&(n=forbidStyle),React__default.default.createElement("div",{style:{cursor:l?"not-allowed":"default"},onClick:()=>{var c;return(t==null?void 0:t.forbidConfirm)&&!l&&((c=t==null?void 0:t.onClick)==null?void 0:c.call(t))}},React__default.default.createElement("div",{className:"icon"},React__default.default.createElement(ActionIcon,{icon:a?t.hoverSvg:t.imgSvg})),React__default.default.createElement("div",{className:"toolName",style:n},t.name))},ActionsConfirm=({allOperation:e,setBatchSetValid:t,valid:l})=>{const a=React.useRef(null),[n,c]=React.useState(null),{t:u}=reactI18next.useTranslation(),s=Math.floor(24/e.length),i=r=>r.forbidConfirm?React__default.default.createElement(ShowIcon,{info:r,isHover:n}):t&&r.key==="setValidity"?t({valid:l,isHover:!!n,singleSetQuestionImg:r.onClick}):React__default.default.createElement(antd.Popconfirm,{title:React__default.default.createElement(PopconfirmTitle,{info:r}),placement:"topRight",okText:u("Confirm"),cancelText:u("Cancel"),getPopupContainer:()=>{var o;return(o=a.current)!=null?o:document.body},onConfirm:r.onClick,onVisibleChange:r.onConfirmVisibleChange,overlayClassName:`${index.prefix}-pop-confirm`},React__default.default.createElement("div",null,React__default.default.createElement(ShowIcon,{info:r,isHover:n})));return React__default.default.createElement("div",{className:"generalOperation",ref:a},e.map((r,o)=>React__default.default.createElement(antd.Col,{span:s,key:o,className:"generalOperation-col"},React__default.default.createElement("div",{key:r.key,className:"item",onMouseEnter:()=>{c(r.key)},onMouseLeave:()=>{c(null)}},i(r)))))};module.exports=ActionsConfirm;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),reactRedux=require("react-redux"),StepUtils=require("../../../../utils/StepUtils.js"),index=require("../../../../utils/index.js"),ActionsConfirm=require("./ActionsConfirm.js"),useOperationList=require("./useOperationList.js"),ctx=require("../../../../store/ctx.js"),unitAttribute=require("../../../../assets/annotation/pointCloudTool/unitAttribute.svg.js"),unitAttributeForbid=require("../../../../assets/annotation/pointCloudTool/unitAttributeForbid.svg.js"),unitAttributeHover=require("../../../../assets/annotation/pointCloudTool/unitAttributeHover.svg.js"),reactI18next=require("react-i18next"),index$1=require("../../../../components/pointCloudView/components/UnifyParamsModal/index.js"),useSingleBox=require("../../../../components/pointCloudView/hooks/useSingleBox.js"),reducer=require("../../../../store/annotation/reducer.js"),useStatus=require("../../../../components/pointCloudView/hooks/useStatus.js");function _interopDefaultLegacy(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),antd=require("antd"),reactRedux=require("react-redux"),StepUtils=require("../../../../utils/StepUtils.js"),index=require("../../../../utils/index.js"),ActionsConfirm=require("./ActionsConfirm.js"),useOperationList=require("./useOperationList.js"),ctx=require("../../../../store/ctx.js"),unitAttribute=require("../../../../assets/annotation/pointCloudTool/unitAttribute.svg.js"),unitAttributeForbid=require("../../../../assets/annotation/pointCloudTool/unitAttributeForbid.svg.js"),unitAttributeHover=require("../../../../assets/annotation/pointCloudTool/unitAttributeHover.svg.js"),reactI18next=require("react-i18next"),index$1=require("../../../../components/pointCloudView/components/UnifyParamsModal/index.js"),useSingleBox=require("../../../../components/pointCloudView/hooks/useSingleBox.js"),reducer=require("../../../../store/annotation/reducer.js"),useStatus=require("../../../../components/pointCloudView/hooks/useStatus.js"),lbUtils=require("@labelbee/lb-utils");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,o)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,__spreadValues=(e,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(e,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(e,o,t[o]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const mapStateToProps=e=>{var t,o;const n=StepUtils.getCurrentStepInfo((t=e.annotation)==null?void 0:t.step,(o=e.annotation)==null?void 0:o.stepList);return{toolInstance:e.annotation.toolInstance,stepInfo:n,imgList:e.annotation.imgList,imgIndex:e.annotation.imgIndex,stepList:e.annotation.stepList}},GeneralOperation=({toolInstance:e,stepInfo:t,hideValidity:o})=>{const n=useOperationList(e),i=index.jsonParser(t==null?void 0:t.config),a=[n.empty];return(t==null?void 0:t.dataSourceStep)===0&&!o&&a.push(n.setValidity),(i==null?void 0:i.copyBackwardResult)&&a.push(n.copyPrevious),React__default.default.createElement(ActionsConfirm,{allOperation:a})},PointCloudOperation=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(({toolInstance:e,stepInfo:t,imgList:o,stepList:n,imgIndex:i,setBatchSetValid:a})=>{const{t:v}=reactI18next.useTranslation(),{selectedBox:u}=useSingleBox.useSingleBox(),c=useOperationList(e),[_,f]=React.useState(!1),[b,x]=React.useState([]),[m,p]=React.useState(!1),{isPointCloudDetectionPattern:P,isPointCloudSegmentationPattern:O}=useStatus.useStatus(),g=index.jsonParser(t.config),s=o==null?void 0:o[i],C=React.useMemo(()=>{var r;const d=(r=index.jsonParser(s==null?void 0:s.preResult))==null?void 0:r[lbUtils.POINT_CLOUD_DEFAULT_STEP];return Boolean(d)},[s==null?void 0:s.preResult])&&P,S=__spreadProps(__spreadValues({},c.empty),{confirmExtra:C?React__default.default.createElement("div",{onClick:r=>r.stopPropagation(),style:{marginTop:8,textAlign:"left",width:"100%"}},React__default.default.createElement(antd.Checkbox,{checked:m,onChange:r=>p(r.target.checked),style:{marginLeft:0}},v("KeepPreAnnotation"))):void 0,onConfirmVisibleChange:r=>{r&&p(!1)},onClick:()=>{e.clearResult({keepPreResult:C&&m}),p(!1)}});let l=[c.copyPrevious,S,c.setValidity];if(P&&g.trackConfigurable===!0){const r=!u,d={name:v("UnifyParams"),key:"UnifyParams",imgSvg:r?unitAttributeForbid:unitAttribute,hoverSvg:unitAttributeHover,onClick:()=>{x(reducer.composeResultByToolInstance({toolInstance:e,imgList:o,imgIndex:i,stepList:n})),f(!0)},forbidConfirm:!0,forbidOperation:r};l.unshift(d)}const j=React.useCallback(()=>{f(!1)},[]),y=u==null?void 0:u.info;return O&&(l=l.filter(r=>!["setValidity","copyPrevious"].includes(r.key))),React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(ActionsConfirm,{allOperation:l,setBatchSetValid:a,valid:e==null?void 0:e.valid}),React__default.default.createElement(index$1,{id:y==null?void 0:y.trackID,visible:_,onCancel:j,config:g,imgList:b}))});var GeneralOperation$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(GeneralOperation);exports.PointCloudOperation=PointCloudOperation,exports.default=GeneralOperation$1;
|