@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.
@@ -1 +1 @@
1
- import{PointCloudContext as re}from"./PointCloudContext.js";import{useRotate as se}from"./hooks/useRotate.js";import{useRotateEdge as ne}from"./hooks/useRotateEdge.js";import{useBoxes as ie}from"./hooks/useBoxes.js";import{useSingleBox as ae}from"./hooks/useSingleBox.js";import{useSphere as le}from"./hooks/useSphere.js";import{useContext as ue,useEffect as c}from"react";import{CommonToolUtils as ce,EToolName as v,cTool as de}from"@labelbee/lb-annotation";import{Modal as pe,message as f}from"antd";import{connect as me}from"react-redux";import{a2MapStateToProps as ve}from"../../store/annotation/map.js";import{useStatus as Pe}from"./hooks/useStatus.js";import{usePointCloudViews as we}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as be}from"../../store/ctx.js";import{useHistory as ye}from"./hooks/useHistory.js";import{useAttribute as fe}from"./hooks/useAttribute.js";import{useConfig as he}from"./hooks/useConfig.js";import{usePolygon as Ce}from"./hooks/usePolygon.js";import{useLine as Se}from"./hooks/useLine.js";import{useUpdatePointCloudColor as ge}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as ke}from"react-i18next";import{useLatest as L}from"ahooks";var Ve=Object.defineProperty,xe=Object.defineProperties,_e=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,Ie=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,O=(i,r,l)=>r in i?Ve(i,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[r]=l,P=(i,r)=>{for(var l in r||(r={}))Ie.call(r,l)&&O(i,l,r[l]);if(B)for(var l of B(r))Le.call(r,l)&&O(i,l,r[l]);return i},w=(i,r)=>xe(i,_e(r));const{EPolygonPattern:Be}=de,Oe=({currentData:i,config:r,checkMode:l,configString:j,imgIndex:h,toolInstanceRef:a,setResourceLoading:C,isBatchSetValid:T})=>{const e=ue(re),{changeSelectedBoxValid:A,selectNextBox:E,selectPrevBox:D,updateSelectedBox:H,deleteSelectedPointCloudBoxAndPolygon:K}=ae(),{selectedSphere:b,updatePointCloudSphere:N}=le(),{clearAllResult:S,updatePointCloudPattern:U}=Pe(),{copySelectedBoxes:z,pasteSelectedBoxes:R,copiedBoxes:Te}=ie({config:r,currentData:i}),{updateRotate:g}=se({currentData:i}),{updateRotateEdge:F}=ne({currentData:i}),{updatePointCloudData:p,topViewSelectedChanged:M}=we({setResourceLoading:C}),{redo:k,undo:V,pushHistoryWithList:q,pushHistoryUnderUpdatePolygon:G,pushHistoryUnderUpdateLine:W}=ye(),{syncThreeViewsAttribute:x}=fe(),{syncAllViewsConfig:Y,reRenderTopViewRange:$,reRenderTopViewTipScopeList:J}=he(),{selectedPolygon:_}=Ce(),{selectedLine:I}=Se(),{t:y}=ke(),{updatePointCloudColor:Q}=ge(C,r),X=L(i),m=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},Z=(t,o)=>{const{topViewInstance:s,mainViewInstance:n}=e;if(!s)return;const{pointCloud2dOperation:u}=s;switch(t){case"q":{g(e.rectRotateSensitivity);break}case"e":g(-Number(e.rectRotateSensitivity));break;case"g":F(-90);break;case"u":{const d=u.pattern===Be.Normal?v.Rect:v.Polygon;U(d);const oe={[v.Polygon]:y("PolygonPattern"),[v.Rect]:y("RectPattern")};f.success(y("ChangePatternMsg",{pattern:oe[d]})),u.clearActiveStatus(),u.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":T?(pe.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){D();break}E(),o.preventDefault();break;case"f":A();break;case"arrowup":m({y:-1});break;case"arrowdown":m({y:1});break;case"arrowleft":m({x:-1});break;case"arrowright":m({x:1});break;case"delete":K(X.current);break}},ee=(t,o)=>{switch(t){case"c":z();break;case"v":R();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?k():V();break}}},te=L(t=>{if(!ce.hotkeyFilter(t)||l===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){ee(o,t);return}Z(o,t)});return c(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(u=>te.current(u))},[e,e.topViewInstance,e.windowKeydownListenerHook]),c(()=>{Y(r)},[j]),c(()=>{(r==null?void 0:r.radius)&&$(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),c(()=>{(r==null?void 0:r.tipScopeList)&&J(r==null?void 0:r.tipScopeList)},[r==null?void 0:r.tipScopeList]),c(()=>{p==null||p()},[h,e.mainViewInstance]),c(()=>{e.setHideAttributes([])},[h]),c(()=>{a.current.setAttrChangeTrigger=t=>{var o;(o=e.topViewInstance)==null||o.toolInstance.setAttrChangeTrigger(t)},a.current.setDefaultAttribute=t=>{var o;if(x(t),Q(t),_&&G(w(P({},_),{attribute:t})),I&&W(w(P({},I),{attribute:t})),b){const s=N(w(P({},b),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),M({newSelectedSphere:b,newSphereList:s}))}},a.current.setSubAttribute=(t,o)=>{var s;const n=e.selectedPointCloudBox;if(n){const u=(s=n==null?void 0:n.subAttribute)!=null?s:{};n.subAttribute=w(P({},u),{[t]:o}),H(n),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(n.id),e.mainViewInstance.render())}},a.current.clearResult=()=>{S==null||S()},a.current.redo=()=>{k()},a.current.undo=()=>{V()},a.current.setValid=t=>{a.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t)})},a.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},a.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},a.current.asyncData=t=>{setTimeout(()=>{p==null||p(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),c(()=>{a.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},a.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),c(()=>{a.current.history={pushHistory:t=>{q({pointCloudBoxList:t})},initRecord:()=>{}}},[]),c(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||l)return;const s=d=>{x(d)},n=d=>{f.error(d)},u=d=>{f.info(d)};return o.on("syncAttribute",s),o.on("messageError",n),o.on("messageInfo",u),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",n),o.unbind("messageInfo",u)}},[e.topViewInstance]),null};var je=me(ve,null,null,{context:be})(Oe);export{je as default};
1
+ import{PointCloudContext as se}from"./PointCloudContext.js";import{useRotate as ne}from"./hooks/useRotate.js";import{useRotateEdge as ie}from"./hooks/useRotateEdge.js";import{useBoxes as ae}from"./hooks/useBoxes.js";import{useSingleBox as le}from"./hooks/useSingleBox.js";import{useSphere as ue}from"./hooks/useSphere.js";import{useContext as de,useEffect as d}from"react";import{CommonToolUtils as ce,EToolName as b,cTool as pe}from"@labelbee/lb-annotation";import{Modal as me,message as w}from"antd";import{connect as ve}from"react-redux";import{a2MapStateToProps as Pe}from"../../store/annotation/map.js";import{useStatus as we}from"./hooks/useStatus.js";import{usePointCloudViews as ye}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as fe}from"../../store/ctx.js";import{useHistory as he}from"./hooks/useHistory.js";import{useAttribute as be}from"./hooks/useAttribute.js";import{useConfig as Ce}from"./hooks/useConfig.js";import{usePolygon as Se}from"./hooks/usePolygon.js";import{useLine as ge}from"./hooks/useLine.js";import{useUpdatePointCloudColor as ke}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as Ve}from"react-i18next";import{useLatest as A}from"ahooks";var xe=Object.defineProperty,_e=Object.defineProperties,Ie=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Be=Object.prototype.propertyIsEnumerable,E=(i,r,n)=>r in i?xe(i,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[r]=n,C=(i,r)=>{for(var n in r||(r={}))Le.call(r,n)&&E(i,n,r[n]);if(T)for(var n of T(r))Be.call(r,n)&&E(i,n,r[n]);return i},S=(i,r)=>_e(i,Ie(r)),Oe=(i,r,n)=>new Promise((g,p)=>{var a=e=>{try{m(n.next(e))}catch(v){p(v)}},y=e=>{try{m(n.throw(e))}catch(v){p(v)}},m=e=>e.done?g(e.value):Promise.resolve(e.value).then(a,y);m((n=n.apply(i,r)).next())});const{EPolygonPattern:je}=pe,Ae=({currentData:i,config:r,checkMode:n,configString:g,imgIndex:p,toolInstanceRef:a,setResourceLoading:y,isBatchSetValid:m})=>{const e=de(se),{changeSelectedBoxValid:v,selectNextBox:D,selectPrevBox:H,updateSelectedBox:K,deleteSelectedPointCloudBoxAndPolygon:N}=le(),{selectedSphere:k,updatePointCloudSphere:R}=ue(),{clearAllResult:V,updatePointCloudPattern:U}=we(),{copySelectedBoxes:z,pasteSelectedBoxes:F,copiedBoxes:Ee}=ae({config:r,currentData:i}),{updateRotate:x}=ne({currentData:i}),{updateRotateEdge:M}=ie({currentData:i}),{updatePointCloudData:f,restorePreResult:_,topViewSelectedChanged:q}=ye({setResourceLoading:y}),{redo:I,undo:L,pushHistoryWithList:G,pushHistoryUnderUpdatePolygon:W,pushHistoryUnderUpdateLine:Y}=he(),{syncThreeViewsAttribute:B}=be(),{syncAllViewsConfig:$,reRenderTopViewRange:J,reRenderTopViewTipScopeList:Q}=Ce(),{selectedPolygon:O}=Se(),{selectedLine:j}=ge(),{t:P}=Ve(),{updatePointCloudColor:X}=ke(y,r),Z=A(i),h=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},ee=(t,o)=>{const{topViewInstance:s,mainViewInstance:l}=e;if(!s)return;const{pointCloud2dOperation:u}=s;switch(t){case"q":{x(e.rectRotateSensitivity);break}case"e":x(-Number(e.rectRotateSensitivity));break;case"g":M(-90);break;case"u":{const c=u.pattern===je.Normal?b.Rect:b.Polygon;U(c);const re={[b.Polygon]:P("PolygonPattern"),[b.Rect]:P("RectPattern")};w.success(P("ChangePatternMsg",{pattern:re[c]})),u.clearActiveStatus(),u.clearDrawingStatus()}break;case"+":l==null||l.updatePointSize({zoomIn:!0});break;case"-":l==null||l.updatePointSize({zoomIn:!1});break;case"v":m?(me.destroyAll(),e.setBatchSetValidModal(!e.visibleBatchSetValid)):e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){H();break}D(),o.preventDefault();break;case"f":v();break;case"arrowup":h({y:-1});break;case"arrowdown":h({y:1});break;case"arrowleft":h({x:-1});break;case"arrowright":h({x:1});break;case"delete":N(Z.current);break}},te=(t,o)=>{switch(t){case"c":z();break;case"v":F();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?I():L();break}}},oe=A(t=>{if(!ce.hotkeyFilter(t)||n===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){te(o,t);return}ee(o,t)});return d(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(u=>oe.current(u))},[e,e.topViewInstance,e.windowKeydownListenerHook]),d(()=>{$(r)},[g]),d(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),d(()=>{(r==null?void 0:r.tipScopeList)&&Q(r==null?void 0:r.tipScopeList)},[r==null?void 0:r.tipScopeList]),d(()=>{f==null||f()},[p,e.mainViewInstance]),d(()=>{e.setHideAttributes([])},[p]),d(()=>{a.current.setAttrChangeTrigger=t=>{var o;(o=e.topViewInstance)==null||o.toolInstance.setAttrChangeTrigger(t)},a.current.setDefaultAttribute=t=>{var o;if(B(t),X(t),O&&W(S(C({},O),{attribute:t})),j&&Y(S(C({},j),{attribute:t})),k){const s=R(S(C({},k),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),q({newSelectedSphere:k,newSphereList:s}))}},a.current.setSubAttribute=(t,o)=>{var s;const l=e.selectedPointCloudBox;if(l){const u=(s=l==null?void 0:l.subAttribute)!=null?s:{};l.subAttribute=S(C({},u),{[t]:o}),K(l),e.mainViewInstance&&e.selectedPointCloudBox&&(e.mainViewInstance.generateBox(e.selectedPointCloudBox),e.mainViewInstance.setHighlightColor(l.id),e.mainViewInstance.render())}},a.current.clearResult=t=>Oe(void 0,null,function*(){if(t==null?void 0:t.keepPreResult){try{(yield _==null?void 0:_())||w.error(P("ClearKeepPreAnnotationFailed"))}catch(o){w.error(P("ClearKeepPreAnnotationFailed"))}return}V==null||V()}),a.current.redo=()=>{I()},a.current.undo=()=>{L()},a.current.setValid=t=>{a.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t)})},a.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},a.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},a.current.asyncData=t=>{setTimeout(()=>{f==null||f(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),d(()=>{a.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},a.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),d(()=>{a.current.history={pushHistory:t=>{G({pointCloudBoxList:t})},initRecord:()=>{}}},[]),d(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||n)return;const s=c=>{B(c)},l=c=>{w.error(c)},u=c=>{w.info(c)};return o.on("syncAttribute",s),o.on("messageError",l),o.on("messageInfo",u),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",l),o.unbind("messageInfo",u)}},[e.topViewInstance]),null};var Te=ve(Pe,null,null,{context:fe})(Ae);export{Te as default};
@@ -1 +1 @@
1
- import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as J,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as Pt,useCallback as mt}from"react";import{PointCloudContext as ht}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as F}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as xt,generatePointCloudBoxRects as po,resolveFileItemValid as go}from"../../../utils/index.js";import{PreDataProcess as rt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as fo}from"./useHistory.js";import{usePolygon as Co}from"./usePolygon.js";import{useLatest as K}from"ahooks";var Po=Object.defineProperty,mo=Object.defineProperties,ho=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,Lo=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Po(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,L=(e,n)=>{for(var t in n||(n={}))xo.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))Lo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>mo(e,ho(n)),bt=(e,n,t)=>new Promise((d,p)=>{var o=a=>{try{u(t.next(a))}catch(h){p(h)}},f=a=>{try{u(t.throw(a))}catch(h){p(h)}},u=a=>a.done?d(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const $=5,tt=90,It=.01,b={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},lt=(e,n,t,d,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,a={center:{x:o,y:f,z:u},id:e.id},h=d?L(L({},d),a):A(L({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},dt=(e,n,t,d,p,o)=>{let f=e.pointList.map(S=>O.transferCanvas2World(S,n)),u=0,a=1,h={};if(t){const S=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&S.fittedCoordinates.length>0&&(f=S.fittedCoordinates),u=(S.maxZ+S.minZ)/2,a=S.maxZ-S.minZ,h={count:S.zCount}}const[P,v,T]=f,V=w.getLineCenterPoint([P,T]),D=w.getLineLength(P,v),U=w.getLineLength(v,T),N=w.getRadiusFromQuadrangle(e.pointList);d&&(u=d.center.z,a=d.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+It:U,height:o?D+It:D,depth:a,rotation:N,id:e.id},j=L(d?L(L({},d),z):A(L({},z),{attribute:"",valid:!0}),h);p&&Object.assign(j,p);const E=f.map(S=>O.transferWorld2Canvas(S,n));return{boxParams:j,newPointList:E}},wt=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x-d.x,y:t.center.y,z:t.center.z-d.y}})},St=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,h]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,a),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j,{newBoxParams:S}=d.getNewBoxBySideUpdate(V,E,N,t);return S},vo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x,y:t.center.y-d.x,z:t.center.z-d.y}})},yo=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,h]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,a),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j;let{newBoxParams:S}=d.getNewBoxByBackUpdate(V,E,N,t);return S},Dt=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,J.Left);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{width:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,J.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,d,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(d,(o=p==null?void 0:p.radius)!=null?o:tt);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,J.Back);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{height:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,J.Back);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxBackPolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},kt=(e,n,t,d)=>{if(!t||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,J.Top),d.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(L(L({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},at=(e,n,t,d)=>{var p,o;if(!t||!d)return;d.generateBox(e),d.setHighlightColor(e.id),d.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:a}=u.getBoxTopPolygon2DCoordinate(e),h=[...f.polygonList],P=h.find(v=>v.id===n.id);P?(P.pointList=a,P.valid=(p=e.valid)!=null?p:!0):h.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(h,n.id)},Bo=e=>{const n=Pt(ht),{topViewInstance:t,sideViewInstance:d,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:a,selectedIDs:h,pointCloudBoxList:P,pointCloudSphereList:v,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:D,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:E,pushHistoryUnderUpdatePolygon:S}=fo(),{selectedPolygon:Ot}=Co(),{getPointCloudSphereByID:At,updatePointCloudSphere:ct,selectedSphere:Q}=ro(),{currentData:H,config:y}=ao(s=>{const{stepList:i,step:c,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:xt(uo.getCurrentStepInfo(c,i).config)}}),M=co(),Tt=K(D),Ut=K(z),zt=mt((s,i)=>{const c=Ut.current,l=i.id;return s.filter(r=>{if(!r)return!1;const m=c.get(r.imageName);return m===void 0?!0:Boolean(m.get(l))})},[]),ot=s=>{const{enableAutoMap2DRect:i=!1}=y;if(!Tt.current||i){const{mappingImgList:c=[]}=H;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:et,getPointCloudByID:jt}=so({generateRects:ot}),ut=k==null?void 0:k.info;if(!t||!d||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:nt}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:s,size:i,zoom:c,trackConfigurable:l})=>{var g;const r={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(r,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const m=lt(s,i,nt,void 0,r);a(s.id);const C=u(m);W(b.Top,s,m,c,C,y),j({newSphereParams:m})},Ft=({polygon:s,size:i,imgList:c,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var m,C,x;const R={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};l===!0&&Object.assign(R,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:v})}),t==null||t.toolInstance;const _=L({},s);let{boxParams:B,newPointList:I}=dt(_,i,nt,void 0,R,r);B=M(rt({tool:st.PointCloud,dataList:[B],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(I==null?void 0:I.length)&&(_.pointList=I);const X=T.includes(_.attribute);ot(B);const Y=f(B),it=(C=n==null?void 0:n.polygonList)!=null?C:[];B.subAttribute=oo.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(x=y==null?void 0:y.inputList)!=null?x:[]:[]),t==null||t.updatePolygonList(Y!=null?Y:[],it,!1),X?a([]):(a(B.id),r&&at(B,_,t,o)),j({newBoxParams:B})},Ht=s=>{const{boxID:i,imageName:c,width:l,height:g,x:r,y:m}=s,C=P.find(I=>I.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(I=>I.imageName===c))return;const R=C.rects.map(I=>I.imageName===c?A(L({},I),{width:l,height:g,x:r,y:m}):I),_=A(L({},C),{rects:R}),B=P.map(I=>I.id===i?_:I);return t==null||t.updatePolygonList(B!=null?B:[]),B},Wt=s=>{const{boxID:i,imageName:c}=s,l=P.find(C=>C.id===i);if(!(l==null?void 0:l.rects))return;const g=l.rects.filter(C=>C.imageName!==c),r=A(L({},l),{rects:g}),m=P.map(C=>C.id===i?r:C);return t==null||t.updatePolygonList(m!=null?m:[]),m},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:c,newSphereList:l})=>{var g;const r=t==null?void 0:t.toolInstance;if(!(h.length===0||!r)){if(s||(k==null?void 0:k.info)){const m=s!=null?s:k==null?void 0:k.info;(g=r==null?void 0:r.selection)==null||g.setSelectedIDs(h[0]);const C=r.selectedPolygon;if(h.length===1&&m){Z({omitView:b.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((c||Q)&&h.length===1){const m=c!=null?c:Q;r.setSelectedID(h[0]);const C=r.selectedPoint;m&&W(b.Top,C,m,void 0,l,y)}}},pt=(s,i,c,l=F.Default)=>{if(ut){let g,r;switch(c){case b.Back:g=yo;break;case b.Side:g=St;break;default:g=St;break}if(r=g(s,i,ut,d.pointCloudInstance),o){const{count:_}=o.getSensesPointZAxisInPolygon(eo(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=A(L({},r),{count:_})}const C=M(rt({tool:st.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],x=r.valid!==C.valid;r=C;const R=Nt(r);return r=R.find(_=>_.id===r.id),Z({omitView:x?void 0:c,polygon:s,boxParams:r,newPointCloudBoxList:R},l),R}},gt=(s,i,c)=>{if(Q){let l,g;switch(c){case b.Back:l=vo;break;case b.Side:l=wt;break;default:l=wt;break}g=l(s,i,Q);const r=ct(g);return W(c,s,g,void 0,r,y),r}},Gt=(s,i)=>{gt(s,i,b.Side)},Jt=(s,i)=>{gt(s,i,b.Back)},Qt=(s,i)=>{pt(s,i,b.Side,F.Single)},Xt=(s,i)=>{pt(s,i,b.Back,F.Single)},Yt=(s,i)=>{const c=At(s.id),l=lt(s,i,nt,c),g=ct(l);W(b.Top,s,l,void 0,g,y)},qt=(s,i)=>{if(Ot){const l=L({},s[0].newPolygon);l.pointList=l.pointList.map(g=>O.transferCanvas2World(g,i)),S(l);return}let c=s.map(({newPolygon:l})=>{const g=jt(l.id),{boxParams:r}=dt(l,i,t.pointCloudInstance,g);return r});if(c=M(rt({tool:st.PointCloud,dataList:c,stepConfig:y,action:"viewUpdateBox"})),c.length===1){const{newPolygon:l}=s[0],g=et(c);Z({polygon:l,boxParams:c[0],newPointCloudBoxList:g},F.Single)}else{const l=et(c);l&&n.syncAllViewPointCloudColor(F.MultiMove,l)}},Kt=s=>{var i,c,l,g,r;if(k){const m=Number(s.widthDefault),C=Number(s.depthDefault),x=Number(s.heightDefault),R=k==null?void 0:k.info.trackID,B=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(q=>(q==null?void 0:q.trackID)===R),I={width:(l=(c=t==null?void 0:t.toolInstance)==null?void 0:c.basicImgInfo)==null?void 0:l.width,height:(r=(g=t==null?void 0:t.toolInstance)==null?void 0:g.basicImgInfo)==null?void 0:r.height},G=B.pointList.map(q=>O.transferCanvas2World(q,I)),X=w.getModifiedRectangleCoordinates(G,x,m),Y=X[0],it=X[2],ft=w.getLineCenterPoint([Y,it]),$t=k.info.center.z-k.info.depth/2,Ct=A(L({},k.info),{center:{x:ft.x,y:ft.y,z:$t+C/2},width:m,height:x,depth:C,valid:!0}),to=et([Ct]);Z({omitView:b["3D"],polygon:B,boxParams:Ct,newPointCloudBoxList:to})}},W=(s,i,c,l,g,r)=>bt(void 0,null,function*(){const m=H==null?void 0:H.url,C={[b.Side]:()=>{Dt(c,i,d,m,r)},[b.Back]:()=>{p&&_t(c,i,p,m,r)},[b.Top]:()=>{kt(c,i,t,o)}};Object.keys(C).forEach(x=>{x!==s&&C[x]()}),l&&(o==null||o.updateCameraZoom(l)),Et(c)}),Z=(s,i=F.Default)=>{const{omitView:c,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:m}=s,C=H==null?void 0:H.url;m&&n.syncAllViewPointCloudColor(i,m);const x={[b.Side]:()=>{Rt(g,l,d,C)},[b.Back]:()=>{p&&Vt(g,l,p,C)},[b.Top]:()=>{at(g,l,t,o)}};Object.keys(x).forEach(R=>{R!==c&&x[R]()}),r&&(o==null||o.updateCameraZoom(r))};return{topViewAddSphere:Mt,topViewAddBox:Ft,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:Z,syncPointCloudPoint:W,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=H){var c,l,g,r,m,C;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(M,!0),vt(M,!0),(c=e==null?void 0:e.setResourceLoading)==null||c.call(e,!0),yield o.loadPCDFile(i.url,(l=y==null?void 0:y.radius)!=null?l:tt,y==null?void 0:y.tipScopeList),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],R=[],_=[],B=[];o.updateTopCamera();const I=go(i.result,i.preResult);if(n.setPointCloudValid(I),(g=n.sideViewInstance)==null||g.clearAllData(),(r=n.backViewInstance)==null||r.clearAllData(),i.result){if(x=O.getBoxParamsFromResultList(i.result),(x==null?void 0:x.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){x=yield o==null?void 0:o.filterPreResult(i.url,y,x);const G=xt(i.result);G[no].result=x,i.result=JSON.stringify(G),n.setPointCloudResult(x)}_=O.getPolygonListFromResultList(i.result),R=O.getLineListFromResultList(i.result),B=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(m=y==null?void 0:y.radius)!=null?m:tt}),o==null||o.generateBoxes(x),o==null||o.generateSpheres(B),yield n.syncAllViewPointCloudColor(F.Default,x,[])}E({pointCloudBoxList:x,polygonList:_,lineList:R,pointCloudSphereList:B}),Lt(M,!1),vt(M,!1),(C=e==null?void 0:e.setResourceLoading)==null||C.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:ot,update2DViewRect:Ht,remove2DViewRect:Wt}},bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=Pt(ht),d=K(e),p=K(n);return{syncToPointCloudBoxList:mt(()=>{const f=d.current,u=p.current;if(u.length===0)return null;const a=new Map,h=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const v=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let D=a.get(v);D||(D=new Map,a.set(v,D)),D.set(T,V),h.add(v)}),a.size){const P=f.map(v=>{var T;const V=v.id;if(h.has(V)){const D=L({},v);return(T=D.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.get(V))==null?void 0:N.get(z))}),D}return v});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,Dt as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,at as synchronizeTopView,lt as topViewPoint2PointCloud,dt as topViewPolygon2PointCloud,Bo as usePointCloudViews,bo as useSyncRectPositionDimensionToPointCloudList};
1
+ import{EPointCloudName as at,TagUtils as ie,MathUtils as R,getCuboidFromPointCloudBox as se}from"@labelbee/lb-annotation";import{EPerspectiveView as X,PointCloudUtils as _,POINT_CLOUD_DEFAULT_STEP as tt,DEFAULT_SPHERE_PARAMS as le}from"@labelbee/lb-utils";import{useContext as vt,useCallback as xt}from"react";import{PointCloudContext as yt}from"../PointCloudContext.js";import{useSingleBox as re}from"./useSingleBox.js";import{useSphere as de}from"./useSphere.js";import ae,{pick as ue}from"lodash";import{useSelector as ce,useDispatch as pe}from"../../../store/ctx.js";import ge from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as H}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as Y,generatePointCloudBoxRects as fe,resolveFileItemValid as Bt}from"../../../utils/index.js";import{PreDataProcess as ut,SetAnnotationLoading as et,SetLoadPCDFileLoading as bt}from"../../../store/annotation/actionCreators.js";import{useHistory as Pe}from"./useHistory.js";import{usePolygon as Ce}from"./usePolygon.js";import{useLatest as ot}from"ahooks";var Le=Object.defineProperty,me=Object.defineProperties,he=Object.getOwnPropertyDescriptors,St=Object.getOwnPropertySymbols,ve=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable,It=(o,n,e)=>n in o?Le(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,y=(o,n)=>{for(var e in n||(n={}))ve.call(n,e)&&It(o,e,n[e]);if(St)for(var e of St(n))xe.call(n,e)&&It(o,e,n[e]);return o},T=(o,n)=>me(o,he(n)),nt=(o,n,e)=>new Promise((u,g)=>{var t=a=>{try{c(e.next(a))}catch(h){g(h)}},P=a=>{try{c(e.throw(a))}catch(h){g(h)}},c=a=>a.done?u(a.value):Promise.resolve(a.value).then(t,P);c((e=e.apply(o,n)).next())});const it=5,q=90,wt=.01,w={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},ct=(o,n,e,u,g)=>{const{x:t,y:P}=_.transferCanvas2World(o,n),{defaultZ:c}=le,a={center:{x:t,y:P,z:c},id:o.id},h=u?y(y({},u),a):T(y({},a),{attribute:"",valid:!0});return g&&Object.assign(h,g),h},pt=(o,n,e,u,g,t)=>{let P=o.pointList.map(D=>_.transferCanvas2World(D,n)),c=0,a=1,h={};if(e){const D=e.getSensesPointZAxisInPolygon(P,void 0,t);t&&D.fittedCoordinates.length>0&&(P=D.fittedCoordinates),c=(D.maxZ+D.minZ)/2,a=D.maxZ-D.minZ,h={count:D.zCount}}const[L,B,U]=P,A=R.getLineCenterPoint([L,U]),V=R.getLineLength(L,B),z=R.getLineLength(B,U),E=R.getRadiusFromQuadrangle(o.pointList);u&&(c=u.center.z,a=u.depth);const N={center:{x:A.x,y:A.y,z:c},width:t?z+wt:z,height:t?V+wt:V,depth:a,rotation:E,id:o.id},F=y(u?y(y({},u),N):T(y({},N),{attribute:"",valid:!0}),h);g&&Object.assign(F,g);const W=P.map(D=>_.transferWorld2Canvas(D,n));return{boxParams:F,newPointList:W}},Rt=(o,n,e)=>{const u={x:o.x-n.x,y:o.y-n.y};return T(y({},e),{center:{x:e.center.x-u.x,y:e.center.y,z:e.center.z-u.y}})},Dt=(o,n,e,u)=>{const[g,t,P]=o.pointList,[c,a,h]=n.pointList,L=R.getLineCenterPoint([g,P]),B=R.getLineCenterPoint([c,h]),A={x:{x:L.x-B.x,y:L.y-B.y}.x,y:0,z:L.y-B.y},V=R.getLineLength(g,t),z=R.getLineLength(c,a),E=V-z,N=R.getLineLength(t,P),F=R.getLineLength(a,h),W=N-F,{newBoxParams:D}=u.getNewBoxBySideUpdate(A,W,E,e);return D},ye=(o,n,e)=>{const u={x:o.x-n.x,y:o.y-n.y};return T(y({},e),{center:{x:e.center.x,y:e.center.y-u.x,z:e.center.z-u.y}})},Be=(o,n,e,u)=>{const[g,t,P]=o.pointList,[c,a,h]=n.pointList,L=R.getLineCenterPoint([g,P]),B=R.getLineCenterPoint([c,h]),A={x:{x:L.x-B.x,y:L.y-B.y}.x,y:0,z:L.y-B.y},V=R.getLineLength(g,t),z=R.getLineLength(c,a),E=V-z,N=R.getLineLength(t,P),F=R.getLineLength(a,h),W=N-F;let{newBoxParams:D}=u.getNewBoxByBackUpdate(A,W,E,e);return D},_t=(o,n,e,u,g)=>{var t;if(!e)return;const{toolInstance:P,pointCloudInstance:c}=e;c.loadPCDFile(u,(t=g==null?void 0:g.radius)!=null?t:q);const{cameraPositionVector:a}=c.updateOrthoCameraBySphere(o,X.Left);c.setInitCameraPosition(a);const{point2d:h,zoom:L}=c.getSphereSidePoint2DCoordinate(o);c.camera.zoom=L,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(L),P.setResult([T(y(y({},n),h),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},Vt=(o,n,e,u)=>{if(!e)return;const{pointCloud2dOperation:g,pointCloudInstance:t}=e;t.loadPCDFileByBox(u,o,{width:it,depth:it});const{cameraPositionVector:P}=t.updateOrthoCamera(o,X.Left);t.setInitCameraPosition(P);const{polygon2d:c,zoom:a}=t.getBoxSidePolygon2DCoordinate(o);t.camera.zoom=a,t.camera.updateProjectionMatrix(),t.render(),g.initPosition(),g.zoomChangeOnCenter(a),g.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},At=(o,n,e,u,g)=>{var t;if(!e)return;const{toolInstance:P,pointCloudInstance:c}=e;c.loadPCDFile(u,(t=g==null?void 0:g.radius)!=null?t:q);const{cameraPositionVector:a}=c.updateOrthoCameraBySphere(o,X.Back);c.setInitCameraPosition(a);const{point2d:h,zoom:L}=c.getSphereBackPoint2DCoordinate(o);c.camera.zoom=L,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(L),P.setResult([T(y(y({},n),h),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(n.id)},Ot=(o,n,e,u)=>{if(!e)return;const{pointCloud2dOperation:g,pointCloudInstance:t}=e;t.loadPCDFileByBox(u,o,{height:it,depth:it});const{cameraPositionVector:P}=t.updateOrthoCamera(o,X.Back);t.setInitCameraPosition(P);const{polygon2d:c,zoom:a}=t.getBoxBackPolygon2DCoordinate(o);t.camera.zoom=a,t.camera.updateProjectionMatrix(),t.render(),g.initPosition(),g.zoomChangeOnCenter(a),g.setResultAndSelectedID([{id:n.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],n.id)},kt=(o,n,e,u)=>{if(!e||!u)return;u.generateSphere(o),u.updateCameraBySphere(o,X.Top),u.render();const{toolInstance:g,pointCloudInstance:t}=e,{point2d:P}=t.getSphereTopPoint2DCoordinate(o),c=[...g.pointList].map(a=>a.id===n.id?T(y(y({},n),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):a);g.setResult(c),g.setSelectedID(n.id)},gt=(o,n,e,u)=>{var g,t;if(!e||!u)return;u.generateBox(o),u.setHighlightColor(o.id),u.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=e,{polygon2d:a}=c.getBoxTopPolygon2DCoordinate(o),h=[...P.polygonList],L=h.find(B=>B.id===n.id);L?(L.pointList=a,L.valid=(g=o.valid)!=null?g:!0):h.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(t=o.valid)!=null?t:!0}),P.setResultAndSelectedID(h,n.id)},be=o=>{const n=vt(yt),{topViewInstance:e,sideViewInstance:u,backViewInstance:g,mainViewInstance:t,addPointCloudBox:P,addPointCloudSphere:c,setSelectedIDs:a,selectedIDs:h,pointCloudBoxList:L,pointCloudSphereList:B,hideAttributes:U,setHighlight2DDataList:A,cuboidBoxIn2DView:V,imageSizes:z,history:E,linkageImageNameRectMap:N}=n,{addHistory:F,initHistory:W,pushHistoryUnderUpdatePolygon:D,pushHistoryWithList:Tt}=Pe(),{selectedPolygon:Ut}=Ce(),{getPointCloudSphereByID:zt,updatePointCloudSphere:ft,selectedSphere:K}=de(),{currentData:O,config:v}=ce(s=>{const{stepList:i,step:d,imgList:r,imgIndex:p}=s.annotation;return{currentData:r[p],config:Y(ge.getCurrentStepInfo(d,i).config)}}),M=pe(),Nt=ot(V),jt=ot(N),Et=xt((s,i)=>{const d=jt.current,r=i.id;return s.filter(l=>{if(!l)return!1;const C=d.get(l.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),st=s=>{const{enableAutoMap2DRect:i=!1}=v;if(!Nt.current||i){const{mappingImgList:d=[]}=O;fe({pointCloudBox:s,mappingImgList:d,imageSizes:z},{prepareRectsFn:Et})}},{selectedBox:k,updateSelectedBox:Ft,updateSelectedBoxes:lt,getPointCloudByID:Mt}=re({generateRects:st}),Pt=k==null?void 0:k.info;if(!e||!u||!g)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{},restorePreResult:()=>nt(void 0,null,function*(){return!1})};const{pointCloudInstance:rt}=e,Ht=s=>{t==null||t.generateSphere(s),t==null||t.controls.update(),t==null||t.render()},Wt=({newPoint:s,size:i,zoom:d,trackConfigurable:r})=>{var p;const l={attribute:(p=e.toolInstance.defaultAttribute)!=null?p:""};r===!0&&Object.assign(l,{trackID:_.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:B})});const C=ct(s,i,rt,void 0,l);a(s.id);const f=c(C);J(w.Top,s,C,d,f,v),F({newSphereParams:C})},Zt=({polygon:s,size:i,imgList:d,trackConfigurable:r,zoom:p,intelligentFit:l})=>{var C,f,m;const I={attribute:(C=e.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(I,{trackID:_.getNextTrackID({imgList:[],extraBoxList:L,extraSphereList:B})}),e==null||e.toolInstance;const x=y({},s);let{boxParams:b,newPointList:S}=pt(x,i,rt,void 0,I,l);b=M(ut({tool:at.PointCloud,dataList:[b],stepConfig:v,action:"viewUpdateBox"}))[0],l&&(S==null?void 0:S.length)&&(x.pointList=S);const G=U.includes(x.attribute);st(b);const Z=P(b),dt=(f=n==null?void 0:n.polygonList)!=null?f:[];b.subAttribute=ie.getDefaultResultByConfig((v==null?void 0:v.secondaryAttributeConfigurable)?(m=v==null?void 0:v.inputList)!=null?m:[]:[]),e==null||e.updatePolygonList(Z!=null?Z:[],dt,!1),G?a([]):(a(b.id),l&&gt(b,x,e,t)),F({newBoxParams:b})},Gt=s=>{const{boxID:i,imageName:d,width:r,height:p,x:l,y:C}=s,f=L.find(S=>S.id===i);if(!(f==null?void 0:f.rects)||!f.rects.find(S=>S.imageName===d))return;const I=f.rects.map(S=>S.imageName===d?T(y({},S),{width:r,height:p,x:l,y:C}):S),x=T(y({},f),{rects:I}),b=L.map(S=>S.id===i?x:S);return e==null||e.updatePolygonList(b!=null?b:[]),b},Jt=s=>{const{boxID:i,imageName:d}=s,r=L.find(f=>f.id===i);if(!(r==null?void 0:r.rects))return;const p=r.rects.filter(f=>f.imageName!==d),l=T(y({},r),{rects:p}),C=L.map(f=>f.id===i?l:f);return e==null||e.updatePolygonList(C!=null?C:[]),C},Qt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:d,newSphereList:r})=>{var p;const l=e==null?void 0:e.toolInstance;if(!(h.length===0||!l)){if(s||(k==null?void 0:k.info)){const C=s!=null?s:k==null?void 0:k.info;(p=l==null?void 0:l.selection)==null||p.setSelectedIDs(h[0]);const f=l.selectedPolygon;if(h.length===1&&C){Q({omitView:w.Top,polygon:f,boxParams:C,newPointCloudBoxList:i});return}}if((d||K)&&h.length===1){const C=d!=null?d:K;l.setSelectedID(h[0]);const f=l.selectedPoint;C&&J(w.Top,f,C,void 0,r,v)}}},Ct=(s,i,d,r=H.Default)=>{if(Pt){let p,l;switch(d){case w.Back:p=Be;break;case w.Side:p=Dt;break;default:p=Dt;break}if(l=p(s,i,Pt,u.pointCloudInstance),t){const{count:x}=t.getSensesPointZAxisInPolygon(se(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=T(y({},l),{count:x})}const f=M(ut({tool:at.PointCloud,dataList:[l],stepConfig:v,action:"viewUpdateBox"}))[0],m=l.valid!==f.valid;l=f;const I=Ft(l);return l=I.find(x=>x.id===l.id),Q({omitView:m?void 0:d,polygon:s,boxParams:l,newPointCloudBoxList:I},r),I}},Lt=(s,i,d)=>{if(K){let r,p;switch(d){case w.Back:r=ye;break;case w.Side:r=Rt;break;default:r=Rt;break}p=r(s,i,K);const l=ft(p);return J(d,s,p,void 0,l,v),l}},Xt=(s,i)=>{Lt(s,i,w.Side)},Yt=(s,i)=>{Lt(s,i,w.Back)},qt=(s,i)=>{Ct(s,i,w.Side,H.Single)},Kt=(s,i)=>{Ct(s,i,w.Back,H.Single)},$t=(s,i)=>{const d=zt(s.id),r=ct(s,i,rt,d),p=ft(r);J(w.Top,s,r,void 0,p,v)},te=(s,i)=>{if(Ut){const r=y({},s[0].newPolygon);r.pointList=r.pointList.map(p=>_.transferCanvas2World(p,i)),D(r);return}let d=s.map(({newPolygon:r})=>{const p=Mt(r.id),{boxParams:l}=pt(r,i,e.pointCloudInstance,p);return l});if(d=M(ut({tool:at.PointCloud,dataList:d,stepConfig:v,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=s[0],p=lt(d);Q({polygon:r,boxParams:d[0],newPointCloudBoxList:p},H.Single)}else{const r=lt(d);r&&n.syncAllViewPointCloudColor(H.MultiMove,r)}},ee=s=>{var i,d,r,p,l;if(k){const C=Number(s.widthDefault),f=Number(s.depthDefault),m=Number(s.heightDefault),I=k==null?void 0:k.info.trackID,b=((i=e==null?void 0:e.toolInstance)==null?void 0:i.polygonList).find($=>($==null?void 0:$.trackID)===I),S={width:(r=(d=e==null?void 0:e.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(l=(p=e==null?void 0:e.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:l.height},j=b.pointList.map($=>_.transferCanvas2World($,S)),G=R.getModifiedRectangleCoordinates(j,m,C),Z=G[0],dt=G[2],mt=R.getLineCenterPoint([Z,dt]),oe=k.info.center.z-k.info.depth/2,ht=T(y({},k.info),{center:{x:mt.x,y:mt.y,z:oe+f/2},width:C,height:m,depth:f,valid:!0}),ne=lt([ht]);Q({omitView:w["3D"],polygon:b,boxParams:ht,newPointCloudBoxList:ne})}},J=(s,i,d,r,p,l)=>nt(void 0,null,function*(){const C=O==null?void 0:O.url,f={[w.Side]:()=>{_t(d,i,u,C,l)},[w.Back]:()=>{g&&At(d,i,g,C,l)},[w.Top]:()=>{kt(d,i,e,t)}};Object.keys(f).forEach(m=>{m!==s&&f[m]()}),r&&(t==null||t.updateCameraZoom(r)),Ht(d)}),Q=(s,i=H.Default)=>{const{omitView:d,polygon:r,boxParams:p,zoom:l,newPointCloudBoxList:C}=s,f=O==null?void 0:O.url;C&&n.syncAllViewPointCloudColor(i,C);const m={[w.Side]:()=>{Vt(p,r,u,f)},[w.Back]:()=>{g&&Ot(p,r,g,f)},[w.Top]:()=>{gt(p,r,e,t)}};Object.keys(m).forEach(I=>{I!==d&&m[I]()}),l&&(t==null||t.updateCameraZoom(l))};return{topViewAddSphere:Wt,topViewAddBox:Zt,topViewSelectedChanged:Qt,topViewUpdatePoint:$t,sideViewUpdatePoint:Xt,backViewUpdatePoint:Yt,topViewUpdateBox:te,sideViewUpdateBox:qt,backViewUpdateBox:Kt,syncPointCloudViews:Q,syncPointCloudPoint:J,pointCloudBoxListUpdated:s=>{e.updatePolygonList(s),t==null||t.generateBoxes(s)},initPointCloud3d:s=>{if(!t)return;const i=_.getDefaultOrthographicParams(s);t.initOrthographicCamera(i),t.initRenderer(),t.render()},updatePointCloudData:(...s)=>nt(void 0,[...s],function*(i=O){var d,r,p,l,C,f;if(!(i==null?void 0:i.url)||!t)return;A([]),et(M,!0),bt(M,!0),(d=o==null?void 0:o.setResourceLoading)==null||d.call(o,!0),yield t.loadPCDFile(i.url,(r=v==null?void 0:v.radius)!=null?r:q,v==null?void 0:v.tipScopeList),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let m=[],I=[],x=[],b=[];t.updateTopCamera();const S=Bt(i.result,i.preResult);if(n.setPointCloudValid(S),(p=n.sideViewInstance)==null||p.clearAllData(),(l=n.backViewInstance)==null||l.clearAllData(),i.result){if(m=_.getBoxParamsFromResultList(i.result),(m==null?void 0:m.length)>0&&i.isPreResult&&(v==null?void 0:v.lowerLimitPointsNumInBox)>0){m=yield t==null?void 0:t.filterPreResult(i.url,v,m);const j=Y(i.result);j[tt].result=m,i.result=JSON.stringify(j),n.setPointCloudResult(m)}x=_.getPolygonListFromResultList(i.result),I=_.getLineListFromResultList(i.result),b=_.getSphereParamsFromResultList(i.result),e.updateData(i.url,i.result,{radius:(C=v==null?void 0:v.radius)!=null?C:q}),t==null||t.generateBoxes(m),t==null||t.generateSpheres(b),yield n.syncAllViewPointCloudColor(H.Default,m,[])}W({pointCloudBoxList:m,polygonList:x,lineList:I,pointCloudSphereList:b}),et(M,!1),bt(M,!1),(f=o==null?void 0:o.setResourceLoading)==null||f.call(o,!1)}),restorePreResult:()=>nt(void 0,null,function*(){var s,i,d,r,p,l;if(!(O==null?void 0:O.url)||!t)return!1;const C=(s=Y(O.preResult))==null?void 0:s[tt];if(!C)return!1;const f=Y(O.result||"{}");f[tt]=ae.cloneDeep(C);let m=JSON.stringify(f);const I=O.url;et(M,!0),(i=o==null?void 0:o.setResourceLoading)==null||i.call(o,!0);try{A([]),a(void 0),t.clearAllBox(),t.clearAllSphere();let x=[],b=[],S=[],j=[];if(n.setPointCloudValid(Bt(m,O.preResult)),(d=n.sideViewInstance)==null||d.clearAllData(),(r=n.backViewInstance)==null||r.clearAllData(),x=_.getBoxParamsFromResultList(m),(x==null?void 0:x.length)>0&&(v==null?void 0:v.lowerLimitPointsNumInBox)>0){x=yield t==null?void 0:t.filterPreResult(I,v,x);const Z=Y(m);Z[tt].result=x,m=JSON.stringify(Z),n.setPointCloudResult(x)}S=_.getPolygonListFromResultList(m),b=_.getLineListFromResultList(m),j=_.getSphereParamsFromResultList(m);const{rectList:G}=_.parsePointCloudCurrentResult(m);return n.setPointCloudResult(x),n.setPolygonList(S),n.setLineList(b),n.setPointCloudSphereList(j),n.setRectList(G),e.updateData(I,m,{radius:(p=v==null?void 0:v.radius)!=null?p:q}),t.generateBoxes(x),t.generateSpheres(j),yield n.syncAllViewPointCloudColor(H.Default,x,[]),Tt({pointCloudBoxList:x,polygonList:S,lineList:b,pointCloudSphereList:j}),!0}finally{et(M,!1),(l=o==null?void 0:o.setResourceLoading)==null||l.call(o,!1)}}),updateViewsByDefaultSize:ee,generateRects:st,update2DViewRect:Gt,remove2DViewRect:Jt}},Se=()=>{const{pointCloudBoxList:o,rectList:n,setPointCloudResult:e}=vt(yt),u=ot(o),g=ot(n);return{syncToPointCloudBoxList:xt(()=>{const P=u.current,c=g.current;if(c.length===0)return null;const a=new Map,h=new Set;if(c.filter(L=>L.extId!==void 0).forEach(L=>{const B=L.extId,U=L.imageName,A=ue(L,["x","y","width","height"]);let V=a.get(B);V||(V=new Map,a.set(B,V)),V.set(U,A),h.add(B)}),a.size){const L=P.map(B=>{var U;const A=B.id;if(h.has(A)){const V=y({},B);return(U=V.rects)==null||U.forEach(z=>{var E;const N=z.imageName;Object.assign(z,(E=a.get(A))==null?void 0:E.get(N))}),V}return B});return e(L),L}return null},[])}};export{At as syncBackViewByPoint,_t as syncSideViewByPoint,kt as syncTopViewByPoint,Ot as synchronizeBackView,Vt as synchronizeSideView,gt as synchronizeTopView,ct as topViewPoint2PointCloud,pt as topViewPolygon2PointCloud,be as usePointCloudViews,Se as useSyncRectPositionDimensionToPointCloudList};
@@ -1 +1 @@
1
- import{timeFormat as C}from"../../../../../utils/audio.js";import{classnames as v}from"../../../../../utils/index.js";import{CloseCircleFilled as k,EnvironmentFilled as N,ScissorOutlined as j}from"@ant-design/icons";import t,{useState as R,useRef as x,useEffect as A,useMemo as _,useLayoutEffect as b}from"react";import{EClipStatus as h,TIME_SLICE_TYPE as F,ETimeSliceType as T}from"../../constant.js";import V from"../timeSliceRange/index.js";import $ from"../ToolTipForClip.js";import{getDisplayContent as D}from"../videoTrack/index.js";import r from"./index.module.scss.js";import{decimalReserved as O}from"../../../../videoPlayer/utils.js";import{LabelBeeContext as w}from"../../../../../store/ctx.js";import{connect as M}from"react-redux";import{useTranslation as y}from"react-i18next";const B=({type:e})=>e===T.Time?t.createElement(N,null):t.createElement(j,{rotate:270}),H=()=>{const{t:e}=y();return t.createElement("div",{className:r.noContent},t.createElement("div",null,e("NoClippedData")),t.createElement("div",null,t.createElement("span",{className:r.hotkey},"X"),e("ClipSlice")),t.createElement("div",null,t.createElement("span",{className:r.hotkey},"E"),e("TimeStamp")))},W=({children:e,scrollRef:n})=>{const o=e.length===0;return t.createElement("div",{ref:n,className:v({[r.empty]:o,[r.timeSliceListContent]:!0})},o?t.createElement(H,null):e)},X=({timeSliceProps:e,index:n,exportContext:o,onItemClick:a})=>{const{selectedID:d,attributeList:s,removeTimeSlice:u}=o;return t.createElement("div",{key:n,className:v({[r.timeSliceItem]:!0,[r.timeSliceItemActivated]:e.id===d}),onClick:()=>{a(e)}},t.createElement($,{slot:t.createElement("div",{className:r.timeSliceItemContent},t.createElement("div",{className:r.textOverflow},`${n+1}\u3001\u3010${F[e.type]}\u3011 ${D(e,s)}`),t.createElement("div",{className:v({[r.textOverflow]:!0})},t.createElement(B,{type:e.type}),t.createElement("span",{style:{marginLeft:10}},`${C(e.start,"ss:SS")} ${e.end&&e.type===T.Period?"~ "+C(e.end,"ss:SS")+", "+O(e.end-e.start,2)+"s":""}`))),item:e,attributeList:s}),t.createElement(k,{className:r.timeSliceItemDeleteIcon,onClick:c=>{c.stopPropagation(),u(e)}}))},Y=e=>{const{toolInstance:n}=e,{selectedID:o,result:a,videoPlayer:d,clipStatus:s,updateSelectedSliceTimeProperty:u}=(n==null?void 0:n.exportContext)||{},[c,S]=R(0),p=x(null),f=x(!1),{t:I}=y();A(()=>(n&&n.singleOn("changeClipSidebar",l=>{S(i=>i+1)}),()=>{var l;(l=n==null?void 0:n.unbindAll)==null||l.call(n,"changeClipSidebar")}),[n]);const L=a==null?void 0:a.find(l=>l.id===o),m=_(()=>{var l;return[...(l=a==null?void 0:a.filter(i=>i.end!==null))!=null?l:[]].sort((i,E)=>i.start-E.start)},[a,c]),g=l=>{f.current=!0,n.exportContext.onSelectedTimeSlice(l)};return b(()=>{var l;if(!o||!p.current)return;if(f.current){f.current=!1;return}const i=m.findIndex(E=>E.id===o);i>=0&&((l=p.current.children[i])==null||l.scrollIntoView({block:"nearest"}))},[o,c,m]),(n==null?void 0:n.exportContext)?t.createElement("div",null,t.createElement("div",{className:r.timeSliceListHeader},I("AnnotatedList")),t.createElement(W,{scrollRef:p},m==null?void 0:m.map((l,i)=>t.createElement(X,{timeSliceProps:l,index:i,key:l.id,exportContext:(n==null?void 0:n.exportContext)||{},onItemClick:g}))),t.createElement(V,{selectedTimeSlice:L,videoPlayer:d,updateTimeForSelected:u,disabled:s===h.Clipping})):null},q=({annotation:e})=>{const{toolInstance:n}=e;return{toolInstance:n}};var z=M(q,null,null,{context:w})(Y);export{z as default};
1
+ import{timeFormat as x}from"../../../../../utils/audio.js";import{classnames as E}from"../../../../../utils/index.js";import{CloseCircleFilled as N,EnvironmentFilled as j,ScissorOutlined as R}from"@ant-design/icons";import t,{useState as b,useRef as T,useEffect as A,useMemo as _,useLayoutEffect as h}from"react";import{EClipStatus as F,TIME_SLICE_TYPE as V,ETimeSliceType as y}from"../../constant.js";import $ from"../timeSliceRange/index.js";import D from"../ToolTipForClip.js";import{getDisplayContent as O}from"../videoTrack/index.js";import r from"./index.module.scss.js";import{decimalReserved as w}from"../../../../videoPlayer/utils.js";import{LabelBeeContext as M}from"../../../../../store/ctx.js";import{connect as B}from"react-redux";import{useTranslation as S}from"react-i18next";const H=({type:e})=>e===y.Time?t.createElement(j,null):t.createElement(R,{rotate:270}),W=()=>{const{t:e}=S();return t.createElement("div",{className:r.noContent},t.createElement("div",null,e("NoClippedData")),t.createElement("div",null,t.createElement("span",{className:r.hotkey},"X"),e("ClipSlice")),t.createElement("div",null,t.createElement("span",{className:r.hotkey},"E"),e("TimeStamp")))},X=({children:e,scrollRef:n})=>{const o=e.length===0;return t.createElement("div",{ref:n,className:E({[r.empty]:o,[r.timeSliceListContent]:!0})},o?t.createElement(W,null):e)},Y=({timeSliceProps:e,index:n,exportContext:o,onItemClick:a})=>{const{selectedID:d,attributeList:c,removeTimeSlice:u}=o;return t.createElement("div",{key:n,className:E({[r.timeSliceItem]:!0,[r.timeSliceItemActivated]:e.id===d}),onClick:()=>{a(e)}},t.createElement(D,{slot:t.createElement("div",{className:r.timeSliceItemContent},t.createElement("div",{className:r.textOverflow},`${n+1}\u3001\u3010${V[e.type]}\u3011 ${O(e,c)}`),t.createElement("div",{className:E({[r.textOverflow]:!0})},t.createElement(H,{type:e.type}),t.createElement("span",{style:{marginLeft:10}},`${x(e.start,"ss:SS")} ${e.end&&e.type===y.Period?"~ "+x(e.end,"ss:SS")+", "+w(e.end-e.start,2)+"s":""}`))),item:e,attributeList:c}),t.createElement(N,{className:r.timeSliceItemDeleteIcon,onClick:s=>{s.stopPropagation(),u(e)}}))},q=e=>{const{toolInstance:n}=e,{selectedID:o,result:a,videoPlayer:d,clipStatus:c,updateSelectedSliceTimeProperty:u,linkageConfigurable:s}=(n==null?void 0:n.exportContext)||{},[C,I]=b(0),p=T(null),f=T(!1),{t:g}=S();A(()=>(n&&n.singleOn("changeClipSidebar",l=>{I(i=>i+1)}),()=>{var l;(l=n==null?void 0:n.unbindAll)==null||l.call(n,"changeClipSidebar")}),[n]);const L=a==null?void 0:a.find(l=>l.id===o),m=_(()=>{var l;return[...(l=a==null?void 0:a.filter(i=>i.end!==null))!=null?l:[]].sort((i,v)=>i.start-v.start)},[a,C]),k=l=>{s&&(f.current=!0),n.exportContext.onSelectedTimeSlice(l)};return h(()=>{var l;if(!s||!o||!p.current)return;if(f.current){f.current=!1;return}const i=m.findIndex(v=>v.id===o);i>=0&&((l=p.current.children[i])==null||l.scrollIntoView({block:"nearest"}))},[s,o,C,m]),(n==null?void 0:n.exportContext)?t.createElement("div",null,t.createElement("div",{className:r.timeSliceListHeader},g("AnnotatedList")),t.createElement(X,{scrollRef:s?p:void 0},m==null?void 0:m.map((l,i)=>t.createElement(Y,{timeSliceProps:l,index:i,key:l.id,exportContext:(n==null?void 0:n.exportContext)||{},onItemClick:k}))),t.createElement($,{selectedTimeSlice:L,videoPlayer:d,updateTimeForSelected:u,disabled:c===F.Clipping})):null},z=({annotation:e})=>{const{toolInstance:n}=e;return{toolInstance:n}};var G=B(z,null,null,{context:M})(q);export{G as default};
@@ -1,2 +1,2 @@
1
- import{MathUtils as w,CommonToolUtils as $,uuid as B,TagUtils as z,AttributeUtils as G}from"@labelbee/lb-annotation";import{jsonParser as V}from"../../../utils/index.js";import{precisionAdd as R,precisionMinus as J,isImageValue as H}from"../../../utils/audio.js";import{message as b}from"antd";import E from"lodash";import T from"react";import k from"./index.module.scss.js";import{VideoClipToolContextProvider as W}from"./VideoClipToolContext.js";import{EClipStatus as d,ETimeSliceType as I,PER_SLICE_CHANGE as x,SLICE_MIN_TIME as A}from"./constant.js";import{VideoPlayer as q}from"../../videoPlayer/index.js";import K from"./components/videoTimeSlicesOverVideo/index.js";import Q from"../../../assets/annotation/video/icon_videoCutting.svg.js";import{decimalReserved as P}from"../../videoPlayer/utils.js";var X=Object.defineProperty,Y=Object.defineProperties,Z=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,tt=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable,j=(h,s,t)=>s in h?X(h,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[s]=t,U=(h,s)=>{for(var t in s||(s={}))tt.call(s,t)&&j(h,t,s[t]);if(O)for(var t of O(s))et.call(s,t)&&j(h,t,s[t]);return h},M=(h,s)=>Y(h,Z(s));class it extends T.Component{constructor(s){super(s);this.fns=new Map,this.throttledUpdateTime=E.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===d.Clipping){b.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:u}=this.state.result[this.selectedSliceIndex],a=w.withinRange(R(n,t),[0,J(u===I.Time?r:l,x)]);this.updateSelectedSliceTimeProperty(a,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===d.Clipping){b.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===I.Time){b.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:n,start:u}=r,a=w.withinRange(R(n,t),[R(u,x),l]);this.updateSelectedSliceTimeProperty(a,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:E.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!$.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(-x);break;case"=":this.updateSelectedSliceTimeStartByPer(x);break;case"[":this.updateSelectedSliceTimeEndByPer(-x);break;case"]":this.updateSelectedSliceTimeEndByPer(x);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:r}=this.state;r===d.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!==d.Clipping)return;const r=t.findIndex(l=>l.id===e);r>-1&&(t.splice(r,1),this.setState({result:t,selectedID:"",clipStatus:d.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,u,a;if(this.disabled)return;const{clipStatus:c,selectedAttribute:p}=this.state,o=c!==d.Clipping;let f=o?d.Clipping:d.Stop,{result:S,selectedID:m,textValue:y}=this.state;const g=E.cloneDeep(S),_=t||((e=this.videoPlayer)==null?void 0:e.currentTime),L=(i=this.videoPlayer)==null?void 0:i.duration;if(L===void 0||_===void 0)return;const N=P(_,2);if(o){const v=B(),C={};m=v;const D=((r=this.props.config)==null?void 0:r.customAttributeInput)===!0?"\u65E0\u5C5E\u6027":p;g.push({start:N,end:null,attribute:D,textAttribute:this.defaultTextAttribute,duration:L,id:v,type:I.Period,subAttribute:C,text:this.getSubAttributeShowText(C,(n=(l=this.props.config)==null?void 0:l.inputList)!=null?n:[])}),y=this.defaultTextAttribute}else{const v=g.findIndex(D=>D.id===m),C=g[v];C&&(_-C.start<A?(g.splice(v,1),b.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${A}s`),f=d.Stop,m="",y=""):(g[v].end=P(_,2),(u=this.videoPlayer)==null||u.pause(),b.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${S.length}`)))}const F={clipStatus:f,result:g,selectedID:m,textValue:y};((a=this.props.config)==null?void 0:a.customAttributeInput)&&o&&(F.selectedAttribute="\u65E0\u5C5E\u6027"),this.setState(F),this.updateSidebar()},this.addTime=()=>{var t,e,i,r,l,n;if(this.disabled)return;const{result:u,selectedAttribute:a,selectedID:c}=this.state,p=B(),o=E.cloneDeep(u),f=((t=this.videoPlayer)==null?void 0:t.currentTime)||0,S=((e=this.props.config)==null?void 0:e.customAttributeInput)?"\u65E0\u5C5E\u6027":a;o.push({start:f,end:f,attribute:S,textAttribute:this.defaultTextAttribute,id:p,type:I.Time,duration:(r=(i=this.videoPlayer)==null?void 0:i.duration)!=null?r:0,subAttribute:{}});const m={result:o,selectedID:p,textValue:this.defaultTextAttribute};((l=this.props.config)==null?void 0:l.customAttributeInput)&&(m.selectedAttribute="\u65E0\u5C5E\u6027");const y=o.find(g=>g.id===c);this.isClipping&&y?(delete m.selectedID,delete m.textValue,b.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${o.length-1}`)):(n=this.videoPlayer)==null||n.pause(),this.setState(m),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t}),this.selectTimeSliceByTime(t)},this.findTimeSliceByTime=t=>{const e=P(t,2);return this.state.result.find(i=>i.end===null?!1:i.type===I.Time?P(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===d.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var r,l;const{result:n}=this.state,u=n.find(a=>a.id===t);if(u){const a=u.duration,c=e==="left",p=c?"start":"end",o=c?-a*i:a*i,f=c?[0,Math.max(((r=u.end)!=null?r:0)-A,0)]:[u.start+A,a],S=w.withinRange(o+((l=u==null?void 0:u[p])!=null?l:0),f);u[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:u,videoError:a,valid:c,currentTime:p}=this.state;return T.createElement("div",{className:k.clipContainer},T.createElement(q,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:n,pageForward:r,pageJump:l,valid:c,setVideoRef:o=>{this.videoPlayer=o},showVideoTrack:!a,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),T.createElement(K,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:u,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&&T.createElement("i",{className:k.clipping,style:{backgroundImage:Q}}))},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 a=V(n[l].result)[`step_${this.stepInfo().step}`],c=(a==null?void 0:a.result)||[],p=(a==null?void 0:a.extraResult)||{globalTag:{}},o=(r=(i=this.props.config)==null?void 0:i.inputList)!=null?r:[];c.forEach(S=>{S.text=this.getSubAttributeShowText(S.subAttribute,o)});const f=H(n[l].result||"[]");this.setState({result:c,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:d.Stop,valid:f,extraResult:p},()=>{this.updateSidebar(),f||b.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 u=l.find(a=>a.id===n);u&&(u.subAttribute||(u.subAttribute={}),u.subAttribute[t]=e,u.text=this.getSubAttributeShowText(u.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:M(U({},i),{globalTag:M(U({},i.globalTag||{}),{[t]:e})})})},this.getSubAttributeShowText=(t,e)=>{if(!t||(e==null?void 0:e.length)===0)return"";let i="";return z.getTagNameList(t,e).forEach(l=>{i+=`
2
- ${l.keyName}: ${l.value.join("\u3001")}`}),i},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:d.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===d.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 G.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 V((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 T.createElement(W,{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())}}export{it as default};
1
+ import{MathUtils as w,CommonToolUtils as $,uuid as F,TagUtils as z,AttributeUtils as G}from"@labelbee/lb-annotation";import{jsonParser as B}from"../../../utils/index.js";import{precisionAdd as R,precisionMinus as J,isImageValue as H}from"../../../utils/audio.js";import{message as b}from"antd";import E from"lodash";import T from"react";import V from"./index.module.scss.js";import{VideoClipToolContextProvider as W}from"./VideoClipToolContext.js";import{EClipStatus as d,ETimeSliceType as I,PER_SLICE_CHANGE as x,SLICE_MIN_TIME as A}from"./constant.js";import{VideoPlayer as q}from"../../videoPlayer/index.js";import K from"./components/videoTimeSlicesOverVideo/index.js";import Q from"../../../assets/annotation/video/icon_videoCutting.svg.js";import{decimalReserved as P}from"../../videoPlayer/utils.js";var X=Object.defineProperty,Y=Object.defineProperties,Z=Object.getOwnPropertyDescriptors,O=Object.getOwnPropertySymbols,tt=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable,j=(f,s,t)=>s in f?X(f,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):f[s]=t,U=(f,s)=>{for(var t in s||(s={}))tt.call(s,t)&&j(f,t,s[t]);if(O)for(var t of O(s))et.call(s,t)&&j(f,t,s[t]);return f},M=(f,s)=>Y(f,Z(s));class it extends T.Component{constructor(s){super(s);this.fns=new Map,this.throttledUpdateTime=E.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===d.Clipping){b.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:u,type:n}=this.state.result[this.selectedSliceIndex],a=w.withinRange(R(u,t),[0,J(n===I.Time?r:l,x)]);this.updateSelectedSliceTimeProperty(a,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===d.Clipping){b.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===I.Time){b.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:u,start:n}=r,a=w.withinRange(R(u,t),[R(n,x),l]);this.updateSelectedSliceTimeProperty(a,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:E.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!$.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(-x);break;case"=":this.updateSelectedSliceTimeStartByPer(x);break;case"[":this.updateSelectedSliceTimeEndByPer(-x);break;case"]":this.updateSelectedSliceTimeEndByPer(x);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:r}=this.state;r===d.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!==d.Clipping)return;const r=t.findIndex(l=>l.id===e);r>-1&&(t.splice(r,1),this.setState({result:t,selectedID:"",clipStatus:d.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,u,n,a;if(this.disabled)return;const{clipStatus:c,selectedAttribute:h}=this.state,o=c!==d.Clipping;let p=o?d.Clipping:d.Stop,{result:S,selectedID:g,textValue:y}=this.state;const m=E.cloneDeep(S),_=t||((e=this.videoPlayer)==null?void 0:e.currentTime),L=(i=this.videoPlayer)==null?void 0:i.duration;if(L===void 0||_===void 0)return;const N=P(_,2);if(o){const v=F(),C={};g=v;const D=((r=this.props.config)==null?void 0:r.customAttributeInput)===!0?"\u65E0\u5C5E\u6027":h;m.push({start:N,end:null,attribute:D,textAttribute:this.defaultTextAttribute,duration:L,id:v,type:I.Period,subAttribute:C,text:this.getSubAttributeShowText(C,(u=(l=this.props.config)==null?void 0:l.inputList)!=null?u:[])}),y=this.defaultTextAttribute}else{const v=m.findIndex(D=>D.id===g),C=m[v];C&&(_-C.start<A?(m.splice(v,1),b.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${A}s`),p=d.Stop,g="",y=""):(m[v].end=P(_,2),(n=this.videoPlayer)==null||n.pause(),b.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${S.length}`)))}const k={clipStatus:p,result:m,selectedID:g,textValue:y};((a=this.props.config)==null?void 0:a.customAttributeInput)&&o&&(k.selectedAttribute="\u65E0\u5C5E\u6027"),this.setState(k),this.updateSidebar()},this.addTime=()=>{var t,e,i,r,l,u;if(this.disabled)return;const{result:n,selectedAttribute:a,selectedID:c}=this.state,h=F(),o=E.cloneDeep(n),p=((t=this.videoPlayer)==null?void 0:t.currentTime)||0,S=((e=this.props.config)==null?void 0:e.customAttributeInput)?"\u65E0\u5C5E\u6027":a;o.push({start:p,end:p,attribute:S,textAttribute:this.defaultTextAttribute,id:h,type:I.Time,duration:(r=(i=this.videoPlayer)==null?void 0:i.duration)!=null?r:0,subAttribute:{}});const g={result:o,selectedID:h,textValue:this.defaultTextAttribute};((l=this.props.config)==null?void 0:l.customAttributeInput)&&(g.selectedAttribute="\u65E0\u5C5E\u6027");const y=o.find(m=>m.id===c);this.isClipping&&y?(delete g.selectedID,delete g.textValue,b.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${o.length-1}`)):(u=this.videoPlayer)==null||u.pause(),this.setState(g),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=P(t,2);return this.state.result.find(i=>i.end===null?!1:i.type===I.Time?P(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===d.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var r,l;const{result:u}=this.state,n=u.find(a=>a.id===t);if(n){const a=n.duration,c=e==="left",h=c?"start":"end",o=c?-a*i:a*i,p=c?[0,Math.max(((r=n.end)!=null?r:0)-A,0)]:[n.start+A,a],S=w.withinRange(o+((l=n==null?void 0:n[h])!=null?l:0),p);n[h]=S,this.throttledUpdateTime(S)}this.setState({result:[...u]}),this.updateSidebar()},this.renderMediaContent=()=>{var t,e,i,r;const{pageForward:l,pageJump:u,pageBackward:n}=this.props,{result:a,videoError:c,valid:h,currentTime:o}=this.state;return T.createElement("div",{className:V.clipContainer},T.createElement(q,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:n,pageForward:l,pageJump:u,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}),T.createElement(K,{key:(e=this.videoPlayer)==null?void 0:e.currentTime,result:a,currentTime:o,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&&T.createElement("i",{className:V.clipping,style:{backgroundImage:Q}}))},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:u}=e;if(!u[l])return;const a=B(u[l].result)[`step_${this.stepInfo().step}`],c=(a==null?void 0:a.result)||[],h=(a==null?void 0:a.extraResult)||{globalTag:{}},o=(r=(i=this.props.config)==null?void 0:i.inputList)!=null?r:[];c.forEach(S=>{S.text=this.getSubAttributeShowText(S.subAttribute,o)});const p=H(u[l].result||"[]");this.setState({result:c,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:d.Stop,valid:p,extraResult:h},()=>{this.updateSidebar(),p||b.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:u}=this.state;if(u){const n=l.find(a=>a.id===u);n&&(n.subAttribute||(n.subAttribute={}),n.subAttribute[t]=e,n.text=this.getSubAttributeShowText(n.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:M(U({},i),{globalTag:M(U({},i.globalTag||{}),{[t]:e})})})},this.getSubAttributeShowText=(t,e)=>{if(!t||(e==null?void 0:e.length)===0)return"";let i="";return z.getTagNameList(t,e).forEach(l=>{i+=`
2
+ ${l.keyName}: ${l.value.join("\u3001")}`}),i},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:d.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===d.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 G.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 B((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 T.createElement(W,{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())}}export{it as default};
@@ -1 +1 @@
1
- import o from"react";import A from"./components/controller/index.js";import j from"../videoAnnotate/videoClipTool/components/videoTrack/index.js";import{getClassName as h}from"../../utils/dom.js";import{cKeyCode as M}from"@labelbee/lb-annotation";import{decimalReserved as n}from"./utils.js";import z from"../fileException/index.js";const l=M.default,v=o.createContext({isPlay:!1,playPause:()=>{},updateNextPlaybackRate:()=>{},playbackRate:1,currentTime:0,duration:0,buffered:0,setCurrentTime:()=>{},imgList:[],imgIndex:-1,pageBackward:()=>{},pageJump:y=>{},pageForward:()=>{},addTime:()=>{},toggleClipStatus:()=>{}}),U=300,f=.1,m=[.1,.2,.3,.4,.5,1,1.5,2,4,6,8,16];class E extends o.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=m.findIndex(r=>r===this.state.playbackRate);let i=e?Math.min(t+1,m.length-1):Math.max(t-1,0);this.changePlaybackPate(m[i])},this.fastForward=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime+f)},this.rewind=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime-f)},this.keydown=e=>{e.keyCode===l.Space&&(e.preventDefault(),this.playPause()),e.keyCode===l.Up&&(e.preventDefault(),this.updateNextPlaybackRate()),e.keyCode===l.Down&&(e.preventDefault(),this.updateNextPlaybackRate(!1)),e.keyCode===l.Left&&(e.preventDefault(),this.rewind()),e.keyCode===l.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:n((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=()=>{this.timeInterval=window.setInterval(()=>{var e,t,i,r,d;if(this.videoElm)try{if(((e=this.videoElm)==null?void 0:e.buffered.length)>0){const s=(t=this.videoElm)==null?void 0:t.buffered.end(0);this.setState({buffered:s})}(d=(r=this.props).updateCurrentTime)==null||d.call(r,n((i=this.videoElm)==null?void 0:i.currentTime,1))}catch(s){console.error(s)}},U)},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=n((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=o.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:d}=this.state,{imgList:s,imgIndex:k,pageBackward:g,pageJump:T,pageForward:R,valid:P,footer:b,drawLayerSlot:u}=this.props,C=isNaN(i)?0:Math.max(n(i,1)-t,0),{playPause:c,updateNextPlaybackRate:_,onPause:w,onPlay:x,onTimeUpdate:S,resetVideoData:V,setDuration:D,setCurrentTime:I,onError:L,videoRef:N,videoSrc:F}=this;return o.createElement(v.Provider,{value:{videoRef:this.videoRef,addTime:this.props.addTime,toggleClipStatus:this.props.toggleClipStatus,isPlay:a,playPause:c,updateNextPlaybackRate:_,playbackRate:e,currentTime:t,duration:i,buffered:r,setCurrentTime:I,imgIndex:k,imgList:s,pageBackward:g,pageJump:T,pageForward:R}},o.createElement(o.Fragment,null,u==null?void 0:u({currentTime:t,remainingTime:C,zoom:1,currentPos:{x:0,y:0}}),o.createElement("div",{className:h("video-wrapper")},o.createElement("div",{className:h("video-container")},o.createElement("video",{ref:N,className:h(this.props.showVideoTrack?"video-track":"video"),src:F,onPause:w,onPlay:x,onTimeUpdate:S,onLoadedMetadata:V,onError:L,onDurationChange:D,width:"100%",height:"100%",onClick:c}),this.props.showVideoTrack&&o.createElement(j,{currentTime:t,onTrackResize:this.props.onTrackResize,onTrackResizeStart:()=>{var p;(p=this.videoElm)==null||p.pause()},readonly:!1}),o.createElement(z,{fileType:"video",errorProps:{reloadImage:this.reload,backgroundColor:"#e2e2e2",ignoreOffsetY:!0,isError:d},invalidProps:{isValid:P}})),o.createElement(A,{footer:b}))))}}export{E as VideoPlayer,v as VideoPlayerCtx,E as default};
1
+ import o from"react";import F from"./components/controller/index.js";import j from"../videoAnnotate/videoClipTool/components/videoTrack/index.js";import{getClassName as c}from"../../utils/dom.js";import{cKeyCode as M}from"@labelbee/lb-annotation";import{decimalReserved as l}from"./utils.js";import U from"../fileException/index.js";const d=M.default,y=o.createContext({isPlay:!1,playPause:()=>{},updateNextPlaybackRate:()=>{},playbackRate:1,currentTime:0,duration:0,buffered:0,setCurrentTime:()=>{},imgList:[],imgIndex:-1,pageBackward:()=>{},pageJump:P=>{},pageForward:()=>{},addTime:()=>{},toggleClipStatus:()=>{}}),z=50,O=300,T=.1,p=[.1,.2,.3,.4,.5,1,1.5,2,4,6,8,16];class k extends o.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=p.findIndex(r=>r===this.state.playbackRate);let i=e?Math.min(t+1,p.length-1):Math.max(t-1,0);this.changePlaybackPate(p[i])},this.fastForward=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime+T)},this.rewind=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime-T)},this.keydown=e=>{e.keyCode===d.Space&&(e.preventDefault(),this.playPause()),e.keyCode===d.Up&&(e.preventDefault(),this.updateNextPlaybackRate()),e.keyCode===d.Down&&(e.preventDefault(),this.updateNextPlaybackRate(!1)),e.keyCode===d.Left&&(e.preventDefault(),this.rewind()),e.keyCode===d.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:l((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?O:z;this.timeInterval=window.setInterval(()=>{var i,r,n,h,m,u;if(this.videoElm)try{if(((i=this.videoElm)==null?void 0:i.buffered.length)>0){const s=(r=this.videoElm)==null?void 0:r.buffered.end(0);e?this.setState({buffered:s}):this.setState({currentTime:l((n=this.videoElm)==null?void 0:n.currentTime,1),buffered:s})}e&&((u=(m=this.props).updateCurrentTime)==null||u.call(m,l((h=this.videoElm)==null?void 0:h.currentTime,1)))}catch(s){console.error(s)}},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=l((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=o.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:n}=this.state,{imgList:h,imgIndex:m,pageBackward:u,pageJump:s,pageForward:R,valid:g,footer:_,drawLayerSlot:v}=this.props,b=isNaN(i)?0:Math.max(l(i,1)-t,0),{playPause:f,updateNextPlaybackRate:C,onPause:w,onPlay:S,onTimeUpdate:x,resetVideoData:V,setDuration:D,setCurrentTime:I,onError:L,videoRef:N,videoSrc:A}=this;return o.createElement(y.Provider,{value:{videoRef:this.videoRef,addTime:this.props.addTime,toggleClipStatus:this.props.toggleClipStatus,isPlay:a,playPause:f,updateNextPlaybackRate:C,playbackRate:e,currentTime:t,duration:i,buffered:r,setCurrentTime:I,imgIndex:m,imgList:h,pageBackward:u,pageJump:s,pageForward:R}},o.createElement(o.Fragment,null,v==null?void 0:v({currentTime:t,remainingTime:b,zoom:1,currentPos:{x:0,y:0}}),o.createElement("div",{className:c("video-wrapper")},o.createElement("div",{className:c("video-container")},o.createElement("video",{ref:N,className:c(this.props.showVideoTrack?"video-track":"video"),src:A,onPause:w,onPlay:S,onTimeUpdate:x,onLoadedMetadata:V,onError:L,onDurationChange:D,width:"100%",height:"100%",onClick:f}),this.props.showVideoTrack&&o.createElement(j,{currentTime:t,onTrackResize:this.props.onTrackResize,onTrackResizeStart:()=>{var E;(E=this.videoElm)==null||E.pause()},readonly:!1}),o.createElement(U,{fileType:"video",errorProps:{reloadImage:this.reload,backgroundColor:"#e2e2e2",ignoreOffsetY:!0,isError:n},invalidProps:{isValid:g}})),o.createElement(F,{footer:_}))))}}export{k as VideoPlayer,y as VideoPlayerCtx,k as default};
@@ -1 +1 @@
1
- import r,{useRef as p,useState as C}from"react";import{Col as y,Popconfirm as E}from"antd";import{useTranslation as i}from"react-i18next";import{prefix as g}from"../../../../constant/index.js";const k={color:"#CCCCCC"},f=({info:e})=>{const{t}=i();return e.key.startsWith("sure")?r.createElement("div",{key:e.key},`${t("ConfirmTo")}${e.name.slice(0)}\uFF1F`,(e==null?void 0:e.content)?e.content:""):r.createElement("span",null,e.name)},h=({icon:e})=>typeof e=="string"?r.createElement("img",{width:23,height:25,src:e}):e,u=({isHover:e,info:t})=>{const l=!!t.forbidOperation,a=t.key===e&&!l;let o={color:a?"#666fff":""};return l&&(o=k),r.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))}},r.createElement("div",{className:"icon"},r.createElement(h,{icon:a?t.hoverSvg:t.imgSvg})),r.createElement("div",{className:"toolName",style:o},t.name))},x=({allOperation:e,setBatchSetValid:t,valid:l})=>{const a=p(null),[o,c]=C(null),{t:m}=i(),d=Math.floor(24/e.length),v=n=>n.forbidConfirm?r.createElement(u,{info:n,isHover:o}):t&&n.key==="setValidity"?t({valid:l,isHover:!!o,singleSetQuestionImg:n.onClick}):r.createElement(E,{title:r.createElement(f,{info:n}),placement:"topRight",okText:m("Confirm"),cancelText:m("Cancel"),getPopupContainer:()=>{var s;return(s=a.current)!=null?s:document.body},onConfirm:n.onClick,overlayClassName:`${g}-pop-confirm`},r.createElement("div",null,r.createElement(u,{info:n,isHover:o})));return r.createElement("div",{className:"generalOperation",ref:a},e.map((n,s)=>r.createElement(y,{span:d,key:s,className:"generalOperation-col"},r.createElement("div",{key:n.key,className:"item",onMouseEnter:()=>{c(n.key)},onMouseLeave:()=>{c(null)}},v(n)))))};export{x as default};
1
+ import t,{useRef as C,useState as p}from"react";import{Col as E,Popconfirm as y}from"antd";import{useTranslation as i}from"react-i18next";import{prefix as g}from"../../../../constant/index.js";const k={color:"#CCCCCC"},h=({info:e})=>{const{t:r}=i(),l=e.key.startsWith("sure")?t.createElement("div",{key:e.key},`${r("ConfirmTo")}${e.name.slice(0)}\uFF1F`,(e==null?void 0:e.content)?e.content:""):t.createElement("span",null,e.name);return e.confirmExtra?t.createElement("div",null,l,e.confirmExtra):l},f=({icon:e})=>typeof e=="string"?t.createElement("img",{width:23,height:25,src:e}):e,u=({isHover:e,info:r})=>{const l=!!r.forbidOperation,a=r.key===e&&!l;let o={color:a?"#666fff":""};return l&&(o=k),t.createElement("div",{style:{cursor:l?"not-allowed":"default"},onClick:()=>{var c;return(r==null?void 0:r.forbidConfirm)&&!l&&((c=r==null?void 0:r.onClick)==null?void 0:c.call(r))}},t.createElement("div",{className:"icon"},t.createElement(f,{icon:a?r.hoverSvg:r.imgSvg})),t.createElement("div",{className:"toolName",style:o},r.name))},x=({allOperation:e,setBatchSetValid:r,valid:l})=>{const a=C(null),[o,c]=p(null),{t:m}=i(),d=Math.floor(24/e.length),v=n=>n.forbidConfirm?t.createElement(u,{info:n,isHover:o}):r&&n.key==="setValidity"?r({valid:l,isHover:!!o,singleSetQuestionImg:n.onClick}):t.createElement(y,{title:t.createElement(h,{info:n}),placement:"topRight",okText:m("Confirm"),cancelText:m("Cancel"),getPopupContainer:()=>{var s;return(s=a.current)!=null?s:document.body},onConfirm:n.onClick,onVisibleChange:n.onConfirmVisibleChange,overlayClassName:`${g}-pop-confirm`},t.createElement("div",null,t.createElement(u,{info:n,isHover:o})));return t.createElement("div",{className:"generalOperation",ref:a},e.map((n,s)=>t.createElement(E,{span:d,key:s,className:"generalOperation-col"},t.createElement("div",{key:n.key,className:"item",onMouseEnter:()=>{c(n.key)},onMouseLeave:()=>{c(null)}},v(n)))))};export{x as default};
@@ -1 +1 @@
1
- import s,{useState as f,useCallback as U}from"react";import{connect as g}from"react-redux";import w from"../../../../utils/StepUtils.js";import{jsonParser as v}from"../../../../utils/index.js";import C from"./ActionsConfirm.js";import y from"./useOperationList.js";import{LabelBeeContext as S}from"../../../../store/ctx.js";import T from"../../../../assets/annotation/pointCloudTool/unitAttribute.svg.js";import V from"../../../../assets/annotation/pointCloudTool/unitAttributeForbid.svg.js";import A from"../../../../assets/annotation/pointCloudTool/unitAttributeHover.svg.js";import{useTranslation as I}from"react-i18next";import E from"../../../../components/pointCloudView/components/UnifyParamsModal/index.js";import{useSingleBox as M}from"../../../../components/pointCloudView/hooks/useSingleBox.js";import{composeResultByToolInstance as _}from"../../../../store/annotation/reducer.js";import{useStatus as R}from"../../../../components/pointCloudView/hooks/useStatus.js";const x=o=>{var t,i;const n=w.getCurrentStepInfo((t=o.annotation)==null?void 0:t.step,(i=o.annotation)==null?void 0:i.stepList);return{toolInstance:o.annotation.toolInstance,stepInfo:n,imgList:o.annotation.imgList,imgIndex:o.annotation.imgIndex,stepList:o.annotation.stepList}},$=({toolInstance:o,stepInfo:t,hideValidity:i})=>{const n=y(o),r=v(t==null?void 0:t.config),e=[n.empty];return(t==null?void 0:t.dataSourceStep)===0&&!i&&e.push(n.setValidity),(r==null?void 0:r.copyBackwardResult)&&e.push(n.copyPrevious),s.createElement(C,{allOperation:e})},D=g(x,null,null,{context:S})(({toolInstance:o,stepInfo:t,imgList:i,stepList:n,imgIndex:r,setBatchSetValid:e})=>{const{t:P}=I(),{selectedBox:m}=M(),u=y(o),[j,c]=f(!1),[L,b]=f([]),{isPointCloudDetectionPattern:k,isPointCloudSegmentationPattern:h}=R(),p=v(t.config);let a=[u.copyPrevious,u.empty,u.setValidity];if(k&&p.trackConfigurable===!0){const l=!m,B={name:P("UnifyParams"),key:"UnifyParams",imgSvg:l?V:T,hoverSvg:A,onClick:()=>{b(_({toolInstance:o,imgList:i,imgIndex:r,stepList:n})),c(!0)},forbidConfirm:!0,forbidOperation:l};a.unshift(B)}const O=U(()=>{c(!1)},[]),d=m==null?void 0:m.info;return h&&(a=a.filter(l=>!["setValidity","copyPrevious"].includes(l.key))),s.createElement(s.Fragment,null,s.createElement(C,{allOperation:a,setBatchSetValid:e,valid:o==null?void 0:o.valid}),s.createElement(E,{id:d==null?void 0:d.trackID,visible:j,onCancel:O,config:p,imgList:L}))});var F=g(x,null,null,{context:S})($);export{D as PointCloudOperation,F as default};
1
+ import i,{useState as d,useMemo as I,useCallback as V}from"react";import{Checkbox as D}from"antd";import{connect as S}from"react-redux";import M from"../../../../utils/StepUtils.js";import{jsonParser as v}from"../../../../utils/index.js";import h from"./ActionsConfirm.js";import j from"./useOperationList.js";import{LabelBeeContext as x}from"../../../../store/ctx.js";import F from"../../../../assets/annotation/pointCloudTool/unitAttribute.svg.js";import K from"../../../../assets/annotation/pointCloudTool/unitAttributeForbid.svg.js";import $ from"../../../../assets/annotation/pointCloudTool/unitAttributeHover.svg.js";import{useTranslation as G}from"react-i18next";import N from"../../../../components/pointCloudView/components/UnifyParamsModal/index.js";import{useSingleBox as H}from"../../../../components/pointCloudView/hooks/useSingleBox.js";import{composeResultByToolInstance as q}from"../../../../store/annotation/reducer.js";import{useStatus as z}from"../../../../components/pointCloudView/hooks/useStatus.js";import{POINT_CLOUD_DEFAULT_STEP as J}from"@labelbee/lb-utils";var Q=Object.defineProperty,W=Object.defineProperties,X=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,Y=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,k=(t,o,e)=>o in t?Q(t,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[o]=e,tt=(t,o)=>{for(var e in o||(o={}))Y.call(o,e)&&k(t,e,o[e]);if(w)for(var e of w(o))Z.call(o,e)&&k(t,e,o[e]);return t},ot=(t,o)=>W(t,X(o));const L=t=>{var o,e;const r=M.getCurrentStepInfo((o=t.annotation)==null?void 0:o.step,(e=t.annotation)==null?void 0:e.stepList);return{toolInstance:t.annotation.toolInstance,stepInfo:r,imgList:t.annotation.imgList,imgIndex:t.annotation.imgIndex,stepList:t.annotation.stepList}},et=({toolInstance:t,stepInfo:o,hideValidity:e})=>{const r=j(t),s=v(o==null?void 0:o.config),a=[r.empty];return(o==null?void 0:o.dataSourceStep)===0&&!e&&a.push(r.setValidity),(s==null?void 0:s.copyBackwardResult)&&a.push(r.copyPrevious),i.createElement(h,{allOperation:a})},nt=S(L,null,null,{context:x})(({toolInstance:t,stepInfo:o,imgList:e,stepList:r,imgIndex:s,setBatchSetValid:a})=>{const{t:P}=G(),{selectedBox:c}=H(),u=j(t),[R,g]=d(!1),[T,E]=d([]),[C,m]=d(!1),{isPointCloudDetectionPattern:y,isPointCloudSegmentationPattern:U}=z(),_=v(o.config),l=e==null?void 0:e[s],O=I(()=>{var n;const f=(n=v(l==null?void 0:l.preResult))==null?void 0:n[J];return Boolean(f)},[l==null?void 0:l.preResult])&&y,A=ot(tt({},u.empty),{confirmExtra:O?i.createElement("div",{onClick:n=>n.stopPropagation(),style:{marginTop:8,textAlign:"left",width:"100%"}},i.createElement(D,{checked:C,onChange:n=>m(n.target.checked),style:{marginLeft:0}},P("KeepPreAnnotation"))):void 0,onConfirmVisibleChange:n=>{n&&m(!1)},onClick:()=>{t.clearResult({keepPreResult:O&&C}),m(!1)}});let p=[u.copyPrevious,A,u.setValidity];if(y&&_.trackConfigurable===!0){const n=!c,f={name:P("UnifyParams"),key:"UnifyParams",imgSvg:n?K:F,hoverSvg:$,onClick:()=>{E(q({toolInstance:t,imgList:e,imgIndex:s,stepList:r})),g(!0)},forbidConfirm:!0,forbidOperation:n};p.unshift(f)}const B=V(()=>{g(!1)},[]),b=c==null?void 0:c.info;return U&&(p=p.filter(n=>!["setValidity","copyPrevious"].includes(n.key))),i.createElement(i.Fragment,null,i.createElement(h,{allOperation:p,setBatchSetValid:a,valid:t==null?void 0:t.valid}),i.createElement(N,{id:b==null?void 0:b.trackID,visible:R,onCancel:B,config:_,imgList:T}))});var rt=S(L,null,null,{context:x})(et);export{nt as PointCloudOperation,rt as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.24.0-alpha.62",
3
+ "version": "1.24.0-alpha.64",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -43,9 +43,9 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "^4.6.2",
46
- "@labelbee/lb-annotation": "1.28.0-alpha.32",
47
- "@labelbee/lb-utils": "1.20.0-alpha.9",
48
- "@labelbee/wavesurfer": "1.1.0",
46
+ "@labelbee/lb-annotation": "1.28.0-alpha.33",
47
+ "@labelbee/lb-utils": "1.20.0-alpha.10",
48
+ "@labelbee/wavesurfer": "1.1.1-alpha.1",
49
49
  "@types/react-dom": "18.3.1",
50
50
  "@types/react-transition-group": "^4.4.9",
51
51
  "ahooks": "3.8.5",
@@ -89,6 +89,7 @@
89
89
  "@svgr/rollup": "^8.1.0",
90
90
  "@types/diff-match-patch": "^1.0.36",
91
91
  "@types/lodash": "^4.14.168",
92
+ "@types/node": "^18.19.130",
92
93
  "@types/react": "16.14.62",
93
94
  "@types/react-redux": "^7.1.16",
94
95
  "@types/react-syntax-highlighter": "^15.5.0",