@labelbee/lb-components 1.10.0-alpha.13 → 1.10.0-alpha.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/pointCloudView/PointCloudTopView.js +1 -1
- package/dist/components/pointCloudView/hooks/useHistory.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/components/pointCloudView/hooks/useSphere.js +1 -1
- package/dist/components/pointCloudView/hooks/useStatus.js +1 -1
- package/dist/types/components/pointCloudView/hooks/useSphere.d.ts +1 -0
- package/es/components/pointCloudView/PointCloudTopView.js +1 -1
- package/es/components/pointCloudView/hooks/useHistory.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/hooks/useSphere.js +1 -1
- package/es/components/pointCloudView/hooks/useStatus.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var dom=require("../../utils/dom.js"),index$1=require("../../views/MainView/toolFooter/index.js"),index$2=require("../../views/MainView/toolFooter/ZoomController/index.js"),icons=require("@ant-design/icons"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudInfos=require("./PointCloudInfos.js"),usePolygon=require("./hooks/usePolygon.js"),useSphere=require("./hooks/useSphere.js"),useZoom=require("./hooks/useZoom.js"),antd=require("antd"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index=require("../../utils/index.js"),ToolUtils=require("../../utils/ToolUtils.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}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=(t,n,
|
|
1
|
+
"use strict";var dom=require("../../utils/dom.js"),index$1=require("../../views/MainView/toolFooter/index.js"),index$2=require("../../views/MainView/toolFooter/ZoomController/index.js"),icons=require("@ant-design/icons"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudInfos=require("./PointCloudInfos.js"),usePolygon=require("./hooks/usePolygon.js"),useSphere=require("./hooks/useSphere.js"),useZoom=require("./hooks/useZoom.js"),antd=require("antd"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index=require("../../utils/index.js"),ToolUtils=require("../../utils/ToolUtils.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}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=(t,n,i)=>n in t?__defProp(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i,__spreadValues=(t,n)=>{for(var i in n||(n={}))__hasOwnProp.call(n,i)&&__defNormalProp(t,i,n[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(n))__propIsEnum.call(n,i)&&__defNormalProp(t,i,n[i]);return t},__spreadProps=(t,n)=>__defProps(t,__getOwnPropDescs(n));const{EPolygonPattern,EToolName}=lbAnnotation.cTool,{ESortDirection}=lbAnnotation.cAnnotation,TransferCanvas2WorldOffset=(t,n,i=1)=>{const{width:v,height:C}=n,m={x:t.x+v*i/2,y:t.y+C*i/2},g={x:n.width/2,y:n.height/2};return{offsetX:(g.x-m.x)/i,offsetY:-(g.y-m.y)/i}},TopViewToolbar=({currentData:t})=>{var n,i;const{zoom:v,zoomIn:C,zoomOut:m,initialPosition:g}=useZoom.useZoom(),{selectNextBox:x,selectPrevBox:I}=useSingleBox.useSingleBox(),{switchToNextSphere:w}=useSphere.useSphere(),{updateRotate:u}=useRotate.useRotate({currentData:t}),e=React__default.default.useContext(PointCloudContext.PointCloudContext),a=(i=(n=e==null?void 0:e.topViewInstance)==null?void 0:n.toolScheduler)==null?void 0:i.getCurrentToolName(),p=2,h=()=>{u(-p)},y=()=>{u(p)},V=()=>{u(180)};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement("span",{onClick:y,className:dom.getClassName("point-cloud","rotate-reserve")}),React__default.default.createElement("span",{onClick:h,className:dom.getClassName("point-cloud","rotate")}),React__default.default.createElement("span",{onClick:V,className:dom.getClassName("point-cloud","rotate-180")}),React__default.default.createElement(index$1.FooterDivider,null),React__default.default.createElement(icons.UpSquareOutlined,{onClick:()=>{a===EToolName.PointCloudPolygon&&I(),a===EToolName.Point&&w(ESortDirection.descend)},className:dom.getClassName("point-cloud","prev")}),React__default.default.createElement(icons.DownSquareOutlined,{onClick:()=>{a===EToolName.PointCloudPolygon&&x(),a===EToolName.Point&&w(ESortDirection.ascend)},className:dom.getClassName("point-cloud","next")}),React__default.default.createElement(index$1.FooterDivider,null),React__default.default.createElement(index$2.ZoomController,{initialPosition:g,zoomIn:C,zoomOut:m,zoom:v}))},ZAxisSlider=({setZAxisLimit:t,zAxisLimit:n,checkMode:i})=>i?null:React__default.default.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},React__default.default.createElement(antd.Slider,{vertical:!0,step:.5,max:10,min:.5,defaultValue:n,onAfterChange:v=>{t(v)}})),PointCloudTopView=({currentData:t,imgList:n,stepInfo:i,drawLayerSlot:v,checkMode:C,intelligentFit:m})=>{var g,x;const[I,w]=React.useState({zoom:1,currentPos:{x:0,y:0}}),u=React.useRef(null),e=React__default.default.useContext(PointCloudContext.PointCloudContext),a=useSize(u),p=index.jsonParser(i.config),{setZoom:h,syncTopviewToolZoom:y}=useZoom.useZoom(),{hideAttributes:V}=e,{addPolygon:L,deletePolygon:j}=usePolygon.usePolygon(),{deletePointCloudSphere:N}=useSphere.useSphere(),{deletePointCloudBox:T,changeValidByID:A}=useSingleBox.useSingleBox(),[S,B]=React.useState(10),{t:k}=reactI18next.useTranslation(),P=usePointCloudViews.usePointCloudViews();return React.useLayoutEffect(()=>{if(!e.topViewInstance&&u.current&&(t==null?void 0:t.url)&&(t==null?void 0:t.result)){const l={width:u.current.clientWidth,height:u.current.clientHeight},d=new lbAnnotation.PointCloudAnnotation({container:u.current,size:l,pcdPath:t.url,config:__spreadProps(__spreadValues({},p),{pointCloudPattern:e.pointCloudPattern}),checkMode:C,toolName:ToolUtils.getPointCloudToolList(),proxyMode:C});e.setTopViewInstance(d)}},[t]),React.useEffect(()=>{if(!a||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:l}=e.topViewInstance;l.singleOn("dataUpdated",(o,s)=>{e.setSelectedIDs(s),e.setLineList(o)}),l.singleOn("pointCreated",(o,s)=>{P.topViewAddSphere({newPoint:o,size:a,trackConfigurable:p.trackConfigurable,zoom:s})}),l.singleOn("pointDeleted",o=>{N(o)}),l.singleOn("pointSelected",o=>{e.setSelectedIDs([o])}),l.singleOn("updatePointByDrag",(o,s)=>{var c;(c=P.topViewUpdatePoint)==null||c.call(P,o,a)}),l.singleOn("polygonCreated",(o,s)=>{if(l.pattern===EPolygonPattern.Normal||!(t==null?void 0:t.url)){const c=__spreadProps(__spreadValues({},o),{pointList:o.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,a))});L(c),e.setSelectedIDs(V.includes(o.attribute)?"":o.id);return}P.topViewAddBox({polygon:o,size:a,imgList:n,trackConfigurable:p.trackConfigurable,zoom:s,intelligentFit:m})}),l.singleOn("deletedObject",({id:o})=>{T(o),j(o)}),l.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),l.singleOn("addSelectedIDs",o=>{e.addSelectedID(o)}),l.singleOn("setSelectedIDs",o=>{e.setSelectedIDs(o)}),l.singleOn("updatePolygonByDrag",o=>{var s;(s=P.topViewUpdateBox)==null||s.call(P,o,a)});const d=o=>{var s;const c=A(o);c&&e.syncAllViewPointCloudColor(c),e.polygonList.find(r=>r.id===o)&&((s=e.topViewInstance)==null||s.toolInstance.setPolygonValidAndRender(o,!0))};return l.on("validUpdate",d),()=>{l.unbind("validUpdate",d)}},[e,a,t,P,e.polygonList,e.lineList,(g=e.topViewInstance)==null?void 0:g.toolInstance]),React.useEffect(()=>{var l,d;if(!(a==null?void 0:a.width)||!e.topViewInstance)return;const o=(d=(l=p==null?void 0:p.attributeList)==null?void 0:l[0])==null?void 0:d.value;o&&e.topViewInstance.toolInstance.setDefaultAttribute(o),e.topViewInstance.initSize(a),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:s,toolInstance:c}}=e;c.singleOn("renderZoom",(r,f)=>{const{offsetX:b,offsetY:_}=TransferCanvas2WorldOffset(f,a,r);if(s.camera.zoom=r,f){const{x:O,y:E,z:q}=s.initCameraPosition;s.camera.position.set(O+_,E-b,q)}s.camera.updateProjectionMatrix(),s.render(),h(r),y(f,r,a),w({zoom:r,currentPos:f})}),c.singleOn("dragMove",({currentPos:r,zoom:f})=>{const{offsetX:b,offsetY:_}=TransferCanvas2WorldOffset(r,a,f);s.camera.zoom=f;const{x:O,y:E,z:q}=s.initCameraPosition;s.camera.position.set(O+_,E-b,q),s.render(),y(r,f,a),w({zoom:f,currentPos:r})})},[a,e.topViewInstance,(x=e.topViewInstance)==null?void 0:x.toolInstance]),React.useEffect(()=>{var l,d;(d=(l=e.topViewInstance)==null?void 0:l.pointCloudInstance)==null||d.applyZAxisPoints(S)},[S]),React.useEffect(()=>{P.topViewSelectedChanged({})},[e.selectedIDs]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","top-view"),title:k("TopView"),toolbar:React__default.default.createElement(TopViewToolbar,{currentData:t})},React__default.default.createElement("div",{style:{position:"relative",flex:1}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"},ref:u},v==null?void 0:v(I)),React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:C,config:p}),React__default.default.createElement(ZAxisSlider,{checkMode:C,zAxisLimit:S,setZAxisLimit:B}),React__default.default.createElement(PointCloudInfos.PointCloudValidity,null)))};var PointCloudTopView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudTopView);module.exports=PointCloudTopView$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,s,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,s,l)=>s in e?__defProp(e,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[s]=l,__spreadValues=(e,s)=>{for(var l in s||(s={}))__hasOwnProp.call(s,l)&&__defNormalProp(e,l,s[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(s))__propIsEnum.call(s,l)&&__defNormalProp(e,l,s[l]);return e};const useHistory=()=>{const{history:e,setPointCloudResult:s,setSelectedIDs:l,pointCloudBoxList:p,pointCloudSphereList:L,setPointCloudSphereList:x,mainViewInstance:u,topViewInstance:y,polygonList:f,setPolygonList:P,lineList:C,setLineList:g,syncAllViewPointCloudColor:_}=React.useContext(PointCloudContext.PointCloudContext),S=({newBoxParams:t,newPolygon:o,newLine:i,newSphereParams:r})=>{const d={pointCloudBoxList:p,polygonList:f,lineList:C,pointCloudSphereList:L};t&&(d.pointCloudBoxList=p.concat(t)),o&&(d.polygonList=f.concat(o)),i&&(d.lineList=C.concat(i)),r&&(d.pointCloudSphereList=L.concat(r)),e.pushHistory(d)},B=t=>{const o={pointCloudBoxList:p,polygonList:f,lineList:C,pointCloudSphereList:L};t.pointCloudBoxList&&(o.pointCloudBoxList=t.pointCloudBoxList),t.polygonList&&(o.polygonList=t.polygonList),t.lineList&&(o.lineList=t.lineList),t.pointCloudSphereList&&(o.pointCloudSphereList=t.pointCloudSphereList),e.pushHistory(o)},H=t=>{if(C.find(i=>i.id===t.id)){const i=C.map(r=>r.id===t.id?t:__spreadValues({},r));e.pushHistory({lineList:i}),g(i)}},O=t=>{if(f.find(i=>i.id===t.id)){const i=f.map(r=>r.id===t.id?t:__spreadValues({},r));e.pushHistory({pointCloudBoxList:p,polygonList:i}),P(i)}},w=({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:i})=>{e.initRecord({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:i},!0)},v=t=>{if(!t)return;const{pointCloudBoxList:o=[],polygonList:i=[],lineList:r=[],pointCloudSphereList:d=[]}=t;if(o){p.length!==o.length&&l();const h=p.filter(n=>o.every(c=>c.id!==n.id)),a=o.filter(n=>p.every(c=>c.id!==n.id));h.forEach(n=>{u==null||u.removeObjectByName(n.id)}),a.forEach(n=>{u==null||u.generateBox(n)}),s(o),_(o)}if(d){L.length!==d.length&&l();let h=L.filter(n=>d.every(c=>c.id!==n.id)),a=d.filter(n=>L.every(c=>c.id!==n.id));h.forEach(n=>{u==null||u.removeObjectByName(n.id)}),a.forEach(n=>{u==null||u.generateSphere(n)}),x(d)}i&&P(i),r&&g(r),y==null||y.updatePolygonList(o!=null?o:[],i!=null?i:[]),y==null||y.updateLineList(r!=null?r:[]),y==null||y.updatePointList(d)};return{addHistory:S,pushHistoryWithList:B,initHistory:w,pushHistoryUnderUpdatePolygon:O,pushHistoryUnderUpdateLine:H,redo:()=>{v(e.redo())},undo:()=>{v(e.undo())}}};exports.useHistory=useHistory;
|
|
@@ -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=(t,o,i)=>o in t?__defProp(t,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[o]=i,__spreadValues=(t,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(t,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(t,i,o[i]);return t},__spreadProps=(t,o)=>__defProps(t,__getOwnPropDescs(o)),__async=(t,o,i)=>new Promise((r,e)=>{var c=l=>{try{s(i.next(l))}catch(h){e(h)}},p=l=>{try{s(i.throw(l))}catch(h){e(h)}},s=l=>l.done?r(l.value):Promise.resolve(l.value).then(c,p);s((i=i.apply(t,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(t,o,i,r,e)=>{const{x:c,y:p}=lbUtils.PointCloudUtils.transferCanvas2World(t,o),{defaultZ:s}=lbUtils.DEFAULT_SPHERE_PARAMS,l={center:{x:c,y:p,z:s},id:t.id},h=r?__spreadValues(__spreadValues({},r),l):__spreadProps(__spreadValues({},l),{attribute:"",valid:!0});return e&&Object.assign(h,e),h},topViewPolygon2PointCloud=(t,o,i,r,e,c)=>{let p=t.pointList.map(y=>lbUtils.PointCloudUtils.transferCanvas2World(y,o)),s=0,l=1,h={};if(i){const y=i.getSensesPointZAxisInPolygon(p,void 0,c);c&&y.fittedCoordinates.length>0&&(p=y.fittedCoordinates),s=(y.maxZ+y.minZ)/2,l=y.maxZ-y.minZ,h={count:y.zCount}}const[g,x,_]=p,V=lbAnnotation.MathUtils.getLineCenterPoint([g,_]),O=lbAnnotation.MathUtils.getLineLength(g,x),k=lbAnnotation.MathUtils.getLineLength(x,_),A=lbAnnotation.MathUtils.getRadiusFromQuadrangle(t.pointList);r&&(s=r.center.z,l=r.depth);const I={center:{x:V.x,y:V.y,z:s},width:k,height:O,depth:l,rotation:A,id:t.id},S=__spreadValues(r?__spreadValues(__spreadValues({},r),I):__spreadProps(__spreadValues({},I),{attribute:"",valid:!0}),h);e&&Object.assign(S,e);const j=p.map(y=>lbUtils.PointCloudUtils.transferWorld2Canvas(y,o));return{boxParams:S,newPointList:j}},sideViewPoint2PointCloud=(t,o,i)=>{const r={x:t.x-o.x,y:t.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-r.x,y:i.center.y,z:i.center.z-r.y}})},sideViewPolygon2PointCloud=(t,o,i,r)=>{const[e,c,p]=t.pointList,[s,l,h]=o.pointList,g=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([s,h]),V={x:{x:g.x-x.x,y:g.y-x.y}.x,y:0,z:g.y-x.y},O=lbAnnotation.MathUtils.getLineLength(e,c),k=lbAnnotation.MathUtils.getLineLength(s,l),A=O-k,I=lbAnnotation.MathUtils.getLineLength(c,p),S=lbAnnotation.MathUtils.getLineLength(l,h),j=I-S,{newBoxParams:y}=r.getNewBoxBySideUpdate(V,j,A,i);return y},backViewPoint2PointCloud=(t,o,i)=>{const r={x:t.x-o.x,y:t.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-r.x,z:i.center.z-r.y}})},backViewPolygon2PointCloud=(t,o,i,r)=>{const[e,c,p]=t.pointList,[s,l,h]=o.pointList,g=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([s,h]),V={x:{x:g.x-x.x,y:g.y-x.y}.x,y:0,z:g.y-x.y},O=lbAnnotation.MathUtils.getLineLength(e,c),k=lbAnnotation.MathUtils.getLineLength(s,l),A=O-k,I=lbAnnotation.MathUtils.getLineLength(c,p),S=lbAnnotation.MathUtils.getLineLength(l,h),j=I-S;let{newBoxParams:y}=r.getNewBoxByBackUpdate(V,j,A,i);return y},syncSideViewByPoint=(t,o,i,r,e)=>{var c;if(!i)return;const{toolInstance:p,pointCloudInstance:s}=i;s.loadPCDFile(r,(c=e==null?void 0:e.radius)!=null?c:DEFAULT_RADIUS);const{cameraPositionVector:l}=s.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Left);s.setInitCameraPosition(l);const{point2d:h,zoom:g}=s.getSphereSidePoint2DCoordinate(t);s.camera.zoom=g,s.camera.updateProjectionMatrix(),s.render(),p.initPosition(),p.zoomChangeOnCenter(g),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),h),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(o.id)},synchronizeSideView=(t,o,i,r)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:c}=i;c.loadPCDFileByBox(r,t,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=c.updateOrthoCamera(t,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(p);const{polygon2d:s,zoom:l}=c.getBoxSidePolygon2DCoordinate(t);c.camera.zoom=l,c.camera.updateProjectionMatrix(),c.render(),e.initPosition(),e.zoomChangeOnCenter(l),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:s,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},syncBackViewByPoint=(t,o,i,r,e)=>{var c;if(!i)return;const{toolInstance:p,pointCloudInstance:s}=i;s.loadPCDFile(r,(c=e==null?void 0:e.radius)!=null?c:DEFAULT_RADIUS);const{cameraPositionVector:l}=s.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Back);s.setInitCameraPosition(l);const{point2d:h,zoom:g}=s.getSphereBackPoint2DCoordinate(t);s.camera.zoom=g,s.camera.updateProjectionMatrix(),s.render(),p.initPosition(),p.zoomChangeOnCenter(g),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),h),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(o.id)},synchronizeBackView=(t,o,i,r)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:c}=i;c.loadPCDFileByBox(r,t,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=c.updateOrthoCamera(t,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(p);const{polygon2d:s,zoom:l}=c.getBoxBackPolygon2DCoordinate(t);c.camera.zoom=l,c.camera.updateProjectionMatrix(),c.render(),e.initPosition(),e.zoomChangeOnCenter(l),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:s,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},syncTopViewByPoint=(t,o,i,r)=>{if(!i||!r)return;r.generateSphere(t),r.updateCameraBySphere(t,lbUtils.EPerspectiveView.Top),r.render();const{toolInstance:e,pointCloudInstance:c}=i,{point2d:p}=c.getSphereTopPoint2DCoordinate(t),s=[...e.pointList].map(l=>l.id===o.id?__spreadProps(__spreadValues(__spreadValues({},o),p),{valid:t.valid,textAttribute:"",attribute:t.attribute}):l);e.setResult(s),e.setSelectedID(o.id)},synchronizeTopView=(t,o,i,r)=>{var e;if(!i||!r)return;r.generateBox(t,o.id),r.render();const{pointCloud2dOperation:c,pointCloudInstance:p}=i,{polygon2d:s}=p.getBoxTopPolygon2DCoordinate(t),l=[...c.polygonList],h=l.find(g=>g.id===o.id);h?h.pointList=s:l.push({id:o.id,pointList:s,textAttribute:"",isRect:!0,valid:(e=t.valid)!=null?e:!0}),c.setResultAndSelectedID(l,o.id)},usePointCloudViews=()=>{const t=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:i,backViewInstance:r,mainViewInstance:e,addPointCloudBox:c,addPointCloudSphere:p,setSelectedIDs:s,selectedIDs:l,pointCloudBoxList:h,pointCloudSphereList:g,hideAttributes:x}=t,{addHistory:_,initHistory:V,pushHistoryUnderUpdatePolygon:O,pushHistoryUnderUpdateLine:k}=useHistory.useHistory(),{selectedPolygon:A}=usePolygon.usePolygon(),{updateSelectedBox:I,updateSelectedBoxes:S,getPointCloudByID:j}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:y,updatePointCloudSphere:H,selectedSphere:z}=useSphere.useSphere(),{currentData:w,config:L}=ctx.useSelector(n=>{const{stepList:a,step:P,imgList:u,imgIndex:d}=n.annotation;return{currentData:u[d],config:index.jsonParser(StepUtils.getCurrentStepInfo(P,a).config)}}),F=ctx.useDispatch(),{selectedBox:T}=useSingleBox.useSingleBox(),{t:G}=reactI18next.useTranslation(),N=T==null?void 0:T.info;if(!o||!i||!r)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:E}=o,Q=n=>{e==null||e.generateBox(n),e==null||e.controls.update(),e==null||e.render()},X=n=>{e==null||e.generateSphere(n),e==null||e.controls.update(),e==null||e.render()},Y=({newPoint:n,size:a,zoom:P,trackConfigurable:u})=>{var d;const C={attribute:(d=o.toolInstance.defaultAttribute)!=null?d:""};u===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:g})});const f=topViewPoint2PointCloud(n,a,E,void 0,C);s(n.id);const v=p(f);M(PointCloudView.Top,n,f,P,v,L),_({newSphereParams:f})},J=({polygon:n,size:a,imgList:P,trackConfigurable:u,zoom:d,intelligentFit:C})=>{var f;const v={attribute:(f=o.toolInstance.defaultAttribute)!=null?f:""};u===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:g})});const m=o==null?void 0:o.toolInstance,b=__spreadValues({},n),{boxParams:B,newPointList:D}=topViewPolygon2PointCloud(b,a,E,void 0,v,C);if((L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(G("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),m.deletePolygon(B.id);return}C&&(D==null?void 0:D.length)&&(b.pointList=D);const q=x.includes(b.attribute),U=c(B);q?s([]):(s(B.id),m.setSelectedIDs([b.id]),R(PointCloudView.Top,b,B,d,U),C&&synchronizeTopView(B,b,o,e)),_({newBoxParams:B})},K=({newSelectedBox:n,newPointCloudList:a,newSelectedSphere:P,newSphereList:u})=>{const d=o==null?void 0:o.toolInstance;if(!(l.length===0||!d)){if(n||(T==null?void 0:T.info)){const C=n!=null?n:T==null?void 0:T.info;d.setSelectedIDs(l);const f=d.selectedPolygon;if(l.length===1&&C){R(PointCloudView.Top,f,C,void 0,a);return}}if((P||z)&&l.length===1){const C=P!=null?P:z;d.setSelectedID(l[0]);const f=d.selectedPoint;C&&M(PointCloudView.Top,f,C,void 0,u,L)}}},Z=(n,a,P)=>{if(N){let u,d;switch(P){case PointCloudView.Back:u=backViewPolygon2PointCloud;break;case PointCloudView.Side:u=sideViewPolygon2PointCloud;break;default:u=sideViewPolygon2PointCloud;break}if(d=u(n,a,N,i.pointCloudInstance),e){const{count:f}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(d).polygonPointList,[d.center.z-d.depth/2,d.center.z+d.depth/2]);d=__spreadProps(__spreadValues({},d),{count:f})}const C=I(d);return R(P,n,d,void 0,C),C}},W=(n,a,P)=>{if(z){let u,d;switch(P){case PointCloudView.Back:u=backViewPoint2PointCloud;break;case PointCloudView.Side:u=sideViewPoint2PointCloud;break;default:u=sideViewPoint2PointCloud;break}d=u(n,a,z);const C=H(d);return M(P,n,d,void 0,C,L),C}},$=(n,a)=>{W(n,a,PointCloudView.Side)},tt=(n,a)=>{W(n,a,PointCloudView.Back)},et=(n,a)=>{Z(n,a,PointCloudView.Side)},ot=(n,a)=>{Z(n,a,PointCloudView.Back)},it=(n,a)=>{k(n)},nt=(n,a)=>{const P=y(n.id),u=topViewPoint2PointCloud(n,a,E,P),d=H(u);M(PointCloudView.Top,n,u,void 0,d,L)},st=(n,a)=>{if(A){const u=n[0].newPolygon;u.pointList=u.pointList.map(d=>lbUtils.PointCloudUtils.transferCanvas2World(d,a)),O(n[0].newPolygon);return}const P=n.map(({newPolygon:u})=>{const d=j(u.id),{boxParams:C}=topViewPolygon2PointCloud(u,a,o.pointCloudInstance,d);return C});if(P.length===1){const{newPolygon:u}=n[0],d=S(P);R(PointCloudView.Top,u,P[0],void 0,d)}else{const u=S(P);u&&t.syncAllViewPointCloudColor(u)}},M=(n,a,P,u,d,C)=>__async(void 0,null,function*(){const f=w==null?void 0:w.url,v={[PointCloudView.Side]:()=>{syncSideViewByPoint(P,a,i,f,C)},[PointCloudView.Back]:()=>{r&&syncBackViewByPoint(P,a,r,f,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(P,a,o,e)}};Object.keys(v).forEach(m=>{m!==n&&v[m]()}),u&&(e==null||e.updateCameraZoom(u)),X(P)}),R=(n,a,P,u,d)=>__async(void 0,null,function*(){const C=w==null?void 0:w.url;d&&(yield t.syncAllViewPointCloudColor(d));const f={[PointCloudView.Side]:()=>{synchronizeSideView(P,a,i,C)},[PointCloudView.Back]:()=>{r&&synchronizeBackView(P,a,r,C)},[PointCloudView.Top]:()=>{synchronizeTopView(P,a,o,e)}};Object.keys(f).forEach(v=>{v!==n&&f[v]()}),u&&(e==null||e.updateCameraZoom(u)),Q(P)});return{topViewAddSphere:Y,topViewAddBox:J,topViewSelectedChanged:K,topViewUpdatePoint:nt,sideViewUpdatePoint:$,backViewUpdatePoint:tt,topViewUpdateBox:st,topViewUpdateLine:it,sideViewUpdateBox:et,backViewUpdateBox:ot,pointCloudBoxListUpdated:n=>{o.updatePolygonList(n),e==null||e.generateBoxes(n)},initPointCloud3d:n=>{if(!e)return;const a={left:-n.width/2,right:n.width/2,top:n.height/2,bottom:-n.height/2,near:100,far:-100};e.initOrthographicCamera(a),e.initRenderer(),e.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(a=w){var P,u,d,C,f,v;if(!(a==null?void 0:a.url)||!e)return;actionCreators.SetPointCloudLoading(F,!0),yield e.loadPCDFile(a.url,(P=L==null?void 0:L.radius)!=null?P:DEFAULT_RADIUS),h.forEach(U=>{e==null||e.removeObjectByName(U.id)}),g.forEach(U=>{e==null||e.removeObjectByName(U.id)});let m=[],b=[],B=[],D=[];w.result?(m=lbUtils.PointCloudUtils.getBoxParamsFromResultList(w.result),B=lbUtils.PointCloudUtils.getPolygonListFromResultList(w.result),b=lbUtils.PointCloudUtils.getLineListFromResultList(w.result),D=lbUtils.PointCloudUtils.getSphereParamsFromResultList(w.result),m.forEach(U=>{e==null||e.generateBox(U)}),D.forEach(U=>{e==null||e.generateSphere(U)}),t.syncAllViewPointCloudColor(m),t.setPointCloudResult(m),t.setPolygonList(B),t.setLineList(b),t.setPointCloudSphereList(D)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),V({pointCloudBoxList:m,polygonList:B,pointCloudSphereList:D}),e.updateTopCamera();const q=(d=(u=index.jsonParser(a.result))==null?void 0:u.valid)!=null?d:!0;t.setPointCloudValid(q),(C=t.sideViewInstance)==null||C.clearAllData(),(f=t.backViewInstance)==null||f.clearAllData(),o.updateData(a.url,a.result,{radius:(v=L==null?void 0:L.radius)!=null?v:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(F,!1)})}};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=(t,o,i)=>o in t?__defProp(t,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[o]=i,__spreadValues=(t,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(t,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(t,i,o[i]);return t},__spreadProps=(t,o)=>__defProps(t,__getOwnPropDescs(o)),__async=(t,o,i)=>new Promise((l,e)=>{var c=d=>{try{r(i.next(d))}catch(h){e(h)}},p=d=>{try{r(i.throw(d))}catch(h){e(h)}},r=d=>d.done?l(d.value):Promise.resolve(d.value).then(c,p);r((i=i.apply(t,o)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(t,o,i,l,e)=>{const{x:c,y:p}=lbUtils.PointCloudUtils.transferCanvas2World(t,o),{defaultZ:r}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:c,y:p,z:r},id:t.id},h=l?__spreadValues(__spreadValues({},l),d):__spreadProps(__spreadValues({},d),{attribute:"",valid:!0});return e&&Object.assign(h,e),h},topViewPolygon2PointCloud=(t,o,i,l,e,c)=>{let p=t.pointList.map(y=>lbUtils.PointCloudUtils.transferCanvas2World(y,o)),r=0,d=1,h={};if(i){const y=i.getSensesPointZAxisInPolygon(p,void 0,c);c&&y.fittedCoordinates.length>0&&(p=y.fittedCoordinates),r=(y.maxZ+y.minZ)/2,d=y.maxZ-y.minZ,h={count:y.zCount}}const[g,x,D]=p,U=lbAnnotation.MathUtils.getLineCenterPoint([g,D]),_=lbAnnotation.MathUtils.getLineLength(g,x),O=lbAnnotation.MathUtils.getLineLength(x,D),k=lbAnnotation.MathUtils.getRadiusFromQuadrangle(t.pointList);l&&(r=l.center.z,d=l.depth);const V={center:{x:U.x,y:U.y,z:r},width:O,height:_,depth:d,rotation:k,id:t.id},S=__spreadValues(l?__spreadValues(__spreadValues({},l),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),h);e&&Object.assign(S,e);const A=p.map(y=>lbUtils.PointCloudUtils.transferWorld2Canvas(y,o));return{boxParams:S,newPointList:A}},sideViewPoint2PointCloud=(t,o,i)=>{const l={x:t.x-o.x,y:t.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x-l.x,y:i.center.y,z:i.center.z-l.y}})},sideViewPolygon2PointCloud=(t,o,i,l)=>{const[e,c,p]=t.pointList,[r,d,h]=o.pointList,g=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,h]),U={x:{x:g.x-x.x,y:g.y-x.y}.x,y:0,z:g.y-x.y},_=lbAnnotation.MathUtils.getLineLength(e,c),O=lbAnnotation.MathUtils.getLineLength(r,d),k=_-O,V=lbAnnotation.MathUtils.getLineLength(c,p),S=lbAnnotation.MathUtils.getLineLength(d,h),A=V-S,{newBoxParams:y}=l.getNewBoxBySideUpdate(U,A,k,i);return y},backViewPoint2PointCloud=(t,o,i)=>{const l={x:t.x-o.x,y:t.y-o.y};return __spreadProps(__spreadValues({},i),{center:{x:i.center.x,y:i.center.y-l.x,z:i.center.z-l.y}})},backViewPolygon2PointCloud=(t,o,i,l)=>{const[e,c,p]=t.pointList,[r,d,h]=o.pointList,g=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,h]),U={x:{x:g.x-x.x,y:g.y-x.y}.x,y:0,z:g.y-x.y},_=lbAnnotation.MathUtils.getLineLength(e,c),O=lbAnnotation.MathUtils.getLineLength(r,d),k=_-O,V=lbAnnotation.MathUtils.getLineLength(c,p),S=lbAnnotation.MathUtils.getLineLength(d,h),A=V-S;let{newBoxParams:y}=l.getNewBoxByBackUpdate(U,A,k,i);return y},syncSideViewByPoint=(t,o,i,l,e)=>{var c;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(c=e==null?void 0:e.radius)!=null?c:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Left);r.setInitCameraPosition(d);const{point2d:h,zoom:g}=r.getSphereSidePoint2DCoordinate(t);r.camera.zoom=g,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(g),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),h),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(o.id)},synchronizeSideView=(t,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:c}=i;c.loadPCDFileByBox(l,t,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=c.updateOrthoCamera(t,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=c.getBoxSidePolygon2DCoordinate(t);c.camera.zoom=d,c.camera.updateProjectionMatrix(),c.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},syncBackViewByPoint=(t,o,i,l,e)=>{var c;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(c=e==null?void 0:e.radius)!=null?c:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Back);r.setInitCameraPosition(d);const{point2d:h,zoom:g}=r.getSphereBackPoint2DCoordinate(t);r.camera.zoom=g,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(g),p.setResult([__spreadProps(__spreadValues(__spreadValues({},o),h),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(o.id)},synchronizeBackView=(t,o,i,l)=>{if(!i)return;const{pointCloud2dOperation:e,pointCloudInstance:c}=i;c.loadPCDFileByBox(l,t,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=c.updateOrthoCamera(t,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=c.getBoxBackPolygon2DCoordinate(t);c.camera.zoom=d,c.camera.updateProjectionMatrix(),c.render(),e.initPosition(),e.zoomChangeOnCenter(d),e.setResultAndSelectedID([{id:o.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],o.id)},syncTopViewByPoint=(t,o,i,l)=>{if(!i||!l)return;l.generateSphere(t),l.updateCameraBySphere(t,lbUtils.EPerspectiveView.Top),l.render();const{toolInstance:e,pointCloudInstance:c}=i,{point2d:p}=c.getSphereTopPoint2DCoordinate(t),r=[...e.pointList].map(d=>d.id===o.id?__spreadProps(__spreadValues(__spreadValues({},o),p),{valid:t.valid,textAttribute:"",attribute:t.attribute}):d);e.setResult(r),e.setSelectedID(o.id)},synchronizeTopView=(t,o,i,l)=>{var e;if(!i||!l)return;l.generateBox(t,o.id),l.render();const{pointCloud2dOperation:c,pointCloudInstance:p}=i,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(t),d=[...c.polygonList],h=d.find(g=>g.id===o.id);h?h.pointList=r:d.push({id:o.id,pointList:r,textAttribute:"",isRect:!0,valid:(e=t.valid)!=null?e:!0}),c.setResultAndSelectedID(d,o.id)},usePointCloudViews=()=>{const t=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:i,backViewInstance:l,mainViewInstance:e,addPointCloudBox:c,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:d,pointCloudBoxList:h,pointCloudSphereList:g,hideAttributes:x}=t,{addHistory:D,initHistory:U,pushHistoryUnderUpdatePolygon:_,pushHistoryUnderUpdateLine:O}=useHistory.useHistory(),{selectedPolygon:k}=usePolygon.usePolygon(),{updateSelectedBox:V,updateSelectedBoxes:S,getPointCloudByID:A}=useSingleBox.useSingleBox(),{getPointCloudSphereByID:y,updatePointCloudSphere:H,selectedSphere:z}=useSphere.useSphere(),{currentData:T,config:L}=ctx.useSelector(n=>{const{stepList:s,step:P,imgList:u,imgIndex:a}=n.annotation;return{currentData:u[a],config:index.jsonParser(StepUtils.getCurrentStepInfo(P,s).config)}}),F=ctx.useDispatch(),{selectedBox:j}=useSingleBox.useSingleBox(),{t:G}=reactI18next.useTranslation(),N=j==null?void 0:j.info;if(!o||!i||!l)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:E}=o,Q=n=>{e==null||e.generateBox(n),e==null||e.controls.update(),e==null||e.render()},X=n=>{e==null||e.generateSphere(n),e==null||e.controls.update(),e==null||e.render()},Y=({newPoint:n,size:s,zoom:P,trackConfigurable:u})=>{var a;const C={attribute:(a=o.toolInstance.defaultAttribute)!=null?a:""};u===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:g})});const f=topViewPoint2PointCloud(n,s,E,void 0,C);r(n.id);const v=p(f);M(PointCloudView.Top,n,f,P,v,L),D({newSphereParams:f})},J=({polygon:n,size:s,imgList:P,trackConfigurable:u,zoom:a,intelligentFit:C})=>{var f;const v={attribute:(f=o.toolInstance.defaultAttribute)!=null?f:""};u===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:g})});const m=o==null?void 0:o.toolInstance,w=__spreadValues({},n),{boxParams:B,newPointList:I}=topViewPolygon2PointCloud(w,s,E,void 0,v,C);if((L==null?void 0:L.lowerLimitPointsNumInBox)&&typeof B.count=="number"&&B.count<L.lowerLimitPointsNumInBox){antd.message.info(G("LowerLimitPointsNumInBox",{num:L.lowerLimitPointsNumInBox})),m.deletePolygon(B.id);return}C&&(I==null?void 0:I.length)&&(w.pointList=I);const q=x.includes(w.attribute),b=c(B);q?r([]):(r(B.id),m.setSelectedIDs([w.id]),R(PointCloudView.Top,w,B,a,b),C&&synchronizeTopView(B,w,o,e)),D({newBoxParams:B})},K=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:P,newSphereList:u})=>{const a=o==null?void 0:o.toolInstance;if(!(d.length===0||!a)){if(n||(j==null?void 0:j.info)){const C=n!=null?n:j==null?void 0:j.info;a==null||a.setSelectedIDs(d);const f=a.selectedPolygon;if(d.length===1&&C){R(PointCloudView.Top,f,C,void 0,s);return}}if((P||z)&&d.length===1){const C=P!=null?P:z;a.setSelectedID(d[0]);const f=a.selectedPoint;C&&M(PointCloudView.Top,f,C,void 0,u,L)}}},Z=(n,s,P)=>{if(N){let u,a;switch(P){case PointCloudView.Back:u=backViewPolygon2PointCloud;break;case PointCloudView.Side:u=sideViewPolygon2PointCloud;break;default:u=sideViewPolygon2PointCloud;break}if(a=u(n,s,N,i.pointCloudInstance),e){const{count:f}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(a).polygonPointList,[a.center.z-a.depth/2,a.center.z+a.depth/2]);a=__spreadProps(__spreadValues({},a),{count:f})}const C=V(a);return R(P,n,a,void 0,C),C}},W=(n,s,P)=>{if(z){let u,a;switch(P){case PointCloudView.Back:u=backViewPoint2PointCloud;break;case PointCloudView.Side:u=sideViewPoint2PointCloud;break;default:u=sideViewPoint2PointCloud;break}a=u(n,s,z);const C=H(a);return M(P,n,a,void 0,C,L),C}},$=(n,s)=>{W(n,s,PointCloudView.Side)},tt=(n,s)=>{W(n,s,PointCloudView.Back)},et=(n,s)=>{Z(n,s,PointCloudView.Side)},ot=(n,s)=>{Z(n,s,PointCloudView.Back)},it=(n,s)=>{O(n)},nt=(n,s)=>{const P=y(n.id),u=topViewPoint2PointCloud(n,s,E,P),a=H(u);M(PointCloudView.Top,n,u,void 0,a,L)},st=(n,s)=>{if(k){const u=n[0].newPolygon;u.pointList=u.pointList.map(a=>lbUtils.PointCloudUtils.transferCanvas2World(a,s)),_(n[0].newPolygon);return}const P=n.map(({newPolygon:u})=>{const a=A(u.id),{boxParams:C}=topViewPolygon2PointCloud(u,s,o.pointCloudInstance,a);return C});if(P.length===1){const{newPolygon:u}=n[0],a=S(P);R(PointCloudView.Top,u,P[0],void 0,a)}else{const u=S(P);u&&t.syncAllViewPointCloudColor(u)}},M=(n,s,P,u,a,C)=>__async(void 0,null,function*(){const f=T==null?void 0:T.url,v={[PointCloudView.Side]:()=>{syncSideViewByPoint(P,s,i,f,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(P,s,l,f,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(P,s,o,e)}};Object.keys(v).forEach(m=>{m!==n&&v[m]()}),u&&(e==null||e.updateCameraZoom(u)),X(P)}),R=(n,s,P,u,a)=>__async(void 0,null,function*(){const C=T==null?void 0:T.url;a&&(yield t.syncAllViewPointCloudColor(a));const f={[PointCloudView.Side]:()=>{synchronizeSideView(P,s,i,C)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(P,s,l,C)},[PointCloudView.Top]:()=>{synchronizeTopView(P,s,o,e)}};Object.keys(f).forEach(v=>{v!==n&&f[v]()}),u&&(e==null||e.updateCameraZoom(u)),Q(P)});return{topViewAddSphere:Y,topViewAddBox:J,topViewSelectedChanged:K,topViewUpdatePoint:nt,sideViewUpdatePoint:$,backViewUpdatePoint:tt,topViewUpdateBox:st,topViewUpdateLine:it,sideViewUpdateBox:et,backViewUpdateBox:ot,pointCloudBoxListUpdated:n=>{o.updatePolygonList(n),e==null||e.generateBoxes(n)},initPointCloud3d:n=>{if(!e)return;const s={left:-n.width/2,right:n.width/2,top:n.height/2,bottom:-n.height/2,near:100,far:-100};e.initOrthographicCamera(s),e.initRenderer(),e.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(s=T){var P,u,a,C,f,v;if(!(s==null?void 0:s.url)||!e)return;actionCreators.SetPointCloudLoading(F,!0),yield e.loadPCDFile(s.url,(P=L==null?void 0:L.radius)!=null?P:DEFAULT_RADIUS),h.forEach(b=>{e==null||e.removeObjectByName(b.id)}),g.forEach(b=>{e==null||e.removeObjectByName(b.id)});let m=[],w=[],B=[],I=[];s.result?(m=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),B=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),w=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),I=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),m.forEach(b=>{e==null||e.generateBox(b)}),I.forEach(b=>{e==null||e.generateSphere(b)}),t.syncAllViewPointCloudColor(m),t.setPointCloudResult(m),t.setPolygonList(B),t.setLineList(w),t.setPointCloudSphereList(I)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),U({pointCloudBoxList:m,polygonList:B,pointCloudSphereList:I}),e.updateTopCamera();const q=(a=(u=index.jsonParser(s.result))==null?void 0:u.valid)!=null?a:!0;t.setPointCloudValid(q),(C=t.sideViewInstance)==null||C.clearAllData(),(f=t.backViewInstance)==null||f.clearAllData(),o.updateData(s.url,s.result,{radius:(v=L==null?void 0:L.radius)!=null?v:DEFAULT_RADIUS}),actionCreators.SetPointCloudLoading(F,!1)})}};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 React=require("react"),PointCloudContext=require("../PointCloudContext.js"),_=require("lodash"),useHistory=require("./useHistory.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_);const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),_=require("lodash"),useHistory=require("./useHistory.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_);const{ESortDirection}=lbAnnotation.cAnnotation,useSphere=()=>{const{pointCloudSphereList:e,setPointCloudSphereList:l,selectedID:u,setSelectedIDs:a,mainViewInstance:s,topViewInstance:r}=React.useContext(PointCloudContext.PointCloudContext),{pushHistoryWithList:p}=useHistory.useHistory(),C=React.useMemo(()=>e.find(t=>t.id===u),[u,e]),f=React.useCallback(t=>e.find(n=>n.id===t),[e]),h=React.useCallback(t=>{const n=e.findIndex(o=>o.id===t.id);if(n>-1){e.splice(n,1,___default.default.merge(e[n],t));const o=___default.default.cloneDeep(e);return l(o),p({pointCloudSphereList:o}),o}return e},[e]),S=React.useCallback(t=>{const n=e.filter(o=>o.id!==t);l(n),s==null||s.removeObjectByName(t),s==null||s.render()},[e]),I=React.useCallback((t=ESortDirection.ascend)=>{if(!r)return;const n=r.toolInstance.pointList,o=r.toolInstance.selectedID,d=n.findIndex(i=>(i==null?void 0:i.id)===o);if(d>-1){let i=1;t===ESortDirection.descend&&(i=-1);const c=n.length,b=n[(d+i+c)%c];a(b.id)}},[r]);return{selectedSphere:C,getPointCloudSphereByID:f,updatePointCloudSphere:h,deletePointCloudSphere:S,switchToNextSphere:I}};exports.useSphere=useSphere;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useHistory=require("./useHistory.js");const{EToolName,EPolygonPattern}=lbAnnotation.cTool,useStatus=()=>{const{topViewInstance:i,sideViewInstance:r,backViewInstance:u,mainViewInstance:t,pointCloudBoxList:c,pointCloudSphereList:d,setPointCloudResult:P,setPointCloudSphereList:C,setPolygonList:v,pointCloudPattern:a,setPointCloudPattern:n,syncAllViewPointCloudColor:h}=React.useContext(PointCloudContext.PointCloudContext),{pushHistoryWithList:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useHistory=require("./useHistory.js");const{EToolName,EPolygonPattern}=lbAnnotation.cTool,useStatus=()=>{const{topViewInstance:i,sideViewInstance:r,backViewInstance:u,mainViewInstance:t,pointCloudBoxList:c,pointCloudSphereList:d,setPointCloudResult:P,setPointCloudSphereList:C,setPolygonList:v,pointCloudPattern:a,setPointCloudPattern:n,syncAllViewPointCloudColor:h,setLineList:p}=React.useContext(PointCloudContext.PointCloudContext),{pushHistoryWithList:y}=useHistory.useHistory(),L=()=>{c.forEach(e=>{t==null||t.removeObjectByName(e.id)}),d.forEach(e=>{t==null||t.removeObjectByName(e.id)}),t==null||t.render(),P([]),v([]),C([]),p([]),i==null||i.toolScheduler.clearStatusAndResult(),h([]),y({pointCloudBoxList:[],polygonList:[],pointCloudSphereList:[]})},l=()=>{r==null||r.toolInstance.clearResult(),u==null||u.toolInstance.clearResult()};return{clearAllResult:L,updatePointCloudPattern:e=>{if(e===a)return;const s=[i,r,u];switch(e){case EToolName.Rect:l(),s.forEach(o=>{o==null||o.switchToCanvas(EToolName.PointCloudPolygon),o==null||o.toolInstance.setPattern(EPolygonPattern.Rect)}),n(EToolName.Rect);break;case EToolName.Polygon:l(),s.forEach(o=>{o==null||o.switchToCanvas(EToolName.PointCloudPolygon),o==null||o.toolInstance.setPattern(EPolygonPattern.Normal)}),n(EToolName.Polygon);break;case EToolName.Point:l(),s.forEach(o=>{o==null||o.switchToCanvas(EToolName.Point)}),n(EToolName.Point);break;case EToolName.Line:l(),s.forEach(o=>{o==null||o.switchToCanvas(EToolName.Line)}),n(EToolName.Line);break}},pointCloudPattern:a}};exports.useStatus=useStatus;
|
|
@@ -3,4 +3,5 @@ export declare const useSphere: () => {
|
|
|
3
3
|
getPointCloudSphereByID: (id: string) => import("@labelbee/lb-utils").IPointCloudSphere | undefined;
|
|
4
4
|
updatePointCloudSphere: (sphereParams: any) => import("@labelbee/lb-utils").IPointCloudSphereList;
|
|
5
5
|
deletePointCloudSphere: (id: string) => void;
|
|
6
|
+
switchToNextSphere: (sort?: any) => void;
|
|
6
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as x}from"../../utils/dom.js";import{FooterDivider as
|
|
1
|
+
import{getClassName as x}from"../../utils/dom.js";import{FooterDivider as k}from"../../views/MainView/toolFooter/index.js";import{ZoomController as ee}from"../../views/MainView/toolFooter/ZoomController/index.js";import{UpSquareOutlined as te,DownSquareOutlined as oe}from"@ant-design/icons";import{PointCloudAnnotation as ne,cTool as ie,cAnnotation as se}from"@labelbee/lb-annotation";import{PointCloudUtils as le}from"@labelbee/lb-utils";import r,{useState as B,useRef as re,useLayoutEffect as ae,useEffect as h}from"react";import{PointCloudContext as D}from"./PointCloudContext.js";import{useRotate as ce}from"./hooks/useRotate.js";import{useSingleBox as U}from"./hooks/useSingleBox.js";import{PointCloudContainer as de}from"./PointCloudLayout.js";import{BoxInfos as pe,PointCloudValidity as ue}from"./PointCloudInfos.js";import{usePolygon as me}from"./hooks/usePolygon.js";import{useSphere as Z}from"./hooks/useSphere.js";import{useZoom as R}from"./hooks/useZoom.js";import{Slider as fe}from"antd";import{a2MapStateToProps as Pe}from"../../store/annotation/map.js";import{connect as we}from"react-redux";import{usePointCloudViews as Ce}from"./hooks/usePointCloudViews.js";import ve from"../../hooks/useSize.js";import{useTranslation as ge}from"react-i18next";import{LabelBeeContext as xe}from"../../store/ctx.js";import{jsonParser as Ie}from"../../utils/index.js";import ye from"../../utils/ToolUtils.js";var Ve=Object.defineProperty,he=Object.defineProperties,Oe=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable,F=(o,n,i)=>n in o?Ve(o,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[n]=i,M=(o,n)=>{for(var i in n||(n={}))Se.call(n,i)&&F(o,i,n[i]);if(z)for(var i of z(n))be.call(n,i)&&F(o,i,n[i]);return o},W=(o,n)=>he(o,Oe(n));const{EPolygonPattern:_e,EToolName:O}=ie,{ESortDirection:X}=se,Y=(o,n,i=1)=>{const{width:P,height:w}=n,g={x:o.x+P*i/2,y:o.y+w*i/2},v={x:n.width/2,y:n.height/2};return{offsetX:(v.x-g.x)/i,offsetY:-(v.y-g.y)/i}},Ee=({currentData:o})=>{var n,i;const{zoom:P,zoomIn:w,zoomOut:g,initialPosition:v}=R(),{selectNextBox:y,selectPrevBox:S}=U(),{switchToNextSphere:I}=Z(),{updateRotate:d}=ce({currentData:o}),e=r.useContext(D),a=(i=(n=e==null?void 0:e.topViewInstance)==null?void 0:n.toolScheduler)==null?void 0:i.getCurrentToolName(),m=2,b=()=>{d(-m)},V=()=>{d(m)},_=()=>{d(180)};return r.createElement(r.Fragment,null,r.createElement("span",{onClick:V,className:x("point-cloud","rotate-reserve")}),r.createElement("span",{onClick:b,className:x("point-cloud","rotate")}),r.createElement("span",{onClick:_,className:x("point-cloud","rotate-180")}),r.createElement(k,null),r.createElement(te,{onClick:()=>{a===O.PointCloudPolygon&&S(),a===O.Point&&I(X.descend)},className:x("point-cloud","prev")}),r.createElement(oe,{onClick:()=>{a===O.PointCloudPolygon&&y(),a===O.Point&&I(X.ascend)},className:x("point-cloud","next")}),r.createElement(k,null),r.createElement(ee,{initialPosition:v,zoomIn:w,zoomOut:g,zoom:P}))},je=({setZAxisLimit:o,zAxisLimit:n,checkMode:i})=>i?null:r.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},r.createElement(fe,{vertical:!0,step:.5,max:10,min:.5,defaultValue:n,onAfterChange:P=>{o(P)}})),Le=({currentData:o,imgList:n,stepInfo:i,drawLayerSlot:P,checkMode:w,intelligentFit:g})=>{var v,y;const[S,I]=B({zoom:1,currentPos:{x:0,y:0}}),d=re(null),e=r.useContext(D),a=ve(d),m=Ie(i.config),{setZoom:b,syncTopviewToolZoom:V}=R(),{hideAttributes:_}=e,{addPolygon:q,deletePolygon:H}=me(),{deletePointCloudSphere:$}=Z(),{deletePointCloudBox:G,changeValidByID:J}=U(),[E,K]=B(10),{t:Q}=ge(),C=Ce();return ae(()=>{if(!e.topViewInstance&&d.current&&(o==null?void 0:o.url)&&(o==null?void 0:o.result)){const s={width:d.current.clientWidth,height:d.current.clientHeight},p=new ne({container:d.current,size:s,pcdPath:o.url,config:W(M({},m),{pointCloudPattern:e.pointCloudPattern}),checkMode:w,toolName:ye.getPointCloudToolList(),proxyMode:w});e.setTopViewInstance(p)}},[o]),h(()=>{if(!a||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:s}=e.topViewInstance;s.singleOn("dataUpdated",(t,l)=>{e.setSelectedIDs(l),e.setLineList(t)}),s.singleOn("pointCreated",(t,l)=>{C.topViewAddSphere({newPoint:t,size:a,trackConfigurable:m.trackConfigurable,zoom:l})}),s.singleOn("pointDeleted",t=>{$(t)}),s.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),s.singleOn("updatePointByDrag",(t,l)=>{var u;(u=C.topViewUpdatePoint)==null||u.call(C,t,a)}),s.singleOn("polygonCreated",(t,l)=>{if(s.pattern===_e.Normal||!(o==null?void 0:o.url)){const u=W(M({},t),{pointList:t.pointList.map(c=>le.transferCanvas2World(c,a))});q(u),e.setSelectedIDs(_.includes(t.attribute)?"":t.id);return}C.topViewAddBox({polygon:t,size:a,imgList:n,trackConfigurable:m.trackConfigurable,zoom:l,intelligentFit:g})}),s.singleOn("deletedObject",({id:t})=>{G(t),H(t)}),s.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),s.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),s.singleOn("setSelectedIDs",t=>{e.setSelectedIDs(t)}),s.singleOn("updatePolygonByDrag",t=>{var l;(l=C.topViewUpdateBox)==null||l.call(C,t,a)});const p=t=>{var l;const u=J(t);u&&e.syncAllViewPointCloudColor(u),e.polygonList.find(c=>c.id===t)&&((l=e.topViewInstance)==null||l.toolInstance.setPolygonValidAndRender(t,!0))};return s.on("validUpdate",p),()=>{s.unbind("validUpdate",p)}},[e,a,o,C,e.polygonList,e.lineList,(v=e.topViewInstance)==null?void 0:v.toolInstance]),h(()=>{var s,p;if(!(a==null?void 0:a.width)||!e.topViewInstance)return;const t=(p=(s=m==null?void 0:m.attributeList)==null?void 0:s[0])==null?void 0:p.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(a),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:l,toolInstance:u}}=e;u.singleOn("renderZoom",(c,f)=>{const{offsetX:j,offsetY:L}=Y(f,a,c);if(l.camera.zoom=c,f){const{x:T,y:A,z:N}=l.initCameraPosition;l.camera.position.set(T+L,A-j,N)}l.camera.updateProjectionMatrix(),l.render(),b(c),V(f,c,a),I({zoom:c,currentPos:f})}),u.singleOn("dragMove",({currentPos:c,zoom:f})=>{const{offsetX:j,offsetY:L}=Y(c,a,f);l.camera.zoom=f;const{x:T,y:A,z:N}=l.initCameraPosition;l.camera.position.set(T+L,A-j,N),l.render(),V(c,f,a),I({zoom:f,currentPos:c})})},[a,e.topViewInstance,(y=e.topViewInstance)==null?void 0:y.toolInstance]),h(()=>{var s,p;(p=(s=e.topViewInstance)==null?void 0:s.pointCloudInstance)==null||p.applyZAxisPoints(E)},[E]),h(()=>{C.topViewSelectedChanged({})},[e.selectedIDs]),r.createElement(de,{className:x("point-cloud-container","top-view"),title:Q("TopView"),toolbar:r.createElement(Ee,{currentData:o})},r.createElement("div",{style:{position:"relative",flex:1}},r.createElement("div",{style:{width:"100%",height:"100%"},ref:d},P==null?void 0:P(S)),r.createElement(pe,{checkMode:w,config:m}),r.createElement(je,{checkMode:w,zAxisLimit:E,setZAxisLimit:K}),r.createElement(ue,null)))};var Te=we(Pe,null,null,{context:xe})(Le);export{Te as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as I}from"react";import{PointCloudContext as b}from"../PointCloudContext.js";var R=Object.defineProperty,x=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,S=(e,s,l)=>s in e?R(e,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[s]=l,_=(e,s)=>{for(var l in s||(s={}))U.call(s,l)&&S(e,l,s[l]);if(x)for(var l of x(s))V.call(s,l)&&S(e,l,s[l]);return e};const N=()=>{const{history:e,setPointCloudResult:s,setSelectedIDs:l,pointCloudBoxList:p,pointCloudSphereList:c,setPointCloudSphereList:B,mainViewInstance:u,topViewInstance:
|
|
1
|
+
import{useContext as I}from"react";import{PointCloudContext as b}from"../PointCloudContext.js";var R=Object.defineProperty,x=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,S=(e,s,l)=>s in e?R(e,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[s]=l,_=(e,s)=>{for(var l in s||(s={}))U.call(s,l)&&S(e,l,s[l]);if(x)for(var l of x(s))V.call(s,l)&&S(e,l,s[l]);return e};const N=()=>{const{history:e,setPointCloudResult:s,setSelectedIDs:l,pointCloudBoxList:p,pointCloudSphereList:c,setPointCloudSphereList:B,mainViewInstance:u,topViewInstance:f,polygonList:y,setPolygonList:a,lineList:C,setLineList:g,syncAllViewPointCloudColor:w}=I(b),H=({newBoxParams:t,newPolygon:o,newLine:i,newSphereParams:r})=>{const d={pointCloudBoxList:p,polygonList:y,lineList:C,pointCloudSphereList:c};t&&(d.pointCloudBoxList=p.concat(t)),o&&(d.polygonList=y.concat(o)),i&&(d.lineList=C.concat(i)),r&&(d.pointCloudSphereList=c.concat(r)),e.pushHistory(d)},O=t=>{const o={pointCloudBoxList:p,polygonList:y,lineList:C,pointCloudSphereList:c};t.pointCloudBoxList&&(o.pointCloudBoxList=t.pointCloudBoxList),t.polygonList&&(o.polygonList=t.polygonList),t.lineList&&(o.lineList=t.lineList),t.pointCloudSphereList&&(o.pointCloudSphereList=t.pointCloudSphereList),e.pushHistory(o)},m=t=>{if(C.find(i=>i.id===t.id)){const i=C.map(r=>r.id===t.id?t:_({},r));e.pushHistory({lineList:i}),g(i)}},E=t=>{if(y.find(i=>i.id===t.id)){const i=y.map(r=>r.id===t.id?t:_({},r));e.pushHistory({pointCloudBoxList:p,polygonList:i}),a(i)}},j=({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:i})=>{e.initRecord({pointCloudBoxList:t,polygonList:o,pointCloudSphereList:i},!0)},v=t=>{if(!t)return;const{pointCloudBoxList:o=[],polygonList:i=[],lineList:r=[],pointCloudSphereList:d=[]}=t;if(o){p.length!==o.length&&l();const h=p.filter(n=>o.every(L=>L.id!==n.id)),P=o.filter(n=>p.every(L=>L.id!==n.id));h.forEach(n=>{u==null||u.removeObjectByName(n.id)}),P.forEach(n=>{u==null||u.generateBox(n)}),s(o),w(o)}if(d){c.length!==d.length&&l();let h=c.filter(n=>d.every(L=>L.id!==n.id)),P=d.filter(n=>c.every(L=>L.id!==n.id));h.forEach(n=>{u==null||u.removeObjectByName(n.id)}),P.forEach(n=>{u==null||u.generateSphere(n)}),B(d)}i&&a(i),r&&g(r),f==null||f.updatePolygonList(o!=null?o:[],i!=null?i:[]),f==null||f.updateLineList(r!=null?r:[]),f==null||f.updatePointList(d)};return{addHistory:H,pushHistoryWithList:O,initHistory:j,pushHistoryUnderUpdatePolygon:E,pushHistoryUnderUpdateLine:m,redo:()=>{v(e.redo())},undo:()=>{v(e.undo())}}};export{N as useHistory};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MathUtils as x,getCuboidFromPointCloudBox as _t}from"@labelbee/lb-annotation";import{EPerspectiveView as N,PointCloudUtils as D,DEFAULT_SPHERE_PARAMS as Vt}from"@labelbee/lb-utils";import{useContext as Ut}from"react";import{PointCloudContext as kt}from"../PointCloudContext.js";import{useSingleBox as st}from"./useSingleBox.js";import{useSphere as At}from"./useSphere.js";import{useSelector as jt,useDispatch as Tt}from"../../../store/ctx.js";import zt from"../../../utils/StepUtils.js";import{jsonParser as rt}from"../../../utils/index.js";import{SetPointCloudLoading as dt}from"../../../store/annotation/actionCreators.js";import{message as Rt}from"antd";import{useTranslation as Et}from"react-i18next";import{useHistory as Ht}from"./useHistory.js";import{usePolygon as Ft}from"./usePolygon.js";var Nt=Object.defineProperty,Zt=Object.defineProperties,Wt=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,at=(t,e,n)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,m=(t,e)=>{for(var n in e||(e={}))Mt.call(e,n)&&at(t,n,e[n]);if(lt)for(var n of lt(e))Gt.call(e,n)&&at(t,n,e[n]);return t},j=(t,e)=>Zt(t,Wt(e)),q=(t,e,n)=>new Promise((r,o)=>{var c=d=>{try{s(n.next(d))}catch(P){o(P)}},p=d=>{try{s(n.throw(d))}catch(P){o(P)}},s=d=>d.done?r(d.value):Promise.resolve(d.value).then(c,p);s((n=n.apply(t,e)).next())});const G=5,Q=90,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},J=(t,e,n,r,o)=>{const{x:c,y:p}=D.transferCanvas2World(t,e),{defaultZ:s}=Vt,d={center:{x:c,y:p,z:s},id:t.id},P=r?m(m({},r),d):j(m({},d),{attribute:"",valid:!0});return o&&Object.assign(P,o),P},K=(t,e,n,r,o,c)=>{let p=t.pointList.map(y=>D.transferCanvas2World(y,e)),s=0,d=1,P={};if(n){const y=n.getSensesPointZAxisInPolygon(p,void 0,c);c&&y.fittedCoordinates.length>0&&(p=y.fittedCoordinates),s=(y.maxZ+y.minZ)/2,d=y.maxZ-y.minZ,P={count:y.zCount}}const[g,B,T]=p,U=x.getLineCenterPoint([g,T]),z=x.getLineLength(g,B),R=x.getLineLength(B,T),E=x.getRadiusFromQuadrangle(t.pointList);r&&(s=r.center.z,d=r.depth);const k={center:{x:U.x,y:U.y,z:s},width:R,height:z,depth:d,rotation:E,id:t.id},O=m(r?m(m({},r),k):j(m({},k),{attribute:"",valid:!0}),P);o&&Object.assign(O,o);const H=p.map(y=>D.transferWorld2Canvas(y,e));return{boxParams:O,newPointList:H}},ct=(t,e,n)=>{const r={x:t.x-e.x,y:t.y-e.y};return j(m({},n),{center:{x:n.center.x-r.x,y:n.center.y,z:n.center.z-r.y}})},ut=(t,e,n,r)=>{const[o,c,p]=t.pointList,[s,d,P]=e.pointList,g=x.getLineCenterPoint([o,p]),B=x.getLineCenterPoint([s,P]),U={x:{x:g.x-B.x,y:g.y-B.y}.x,y:0,z:g.y-B.y},z=x.getLineLength(o,c),R=x.getLineLength(s,d),E=z-R,k=x.getLineLength(c,p),O=x.getLineLength(d,P),H=k-O,{newBoxParams:y}=r.getNewBoxBySideUpdate(U,H,E,n);return y},Qt=(t,e,n)=>{const r={x:t.x-e.x,y:t.y-e.y};return j(m({},n),{center:{x:n.center.x,y:n.center.y-r.x,z:n.center.z-r.y}})},Xt=(t,e,n,r)=>{const[o,c,p]=t.pointList,[s,d,P]=e.pointList,g=x.getLineCenterPoint([o,p]),B=x.getLineCenterPoint([s,P]),U={x:{x:g.x-B.x,y:g.y-B.y}.x,y:0,z:g.y-B.y},z=x.getLineLength(o,c),R=x.getLineLength(s,d),E=z-R,k=x.getLineLength(c,p),O=x.getLineLength(d,P),H=k-O;let{newBoxParams:y}=r.getNewBoxByBackUpdate(U,H,E,n);return y},pt=(t,e,n,r,o)=>{var c;if(!n)return;const{toolInstance:p,pointCloudInstance:s}=n;s.loadPCDFile(r,(c=o==null?void 0:o.radius)!=null?c:Q);const{cameraPositionVector:d}=s.updateOrthoCameraBySphere(t,N.Left);s.setInitCameraPosition(d);const{point2d:P,zoom:g}=s.getSphereSidePoint2DCoordinate(t);s.camera.zoom=g,s.camera.updateProjectionMatrix(),s.render(),p.initPosition(),p.zoomChangeOnCenter(g),p.setResult([j(m(m({},e),P),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(e.id)},ft=(t,e,n,r)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=n;c.loadPCDFileByBox(r,t,{width:G,depth:G});const{cameraPositionVector:p}=c.updateOrthoCamera(t,N.Left);c.setInitCameraPosition(p);const{polygon2d:s,zoom:d}=c.getBoxSidePolygon2DCoordinate(t);c.camera.zoom=d,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(d),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:s,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},Ct=(t,e,n,r,o)=>{var c;if(!n)return;const{toolInstance:p,pointCloudInstance:s}=n;s.loadPCDFile(r,(c=o==null?void 0:o.radius)!=null?c:Q);const{cameraPositionVector:d}=s.updateOrthoCameraBySphere(t,N.Back);s.setInitCameraPosition(d);const{point2d:P,zoom:g}=s.getSphereBackPoint2DCoordinate(t);s.camera.zoom=g,s.camera.updateProjectionMatrix(),s.render(),p.initPosition(),p.zoomChangeOnCenter(g),p.setResult([j(m(m({},e),P),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(e.id)},Pt=(t,e,n,r)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=n;c.loadPCDFileByBox(r,t,{height:G,depth:G});const{cameraPositionVector:p}=c.updateOrthoCamera(t,N.Back);c.setInitCameraPosition(p);const{polygon2d:s,zoom:d}=c.getBoxBackPolygon2DCoordinate(t);c.camera.zoom=d,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(d),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:s,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},gt=(t,e,n,r)=>{if(!n||!r)return;r.generateSphere(t),r.updateCameraBySphere(t,N.Top),r.render();const{toolInstance:o,pointCloudInstance:c}=n,{point2d:p}=c.getSphereTopPoint2DCoordinate(t),s=[...o.pointList].map(d=>d.id===e.id?j(m(m({},e),p),{valid:t.valid,textAttribute:"",attribute:t.attribute}):d);o.setResult(s),o.setSelectedID(e.id)},$=(t,e,n,r)=>{var o;if(!n||!r)return;r.generateBox(t,e.id),r.render();const{pointCloud2dOperation:c,pointCloudInstance:p}=n,{polygon2d:s}=p.getBoxTopPolygon2DCoordinate(t),d=[...c.polygonList],P=d.find(g=>g.id===e.id);P?P.pointList=s:d.push({id:e.id,pointList:s,textAttribute:"",isRect:!0,valid:(o=t.valid)!=null?o:!0}),c.setResultAndSelectedID(d,e.id)},Yt=()=>{const t=Ut(kt),{topViewInstance:e,sideViewInstance:n,backViewInstance:r,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:p,setSelectedIDs:s,selectedIDs:d,pointCloudBoxList:P,pointCloudSphereList:g,hideAttributes:B}=t,{addHistory:T,initHistory:U,pushHistoryUnderUpdatePolygon:z,pushHistoryUnderUpdateLine:R}=Ht(),{selectedPolygon:E}=Ft(),{updateSelectedBox:k,updateSelectedBoxes:O,getPointCloudByID:H}=st(),{getPointCloudSphereByID:y,updatePointCloudSphere:tt,selectedSphere:Z}=At(),{currentData:I,config:S}=jt(i=>{const{stepList:l,step:f,imgList:u,imgIndex:a}=i.annotation;return{currentData:u[a],config:rt(zt.getCurrentStepInfo(f,l).config)}}),ot=Tt(),{selectedBox:F}=st(),{t:ht}=Et(),et=F==null?void 0:F.info;if(!e||!n||!r)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=e,Lt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},mt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},yt=({newPoint:i,size:l,zoom:f,trackConfigurable:u})=>{var a;const C={attribute:(a=e.toolInstance.defaultAttribute)!=null?a:""};u===!0&&Object.assign(C,{trackID:D.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:g})});const h=J(i,l,X,void 0,C);s(i.id);const v=p(h);W(L.Top,i,h,f,v,S),T({newSphereParams:h})},xt=({polygon:i,size:l,imgList:f,trackConfigurable:u,zoom:a,intelligentFit:C})=>{var h;const v={attribute:(h=e.toolInstance.defaultAttribute)!=null?h:""};u===!0&&Object.assign(v,{trackID:D.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:g})});const w=e==null?void 0:e.toolInstance,_=m({},i),{boxParams:b,newPointList:A}=K(_,l,X,void 0,v,C);if((S==null?void 0:S.lowerLimitPointsNumInBox)&&typeof b.count=="number"&&b.count<S.lowerLimitPointsNumInBox){Rt.info(ht("LowerLimitPointsNumInBox",{num:S.lowerLimitPointsNumInBox})),w.deletePolygon(b.id);return}C&&(A==null?void 0:A.length)&&(_.pointList=A);const Y=B.includes(_.attribute),V=c(b);Y?s([]):(s(b.id),w.setSelectedIDs([_.id]),M(L.Top,_,b,a,V),C&&$(b,_,e,o)),T({newBoxParams:b})},vt=({newSelectedBox:i,newPointCloudList:l,newSelectedSphere:f,newSphereList:u})=>{const a=e==null?void 0:e.toolInstance;if(!(d.length===0||!a)){if(i||(F==null?void 0:F.info)){const C=i!=null?i:F==null?void 0:F.info;a.setSelectedIDs(d);const h=a.selectedPolygon;if(d.length===1&&C){M(L.Top,h,C,void 0,l);return}}if((f||Z)&&d.length===1){const C=f!=null?f:Z;a.setSelectedID(d[0]);const h=a.selectedPoint;C&&W(L.Top,h,C,void 0,u,S)}}},nt=(i,l,f)=>{if(et){let u,a;switch(f){case L.Back:u=Xt;break;case L.Side:u=ut;break;default:u=ut;break}if(a=u(i,l,et,n.pointCloudInstance),o){const{count:h}=o.getSensesPointZAxisInPolygon(_t(a).polygonPointList,[a.center.z-a.depth/2,a.center.z+a.depth/2]);a=j(m({},a),{count:h})}const C=k(a);return M(f,i,a,void 0,C),C}},it=(i,l,f)=>{if(Z){let u,a;switch(f){case L.Back:u=Qt;break;case L.Side:u=ct;break;default:u=ct;break}a=u(i,l,Z);const C=tt(a);return W(f,i,a,void 0,C,S),C}},Bt=(i,l)=>{it(i,l,L.Side)},St=(i,l)=>{it(i,l,L.Back)},bt=(i,l)=>{nt(i,l,L.Side)},wt=(i,l)=>{nt(i,l,L.Back)},It=(i,l)=>{R(i)},Dt=(i,l)=>{const f=y(i.id),u=J(i,l,X,f),a=tt(u);W(L.Top,i,u,void 0,a,S)},Ot=(i,l)=>{if(E){const u=i[0].newPolygon;u.pointList=u.pointList.map(a=>D.transferCanvas2World(a,l)),z(i[0].newPolygon);return}const f=i.map(({newPolygon:u})=>{const a=H(u.id),{boxParams:C}=K(u,l,e.pointCloudInstance,a);return C});if(f.length===1){const{newPolygon:u}=i[0],a=O(f);M(L.Top,u,f[0],void 0,a)}else{const u=O(f);u&&t.syncAllViewPointCloudColor(u)}},W=(i,l,f,u,a,C)=>q(void 0,null,function*(){const h=I==null?void 0:I.url,v={[L.Side]:()=>{pt(f,l,n,h,C)},[L.Back]:()=>{r&&Ct(f,l,r,h,C)},[L.Top]:()=>{gt(f,l,e,o)}};Object.keys(v).forEach(w=>{w!==i&&v[w]()}),u&&(o==null||o.updateCameraZoom(u)),mt(f)}),M=(i,l,f,u,a)=>q(void 0,null,function*(){const C=I==null?void 0:I.url;a&&(yield t.syncAllViewPointCloudColor(a));const h={[L.Side]:()=>{ft(f,l,n,C)},[L.Back]:()=>{r&&Pt(f,l,r,C)},[L.Top]:()=>{$(f,l,e,o)}};Object.keys(h).forEach(v=>{v!==i&&h[v]()}),u&&(o==null||o.updateCameraZoom(u)),Lt(f)});return{topViewAddSphere:yt,topViewAddBox:xt,topViewSelectedChanged:vt,topViewUpdatePoint:Dt,sideViewUpdatePoint:Bt,backViewUpdatePoint:St,topViewUpdateBox:Ot,topViewUpdateLine:It,sideViewUpdateBox:bt,backViewUpdateBox:wt,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const l={left:-i.width/2,right:i.width/2,top:i.height/2,bottom:-i.height/2,near:100,far:-100};o.initOrthographicCamera(l),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>q(void 0,[...i],function*(l=I){var f,u,a,C,h,v;if(!(l==null?void 0:l.url)||!o)return;dt(ot,!0),yield o.loadPCDFile(l.url,(f=S==null?void 0:S.radius)!=null?f:Q),P.forEach(V=>{o==null||o.removeObjectByName(V.id)}),g.forEach(V=>{o==null||o.removeObjectByName(V.id)});let w=[],_=[],b=[],A=[];I.result?(w=D.getBoxParamsFromResultList(I.result),b=D.getPolygonListFromResultList(I.result),_=D.getLineListFromResultList(I.result),A=D.getSphereParamsFromResultList(I.result),w.forEach(V=>{o==null||o.generateBox(V)}),A.forEach(V=>{o==null||o.generateSphere(V)}),t.syncAllViewPointCloudColor(w),t.setPointCloudResult(w),t.setPolygonList(b),t.setLineList(_),t.setPointCloudSphereList(A)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),U({pointCloudBoxList:w,polygonList:b,pointCloudSphereList:A}),o.updateTopCamera();const Y=(a=(u=rt(l.result))==null?void 0:u.valid)!=null?a:!0;t.setPointCloudValid(Y),(C=t.sideViewInstance)==null||C.clearAllData(),(h=t.backViewInstance)==null||h.clearAllData(),e.updateData(l.url,l.result,{radius:(v=S==null?void 0:S.radius)!=null?v:Q}),dt(ot,!1)})}};export{Ct as syncBackViewByPoint,pt as syncSideViewByPoint,gt as syncTopViewByPoint,Pt as synchronizeBackView,ft as synchronizeSideView,$ as synchronizeTopView,J as topViewPoint2PointCloud,K as topViewPolygon2PointCloud,Yt as usePointCloudViews};
|
|
1
|
+
import{MathUtils as v,getCuboidFromPointCloudBox as _t}from"@labelbee/lb-annotation";import{EPerspectiveView as N,PointCloudUtils as I,DEFAULT_SPHERE_PARAMS as Vt}from"@labelbee/lb-utils";import{useContext as Ut}from"react";import{PointCloudContext as kt}from"../PointCloudContext.js";import{useSingleBox as st}from"./useSingleBox.js";import{useSphere as At}from"./useSphere.js";import{useSelector as jt,useDispatch as Tt}from"../../../store/ctx.js";import zt from"../../../utils/StepUtils.js";import{jsonParser as rt}from"../../../utils/index.js";import{SetPointCloudLoading as dt}from"../../../store/annotation/actionCreators.js";import{message as Rt}from"antd";import{useTranslation as Et}from"react-i18next";import{useHistory as Ht}from"./useHistory.js";import{usePolygon as Ft}from"./usePolygon.js";var Nt=Object.defineProperty,Zt=Object.defineProperties,Wt=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,at=(t,e,n)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,m=(t,e)=>{for(var n in e||(e={}))Mt.call(e,n)&&at(t,n,e[n]);if(lt)for(var n of lt(e))Gt.call(e,n)&&at(t,n,e[n]);return t},A=(t,e)=>Zt(t,Wt(e)),q=(t,e,n)=>new Promise((d,o)=>{var c=l=>{try{r(n.next(l))}catch(P){o(P)}},p=l=>{try{r(n.throw(l))}catch(P){o(P)}},r=l=>l.done?d(l.value):Promise.resolve(l.value).then(c,p);r((n=n.apply(t,e)).next())});const G=5,Q=90,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},J=(t,e,n,d,o)=>{const{x:c,y:p}=I.transferCanvas2World(t,e),{defaultZ:r}=Vt,l={center:{x:c,y:p,z:r},id:t.id},P=d?m(m({},d),l):A(m({},l),{attribute:"",valid:!0});return o&&Object.assign(P,o),P},K=(t,e,n,d,o,c)=>{let p=t.pointList.map(y=>I.transferCanvas2World(y,e)),r=0,l=1,P={};if(n){const y=n.getSensesPointZAxisInPolygon(p,void 0,c);c&&y.fittedCoordinates.length>0&&(p=y.fittedCoordinates),r=(y.maxZ+y.minZ)/2,l=y.maxZ-y.minZ,P={count:y.zCount}}const[g,B,j]=p,V=v.getLineCenterPoint([g,j]),T=v.getLineLength(g,B),z=v.getLineLength(B,j),R=v.getRadiusFromQuadrangle(t.pointList);d&&(r=d.center.z,l=d.depth);const U={center:{x:V.x,y:V.y,z:r},width:z,height:T,depth:l,rotation:R,id:t.id},D=m(d?m(m({},d),U):A(m({},U),{attribute:"",valid:!0}),P);o&&Object.assign(D,o);const E=p.map(y=>I.transferWorld2Canvas(y,e));return{boxParams:D,newPointList:E}},ct=(t,e,n)=>{const d={x:t.x-e.x,y:t.y-e.y};return A(m({},n),{center:{x:n.center.x-d.x,y:n.center.y,z:n.center.z-d.y}})},ut=(t,e,n,d)=>{const[o,c,p]=t.pointList,[r,l,P]=e.pointList,g=v.getLineCenterPoint([o,p]),B=v.getLineCenterPoint([r,P]),V={x:{x:g.x-B.x,y:g.y-B.y}.x,y:0,z:g.y-B.y},T=v.getLineLength(o,c),z=v.getLineLength(r,l),R=T-z,U=v.getLineLength(c,p),D=v.getLineLength(l,P),E=U-D,{newBoxParams:y}=d.getNewBoxBySideUpdate(V,E,R,n);return y},Qt=(t,e,n)=>{const d={x:t.x-e.x,y:t.y-e.y};return A(m({},n),{center:{x:n.center.x,y:n.center.y-d.x,z:n.center.z-d.y}})},Xt=(t,e,n,d)=>{const[o,c,p]=t.pointList,[r,l,P]=e.pointList,g=v.getLineCenterPoint([o,p]),B=v.getLineCenterPoint([r,P]),V={x:{x:g.x-B.x,y:g.y-B.y}.x,y:0,z:g.y-B.y},T=v.getLineLength(o,c),z=v.getLineLength(r,l),R=T-z,U=v.getLineLength(c,p),D=v.getLineLength(l,P),E=U-D;let{newBoxParams:y}=d.getNewBoxByBackUpdate(V,E,R,n);return y},pt=(t,e,n,d,o)=>{var c;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(d,(c=o==null?void 0:o.radius)!=null?c:Q);const{cameraPositionVector:l}=r.updateOrthoCameraBySphere(t,N.Left);r.setInitCameraPosition(l);const{point2d:P,zoom:g}=r.getSphereSidePoint2DCoordinate(t);r.camera.zoom=g,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(g),p.setResult([A(m(m({},e),P),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(e.id)},ft=(t,e,n,d)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=n;c.loadPCDFileByBox(d,t,{width:G,depth:G});const{cameraPositionVector:p}=c.updateOrthoCamera(t,N.Left);c.setInitCameraPosition(p);const{polygon2d:r,zoom:l}=c.getBoxSidePolygon2DCoordinate(t);c.camera.zoom=l,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(l),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},Ct=(t,e,n,d,o)=>{var c;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(d,(c=o==null?void 0:o.radius)!=null?c:Q);const{cameraPositionVector:l}=r.updateOrthoCameraBySphere(t,N.Back);r.setInitCameraPosition(l);const{point2d:P,zoom:g}=r.getSphereBackPoint2DCoordinate(t);r.camera.zoom=g,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(g),p.setResult([A(m(m({},e),P),{valid:t.valid,textAttribute:"",attribute:t.attribute})]),p.setSelectedID(e.id)},Pt=(t,e,n,d)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=n;c.loadPCDFileByBox(d,t,{height:G,depth:G});const{cameraPositionVector:p}=c.updateOrthoCamera(t,N.Back);c.setInitCameraPosition(p);const{polygon2d:r,zoom:l}=c.getBoxBackPolygon2DCoordinate(t);c.camera.zoom=l,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(l),o.setResultAndSelectedID([{id:e.id,valid:t.valid,pointList:r,textAttribute:"",isRect:!0,attribute:t.attribute}],e.id)},gt=(t,e,n,d)=>{if(!n||!d)return;d.generateSphere(t),d.updateCameraBySphere(t,N.Top),d.render();const{toolInstance:o,pointCloudInstance:c}=n,{point2d:p}=c.getSphereTopPoint2DCoordinate(t),r=[...o.pointList].map(l=>l.id===e.id?A(m(m({},e),p),{valid:t.valid,textAttribute:"",attribute:t.attribute}):l);o.setResult(r),o.setSelectedID(e.id)},$=(t,e,n,d)=>{var o;if(!n||!d)return;d.generateBox(t,e.id),d.render();const{pointCloud2dOperation:c,pointCloudInstance:p}=n,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(t),l=[...c.polygonList],P=l.find(g=>g.id===e.id);P?P.pointList=r:l.push({id:e.id,pointList:r,textAttribute:"",isRect:!0,valid:(o=t.valid)!=null?o:!0}),c.setResultAndSelectedID(l,e.id)},Yt=()=>{const t=Ut(kt),{topViewInstance:e,sideViewInstance:n,backViewInstance:d,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:l,pointCloudBoxList:P,pointCloudSphereList:g,hideAttributes:B}=t,{addHistory:j,initHistory:V,pushHistoryUnderUpdatePolygon:T,pushHistoryUnderUpdateLine:z}=Ht(),{selectedPolygon:R}=Ft(),{updateSelectedBox:U,updateSelectedBoxes:D,getPointCloudByID:E}=st(),{getPointCloudSphereByID:y,updatePointCloudSphere:tt,selectedSphere:Z}=At(),{currentData:F,config:S}=jt(i=>{const{stepList:s,step:f,imgList:u,imgIndex:a}=i.annotation;return{currentData:u[a],config:rt(zt.getCurrentStepInfo(f,s).config)}}),ot=Tt(),{selectedBox:H}=st(),{t:ht}=Et(),et=H==null?void 0:H.info;if(!e||!n||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:X}=e,Lt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},mt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},yt=({newPoint:i,size:s,zoom:f,trackConfigurable:u})=>{var a;const C={attribute:(a=e.toolInstance.defaultAttribute)!=null?a:""};u===!0&&Object.assign(C,{trackID:I.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:g})});const h=J(i,s,X,void 0,C);r(i.id);const x=p(h);W(L.Top,i,h,f,x,S),j({newSphereParams:h})},vt=({polygon:i,size:s,imgList:f,trackConfigurable:u,zoom:a,intelligentFit:C})=>{var h;const x={attribute:(h=e.toolInstance.defaultAttribute)!=null?h:""};u===!0&&Object.assign(x,{trackID:I.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:g})});const w=e==null?void 0:e.toolInstance,O=m({},i),{boxParams:b,newPointList:k}=K(O,s,X,void 0,x,C);if((S==null?void 0:S.lowerLimitPointsNumInBox)&&typeof b.count=="number"&&b.count<S.lowerLimitPointsNumInBox){Rt.info(ht("LowerLimitPointsNumInBox",{num:S.lowerLimitPointsNumInBox})),w.deletePolygon(b.id);return}C&&(k==null?void 0:k.length)&&(O.pointList=k);const Y=B.includes(O.attribute),_=c(b);Y?r([]):(r(b.id),w.setSelectedIDs([O.id]),M(L.Top,O,b,a,_),C&&$(b,O,e,o)),j({newBoxParams:b})},xt=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:f,newSphereList:u})=>{const a=e==null?void 0:e.toolInstance;if(!(l.length===0||!a)){if(i||(H==null?void 0:H.info)){const C=i!=null?i:H==null?void 0:H.info;a==null||a.setSelectedIDs(l);const h=a.selectedPolygon;if(l.length===1&&C){M(L.Top,h,C,void 0,s);return}}if((f||Z)&&l.length===1){const C=f!=null?f:Z;a.setSelectedID(l[0]);const h=a.selectedPoint;C&&W(L.Top,h,C,void 0,u,S)}}},nt=(i,s,f)=>{if(et){let u,a;switch(f){case L.Back:u=Xt;break;case L.Side:u=ut;break;default:u=ut;break}if(a=u(i,s,et,n.pointCloudInstance),o){const{count:h}=o.getSensesPointZAxisInPolygon(_t(a).polygonPointList,[a.center.z-a.depth/2,a.center.z+a.depth/2]);a=A(m({},a),{count:h})}const C=U(a);return M(f,i,a,void 0,C),C}},it=(i,s,f)=>{if(Z){let u,a;switch(f){case L.Back:u=Qt;break;case L.Side:u=ct;break;default:u=ct;break}a=u(i,s,Z);const C=tt(a);return W(f,i,a,void 0,C,S),C}},Bt=(i,s)=>{it(i,s,L.Side)},St=(i,s)=>{it(i,s,L.Back)},bt=(i,s)=>{nt(i,s,L.Side)},wt=(i,s)=>{nt(i,s,L.Back)},It=(i,s)=>{z(i)},Dt=(i,s)=>{const f=y(i.id),u=J(i,s,X,f),a=tt(u);W(L.Top,i,u,void 0,a,S)},Ot=(i,s)=>{if(R){const u=i[0].newPolygon;u.pointList=u.pointList.map(a=>I.transferCanvas2World(a,s)),T(i[0].newPolygon);return}const f=i.map(({newPolygon:u})=>{const a=E(u.id),{boxParams:C}=K(u,s,e.pointCloudInstance,a);return C});if(f.length===1){const{newPolygon:u}=i[0],a=D(f);M(L.Top,u,f[0],void 0,a)}else{const u=D(f);u&&t.syncAllViewPointCloudColor(u)}},W=(i,s,f,u,a,C)=>q(void 0,null,function*(){const h=F==null?void 0:F.url,x={[L.Side]:()=>{pt(f,s,n,h,C)},[L.Back]:()=>{d&&Ct(f,s,d,h,C)},[L.Top]:()=>{gt(f,s,e,o)}};Object.keys(x).forEach(w=>{w!==i&&x[w]()}),u&&(o==null||o.updateCameraZoom(u)),mt(f)}),M=(i,s,f,u,a)=>q(void 0,null,function*(){const C=F==null?void 0:F.url;a&&(yield t.syncAllViewPointCloudColor(a));const h={[L.Side]:()=>{ft(f,s,n,C)},[L.Back]:()=>{d&&Pt(f,s,d,C)},[L.Top]:()=>{$(f,s,e,o)}};Object.keys(h).forEach(x=>{x!==i&&h[x]()}),u&&(o==null||o.updateCameraZoom(u)),Lt(f)});return{topViewAddSphere:yt,topViewAddBox:vt,topViewSelectedChanged:xt,topViewUpdatePoint:Dt,sideViewUpdatePoint:Bt,backViewUpdatePoint:St,topViewUpdateBox:Ot,topViewUpdateLine:It,sideViewUpdateBox:bt,backViewUpdateBox:wt,pointCloudBoxListUpdated:i=>{e.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const s={left:-i.width/2,right:i.width/2,top:i.height/2,bottom:-i.height/2,near:100,far:-100};o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>q(void 0,[...i],function*(s=F){var f,u,a,C,h,x;if(!(s==null?void 0:s.url)||!o)return;dt(ot,!0),yield o.loadPCDFile(s.url,(f=S==null?void 0:S.radius)!=null?f:Q),P.forEach(_=>{o==null||o.removeObjectByName(_.id)}),g.forEach(_=>{o==null||o.removeObjectByName(_.id)});let w=[],O=[],b=[],k=[];s.result?(w=I.getBoxParamsFromResultList(s.result),b=I.getPolygonListFromResultList(s.result),O=I.getLineListFromResultList(s.result),k=I.getSphereParamsFromResultList(s.result),w.forEach(_=>{o==null||o.generateBox(_)}),k.forEach(_=>{o==null||o.generateSphere(_)}),t.syncAllViewPointCloudColor(w),t.setPointCloudResult(w),t.setPolygonList(b),t.setLineList(O),t.setPointCloudSphereList(k)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),V({pointCloudBoxList:w,polygonList:b,pointCloudSphereList:k}),o.updateTopCamera();const Y=(a=(u=rt(s.result))==null?void 0:u.valid)!=null?a:!0;t.setPointCloudValid(Y),(C=t.sideViewInstance)==null||C.clearAllData(),(h=t.backViewInstance)==null||h.clearAllData(),e.updateData(s.url,s.result,{radius:(x=S==null?void 0:S.radius)!=null?x:Q}),dt(ot,!1)})}};export{Ct as syncBackViewByPoint,pt as syncSideViewByPoint,gt as syncTopViewByPoint,Pt as synchronizeBackView,ft as synchronizeSideView,$ as synchronizeTopView,J as topViewPoint2PointCloud,K as topViewPolygon2PointCloud,Yt as usePointCloudViews};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as w,useMemo as D,useCallback as d}from"react";import{PointCloudContext as b}from"../PointCloudContext.js";import h from"lodash";import{useHistory as y}from"./useHistory.js";import{cAnnotation as g}from"@labelbee/lb-annotation";const{ESortDirection:S}=g,j=()=>{const{pointCloudSphereList:e,setPointCloudSphereList:c,selectedID:l,setSelectedIDs:a,mainViewInstance:s,topViewInstance:r}=w(b),{pushHistoryWithList:f}=y(),m=D(()=>e.find(t=>t.id===l),[l,e]),C=d(t=>e.find(n=>n.id===t),[e]),I=d(t=>{const n=e.findIndex(o=>o.id===t.id);if(n>-1){e.splice(n,1,h.merge(e[n],t));const o=h.cloneDeep(e);return c(o),f({pointCloudSphereList:o}),o}return e},[e]),x=d(t=>{const n=e.filter(o=>o.id!==t);c(n),s==null||s.removeObjectByName(t),s==null||s.render()},[e]),L=d((t=S.ascend)=>{if(!r)return;const n=r.toolInstance.pointList,o=r.toolInstance.selectedID,u=n.findIndex(i=>(i==null?void 0:i.id)===o);if(u>-1){let i=1;t===S.descend&&(i=-1);const p=n.length,P=n[(u+i+p)%p];a(P.id)}},[r]);return{selectedSphere:m,getPointCloudSphereByID:C,updatePointCloudSphere:I,deletePointCloudSphere:x,switchToNextSphere:L}};export{j as useSphere};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as w}from"react";import{PointCloudContext as
|
|
1
|
+
import{useContext as w}from"react";import{PointCloudContext as b}from"../PointCloudContext.js";import{cTool as R}from"@labelbee/lb-annotation";import{useHistory as E}from"./useHistory.js";const{EToolName:t,EPolygonPattern:d}=R,I=()=>{const{topViewInstance:r,sideViewInstance:a,backViewInstance:u,mainViewInstance:e,pointCloudBoxList:P,pointCloudSphereList:C,setPointCloudResult:p,setPointCloudSphereList:v,setPolygonList:h,pointCloudPattern:c,setPointCloudPattern:l,syncAllViewPointCloudColor:m,setLineList:y}=w(b),{pushHistoryWithList:L}=E(),f=()=>{P.forEach(n=>{e==null||e.removeObjectByName(n.id)}),C.forEach(n=>{e==null||e.removeObjectByName(n.id)}),e==null||e.render(),p([]),h([]),v([]),y([]),r==null||r.toolScheduler.clearStatusAndResult(),m([]),L({pointCloudBoxList:[],polygonList:[],pointCloudSphereList:[]})},i=()=>{a==null||a.toolInstance.clearResult(),u==null||u.toolInstance.clearResult()};return{clearAllResult:f,updatePointCloudPattern:n=>{if(n===c)return;const s=[r,a,u];switch(n){case t.Rect:i(),s.forEach(o=>{o==null||o.switchToCanvas(t.PointCloudPolygon),o==null||o.toolInstance.setPattern(d.Rect)}),l(t.Rect);break;case t.Polygon:i(),s.forEach(o=>{o==null||o.switchToCanvas(t.PointCloudPolygon),o==null||o.toolInstance.setPattern(d.Normal)}),l(t.Polygon);break;case t.Point:i(),s.forEach(o=>{o==null||o.switchToCanvas(t.Point)}),l(t.Point);break;case t.Line:i(),s.forEach(o=>{o==null||o.switchToCanvas(t.Line)}),l(t.Line);break}},pointCloudPattern:c}};export{I as useStatus};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.10.0-alpha.
|
|
3
|
+
"version": "1.10.0-alpha.15",
|
|
4
4
|
"description": "Provide a complete library of annotation components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"es": "./es/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ant-design/icons": "^4.6.2",
|
|
46
|
-
"@labelbee/lb-annotation": "1.14.0-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.14.0-alpha.15",
|
|
47
47
|
"@labelbee/lb-utils": "1.7.0-alpha.8",
|
|
48
48
|
"ahooks": "^3.4.0",
|
|
49
49
|
"classnames": "^2.3.0",
|