@labelbee/lb-components 1.23.0-alpha.45 → 1.23.0-alpha.46
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/pointCloud2DRectOperationView/index.js +1 -1
- package/dist/components/pointCloudView/PointCloud2DSingleView.js +1 -1
- package/dist/components/pointCloudView/PointCloudSegment2DView.js +1 -1
- package/dist/components/pointCloudView/hooks/useHighlight.js +1 -1
- package/dist/types/components/pointCloudView/PointCloudContext.d.ts +1 -0
- package/dist/types/components/pointCloudView/hooks/useHighlight.d.ts +1 -1
- package/es/components/pointCloud2DRectOperationView/index.js +1 -1
- package/es/components/pointCloudView/PointCloud2DSingleView.js +1 -1
- package/es/components/pointCloudView/PointCloudSegment2DView.js +1 -1
- package/es/components/pointCloudView/hooks/useHighlight.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(u,i,
|
|
1
|
+
"use strict";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(u,i,l)=>i in u?__defProp(u,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[i]=l,__spreadValues=(u,i)=>{for(var l in i||(i={}))__hasOwnProp.call(i,l)&&__defNormalProp(u,l,i[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(i))__propIsEnum.call(i,l)&&__defNormalProp(u,l,i[l]);return u},__spreadProps=(u,i)=>__defProps(u,__getOwnPropDescs(i)),__async=(u,i,l)=>new Promise((c,d)=>{var v=a=>{try{p(l.next(a))}catch(f){d(f)}},R=a=>{try{p(l.throw(a))}catch(f){d(f)}},p=a=>a.done?c(a.value):Promise.resolve(a.value).then(v,R);p((l=l.apply(u,i)).next())});const PointCloud2DRectOperationView=u=>{var i,l;const{mappingData:c,size:d,config:v,checkMode:R,afterImgOnLoad:p,shouldExcludePointCloudBoxListUpdate:a}=u,f=(i=c==null?void 0:c.url)!=null?i:"",m=(l=c==null?void 0:c.fallbackUrl)!=null?l:"",{pointCloudBoxList:b,setPointCloudResult:y,defaultAttribute:D,rectList:w,addRectIn2DView:N,updateRectIn2DView:x,removeRectIn2DView:B}=React.useContext(PointCloudContext.PointCloudContext),{update2DViewRect:M,remove2DViewRect:z}=usePointCloudViews.usePointCloudViews(),P=React__default.default.useRef(null),n=React.useRef(null),O=ahooks.useMemoizedFn(M),L=ahooks.useMemoizedFn(z),C=React.useRef(null),[A,E]=React.useState(!0),h=React.useMemo(()=>w==null?void 0:w.filter(e=>e.imageName===(c==null?void 0:c.path)),[c==null?void 0:c.path,w]),g=ahooks.useLatest(c==null?void 0:c.path),V=e=>{const{boxID:o}=e;if(!a&&o){const t=O==null?void 0:O(e);C.current=t,y(t);return}x(e,!0)},S=e=>{g.current&&N(__spreadProps(__spreadValues({},e),{imageName:g.current}))},j=e=>{if(!a){const o=e.find(t=>t.boxID);if(o){const t=L==null?void 0:L(o);C.current=t,y(t),_();return}}B(e)},F=ahooks.useMemoizedFn(()=>{let e=[];return b.forEach(o=>{const{rects:t=[],id:r,attribute:s,trackID:I}=o,q=t.find(k=>k.imageName===g.current),U=r+"_"+g.current;q&&(e=[...e,__spreadProps(__spreadValues({},q),{boxID:r,id:U,attribute:s,order:I})])}),e}),_=ahooks.useMemoizedFn(()=>{var e,o,t;const r=a?[]:F(),s=(e=n.current)==null?void 0:e.selectedRectID;(o=n.current)==null||o.setResult([...r,...h]),s&&((t=n.current)==null||t.setSelectedRectID(s))});return React.useEffect(()=>{if(P.current){const e=new lbAnnotation.PointCloud2DRectOperation({container:P.current,size:d,config:__spreadProps(__spreadValues({},v),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:R});return n.current=e,n.current.init(),n.current.on("updateDragResult",V),n.current.on("afterAddingDrawingRect",S),n.current.on("deleteSelectedRects",j),()=>{var o,t,r,s;(o=n.current)==null||o.unbind("updateDragResult",V),(t=n.current)==null||t.unbind("afterAddingDrawingRect",S),(r=n.current)==null||r.unbind("deleteSelectedRects",j),(s=n.current)==null||s.destroy()}}},[]),React.useEffect(()=>{const e=t=>__async(void 0,null,function*(){try{return yield lbAnnotation.ImgUtils.load(t)}catch(r){return console.error("Error loading image:",r),null}}),o=()=>__async(void 0,null,function*(){var t;E(!0);let r=yield e(f);!r&&m&&(r=yield e(m)),r&&((t=n.current)==null||t.setImgNode(r),p(r)),E(!1)});n.current&&(f||m)&&o()},[f,m]),React.useEffect(()=>{var e;(e=n.current)==null||e.setSize(d)},[d]),React.useEffect(()=>{b!==C.current&&_()},[b]),React.useEffect(()=>{var e,o,t;const r=h.find(s=>s.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,D),r&&x(__spreadProps(__spreadValues({},(t=n.current)==null?void 0:t.selectedRect),{attribute:D})),_()},[D]),React.useEffect(()=>{_()},[h]),React.useEffect(()=>{_()},[a]),React.useEffect(()=>{var e,o,t,r;const s=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},I=__spreadProps(__spreadValues({},s),{attributeList:(t=v.attributeList)!=null?t:[]});(r=n.current)==null||r.setConfig(JSON.stringify(I))},[v.attributeList]),React__default.default.createElement(es.Spin,{spinning:A},React__default.default.createElement("div",{ref:P,style:__spreadValues({position:"relative"},d)}))};var PointCloud2DRectOperationView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DRectOperationView);module.exports=PointCloud2DRectOperationView$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var dom=require("../../utils/dom.js"),React=require("react"),index=require("../AnnotationView/index.js"),useSize=require("../../hooks/useSize.js"),useSingleBox=require("./hooks/useSingleBox.js"),useHighlight=require("./hooks/useHighlight.js"),index$2=require("./components/HighlightVisible/index.js"),PointCloudContext=require("./PointCloudContext.js"),useDataLinkSwitch=require("./hooks/useDataLinkSwitch.js"),index$1=require("../pointCloud2DRectOperationView/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__async=(e,a,i)=>new Promise((l,u)=>{var f=t=>{try{o(i.next(t))}catch(n){u(n)}},r=t=>{try{o(i.throw(t))}catch(n){u(n)}},o=t=>t.done?l(t.value):Promise.resolve(t.value).then(f,r);o((i=i.apply(e,a)).next())});const PointCloud2DSingleView=({view2dData:e,setSelectedID:a,currentData:i,showEnlarge:l,checkMode:u=!1,measureVisible:f})=>{var r,o;const t=React.useRef(null),n=React.useRef(),{selectedBox:c}=useSingleBox.useSingleBox(),m=useSize(t),{url:p,
|
|
1
|
+
"use strict";var dom=require("../../utils/dom.js"),React=require("react"),index=require("../AnnotationView/index.js"),useSize=require("../../hooks/useSize.js"),useSingleBox=require("./hooks/useSingleBox.js"),useHighlight=require("./hooks/useHighlight.js"),index$2=require("./components/HighlightVisible/index.js"),PointCloudContext=require("./PointCloudContext.js"),useDataLinkSwitch=require("./hooks/useDataLinkSwitch.js"),index$1=require("../pointCloud2DRectOperationView/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__async=(e,a,i)=>new Promise((l,u)=>{var f=t=>{try{o(i.next(t))}catch(n){u(n)}},r=t=>{try{o(i.throw(t))}catch(n){u(n)}},o=t=>t.done?l(t.value):Promise.resolve(t.value).then(f,r);o((i=i.apply(e,a)).next())});const PointCloud2DSingleView=({view2dData:e,setSelectedID:a,currentData:i,showEnlarge:l,checkMode:u=!1,measureVisible:f})=>{var r,o;const t=React.useRef(null),n=React.useRef(),{selectedBox:c}=useSingleBox.useSingleBox(),m=useSize(t),{url:p,fallbackUrl:x,calib:v,path:y}=e,{toggle2dVisible:j,isHighlightVisible:q}=useHighlight.useHighlight({currentData:i}),[P,k]=React.useState(!1),{cuboidBoxIn2DView:h,cacheImageNodeSize:_}=React.useContext(PointCloudContext.PointCloudContext),B=!e,V=React.useMemo(()=>({zIndex:l?-1:101,is2DView:!h,imageName:e.path}),[l,h,e.path]),{rendered:z,isLinking:I}=useDataLinkSwitch(V),b=d=>{g(),_({path:y,imgNode:d})},g=React.useCallback(()=>{var d,C;const L=(d=n.current)==null?void 0:d.toolInstance;if(a(""),!c||!L)return;const s=e.annotations.find(E=>E.annotation.id===c.info.id);let S="";s&&((C=s==null?void 0:s.annotation.pointList)==null?void 0:C.length)>0&&(L.focusPositionByPointList(s==null?void 0:s.annotation.pointList),S=c.info.id,a(S))},[c,n.current,e.annotations]);React.useEffect(()=>{g()},[g]);const R=()=>__async(void 0,null,function*(){k(!0),yield j(p,x!=null?x:"",v),k(!1)});return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-2d-image"),ref:t},h?React__default.default.createElement(index,{src:(r=e==null?void 0:e.url)!=null?r:"",fallbackSrc:(o=e==null?void 0:e.fallbackUrl)!=null?o:"",annotations:e.annotations,size:m,ref:n,globalStyle:{display:B?"none":"block"},afterImgOnLoad:b,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f}):React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{shouldExcludePointCloudBoxListUpdate:!I,mappingData:e,size:m,checkMode:u,afterImgOnLoad:b}),z),v&&React__default.default.createElement(index$2,{visible:q(p),onClick:R,loading:P,style:{position:"absolute",right:16,top:16,zIndex:l?-1:101}}))};module.exports=PointCloud2DSingleView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),React=require("react"),index$1=require("../AnnotationView/index.js"),reactRedux=require("react-redux"),PointCloudContext=require("./PointCloudContext.js"),index=require("./components/TitleButton/index.js"),antd=require("antd"),highlightSegmentWorker=require("../../_virtual/highlightSegmentWorker.js"),lbAnnotation=require("@labelbee/lb-annotation"),_=require("lodash");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,
|
|
1
|
+
"use strict";var map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),React=require("react"),index$1=require("../AnnotationView/index.js"),reactRedux=require("react-redux"),PointCloudContext=require("./PointCloudContext.js"),index=require("./components/TitleButton/index.js"),antd=require("antd"),highlightSegmentWorker=require("../../_virtual/highlightSegmentWorker.js"),lbAnnotation=require("@labelbee/lb-annotation"),_=require("lodash");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,r,o)=>r in t?__defProp(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,__spreadValues=(t,r)=>{for(var o in r||(r={}))__hasOwnProp.call(r,o)&&__defNormalProp(t,o,r[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(r))__propIsEnum.call(r,o)&&__defNormalProp(t,o,r[o]);return t},__spreadProps=(t,r)=>__defProps(t,__getOwnPropDescs(r));const PointCloudSegment2DSingleView=({path:t,url:r,fallbackUrl:o,calib:s,pcdUrl:u,highlightAttribute:c})=>{const{ptSegmentInstance:e,cacheImageNodeSize:y,imageSizes:x}=React.useContext(PointCloudContext.PointCloudContext),w=React.useRef(null),p=React.useRef(0),g=React.useRef({}),d=React.useRef(),[v,m]=React.useState([]),[D,P]=React.useState(!1),b=React.useRef(void 0);React.useEffect(()=>()=>{p.current=0,g.current={},d.current=void 0},[u]);const h=React.useCallback(()=>{var n,l,i;if(p.current=p.current+1,p.current===2){const a=(n=e==null?void 0:e.store)==null?void 0:n.originPoints;if(!a||!d.current){console.error("cacheMappingPCD2Img Error",{path:t,points:a,filterSize:d.current});return}g.current=(i=(l=lbAnnotation.pointMappingLidar2image(a,s,d.current))==null?void 0:l.pcdMapping)!=null?i:{}}},[e]),C=React.useMemo(()=>{const n=(l,i)=>{var a,S;if(l&&d.current){b.current&&((S=(a=b.current)==null?void 0:a.terminate)==null||S.call(a));const k=g.current,f=new highlightSegmentWorker;f.current=f,P(!0),f.postMessage({cacheMap:k,indexes:l,defaultRGBA:i}),f.onmessage=O=>{m(O.data.annotations),f.terminate(),P(!1),f.current=void 0}}};return _.debounce(n,100)},[]);React.useEffect(()=>{if(!(e==null?void 0:e.store))return;const n=e.store.getHighlightAttribute(c!=null?c:""),l=e==null?void 0:e.getColorFromConfig(c!=null?c:"");C(n.flat(),l.stroke)},[c,e]),React.useEffect(()=>{if(e){const n=({newAttribute:l})=>{const i=e==null?void 0:e.getColorFromConfig(l);i&&m(v.map(a=>__spreadProps(__spreadValues({},a),{defaultRGBA:i.stroke})))};return e.on("updateDefaultAttribute",n),()=>{e.unbind("updateDefaultAttribute",n)}}},[e,v]),React.useEffect(()=>{if(e){const n=l=>{if(l.cacheSegData){const{cacheSegData:i}=l;if(i==null?void 0:i.indexes){const a=e.getColorFromConfig(i.attribute);C(i==null?void 0:i.indexes,a.stroke)}}else m([])};return e.on("syncPointCloudStatus",n),e.on("loadPCDFileEnd",h),()=>{e.unbind("syncPointCloudStatus",n),e.unbind("loadPCDFileEnd",h)}}},[e,u,x]);const E=n=>{y({path:t,imgNode:n}),d.current={width:n.width,height:n.height},h()};return React__default.default.createElement("div",{key:t,style:{position:"relative"},ref:w},React__default.default.createElement(index,{title:s.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF",position:"absolute",top:10,left:10,zIndex:1}}),React__default.default.createElement(antd.Spin,{spinning:D,delay:1e3},React__default.default.createElement(index$1,{size:{width:300,height:200},key:t,src:r,fallbackSrc:o,annotations:v,afterImgOnLoad:E})))},PointCloudSegment2DView=({currentData:t,highlightAttribute:r})=>{var o;const s=(o=t.mappingImgList)!=null?o:[];return(s==null?void 0:s.length)>0?React__default.default.createElement("div",{style:{position:"absolute",height:"100%",overflowY:"scroll",zIndex:100,width:300}},s==null?void 0:s.map((u,c)=>{var e;return u.calib&&React__default.default.createElement(PointCloudSegment2DSingleView,{key:u.path+c,path:u.path,url:u.url,fallbackUrl:(e=u.fallbackUrl)!=null?e:"",calib:u.calib,pcdUrl:t.url,highlightAttribute:r})})):null};var PointCloudSegment2DView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudSegment2DView);module.exports=PointCloudSegment2DView$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),__async=(s,r,t)=>new Promise((u,a)=>{var e=i=>{try{n(t.next(i))}catch(l){a(l)}},d=i=>{try{n(t.throw(i))}catch(l){a(l)}},n=i=>i.done?u(i.value):Promise.resolve(i.value).then(e,d);n((t=t.apply(s,r)).next())});const useHighlight=({currentData:s})=>{var r;const{mainViewInstance:t,topViewInstance:u,pointCloudBoxList:a,highlight2DDataList:e,setHighlight2DDataList:d}=React.useContext(PointCloudContext.PointCloudContext),n=(r=s==null?void 0:s.mappingImgList)!=null?r:[],i=(o,h)=>__async(void 0,null,function*(){var p;let g=[...e];if(e.find(c=>c.url===o)?g=e.filter(c=>c.url!==o):g.push({url:o,calib:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),__async=(s,r,t)=>new Promise((u,a)=>{var e=i=>{try{n(t.next(i))}catch(l){a(l)}},d=i=>{try{n(t.throw(i))}catch(l){a(l)}},n=i=>i.done?u(i.value):Promise.resolve(i.value).then(e,d);n((t=t.apply(s,r)).next())});const useHighlight=({currentData:s})=>{var r;const{mainViewInstance:t,topViewInstance:u,pointCloudBoxList:a,highlight2DDataList:e,setHighlight2DDataList:d}=React.useContext(PointCloudContext.PointCloudContext),n=(r=s==null?void 0:s.mappingImgList)!=null?r:[],i=(o,h,f)=>__async(void 0,null,function*(){var p;let g=[...e];if(e.find(c=>c.url===o)?g=e.filter(c=>c.url!==o):g.push({url:o,fallbackUrl:h,calib:f}),d(g),!t||(n==null?void 0:n.length)===0)return;const v=t.pointCloudObject;if(!v)return;const m=yield t.getHighlightIndexByMappingImgList({mappingImgList:g,points:v.geometry.attributes.position.array}),C=yield t.highlightOriginPointCloud(a,m);C&&((p=u==null?void 0:u.pointCloudInstance)==null||p.updateColor(C))}),l=React.useCallback(o=>e.findIndex(h=>h.url===o)>=0,[e]);return{toggle2dVisible:i,isHighlightVisible:l}};exports.useHighlight=useHighlight;
|
|
@@ -23,6 +23,7 @@ type UnlinkImageItem = string;
|
|
|
23
23
|
type AttrPanelLayout = '' | 'left' | 'right';
|
|
24
24
|
interface IHighlight2DData {
|
|
25
25
|
url: string;
|
|
26
|
+
fallbackUrl: string;
|
|
26
27
|
calib?: ICalib;
|
|
27
28
|
}
|
|
28
29
|
export interface IPointCloudContext extends IPointCloudContextInstances, IPointCloudStatus, IPointCloudSegment {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { IAnnotationStateProps } from '../../../store/annotation/map';
|
|
7
7
|
import { ICalib } from '@labelbee/lb-utils';
|
|
8
8
|
declare const useHighlight: ({ currentData }: Partial<IAnnotationStateProps>) => {
|
|
9
|
-
toggle2dVisible: (url: string, calib?: ICalib) => Promise<void>;
|
|
9
|
+
toggle2dVisible: (url: string, fallbackUrl: string, calib?: ICalib) => Promise<void>;
|
|
10
10
|
isHighlightVisible: (url: string) => boolean;
|
|
11
11
|
};
|
|
12
12
|
export { useHighlight };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemoizedFn as
|
|
1
|
+
import{useMemoizedFn as w,useLatest as Y}from"ahooks";import{Spin as Z}from"antd/es";import V,{useContext as ee,useRef as z,useState as te,useMemo as re,useEffect as d}from"react";import{connect as ne}from"react-redux";import{usePointCloudViews as oe}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as ie}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as le}from"../../store/annotation/map.js";import{LabelBeeContext as ce}from"../../store/ctx.js";import{PointCloud2DRectOperation as ue,ImgUtils as ae}from"@labelbee/lb-annotation";var se=Object.defineProperty,de=Object.defineProperties,fe=Object.getOwnPropertyDescriptors,F=Object.getOwnPropertySymbols,pe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,J=(c,i,l)=>i in c?se(c,i,{enumerable:!0,configurable:!0,writable:!0,value:l}):c[i]=l,m=(c,i)=>{for(var l in i||(i={}))pe.call(i,l)&&J(c,l,i[l]);if(F)for(var l of F(i))me.call(i,l)&&J(c,l,i[l]);return c},R=(c,i)=>de(c,fe(i)),T=(c,i,l)=>new Promise((u,f)=>{var v=a=>{try{_(l.next(a))}catch(p){f(p)}},P=a=>{try{_(l.throw(a))}catch(p){f(p)}},_=a=>a.done?u(a.value):Promise.resolve(a.value).then(v,P);_((l=l.apply(c,i)).next())});const ve=c=>{var i,l;const{mappingData:u,size:f,config:v,checkMode:P,afterImgOnLoad:_,shouldExcludePointCloudBoxListUpdate:a}=c,p=(i=u==null?void 0:u.url)!=null?i:"",b=(l=u==null?void 0:u.fallbackUrl)!=null?l:"",{pointCloudBoxList:I,setPointCloudResult:S,defaultAttribute:h,rectList:C,addRectIn2DView:$,updateRectIn2DView:N,removeRectIn2DView:q}=ee(ie),{update2DViewRect:G,remove2DViewRect:H}=oe(),y=V.useRef(null),n=z(null),j=w(G),B=w(H),O=z(null),[K,E]=te(!0),x=re(()=>C==null?void 0:C.filter(e=>e.imageName===(u==null?void 0:u.path)),[u==null?void 0:u.path,C]),D=Y(u==null?void 0:u.path),U=e=>{const{boxID:o}=e;if(!a&&o){const t=j==null?void 0:j(e);O.current=t,S(t);return}N(e,!0)},A=e=>{D.current&&$(R(m({},e),{imageName:D.current}))},k=e=>{if(!a){const o=e.find(t=>t.boxID);if(o){const t=B==null?void 0:B(o);O.current=t,S(t),g();return}}q(e)},Q=w(()=>{let e=[];return I.forEach(o=>{const{rects:t=[],id:r,attribute:s,trackID:L}=o,M=t.find(X=>X.imageName===D.current),W=r+"_"+D.current;M&&(e=[...e,R(m({},M),{boxID:r,id:W,attribute:s,order:L})])}),e}),g=w(()=>{var e,o,t;const r=a?[]:Q(),s=(e=n.current)==null?void 0:e.selectedRectID;(o=n.current)==null||o.setResult([...r,...x]),s&&((t=n.current)==null||t.setSelectedRectID(s))});return d(()=>{if(y.current){const e=new ue({container:y.current,size:f,config:R(m({},v),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:P});return n.current=e,n.current.init(),n.current.on("updateDragResult",U),n.current.on("afterAddingDrawingRect",A),n.current.on("deleteSelectedRects",k),()=>{var o,t,r,s;(o=n.current)==null||o.unbind("updateDragResult",U),(t=n.current)==null||t.unbind("afterAddingDrawingRect",A),(r=n.current)==null||r.unbind("deleteSelectedRects",k),(s=n.current)==null||s.destroy()}}},[]),d(()=>{const e=t=>T(void 0,null,function*(){try{return yield ae.load(t)}catch(r){return console.error("Error loading image:",r),null}}),o=()=>T(void 0,null,function*(){var t;E(!0);let r=yield e(p);!r&&b&&(r=yield e(b)),r&&((t=n.current)==null||t.setImgNode(r),_(r)),E(!1)});n.current&&(p||b)&&o()},[p,b]),d(()=>{var e;(e=n.current)==null||e.setSize(f)},[f]),d(()=>{I!==O.current&&g()},[I]),d(()=>{var e,o,t;const r=x.find(s=>s.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,h),r&&N(R(m({},(t=n.current)==null?void 0:t.selectedRect),{attribute:h})),g()},[h]),d(()=>{g()},[x]),d(()=>{g()},[a]),d(()=>{var e,o,t,r;const s=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},L=R(m({},s),{attributeList:(t=v.attributeList)!=null?t:[]});(r=n.current)==null||r.setConfig(JSON.stringify(L))},[v.attributeList]),V.createElement(Z,{spinning:K},V.createElement("div",{ref:y,style:m({position:"relative"},f)}))};var _e=ne(le,null,null,{context:ce})(ve);export{_e as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as
|
|
1
|
+
import{getClassName as U}from"../../utils/dom.js";import l,{useRef as j,useState as A,useContext as F,useMemo as M,useCallback as T,useEffect as q}from"react";import w from"../AnnotationView/index.js";import G from"../../hooks/useSize.js";import{useSingleBox as J}from"./hooks/useSingleBox.js";import{useHighlight as K}from"./hooks/useHighlight.js";import Q from"./components/HighlightVisible/index.js";import{PointCloudContext as W}from"./PointCloudContext.js";import X from"./hooks/useDataLinkSwitch.js";import Y from"../pointCloud2DRectOperationView/index.js";var Z=(o,r,e)=>new Promise((s,c)=>{var f=t=>{try{i(e.next(t))}catch(n){c(n)}},u=t=>{try{i(e.throw(t))}catch(n){c(n)}},i=t=>t.done?s(t.value):Promise.resolve(t.value).then(f,u);i((e=e.apply(o,r)).next())});const $=({view2dData:o,setSelectedID:r,currentData:e,showEnlarge:s,checkMode:c=!1,measureVisible:f})=>{var u,i;const t=j(null),n=j(),{selectedBox:d}=J(),g=G(t),{url:k,fallbackUrl:x,calib:b,path:y}=o,{toggle2dVisible:_,isHighlightVisible:v}=K({currentData:e}),[z,C]=A(!1),{cuboidBoxIn2DView:p,cacheImageNodeSize:B}=F(W),I=!o,O=M(()=>({zIndex:s?-1:101,is2DView:!p,imageName:o.path}),[s,p,o.path]),{rendered:R,isLinking:E}=X(O),L=m=>{h(),B({path:y,imgNode:m})},h=T(()=>{var m,S;const V=(m=n.current)==null?void 0:m.toolInstance;if(r(""),!d||!V)return;const a=o.annotations.find(N=>N.annotation.id===d.info.id);let P="";a&&((S=a==null?void 0:a.annotation.pointList)==null?void 0:S.length)>0&&(V.focusPositionByPointList(a==null?void 0:a.annotation.pointList),P=d.info.id,r(P))},[d,n.current,o.annotations]);q(()=>{h()},[h]);const H=()=>Z(void 0,null,function*(){C(!0),yield _(k,x!=null?x:"",b),C(!1)});return l.createElement("div",{className:U("point-cloud-2d-image"),ref:t},p?l.createElement(w,{src:(u=o==null?void 0:o.url)!=null?u:"",fallbackSrc:(i=o==null?void 0:o.fallbackUrl)!=null?i:"",annotations:o.annotations,size:g,ref:n,globalStyle:{display:I?"none":"block"},afterImgOnLoad:L,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f}):l.createElement(l.Fragment,null,l.createElement(Y,{shouldExcludePointCloudBoxListUpdate:!E,mappingData:o,size:g,checkMode:c,afterImgOnLoad:L}),R),b&&l.createElement(Q,{visible:v(k),onClick:H,loading:z,style:{position:"absolute",right:16,top:16,zIndex:s?-1:101}}))};export{$ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a2MapStateToProps as
|
|
1
|
+
import{a2MapStateToProps as z}from"../../store/annotation/map.js";import{LabelBeeContext as R}from"../../store/ctx.js";import f,{useContext as V,useRef as m,useState as x,useEffect as v,useCallback as B,useMemo as A}from"react";import W from"../AnnotationView/index.js";import{connect as T}from"react-redux";import{PointCloudContext as U}from"./PointCloudContext.js";import G from"./components/TitleButton/index.js";import{Spin as H}from"antd";import N from"../../_virtual/highlightSegmentWorker.js";import{pointMappingLidar2image as Y}from"@labelbee/lb-annotation";import{debounce as $}from"lodash";var q=Object.defineProperty,J=Object.defineProperties,K=Object.getOwnPropertyDescriptors,D=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,k=(t,o,n)=>o in t?q(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,Z=(t,o)=>{for(var n in o||(o={}))Q.call(o,n)&&k(t,n,o[n]);if(D)for(var n of D(o))X.call(o,n)&&k(t,n,o[n]);return t},ee=(t,o)=>J(t,K(o));const te=({path:t,url:o,fallbackUrl:n,calib:c,pcdUrl:s,highlightAttribute:u})=>{const{ptSegmentInstance:e,cacheImageNodeSize:O,imageSizes:E}=V(U),F=m(null),g=m(0),h=m({}),p=m(),[P,_]=x([]),[I,C]=x(!1),S=m(void 0);v(()=>()=>{g.current=0,h.current={},p.current=void 0},[s]);const b=B(()=>{var r,l,i;if(g.current=g.current+1,g.current===2){const a=(r=e==null?void 0:e.store)==null?void 0:r.originPoints;if(!a||!p.current){console.error("cacheMappingPCD2Img Error",{path:t,points:a,filterSize:p.current});return}h.current=(i=(l=Y(a,c,p.current))==null?void 0:l.pcdMapping)!=null?i:{}}},[e]),y=A(()=>$((l,i)=>{var a,w;if(l&&p.current){S.current&&((w=(a=S.current)==null?void 0:a.terminate)==null||w.call(a));const M=h.current,d=new N;d.current=d,C(!0),d.postMessage({cacheMap:M,indexes:l,defaultRGBA:i}),d.onmessage=L=>{_(L.data.annotations),d.terminate(),C(!1),d.current=void 0}}},100),[]);v(()=>{if(!(e==null?void 0:e.store))return;const r=e.store.getHighlightAttribute(u!=null?u:""),l=e==null?void 0:e.getColorFromConfig(u!=null?u:"");y(r.flat(),l.stroke)},[u,e]),v(()=>{if(e){const r=({newAttribute:l})=>{const i=e==null?void 0:e.getColorFromConfig(l);i&&_(P.map(a=>ee(Z({},a),{defaultRGBA:i.stroke})))};return e.on("updateDefaultAttribute",r),()=>{e.unbind("updateDefaultAttribute",r)}}},[e,P]),v(()=>{if(e){const r=l=>{if(l.cacheSegData){const{cacheSegData:i}=l;if(i==null?void 0:i.indexes){const a=e.getColorFromConfig(i.attribute);y(i==null?void 0:i.indexes,a.stroke)}}else _([])};return e.on("syncPointCloudStatus",r),e.on("loadPCDFileEnd",b),()=>{e.unbind("syncPointCloudStatus",r),e.unbind("loadPCDFileEnd",b)}}},[e,s,E]);const j=r=>{O({path:t,imgNode:r}),p.current={width:r.width,height:r.height},b()};return f.createElement("div",{key:t,style:{position:"relative"},ref:F},f.createElement(G,{title:c.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF",position:"absolute",top:10,left:10,zIndex:1}}),f.createElement(H,{spinning:I,delay:1e3},f.createElement(W,{size:{width:300,height:200},key:t,src:o,fallbackSrc:n,annotations:P,afterImgOnLoad:j})))},oe=({currentData:t,highlightAttribute:o})=>{var n;const c=(n=t.mappingImgList)!=null?n:[];return(c==null?void 0:c.length)>0?f.createElement("div",{style:{position:"absolute",height:"100%",overflowY:"scroll",zIndex:100,width:300}},c==null?void 0:c.map((s,u)=>{var e;return s.calib&&f.createElement(te,{key:s.path+u,path:s.path,url:s.url,fallbackUrl:(e=s.fallbackUrl)!=null?e:"",calib:s.calib,pcdUrl:t.url,highlightAttribute:o})})):null};var ne=T(z,null,null,{context:R})(oe);export{ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as I,useCallback as y}from"react";import{PointCloudContext as x}from"../PointCloudContext.js";var L=(s,r,t)=>new Promise((a,u)=>{var n=i=>{try{e(t.next(i))}catch(l){u(l)}},h=i=>{try{e(t.throw(i))}catch(l){u(l)}},e=i=>i.done?a(i.value):Promise.resolve(i.value).then(n,h);e((t=t.apply(s,r)).next())});const b=({currentData:s})=>{var r;const{mainViewInstance:t,topViewInstance:a,pointCloudBoxList:u,highlight2DDataList:n,setHighlight2DDataList:h}=I(x),e=(r=s==null?void 0:s.mappingImgList)!=null?r:[],i=(o,d,f)=>L(void 0,null,function*(){var c;let g=[...n];if(n.find(p=>p.url===o)?g=n.filter(p=>p.url!==o):g.push({url:o,fallbackUrl:d,calib:f}),h(g),!t||(e==null?void 0:e.length)===0)return;const m=t.pointCloudObject;if(!m)return;const C=yield t.getHighlightIndexByMappingImgList({mappingImgList:g,points:m.geometry.attributes.position.array}),v=yield t.highlightOriginPointCloud(u,C);v&&((c=a==null?void 0:a.pointCloudInstance)==null||c.updateColor(v))}),l=y(o=>n.findIndex(d=>d.url===o)>=0,[n]);return{toggle2dVisible:i,isHighlightVisible:l}};export{b as useHighlight};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labelbee/lb-components",
|
|
3
|
-
"version": "1.23.0-alpha.
|
|
3
|
+
"version": "1.23.0-alpha.46",
|
|
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.27.0-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.27.0-alpha.23",
|
|
47
47
|
"@labelbee/lb-utils": "1.19.0-alpha.16",
|
|
48
48
|
"@labelbee/wavesurfer": "1.0.0",
|
|
49
49
|
"@types/react-dom": "^18.2.7",
|