@labelbee/lb-components 1.14.0-alpha.8 → 1.14.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.
@@ -1 +1 @@
1
- "use strict";var PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.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"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(u,o,i)=>o in u?__defProp(u,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[o]=i,__spreadValues=(u,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(u,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(u,i,o[i]);return u},__spreadProps=(u,o)=>__defProps(u,__getOwnPropDescs(o));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:u,config:o,checkMode:i,configString:L,imgIndex:C,toolInstanceRef:a})=>{const r=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:V,selectNextBox:E,selectPrevBox:O,updateSelectedBox:g,deleteSelectedPointCloudBoxAndPolygon:q}=useSingleBox.useSingleBox(),{selectedSphere:b,updatePointCloudSphere:A}=useSphere.useSphere(),{clearAllResult:P,updatePointCloudPattern:j}=useStatus.useStatus(),{copySelectedBoxes:T,pasteSelectedBoxes:I,copiedBoxes:D}=useBoxes.useBoxes({config:o}),{updateRotate:y}=useRotate.useRotate({currentData:u}),{updatePointCloudData:p,topViewSelectedChanged:m}=usePointCloudViews.usePointCloudViews(),{redo:S,undo:h,pushHistoryWithList:N,pushHistoryUnderUpdatePolygon:H,pushHistoryUnderUpdateLine:K}=useHistory.useHistory(),{syncThreeViewsAttribute:x}=useAttribute.useAttribute(),{syncAllViewsConfig:U,reRenderTopViewRange:z}=useConfig.useConfig(),{selectedPolygon:k}=usePolygon.usePolygon(),{selectedLine:_}=useLine.useLine(),{t:f}=reactI18next.useTranslation(),v=e=>{var t;const{topViewInstance:s}=r;!s||(t=s.pointCloud2dOperation)==null||t.updateSelectedPolygonsPoints(e)},F=(e,t)=>{var s,n;const{topViewInstance:c,mainViewInstance:l}=r;if(!c)return;const{pointCloud2dOperation:w}=c;switch(e){case"q":{y(2);break}case"e":y(-2);break;case"g":y(180);break;case"u":{const d=w.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;j(d);const G={[lbAnnotation.EToolName.Polygon]:f("PolygonPattern"),[lbAnnotation.EToolName.Rect]:f("RectPattern")};antd.message.success(f("ChangePatternMsg",{pattern:G[d]})),w.clearActiveStatus(),w.clearDrawingStatus()}break;case"+":l==null||l.updatePointSize({zoomIn:!0});break;case"-":l==null||l.updatePointSize({zoomIn:!1});break;case"v":r.setPointCloudValid(!r.valid);break;case"tab":if(t.shiftKey){O();break}E(),t.preventDefault();break;case"f":V();break;case"arrowup":v({y:-1});break;case"arrowdown":v({y:1});break;case"arrowleft":v({x:-1});break;case"arrowright":v({x:1});break;case"delete":q();break;default:{if(((s=o.attributeList)==null?void 0:s.length)>0){const d=lbAnnotation.AttributeUtils.getAttributeByKeycode(t.keyCode,o.attributeList);d!==void 0&&((n=a.current)==null||n.setDefaultAttribute(d))}return}}},R=(e,t)=>{switch(e){case"c":T();break;case"v":I();break;case"a":t.preventDefault(),r.selectedAllBoxes();break;case"z":{t.shiftKey?S():h();break}}},B=e=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(e)||i===!0)return;const t=e.key.toLocaleLowerCase();if(e.ctrlKey){R(t,e);return}F(t,e)};return React.useEffect(()=>{const{topViewInstance:e}=r;if(!!e)return window.addEventListener("keydown",B),()=>{window.removeEventListener("keydown",B)}},[r,D,o,r.pointCloudBoxList,r.polygonList]),React.useEffect(()=>{U(o)},[L]),React.useEffect(()=>{(o==null?void 0:o.radius)&&z(o==null?void 0:o.radius)},[o==null?void 0:o.radius]),React.useEffect(()=>{p==null||p()},[C,r.mainViewInstance]),React.useEffect(()=>{r.setHideAttributes([])},[C]),React.useEffect(()=>{a.current.setDefaultAttribute=e=>{var t;x(e);const s=r.selectedPointCloudBox;if(s){s.attribute=e;const n=g(s);r.mainViewInstance&&m({newSelectedBox:s,newPointCloudList:n})}if(k&&H(__spreadProps(__spreadValues({},k),{attribute:e})),_&&K(__spreadProps(__spreadValues({},_),{attribute:e})),b){const n=A(__spreadProps(__spreadValues({},b),{attribute:e}));r.mainViewInstance&&((t=r.mainViewInstance)==null||t.generateSpheres(n),m({newSelectedSphere:b,newSphereList:n}))}},a.current.setSubAttribute=(e,t)=>{var s;const n=r.selectedPointCloudBox;if(n){const c=(s=n==null?void 0:n.subAttribute)!=null?s:{};n.subAttribute=__spreadProps(__spreadValues({},c),{[e]:t}),g(n)}},a.current.clearResult=()=>{P==null||P()},a.current.redo=()=>{S()},a.current.undo=()=>{h()},a.current.setValid=e=>{a.current.valid=e,setTimeout(()=>{r.setPointCloudValid(e),e===!1&&P()})},a.current.setForbidOperation=e=>{var t,s;(s=(t=r.topViewInstance)==null?void 0:t.pointCloud2dOperation)==null||s.setForbidOperation(e),e===!0&&r.setSelectedIDs(void 0)},a.current.setShowDefaultCursor=e=>{var t,s;(s=(t=r.topViewInstance)==null?void 0:t.pointCloud2dOperation)==null||s.setShowDefaultCursor(e)},a.current.asyncData=e=>{setTimeout(()=>{p==null||p(e)})}},[r.pointCloudBoxList,r.pointCloudSphereList,r.selectedID,r.valid,r.polygonList,r.lineList,r.mainViewInstance,r.ptSegmentInstance]),React.useEffect(()=>{a.current.updateSegmentTool=e=>{var t;(t=r.ptSegmentInstance)==null||t.emit(e)},a.current.segmentInstance=r.ptSegmentInstance},[r.ptSegmentInstance]),React.useEffect(()=>{a.current.history={pushHistory:e=>{N({pointCloudBoxList:e})},initRecord:()=>{}}},[]),React.useEffect(()=>{var e;const t=(e=r.topViewInstance)==null?void 0:e.toolInstance;if(!t||i)return;const s=l=>{x(l)},n=l=>{antd.message.error(l)},c=l=>{antd.message.info(l)};return t.on("syncAttribute",s),t.on("messageError",n),t.on("messageInfo",c),()=>{t.unbind("syncAttribute",s),t.unbind("messageError",n),t.unbind("messageInfo",c)}},[r.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"),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"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(l,r,u)=>r in l?__defProp(l,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[r]=u,__spreadValues=(l,r)=>{for(var u in r||(r={}))__hasOwnProp.call(r,u)&&__defNormalProp(l,u,r[u]);if(__getOwnPropSymbols)for(var u of __getOwnPropSymbols(r))__propIsEnum.call(r,u)&&__defNormalProp(l,u,r[u]);return l},__spreadProps=(l,r)=>__defProps(l,__getOwnPropDescs(r));const{EPolygonPattern}=lbAnnotation.cTool,PointCloudListener=({currentData:l,config:r,checkMode:u,configString:B,imgIndex:f,toolInstanceRef:a})=>{const t=React.useContext(PointCloudContext.PointCloudContext),{changeSelectedBoxValid:L,selectNextBox:E,selectPrevBox:O,updateSelectedBox:g,deleteSelectedPointCloudBoxAndPolygon:q}=useSingleBox.useSingleBox(),{selectedSphere:P,updatePointCloudSphere:A}=useSphere.useSphere(),{clearAllResult:y,updatePointCloudPattern:j}=useStatus.useStatus(),{copySelectedBoxes:I,pasteSelectedBoxes:T,copiedBoxes:D}=useBoxes.useBoxes({config:r}),{updateRotate:w}=useRotate.useRotate({currentData:l}),{updatePointCloudData:v,topViewSelectedChanged:m}=usePointCloudViews.usePointCloudViews(),{redo:h,undo:x,pushHistoryWithList:N,pushHistoryUnderUpdatePolygon:H,pushHistoryUnderUpdateLine:K}=useHistory.useHistory(),U=ctx.useDispatch(),{syncThreeViewsAttribute:S}=useAttribute.useAttribute(),{syncAllViewsConfig:z,reRenderTopViewRange:R}=useConfig.useConfig(),{selectedPolygon:k}=usePolygon.usePolygon(),{selectedLine:_}=useLine.useLine(),{t:C}=reactI18next.useTranslation(),b=e=>{var o;const{topViewInstance:s}=t;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(e)},F=(e,o)=>{var s,i;const{topViewInstance:c,mainViewInstance:n}=t;if(!c)return;const{pointCloud2dOperation:d}=c;switch(e){case"q":{w(2);break}case"e":w(-2);break;case"g":w(180);break;case"u":{const p=d.pattern===EPolygonPattern.Normal?lbAnnotation.EToolName.Rect:lbAnnotation.EToolName.Polygon;j(p);const M={[lbAnnotation.EToolName.Polygon]:C("PolygonPattern"),[lbAnnotation.EToolName.Rect]:C("RectPattern")};antd.message.success(C("ChangePatternMsg",{pattern:M[p]})),d.clearActiveStatus(),d.clearDrawingStatus()}break;case"+":n==null||n.updatePointSize({zoomIn:!0});break;case"-":n==null||n.updatePointSize({zoomIn:!1});break;case"v":t.setPointCloudValid(!t.valid);break;case"tab":if(o.shiftKey){O();break}E(),o.preventDefault();break;case"f":L();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();break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const p=lbAnnotation.AttributeUtils.getAttributeByKeycode(o.keyCode,r.attributeList);p!==void 0&&((i=a.current)==null||i.setDefaultAttribute(p))}return}}},G=(e,o)=>{switch(e){case"c":I();break;case"v":T();break;case"a":o.preventDefault(),t.selectedAllBoxes();break;case"z":{o.shiftKey?h():x();break}}},V=e=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(e)||u===!0)return;const o=e.key.toLocaleLowerCase();if(e.ctrlKey){G(o,e);return}F(o,e)};return React.useEffect(()=>{const{topViewInstance:e}=t;if(!!e)return window.addEventListener("keydown",V),()=>{window.removeEventListener("keydown",V)}},[t,D,r,t.pointCloudBoxList,t.polygonList]),React.useEffect(()=>{z(r)},[B]),React.useEffect(()=>{(r==null?void 0:r.radius)&&R(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),React.useEffect(()=>{v==null||v()},[f,t.mainViewInstance]),React.useEffect(()=>{t.setHideAttributes([])},[f]),React.useEffect(()=>{a.current.setDefaultAttribute=e=>{var o,s,i,c;S(e);const n=t.selectedPointCloudBox;if(n){n.attribute=e;const d=U(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[n],stepConfig:r,action:"viewUpdateBox"}));n.valid=d[0].valid;const p=g(n);(i=(s=(o=t==null?void 0:t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:s.setPolygonValidAndRender)==null||i.call(s,n.id,!0,n.valid),t.mainViewInstance&&m({newSelectedBox:n,newPointCloudList:p})}if(k&&H(__spreadProps(__spreadValues({},k),{attribute:e})),_&&K(__spreadProps(__spreadValues({},_),{attribute:e})),P){const d=A(__spreadProps(__spreadValues({},P),{attribute:e}));t.mainViewInstance&&((c=t.mainViewInstance)==null||c.generateSpheres(d),m({newSelectedSphere:P,newSphereList:d}))}},a.current.setSubAttribute=(e,o)=>{var s;const i=t.selectedPointCloudBox;if(i){const c=(s=i==null?void 0:i.subAttribute)!=null?s:{};i.subAttribute=__spreadProps(__spreadValues({},c),{[e]:o}),g(i)}},a.current.clearResult=()=>{y==null||y()},a.current.redo=()=>{h()},a.current.undo=()=>{x()},a.current.setValid=e=>{a.current.valid=e,setTimeout(()=>{t.setPointCloudValid(e),e===!1&&y()})},a.current.setForbidOperation=e=>{var o,s;(s=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(e),e===!0&&t.setSelectedIDs(void 0)},a.current.setShowDefaultCursor=e=>{var o,s;(s=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(e)},a.current.asyncData=e=>{setTimeout(()=>{v==null||v(e)})}},[t.pointCloudBoxList,t.pointCloudSphereList,t.selectedID,t.valid,t.polygonList,t.lineList,t.mainViewInstance,t.ptSegmentInstance]),React.useEffect(()=>{a.current.updateSegmentTool=e=>{var o;(o=t.ptSegmentInstance)==null||o.emit(e)},a.current.segmentInstance=t.ptSegmentInstance},[t.ptSegmentInstance]),React.useEffect(()=>{a.current.history={pushHistory:e=>{N({pointCloudBoxList:e})},initRecord:()=>{}}},[]),React.useEffect(()=>{var e;const o=(e=t.topViewInstance)==null?void 0:e.toolInstance;if(!o||u)return;const s=n=>{S(n)},i=n=>{antd.message.error(n)},c=n=>{antd.message.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)}},[t.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 lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,e,i)=>e in o?__defProp(o,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[e]=i,__spreadValues=(o,e)=>{for(var i in e||(e={}))__hasOwnProp.call(e,i)&&__defNormalProp(o,i,e[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(e))__propIsEnum.call(e,i)&&__defNormalProp(o,i,e[i]);return o},__spreadProps=(o,e)=>__defProps(o,__getOwnPropDescs(e)),__async=(o,e,i)=>new Promise((l,t)=>{var a=c=>{try{d(i.next(c))}catch(g){t(g)}},P=c=>{try{d(i.throw(c))}catch(g){t(g)}},d=c=>c.done?l(c.value):Promise.resolve(c.value).then(a,P);d((i=i.apply(o,e)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(o,e,i,l,t)=>{const{x:a,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(o,e),{defaultZ:d}=lbUtils.DEFAULT_SPHERE_PARAMS,c={center:{x:a,y:P,z:d},id:o.id},g=l?__spreadValues(__spreadValues({},l),c):__spreadProps(__spreadValues({},c),{attribute:"",valid:!0});return t&&Object.assign(g,t),g},topViewPolygon2PointCloud=(o,e,i,l,t,a)=>{let P=o.pointList.map(f=>lbUtils.PointCloudUtils.transferCanvas2World(f,e)),d=0,c=1,g={};if(i){const f=i.getSensesPointZAxisInPolygon(P,void 0,a);a&&f.fittedCoordinates.length>0&&(P=f.fittedCoordinates),d=(f.maxZ+f.minZ)/2,c=f.maxZ-f.minZ,g={count:f.zCount}}const[h,m,T]=P,b=lbAnnotation.MathUtils.getLineCenterPoint([h,T]),D=lbAnnotation.MathUtils.getLineLength(h,m),I=lbAnnotation.MathUtils.getLineLength(m,T),O=lbAnnotation.MathUtils.getRadiusFromQuadrangle(o.pointList);l&&(d=l.center.z,c=l.depth);const _={center:{x:b.x,y:b.y,z:d},width:a?I+INTELLIGENT_FIT_MARGIN:I,height:a?D+INTELLIGENT_FIT_MARGIN:D,depth:c,rotation:O,id:o.id},k=__spreadValues(l?__spreadValues(__spreadValues({},l),_):__spreadProps(__spreadValues({},_),{attribute:"",valid:!0}),g);t&&Object.assign(k,t);const S=P.map(f=>lbUtils.PointCloudUtils.transferWorld2Canvas(f,e));return{boxParams:k,newPointList:S}},sideViewPoint2PointCloud=(o,e,i)=>{const l={x:o.x-e.x,y:o.y-e.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(o,e,i,l)=>{const[t,a,P]=o.pointList,[d,c,g]=e.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([t,P]),m=lbAnnotation.MathUtils.getLineCenterPoint([d,g]),b={x:{x:h.x-m.x,y:h.y-m.y}.x,y:0,z:h.y-m.y},D=lbAnnotation.MathUtils.getLineLength(t,a),I=lbAnnotation.MathUtils.getLineLength(d,c),O=D-I,_=lbAnnotation.MathUtils.getLineLength(a,P),k=lbAnnotation.MathUtils.getLineLength(c,g),S=_-k,{newBoxParams:f}=l.getNewBoxBySideUpdate(b,S,O,i);return f},backViewPoint2PointCloud=(o,e,i)=>{const l={x:o.x-e.x,y:o.y-e.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(o,e,i,l)=>{const[t,a,P]=o.pointList,[d,c,g]=e.pointList,h=lbAnnotation.MathUtils.getLineCenterPoint([t,P]),m=lbAnnotation.MathUtils.getLineCenterPoint([d,g]),b={x:{x:h.x-m.x,y:h.y-m.y}.x,y:0,z:h.y-m.y},D=lbAnnotation.MathUtils.getLineLength(t,a),I=lbAnnotation.MathUtils.getLineLength(d,c),O=D-I,_=lbAnnotation.MathUtils.getLineLength(a,P),k=lbAnnotation.MathUtils.getLineLength(c,g),S=_-k;let{newBoxParams:f}=l.getNewBoxByBackUpdate(b,S,O,i);return f},syncSideViewByPoint=(o,e,i,l,t)=>{var a;if(!i)return;const{toolInstance:P,pointCloudInstance:d}=i;d.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:c}=d.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(c);const{point2d:g,zoom:h}=d.getSphereSidePoint2DCoordinate(o);d.camera.zoom=h,d.camera.updateProjectionMatrix(),d.render(),P.initPosition(),P.zoomChangeOnCenter(h),P.setResult([__spreadProps(__spreadValues(__spreadValues({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(e.id)},synchronizeSideView=(o,e,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,o,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=a.updateOrthoCamera(o,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(P);const{polygon2d:d,zoom:c}=a.getBoxSidePolygon2DCoordinate(o);a.camera.zoom=c,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(c),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:d,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},syncBackViewByPoint=(o,e,i,l,t)=>{var a;if(!i)return;const{toolInstance:P,pointCloudInstance:d}=i;d.loadPCDFile(l,(a=t==null?void 0:t.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:c}=d.updateOrthoCameraBySphere(o,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(c);const{point2d:g,zoom:h}=d.getSphereBackPoint2DCoordinate(o);d.camera.zoom=h,d.camera.updateProjectionMatrix(),d.render(),P.initPosition(),P.zoomChangeOnCenter(h),P.setResult([__spreadProps(__spreadValues(__spreadValues({},e),g),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),P.setSelectedID(e.id)},synchronizeBackView=(o,e,i,l)=>{if(!i)return;const{pointCloud2dOperation:t,pointCloudInstance:a}=i;a.loadPCDFileByBox(l,o,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=a.updateOrthoCamera(o,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(P);const{polygon2d:d,zoom:c}=a.getBoxBackPolygon2DCoordinate(o);a.camera.zoom=c,a.camera.updateProjectionMatrix(),a.render(),t.initPosition(),t.zoomChangeOnCenter(c),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:d,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},syncTopViewByPoint=(o,e,i,l)=>{if(!i||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:t,pointCloudInstance:a}=i,{point2d:P}=a.getSphereTopPoint2DCoordinate(o),d=[...t.pointList].map(c=>c.id===e.id?__spreadProps(__spreadValues(__spreadValues({},e),P),{valid:o.valid,textAttribute:"",attribute:o.attribute}):c);t.setResult(d),t.setSelectedID(e.id)},synchronizeTopView=(o,e,i,l)=>{var t,a;if(!i||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:P,pointCloudInstance:d}=i,{polygon2d:c}=d.getBoxTopPolygon2DCoordinate(o),g=[...P.polygonList],h=g.find(m=>m.id===e.id);h?(h.pointList=c,h.valid=(t=o.valid)!=null?t:!0):g.push({id:e.id,pointList:c,textAttribute:"",isRect:!0,valid:(a=o.valid)!=null?a:!0}),P.setResultAndSelectedID(g,e.id)},usePointCloudViews=()=>{const o=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:e,sideViewInstance:i,backViewInstance:l,mainViewInstance:t,addPointCloudBox:a,addPointCloudSphere:P,setSelectedIDs:d,selectedIDs:c,pointCloudBoxList:g,pointCloudSphereList:h,hideAttributes:m,setHighlight2DDataList:T}=o,{addHistory:b,initHistory:D,pushHistoryUnderUpdatePolygon:I,pushHistoryUnderUpdateLine:O}=useHistory.useHistory(),{selectedPolygon:_}=usePolygon.usePolygon(),{updateSelectedBox:k,updateSelectedBoxes:S,getPointCloudByID:f}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:G,updatePointCloudSphere:H,selectedSphere:M}=useSphere.useSphere(),{currentData:z,config:L}=ctx.useSelector(n=>{const{stepList:s,step:p,imgList:u,imgIndex:r}=n.annotation;return{currentData:u[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,s).config)}}),A=ctx.useDispatch(),{selectedBox:w}=useSingleBox.useSingleBox(),{t:Q}=reactI18next.useTranslation(),F=w==null?void 0:w.info;if(!e||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:N}=e,X=n=>{t==null||t.generateBox(n),t==null||t.controls.update(),t==null||t.render()},Y=n=>{t==null||t.generateSphere(n),t==null||t.controls.update(),t==null||t.render()},J=({newPoint:n,size:s,zoom:p,trackConfigurable:u})=>{var r;const C={attribute:(r=e.toolInstance.defaultAttribute)!=null?r:""};u===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const x=topViewPoint2PointCloud(n,s,N,void 0,C);d(n.id);const y=P(x);E(PointCloudView.Top,n,x,p,y,L),b({newSphereParams:x})},K=({polygon:n,size:s,imgList:p,trackConfigurable:u,zoom:r,intelligentFit:C})=>{var x,y;const v={attribute:(x=e.toolInstance.defaultAttribute)!=null?x:""};u===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:g,extraSphereList:h})});const U=e==null?void 0:e.toolInstance,V=__spreadValues({},n);let{boxParams:B,newPointList:R}=topViewPolygon2PointCloud(V,s,N,void 0,v,C);if(B=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[B],stepConfig:L,action:"viewUpdateBox"}))[0],(L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(Q("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),U.deletePolygon(B.id);return}C&&(R==null?void 0:R.length)&&(V.pointList=R);const at=m.includes(V.attribute),q=a(B),dt=(y=o==null?void 0:o.polygonList)!=null?y:[];e==null||e.updatePolygonList(q!=null?q:[],dt),at?d([]):(d(B.id),U.selection.setSelectedIDs(V.id),j({omitView:PointCloudView.Top,polygon:V,boxParams:B,zoom:r,newPointCloudBoxList:q}),C&&synchronizeTopView(B,V,e,t)),b({newBoxParams:B})},$=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:u})=>{var r;const C=e==null?void 0:e.toolInstance;if(!(c.length===0||!C)){if(n||(w==null?void 0:w.info)){const x=n!=null?n:w==null?void 0:w.info;(r=C==null?void 0:C.selection)==null||r.setSelectedIDs(c[0]);const y=C.selectedPolygon;if(c.length===1&&x){j({omitView:PointCloudView.Top,polygon:y,boxParams:x,newPointCloudBoxList:s});return}}if((p||M)&&c.length===1){const x=p!=null?p:M;C.setSelectedID(c[0]);const y=C.selectedPoint;x&&E(PointCloudView.Top,y,x,void 0,u,L)}}},Z=(n,s,p)=>{if(F){let u,r;switch(p){case PointCloudView.Back:u=backViewPolygon2PointCloud;break;case PointCloudView.Side:u=sideViewPolygon2PointCloud;break;default:u=sideViewPolygon2PointCloud;break}r=u(n,s,F,i.pointCloudInstance);const x=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:L,action:"viewUpdateBox"}))[0],y=r.valid!==x.valid;if(r=x,t){const{count:U}=t.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:U})}const v=k(r);return r=v.find(U=>U.id===r.id),j({omitView:y?void 0:p,polygon:n,boxParams:r,newPointCloudBoxList:v}),v}},W=(n,s,p)=>{if(M){let u,r;switch(p){case PointCloudView.Back:u=backViewPoint2PointCloud;break;case PointCloudView.Side:u=sideViewPoint2PointCloud;break;default:u=sideViewPoint2PointCloud;break}r=u(n,s,M);const C=H(r);return E(p,n,r,void 0,C,L),C}},tt=(n,s)=>{W(n,s,PointCloudView.Side)},ot=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},it=(n,s)=>{Z(n,s,PointCloudView.Back)},nt=(n,s)=>{O(n)},st=(n,s)=>{const p=G(n.id),u=topViewPoint2PointCloud(n,s,N,p),r=H(u);E(PointCloudView.Top,n,u,void 0,r,L)},rt=(n,s)=>{if(_){const u=n[0].newPolygon;u.pointList=u.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,s)),I(n[0].newPolygon);return}let p=n.map(({newPolygon:u})=>{const r=f(u.id),{boxParams:C}=topViewPolygon2PointCloud(u,s,e.pointCloudInstance,r);return C});if(p=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:p,stepConfig:L,action:"viewUpdateBox"})),p.length===1){const{newPolygon:u}=n[0],r=S(p);j({omitView:PointCloudView.Top,polygon:u,boxParams:p[0],newPointCloudBoxList:r})}else{const u=S(p);u&&o.syncAllViewPointCloudColor(u)}},lt=n=>{var s;if(w){const p=w==null?void 0:w.info.trackID,r=((s=e==null?void 0:e.toolInstance)==null?void 0:s.polygonList).find(y=>(y==null?void 0:y.trackID)===p),C=__spreadProps(__spreadValues({},w.info),{width:Number(n.widthDefault),depth:Number(n.depthDefault),height:Number(n.heightDefault)}),x=S([C]);j({omitView:PointCloudView["3D"],polygon:r,boxParams:C,newPointCloudBoxList:x})}},E=(n,s,p,u,r,C)=>__async(void 0,null,function*(){const x=z==null?void 0:z.url,y={[PointCloudView.Side]:()=>{syncSideViewByPoint(p,s,i,x,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(p,s,l,x,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(p,s,e,t)}};Object.keys(y).forEach(v=>{v!==n&&y[v]()}),u&&(t==null||t.updateCameraZoom(u)),Y(p)}),j=n=>__async(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:u,zoom:r,newPointCloudBoxList:C}=n,x=z==null?void 0:z.url;C&&(yield o.syncAllViewPointCloudColor(C));const y={[PointCloudView.Side]:()=>{synchronizeSideView(u,p,i,x)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(u,p,l,x)},[PointCloudView.Top]:()=>{synchronizeTopView(u,p,e,t)}};Object.keys(y).forEach(v=>{v!==s&&y[v]()}),r&&(t==null||t.updateCameraZoom(r)),X(u)});return{topViewAddSphere:J,topViewAddBox:K,topViewSelectedChanged:$,topViewUpdatePoint:st,sideViewUpdatePoint:tt,backViewUpdatePoint:ot,topViewUpdateBox:rt,topViewUpdateLine:nt,sideViewUpdateBox:et,backViewUpdateBox:it,pointCloudBoxListUpdated:n=>{e.updatePolygonList(n),t==null||t.generateBoxes(n)},initPointCloud3d:n=>{if(!t)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=z){var p,u,r,C,x,y;if(!(s==null?void 0:s.url)||!t)return;T([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield t.loadPCDFile(s.url,(p=L==null?void 0:L.radius)!=null?p:DEFAULT_RADIUS),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let v=[],U=[],V=[],B=[];t.updateTopCamera();const R=(r=(u=index.jsonParser(s.result))==null?void 0:u.valid)!=null?r:!0;o.setPointCloudValid(R),(C=o.sideViewInstance)==null||C.clearAllData(),(x=o.backViewInstance)==null||x.clearAllData(),e.updateData(s.url,s.result,{radius:(y=L==null?void 0:L.radius)!=null?y:DEFAULT_RADIUS}),s.result&&(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),V=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),U=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(v),t==null||t.generateSpheres(B),yield o.syncAllViewPointCloudColor(v,[])),D({pointCloudBoxList:v,polygonList:V,lineList:U,pointCloudSphereList:B}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:lt}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),antd=require("antd"),reactI18next=require("react-i18next"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,i)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,__spreadValues=(e,t)=>{for(var i in t||(t={}))__hasOwnProp.call(t,i)&&__defNormalProp(e,i,t[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(t))__propIsEnum.call(t,i)&&__defNormalProp(e,i,t[i]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,i)=>new Promise((a,o)=>{var d=u=>{try{c(i.next(u))}catch(h){o(h)}},P=u=>{try{c(i.throw(u))}catch(h){o(h)}},c=u=>u.done?a(u.value):Promise.resolve(u.value).then(d,P);c((i=i.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,i,a,o)=>{const{x:d,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,u={center:{x:d,y:P,z:c},id:e.id},h=a?__spreadValues(__spreadValues({},a),u):__spreadProps(__spreadValues({},u),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},topViewPolygon2PointCloud=(e,t,i,a,o,d)=>{let P=e.pointList.map(y=>lbUtils.PointCloudUtils.transferCanvas2World(y,t)),c=0,u=1,h={};if(i){const y=i.getSensesPointZAxisInPolygon(P,void 0,d);d&&y.fittedCoordinates.length>0&&(P=y.fittedCoordinates),c=(y.maxZ+y.minZ)/2,u=y.maxZ-y.minZ,h={count:y.zCount}}const[f,B,T]=P,U=lbAnnotation.MathUtils.getLineCenterPoint([f,T]),D=lbAnnotation.MathUtils.getLineLength(f,B),V=lbAnnotation.MathUtils.getLineLength(B,T),O=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(c=a.center.z,u=a.depth);const _={center:{x:U.x,y:U.y,z:c},width:d?V+INTELLIGENT_FIT_MARGIN:V,height:d?D+INTELLIGENT_FIT_MARGIN:D,depth:u,rotation:O,id:e.id},k=__spreadValues(a?__spreadValues(__spreadValues({},a),_):__spreadProps(__spreadValues({},_),{attribute:"",valid:!0}),h);o&&Object.assign(k,o);const I=P.map(y=>lbUtils.PointCloudUtils.transferWorld2Canvas(y,t));return{boxParams:k,newPointList:I}},sideViewPoint2PointCloud=(e,t,i)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-a.x,y:i.center.y,z:i.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,i,a)=>{const[o,d,P]=e.pointList,[c,u,h]=t.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),B=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),U={x:{x:f.x-B.x,y:f.y-B.y}.x,y:0,z:f.y-B.y},D=lbAnnotation.MathUtils.getLineLength(o,d),V=lbAnnotation.MathUtils.getLineLength(c,u),O=D-V,_=lbAnnotation.MathUtils.getLineLength(d,P),k=lbAnnotation.MathUtils.getLineLength(u,h),I=_-k,{newBoxParams:y}=a.getNewBoxBySideUpdate(U,I,O,i);return y},backViewPoint2PointCloud=(e,t,i)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-a.x,z:i.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,i,a)=>{const[o,d,P]=e.pointList,[c,u,h]=t.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),B=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),U={x:{x:f.x-B.x,y:f.y-B.y}.x,y:0,z:f.y-B.y},D=lbAnnotation.MathUtils.getLineLength(o,d),V=lbAnnotation.MathUtils.getLineLength(c,u),O=D-V,_=lbAnnotation.MathUtils.getLineLength(d,P),k=lbAnnotation.MathUtils.getLineLength(u,h),I=_-k;let{newBoxParams:y}=a.getNewBoxByBackUpdate(U,I,O,i);return y},syncSideViewByPoint=(e,t,i,a,o)=>{var d;if(!i)return;const{toolInstance:P,pointCloudInstance:c}=i;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(u);const{point2d:h,zoom:f}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,i,a)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=i;d.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxSidePolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,i,a,o)=>{var d;if(!i)return;const{toolInstance:P,pointCloudInstance:c}=i;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(u);const{point2d:h,zoom:f}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=f,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(f),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,i,a)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=i;d.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxBackPolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,i,a)=>{if(!i||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:d}=i,{point2d:P}=d.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},synchronizeTopView=(e,t,i,a)=>{var o,d;if(!i||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=i,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),h=[...P.polygonList],f=h.find(B=>B.id===t.id);f?(f.pointList=u,f.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(d=e.valid)!=null?d:!0}),P.setResultAndSelectedID(h,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:i,backViewInstance:a,mainViewInstance:o,addPointCloudBox:d,addPointCloudSphere:P,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:h,pointCloudSphereList:f,hideAttributes:B,setHighlight2DDataList:T}=e,{addHistory:U,initHistory:D,pushHistoryUnderUpdatePolygon:V,pushHistoryUnderUpdateLine:O}=useHistory.useHistory(),{selectedPolygon:_}=usePolygon.usePolygon(),{updateSelectedBox:k,updateSelectedBoxes:I,getPointCloudByID:y}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:$,updatePointCloudSphere:Z,selectedSphere:E}=useSphere.useSphere(),{currentData:j,config:m}=ctx.useSelector(n=>{const{stepList:s,step:p,imgList:l,imgIndex:r}=n.annotation;return{currentData:l[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,s).config)}}),A=ctx.useDispatch(),{selectedBox:w}=useSingleBox.useSingleBox(),{t:tt}=reactI18next.useTranslation(),G=w==null?void 0:w.info;if(!t||!i||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:F}=t,ot=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},et=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},it=({newPoint:n,size:s,zoom:p,trackConfigurable:l})=>{var r;const C={attribute:(r=t.toolInstance.defaultAttribute)!=null?r:""};l===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:f})});const g=topViewPoint2PointCloud(n,s,F,void 0,C);c(n.id);const x=P(g);N(PointCloudView.Top,n,g,p,x,m),U({newSphereParams:g})},nt=({polygon:n,size:s,imgList:p,trackConfigurable:l,zoom:r,intelligentFit:C})=>{var g,x;const v={attribute:(g=t.toolInstance.defaultAttribute)!=null?g:""};l===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:f})});const b=t==null?void 0:t.toolInstance,S=__spreadValues({},n);let{boxParams:L,newPointList:z}=topViewPolygon2PointCloud(S,s,F,void 0,v,C);if(L=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[L],stepConfig:m,action:"viewUpdateBox"}))[0],(m==null?void 0:m.lowerLimitPointsNumInBox)&&typeof L.count=="number"&&L.count<m.lowerLimitPointsNumInBox){antd.message.info(tt("LowerLimitPointsNumInBox",{num:m.lowerLimitPointsNumInBox})),b.deletePolygon(L.id);return}C&&(z==null?void 0:z.length)&&(S.pointList=z);const q=B.includes(S.attribute),R=d(L),W=(x=e==null?void 0:e.polygonList)!=null?x:[];t==null||t.updatePolygonList(R!=null?R:[],W),q?c([]):(c(L.id),b.selection.setSelectedIDs(S.id),M({omitView:PointCloudView.Top,polygon:S,boxParams:L,zoom:r,newPointCloudBoxList:R}),C&&synchronizeTopView(L,S,t,o)),U({newBoxParams:L})},st=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:l})=>{var r;const C=t==null?void 0:t.toolInstance;if(!(u.length===0||!C)){if(n||(w==null?void 0:w.info)){const g=n!=null?n:w==null?void 0:w.info;(r=C==null?void 0:C.selection)==null||r.setSelectedIDs(u[0]);const x=C.selectedPolygon;if(u.length===1&&g){M({omitView:PointCloudView.Top,polygon:x,boxParams:g,newPointCloudBoxList:s});return}}if((p||E)&&u.length===1){const g=p!=null?p:E;C.setSelectedID(u[0]);const x=C.selectedPoint;g&&N(PointCloudView.Top,x,g,void 0,l,m)}}},Q=(n,s,p)=>{if(G){let l,r;switch(p){case PointCloudView.Back:l=backViewPolygon2PointCloud;break;case PointCloudView.Side:l=sideViewPolygon2PointCloud;break;default:l=sideViewPolygon2PointCloud;break}r=l(n,s,G,i.pointCloudInstance);const g=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:m,action:"viewUpdateBox"}))[0],x=r.valid!==g.valid;if(r=g,o){const{count:b}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:b})}const v=k(r);return r=v.find(b=>b.id===r.id),M({omitView:x?void 0:p,polygon:n,boxParams:r,newPointCloudBoxList:v}),v}},X=(n,s,p)=>{if(E){let l,r;switch(p){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}r=l(n,s,E);const C=Z(r);return N(p,n,r,void 0,C,m),C}},rt=(n,s)=>{X(n,s,PointCloudView.Side)},lt=(n,s)=>{X(n,s,PointCloudView.Back)},at=(n,s)=>{Q(n,s,PointCloudView.Side)},dt=(n,s)=>{Q(n,s,PointCloudView.Back)},ct=(n,s)=>{O(n)},ut=(n,s)=>{const p=$(n.id),l=topViewPoint2PointCloud(n,s,F,p),r=Z(l);N(PointCloudView.Top,n,l,void 0,r,m)},pt=(n,s)=>{if(_){const l=n[0].newPolygon;l.pointList=l.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,s)),V(n[0].newPolygon);return}let p=n.map(({newPolygon:l})=>{const r=y(l.id),{boxParams:C}=topViewPolygon2PointCloud(l,s,t.pointCloudInstance,r);return C});if(p=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:p,stepConfig:m,action:"viewUpdateBox"})),p.length===1){const{newPolygon:l}=n[0],r=I(p);M({polygon:l,boxParams:p[0],newPointCloudBoxList:r})}else{const l=I(p);l&&e.syncAllViewPointCloudColor(l)}},Pt=n=>{var s,p,l,r,C;if(w){const g=Number(n.widthDefault),x=Number(n.depthDefault),v=Number(n.heightDefault),b=w==null?void 0:w.info.trackID,L=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(H=>(H==null?void 0:H.trackID)===b),z={width:(l=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:l.width,height:(C=(r=t==null?void 0:t.toolInstance)==null?void 0:r.basicImgInfo)==null?void 0:C.height},Y=L.pointList.map(H=>lbUtils.PointCloudUtils.transferCanvas2World(H,z)),q=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(Y,v,g),R=q[0],W=q[2],J=lbAnnotation.MathUtils.getLineCenterPoint([R,W]),Ct=w.info.center.z-w.info.depth/2,K=__spreadProps(__spreadValues({},w.info),{center:{x:J.x,y:J.y,z:Ct+x/2},width:g,height:v,depth:x,valid:!0}),gt=I([K]);M({omitView:PointCloudView["3D"],polygon:L,boxParams:K,newPointCloudBoxList:gt})}},N=(n,s,p,l,r,C)=>__async(void 0,null,function*(){const g=j==null?void 0:j.url,x={[PointCloudView.Side]:()=>{syncSideViewByPoint(p,s,i,g,C)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(p,s,a,g,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(p,s,t,o)}};Object.keys(x).forEach(v=>{v!==n&&x[v]()}),l&&(o==null||o.updateCameraZoom(l)),et(p)}),M=n=>__async(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:l,zoom:r,newPointCloudBoxList:C}=n,g=j==null?void 0:j.url;C&&(yield e.syncAllViewPointCloudColor(C));const x={[PointCloudView.Side]:()=>{synchronizeSideView(l,p,i,g)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(l,p,a,g)},[PointCloudView.Top]:()=>{synchronizeTopView(l,p,t,o)}};Object.keys(x).forEach(v=>{v!==s&&x[v]()}),r&&(o==null||o.updateCameraZoom(r)),ot(l)});return{topViewAddSphere:it,topViewAddBox:nt,topViewSelectedChanged:st,topViewUpdatePoint:ut,sideViewUpdatePoint:rt,backViewUpdatePoint:lt,topViewUpdateBox:pt,topViewUpdateLine:ct,sideViewUpdateBox:at,backViewUpdateBox:dt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=j){var p,l,r,C,g,x;if(!(s==null?void 0:s.url)||!o)return;T([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield o.loadPCDFile(s.url,(p=m==null?void 0:m.radius)!=null?p:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],b=[],S=[],L=[];o.updateTopCamera();const z=(r=(l=index.jsonParser(s.result))==null?void 0:l.valid)!=null?r:!0;e.setPointCloudValid(z),(C=e.sideViewInstance)==null||C.clearAllData(),(g=e.backViewInstance)==null||g.clearAllData(),t.updateData(s.url,s.result,{radius:(x=m==null?void 0:m.radius)!=null?x:DEFAULT_RADIUS}),s.result&&(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),S=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),b=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),L=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),o==null||o.generateBoxes(v),o==null||o.generateSpheres(L),yield e.syncAllViewPointCloudColor(v,[])),D({pointCloudBoxList:v,polygonList:S,lineList:b,pointCloudSphereList:L}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:Pt}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var PointCloudContext=require("../../../../components/pointCloudView/PointCloudContext.js"),antd=require("antd"),React=require("react"),selectors=require("../../../../store/annotation/selectors.js"),ctx=require("../../../../store/ctx.js"),lbUtils=require("@labelbee/lb-utils"),icons=require("@ant-design/icons"),useHistory=require("../../../../components/pointCloudView/hooks/useHistory.js"),dom=require("../../../../utils/dom.js"),StepUtils=require("../../../../utils/StepUtils.js"),lbAnnotation=require("@labelbee/lb-annotation"),reactI18next=require("react-i18next"),FooterPopover=require("../FooterPopover.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,n,t)=>n in e?__defProp(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,__spreadValues=(e,n)=>{for(var t in n||(n={}))__hasOwnProp.call(n,t)&&__defNormalProp(e,t,n[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(n))__propIsEnum.call(n,t)&&__defNormalProp(e,t,n[t]);return e},__spreadProps=(e,n)=>__defProps(e,__getOwnPropDescs(n));const AnnotatedAttributesItem=({attribute:e})=>{const n=React.useContext(PointCloudContext.PointCloudContext),{pointCloudBoxList:t,pointCloudSphereList:r,hideAttributes:u,toggleAttributesVisible:d,polygonList:c,setPolygonList:p,lineList:i,setLineList:m,setPointCloudResult:f,setPointCloudSphereList:s,reRender:E,selectSpecAttr:A,segmentation:y,setSegmentation:h}=n,[C,_]=React.useState(!0),{pushHistoryWithList:N}=useHistory.useHistory(),L=[...t,...c,...r,...i,...y].filter(l=>l.attribute===e.value),b=()=>{d(e.value)},O=u.includes(e.value),S=({trackID:l,order:o})=>l||o,F=({trackID:l,order:o})=>l?`trackID_${l}`:`order_${o}`,w=l=>{if(L.length===0)return;const o=c.filter(a=>l!==a.attribute),g=t.filter(a=>l!==a.attribute),v=i.filter(a=>l!==a.attribute),P=r.filter(a=>l!==a.attribute),x=y.filter(a=>l!==a.attribute);E(g,o,P,v,x),p(o),f(g),s(P),m(v),h(x),N({pointCloudBoxList:g,polygonList:o,lineList:v,pointCloudSphereList:P,segmentation:x})},j=l=>{antd.Modal.confirm({content:lbUtils.i18n.t("onDeleteGraphByAttr",{attribute:l.key}),onOk:()=>{w(l.value)},okText:lbUtils.i18n.t("Confirm"),cancelText:lbUtils.i18n.t("Cancel")})};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement("div",{className:dom.getClassName("annotated-attribute","item")},O?React__default.default.createElement(icons.EyeInvisibleFilled,{onClick:b}):React__default.default.createElement(icons.EyeFilled,{onClick:b}),React__default.default.createElement(icons.CaretDownFilled,{rotate:C?0:270,onClick:()=>{_(!C)}}),React__default.default.createElement("span",{className:dom.getClassName("annotated-attribute","item","text"),onClick:()=>{A(e.value)}},e.key),React__default.default.createElement(icons.DeleteOutlined,{onClick:()=>j(e)})),C&&L.map((l,o)=>React__default.default.createElement("div",{key:F(__spreadProps(__spreadValues({},l),{order:o})),style:{paddingLeft:54}},`${S(__spreadProps(__spreadValues({},l),{order:o}))}.${e.key}`)))},AnnotatedAttributesPanel=()=>{const e=ctx.useSelector(selectors.stepConfigSelector),{attrPanelLayout:n,setAttrPanelLayout:t,pointCloudBoxList:r,pointCloudSphereList:u,polygonList:d,lineList:c,segmentation:p}=React.useContext(PointCloudContext.PointCloudContext),{t:i}=reactI18next.useTranslation(),m=React.useMemo(()=>[...r,...u,...d,...c,...p].map(s=>s.attribute),[r,u,d,c,p]),f=React.useMemo(()=>e.attributeList.filter(s=>m.includes(s.value)),[m]);return React__default.default.createElement("div",{className:dom.getClassName("annotated-attribute")},n?React__default.default.createElement("div",{className:dom.getClassName("annotated-attribute","text")},React__default.default.createElement("span",null,i("AnnotatedResult")),React__default.default.createElement("span",{className:dom.getClassName("annotated-attribute","pin"),onClick:()=>{t("")}},React__default.default.createElement(icons.PushpinFilled,null),i("CancelFixed"))):React__default.default.createElement("div",{className:dom.getClassName("annotated-attribute","text")},React__default.default.createElement("span",{onClick:()=>{t("left")},className:dom.getClassName("annotated-attribute","pin")},React__default.default.createElement(icons.PushpinFilled,null),i("FixedOnLeft")),React__default.default.createElement("span",{onClick:()=>{t("right")},className:dom.getClassName("annotated-attribute","pin")},React__default.default.createElement(icons.PushpinFilled,null),i("FixedOnRight"))),React__default.default.createElement("div",null,f.length>0?f.map(s=>React__default.default.createElement(AnnotatedAttributesItem,{attribute:s,key:s.value})):React__default.default.createElement("div",{style:{textAlign:"center",height:200,lineHeight:"200px"}},i("NoData"))))},AnnotatedAttributesPanelFixedLeft=()=>{const{attrPanelLayout:e}=React.useContext(PointCloudContext.PointCloudContext);return e==="left"?React__default.default.createElement(AnnotatedAttributesPanel,null):null},AnnotatedAttributesPanelFixedRight=()=>{const{attrPanelLayout:e}=React.useContext(PointCloudContext.PointCloudContext);return e==="right"?React__default.default.createElement(AnnotatedAttributesPanel,null):null},AnnotatedAttributesIcon=()=>{const{attrPanelLayout:e}=React.useContext(PointCloudContext.PointCloudContext),{t:n}=reactI18next.useTranslation(),t=ctx.useSelector(r=>{var u,d;return StepUtils.getCurrentStepInfo((u=r==null?void 0:r.annotation)==null?void 0:u.step,(d=r.annotation)==null?void 0:d.stepList)});return(t==null?void 0:t.tool)!==lbAnnotation.EPointCloudName.PointCloud||e?null:React__default.default.createElement(FooterPopover,{hoverIcon:React__default.default.createElement(icons.UnorderedListOutlined,{style:{marginRight:4}}),icon:React__default.default.createElement(icons.UnorderedListOutlined,{style:{marginRight:4}}),title:n("AnnotatedList"),content:React__default.default.createElement(AnnotatedAttributesPanel,null)})};exports.AnnotatedAttributesIcon=AnnotatedAttributesIcon,exports.AnnotatedAttributesPanel=AnnotatedAttributesPanel,exports.AnnotatedAttributesPanelFixedLeft=AnnotatedAttributesPanelFixedLeft,exports.AnnotatedAttributesPanelFixedRight=AnnotatedAttributesPanelFixedRight;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var PointCloudContext=require("../../../../components/pointCloudView/PointCloudContext.js"),antd=require("antd"),React=require("react"),selectors=require("../../../../store/annotation/selectors.js"),ctx=require("../../../../store/ctx.js"),lbUtils=require("@labelbee/lb-utils"),icons=require("@ant-design/icons"),useHistory=require("../../../../components/pointCloudView/hooks/useHistory.js"),dom=require("../../../../utils/dom.js"),StepUtils=require("../../../../utils/StepUtils.js"),lbAnnotation=require("@labelbee/lb-annotation"),reactI18next=require("react-i18next"),FooterPopover=require("../FooterPopover.js"),index=require("../../../../components/longText/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,n,t)=>n in e?__defProp(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,__spreadValues=(e,n)=>{for(var t in n||(n={}))__hasOwnProp.call(n,t)&&__defNormalProp(e,t,n[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(n))__propIsEnum.call(n,t)&&__defNormalProp(e,t,n[t]);return e},__spreadProps=(e,n)=>__defProps(e,__getOwnPropDescs(n));const AnnotatedAttributesItem=({attribute:e})=>{const n=React.useContext(PointCloudContext.PointCloudContext),{pointCloudBoxList:t,pointCloudSphereList:r,hideAttributes:u,toggleAttributesVisible:d,polygonList:c,setPolygonList:p,lineList:i,setLineList:m,setPointCloudResult:f,setPointCloudSphereList:s,reRender:E,selectSpecAttr:h,segmentation:y,setSegmentation:A}=n,[C,_]=React.useState(!0),{pushHistoryWithList:N}=useHistory.useHistory(),L=[...t,...c,...r,...i,...y].filter(l=>l.attribute===e.value),b=()=>{d(e.value)},O=u.includes(e.value),S=({trackID:l,order:o})=>l||o,w=({trackID:l,order:o})=>l?`trackID_${l}`:`order_${o}`,F=l=>{if(L.length===0)return;const o=c.filter(a=>l!==a.attribute),g=t.filter(a=>l!==a.attribute),v=i.filter(a=>l!==a.attribute),x=r.filter(a=>l!==a.attribute),P=y.filter(a=>l!==a.attribute);E(g,o,x,v,P),p(o),f(g),s(x),m(v),A(P),N({pointCloudBoxList:g,polygonList:o,lineList:v,pointCloudSphereList:x,segmentation:P})},j=l=>{antd.Modal.confirm({content:lbUtils.i18n.t("onDeleteGraphByAttr",{attribute:l.key}),onOk:()=>{F(l.value)},okText:lbUtils.i18n.t("Confirm"),cancelText:lbUtils.i18n.t("Cancel")})};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement("div",{className:dom.getClassName("annotated-attribute","item")},O?React__default.default.createElement(icons.EyeInvisibleFilled,{onClick:b}):React__default.default.createElement(icons.EyeFilled,{onClick:b}),React__default.default.createElement(icons.CaretDownFilled,{rotate:C?0:270,onClick:()=>{_(!C)}}),React__default.default.createElement("span",{className:dom.getClassName("annotated-attribute","item","text"),style:{width:"100%",overflow:"hidden"},onClick:()=>{h(e.value)}},React__default.default.createElement(index,{text:e.key,openByText:!0})),React__default.default.createElement(icons.DeleteOutlined,{onClick:()=>j(e)})),C&&L.map((l,o)=>React__default.default.createElement("div",{key:w(__spreadProps(__spreadValues({},l),{order:o})),style:{paddingLeft:54}},`${S(__spreadProps(__spreadValues({},l),{order:o}))}.${e.key}`)))},AnnotatedAttributesPanel=()=>{const e=ctx.useSelector(selectors.stepConfigSelector),{attrPanelLayout:n,setAttrPanelLayout:t,pointCloudBoxList:r,pointCloudSphereList:u,polygonList:d,lineList:c,segmentation:p}=React.useContext(PointCloudContext.PointCloudContext),{t:i}=reactI18next.useTranslation(),m=React.useMemo(()=>[...r,...u,...d,...c,...p].map(s=>s.attribute),[r,u,d,c,p]),f=React.useMemo(()=>e.attributeList.filter(s=>m.includes(s.value)),[m]);return React__default.default.createElement("div",{className:dom.getClassName("annotated-attribute")},n?React__default.default.createElement("div",{className:dom.getClassName("annotated-attribute","text")},React__default.default.createElement("span",null,i("AnnotatedResult")),React__default.default.createElement("span",{className:dom.getClassName("annotated-attribute","pin"),onClick:()=>{t("")}},React__default.default.createElement(icons.PushpinFilled,null),i("CancelFixed"))):React__default.default.createElement("div",{className:dom.getClassName("annotated-attribute","text")},React__default.default.createElement("span",{onClick:()=>{t("left")},className:dom.getClassName("annotated-attribute","pin")},React__default.default.createElement(icons.PushpinFilled,null),i("FixedOnLeft")),React__default.default.createElement("span",{onClick:()=>{t("right")},className:dom.getClassName("annotated-attribute","pin")},React__default.default.createElement(icons.PushpinFilled,null),i("FixedOnRight"))),React__default.default.createElement("div",null,f.length>0?f.map(s=>React__default.default.createElement(AnnotatedAttributesItem,{attribute:s,key:s.value})):React__default.default.createElement("div",{style:{textAlign:"center",height:200,lineHeight:"200px"}},i("NoData"))))},AnnotatedAttributesPanelFixedLeft=()=>{const{attrPanelLayout:e}=React.useContext(PointCloudContext.PointCloudContext);return e==="left"?React__default.default.createElement(AnnotatedAttributesPanel,null):null},AnnotatedAttributesPanelFixedRight=()=>{const{attrPanelLayout:e}=React.useContext(PointCloudContext.PointCloudContext);return e==="right"?React__default.default.createElement(AnnotatedAttributesPanel,null):null},AnnotatedAttributesIcon=()=>{const{attrPanelLayout:e}=React.useContext(PointCloudContext.PointCloudContext),{t:n}=reactI18next.useTranslation(),t=ctx.useSelector(r=>{var u,d;return StepUtils.getCurrentStepInfo((u=r==null?void 0:r.annotation)==null?void 0:u.step,(d=r.annotation)==null?void 0:d.stepList)});return(t==null?void 0:t.tool)!==lbAnnotation.EPointCloudName.PointCloud||e?null:React__default.default.createElement(FooterPopover,{hoverIcon:React__default.default.createElement(icons.UnorderedListOutlined,{style:{marginRight:4}}),icon:React__default.default.createElement(icons.UnorderedListOutlined,{style:{marginRight:4}}),title:n("AnnotatedList"),content:React__default.default.createElement(AnnotatedAttributesPanel,null)})};exports.AnnotatedAttributesIcon=AnnotatedAttributesIcon,exports.AnnotatedAttributesPanel=AnnotatedAttributesPanel,exports.AnnotatedAttributesPanelFixedLeft=AnnotatedAttributesPanelFixedLeft,exports.AnnotatedAttributesPanelFixedRight=AnnotatedAttributesPanelFixedRight;
@@ -1 +1 @@
1
- import{PointCloudContext as R}from"./PointCloudContext.js";import{useRotate as ee}from"./hooks/useRotate.js";import{useBoxes as te}from"./hooks/useBoxes.js";import{useSingleBox as oe}from"./hooks/useSingleBox.js";import{useSphere as re}from"./hooks/useSphere.js";import{useContext as se,useEffect as c}from"react";import{CommonToolUtils as ne,AttributeUtils as ie,EToolName as f,cTool as ae}from"@labelbee/lb-annotation";import{message as S}from"antd";import{connect as ue}from"react-redux";import{a2MapStateToProps as le}from"../../store/annotation/map.js";import{useStatus as ce}from"./hooks/useStatus.js";import{usePointCloudViews as de}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as pe}from"../../store/ctx.js";import{useHistory as me}from"./hooks/useHistory.js";import{useAttribute as be}from"./hooks/useAttribute.js";import{useConfig as fe}from"./hooks/useConfig.js";import{usePolygon as ve}from"./hooks/usePolygon.js";import{useLine as ye}from"./hooks/useLine.js";import{useTranslation as Pe}from"react-i18next";var we=Object.defineProperty,Ce=Object.defineProperties,he=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,ge=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable,D=(u,r,a)=>r in u?we(u,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):u[r]=a,v=(u,r)=>{for(var a in r||(r={}))ge.call(r,a)&&D(u,a,r[a]);if(I)for(var a of I(r))Se.call(r,a)&&D(u,a,r[a]);return u},y=(u,r)=>Ce(u,he(r));const{EPolygonPattern:ke}=ae,xe=({currentData:u,config:r,checkMode:a,configString:T,imgIndex:k,toolInstanceRef:i})=>{const o=se(R),{changeSelectedBoxValid:E,selectNextBox:H,selectPrevBox:K,updateSelectedBox:x,deleteSelectedPointCloudBoxAndPolygon:N}=oe(),{selectedSphere:P,updatePointCloudSphere:U}=re(),{clearAllResult:w,updatePointCloudPattern:z}=ce(),{copySelectedBoxes:F,pasteSelectedBoxes:q,copiedBoxes:G}=te({config:r}),{updateRotate:C}=ee({currentData:u}),{updatePointCloudData:m,topViewSelectedChanged:_}=de(),{redo:L,undo:V,pushHistoryWithList:M,pushHistoryUnderUpdatePolygon:W,pushHistoryUnderUpdateLine:Y}=me(),{syncThreeViewsAttribute:B}=be(),{syncAllViewsConfig:$,reRenderTopViewRange:J}=fe(),{selectedPolygon:O}=ve(),{selectedLine:j}=ye(),{t:h}=Pe(),b=e=>{var t;const{topViewInstance:s}=o;!s||(t=s.pointCloud2dOperation)==null||t.updateSelectedPolygonsPoints(e)},Q=(e,t)=>{var s,n;const{topViewInstance:d,mainViewInstance:l}=o;if(!d)return;const{pointCloud2dOperation:g}=d;switch(e){case"q":{C(2);break}case"e":C(-2);break;case"g":C(180);break;case"u":{const p=g.pattern===ke.Normal?f.Rect:f.Polygon;z(p);const Z={[f.Polygon]:h("PolygonPattern"),[f.Rect]:h("RectPattern")};S.success(h("ChangePatternMsg",{pattern:Z[p]})),g.clearActiveStatus(),g.clearDrawingStatus()}break;case"+":l==null||l.updatePointSize({zoomIn:!0});break;case"-":l==null||l.updatePointSize({zoomIn:!1});break;case"v":o.setPointCloudValid(!o.valid);break;case"tab":if(t.shiftKey){K();break}H(),t.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":N();break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const p=ie.getAttributeByKeycode(t.keyCode,r.attributeList);p!==void 0&&((n=i.current)==null||n.setDefaultAttribute(p))}return}}},X=(e,t)=>{switch(e){case"c":F();break;case"v":q();break;case"a":t.preventDefault(),o.selectedAllBoxes();break;case"z":{t.shiftKey?L():V();break}}},A=e=>{if(!ne.hotkeyFilter(e)||a===!0)return;const t=e.key.toLocaleLowerCase();if(e.ctrlKey){X(t,e);return}Q(t,e)};return c(()=>{const{topViewInstance:e}=o;if(!!e)return window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}},[o,G,r,o.pointCloudBoxList,o.polygonList]),c(()=>{$(r)},[T]),c(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),c(()=>{m==null||m()},[k,o.mainViewInstance]),c(()=>{o.setHideAttributes([])},[k]),c(()=>{i.current.setDefaultAttribute=e=>{var t;B(e);const s=o.selectedPointCloudBox;if(s){s.attribute=e;const n=x(s);o.mainViewInstance&&_({newSelectedBox:s,newPointCloudList:n})}if(O&&W(y(v({},O),{attribute:e})),j&&Y(y(v({},j),{attribute:e})),P){const n=U(y(v({},P),{attribute:e}));o.mainViewInstance&&((t=o.mainViewInstance)==null||t.generateSpheres(n),_({newSelectedSphere:P,newSphereList:n}))}},i.current.setSubAttribute=(e,t)=>{var s;const n=o.selectedPointCloudBox;if(n){const d=(s=n==null?void 0:n.subAttribute)!=null?s:{};n.subAttribute=y(v({},d),{[e]:t}),x(n)}},i.current.clearResult=()=>{w==null||w()},i.current.redo=()=>{L()},i.current.undo=()=>{V()},i.current.setValid=e=>{i.current.valid=e,setTimeout(()=>{o.setPointCloudValid(e),e===!1&&w()})},i.current.setForbidOperation=e=>{var t,s;(s=(t=o.topViewInstance)==null?void 0:t.pointCloud2dOperation)==null||s.setForbidOperation(e),e===!0&&o.setSelectedIDs(void 0)},i.current.setShowDefaultCursor=e=>{var t,s;(s=(t=o.topViewInstance)==null?void 0:t.pointCloud2dOperation)==null||s.setShowDefaultCursor(e)},i.current.asyncData=e=>{setTimeout(()=>{m==null||m(e)})}},[o.pointCloudBoxList,o.pointCloudSphereList,o.selectedID,o.valid,o.polygonList,o.lineList,o.mainViewInstance,o.ptSegmentInstance]),c(()=>{i.current.updateSegmentTool=e=>{var t;(t=o.ptSegmentInstance)==null||t.emit(e)},i.current.segmentInstance=o.ptSegmentInstance},[o.ptSegmentInstance]),c(()=>{i.current.history={pushHistory:e=>{M({pointCloudBoxList:e})},initRecord:()=>{}}},[]),c(()=>{var e;const t=(e=o.topViewInstance)==null?void 0:e.toolInstance;if(!t||a)return;const s=l=>{B(l)},n=l=>{S.error(l)},d=l=>{S.info(l)};return t.on("syncAttribute",s),t.on("messageError",n),t.on("messageInfo",d),()=>{t.unbind("syncAttribute",s),t.unbind("messageError",n),t.unbind("messageInfo",d)}},[o.topViewInstance]),null};var _e=ue(le,null,null,{context:pe})(xe);export{_e as default};
1
+ import{PointCloudContext as ee}from"./PointCloudContext.js";import{useRotate as te}from"./hooks/useRotate.js";import{useBoxes as oe}from"./hooks/useBoxes.js";import{useSingleBox as re}from"./hooks/useSingleBox.js";import{useSphere as ne}from"./hooks/useSphere.js";import{useContext as se,useEffect as c}from"react";import{EPointCloudName as ie,CommonToolUtils as ae,AttributeUtils as ue,EToolName as P,cTool as le}from"@labelbee/lb-annotation";import{message as S}from"antd";import{connect as de}from"react-redux";import{a2MapStateToProps as ce}from"../../store/annotation/map.js";import{useStatus as pe}from"./hooks/useStatus.js";import{usePointCloudViews as me}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as ve,useDispatch as be}from"../../store/ctx.js";import{useHistory as Pe}from"./hooks/useHistory.js";import{useAttribute as fe}from"./hooks/useAttribute.js";import{useConfig as ye}from"./hooks/useConfig.js";import{usePolygon as we}from"./hooks/usePolygon.js";import{useLine as Ce}from"./hooks/useLine.js";import{useTranslation as he}from"react-i18next";import{PreDataProcess as ge}from"../../store/annotation/actionCreators.js";var Se=Object.defineProperty,xe=Object.defineProperties,ke=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,_e=Object.prototype.hasOwnProperty,Ve=Object.prototype.propertyIsEnumerable,I=(l,r,u)=>r in l?Se(l,r,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[r]=u,f=(l,r)=>{for(var u in r||(r={}))_e.call(r,u)&&I(l,u,r[u]);if(D)for(var u of D(r))Ve.call(r,u)&&I(l,u,r[u]);return l},y=(l,r)=>xe(l,ke(r));const{EPolygonPattern:Le}=le,Be=({currentData:l,config:r,checkMode:u,configString:E,imgIndex:x,toolInstanceRef:i})=>{const t=se(ee),{changeSelectedBoxValid:T,selectNextBox:N,selectPrevBox:H,updateSelectedBox:k,deleteSelectedPointCloudBoxAndPolygon:K}=re(),{selectedSphere:w,updatePointCloudSphere:U}=ne(),{clearAllResult:C,updatePointCloudPattern:z}=pe(),{copySelectedBoxes:F,pasteSelectedBoxes:q,copiedBoxes:G}=oe({config:r}),{updateRotate:h}=te({currentData:l}),{updatePointCloudData:v,topViewSelectedChanged:_}=me(),{redo:V,undo:L,pushHistoryWithList:M,pushHistoryUnderUpdatePolygon:R,pushHistoryUnderUpdateLine:W}=Pe(),Y=be(),{syncThreeViewsAttribute:B}=fe(),{syncAllViewsConfig:$,reRenderTopViewRange:J}=ye(),{selectedPolygon:O}=we(),{selectedLine:j}=Ce(),{t:g}=he(),b=e=>{var o;const{topViewInstance:n}=t;!n||(o=n.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(e)},Q=(e,o)=>{var n,a;const{topViewInstance:d,mainViewInstance:s}=t;if(!d)return;const{pointCloud2dOperation:p}=d;switch(e){case"q":{h(2);break}case"e":h(-2);break;case"g":h(180);break;case"u":{const m=p.pattern===Le.Normal?P.Rect:P.Polygon;z(m);const Z={[P.Polygon]:g("PolygonPattern"),[P.Rect]:g("RectPattern")};S.success(g("ChangePatternMsg",{pattern:Z[m]})),p.clearActiveStatus(),p.clearDrawingStatus()}break;case"+":s==null||s.updatePointSize({zoomIn:!0});break;case"-":s==null||s.updatePointSize({zoomIn:!1});break;case"v":t.setPointCloudValid(!t.valid);break;case"tab":if(o.shiftKey){H();break}N(),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":K();break;default:{if(((n=r.attributeList)==null?void 0:n.length)>0){const m=ue.getAttributeByKeycode(o.keyCode,r.attributeList);m!==void 0&&((a=i.current)==null||a.setDefaultAttribute(m))}return}}},X=(e,o)=>{switch(e){case"c":F();break;case"v":q();break;case"a":o.preventDefault(),t.selectedAllBoxes();break;case"z":{o.shiftKey?V():L();break}}},A=e=>{if(!ae.hotkeyFilter(e)||u===!0)return;const o=e.key.toLocaleLowerCase();if(e.ctrlKey){X(o,e);return}Q(o,e)};return c(()=>{const{topViewInstance:e}=t;if(!!e)return window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}},[t,G,r,t.pointCloudBoxList,t.polygonList]),c(()=>{$(r)},[E]),c(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),c(()=>{v==null||v()},[x,t.mainViewInstance]),c(()=>{t.setHideAttributes([])},[x]),c(()=>{i.current.setDefaultAttribute=e=>{var o,n,a,d;B(e);const s=t.selectedPointCloudBox;if(s){s.attribute=e;const p=Y(ge({tool:ie.PointCloud,dataList:[s],stepConfig:r,action:"viewUpdateBox"}));s.valid=p[0].valid;const m=k(s);(a=(n=(o=t==null?void 0:t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:n.setPolygonValidAndRender)==null||a.call(n,s.id,!0,s.valid),t.mainViewInstance&&_({newSelectedBox:s,newPointCloudList:m})}if(O&&R(y(f({},O),{attribute:e})),j&&W(y(f({},j),{attribute:e})),w){const p=U(y(f({},w),{attribute:e}));t.mainViewInstance&&((d=t.mainViewInstance)==null||d.generateSpheres(p),_({newSelectedSphere:w,newSphereList:p}))}},i.current.setSubAttribute=(e,o)=>{var n;const a=t.selectedPointCloudBox;if(a){const d=(n=a==null?void 0:a.subAttribute)!=null?n:{};a.subAttribute=y(f({},d),{[e]:o}),k(a)}},i.current.clearResult=()=>{C==null||C()},i.current.redo=()=>{V()},i.current.undo=()=>{L()},i.current.setValid=e=>{i.current.valid=e,setTimeout(()=>{t.setPointCloudValid(e),e===!1&&C()})},i.current.setForbidOperation=e=>{var o,n;(n=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||n.setForbidOperation(e),e===!0&&t.setSelectedIDs(void 0)},i.current.setShowDefaultCursor=e=>{var o,n;(n=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||n.setShowDefaultCursor(e)},i.current.asyncData=e=>{setTimeout(()=>{v==null||v(e)})}},[t.pointCloudBoxList,t.pointCloudSphereList,t.selectedID,t.valid,t.polygonList,t.lineList,t.mainViewInstance,t.ptSegmentInstance]),c(()=>{i.current.updateSegmentTool=e=>{var o;(o=t.ptSegmentInstance)==null||o.emit(e)},i.current.segmentInstance=t.ptSegmentInstance},[t.ptSegmentInstance]),c(()=>{i.current.history={pushHistory:e=>{M({pointCloudBoxList:e})},initRecord:()=>{}}},[]),c(()=>{var e;const o=(e=t.topViewInstance)==null?void 0:e.toolInstance;if(!o||u)return;const n=s=>{B(s)},a=s=>{S.error(s)},d=s=>{S.info(s)};return o.on("syncAttribute",n),o.on("messageError",a),o.on("messageInfo",d),()=>{o.unbind("syncAttribute",n),o.unbind("messageError",a),o.unbind("messageInfo",d)}},[t.topViewInstance]),null};var Oe=de(ce,null,null,{context:ve})(Be);export{Oe as default};
@@ -1 +1 @@
1
- import{EPointCloudName as J,MathUtils as B,getCuboidFromPointCloudBox as Rt}from"@labelbee/lb-annotation";import{EPerspectiveView as W,PointCloudUtils as I,DEFAULT_SPHERE_PARAMS as Nt}from"@labelbee/lb-utils";import{useContext as Et}from"react";import{PointCloudContext as Ht}from"../PointCloudContext.js";import{useSingleBox as lt}from"./useSingleBox.js";import{useSphere as Ft}from"./useSphere.js";import{useSelector as Zt,useDispatch as Wt}from"../../../store/ctx.js";import Mt from"../../../utils/StepUtils.js";import{jsonParser as dt}from"../../../utils/index.js";import{PreDataProcess as K,SetPointCloudLoading as at,SetLoadPCDFileLoading as ct}from"../../../store/annotation/actionCreators.js";import{message as Gt}from"antd";import{useTranslation as Qt}from"react-i18next";import{useHistory as Xt}from"./useHistory.js";import{usePolygon as Yt}from"./usePolygon.js";var qt=Object.defineProperty,Jt=Object.defineProperties,Kt=Object.getOwnPropertyDescriptors,ut=Object.getOwnPropertySymbols,$t=Object.prototype.hasOwnProperty,to=Object.prototype.propertyIsEnumerable,pt=(o,e,n)=>e in o?qt(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,y=(o,e)=>{for(var n in e||(e={}))$t.call(e,n)&&pt(o,n,e[n]);if(ut)for(var n of ut(e))to.call(e,n)&&pt(o,n,e[n]);return o},k=(o,e)=>Jt(o,Kt(e)),$=(o,e,n)=>new Promise((l,t)=>{var d=u=>{try{a(n.next(u))}catch(C){t(C)}},f=u=>{try{a(n.throw(u))}catch(C){t(C)}},a=u=>u.done?l(u.value):Promise.resolve(u.value).then(d,f);a((n=n.apply(o,e)).next())});const Q=5,X=90,ft=.01,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},tt=(o,e,n,l,t)=>{const{x:d,y:f}=I.transferCanvas2World(o,e),{defaultZ:a}=Nt,u={center:{x:d,y:f,z:a},id:o.id},C=l?y(y({},l),u):k(y({},u),{attribute:"",valid:!0});return t&&Object.assign(C,t),C},ot=(o,e,n,l,t,d)=>{let f=o.pointList.map(h=>I.transferCanvas2World(h,e)),a=0,u=1,C={};if(n){const h=n.getSensesPointZAxisInPolygon(f,void 0,d);d&&h.fittedCoordinates.length>0&&(f=h.fittedCoordinates),a=(h.maxZ+h.minZ)/2,u=h.maxZ-h.minZ,C={count:h.zCount}}const[m,b,E]=f,V=B.getLineCenterPoint([m,E]),A=B.getLineLength(m,b),T=B.getLineLength(b,E),R=B.getRadiusFromQuadrangle(o.pointList);l&&(a=l.center.z,u=l.depth);const z={center:{x:V.x,y:V.y,z:a},width:d?T+ft:T,height:d?A+ft:A,depth:u,rotation:R,id:o.id},j=y(l?y(y({},l),z):k(y({},z),{attribute:"",valid:!0}),C);t&&Object.assign(j,t);const _=f.map(h=>I.transferWorld2Canvas(h,e));return{boxParams:j,newPointList:_}},gt=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return k(y({},n),{center:{x:n.center.x-l.x,y:n.center.y,z:n.center.z-l.y}})},Ct=(o,e,n,l)=>{const[t,d,f]=o.pointList,[a,u,C]=e.pointList,m=B.getLineCenterPoint([t,f]),b=B.getLineCenterPoint([a,C]),V={x:{x:m.x-b.x,y:m.y-b.y}.x,y:0,z:m.y-b.y},A=B.getLineLength(t,d),T=B.getLineLength(a,u),R=A-T,z=B.getLineLength(d,f),j=B.getLineLength(u,C),_=z-j,{newBoxParams:h}=l.getNewBoxBySideUpdate(V,_,R,n);return h},oo=(o,e,n)=>{const l={x:o.x-e.x,y:o.y-e.y};return k(y({},n),{center:{x:n.center.x,y:n.center.y-l.x,z:n.center.z-l.y}})},eo=(o,e,n,l)=>{const[t,d,f]=o.pointList,[a,u,C]=e.pointList,m=B.getLineCenterPoint([t,f]),b=B.getLineCenterPoint([a,C]),V={x:{x:m.x-b.x,y:m.y-b.y}.x,y:0,z:m.y-b.y},A=B.getLineLength(t,d),T=B.getLineLength(a,u),R=A-T,z=B.getLineLength(d,f),j=B.getLineLength(u,C),_=z-j;let{newBoxParams:h}=l.getNewBoxByBackUpdate(V,_,R,n);return h},Pt=(o,e,n,l,t)=>{var d;if(!n)return;const{toolInstance:f,pointCloudInstance:a}=n;a.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:X);const{cameraPositionVector:u}=a.updateOrthoCameraBySphere(o,W.Left);a.setInitCameraPosition(u);const{point2d:C,zoom:m}=a.getSphereSidePoint2DCoordinate(o);a.camera.zoom=m,a.camera.updateProjectionMatrix(),a.render(),f.initPosition(),f.zoomChangeOnCenter(m),f.setResult([k(y(y({},e),C),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(e.id)},mt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=n;d.loadPCDFileByBox(l,o,{width:Q,depth:Q});const{cameraPositionVector:f}=d.updateOrthoCamera(o,W.Left);d.setInitCameraPosition(f);const{polygon2d:a,zoom:u}=d.getBoxSidePolygon2DCoordinate(o);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(u),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:a,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},xt=(o,e,n,l,t)=>{var d;if(!n)return;const{toolInstance:f,pointCloudInstance:a}=n;a.loadPCDFile(l,(d=t==null?void 0:t.radius)!=null?d:X);const{cameraPositionVector:u}=a.updateOrthoCameraBySphere(o,W.Back);a.setInitCameraPosition(u);const{point2d:C,zoom:m}=a.getSphereBackPoint2DCoordinate(o);a.camera.zoom=m,a.camera.updateProjectionMatrix(),a.render(),f.initPosition(),f.zoomChangeOnCenter(m),f.setResult([k(y(y({},e),C),{valid:o.valid,textAttribute:"",attribute:o.attribute})]),f.setSelectedID(e.id)},Lt=(o,e,n,l)=>{if(!n)return;const{pointCloud2dOperation:t,pointCloudInstance:d}=n;d.loadPCDFileByBox(l,o,{height:Q,depth:Q});const{cameraPositionVector:f}=d.updateOrthoCamera(o,W.Back);d.setInitCameraPosition(f);const{polygon2d:a,zoom:u}=d.getBoxBackPolygon2DCoordinate(o);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),t.initPosition(),t.zoomChangeOnCenter(u),t.setResultAndSelectedID([{id:e.id,valid:o.valid,pointList:a,textAttribute:"",isRect:!0,attribute:o.attribute}],e.id)},yt=(o,e,n,l)=>{if(!n||!l)return;l.generateSphere(o),l.updateCameraBySphere(o,W.Top),l.render();const{toolInstance:t,pointCloudInstance:d}=n,{point2d:f}=d.getSphereTopPoint2DCoordinate(o),a=[...t.pointList].map(u=>u.id===e.id?k(y(y({},e),f),{valid:o.valid,textAttribute:"",attribute:o.attribute}):u);t.setResult(a),t.setSelectedID(e.id)},et=(o,e,n,l)=>{var t,d;if(!n||!l)return;l.generateBox(o,e.id),l.render();const{pointCloud2dOperation:f,pointCloudInstance:a}=n,{polygon2d:u}=a.getBoxTopPolygon2DCoordinate(o),C=[...f.polygonList],m=C.find(b=>b.id===e.id);m?(m.pointList=u,m.valid=(t=o.valid)!=null?t:!0):C.push({id:e.id,pointList:u,textAttribute:"",isRect:!0,valid:(d=o.valid)!=null?d:!0}),f.setResultAndSelectedID(C,e.id)},no=()=>{const o=Et(Ht),{topViewInstance:e,sideViewInstance:n,backViewInstance:l,mainViewInstance:t,addPointCloudBox:d,addPointCloudSphere:f,setSelectedIDs:a,selectedIDs:u,pointCloudBoxList:C,pointCloudSphereList:m,hideAttributes:b,setHighlight2DDataList:E}=o,{addHistory:V,initHistory:A,pushHistoryUnderUpdatePolygon:T,pushHistoryUnderUpdateLine:R}=Xt(),{selectedPolygon:z}=Yt(),{updateSelectedBox:j,updateSelectedBoxes:_,getPointCloudByID:h}=lt(),{getPointCloudSphereByID:ht,updatePointCloudSphere:nt,selectedSphere:M}=Ft(),{currentData:H,config:w}=Zt(i=>{const{stepList:s,step:p,imgList:c,imgIndex:r}=i.annotation;return{currentData:c[r],config:dt(Mt.getCurrentStepInfo(p,s).config)}}),N=Wt(),{selectedBox:D}=lt(),{t:vt}=Qt(),it=D==null?void 0:D.info;if(!e||!n||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:Y}=e,Bt=i=>{t==null||t.generateBox(i),t==null||t.controls.update(),t==null||t.render()},wt=i=>{t==null||t.generateSphere(i),t==null||t.controls.update(),t==null||t.render()},bt=({newPoint:i,size:s,zoom:p,trackConfigurable:c})=>{var r;const g={attribute:(r=e.toolInstance.defaultAttribute)!=null?r:""};c===!0&&Object.assign(g,{trackID:I.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:m})});const P=tt(i,s,Y,void 0,g);a(i.id);const x=f(P);G(L.Top,i,P,p,x,w),V({newSphereParams:P})},St=({polygon:i,size:s,imgList:p,trackConfigurable:c,zoom:r,intelligentFit:g})=>{var P,x;const v={attribute:(P=e.toolInstance.defaultAttribute)!=null?P:""};c===!0&&Object.assign(v,{trackID:I.getNextTrackID({imgList:[],extraBoxList:C,extraSphereList:m})});const O=e==null?void 0:e.toolInstance,U=y({},i);let{boxParams:S,newPointList:Z}=ot(U,s,Y,void 0,v,g);if(S=N(K({tool:J.PointCloud,dataList:[S],stepConfig:w,action:"viewUpdateBox"}))[0],(w==null?void 0:w.lowerLimitPointsNumInBox)&&typeof S.count=="number"&&S.count<w.lowerLimitPointsNumInBox){Gt.info(vt("LowerLimitPointsNumInBox",{num:w.lowerLimitPointsNumInBox})),O.deletePolygon(S.id);return}g&&(Z==null?void 0:Z.length)&&(U.pointList=Z);const zt=b.includes(U.attribute),q=d(S),jt=(x=o==null?void 0:o.polygonList)!=null?x:[];e==null||e.updatePolygonList(q!=null?q:[],jt),zt?a([]):(a(S.id),O.selection.setSelectedIDs(U.id),F({omitView:L.Top,polygon:U,boxParams:S,zoom:r,newPointCloudBoxList:q}),g&&et(S,U,e,t)),V({newBoxParams:S})},It=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:p,newSphereList:c})=>{var r;const g=e==null?void 0:e.toolInstance;if(!(u.length===0||!g)){if(i||(D==null?void 0:D.info)){const P=i!=null?i:D==null?void 0:D.info;(r=g==null?void 0:g.selection)==null||r.setSelectedIDs(u[0]);const x=g.selectedPolygon;if(u.length===1&&P){F({omitView:L.Top,polygon:x,boxParams:P,newPointCloudBoxList:s});return}}if((p||M)&&u.length===1){const P=p!=null?p:M;g.setSelectedID(u[0]);const x=g.selectedPoint;P&&G(L.Top,x,P,void 0,c,w)}}},st=(i,s,p)=>{if(it){let c,r;switch(p){case L.Back:c=eo;break;case L.Side:c=Ct;break;default:c=Ct;break}r=c(i,s,it,n.pointCloudInstance);const P=N(K({tool:J.PointCloud,dataList:[r],stepConfig:w,action:"viewUpdateBox"}))[0],x=r.valid!==P.valid;if(r=P,t){const{count:O}=t.getSensesPointZAxisInPolygon(Rt(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=k(y({},r),{count:O})}const v=j(r);return r=v.find(O=>O.id===r.id),F({omitView:x?void 0:p,polygon:i,boxParams:r,newPointCloudBoxList:v}),v}},rt=(i,s,p)=>{if(M){let c,r;switch(p){case L.Back:c=oo;break;case L.Side:c=gt;break;default:c=gt;break}r=c(i,s,M);const g=nt(r);return G(p,i,r,void 0,g,w),g}},Dt=(i,s)=>{rt(i,s,L.Side)},Vt=(i,s)=>{rt(i,s,L.Back)},_t=(i,s)=>{st(i,s,L.Side)},Ot=(i,s)=>{st(i,s,L.Back)},Ut=(i,s)=>{R(i)},kt=(i,s)=>{const p=ht(i.id),c=tt(i,s,Y,p),r=nt(c);G(L.Top,i,c,void 0,r,w)},At=(i,s)=>{if(z){const c=i[0].newPolygon;c.pointList=c.pointList.map(r=>I.transferCanvas2World(r,s)),T(i[0].newPolygon);return}let p=i.map(({newPolygon:c})=>{const r=h(c.id),{boxParams:g}=ot(c,s,e.pointCloudInstance,r);return g});if(p=N(K({tool:J.PointCloud,dataList:p,stepConfig:w,action:"viewUpdateBox"})),p.length===1){const{newPolygon:c}=i[0],r=_(p);F({omitView:L.Top,polygon:c,boxParams:p[0],newPointCloudBoxList:r})}else{const c=_(p);c&&o.syncAllViewPointCloudColor(c)}},Tt=i=>{var s;if(D){const p=D==null?void 0:D.info.trackID,r=((s=e==null?void 0:e.toolInstance)==null?void 0:s.polygonList).find(x=>(x==null?void 0:x.trackID)===p),g=k(y({},D.info),{width:Number(i.widthDefault),depth:Number(i.depthDefault),height:Number(i.heightDefault)}),P=_([g]);F({omitView:L["3D"],polygon:r,boxParams:g,newPointCloudBoxList:P})}},G=(i,s,p,c,r,g)=>$(void 0,null,function*(){const P=H==null?void 0:H.url,x={[L.Side]:()=>{Pt(p,s,n,P,g)},[L.Back]:()=>{l&&xt(p,s,l,P,g)},[L.Top]:()=>{yt(p,s,e,t)}};Object.keys(x).forEach(v=>{v!==i&&x[v]()}),c&&(t==null||t.updateCameraZoom(c)),wt(p)}),F=i=>$(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:c,zoom:r,newPointCloudBoxList:g}=i,P=H==null?void 0:H.url;g&&(yield o.syncAllViewPointCloudColor(g));const x={[L.Side]:()=>{mt(c,p,n,P)},[L.Back]:()=>{l&&Lt(c,p,l,P)},[L.Top]:()=>{et(c,p,e,t)}};Object.keys(x).forEach(v=>{v!==s&&x[v]()}),r&&(t==null||t.updateCameraZoom(r)),Bt(c)});return{topViewAddSphere:bt,topViewAddBox:St,topViewSelectedChanged:It,topViewUpdatePoint:kt,sideViewUpdatePoint:Dt,backViewUpdatePoint:Vt,topViewUpdateBox:At,topViewUpdateLine:Ut,sideViewUpdateBox:_t,backViewUpdateBox:Ot,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),t==null||t.generateBoxes(i)},initPointCloud3d:i=>{if(!t)return;const s=I.getDefaultOrthographicParams(i);t.initOrthographicCamera(s),t.initRenderer(),t.render()},updatePointCloudData:(...i)=>$(void 0,[...i],function*(s=H){var p,c,r,g,P,x;if(!(s==null?void 0:s.url)||!t)return;E([]),at(N,!0),ct(N,!0),yield t.loadPCDFile(s.url,(p=w==null?void 0:w.radius)!=null?p:X),t==null||t.clearAllBox(),t==null||t.clearAllSphere();let v=[],O=[],U=[],S=[];t.updateTopCamera();const Z=(r=(c=dt(s.result))==null?void 0:c.valid)!=null?r:!0;o.setPointCloudValid(Z),(g=o.sideViewInstance)==null||g.clearAllData(),(P=o.backViewInstance)==null||P.clearAllData(),e.updateData(s.url,s.result,{radius:(x=w==null?void 0:w.radius)!=null?x:X}),s.result&&(v=I.getBoxParamsFromResultList(s.result),U=I.getPolygonListFromResultList(s.result),O=I.getLineListFromResultList(s.result),S=I.getSphereParamsFromResultList(s.result),t==null||t.generateBoxes(v),t==null||t.generateSpheres(S),yield o.syncAllViewPointCloudColor(v,[])),A({pointCloudBoxList:v,polygonList:U,lineList:O,pointCloudSphereList:S}),at(N,!1),ct(N,!1)}),updateViewsByDefaultSize:Tt}};export{xt as syncBackViewByPoint,Pt as syncSideViewByPoint,yt as syncTopViewByPoint,Lt as synchronizeBackView,mt as synchronizeSideView,et as synchronizeTopView,tt as topViewPoint2PointCloud,ot as topViewPolygon2PointCloud,no as usePointCloudViews};
1
+ import{EPointCloudName as tt,MathUtils as v,getCuboidFromPointCloudBox as Zt}from"@labelbee/lb-annotation";import{EPerspectiveView as M,PointCloudUtils as D,DEFAULT_SPHERE_PARAMS as Mt}from"@labelbee/lb-utils";import{useContext as Gt}from"react";import{PointCloudContext as Qt}from"../PointCloudContext.js";import{useSingleBox as ft}from"./useSingleBox.js";import{useSphere as Xt}from"./useSphere.js";import{useSelector as Yt,useDispatch as qt}from"../../../store/ctx.js";import Jt from"../../../utils/StepUtils.js";import{jsonParser as gt}from"../../../utils/index.js";import{PreDataProcess as ot,SetPointCloudLoading as Pt,SetLoadPCDFileLoading as Ct}from"../../../store/annotation/actionCreators.js";import{message as Kt}from"antd";import{useTranslation as $t}from"react-i18next";import{useHistory as to}from"./useHistory.js";import{usePolygon as oo}from"./usePolygon.js";var eo=Object.defineProperty,no=Object.defineProperties,io=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,so=Object.prototype.hasOwnProperty,ro=Object.prototype.propertyIsEnumerable,mt=(e,t,n)=>t in e?eo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,L=(e,t)=>{for(var n in t||(t={}))so.call(t,n)&&mt(e,n,t[n]);if(ht)for(var n of ht(t))ro.call(t,n)&&mt(e,n,t[n]);return e},k=(e,t)=>no(e,io(t)),et=(e,t,n)=>new Promise((d,o)=>{var a=u=>{try{c(n.next(u))}catch(C){o(C)}},f=u=>{try{c(n.throw(u))}catch(C){o(C)}},c=u=>u.done?d(u.value):Promise.resolve(u.value).then(a,f);c((n=n.apply(e,t)).next())});const q=5,J=90,xt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},nt=(e,t,n,d,o)=>{const{x:a,y:f}=D.transferCanvas2World(e,t),{defaultZ:c}=Mt,u={center:{x:a,y:f,z:c},id:e.id},C=d?L(L({},d),u):k(L({},u),{attribute:"",valid:!0});return o&&Object.assign(C,o),C},it=(e,t,n,d,o,a)=>{let f=e.pointList.map(B=>D.transferCanvas2World(B,t)),c=0,u=1,C={};if(n){const B=n.getSensesPointZAxisInPolygon(f,void 0,a);a&&B.fittedCoordinates.length>0&&(f=B.fittedCoordinates),c=(B.maxZ+B.minZ)/2,u=B.maxZ-B.minZ,C={count:B.zCount}}const[h,I,H]=f,O=v.getLineCenterPoint([h,H]),A=v.getLineLength(h,I),z=v.getLineLength(I,H),R=v.getRadiusFromQuadrangle(e.pointList);d&&(c=d.center.z,u=d.depth);const T={center:{x:O.x,y:O.y,z:c},width:a?z+xt:z,height:a?A+xt:A,depth:u,rotation:R,id:e.id},j=L(d?L(L({},d),T):k(L({},T),{attribute:"",valid:!0}),C);o&&Object.assign(j,o);const U=f.map(B=>D.transferWorld2Canvas(B,t));return{boxParams:j,newPointList:U}},yt=(e,t,n)=>{const d={x:e.x-t.x,y:e.y-t.y};return k(L({},n),{center:{x:n.center.x-d.x,y:n.center.y,z:n.center.z-d.y}})},Lt=(e,t,n,d)=>{const[o,a,f]=e.pointList,[c,u,C]=t.pointList,h=v.getLineCenterPoint([o,f]),I=v.getLineCenterPoint([c,C]),O={x:{x:h.x-I.x,y:h.y-I.y}.x,y:0,z:h.y-I.y},A=v.getLineLength(o,a),z=v.getLineLength(c,u),R=A-z,T=v.getLineLength(a,f),j=v.getLineLength(u,C),U=T-j,{newBoxParams:B}=d.getNewBoxBySideUpdate(O,U,R,n);return B},lo=(e,t,n)=>{const d={x:e.x-t.x,y:e.y-t.y};return k(L({},n),{center:{x:n.center.x,y:n.center.y-d.x,z:n.center.z-d.y}})},ao=(e,t,n,d)=>{const[o,a,f]=e.pointList,[c,u,C]=t.pointList,h=v.getLineCenterPoint([o,f]),I=v.getLineCenterPoint([c,C]),O={x:{x:h.x-I.x,y:h.y-I.y}.x,y:0,z:h.y-I.y},A=v.getLineLength(o,a),z=v.getLineLength(c,u),R=A-z,T=v.getLineLength(a,f),j=v.getLineLength(u,C),U=T-j;let{newBoxParams:B}=d.getNewBoxByBackUpdate(O,U,R,n);return B},vt=(e,t,n,d,o)=>{var a;if(!n)return;const{toolInstance:f,pointCloudInstance:c}=n;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:J);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,M.Left);c.setInitCameraPosition(u);const{point2d:C,zoom:h}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=h,c.camera.updateProjectionMatrix(),c.render(),f.initPosition(),f.zoomChangeOnCenter(h),f.setResult([k(L(L({},t),C),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(t.id)},Bt=(e,t,n,d)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=n;a.loadPCDFileByBox(d,e,{width:q,depth:q});const{cameraPositionVector:f}=a.updateOrthoCamera(e,M.Left);a.setInitCameraPosition(f);const{polygon2d:c,zoom:u}=a.getBoxSidePolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,n,d,o)=>{var a;if(!n)return;const{toolInstance:f,pointCloudInstance:c}=n;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:J);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,M.Back);c.setInitCameraPosition(u);const{point2d:C,zoom:h}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=h,c.camera.updateProjectionMatrix(),c.render(),f.initPosition(),f.zoomChangeOnCenter(h),f.setResult([k(L(L({},t),C),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(t.id)},wt=(e,t,n,d)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=n;a.loadPCDFileByBox(d,e,{height:q,depth:q});const{cameraPositionVector:f}=a.updateOrthoCamera(e,M.Back);a.setInitCameraPosition(f);const{polygon2d:c,zoom:u}=a.getBoxBackPolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,n,d)=>{if(!n||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,M.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=n,{point2d:f}=a.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?k(L(L({},t),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},st=(e,t,n,d)=>{var o,a;if(!n||!d)return;d.generateBox(e,t.id),d.render();const{pointCloud2dOperation:f,pointCloudInstance:c}=n,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),C=[...f.polygonList],h=C.find(I=>I.id===t.id);h?(h.pointList=u,h.valid=(o=e.valid)!=null?o:!0):C.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(a=e.valid)!=null?a:!0}),f.setResultAndSelectedID(C,t.id)},co=()=>{const e=Gt(Qt),{topViewInstance:t,sideViewInstance:n,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:f,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:C,pointCloudSphereList:h,hideAttributes:I,setHighlight2DDataList:H}=e,{addHistory:O,initHistory:A,pushHistoryUnderUpdatePolygon:z,pushHistoryUnderUpdateLine:R}=to(),{selectedPolygon:T}=oo(),{updateSelectedBox:j,updateSelectedBoxes:U,getPointCloudByID:B}=ft(),{getPointCloudSphereByID:St,updatePointCloudSphere:rt,selectedSphere:G}=Xt(),{currentData:F,config:w}=Yt(i=>{const{stepList:s,step:p,imgList:l,imgIndex:r}=i.annotation;return{currentData:l[r],config:gt(Jt.getCurrentStepInfo(p,s).config)}}),N=qt(),{selectedBox:S}=ft(),{t:Dt}=$t(),lt=S==null?void 0:S.info;if(!t||!n||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:K}=t,_t=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},Vt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},Ot=({newPoint:i,size:s,zoom:p,trackConfigurable:l})=>{var r;const g={attribute:(r=t.toolInstance.defaultAttribute)!=null?r:""};l===!0&&Object.assign(g,{trackID:D.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const P=nt(i,s,K,void 0,g);c(i.id);const m=f(P);Q(y.Top,i,P,p,m,w),O({newSphereParams:P})},Ut=({polygon:i,size:s,imgList:p,trackConfigurable:l,zoom:r,intelligentFit:g})=>{var P,m;const x={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};l===!0&&Object.assign(x,{trackID:D.getNextTrackID({imgList:[],extraBoxList:C,extraSphereList:h})});const _=t==null?void 0:t.toolInstance,V=L({},i);let{boxParams:b,newPointList:E}=it(V,s,K,void 0,x,g);if(b=N(ot({tool:tt.PointCloud,dataList:[b],stepConfig:w,action:"viewUpdateBox"}))[0],(w==null?void 0:w.lowerLimitPointsNumInBox)&&typeof b.count=="number"&&b.count<w.lowerLimitPointsNumInBox){Kt.info(Dt("LowerLimitPointsNumInBox",{num:w.lowerLimitPointsNumInBox})),_.deletePolygon(b.id);return}g&&(E==null?void 0:E.length)&&(V.pointList=E);const X=I.includes(V.attribute),Z=a(b),$=(m=e==null?void 0:e.polygonList)!=null?m:[];t==null||t.updatePolygonList(Z!=null?Z:[],$),X?c([]):(c(b.id),_.selection.setSelectedIDs(V.id),W({omitView:y.Top,polygon:V,boxParams:b,zoom:r,newPointCloudBoxList:Z}),g&&st(b,V,t,o)),O({newBoxParams:b})},kt=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:p,newSphereList:l})=>{var r;const g=t==null?void 0:t.toolInstance;if(!(u.length===0||!g)){if(i||(S==null?void 0:S.info)){const P=i!=null?i:S==null?void 0:S.info;(r=g==null?void 0:g.selection)==null||r.setSelectedIDs(u[0]);const m=g.selectedPolygon;if(u.length===1&&P){W({omitView:y.Top,polygon:m,boxParams:P,newPointCloudBoxList:s});return}}if((p||G)&&u.length===1){const P=p!=null?p:G;g.setSelectedID(u[0]);const m=g.selectedPoint;P&&Q(y.Top,m,P,void 0,l,w)}}},dt=(i,s,p)=>{if(lt){let l,r;switch(p){case y.Back:l=ao;break;case y.Side:l=Lt;break;default:l=Lt;break}r=l(i,s,lt,n.pointCloudInstance);const P=N(ot({tool:tt.PointCloud,dataList:[r],stepConfig:w,action:"viewUpdateBox"}))[0],m=r.valid!==P.valid;if(r=P,o){const{count:_}=o.getSensesPointZAxisInPolygon(Zt(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=k(L({},r),{count:_})}const x=j(r);return r=x.find(_=>_.id===r.id),W({omitView:m?void 0:p,polygon:i,boxParams:r,newPointCloudBoxList:x}),x}},at=(i,s,p)=>{if(G){let l,r;switch(p){case y.Back:l=lo;break;case y.Side:l=yt;break;default:l=yt;break}r=l(i,s,G);const g=rt(r);return Q(p,i,r,void 0,g,w),g}},At=(i,s)=>{at(i,s,y.Side)},zt=(i,s)=>{at(i,s,y.Back)},Tt=(i,s)=>{dt(i,s,y.Side)},jt=(i,s)=>{dt(i,s,y.Back)},Rt=(i,s)=>{R(i)},Nt=(i,s)=>{const p=St(i.id),l=nt(i,s,K,p),r=rt(l);Q(y.Top,i,l,void 0,r,w)},Et=(i,s)=>{if(T){const l=i[0].newPolygon;l.pointList=l.pointList.map(r=>D.transferCanvas2World(r,s)),z(i[0].newPolygon);return}let p=i.map(({newPolygon:l})=>{const r=B(l.id),{boxParams:g}=it(l,s,t.pointCloudInstance,r);return g});if(p=N(ot({tool:tt.PointCloud,dataList:p,stepConfig:w,action:"viewUpdateBox"})),p.length===1){const{newPolygon:l}=i[0],r=U(p);W({polygon:l,boxParams:p[0],newPointCloudBoxList:r})}else{const l=U(p);l&&e.syncAllViewPointCloudColor(l)}},Ht=i=>{var s,p,l,r,g;if(S){const P=Number(i.widthDefault),m=Number(i.depthDefault),x=Number(i.heightDefault),_=S==null?void 0:S.info.trackID,b=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===_),E={width:(l=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:l.width,height:(g=(r=t==null?void 0:t.toolInstance)==null?void 0:r.basicImgInfo)==null?void 0:g.height},ct=b.pointList.map(Y=>D.transferCanvas2World(Y,E)),X=v.getModifiedRectangleCoordinates(ct,x,P),Z=X[0],$=X[2],ut=v.getLineCenterPoint([Z,$]),Ft=S.info.center.z-S.info.depth/2,pt=k(L({},S.info),{center:{x:ut.x,y:ut.y,z:Ft+m/2},width:P,height:x,depth:m,valid:!0}),Wt=U([pt]);W({omitView:y["3D"],polygon:b,boxParams:pt,newPointCloudBoxList:Wt})}},Q=(i,s,p,l,r,g)=>et(void 0,null,function*(){const P=F==null?void 0:F.url,m={[y.Side]:()=>{vt(p,s,n,P,g)},[y.Back]:()=>{d&&bt(p,s,d,P,g)},[y.Top]:()=>{It(p,s,t,o)}};Object.keys(m).forEach(x=>{x!==i&&m[x]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(p)}),W=i=>et(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:l,zoom:r,newPointCloudBoxList:g}=i,P=F==null?void 0:F.url;g&&(yield e.syncAllViewPointCloudColor(g));const m={[y.Side]:()=>{Bt(l,p,n,P)},[y.Back]:()=>{d&&wt(l,p,d,P)},[y.Top]:()=>{st(l,p,t,o)}};Object.keys(m).forEach(x=>{x!==s&&m[x]()}),r&&(o==null||o.updateCameraZoom(r)),_t(l)});return{topViewAddSphere:Ot,topViewAddBox:Ut,topViewSelectedChanged:kt,topViewUpdatePoint:Nt,sideViewUpdatePoint:At,backViewUpdatePoint:zt,topViewUpdateBox:Et,topViewUpdateLine:Rt,sideViewUpdateBox:Tt,backViewUpdateBox:jt,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const s=D.getDefaultOrthographicParams(i);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>et(void 0,[...i],function*(s=F){var p,l,r,g,P,m;if(!(s==null?void 0:s.url)||!o)return;H([]),Pt(N,!0),Ct(N,!0),yield o.loadPCDFile(s.url,(p=w==null?void 0:w.radius)!=null?p:J),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],_=[],V=[],b=[];o.updateTopCamera();const E=(r=(l=gt(s.result))==null?void 0:l.valid)!=null?r:!0;e.setPointCloudValid(E),(g=e.sideViewInstance)==null||g.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),t.updateData(s.url,s.result,{radius:(m=w==null?void 0:w.radius)!=null?m:J}),s.result&&(x=D.getBoxParamsFromResultList(s.result),V=D.getPolygonListFromResultList(s.result),_=D.getLineListFromResultList(s.result),b=D.getSphereParamsFromResultList(s.result),o==null||o.generateBoxes(x),o==null||o.generateSpheres(b),yield e.syncAllViewPointCloudColor(x,[])),A({pointCloudBoxList:x,polygonList:V,lineList:_,pointCloudSphereList:b}),Pt(N,!1),Ct(N,!1)}),updateViewsByDefaultSize:Ht}};export{bt as syncBackViewByPoint,vt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,st as synchronizeTopView,nt as topViewPoint2PointCloud,it as topViewPolygon2PointCloud,co as usePointCloudViews};
@@ -1 +1 @@
1
- import{PointCloudContext as f}from"../../../../components/pointCloudView/PointCloudContext.js";import{Modal as z}from"antd";import t,{useContext as g,useMemo as k,useState as J}from"react";import{stepConfigSelector as Q}from"../../../../store/annotation/selectors.js";import{useSelector as F}from"../../../../store/ctx.js";import{i18n as A}from"@labelbee/lb-utils";import{UnorderedListOutlined as N,PushpinFilled as _,EyeInvisibleFilled as X,EyeFilled as Y,CaretDownFilled as Z,DeleteOutlined as tt}from"@ant-design/icons";import{useHistory as et}from"../../../../components/pointCloudView/hooks/useHistory.js";import{getClassName as u}from"../../../../utils/dom.js";import nt from"../../../../utils/StepUtils.js";import{EPointCloudName as ot}from"@labelbee/lb-annotation";import{useTranslation as j}from"react-i18next";import rt from"../FooterPopover.js";var it=Object.defineProperty,lt=Object.defineProperties,at=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,st=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable,R=(e,o,n)=>o in e?it(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n,D=(e,o)=>{for(var n in o||(o={}))st.call(o,n)&&R(e,n,o[n]);if(I)for(var n of I(o))ct.call(o,n)&&R(e,n,o[n]);return e},B=(e,o)=>lt(e,at(o));const ut=({attribute:e})=>{const o=g(f),{pointCloudBoxList:n,pointCloudSphereList:l,hideAttributes:m,toggleAttributesVisible:p,polygonList:d,setPolygonList:C,lineList:s,setLineList:y,setPointCloudResult:L,setPointCloudSphereList:c,reRender:H,selectSpecAttr:V,segmentation:O,setSegmentation:$}=o,[E,G]=J(!0),{pushHistoryWithList:T}=et(),S=[...n,...d,...l,...s,...O].filter(r=>r.attribute===e.value),w=()=>{p(e.value)},U=m.includes(e.value),M=({trackID:r,order:i})=>r||i,K=({trackID:r,order:i})=>r?`trackID_${r}`:`order_${i}`,W=r=>{if(S.length===0)return;const i=d.filter(a=>r!==a.attribute),P=n.filter(a=>r!==a.attribute),b=s.filter(a=>r!==a.attribute),h=l.filter(a=>r!==a.attribute),x=O.filter(a=>r!==a.attribute);H(P,i,h,b,x),C(i),L(P),c(h),y(b),$(x),T({pointCloudBoxList:P,polygonList:i,lineList:b,pointCloudSphereList:h,segmentation:x})},q=r=>{z.confirm({content:A.t("onDeleteGraphByAttr",{attribute:r.key}),onOk:()=>{W(r.value)},okText:A.t("Confirm"),cancelText:A.t("Cancel")})};return t.createElement(t.Fragment,null,t.createElement("div",{className:u("annotated-attribute","item")},U?t.createElement(X,{onClick:w}):t.createElement(Y,{onClick:w}),t.createElement(Z,{rotate:E?0:270,onClick:()=>{G(!E)}}),t.createElement("span",{className:u("annotated-attribute","item","text"),onClick:()=>{V(e.value)}},e.key),t.createElement(tt,{onClick:()=>q(e)})),E&&S.map((r,i)=>t.createElement("div",{key:K(B(D({},r),{order:i})),style:{paddingLeft:54}},`${M(B(D({},r),{order:i}))}.${e.key}`)))},v=()=>{const e=F(Q),{attrPanelLayout:o,setAttrPanelLayout:n,pointCloudBoxList:l,pointCloudSphereList:m,polygonList:p,lineList:d,segmentation:C}=g(f),{t:s}=j(),y=k(()=>[...l,...m,...p,...d,...C].map(c=>c.attribute),[l,m,p,d,C]),L=k(()=>e.attributeList.filter(c=>y.includes(c.value)),[y]);return t.createElement("div",{className:u("annotated-attribute")},o?t.createElement("div",{className:u("annotated-attribute","text")},t.createElement("span",null,s("AnnotatedResult")),t.createElement("span",{className:u("annotated-attribute","pin"),onClick:()=>{n("")}},t.createElement(_,null),s("CancelFixed"))):t.createElement("div",{className:u("annotated-attribute","text")},t.createElement("span",{onClick:()=>{n("left")},className:u("annotated-attribute","pin")},t.createElement(_,null),s("FixedOnLeft")),t.createElement("span",{onClick:()=>{n("right")},className:u("annotated-attribute","pin")},t.createElement(_,null),s("FixedOnRight"))),t.createElement("div",null,L.length>0?L.map(c=>t.createElement(ut,{attribute:c,key:c.value})):t.createElement("div",{style:{textAlign:"center",height:200,lineHeight:"200px"}},s("NoData"))))},mt=()=>{const{attrPanelLayout:e}=g(f);return e==="left"?t.createElement(v,null):null},pt=()=>{const{attrPanelLayout:e}=g(f);return e==="right"?t.createElement(v,null):null},dt=()=>{const{attrPanelLayout:e}=g(f),{t:o}=j(),n=F(l=>{var m,p;return nt.getCurrentStepInfo((m=l==null?void 0:l.annotation)==null?void 0:m.step,(p=l.annotation)==null?void 0:p.stepList)});return(n==null?void 0:n.tool)!==ot.PointCloud||e?null:t.createElement(rt,{hoverIcon:t.createElement(N,{style:{marginRight:4}}),icon:t.createElement(N,{style:{marginRight:4}}),title:o("AnnotatedList"),content:t.createElement(v,null)})};export{dt as AnnotatedAttributesIcon,v as AnnotatedAttributesPanel,mt as AnnotatedAttributesPanelFixedLeft,pt as AnnotatedAttributesPanelFixedRight};
1
+ import{PointCloudContext as f}from"../../../../components/pointCloudView/PointCloudContext.js";import{Modal as z}from"antd";import t,{useContext as g,useMemo as k,useState as J}from"react";import{stepConfigSelector as Q}from"../../../../store/annotation/selectors.js";import{useSelector as F}from"../../../../store/ctx.js";import{i18n as A}from"@labelbee/lb-utils";import{UnorderedListOutlined as j,PushpinFilled as _,EyeInvisibleFilled as X,EyeFilled as Y,CaretDownFilled as Z,DeleteOutlined as tt}from"@ant-design/icons";import{useHistory as et}from"../../../../components/pointCloudView/hooks/useHistory.js";import{getClassName as u}from"../../../../utils/dom.js";import nt from"../../../../utils/StepUtils.js";import{EPointCloudName as ot}from"@labelbee/lb-annotation";import{useTranslation as N}from"react-i18next";import rt from"../FooterPopover.js";import it from"../../../../components/longText/index.js";var lt=Object.defineProperty,at=Object.defineProperties,st=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,ct=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,R=(e,o,n)=>o in e?lt(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n,B=(e,o)=>{for(var n in o||(o={}))ct.call(o,n)&&R(e,n,o[n]);if(I)for(var n of I(o))ut.call(o,n)&&R(e,n,o[n]);return e},D=(e,o)=>at(e,st(o));const mt=({attribute:e})=>{const o=g(f),{pointCloudBoxList:n,pointCloudSphereList:l,hideAttributes:m,toggleAttributesVisible:p,polygonList:d,setPolygonList:y,lineList:s,setLineList:C,setPointCloudResult:L,setPointCloudSphereList:c,reRender:T,selectSpecAttr:H,segmentation:w,setSegmentation:V}=o,[E,$]=J(!0),{pushHistoryWithList:G}=et(),O=[...n,...d,...l,...s,...w].filter(r=>r.attribute===e.value),S=()=>{p(e.value)},U=m.includes(e.value),M=({trackID:r,order:i})=>r||i,K=({trackID:r,order:i})=>r?`trackID_${r}`:`order_${i}`,W=r=>{if(O.length===0)return;const i=d.filter(a=>r!==a.attribute),P=n.filter(a=>r!==a.attribute),b=s.filter(a=>r!==a.attribute),h=l.filter(a=>r!==a.attribute),x=w.filter(a=>r!==a.attribute);T(P,i,h,b,x),y(i),L(P),c(h),C(b),V(x),G({pointCloudBoxList:P,polygonList:i,lineList:b,pointCloudSphereList:h,segmentation:x})},q=r=>{z.confirm({content:A.t("onDeleteGraphByAttr",{attribute:r.key}),onOk:()=>{W(r.value)},okText:A.t("Confirm"),cancelText:A.t("Cancel")})};return t.createElement(t.Fragment,null,t.createElement("div",{className:u("annotated-attribute","item")},U?t.createElement(X,{onClick:S}):t.createElement(Y,{onClick:S}),t.createElement(Z,{rotate:E?0:270,onClick:()=>{$(!E)}}),t.createElement("span",{className:u("annotated-attribute","item","text"),style:{width:"100%",overflow:"hidden"},onClick:()=>{H(e.value)}},t.createElement(it,{text:e.key,openByText:!0})),t.createElement(tt,{onClick:()=>q(e)})),E&&O.map((r,i)=>t.createElement("div",{key:K(D(B({},r),{order:i})),style:{paddingLeft:54}},`${M(D(B({},r),{order:i}))}.${e.key}`)))},v=()=>{const e=F(Q),{attrPanelLayout:o,setAttrPanelLayout:n,pointCloudBoxList:l,pointCloudSphereList:m,polygonList:p,lineList:d,segmentation:y}=g(f),{t:s}=N(),C=k(()=>[...l,...m,...p,...d,...y].map(c=>c.attribute),[l,m,p,d,y]),L=k(()=>e.attributeList.filter(c=>C.includes(c.value)),[C]);return t.createElement("div",{className:u("annotated-attribute")},o?t.createElement("div",{className:u("annotated-attribute","text")},t.createElement("span",null,s("AnnotatedResult")),t.createElement("span",{className:u("annotated-attribute","pin"),onClick:()=>{n("")}},t.createElement(_,null),s("CancelFixed"))):t.createElement("div",{className:u("annotated-attribute","text")},t.createElement("span",{onClick:()=>{n("left")},className:u("annotated-attribute","pin")},t.createElement(_,null),s("FixedOnLeft")),t.createElement("span",{onClick:()=>{n("right")},className:u("annotated-attribute","pin")},t.createElement(_,null),s("FixedOnRight"))),t.createElement("div",null,L.length>0?L.map(c=>t.createElement(mt,{attribute:c,key:c.value})):t.createElement("div",{style:{textAlign:"center",height:200,lineHeight:"200px"}},s("NoData"))))},pt=()=>{const{attrPanelLayout:e}=g(f);return e==="left"?t.createElement(v,null):null},dt=()=>{const{attrPanelLayout:e}=g(f);return e==="right"?t.createElement(v,null):null},ft=()=>{const{attrPanelLayout:e}=g(f),{t:o}=N(),n=F(l=>{var m,p;return nt.getCurrentStepInfo((m=l==null?void 0:l.annotation)==null?void 0:m.step,(p=l.annotation)==null?void 0:p.stepList)});return(n==null?void 0:n.tool)!==ot.PointCloud||e?null:t.createElement(rt,{hoverIcon:t.createElement(j,{style:{marginRight:4}}),icon:t.createElement(j,{style:{marginRight:4}}),title:o("AnnotatedList"),content:t.createElement(v,null)})};export{ft as AnnotatedAttributesIcon,v as AnnotatedAttributesPanel,pt as AnnotatedAttributesPanelFixedLeft,dt as AnnotatedAttributesPanelFixedRight};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.14.0-alpha.8",
3
+ "version": "1.14.0",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -43,8 +43,8 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "^4.6.2",
46
- "@labelbee/lb-annotation": "1.18.0-alpha.6",
47
- "@labelbee/lb-utils": "1.10.0-alpha.4",
46
+ "@labelbee/lb-annotation": "1.18.0",
47
+ "@labelbee/lb-utils": "1.10.0",
48
48
  "ahooks": "^3.4.0",
49
49
  "classnames": "^2.3.0",
50
50
  "lodash": "^4.17.21",