@labelbee/lb-components 1.23.0-alpha.7 → 1.23.0-alpha.70
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/App.js +1 -1
- package/dist/assets/annotation/icon_link.svg.js +1 -0
- package/dist/assets/annotation/icon_unlink.svg.js +1 -0
- package/dist/assets/annotation/pointCloudTool/Image2DBoxScale.svg.js +1 -0
- package/dist/assets/annotation/pointCloudTool/leftArrow.svg.js +1 -1
- package/dist/assets/annotation/pointCloudTool/rightArrow.svg.js +1 -1
- package/dist/assets/annotation/pointCloudTool/rotate90_black.svg.js +1 -0
- package/dist/assets/icons/ad33251.svg +26 -0
- package/dist/components/AnnotationView/index.js +1 -1
- package/dist/components/LLMToolView/index.js +1 -1
- package/dist/components/LLMToolView/questionView/components/header/index.js +1 -1
- package/dist/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
- package/dist/components/LLMToolView/sidebar/components/textEditor/index.module.scss.js +1 -1
- package/dist/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
- package/dist/components/LLMToolView/sidebar/index.js +1 -1
- package/dist/components/LLMToolView/utils/data.js +1 -1
- package/dist/components/NLPToolView/index.js +1 -1
- package/dist/components/audioAnnotate/audioContext/index.js +1 -1
- package/dist/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
- package/dist/components/audioAnnotate/index.js +1 -1
- package/dist/components/audioAnnotate/textInput/index.js +1 -1
- package/dist/components/audioAnnotate/textInput/index.module.scss.js +1 -1
- package/dist/components/audioAnnotate/utils/dataTransform.js +1 -0
- package/dist/components/audioPlayer/clipRegion/index.js +1 -1
- package/dist/components/audioPlayer/index.js +1 -1
- package/dist/components/audioPlayer/useAudioCombine/index.js +3 -2
- package/dist/components/audioPlayer/useAudioSegment/index.js +1 -1
- package/dist/components/longText/index.js +1 -1
- package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
- package/dist/components/pointCloud2DRectOperationView/useUpdateRectList.js +1 -0
- package/dist/components/pointCloud2DRectOperationView/util.js +1 -0
- package/dist/components/pointCloudView/PointCloud2DSingleView.js +1 -1
- package/dist/components/pointCloudView/PointCloud2DView.js +1 -1
- package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
- package/dist/components/pointCloudView/PointCloudContext.js +1 -1
- package/dist/components/pointCloudView/PointCloudInfos.js +1 -1
- package/dist/components/pointCloudView/PointCloudListener.js +1 -1
- package/dist/components/pointCloudView/PointCloudSegment2DView.js +1 -1
- package/dist/components/pointCloudView/PointCloudTopView.js +1 -1
- package/dist/components/pointCloudView/components/HighlightVisible/index.js +1 -1
- package/dist/components/pointCloudView/hooks/useBoxes.js +1 -1
- package/dist/components/pointCloudView/hooks/useDataLinkSwitch.js +1 -0
- package/dist/components/pointCloudView/hooks/useHighlight.js +1 -1
- package/dist/components/pointCloudView/hooks/useHistory.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/components/pointCloudView/hooks/usePolygon.js +1 -1
- package/dist/components/pointCloudView/hooks/useRotate.js +1 -1
- package/dist/components/pointCloudView/hooks/useRotateEdge.js +1 -0
- package/dist/components/pointCloudView/hooks/useSingleBox.js +1 -1
- package/dist/components/pointCloudView/hooks/useStatus.js +1 -1
- package/dist/components/pointCloudView/hooks/useTimeoutFunc.js +1 -0
- package/dist/components/pointCloudView/hooks/useWindowKeydownListener.js +1 -0
- package/dist/components/pointCloudView/index.js +1 -1
- package/dist/components/pointCloudView/utils/event-polyfill.js +1 -0
- package/dist/components/pointCloudView/utils/map.js +1 -0
- package/dist/components/subAttributeList/index.js +1 -0
- package/dist/components/videoAnnotate/videoClipTool/index.js +1 -1
- package/dist/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
- package/dist/hooks/useToolStyle.js +1 -0
- package/dist/index.css +59 -17
- package/dist/index.js +1 -1
- package/dist/store/Actions.js +1 -1
- package/dist/store/annotatedBox/index.js +1 -1
- package/dist/store/annotation/actionCreators.js +1 -1
- package/dist/store/annotation/reducer.js +1 -1
- package/dist/types/App.d.ts +5 -1
- package/dist/types/components/AnnotationView/index.d.ts +1 -0
- package/dist/types/components/LLMToolView/utils/data.d.ts +1 -1
- package/dist/types/components/audioAnnotate/audioContext/index.d.ts +10 -2
- package/dist/types/components/audioAnnotate/textInput/index.d.ts +1 -0
- package/dist/types/components/audioAnnotate/utils/dataTransform.d.ts +9 -0
- package/dist/types/components/audioPlayer/index.d.ts +28 -21
- package/dist/types/components/longText/index.d.ts +1 -0
- package/dist/types/components/pointCloud2DRectOperationView/index.d.ts +1 -0
- package/dist/types/components/pointCloud2DRectOperationView/useUpdateRectList.d.ts +2 -0
- package/dist/types/components/pointCloud2DRectOperationView/util.d.ts +8 -0
- package/dist/types/components/pointCloudView/PointCloud2DView.d.ts +2 -1
- package/dist/types/components/pointCloudView/PointCloudContext.d.ts +28 -4
- package/dist/types/components/pointCloudView/components/HighlightVisible/index.d.ts +2 -1
- package/dist/types/components/pointCloudView/hooks/useDataLinkSwitch.d.ts +19 -0
- package/dist/types/components/pointCloudView/hooks/useHighlight.d.ts +1 -1
- package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +8 -0
- package/dist/types/components/pointCloudView/hooks/useRotateEdge.d.ts +9 -0
- package/dist/types/components/pointCloudView/hooks/useSingleBox.d.ts +3 -2
- package/dist/types/components/pointCloudView/hooks/useTimeoutFunc.d.ts +6 -0
- package/dist/types/components/pointCloudView/hooks/useWindowKeydownListener.d.ts +16 -0
- package/dist/types/components/pointCloudView/utils/event-polyfill.d.ts +8 -0
- package/dist/types/components/pointCloudView/utils/map.d.ts +11 -0
- package/dist/types/components/subAttributeList/index.d.ts +10 -0
- package/dist/types/components/videoAnnotate/index.d.ts +2 -1
- package/dist/types/components/videoAnnotate/videoClipTool/index.d.ts +2 -1
- package/dist/types/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.d.ts +1 -1
- package/dist/types/hooks/useToolStyle.d.ts +30 -0
- package/dist/types/index.d.ts +7 -2
- package/dist/types/store/Actions.d.ts +1 -0
- package/dist/types/store/annotatedBox/index.d.ts +2 -0
- package/dist/types/store/annotation/actionCreators.d.ts +3 -2
- package/dist/types/store/annotation/reducer.d.ts +1 -0
- package/dist/types/store/annotation/types.d.ts +9 -2
- package/dist/types/utils/AnnotationDataUtils.d.ts +58 -1
- package/dist/types/utils/ToolPointCloudBoxRenderHelper.d.ts +23 -0
- package/dist/types/utils/index.d.ts +31 -1
- package/dist/types/views/MainView/sidebar/PointCloudToolSidebar/components/rectRotateSensitivitySlider/index.d.ts +3 -0
- package/dist/types/views/MainView/sidebar/TextToolSidebar/index.d.ts +1 -1
- package/dist/types/views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.d.ts +9 -0
- package/dist/types/views/MainView/toolFooter/BatchSwitchConnectIn2DView/Icons.d.ts +3 -0
- package/dist/types/views/MainView/toolFooter/BatchSwitchConnectIn2DView/index.d.ts +1 -0
- package/dist/types/views/MainView/toolFooter/SwitchCuboidBoxIn2DView/index.d.ts +10 -2
- package/dist/types/views/MainView/toolFooter/index.d.ts +1 -1
- package/dist/types/views/MainView/toolHeader/StepSwitch/index.d.ts +1 -1
- package/dist/types/views/MainView/toolHeader/index.d.ts +1 -1
- package/dist/utils/AnnotationDataUtils.js +1 -1
- package/dist/utils/ToolPointCloudBoxRenderHelper.js +1 -0
- package/dist/utils/index.js +1 -1
- package/dist/views/MainView/index.js +1 -1
- package/dist/views/MainView/sidebar/NLPSidebar/NLPAnnotatedList.js +1 -1
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/rectRotateSensitivitySlider/index.js +1 -0
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/rectRotateSensitivitySlider/index.module.scss.js +1 -0
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/dist/views/MainView/sidebar/TagSidebar/index.js +1 -1
- package/dist/views/MainView/sidebar/TextToolSidebar/index.js +1 -1
- package/dist/views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js +1 -0
- package/dist/views/MainView/toolFooter/BatchSwitchConnectIn2DView/Icons.js +1 -0
- package/dist/views/MainView/toolFooter/FooterTips/ToolHotKey/pointCloud/index.js +1 -1
- package/dist/views/MainView/toolFooter/SwitchCuboidBoxIn2DView/index.js +1 -1
- package/dist/views/MainView/toolFooter/index.js +1 -1
- package/es/App.js +1 -1
- package/es/assets/annotation/icon_link.svg.js +1 -0
- package/es/assets/annotation/icon_unlink.svg.js +1 -0
- package/es/assets/annotation/pointCloudTool/Image2DBoxScale.svg.js +1 -0
- package/es/assets/annotation/pointCloudTool/leftArrow.svg.js +1 -1
- package/es/assets/annotation/pointCloudTool/rightArrow.svg.js +1 -1
- package/es/assets/annotation/pointCloudTool/rotate90_black.svg.js +1 -0
- package/es/components/AnnotationView/index.js +1 -1
- package/es/components/LLMToolView/index.js +1 -1
- package/es/components/LLMToolView/questionView/components/header/index.js +1 -1
- package/es/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
- package/es/components/LLMToolView/sidebar/components/textEditor/index.module.scss.js +1 -1
- package/es/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
- package/es/components/LLMToolView/sidebar/index.js +1 -1
- package/es/components/LLMToolView/utils/data.js +1 -1
- package/es/components/NLPToolView/index.js +1 -1
- package/es/components/audioAnnotate/audioContext/index.js +1 -1
- package/es/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
- package/es/components/audioAnnotate/index.js +1 -1
- package/es/components/audioAnnotate/textInput/index.js +1 -1
- package/es/components/audioAnnotate/textInput/index.module.scss.js +1 -1
- package/es/components/audioAnnotate/utils/dataTransform.js +1 -0
- package/es/components/audioPlayer/clipRegion/index.js +1 -1
- package/es/components/audioPlayer/index.js +1 -1
- package/es/components/audioPlayer/useAudioCombine/index.js +3 -2
- package/es/components/audioPlayer/useAudioSegment/index.js +1 -1
- package/es/components/longText/index.js +1 -1
- package/es/components/pointCloud2DRectOperationView/index.js +1 -1
- package/es/components/pointCloud2DRectOperationView/useUpdateRectList.js +1 -0
- package/es/components/pointCloud2DRectOperationView/util.js +1 -0
- package/es/components/pointCloudView/PointCloud2DSingleView.js +1 -1
- package/es/components/pointCloudView/PointCloud2DView.js +1 -1
- package/es/components/pointCloudView/PointCloud3DView.js +1 -1
- package/es/components/pointCloudView/PointCloudContext.js +1 -1
- package/es/components/pointCloudView/PointCloudInfos.js +1 -1
- package/es/components/pointCloudView/PointCloudListener.js +1 -1
- package/es/components/pointCloudView/PointCloudSegment2DView.js +1 -1
- package/es/components/pointCloudView/PointCloudTopView.js +1 -1
- package/es/components/pointCloudView/components/HighlightVisible/index.js +1 -1
- package/es/components/pointCloudView/hooks/useBoxes.js +1 -1
- package/es/components/pointCloudView/hooks/useDataLinkSwitch.js +1 -0
- package/es/components/pointCloudView/hooks/useHighlight.js +1 -1
- package/es/components/pointCloudView/hooks/useHistory.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/hooks/usePolygon.js +1 -1
- package/es/components/pointCloudView/hooks/useRotate.js +1 -1
- package/es/components/pointCloudView/hooks/useRotateEdge.js +1 -0
- package/es/components/pointCloudView/hooks/useSingleBox.js +1 -1
- package/es/components/pointCloudView/hooks/useStatus.js +1 -1
- package/es/components/pointCloudView/hooks/useTimeoutFunc.js +1 -0
- package/es/components/pointCloudView/hooks/useWindowKeydownListener.js +1 -0
- package/es/components/pointCloudView/index.js +1 -1
- package/es/components/pointCloudView/utils/event-polyfill.js +1 -0
- package/es/components/pointCloudView/utils/map.js +1 -0
- package/es/components/subAttributeList/index.js +1 -0
- package/es/components/videoAnnotate/videoClipTool/index.js +1 -1
- package/es/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
- package/es/hooks/useToolStyle.js +1 -0
- package/es/index.css +59 -17
- package/es/index.js +1 -1
- package/es/store/Actions.js +1 -1
- package/es/store/annotatedBox/index.js +1 -1
- package/es/store/annotation/actionCreators.js +1 -1
- package/es/store/annotation/reducer.js +1 -1
- package/es/utils/AnnotationDataUtils.js +1 -1
- package/es/utils/ToolPointCloudBoxRenderHelper.js +1 -0
- package/es/utils/index.js +1 -1
- package/es/views/MainView/index.js +1 -1
- package/es/views/MainView/sidebar/NLPSidebar/NLPAnnotatedList.js +1 -1
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/rectRotateSensitivitySlider/index.js +1 -0
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/rectRotateSensitivitySlider/index.module.scss.js +1 -0
- package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/es/views/MainView/sidebar/TagSidebar/index.js +1 -1
- package/es/views/MainView/sidebar/TextToolSidebar/index.js +1 -1
- package/es/views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js +1 -0
- package/es/views/MainView/toolFooter/BatchSwitchConnectIn2DView/Icons.js +1 -0
- package/es/views/MainView/toolFooter/FooterTips/ToolHotKey/pointCloud/index.js +1 -1
- package/es/views/MainView/toolFooter/SwitchCuboidBoxIn2DView/index.js +1 -1
- package/package.json +3 -3
- package/dist/assets/annotation/pointCloudTool/rotate180_black.svg.js +0 -1
- package/dist/assets/icons/9d70807.svg +0 -5
- package/es/assets/annotation/pointCloudTool/rotate180_black.svg.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudContext as
|
|
1
|
+
import{PointCloudContext as oe}from"./PointCloudContext.js";import{useRotate as re}from"./hooks/useRotate.js";import{useRotateEdge as se}from"./hooks/useRotateEdge.js";import{useBoxes as ne}from"./hooks/useBoxes.js";import{useSingleBox as ie}from"./hooks/useSingleBox.js";import{useSphere as ae}from"./hooks/useSphere.js";import{useContext as ue,useEffect as d}from"react";import{CommonToolUtils as le,EPointCloudName as ce,AttributeUtils as de,EToolName as f,cTool as pe}from"@labelbee/lb-annotation";import{message as g}from"antd";import{connect as me}from"react-redux";import{a2MapStateToProps as ve}from"../../store/annotation/map.js";import{useStatus as be}from"./hooks/useStatus.js";import{usePointCloudViews as fe}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as Pe,useDispatch as ye}from"../../store/ctx.js";import{useHistory as we}from"./hooks/useHistory.js";import{useAttribute as Ce}from"./hooks/useAttribute.js";import{useConfig as he}from"./hooks/useConfig.js";import{usePolygon as ge}from"./hooks/usePolygon.js";import{useLine as Se}from"./hooks/useLine.js";import{useTranslation as ke}from"react-i18next";import{PreDataProcess as xe}from"../../store/annotation/actionCreators.js";import{useLatest as A}from"ahooks";var _e=Object.defineProperty,Ve=Object.defineProperties,Le=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,E=(u,r,l)=>r in u?_e(u,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[r]=l,P=(u,r)=>{for(var l in r||(r={}))Be.call(r,l)&&E(u,l,r[l]);if(I)for(var l of I(r))Oe.call(r,l)&&E(u,l,r[l]);return u},y=(u,r)=>Ve(u,Le(r));const{EPolygonPattern:je}=pe,Ae=({currentData:u,config:r,checkMode:l,configString:D,imgIndex:S,toolInstanceRef:a})=>{const e=ue(oe),{changeSelectedBoxValid:T,selectNextBox:H,selectPrevBox:K,updateSelectedBox:k,deleteSelectedPointCloudBoxAndPolygon:N}=ie(),{selectedSphere:w,updatePointCloudSphere:R}=ae(),{clearAllResult:C,updatePointCloudPattern:U}=be(),{copySelectedBoxes:z,pasteSelectedBoxes:F,copiedBoxes:Ee}=ne({config:r}),{updateRotate:x}=re({currentData:u}),{updateRotateEdge:q}=se({currentData:u}),{updatePointCloudData:v,topViewSelectedChanged:_}=fe(),{redo:V,undo:L,pushHistoryWithList:G,pushHistoryUnderUpdatePolygon:M,pushHistoryUnderUpdateLine:W}=we(),Y=ye(),{syncThreeViewsAttribute:B}=Ce(),{syncAllViewsConfig:$,reRenderTopViewRange:J}=he(),{selectedPolygon:O}=ge(),{selectedLine:j}=Se(),{t:h}=ke(),Q=A(u),b=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},X=(t,o)=>{var s,i;const{topViewInstance:c,mainViewInstance:n}=e;if(!c)return;const{pointCloud2dOperation:p}=c;switch(t){case"q":{x(e.rectRotateSensitivity);break}case"e":x(-Number(e.rectRotateSensitivity));break;case"g":q(-90);break;case"u":{const m=p.pattern===je.Normal?f.Rect:f.Polygon;U(m);const te={[f.Polygon]:h("PolygonPattern"),[f.Rect]:h("RectPattern")};g.success(h("ChangePatternMsg",{pattern:te[m]})),p.clearActiveStatus(),p.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){K();break}H(),o.preventDefault();break;case"f":T();break;case"arrowup":b({y:-1});break;case"arrowdown":b({y:1});break;case"arrowleft":b({x:-1});break;case"arrowright":b({x:1});break;case"delete":N(Q.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const m=de.getAttributeByKeycode(o.keyCode,r.attributeList);m!==void 0&&((i=a.current)==null||i.setDefaultAttribute(m))}return}}},Z=(t,o)=>{switch(t){case"c":z();break;case"v":F();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?V():L();break}}},ee=A(t=>{if(!le.hotkeyFilter(t)||l===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){Z(o,t);return}X(o,t)});return d(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>ee.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),d(()=>{$(r)},[D]),d(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),d(()=>{v==null||v()},[S,e.mainViewInstance]),d(()=>{e.setHideAttributes([])},[S]),d(()=>{a.current.setDefaultAttribute=t=>{var o,s,i,c;B(t);const n=e.selectedPointCloudBox;if(n){n.attribute=t;const p=Y(xe({tool:ce.PointCloud,dataList:[n],stepConfig:r,action:"viewUpdateBox"}));n.valid=p[0].valid;const m=k(n);(i=(s=(o=e==null?void 0:e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:s.setPolygonValidAndRender)==null||i.call(s,n.id,!0,n.valid),e.mainViewInstance&&_({newSelectedBox:n,newPointCloudList:m})}if(O&&M(y(P({},O),{attribute:t})),j&&W(y(P({},j),{attribute:t})),w){const p=R(y(P({},w),{attribute:t}));e.mainViewInstance&&((c=e.mainViewInstance)==null||c.generateSpheres(p),_({newSelectedSphere:w,newSphereList:p}))}},a.current.setSubAttribute=(t,o)=>{var s;const i=e.selectedPointCloudBox;if(i){const c=(s=i==null?void 0:i.subAttribute)!=null?s:{};i.subAttribute=y(P({},c),{[t]:o}),k(i)}},a.current.clearResult=()=>{C==null||C()},a.current.redo=()=>{V()},a.current.undo=()=>{L()},a.current.setValid=t=>{a.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&C()})},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(()=>{v==null||v(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,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||l)return;const s=n=>{B(n)},i=n=>{g.error(n)},c=n=>{g.info(n)};return o.on("syncAttribute",s),o.on("messageError",i),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",i),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var Ie=me(ve,null,null,{context:Pe})(Ae);export{Ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a2MapStateToProps as
|
|
1
|
+
import{a2MapStateToProps as z}from"../../store/annotation/map.js";import{LabelBeeContext as R}from"../../store/ctx.js";import f,{useContext as V,useRef as m,useState as x,useEffect as v,useCallback as B,useMemo as A}from"react";import W from"../AnnotationView/index.js";import{connect as T}from"react-redux";import{PointCloudContext as U}from"./PointCloudContext.js";import G from"./components/TitleButton/index.js";import{Spin as H}from"antd";import N from"../../_virtual/highlightSegmentWorker.js";import{pointMappingLidar2image as Y}from"@labelbee/lb-annotation";import{debounce as $}from"lodash";var q=Object.defineProperty,J=Object.defineProperties,K=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,k=(t,o,n)=>o in t?q(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,Z=(t,o)=>{for(var n in o||(o={}))Q.call(o,n)&&k(t,n,o[n]);if(D)for(var n of D(o))X.call(o,n)&&k(t,n,o[n]);return t},ee=(t,o)=>J(t,K(o));const te=({path:t,url:o,fallbackUrl:n,calib:c,pcdUrl:s,highlightAttribute:u})=>{const{ptSegmentInstance:e,cacheImageNodeSize:O,imageSizes:E}=V(U),F=m(null),g=m(0),h=m({}),p=m(),[P,_]=x([]),[I,C]=x(!1),S=m(void 0);v(()=>()=>{g.current=0,h.current={},p.current=void 0},[s]);const b=B(()=>{var r,l,i;if(g.current=g.current+1,g.current===2){const a=(r=e==null?void 0:e.store)==null?void 0:r.originPoints;if(!a||!p.current){console.error("cacheMappingPCD2Img Error",{path:t,points:a,filterSize:p.current});return}h.current=(i=(l=Y(a,c,p.current))==null?void 0:l.pcdMapping)!=null?i:{}}},[e]),y=A(()=>$((l,i)=>{var a,w;if(l&&p.current){S.current&&((w=(a=S.current)==null?void 0:a.terminate)==null||w.call(a));const M=h.current,d=new N;d.current=d,C(!0),d.postMessage({cacheMap:M,indexes:l,defaultRGBA:i}),d.onmessage=L=>{_(L.data.annotations),d.terminate(),C(!1),d.current=void 0}}},100),[]);v(()=>{if(!(e==null?void 0:e.store))return;const r=e.store.getHighlightAttribute(u!=null?u:""),l=e==null?void 0:e.getColorFromConfig(u!=null?u:"");y(r.flat(),l.stroke)},[u,e]),v(()=>{if(e){const r=({newAttribute:l})=>{const i=e==null?void 0:e.getColorFromConfig(l);i&&_(P.map(a=>ee(Z({},a),{defaultRGBA:i.stroke})))};return e.on("updateDefaultAttribute",r),()=>{e.unbind("updateDefaultAttribute",r)}}},[e,P]),v(()=>{if(e){const r=l=>{if(l.cacheSegData){const{cacheSegData:i}=l;if(i==null?void 0:i.indexes){const a=e.getColorFromConfig(i.attribute);y(i==null?void 0:i.indexes,a.stroke)}}else _([])};return e.on("syncPointCloudStatus",r),e.on("loadPCDFileEnd",b),()=>{e.unbind("syncPointCloudStatus",r),e.unbind("loadPCDFileEnd",b)}}},[e,s,E]);const j=r=>{O({path:t,imgNode:r}),p.current={width:r.width,height:r.height},b()};return f.createElement("div",{key:t,style:{position:"relative"},ref:F},f.createElement(G,{title:c.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF",position:"absolute",top:10,left:10,zIndex:1}}),f.createElement(H,{spinning:I,delay:1e3},f.createElement(W,{size:{width:300,height:200},key:t,src:o,fallbackSrc:n,annotations:P,afterImgOnLoad:j})))},oe=({currentData:t,highlightAttribute:o})=>{var n;const c=(n=t.mappingImgList)!=null?n:[];return(c==null?void 0:c.length)>0?f.createElement("div",{style:{position:"absolute",height:"100%",overflowY:"scroll",zIndex:100,width:300}},c==null?void 0:c.map((s,u)=>{var e;return s.calib&&f.createElement(te,{key:s.path+u,path:s.path,url:s.url,fallbackUrl:(e=s.fallbackUrl)!=null?e:"",calib:s.calib,pcdUrl:t.url,highlightAttribute:o})})):null};var ne=T(z,null,null,{context:R})(oe);export{ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as
|
|
1
|
+
import{getClassName as I}from"../../utils/dom.js";import{FooterDivider as z}from"../../views/MainView/toolFooter/index.js";import{ZoomController as ae}from"../../views/MainView/toolFooter/ZoomController/index.js";import{LeftOutlined as de,UpSquareOutlined as ce,DownSquareOutlined as pe}from"@ant-design/icons";import{cKeyCode as ue,PointCloudAnnotation as me,cTool as fe,cAnnotation as ve}from"@labelbee/lb-annotation";import{PointCloudUtils as H}from"@labelbee/lb-utils";import{EPointCloudBoxRenderTrigger as we}from"../../utils/ToolPointCloudBoxRenderHelper.js";import i,{useState as W,useRef as Ce,useLayoutEffect as ge,useEffect as x}from"react";import{PointCloudContext as F}from"./PointCloudContext.js";import{useRotate as Pe}from"./hooks/useRotate.js";import{useRotateEdge as ye}from"./hooks/useRotateEdge.js";import{useSingleBox as K}from"./hooks/useSingleBox.js";import{PointCloudContainer as Ie}from"./PointCloudLayout.js";import{BoxInfos as X,PointCloudValidity as xe}from"./PointCloudInfos.js";import{usePolygon as he}from"./hooks/usePolygon.js";import{useSphere as Y}from"./hooks/useSphere.js";import{useZoom as q}from"./hooks/useZoom.js";import{Slider as Ve}from"antd";import{a2MapStateToProps as Se}from"../../store/annotation/map.js";import{connect as _e}from"react-redux";import{usePointCloudViews as Ee}from"./hooks/usePointCloudViews.js";import Le from"../../hooks/useSize.js";import{useTranslation as Oe}from"react-i18next";import{LabelBeeContext as be}from"../../store/ctx.js";import{jsonParser as je}from"../../utils/index.js";import Te from"../../utils/ToolUtils.js";import ke from"lodash";import Re from"./components/PointCloudSizeSlider/index.js";import{useHistory as Ae}from"./hooks/useHistory.js";import Be from"./components/TitleButton/index.js";var Ne=Object.defineProperty,De=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,Ze=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,$=(n,l,r)=>l in n?Ne(n,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[l]=r,N=(n,l)=>{for(var r in l||(l={}))Ze.call(l,r)&&$(n,r,l[r]);if(M)for(var r of M(l))ze.call(l,r)&&$(n,r,l[r]);return n},D=(n,l)=>De(n,Ue(l));const{EPolygonPattern:He,EToolName:G}=fe,{ESortDirection:J}=ve,We=ue.default,Q=(n,l,r=1)=>{const{width:w,height:u}=l,P={x:n.x+w*r/2,y:n.y+u*r/2},y={x:l.width/2,y:l.height/2};return{offsetX:(y.x-P.x)/r,offsetY:-(y.y-P.y)/r}},Fe=({currentData:n})=>{var l,r;const{zoom:w,zoomIn:u,zoomOut:P,initialPosition:y}=q(),{selectNextBox:E,selectPrevBox:L}=K(),{switchToNextSphere:h}=Y(),{updateRotate:V}=Pe({currentData:n}),{updateRotateEdge:O}=ye({currentData:n}),g=i.useContext(F),{topViewInstance:S}=g,m=(r=(l=g==null?void 0:g.topViewInstance)==null?void 0:l.toolScheduler)==null?void 0:r.getCurrentToolName(),e=()=>{V(-Number(g.rectRotateSensitivity))},d=()=>{V(g.rectRotateSensitivity)},f=()=>{O(-90)};return i.createElement(i.Fragment,null,i.createElement(Re,{onChange:b=>{var _;(_=S==null?void 0:S.pointCloudInstance)==null||_.updatePointSize({customSize:b})}}),i.createElement("span",{onClick:d,className:I("point-cloud","rotate-reserve")}),i.createElement("span",{onClick:e,className:I("point-cloud","rotate")}),i.createElement("span",{onClick:f,className:I("point-cloud","rotate-90")}),i.createElement(z,null),i.createElement(ce,{onClick:()=>{if(m===G.Point){h(J.descend);return}L(!0)},className:I("point-cloud","prev")}),i.createElement(pe,{onClick:()=>{if(m===G.Point){h(J.ascend);return}E(!0)},className:I("point-cloud","next")}),i.createElement(z,null),i.createElement(ae,{initialPosition:y,zoomIn:u,zoomOut:P,zoom:w}))},Ke=({setZAxisLimit:n,zAxisLimit:l,checkMode:r})=>r?null:i.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},i.createElement(Ve,{vertical:!0,step:.5,max:10,min:.5,defaultValue:l,onAfterChange:w=>{n(w)}})),Xe=({currentData:n,imgList:l,stepInfo:r,drawLayerSlot:w,checkMode:u,intelligentFit:P,setIsEnlargeTopView:y,isEnlargeTopView:E,onExitZoom:L,highlightAttribute:h})=>{var V,O;const[g,S]=W({zoom:1,currentPos:{x:0,y:0}}),m=Ce(null),e=i.useContext(F),d=Le(m),f=je(r.config),{setZoom:b,syncTopviewToolZoom:_}=q(),{hideAttributes:ee}=e,{addPolygon:te,deletePolygon:oe}=he(),{deletePointCloudSphere:ne}=Y(),{deletePointCloudBox:ie,changeValidByID:se}=K(),[j,le]=W(10),{t:U}=Oe(),C=Ee(),{pushHistoryWithList:re}=Ae();ge(()=>{if(!e.topViewInstance&&m.current&&(n==null?void 0:n.url)&&(n==null?void 0:n.result)){const o={width:m.current.clientWidth,height:m.current.clientHeight},a=new me({container:m.current,size:o,pcdPath:n.url,config:D(N({},f),{pointCloudPattern:e.pointCloudPattern}),checkMode:u,toolName:Te.getPointCloudToolList(),proxyMode:u});e.setTopViewInstance(a)}},[n]),x(()=>{if(!d||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:o}=e.topViewInstance;o.singleOn("dataUpdated",(t,s)=>{const p=ke.cloneDeep(t).map(c=>D(N({},c),{pointList:H.pointListTransferCanvas2World(c.pointList,d)}));e.setSelectedIDs(s),e.setLineList(p),re({lineList:p})}),o.singleOn("pointCreated",(t,s)=>{C.topViewAddSphere({newPoint:t,size:d,trackConfigurable:f.trackConfigurable,zoom:s})}),o.singleOn("pointDeleted",t=>{ne(t)}),o.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),o.singleOn("updatePointByDrag",(t,s)=>{var p;(p=C.topViewUpdatePoint)==null||p.call(C,t,d)}),o.singleOn("polygonCreated",(t,s)=>{if(o.pattern===He.Normal||!(n==null?void 0:n.url)){const p=D(N({},t),{pointList:t.pointList.map(c=>H.transferCanvas2World(c,d))});te(p),e.setSelectedIDs(ee.includes(t.attribute)?"":t.id);return}C.topViewAddBox({polygon:t,size:d,imgList:l,trackConfigurable:f.trackConfigurable,zoom:s,intelligentFit:P})}),o.singleOn("deletedObject",({id:t})=>{ie(t),oe(t)}),o.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),o.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),o.singleOn("setSelectedIDs",t=>{e.setSelectedIDs(t)}),o.singleOn("updatePolygonByDrag",t=>{var s;(s=C.topViewUpdateBox)==null||s.call(C,t,d)});const a=t=>{var s;const p=se(t);p&&e.syncAllViewPointCloudColor(we.Default,p),e.polygonList.find(c=>c.id===t)&&((s=e.topViewInstance)==null||s.toolInstance.setPolygonValidAndRender(t,!0))};return o.on("validUpdate",a),()=>{o.unbind("validUpdate",a)}},[e,d,n,C,e.polygonList,e.lineList,(V=e.topViewInstance)==null?void 0:V.toolInstance]),x(()=>{var o,a;if(!(d==null?void 0:d.width)||!e.topViewInstance)return;const t=(a=(o=f==null?void 0:f.attributeList)==null?void 0:o[0])==null?void 0:a.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(d),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:s,toolInstance:p}}=e;p.singleOn("renderZoom",(c,v)=>{const{offsetX:T,offsetY:k}=Q(v,d,c);if(s.camera.zoom=c,v){const{x:R,y:A,z:B}=s.initCameraPosition;s.camera.position.set(R+k,A-T,B)}s.camera.updateProjectionMatrix(),s.render(),b(c),_(v,c,d),S({zoom:c,currentPos:v})}),p.singleOn("dragMove",({currentPos:c,zoom:v})=>{const{offsetX:T,offsetY:k}=Q(c,d,v);s.camera.zoom=v;const{x:R,y:A,z:B}=s.initCameraPosition;s.camera.position.set(R+k,A-T,B),s.render(),_(c,v,d),S({zoom:v,currentPos:c})})},[d,e.topViewInstance,(O=e.topViewInstance)==null?void 0:O.toolInstance]),x(()=>{var o,a;(a=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null||a.applyZAxisPoints(j)},[j]),x(()=>{var o,a,t,s;C.topViewSelectedChanged({}),(s=(t=(a=(o=e.topViewInstance)==null?void 0:o.toolInstance)==null?void 0:a.selection)==null?void 0:t.hardSetSelectedIDs)==null||s.call(t,e.selectedIDs)},[e.selectedIDs]),x(()=>(window.addEventListener("keydown",Z),()=>{window.removeEventListener("keydown",Z)}),[]);const Z=o=>{const{keyCode:a}=o;a===We.Esc&&L()};return x(()=>{var o,a,t;(t=(a=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:a.setHighlightAttribute)==null||t.call(a,h)},[e.topViewInstance,h]),i.createElement(Ie,{className:I("point-cloud-container","top-view"),title:E?i.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},i.createElement(de,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{L()}}),i.createElement("span",null,U("TopView")),i.createElement(X,{checkMode:u,config:f,style:{display:"flex",position:"initial",margin:"0px 20px"}})):i.createElement(Be,{title:U("TopView"),onClick:()=>{y(!0)}}),toolbar:i.createElement(Fe,{currentData:n})},i.createElement("div",{style:{position:"relative",flex:1}},i.createElement("div",{style:{width:"100%",height:"100%"},ref:m},w==null?void 0:w(g)),!E&&i.createElement(X,{checkMode:u,config:f}),i.createElement(Ke,{checkMode:u,zAxisLimit:j,setZAxisLimit:le}),i.createElement(xe,null)))};var Ye=_e(Se,null,null,{context:be})(Xe);export{Ye as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import u from"react";import{EyeFilled as f,EyeInvisibleFilled as g,LoadingOutlined as m}from"@ant-design/icons";import{getClassName as _}from"../../../../utils/dom.js";var b=Object.defineProperty,s=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,c=(t,e,r)=>e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,d=(t,e)=>{for(var r in e||(e={}))y.call(e,r)&&c(t,r,e[r]);if(s)for(var r of s(e))O.call(e,r)&&c(t,r,e[r]);return t};const h=({visible:t,style:e,onClick:r,loading:a,disabled:o})=>{const l={background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,fontSize:16},p={background:"rgba(0, 0, 0, 0.2)",color:"rgba(255, 255, 255, 0.5)",cursor:"not-allowed"};let i=t?f:g;a&&(i=m,Object.assign(l,{borderRadius:100}));const n=d(d({},l),e);return o&&Object.assign(n,p),u.createElement(i,{disabled:o,className:_("point-cloud-highlight-view"),style:n,onClick:a||o?()=>{}:r})};export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as k,useState as y,useMemo as R,useCallback as p}from"react";import h from"lodash";import{message as C,Modal as H}from"antd";import{usePointCloudViews as M}from"./usePointCloudViews.js";import{PointCloudContext as j}from"../PointCloudContext.js";import{useTranslation as w}from"react-i18next";import{EPointCloudBoxRenderTrigger as E}from"../../../utils/ToolPointCloudBoxRenderHelper.js";const S=({config:m})=>{const{selectedIDs:l,pointCloudBoxList:a,displayPointCloudList:o,setPointCloudResult:f,syncAllViewPointCloudColor:P}=k(j),[t,i]=y([]),{pointCloudBoxListUpdated:c}=M(),{t:n,i18n:d}=w(),x=s=>m.trackConfigurable!==!0?!1:a.some(r=>s.some(e=>e.trackID===r.trackID)),u=R(()=>o.filter(s=>l.includes(s.id)),[l,o]),D=p(()=>{u.length>0?i(h.cloneDeep(u)):(i([]),C.error(n("CopyEmptyInPointCloud")))},[l,o,d.language]),g=p(()=>{if(t.length===0){C.error(n("PasteEmptyInPointCloud"));return}const s=x(t),r=e=>{f(e),c==null||c(e),i([]),P(E.MultiPaste,e)};if(s)H.confirm({title:n("HasDuplicateIDHeader"),content:n("HasDuplicateIDMsg"),onOk:()=>{const e=a.filter(I=>!t.find(B=>B.trackID===I.trackID)).concat(t);r(e)}});else{const e=[...o,...t];r(e)}},[t,o,d.language]);return{copySelectedBoxes:D,pasteSelectedBoxes:g,copiedBoxes:t,selectedBoxes:u}};export{S as useBoxes};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import v,{useState as T,useContext as p,useCallback as B,useMemo as h,useEffect as C}from"react";import{useLatest as s}from"ahooks";import{PointCloudContext as y}from"../PointCloudContext.js";import U from"../../../assets/annotation/icon_link.svg.js";import $ from"../../../assets/annotation/icon_unlink.svg.js";import{EventBusEvent as L}from"../../../views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js";import{EventBus as M}from"@labelbee/lb-annotation";import{useSyncRectPositionDimensionToPointCloudList as q}from"./usePointCloudViews.js";const A=e=>{const{imageNamePointCloudBoxMap:o,linkageImageNameRectMap:m}=p(y),r=h(()=>e?o.has(e):(console.error("Missing image name"),!1),[e,o]),d=h(()=>{var a,f;return e?((f=(a=m.get(e))==null?void 0:a.size)!=null?f:0)>0:!1},[m,e]),g=h(()=>r||d,[r,d]),I=s(g);return{visible:g,visibleRef:I}},N={width:16,height:16},G=e=>{e.imageName||console.warn("missing imageName");const[o,m]=T(!0),r=s(e.imageName),{addRectFromPointCloudBoxByImageName:d,removeRectByPointCloudBoxId:g,linkageImageNameRectMap:I,pointCloudBoxList:a,rectList:f,updateRectListByReducer:P}=p(y),{visible:R,visibleRef:D}=A(e.imageName),{syncToPointCloudBoxList:E}=q(),S=s(d),_=s(g),V=s(()=>E()),w=B(n=>{if(!D.current)return;const t=r.current;if(!t){console.warn("invalid image name");return}m(n),n?_.current(t):S.current(t)},[]),j=s(n=>{n&&V.current(),w(n)}),z=h(()=>{var n;if(!e.is2DView||!R)return null;const i={zIndex:(n=e.zIndex)!=null?n:999,position:"absolute",top:16,right:16+28+12,background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28};return v.createElement("div",{style:i},o&&v.createElement("img",{src:U,style:N}),!o&&v.createElement("img",{src:$,style:N}))},[o,e.is2DView,e.zIndex,R]),F=s(I),k=B(()=>{var n,t;if(!e.is2DView)return;const i=r.current;if(!i){console.warn("invalid image name");return}const c=[...(t=(n=F.current.get(i))==null?void 0:n.keys())!=null?t:[]];let l=!0;c.length&&(l=!1),w(l)},[e.is2DView,w]);return C(()=>{k()},[k,a,f]),C(()=>{const n=a.map(i=>i.id),t=new Set(n);P((i,x)=>{const c=[],l=[];return i.forEach(u=>{const b=u.extId;b!==void 0&&t.has(b)===!1?c.push(u):l.push(u)}),c.length?[...c.map(u=>x(u)),...l]:i})},[a]),C(()=>{const n=t=>{j.current(t)};return M.on(L.switchConnect,n),()=>M.unbind(L.switchConnect,n)},[]),{rendered:z,isLinking:o}};export{G as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as C,useCallback as
|
|
1
|
+
import{useContext as C,useCallback as y}from"react";import{PointCloudContext as I}from"../PointCloudContext.js";var x=(s,g,t)=>new Promise((a,h)=>{var e=i=>{try{o(t.next(i))}catch(l){h(l)}},d=i=>{try{o(t.throw(i))}catch(l){h(l)}},o=i=>i.done?a(i.value):Promise.resolve(i.value).then(e,d);o((t=t.apply(s,g)).next())});const L=({currentData:s})=>{var g;const{mainViewInstance:t,topViewInstance:a,pointCloudBoxList:h,highlight2DDataList:e,setHighlight2DDataList:d}=C(I),o=(g=s==null?void 0:s.mappingImgList)!=null?g:[],i=(r,c,v)=>x(void 0,null,function*(){var p;let u=[...e];if(e.find(n=>n.url===r)?u=e.filter(n=>n.url!==r):u.push({url:r,fallbackUrl:c,calib:v}),d(u),!t||(o==null?void 0:o.length)===0)return;const m=t.pointCloudObject;if(!m)return;const f=yield t.getHighlightIndexByMappingImgList({mappingImgList:u,points:m.geometry.attributes.position.array});try{const n=yield t.highlightOriginPointCloud(h,f);n&&((p=a==null?void 0:a.pointCloudInstance)==null||p.updateColor(n))}catch(n){console.error("toggle2dVisible highlightOriginPointCloud error:",n)}}),l=y(r=>e.findIndex(c=>c.url===r)>=0,[e]);return{toggle2dVisible:i,isHighlightVisible:l}};export{L as useHighlight};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{EPointCloudBoxRenderTrigger as m}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{useContext as R}from"react";import{PointCloudContext as I}from"../PointCloudContext.js";var U=Object.defineProperty,h=Object.getOwnPropertySymbols,j=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,P=(e,n,s)=>n in e?U(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,a=(e,n)=>{for(var s in n||(n={}))j.call(n,s)&&P(e,s,n[s]);if(h)for(var s of h(n))V.call(n,s)&&P(e,s,n[s]);return e};const A=()=>{const{history:e,setPointCloudResult:n,setSelectedIDs:s,pointCloudBoxList:L,pointCloudSphereList:f,setPointCloudSphereList:x,mainViewInstance:d,topViewInstance:u,polygonList:c,setPolygonList:y,lineList:p,setLineList:C,syncAllViewPointCloudColor:S,segmentation:v}=R(I),B=({newBoxParams:t,newPolygon:o,newLine:i,newSphereParams:l})=>{const r={pointCloudBoxList:L,polygonList:c,lineList:p,pointCloudSphereList:f};t&&(r.pointCloudBoxList=L.concat(t)),o&&(r.polygonList=c.concat(o)),i&&(r.lineList=p.concat(i)),l&&(r.pointCloudSphereList=f.concat(l)),e.pushHistory(r)},_=t=>{const o={pointCloudBoxList:L,polygonList:c,lineList:p,pointCloudSphereList:f,segmentation:v};t.pointCloudBoxList&&(o.pointCloudBoxList=t.pointCloudBoxList),t.polygonList&&(o.polygonList=t.polygonList),t.lineList&&(o.lineList=t.lineList),t.pointCloudSphereList&&(o.pointCloudSphereList=t.pointCloudSphereList),t.segmentation&&(o.segmentation=t.segmentation),e.pushHistory(o)},H=t=>{if(p.find(i=>i.id===t.id)){const i=p.map(l=>l.id===t.id?t:a({},l));e.pushHistory({lineList:i}),C(i)}},w=t=>{if(c.find(i=>i.id===t.id)){const i=c.map(l=>l.id===t.id?t:a({},l));e.pushHistory({pointCloudBoxList:L,polygonList:i}),y(i)}},O=({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:i})=>{e.initRecord({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:i,lineList:p},!0)},g=t=>{if(!t)return;const{pointCloudBoxList:o=[],polygonList:i=[],lineList:l=[],pointCloudSphereList:r=[]}=t;o&&(L.length!==o.length&&s(),d==null||d.clearAllBox(),d==null||d.generateBoxes(o),n(o),S(m.UndoRedo,o)),r&&(f.length!==r.length&&s(),d==null||d.clearAllSphere(),d==null||d.generateSpheres(r),x(r)),i&&y(i),l&&C(l),u==null||u.updatePolygonList(o!=null?o:[],i!=null?i:[]),u==null||u.updateLineList(l!=null?l:[]),u==null||u.updatePointList(r)};return{addHistory:B,pushHistoryWithList:_,initHistory:O,pushHistoryUnderUpdatePolygon:w,pushHistoryUnderUpdateLine:H,redo:()=>{g(e.redo())},undo:()=>{g(e.undo())}}};export{A as useHistory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudName as nt,MathUtils as B,getCuboidFromPointCloudBox as Mt}from"@labelbee/lb-annotation";import{EPerspectiveView as J,PointCloudUtils as V,POINT_CLOUD_DEFAULT_STEP as Gt,DEFAULT_SPHERE_PARAMS as Jt}from"@labelbee/lb-utils";import{useContext as Qt}from"react";import{PointCloudContext as Xt}from"../PointCloudContext.js";import{useSingleBox as Yt}from"./useSingleBox.js";import{useSphere as qt}from"./useSphere.js";import{useSelector as Kt,useDispatch as $t}from"../../../store/ctx.js";import to from"../../../utils/StepUtils.js";import{jsonParser as it,getRectPointCloudBox as oo}from"../../../utils/index.js";import{PreDataProcess as st,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as eo}from"./useHistory.js";import{usePolygon as no}from"./usePolygon.js";import{useLatest as io}from"ahooks";var so=Object.defineProperty,ro=Object.defineProperties,lo=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,ao=Object.prototype.hasOwnProperty,co=Object.prototype.propertyIsEnumerable,xt=(e,t,i)=>t in e?so(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,L=(e,t)=>{for(var i in t||(t={}))ao.call(t,i)&&xt(e,i,t[i]);if(ht)for(var i of ht(t))co.call(t,i)&&xt(e,i,t[i]);return e},O=(e,t)=>ro(e,lo(t)),rt=(e,t,i)=>new Promise((d,o)=>{var a=u=>{try{c(i.next(u))}catch(h){o(h)}},g=u=>{try{c(i.throw(u))}catch(h){o(h)}},c=u=>u.done?d(u.value):Promise.resolve(u.value).then(a,g);c((i=i.apply(e,t)).next())});const q=5,K=90,mt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},lt=(e,t,i,d,o)=>{const{x:a,y:g}=V.transferCanvas2World(e,t),{defaultZ:c}=Jt,u={center:{x:a,y:g,z:c},id:e.id},h=d?L(L({},d),u):O(L({},u),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},dt=(e,t,i,d,o,a)=>{let g=e.pointList.map(v=>V.transferCanvas2World(v,t)),c=0,u=1,h={};if(i){const v=i.getSensesPointZAxisInPolygon(g,void 0,a);a&&v.fittedCoordinates.length>0&&(g=v.fittedCoordinates),c=(v.maxZ+v.minZ)/2,u=v.maxZ-v.minZ,h={count:v.zCount}}const[m,I,W]=g,z=B.getLineCenterPoint([m,W]),T=B.getLineLength(m,I),R=B.getLineLength(I,W),E=B.getRadiusFromQuadrangle(e.pointList);d&&(c=d.center.z,u=d.depth);const j={center:{x:z.x,y:z.y,z:c},width:a?R+mt:R,height:a?T+mt:T,depth:u,rotation:E,id:e.id},N=L(d?L(L({},d),j):O(L({},j),{attribute:"",valid:!0}),h);o&&Object.assign(N,o);const F=g.map(v=>V.transferWorld2Canvas(v,t));return{boxParams:N,newPointList:F}},Lt=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x-d.x,y:i.center.y,z:i.center.z-d.y}})},yt=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,h]=t.pointList,m=B.getLineCenterPoint([o,g]),I=B.getLineCenterPoint([c,h]),z={x:{x:m.x-I.x,y:m.y-I.y}.x,y:0,z:m.y-I.y},T=B.getLineLength(o,a),R=B.getLineLength(c,u),E=T-R,j=B.getLineLength(a,g),N=B.getLineLength(u,h),F=j-N,{newBoxParams:v}=d.getNewBoxBySideUpdate(z,F,E,i);return v},uo=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x,y:i.center.y-d.x,z:i.center.z-d.y}})},po=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,h]=t.pointList,m=B.getLineCenterPoint([o,g]),I=B.getLineCenterPoint([c,h]),z={x:{x:m.x-I.x,y:m.y-I.y}.x,y:0,z:m.y-I.y},T=B.getLineLength(o,a),R=B.getLineLength(c,u),E=T-R,j=B.getLineLength(a,g),N=B.getLineLength(u,h),F=j-N;let{newBoxParams:v}=d.getNewBoxByBackUpdate(z,F,E,i);return v},vt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,J.Left);c.setInitCameraPosition(u);const{point2d:h,zoom:m}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=m,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(m),g.setResult([O(L(L({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{width:q,depth:q});const{cameraPositionVector:g}=a.updateOrthoCamera(e,J.Left);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxSidePolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,J.Back);c.setInitCameraPosition(u);const{point2d:h,zoom:m}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=m,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(m),g.setResult([O(L(L({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{height:q,depth:q});const{cameraPositionVector:g}=a.updateOrthoCamera(e,J.Back);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxBackPolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,i,d)=>{if(!i||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,J.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=i,{point2d:g}=a.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},at=(e,t,i,d)=>{var o,a;if(!i||!d)return;d.generateBox(e,t.id),d.render();const{pointCloud2dOperation:g,pointCloudInstance:c}=i,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),h=[...g.polygonList],m=h.find(I=>I.id===t.id);m?(m.pointList=u,m.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(a=e.valid)!=null?a:!0}),g.setResultAndSelectedID(h,t.id)},go=()=>{const e=Qt(Xt),{topViewInstance:t,sideViewInstance:i,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:g,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:h,pointCloudSphereList:m,hideAttributes:I,setHighlight2DDataList:W,cuboidBoxIn2DView:z,imageSizes:T}=e,{addHistory:R,initHistory:E,pushHistoryUnderUpdatePolygon:j}=eo(),{selectedPolygon:N}=no(),{getPointCloudSphereByID:F,updatePointCloudSphere:v,selectedSphere:Q}=qt(),{currentData:Z,config:S}=Kt(n=>{const{stepList:s,step:p,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:it(to.getCurrentStepInfo(p,s).config)}}),H=$t(),St=io(z),$=n=>{if(!St.current){const{mappingImgList:s=[]}=Z,p=s.map(r=>oo({pointCloudBox:n,mappingData:r,imageSizes:T}));Object.assign(n,{rects:p.filter(r=>r!==void 0)})}},{selectedBox:_,updateSelectedBox:Dt,updateSelectedBoxes:tt,getPointCloudByID:_t}=Yt({generateRects:$}),ct=_==null?void 0:_.info;if(!t||!i||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},Ot=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},kt=({newPoint:n,size:s,zoom:p,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:m})});const P=lt(n,s,ot,void 0,f);c(n.id);const x=g(P);X(y.Top,n,P,p,x,S),R({newSphereParams:P})},Rt=({polygon:n,size:s,imgList:p,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var P,x;const C={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};r===!0&&Object.assign(C,{trackID:V.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:m})});const D=t==null?void 0:t.toolInstance,w=L({},n);let{boxParams:b,newPointList:A}=dt(w,s,ot,void 0,C,f);b=H(st({tool:nt.PointCloud,dataList:[b],stepConfig:S,action:"viewUpdateBox"}))[0],f&&(A==null?void 0:A.length)&&(w.pointList=A);const k=I.includes(w.attribute);$(b);const G=a(b),et=(x=e==null?void 0:e.polygonList)!=null?x:[];t==null||t.updatePolygonList(G!=null?G:[],et),k?c([]):(c(b.id),D.selection.setSelectedIDs(w.id),M({omitView:y.Top,polygon:w,boxParams:b,zoom:l,newPointCloudBoxList:G}),f&&at(b,w,t,o)),R({newBoxParams:b})},At=n=>{const{boxID:s,imageName:p,width:r,height:l,x:f,y:P}=n,x=h.find(C=>C.id===s);if(x==null?void 0:x.rects){const{rects:C=[]}=x,D=C.find(w=>w.imageName===p);if(D){let w=C;const b=O(L({},D),{width:r,height:l,x:f,y:P});w=C.map(k=>k===D?b:k);const A=O(L({},x),{rects:w}),U=h.map(k=>k===x?A:k);return t==null||t.updatePolygonList(U!=null?U:[]),U}}},Ut=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(u.length===0||!f)){if(n||(_==null?void 0:_.info)){const P=n!=null?n:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(u[0]);const x=f.selectedPolygon;if(u.length===1&&P){M({omitView:y.Top,polygon:x,boxParams:P,newPointCloudBoxList:s});return}}if((p||Q)&&u.length===1){const P=p!=null?p:Q;f.setSelectedID(u[0]);const x=f.selectedPoint;P&&X(y.Top,x,P,void 0,r,S)}}},ut=(n,s,p)=>{if(ct){let r,l;switch(p){case y.Back:r=po;break;case y.Side:r=yt;break;default:r=yt;break}if(l=r(n,s,ct,i.pointCloudInstance),o){const{count:D}=o.getSensesPointZAxisInPolygon(Mt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:D})}const P=H(st({tool:nt.PointCloud,dataList:[l],stepConfig:S,action:"viewUpdateBox"}))[0],x=l.valid!==P.valid;l=P;const C=Dt(l);return l=C.find(D=>D.id===l.id),M({omitView:x?void 0:p,polygon:n,boxParams:l,newPointCloudBoxList:C}),C}},pt=(n,s,p)=>{if(Q){let r,l;switch(p){case y.Back:r=uo;break;case y.Side:r=Lt;break;default:r=Lt;break}l=r(n,s,Q);const f=v(l);return X(p,n,l,void 0,f,S),f}},zt=(n,s)=>{pt(n,s,y.Side)},Tt=(n,s)=>{pt(n,s,y.Back)},jt=(n,s)=>{ut(n,s,y.Side)},Nt=(n,s)=>{ut(n,s,y.Back)},Et=(n,s)=>{const p=F(n.id),r=lt(n,s,ot,p),l=v(r);X(y.Top,n,r,void 0,l,S)},Ft=(n,s)=>{if(N){const r=L({},n[0].newPolygon);r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,s)),j(r);return}let p=n.map(({newPolygon:r})=>{const l=_t(r.id),{boxParams:f}=dt(r,s,t.pointCloudInstance,l);return f});if(p=H(st({tool:nt.PointCloud,dataList:p,stepConfig:S,action:"viewUpdateBox"})),p.length===1){const{newPolygon:r}=n[0],l=tt(p);M({polygon:r,boxParams:p[0],newPointCloudBoxList:l})}else{const r=tt(p);r&&e.syncAllViewPointCloudColor(r)}},Ht=n=>{var s,p,r,l,f;if(_){const P=Number(n.widthDefault),x=Number(n.depthDefault),C=Number(n.heightDefault),D=_==null?void 0:_.info.trackID,b=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===D),A={width:(r=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},U=b.pointList.map(Y=>V.transferCanvas2World(Y,A)),k=B.getModifiedRectangleCoordinates(U,C,P),G=k[0],et=k[2],gt=B.getLineCenterPoint([G,et]),Wt=_.info.center.z-_.info.depth/2,ft=O(L({},_.info),{center:{x:gt.x,y:gt.y,z:Wt+x/2},width:P,height:C,depth:x,valid:!0}),Zt=tt([ft]);M({omitView:y["3D"],polygon:b,boxParams:ft,newPointCloudBoxList:Zt})}},X=(n,s,p,r,l,f)=>rt(void 0,null,function*(){const P=Z==null?void 0:Z.url,x={[y.Side]:()=>{vt(p,s,i,P,f)},[y.Back]:()=>{d&&bt(p,s,d,P,f)},[y.Top]:()=>{It(p,s,t,o)}};Object.keys(x).forEach(C=>{C!==n&&x[C]()}),r&&(o==null||o.updateCameraZoom(r)),Ot(p)}),M=n=>rt(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:r,zoom:l,newPointCloudBoxList:f}=n,P=Z==null?void 0:Z.url;f&&(yield e.syncAllViewPointCloudColor(f));const x={[y.Side]:()=>{Bt(r,p,i,P)},[y.Back]:()=>{d&&wt(r,p,d,P)},[y.Top]:()=>{at(r,p,t,o)}};Object.keys(x).forEach(C=>{C!==s&&x[C]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(r)});return{topViewAddSphere:kt,topViewAddBox:Rt,topViewSelectedChanged:Ut,topViewUpdatePoint:Et,sideViewUpdatePoint:zt,backViewUpdatePoint:Tt,topViewUpdateBox:Ft,sideViewUpdateBox:jt,backViewUpdateBox:Nt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const s=V.getDefaultOrthographicParams(n);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>rt(void 0,[...n],function*(s=Z){var p,r,l,f,P,x;if(!(s==null?void 0:s.url)||!o)return;W([]),Ct(H,!0),Pt(H,!0),yield o.loadPCDFile(s.url,(p=S==null?void 0:S.radius)!=null?p:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let C=[],D=[],w=[],b=[];o.updateTopCamera();const A=(l=(r=it(s.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(A),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),s.result){if(C=V.getBoxParamsFromResultList(s.result),(C==null?void 0:C.length)>0&&s.isPreResult&&(S==null?void 0:S.lowerLimitPointsNumInBox)>0){C=yield o==null?void 0:o.filterPreResult(s.url,S,C);const U=it(s.result);U[Gt].result=C,s.result=JSON.stringify(U),e.setPointCloudResult(C)}w=V.getPolygonListFromResultList(s.result),D=V.getLineListFromResultList(s.result),b=V.getSphereParamsFromResultList(s.result),t.updateData(s.url,s.result,{radius:(x=S==null?void 0:S.radius)!=null?x:K}),o==null||o.generateBoxes(C),o==null||o.generateSpheres(b),yield e.syncAllViewPointCloudColor(C,[])}E({pointCloudBoxList:C,polygonList:w,lineList:D,pointCloudSphereList:b}),Ct(H,!1),Pt(H,!1)}),updateViewsByDefaultSize:Ht,generateRects:$,update2DViewRect:At}};export{bt as syncBackViewByPoint,vt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,at as synchronizeTopView,lt as topViewPoint2PointCloud,dt as topViewPolygon2PointCloud,go as usePointCloudViews};
|
|
1
|
+
import{EPointCloudName as st,TagUtils as to,MathUtils as w,getCuboidFromPointCloudBox as oo}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as k,POINT_CLOUD_DEFAULT_STEP as eo,DEFAULT_SPHERE_PARAMS as no}from"@labelbee/lb-utils";import{useContext as mt,useCallback as xt}from"react";import{PointCloudContext as ht}from"../PointCloudContext.js";import{useSingleBox as io}from"./useSingleBox.js";import{useSphere as so}from"./useSphere.js";import{pick as ro}from"lodash";import{useSelector as lo,useDispatch as ao}from"../../../store/ctx.js";import co from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as rt}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as lt,generatePointCloudBoxRects as uo}from"../../../utils/index.js";import{PreDataProcess as dt,SetPointCloudLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as po}from"./useHistory.js";import{usePolygon as go}from"./usePolygon.js";import{useLatest as q}from"ahooks";var fo=Object.defineProperty,Co=Object.defineProperties,Po=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,mo=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,Bt=(o,t,i)=>t in o?fo(o,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[t]=i,v=(o,t)=>{for(var i in t||(t={}))mo.call(t,i)&&Bt(o,i,t[i]);if(yt)for(var i of yt(t))xo.call(t,i)&&Bt(o,i,t[i]);return o},O=(o,t)=>Co(o,Po(t)),bt=(o,t,i)=>new Promise((u,e)=>{var p=d=>{try{c(i.next(d))}catch(m){e(m)}},f=d=>{try{c(i.throw(d))}catch(m){e(m)}},c=d=>d.done?u(d.value):Promise.resolve(d.value).then(p,f);c((i=i.apply(o,t)).next())});const K=5,$=90,wt=.01,B={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(o,t,i,u,e)=>{const{x:p,y:f}=k.transferCanvas2World(o,t),{defaultZ:c}=no,d={center:{x:p,y:f,z:c},id:o.id},m=u?v(v({},u),d):O(v({},d),{attribute:"",valid:!0});return e&&Object.assign(m,e),m},ct=(o,t,i,u,e,p)=>{let f=o.pointList.map(I=>k.transferCanvas2World(I,t)),c=0,d=1,m={};if(i){const I=i.getSensesPointZAxisInPolygon(f,void 0,p);p&&I.fittedCoordinates.length>0&&(f=I.fittedCoordinates),c=(I.maxZ+I.minZ)/2,d=I.maxZ-I.minZ,m={count:I.zCount}}const[x,y,A]=f,R=w.getLineCenterPoint([x,A]),S=w.getLineLength(x,y),U=w.getLineLength(y,A),z=w.getRadiusFromQuadrangle(o.pointList);u&&(c=u.center.z,d=u.depth);const T={center:{x:R.x,y:R.y,z:c},width:p?U+wt:U,height:p?S+wt:S,depth:d,rotation:z,id:o.id},N=v(u?v(v({},u),T):O(v({},T),{attribute:"",valid:!0}),m);e&&Object.assign(N,e);const E=f.map(I=>k.transferWorld2Canvas(I,t));return{boxParams:N,newPointList:E}},It=(o,t,i)=>{const u={x:o.x-t.x,y:o.y-t.y};return O(v({},i),{center:{x:i.center.x-u.x,y:i.center.y,z:i.center.z-u.y}})},Dt=(o,t,i,u)=>{const[e,p,f]=o.pointList,[c,d,m]=t.pointList,x=w.getLineCenterPoint([e,f]),y=w.getLineCenterPoint([c,m]),R={x:{x:x.x-y.x,y:x.y-y.y}.x,y:0,z:x.y-y.y},S=w.getLineLength(e,p),U=w.getLineLength(c,d),z=S-U,T=w.getLineLength(p,f),N=w.getLineLength(d,m),E=T-N,{newBoxParams:I}=u.getNewBoxBySideUpdate(R,E,z,i);return I},ho=(o,t,i)=>{const u={x:o.x-t.x,y:o.y-t.y};return O(v({},i),{center:{x:i.center.x,y:i.center.y-u.x,z:i.center.z-u.y}})},Lo=(o,t,i,u)=>{const[e,p,f]=o.pointList,[c,d,m]=t.pointList,x=w.getLineCenterPoint([e,f]),y=w.getLineCenterPoint([c,m]),R={x:{x:x.x-y.x,y:x.y-y.y}.x,y:0,z:x.y-y.y},S=w.getLineLength(e,p),U=w.getLineLength(c,d),z=S-U,T=w.getLineLength(p,f),N=w.getLineLength(d,m),E=T-N;let{newBoxParams:I}=u.getNewBoxByBackUpdate(R,E,z,i);return I},St=(o,t,i,u,e)=>{var p;if(!i)return;const{toolInstance:f,pointCloudInstance:c}=i;c.loadPCDFile(u,(p=e==null?void 0:e.radius)!=null?p:$);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(o,G.Left);c.setInitCameraPosition(d);const{point2d:m,zoom:x}=c.getSphereSidePoint2DCoordinate(o);c.camera.zoom=x,c.camera.updateProjectionMatrix(),c.render(),f.initPosition(),f.zoomChangeOnCenter(x),f.setResult([O(v(v({},t),m),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(t.id)},Rt=(o,t,i,u)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:p}=i;p.loadPCDFileByBox(u,o,{width:K,depth:K});const{cameraPositionVector:f}=p.updateOrthoCamera(o,G.Left);p.setInitCameraPosition(f);const{polygon2d:c,zoom:d}=p.getBoxSidePolygon2DCoordinate(o);p.camera.zoom=d,p.camera.updateProjectionMatrix(),p.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:t.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],t.id)},_t=(o,t,i,u,e)=>{var p;if(!i)return;const{toolInstance:f,pointCloudInstance:c}=i;c.loadPCDFile(u,(p=e==null?void 0:e.radius)!=null?p:$);const{cameraPositionVector:d}=c.updateOrthoCameraBySphere(o,G.Back);c.setInitCameraPosition(d);const{point2d:m,zoom:x}=c.getSphereBackPoint2DCoordinate(o);c.camera.zoom=x,c.camera.updateProjectionMatrix(),c.render(),f.initPosition(),f.zoomChangeOnCenter(x),f.setResult([O(v(v({},t),m),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(t.id)},Vt=(o,t,i,u)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:p}=i;p.loadPCDFileByBox(u,o,{height:K,depth:K});const{cameraPositionVector:f}=p.updateOrthoCamera(o,G.Back);p.setInitCameraPosition(f);const{polygon2d:c,zoom:d}=p.getBoxBackPolygon2DCoordinate(o);p.camera.zoom=d,p.camera.updateProjectionMatrix(),p.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:t.id,valid:o.valid,pointList:c,textAttribute:"",isRect:!0,attribute:o.attribute}],t.id)},kt=(o,t,i,u)=>{if(!i||!u)return;u.generateSphere(o),u.updateCameraBySphere(o,G.Top),u.render();const{toolInstance:e,pointCloudInstance:p}=i,{point2d:f}=p.getSphereTopPoint2DCoordinate(o),c=[...e.pointList].map(d=>d.id===t.id?O(v(v({},t),f),{valid:o.valid,textAttribute:"",attribute:o.attribute}):d);e.setResult(c),e.setSelectedID(t.id)},ut=(o,t,i,u)=>{var e,p;if(!i||!u)return;u.generateBox(o,t.id),u.render();const{pointCloud2dOperation:f,pointCloudInstance:c}=i,{polygon2d:d}=c.getBoxTopPolygon2DCoordinate(o),m=[...f.polygonList],x=m.find(y=>y.id===t.id);x?(x.pointList=d,x.valid=(e=o.valid)!=null?e:!0):m.push({id:t.id,pointList:d,textAttribute:"",isRect:!0,valid:(p=o.valid)!=null?p:!0}),f.setResultAndSelectedID(m,t.id)},vo=()=>{const o=mt(ht),{topViewInstance:t,sideViewInstance:i,backViewInstance:u,mainViewInstance:e,addPointCloudBox:p,addPointCloudSphere:f,setSelectedIDs:c,selectedIDs:d,pointCloudBoxList:m,pointCloudSphereList:x,hideAttributes:y,setHighlight2DDataList:A,cuboidBoxIn2DView:R,imageSizes:S,history:U,linkageImageNameRectMap:z}=o,{addHistory:T,initHistory:N,pushHistoryUnderUpdatePolygon:E}=po(),{selectedPolygon:I}=go(),{getPointCloudSphereByID:Ot,updatePointCloudSphere:pt,selectedSphere:J}=so(),{currentData:H,config:b}=lo(s=>{const{stepList:n,step:a,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:lt(co.getCurrentStepInfo(a,n).config)}}),M=ao(),At=q(R),Tt=q(z),Ut=xt((s,n)=>{const a=Tt.current,r=n.id;return s.filter(g=>{if(!g)return!1;const C=a.get(g.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),tt=s=>{const{enableAutoMap2DRect:n=!1}=b;if(!At.current||n){const{mappingImgList:a=[]}=H;uo({pointCloudBox:s,mappingImgList:a,imageSizes:S},{prepareRectsFn:Ut})}},{selectedBox:V,updateSelectedBox:zt,updateSelectedBoxes:ot,getPointCloudByID:Nt}=io({generateRects:tt}),gt=V==null?void 0:V.info;if(!t||!i||!u)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:et}=t,jt=s=>{e==null||e.generateSphere(s),e==null||e.controls.update(),e==null||e.render()},Et=({newPoint:s,size:n,zoom:a,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:k.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:x})});const C=at(s,n,et,void 0,g);c(s.id);const P=f(C);Q(B.Top,s,C,a,P,b),T({newSphereParams:C})},Mt=({polygon:s,size:n,imgList:a,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,P,h;const _={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(_,{trackID:k.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:x})});const F=t==null?void 0:t.toolInstance,D=v({},s);let{boxParams:L,newPointList:j}=ct(D,n,et,void 0,_,g);L=M(dt({tool:st.PointCloud,dataList:[L],stepConfig:b,action:"viewUpdateBox"}))[0],g&&(j==null?void 0:j.length)&&(D.pointList=j);const it=y.includes(D.attribute);tt(L);const Z=p(L),X=(P=o==null?void 0:o.polygonList)!=null?P:[];L.subAttribute=to.getDefaultResultByConfig((b==null?void 0:b.secondaryAttributeConfigurable)?(h=b==null?void 0:b.inputList)!=null?h:[]:[]),t==null||t.updatePolygonList(Z!=null?Z:[],X),it?c([]):(c(L.id),F.selection.setSelectedIDs(D.id),W({omitView:B.Top,polygon:D,boxParams:L,zoom:l,newPointCloudBoxList:Z}),g&&ut(L,D,t,e)),T({newBoxParams:L})},Ft=s=>{const{boxID:n,imageName:a,width:r,height:l,x:g,y:C}=s,P=m.find(L=>L.id===n);if(!(P==null?void 0:P.rects)||!P.rects.find(L=>L.imageName===a))return;const _=P.rects.map(L=>L.imageName===a?O(v({},L),{width:r,height:l,x:g,y:C}):L),F=O(v({},P),{rects:_}),D=m.map(L=>L.id===n?F:L);return t==null||t.updatePolygonList(D!=null?D:[]),D},Ht=s=>{const{boxID:n,imageName:a}=s,r=m.find(P=>P.id===n);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(P=>P.imageName!==a),g=O(v({},r),{rects:l}),C=m.map(P=>P.id===n?g:P);return t==null||t.updatePolygonList(C!=null?C:[]),C},Wt=({newSelectedBox:s,newPointCloudList:n,newSelectedSphere:a,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(d.length===0||!g)){if(s||(V==null?void 0:V.info)){const C=s!=null?s:V==null?void 0:V.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(d[0]);const P=g.selectedPolygon;if(d.length===1&&C){W({omitView:B.Top,polygon:P,boxParams:C,newPointCloudBoxList:n});return}}if((a||J)&&d.length===1){const C=a!=null?a:J;g.setSelectedID(d[0]);const P=g.selectedPoint;C&&Q(B.Top,P,C,void 0,r,b)}}},ft=(s,n,a)=>{if(gt){let r,l;switch(a){case B.Back:r=Lo;break;case B.Side:r=Dt;break;default:r=Dt;break}if(l=r(s,n,gt,i.pointCloudInstance),e){const{count:_}=e.getSensesPointZAxisInPolygon(oo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(v({},l),{count:_})}const C=M(dt({tool:st.PointCloud,dataList:[l],stepConfig:b,action:"viewUpdateBox"}))[0],P=l.valid!==C.valid;l=C;const h=zt(l);return l=h.find(_=>_.id===l.id),W({omitView:P?void 0:a,polygon:s,boxParams:l,newPointCloudBoxList:h}),h}},Ct=(s,n,a)=>{if(J){let r,l;switch(a){case B.Back:r=ho;break;case B.Side:r=It;break;default:r=It;break}l=r(s,n,J);const g=pt(l);return Q(a,s,l,void 0,g,b),g}},Zt=(s,n)=>{Ct(s,n,B.Side)},Gt=(s,n)=>{Ct(s,n,B.Back)},Jt=(s,n)=>{ft(s,n,B.Side)},Qt=(s,n)=>{ft(s,n,B.Back)},Xt=(s,n)=>{const a=Ot(s.id),r=at(s,n,et,a),l=pt(r);Q(B.Top,s,r,void 0,l,b)},Yt=(s,n)=>{if(I){const r=v({},s[0].newPolygon);r.pointList=r.pointList.map(l=>k.transferCanvas2World(l,n)),E(r);return}let a=s.map(({newPolygon:r})=>{const l=Nt(r.id),{boxParams:g}=ct(r,n,t.pointCloudInstance,l);return g});if(a=M(dt({tool:st.PointCloud,dataList:a,stepConfig:b,action:"viewUpdateBox"})),a.length===1){const{newPolygon:r}=s[0],l=ot(a);W({polygon:r,boxParams:a[0],newPointCloudBoxList:l})}else{const r=ot(a);r&&o.syncAllViewPointCloudColor(rt.MultiMove,r)}},qt=s=>{var n,a,r,l,g;if(V){const C=Number(s.widthDefault),P=Number(s.depthDefault),h=Number(s.heightDefault),_=V==null?void 0:V.info.trackID,D=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===_),L={width:(r=(a=t==null?void 0:t.toolInstance)==null?void 0:a.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},j=D.pointList.map(Y=>k.transferCanvas2World(Y,L)),nt=w.getModifiedRectangleCoordinates(j,h,C),it=nt[0],Z=nt[2],X=w.getLineCenterPoint([it,Z]),Kt=V.info.center.z-V.info.depth/2,Pt=O(v({},V.info),{center:{x:X.x,y:X.y,z:Kt+P/2},width:C,height:h,depth:P,valid:!0}),$t=ot([Pt]);W({omitView:B["3D"],polygon:D,boxParams:Pt,newPointCloudBoxList:$t})}},Q=(s,n,a,r,l,g)=>bt(void 0,null,function*(){const C=H==null?void 0:H.url,P={[B.Side]:()=>{St(a,n,i,C,g)},[B.Back]:()=>{u&&_t(a,n,u,C,g)},[B.Top]:()=>{kt(a,n,t,e)}};Object.keys(P).forEach(h=>{h!==s&&P[h]()}),r&&(e==null||e.updateCameraZoom(r)),jt(a)}),W=s=>{const{omitView:n,polygon:a,boxParams:r,zoom:l,newPointCloudBoxList:g}=s,C=H==null?void 0:H.url;g&&o.syncAllViewPointCloudColor(rt.Single,g);const P={[B.Side]:()=>{Rt(r,a,i,C)},[B.Back]:()=>{u&&Vt(r,a,u,C)},[B.Top]:()=>{ut(r,a,t,e)}};Object.keys(P).forEach(h=>{h!==n&&P[h]()}),l&&(e==null||e.updateCameraZoom(l))};return{topViewAddSphere:Et,topViewAddBox:Mt,topViewSelectedChanged:Wt,topViewUpdatePoint:Xt,sideViewUpdatePoint:Zt,backViewUpdatePoint:Gt,topViewUpdateBox:Yt,sideViewUpdateBox:Jt,backViewUpdateBox:Qt,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),e==null||e.generateBoxes(s)},initPointCloud3d:s=>{if(!e)return;const n=k.getDefaultOrthographicParams(s);e.initOrthographicCamera(n),e.initRenderer(),e.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(n=H){var a,r,l,g,C,P;if(!(n==null?void 0:n.url)||!e)return;A([]),Lt(M,!0),vt(M,!0),yield e.loadPCDFile(n.url,(a=b==null?void 0:b.radius)!=null?a:$),e==null||e.clearAllBox(),e==null||e.clearAllSphere();let h=[],_=[],F=[],D=[];e.updateTopCamera();const L=(l=(r=lt(n.result))==null?void 0:r.valid)!=null?l:!0;if(o.setPointCloudValid(L),(g=o.sideViewInstance)==null||g.clearAllData(),(C=o.backViewInstance)==null||C.clearAllData(),n.result){if(h=k.getBoxParamsFromResultList(n.result),(h==null?void 0:h.length)>0&&n.isPreResult&&(b==null?void 0:b.lowerLimitPointsNumInBox)>0){h=yield e==null?void 0:e.filterPreResult(n.url,b,h);const j=lt(n.result);j[eo].result=h,n.result=JSON.stringify(j),o.setPointCloudResult(h)}F=k.getPolygonListFromResultList(n.result),_=k.getLineListFromResultList(n.result),D=k.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(P=b==null?void 0:b.radius)!=null?P:$}),e==null||e.generateBoxes(h),e==null||e.generateSpheres(D),yield o.syncAllViewPointCloudColor(rt.Default,h,[])}N({pointCloudBoxList:h,polygonList:F,lineList:_,pointCloudSphereList:D}),Lt(M,!1),vt(M,!1)}),updateViewsByDefaultSize:qt,generateRects:tt,update2DViewRect:Ft,remove2DViewRect:Ht}},yo=()=>{const{pointCloudBoxList:o,rectList:t,setPointCloudResult:i}=mt(ht),u=q(o),e=q(t);return{syncToPointCloudBoxList:xt(()=>{const f=u.current,c=e.current;if(c.length===0)return null;const d=new Map,m=new Set;if(c.filter(x=>x.extId!==void 0).forEach(x=>{const y=x.extId,A=x.imageName,R=ro(x,["x","y","width","height"]);let S=d.get(y);S||(S=new Map,d.set(y,S)),S.set(A,R),m.add(y)}),d.size){const x=f.map(y=>{var A;const R=y.id;if(m.has(R)){const S=v({},y);return(A=S.rects)==null||A.forEach(U=>{var z;const T=U.imageName;Object.assign(U,(z=d.get(R))==null?void 0:z.get(T))}),S}return y});return i(x),x}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ut as synchronizeTopView,at as topViewPoint2PointCloud,ct as topViewPolygon2PointCloud,vo as usePointCloudViews,yo as useSyncRectPositionDimensionToPointCloudList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as f}from"react";import{PointCloudContext as g}from"../PointCloudContext.js";import{useHistory as _}from"./useHistory.js";var m=Object.defineProperty,O=Object.defineProperties,w=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,y=(o,t,e)=>t in o?m(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,p=(o,t)=>{for(var e in t||(t={}))x.call(t,e)&&y(o,e,t[e]);if(c)for(var e of c(t))C.call(t,e)&&y(o,e,t[e]);return o},L=(o,t)=>O(o,w(t));const h=()=>{const{polygonList:o,pointCloudBoxList:t,setPolygonList:e,selectedID:a}=f(g),{addHistory:u,pushHistoryWithList:P}=_(),d=o.find(r=>r.id===a);return{addPolygon:r=>{e(o.concat(r)),u({newPolygon:r})},deletePolygon:r=>{const i=o.filter(s=>s.id!==r).map(s=>p({},s));e(i);const n={polygonList:i};try{const s=t.filter(l=>l.id!==r).map(l=>p({},l));s.length<t.length&&(n.pointCloudBoxList=s)}catch(s){console.error("exec update history pointCloudBoxList error:",s)}P(n)},selectedPolygon:d,updateSelectedPolygon:r=>{d&&e(o.map(i=>i.id===a?r:i))},updatePolygonValidByID:r=>{o.find(n=>n.id===r)&&e(o.map(n=>n.id===r?L(p({},n),{valid:!n.valid}):n))}}};export{h as usePolygon};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as p}from"react";import{synchronizeSideView as C,synchronizeBackView as P}from"./usePointCloudViews.js";import{useSingleBox as
|
|
1
|
+
import{useContext as p}from"react";import{synchronizeSideView as C,synchronizeBackView as P}from"./usePointCloudViews.js";import{useSingleBox as x}from"./useSingleBox.js";import{PointCloudContext as w}from"../PointCloudContext.js";import{cAnnotation as f}from"@labelbee/lb-annotation";import{PointCloudUtils as g}from"@labelbee/lb-utils";import{EPointCloudBoxRenderTrigger as b}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{useThrottleFn as B}from"ahooks";const{ERotateDirection:V}=f,y=({currentData:t})=>{const e=p(w),{selectedBox:i,updateSelectedBox:u}=x(),{run:d}=B(l=>{const{topViewInstance:r,mainViewInstance:n,syncAllViewPointCloudColor:a}=e;if(!r||!n)return;const{pointCloud2dOperation:s}=r,o=i==null?void 0:i.info;if(!o||!(t==null?void 0:t.url)||!e.backViewInstance)return;const m=u({rotation:g.restrictAngleRange(o.rotation+Number(Math.PI*l)/180)});s.rotatePolygon(l,V.Anticlockwise);const c=s.selectedPolygon;n.generateBox(o),a(b.SingleRotate,m),C(o,c,e.sideViewInstance,t.url),P(o,c,e.backViewInstance,t.url),n.render()},{wait:800});return{updateRotate:d}};export{y as useRotate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useContext as g}from"react";import{synchronizeSideView as m,synchronizeBackView as P}from"./usePointCloudViews.js";import{useSingleBox as h}from"./useSingleBox.js";import{PointCloudContext as w}from"../PointCloudContext.js";import{useThrottleFn as x}from"ahooks";import{PointCloudUtils as C}from"@labelbee/lb-utils";const f=({currentData:t})=>{const e=g(w),{selectedBox:l,updateSelectedBox:c}=h(),{run:u}=x(a=>{const{topViewInstance:r,mainViewInstance:i}=e;if(!r||!i)return;const{pointCloud2dOperation:s}=r,o=l==null?void 0:l.info;if(!o||!(t==null?void 0:t.url)||!e.backViewInstance)return;const n=s.selectedPolygon.pointList||[],p=n.shift();n.push(p),c({newPointList:n,rotation:C.restrictAngleRange(o.rotation+Number(Math.PI*a)/180),width:o.height,height:o.width}),s.rotatePolygonEdge(n);const d=s.selectedPolygon;i.generateBox(o),m(o,d,e.sideViewInstance,t.url),P(o,d,e.backViewInstance,t.url),i.render()},{wait:800});return{updateRotateEdge:u}};export{f as useRotateEdge};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as de,useMemo as A,useCallback as f}from"react";import m from"lodash";import{PointCloudContext as le}from"../PointCloudContext.js";import{EToolName as T,cAnnotation as re}from"@labelbee/lb-annotation";import{useHistory as se}from"./useHistory.js";import{usePolygon as ae}from"./usePolygon.js";import{EPointCloudBoxRenderTrigger as H}from"../../../utils/ToolPointCloudBoxRenderHelper.js";var ce=Object.defineProperty,ue=Object.defineProperties,fe=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,ge=Object.prototype.propertyIsEnumerable,k=(d,t,l)=>t in d?ce(d,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):d[t]=l,xe=(d,t)=>{for(var l in t||(t={}))pe.call(t,l)&&k(d,l,t[l]);if(M)for(var l of M(t))ge.call(t,l)&&k(d,l,t[l]);return d},Pe=(d,t)=>ue(d,fe(t));const{ESortDirection:B}=re,ve=d=>{const{pointCloudBoxList:t,setPointCloudResult:l,topViewInstance:s,backViewInstance:_,sideViewInstance:h,selectedIDs:y,selectedID:O,mainViewInstance:p,setSelectedIDs:K,syncAllViewPointCloudColor:V,polygonList:U,pointCloudPattern:R,rectList:S,updateRectIn2DView:me,removeRectIn2DView:F,addRectIn2DView:W,updateRectListByReducer:D}=de(le),{selectedPolygon:g,updateSelectedPolygon:q,updatePolygonValidByID:z,deletePolygon:G}=ae(),{pushHistoryWithList:b}=se(),a=A(()=>{const e=t.findIndex(n=>n.id===O);if(e>-1)return{info:t[e],index:e}},[O,t]),L=f(e=>{var n;if(a==null?void 0:a.info){(n=d==null?void 0:d.generateRects)==null||n.call(d,e),t.splice(a.index,1,m.merge(a.info,e));const o=m.cloneDeep(t);return l(o),b({pointCloudBoxList:o}),o}return t},[O,t]),J=f((e,n)=>{const o=t.findIndex(i=>i.id===n);if(o>-1){t.splice(o,1,m.merge(t[o],e));const i=m.cloneDeep(t);return l(i),i}return t},[t]),w=f(e=>{s==null||s.pointCloud2dOperation.setPolygonValidAndRender(e,!0),h==null||h.pointCloud2dOperation.setPolygonValidAndRender(e,!0),_==null||_.pointCloud2dOperation.setPolygonValidAndRender(e,!0)},[s,h,_]),Q=f(()=>{if(a==null?void 0:a.info){const{id:e,valid:n=!0}=a.info,o=L({valid:!n});V(H.SingleToggleValid,o),w(e)}g&&(q(Pe(xe({},g),{valid:!g.valid})),s==null||s.pointCloud2dOperation.setPolygonValidAndRender(g.id,!0))},[w,a,g]),X=f(e=>{const n=t.find(o=>o.id===e);if(n){const{id:o,valid:i=!0}=n,c=J({valid:!i},o);return w(o),c}z(e)},[w,t,U]),E=f((e=B.ascend,n=!1)=>{if(!s||y.length>1)return;if(R!==T.Rect&&R!==T.Polygon){n&&document.dispatchEvent(new KeyboardEvent("keydown",{keyCode:9,shiftKey:e!==B.ascend}));return}const{pointCloud2dOperation:o}=s,i=o.switchToNextPolygon(e);i&&K(i)},[s,R,s==null?void 0:s.toolInstance]),Y=(e=!1)=>{E(B.descend,e)},Z=(e=!1)=>{E(B.ascend,e)},N=(e,n=!0)=>{const o=t.filter(i=>i.id!==e);if(l(o),p==null||p.removeObjectByName(e,"box"),p==null||p.render(),V(H.SingleDelete,o),n){const i=S.filter(r=>r.extId===e),c=new Set(i.map(r=>r.id));D(j(c))}},j=e=>(n,o)=>{let i=!1;const c=n.map(r=>e.has(r.id)?(i=!0,o(r)):r);return i?c:n},$=f((e,n)=>{var o,i;const c=new Set((i=(o=n.mappingImgList)==null?void 0:o.map(u=>u.path))!=null?i:[]),r=new Map;e.forEach(u=>{const I=u.id;(u.rects||[]).forEach(C=>{const{imageName:v}=C;if(c.has(v)){let P=r.get(v);P||(P=new Set,r.set(v,P)),P.add(I)}})});const x=S.filter(u=>{var I;const C=u.extId,v=u.imageName;if(v!==void 0&&C!==void 0){const P=r.get(v);return(I=P==null?void 0:P.has(C))!=null?I:!1}return!1}),ie=new Set(x.map(u=>u.id));D(j(ie))},[S,F,W]),ee=e=>{a&&(N(a.info.id,!1),s==null||s.pointCloud2dOperation.deletePolygon(a.info.id),$([a.info],e)),g&&(G(g.id),s==null||s.pointCloud2dOperation.deletePolygon(g.id))},te=A(()=>t.filter(e=>y.includes(e.id)),[y,t]),oe=f(e=>{var n;const o=m.cloneDeep(t);let i=!1;for(const c of e){const r=o.findIndex(x=>x.id===c.id);if(r>-1){const x=m.merge(o[r],c);(n=d==null?void 0:d.generateRects)==null||n.call(d,x),o.splice(r,1,x),p==null||p.generateBox(x),i=!0}}if(i)return l(o),b({pointCloudBoxList:o}),p==null||p.render(),o},[y,t]),ne=f(e=>t.find(n=>n.id===e),[t]);return{selectedBox:a,updateSelectedBox:L,changeSelectedBoxValid:Q,changeValidByID:X,selectNextBox:Z,selectPrevBox:Y,deletePointCloudBox:N,selectedBoxes:te,updateSelectedBoxes:oe,getPointCloudByID:ne,deleteSelectedPointCloudBoxAndPolygon:ee}};export{ve as useSingleBox};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as x,useMemo as P}from"react";import{PointCloudContext as E}from"../PointCloudContext.js";import{cTool as I}from"@labelbee/lb-annotation";import{useHistory as T}from"./useHistory.js";import{EPointCloudPattern as C}from"@labelbee/lb-utils";import{EPointCloudBoxRenderTrigger as A}from"../../../utils/ToolPointCloudBoxRenderHelper.js";const{EToolName:t,EPolygonPattern:p}=I,V=()=>{const{topViewInstance:s,sideViewInstance:a,backViewInstance:u,mainViewInstance:e,setPointCloudResult:m,setPointCloudSphereList:v,setPolygonList:h,setRectList:b,pointCloudPattern:c,setPointCloudPattern:l,syncAllViewPointCloudColor:g,globalPattern:n,setLineList:L}=x(E),{pushHistoryWithList:R}=T(),f=()=>{e==null||e.clearAllBox(),e==null||e.clearAllSphere(),e==null||e.render(),m([]),h([]),v([]),L([]),b([]),s==null||s.toolScheduler.clearStatusAndResult(),g(A.ClearAll,[]),R({pointCloudBoxList:[],polygonList:[],pointCloudSphereList:[]})},i=()=>{a==null||a.toolInstance.clearResult(),u==null||u.toolInstance.clearResult()},w=d=>{if(d===c)return;const r=[s,a,u];switch(d){case t.Rect:i(),r.forEach(o=>{o==null||o.switchToCanvas(t.PointCloudPolygon),o==null||o.toolInstance.setPattern(p.Rect)}),l(t.Rect);break;case t.Polygon:i(),r.forEach(o=>{o==null||o.switchToCanvas(t.PointCloudPolygon),o==null||o.toolInstance.setPattern(p.Normal)}),l(t.Polygon);break;case t.Point:i(),r.forEach(o=>{o==null||o.switchToCanvas(t.Point)}),l(t.Point);break;case t.Line:i(),r.forEach(o=>{o==null||o.switchToCanvas(t.Line)}),l(t.Line);break}},y=P(()=>n===C.Detection,[n]),S=P(()=>n===C.Segmentation,[n]);return{clearAllResult:f,updatePointCloudPattern:w,pointCloudPattern:c,isPointCloudDetectionPattern:y,isPointCloudSegmentationPattern:S}};export{V as useStatus};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRef as f,useCallback as n,useEffect as i}from"react";import{useMemoizedFn as a}from"ahooks";const o=r=>typeof r=="number",l=(r,e)=>{const c=a(r),u=f(null),t=n(()=>{u.current&&clearTimeout(u.current)},[]),s=n((...m)=>{!o(e)||e<0||(t(),u.current=setTimeout(()=>c(...m),e))},[e]);return i(()=>t,[t]),{fn:s,clear:t}};export{l as default,o as isNumber};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRef as l,useCallback as i,useEffect as a,useMemo as f}from"react";import"../utils/event-polyfill.js";const c=()=>()=>{},L=()=>({appendEventListener:c,preappendEventListener:c,addEventListener:c}),w=()=>{},v=()=>{const t=l([]),p=i(e=>{const n=t.current,s=n.findIndex(d=>d===e);s>-1&&n.splice(s,1)},[]),r=i((e,n)=>e?(n(e),()=>{p(e)}):(console.warn("invalid listener"),w),[p]),o=i(e=>r(e,n=>{t.current.push(n)}),[r]),u=i(e=>r(e,n=>{t.current.unshift(n)}),[r]);return a(()=>()=>{t.current.length=0},[]),a(()=>{const e=n=>{const s=t.current.slice(0);for(let d of s){if(n.isImmediatePropagationStopped())break;d(n)}};return window.addEventListener("keydown",e,!1),()=>{window.removeEventListener("keydown",e,!1)}},[]),f(()=>({appendEventListener:o,preappendEventListener:u,addEventListener:o}),[o,u])};export{v as default,L as getEmptyUseWindowKeydownListener};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as n}from"../../utils/dom.js";import t,{useContext as
|
|
1
|
+
import{getClassName as n}from"../../utils/dom.js";import t,{useContext as T,useState as y,useEffect as C}from"react";import _ from"./PointCloud3DView.js";import k from"./PointCloudBackView.js";import B from"./PointCloudTopView.js";import F from"./PointCloudSideView.js";import R from"./PointCloud2DView.js";import M from"./PointCloudListener.js";import G from"./PointCloudSegmentListener.js";import O from"./PointCloudSegment.js";import Z from"./PointCloudSegmentStatus.js";import U from"./PointCloudSegmentToolbar.js";import W from"./PointCloudSegment2DView.js";import{connect as $}from"react-redux";import{LabelBeeContext as q,useDispatch as z}from"../../store/ctx.js";import{AnnotatedAttributesPanelFixedLeft as H,AnnotatedAttributesPanelFixedRight as J}from"../../views/MainView/toolFooter/AnnotatedAttributes/index.js";import{PointCloudContext as K}from"./PointCloudContext.js";import{PointCloudUtils as Q,EPointCloudPattern as X}from"@labelbee/lb-utils";import{useCustomToolInstance as Y}from"../../hooks/annotation.js";import{jsonParser as tt}from"../../utils/index.js";import{a2MapStateToProps as et}from"../../store/annotation/map.js";import L from"classnames";import ot from"./components/sideAndBackOverView/index.js";import{SetLoadPCDFileLoading as nt}from"../../store/annotation/actionCreators.js";const it=E=>{const{currentData:a,imgList:S,drawLayerSlot:d,checkMode:i,intelligentFit:w,imgIndex:x,config:b,measureVisible:j}=E,e=T(K),{globalPattern:p,setGlobalPattern:v,selectedIDs:P}=e,V=z(),[l,f]=y(!1),h=(P==null?void 0:P.length)>0&&l,D=tt(a.result),{toolInstanceRef:r,clearToolInstance:A}=Y({basicInfo:D});if(C(()=>{r.current.setPointCloudGlobalPattern=o=>{o!==p&&(v(o),e.clearAllDetectionInstance(),A())}},[p]),C(()=>{var o;if(nt(V,!0),a){const{boxParamsList:s,polygonList:m,lineList:u,sphereParamsList:c,segmentation:N,rectList:I}=Q.parsePointCloudCurrentResult((o=a==null?void 0:a.result)!=null?o:"");e.setPointCloudResult(s),e.setPolygonList(m),e.setLineList(u),e.setPointCloudSphereList(c),e.setRectList(I),e.setSegmentation(N)}},[x]),C(()=>{r.current.exportData=()=>[e.pointCloudBoxList,{valid:e.valid}],r.current.exportCustomData=()=>{var o,s,m,u,c;return{resultPolygon:(o=e.polygonList)!=null?o:[],resultLine:(s=e.lineList)!=null?s:[],resultPoint:(m=e.pointCloudSphereList)!=null?m:[],resultRect:(u=e.rectList)!=null?u:[],segmentation:(c=e.segmentation)!=null?c:[]}}},[e.pointCloudBoxList,e.rectList,e.valid,e.polygonList,e.lineList,e.pointCloudSphereList,e.ptSegmentInstance,e.segmentation]),S.length===0)return null;if(p===X.Segmentation)return t.createElement(t.Fragment,null,t.createElement(G,{checkMode:i,toolInstanceRef:r}),t.createElement(U,null),t.createElement("div",{className:n("point-cloud-layout")},t.createElement(O,{checkMode:i}),t.createElement(W,null)),t.createElement(Z,{config:b}),d==null?void 0:d({direct:!0}));let g=t.createElement("div",{className:n("point-cloud-container","left-bottom")},t.createElement(k,{checkMode:i}),t.createElement(F,{checkMode:i}));return l&&(g=t.createElement(ot,{selectAndEnlarge:h,checkMode:i})),t.createElement(t.Fragment,null,t.createElement(M,{checkMode:i,toolInstanceRef:r}),t.createElement("div",{className:n("point-cloud-layout"),onContextMenu:o=>o.preventDefault()},t.createElement("div",{className:n("point-cloud-wrapper")},t.createElement(H,null),t.createElement("div",{className:n("point-cloud-content")},t.createElement("div",{className:n("point-cloud-container","left")},t.createElement(_,null),g),t.createElement("div",{className:L({[n("point-cloud-container","right")]:!0,[n("point-cloud-container","rightZoom")]:l})},t.createElement(B,{drawLayerSlot:d,checkMode:i,intelligentFit:w,setIsEnlargeTopView:f,onExitZoom:()=>{f(!1)},isEnlargeTopView:l}),t.createElement("div",{className:L({[n("point-cloud-container","right-bottom")]:!l,[n("point-cloud-container","right-bottom-floatLeft")]:l})},t.createElement(R,{isEnlargeTopView:l,thumbnailWidth:l?300:455,checkMode:i,measureVisible:j})))),t.createElement(J,null))))};var lt=$(et,null,null,{context:q})(it);export{lt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const stopImmediatePropagationOriginal=Event.prototype.stopImmediatePropagation;Event.prototype.isImmediatePropagationStopped=()=>!1,Event.prototype.stopImmediatePropagation=function(t){stopImmediatePropagationOriginal.bind(this).call(t),this.isImmediatePropagationStopped=()=>!0};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=(n,r,d,a)=>{let e=n.get(r);e||(e=new Map,n.set(r,e));let t=e.get(d);return t||(t=new WeakSet,e.set(d,t)),t.add(a),n};export{s as addMapIndirectWeakSetItem};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o,{useEffect as g}from"react";import{Checkbox as y,Select as u,Divider as x}from"antd";import{I18nextProvider as S,useTranslation as _}from"react-i18next";import E from"../attributeList/index.js";import{i18n as v}from"@labelbee/lb-utils";var h=Object.defineProperty,s=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,f=(t,a,r)=>a in t?h(t,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[a]=r,P=(t,a)=>{for(var r in a||(a={}))w.call(a,r)&&f(t,r,a[r]);if(s)for(var r of s(a))O.call(a,r)&&f(t,r,a[r]);return t};const k={margin:"12px 20px 8px",fontSize:14,fontWeight:500,wordWrap:"break-word"},C=t=>{const{subAttributeList:a,setSubAttribute:r,getValue:i,lang:p}=t,{t:c}=_();g(()=>{var e;p&&((e=v)==null||e.changeLanguage(p))},[]);const m=(e,n)=>{if(Array.isArray(n)){r(e,n.join(";"));return}r(e,n)},d=e=>{const n=i(e);return(e==null?void 0:e.isMulti)?n?n==null?void 0:n.split(";"):[]:n};return o.createElement(o.Fragment,null,a.map(e=>{var n;return(e==null?void 0:e.subSelected)&&o.createElement("div",{style:{marginTop:12},key:e.value},o.createElement("div",{style:k},c("SubAttribute"),"-",e.key),((n=e.subSelected)==null?void 0:n.length)<5?(e==null?void 0:e.isMulti)?o.createElement(y.Group,{style:{padding:"0px 20px 16px 16px"},options:e.subSelected.map(l=>({label:l.key,value:l.value})),value:d(e),onChange:l=>m(e.value,l)}):o.createElement(E,{list:e.subSelected.map(l=>({label:l.key,value:l.value})),selectedAttribute:i(e),num:"-",forbidColor:!0,forbidDefault:!0,attributeChanged:l=>r(e.value,l),style:{marginBottom:12}}):o.createElement(u,{style:{margin:"0px 20px 16px 16px",width:"87%"},mode:(e==null?void 0:e.isMulti)?"multiple":void 0,value:d(e),placeholder:c("PleaseSelect"),onChange:l=>m(e.value,l),allowClear:!0},e.subSelected.map(l=>o.createElement(u.Option,{key:l.value,value:l.value},l.key))),o.createElement(x,{style:{margin:0}}))}))},L=t=>o.createElement(S,{i18n:v},o.createElement(C,P({},t)));export{L as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MathUtils as C,CommonToolUtils as F,uuid as A,AttributeUtils as k}from"@labelbee/lb-annotation";import{jsonParser as P}from"../../../utils/index.js";import{precisionAdd as I,precisionMinus as V,isImageValue as R}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 o,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===o.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(I(u,t),[0,V(a===T.Time?s:l,v)]);this.updateSelectedSliceTimeProperty(n,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===o.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(I(u,t),[I(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===o.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!==o.Clipping)return;const s=t.findIndex(l=>l.id===e);s>-1&&(t.splice(s,1),this.setState({result:t,selectedID:"",clipStatus:o.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i,s;if(this.disabled)return;const{clipStatus:l,selectedAttribute:u}=this.state,a=l!==o.Clipping;let n=a?o.Clipping:o.Stop,{result:d,selectedID:c,textValue:p}=this.state;const h=b.cloneDeep(d),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(a){const f=A();c=f,h.push({start:w,end:null,attribute:u,textAttribute:this.defaultTextAttribute,duration:y,id:f,type:T.Period}),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`),n=o.Stop,c="",p=""):(h[f].end=L(S,2),(s=this.videoPlayer)==null||s.pause(),m.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${d.length}`)))}this.setState({clipStatus:n,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:a}=this.state,n=A(),d=b.cloneDeep(l),c=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;d.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 p={result:d,selectedID:n,textValue:this.defaultTextAttribute},h=d.find(S=>S.id===a);this.isClipping&&h?(delete p.selectedID,delete p.textValue,m.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${d.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===o.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,d=e==="left",c=d?"start":"end",p=d?-n*i:n*i,h=d?[0,Math.max(((s=a.end)!=null?s:0)-x,0)]:[a.start+x,n],S=C.withinRange(p+((l=a==null?void 0:a[c])!=null?l:0),h);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:d=>{this.videoPlayer=d},showVideoTrack:!u,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),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=R(s[i].result||"[]");this.setState({result:a,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:o.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:o.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===o.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 k.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 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 +1 @@
|
|
|
1
|
-
import h from"react";import{TagUtils as
|
|
1
|
+
import h from"react";import{TagUtils as m,CommonToolUtils as f,uuid as v}from"@labelbee/lb-annotation";import{jsonParser as g}from"../../../utils/index.js";import{VideoPlayer as y}from"../../videoPlayer/index.js";import{VideoTagLayer as L}from"../../videoPlayer/VideoTagLayer.js";import p,{cloneDeep as R}from"lodash";import{getKeyCodeNumber as b}from"../../videoPlayer/utils.js";class S extends h.Component{constructor(e){super(e);this.fns={},this.labelSelectedList=[],this.clearResult=(t=!0,s)=>{const n=s?this.state.tagResult.map(i=>((i==null?void 0:i.result[s])&&delete i.result[s],i)):[];this.setState({tagResult:n},()=>this.emitEvent("render"))},this.exportData=()=>{var t,s;const n=(s=(t=this.videoPlayer)==null?void 0:t.duration)!=null?s:0;return[this.state.tagResult,{valid:this.state.valid,duration:n}]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.combineResult=(t,s={})=>{var n,i;const l=R(s),{isMulti:a}=t,{key:r,value:d}=t.value;if(a){let o=(i=(n=l[r])==null?void 0:n.split(";"))!=null?i:[];o.includes(d)?o=o.filter(c=>c!==d):o.push(d);const u=new Set(o);return l[r]=Array.from(u).join(";"),p.pickBy(l,c=>c)}return l[r]=l[r]===d?void 0:d,p.pickBy(l,o=>o)},this.setResult=t=>{this.setState({tagResult:t}),this.fns.render&&this.fns.render()},this.setLabel=(t,s)=>{this.setLabelBySelectedList(t,s)},this.keydown=t=>{var s;const n=b(t.keyCode);if(n){const i=n-1;if(((s=this.config.inputList)==null?void 0:s.length)===1){this.labelSelectedList=[0,i],this.setLabel(0,i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],i],this.setLabel(this.labelSelectedList[0],i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500)):(this.labelSelectedList=[i],this.emitEvent("expend"))}},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({tagResult:[]}),this.emitEvent("render")},this.setResultFromImgList=t=>{const{imgList:s,imgIndex:n,stepInfo:i}=t;if(!s[n])return;const l=g(s[n].result),a=l[`step_${i.step}`],r=this.getInitResultList();this.setState({tagResult:a?a==null?void 0:a.result:r,valid:(l==null?void 0:l.valid)===void 0?!0:l.valid},()=>this.emitEvent("render"))},this.getInitResultList=()=>{var t;return m.getDefaultTagResult((t=this.config.inputList)!=null?t:[],[])},this.state={tagResult:[],labelSelectedList:[],valid:!0}}get config(){var e;return g((e=this.props.stepInfo)==null?void 0:e.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get currentTagResult(){var e;return(e=this.state.tagResult[0])!=null?e:{}}get valid(){return this.state.valid}singleOn(e,t){this.fns[e]=t}on(e,t){this.singleOn(e,t)}unbindAll(e){delete this.fns[e]}getTagResultByCode(e,t){var s,n,i;try{const l=(n=(s=this.config)==null?void 0:s.inputList)!=null?n:[],a=(l==null?void 0:l.length)>1,r=t!==void 0?e:0,d=t!==void 0?t:e,o=a?l[r]:l[0],u=((i=o.subSelected)!=null?i:[])[d];if(o&&u)return{value:{key:o.value,value:u.value},isMulti:o.isMulti}}catch(l){return}}setLabelBySelectedList(e,t){var s,n,i,l,a,r;const d=this.getTagResultByCode(e,t);if(d){const o=this.combineResult(d,(n=(s=this.state.tagResult[0])==null?void 0:s.result)!=null?n:{}),u=[{sourceID:f.getSourceID(),id:(l=(i=this.currentTagResult)==null?void 0:i.id)!=null?l:v(8,62),result:o}];if(typeof((a=this.props)==null?void 0:a.annotationBefore)=="function"){(r=this.props)==null||r.annotationBefore(()=>this.setState({tagResult:u},()=>this.emitEvent("render")));return}this.setState({tagResult:u},()=>this.emitEvent("render"))}}componentDidMount(){document.addEventListener("keydown",this.keydown),this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){document.addEventListener("keydown",this.keydown),this.props.onUnmounted()}shouldComponentUpdate(e){return e.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(e),!0}render(){var e;const{imgIndex:t,imgList:s,pageForward:n,pageJump:i,pageBackward:l}=this.props,{tagResult:a,valid:r}=this.state;return h.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},h.createElement(y,{imgIndex:t,imgList:s,pageBackward:l,pageForward:n,pageJump:i,valid:r,setVideoRef:d=>{this.videoPlayer=d},dataLoaded:this.props.onVideoLoaded,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer}),h.createElement(L,{result:a,inputList:(e=this.config)==null?void 0:e.inputList,hasPromptLayer:!!this.props.drawLayerSlot}))}}export{S as TagToolInstanceAdaptor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import p,{createContext as d,useContext as _,useState as y,useCallback as m,useMemo as v,useEffect as O}from"react";import{pick as P}from"lodash";var h=Object.defineProperty,c=Object.getOwnPropertySymbols,x=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,s=(r,e,t)=>e in r?h(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,l=(r,e)=>{for(var t in e||(e={}))x.call(e,t)&&s(r,t,e[t]);if(c)for(var t of c(e))V.call(e,t)&&s(r,t,e[t]);return r};const w=["hiddenText"],i={hiddenText:!1},u=d({value:i,updateValue:()=>{}}),T=()=>_(u),b=r=>{const[e,t]=y(()=>l({},i)),a=m(o=>{t(n=>!o||typeof o=="object"&&Object.keys(o).length===0?n:l(l({},n),o))},[]),f=v(()=>({value:e,updateValue:a}),[e,a]);return O(()=>{const o=r.value;if(!o)return;const n=P(o,w);Object.keys(n).length!==0&&a(n)},[r.value,a]),p.createElement(u.Provider,{value:f},r.children)};export{u as ToolStyleContext,b as ToolStyleProvider,T as useToolStyleContext};
|