@labelbee/lb-components 1.24.0-alpha.62 → 1.24.0-alpha.64
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/components/videoAnnotate/videoClipTool/components/annotatedList/index.js +1 -1
- package/dist/components/videoAnnotate/videoClipTool/index.js +2 -2
- package/dist/components/videoPlayer/index.js +1 -1
- package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +2 -0
- package/dist/types/components/videoAnnotate/videoClipTool/index.d.ts +1 -0
- package/dist/types/components/videoPlayer/index.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/components/videoAnnotate/videoClipTool/components/annotatedList/index.js +1 -1
- package/es/components/videoAnnotate/videoClipTool/index.js +2 -2
- package/es/components/videoPlayer/index.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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var audio=require("../../../../../utils/audio.js"),index$1=require("../../../../../utils/index.js"),icons=require("@ant-design/icons"),React=require("react"),constant=require("../../constant.js"),index=require("../timeSliceRange/index.js"),ToolTipForClip=require("../ToolTipForClip.js"),index$2=require("../videoTrack/index.js"),index_module=require("./index.module.scss.js"),utils=require("../../../../videoPlayer/utils.js"),ctx=require("../../../../../store/ctx.js"),reactRedux=require("react-redux"),reactI18next=require("react-i18next");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);const TimeSliceIcon=({type:e})=>e===constant.ETimeSliceType.Time?React__default.default.createElement(icons.EnvironmentFilled,null):React__default.default.createElement(icons.ScissorOutlined,{rotate:270}),EmptyVideoClipAnnotatedList=()=>{const{t:e}=reactI18next.useTranslation();return React__default.default.createElement("div",{className:index_module.noContent},React__default.default.createElement("div",null,e("NoClippedData")),React__default.default.createElement("div",null,React__default.default.createElement("span",{className:index_module.hotkey},"X"),e("ClipSlice")),React__default.default.createElement("div",null,React__default.default.createElement("span",{className:index_module.hotkey},"E"),e("TimeStamp")))},VideoClipAnnotatedListWrapper=({children:e,scrollRef:t})=>{const a=e.length===0;return React__default.default.createElement("div",{ref:t,className:index$1.classnames({[index_module.empty]:a,[index_module.timeSliceListContent]:!0})},a?React__default.default.createElement(EmptyVideoClipAnnotatedList,null):e)},VideoClipAnnotatedItem=({timeSliceProps:e,index:t,exportContext:a,onItemClick:r})=>{const{selectedID:c,attributeList:
|
|
1
|
+
"use strict";var audio=require("../../../../../utils/audio.js"),index$1=require("../../../../../utils/index.js"),icons=require("@ant-design/icons"),React=require("react"),constant=require("../../constant.js"),index=require("../timeSliceRange/index.js"),ToolTipForClip=require("../ToolTipForClip.js"),index$2=require("../videoTrack/index.js"),index_module=require("./index.module.scss.js"),utils=require("../../../../videoPlayer/utils.js"),ctx=require("../../../../../store/ctx.js"),reactRedux=require("react-redux"),reactI18next=require("react-i18next");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);const TimeSliceIcon=({type:e})=>e===constant.ETimeSliceType.Time?React__default.default.createElement(icons.EnvironmentFilled,null):React__default.default.createElement(icons.ScissorOutlined,{rotate:270}),EmptyVideoClipAnnotatedList=()=>{const{t:e}=reactI18next.useTranslation();return React__default.default.createElement("div",{className:index_module.noContent},React__default.default.createElement("div",null,e("NoClippedData")),React__default.default.createElement("div",null,React__default.default.createElement("span",{className:index_module.hotkey},"X"),e("ClipSlice")),React__default.default.createElement("div",null,React__default.default.createElement("span",{className:index_module.hotkey},"E"),e("TimeStamp")))},VideoClipAnnotatedListWrapper=({children:e,scrollRef:t})=>{const a=e.length===0;return React__default.default.createElement("div",{ref:t,className:index$1.classnames({[index_module.empty]:a,[index_module.timeSliceListContent]:!0})},a?React__default.default.createElement(EmptyVideoClipAnnotatedList,null):e)},VideoClipAnnotatedItem=({timeSliceProps:e,index:t,exportContext:a,onItemClick:r})=>{const{selectedID:c,attributeList:s,removeTimeSlice:d}=a;return React__default.default.createElement("div",{key:t,className:index$1.classnames({[index_module.timeSliceItem]:!0,[index_module.timeSliceItemActivated]:e.id===c}),onClick:()=>{r(e)}},React__default.default.createElement(ToolTipForClip,{slot:React__default.default.createElement("div",{className:index_module.timeSliceItemContent},React__default.default.createElement("div",{className:index_module.textOverflow},`${t+1}\u3001\u3010${constant.TIME_SLICE_TYPE[e.type]}\u3011 ${index$2.getDisplayContent(e,s)}`),React__default.default.createElement("div",{className:index$1.classnames({[index_module.textOverflow]:!0})},React__default.default.createElement(TimeSliceIcon,{type:e.type}),React__default.default.createElement("span",{style:{marginLeft:10}},`${audio.timeFormat(e.start,"ss:SS")} ${e.end&&e.type===constant.ETimeSliceType.Period?"~ "+audio.timeFormat(e.end,"ss:SS")+", "+utils.decimalReserved(e.end-e.start,2)+"s":""}`))),item:e,attributeList:s}),React__default.default.createElement(icons.CloseCircleFilled,{className:index_module.timeSliceItemDeleteIcon,onClick:i=>{i.stopPropagation(),d(e)}}))},VideoClipAnnotatedList=e=>{const{toolInstance:t}=e,{selectedID:a,result:r,videoPlayer:c,clipStatus:s,updateSelectedSliceTimeProperty:d,linkageConfigurable:i}=(t==null?void 0:t.exportContext)||{},[v,p]=React.useState(0),o=React.useRef(null),m=React.useRef(!1),{t:E}=reactI18next.useTranslation();React.useEffect(()=>(t&&t.singleOn("changeClipSidebar",l=>{p(n=>n+1)}),()=>{var l;(l=t==null?void 0:t.unbindAll)==null||l.call(t,"changeClipSidebar")}),[t]);const x=r==null?void 0:r.find(l=>l.id===a),u=React.useMemo(()=>{var l;return[...(l=r==null?void 0:r.filter(n=>n.end!==null))!=null?l:[]].sort((n,f)=>n.start-f.start)},[r,v]),C=l=>{i&&(m.current=!0),t.exportContext.onSelectedTimeSlice(l)};return React.useLayoutEffect(()=>{var l;if(!i||!a||!o.current)return;if(m.current){m.current=!1;return}const n=u.findIndex(f=>f.id===a);n>=0&&((l=o.current.children[n])==null||l.scrollIntoView({block:"nearest"}))},[i,a,v,u]),(t==null?void 0:t.exportContext)?React__default.default.createElement("div",null,React__default.default.createElement("div",{className:index_module.timeSliceListHeader},E("AnnotatedList")),React__default.default.createElement(VideoClipAnnotatedListWrapper,{scrollRef:i?o:void 0},u==null?void 0:u.map((l,n)=>React__default.default.createElement(VideoClipAnnotatedItem,{timeSliceProps:l,index:n,key:l.id,exportContext:(t==null?void 0:t.exportContext)||{},onItemClick:C}))),React__default.default.createElement(index,{selectedTimeSlice:x,videoPlayer:c,updateTimeForSelected:d,disabled:s===constant.EClipStatus.Clipping})):null},mapStateToProps=({annotation:e})=>{const{toolInstance:t}=e;return{toolInstance:t}};var VideoClipAnnotatedList$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(VideoClipAnnotatedList);module.exports=VideoClipAnnotatedList$1;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index$2=require("../../../utils/index.js"),audio=require("../../../utils/audio.js"),antd=require("antd"),_=require("lodash"),React=require("react"),index_module=require("./index.module.scss.js"),VideoClipToolContext=require("./VideoClipToolContext.js"),constant=require("./constant.js"),index=require("../../videoPlayer/index.js"),index$1=require("./components/videoTimeSlicesOverVideo/index.js"),icon_videoCutting=require("../../../assets/annotation/video/icon_videoCutting.svg.js"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var ___default=_interopDefaultLegacy(_),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=(o,s,t)=>s in o?__defProp(o,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[s]=t,__spreadValues=(o,s)=>{for(var t in s||(s={}))__hasOwnProp.call(s,t)&&__defNormalProp(o,t,s[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(s))__propIsEnum.call(s,t)&&__defNormalProp(o,t,s[t]);return o},__spreadProps=(o,s)=>__defProps(o,__getOwnPropDescs(s));class VideoClipTool extends React__default.default.Component{constructor(s){super(s);this.fns=new Map,this.throttledUpdateTime=___default.default.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(r=>r.end!==null),{valid:this.state.valid,duration:i}]},this.exportCustomData=()=>({extraResult:this.state.extraResult}),this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const r=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:l,start:n,type:a}=this.state.result[this.selectedSliceIndex],u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[0,audio.precisionMinus(a===constant.ETimeSliceType.Time?r:l,constant.PER_SLICE_CHANGE)]);this.updateSelectedSliceTimeProperty(u,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const r=this.state.result[this.selectedSliceIndex],l=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(r.type===constant.ETimeSliceType.Time){antd.message.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:n,start:a}=r,u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[audio.precisionAdd(a,constant.PER_SLICE_CHANGE),l]);this.updateSelectedSliceTimeProperty(u,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:___default.default.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-constant.PER_SLICE_CHANGE);break;case"=":this.updateSelectedSliceTimeStartByPer(constant.PER_SLICE_CHANGE);break;case"[":this.updateSelectedSliceTimeEndByPer(-constant.PER_SLICE_CHANGE);break;case"]":this.updateSelectedSliceTimeEndByPer(constant.PER_SLICE_CHANGE);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:r}=this.state;r===constant.EClipStatus.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==constant.EClipStatus.Clipping)return;const r=t.findIndex(l=>l.id===e);r>-1&&(t.splice(r,1),this.setState({result:t,selectedID:"",clipStatus:constant.EClipStatus.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i;if(typeof((e=this.props)==null?void 0:e.annotationBefore)=="function"){(i=this.props)==null||i.annotationBefore(()=>this.setClipResult(t));return}this.setClipResult(t)},this.setClipResult=t=>{var e,i,r,l,n,a,u;if(this.disabled)return;const{clipStatus:c,selectedAttribute:p}=this.state,d=c!==constant.EClipStatus.Clipping;let h=d?constant.EClipStatus.Clipping:constant.EClipStatus.Stop,{result:S,selectedID:f,textValue:m}=this.state;const g=___default.default.cloneDeep(S),T=t||((e=this.videoPlayer)==null?void 0:e.currentTime),E=(i=this.videoPlayer)==null?void 0:i.duration;if(E===void 0||T===void 0)return;const I=utils.decimalReserved(T,2);if(d){const v=lbAnnotation.uuid(),b={};f=v;const C=((r=this.props.config)==null?void 0:r.customAttributeInput)===!0?"\u65E0\u5C5E\u6027":p;g.push({start:I,end:null,attribute:C,textAttribute:this.defaultTextAttribute,duration:E,id:v,type:constant.ETimeSliceType.Period,subAttribute:b,text:this.getSubAttributeShowText(b,(n=(l=this.props.config)==null?void 0:l.inputList)!=null?n:[])}),m=this.defaultTextAttribute}else{const v=g.findIndex(C=>C.id===f),b=g[v];b&&(T-b.start<constant.SLICE_MIN_TIME?(g.splice(v,1),antd.message.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${constant.SLICE_MIN_TIME}s`),h=constant.EClipStatus.Stop,f="",m=""):(g[v].end=utils.decimalReserved(T,2),(a=this.videoPlayer)==null||a.pause(),antd.message.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${S.length}`)))}const x={clipStatus:h,result:g,selectedID:f,textValue:m};((u=this.props.config)==null?void 0:u.customAttributeInput)&&d&&(x.selectedAttribute="\u65E0\u5C5E\u6027"),this.setState(x),this.updateSidebar()},this.addTime=()=>{var t,e,i,r,l,n;if(this.disabled)return;const{result:a,selectedAttribute:u,selectedID:c}=this.state,p=lbAnnotation.uuid(),d=___default.default.cloneDeep(a),h=((t=this.videoPlayer)==null?void 0:t.currentTime)||0,S=((e=this.props.config)==null?void 0:e.customAttributeInput)?"\u65E0\u5C5E\u6027":u;d.push({start:h,end:h,attribute:S,textAttribute:this.defaultTextAttribute,id:p,type:constant.ETimeSliceType.Time,duration:(r=(i=this.videoPlayer)==null?void 0:i.duration)!=null?r:0,subAttribute:{}});const f={result:d,selectedID:p,textValue:this.defaultTextAttribute};((l=this.props.config)==null?void 0:l.customAttributeInput)&&(f.selectedAttribute="\u65E0\u5C5E\u6027");const m=d.find(g=>g.id===c);this.isClipping&&m?(delete f.selectedID,delete f.textValue,antd.message.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${d.length-1}`)):(n=this.videoPlayer)==null||n.pause(),this.setState(f),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t}),this.selectTimeSliceByTime(t)},this.findTimeSliceByTime=t=>{const e=utils.decimalReserved(t,2);return this.state.result.find(i=>i.end===null?!1:i.type===constant.ETimeSliceType.Time?utils.decimalReserved(i.start,2)===e:i.start<=e&&e<i.end)},this.selectTimeSliceByTime=t=>{if(this.isClipping)return;const e=this.findTimeSliceByTime(t);if(e){if(e.id===this.state.selectedID)return;this.setState({selectedID:e.id,selectedAttribute:e.attribute,textValue:e.textAttribute})}else{if(!this.state.selectedID)return;this.setState({selectedID:""})}this.updateSidebar()},this.contextToCancel=t=>{this.state.clipStatus===constant.EClipStatus.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var r,l;const{result:n}=this.state,a=n.find(u=>u.id===t);if(a){const u=a.duration,c=e==="left",p=c?"start":"end",d=c?-u*i:u*i,h=c?[0,Math.max(((r=a.end)!=null?r:0)-constant.SLICE_MIN_TIME,0)]:[a.start+constant.SLICE_MIN_TIME,u],S=lbAnnotation.MathUtils.withinRange(d+((l=a==null?void 0:a[p])!=null?l:0),h);a[p]=S,this.throttledUpdateTime(S)}this.setState({result:[...n]}),this.updateSidebar()},this.renderMediaContent=()=>{var t,e,i;const{pageForward:r,pageJump:l,pageBackward:n}=this.props,{result:a,videoError:u,valid:c,currentTime:p}=this.state;return React__default.default.createElement("div",{className:index_module.clipContainer},React__default.default.createElement(index.VideoPlayer,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:n,pageForward:r,pageJump:l,valid:c,setVideoRef:d=>{this.videoPlayer=d},showVideoTrack:!u,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),React__default.default.createElement(index$1,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:a,currentTime:p,attributeList:this.props.config.attributeList,inputList:(i=(e=this.props.config)==null?void 0:e.inputList)!=null?i:[],extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&React__default.default.createElement("i",{className:index_module.clipping,style:{backgroundImage:icon_videoCutting}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,r=e.findIndex(l=>l.id===t.id);r>-1&&(e.splice(r,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{var i,r;try{const{imgIndex:l,imgList:n}=e;if(!n[l])return;const u=index$2.jsonParser(n[l].result)[`step_${this.stepInfo().step}`],c=(u==null?void 0:u.result)||[],p=(u==null?void 0:u.extraResult)||{globalTag:{}},d=(r=(i=this.props.config)==null?void 0:i.inputList)!=null?r:[];c.forEach(S=>{S.text=this.getSubAttributeShowText(S.subAttribute,d)});const h=audio.isImageValue(n[l].result||"[]");this.setState({result:c,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:constant.EClipStatus.Stop,valid:h,extraResult:p},()=>{this.updateSidebar(),h||antd.message.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(l){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0,extraResult:{globalTag:{}}},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,r=e.find(l=>l.id===i);r&&i&&(r.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.setSubAttribute=(t,e)=>{var i,r;const{result:l,selectedID:n}=this.state;if(n){const a=l.find(u=>u.id===n);a&&(a.subAttribute||(a.subAttribute={}),a.subAttribute[t]=e,a.text=this.getSubAttributeShowText(a.subAttribute,(r=(i=this.props.config)==null?void 0:i.inputList)!=null?r:[]),this.setState({result:[...l]}),this.updateSidebar())}},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const r=e.find(l=>l.id===i);r&&(r.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.setGlobalTag=(t,e)=>{const{extraResult:i}=this.state;this.setState({extraResult:__spreadProps(__spreadValues({},i),{globalTag:__spreadProps(__spreadValues({},i.globalTag||{}),{[t]:e})})})},this.getSubAttributeShowText=(t,e)=>{if(!t||(e==null?void 0:e.length)===0)return"";let i="";return lbAnnotation.TagUtils.getTagNameList(t,e).forEach(l=>{i+=`
|
|
2
|
-
${l.keyName}: ${l.value.join("\u3001")}`}),i},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:constant.EClipStatus.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0,extraResult:{globalTag:{}}}}get videoUrl(){var s;const{imgIndex:t,imgList:e}=this.props;return((s=e[t])==null?void 0:s.url)||""}get isClipping(){return this.state.clipStatus===constant.EClipStatus.Clipping}get resultJSON(){const{imgIndex:s,imgList:t}=this.props;return t.length===0||!t[s]?"[]":t[s].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return lbAnnotation.AttributeUtils.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(s=>s.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty,extraResult:this.state.extraResult}}get valid(){return this.state.valid}get config(){var s;return index$2.jsonParser((s=this.props.stepInfo)==null?void 0:s.config)}get selectedText(){var s,t;return(t=(s=this.state.result)==null?void 0:s[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(s,t){const e=s.imgIndex-this.props.imgIndex,i=s.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,s),i!==0&&this.setState({loading:!1})),!0}singleOn(s,t){this.fns.set(s,[t])}on(s,t){this.singleOn(s,t)}unbindAll(s){this.fns.delete(s)}render(){const{selectedID:s,result:t,clipStatus:e,selectedAttribute:i}=this.state;return React__default.default.createElement(VideoClipToolContext.VideoClipToolContextProvider,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:s,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel,selectTimeSliceByTime:this.selectTimeSliceByTime}},this.renderMediaContent())}}module.exports=VideoClipTool;
|
|
1
|
+
"use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index$2=require("../../../utils/index.js"),audio=require("../../../utils/audio.js"),antd=require("antd"),_=require("lodash"),React=require("react"),index_module=require("./index.module.scss.js"),VideoClipToolContext=require("./VideoClipToolContext.js"),constant=require("./constant.js"),index=require("../../videoPlayer/index.js"),index$1=require("./components/videoTimeSlicesOverVideo/index.js"),icon_videoCutting=require("../../../assets/annotation/video/icon_videoCutting.svg.js"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var ___default=_interopDefaultLegacy(_),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=(o,s,t)=>s in o?__defProp(o,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[s]=t,__spreadValues=(o,s)=>{for(var t in s||(s={}))__hasOwnProp.call(s,t)&&__defNormalProp(o,t,s[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(s))__propIsEnum.call(s,t)&&__defNormalProp(o,t,s[t]);return o},__spreadProps=(o,s)=>__defProps(o,__getOwnPropDescs(s));class VideoClipTool extends React__default.default.Component{constructor(s){super(s);this.fns=new Map,this.throttledUpdateTime=___default.default.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(r=>r.end!==null),{valid:this.state.valid,duration:i}]},this.exportCustomData=()=>({extraResult:this.state.extraResult}),this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const r=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:l,start:n,type:a}=this.state.result[this.selectedSliceIndex],u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[0,audio.precisionMinus(a===constant.ETimeSliceType.Time?r:l,constant.PER_SLICE_CHANGE)]);this.updateSelectedSliceTimeProperty(u,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const r=this.state.result[this.selectedSliceIndex],l=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(r.type===constant.ETimeSliceType.Time){antd.message.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:n,start:a}=r,u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[audio.precisionAdd(a,constant.PER_SLICE_CHANGE),l]);this.updateSelectedSliceTimeProperty(u,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:___default.default.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-constant.PER_SLICE_CHANGE);break;case"=":this.updateSelectedSliceTimeStartByPer(constant.PER_SLICE_CHANGE);break;case"[":this.updateSelectedSliceTimeEndByPer(-constant.PER_SLICE_CHANGE);break;case"]":this.updateSelectedSliceTimeEndByPer(constant.PER_SLICE_CHANGE);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:r}=this.state;r===constant.EClipStatus.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==constant.EClipStatus.Clipping)return;const r=t.findIndex(l=>l.id===e);r>-1&&(t.splice(r,1),this.setState({result:t,selectedID:"",clipStatus:constant.EClipStatus.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i;if(typeof((e=this.props)==null?void 0:e.annotationBefore)=="function"){(i=this.props)==null||i.annotationBefore(()=>this.setClipResult(t));return}this.setClipResult(t)},this.setClipResult=t=>{var e,i,r,l,n,a,u;if(this.disabled)return;const{clipStatus:c,selectedAttribute:h}=this.state,d=c!==constant.EClipStatus.Clipping;let p=d?constant.EClipStatus.Clipping:constant.EClipStatus.Stop,{result:S,selectedID:f,textValue:m}=this.state;const g=___default.default.cloneDeep(S),T=t||((e=this.videoPlayer)==null?void 0:e.currentTime),E=(i=this.videoPlayer)==null?void 0:i.duration;if(E===void 0||T===void 0)return;const I=utils.decimalReserved(T,2);if(d){const v=lbAnnotation.uuid(),b={};f=v;const C=((r=this.props.config)==null?void 0:r.customAttributeInput)===!0?"\u65E0\u5C5E\u6027":h;g.push({start:I,end:null,attribute:C,textAttribute:this.defaultTextAttribute,duration:E,id:v,type:constant.ETimeSliceType.Period,subAttribute:b,text:this.getSubAttributeShowText(b,(n=(l=this.props.config)==null?void 0:l.inputList)!=null?n:[])}),m=this.defaultTextAttribute}else{const v=g.findIndex(C=>C.id===f),b=g[v];b&&(T-b.start<constant.SLICE_MIN_TIME?(g.splice(v,1),antd.message.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${constant.SLICE_MIN_TIME}s`),p=constant.EClipStatus.Stop,f="",m=""):(g[v].end=utils.decimalReserved(T,2),(a=this.videoPlayer)==null||a.pause(),antd.message.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${S.length}`)))}const x={clipStatus:p,result:g,selectedID:f,textValue:m};((u=this.props.config)==null?void 0:u.customAttributeInput)&&d&&(x.selectedAttribute="\u65E0\u5C5E\u6027"),this.setState(x),this.updateSidebar()},this.addTime=()=>{var t,e,i,r,l,n;if(this.disabled)return;const{result:a,selectedAttribute:u,selectedID:c}=this.state,h=lbAnnotation.uuid(),d=___default.default.cloneDeep(a),p=((t=this.videoPlayer)==null?void 0:t.currentTime)||0,S=((e=this.props.config)==null?void 0:e.customAttributeInput)?"\u65E0\u5C5E\u6027":u;d.push({start:p,end:p,attribute:S,textAttribute:this.defaultTextAttribute,id:h,type:constant.ETimeSliceType.Time,duration:(r=(i=this.videoPlayer)==null?void 0:i.duration)!=null?r:0,subAttribute:{}});const f={result:d,selectedID:h,textValue:this.defaultTextAttribute};((l=this.props.config)==null?void 0:l.customAttributeInput)&&(f.selectedAttribute="\u65E0\u5C5E\u6027");const m=d.find(g=>g.id===c);this.isClipping&&m?(delete f.selectedID,delete f.textValue,antd.message.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${d.length-1}`)):(n=this.videoPlayer)==null||n.pause(),this.setState(f),this.updateSidebar()},this.updateCurrentTime=t=>{var e;this.setState({currentTime:t}),((e=this.props.config)==null?void 0:e.linkageConfigurable)===!0&&this.selectTimeSliceByTime(t)},this.findTimeSliceByTime=t=>{const e=utils.decimalReserved(t,2);return this.state.result.find(i=>i.end===null?!1:i.type===constant.ETimeSliceType.Time?utils.decimalReserved(i.start,2)===e:i.start<=e&&e<i.end)},this.selectTimeSliceByTime=t=>{if(this.isClipping)return;const e=this.findTimeSliceByTime(t);if(e){if(e.id===this.state.selectedID)return;this.setState({selectedID:e.id,selectedAttribute:e.attribute,textValue:e.textAttribute})}else{if(!this.state.selectedID)return;this.setState({selectedID:""})}this.updateSidebar()},this.contextToCancel=t=>{this.state.clipStatus===constant.EClipStatus.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var r,l;const{result:n}=this.state,a=n.find(u=>u.id===t);if(a){const u=a.duration,c=e==="left",h=c?"start":"end",d=c?-u*i:u*i,p=c?[0,Math.max(((r=a.end)!=null?r:0)-constant.SLICE_MIN_TIME,0)]:[a.start+constant.SLICE_MIN_TIME,u],S=lbAnnotation.MathUtils.withinRange(d+((l=a==null?void 0:a[h])!=null?l:0),p);a[h]=S,this.throttledUpdateTime(S)}this.setState({result:[...n]}),this.updateSidebar()},this.renderMediaContent=()=>{var t,e,i,r;const{pageForward:l,pageJump:n,pageBackward:a}=this.props,{result:u,videoError:c,valid:h,currentTime:d}=this.state;return React__default.default.createElement("div",{className:index_module.clipContainer},React__default.default.createElement(index.VideoPlayer,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:a,pageForward:l,pageJump:n,valid:h,setVideoRef:p=>{this.videoPlayer=p},showVideoTrack:!c,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime,syncTimeOnPlay:((t=this.props.config)==null?void 0:t.linkageConfigurable)===!0}),React__default.default.createElement(index$1,{key:(e=this.videoPlayer)==null?void 0:e.currentTime,result:u,currentTime:d,attributeList:this.props.config.attributeList,inputList:(r=(i=this.props.config)==null?void 0:i.inputList)!=null?r:[],extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&React__default.default.createElement("i",{className:index_module.clipping,style:{backgroundImage:icon_videoCutting}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,r=e.findIndex(l=>l.id===t.id);r>-1&&(e.splice(r,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{var i,r;try{const{imgIndex:l,imgList:n}=e;if(!n[l])return;const u=index$2.jsonParser(n[l].result)[`step_${this.stepInfo().step}`],c=(u==null?void 0:u.result)||[],h=(u==null?void 0:u.extraResult)||{globalTag:{}},d=(r=(i=this.props.config)==null?void 0:i.inputList)!=null?r:[];c.forEach(S=>{S.text=this.getSubAttributeShowText(S.subAttribute,d)});const p=audio.isImageValue(n[l].result||"[]");this.setState({result:c,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:constant.EClipStatus.Stop,valid:p,extraResult:h},()=>{this.updateSidebar(),p||antd.message.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(l){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0,extraResult:{globalTag:{}}},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,r=e.find(l=>l.id===i);r&&i&&(r.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.setSubAttribute=(t,e)=>{var i,r;const{result:l,selectedID:n}=this.state;if(n){const a=l.find(u=>u.id===n);a&&(a.subAttribute||(a.subAttribute={}),a.subAttribute[t]=e,a.text=this.getSubAttributeShowText(a.subAttribute,(r=(i=this.props.config)==null?void 0:i.inputList)!=null?r:[]),this.setState({result:[...l]}),this.updateSidebar())}},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const r=e.find(l=>l.id===i);r&&(r.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.setGlobalTag=(t,e)=>{const{extraResult:i}=this.state;this.setState({extraResult:__spreadProps(__spreadValues({},i),{globalTag:__spreadProps(__spreadValues({},i.globalTag||{}),{[t]:e})})})},this.getSubAttributeShowText=(t,e)=>{if(!t||(e==null?void 0:e.length)===0)return"";let i="";return lbAnnotation.TagUtils.getTagNameList(t,e).forEach(l=>{i+=`
|
|
2
|
+
${l.keyName}: ${l.value.join("\u3001")}`}),i},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:constant.EClipStatus.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0,extraResult:{globalTag:{}}}}get videoUrl(){var s;const{imgIndex:t,imgList:e}=this.props;return((s=e[t])==null?void 0:s.url)||""}get isClipping(){return this.state.clipStatus===constant.EClipStatus.Clipping}get resultJSON(){const{imgIndex:s,imgList:t}=this.props;return t.length===0||!t[s]?"[]":t[s].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return lbAnnotation.AttributeUtils.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(s=>s.id===this.state.selectedID)}get exportContext(){var s;return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty,extraResult:this.state.extraResult,linkageConfigurable:((s=this.props.config)==null?void 0:s.linkageConfigurable)===!0}}get valid(){return this.state.valid}get config(){var s;return index$2.jsonParser((s=this.props.stepInfo)==null?void 0:s.config)}get selectedText(){var s,t;return(t=(s=this.state.result)==null?void 0:s[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(s,t){const e=s.imgIndex-this.props.imgIndex,i=s.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,s),i!==0&&this.setState({loading:!1})),!0}singleOn(s,t){this.fns.set(s,[t])}on(s,t){this.singleOn(s,t)}unbindAll(s){this.fns.delete(s)}render(){const{selectedID:s,result:t,clipStatus:e,selectedAttribute:i}=this.state;return React__default.default.createElement(VideoClipToolContext.VideoClipToolContextProvider,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:s,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel,selectTimeSliceByTime:this.selectTimeSliceByTime}},this.renderMediaContent())}}module.exports=VideoClipTool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),index$2=require("./components/controller/index.js"),index=require("../videoAnnotate/videoClipTool/components/videoTrack/index.js"),dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),utils=require("./utils.js"),index$1=require("../fileException/index.js");function _interopDefaultLegacy(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),index$2=require("./components/controller/index.js"),index=require("../videoAnnotate/videoClipTool/components/videoTrack/index.js"),dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),utils=require("./utils.js"),index$1=require("../fileException/index.js");function _interopDefaultLegacy(s){return s&&typeof s=="object"&&"default"in s?s:{default:s}}var React__default=_interopDefaultLegacy(React);const EKeyCode=lbAnnotation.cKeyCode.default,VideoPlayerCtx=React__default.default.createContext({isPlay:!1,playPause:()=>{},updateNextPlaybackRate:()=>{},playbackRate:1,currentTime:0,duration:0,buffered:0,setCurrentTime:()=>{},imgList:[],imgIndex:-1,pageBackward:()=>{},pageJump:s=>{},pageForward:()=>{},addTime:()=>{},toggleClipStatus:()=>{}}),PER_INTERVAL_DEFAULT=50,PER_INTERVAL_SYNC=300,PER_FORWARD=.1,PLAYBACK_RATES=[.1,.2,.3,.4,.5,1,1.5,2,4,6,8,16];class VideoPlayer extends React__default.default.Component{constructor(a){super(a);this.changePlaybackPate=e=>{this.videoElm&&(this.videoElm.playbackRate=e,this.setState({playbackRate:e}))},this.playPause=()=>{var e,t,i;((e=this.videoElm)==null?void 0:e.paused)?(t=this.videoElm)==null||t.play():(i=this.videoElm)==null||i.pause()},this.updateNextPlaybackRate=(e=!0)=>{const t=PLAYBACK_RATES.findIndex(r=>r===this.state.playbackRate);let i=e?Math.min(t+1,PLAYBACK_RATES.length-1):Math.max(t-1,0);this.changePlaybackPate(PLAYBACK_RATES[i])},this.fastForward=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime+PER_FORWARD)},this.rewind=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime-PER_FORWARD)},this.keydown=e=>{e.keyCode===EKeyCode.Space&&(e.preventDefault(),this.playPause()),e.keyCode===EKeyCode.Up&&(e.preventDefault(),this.updateNextPlaybackRate()),e.keyCode===EKeyCode.Down&&(e.preventDefault(),this.updateNextPlaybackRate(!1)),e.keyCode===EKeyCode.Left&&(e.preventDefault(),this.rewind()),e.keyCode===EKeyCode.Right&&(e.preventDefault(),this.fastForward())},this.onPlay=()=>{this.setState({isPlay:!0},this.onVideoStart)},this.onPause=()=>{this.onVideoStopped()},this.onTimeUpdate=()=>{var e;this.videoElm&&this.setState({currentTime:utils.decimalReserved((e=this.videoElm)==null?void 0:e.currentTime,1)})},this.onVideoStopped=()=>{this.setState({isPlay:!1}),this.timeInterval&&(clearInterval(this.timeInterval),this.timeInterval=void 0),this.videoElm&&this.setCurrentTime(this.videoElm.currentTime)},this.onVideoStart=()=>{const e=this.props.syncTimeOnPlay===!0,t=e?PER_INTERVAL_SYNC:PER_INTERVAL_DEFAULT;this.timeInterval=window.setInterval(()=>{var i,r,l,d,n,u;if(this.videoElm)try{if(((i=this.videoElm)==null?void 0:i.buffered.length)>0){const o=(r=this.videoElm)==null?void 0:r.buffered.end(0);e?this.setState({buffered:o}):this.setState({currentTime:utils.decimalReserved((l=this.videoElm)==null?void 0:l.currentTime,1),buffered:o})}e&&((u=(n=this.props).updateCurrentTime)==null||u.call(n,utils.decimalReserved((d=this.videoElm)==null?void 0:d.currentTime,1)))}catch(o){console.error(o)}},t)},this.resetVideoData=()=>{this.setState({currentTime:0,buffered:0,error:!1,isPlay:!1}),this.videoElm&&(this.videoElm.playbackRate=this.state.playbackRate),this.onVideoStopped()},this.setDuration=()=>{var e,t,i;if(this.videoElm){const r=utils.decimalReserved((e=this.videoElm)==null?void 0:e.duration,1);(i=(t=this.props).dataLoaded)==null||i.call(t),this.setState({duration:r})}},this.setCurrentTime=e=>{var t,i;this.videoElm&&(this.videoElm.currentTime=e,this.setState({currentTime:e}),(i=(t=this.props).updateCurrentTime)==null||i.call(t,e))},this.reload=()=>{var e;(e=this.videoElm)==null||e.load()},this.onError=()=>{var e,t;(t=(e=this.props).dataLoaded)==null||t.call(e,!0),this.resetVideoData(),this.setState({error:!0})},this.state={playbackRate:1,currentTime:0,isPlay:!1,duration:0,buffered:0,error:!1},this.videoRef=React__default.default.createRef()}get videoElm(){var a;return(a=this.videoRef)==null?void 0:a.current}get videoSrc(){var a,e;const{imgIndex:t,imgList:i}=this.props;return t>-1&&(e=(a=i[t])==null?void 0:a.url)!=null?e:""}componentDidMount(){var a,e;window.addEventListener("keydown",this.keydown),((a=this.videoRef)==null?void 0:a.current)&&this.props.setVideoRef&&this.props.setVideoRef((e=this.videoRef)==null?void 0:e.current)}componentWillUnmount(){window.removeEventListener("keydown",this.keydown)}render(){const{isPlay:a,playbackRate:e,currentTime:t,duration:i,buffered:r,error:l}=this.state,{imgList:d,imgIndex:n,pageBackward:u,pageJump:o,pageForward:m,valid:p,footer:f,drawLayerSlot:c}=this.props,y=isNaN(i)?0:Math.max(utils.decimalReserved(i,1)-t,0),{playPause:h,updateNextPlaybackRate:E,onPause:R,onPlay:T,onTimeUpdate:P,resetVideoData:g,setDuration:_,setCurrentTime:b,onError:k,videoRef:C,videoSrc:x}=this;return React__default.default.createElement(VideoPlayerCtx.Provider,{value:{videoRef:this.videoRef,addTime:this.props.addTime,toggleClipStatus:this.props.toggleClipStatus,isPlay:a,playPause:h,updateNextPlaybackRate:E,playbackRate:e,currentTime:t,duration:i,buffered:r,setCurrentTime:b,imgIndex:n,imgList:d,pageBackward:u,pageJump:o,pageForward:m}},React__default.default.createElement(React__default.default.Fragment,null,c==null?void 0:c({currentTime:t,remainingTime:y,zoom:1,currentPos:{x:0,y:0}}),React__default.default.createElement("div",{className:dom.getClassName("video-wrapper")},React__default.default.createElement("div",{className:dom.getClassName("video-container")},React__default.default.createElement("video",{ref:C,className:dom.getClassName(this.props.showVideoTrack?"video-track":"video"),src:x,onPause:R,onPlay:T,onTimeUpdate:P,onLoadedMetadata:g,onError:k,onDurationChange:_,width:"100%",height:"100%",onClick:h}),this.props.showVideoTrack&&React__default.default.createElement(index.default,{currentTime:t,onTrackResize:this.props.onTrackResize,onTrackResizeStart:()=>{var v;(v=this.videoElm)==null||v.pause()},readonly:!1}),React__default.default.createElement(index$1,{fileType:"video",errorProps:{reloadImage:this.reload,backgroundColor:"#e2e2e2",ignoreOffsetY:!0,isError:l},invalidProps:{isValid:p}})),React__default.default.createElement(index$2.default,{footer:f}))))}}exports.VideoPlayer=VideoPlayer,exports.VideoPlayerCtx=VideoPlayerCtx,exports.default=VideoPlayer;
|
|
@@ -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 & {
|
|
@@ -49,6 +49,7 @@ declare class VideoClipTool extends React.Component<IVideoClipProps, IState> {
|
|
|
49
49
|
removeTimeSlice: (item: IVideoTimeSlice) => void;
|
|
50
50
|
updateSelectedSliceTimeProperty: (val: number, key: "end" | "start") => void;
|
|
51
51
|
extraResult: IExtraResult;
|
|
52
|
+
linkageConfigurable: boolean;
|
|
52
53
|
};
|
|
53
54
|
fns: Map<string, any[]>;
|
|
54
55
|
videoPlayer?: any;
|
|
@@ -40,6 +40,8 @@ interface IVideoPlayerProps {
|
|
|
40
40
|
toggleClipStatus?: () => void;
|
|
41
41
|
drawLayerSlot?: any;
|
|
42
42
|
updateCurrentTime?: (time: number) => void;
|
|
43
|
+
/** 开启后播放过程持续同步 currentTime(具身联动) */
|
|
44
|
+
syncTimeOnPlay?: boolean;
|
|
43
45
|
}
|
|
44
46
|
interface IVideoPlayerState {
|
|
45
47
|
playbackRate: number;
|
|
@@ -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;
|