@labelbee/lb-components 1.24.0-alpha.43 → 1.24.0-alpha.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as S}from"../../utils/dom.js";import{FooterDivider as
|
|
1
|
+
import{getClassName as S}from"../../utils/dom.js";import{FooterDivider as H}from"../../views/MainView/toolFooter/index.js";import{ZoomController as ge}from"../../views/MainView/toolFooter/ZoomController/index.js";import{LeftOutlined as Ie,UpSquareOutlined as ye,DownSquareOutlined as xe}from"@ant-design/icons";import{cKeyCode as Ve,PointCloudAnnotation as he,MathUtils as W,cTool as Se,cAnnotation as _e}from"@labelbee/lb-annotation";import{PointCloudUtils as K}from"@labelbee/lb-utils";import{EPointCloudBoxRenderTrigger as M}from"../../utils/ToolPointCloudBoxRenderHelper.js";import s,{useState as D,useRef as Ee,useContext as X,useLayoutEffect as Le,useEffect as C}from"react";import{PointCloudContext as Y}from"./PointCloudContext.js";import{useRotate as be}from"./hooks/useRotate.js";import{useRotateEdge as Oe}from"./hooks/useRotateEdge.js";import{useSingleBox as q}from"./hooks/useSingleBox.js";import{PointCloudContainer as je}from"./PointCloudLayout.js";import{BoxInfos as $,PointCloudValidity as Te}from"./PointCloudInfos.js";import{usePolygon as De}from"./hooks/usePolygon.js";import{useSphere as G}from"./hooks/useSphere.js";import{useZoom as J}from"./hooks/useZoom.js";import{Slider as ke}from"antd";import{a2MapStateToProps as Re}from"../../store/annotation/map.js";import{connect as Be}from"react-redux";import{usePointCloudViews as Ae}from"./hooks/usePointCloudViews.js";import Ne from"../../hooks/useSize.js";import{useTranslation as Ue}from"react-i18next";import{LabelBeeContext as ze}from"../../store/ctx.js";import{jsonParser as Ze}from"../../utils/index.js";import Fe from"../../utils/ToolUtils.js";import He from"lodash";import We from"./components/PointCloudSizeSlider/index.js";import{useHistory as Ke}from"./hooks/useHistory.js";import Me from"./components/TitleButton/index.js";import{useDebounceFn as Xe}from"ahooks";var Ye=Object.defineProperty,qe=Object.defineProperties,$e=Object.getOwnPropertyDescriptors,Q=Object.getOwnPropertySymbols,Ge=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,ee=(i,l,a)=>l in i?Ye(i,l,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[l]=a,A=(i,l)=>{for(var a in l||(l={}))Ge.call(l,a)&&ee(i,a,l[a]);if(Q)for(var a of Q(l))Je.call(l,a)&&ee(i,a,l[a]);return i},N=(i,l)=>qe(i,$e(l));const{EPolygonPattern:Qe,EToolName:te}=Se,{ESortDirection:oe}=_e,et=Ve.default,ne=(i,l,a=1)=>{const{width:v,height:p}=l,I={x:i.x+v*a/2,y:i.y+p*a/2},y={x:l.width/2,y:l.height/2};return{offsetX:(y.x-I.x)/a,offsetY:-(y.y-I.y)/a}},tt=({currentData:i})=>{var l,a;const{zoom:v,zoomIn:p,zoomOut:I,initialPosition:y}=J(),{selectNextBox:b,selectPrevBox:O}=q(),{switchToNextSphere:_}=G(),{updateRotate:E}=be({currentData:i}),{updateRotateEdge:j}=Oe({currentData:i}),g=X(Y),{topViewInstance:x}=g,m=(a=(l=g==null?void 0:g.topViewInstance)==null?void 0:l.toolScheduler)==null?void 0:a.getCurrentToolName(),t=()=>{E(-Number(g.rectRotateSensitivity))},c=()=>{E(g.rectRotateSensitivity)},f=()=>{j(-90)};return s.createElement(s.Fragment,null,s.createElement(We,{onChange:k=>{var V;(V=x==null?void 0:x.pointCloudInstance)==null||V.updatePointSize({customSize:k})}}),s.createElement("span",{onClick:c,className:S("point-cloud","rotate-reserve")}),s.createElement("span",{onClick:t,className:S("point-cloud","rotate")}),s.createElement("span",{onClick:f,className:S("point-cloud","rotate-90")}),s.createElement(H,null),s.createElement(ye,{onClick:()=>{if(m===te.Point){_(oe.descend);return}O(!0)},className:S("point-cloud","prev")}),s.createElement(xe,{onClick:()=>{if(m===te.Point){_(oe.ascend);return}b(!0)},className:S("point-cloud","next")}),s.createElement(H,null),s.createElement(ge,{initialPosition:y,zoomIn:p,zoomOut:I,zoom:v}))},ot=({setZAxisLimit:i,zAxisLimit:l,checkMode:a})=>a?null:s.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},s.createElement(ke,{vertical:!0,step:.5,max:10,min:.5,defaultValue:l,onAfterChange:v=>{i(v)}})),nt=({currentData:i,imgList:l,stepInfo:a,drawLayerSlot:v,checkMode:p,intelligentFit:I,setIsEnlargeTopView:y,isEnlargeTopView:b,onExitZoom:O,highlightAttribute:_})=>{var E,j;const[g,x]=D({zoom:1,currentPos:{x:0,y:0}}),m=Ee(null),t=X(Y),c=Ne(m),f=Ze(a.config),{setZoom:k,syncTopviewToolZoom:V}=J(),{run:ie}=Xe(k,{wait:500}),{hideAttributes:se,setIsLargeStatus:le,selectedID:re,pointCloudBoxList:ae}=t,{addPolygon:ce,deletePolygon:de}=De(),{deletePointCloudSphere:ue}=G(),{deletePointCloudBox:pe,changeValidByID:me}=q(),[R,fe]=D(10),{t:U}=Ue(),w=Ae(),{pushHistoryWithList:Ce}=Ke(),[ve,T]=D(!0),[z,Z]=D(!1);Le(()=>{if(!t.topViewInstance&&m.current&&(i==null?void 0:i.url)&&(i==null?void 0:i.result)){const o={width:m.current.clientWidth,height:m.current.clientHeight},r=new he({container:m.current,size:o,pcdPath:i.url,config:N(A({},f),{pointCloudPattern:t.pointCloudPattern}),checkMode:p,toolName:Fe.getPointCloudToolList(),proxyMode:p,view:"topView"});t.setTopViewInstance(r)}},[i]),C(()=>{z&&re&&(t.syncAllViewPointCloudColor(M.Single,ae),Z(!1))},[z]),C(()=>{if(!c||!t.topViewInstance||!t.sideViewInstance)return;const{toolInstance:o}=t.topViewInstance;o.singleOn("dataUpdated",(e,n)=>{const d=He.cloneDeep(e).map(u=>N(A({},u),{pointList:K.pointListTransferCanvas2World(u.pointList,c)}));t.setSelectedIDs(n),t.setLineList(d),Ce({lineList:d})}),o.singleOn("pointCreated",(e,n)=>{w.topViewAddSphere({newPoint:e,size:c,trackConfigurable:f.trackConfigurable,zoom:n})}),o.singleOn("pointDeleted",e=>{ue(e)}),o.singleOn("pointSelected",e=>{t.setSelectedIDs([e])}),o.singleOn("updatePointByDrag",(e,n)=>{var d;(d=w.topViewUpdatePoint)==null||d.call(w,e,c)}),o.singleOn("polygonCreated",(e,n)=>{if(o.pattern===Qe.Normal||!(i==null?void 0:i.url)){const d=N(A({},e),{pointList:e.pointList.map(u=>K.transferCanvas2World(u,c))});ce(d),t.setSelectedIDs(se.includes(e.attribute)?"":e.id);return}T(!1),w.topViewAddBox({polygon:e,size:c,imgList:l,trackConfigurable:f.trackConfigurable,zoom:n,intelligentFit:I}),Z(!0)}),o.singleOn("deletedObject",({id:e})=>{pe(e),de(e)}),o.singleOn("deleteSelectedIDs",()=>{t.setSelectedIDs([])}),o.singleOn("addSelectedIDs",e=>{t.addSelectedID(e)}),o.singleOn("setSelectedIDs",e=>{T(!1),t.setSelectedIDs(e)}),o.singleOn("updatePolygonByDrag",e=>{var n;(n=w.topViewUpdateBox)==null||n.call(w,e,c)});const r=e=>{var n;const d=me(e);d&&t.syncAllViewPointCloudColor(M.Default,d),t.polygonList.find(u=>u.id===e)&&((n=t.topViewInstance)==null||n.toolInstance.setPolygonValidAndRender(e,!0))};return o.on("validUpdate",r),()=>{o.unbind("validUpdate",r)}},[t,c,i,w,t.polygonList,t.lineList,(E=t.topViewInstance)==null?void 0:E.toolInstance]),C(()=>{var o,r;if(!t.topViewInstance)return;const e=(r=(o=f==null?void 0:f.attributeList)==null?void 0:o[0])==null?void 0:r.value;e&&t.topViewInstance.toolInstance.setDefaultAttribute(e)},[t.topViewInstance]),C(()=>{if(!(c==null?void 0:c.width)||!t.topViewInstance)return;t.topViewInstance.initSize(c),t.topViewInstance.updatePolygonList(t.displayPointCloudList,t.polygonList),t.topViewInstance.updatePointList(t.displaySphereList),t.topViewInstance.updateLineList(t.displayLineList);const{topViewInstance:{pointCloudInstance:o,toolInstance:r}}=t;r.singleOn("renderZoom",(e,n)=>{const{offsetX:d,offsetY:u}=ne(n,c,e);if(o.camera.zoom=e,n){const{x:P,y:h,z:L}=o.initCameraPosition;o.camera.position.set(P+u,h-d,L)}o.camera.updateProjectionMatrix(),o.render(),ie(e),V(n,e,c),x({zoom:e,currentPos:n})}),r.singleOn("dragMove",({currentPos:e,zoom:n})=>{const{offsetX:d,offsetY:u}=ne(e,c,n);o.camera.zoom=n;const{x:P,y:h,z:L}=o.initCameraPosition;o.camera.position.set(P+u,h-d,L),o.render(),V(e,n,c),x({zoom:n,currentPos:e})})},[c,t.topViewInstance,(j=t.topViewInstance)==null?void 0:j.toolInstance]),C(()=>{var o,r;(r=(o=t.topViewInstance)==null?void 0:o.pointCloudInstance)==null||r.applyZAxisPoints(R)},[R]),C(()=>{var o,r,e,n;w.topViewSelectedChanged({}),(n=(e=(r=(o=t.topViewInstance)==null?void 0:o.toolInstance)==null?void 0:r.selection)==null?void 0:e.hardSetSelectedIDs)==null||n.call(e,t.selectedIDs)},[t.selectedIDs]),C(()=>{const{topViewInstance:o,selectedID:r,selectedPointCloudBox:e,zoom:n}=t;if(!o||!r||!e||!ve){T(!0);return}const{center:d}=e,{pointCloudInstance:u,toolInstance:P}=o,h=P.polygonList.find(Pe=>Pe.id===t.selectedID);if(!h){T(!0);return}const L=W.getRectCenterPoint(h.pointList),B=W.getCurrentPosFromRectCenter(P.size,L,n);P.setCurrentPos(B),P.render();const{x:st,y:lt,z:we}=u.initCameraPosition;u.camera.position.set(d.x,d.y,we),u.render(),V(B,n,c),x({zoom:n,currentPos:B})},[t.selectedID]),C(()=>(window.addEventListener("keydown",F),()=>{window.removeEventListener("keydown",F)}),[]);const F=o=>{const{keyCode:r}=o;r===et.Esc&&O()};return C(()=>{var o,r,e;(e=(r=(o=t.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:r.setHighlightAttribute)==null||e.call(r,_)},[t.topViewInstance,_]),s.createElement(je,{className:S("point-cloud-container","top-view"),title:b?s.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},s.createElement(Ie,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{O()}}),s.createElement("span",null,U("TopView")),s.createElement($,{checkMode:p,config:f,style:{display:"flex",position:"initial",margin:"0px 20px"}})):s.createElement(Me,{title:U("TopView"),onClick:()=>{le(!0),y(!0)}}),toolbar:s.createElement(tt,{currentData:i})},s.createElement("div",{style:{position:"relative",flex:1}},s.createElement("div",{style:{width:"100%",height:"100%"},ref:m},v==null?void 0:v(g)),!b&&s.createElement($,{checkMode:p,config:f}),s.createElement(ot,{checkMode:p,zAxisLimit:R,setZAxisLimit:fe}),s.createElement(Te,null)))};var it=Be(Re,null,null,{context:ze})(nt);export{it as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.24.0-alpha.
|
|
3
|
+
"version": "1.24.0-alpha.45",
|
|
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.28.0-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.28.0-alpha.25",
|
|
47
47
|
"@labelbee/lb-utils": "1.20.0-alpha.3",
|
|
48
48
|
"@labelbee/wavesurfer": "1.1.0",
|
|
49
49
|
"@types/react-dom": "18.3.1",
|