@labelbee/lb-components 1.23.0-alpha.92 → 1.23.0-alpha.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),reactI18next=require("react-i18next"),actionCreators=require("../../store/annotation/actionCreators.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(u,r,l)=>r in u?__defProp(u,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[r]=l,__spreadValues=(u,r)=>{for(var l in r||(r={}))__hasOwnProp.call(r,l)&&__defNormalProp(u,l,r[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(r))__propIsEnum.call(r,l)&&__defNormalProp(u,l,r[l]);return u},__spreadProps=(u,r)=>__defProps(u,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:u,config:r,checkMode:l,configString:V,imgIndex:f,toolInstanceRef:i})=>{const e=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:E,selectNextBox:L,selectPrevBox:B,updateSelectedBox:C,deleteSelectedPointCloudBoxAndPolygon:q}=useSingleBox.useSingleBox(),{selectedSphere:P,updatePointCloudSphere:O}=useSphere.useSphere(),{clearAllResult:y,updatePointCloudPattern:A}=useStatus.useStatus(),{copySelectedBoxes:j,pasteSelectedBoxes:I,copiedBoxes:Y}=useBoxes.useBoxes({config:r}),{updateRotate:g}=useRotate.useRotate({currentData:u}),{updateRotateEdge:T}=useRotateEdge.useRotateEdge({currentData:u}),{updatePointCloudData:v,topViewSelectedChanged:h}=usePointCloudViews.usePointCloudViews(),{redo:m,undo:S,pushHistoryWithList:D,pushHistoryUnderUpdatePolygon:N,pushHistoryUnderUpdateLine:R}=useHistory.useHistory(),H=ctx.useDispatch(),{syncThreeViewsAttribute:x}=useAttribute.useAttribute(),{syncAllViewsConfig:K,reRenderTopViewRange:U}=useConfig.useConfig(),{selectedPolygon:k}=usePolygon.usePolygon(),{selectedLine:_}=useLine.useLine(),{t:w}=reactI18next.useTranslation(),z=ahooks.useLatest(u),b=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},F=(t,o)=>{var s,a;const{topViewInstance:c,mainViewInstance:n}=e;if(!c)return;const{pointCloud2dOperation:d}=c;switch(t){case"q":{g(e.rectRotateSensitivity);break}case"e":g(-Number(e.rectRotateSensitivity));break;case"g":T(-90);break;case"u":{const p=d.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;A(p);const W={[lbAnnotation.EToolName.Polygon]:w("PolygonPattern"),[lbAnnotation.EToolName.Rect]:w("RectPattern")};antd.message.success(w("ChangePatternMsg",{pattern:W[p]})),d.clearActiveStatus(),d.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){B();break}L(),o.preventDefault();break;case"f":E();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":q(z.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const p=lbAnnotation.AttributeUtils.getAttributeByKeycode(o.keyCode,r.attributeList);p!==void 0&&((a=i.current)==null||a.setDefaultAttribute(p))}return}}},G=(t,o)=>{switch(t){case"c":j();break;case"v":I();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?m():S();break}}},M=ahooks.useLatest(t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t)||l===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){G(o,t);return}F(o,t)});return React.useEffect(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>M.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),React.useEffect(()=>{K(r)},[V]),React.useEffect(()=>{(r==null?void 0:r.radius)&&U(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{v==null||v()},[f,e.mainViewInstance]),React.useEffect(()=>{e.setHideAttributes([])},[f]),React.useEffect(()=>{i.current.setDefaultAttribute=t=>{var o,s,a,c;x(t);const n=e.selectedPointCloudBox;if(n){n.attribute=t;const d=H(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[n],stepConfig:r,action:"viewUpdateBox"}));n.valid=d[0].valid;const p=C(n);(a=(s=(o=e==null?void 0:e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:s.setPolygonValidAndRender)==null||a.call(s,n.id,!0,n.valid),e.mainViewInstance&&h({newSelectedBox:n,newPointCloudList:p})}if(k&&N(__spreadProps(__spreadValues({},k),{attribute:t})),_&&R(__spreadProps(__spreadValues({},_),{attribute:t})),P){const d=O(__spreadProps(__spreadValues({},P),{attribute:t}));e.mainViewInstance&&((c=e.mainViewInstance)==null||c.generateSpheres(d),h({newSelectedSphere:P,newSphereList:d}))}},i.current.setSubAttribute=(t,o)=>{var s;const a=e.selectedPointCloudBox;if(a){const c=(s=a==null?void 0:a.subAttribute)!=null?s:{};a.subAttribute=__spreadProps(__spreadValues({},c),{[t]:o}),C(a)}},i.current.clearResult=()=>{y==null||y()},i.current.redo=()=>{m()},i.current.undo=()=>{S()},i.current.setValid=t=>{i.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&y()})},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(()=>{v==null||v(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),React.useEffect(()=>{i.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},i.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),React.useEffect(()=>{i.current.history={pushHistory:t=>{D({pointCloudBoxList:t})},initRecord:()=>{}}},[]),React.useEffect(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||l)return;const s=n=>{x(n)},a=n=>{antd.message.error(n)},c=n=>{antd.message.info(n)};return o.on("syncAttribute",s),o.on("messageError",a),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",a),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var PointCloudListener$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudListener);module.exports=PointCloudListener$1;
1
+ "use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useBoxes=require("./hooks/useBoxes.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),antd=require("antd"),reactRedux=require("react-redux"),map=require("../../store/annotation/map.js"),useStatus=require("./hooks/useStatus.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),ctx=require("../../store/ctx.js"),useHistory=require("./hooks/useHistory.js"),useAttribute=require("./hooks/useAttribute.js"),useConfig=require("./hooks/useConfig.js"),usePolygon=require("./hooks/usePolygon.js"),useLine=require("./hooks/useLine.js"),reactI18next=require("react-i18next"),actionCreators=require("../../store/annotation/actionCreators.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,r,l)=>r in i?__defProp(i,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[r]=l,__spreadValues=(i,r)=>{for(var l in r||(r={}))__hasOwnProp.call(r,l)&&__defNormalProp(i,l,r[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(r))__propIsEnum.call(r,l)&&__defNormalProp(i,l,r[l]);return i},__spreadProps=(i,r)=>__defProps(i,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:i,config:r,checkMode:l,configString:V,imgIndex:f,toolInstanceRef:u})=>{const e=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:E,selectNextBox:L,selectPrevBox:B,updateSelectedBox:C,deleteSelectedPointCloudBoxAndPolygon:q}=useSingleBox.useSingleBox(),{selectedSphere:P,updatePointCloudSphere:O}=useSphere.useSphere(),{clearAllResult:y,updatePointCloudPattern:A}=useStatus.useStatus(),{copySelectedBoxes:j,pasteSelectedBoxes:I,copiedBoxes:Y}=useBoxes.useBoxes({config:r,currentData:i}),{updateRotate:g}=useRotate.useRotate({currentData:i}),{updateRotateEdge:T}=useRotateEdge.useRotateEdge({currentData:i}),{updatePointCloudData:v,topViewSelectedChanged:h}=usePointCloudViews.usePointCloudViews(),{redo:m,undo:S,pushHistoryWithList:D,pushHistoryUnderUpdatePolygon:N,pushHistoryUnderUpdateLine:R}=useHistory.useHistory(),H=ctx.useDispatch(),{syncThreeViewsAttribute:x}=useAttribute.useAttribute(),{syncAllViewsConfig:K,reRenderTopViewRange:U}=useConfig.useConfig(),{selectedPolygon:k}=usePolygon.usePolygon(),{selectedLine:_}=useLine.useLine(),{t:w}=reactI18next.useTranslation(),z=ahooks.useLatest(i),b=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},F=(t,o)=>{var s,a;const{topViewInstance:c,mainViewInstance:n}=e;if(!c)return;const{pointCloud2dOperation:d}=c;switch(t){case"q":{g(e.rectRotateSensitivity);break}case"e":g(-Number(e.rectRotateSensitivity));break;case"g":T(-90);break;case"u":{const p=d.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;A(p);const W={[lbAnnotation.EToolName.Polygon]:w("PolygonPattern"),[lbAnnotation.EToolName.Rect]:w("RectPattern")};antd.message.success(w("ChangePatternMsg",{pattern:W[p]})),d.clearActiveStatus(),d.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){B();break}L(),o.preventDefault();break;case"f":E();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":q(z.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const p=lbAnnotation.AttributeUtils.getAttributeByKeycode(o.keyCode,r.attributeList);p!==void 0&&((a=u.current)==null||a.setDefaultAttribute(p))}return}}},G=(t,o)=>{switch(t){case"c":j();break;case"v":I();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?m():S();break}}},M=ahooks.useLatest(t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t)||l===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){G(o,t);return}F(o,t)});return React.useEffect(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>M.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),React.useEffect(()=>{K(r)},[V]),React.useEffect(()=>{(r==null?void 0:r.radius)&&U(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{v==null||v()},[f,e.mainViewInstance]),React.useEffect(()=>{e.setHideAttributes([])},[f]),React.useEffect(()=>{u.current.setDefaultAttribute=t=>{var o,s,a,c;x(t);const n=e.selectedPointCloudBox;if(n){n.attribute=t;const d=H(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[n],stepConfig:r,action:"viewUpdateBox"}));n.valid=d[0].valid;const p=C(n);(a=(s=(o=e==null?void 0:e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:s.setPolygonValidAndRender)==null||a.call(s,n.id,!0,n.valid),e.mainViewInstance&&h({newSelectedBox:n,newPointCloudList:p})}if(k&&N(__spreadProps(__spreadValues({},k),{attribute:t})),_&&R(__spreadProps(__spreadValues({},_),{attribute:t})),P){const d=O(__spreadProps(__spreadValues({},P),{attribute:t}));e.mainViewInstance&&((c=e.mainViewInstance)==null||c.generateSpheres(d),h({newSelectedSphere:P,newSphereList:d}))}},u.current.setSubAttribute=(t,o)=>{var s;const a=e.selectedPointCloudBox;if(a){const c=(s=a==null?void 0:a.subAttribute)!=null?s:{};a.subAttribute=__spreadProps(__spreadValues({},c),{[t]:o}),C(a)}},u.current.clearResult=()=>{y==null||y()},u.current.redo=()=>{m()},u.current.undo=()=>{S()},u.current.setValid=t=>{u.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&y()})},u.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)},u.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},u.current.asyncData=t=>{setTimeout(()=>{v==null||v(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),React.useEffect(()=>{u.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},u.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),React.useEffect(()=>{u.current.history={pushHistory:t=>{D({pointCloudBoxList:t})},initRecord:()=>{}}},[]),React.useEffect(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||l)return;const s=n=>{x(n)},a=n=>{antd.message.error(n)},c=n=>{antd.message.info(n)};return o.on("syncAttribute",s),o.on("messageError",a),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",a),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var PointCloudListener$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudListener);module.exports=PointCloudListener$1;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),_=require("lodash"),antd=require("antd"),usePointCloudViews=require("./usePointCloudViews.js"),PointCloudContext=require("../PointCloudContext.js"),reactI18next=require("react-i18next"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var ___default=_interopDefaultLegacy(_);const useBoxes=({config:t})=>{const{selectedIDs:l,pointCloudBoxList:c,displayPointCloudList:r,setPointCloudResult:p,syncAllViewPointCloudColor:f}=React.useContext(PointCloudContext.PointCloudContext),[o,i]=React.useState([]),{pointCloudBoxListUpdated:d}=usePointCloudViews.usePointCloudViews(),{t:n,i18n:C}=reactI18next.useTranslation(),x=s=>t.trackConfigurable!==!0?!1:c.some(u=>s.some(e=>e.trackID===u.trackID)),a=React.useMemo(()=>r.filter(s=>l.includes(s.id)),[l,r]),P=React.useCallback(()=>{a.length>0?i(___default.default.cloneDeep(a)):(i([]),antd.message.error(n("CopyEmptyInPointCloud")))},[l,r,C.language]),D=React.useCallback(()=>{if(o.length===0){antd.message.error(n("PasteEmptyInPointCloud"));return}const s=x(o),u=e=>{p(e),d==null||d(e),i([]),f(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiPaste,e)};if(s)antd.Modal.confirm({title:n("HasDuplicateIDHeader"),content:n("HasDuplicateIDMsg"),onOk:()=>{const e=c.filter(g=>!o.find(I=>I.trackID===g.trackID)).concat(o);u(e)}});else{const e=[...r,...o];u(e)}},[o,r,C.language]);return{copySelectedBoxes:P,pasteSelectedBoxes:D,copiedBoxes:o,selectedBoxes:a}};exports.useBoxes=useBoxes;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),_=require("lodash"),antd=require("antd"),usePointCloudViews=require("./usePointCloudViews.js"),PointCloudContext=require("../PointCloudContext.js"),reactI18next=require("react-i18next"),ToolPointCloudBoxRenderHelper=require("../../../utils/ToolPointCloudBoxRenderHelper.js"),AnnotationDataUtils=require("../../../utils/AnnotationDataUtils.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,e,o)=>e in t?__defProp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,__spreadValues=(t,e)=>{for(var o in e||(e={}))__hasOwnProp.call(e,o)&&__defNormalProp(t,o,e[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(e))__propIsEnum.call(e,o)&&__defNormalProp(t,o,e[o]);return t},__spreadProps=(t,e)=>__defProps(t,__getOwnPropDescs(e));const updateBoxRects=(t,e=[],o=[])=>{const{rects:u=[]}=t,n=u.map(i=>{var p;return __spreadProps(__spreadValues({},i),{imageName:(p=AnnotationDataUtils.getNextPath({prePath:i.imageName,preMappingImgList:o,nextMappingImgList:e}))!=null?p:""})}).filter(i=>i.imageName!=="");return __spreadProps(__spreadValues({},t),{rects:n})},useBoxes=({config:t,currentData:e})=>{const{selectedIDs:o,pointCloudBoxList:u,displayPointCloudList:n,setPointCloudResult:i,syncAllViewPointCloudColor:p}=React.useContext(PointCloudContext.PointCloudContext),[d,g]=React.useState({copiedBoxes:[],copiedMappingImgList:[]}),{copiedBoxes:l}=d,{pointCloudBoxListUpdated:v}=usePointCloudViews.usePointCloudViews(),{t:c,i18n:C}=reactI18next.useTranslation(),I=r=>t.trackConfigurable!==!0?!1:u.some(a=>r.some(P=>P.trackID===a.trackID)),m=React.useMemo(()=>n.filter(r=>o.includes(r.id)),[o,n]),y=React.useCallback(()=>{var r;if(m.length>0){const a=(r=e==null?void 0:e.mappingImgList)!=null?r:[];g({copiedBoxes:___default.default.cloneDeep(m),copiedMappingImgList:a})}else g({copiedBoxes:[],copiedMappingImgList:[]}),antd.message.error(c("CopyEmptyInPointCloud"))},[o,n,C.language,e]),B=React.useCallback(()=>{var r,a;if(l.length===0){antd.message.error(c("PasteEmptyInPointCloud"));return}const P=I(l),O=(r=e==null?void 0:e.mappingImgList)!=null?r:[],D=(a=d==null?void 0:d.copiedMappingImgList)!=null?a:[],f=l.map(s=>updateBoxRects(s,O,D)),x=s=>{i(s),v==null||v(s),g({copiedBoxes:[],copiedMappingImgList:[]}),p(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.MultiPaste,s)};if(P)antd.Modal.confirm({title:c("HasDuplicateIDHeader"),content:c("HasDuplicateIDMsg"),onOk:()=>{const s=u.filter(L=>!f.find(w=>w.trackID===L.trackID)).concat(f);x(s)}});else{const s=[...n,...f];x(s)}},[l,n,C.language,e]);return{copySelectedBoxes:y,pasteSelectedBoxes:B,copiedBoxes:l,selectedBoxes:m}};exports.useBoxes=useBoxes;
@@ -1,12 +1,14 @@
1
- import { IPointCloudBoxList, IPointCloudConfig } from '@labelbee/lb-utils';
1
+ import { IPointCloudBox, IPointCloudBoxList, IPointCloudConfig } from '@labelbee/lb-utils';
2
+ import { IFileItem } from '@/types/data';
2
3
  /**
3
4
  * Actions for selected boxes
4
5
  */
5
- export declare const useBoxes: ({ config }: {
6
+ export declare const useBoxes: ({ config, currentData, }: {
6
7
  config: IPointCloudConfig;
8
+ currentData: IFileItem;
7
9
  }) => {
8
10
  copySelectedBoxes: () => void;
9
11
  pasteSelectedBoxes: () => void;
10
12
  copiedBoxes: IPointCloudBoxList;
11
- selectedBoxes: import("@labelbee/lb-utils").IPointCloudBox[];
13
+ selectedBoxes: IPointCloudBox[];
12
14
  };
@@ -1 +1 @@
1
- import{PointCloudContext as oe}from"./PointCloudContext.js";import{useRotate as re}from"./hooks/useRotate.js";import{useRotateEdge as se}from"./hooks/useRotateEdge.js";import{useBoxes as ne}from"./hooks/useBoxes.js";import{useSingleBox as ie}from"./hooks/useSingleBox.js";import{useSphere as ae}from"./hooks/useSphere.js";import{useContext as ue,useEffect as d}from"react";import{CommonToolUtils as le,EPointCloudName as ce,AttributeUtils as de,EToolName as f,cTool as pe}from"@labelbee/lb-annotation";import{message as g}from"antd";import{connect as me}from"react-redux";import{a2MapStateToProps as ve}from"../../store/annotation/map.js";import{useStatus as be}from"./hooks/useStatus.js";import{usePointCloudViews as fe}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as Pe,useDispatch as ye}from"../../store/ctx.js";import{useHistory as we}from"./hooks/useHistory.js";import{useAttribute as Ce}from"./hooks/useAttribute.js";import{useConfig as he}from"./hooks/useConfig.js";import{usePolygon as ge}from"./hooks/usePolygon.js";import{useLine as Se}from"./hooks/useLine.js";import{useTranslation as ke}from"react-i18next";import{PreDataProcess as xe}from"../../store/annotation/actionCreators.js";import{useLatest as A}from"ahooks";var _e=Object.defineProperty,Ve=Object.defineProperties,Le=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,E=(u,r,l)=>r in u?_e(u,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[r]=l,P=(u,r)=>{for(var l in r||(r={}))Be.call(r,l)&&E(u,l,r[l]);if(I)for(var l of I(r))Oe.call(r,l)&&E(u,l,r[l]);return u},y=(u,r)=>Ve(u,Le(r));const{EPolygonPattern:je}=pe,Ae=({currentData:u,config:r,checkMode:l,configString:D,imgIndex:S,toolInstanceRef:a})=>{const e=ue(oe),{changeSelectedBoxValid:T,selectNextBox:H,selectPrevBox:K,updateSelectedBox:k,deleteSelectedPointCloudBoxAndPolygon:N}=ie(),{selectedSphere:w,updatePointCloudSphere:R}=ae(),{clearAllResult:C,updatePointCloudPattern:U}=be(),{copySelectedBoxes:z,pasteSelectedBoxes:F,copiedBoxes:Ee}=ne({config:r}),{updateRotate:x}=re({currentData:u}),{updateRotateEdge:q}=se({currentData:u}),{updatePointCloudData:v,topViewSelectedChanged:_}=fe(),{redo:V,undo:L,pushHistoryWithList:G,pushHistoryUnderUpdatePolygon:M,pushHistoryUnderUpdateLine:W}=we(),Y=ye(),{syncThreeViewsAttribute:B}=Ce(),{syncAllViewsConfig:$,reRenderTopViewRange:J}=he(),{selectedPolygon:O}=ge(),{selectedLine:j}=Se(),{t:h}=ke(),Q=A(u),b=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},X=(t,o)=>{var s,i;const{topViewInstance:c,mainViewInstance:n}=e;if(!c)return;const{pointCloud2dOperation:p}=c;switch(t){case"q":{x(e.rectRotateSensitivity);break}case"e":x(-Number(e.rectRotateSensitivity));break;case"g":q(-90);break;case"u":{const m=p.pattern===je.Normal?f.Rect:f.Polygon;U(m);const te={[f.Polygon]:h("PolygonPattern"),[f.Rect]:h("RectPattern")};g.success(h("ChangePatternMsg",{pattern:te[m]})),p.clearActiveStatus(),p.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){K();break}H(),o.preventDefault();break;case"f":T();break;case"arrowup":b({y:-1});break;case"arrowdown":b({y:1});break;case"arrowleft":b({x:-1});break;case"arrowright":b({x:1});break;case"delete":N(Q.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const m=de.getAttributeByKeycode(o.keyCode,r.attributeList);m!==void 0&&((i=a.current)==null||i.setDefaultAttribute(m))}return}}},Z=(t,o)=>{switch(t){case"c":z();break;case"v":F();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?V():L();break}}},ee=A(t=>{if(!le.hotkeyFilter(t)||l===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){Z(o,t);return}X(o,t)});return d(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>ee.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),d(()=>{$(r)},[D]),d(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),d(()=>{v==null||v()},[S,e.mainViewInstance]),d(()=>{e.setHideAttributes([])},[S]),d(()=>{a.current.setDefaultAttribute=t=>{var o,s,i,c;B(t);const n=e.selectedPointCloudBox;if(n){n.attribute=t;const p=Y(xe({tool:ce.PointCloud,dataList:[n],stepConfig:r,action:"viewUpdateBox"}));n.valid=p[0].valid;const m=k(n);(i=(s=(o=e==null?void 0:e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:s.setPolygonValidAndRender)==null||i.call(s,n.id,!0,n.valid),e.mainViewInstance&&_({newSelectedBox:n,newPointCloudList:m})}if(O&&M(y(P({},O),{attribute:t})),j&&W(y(P({},j),{attribute:t})),w){const p=R(y(P({},w),{attribute:t}));e.mainViewInstance&&((c=e.mainViewInstance)==null||c.generateSpheres(p),_({newSelectedSphere:w,newSphereList:p}))}},a.current.setSubAttribute=(t,o)=>{var s;const i=e.selectedPointCloudBox;if(i){const c=(s=i==null?void 0:i.subAttribute)!=null?s:{};i.subAttribute=y(P({},c),{[t]:o}),k(i)}},a.current.clearResult=()=>{C==null||C()},a.current.redo=()=>{V()},a.current.undo=()=>{L()},a.current.setValid=t=>{a.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&C()})},a.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},a.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},a.current.asyncData=t=>{setTimeout(()=>{v==null||v(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),d(()=>{a.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},a.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),d(()=>{a.current.history={pushHistory:t=>{G({pointCloudBoxList:t})},initRecord:()=>{}}},[]),d(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||l)return;const s=n=>{B(n)},i=n=>{g.error(n)},c=n=>{g.info(n)};return o.on("syncAttribute",s),o.on("messageError",i),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",i),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var Ie=me(ve,null,null,{context:Pe})(Ae);export{Ie as default};
1
+ import{PointCloudContext as oe}from"./PointCloudContext.js";import{useRotate as re}from"./hooks/useRotate.js";import{useRotateEdge as se}from"./hooks/useRotateEdge.js";import{useBoxes as ne}from"./hooks/useBoxes.js";import{useSingleBox as ie}from"./hooks/useSingleBox.js";import{useSphere as ae}from"./hooks/useSphere.js";import{useContext as ue,useEffect as d}from"react";import{CommonToolUtils as le,EPointCloudName as ce,AttributeUtils as de,EToolName as f,cTool as pe}from"@labelbee/lb-annotation";import{message as g}from"antd";import{connect as me}from"react-redux";import{a2MapStateToProps as ve}from"../../store/annotation/map.js";import{useStatus as be}from"./hooks/useStatus.js";import{usePointCloudViews as fe}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as Pe,useDispatch as ye}from"../../store/ctx.js";import{useHistory as we}from"./hooks/useHistory.js";import{useAttribute as Ce}from"./hooks/useAttribute.js";import{useConfig as he}from"./hooks/useConfig.js";import{usePolygon as ge}from"./hooks/usePolygon.js";import{useLine as Se}from"./hooks/useLine.js";import{useTranslation as ke}from"react-i18next";import{PreDataProcess as xe}from"../../store/annotation/actionCreators.js";import{useLatest as A}from"ahooks";var _e=Object.defineProperty,Ve=Object.defineProperties,Le=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,E=(a,r,l)=>r in a?_e(a,r,{enumerable:!0,configurable:!0,writable:!0,value:l}):a[r]=l,P=(a,r)=>{for(var l in r||(r={}))Be.call(r,l)&&E(a,l,r[l]);if(I)for(var l of I(r))Oe.call(r,l)&&E(a,l,r[l]);return a},y=(a,r)=>Ve(a,Le(r));const{EPolygonPattern:je}=pe,Ae=({currentData:a,config:r,checkMode:l,configString:D,imgIndex:S,toolInstanceRef:u})=>{const e=ue(oe),{changeSelectedBoxValid:T,selectNextBox:H,selectPrevBox:K,updateSelectedBox:k,deleteSelectedPointCloudBoxAndPolygon:N}=ie(),{selectedSphere:w,updatePointCloudSphere:R}=ae(),{clearAllResult:C,updatePointCloudPattern:U}=be(),{copySelectedBoxes:z,pasteSelectedBoxes:F,copiedBoxes:Ee}=ne({config:r,currentData:a}),{updateRotate:x}=re({currentData:a}),{updateRotateEdge:q}=se({currentData:a}),{updatePointCloudData:v,topViewSelectedChanged:_}=fe(),{redo:V,undo:L,pushHistoryWithList:G,pushHistoryUnderUpdatePolygon:M,pushHistoryUnderUpdateLine:W}=we(),Y=ye(),{syncThreeViewsAttribute:B}=Ce(),{syncAllViewsConfig:$,reRenderTopViewRange:J}=he(),{selectedPolygon:O}=ge(),{selectedLine:j}=Se(),{t:h}=ke(),Q=A(a),b=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},X=(t,o)=>{var s,i;const{topViewInstance:c,mainViewInstance:n}=e;if(!c)return;const{pointCloud2dOperation:p}=c;switch(t){case"q":{x(e.rectRotateSensitivity);break}case"e":x(-Number(e.rectRotateSensitivity));break;case"g":q(-90);break;case"u":{const m=p.pattern===je.Normal?f.Rect:f.Polygon;U(m);const te={[f.Polygon]:h("PolygonPattern"),[f.Rect]:h("RectPattern")};g.success(h("ChangePatternMsg",{pattern:te[m]})),p.clearActiveStatus(),p.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){K();break}H(),o.preventDefault();break;case"f":T();break;case"arrowup":b({y:-1});break;case"arrowdown":b({y:1});break;case"arrowleft":b({x:-1});break;case"arrowright":b({x:1});break;case"delete":N(Q.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const m=de.getAttributeByKeycode(o.keyCode,r.attributeList);m!==void 0&&((i=u.current)==null||i.setDefaultAttribute(m))}return}}},Z=(t,o)=>{switch(t){case"c":z();break;case"v":F();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?V():L();break}}},ee=A(t=>{if(!le.hotkeyFilter(t)||l===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){Z(o,t);return}X(o,t)});return d(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>ee.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),d(()=>{$(r)},[D]),d(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),d(()=>{v==null||v()},[S,e.mainViewInstance]),d(()=>{e.setHideAttributes([])},[S]),d(()=>{u.current.setDefaultAttribute=t=>{var o,s,i,c;B(t);const n=e.selectedPointCloudBox;if(n){n.attribute=t;const p=Y(xe({tool:ce.PointCloud,dataList:[n],stepConfig:r,action:"viewUpdateBox"}));n.valid=p[0].valid;const m=k(n);(i=(s=(o=e==null?void 0:e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:s.setPolygonValidAndRender)==null||i.call(s,n.id,!0,n.valid),e.mainViewInstance&&_({newSelectedBox:n,newPointCloudList:m})}if(O&&M(y(P({},O),{attribute:t})),j&&W(y(P({},j),{attribute:t})),w){const p=R(y(P({},w),{attribute:t}));e.mainViewInstance&&((c=e.mainViewInstance)==null||c.generateSpheres(p),_({newSelectedSphere:w,newSphereList:p}))}},u.current.setSubAttribute=(t,o)=>{var s;const i=e.selectedPointCloudBox;if(i){const c=(s=i==null?void 0:i.subAttribute)!=null?s:{};i.subAttribute=y(P({},c),{[t]:o}),k(i)}},u.current.clearResult=()=>{C==null||C()},u.current.redo=()=>{V()},u.current.undo=()=>{L()},u.current.setValid=t=>{u.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&C()})},u.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)},u.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},u.current.asyncData=t=>{setTimeout(()=>{v==null||v(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),d(()=>{u.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},u.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),d(()=>{u.current.history={pushHistory:t=>{G({pointCloudBoxList:t})},initRecord:()=>{}}},[]),d(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||l)return;const s=n=>{B(n)},i=n=>{g.error(n)},c=n=>{g.info(n)};return o.on("syncAttribute",s),o.on("messageError",i),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",i),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var Ie=me(ve,null,null,{context:Pe})(Ae);export{Ie as default};
@@ -1 +1 @@
1
- import{useContext as k,useState as y,useMemo as R,useCallback as p}from"react";import h from"lodash";import{message as C,Modal as H}from"antd";import{usePointCloudViews as M}from"./usePointCloudViews.js";import{PointCloudContext as j}from"../PointCloudContext.js";import{useTranslation as w}from"react-i18next";import{EPointCloudBoxRenderTrigger as E}from"../../../utils/ToolPointCloudBoxRenderHelper.js";const S=({config:m})=>{const{selectedIDs:l,pointCloudBoxList:a,displayPointCloudList:o,setPointCloudResult:f,syncAllViewPointCloudColor:P}=k(j),[t,i]=y([]),{pointCloudBoxListUpdated:c}=M(),{t:n,i18n:d}=w(),x=s=>m.trackConfigurable!==!0?!1:a.some(r=>s.some(e=>e.trackID===r.trackID)),u=R(()=>o.filter(s=>l.includes(s.id)),[l,o]),D=p(()=>{u.length>0?i(h.cloneDeep(u)):(i([]),C.error(n("CopyEmptyInPointCloud")))},[l,o,d.language]),g=p(()=>{if(t.length===0){C.error(n("PasteEmptyInPointCloud"));return}const s=x(t),r=e=>{f(e),c==null||c(e),i([]),P(E.MultiPaste,e)};if(s)H.confirm({title:n("HasDuplicateIDHeader"),content:n("HasDuplicateIDMsg"),onOk:()=>{const e=a.filter(I=>!t.find(B=>B.trackID===I.trackID)).concat(t);r(e)}});else{const e=[...o,...t];r(e)}},[t,o,d.language]);return{copySelectedBoxes:D,pasteSelectedBoxes:g,copiedBoxes:t,selectedBoxes:u}};export{S as useBoxes};
1
+ import{useContext as k,useState as E,useMemo as N,useCallback as x}from"react";import S from"lodash";import{message as v,Modal as H}from"antd";import{usePointCloudViews as V}from"./usePointCloudViews.js";import{PointCloudContext as A}from"../PointCloudContext.js";import{useTranslation as T}from"react-i18next";import{EPointCloudBoxRenderTrigger as U}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import q from"../../../utils/AnnotationDataUtils.js";var z=Object.defineProperty,F=Object.defineProperties,G=Object.getOwnPropertyDescriptors,y=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,B=(o,e,t)=>e in o?z(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,O=(o,e)=>{for(var t in e||(e={}))J.call(e,t)&&B(o,t,e[t]);if(y)for(var t of y(e))K.call(e,t)&&B(o,t,e[t]);return o},D=(o,e)=>F(o,G(e));const Q=(o,e=[],t=[])=>{const{rects:l=[]}=o,n=l.map(i=>{var c;return D(O({},i),{imageName:(c=q.getNextPath({prePath:i.imageName,preMappingImgList:t,nextMappingImgList:e}))!=null?c:""})}).filter(i=>i.imageName!=="");return D(O({},o),{rects:n})},W=({config:o,currentData:e})=>{const{selectedIDs:t,pointCloudBoxList:l,displayPointCloudList:n,setPointCloudResult:i,syncAllViewPointCloudColor:c}=k(A),[d,m]=E({copiedBoxes:[],copiedMappingImgList:[]}),{copiedBoxes:p}=d,{pointCloudBoxListUpdated:I}=V(),{t:u,i18n:_}=T(),L=s=>o.trackConfigurable!==!0?!1:l.some(a=>s.some(f=>f.trackID===a.trackID)),g=N(()=>n.filter(s=>t.includes(s.id)),[t,n]),w=x(()=>{var s;if(g.length>0){const a=(s=e==null?void 0:e.mappingImgList)!=null?s:[];m({copiedBoxes:S.cloneDeep(g),copiedMappingImgList:a})}else m({copiedBoxes:[],copiedMappingImgList:[]}),v.error(u("CopyEmptyInPointCloud"))},[t,n,_.language,e]),M=x(()=>{var s,a;if(p.length===0){v.error(u("PasteEmptyInPointCloud"));return}const f=L(p),h=(s=e==null?void 0:e.mappingImgList)!=null?s:[],j=(a=d==null?void 0:d.copiedMappingImgList)!=null?a:[],P=p.map(r=>Q(r,h,j)),C=r=>{i(r),I==null||I(r),m({copiedBoxes:[],copiedMappingImgList:[]}),c(U.MultiPaste,r)};if(f)H.confirm({title:u("HasDuplicateIDHeader"),content:u("HasDuplicateIDMsg"),onOk:()=>{const r=l.filter(R=>!P.find(b=>b.trackID===R.trackID)).concat(P);C(r)}});else{const r=[...n,...P];C(r)}},[p,n,_.language,e]);return{copySelectedBoxes:w,pasteSelectedBoxes:M,copiedBoxes:p,selectedBoxes:g}};export{W as useBoxes};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.23.0-alpha.92",
3
+ "version": "1.23.0-alpha.94",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",