@labelbee/lb-components 1.10.0-alpha.21 → 1.10.0-alpha.23
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/usePointCloudViews.js +1 -1
- package/dist/components/pointCloudView/hooks/useSingleBox.js +1 -1
- package/dist/components/pointCloudView/hooks/useZoom.js +1 -1
- package/dist/types/components/pointCloudView/hooks/useSingleBox.d.ts +2 -2
- package/es/components/pointCloudView/PointCloudTopView.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/hooks/useSingleBox.js +1 -1
- package/es/components/pointCloudView/hooks/useZoom.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var dom=require("../../utils/dom.js"),index$2=require("../../views/MainView/toolFooter/index.js"),index$3=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"),_=require("lodash"),index$1=require("./components/PointCloudSizeSlider/index.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__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,g={x:t.x+v*i/2,y:t.y+C*i/2},
|
|
1
|
+
"use strict";var dom=require("../../utils/dom.js"),index$2=require("../../views/MainView/toolFooter/index.js"),index$3=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"),_=require("lodash"),index$1=require("./components/PointCloudSizeSlider/index.js"),useHistory=require("./hooks/useHistory.js");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_),__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,g={x:t.x+v*i/2,y:t.y+C*i/2},P={x:n.width/2,y:n.height/2};return{offsetX:(P.x-g.x)/i,offsetY:-(P.y-g.y)/i}},TopViewToolbar=({currentData:t})=>{var n,i;const{zoom:v,zoomIn:C,zoomOut:g,initialPosition:P}=useZoom.useZoom(),{selectNextBox:x,selectPrevBox:V}=useSingleBox.useSingleBox(),{switchToNextSphere:w}=useSphere.useSphere(),{updateRotate:d}=useRotate.useRotate({currentData:t}),e=React__default.default.useContext(PointCloudContext.PointCloudContext),{topViewInstance:a}=e,p=(i=(n=e==null?void 0:e.topViewInstance)==null?void 0:n.toolScheduler)==null?void 0:i.getCurrentToolName(),y=2,I=()=>{d(-y)},S=()=>{d(y)},b=()=>{d(180)};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:L=>{var h;(h=a==null?void 0:a.pointCloudInstance)==null||h.updatePointSize({customSize:L})}}),React__default.default.createElement("span",{onClick:S,className:dom.getClassName("point-cloud","rotate-reserve")}),React__default.default.createElement("span",{onClick:I,className:dom.getClassName("point-cloud","rotate")}),React__default.default.createElement("span",{onClick:b,className:dom.getClassName("point-cloud","rotate-180")}),React__default.default.createElement(index$2.FooterDivider,null),React__default.default.createElement(icons.UpSquareOutlined,{onClick:()=>{if(p===EToolName.Point){w(ESortDirection.descend);return}V(!0)},className:dom.getClassName("point-cloud","prev")}),React__default.default.createElement(icons.DownSquareOutlined,{onClick:()=>{if(p===EToolName.Point){w(ESortDirection.ascend);return}x(!0)},className:dom.getClassName("point-cloud","next")}),React__default.default.createElement(index$2.FooterDivider,null),React__default.default.createElement(index$3.ZoomController,{initialPosition:P,zoomIn:C,zoomOut:g,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:g})=>{var P,x;const[V,w]=React.useState({zoom:1,currentPos:{x:0,y:0}}),d=React.useRef(null),e=React__default.default.useContext(PointCloudContext.PointCloudContext),a=useSize(d),p=index.jsonParser(i.config),{setZoom:y,syncTopviewToolZoom:I}=useZoom.useZoom(),{hideAttributes:S}=e,{addPolygon:b,deletePolygon:L}=usePolygon.usePolygon(),{deletePointCloudSphere:h}=useSphere.useSphere(),{deletePointCloudBox:A,changeValidByID:k}=useSingleBox.useSingleBox(),[O,B]=React.useState(10),{t:D}=reactI18next.useTranslation(),m=usePointCloudViews.usePointCloudViews(),{pushHistoryWithList:R}=useHistory.useHistory();return React.useLayoutEffect(()=>{if(!e.topViewInstance&&d.current&&(t==null?void 0:t.url)&&(t==null?void 0:t.result)){const s={width:d.current.clientWidth,height:d.current.clientHeight},c=new lbAnnotation.PointCloudAnnotation({container:d.current,size:s,pcdPath:t.url,config:__spreadProps(__spreadValues({},p),{pointCloudPattern:e.pointCloudPattern}),checkMode:C,toolName:ToolUtils.getPointCloudToolList(),proxyMode:C});e.setTopViewInstance(c)}},[t]),React.useEffect(()=>{if(!a||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:s}=e.topViewInstance;s.singleOn("dataUpdated",(o,l)=>{const u=___default.default.cloneDeep(o).map(r=>__spreadProps(__spreadValues({},r),{pointList:lbUtils.PointCloudUtils.pointListTransferCanvas2World(r.pointList,a)}));e.setSelectedIDs(l),e.setLineList(u),R({lineList:u})}),s.singleOn("pointCreated",(o,l)=>{m.topViewAddSphere({newPoint:o,size:a,trackConfigurable:p.trackConfigurable,zoom:l})}),s.singleOn("pointDeleted",o=>{h(o)}),s.singleOn("pointSelected",o=>{e.setSelectedIDs([o])}),s.singleOn("updatePointByDrag",(o,l)=>{var u;(u=m.topViewUpdatePoint)==null||u.call(m,o,a)}),s.singleOn("polygonCreated",(o,l)=>{if(s.pattern===EPolygonPattern.Normal||!(t==null?void 0:t.url)){const u=__spreadProps(__spreadValues({},o),{pointList:o.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,a))});b(u),e.setSelectedIDs(S.includes(o.attribute)?"":o.id);return}m.topViewAddBox({polygon:o,size:a,imgList:n,trackConfigurable:p.trackConfigurable,zoom:l,intelligentFit:g})}),s.singleOn("deletedObject",({id:o})=>{A(o),L(o)}),s.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),s.singleOn("addSelectedIDs",o=>{e.addSelectedID(o)}),s.singleOn("setSelectedIDs",o=>{e.setSelectedIDs(o)}),s.singleOn("updatePolygonByDrag",o=>{var l;(l=m.topViewUpdateBox)==null||l.call(m,o,a)});const c=o=>{var l;const u=k(o);u&&e.syncAllViewPointCloudColor(u),e.polygonList.find(r=>r.id===o)&&((l=e.topViewInstance)==null||l.toolInstance.setPolygonValidAndRender(o,!0))};return s.on("validUpdate",c),()=>{s.unbind("validUpdate",c)}},[e,a,t,m,e.polygonList,e.lineList,(P=e.topViewInstance)==null?void 0:P.toolInstance]),React.useEffect(()=>{var s,c;if(!(a==null?void 0:a.width)||!e.topViewInstance)return;const o=(c=(s=p==null?void 0:p.attributeList)==null?void 0:s[0])==null?void 0:c.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:l,toolInstance:u}}=e;u.singleOn("renderZoom",(r,f)=>{const{offsetX:q,offsetY:E}=TransferCanvas2WorldOffset(f,a,r);if(l.camera.zoom=r,f){const{x:j,y:T,z:N}=l.initCameraPosition;l.camera.position.set(j+E,T-q,N)}l.camera.updateProjectionMatrix(),l.render(),y(r),I(f,r,a),w({zoom:r,currentPos:f})}),u.singleOn("dragMove",({currentPos:r,zoom:f})=>{const{offsetX:q,offsetY:E}=TransferCanvas2WorldOffset(r,a,f);l.camera.zoom=f;const{x:j,y:T,z:N}=l.initCameraPosition;l.camera.position.set(j+E,T-q,N),l.render(),I(r,f,a),w({zoom:f,currentPos:r})})},[a,e.topViewInstance,(x=e.topViewInstance)==null?void 0:x.toolInstance]),React.useEffect(()=>{var s,c;(c=(s=e.topViewInstance)==null?void 0:s.pointCloudInstance)==null||c.applyZAxisPoints(O)},[O]),React.useEffect(()=>{m.topViewSelectedChanged({})},[e.selectedIDs]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","top-view"),title:D("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:d},v==null?void 0:v(V)),React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:C,config:p}),React__default.default.createElement(ZAxisSlider,{checkMode:C,zAxisLimit:O,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 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
|
+
"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 a=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(a,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:a,y:p}=lbUtils.PointCloudUtils.transferCanvas2World(t,o),{defaultZ:r}=lbUtils.DEFAULT_SPHERE_PARAMS,d={center:{x:a,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,a)=>{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,a);a&&y.fittedCoordinates.length>0&&(p=y.fittedCoordinates),r=(y.maxZ+y.minZ)/2,d=y.maxZ-y.minZ,h={count:y.zCount}}const[f,x,_]=p,U=lbAnnotation.MathUtils.getLineCenterPoint([f,_]),D=lbAnnotation.MathUtils.getLineLength(f,x),O=lbAnnotation.MathUtils.getLineLength(x,_),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:D,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,a,p]=t.pointList,[r,d,h]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,h]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},D=lbAnnotation.MathUtils.getLineLength(e,a),O=lbAnnotation.MathUtils.getLineLength(r,d),k=D-O,V=lbAnnotation.MathUtils.getLineLength(a,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,a,p]=t.pointList,[r,d,h]=o.pointList,f=lbAnnotation.MathUtils.getLineCenterPoint([e,p]),x=lbAnnotation.MathUtils.getLineCenterPoint([r,h]),U={x:{x:f.x-x.x,y:f.y-x.y}.x,y:0,z:f.y-x.y},D=lbAnnotation.MathUtils.getLineLength(e,a),O=lbAnnotation.MathUtils.getLineLength(r,d),k=D-O,V=lbAnnotation.MathUtils.getLineLength(a,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 a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=e==null?void 0:e.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Left);r.setInitCameraPosition(d);const{point2d:h,zoom:f}=r.getSphereSidePoint2DCoordinate(t);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),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:a}=i;a.loadPCDFileByBox(l,t,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(t,lbUtils.EPerspectiveView.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxSidePolygon2DCoordinate(t);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.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 a;if(!i)return;const{toolInstance:p,pointCloudInstance:r}=i;r.loadPCDFile(l,(a=e==null?void 0:e.radius)!=null?a:DEFAULT_RADIUS);const{cameraPositionVector:d}=r.updateOrthoCameraBySphere(t,lbUtils.EPerspectiveView.Back);r.setInitCameraPosition(d);const{point2d:h,zoom:f}=r.getSphereBackPoint2DCoordinate(t);r.camera.zoom=f,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(f),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:a}=i;a.loadPCDFileByBox(l,t,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:p}=a.updateOrthoCamera(t,lbUtils.EPerspectiveView.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:d}=a.getBoxBackPolygon2DCoordinate(t);a.camera.zoom=d,a.camera.updateProjectionMatrix(),a.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:a}=i,{point2d:p}=a.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:a,pointCloudInstance:p}=i,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(t),d=[...a.polygonList],h=d.find(f=>f.id===o.id);h?h.pointList=r:d.push({id:o.id,pointList:r,textAttribute:"",isRect:!0,valid:(e=t.valid)!=null?e:!0}),a.setResultAndSelectedID(d,o.id)},usePointCloudViews=()=>{const t=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:o,sideViewInstance:i,backViewInstance:l,mainViewInstance:e,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:d,pointCloudBoxList:h,pointCloudSphereList:f,hideAttributes:x}=t,{addHistory:_,initHistory:U,pushHistoryUnderUpdatePolygon:D,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:c,imgIndex:u}=n.annotation;return{currentData:c[u],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:c})=>{var u;const C={attribute:(u=o.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:f})});const g=topViewPoint2PointCloud(n,s,E,void 0,C);r(n.id);const v=p(g);M(PointCloudView.Top,n,g,P,v,L),_({newSphereParams:g})},J=({polygon:n,size:s,imgList:P,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var g;const v={attribute:(g=o.toolInstance.defaultAttribute)!=null?g:""};c===!0&&Object.assign(v,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:f})});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=a(B);q?r([]):(r(B.id),m.selection.setSelectedIDs(w.id),R(PointCloudView.Top,w,B,u,b),C&&synchronizeTopView(B,w,o,e)),_({newBoxParams:B})},K=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:P,newSphereList:c})=>{var u;const C=o==null?void 0:o.toolInstance;if(!(d.length===0||!C)){if(n||(j==null?void 0:j.info)){const g=n!=null?n:j==null?void 0:j.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(d[0]);const v=C.selectedPolygon;if(d.length===1&&g){R(PointCloudView.Top,v,g,void 0,s);return}}if((P||z)&&d.length===1){const g=P!=null?P:z;C.setSelectedID(d[0]);const v=C.selectedPoint;g&&M(PointCloudView.Top,v,g,void 0,c,L)}}},Z=(n,s,P)=>{if(N){let c,u;switch(P){case PointCloudView.Back:c=backViewPolygon2PointCloud;break;case PointCloudView.Side:c=sideViewPolygon2PointCloud;break;default:c=sideViewPolygon2PointCloud;break}if(u=c(n,s,N,i.pointCloudInstance),e){const{count:g}=e.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=__spreadProps(__spreadValues({},u),{count:g})}const C=V(u);return R(P,n,u,void 0,C),C}},W=(n,s,P)=>{if(z){let c,u;switch(P){case PointCloudView.Back:c=backViewPoint2PointCloud;break;case PointCloudView.Side:c=sideViewPoint2PointCloud;break;default:c=sideViewPoint2PointCloud;break}u=c(n,s,z);const C=H(u);return M(P,n,u,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),c=topViewPoint2PointCloud(n,s,E,P),u=H(c);M(PointCloudView.Top,n,c,void 0,u,L)},st=(n,s)=>{if(k){const c=n[0].newPolygon;c.pointList=c.pointList.map(u=>lbUtils.PointCloudUtils.transferCanvas2World(u,s)),D(n[0].newPolygon);return}const P=n.map(({newPolygon:c})=>{const u=A(c.id),{boxParams:C}=topViewPolygon2PointCloud(c,s,o.pointCloudInstance,u);return C});if(P.length===1){const{newPolygon:c}=n[0],u=S(P);R(PointCloudView.Top,c,P[0],void 0,u)}else{const c=S(P);c&&t.syncAllViewPointCloudColor(c)}},M=(n,s,P,c,u,C)=>__async(void 0,null,function*(){const g=T==null?void 0:T.url,v={[PointCloudView.Side]:()=>{syncSideViewByPoint(P,s,i,g,C)},[PointCloudView.Back]:()=>{l&&syncBackViewByPoint(P,s,l,g,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(P,s,o,e)}};Object.keys(v).forEach(m=>{m!==n&&v[m]()}),c&&(e==null||e.updateCameraZoom(c)),X(P)}),R=(n,s,P,c,u)=>__async(void 0,null,function*(){const C=T==null?void 0:T.url;u&&(yield t.syncAllViewPointCloudColor(u));const g={[PointCloudView.Side]:()=>{synchronizeSideView(P,s,i,C)},[PointCloudView.Back]:()=>{l&&synchronizeBackView(P,s,l,C)},[PointCloudView.Top]:()=>{synchronizeTopView(P,s,o,e)}};Object.keys(g).forEach(v=>{v!==n&&g[v]()}),c&&(e==null||e.updateCameraZoom(c)),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,c,u,C,g,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)}),f.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=(u=(c=index.jsonParser(s.result))==null?void 0:c.valid)!=null?u:!0;t.setPointCloudValid(q),(C=t.sideViewInstance)==null||C.clearAllData(),(g=t.backViewInstance)==null||g.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"),_=require("lodash"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,l,n)=>l in e?__defProp(e,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[l]=n,__spreadValues=(e,l)=>{for(var n in l||(l={}))__hasOwnProp.call(l,n)&&__defNormalProp(e,n,l[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(l))__propIsEnum.call(l,n)&&__defNormalProp(e,n,l[n]);return e},__spreadProps=(e,l)=>__defProps(e,__getOwnPropDescs(l));const{ESortDirection}=lbAnnotation.cAnnotation,useSingleBox=()=>{const{pointCloudBoxList:e,setPointCloudResult:l,topViewInstance:n,backViewInstance:P,sideViewInstance:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),_=require("lodash"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,l,n)=>l in e?__defProp(e,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[l]=n,__spreadValues=(e,l)=>{for(var n in l||(l={}))__hasOwnProp.call(l,n)&&__defNormalProp(e,n,l[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(l))__propIsEnum.call(l,n)&&__defNormalProp(e,n,l[n]);return e},__spreadProps=(e,l)=>__defProps(e,__getOwnPropDescs(l));const{ESortDirection}=lbAnnotation.cAnnotation,useSingleBox=()=>{const{pointCloudBoxList:e,setPointCloudResult:l,topViewInstance:n,backViewInstance:P,sideViewInstance:y,selectedIDs:c,selectedID:v,mainViewInstance:s,setSelectedIDs:I,syncAllViewPointCloudColor:C,polygonList:O,pointCloudPattern:x}=React.useContext(PointCloudContext.PointCloudContext),{selectedPolygon:a,updateSelectedPolygon:m,updatePolygonValidByID:h,deletePolygon:D}=usePolygon.usePolygon(),{pushHistoryWithList:g}=useHistory.useHistory(),d=React.useMemo(()=>{const o=e.findIndex(t=>t.id===v);if(o>-1)return{info:e[o],index:o}},[v,e]),B=React.useCallback(o=>{if(d==null?void 0:d.info){e.splice(d.index,1,___default.default.merge(d.info,o));const t=___default.default.cloneDeep(e);return l(t),g({pointCloudBoxList:t}),t}return e},[v,e]),V=React.useCallback((o,t)=>{const i=e.findIndex(r=>r.id===t);if(i>-1){e.splice(i,1,___default.default.merge(e[i],o));const r=___default.default.cloneDeep(e);return l(r),r}return e},[e]),f=React.useCallback(o=>{n==null||n.pointCloud2dOperation.setPolygonValidAndRender(o,!0),y==null||y.pointCloud2dOperation.setPolygonValidAndRender(o,!0),P==null||P.pointCloud2dOperation.setPolygonValidAndRender(o,!0)},[n,y,P]),L=React.useCallback(()=>{if(d==null?void 0:d.info){const{id:o,valid:t=!0}=d.info,i=B({valid:!t});C(i),f(o)}a&&(m(__spreadProps(__spreadValues({},a),{valid:!a.valid})),n==null||n.pointCloud2dOperation.setPolygonValidAndRender(a.id,!0))},[f,d,a]),S=React.useCallback(o=>{const t=e.find(i=>i.id===o);if(t){const{id:i,valid:r=!0}=t,u=V({valid:!r},i);return f(i),u}h(o)},[f,e,O]),b=React.useCallback((o=ESortDirection.ascend,t=!1)=>{if(!n||c.length>1)return;if(x!==lbAnnotation.EToolName.Rect&&x!==lbAnnotation.EToolName.Polygon){t&&document.dispatchEvent(new KeyboardEvent("keydown",{keyCode:9,shiftKey:o!==ESortDirection.ascend}));return}const{pointCloud2dOperation:i}=n,r=i.switchToNextPolygon(o);r&&I(r)},[n,x,n==null?void 0:n.toolInstance]),j=(o=!1)=>{b(ESortDirection.descend,o)},k=(o=!1)=>{b(ESortDirection.ascend,o)},w=o=>{const t=e.filter(i=>i.id!==o);l(t),s==null||s.removeObjectByName(o),s==null||s.render(),C(t)},A=()=>{d&&(w(d.info.id),n==null||n.pointCloud2dOperation.deletePolygon(d.info.id)),a&&(D(a.id),n==null||n.pointCloud2dOperation.deletePolygon(a.id))},E=React.useMemo(()=>e.filter(o=>c.includes(o.id)),[c,e]),N=React.useCallback(o=>{const t=___default.default.cloneDeep(e);let i=!1;if(o.forEach(r=>{const u=t.findIndex(p=>p.id===r.id);if(u>-1){const p=___default.default.merge(t[u],r);t.splice(u,1,p),s==null||s.generateBox(p),i=!0}}),i)return l(t),g({pointCloudBoxList:t}),s==null||s.render(),t},[c,e]),R=React.useCallback(o=>e.find(t=>t.id===o),[e]);return{selectedBox:d,updateSelectedBox:B,changeSelectedBoxValid:L,changeValidByID:S,selectNextBox:k,selectPrevBox:j,deletePointCloudBox:w,selectedBoxes:E,updateSelectedBoxes:N,getPointCloudByID:R,deleteSelectedPointCloudBoxAndPolygon:A}};exports.useSingleBox=useSingleBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js");const useZoom=()=>{const{topViewInstance:o,sideViewInstance:i,backViewInstance:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js");const useZoom=()=>{const{topViewInstance:o,sideViewInstance:i,backViewInstance:s}=React.useContext(PointCloudContext.PointCloudContext),{zoom:l,setZoom:c}=React.useContext(PointCloudContext.PointCloudContext);return{zoom:l,setZoom:c,initialPosition:()=>{o==null||o.toolInstance.initImgPos()},zoomOut:()=>{o==null||o.toolInstance.zoomChanged(!1)},zoomIn:()=>{o==null||o.toolInstance.zoomChanged(!0)},syncTopviewToolZoom:(n,t,e)=>{o==null||o.toolScheduler.syncPosition(n,t,e,o==null?void 0:o.toolInstance)},syncSideviewToolZoom:(n,t,e)=>{i==null||i.toolScheduler.syncPosition(n,t,e,i==null?void 0:i.toolInstance)},syncBackviewToolZoom:(n,t,e)=>{s==null||s.toolScheduler.syncPosition(n,t,e,s==null?void 0:s.toolInstance)}}};exports.useZoom=useZoom;
|
|
@@ -8,8 +8,8 @@ export declare const useSingleBox: () => {
|
|
|
8
8
|
updateSelectedBox: (params: Partial<IPointCloudBox>) => import("@labelbee/lb-utils").IPointCloudBoxList;
|
|
9
9
|
changeSelectedBoxValid: () => void;
|
|
10
10
|
changeValidByID: (id: string) => import("@labelbee/lb-utils").IPointCloudBoxList | undefined;
|
|
11
|
-
selectNextBox: (
|
|
12
|
-
selectPrevBox: () => void;
|
|
11
|
+
selectNextBox: (manual?: boolean) => void;
|
|
12
|
+
selectPrevBox: (manual?: boolean) => void;
|
|
13
13
|
deletePointCloudBox: (id: string) => void;
|
|
14
14
|
selectedBoxes: IPointCloudBox[];
|
|
15
15
|
updateSelectedBoxes: (updateList: PartialIPointCloudBoxList) => import("@labelbee/lb-utils").IPointCloudBoxList | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as I}from"../../utils/dom.js";import{FooterDivider as
|
|
1
|
+
import{getClassName as I}from"../../utils/dom.js";import{FooterDivider as Z}from"../../views/MainView/toolFooter/index.js";import{ZoomController as oe}from"../../views/MainView/toolFooter/ZoomController/index.js";import{UpSquareOutlined as ne,DownSquareOutlined as ie}from"@ant-design/icons";import{PointCloudAnnotation as se,cTool as le,cAnnotation as re}from"@labelbee/lb-annotation";import{PointCloudUtils as R}from"@labelbee/lb-utils";import r,{useState as z,useRef as ae,useLayoutEffect as ce,useEffect as O}from"react";import{PointCloudContext as W}from"./PointCloudContext.js";import{useRotate as de}from"./hooks/useRotate.js";import{useSingleBox as F}from"./hooks/useSingleBox.js";import{PointCloudContainer as pe}from"./PointCloudLayout.js";import{BoxInfos as ue,PointCloudValidity as me}from"./PointCloudInfos.js";import{usePolygon as fe}from"./hooks/usePolygon.js";import{useSphere as H}from"./hooks/useSphere.js";import{useZoom as M}from"./hooks/useZoom.js";import{Slider as ve}from"antd";import{a2MapStateToProps as Ce}from"../../store/annotation/map.js";import{connect as we}from"react-redux";import{usePointCloudViews as Pe}from"./hooks/usePointCloudViews.js";import ge from"../../hooks/useSize.js";import{useTranslation as Ie}from"react-i18next";import{LabelBeeContext as xe}from"../../store/ctx.js";import{jsonParser as he}from"../../utils/index.js";import ye from"../../utils/ToolUtils.js";import Ve from"lodash";import Se from"./components/PointCloudSizeSlider/index.js";import{useHistory as Oe}from"./hooks/useHistory.js";var _e=Object.defineProperty,Le=Object.defineProperties,be=Object.getOwnPropertyDescriptors,X=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,Y=(o,n,i)=>n in o?_e(o,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[n]=i,D=(o,n)=>{for(var i in n||(n={}))je.call(n,i)&&Y(o,i,n[i]);if(X)for(var i of X(n))Ee.call(n,i)&&Y(o,i,n[i]);return o},U=(o,n)=>Le(o,be(n));const{EPolygonPattern:Te,EToolName:q}=le,{ESortDirection:$}=re,G=(o,n,i=1)=>{const{width:v,height:C}=n,g={x:o.x+v*i/2,y:o.y+C*i/2},P={x:n.width/2,y:n.height/2};return{offsetX:(P.x-g.x)/i,offsetY:-(P.y-g.y)/i}},Ae=({currentData:o})=>{var n,i;const{zoom:v,zoomIn:C,zoomOut:g,initialPosition:P}=M(),{selectNextBox:h,selectPrevBox:_}=F(),{switchToNextSphere:x}=H(),{updateRotate:p}=de({currentData:o}),e=r.useContext(W),{topViewInstance:a}=e,m=(i=(n=e==null?void 0:e.topViewInstance)==null?void 0:n.toolScheduler)==null?void 0:i.getCurrentToolName(),y=2,V=()=>{p(-y)},L=()=>{p(y)},b=()=>{p(180)};return r.createElement(r.Fragment,null,r.createElement(Se,{onChange:j=>{var S;(S=a==null?void 0:a.pointCloudInstance)==null||S.updatePointSize({customSize:j})}}),r.createElement("span",{onClick:L,className:I("point-cloud","rotate-reserve")}),r.createElement("span",{onClick:V,className:I("point-cloud","rotate")}),r.createElement("span",{onClick:b,className:I("point-cloud","rotate-180")}),r.createElement(Z,null),r.createElement(ne,{onClick:()=>{if(m===q.Point){x($.descend);return}_(!0)},className:I("point-cloud","prev")}),r.createElement(ie,{onClick:()=>{if(m===q.Point){x($.ascend);return}h(!0)},className:I("point-cloud","next")}),r.createElement(Z,null),r.createElement(oe,{initialPosition:P,zoomIn:C,zoomOut:g,zoom:v}))},Ne=({setZAxisLimit:o,zAxisLimit:n,checkMode:i})=>i?null:r.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},r.createElement(ve,{vertical:!0,step:.5,max:10,min:.5,defaultValue:n,onAfterChange:v=>{o(v)}})),ke=({currentData:o,imgList:n,stepInfo:i,drawLayerSlot:v,checkMode:C,intelligentFit:g})=>{var P,h;const[_,x]=z({zoom:1,currentPos:{x:0,y:0}}),p=ae(null),e=r.useContext(W),a=ge(p),m=he(i.config),{setZoom:y,syncTopviewToolZoom:V}=M(),{hideAttributes:L}=e,{addPolygon:b,deletePolygon:j}=fe(),{deletePointCloudSphere:S}=H(),{deletePointCloudBox:J,changeValidByID:K}=F(),[E,Q]=z(10),{t:ee}=Ie(),w=Pe(),{pushHistoryWithList:te}=Oe();return ce(()=>{if(!e.topViewInstance&&p.current&&(o==null?void 0:o.url)&&(o==null?void 0:o.result)){const s={width:p.current.clientWidth,height:p.current.clientHeight},u=new se({container:p.current,size:s,pcdPath:o.url,config:U(D({},m),{pointCloudPattern:e.pointCloudPattern}),checkMode:C,toolName:ye.getPointCloudToolList(),proxyMode:C});e.setTopViewInstance(u)}},[o]),O(()=>{if(!a||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:s}=e.topViewInstance;s.singleOn("dataUpdated",(t,l)=>{const d=Ve.cloneDeep(t).map(c=>U(D({},c),{pointList:R.pointListTransferCanvas2World(c.pointList,a)}));e.setSelectedIDs(l),e.setLineList(d),te({lineList:d})}),s.singleOn("pointCreated",(t,l)=>{w.topViewAddSphere({newPoint:t,size:a,trackConfigurable:m.trackConfigurable,zoom:l})}),s.singleOn("pointDeleted",t=>{S(t)}),s.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),s.singleOn("updatePointByDrag",(t,l)=>{var d;(d=w.topViewUpdatePoint)==null||d.call(w,t,a)}),s.singleOn("polygonCreated",(t,l)=>{if(s.pattern===Te.Normal||!(o==null?void 0:o.url)){const d=U(D({},t),{pointList:t.pointList.map(c=>R.transferCanvas2World(c,a))});b(d),e.setSelectedIDs(L.includes(t.attribute)?"":t.id);return}w.topViewAddBox({polygon:t,size:a,imgList:n,trackConfigurable:m.trackConfigurable,zoom:l,intelligentFit:g})}),s.singleOn("deletedObject",({id:t})=>{J(t),j(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=w.topViewUpdateBox)==null||l.call(w,t,a)});const u=t=>{var l;const d=K(t);d&&e.syncAllViewPointCloudColor(d),e.polygonList.find(c=>c.id===t)&&((l=e.topViewInstance)==null||l.toolInstance.setPolygonValidAndRender(t,!0))};return s.on("validUpdate",u),()=>{s.unbind("validUpdate",u)}},[e,a,o,w,e.polygonList,e.lineList,(P=e.topViewInstance)==null?void 0:P.toolInstance]),O(()=>{var s,u;if(!(a==null?void 0:a.width)||!e.topViewInstance)return;const t=(u=(s=m==null?void 0:m.attributeList)==null?void 0:s[0])==null?void 0:u.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:d}}=e;d.singleOn("renderZoom",(c,f)=>{const{offsetX:T,offsetY:A}=G(f,a,c);if(l.camera.zoom=c,f){const{x:N,y:k,z:B}=l.initCameraPosition;l.camera.position.set(N+A,k-T,B)}l.camera.updateProjectionMatrix(),l.render(),y(c),V(f,c,a),x({zoom:c,currentPos:f})}),d.singleOn("dragMove",({currentPos:c,zoom:f})=>{const{offsetX:T,offsetY:A}=G(c,a,f);l.camera.zoom=f;const{x:N,y:k,z:B}=l.initCameraPosition;l.camera.position.set(N+A,k-T,B),l.render(),V(c,f,a),x({zoom:f,currentPos:c})})},[a,e.topViewInstance,(h=e.topViewInstance)==null?void 0:h.toolInstance]),O(()=>{var s,u;(u=(s=e.topViewInstance)==null?void 0:s.pointCloudInstance)==null||u.applyZAxisPoints(E)},[E]),O(()=>{w.topViewSelectedChanged({})},[e.selectedIDs]),r.createElement(pe,{className:I("point-cloud-container","top-view"),title:ee("TopView"),toolbar:r.createElement(Ae,{currentData:o})},r.createElement("div",{style:{position:"relative",flex:1}},r.createElement("div",{style:{width:"100%",height:"100%"},ref:p},v==null?void 0:v(_)),r.createElement(ue,{checkMode:C,config:m}),r.createElement(Ne,{checkMode:C,zAxisLimit:E,setZAxisLimit:Q}),r.createElement(me,null)))};var Be=we(Ce,null,null,{context:xe})(ke);export{Be as default};
|
|
@@ -1 +1 @@
|
|
|
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
|
+
import{MathUtils as x,getCuboidFromPointCloudBox as Ot}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 a=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(a,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:a,y:p}=I.transferCanvas2World(t,e),{defaultZ:r}=Vt,l={center:{x:a,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,a)=>{let p=t.pointList.map(y=>I.transferCanvas2World(y,e)),r=0,l=1,P={};if(n){const y=n.getSensesPointZAxisInPolygon(p,void 0,a);a&&y.fittedCoordinates.length>0&&(p=y.fittedCoordinates),r=(y.maxZ+y.minZ)/2,l=y.maxZ-y.minZ,P={count:y.zCount}}const[h,B,j]=p,V=x.getLineCenterPoint([h,j]),T=x.getLineLength(h,B),z=x.getLineLength(B,j),R=x.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,a,p]=t.pointList,[r,l,P]=e.pointList,h=x.getLineCenterPoint([o,p]),B=x.getLineCenterPoint([r,P]),V={x:{x:h.x-B.x,y:h.y-B.y}.x,y:0,z:h.y-B.y},T=x.getLineLength(o,a),z=x.getLineLength(r,l),R=T-z,U=x.getLineLength(a,p),D=x.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,a,p]=t.pointList,[r,l,P]=e.pointList,h=x.getLineCenterPoint([o,p]),B=x.getLineCenterPoint([r,P]),V={x:{x:h.x-B.x,y:h.y-B.y}.x,y:0,z:h.y-B.y},T=x.getLineLength(o,a),z=x.getLineLength(r,l),R=T-z,U=x.getLineLength(a,p),D=x.getLineLength(l,P),E=U-D;let{newBoxParams:y}=d.getNewBoxByBackUpdate(V,E,R,n);return y},pt=(t,e,n,d,o)=>{var a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:Q);const{cameraPositionVector:l}=r.updateOrthoCameraBySphere(t,N.Left);r.setInitCameraPosition(l);const{point2d:P,zoom:h}=r.getSphereSidePoint2DCoordinate(t);r.camera.zoom=h,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(h),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:a}=n;a.loadPCDFileByBox(d,t,{width:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(t,N.Left);a.setInitCameraPosition(p);const{polygon2d:r,zoom:l}=a.getBoxSidePolygon2DCoordinate(t);a.camera.zoom=l,a.camera.updateProjectionMatrix(),a.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 a;if(!n)return;const{toolInstance:p,pointCloudInstance:r}=n;r.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:Q);const{cameraPositionVector:l}=r.updateOrthoCameraBySphere(t,N.Back);r.setInitCameraPosition(l);const{point2d:P,zoom:h}=r.getSphereBackPoint2DCoordinate(t);r.camera.zoom=h,r.camera.updateProjectionMatrix(),r.render(),p.initPosition(),p.zoomChangeOnCenter(h),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:a}=n;a.loadPCDFileByBox(d,t,{height:G,depth:G});const{cameraPositionVector:p}=a.updateOrthoCamera(t,N.Back);a.setInitCameraPosition(p);const{polygon2d:r,zoom:l}=a.getBoxBackPolygon2DCoordinate(t);a.camera.zoom=l,a.camera.updateProjectionMatrix(),a.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:a}=n,{point2d:p}=a.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:a,pointCloudInstance:p}=n,{polygon2d:r}=p.getBoxTopPolygon2DCoordinate(t),l=[...a.polygonList],P=l.find(h=>h.id===e.id);P?P.pointList=r:l.push({id:e.id,pointList:r,textAttribute:"",isRect:!0,valid:(o=t.valid)!=null?o:!0}),a.setResultAndSelectedID(l,e.id)},Yt=()=>{const t=Ut(kt),{topViewInstance:e,sideViewInstance:n,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:p,setSelectedIDs:r,selectedIDs:l,pointCloudBoxList:P,pointCloudSphereList:h,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:c,imgIndex:u}=i.annotation;return{currentData:c[u],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:c})=>{var u;const C={attribute:(u=e.toolInstance.defaultAttribute)!=null?u:""};c===!0&&Object.assign(C,{trackID:I.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:h})});const g=J(i,s,X,void 0,C);r(i.id);const v=p(g);W(L.Top,i,g,f,v,S),j({newSphereParams:g})},vt=({polygon:i,size:s,imgList:f,trackConfigurable:c,zoom:u,intelligentFit:C})=>{var g;const v={attribute:(g=e.toolInstance.defaultAttribute)!=null?g:""};c===!0&&Object.assign(v,{trackID:I.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:h})});const w=e==null?void 0:e.toolInstance,_=m({},i),{boxParams:b,newPointList:k}=K(_,s,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&&(k==null?void 0:k.length)&&(_.pointList=k);const Y=B.includes(_.attribute),O=a(b);Y?r([]):(r(b.id),w.selection.setSelectedIDs(_.id),M(L.Top,_,b,u,O),C&&$(b,_,e,o)),j({newBoxParams:b})},xt=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:f,newSphereList:c})=>{var u;const C=e==null?void 0:e.toolInstance;if(!(l.length===0||!C)){if(i||(H==null?void 0:H.info)){const g=i!=null?i:H==null?void 0:H.info;(u=C==null?void 0:C.selection)==null||u.setSelectedIDs(l[0]);const v=C.selectedPolygon;if(l.length===1&&g){M(L.Top,v,g,void 0,s);return}}if((f||Z)&&l.length===1){const g=f!=null?f:Z;C.setSelectedID(l[0]);const v=C.selectedPoint;g&&W(L.Top,v,g,void 0,c,S)}}},nt=(i,s,f)=>{if(et){let c,u;switch(f){case L.Back:c=Xt;break;case L.Side:c=ut;break;default:c=ut;break}if(u=c(i,s,et,n.pointCloudInstance),o){const{count:g}=o.getSensesPointZAxisInPolygon(Ot(u).polygonPointList,[u.center.z-u.depth/2,u.center.z+u.depth/2]);u=A(m({},u),{count:g})}const C=U(u);return M(f,i,u,void 0,C),C}},it=(i,s,f)=>{if(Z){let c,u;switch(f){case L.Back:c=Qt;break;case L.Side:c=ct;break;default:c=ct;break}u=c(i,s,Z);const C=tt(u);return W(f,i,u,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),c=J(i,s,X,f),u=tt(c);W(L.Top,i,c,void 0,u,S)},_t=(i,s)=>{if(R){const c=i[0].newPolygon;c.pointList=c.pointList.map(u=>I.transferCanvas2World(u,s)),T(i[0].newPolygon);return}const f=i.map(({newPolygon:c})=>{const u=E(c.id),{boxParams:C}=K(c,s,e.pointCloudInstance,u);return C});if(f.length===1){const{newPolygon:c}=i[0],u=D(f);M(L.Top,c,f[0],void 0,u)}else{const c=D(f);c&&t.syncAllViewPointCloudColor(c)}},W=(i,s,f,c,u,C)=>q(void 0,null,function*(){const g=F==null?void 0:F.url,v={[L.Side]:()=>{pt(f,s,n,g,C)},[L.Back]:()=>{d&&Ct(f,s,d,g,C)},[L.Top]:()=>{gt(f,s,e,o)}};Object.keys(v).forEach(w=>{w!==i&&v[w]()}),c&&(o==null||o.updateCameraZoom(c)),mt(f)}),M=(i,s,f,c,u)=>q(void 0,null,function*(){const C=F==null?void 0:F.url;u&&(yield t.syncAllViewPointCloudColor(u));const g={[L.Side]:()=>{ft(f,s,n,C)},[L.Back]:()=>{d&&Pt(f,s,d,C)},[L.Top]:()=>{$(f,s,e,o)}};Object.keys(g).forEach(v=>{v!==i&&g[v]()}),c&&(o==null||o.updateCameraZoom(c)),Lt(f)});return{topViewAddSphere:yt,topViewAddBox:vt,topViewSelectedChanged:xt,topViewUpdatePoint:Dt,sideViewUpdatePoint:Bt,backViewUpdatePoint:St,topViewUpdateBox:_t,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,c,u,C,g,v;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=>{o==null||o.removeObjectByName(O.id)}),h.forEach(O=>{o==null||o.removeObjectByName(O.id)});let w=[],_=[],b=[],k=[];s.result?(w=I.getBoxParamsFromResultList(s.result),b=I.getPolygonListFromResultList(s.result),_=I.getLineListFromResultList(s.result),k=I.getSphereParamsFromResultList(s.result),w.forEach(O=>{o==null||o.generateBox(O)}),k.forEach(O=>{o==null||o.generateSphere(O)}),t.syncAllViewPointCloudColor(w),t.setPointCloudResult(w),t.setPolygonList(b),t.setLineList(_),t.setPointCloudSphereList(k)):(t.setPointCloudResult([]),t.setPolygonList([]),t.setPointCloudSphereList([]),t.setLineList([])),V({pointCloudBoxList:w,polygonList:b,pointCloudSphereList:k}),o.updateTopCamera();const Y=(u=(c=rt(s.result))==null?void 0:c.valid)!=null?u:!0;t.setPointCloudValid(Y),(C=t.sideViewInstance)==null||C.clearAllData(),(g=t.backViewInstance)==null||g.clearAllData(),e.updateData(s.url,s.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 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as z,useMemo as h,useCallback as a}from"react";import u from"lodash";import{PointCloudContext as F}from"../PointCloudContext.js";import{EToolName as V,cAnnotation as G}from"@labelbee/lb-annotation";import{useHistory as J}from"./useHistory.js";import{usePolygon as Q}from"./usePolygon.js";var U=Object.defineProperty,X=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,D=(e,i,t)=>i in e?U(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t,ee=(e,i)=>{for(var t in i||(i={}))Z.call(i,t)&&D(e,t,i[t]);if(b)for(var t of b(i))$.call(i,t)&&D(e,t,i[t]);return e},oe=(e,i)=>X(e,Y(i));const{ESortDirection:y}=G,ne=()=>{const{pointCloudBoxList:e,setPointCloudResult:i,topViewInstance:t,backViewInstance:v,sideViewInstance:g,selectedIDs:f,selectedID:C,mainViewInstance:s,setSelectedIDs:L,syncAllViewPointCloudColor:B,polygonList:S,pointCloudPattern:m}=z(F),{selectedPolygon:c,updateSelectedPolygon:j,updatePolygonValidByID:A,deletePolygon:E}=Q(),{pushHistoryWithList:w}=J(),l=h(()=>{const o=e.findIndex(n=>n.id===C);if(o>-1)return{info:e[o],index:o}},[C,e]),I=a(o=>{if(l==null?void 0:l.info){e.splice(l.index,1,u.merge(l.info,o));const n=u.cloneDeep(e);return i(n),w({pointCloudBoxList:n}),n}return e},[C,e]),N=a((o,n)=>{const d=e.findIndex(r=>r.id===n);if(d>-1){e.splice(d,1,u.merge(e[d],o));const r=u.cloneDeep(e);return i(r),r}return e},[e]),P=a(o=>{t==null||t.pointCloud2dOperation.setPolygonValidAndRender(o,!0),g==null||g.pointCloud2dOperation.setPolygonValidAndRender(o,!0),v==null||v.pointCloud2dOperation.setPolygonValidAndRender(o,!0)},[t,g,v]),R=a(()=>{if(l==null?void 0:l.info){const{id:o,valid:n=!0}=l.info,d=I({valid:!n});B(d),P(o)}c&&(j(oe(ee({},c),{valid:!c.valid})),t==null||t.pointCloud2dOperation.setPolygonValidAndRender(c.id,!0))},[P,l,c]),H=a(o=>{const n=e.find(d=>d.id===o);if(n){const{id:d,valid:r=!0}=n,p=N({valid:!r},d);return P(d),p}A(o)},[P,e,S]),O=a((o=y.ascend,n=!1)=>{if(!t||f.length>1)return;if(m!==V.Rect&&m!==V.Polygon){n&&document.dispatchEvent(new KeyboardEvent("keydown",{keyCode:9,shiftKey:o!==y.ascend}));return}const{pointCloud2dOperation:d}=t,r=d.switchToNextPolygon(o);r&&L(r)},[t,m,t==null?void 0:t.toolInstance]),T=(o=!1)=>{O(y.descend,o)},k=(o=!1)=>{O(y.ascend,o)},_=o=>{const n=e.filter(d=>d.id!==o);i(n),s==null||s.removeObjectByName(o),s==null||s.render(),B(n)},K=()=>{l&&(_(l.info.id),t==null||t.pointCloud2dOperation.deletePolygon(l.info.id)),c&&(E(c.id),t==null||t.pointCloud2dOperation.deletePolygon(c.id))},M=h(()=>e.filter(o=>f.includes(o.id)),[f,e]),W=a(o=>{const n=u.cloneDeep(e);let d=!1;if(o.forEach(r=>{const p=n.findIndex(x=>x.id===r.id);if(p>-1){const x=u.merge(n[p],r);n.splice(p,1,x),s==null||s.generateBox(x),d=!0}}),d)return i(n),w({pointCloudBoxList:n}),s==null||s.render(),n},[f,e]),q=a(o=>e.find(n=>n.id===o),[e]);return{selectedBox:l,updateSelectedBox:I,changeSelectedBoxValid:R,changeValidByID:H,selectNextBox:k,selectPrevBox:T,deletePointCloudBox:_,selectedBoxes:M,updateSelectedBoxes:W,getPointCloudByID:q,deleteSelectedPointCloudBoxAndPolygon:K}};export{ne as useSingleBox};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as s}from"react";import{PointCloudContext as c}from"../PointCloudContext.js";const
|
|
1
|
+
import{useContext as s}from"react";import{PointCloudContext as c}from"../PointCloudContext.js";const d=()=>{const{topViewInstance:o,sideViewInstance:l,backViewInstance:e}=s(c),{zoom:m,setZoom:u}=s(c);return{zoom:m,setZoom:u,initialPosition:()=>{o==null||o.toolInstance.initImgPos()},zoomOut:()=>{o==null||o.toolInstance.zoomChanged(!1)},zoomIn:()=>{o==null||o.toolInstance.zoomChanged(!0)},syncTopviewToolZoom:(n,t,i)=>{o==null||o.toolScheduler.syncPosition(n,t,i,o==null?void 0:o.toolInstance)},syncSideviewToolZoom:(n,t,i)=>{l==null||l.toolScheduler.syncPosition(n,t,i,l==null?void 0:l.toolInstance)},syncBackviewToolZoom:(n,t,i)=>{e==null||e.toolScheduler.syncPosition(n,t,i,e==null?void 0:e.toolInstance)}}};export{d as useZoom};
|
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.23",
|
|
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.21",
|
|
47
47
|
"@labelbee/lb-utils": "1.7.0-alpha.10",
|
|
48
48
|
"ahooks": "^3.4.0",
|
|
49
49
|
"classnames": "^2.3.0",
|