@labelbee/lb-components 1.23.0-alpha.98 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/2DViewWorker.js +1 -1
- package/dist/components/AnnotationView/hooks/useFilterAnnotations.js +1 -0
- package/dist/components/AnnotationView/index.js +1 -1
- package/dist/components/LLMMultiWheelView/dialogView/index.js +1 -0
- package/dist/components/LLMMultiWheelView/index.js +1 -0
- package/dist/components/LLMMultiWheelView/sidebar/index.js +1 -0
- package/dist/components/LLMToolView/index.js +1 -1
- package/dist/components/LLMToolView/questionView/components/header/index.js +1 -1
- package/dist/components/LLMToolView/questionView/components/imgView/index.js +1 -1
- package/dist/components/LLMToolView/questionView/index.js +1 -1
- package/dist/components/LLMToolView/sidebar/components/answerSort/index.js +1 -1
- package/dist/components/LLMToolView/sidebar/components/modelAnswerSort/index.js +1 -0
- package/dist/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
- package/dist/components/LLMToolView/sidebar/index.js +1 -1
- package/dist/components/attributeList/index.js +1 -1
- package/dist/components/audioPlayer/index.js +1 -1
- package/dist/components/audioPlayer/useAudioScroll/index.js +1 -1
- package/dist/components/markdownView/index.js +1 -1
- package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
- package/dist/components/pointCloudView/PointCloud2DSingleView.js +1 -1
- package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
- package/dist/components/pointCloudView/PointCloudListener.js +1 -1
- package/dist/components/pointCloudView/PointCloudSegmentListener.js +1 -1
- package/dist/components/pointCloudView/PointCloudTopView.js +1 -1
- package/dist/components/pointCloudView/hooks/useBoxes.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/components/pointCloudView/hooks/useUpdatePointCloudColor.js +1 -0
- package/dist/components/pointCloudView/index.js +1 -1
- package/dist/components/predictTracking/predictTrackingIcon/index.js +1 -1
- package/dist/components/predictTracking/previewResult/index.js +1 -1
- package/dist/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
- package/dist/data/enums/ToolType.js +1 -1
- package/dist/index.css +71 -4
- package/dist/index.js +1 -1
- package/dist/store/LLMMultiWheel/index.js +1 -0
- package/dist/store/annotation/actionCreators.js +1 -1
- package/dist/store/annotation/reducer.js +1 -1
- package/dist/store/ctx.js +1 -1
- package/dist/store/toolConfig/baseToolConfig.js +1 -0
- package/dist/store/toolConfig/index.js +1 -0
- package/dist/store/toolConfig/pointCloudToolConfig.js +1 -0
- package/dist/types/App.d.ts +1 -0
- package/dist/types/components/AnnotationView/hooks/useFilterAnnotations.d.ts +2 -0
- package/dist/types/components/AnnotationView/index.d.ts +9 -0
- package/dist/types/components/LLMMultiWheelView/dialogView/index.d.ts +15 -0
- package/dist/types/components/LLMMultiWheelView/index.d.ts +21 -0
- package/dist/types/components/LLMMultiWheelView/sidebar/index.d.ts +8 -0
- package/dist/types/components/LLMMultiWheelView/types.d.ts +62 -0
- package/dist/types/components/LLMToolView/questionView/components/header/index.d.ts +15 -0
- package/dist/types/components/LLMToolView/questionView/index.d.ts +7 -0
- package/dist/types/components/LLMToolView/sidebar/components/answerSort/index.d.ts +3 -0
- package/dist/types/components/LLMToolView/sidebar/components/modelAnswerSort/index.d.ts +30 -0
- package/dist/types/components/LLMToolView/sidebar/components/textInputBox/index.d.ts +2 -2
- package/dist/types/components/LLMToolView/sidebar/index.d.ts +10 -0
- package/dist/types/components/LLMToolView/types.d.ts +6 -2
- package/dist/types/components/LLMToolView/utils/data.d.ts +1 -0
- package/dist/types/components/pointCloudView/PointCloudListener.d.ts +1 -0
- package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +23 -1
- package/dist/types/components/pointCloudView/hooks/useUpdatePointCloudColor.d.ts +4 -0
- package/dist/types/components/pointCloudView/index.d.ts +1 -0
- package/dist/types/data/enums/ToolType.d.ts +2 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/store/LLMMultiWheel/index.d.ts +15 -0
- package/dist/types/store/annotation/actionCreators.d.ts +1 -1
- package/dist/types/store/ctx.d.ts +7 -0
- package/dist/types/store/toolConfig/baseToolConfig.d.ts +4 -0
- package/dist/types/store/toolConfig/index.d.ts +3 -0
- package/dist/types/store/toolConfig/pointCloudToolConfig.d.ts +4 -0
- package/dist/types/store/toolConfig/types.d.ts +10 -0
- package/dist/types/utils/ToolPointCloudBoxRenderHelper.d.ts +2 -1
- package/dist/types/views/MainView/LLMMultiWheelLayout/index.d.ts +9 -0
- package/dist/types/views/MainView/sidebar/PointCloudToolSidebar/components/firstFrameDataSwitch/index.d.ts +3 -0
- package/dist/types/views/MainView/sidebar/PointCloudToolSidebar/components/selectBoxVisibleSwitch/index.d.ts +3 -0
- package/dist/utils/ToolPointCloudBoxRenderHelper.js +1 -1
- package/dist/views/MainView/LLMMultiWheelLayout/index.js +1 -0
- package/dist/views/MainView/index.js +1 -1
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/firstFrameDataSwitch/index.js +1 -0
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/firstFrameDataSwitch/index.module.scss.js +1 -0
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/selectBoxVisibleSwitch/index.js +1 -0
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/components/selectBoxVisibleSwitch/index.module.scss.js +1 -0
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/dist/views/MainView/sidebar/index.js +1 -1
- package/dist/views/MainView/toolFooter/FooterTips/ToolHotKey/index.js +1 -1
- package/es/_virtual/2DViewWorker.js +1 -1
- package/es/components/AnnotationView/hooks/useFilterAnnotations.js +1 -0
- package/es/components/AnnotationView/index.js +1 -1
- package/es/components/LLMMultiWheelView/dialogView/index.js +1 -0
- package/es/components/LLMMultiWheelView/index.js +1 -0
- package/es/components/LLMMultiWheelView/sidebar/index.js +1 -0
- package/es/components/LLMToolView/index.js +1 -1
- package/es/components/LLMToolView/questionView/components/header/index.js +1 -1
- package/es/components/LLMToolView/questionView/components/imgView/index.js +1 -1
- package/es/components/LLMToolView/questionView/index.js +1 -1
- package/es/components/LLMToolView/sidebar/components/answerSort/index.js +1 -1
- package/es/components/LLMToolView/sidebar/components/modelAnswerSort/index.js +1 -0
- package/es/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
- package/es/components/LLMToolView/sidebar/index.js +1 -1
- package/es/components/attributeList/index.js +1 -1
- package/es/components/audioPlayer/index.js +1 -1
- package/es/components/audioPlayer/useAudioScroll/index.js +1 -1
- package/es/components/markdownView/index.js +1 -1
- package/es/components/pointCloud2DRectOperationView/index.js +1 -1
- package/es/components/pointCloudView/PointCloud2DSingleView.js +1 -1
- package/es/components/pointCloudView/PointCloud3DView.js +1 -1
- package/es/components/pointCloudView/PointCloudListener.js +1 -1
- package/es/components/pointCloudView/PointCloudSegmentListener.js +1 -1
- package/es/components/pointCloudView/PointCloudTopView.js +1 -1
- package/es/components/pointCloudView/hooks/useBoxes.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/hooks/useUpdatePointCloudColor.js +1 -0
- package/es/components/pointCloudView/index.js +1 -1
- package/es/components/predictTracking/predictTrackingIcon/index.js +1 -1
- package/es/components/predictTracking/previewResult/index.js +1 -1
- package/es/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
- package/es/data/enums/ToolType.js +1 -1
- package/es/index.css +71 -4
- package/es/index.js +1 -1
- package/es/store/LLMMultiWheel/index.js +1 -0
- package/es/store/annotation/actionCreators.js +1 -1
- package/es/store/annotation/reducer.js +1 -1
- package/es/store/ctx.js +1 -1
- package/es/store/toolConfig/baseToolConfig.js +1 -0
- package/es/store/toolConfig/index.js +1 -0
- package/es/store/toolConfig/pointCloudToolConfig.js +1 -0
- package/es/utils/ToolPointCloudBoxRenderHelper.js +1 -1
- package/es/views/MainView/LLMMultiWheelLayout/index.js +1 -0
- package/es/views/MainView/index.js +1 -1
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/firstFrameDataSwitch/index.js +1 -0
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/firstFrameDataSwitch/index.module.scss.js +1 -0
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/selectBoxVisibleSwitch/index.js +1 -0
- package/es/views/MainView/sidebar/PointCloudToolSidebar/components/selectBoxVisibleSwitch/index.module.scss.js +1 -0
- package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/es/views/MainView/sidebar/index.js +1 -1
- package/es/views/MainView/toolFooter/FooterTips/ToolHotKey/index.js +1 -1
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudContext as
|
|
1
|
+
import{PointCloudContext as re}from"./PointCloudContext.js";import{useRotate as se}from"./hooks/useRotate.js";import{useRotateEdge as ne}from"./hooks/useRotateEdge.js";import{useBoxes as ie}from"./hooks/useBoxes.js";import{useSingleBox as ae}from"./hooks/useSingleBox.js";import{useSphere as ue}from"./hooks/useSphere.js";import{useContext as le,useEffect as d}from"react";import{CommonToolUtils 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 be}from"../../store/annotation/map.js";import{useStatus as fe}from"./hooks/useStatus.js";import{usePointCloudViews as Pe}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as ye}from"../../store/ctx.js";import{useHistory as ve}from"./hooks/useHistory.js";import{useAttribute as we}from"./hooks/useAttribute.js";import{useConfig as Ce}from"./hooks/useConfig.js";import{usePolygon as he}from"./hooks/usePolygon.js";import{useLine as ge}from"./hooks/useLine.js";import{useUpdatePointCloudColor as Se}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as ke}from"react-i18next";import{useLatest as j}from"ahooks";var xe=Object.defineProperty,_e=Object.defineProperties,Ve=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,A=(n,r,a)=>r in n?xe(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,P=(n,r)=>{for(var a in r||(r={}))Be.call(r,a)&&A(n,a,r[a]);if(I)for(var a of I(r))Le.call(r,a)&&A(n,a,r[a]);return n},y=(n,r)=>_e(n,Ve(r));const{EPolygonPattern:Oe}=pe,je=({currentData:n,config:r,checkMode:a,configString:E,imgIndex:S,toolInstanceRef:i,setResourceLoading:k})=>{const e=le(re),{changeSelectedBoxValid:T,selectNextBox:D,selectPrevBox:H,updateSelectedBox:K,deleteSelectedPointCloudBoxAndPolygon:N}=ae(),{selectedSphere:v,updatePointCloudSphere:U}=ue(),{clearAllResult:w,updatePointCloudPattern:z}=fe(),{copySelectedBoxes:R,pasteSelectedBoxes:F,copiedBoxes:Ae}=ie({config:r,currentData:n}),{updateRotate:x}=se({currentData:n}),{updateRotateEdge:q}=ne({currentData:n}),{updatePointCloudData:m,topViewSelectedChanged:G}=Pe({setResourceLoading:k}),{redo:_,undo:V,pushHistoryWithList:M,pushHistoryUnderUpdatePolygon:W,pushHistoryUnderUpdateLine:Y}=ve(),{syncThreeViewsAttribute:B}=we(),{syncAllViewsConfig:$,reRenderTopViewRange:J}=Ce(),{selectedPolygon:L}=he(),{selectedLine:O}=ge(),{t:C}=ke(),{updatePointCloudColor:Q}=Se(k,r),X=j(n),b=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},Z=(t,o)=>{var s,u;const{topViewInstance:c,mainViewInstance:l}=e;if(!c)return;const{pointCloud2dOperation:h}=c;switch(t){case"q":{x(e.rectRotateSensitivity);break}case"e":x(-Number(e.rectRotateSensitivity));break;case"g":q(-90);break;case"u":{const p=h.pattern===Oe.Normal?f.Rect:f.Polygon;z(p);const oe={[f.Polygon]:C("PolygonPattern"),[f.Rect]:C("RectPattern")};g.success(C("ChangePatternMsg",{pattern:oe[p]})),h.clearActiveStatus(),h.clearDrawingStatus()}break;case"+":l==null||l.updatePointSize({zoomIn:!0});break;case"-":l==null||l.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){H();break}D(),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(X.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const p=de.getAttributeByKeycode(o.keyCode,r.attributeList);p!==void 0&&((u=i.current)==null||u.setDefaultAttribute(p))}return}}},ee=(t,o)=>{switch(t){case"c":R();break;case"v":F();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?_():V();break}}},te=j(t=>{if(!ce.hotkeyFilter(t)||a===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){ee(o,t);return}Z(o,t)});return d(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>te.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),d(()=>{$(r)},[E]),d(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),d(()=>{m==null||m()},[S,e.mainViewInstance]),d(()=>{e.setHideAttributes([])},[S]),d(()=>{i.current.setDefaultAttribute=t=>{var o;if(B(t),Q(t),L&&W(y(P({},L),{attribute:t})),O&&Y(y(P({},O),{attribute:t})),v){const s=U(y(P({},v),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),G({newSelectedSphere:v,newSphereList:s}))}},i.current.setSubAttribute=(t,o)=>{var s;const u=e.selectedPointCloudBox;if(u){const c=(s=u==null?void 0:u.subAttribute)!=null?s:{};u.subAttribute=y(P({},c),{[t]:o}),K(u),e.mainViewInstance&&e.selectedPointCloudBox&&e.mainViewInstance.generateBox(e.selectedPointCloudBox)}},i.current.clearResult=()=>{w==null||w()},i.current.redo=()=>{_()},i.current.undo=()=>{V()},i.current.setValid=t=>{i.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&w()})},i.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},i.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},i.current.asyncData=t=>{setTimeout(()=>{m==null||m(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),d(()=>{i.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},i.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),d(()=>{i.current.history={pushHistory:t=>{M({pointCloudBoxList:t})},initRecord:()=>{}}},[]),d(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||a)return;const s=l=>{B(l)},u=l=>{g.error(l)},c=l=>{g.info(l)};return o.on("syncAttribute",s),o.on("messageError",u),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",u),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var Ie=me(be,null,null,{context:ye})(je);export{Ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as L,useEffect as r}from"react";import{a2MapStateToProps as x}from"../../store/annotation/map.js";import{connect as y}from"react-redux";import{LabelBeeContext as
|
|
1
|
+
import{useContext as L,useEffect as r}from"react";import{a2MapStateToProps as x}from"../../store/annotation/map.js";import{connect as y}from"react-redux";import{LabelBeeContext as w,useDispatch as P}from"../../store/ctx.js";import{PointCloudContext as h}from"./PointCloudContext.js";import{CommonToolUtils as A}from"@labelbee/lb-annotation";import{PointCloudUtils as j,EPointCloudSegmentMode as S}from"@labelbee/lb-utils";import{useAttribute as D}from"./hooks/useAttribute.js";import{SetAnnotationLoading as v}from"../../store/annotation/actionCreators.js";import{jsonParser as E}from"../../utils/index.js";const _=({checkMode:b,currentData:l,imgIndex:g,highlightAttribute:s,config:B,toolInstanceRef:u,configString:m})=>{const d=P(),{updateSegmentAttribute:C,updateSegmentSubAttribute:f}=D(),n=L(h),{ptSegmentInstance:e,setSegmentation:c}=n;r(()=>{var t;if(e&&l.url)return v(d,!0),e.emit("clearStash"),e.emit("clearAllSegmentData"),e.loadPCDFile((t=l==null?void 0:l.url)!=null?t:"").then(()=>{var o,i;const a=j.getSegmentFromResultList((o=l==null?void 0:l.result)!=null?o:"");(i=e==null?void 0:e.store)==null||i.updateCurrentSegment(a),v(d,!1)}),e.on("syncSegmentData",c),()=>{e.unbind("syncSegmentData",c)}},[g,e]),r(()=>{var t;(t=e==null?void 0:e.store)==null||t.highlightPointsByAttribute(s!=null?s:"")},[s,e]),r(()=>{e==null||e.setConfig(E(m))},[m]);const k=(t,o)=>{var i,a;switch(t){case"h":e==null||e.emit("LassoSelector");break;case"j":e==null||e.emit("RectSelector");break;case"k":e==null||e.emit("CircleSelector");break;case"u":e==null||e.emit("setSegmentMode",S.Add);break;case"i":e==null||e.emit("setSegmentMode",S.Remove);break;case"enter":e==null||e.emit("updateCheck2Edit");break;case"delete":e==null||e.emit("deleteSelectedSegmentData",(a=(i=e.store)==null?void 0:i.cacheSegData)==null?void 0:a.id);break}},p=t=>{if(!A.hotkeyFilter(t)||b===!0)return;const o=t.key.toLocaleLowerCase();k(o)};return r(()=>(window.addEventListener("keydown",p),u.current.setDefaultAttribute=t=>{C(t),e==null||e.emit("updateDefaultAttribute",{newAttribute:t})},u.current.setSubAttribute=(t,o)=>{f(t,o)},()=>{window.removeEventListener("keydown",p)}),[e]),r(()=>{u.current.clearResult=()=>{!n.ptSegmentInstance||(n.ptSegmentInstance.emit("clearStash"),n.ptSegmentInstance.emit("clearAllSegmentData"))}},[n.pointCloudBoxList,n.valid,n.polygonList,n.lineList,n.pointCloudSphereList,n.ptSegmentInstance]),null};var M=y(x,null,null,{context:w})(_);export{M as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as
|
|
1
|
+
import{getClassName as _}from"../../utils/dom.js";import{FooterDivider as F}from"../../views/MainView/toolFooter/index.js";import{ZoomController as me}from"../../views/MainView/toolFooter/ZoomController/index.js";import{LeftOutlined as fe,UpSquareOutlined as Ce,DownSquareOutlined as ve}from"@ant-design/icons";import{cKeyCode as we,PointCloudAnnotation as Pe,MathUtils as W,cTool as ge,cAnnotation as ye}from"@labelbee/lb-annotation";import{PointCloudUtils as K}from"@labelbee/lb-utils";import{EPointCloudBoxRenderTrigger as Ie}from"../../utils/ToolPointCloudBoxRenderHelper.js";import s,{useState as A,useRef as xe,useLayoutEffect as he,useEffect as y}from"react";import{PointCloudContext as M}from"./PointCloudContext.js";import{useRotate as Ve}from"./hooks/useRotate.js";import{useRotateEdge as Se}from"./hooks/useRotateEdge.js";import{useSingleBox as X}from"./hooks/useSingleBox.js";import{PointCloudContainer as _e}from"./PointCloudLayout.js";import{BoxInfos as Y,PointCloudValidity as Ee}from"./PointCloudInfos.js";import{usePolygon as Le}from"./hooks/usePolygon.js";import{useSphere as q}from"./hooks/useSphere.js";import{useZoom as $}from"./hooks/useZoom.js";import{Slider as be}from"antd";import{a2MapStateToProps as Oe}from"../../store/annotation/map.js";import{connect as je}from"react-redux";import{usePointCloudViews as Te}from"./hooks/usePointCloudViews.js";import Re from"../../hooks/useSize.js";import{useTranslation as ke}from"react-i18next";import{LabelBeeContext as De}from"../../store/ctx.js";import{jsonParser as Be}from"../../utils/index.js";import Ne from"../../utils/ToolUtils.js";import Ae from"lodash";import Ue from"./components/PointCloudSizeSlider/index.js";import{useHistory as ze}from"./hooks/useHistory.js";import Ze from"./components/TitleButton/index.js";var He=Object.defineProperty,Fe=Object.defineProperties,We=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable,J=(i,l,r)=>l in i?He(i,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[l]=r,U=(i,l)=>{for(var r in l||(l={}))Ke.call(l,r)&&J(i,r,l[r]);if(G)for(var r of G(l))Me.call(l,r)&&J(i,r,l[r]);return i},z=(i,l)=>Fe(i,We(l));const{EPolygonPattern:Xe,EToolName:Q}=ge,{ESortDirection:ee}=ye,Ye=we.default,te=(i,l,r=1)=>{const{width:v,height:m}=l,I={x:i.x+v*r/2,y:i.y+m*r/2},x={x:l.width/2,y:l.height/2};return{offsetX:(x.x-I.x)/r,offsetY:-(x.y-I.y)/r}},qe=({currentData:i})=>{var l,r;const{zoom:v,zoomIn:m,zoomOut:I,initialPosition:x}=$(),{selectNextBox:O,selectPrevBox:j}=X(),{switchToNextSphere:E}=q(),{updateRotate:L}=Ve({currentData:i}),{updateRotateEdge:T}=Se({currentData:i}),P=s.useContext(M),{topViewInstance:h}=P,f=(r=(l=P==null?void 0:P.topViewInstance)==null?void 0:l.toolScheduler)==null?void 0:r.getCurrentToolName(),e=()=>{L(-Number(P.rectRotateSensitivity))},d=()=>{L(P.rectRotateSensitivity)},C=()=>{T(-90)};return s.createElement(s.Fragment,null,s.createElement(Ue,{onChange:B=>{var V;(V=h==null?void 0:h.pointCloudInstance)==null||V.updatePointSize({customSize:B})}}),s.createElement("span",{onClick:d,className:_("point-cloud","rotate-reserve")}),s.createElement("span",{onClick:e,className:_("point-cloud","rotate")}),s.createElement("span",{onClick:C,className:_("point-cloud","rotate-90")}),s.createElement(F,null),s.createElement(Ce,{onClick:()=>{if(f===Q.Point){E(ee.descend);return}j(!0)},className:_("point-cloud","prev")}),s.createElement(ve,{onClick:()=>{if(f===Q.Point){E(ee.ascend);return}O(!0)},className:_("point-cloud","next")}),s.createElement(F,null),s.createElement(me,{initialPosition:x,zoomIn:m,zoomOut:I,zoom:v}))},$e=({setZAxisLimit:i,zAxisLimit:l,checkMode:r})=>r?null:s.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},s.createElement(be,{vertical:!0,step:.5,max:10,min:.5,defaultValue:l,onAfterChange:v=>{i(v)}})),Ge=({currentData:i,imgList:l,stepInfo:r,drawLayerSlot:v,checkMode:m,intelligentFit:I,setIsEnlargeTopView:x,isEnlargeTopView:O,onExitZoom:j,highlightAttribute:E})=>{var L,T;const[P,h]=A({zoom:1,currentPos:{x:0,y:0}}),f=xe(null),e=s.useContext(M),d=Re(f),C=Be(r.config),{setZoom:B,syncTopviewToolZoom:V}=$(),{hideAttributes:oe}=e,{addPolygon:ne,deletePolygon:ie}=Le(),{deletePointCloudSphere:se}=q(),{deletePointCloudBox:le,changeValidByID:re}=X(),[N,ae]=A(10),{t:Z}=ke(),w=Te(),{pushHistoryWithList:ce}=ze(),[de,R]=A(!0);he(()=>{if(!e.topViewInstance&&f.current&&(i==null?void 0:i.url)&&(i==null?void 0:i.result)){const o={width:f.current.clientWidth,height:f.current.clientHeight},a=new Pe({container:f.current,size:o,pcdPath:i.url,config:z(U({},C),{pointCloudPattern:e.pointCloudPattern}),checkMode:m,toolName:Ne.getPointCloudToolList(),proxyMode:m});e.setTopViewInstance(a)}},[i]),y(()=>{if(!d||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:o}=e.topViewInstance;o.singleOn("dataUpdated",(t,n)=>{const u=Ae.cloneDeep(t).map(c=>z(U({},c),{pointList:K.pointListTransferCanvas2World(c.pointList,d)}));e.setSelectedIDs(n),e.setLineList(u),ce({lineList:u})}),o.singleOn("pointCreated",(t,n)=>{w.topViewAddSphere({newPoint:t,size:d,trackConfigurable:C.trackConfigurable,zoom:n})}),o.singleOn("pointDeleted",t=>{se(t)}),o.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),o.singleOn("updatePointByDrag",(t,n)=>{var u;(u=w.topViewUpdatePoint)==null||u.call(w,t,d)}),o.singleOn("polygonCreated",(t,n)=>{if(o.pattern===Xe.Normal||!(i==null?void 0:i.url)){const u=z(U({},t),{pointList:t.pointList.map(c=>K.transferCanvas2World(c,d))});ne(u),e.setSelectedIDs(oe.includes(t.attribute)?"":t.id);return}R(!1),w.topViewAddBox({polygon:t,size:d,imgList:l,trackConfigurable:C.trackConfigurable,zoom:n,intelligentFit:I})}),o.singleOn("deletedObject",({id:t})=>{le(t),ie(t)}),o.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),o.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),o.singleOn("setSelectedIDs",t=>{R(!1),e.setSelectedIDs(t)}),o.singleOn("updatePolygonByDrag",t=>{var n;(n=w.topViewUpdateBox)==null||n.call(w,t,d)});const a=t=>{var n;const u=re(t);u&&e.syncAllViewPointCloudColor(Ie.Default,u),e.polygonList.find(c=>c.id===t)&&((n=e.topViewInstance)==null||n.toolInstance.setPolygonValidAndRender(t,!0))};return o.on("validUpdate",a),()=>{o.unbind("validUpdate",a)}},[e,d,i,w,e.polygonList,e.lineList,(L=e.topViewInstance)==null?void 0:L.toolInstance]),y(()=>{var o,a;if(!(d==null?void 0:d.width)||!e.topViewInstance)return;const t=(a=(o=C==null?void 0:C.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:n,toolInstance:u}}=e;u.singleOn("renderZoom",(c,p)=>{const{offsetX:S,offsetY:b}=te(p,d,c);if(n.camera.zoom=c,p){const{x:g,y:k,z:D}=n.initCameraPosition;n.camera.position.set(g+b,k-S,D)}n.camera.updateProjectionMatrix(),n.render(),B(c),V(p,c,d),h({zoom:c,currentPos:p})}),u.singleOn("dragMove",({currentPos:c,zoom:p})=>{const{offsetX:S,offsetY:b}=te(c,d,p);n.camera.zoom=p;const{x:g,y:k,z:D}=n.initCameraPosition;n.camera.position.set(g+b,k-S,D),n.render(),V(c,p,d),h({zoom:p,currentPos:c})})},[d,e.topViewInstance,(T=e.topViewInstance)==null?void 0:T.toolInstance]),y(()=>{var o,a;(a=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null||a.applyZAxisPoints(N)},[N]),y(()=>{var o,a,t,n;w.topViewSelectedChanged({}),(n=(t=(a=(o=e.topViewInstance)==null?void 0:o.toolInstance)==null?void 0:a.selection)==null?void 0:t.hardSetSelectedIDs)==null||n.call(t,e.selectedIDs)},[e.selectedIDs]),y(()=>{const{topViewInstance:o,selectedID:a,selectedPointCloudBox:t,zoom:n}=e;if(!o||!a||!t||!de){R(!0);return}const{center:u}=t,{pointCloudInstance:c,toolInstance:p}=o,S=p.polygonList.find(pe=>pe.id===e.selectedID);if(!S){R(!0);return}const b=W.getRectCenterPoint(S.pointList),g=W.getCurrentPosFromRectCenter(p.size,b,n);p.setCurrentPos(g),p.render();const{x:k,y:D,z:ue}=c.initCameraPosition;c.camera.position.set(u.x,u.y,ue),c.render(),V(g,n,d),h({zoom:n,currentPos:g})},[e.selectedID]),y(()=>(window.addEventListener("keydown",H),()=>{window.removeEventListener("keydown",H)}),[]);const H=o=>{const{keyCode:a}=o;a===Ye.Esc&&j()};return y(()=>{var o,a,t;(t=(a=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:a.setHighlightAttribute)==null||t.call(a,E)},[e.topViewInstance,E]),s.createElement(_e,{className:_("point-cloud-container","top-view"),title:O?s.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},s.createElement(fe,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{j()}}),s.createElement("span",null,Z("TopView")),s.createElement(Y,{checkMode:m,config:C,style:{display:"flex",position:"initial",margin:"0px 20px"}})):s.createElement(Ze,{title:Z("TopView"),onClick:()=>{x(!0)}}),toolbar:s.createElement(qe,{currentData:i})},s.createElement("div",{style:{position:"relative",flex:1}},s.createElement("div",{style:{width:"100%",height:"100%"},ref:f},v==null?void 0:v(P)),!O&&s.createElement(Y,{checkMode:m,config:C}),s.createElement($e,{checkMode:m,zAxisLimit:N,setZAxisLimit:ae}),s.createElement(Ee,null)))};var Je=je(Oe,null,null,{context:De})(Ge);export{Je as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as E,useState as T,useMemo as k,useCallback as O}from"react";import N from"lodash";import{message as v}from"antd";import{usePointCloudViews as H}from"./usePointCloudViews.js";import{PointCloudContext as V}from"../PointCloudContext.js";import{useTranslation as A}from"react-i18next";import{EPointCloudBoxRenderTrigger as U}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import z from"../../../utils/AnnotationDataUtils.js";import{uuid as L}from"@labelbee/lb-annotation";import{useHistory as X}from"./useHistory.js";import{generatePointCloudBoxRects as Y}from"../../../utils/index.js";var W=Object.defineProperty,q=Object.defineProperties,F=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,j=(o,t,e)=>t in o?W(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,M=(o,t)=>{for(var e in t||(t={}))G.call(t,e)&&j(o,e,t[e]);if(b)for(var e of b(t))J.call(t,e)&&j(o,e,t[e]);return o},B=(o,t)=>q(o,F(t));const K=(o,t=[],e=[])=>{const{rects:p=[]}=o,s=p.map(i=>{var m;return B(M({},i),{imageName:(m=z.getNextPath({prePath:i.imageName,preMappingImgList:e,nextMappingImgList:t}))!=null?m:""})}).filter(i=>i.imageName!=="");return B(M({},o),{rects:s})},Q=(o,t)=>{const e=new Set(o.map(i=>i.trackID||0));let p=Math.max(...e,0);const s=.2;return t.map((i,m)=>{const{width:_,height:u,center:g,rotation:n,trackID:f=0}=i,{x,y:P,z:h}=g,c=_*s,C=u*s,y=c*Math.cos(n)-C*Math.sin(n),r=c*Math.sin(n)+C*Math.cos(n),l=x-Math.abs(y),I=P-Math.abs(r);let d=f;return e.has(f)?d=++p:p=Math.max(p,d),e.add(d),B(M({},i),{id:L(),uuid:L(),center:{x:l,y:I,z:h},trackID:d})})},Z=({config:o,currentData:t})=>{const{selectedIDs:e,pointCloudBoxList:p,displayPointCloudList:s,setPointCloudResult:i,syncAllViewPointCloudColor:m,imageSizes:_}=E(V),[u,g]=T({copiedBoxes:[],copiedMappingImgList:[]}),{copiedBoxes:n}=u,{pointCloudBoxListUpdated:f}=H(),{t:x,i18n:P}=A(),{pushHistoryWithList:h}=X(),c=k(()=>s.filter(r=>e.includes(r.id)),[e,s]),C=O(()=>{var r;if(c.length>0){const l=(r=t==null?void 0:t.mappingImgList)!=null?r:[];g({copiedBoxes:N.cloneDeep(c),copiedMappingImgList:l})}else g({copiedBoxes:[],copiedMappingImgList:[]}),v.error(x("CopyEmptyInPointCloud"));v.success(x("CopySuccess"))},[e,s,P.language,t]),y=O(()=>{var r,l;if(n.length===0){v.error(x("PasteEmptyInPointCloud"));return}const I=(r=t==null?void 0:t.mappingImgList)!=null?r:[],d=(l=u==null?void 0:u.copiedMappingImgList)!=null?l:[],R=n.map(a=>K(a,I,d)),w=Q(s,R),S=a=>{i(a),f==null||f(a),g({copiedBoxes:[],copiedMappingImgList:[]}),h({pointCloudBoxList:a}),m(U.MultiPaste,a)};w.forEach(a=>Y({pointCloudBox:a,mappingImgList:I,imageSizes:_}));const D=[...s,...w];S(D)},[n,s,P.language,t]);return{copySelectedBoxes:C,pasteSelectedBoxes:y,copiedBoxes:n,selectedBoxes:c}};export{Z as useBoxes};
|
|
@@ -1 +1 @@
|
|
|
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
|
+
import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as X,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as mt,useCallback as xt}from"react";import{PointCloudContext as ht}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as rt}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as lt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as dt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as $}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,ho=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,L=(e,n)=>{for(var t in n||(n={}))xo.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))ho.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((c,p)=>{var o=d=>{try{u(t.next(d))}catch(x){p(x)}},f=d=>{try{u(t.throw(d))}catch(x){p(x)}},u=d=>d.done?c(d.value):Promise.resolve(d.value).then(o,f);u((t=t.apply(e,n)).next())});const tt=5,ot=90,wt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(e,n,t,c,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,d={center:{x:o,y:f,z:u},id:e.id},x=c?L(L({},c),d):A(L({},d),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},ct=(e,n,t,c,p,o)=>{let f=e.pointList.map(I=>O.transferCanvas2World(I,n)),u=0,d=1,x={};if(t){const I=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&I.fittedCoordinates.length>0&&(f=I.fittedCoordinates),u=(I.maxZ+I.minZ)/2,d=I.maxZ-I.minZ,x={count:I.zCount}}const[P,v,T]=f,V=w.getLineCenterPoint([P,T]),D=w.getLineLength(P,v),U=w.getLineLength(v,T),N=w.getRadiusFromQuadrangle(e.pointList);c&&(u=c.center.z,d=c.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+wt:U,height:o?D+wt:D,depth:d,rotation:N,id:e.id},j=L(c?L(L({},c),z):A(L({},z),{attribute:"",valid:!0}),x);p&&Object.assign(j,p);const M=f.map(I=>O.transferWorld2Canvas(I,n));return{boxParams:j,newPointList:M}},It=(e,n,t)=>{const c={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x-c.x,y:t.center.y,z:t.center.z-c.y}})},Dt=(e,n,t,c)=>{const[p,o,f]=e.pointList,[u,d,x]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,x]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,d),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(d,x),M=z-j,{newBoxParams:I}=c.getNewBoxBySideUpdate(V,M,N,t);return I},Lo=(e,n,t)=>{const c={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x,y:t.center.y-c.x,z:t.center.z-c.y}})},vo=(e,n,t,c)=>{const[p,o,f]=e.pointList,[u,d,x]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,x]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,d),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(d,x),M=z-j;let{newBoxParams:I}=c.getNewBoxByBackUpdate(V,M,N,t);return I},St=(e,n,t,c,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(c,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:d}=u.updateOrthoCameraBySphere(e,X.Left);u.setInitCameraPosition(d);const{point2d:x,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,c)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(c,e,{width:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:d}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=d,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,c,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(c,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:d}=u.updateOrthoCameraBySphere(e,X.Back);u.setInitCameraPosition(d);const{point2d:x,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,c)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(c,e,{height:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Back);o.setInitCameraPosition(f);const{polygon2d:u,zoom:d}=o.getBoxBackPolygon2DCoordinate(e);o.camera.zoom=d,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},kt=(e,n,t,c)=>{if(!t||!c)return;c.generateSphere(e),c.updateCameraBySphere(e,X.Top),c.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(d=>d.id===n.id?A(L(L({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):d);p.setResult(u),p.setSelectedID(n.id)},ut=(e,n,t,c)=>{var p,o;if(!t||!c)return;c.generateBox(e,n.id),c.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:d}=u.getBoxTopPolygon2DCoordinate(e),x=[...f.polygonList],P=x.find(v=>v.id===n.id);P?(P.pointList=d,P.valid=(p=e.valid)!=null?p:!0):x.push({id:n.id,pointList:d,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(x,n.id)},yo=e=>{const n=mt(ht),{topViewInstance:t,sideViewInstance:c,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:d,selectedIDs:x,pointCloudBoxList:P,pointCloudSphereList:v,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:D,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:M,pushHistoryUnderUpdatePolygon:I}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:pt,selectedSphere:Y}=ro(),{currentData:H,config:B}=ao(s=>{const{stepList:i,step:a,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:lt(uo.getCurrentStepInfo(a,i).config)}}),F=co(),Tt=$(D),Ut=$(z),zt=xt((s,i)=>{const a=Ut.current,r=i.id;return s.filter(g=>{if(!g)return!1;const C=a.get(g.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),et=s=>{const{enableAutoMap2DRect:i=!1}=B;if(!Tt.current||i){const{mappingImgList:a=[]}=H;po({pointCloudBox:s,mappingImgList:a,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:nt,getPointCloudByID:jt}=so({generateRects:et}),gt=k==null?void 0:k.info;if(!t||!c||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:it}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:s,size:i,zoom:a,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const C=at(s,i,it,void 0,g);d(s.id);const m=u(C);G(y.Top,s,C,a,m,B),j({newSphereParams:C})},Ft=({polygon:s,size:i,imgList:a,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,m,b;const S={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(S,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:v})});const _=t==null?void 0:t.toolInstance,R=L({},s);let{boxParams:h,newPointList:E}=ct(R,i,it,void 0,S,g);h=F(dt({tool:st.PointCloud,dataList:[h],stepConfig:B,action:"viewUpdateBox"}))[0],g&&(E==null?void 0:E.length)&&(R.pointList=E);const Z=T.includes(R.attribute);et(h);const Q=f(h),q=(m=n==null?void 0:n.polygonList)!=null?m:[];h.subAttribute=oo.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(b=B==null?void 0:B.inputList)!=null?b:[]:[]),t==null||t.updatePolygonList(Q!=null?Q:[],q),Z?d([]):(d(h.id),_.selection.setSelectedIDs(R.id),W({omitView:y.Top,polygon:R,boxParams:h,zoom:l,newPointCloudBoxList:Q}),g&&ut(h,R,t,o)),j({newBoxParams:h})},Ht=s=>{const{boxID:i,imageName:a,width:r,height:l,x:g,y:C}=s,m=P.find(h=>h.id===i);if(!(m==null?void 0:m.rects)||!m.rects.find(h=>h.imageName===a))return;const S=m.rects.map(h=>h.imageName===a?A(L({},h),{width:r,height:l,x:g,y:C}):h),_=A(L({},m),{rects:S}),R=P.map(h=>h.id===i?_:h);return t==null||t.updatePolygonList(R!=null?R:[]),R},Wt=s=>{const{boxID:i,imageName:a}=s,r=P.find(m=>m.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(m=>m.imageName!==a),g=A(L({},r),{rects:l}),C=P.map(m=>m.id===i?g:m);return t==null||t.updatePolygonList(C!=null?C:[]),C},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:a,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(x.length===0||!g)){if(s||(k==null?void 0:k.info)){const C=s!=null?s:k==null?void 0:k.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(x[0]);const m=g.selectedPolygon;if(x.length===1&&C){W({omitView:y.Top,polygon:m,boxParams:C,newPointCloudBoxList:i});return}}if((a||Y)&&x.length===1){const C=a!=null?a:Y;g.setSelectedID(x[0]);const m=g.selectedPoint;C&&G(y.Top,m,C,void 0,r,B)}}},ft=(s,i,a)=>{if(gt){let r,l;switch(a){case y.Back:r=vo;break;case y.Side:r=Dt;break;default:r=Dt;break}if(l=r(s,i,gt,c.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(eo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=A(L({},l),{count:S})}const C=F(dt({tool:st.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],m=l.valid!==C.valid;l=C;const b=Nt(l);return l=b.find(S=>S.id===l.id),W({omitView:m?void 0:a,polygon:s,boxParams:l,newPointCloudBoxList:b}),b}},Ct=(s,i,a)=>{if(Y){let r,l;switch(a){case y.Back:r=Lo;break;case y.Side:r=It;break;default:r=It;break}l=r(s,i,Y);const g=pt(l);return G(a,s,l,void 0,g,B),g}},Gt=(s,i)=>{Ct(s,i,y.Side)},Jt=(s,i)=>{Ct(s,i,y.Back)},Qt=(s,i)=>{ft(s,i,y.Side)},Xt=(s,i)=>{ft(s,i,y.Back)},Yt=(s,i)=>{const a=At(s.id),r=at(s,i,it,a),l=pt(r);G(y.Top,s,r,void 0,l,B)},qt=(s,i)=>{if(Ot){const r=L({},s[0].newPolygon);r.pointList=r.pointList.map(l=>O.transferCanvas2World(l,i)),I(r);return}let a=s.map(({newPolygon:r})=>{const l=jt(r.id),{boxParams:g}=ct(r,i,t.pointCloudInstance,l);return g});if(a=F(dt({tool:st.PointCloud,dataList:a,stepConfig:B,action:"viewUpdateBox"})),a.length===1){const{newPolygon:r}=s[0],l=nt(a);W({polygon:r,boxParams:a[0],newPointCloudBoxList:l})}else{const r=nt(a);r&&n.syncAllViewPointCloudColor(rt.MultiMove,r)}},Kt=s=>{var i,a,r,l,g;if(k){const C=Number(s.widthDefault),m=Number(s.depthDefault),b=Number(s.heightDefault),S=k==null?void 0:k.info.trackID,R=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(K=>(K==null?void 0:K.trackID)===S),h={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},E=R.pointList.map(K=>O.transferCanvas2World(K,h)),J=w.getModifiedRectangleCoordinates(E,b,C),Z=J[0],Q=J[2],q=w.getLineCenterPoint([Z,Q]),$t=k.info.center.z-k.info.depth/2,Pt=A(L({},k.info),{center:{x:q.x,y:q.y,z:$t+m/2},width:C,height:b,depth:m,valid:!0}),to=nt([Pt]);W({omitView:y["3D"],polygon:R,boxParams:Pt,newPointCloudBoxList:to})}},G=(s,i,a,r,l,g)=>bt(void 0,null,function*(){const C=H==null?void 0:H.url,m={[y.Side]:()=>{St(a,i,c,C,g)},[y.Back]:()=>{p&&_t(a,i,p,C,g)},[y.Top]:()=>{kt(a,i,t,o)}};Object.keys(m).forEach(b=>{b!==s&&m[b]()}),r&&(o==null||o.updateCameraZoom(r)),Et(a)}),W=(s,i=rt.Default)=>{const{omitView:a,polygon:r,boxParams:l,zoom:g,newPointCloudBoxList:C}=s,m=H==null?void 0:H.url;C&&n.syncAllViewPointCloudColor(i,C);const b={[y.Side]:()=>{Rt(l,r,c,m)},[y.Back]:()=>{p&&Vt(l,r,p,m)},[y.Top]:()=>{ut(l,r,t,o)}};Object.keys(b).forEach(S=>{S!==a&&b[S]()}),g&&(o==null||o.updateCameraZoom(g))};return{topViewAddSphere:Mt,topViewAddBox:Ft,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:W,syncPointCloudPoint:G,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=H){var a,r,l,g,C,m,b,S;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(F,!0),vt(F,!0),(a=e==null?void 0:e.setResourceLoading)==null||a.call(e,!0),yield o.loadPCDFile(i.url,(r=B==null?void 0:B.radius)!=null?r:ot),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let _=[],R=[],h=[],E=[];o.updateTopCamera();const J=(g=(l=lt(i.result))==null?void 0:l.valid)!=null?g:!0;if(n.setPointCloudValid(J),(C=n.sideViewInstance)==null||C.clearAllData(),(m=n.backViewInstance)==null||m.clearAllData(),i.result){if(_=O.getBoxParamsFromResultList(i.result),(_==null?void 0:_.length)>0&&i.isPreResult&&(B==null?void 0:B.lowerLimitPointsNumInBox)>0){_=yield o==null?void 0:o.filterPreResult(i.url,B,_);const Z=lt(i.result);Z[no].result=_,i.result=JSON.stringify(Z),n.setPointCloudResult(_)}h=O.getPolygonListFromResultList(i.result),R=O.getLineListFromResultList(i.result),E=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(b=B==null?void 0:B.radius)!=null?b:ot}),o==null||o.generateBoxes(_),o==null||o.generateSpheres(E),yield n.syncAllViewPointCloudColor(rt.Default,_,[])}M({pointCloudBoxList:_,polygonList:h,lineList:R,pointCloudSphereList:E}),Lt(F,!1),vt(F,!1),(S=e==null?void 0:e.setResourceLoading)==null||S.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:et,update2DViewRect:Ht,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(ht),c=$(e),p=$(n);return{syncToPointCloudBoxList:xt(()=>{const f=c.current,u=p.current;if(u.length===0)return null;const d=new Map,x=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const v=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let D=d.get(v);D||(D=new Map,d.set(v,D)),D.set(T,V),x.add(v)}),d.size){const P=f.map(v=>{var T;const V=v.id;if(x.has(V)){const D=L({},v);return(T=D.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=d.get(V))==null?void 0:N.get(z))}),D}return v});return t(P),P}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,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useContext as w}from"react";import{useDispatch as D}from"../../../store/ctx.js";import{useSingleBox as b}from"./useSingleBox.js";import{PointCloudContext as T}from"../PointCloudContext.js";import{EPointCloudName as R}from"@labelbee/lb-annotation";import{PreDataProcess as H}from"../../../store/annotation/actionCreators.js";import{usePointCloudViews as E}from"./usePointCloudViews.js";import{useSphere as L}from"./useSphere.js";import{useHistory as _}from"./useHistory.js";import{EPointCloudBoxRenderTrigger as f}from"../../../utils/ToolPointCloudBoxRenderHelper.js";const P={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},k=(g,a)=>{const r=w(T),{topViewInstance:d,selectedIDs:i,pointCloudBoxList:l,mainViewInstance:c,selectedID:v}=r,h=D(),{selectedSphere:p}=L(),{syncPointCloudViews:C,syncPointCloudPoint:m,generateRects:V}=E({setResourceLoading:g}),{selectedBox:u,updateSelectedBox:j}=b({generateRects:V}),{pushHistoryWithList:x}=_(),y=({newSelectedSphere:e,newSphereList:o})=>{const n=d==null?void 0:d.toolInstance;if((e||p)&&i.length===1){const t=e!=null?e:p;n.setSelectedID(i[0]);const s=n.selectedPoint;t&&(m==null||m(P.Top,s,t,void 0,o,a))}},I=({trigger:e,newSelectedBox:o})=>{const n=d==null?void 0:d.toolInstance;if(!(i.length===0||!n)&&(o||(u==null?void 0:u.info))){const t=o!=null?o:u==null?void 0:u.info,s=o;if(t){C==null||C({omitView:P.Top,polygon:s,boxParams:t},e);return}}};return{updatePointCloudColor:e=>{if(l.forEach(o=>{var n,t,s;if(o&&i.includes(o.id)){o.attribute=e;const S=h(H({tool:R.PointCloud,dataList:[o],stepConfig:a,action:"viewUpdateBox"}));o.valid=S[0].valid,j(o),(s=(t=(n=r==null?void 0:r.topViewInstance)==null?void 0:n.pointCloud2dOperation)==null?void 0:t.setPolygonValidAndRender)==null||s.call(t,o.id,!0,o.valid),y({})}}),c){const o=i&&i.length>1?f.MulitSelect:f.Single;if(r.syncAllViewPointCloudColor(o,l),i&&i.length===1){const n=l.find(t=>t.id===i[0]);I({trigger:o,newSelectedBox:n})}c.generateBoxes(l)}v||x({pointCloudBoxList:l})}}};export{k as useUpdatePointCloudColor};
|
|
@@ -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 y,useState as R,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 M from"./PointCloud2DView.js";import G from"./PointCloudListener.js";import O from"./PointCloudSegmentListener.js";import Z from"./PointCloudSegment.js";import U from"./PointCloudSegmentStatus.js";import W from"./PointCloudSegmentToolbar.js";import $ from"./PointCloudSegment2DView.js";import{connect as q}from"react-redux";import{LabelBeeContext as z,useDispatch as H}from"../../store/ctx.js";import{AnnotatedAttributesPanelFixedLeft as J,AnnotatedAttributesPanelFixedRight as K}from"../../views/MainView/toolFooter/AnnotatedAttributes/index.js";import{PointCloudContext as Q}from"./PointCloudContext.js";import{PointCloudUtils as X,EPointCloudPattern as Y}from"@labelbee/lb-utils";import{useCustomToolInstance as tt}from"../../hooks/annotation.js";import{jsonParser as et}from"../../utils/index.js";import{a2MapStateToProps as ot}from"../../store/annotation/map.js";import L from"classnames";import nt from"./components/sideAndBackOverView/index.js";import{SetLoadPCDFileLoading as it}from"../../store/annotation/actionCreators.js";const lt=E=>{const{currentData:s,imgList:S,drawLayerSlot:d,checkMode:i,intelligentFit:w,imgIndex:x,config:b,measureVisible:j,setResourceLoading:v}=E,e=y(Q),{globalPattern:p,setGlobalPattern:V,selectedIDs:P}=e,h=H(),[l,f]=R(!1),D=(P==null?void 0:P.length)>0&&l,A=et(s.result),{toolInstanceRef:r,clearToolInstance:N}=tt({basicInfo:A});if(C(()=>{r.current.setPointCloudGlobalPattern=o=>{o!==p&&(V(o),e.clearAllDetectionInstance(),N())}},[p]),C(()=>{var o;if(it(h,!0),s){const{boxParamsList:a,polygonList:m,lineList:u,sphereParamsList:c,segmentation:I,rectList:T}=X.parsePointCloudCurrentResult((o=s==null?void 0:s.result)!=null?o:"");e.setPointCloudResult(a),e.setPolygonList(m),e.setLineList(u),e.setPointCloudSphereList(c),e.setRectList(T),e.setSegmentation(I)}},[x]),C(()=>{r.current.exportData=()=>[e.pointCloudBoxList,{valid:e.valid}],r.current.exportCustomData=()=>{var o,a,m,u,c;return{resultPolygon:(o=e.polygonList)!=null?o:[],resultLine:(a=e.lineList)!=null?a:[],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===Y.Segmentation)return t.createElement(t.Fragment,null,t.createElement(O,{checkMode:i,toolInstanceRef:r}),t.createElement(W,null),t.createElement("div",{className:n("point-cloud-layout")},t.createElement(Z,{checkMode:i}),t.createElement($,null)),t.createElement(U,{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(nt,{selectAndEnlarge:D,checkMode:i})),t.createElement(t.Fragment,null,t.createElement(G,{checkMode:i,toolInstanceRef:r,setResourceLoading:v}),t.createElement("div",{className:n("point-cloud-layout"),onContextMenu:o=>o.preventDefault()},t.createElement("div",{className:n("point-cloud-wrapper")},t.createElement(J,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(M,{isEnlargeTopView:l,thumbnailWidth:l?300:455,checkMode:i,measureVisible:j})))),t.createElement(K,null))))};var rt=q(ot,null,null,{context:z})(lt);export{rt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Button as v,message as c}from"antd";import p from"react";import{useTranslation as y}from"react-i18next";import{connect as S}from"react-redux";import k from"../../../assets/predictTracking/icon.svg.js";import{useSingleBox as B}from"../../pointCloudView/hooks/useSingleBox.js";import{ChangeSave as
|
|
1
|
+
import{Button as v,message as c}from"antd";import p from"react";import{useTranslation as y}from"react-i18next";import{connect as S}from"react-redux";import k from"../../../assets/predictTracking/icon.svg.js";import{useSingleBox as B}from"../../pointCloudView/hooks/useSingleBox.js";import{ChangeSave as I,GetBoxesByID as C,SetAnnotationLoading as D,SetPredictResult as T,SetPredictResultVisible as R}from"../../../store/annotation/actionCreators.js";import{LabelBeeContext as b,useDispatch as j}from"../../../store/ctx.js";import{predict as V}from"../previewResult/util.js";import{useStatus as w}from"../../pointCloudView/hooks/useStatus.js";var _=(o,n,e)=>new Promise((d,l)=>{var u=t=>{try{s(e.next(t))}catch(i){l(i)}},r=t=>{try{s(e.throw(t))}catch(i){l(i)}},s=t=>t.done?d(t.value):Promise.resolve(t.value).then(u,r);s((e=e.apply(o,n)).next())});const E=o=>{const n=j(),{t:e}=y(),{isPointCloudSegmentationPattern:d}=w(),{loading:l,predictionResultVisible:u}=o,{selectedBox:r}=B(),s=()=>_(void 0,null,function*(){if(l||u)return;const t=r==null?void 0:r.info.trackID;if(!t){c.error(e("BeforePredictStarting"));return}yield n(I);const i=r==null?void 0:r.info.id,a=yield n(C(t,i));if(a.length<2){c.error(e("MarkOnlyOne"));return}const x=a.findIndex(h=>h.id===i),m=a[x-1],f=a[x],g=f.index-m.index;if(g<2){c.error(e("HaveNoNeed"));return}if(g>8){c.error(e("ThePredictedPointCloud"));return}c.success(e("PredictingDataFrom",{startPage:m.index+1,endPage:f.index+1,selectedBoxTrackID:t})),D(n,!0);const P=V(m,f);T(n,P),R(n,!0)});return d?null:p.createElement(v,{type:"link",onClick:s,style:{display:"flex",flexDirection:"column",height:"auto",alignItems:"center"}},p.createElement("img",{src:k,style:{alignSelf:"center"}}),p.createElement("span",{style:{color:"#797979"}},e("ComplementaryTracking")))},L=o=>({loading:o.annotation.loading,predictionResultVisible:o.annotation.predictionResultVisible});var N=S(L,null,null,{context:b})(E);export{N as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import w from"classnames";import n,{useState as j,useRef as S,useEffect as F}from"react";import{useTranslation as C}from"react-i18next";import{connect as L}from"react-redux";import{PointCloudContext as B}from"../../pointCloudView/PointCloudContext.js";import{SetPredictResultVisible as D,SetPredictResult as T,SetAnnotationLoading as v,BatchUpdateImgListResultByPredictResult as I}from"../../../store/annotation/actionCreators.js";import{LabelBeeContext as U,useDispatch as E}from"../../../store/ctx.js";import{getClassName as o}from"../../../utils/dom.js";import{PointCloud as $}from"@labelbee/lb-annotation";import{PointCloudUtils as z,toolStyleConverter as A}from"@labelbee/lb-utils";import{views as G,sleep as Z,getViewsDataUrl as q}from"./util.js";var H=Object.defineProperty,J=Object.defineProperties,K=Object.getOwnPropertyDescriptors,k=Object.getOwnPropertySymbols,M=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,N=(i,e,t)=>e in i?H(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,W=(i,e)=>{for(var t in e||(e={}))M.call(e,t)&&N(i,t,e[t]);if(k)for(var t of k(e))Q.call(e,t)&&N(i,t,e[t]);return i},X=(i,e)=>J(i,K(e)),O=(i,e,t)=>new Promise((d,r)=>{var s=l=>{try{c(t.next(l))}catch(u){r(u)}},a=l=>{try{c(t.throw(l))}catch(u){r(u)}},c=l=>l.done?d(l.value):Promise.resolve(l.value).then(s,a);c((t=t.apply(i,e)).next())});const Y=i=>{const{predictionResult:e,predictionResultVisible:t,imgList:d}=i,[r,s]=j([]),a=E(),{t:c}=C(),l=()=>{D(a,!1),T(a,[]),s([])},u=()=>O(void 0,null,function*(){v(a,!0),yield a(I()),v(a,!1),l()});return t?n.createElement(n.Fragment,null,r.length>0&&n.createElement("div",{className:o("point-cloud-predict-tracking-container")},n.createElement("div",{className:o("point-cloud-predict-tracking-container","bar")},n.createElement("div",{className:o("point-cloud-predict-tracking-container","title")},n.createElement("div",null,c("ComplementaryTrackingPrediction"),r.length>0?`\uFF08${r.length}\uFF09`:""),n.createElement("div",{className:o("point-cloud-predict-tracking-container","option")},n.createElement("div",{className:w([o("point-cloud-predict-tracking-container","cancelOption"),o("point-cloud-predict-tracking-container","button")]),onClick:l},c("Cancel")),n.createElement("div",{className:w([o("point-cloud-predict-tracking-container","okOption"),o("point-cloud-predict-tracking-container","button")]),onClick:u},c("Apply")))),n.createElement("div",{className:o("point-cloud-predict-tracking-container","content")},n.createElement(ee,{list:r})))),e.length>0&&n.createElement(te,{result:e,imgList:d,setList:s})):null},ee=i=>{const{list:e}=i,{t}=C(),d=[t("TopView"),t("SideView"),t("BackView")];return n.createElement(n.Fragment,null,n.createElement("div",{className:o("point-cloud-predict-tracking-container","left")},d.map(r=>n.createElement("div",{className:o("point-cloud-predict-tracking-container","title"),key:r},r))),n.createElement("div",{className:o("point-cloud-predict-tracking-container","right")},e.map(r=>n.createElement("div",{className:o("point-cloud-predict-tracking-container","item"),key:r.id},G.map(s=>{const a=r[s];return n.createElement("div",{className:o("point-cloud-predict-tracking-container","view"),key:`${r.id}-${s}`},n.createElement("img",{src:a}))})))))},te=i=>{const e=n.useContext(B),t=E(),{result:d,imgList:r,setList:s}=i,a=S(null),c={width:600,height:600};return F(()=>{(()=>O(void 0,null,function*(){var u,P,h,y,_,b;const f=(u=e.mainViewInstance)==null?void 0:u.config;if(f&&a.current){const R=z.getDefaultOrthographicParams(c),p=new $({container:a.current,isOrthographicCamera:!0,orthographicParams:R,config:f});p.setShowDirection(!1);for(const m of d){const{index:g}=m,x=r[g].url?r[g].url:(_=(y=(h=(P=r[g])==null?void 0:P.webPointCloudFile)==null?void 0:h.lidar)==null?void 0:y.url)!=null?_:"";yield p.loadPCDFileByBox(x,m,{width:2,height:2,depth:2}),yield p.updateCameraZoom(e.zoom);const V=(b=A.getColorFromConfig({attribute:m.attribute},X(W({},f),{attributeConfigurable:!0}),{}))==null?void 0:b.fill;p.generateBox(m,V),yield Z(500),yield q(p,m,e.zoom),yield p.removeObjectByName(m.id,"box"),yield p.clearPointCloudAndRender()}s(d),v(t,!1)}}))()},[]),n.createElement("div",{style:c,ref:a,className:"generate-view"})},ne=i=>({predictionResult:i.annotation.predictionResult,predictionResultVisible:i.annotation.predictionResultVisible,imgList:i.annotation.imgList});var ie=L(ne,null,null,{context:U})(Y);export{ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import h from"react";import{TagUtils as m,CommonToolUtils as
|
|
1
|
+
import h from"react";import{TagUtils as m,CommonToolUtils as v,uuid as f}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:v.getSourceID(),id:(l=(i=this.currentTagResult)==null?void 0:i.id)!=null?l:f(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.removeEventListener("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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var o;(function(n){n[n.Scribble=1]="Scribble",n[n.Erase=2]="Erase"})(o||(o={}));var t;(function(n){n.Rect="rectTool",n.Tag="tagTool",n.Point="pointTool",n.PointMarker="pointMarkerTool",n.Segmentation="segmentationTool",n.Filter="filterTool",n.Text="textTool",n.Polygon="polygonTool",n.Line="lineTool",n.LineMarker="lineMarkerTool",n.Empty="emptyTool",n.FolderTag="folderTagTool",n.RectTrack="rectTrackTool",n.ScribbleTool="scribbleTool",n.Face="faceTool",n.ClientAttribute="clientAttributeTool",n.OCRRelation="OCRRelationTool",n.SegmentByRect="segmentByRectTool",n.Cuboid="cuboidTool",n.PointCloudPolygon="pointCloudPolygon",n.LLM="LLMTool",n.NLP="NLPTool"})(t||(t={}));var r;(function(n){n[n.AnyString=0]="AnyString",n[n.Order=1]="Order",n[n.EnglishOnly=2]="EnglishOnly",n[n.NumberOnly=3]="NumberOnly",n[n.CustomFormat=4]="CustomFormat"})(r||(r={}));const i=1e3;export{o as EScribblePattern,r as ETextType,t as EToolName,i as TEXT_ATTRIBUTE_MAX_LENGTH};
|
|
1
|
+
var o;(function(n){n[n.Scribble=1]="Scribble",n[n.Erase=2]="Erase"})(o||(o={}));var t;(function(n){n.Rect="rectTool",n.Tag="tagTool",n.Point="pointTool",n.PointMarker="pointMarkerTool",n.Segmentation="segmentationTool",n.Filter="filterTool",n.Text="textTool",n.Polygon="polygonTool",n.Line="lineTool",n.LineMarker="lineMarkerTool",n.Empty="emptyTool",n.FolderTag="folderTagTool",n.RectTrack="rectTrackTool",n.ScribbleTool="scribbleTool",n.Face="faceTool",n.ClientAttribute="clientAttributeTool",n.OCRRelation="OCRRelationTool",n.SegmentByRect="segmentByRectTool",n.Cuboid="cuboidTool",n.PointCloudPolygon="pointCloudPolygon",n.LLM="LLMTool",n.NLP="NLPTool",n.LLMMultiWheel="LLMMultiWheelTool"})(t||(t={}));var r;(function(n){n[n.AnyString=0]="AnyString",n[n.Order=1]="Order",n[n.EnglishOnly=2]="EnglishOnly",n[n.NumberOnly=3]="NumberOnly",n[n.CustomFormat=4]="CustomFormat"})(r||(r={}));const i=1e3;export{o as EScribblePattern,r as ETextType,t as EToolName,i as TEXT_ATTRIBUTE_MAX_LENGTH};
|
package/es/index.css
CHANGED
|
@@ -8,13 +8,9 @@
|
|
|
8
8
|
}
|
|
9
9
|
.index-module_imgView__wmxDk .index-module_item__-80YI {
|
|
10
10
|
margin: 0px 40px 40px 0px;
|
|
11
|
-
width: 400px;
|
|
12
11
|
display: flex;
|
|
13
|
-
height: 300px;
|
|
14
12
|
}
|
|
15
13
|
.index-module_imgView__wmxDk .index-module_item__-80YI .index-module_image__V49oW {
|
|
16
|
-
height: 260px;
|
|
17
|
-
min-width: 300px;
|
|
18
14
|
flex: 1;
|
|
19
15
|
background: #E9EBF1;
|
|
20
16
|
display: flex;
|
|
@@ -63,6 +59,27 @@
|
|
|
63
59
|
justify-content: space-between;
|
|
64
60
|
margin-top: 16px;
|
|
65
61
|
}
|
|
62
|
+
.index-module_switchBox__6DlnW {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: space-between;
|
|
66
|
+
padding: 12px 20px;
|
|
67
|
+
}
|
|
68
|
+
.index-module_switchBox__mLSzh {
|
|
69
|
+
display: flex;
|
|
70
|
+
justify-content: space-between;
|
|
71
|
+
align-items: center;
|
|
72
|
+
padding: 12px 20px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.index-module_switchLeft__7qd-2 {
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.index-module_switchTitle__de9li {
|
|
81
|
+
margin-right: 8px;
|
|
82
|
+
}
|
|
66
83
|
.dynamic-resizer-content {
|
|
67
84
|
width: 100%;
|
|
68
85
|
height: 100%;
|
|
@@ -3346,4 +3363,54 @@
|
|
|
3346
3363
|
|
|
3347
3364
|
.bee-audio-combined {
|
|
3348
3365
|
cursor: url("../dist/assets/icons/ad8081bf.svg") 10 12, default;
|
|
3366
|
+
}
|
|
3367
|
+
|
|
3368
|
+
/** LLMMultiWheel style */
|
|
3369
|
+
.bee-LLMMultiWheelView {
|
|
3370
|
+
display: flex;
|
|
3371
|
+
flex: 1;
|
|
3372
|
+
flex-direction: column;
|
|
3373
|
+
overflow: hidden;
|
|
3374
|
+
background-color: #fff;
|
|
3375
|
+
}
|
|
3376
|
+
|
|
3377
|
+
.bee-LLMMultiWheelView-container {
|
|
3378
|
+
flex: auto;
|
|
3379
|
+
display: flex;
|
|
3380
|
+
overflow: auto;
|
|
3381
|
+
}
|
|
3382
|
+
.bee-LLMMultiWheelView-container .dialog {
|
|
3383
|
+
min-width: 50%;
|
|
3384
|
+
padding: 8px;
|
|
3385
|
+
border: 1px solid transparent;
|
|
3386
|
+
overflow: auto;
|
|
3387
|
+
}
|
|
3388
|
+
.bee-LLMMultiWheelView-container .dialog.selected {
|
|
3389
|
+
border-color: #69b1ff;
|
|
3390
|
+
}
|
|
3391
|
+
.bee-LLMMultiWheelView-container .dialog .header {
|
|
3392
|
+
position: relative;
|
|
3393
|
+
}
|
|
3394
|
+
.bee-LLMMultiWheelView-container .dialog .header .order {
|
|
3395
|
+
position: absolute;
|
|
3396
|
+
left: 0;
|
|
3397
|
+
top: 0;
|
|
3398
|
+
width: 32px;
|
|
3399
|
+
height: 32px;
|
|
3400
|
+
line-height: 32px;
|
|
3401
|
+
text-align: center;
|
|
3402
|
+
background: #d4cbcb;
|
|
3403
|
+
border-radius: 4px;
|
|
3404
|
+
}
|
|
3405
|
+
.bee-LLMMultiWheelView-container .dialog .header .name {
|
|
3406
|
+
display: flex;
|
|
3407
|
+
flex-direction: column;
|
|
3408
|
+
align-items: center;
|
|
3409
|
+
justify-content: center;
|
|
3410
|
+
}
|
|
3411
|
+
.bee-LLMMultiWheelView-container .dialog .header .name .show-name {
|
|
3412
|
+
font-size: 16px;
|
|
3413
|
+
}
|
|
3414
|
+
.bee-LLMMultiWheelView-container .dialog .header .name .tips {
|
|
3415
|
+
color: #d4cbcb;
|
|
3349
3416
|
}
|
package/es/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as AnnotationView}from"./components/AnnotationView/index.js";export{default as PointCloudAnnotationView}from"./components/AnnotationView/pointCloudAnnotationView.js";export{default as QuestionView}from"./components/LLMToolView/questionView/index.js";export{default as TextContent}from"./components/NLPToolView/textContent/index.js";import{i18n as s}from"@labelbee/lb-utils";export{i18n}from"@labelbee/lb-utils";import
|
|
1
|
+
export{default as AnnotationView}from"./components/AnnotationView/index.js";export{default as PointCloudAnnotationView}from"./components/AnnotationView/pointCloudAnnotationView.js";export{default as QuestionView}from"./components/LLMToolView/questionView/index.js";export{default as TextContent}from"./components/NLPToolView/textContent/index.js";import{i18n as s}from"@labelbee/lb-utils";export{i18n}from"@labelbee/lb-utils";import r,{useState as m,useImperativeHandle as u}from"react";import{initReactI18next as f,I18nextProvider as x}from"react-i18next";import{Provider as w}from"react-redux";import P from"./App.js";import v from"./configureStore.js";import{PageBackward as j,PageForward as S,PageJump as T}from"./store/annotation/actionCreators.js";export{VideoTagTool}from"./components/videoAnnotate/videoTagTool/TagToolInstanceAdaptorI18nProvider.js";import{PointCloudProvider as V}from"./components/pointCloudView/PointCloudContext.js";import{LabelBeeContext as b}from"./store/ctx.js";export{default as PredictTracking}from"./components/predictTracking/predictTrackingIcon/index.js";export{default as LLMToolView}from"./components/LLMToolView/index.js";export{default as SwitchCuboidBoxIn2DView,SwitchCuboidBoxIn2DViewStateMode}from"./views/MainView/toolFooter/SwitchCuboidBoxIn2DView/index.js";export{default as BatchSwitchConnectIn2DView}from"./views/MainView/toolFooter/BatchSwitchConnectIn2DView/BatchSwitchConnectIn2DView.js";export{default as MeasureCanvas}from"./components/measureCanvas/index.js";export{default as AnnotatedBox}from"./views/MainView/sidebar/PointCloudToolSidebar/components/annotatedBox/index.js";export{default as RectRotateSensitivitySlider}from"./views/MainView/sidebar/PointCloudToolSidebar/components/rectRotateSensitivitySlider/index.js";export{FindTrackIDIndexInCheckMode as FindTrackIDIndex}from"./views/MainView/sidebar/PointCloudToolSidebar/components/findTrackIDIndex/index.js";export{WrapAudioPlayer as AudioPlayer}from"./components/audioPlayer/index.js";export{generatePointCloudBoxRects}from"./utils/index.js";export{default as SubAttributeList}from"./components/subAttributeList/index.js";import{ToolStyleProvider as g}from"./hooks/useToolStyle.js";import{LoadFileAndFileData as C}from"./store/annotation/reducer.js";export{default as useToolConfigStore}from"./store/toolConfig/index.js";export{LLMMultiWheelSourceView}from"./components/LLMMultiWheelView/index.js";export{EDataFormatType,ELLMDataType,EStepType,ESubmitType,componentCls,prefix}from"./constant/index.js";var I=Object.defineProperty,h=Object.defineProperties,_=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable,p=(o,e,t)=>e in o?I(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,L=(o,e)=>{for(var t in e||(e={}))y.call(e,t)&&p(o,t,e[t]);if(l)for(var t of l(e))A.call(e,t)&&p(o,t,e[t]);return o},M=(o,e)=>h(o,_(e));const n=v();s.use(f),s.options.react={useSuspense:!1};const D=(o,e)=>{const[t,c]=m();return u(e,()=>({toolInstance:t,annotationEngine:n.getState().annotation.annotationEngine,pageBackwardActions:()=>n.dispatch(j()),pageForwardActions:()=>n.dispatch(S()),pageJump:(i,a)=>{const d=~~i-1;n.dispatch(T(d)),a&&n.dispatch(C(d))},hello:()=>alert("hello labelBee!!!")}),[t]),r.createElement(w,{store:n,context:b},r.createElement(x,{i18n:s},r.createElement(g,{value:o.toolStyle},r.createElement(V,null,r.createElement(P,M(L({},o),{setToolInstance:i=>{var a;c(i),(a=o.onLoad)==null||a.call(o,{toolInstance:i})}}))))))};var B=r.forwardRef(D);export{B as default,n as store};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{EDataFormatType as s}from"../../constant/index.js";import{create as r}from"zustand";const o=r(e=>({dataFormatType:s.Default,setDataFormatType:t=>e(a=>({dataFormatType:t})),selectedID:"",setSelectedID:t=>e(a=>({selectedID:t})),newAnswerListMap:{},setNewAnswerListMap:t=>e(a=>({newAnswerListMap:t}))}));export{o as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ANNOTATION_ACTIONS as a}from"../Actions.js";import{LoadFileAndFileData as
|
|
1
|
+
import{ANNOTATION_ACTIONS as a}from"../Actions.js";import{LoadFileAndFileData as N,getStepConfig as V}from"./reducer.js";import{ESubmitType as E}from"../../constant/index.js";import{EPageTurningOperation as y}from"../../data/enums/AnnotationSize.js";import J from"../../utils/PageOperator.js";import{jsonParser as X}from"../../utils/index.js";import{getBoxesByTrackID as Y}from"../../components/predictTracking/previewResult/util.js";var S=(t,n,e)=>new Promise((o,r)=>{var i=l=>{try{u(e.next(l))}catch(p){r(p)}},s=l=>{try{u(e.throw(l))}catch(p){r(p)}},u=l=>l.done?o(l.value):Promise.resolve(l.value).then(i,s);u((e=e.apply(t,n)).next())});const G=(t,n)=>n.map(e=>t(e)),W=t=>t===y.Forward?E.Forward:t===y.Backward?E.Backward:t===y.Jump?E.Jump:E.Forward,q=(t,n)=>{var e,o,r;const{imgList:i,imgIndex:s}=t,{dataSourceStep:u}=V(t.stepList,t.step);return((r=(o=X((e=i[s-1])==null?void 0:e.result)[`step_${u}`])==null?void 0:o.result)==null?void 0:r.length)-1||n};function z(t){return{type:a.UPDATE_TOOL_INSTANCE,payload:{toolInstance:t}}}function w({stepList:t}){return{type:a.SET_TASK_STEP_LIST,payload:{stepList:t}}}function F({stepList:t,step:n}){return{type:a.SET_TASK_CONFIG,payload:{stepList:t,step:n}}}function L(t){return{type:a.UPDATE_ON_SUBMIT,payload:{onSubmit:t}}}function D(t){return{type:a.UPDATE_ON_SAVE,payload:{onSave:t}}}function m(t){return{type:a.UPDATE_ON_PAGE_CHANGE,payload:{onPageChange:t}}}function R(t){return{type:a.UPDATE_ON_STEP_CHANGE,payload:{onStepChange:t}}}function g(t){return{type:a.UPDATE_GET_FILE_DATA,payload:{getFileData:t}}}function h(t){return{type:a.UPDATE_PAGE_SIZE,payload:{pageSize:t}}}function B(t){return{type:a.UPDATE_LOAD_FILE_LIST,payload:{loadFileList:t}}}function Z(){return{type:a.UPDATE_ROTATE}}function k(t){return{type:a.SKIP_BEFORE_PAGE_TURNING,payload:{skipBeforePageTurning:t}}}function C(t){return{type:a.UPDATE_BEFORE_ROTATE,payload:{beforeRotate:t}}}function v(t){return{type:a.UPDATE_PRE_DATA_PROCESS,payload:{preDataProcess:t}}}function $(){return{type:a.COPY_BACKWARD_RESULT}}function b(t){return{type:a.UPDATE_IMG_INDEX_BY_EXTERNAL,payload:{getImgIndexByExternal:t}}}function Q({id:t,newID:n,rangeIndex:e,imgList:o}){return{type:a.BATCH_UPDATE_TRACK_ID,payload:{id:t,newID:n,rangeIndex:e,imgList:o}}}function tt(t,n,e){return{type:a.BATCH_UPDATE_RESULT_BY_TRACK_ID,payload:{id:t,newData:n,rangeIndex:e}}}function nt(){return{type:a.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT,payload:{}}}const H=t=>({type:a.SET_CHECK_MODE,payload:{checkMode:t}}),x=t=>({type:a.SET_HIGHLIGHT_ATTRIBUTE,payload:{attribute:t}});function et({onSubmit:t,onSave:n,onPageChange:e,onStepChange:o,getFileData:r,pageSize:i,loadFileList:s,step:u,stepList:l,skipBeforePageTurning:p,beforeRotate:_,checkMode:c,highlightAttribute:T,preDataProcess:f,getImgIndexByExternal:I}){const d=[];return t&&d.push(L(t)),n&&d.push(D(n)),e&&d.push(m(e)),o&&d.push(R(o)),r&&d.push(g(r)),s&&d.push(B(s)),i&&d.push(h(i)),p&&d.push(k(p)),_&&d.push(C(_)),f&&d.push(v(f)),typeof c=="boolean"&&d.push(H(c)),I&&d.push(b(I)),d.push(x(T)),d.push(F({stepList:l,step:u})),d.push({type:a.CALC_STEP_PROGRESS}),d.push({type:a.INIT_TOOL}),O=>G(O,d)}function at({onSubmit:t,onSave:n,onPageChange:e,onStepChange:o,getFileData:r,pageSize:i,loadFileList:s,stepList:u,beforeRotate:l,highlightAttribute:p,preDataProcess:_}){const c=[];return t&&c.push(L(t)),n&&c.push(D(n)),e&&c.push(m(e)),o&&c.push(R(o)),r&&c.push(g(r)),s&&c.push(B(s)),i&&c.push(h(i)),l&&c.push(C(l)),_&&c.push(v(_)),c.push(x(p)),c.push(w({stepList:u})),T=>G(T,c)}const ot=(t,n)=>{var e;const o=n==null?void 0:n.findIndex(r=>(r==null?void 0:r.step)===t);return(e=n[o+1])==null?void 0:e.step},rt=t=>(n,e)=>{const{annotation:o}=e(),{step:r,stepList:i}=o,s=ot(r,i);return[n(M(s,t))]},M=(t,n)=>(e,o)=>{var r,i;const{annotation:s}=o();(r=s==null?void 0:s.onStepChange)==null||r.call(s,t);const u=(i=s==null?void 0:s.imgIndex)!=null?i:0;return[e({type:a.SUBMIT_RESULT}),e({type:a.SUBMIT_FILE_DATA,payload:{submitType:E.StepChanged}}),e({type:a.SET_STEP,payload:{toStep:t}}),e({type:a.CALC_STEP_PROGRESS}),e(N(n!=null?n:u,0))]},A=t=>n=>[n({type:a.SUBMIT_RESULT}),n({type:a.SUBMIT_FILE_DATA,payload:{submitType:t}})],it=(t,n,e,o)=>S(void 0,null,function*(){t(A(e)),yield t(K(e)),t(N(n,o))}),ut=(t,n)=>[t({type:a.SUBMIT_RESULT}),t({type:a.SET_BASIC_INDEX,payload:{basicIndex:n}})],st=(t,n)=>{t({type:a.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED,payload:{triggerEventAfterIndexChanged:n}})},lt=(t=!1)=>(n,e)=>P(n,e,y.Backward,t),pt=(t=!1)=>(n,e)=>P(n,e,y.Forward,t),dt=(t,n=!1)=>(e,o)=>{if(t!==o().imgIndex)return P(e,o,y.Jump,n,t)},j=(t,n,e,o)=>S(void 0,null,function*(){var r;const{loadFileList:i,imgList:s,pageSize:u}=n().annotation,l=Math.floor(e/u);U(t,!0);try{const p=yield i(l,u);if(U(t,!1),!((r=p==null?void 0:p.fileList)==null?void 0:r.length)||!(p==null?void 0:p.total))throw new Error("fileList and total are required");const _=o?new Array(p.total):[...s];return _.splice(l*u,u,...p.fileList),t({type:a.UPDATE_IMG_LIST,payload:{imgList:_}}),!0}catch(p){U(t,!1),console.error(p)}}),P=(t,n,e,o=!1,r)=>S(void 0,null,function*(){var i,s;const u=n().annotation,l=W(e);let{fileIndexChanged:p,fileIndex:_,basicIndexChanged:c,basicIndex:T}=J.getNextPageInfo(e,u,r);const f=(i=u==null?void 0:u.getImgIndexByExternal)==null?void 0:i.call(u,u.imgIndex,l);if(f!==void 0&&(p=!0,_=f),st(t,o),p){if(u.loading||!u.imgList[_]&&!(yield j(t,n,_)))return;const I=n();(s=u.onPageChange)==null||s.call(u,_);const d=l===E.Backward?q(I.annotation,T):T;return it(t,_,l,d)}return c?ut(t,T):t(A(l))}),ct=t=>{t(A(E.Save)),t({type:a.SAVE_RESULT})},U=(t,n)=>{t({type:a.SET_LOADING,payload:{loading:n}})},_t=(t,n)=>{t({type:a.SET_LOADPCDFILE_LOADING,payload:{loadPCDFileLoading:n}})},Tt=t=>{t({type:a.INIT_ALL_STATE,payload:{}})},Et=(t,n)=>{t({type:a.SET_PREDICT_RESULT,payload:{result:n}})},yt=(t,n)=>{t({type:a.SET_PREDICT_RESULT_VISIBLE,payload:{visible:n}})},ft=(t,n)=>(e,o)=>{const{imgList:r,step:i}=o().annotation;return Y(r,i,t,n)},It=t=>(n,e)=>{var o,r;const{annotation:i}=e();return(r=(o=i==null?void 0:i.preDataProcess)==null?void 0:o.call(i,t))!=null?r:t.dataList},K=t=>(n,e)=>S(void 0,null,function*(){const{annotation:o}=e(),{onSubmit:r,imgIndex:i,imgList:s}=o;!r||(yield r([s[i]],t,i,s))});export{nt as BatchUpdateImgListResultByPredictResult,tt as BatchUpdateResultByTrackID,Q as BatchUpdateTrackID,ct as ChangeSave,$ as CopyBackWordResult,P as DispatcherTurning,ft as GetBoxesByID,Tt as InitAnnotationState,et as InitTaskData,lt as PageBackward,pt as PageForward,dt as PageJump,It as PreDataProcess,U as SetAnnotationLoading,_t as SetLoadPCDFileLoading,Et as SetPredictResult,yt as SetPredictResultVisible,F as SetTaskConfig,w as SetTaskStepList,K as SubmitHandler,rt as ToNextStep,A as ToSubmitFileData,C as UpdateBeforeRotate,H as UpdateCheckMode,g as UpdateGetFileData,B as UpdateGetFileList,x as UpdateHighlightAttribute,b as UpdateImgIndexByExternal,at as UpdateInjectFunc,m as UpdateOnPageChange,D as UpdateOnSave,R as UpdateOnStepChange,L as UpdateOnSubmit,h as UpdatePageSize,v as UpdatePreDataProcess,M as UpdateProcessingStep,Z as UpdateRotate,k as UpdateSkipBeforePageTurning,z as UpdateToolInstance,j as loadImgList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getFormatSize as Rt}from"../../components/customResizeHook/index.js";import{ESubmitType as K}from"../../constant/index.js";import Pt from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as i}from"../Actions.js";import{jsonParser as x}from"../../utils/index.js";import X from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as Ct}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as pt,composeResult as Y}from"../../utils/data.js";import O from"../../utils/StepUtils.js";import J from"../../utils/ToolUtils.js";import{MathUtils as gt,CommonToolUtils as Ot,AnnotationEngine as ht,ImgUtils as bt}from"@labelbee/lb-annotation";import{PointCloudUtils as _t,i18n as G}from"@labelbee/lb-utils";import{Modal as It}from"antd";import{message as mt}from"antd/es";import ft from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as W}from"../../data/enums/ToolType.js";var Nt=Object.defineProperty,Ut=Object.defineProperties,Bt=Object.getOwnPropertyDescriptors,Tt=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,Lt=(t,e,u)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[e]=u,o=(t,e)=>{for(var u in e||(e={}))xt.call(e,u)&&Lt(t,u,e[u]);if(Tt)for(var u of Tt(e))wt.call(e,u)&&Lt(t,u,e[u]);return t},s=(t,e)=>Ut(t,Bt(e)),Et=(t,e,u)=>new Promise((S,d)=>{var A=m=>{try{E(u.next(m))}catch(R){d(R)}},L=m=>{try{E(u.throw(m))}catch(R){d(R)}},E=m=>m.done?S(m.value):Promise.resolve(m.value).then(A,L);E((u=u.apply(t,e)).next())});const w=(t,e)=>t.find(u=>u.step===e),St={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:""},Ft=t=>{const{imgList:e,imgPageSize:u}=t;return Math.ceil(e.length/u)},At=(t,e)=>t.reduce((u,S)=>{if(S){const d=S.result;if(x(d)[`step_${e}`])return u+1}return u},0)/t.length,jt=(t,e)=>{const{step:u,stepList:S}=t,d=O.getCurrentStepInfo(u,S),A=Ct.jsonParser(d.config);if(J.isVideoTool(d==null?void 0:d.tool)||J.isAudioTool(d==null?void 0:d.tool)||J.isPointCloudTool(d==null?void 0:d.tool)||[W.LLM,W.NLP].includes(d==null?void 0:d.tool))return;const L=document.getElementById("toolContainer");if(!L)throw"Not exist dom named id-toolContainer";const E=Rt({width:window.innerWidth,height:window.innerHeight}),m=new ht({container:L,toolName:d.tool,size:E,imgNode:e,config:A,style:JSON.parse(Pt)});return{toolInstance:m==null?void 0:m.toolInstance,annotationEngine:m}},Gt=(t,e)=>(u,S)=>Et(void 0,null,function*(){var d,A;const{stepList:L,step:E}=S().annotation,m=O.currentToolIsVideo(E,L),R=O.currentToolIsPointCloud(E,L),h=((d=O.getCurrentStepInfo(E,L))==null?void 0:d.tool)===W.LLM,b=((A=O.getCurrentStepInfo(E,L))==null?void 0:A.tool)===W.NLP,N=O.currentToolIsAudio(E,L);if($(u,!0),yield u(Vt(t)),m){u(Mt(t));return}if(R||h||N||b){u(kt(t));return}u(Ht(t,e))}),Vt=t=>(e,u)=>Et(void 0,null,function*(){const{getFileData:S,imgList:d}=u().annotation;if(S){const A=yield S(d[t],t);e({type:i.SET_FILE_DATA,payload:{fileData:A,index:t}})}}),Mt=t=>e=>{e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},kt=t=>e=>{$(e,!1),e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},Ht=(t,e)=>(u,S)=>{var d;const{toolInstance:A,imgList:L}=S().annotation,E=(d=L==null?void 0:L[t])==null?void 0:d.url;bt.load(E).then(m=>{$(u,!1),u({type:i.LOAD_FILE_DATA,payload:{imgNode:m,nextIndex:t,nextBasicIndex:e}})}).catch(()=>{$(u,!1),A==null||A.setErrorImg(),u({type:i.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:e}})})},zt=({toolInstance:t,imgList:e,imgIndex:u,stepList:S,step:d=1})=>{var A,L,E,m;const R=((A=e[u])==null?void 0:A.result)||"",[h,b,N]=(L=t==null?void 0:t.exportData())!=null?L:[],V=(m=(E=t==null?void 0:t.exportCustomData)==null?void 0:E.call(t))!=null?m:{},M=pt(R,b),k=Y(M,{step:d,stepList:S},{rect:h},V);return e.map((F,H)=>H===u?o(s(o({},F),{result:k}),N):o({},F))},Kt=(t=o({},St),e)=>{var u,S,d,A,L,E,m,R,h,b,N,V,M,k,F,H,q,Z,Q,tt,et,nt,ot,lt,st,it,rt,ut,at;switch(e.type){case i.INIT_ALL_STATE:return o(o({},t),St);case i.UPDATE_TOOL_INSTANCE:return s(o({},t),{toolInstance:e.payload.toolInstance});case i.UPDATE_IMG_LIST:return s(o({},t),{imgList:e.payload.imgList});case i.CALC_STEP_PROGRESS:{const{imgList:n,step:l}=t,r=At(n,l);return s(o({},t),{stepProgress:r})}case i.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:l,step:r,stepList:a,toolInstance:p,onSubmit:c,resultList:f}=t;if(!p||!n[l])return t;const I=((u=n[l])==null?void 0:u.result)||"",[,_,g]=(S=p==null?void 0:p.exportData())!=null?S:[],T=(A=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?A:{},D=pt(I,_),v=Y(D,{step:r,stepList:a},{rect:f},T),y=t.imgList.map((C,P)=>{if(P===l){const j=X.dataCorrection(v,I,r,a);return o(s(o({},C),{result:j}),g)}return C});if(((L=e.payload)==null?void 0:L.submitType)===K.SyncImgList)return s(o({},t),{imgList:y});c&&c([y[l]],(E=e.payload)==null?void 0:E.submitType,l,y);const U=At(y,r);return s(o({},t),{stepProgress:U,imgList:y})}case i.SAVE_RESULT:{const{imgList:n,imgIndex:l,onSave:r}=t;return r==null||r(n[l],l,n),o({},t)}case i.SUBMIT_RESULT:{const{imgList:n,basicIndex:l,resultList:r,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(m=a==null?void 0:a.exportData())!=null?m:[];let f=c;if((p==null?void 0:p.length)>0){const I=(R=p[l])==null?void 0:R.id,_=c.map(g=>s(o({},g),{sourceID:I}));f=ft.cloneDeep(r).filter(g=>g.sourceID!==I),f.push(..._)}return s(o({},t),{resultList:f,imgList:n})}case i.SET_BASIC_INDEX:{const{toolInstance:n,step:l,imgList:r,imgIndex:a,stepList:p,annotationEngine:c,resultList:f,basicResultList:I}=t;if(!n||!c)return t;const _=e.payload.basicIndex,g=(h=I[_])==null?void 0:h.id,T=x((b=r[a])==null?void 0:b.result),D=(f||[]).filter(j=>j.sourceID===g),v=w(p,l),{dataSourceStep:y,tool:U}=v,C=w(p,y);let P=[];return y&&U&&(P=(N=T[`step_${y}`])==null?void 0:N.result,(P==null?void 0:P.length)>0?(c==null||c.setBasicInfo(C.tool,P[_]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),mt.info(G.t("NoDependency")))),n==null||n.setResult(D),n==null||n.history.initRecord(D,!0),s(o({},t),{basicIndex:_})}case i.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=e.payload;return s(o({},t),{triggerEventAfterIndexChanged:!!n})}case i.LOAD_FILE_DATA:{const{imgList:n,step:l,toolInstance:r,annotationEngine:a,stepList:p}=t;if(!r)return s(o({},t),{imgIndex:e.payload.nextIndex});const c=O.getCurrentStepInfo(l,p),{nextIndex:f,imgNode:I,nextBasicIndex:_,imgError:g}=e.payload,T=_!=null?_:0,D=x((V=n[f])==null?void 0:V.result),v=D[`step_${c.step}`],y=!v,U={rotate:(M=D.rotate)!=null?M:0,valid:(k=D.valid)!=null?k:!0};I&&g!==!0?a==null||a.setImgNode(I,U):r==null||r.setValid(U.valid);const C=w(p,c.step),{dataSourceStep:P,tool:j}=C,ct=w(p,P),dt=P&&j,B=(H=(F=D[`step_${P}`])==null?void 0:F.result)!=null?H:[],z=X.getInitialResultList(v==null?void 0:v.result,r,C,B,y);if(a==null||a.launchOperation(),dt&&((B==null?void 0:B.length)>0?a==null||a.setBasicInfo(ct.tool,B[T]):(a==null||a.setBasicInfo(ct.tool),a==null||a.forbidOperation(),mt.info(G.t("NoDependency")))),c.tool!=="check"){const Dt=(Z=(q=B[T])==null?void 0:q.id)!=null?Z:"",vt=dt?z.filter(yt=>Ot.isSameSourceID(yt.sourceID,Dt)):z;(Q=r==null?void 0:r.history)==null||Q.initRecord(z,!0),r==null||r.setResult(vt)}return s(o({},t),{imgIndex:f,basicIndex:T,basicResultList:B,resultList:z})}case i.UPDATE_ANNOTATION_CONFIG:return s(o({},t),{config:(tt=e.payload.config)!=null?tt:"{}"});case i.SET_TASK_STEP_LIST:{const{stepList:n}=e.payload;return s(o({},t),{stepList:n})}case i.SET_TASK_CONFIG:{const{stepList:n,step:l}=e.payload;return s(o({},t),{stepList:n,step:l})}case i.INIT_TOOL:{const{imgNode:n}=t,l=jt(t,n);if(l){const{toolInstance:r,annotationEngine:a}=l;return s(o({},t),{toolInstance:r,annotationEngine:a})}return o({},t)}case i.SET_TOOL:{const n=(et=e.payload)==null?void 0:et.instance;return n?s(o({},t),{toolInstance:n}):o({},t)}case i.UPDATE_ON_SUBMIT:return s(o({},t),{onSubmit:e.payload.onSubmit});case i.UPDATE_ON_SAVE:return s(o({},t),{onSave:e.payload.onSave});case i.UPDATE_ON_PAGE_CHANGE:return s(o({},t),{onPageChange:e.payload.onPageChange});case i.SET_PREDICT_RESULT:return s(o({},t),{predictionResult:e.payload.result});case i.SET_PREDICT_RESULT_VISIBLE:return s(o({},t),{predictionResultVisible:e.payload.visible});case i.UPDATE_ON_STEP_CHANGE:return s(o({},t),{onStepChange:e.payload.onStepChange});case i.UPDATE_GET_FILE_DATA:return s(o({},t),{getFileData:e.payload.getFileData});case i.UPDATE_PAGE_SIZE:return s(o({},t),{pageSize:e.payload.pageSize});case i.UPDATE_LOAD_FILE_LIST:return s(o({},t),{loadFileList:e.payload.loadFileList});case i.UPDATE_BEFORE_ROTATE:return s(o({},t),{beforeRotate:e.payload.beforeRotate});case i.UPDATE_PRE_DATA_PROCESS:return s(o({},t),{preDataProcess:e.payload.preDataProcess});case i.UPDATE_IMG_INDEX_BY_EXTERNAL:return s(o({},t),{getImgIndexByExternal:e.payload.getImgIndexByExternal});case i.SKIP_BEFORE_PAGE_TURNING:return s(o({},t),{skipBeforePageTurning:e.payload.skipBeforePageTurning});case i.SET_FILE_DATA:{const{fileData:n,index:l}=e.payload,{imgList:r}=t,a=[...r];return a[l]=o(o({},a[l]),n),s(o({},t),{imgList:a})}case i.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:l}=t;return l&&l()===!1||(nt=n==null?void 0:n.updateRotate)==null||nt.call(n),t}case i.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=t,l=(ot=n==null?void 0:n.valid)!=null?ot:!0;return It.destroyAll(),It.confirm({content:G.t(l?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!l)},okText:G.t("Confirm"),cancelText:G.t("Cancel")}),t}case i.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:l,imgList:r,step:a,stepList:p}=t;if(!n)return t;if(l===0||l>=r.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const c=r[l-1].result;if(!c)return t;const f=O.getCurrentStepInfo(a,p),I=(lt=f==null?void 0:f.step)!=null?lt:a,_=(st=n==null?void 0:n.valid)!=null?st:!0,g=X.copyResultChange({copyResult:c,step:I,currentResult:(it=r[l].result)!=null?it:"",preMappingImgList:(rt=r[l-1].mappingImgList)!=null?rt:[],mappingImgList:(ut=r[l].mappingImgList)!=null?ut:[],valid:_});r[l]=s(o({},r[l]),{result:g});const D=x(g)[`step_${a}`],v=(D==null?void 0:D.result)||[];return n==null||n.setResult(v),n==null||n.history.pushHistory(v),(at=n==null?void 0:n.asyncData)==null||at.call(n,r[l]),s(o({},t),{imgList:[...r]})}case i.SET_STEP:{const{stepList:n,annotationEngine:l}=t,{toStep:r}=e.payload;if(l){const a=w(n,r);return l==null||l.setToolName(a.tool,a.config),s(o({},t),{step:r,toolInstance:l==null?void 0:l.toolInstance})}return s(o({},t),{step:r})}case i.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=e.payload;return s(o({},t),{loadPCDFileLoading:!!n})}case i.SET_LOADING:{const{loading:n}=e.payload;return s(o({},t),{loading:!!n})}case i.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=e.payload;return s(o({},t),{pointCloudLoading:!!n})}case i.SET_CHECK_MODE:{const{checkMode:n}=e.payload;return s(o({},t),{checkMode:!!n})}case i.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=e.payload;return s(o({},t),{highlightAttribute:n})}case i.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:l,rangeIndex:r,imgList:a}=e.payload,{imgIndex:p,onSubmit:c}=t,f=[],I=a.map((_,g)=>{if(gt.isInRange(g,r)){const T=s(o({},_),{result:_t.batchUpdateTrackID({id:n,newID:l,result:_.result})});return f.push({imgIndex:g,newInfo:T}),T}return _});return c&&c([I[p]],K.BatchUpdateTrackID,p,I,{updateImgList:f}),s(o({},t),{imgList:I})}case i.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:n,newData:l,rangeIndex:r}=e.payload,{imgList:a,imgIndex:p,onSubmit:c}=t,f=[],I=a.map((_,g)=>{if(gt.isInRange(g,r)){const T=s(o({},_),{result:_t.batchUpdateResultByTrackID({id:n,newData:l,result:_.result})});return f.push({imgIndex:g,newInfo:T}),T}return _});return c&&c([I[p]],K.BatchUpdateTrackID,p,I,{updateImgList:f}),s(o({},t),{imgList:I})}case i.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:l,stepList:r,step:a,predictionResult:p}=t,c={};p.forEach(g=>{const{index:T}=g;c[T]=ft.pick(g,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const f=`step_${a}`,I=[],_=l.map((g,T)=>{if(c[T]){const D=g.result==="{}"?x(Y("",{step:a,stepList:r},{rect:[]},{})):x(g.result);D[f].result.push(c[T]);const v=s(o({},g),{result:JSON.stringify(D)});return I.push({imgIndex:T,newInfo:v}),v}return g});return n==null||n(_,K.BatchUpdateImgList,-1,_,{updateImgList:I}),s(o({},t),{imgList:_})}default:return t}};export{Gt as LoadFileAndFileData,Kt as annotationReducer,zt as composeResultByToolInstance,w as getStepConfig,Ft as getTotalPage};
|
|
1
|
+
import{getFormatSize as yt}from"../../components/customResizeHook/index.js";import{ESubmitType as W}from"../../constant/index.js";import Rt from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as i}from"../Actions.js";import{jsonParser as x}from"../../utils/index.js";import X from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as Pt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as dt,composeResult as Y}from"../../utils/data.js";import h from"../../utils/StepUtils.js";import J from"../../utils/ToolUtils.js";import{MathUtils as pt,CommonToolUtils as Ct,AnnotationEngine as ht,ImgUtils as Ot}from"@labelbee/lb-annotation";import{PointCloudUtils as gt,i18n as M}from"@labelbee/lb-utils";import{Modal as _t}from"antd";import{message as It}from"antd/es";import mt from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as w}from"../../data/enums/ToolType.js";var bt=Object.defineProperty,Nt=Object.defineProperties,Ut=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertySymbols,Bt=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable,Lt=(t,e,u)=>e in t?bt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):t[e]=u,o=(t,e)=>{for(var u in e||(e={}))Bt.call(e,u)&&Lt(t,u,e[u]);if(ft)for(var u of ft(e))xt.call(e,u)&&Lt(t,u,e[u]);return t},s=(t,e)=>Nt(t,Ut(e)),Tt=(t,e,u)=>new Promise((S,d)=>{var A=m=>{try{E(u.next(m))}catch(y){d(y)}},T=m=>{try{E(u.throw(m))}catch(y){d(y)}},E=m=>m.done?S(m.value):Promise.resolve(m.value).then(A,T);E((u=u.apply(t,e)).next())});const F=(t,e)=>t.find(u=>u.step===e),Et={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:""},wt=t=>{const{imgList:e,imgPageSize:u}=t;return Math.ceil(e.length/u)},St=(t,e)=>t.reduce((u,S)=>{if(S){const d=S.result;if(x(d)[`step_${e}`])return u+1}return u},0)/t.length,Ft=(t,e)=>{const{step:u,stepList:S}=t,d=h.getCurrentStepInfo(u,S),A=Pt.jsonParser(d.config);if(J.isVideoTool(d==null?void 0:d.tool)||J.isAudioTool(d==null?void 0:d.tool)||J.isPointCloudTool(d==null?void 0:d.tool)||[w.LLM,w.NLP,w.LLMMultiWheel].includes(d==null?void 0:d.tool))return;const T=document.getElementById("toolContainer");if(!T)throw"Not exist dom named id-toolContainer";const E=yt({width:window.innerWidth,height:window.innerHeight}),m=new ht({container:T,toolName:d.tool,size:E,imgNode:e,config:A,style:JSON.parse(Rt)});return{toolInstance:m==null?void 0:m.toolInstance,annotationEngine:m}},jt=(t,e)=>(u,S)=>Tt(void 0,null,function*(){var d,A;const{stepList:T,step:E}=S().annotation,m=h.currentToolIsVideo(E,T),y=h.currentToolIsPointCloud(E,T),O=[w.LLM,w.LLMMultiWheel].includes((d=h.getCurrentStepInfo(E,T))==null?void 0:d.tool),b=((A=h.getCurrentStepInfo(E,T))==null?void 0:A.tool)===w.NLP,N=h.currentToolIsAudio(E,T);if($(u,!0),yield u(Gt(t)),m){u(Mt(t));return}if(y||O||N||b){u(Vt(t));return}u(kt(t,e))}),Gt=t=>(e,u)=>Tt(void 0,null,function*(){const{getFileData:S,imgList:d}=u().annotation;if(S){const A=yield S(d[t],t);e({type:i.SET_FILE_DATA,payload:{fileData:A,index:t}})}}),Mt=t=>e=>{e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},Vt=t=>e=>{$(e,!1),e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},kt=(t,e)=>(u,S)=>{var d;const{toolInstance:A,imgList:T}=S().annotation,E=(d=T==null?void 0:T[t])==null?void 0:d.url;Ot.load(E).then(m=>{$(u,!1),u({type:i.LOAD_FILE_DATA,payload:{imgNode:m,nextIndex:t,nextBasicIndex:e}})}).catch(()=>{$(u,!1),A==null||A.setErrorImg(),u({type:i.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:e}})})},Ht=({toolInstance:t,imgList:e,imgIndex:u,stepList:S,step:d=1})=>{var A,T,E,m;const y=((A=e[u])==null?void 0:A.result)||"",[O,b,N]=(T=t==null?void 0:t.exportData())!=null?T:[],V=(m=(E=t==null?void 0:t.exportCustomData)==null?void 0:E.call(t))!=null?m:{},k=dt(y,b),H=Y(k,{step:d,stepList:S},{rect:O},V);return e.map((j,z)=>z===u?o(s(o({},j),{result:H}),N):o({},j))},zt=(t=o({},Et),e)=>{var u,S,d,A,T,E,m,y,O,b,N,V,k,H,j,z,q,Z,Q,tt,et,nt,ot,lt,st,it,rt,ut;switch(e.type){case i.INIT_ALL_STATE:return o(o({},t),Et);case i.UPDATE_TOOL_INSTANCE:return s(o({},t),{toolInstance:e.payload.toolInstance});case i.UPDATE_IMG_LIST:return s(o({},t),{imgList:e.payload.imgList});case i.CALC_STEP_PROGRESS:{const{imgList:n,step:l}=t,r=St(n,l);return s(o({},t),{stepProgress:r})}case i.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:l,step:r,stepList:a,toolInstance:p,onSubmit:c,resultList:f}=t;if(!p||!n[l])return t;const I=((u=n[l])==null?void 0:u.result)||"",[,_,g]=(S=p==null?void 0:p.exportData())!=null?S:[],L=(A=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?A:{},D=dt(I,_),v=Y(D,{step:r,stepList:a},{rect:f},L),P=t.imgList.map((C,R)=>{if(R===l){const G=X.dataCorrection(v,I,r,a);return o(s(o({},C),{result:G}),g)}return C});if(((T=e.payload)==null?void 0:T.submitType)===W.SyncImgList)return s(o({},t),{imgList:P});const U=St(P,r);return s(o({},t),{stepProgress:U,imgList:P})}case i.SAVE_RESULT:{const{imgList:n,imgIndex:l,onSave:r}=t;return r==null||r(n[l],l,n),o({},t)}case i.SUBMIT_RESULT:{const{imgList:n,basicIndex:l,resultList:r,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(E=a==null?void 0:a.exportData())!=null?E:[];let f=c;if((p==null?void 0:p.length)>0){const I=(m=p[l])==null?void 0:m.id,_=c.map(g=>s(o({},g),{sourceID:I}));f=mt.cloneDeep(r).filter(g=>g.sourceID!==I),f.push(..._)}return s(o({},t),{resultList:f,imgList:n})}case i.SET_BASIC_INDEX:{const{toolInstance:n,step:l,imgList:r,imgIndex:a,stepList:p,annotationEngine:c,resultList:f,basicResultList:I}=t;if(!n||!c)return t;const _=e.payload.basicIndex,g=(y=I[_])==null?void 0:y.id,L=x((O=r[a])==null?void 0:O.result),D=(f||[]).filter(G=>G.sourceID===g),v=F(p,l),{dataSourceStep:P,tool:U}=v,C=F(p,P);let R=[];return P&&U&&(R=(b=L[`step_${P}`])==null?void 0:b.result,(R==null?void 0:R.length)>0?(c==null||c.setBasicInfo(C.tool,R[_]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),It.info(M.t("NoDependency")))),n==null||n.setResult(D),n==null||n.history.initRecord(D,!0),s(o({},t),{basicIndex:_})}case i.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=e.payload;return s(o({},t),{triggerEventAfterIndexChanged:!!n})}case i.LOAD_FILE_DATA:{const{imgList:n,step:l,toolInstance:r,annotationEngine:a,stepList:p}=t;if(!r)return s(o({},t),{imgIndex:e.payload.nextIndex});const c=h.getCurrentStepInfo(l,p),{nextIndex:f,imgNode:I,nextBasicIndex:_,imgError:g}=e.payload,L=_!=null?_:0,D=x((N=n[f])==null?void 0:N.result),v=D[`step_${c.step}`],P=!v,U={rotate:(V=D.rotate)!=null?V:0,valid:(k=D.valid)!=null?k:!0};I&&g!==!0?a==null||a.setImgNode(I,U):r==null||r.setValid(U.valid);const C=F(p,c.step),{dataSourceStep:R,tool:G}=C,at=F(p,R),ct=R&&G,B=(j=(H=D[`step_${R}`])==null?void 0:H.result)!=null?j:[],K=X.getInitialResultList(v==null?void 0:v.result,r,C,B,P);if(a==null||a.launchOperation(),ct&&((B==null?void 0:B.length)>0?a==null||a.setBasicInfo(at.tool,B[L]):(a==null||a.setBasicInfo(at.tool),a==null||a.forbidOperation(),It.info(M.t("NoDependency")))),c.tool!=="check"){const At=(q=(z=B[L])==null?void 0:z.id)!=null?q:"",Dt=ct?K.filter(vt=>Ct.isSameSourceID(vt.sourceID,At)):K;(Z=r==null?void 0:r.history)==null||Z.initRecord(K,!0),r==null||r.setResult(Dt)}return s(o({},t),{imgIndex:f,basicIndex:L,basicResultList:B,resultList:K})}case i.UPDATE_ANNOTATION_CONFIG:return s(o({},t),{config:(Q=e.payload.config)!=null?Q:"{}"});case i.SET_TASK_STEP_LIST:{const{stepList:n}=e.payload;return s(o({},t),{stepList:n})}case i.SET_TASK_CONFIG:{const{stepList:n,step:l}=e.payload;return s(o({},t),{stepList:n,step:l})}case i.INIT_TOOL:{const{imgNode:n}=t,l=Ft(t,n);if(l){const{toolInstance:r,annotationEngine:a}=l;return s(o({},t),{toolInstance:r,annotationEngine:a})}return o({},t)}case i.SET_TOOL:{const n=(tt=e.payload)==null?void 0:tt.instance;return n?s(o({},t),{toolInstance:n}):o({},t)}case i.UPDATE_ON_SUBMIT:return s(o({},t),{onSubmit:e.payload.onSubmit});case i.UPDATE_ON_SAVE:return s(o({},t),{onSave:e.payload.onSave});case i.UPDATE_ON_PAGE_CHANGE:return s(o({},t),{onPageChange:e.payload.onPageChange});case i.SET_PREDICT_RESULT:return s(o({},t),{predictionResult:e.payload.result});case i.SET_PREDICT_RESULT_VISIBLE:return s(o({},t),{predictionResultVisible:e.payload.visible});case i.UPDATE_ON_STEP_CHANGE:return s(o({},t),{onStepChange:e.payload.onStepChange});case i.UPDATE_GET_FILE_DATA:return s(o({},t),{getFileData:e.payload.getFileData});case i.UPDATE_PAGE_SIZE:return s(o({},t),{pageSize:e.payload.pageSize});case i.UPDATE_LOAD_FILE_LIST:return s(o({},t),{loadFileList:e.payload.loadFileList});case i.UPDATE_BEFORE_ROTATE:return s(o({},t),{beforeRotate:e.payload.beforeRotate});case i.UPDATE_PRE_DATA_PROCESS:return s(o({},t),{preDataProcess:e.payload.preDataProcess});case i.UPDATE_IMG_INDEX_BY_EXTERNAL:return s(o({},t),{getImgIndexByExternal:e.payload.getImgIndexByExternal});case i.SKIP_BEFORE_PAGE_TURNING:return s(o({},t),{skipBeforePageTurning:e.payload.skipBeforePageTurning});case i.SET_FILE_DATA:{const{fileData:n,index:l}=e.payload,{imgList:r}=t,a=[...r];return a[l]=o(o({},a[l]),n),s(o({},t),{imgList:a})}case i.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:l}=t;return l&&l()===!1||(et=n==null?void 0:n.updateRotate)==null||et.call(n),t}case i.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=t,l=(nt=n==null?void 0:n.valid)!=null?nt:!0;return _t.destroyAll(),_t.confirm({content:M.t(l?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!l)},okText:M.t("Confirm"),cancelText:M.t("Cancel")}),t}case i.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:l,imgList:r,step:a,stepList:p}=t;if(!n)return t;if(l===0||l>=r.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const c=r[l-1].result;if(!c)return t;const f=h.getCurrentStepInfo(a,p),I=(ot=f==null?void 0:f.step)!=null?ot:a,_=(lt=n==null?void 0:n.valid)!=null?lt:!0,g=X.copyResultChange({copyResult:c,step:I,currentResult:(st=r[l].result)!=null?st:"",preMappingImgList:(it=r[l-1].mappingImgList)!=null?it:[],mappingImgList:(rt=r[l].mappingImgList)!=null?rt:[],valid:_});r[l]=s(o({},r[l]),{result:g});const D=x(g)[`step_${a}`],v=(D==null?void 0:D.result)||[];return n==null||n.setResult(v),n==null||n.history.pushHistory(v),(ut=n==null?void 0:n.asyncData)==null||ut.call(n,r[l]),s(o({},t),{imgList:[...r]})}case i.SET_STEP:{const{stepList:n,annotationEngine:l}=t,{toStep:r}=e.payload;if(l){const a=F(n,r);return l==null||l.setToolName(a.tool,a.config),s(o({},t),{step:r,toolInstance:l==null?void 0:l.toolInstance})}return s(o({},t),{step:r})}case i.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=e.payload;return s(o({},t),{loadPCDFileLoading:!!n})}case i.SET_LOADING:{const{loading:n}=e.payload;return s(o({},t),{loading:!!n})}case i.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=e.payload;return s(o({},t),{pointCloudLoading:!!n})}case i.SET_CHECK_MODE:{const{checkMode:n}=e.payload;return s(o({},t),{checkMode:!!n})}case i.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=e.payload;return s(o({},t),{highlightAttribute:n})}case i.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:l,rangeIndex:r,imgList:a}=e.payload,{imgIndex:p,onSubmit:c}=t,f=[],I=a.map((_,g)=>{if(pt.isInRange(g,r)){const L=s(o({},_),{result:gt.batchUpdateTrackID({id:n,newID:l,result:_.result})});return f.push({imgIndex:g,newInfo:L}),L}return _});return c&&c([I[p]],W.BatchUpdateTrackID,p,I,{updateImgList:f}),s(o({},t),{imgList:I})}case i.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:n,newData:l,rangeIndex:r}=e.payload,{imgList:a,imgIndex:p,onSubmit:c}=t,f=[],I=a.map((_,g)=>{if(pt.isInRange(g,r)){const L=s(o({},_),{result:gt.batchUpdateResultByTrackID({id:n,newData:l,result:_.result})});return f.push({imgIndex:g,newInfo:L}),L}return _});return c&&c([I[p]],W.BatchUpdateTrackID,p,I,{updateImgList:f}),s(o({},t),{imgList:I})}case i.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:l,stepList:r,step:a,predictionResult:p}=t,c={};p.forEach(g=>{const{index:L}=g;c[L]=mt.pick(g,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const f=`step_${a}`,I=[],_=l.map((g,L)=>{if(c[L]){const D=g.result==="{}"?x(Y("",{step:a,stepList:r},{rect:[]},{})):x(g.result);D[f].result.push(c[L]);const v=s(o({},g),{result:JSON.stringify(D)});return I.push({imgIndex:L,newInfo:v}),v}return g});return n==null||n(_,W.BatchUpdateImgList,-1,_,{updateImgList:I}),s(o({},t),{imgList:_})}default:return t}};export{jt as LoadFileAndFileData,zt as annotationReducer,Ht as composeResultByToolInstance,F as getStepConfig,wt as getTotalPage};
|