@labelbee/lb-components 1.24.0-alpha.50 → 1.24.0-alpha.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/2DViewWorker.js +1 -1
- package/dist/components/pointCloudView/PointCloudListener.js +1 -1
- package/dist/components/pointCloudView/hooks/useConfig.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/components/videoAnnotate/videoClipTool/components/videoTimeSlicesOverVideo/index.js +2 -1
- package/dist/components/videoAnnotate/videoClipTool/components/videoTimeSlicesOverVideo/index.module.scss.js +1 -1
- package/dist/components/videoAnnotate/videoClipTool/components/videoTrack/index.js +1 -1
- package/dist/components/videoAnnotate/videoClipTool/index.js +1 -1
- package/dist/index.css +20 -6
- package/dist/types/components/pointCloudView/hooks/useConfig.d.ts +2 -1
- package/dist/types/components/videoAnnotate/videoClipTool/index.d.ts +6 -0
- package/dist/types/views/MainView/sidebar/VideoClipToolAttributeList/index.d.ts +11 -0
- package/dist/views/MainView/sidebar/SwitchAttributeList/index.js +1 -1
- package/dist/views/MainView/sidebar/VideoClipToolAttributeList/index.js +1 -0
- package/dist/views/MainView/sidebar/index.js +1 -1
- package/es/_virtual/2DViewWorker.js +1 -1
- package/es/components/pointCloudView/PointCloudListener.js +1 -1
- package/es/components/pointCloudView/hooks/useConfig.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/videoAnnotate/videoClipTool/components/videoTimeSlicesOverVideo/index.js +2 -1
- package/es/components/videoAnnotate/videoClipTool/components/videoTimeSlicesOverVideo/index.module.scss.js +1 -1
- package/es/components/videoAnnotate/videoClipTool/components/videoTrack/index.js +1 -1
- package/es/components/videoAnnotate/videoClipTool/index.js +1 -1
- package/es/index.css +20 -6
- package/es/views/MainView/sidebar/SwitchAttributeList/index.js +1 -1
- package/es/views/MainView/sidebar/VideoClipToolAttributeList/index.js +1 -0
- package/es/views/MainView/sidebar/index.js +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudContext as
|
|
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 +1 @@
|
|
|
1
|
-
import{PointCloudContext as
|
|
1
|
+
import{PointCloudContext as a}from"../PointCloudContext.js";import{useContext as s}from"react";const p=()=>{const{topViewInstance:n,sideViewInstance:u,backViewInstance:r,mainViewInstance:i}=s(a);return{syncAllViewsConfig:o=>{[n,u,r].forEach(e=>{var t,l;e==null||e.updateConfig(o);const d=(l=(t=o==null?void 0:o.attributeList)==null?void 0:t[0])==null?void 0:l.value;d&&(e==null||e.pointCloud2dOperation.setDefaultAttribute(d))}),i==null||i.setConfig(o)},reRenderTopViewRange:o=>{var e,t,l;(t=(e=n==null?void 0:n.pointCloudInstance)==null?void 0:e.generateRange)==null||t.call(e,o),(l=n==null?void 0:n.pointCloudInstance)==null||l.render()},reRenderTopViewTipScopeList:(o=[])=>{var e,t,l;(t=(e=n==null?void 0:n.pointCloudInstance)==null?void 0:e.generateTipScopeList)==null||t.call(e,o),(l=n==null?void 0:n.pointCloudInstance)==null||l.render()}}};export{p as useConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as X,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as mt,useCallback as ht}from"react";import{PointCloudContext as xt}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as 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 rt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as lt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as K}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,ho=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,x=(e,n)=>{for(var t in n||(n={}))ho.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))xo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((d,p)=>{var o=a=>{try{u(t.next(a))}catch(h){p(h)}},f=a=>{try{u(t.throw(a))}catch(h){p(h)}},u=a=>a.done?d(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const $=5,tt=90,It=.01,b={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(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?x(x({},d),a):A(x({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},at=(e,n,t,d,p,o)=>{let f=e.pointList.map(D=>O.transferCanvas2World(D,n)),u=0,a=1,h={};if(t){const D=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&D.fittedCoordinates.length>0&&(f=D.fittedCoordinates),u=(D.maxZ+D.minZ)/2,a=D.maxZ-D.minZ,h={count:D.zCount}}const[P,L,T]=f,V=w.getLineCenterPoint([P,T]),R=w.getLineLength(P,L),U=w.getLineLength(L,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?R+It:R,depth:a,rotation:N,id:e.id},j=x(d?x(x({},d),z):A(x({},z),{attribute:"",valid:!0}),h);p&&Object.assign(j,p);const E=f.map(D=>O.transferWorld2Canvas(D,n));return{boxParams:j,newPointList:E}},wt=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x-d.x,y:t.center.y,z:t.center.z-d.y}})},Dt=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j,{newBoxParams:D}=d.getNewBoxBySideUpdate(V,E,N,t);return D},Lo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x,y:t.center.y-d.x,z:t.center.z-d.y}})},vo=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j;let{newBoxParams:D}=d.getNewBoxByBackUpdate(V,E,N,t);return D},St=(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,X.Left);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{width:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.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,X.Back);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{height:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.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,X.Top),d.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(x(x({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},ct=(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(L=>L.id===n.id);P?(P.pointList=a,P.valid=(p=e.valid)!=null?p:!0):h.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(h,n.id)},yo=e=>{const n=mt(xt),{topViewInstance:t,sideViewInstance:d,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:a,selectedIDs:h,pointCloudBoxList:P,pointCloudSphereList:L,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:R,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:E,pushHistoryUnderUpdatePolygon:D}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:ut,selectedSphere:Y}=ro(),{currentData:W,config:y}=ao(s=>{const{stepList:i,step:c,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:rt(uo.getCurrentStepInfo(c,i).config)}}),M=co(),Tt=K(R),Ut=K(z),zt=ht((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=[]}=W;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:et,getPointCloudByID:jt}=so({generateRects:ot}),pt=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:L})});const m=dt(s,i,nt,void 0,r);a(s.id);const C=u(m);J(b.Top,s,m,c,C,y),j({newSphereParams:m})},Ht=({polygon:s,size:i,imgList:c,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var m,C,S;const _={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};l===!0&&Object.assign(_,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:L})}),t==null||t.toolInstance;const v=x({},s);let{boxParams:I,newPointList:B}=at(v,i,nt,void 0,_,r);I=M(lt({tool:st.PointCloud,dataList:[I],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(B==null?void 0:B.length)&&(v.pointList=B);const G=T.includes(v.attribute);ot(I);const H=f(I),it=(C=n==null?void 0:n.polygonList)!=null?C:[];I.subAttribute=oo.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(S=y==null?void 0:y.inputList)!=null?S:[]:[]),t==null||t.updatePolygonList(H!=null?H:[],it,!1),G?a([]):(a(I.id),r&&ct(I,v,t,o)),j({newBoxParams:I})},Ft=s=>{const{boxID:i,imageName:c,width:l,height:g,x:r,y:m}=s,C=P.find(B=>B.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(B=>B.imageName===c))return;const _=C.rects.map(B=>B.imageName===c?A(x({},B),{width:l,height:g,x:r,y:m}):B),v=A(x({},C),{rects:_}),I=P.map(B=>B.id===i?v:B);return t==null||t.updatePolygonList(I!=null?I:[]),I},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(x({},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){Q({omitView:b.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((c||Y)&&h.length===1){const m=c!=null?c:Y;r.setSelectedID(h[0]);const C=r.selectedPoint;m&&J(b.Top,C,m,void 0,l,y)}}},gt=(s,i,c,l=F.Default)=>{if(pt){let g,r;switch(c){case b.Back:g=vo;break;case b.Side:g=Dt;break;default:g=Dt;break}if(r=g(s,i,pt,d.pointCloudInstance),o){const{count:v}=o.getSensesPointZAxisInPolygon(eo(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=A(x({},r),{count:v})}const C=M(lt({tool:st.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],S=r.valid!==C.valid;r=C;const _=Nt(r);return r=_.find(v=>v.id===r.id),Q({omitView:S?void 0:c,polygon:s,boxParams:r,newPointCloudBoxList:_},l),_}},ft=(s,i,c)=>{if(Y){let l,g;switch(c){case b.Back:l=Lo;break;case b.Side:l=wt;break;default:l=wt;break}g=l(s,i,Y);const r=ut(g);return J(c,s,g,void 0,r,y),r}},Gt=(s,i)=>{ft(s,i,b.Side)},Jt=(s,i)=>{ft(s,i,b.Back)},Qt=(s,i)=>{gt(s,i,b.Side,F.Single)},Xt=(s,i)=>{gt(s,i,b.Back,F.Single)},Yt=(s,i)=>{const c=At(s.id),l=dt(s,i,nt,c),g=ut(l);J(b.Top,s,l,void 0,g,y)},qt=(s,i)=>{if(Ot){const l=x({},s[0].newPolygon);l.pointList=l.pointList.map(g=>O.transferCanvas2World(g,i)),D(l);return}let c=s.map(({newPolygon:l})=>{const g=jt(l.id),{boxParams:r}=at(l,i,t.pointCloudInstance,g);return r});if(c=M(lt({tool:st.PointCloud,dataList:c,stepConfig:y,action:"viewUpdateBox"})),c.length===1){const{newPolygon:l}=s[0],g=et(c);Q({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),S=Number(s.heightDefault),_=k==null?void 0:k.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(q=>(q==null?void 0:q.trackID)===_),B={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},Z=I.pointList.map(q=>O.transferCanvas2World(q,B)),G=w.getModifiedRectangleCoordinates(Z,S,m),H=G[0],it=G[2],Ct=w.getLineCenterPoint([H,it]),$t=k.info.center.z-k.info.depth/2,Pt=A(x({},k.info),{center:{x:Ct.x,y:Ct.y,z:$t+C/2},width:m,height:S,depth:C,valid:!0}),to=et([Pt]);Q({omitView:b["3D"],polygon:I,boxParams:Pt,newPointCloudBoxList:to})}},J=(s,i,c,l,g,r)=>bt(void 0,null,function*(){const m=W==null?void 0:W.url,C={[b.Side]:()=>{St(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(S=>{S!==s&&C[S]()}),l&&(o==null||o.updateCameraZoom(l)),Et(c)}),Q=(s,i=F.Default)=>{const{omitView:c,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:m}=s,C=W==null?void 0:W.url;m&&n.syncAllViewPointCloudColor(i,m);const S={[b.Side]:()=>{Rt(g,l,d,C)},[b.Back]:()=>{p&&Vt(g,l,p,C)},[b.Top]:()=>{ct(g,l,t,o)}};Object.keys(S).forEach(_=>{_!==c&&S[_]()}),r&&(o==null||o.updateCameraZoom(r))};return{topViewAddSphere:Mt,topViewAddBox:Ht,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:Q,syncPointCloudPoint:J,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=W){var c,l,g,r,m,C,S,_;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),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],I=[],B=[],Z=[];o.updateTopCamera();const G=(r=(g=rt(i.result))==null?void 0:g.valid)!=null?r:!0;if(n.setPointCloudValid(G),(m=n.sideViewInstance)==null||m.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(v=O.getBoxParamsFromResultList(i.result),(v==null?void 0:v.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(i.url,y,v);const H=rt(i.result);H[no].result=v,i.result=JSON.stringify(H),n.setPointCloudResult(v)}B=O.getPolygonListFromResultList(i.result),I=O.getLineListFromResultList(i.result),Z=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(S=y==null?void 0:y.radius)!=null?S:tt}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(Z),yield n.syncAllViewPointCloudColor(F.Default,v,[])}E({pointCloudBoxList:v,polygonList:B,lineList:I,pointCloudSphereList:Z}),Lt(M,!1),vt(M,!1),(_=e==null?void 0:e.setResourceLoading)==null||_.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:ot,update2DViewRect:Ft,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(xt),d=K(e),p=K(n);return{syncToPointCloudBoxList:ht(()=>{const f=d.current,u=p.current;if(u.length===0)return null;const a=new Map,h=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const L=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let R=a.get(L);R||(R=new Map,a.set(L,R)),R.set(T,V),h.add(L)}),a.size){const P=f.map(L=>{var T;const V=L.id;if(h.has(V)){const R=x({},L);return(T=R.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.get(V))==null?void 0:N.get(z))}),R}return L});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
|
|
1
|
+
import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as X,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as mt,useCallback as ht}from"react";import{PointCloudContext as xt}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as 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 rt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as lt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as K}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,ho=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,x=(e,n)=>{for(var t in n||(n={}))ho.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))xo.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((d,p)=>{var o=a=>{try{u(t.next(a))}catch(h){p(h)}},f=a=>{try{u(t.throw(a))}catch(h){p(h)}},u=a=>a.done?d(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const $=5,tt=90,It=.01,b={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(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?x(x({},d),a):A(x({},a),{attribute:"",valid:!0});return p&&Object.assign(h,p),h},at=(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,L,T]=f,V=w.getLineCenterPoint([P,T]),R=w.getLineLength(P,L),U=w.getLineLength(L,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?R+It:R,depth:a,rotation:N,id:e.id},j=x(d?x(x({},d),z):A(x({},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(x({},t),{center:{x:t.center.x-d.x,y:t.center.y,z:t.center.z-d.y}})},St=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-U,z=w.getLineLength(o,f),j=w.getLineLength(a,h),E=z-j,{newBoxParams:S}=d.getNewBoxBySideUpdate(V,E,N,t);return S},Lo=(e,n,t)=>{const d={x:e.x-n.x,y:e.y-n.y};return A(x({},t),{center:{x:t.center.x,y:t.center.y-d.x,z:t.center.z-d.y}})},vo=(e,n,t,d)=>{const[p,o,f]=e.pointList,[u,a,h]=n.pointList,P=w.getLineCenterPoint([p,f]),L=w.getLineCenterPoint([u,h]),V={x:{x:P.x-L.x,y:P.y-L.y}.x,y:0,z:P.y-L.y},R=w.getLineLength(p,o),U=w.getLineLength(u,a),N=R-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,X.Left);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{width:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.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,X.Back);u.setInitCameraPosition(a);const{point2d:h,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(x(x({},n),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,d)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(d,e,{height:$,depth:$});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.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,X.Top),d.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(x(x({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},ct=(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(L=>L.id===n.id);P?(P.pointList=a,P.valid=(p=e.valid)!=null?p:!0):h.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(h,n.id)},yo=e=>{const n=mt(xt),{topViewInstance:t,sideViewInstance:d,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:a,selectedIDs:h,pointCloudBoxList:P,pointCloudSphereList:L,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:R,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:E,pushHistoryUnderUpdatePolygon:S}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:ut,selectedSphere:Y}=ro(),{currentData:W,config:y}=ao(s=>{const{stepList:i,step:c,imgList:l,imgIndex:g}=s.annotation;return{currentData:l[g],config:rt(uo.getCurrentStepInfo(c,i).config)}}),M=co(),Tt=K(R),Ut=K(z),zt=ht((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=[]}=W;po({pointCloudBox:s,mappingImgList:c,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:et,getPointCloudByID:jt}=so({generateRects:ot}),pt=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:L})});const m=dt(s,i,nt,void 0,r);a(s.id);const C=u(m);J(b.Top,s,m,c,C,y),j({newSphereParams:m})},Ht=({polygon:s,size:i,imgList:c,trackConfigurable:l,zoom:g,intelligentFit:r})=>{var m,C,D;const _={attribute:(m=t.toolInstance.defaultAttribute)!=null?m:""};l===!0&&Object.assign(_,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:L})}),t==null||t.toolInstance;const v=x({},s);let{boxParams:I,newPointList:B}=at(v,i,nt,void 0,_,r);I=M(lt({tool:st.PointCloud,dataList:[I],stepConfig:y,action:"viewUpdateBox"}))[0],r&&(B==null?void 0:B.length)&&(v.pointList=B);const G=T.includes(v.attribute);ot(I);const H=f(I),it=(C=n==null?void 0:n.polygonList)!=null?C:[];I.subAttribute=oo.getDefaultResultByConfig((y==null?void 0:y.secondaryAttributeConfigurable)?(D=y==null?void 0:y.inputList)!=null?D:[]:[]),t==null||t.updatePolygonList(H!=null?H:[],it,!1),G?a([]):(a(I.id),r&&ct(I,v,t,o)),j({newBoxParams:I})},Ft=s=>{const{boxID:i,imageName:c,width:l,height:g,x:r,y:m}=s,C=P.find(B=>B.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(B=>B.imageName===c))return;const _=C.rects.map(B=>B.imageName===c?A(x({},B),{width:l,height:g,x:r,y:m}):B),v=A(x({},C),{rects:_}),I=P.map(B=>B.id===i?v:B);return t==null||t.updatePolygonList(I!=null?I:[]),I},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(x({},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){Q({omitView:b.Top,polygon:C,boxParams:m,newPointCloudBoxList:i});return}}if((c||Y)&&h.length===1){const m=c!=null?c:Y;r.setSelectedID(h[0]);const C=r.selectedPoint;m&&J(b.Top,C,m,void 0,l,y)}}},gt=(s,i,c,l=F.Default)=>{if(pt){let g,r;switch(c){case b.Back:g=vo;break;case b.Side:g=St;break;default:g=St;break}if(r=g(s,i,pt,d.pointCloudInstance),o){const{count:v}=o.getSensesPointZAxisInPolygon(eo(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=A(x({},r),{count:v})}const C=M(lt({tool:st.PointCloud,dataList:[r],stepConfig:y,action:"viewUpdateBox"}))[0],D=r.valid!==C.valid;r=C;const _=Nt(r);return r=_.find(v=>v.id===r.id),Q({omitView:D?void 0:c,polygon:s,boxParams:r,newPointCloudBoxList:_},l),_}},ft=(s,i,c)=>{if(Y){let l,g;switch(c){case b.Back:l=Lo;break;case b.Side:l=wt;break;default:l=wt;break}g=l(s,i,Y);const r=ut(g);return J(c,s,g,void 0,r,y),r}},Gt=(s,i)=>{ft(s,i,b.Side)},Jt=(s,i)=>{ft(s,i,b.Back)},Qt=(s,i)=>{gt(s,i,b.Side,F.Single)},Xt=(s,i)=>{gt(s,i,b.Back,F.Single)},Yt=(s,i)=>{const c=At(s.id),l=dt(s,i,nt,c),g=ut(l);J(b.Top,s,l,void 0,g,y)},qt=(s,i)=>{if(Ot){const l=x({},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}=at(l,i,t.pointCloudInstance,g);return r});if(c=M(lt({tool:st.PointCloud,dataList:c,stepConfig:y,action:"viewUpdateBox"})),c.length===1){const{newPolygon:l}=s[0],g=et(c);Q({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),D=Number(s.heightDefault),_=k==null?void 0:k.info.trackID,I=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(q=>(q==null?void 0:q.trackID)===_),B={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},Z=I.pointList.map(q=>O.transferCanvas2World(q,B)),G=w.getModifiedRectangleCoordinates(Z,D,m),H=G[0],it=G[2],Ct=w.getLineCenterPoint([H,it]),$t=k.info.center.z-k.info.depth/2,Pt=A(x({},k.info),{center:{x:Ct.x,y:Ct.y,z:$t+C/2},width:m,height:D,depth:C,valid:!0}),to=et([Pt]);Q({omitView:b["3D"],polygon:I,boxParams:Pt,newPointCloudBoxList:to})}},J=(s,i,c,l,g,r)=>bt(void 0,null,function*(){const m=W==null?void 0:W.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(D=>{D!==s&&C[D]()}),l&&(o==null||o.updateCameraZoom(l)),Et(c)}),Q=(s,i=F.Default)=>{const{omitView:c,polygon:l,boxParams:g,zoom:r,newPointCloudBoxList:m}=s,C=W==null?void 0:W.url;m&&n.syncAllViewPointCloudColor(i,m);const D={[b.Side]:()=>{Rt(g,l,d,C)},[b.Back]:()=>{p&&Vt(g,l,p,C)},[b.Top]:()=>{ct(g,l,t,o)}};Object.keys(D).forEach(_=>{_!==c&&D[_]()}),r&&(o==null||o.updateCameraZoom(r))};return{topViewAddSphere:Mt,topViewAddBox:Ht,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:Q,syncPointCloudPoint:J,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=W){var c,l,g,r,m,C,D,_;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 v=[],I=[],B=[],Z=[];o.updateTopCamera();const G=(r=(g=rt(i.result))==null?void 0:g.valid)!=null?r:!0;if(n.setPointCloudValid(G),(m=n.sideViewInstance)==null||m.clearAllData(),(C=n.backViewInstance)==null||C.clearAllData(),i.result){if(v=O.getBoxParamsFromResultList(i.result),(v==null?void 0:v.length)>0&&i.isPreResult&&(y==null?void 0:y.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(i.url,y,v);const H=rt(i.result);H[no].result=v,i.result=JSON.stringify(H),n.setPointCloudResult(v)}B=O.getPolygonListFromResultList(i.result),I=O.getLineListFromResultList(i.result),Z=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(D=y==null?void 0:y.radius)!=null?D:tt}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(Z),yield n.syncAllViewPointCloudColor(F.Default,v,[])}E({pointCloudBoxList:v,polygonList:B,lineList:I,pointCloudSphereList:Z}),Lt(M,!1),vt(M,!1),(_=e==null?void 0:e.setResourceLoading)==null||_.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:ot,update2DViewRect:Ft,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(xt),d=K(e),p=K(n);return{syncToPointCloudBoxList:ht(()=>{const f=d.current,u=p.current;if(u.length===0)return null;const a=new Map,h=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const L=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let R=a.get(L);R||(R=new Map,a.set(L,R)),R.set(T,V),h.add(L)}),a.size){const P=f.map(L=>{var T;const V=L.id;if(h.has(V)){const R=x({},L);return(T=R.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.get(V))==null?void 0:N.get(z))}),R}return L});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,Dt as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
|
package/es/components/videoAnnotate/videoClipTool/components/videoTimeSlicesOverVideo/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{classnames as S}from"../../../../../utils/index.js";import{AttributeUtils as
|
|
1
|
+
import{classnames as S}from"../../../../../utils/index.js";import{AttributeUtils as c,TagUtils as E,MathUtils as b}from"@labelbee/lb-annotation";import s from"react";import{CSSTransition as h,TransitionGroup as w}from"react-transition-group";import{TIME_SLICE_TYPE as O,ETimeSliceType as P}from"../../constant.js";import o from"./index.module.scss.js";var A=Object.defineProperty,I=Object.defineProperties,N=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,j=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,T=(i,t,r)=>t in i?A(i,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[t]=r,C=(i,t)=>{for(var r in t||(t={}))j.call(t,r)&&T(i,r,t[r]);if(f)for(var r of f(t))x.call(t,r)&&T(i,r,t[r]);return i},L=(i,t)=>I(i,N(t));const $=i=>{const{attributeList:t,result:r,currentTime:u,extraStyle:_,inputList:p=[]}=i,g=e=>{const{type:a,start:n,end:l}=e;let m=!1;return a===P.Time?m=b.isInRange(u,[n-.1,n+.1]):m=l===null||b.isInRange(u,[n,l]),m},v=[],d=[];r.forEach(e=>{(g(e)?d:v).push(e)});const y=d.sort((e,a)=>e.start-a.start).map(e=>L(C({},e),{withinTime:!0})).map(e=>s.createElement(h,{classNames:"fade",key:e.id,timeout:500},s.createElement("div",{className:S({[o.timeSliceWrapper]:!0,[o.active]:e.withinTime})},s.createElement("div",{className:o.timeSliceItemAttribute,style:{backgroundColor:c.getAttributeColor(e.attribute,t)}},`${O[e.type]}: ${c.getAttributeShowText(e.attribute,t)||"\u65E0\u5C5E\u6027"}`),(e==null?void 0:e.subAttribute)&&p.length>0&&(()=>{const a=E.getTagNameList(e.subAttribute,p);return a.length>0?s.createElement("div",{className:o.timeSliceItemSubAttribute,style:{backgroundColor:c.getAttributeColor(e.attribute,t)}},a.map((n,l)=>s.createElement("div",{key:l},`${n.keyName}\uFF1A${n.value.join(`
|
|
2
|
+
`)}`))):null})(),e.textAttribute&&s.createElement("div",{className:o.timeSliceItemText},`\u6587\u672C: ${e.textAttribute}`))));return s.createElement("div",{className:o.videoTimeSlices,style:_},s.createElement(w,{className:"fade-group"},y))};export{$ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={videoTimeSlices:"index-module_videoTimeSlices__v-2k1",timeSliceWrapper:"index-module_timeSliceWrapper__kebC3",timeSliceItemText:"index-module_timeSliceItemText__FJFwH",timeSliceItemAttribute:"index-module_timeSliceItemAttribute__--3E1"};export{e as default};
|
|
1
|
+
var e={videoTimeSlices:"index-module_videoTimeSlices__v-2k1",timeSliceWrapper:"index-module_timeSliceWrapper__kebC3",timeSliceItemText:"index-module_timeSliceItemText__FJFwH",timeSliceItemAttribute:"index-module_timeSliceItemAttribute__--3E1",timeSliceItemSubAttribute:"index-module_timeSliceItemSubAttribute__MtsgS"};export{e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{timeFormat as
|
|
1
|
+
import{timeFormat as z}from"../../../../../utils/audio.js";import{AttributeUtils as x,MathUtils as b}from"@labelbee/lb-annotation";import{EnvironmentFilled as D}from"@ant-design/icons";import s,{useContext as S,useRef as X,useMemo as j}from"react";import U from"../resizableSnippet/index.js";import{ETimeSliceType as N,EClipStatus as W}from"../../constant.js";import L from"../ToolTipForClip.js";import u from"./index.module.scss.js";import{decimalReserved as C,hashCode as q}from"../../../../videoPlayer/utils.js";import{VideoClipToolContext as B}from"../../VideoClipToolContext.js";import{VideoPlayerCtx as G}from"../../../../videoPlayer/index.js";import{useTranslation as H}from"react-i18next";var K=Object.defineProperty,Q=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,A=(o,r,t)=>r in o?K(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,tt=(o,r)=>{for(var t in r||(r={}))Z.call(r,t)&&A(o,t,r[t]);if(w)for(var t of w(r))J.call(r,t)&&A(o,t,r[t]);return o},et=(o,r)=>Q(o,Y(r));const rt=(o,r)=>{const{t}=H(),{attribute:p,textAttribute:n}=o;return[x.getAttributeShowText(p,r)||t("NoAttribute"),n?`${t("textTool")}: ${n}`:""].filter(y=>y).join("\uFF0C")},ot=(o,r)=>{const t=(o||[]).filter(n=>n).map(()=>[]);o.forEach(n=>{if(n.id!==r){const l=t.findIndex(y=>{const i=n.start,c=n.end;return y.every(f=>{const T=[f.start,f.end],m=[i,c];return!b.isInRange(i,T)&&!b.isInRange(c,T)&&!b.isInRange(f.start,m)&&!b.isInRange(f.end,m)})});l>-1&&t[l].push(n)}});const p=nt(t.filter(n=>n.length>0));return p==null?void 0:p.map(n=>({data:n,id:q(n==null?void 0:n.map(l=>l.id).join("_"))}))},nt=(o,r=2)=>{let t=o;return t.length-r<0&&(t=t.concat(Array.from({length:r-t.length}))),t},at=o=>{var r;const{currentTime:t,readonly:p,onTrackResizeStart:n}=o,{result:l,selectedAttribute:y,attributeList:i,selectedID:c,clipStatus:f,contextToCancel:T}=S(B),{duration:m}=S(G),_=X(null),I=t/m,k=(e,a=4)=>`${C(e*100,a)}%`,h=e=>{if(e){const a=x.getAttributeColor(e.attribute,i),v=Math.max((e.end||t)-e.start,0)/m,d={backgroundColor:a,left:k(e.start/m,2),width:k(e.end?Math.max(v,.001):v,2),position:"absolute",borderRadius:5};return e.type===N.Time&&(delete d.width,delete d.backgroundColor,d.top="50%",d.transform="translate(-50%)",d.color=a),d}return{}},E=x.getAttributeColor(y,i),P=((r=_.current)==null?void 0:r.clientWidth)||0,O=C(Math.max(P*I,0),0),F=C(Math.min(O,Math.floor(P-68)),0),R=e=>{if(e)return e.type===N.Time?s.createElement(L,{slot:s.createElement(D,{style:h(e)}),item:et(tt({},e),{end:e.end===null?t:e.end}),attributeList:i}):s.createElement(U,{track:e,currentTime:t,style:h(e),onResize:(a,v)=>o.onTrackResize(e.id,a,v),onTrackResizeStart:n,onClipping:f===W.Clipping,isSelected:e.id===c,readonly:p,attributeList:i})},M=j(()=>{const e=ot(l,c);return e==null?void 0:e.map((a,v)=>{var d;return s.createElement("div",{className:u.track,key:(a==null?void 0:a.id)||v},(d=a.data)==null?void 0:d.map((g,V)=>s.createElement(s.Fragment,{key:(g==null?void 0:g.id)||`${a==null?void 0:a.id}_${V}`},R(g))))})},[l,c,m,JSON.stringify(i)]),$=j(()=>{const e=l.find(a=>(a==null?void 0:a.id)===c);return c&&e?s.createElement("div",{className:u.track,key:e==null?void 0:e.id},R(e)):null},[l,c,m,t,JSON.stringify(i)]);return s.createElement("div",{className:u.videoTrackContainer,ref:_,onContextMenu:T},s.createElement("div",{className:u.timeTrack}),s.createElement("div",{className:u.videoTrack},$,M),s.createElement("div",{className:u.timeline,style:{transform:`translate3d(${O}px, 0px, 0px)`,backgroundColor:E}}),s.createElement("div",{className:u.displayTime,style:{backgroundColor:E,transform:`translateX(${F}px, 0px, 0px)`}},z(t)))};var st=at;export{st as default,rt as getDisplayContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MathUtils as C,CommonToolUtils as F,uuid as A,AttributeUtils as R}from"@labelbee/lb-annotation";import{jsonParser as P}from"../../../utils/index.js";import{precisionAdd as y,precisionMinus as k,isImageValue as V}from"../../../utils/audio.js";import{message as m}from"antd";import b from"lodash";import g from"react";import _ from"./index.module.scss.js";import{VideoClipToolContextProvider as B}from"./VideoClipToolContext.js";import{EClipStatus as d,ETimeSliceType as T,PER_SLICE_CHANGE as v,SLICE_MIN_TIME as x}from"./constant.js";import{VideoPlayer as j}from"../../videoPlayer/index.js";import M from"./components/videoTimeSlicesOverVideo/index.js";import U from"../../../assets/annotation/video/icon_videoCutting.svg.js";import{decimalReserved as L}from"../../videoPlayer/utils.js";class N extends g.Component{constructor(r){super(r);this.fns=new Map,this.throttledUpdateTime=b.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(s=>s.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===d.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:l,start:u,type:a}=this.state.result[this.selectedSliceIndex],n=C.withinRange(y(u,t),[0,k(a===T.Time?s:l,v)]);this.updateSelectedSliceTimeProperty(n,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===d.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=this.state.result[this.selectedSliceIndex],l=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(s.type===T.Time){m.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:u,start:a}=s,n=C.withinRange(y(u,t),[y(a,v),l]);this.updateSelectedSliceTimeProperty(n,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:b.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!F.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(-v);break;case"=":this.updateSelectedSliceTimeStartByPer(v);break;case"[":this.updateSelectedSliceTimeEndByPer(-v);break;case"]":this.updateSelectedSliceTimeEndByPer(v);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:s}=this.state;s===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 s=t.findIndex(l=>l.id===e);s>-1&&(t.splice(s,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,s;if(this.disabled)return;const{clipStatus:l,selectedAttribute:u}=this.state,a=l!==d.Clipping;let n=a?d.Clipping:d.Stop,{result:o,selectedID:c,textValue:h}=this.state;const p=b.cloneDeep(o),S=t||((e=this.videoPlayer)==null?void 0:e.currentTime),I=(i=this.videoPlayer)==null?void 0:i.duration;if(I===void 0||S===void 0)return;const w=L(S,2);if(a){const f=A();c=f,p.push({start:w,end:null,attribute:u,textAttribute:this.defaultTextAttribute,duration:I,id:f,type:T.Period}),h=this.defaultTextAttribute}else{const f=p.findIndex(E=>E.id===c),D=p[f];D&&(S-D.start<x?(p.splice(f,1),m.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${x}s`),n=d.Stop,c="",h=""):(p[f].end=L(S,2),(s=this.videoPlayer)==null||s.pause(),m.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${o.length}`)))}this.setState({clipStatus:n,result:p,selectedID:c,textValue:h}),this.updateSidebar()},this.addTime=()=>{var t,e,i,s;if(this.disabled)return;const{result:l,selectedAttribute:u,selectedID:a}=this.state,n=A(),o=b.cloneDeep(l),c=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;o.push({start:c,end:c,attribute:u,textAttribute:this.defaultTextAttribute,id:n,type:T.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const h={result:o,selectedID:n,textValue:this.defaultTextAttribute},p=o.find(S=>S.id===a);this.isClipping&&p?(delete h.selectedID,delete h.textValue,m.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${o.length-1}`)):(s=this.videoPlayer)==null||s.pause(),this.setState(h),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===d.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var s,l;const{result:u}=this.state,a=u.find(n=>n.id===t);if(a){const n=a.duration,o=e==="left",c=o?"start":"end",h=o?-n*i:n*i,p=o?[0,Math.max(((s=a.end)!=null?s:0)-x,0)]:[a.start+x,n],S=C.withinRange(h+((l=a==null?void 0:a[c])!=null?l:0),p);a[c]=S,this.throttledUpdateTime(S)}this.setState({result:[...u]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:s}=this.props,{result:l,videoError:u,valid:a,currentTime:n}=this.state;return g.createElement("div",{className:_.clipContainer},g.createElement(j,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:s,pageForward:e,pageJump:i,valid:a,setVideoRef:o=>{this.videoPlayer=o},showVideoTrack:!u,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),g.createElement(M,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:l,currentTime:n,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&g.createElement("i",{className:_.clipping,style:{backgroundImage:U}}))},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,s=e.findIndex(l=>l.id===t.id);s>-1&&(e.splice(s,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:s}=e;if(!s[i])return;const u=P(s[i].result)[`step_${this.stepInfo().step}`],a=(u==null?void 0:u.result)||[],n=V(s[i].result||"[]");this.setState({result:a,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:d.Stop,valid:n},()=>{this.updateSidebar(),n||m.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,s=e.find(l=>l.id===i);s&&i&&(s.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const s=e.find(l=>l.id===i);s&&(s.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:d.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var r;const{imgIndex:t,imgList:e}=this.props;return((r=e[t])==null?void 0:r.url)||""}get isClipping(){return this.state.clipStatus===d.Clipping}get resultJSON(){const{imgIndex:r,imgList:t}=this.props;return t.length===0||!t[r]?"[]":t[r].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return R.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(r=>r.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}}get valid(){return this.state.valid}get config(){var r;return P((r=this.props.stepInfo)==null?void 0:r.config)}get selectedText(){var r,t;return(t=(r=this.state.result)==null?void 0:r[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(r,t){const e=r.imgIndex-this.props.imgIndex,i=r.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,r),i!==0&&this.setState({loading:!1})),!0}singleOn(r,t){this.fns.set(r,[t])}on(r,t){this.singleOn(r,t)}unbindAll(r){this.fns.delete(r)}render(){const{selectedID:r,result:t,clipStatus:e,selectedAttribute:i}=this.state;return g.createElement(B,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:r,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}export{N as default};
|
|
1
|
+
import{MathUtils as C,CommonToolUtils as F,uuid as A,AttributeUtils as R}from"@labelbee/lb-annotation";import{jsonParser as _}from"../../../utils/index.js";import{precisionAdd as I,precisionMinus as k,isImageValue as V}from"../../../utils/audio.js";import{message as m}from"antd";import b from"lodash";import g from"react";import P from"./index.module.scss.js";import{VideoClipToolContextProvider as B}from"./VideoClipToolContext.js";import{EClipStatus as d,ETimeSliceType as T,PER_SLICE_CHANGE as v,SLICE_MIN_TIME as x}from"./constant.js";import{VideoPlayer as j}from"../../videoPlayer/index.js";import M from"./components/videoTimeSlicesOverVideo/index.js";import U from"../../../assets/annotation/video/icon_videoCutting.svg.js";import{decimalReserved as L}from"../../videoPlayer/utils.js";class N extends g.Component{constructor(r){super(r);this.fns=new Map,this.throttledUpdateTime=b.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(s=>s.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===d.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:l,start:u,type:n}=this.state.result[this.selectedSliceIndex],a=C.withinRange(I(u,t),[0,k(n===T.Time?s:l,v)]);this.updateSelectedSliceTimeProperty(a,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===d.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=this.state.result[this.selectedSliceIndex],l=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(s.type===T.Time){m.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:u,start:n}=s,a=C.withinRange(I(u,t),[I(n,v),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:b.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!F.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(-v);break;case"=":this.updateSelectedSliceTimeStartByPer(v);break;case"[":this.updateSelectedSliceTimeEndByPer(-v);break;case"]":this.updateSelectedSliceTimeEndByPer(v);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:s}=this.state;s===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 s=t.findIndex(l=>l.id===e);s>-1&&(t.splice(s,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,s;if(this.disabled)return;const{clipStatus:l,selectedAttribute:u}=this.state,n=l!==d.Clipping;let a=n?d.Clipping:d.Stop,{result:o,selectedID:c,textValue:p}=this.state;const h=b.cloneDeep(o),S=t||((e=this.videoPlayer)==null?void 0:e.currentTime),y=(i=this.videoPlayer)==null?void 0:i.duration;if(y===void 0||S===void 0)return;const w=L(S,2);if(n){const f=A();c=f,h.push({start:w,end:null,attribute:u,textAttribute:this.defaultTextAttribute,duration:y,id:f,type:T.Period,subAttribute:{}}),p=this.defaultTextAttribute}else{const f=h.findIndex(E=>E.id===c),D=h[f];D&&(S-D.start<x?(h.splice(f,1),m.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${x}s`),a=d.Stop,c="",p=""):(h[f].end=L(S,2),(s=this.videoPlayer)==null||s.pause(),m.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${o.length}`)))}this.setState({clipStatus:a,result:h,selectedID:c,textValue:p}),this.updateSidebar()},this.addTime=()=>{var t,e,i,s;if(this.disabled)return;const{result:l,selectedAttribute:u,selectedID:n}=this.state,a=A(),o=b.cloneDeep(l),c=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;o.push({start:c,end:c,attribute:u,textAttribute:this.defaultTextAttribute,id:a,type:T.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,subAttribute:{}});const p={result:o,selectedID:a,textValue:this.defaultTextAttribute},h=o.find(S=>S.id===n);this.isClipping&&h?(delete p.selectedID,delete p.textValue,m.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${o.length-1}`)):(s=this.videoPlayer)==null||s.pause(),this.setState(p),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===d.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var s,l;const{result:u}=this.state,n=u.find(a=>a.id===t);if(n){const a=n.duration,o=e==="left",c=o?"start":"end",p=o?-a*i:a*i,h=o?[0,Math.max(((s=n.end)!=null?s:0)-x,0)]:[n.start+x,a],S=C.withinRange(p+((l=n==null?void 0:n[c])!=null?l:0),h);n[c]=S,this.throttledUpdateTime(S)}this.setState({result:[...u]}),this.updateSidebar()},this.renderMediaContent=()=>{var t,e,i;const{pageForward:s,pageJump:l,pageBackward:u}=this.props,{result:n,videoError:a,valid:o,currentTime:c}=this.state;return g.createElement("div",{className:P.clipContainer},g.createElement(j,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:u,pageForward:s,pageJump:l,valid:o,setVideoRef:p=>{this.videoPlayer=p},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}),g.createElement(M,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:n,currentTime:c,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&&g.createElement("i",{className:P.clipping,style:{backgroundImage:U}}))},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,s=e.findIndex(l=>l.id===t.id);s>-1&&(e.splice(s,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:s}=e;if(!s[i])return;const u=_(s[i].result)[`step_${this.stepInfo().step}`],n=(u==null?void 0:u.result)||[],a=V(s[i].result||"[]");this.setState({result:n,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:d.Stop,valid:a},()=>{this.updateSidebar(),a||m.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,s=e.find(l=>l.id===i);s&&i&&(s.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.setSubAttribute=(t,e)=>{const{result:i,selectedID:s}=this.state;if(s){const l=i.find(u=>u.id===s);l&&(l.subAttribute||(l.subAttribute={}),l.subAttribute[t]=e,this.setState({result:[...i]}),this.updateSidebar())}},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const s=e.find(l=>l.id===i);s&&(s.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:d.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var r;const{imgIndex:t,imgList:e}=this.props;return((r=e[t])==null?void 0:r.url)||""}get isClipping(){return this.state.clipStatus===d.Clipping}get resultJSON(){const{imgIndex:r,imgList:t}=this.props;return t.length===0||!t[r]?"[]":t[r].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return R.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(r=>r.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}}get valid(){return this.state.valid}get config(){var r;return _((r=this.props.stepInfo)==null?void 0:r.config)}get selectedText(){var r,t;return(t=(r=this.state.result)==null?void 0:r[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(r,t){const e=r.imgIndex-this.props.imgIndex,i=r.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,r),i!==0&&this.setState({loading:!1})),!0}singleOn(r,t){this.fns.set(r,[t])}on(r,t){this.singleOn(r,t)}unbindAll(r){this.fns.delete(r)}render(){const{selectedID:r,result:t,clipStatus:e,selectedAttribute:i}=this.state;return g.createElement(B,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:r,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}export{N as default};
|
package/es/index.css
CHANGED
|
@@ -521,14 +521,28 @@
|
|
|
521
521
|
word-break: break-all;
|
|
522
522
|
}
|
|
523
523
|
.index-module_timeSliceWrapper__kebC3 .index-module_timeSliceItemText__FJFwH {
|
|
524
|
-
|
|
524
|
+
width: 100%;
|
|
525
525
|
padding: 8px 24px;
|
|
526
|
+
background-color: #ccc;
|
|
526
527
|
}
|
|
527
|
-
.index-module_timeSliceWrapper__kebC3 .index-module_timeSliceItemAttribute__--3E1
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
528
|
+
.index-module_timeSliceWrapper__kebC3 .index-module_timeSliceItemAttribute__--3E1 {
|
|
529
|
+
width: 100%;
|
|
530
|
+
padding: 8px 24px;
|
|
531
|
+
text-align: left;
|
|
532
|
+
}
|
|
533
|
+
.index-module_timeSliceWrapper__kebC3 .index-module_timeSliceItemSubAttribute__MtsgS {
|
|
534
|
+
font-size: 14px;
|
|
535
|
+
color: #fff;
|
|
536
|
+
padding: 8px 24px;
|
|
537
|
+
word-break: break-all;
|
|
538
|
+
line-height: 1.5;
|
|
539
|
+
width: 100%;
|
|
540
|
+
}
|
|
541
|
+
.index-module_timeSliceWrapper__kebC3 .index-module_timeSliceItemSubAttribute__MtsgS div {
|
|
542
|
+
margin-bottom: 4px;
|
|
543
|
+
}
|
|
544
|
+
.index-module_timeSliceWrapper__kebC3 .index-module_timeSliceItemSubAttribute__MtsgS div:last-child {
|
|
545
|
+
margin-bottom: 0;
|
|
532
546
|
}
|
|
533
547
|
.index-module_speedControllerWrap__aFz7r {
|
|
534
548
|
display: flex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import p,{useState as v,useRef as L,useEffect as A}from"react";import{connect as S}from"react-redux";import g from"../../../../components/attributeList/index.js";import I from"../../../../utils/StepUtils.js";import{jsonParser as h}from"../../../../utils/index.js";import{useTranslation as x}from"react-i18next";import{EToolName as T}from"../../../../data/enums/ToolType.js";import{LabelBeeContext as _}from"../../../../store/ctx.js";const j=e=>{var r;const[a,l]=v(0),u=L(null),{toolInstance:t}=e,{t:b}=x(),d=n=>{t==null||t.setAttributeLockList(n)};if(A(()=>(t&&t.singleOn("changeAttributeSidebar",n=>{var s;l(f=>f+1),!!u.current&&((s=u.current.children[n])==null||s.scrollIntoView({block:"center"}))}),()=>{t==null||t.unbindAll("changeAttributeSidebar")}),[t,u]),!e.stepInfo)return null;const i=h(e.stepInfo.config),c=e.stepInfo.tool===T.ScribbleTool;if(i.attributeConfigurable!==!0&&!c)return null;if((i.attributeConfigurable===!0||c)&&(i==null?void 0:i.attributeList)){const n=i.attributeList.map(o=>({label:o.key,value:o.value,color:o==null?void 0:o.color}));c||n.unshift({label:b("NoAttribute"),value:""});const s=o=>{t&&(t.setDefaultAttribute(o),l(m=>m+1))},f=(r=t==null?void 0:t.defaultAttribute)!=null?r:"";return p.createElement(g,{list:n,attributeChanged:s,selectedAttribute:f,ref:u,attributeLockChange:d})}return null},C=e=>{var r,a;const l=I.getCurrentStepInfo((r=e.annotation)==null?void 0:r.step,(a=e.annotation)==null?void 0:a.stepList);return{toolInstance:e.annotation.toolInstance,stepInfo:l}};var k=S(C,null,null,{context:_})(j);export{k as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r,{useState as _,useRef as j,useMemo as E,useEffect as k}from"react";import{connect as T}from"react-redux";import V from"../../../../components/attributeList/index.js";import w from"../../../../utils/StepUtils.js";import{jsonParser as y}from"../../../../utils/index.js";import{useTranslation as D}from"react-i18next";import{LabelBeeContext as R}from"../../../../store/ctx.js";import P from"../../../../components/subAttributeList/index.js";import{Divider as U}from"antd";const B=n=>{var l,u;const[v,d]=_(0),s=j(null),{toolInstance:t}=n,{t:L}=D(),o=n.stepInfo?y(n.stepInfo.config):{},p=(l=t==null?void 0:t.defaultAttribute)!=null?l:"",a=t==null?void 0:t.exportContext,c=a==null?void 0:a.selectedID,f=a==null?void 0:a.result,A=(u=o==null?void 0:o.inputList)!=null?u:[],b=E(()=>{if(c&&f)return f.find(e=>e.id===c)},[c,f]),S=e=>{t==null||t.setAttributeLockList(e)};if(k(()=>(t&&t.singleOn("changeAttributeSidebar",e=>{var i;d(m=>m+1),!!s.current&&((i=s.current.children[e])==null||i.scrollIntoView({block:"center"}))}),()=>{t==null||t.unbindAll("changeAttributeSidebar")}),[t,s]),!n.stepInfo||o.attributeConfigurable!==!0||!(o==null?void 0:o.attributeList))return null;const g=o.attributeList.map(e=>({label:e.key,value:e.value,color:e==null?void 0:e.color}));g.unshift({label:L("NoAttribute"),value:""});const x=e=>{t&&(t.setDefaultAttribute(e),d(i=>i+1))},h=(e,i)=>{t&&t.setSubAttribute&&(t.setSubAttribute(e,i),d(m=>m+1))},C=e=>{if(b==null?void 0:b.subAttribute)return b.subAttribute[e.value]},I=p&&c&&b&&A.length>0&&(o==null?void 0:o.secondaryAttributeConfigurable)===!0;return r.createElement("div",{style:{height:0,flex:1,overflowY:"auto",overflowX:"hidden"}},r.createElement(V,{list:g,attributeChanged:x,selectedAttribute:p,ref:s,attributeLockChange:S}),I&&r.createElement(r.Fragment,null,r.createElement(U,{style:{margin:0}}),r.createElement(P,{subAttributeList:A,setSubAttribute:h,getValue:C,lang:"cn"})))},F=n=>{var l,u;const v=w.getCurrentStepInfo((l=n.annotation)==null?void 0:l.step,(u=n.annotation)==null?void 0:u.stepList);return{toolInstance:n.annotation.toolInstance,stepInfo:v}};var M=T(F,null,null,{context:R})(B);export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{prefix as
|
|
1
|
+
import{prefix as z}from"../../../constant/index.js";import{EToolName as n}from"../../../data/enums/ToolType.js";import D from"../../../utils/StepUtils.js";import{Collapse as b}from"antd/es";import e,{useState as G}from"react";import{useTranslation as U}from"react-i18next";import q from"./AnnotationText/index.js";import H from"./ClearIcon/index.js";import J,{PointCloudOperation as _}from"./GeneralOperation/index.js";import Q from"./ImgAttributeInfo/index.js";import $ from"./SwitchAttributeList/index.js";import E,{expandIconFuc as A}from"./TagSidebar/index.js";import x from"./TextToolSidebar/index.js";import I from"./PointCloudToolSidebar/index.js";import X from"./ToolStyle/index.js";import{cTool as Y}from"@labelbee/lb-annotation";import Z from"./ScribbleSidebar/index.js";import{ToolIcons as ee}from"./ToolIcons.js";import{useSelector as te}from"../../../store/ctx.js";import{Tabs as P}from"antd";import{classnames as oe}from"../../../utils/index.js";import w from"../../../assets/annotation/common/icon_menu_fold.svg.js";import ne from"../../../components/LLMToolView/sidebar/index.js";import re from"../../../components/LLMMultiWheelView/sidebar/index.js";import ie from"./NLPSidebar/index.js";import le from"../../../components/videoAnnotate/videoClipTool/components/annotatedList/index.js";import ae from"./VideoClipToolAttributeList/index.js";const{EVideoToolName:m,EPointCloudName:se}=Y,{Panel:M}=b,t=`${z}-sidebar`,ce=i=>{var a;return i?(a={[m.VideoClipTool]:e.createElement(ae,null)}[i])!=null?a:e.createElement($,null):e.createElement($,null)},me=({sider:i,enableColorPicker:a,setSiderWidth:d,propsSiderWidth:de,checkMode:u,setBatchSetValid:V})=>{const T=te(r=>D.getCurrentStepInfo(r.annotation.step,r.annotation.stepList)),[p,B]=G(!0),o=T==null?void 0:T.tool,{t:S}=U();if(!o)return null;const O=r=>{const c=e.createElement(X,null);return e.createElement(M,{header:S("Style"),className:"panel",key:r},c)},g=e.createElement(ee,{toolName:o,onChange:()=>{}}),s=ce(o),L=e.createElement(q,null),C=e.createElement(b,{defaultActiveKey:["1","imgAttribute"],bordered:!1,expandIconPosition:"right",className:`${t}__content`,expandIcon:A},O("1")),h=e.createElement(b,{defaultActiveKey:["1","imgAttribute"],bordered:!1,expandIconPosition:"right",className:`${t}__content`,expandIcon:A},e.createElement(M,{header:e.createElement("div",null,S("Adjust"),e.createElement(H,null)),className:"panel",key:"imgAttribute"},e.createElement(Q,null))),l=e.createElement(J,null),k=e.createElement(E,null),F=r=>e.createElement(x,{disabled:r}),v=e.createElement(Z,{onChange:(r,c)=>{}}),N=e.createElement(le,null),j=e.createElement(ne,{checkMode:u}),K=e.createElement(re,{checkMode:u}),y=e.createElement(ie,{checkMode:u}),f=e.createElement("div",{className:`${t}__horizontal`}),R=e.createElement(I,{enableColorPicker:a}),W=e.createElement(_,{setBatchSetValid:V});if(i)return typeof i=="function"?e.createElement("div",{className:`${t}`},i({toolIcon:g,attributeList:s,annotationText:L,toolStyle:C,imageAttributeInfo:h,operation:l,tagToolSideBar:k,textToolSideBar:F,horizontal:f,pointCloudToolSidebar:R,pointCloudOperation:W,scribbleSidebar:v,LLMSidebar:j,LLMMultiWheelSidebar:K,videoClipSidebar:N,NLPSidebar:y})):i;if([n.Rect,n.Point,n.Line,n.Rect,n.Polygon,n.Cuboid].includes(o))return e.createElement("div",{className:`${t}`},g,f,s,L,f,e.createElement("div",{className:`${t}__content`},C,h),l);if(o===n.Tag)return e.createElement("div",{className:`${t}`},e.createElement(E,null));if(o===m.VideoClipTool)return e.createElement("div",{className:`${t}`},e.createElement("div",{className:`${t}__content`},N,s),l);if(o===m.VideoTagTool)return e.createElement("div",{className:`${t}`},e.createElement("div",{className:`${t}__content`},e.createElement(E,null)),l);if(o===m.VideoTextTool)return e.createElement("div",{className:`${t}`},e.createElement(x,null));if(o===n.Text)return e.createElement("div",{className:`${t}`},"s",e.createElement(x,null));if(o===se.PointCloud){const r=()=>{B(!p),d&&d(p?48:void 0)},c=e.createElement("div",{style:{width:"48px",height:"100%",display:"flex",justifyContent:"center",background:"#ffffff"}},e.createElement("span",{onClick:()=>r()},e.createElement("img",{style:{width:"16px",height:"16px",marginTop:"18px",cursor:"pointer",transform:"rotate(180deg)"},src:w})));return p?e.createElement(P,{type:"card",activeKey:"1",className:oe({[`${t}`]:!0,[`${t}__pointCloud`]:!0}),tabBarExtraContent:{left:e.createElement("span",{onClick:()=>r(),style:{padding:"0px 4px"}},e.createElement("img",{style:{width:"16px",height:"16px",marginLeft:"4px",cursor:"pointer"},src:w}))}},e.createElement(P.TabPane,{tab:"\u5DE5\u5177\u9762\u677F",key:"1",style:{height:"100%",display:"flex",flexDirection:"column"}},e.createElement("div",{className:`${t}__content`},e.createElement(I,null)),e.createElement(_,null))):c}return o===n.ScribbleTool?e.createElement("div",{className:`${t}`},e.createElement("div",{className:`${t}__content`},v,s),l):o===n.LLM?j:o===n.NLP?y:null};export{me as default,t as sidebarCls};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.24.0-alpha.
|
|
3
|
+
"version": "1.24.0-alpha.52",
|
|
4
4
|
"description": "Provide a complete library of annotation components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"es": "./es/index.js",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ant-design/icons": "^4.6.2",
|
|
46
|
-
"@labelbee/lb-annotation": "1.28.0-alpha.
|
|
47
|
-
"@labelbee/lb-utils": "1.20.0-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.28.0-alpha.29",
|
|
47
|
+
"@labelbee/lb-utils": "1.20.0-alpha.7",
|
|
48
48
|
"@labelbee/wavesurfer": "1.1.0",
|
|
49
49
|
"@types/react-dom": "18.3.1",
|
|
50
50
|
"@types/react-transition-group": "^4.4.9",
|