@labelbee/lb-components 1.23.0-alpha.135 → 1.23.0-alpha.137
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/AnnotationView/index.js +1 -1
- package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
- package/dist/components/pointCloudView/PointCloud2DSingleView.js +1 -1
- package/dist/types/components/AnnotationView/index.d.ts +2 -0
- package/es/components/AnnotationView/index.js +1 -1
- package/es/components/pointCloud2DRectOperationView/index.js +1 -1
- package/es/components/pointCloudView/PointCloud2DSingleView.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),es=require("antd/es"),useRefCache=require("../../hooks/useRefCache.js"),index=require("../measureCanvas/index.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,o)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o,__spreadValues=(e,r)=>{for(var o in r||(r={}))__hasOwnProp.call(r,o)&&__defNormalProp(e,o,r[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(r))__propIsEnum.call(r,o)&&__defNormalProp(e,o,r[o]);return e},__async=(e,r,o)=>new Promise((g,d)=>{var c=
|
|
1
|
+
"use strict";var React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),es=require("antd/es"),useRefCache=require("../../hooks/useRefCache.js"),index=require("../measureCanvas/index.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,r,o)=>r in e?__defProp(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o,__spreadValues=(e,r)=>{for(var o in r||(r={}))__hasOwnProp.call(r,o)&&__defNormalProp(e,o,r[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(r))__propIsEnum.call(r,o)&&__defNormalProp(e,o,r[o]);return e},__async=(e,r,o)=>new Promise((g,d)=>{var c=u=>{try{f(o.next(u))}catch(v){d(v)}},s=u=>{try{f(o.throw(u))}catch(v){d(v)}},f=u=>u.done?g(u.value):Promise.resolve(u.value).then(c,s);f((o=o.apply(e,r)).next())});const DEFAULT_SIZE={width:455,height:100},sizeInitialized=e=>{if(!e)return DEFAULT_SIZE;if(e.width&&e.height)return e;const r=__spreadValues({},e);return r.width||(r.width=DEFAULT_SIZE.width),r.height||(r.height=DEFAULT_SIZE.height),r},AnnotationView=(e,r)=>{var o,g;const{src:d,fallbackSrc:c,annotations:s=[],style:f={stroke:"blue",thickness:3},zoomChange:u,backgroundStyle:v={},onChange:C,showLoading:x=!1,globalStyle:L,afterImgOnLoad:k,measureVisible:y,onRightClick:m,pointCloudBoxList:E=[],hiddenText:P=!1,renderToolName:A}=e,_=sizeInitialized(e.size),[j,R]=React.useState(!1),w=React.useRef(null),t=React.useRef(),z=useRefCache(k),h=React.useRef([]),b=React.useRef(!0);React.useContext(PointCloudContext.PointCloudContext),React.useImperativeHandle(r,()=>{const n=t.current;return n?{zoomIn:()=>n.zoomChanged(!0),zoomOut:()=>n.zoomChanged(!1),initImgPos:()=>n.initImgPos(),toolInstance:n}:{}},[t.current]),React.useEffect(()=>(w.current&&(t.current=new lbAnnotation.ViewOperation({container:w.current,size:_,style:f,annotations:s,config:"{}",zoomInfo:e.zoomInfo,staticMode:e.staticMode,renderToolName:A}),t.current.init(),m&&t.current.on("onRightClick",m)),()=>{var n,i;m&&((n=t.current)==null||n.unbind("onRightClick",m)),(i=t.current)==null||i.destroy()}),[y]);const I=React.useCallback(n=>__async(void 0,null,function*(){var i,a;try{const l=yield lbAnnotation.ImgUtils.load(n);return(i=t.current)==null||i.setImgNode(l),(a=z.current)==null||a.call(z,l),null}catch(l){return console.error("Error loading image:",l),l}}),[]),O=React.useCallback(n=>__async(void 0,null,function*(){var i,a;if(R(!0),(i=t.current)==null||i.setLoading(!0),(yield I(n))&&c){const p=yield I(c);p&&console.error("Error loading fallback image:",p)}(a=t.current)==null||a.setLoading(!1),R(!1)}),[I,c]);React.useEffect(()=>{t.current&&O(d)},[d,y,c,O]),React.useEffect(()=>{(t==null?void 0:t.current)&&t.current.setPointCloudBoxList(E)},[E]),React.useEffect(()=>{var n;(t==null?void 0:t.current)&&((n=t.current)==null||n.setHiddenText(P))},[P]),React.useEffect(()=>{if(b.current===!1){h.current.push(s);return}const n=()=>{b.current=!0,h.current=[]},i=()=>{var a;const l=h.current.length;if(l>0){const p=h.current[l-1];h.current=[],(a=t.current)==null||a.updateData(p).then(i).catch(n)}else b.current=!0};t.current&&(b.current=!1,t.current.updateData(s).then(i).catch(n))},[s]),React.useEffect(()=>{const n=t.current;(n==null?void 0:n.setSize)&&(n.setSize(_),n.initPosition())},[(o=e.size)==null?void 0:o.width,(g=e.size)==null?void 0:g.height]),React.useEffect(()=>{var n,i;return t.current&&((n=t.current)==null||n.on("onChange",(...a)=>{C==null||C.apply(null,a)}),(i=t.current)==null||i.on("renderZoom",a=>{u&&u(a)})),()=>{var a,l;(a=t.current)==null||a.unbindAll("onChange"),(l=t.current)==null||l.unbindAll("renderZoom")}},[u,C]);const q=React__default.default.createElement("div",{ref:w,style:__spreadValues(__spreadValues({position:"relative"},_),v)}),{imgNode:S,zoom:V,currentPos:D}=t.current||{};return React__default.default.createElement(es.Spin,{spinning:x||j,delay:300,style:L},y&&S?React__default.default.createElement(index,{size:_,imgNode:S,zoom:V,currentPos:D}):q)};var AnnotationView$1=React__default.default.forwardRef(AnnotationView);module.exports=AnnotationView$1;
|
|
@@ -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"),util=require("./util.js"),useUpdateRectList=require("./useUpdateRectList.js"),_=require("lodash"),useToolStyle=require("../../hooks/useToolStyle.js"),index=require("../../store/toolConfig/index.js");function _interopDefaultLegacy(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}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=(i,l,s)=>l in i?__defProp(i,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[l]=s,__spreadValues=(i,l)=>{for(var s in l||(l={}))__hasOwnProp.call(l,s)&&__defNormalProp(i,s,l[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(l))__propIsEnum.call(l,s)&&__defNormalProp(i,s,l[s]);return i},__spreadProps=(i,l)=>__defProps(i,__getOwnPropDescs(l)),__async=(i,l,s)=>new Promise((d,p)=>{var I=f=>{try{D(s.next(f))}catch(R){p(R)}},
|
|
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"),util=require("./util.js"),useUpdateRectList=require("./useUpdateRectList.js"),_=require("lodash"),useToolStyle=require("../../hooks/useToolStyle.js"),index=require("../../store/toolConfig/index.js");function _interopDefaultLegacy(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}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=(i,l,s)=>l in i?__defProp(i,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[l]=s,__spreadValues=(i,l)=>{for(var s in l||(l={}))__hasOwnProp.call(l,s)&&__defNormalProp(i,s,l[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(l))__propIsEnum.call(l,s)&&__defNormalProp(i,s,l[s]);return i},__spreadProps=(i,l)=>__defProps(i,__getOwnPropDescs(l)),__async=(i,l,s)=>new Promise((d,p)=>{var I=f=>{try{D(s.next(f))}catch(R){p(R)}},P=f=>{try{D(s.throw(f))}catch(R){p(R)}},D=f=>f.done?d(f.value):Promise.resolve(f.value).then(I,P);D((s=s.apply(i,l)).next())});const PointCloud2DRectOperationView=i=>{var l,s;const{mappingData:d,size:p,config:I,checkMode:P,afterImgOnLoad:D,shouldExcludePointCloudBoxListUpdate:f}=i,{selectBoxVisibleSwitch:R}=index(),S=(l=d==null?void 0:d.url)!=null?l:"",b=(s=d==null?void 0:d.fallbackUrl)!=null?s:"",{pointCloudBoxList:L,setPointCloudResult:E,defaultAttribute:O,rectList:V,addRectIn2DView:X,updateRectIn2DView:Y,removeRectIn2DView:Z,updateRectListByReducer:ee,selectedIDs:v,setSelectedIDs:q,selectedID:C}=React.useContext(PointCloudContext.PointCloudContext),{value:j}=useToolStyle.useToolStyleContext(),te=ahooks.useLatest(v),{update2DViewRect:re,remove2DViewRect:ne}=usePointCloudViews.usePointCloudViews(),k=React__default.default.useRef(null),n=React.useRef(null),A=ahooks.useMemoizedFn(re),x=ahooks.useMemoizedFn(ne),y=React.useRef(null),[oe,F]=React.useState(!0),[T,H]=React.useState(""),[ue,U]=React.useState(!1),[ie,B]=React.useState(!0),g=React.useMemo(()=>V==null?void 0:V.filter(e=>e.imageName===(d==null?void 0:d.path)),[d==null?void 0:d.path,V]),J=React.useRef(g),w=ahooks.useLatest(d==null?void 0:d.path),N=React.useCallback(e=>__async(void 0,null,function*(){try{const o=te.current.slice(0),r=yield Promise.resolve(e());if(!r||r.length===0)return r;if(o.length){const t=new Set(o),u=r.filter(c=>t.has(c.id)).map(c=>c.id);q(u)}return r}catch(o){}}),[q]),$=e=>{const{boxID:o}=e;if(!f&&o){N(()=>{const r=A==null?void 0:A(e);return r?(y.current=r,E(r),r):null});return}Y(e,!0)},G=e=>{w.current&&X(__spreadProps(__spreadValues({},e),{imageName:w.current}))},K=e=>{if(e.length===0)return;if(!f){const r=e.find(t=>t.boxID);if(r){N(()=>{const t=x==null?void 0:x(r);return t?(y.current=t,E(t),h(),t):null});return}}const o=e.find(r=>r.extId);o&&N(()=>{const{imageName:r,extId:t}=o,u=x==null?void 0:x({boxID:t,imageName:r});return u?(y.current=u,E(u),u):null}),Z(e)},ce=ahooks.useMemoizedFn(()=>{let e=[];return L.forEach(o=>{const{rects:r=[],id:t,attribute:u,trackID:c}=o,a=r.find(M=>M.imageName===w.current),m=t+"_"+w.current;a&&(e=[...e,__spreadProps(__spreadValues({},a),{boxID:t,id:m,attribute:u,order:c})])}),e}),h=useUpdateRectList.useUpdateRectList(()=>{var e,o,r,t,u;const c=f?[]:ce(),a=(e=n.current)==null?void 0:e.selectedRectID,m=v.slice(0),M=R?util.selectSpecifiedRectsFromTopViewSelectedIds(m,c,g):[...c,...g];let W=[];!R&&(v==null?void 0:v.length)&&(W=c.filter(z=>a?v.includes(z.boxID)&&!a.includes(z.boxID):v.includes(z.boxID))),(o=n.current)==null||o.setHighLightRectList(W),(r=n.current)==null||r.setResult(M),T?((t=n.current)==null||t.setSelectedRectID(T),H("")):ue&&a&&((u=n.current)==null||u.setSelectedRectID(a),U(!1))}),Q=({targetId:e,id:o})=>{B(!1),q(e),H(o)};return React.useEffect(()=>{if(k.current){const e=new lbAnnotation.PointCloud2DRectOperation({container:k.current,size:p,config:__spreadProps(__spreadValues({},I),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:P});return n.current=e,n.current.init(),n.current.on("updateDragResult",$),n.current.on("afterAddingDrawingRect",G),n.current.on("deleteSelectedRects",K),n.current.on("onRightClick",Q),()=>{var o,r,t,u,c;(o=n.current)==null||o.unbind("updateDragResult",$),(r=n.current)==null||r.unbind("afterAddingDrawingRect",G),(t=n.current)==null||t.unbind("deleteSelectedRects",K),(u=n.current)==null||u.unbind("onRightClick",Q),(c=n.current)==null||c.destroy()}}},[]),React.useEffect(()=>{const e=r=>__async(void 0,null,function*(){try{return yield lbAnnotation.ImgUtils.load(r)}catch(t){return console.error("Error loading image:",t),null}}),o=()=>__async(void 0,null,function*(){var r;F(!0);let t=yield e(S);!t&&b&&(t=yield e(b)),t&&((r=n.current)==null||r.setImgNode(t),D(t)),F(!1)});n.current&&(S||b)&&o()},[S,b]),React.useEffect(()=>{var e;(e=n.current)==null||e.setSize(p)},[p]),React.useEffect(()=>{L!==y.current&&h()},[L]),React.useEffect(()=>{var e,o;const r=g.find(t=>t.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,O),r&&ee(t=>{var u;const c=[];let a=null;return t.forEach(m=>{m.id!==n.current.selectedRectID?c.push(m):a=m}),r.extId===void 0&&(a=(u=n.current)==null?void 0:u.selectedRect),[...c,__spreadProps(__spreadValues({},a||{}),{attribute:O})]}),U(!0),h()},[O]),React.useEffect(()=>{const e=J.current;___default.default.isEqual(e,g)||(U(!0),h(),J.current=g)},[g]),React.useEffect(()=>{h()},[f]),React.useEffect(()=>{var e,o,r,t;const u=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},c=__spreadProps(__spreadValues({},u),{attributeList:(r=I.attributeList)!=null?r:[]});(t=n.current)==null||t.setConfig(JSON.stringify(c))},[I.attributeList]),React.useEffect(()=>{var e;(e=n.current)==null||e.setEnableAddRect(v.length===0),h()},[v]),React.useEffect(()=>{if(!C||!ie){B(!0);return}const{rectList:e,size:o,zoom:r}=n.current,t=e.find(a=>a.boxID===C||a.extId===C);if(!t){B(!0);return}const u={x:t.x+t.width/2,y:t.y+t.height/2},c=lbAnnotation.MathUtils.getCurrentPosFromRectCenter(o,u,r);n.current.setHoverRectID(t.id),n.current.setCurrentPos(c),n.current.renderBasicCanvas(),n.current.render()},[C]),React.useEffect(()=>{const{hiddenText:e}=j||{};if(e===void 0)return;const o=n.current;if(!o)return;const r=__spreadValues(__spreadValues({},o.style),j);o.setStyle(r)},[j]),React.useEffect(()=>{h()},[R]),React__default.default.createElement(es.Spin,{spinning:oe},React__default.default.createElement("div",{ref:k,style:__spreadValues({position:"relative"},p)}))};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"),useToolStyle=require("../../hooks/useToolStyle.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__async=(e,u,i)=>new Promise((s,a)=>{var h=t=>{try{l(i.next(t))}catch(o){a(o)}},c=t=>{try{l(i.throw(t))}catch(o){a(o)}},l=t=>t.done?s(t.value):Promise.resolve(t.value).then(h,c);l((i=i.apply(e,u)).next())});const PointCloud2DSingleView=({view2dData:e,setSelectedID:u,currentData:i,showEnlarge:s,checkMode:a=!1,measureVisible:h})=>{var c,l;const t=React.useRef(null),o=React.useRef(),{selectedBox:d}=useSingleBox.useSingleBox(),
|
|
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"),lbAnnotation=require("@labelbee/lb-annotation"),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"),useToolStyle=require("../../hooks/useToolStyle.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__async=(e,u,i)=>new Promise((s,a)=>{var h=t=>{try{l(i.next(t))}catch(o){a(o)}},c=t=>{try{l(i.throw(t))}catch(o){a(o)}},l=t=>t.done?s(t.value):Promise.resolve(t.value).then(h,c);l((i=i.apply(e,u)).next())});const PointCloud2DSingleView=({view2dData:e,setSelectedID:u,currentData:i,showEnlarge:s,checkMode:a=!1,measureVisible:h})=>{var c,l;const t=React.useRef(null),o=React.useRef(),{selectedBox:d}=useSingleBox.useSingleBox(),m=useSize(t),{url:x,fallbackUrl:p,calib:b,path:q}=e,{toggle2dVisible:P,isHighlightVisible:j}=useHighlight.useHighlight({currentData:i}),[B,v]=React.useState(!1),{highlight2DLoading:_,setHighlight2DLoading:C,cuboidBoxIn2DView:f,cacheImageNodeSize:I,setSelectedIDs:R,pointCloudBoxList:V}=React.useContext(PointCloudContext.PointCloudContext),{value:z}=useToolStyle.useToolStyleContext(),{hiddenText:N}=z||{},E=!e,H=React.useMemo(()=>({zIndex:s?-1:101,is2DView:!f,imageName:e.path}),[s,f,e.path]),{rendered:O,isLinking:T}=useDataLinkSwitch(H),k=n=>{g(),I({path:q,imgNode:n})},g=React.useCallback(()=>{var n,S;const y=(n=o.current)==null?void 0:n.toolInstance;if(u(""),!d||!y)return;const r=e.annotations.find(A=>A.annotation.id===d.info.id);let L="";r&&((S=r==null?void 0:r.annotation.pointList)==null?void 0:S.length)>0&&(y.focusPositionByPointList(r==null?void 0:r.annotation.pointList),L=d.info.id,u(L))},[d,o.current,e.annotations]);React.useEffect(()=>{g()},[g]);const U=()=>__async(void 0,null,function*(){v(!0),C(!0);try{yield P(x,p!=null?p:"",b)}catch(n){console.error("highlightOnClick error:",n)}finally{v(!1),C(!1)}});return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-2d-image"),ref:t},f?React__default.default.createElement(index,{src:(c=e==null?void 0:e.url)!=null?c:"",fallbackSrc:(l=e==null?void 0:e.fallbackUrl)!=null?l:"",annotations:e.annotations,size:m,ref:o,globalStyle:{display:E?"none":"block"},afterImgOnLoad:k,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:h,onRightClick:({targetId:n})=>R(n),pointCloudBoxList:V,hiddenText:N,renderToolName:lbAnnotation.EPointCloudName.PointCloud}):React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{shouldExcludePointCloudBoxListUpdate:!T,mappingData:e,size:m,checkMode:a,afterImgOnLoad:k}),!a&&O),b&&React__default.default.createElement(index$2,{visible:j(x),onClick:U,loading:B,disabled:_,style:{position:"absolute",right:16,top:16,zIndex:s?-1:101}}))};module.exports=PointCloud2DSingleView;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @author laoluo
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import { EPointCloudName } from '@labelbee/lb-annotation';
|
|
6
7
|
import { IPointCloudBoxList } from '@labelbee/lb-utils';
|
|
7
8
|
export type TAfterImgOnLoad = (img: HTMLImageElement) => void;
|
|
8
9
|
interface IProps {
|
|
@@ -37,6 +38,7 @@ interface IProps {
|
|
|
37
38
|
}) => void;
|
|
38
39
|
pointCloudBoxList?: IPointCloudBoxList;
|
|
39
40
|
hiddenText?: boolean;
|
|
41
|
+
renderToolName?: EPointCloudName.PointCloud | undefined;
|
|
40
42
|
}
|
|
41
43
|
declare const _default: React.ForwardRefExoticComponent<IProps & React.RefAttributes<unknown>>;
|
|
42
44
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import w,{useState as
|
|
1
|
+
import w,{useState as G,useRef as y,useContext as J,useImperativeHandle as K,useEffect as c,useCallback as j}from"react";import{ViewOperation as Q,ImgUtils as W}from"@labelbee/lb-annotation";import{Spin as X}from"antd/es";import Y from"../../hooks/useRefCache.js";import ee from"../measureCanvas/index.js";import{PointCloudContext as te}from"../pointCloudView/PointCloudContext.js";var ne=Object.defineProperty,N=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable,D=(n,r,o)=>r in n?ne(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o,R=(n,r)=>{for(var o in r||(r={}))re.call(r,o)&&D(n,o,r[o]);if(N)for(var o of N(r))oe.call(r,o)&&D(n,o,r[o]);return n},T=(n,r,o)=>new Promise((g,f)=>{var s=u=>{try{m(o.next(u))}catch(h){f(h)}},d=u=>{try{m(o.throw(u))}catch(h){f(h)}},m=u=>u.done?g(u.value):Promise.resolve(u.value).then(s,d);m((o=o.apply(n,r)).next())});const S={width:455,height:100},ie=n=>{if(!n)return S;if(n.width&&n.height)return n;const r=R({},n);return r.width||(r.width=S.width),r.height||(r.height=S.height),r},ae=(n,r)=>{var o,g;const{src:f,fallbackSrc:s,annotations:d=[],style:m={stroke:"blue",thickness:3},zoomChange:u,backgroundStyle:h={},onChange:I,showLoading:M=!1,globalStyle:U,afterImgOnLoad:Z,measureVisible:P,onRightClick:_,pointCloudBoxList:E=[],hiddenText:L=!1,renderToolName:B}=n,p=ie(n.size),[H,k]=G(!1),z=y(null),e=y(),x=Y(Z),v=y([]),C=y(!0);J(te),K(r,()=>{const t=e.current;return t?{zoomIn:()=>t.zoomChanged(!0),zoomOut:()=>t.zoomChanged(!1),initImgPos:()=>t.initImgPos(),toolInstance:t}:{}},[e.current]),c(()=>(z.current&&(e.current=new Q({container:z.current,size:p,style:m,annotations:d,config:"{}",zoomInfo:n.zoomInfo,staticMode:n.staticMode,renderToolName:B}),e.current.init(),_&&e.current.on("onRightClick",_)),()=>{var t,a;_&&((t=e.current)==null||t.unbind("onRightClick",_)),(a=e.current)==null||a.destroy()}),[P]);const O=j(t=>T(void 0,null,function*(){var a,i;try{const l=yield W.load(t);return(a=e.current)==null||a.setImgNode(l),(i=x.current)==null||i.call(x,l),null}catch(l){return console.error("Error loading image:",l),l}}),[]),A=j(t=>T(void 0,null,function*(){var a,i;if(k(!0),(a=e.current)==null||a.setLoading(!0),(yield O(t))&&s){const b=yield O(s);b&&console.error("Error loading fallback image:",b)}(i=e.current)==null||i.setLoading(!1),k(!1)}),[O,s]);c(()=>{e.current&&A(f)},[f,P,s,A]),c(()=>{(e==null?void 0:e.current)&&e.current.setPointCloudBoxList(E)},[E]),c(()=>{var t;(e==null?void 0:e.current)&&((t=e.current)==null||t.setHiddenText(L))},[L]),c(()=>{if(C.current===!1){v.current.push(d);return}const t=()=>{C.current=!0,v.current=[]},a=()=>{var i;const l=v.current.length;if(l>0){const b=v.current[l-1];v.current=[],(i=e.current)==null||i.updateData(b).then(a).catch(t)}else C.current=!0};e.current&&(C.current=!1,e.current.updateData(d).then(a).catch(t))},[d]),c(()=>{const t=e.current;(t==null?void 0:t.setSize)&&(t.setSize(p),t.initPosition())},[(o=n.size)==null?void 0:o.width,(g=n.size)==null?void 0:g.height]),c(()=>{var t,a;return e.current&&((t=e.current)==null||t.on("onChange",(...i)=>{I==null||I.apply(null,i)}),(a=e.current)==null||a.on("renderZoom",i=>{u&&u(i)})),()=>{var i,l;(i=e.current)==null||i.unbindAll("onChange"),(l=e.current)==null||l.unbindAll("renderZoom")}},[u,I]);const F=w.createElement("div",{ref:z,style:R(R({position:"relative"},p),h)}),{imgNode:V,zoom:$,currentPos:q}=e.current||{};return w.createElement(X,{spinning:M||H,delay:300,style:U},P&&V?w.createElement(ee,{size:p,imgNode:V,zoom:$,currentPos:q}):F)};var le=w.forwardRef(ae);export{le as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useLatest as oe,useMemoizedFn as
|
|
1
|
+
import{useLatest as oe,useMemoizedFn as q}from"ahooks";import{Spin as he}from"antd/es";import J,{useContext as Ie,useRef as $,useState as L,useMemo as _e,useCallback as De,useEffect as p}from"react";import{connect as be}from"react-redux";import{usePointCloudViews as Ce}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as we}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as xe}from"../../store/annotation/map.js";import{LabelBeeContext as ye}from"../../store/ctx.js";import{PointCloud2DRectOperation as Pe,MathUtils as Se,ImgUtils as Le}from"@labelbee/lb-annotation";import{selectSpecifiedRectsFromTopViewSelectedIds as Oe}from"./util.js";import{useUpdateRectList as Ve}from"./useUpdateRectList.js";import je from"lodash";import{useToolStyleContext as Ee}from"../../hooks/useToolStyle.js";import ke from"../../store/toolConfig/index.js";var Be=Object.defineProperty,Ne=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,Me=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,le=(d,c,s)=>c in d?Be(d,c,{enumerable:!0,configurable:!0,writable:!0,value:s}):d[c]=s,v=(d,c)=>{for(var s in c||(c={}))Me.call(c,s)&&le(d,s,c[s]);if(ie)for(var s of ie(c))ze.call(c,s)&&le(d,s,c[s]);return d},C=(d,c)=>Ne(d,Ue(c)),G=(d,c,s)=>new Promise((a,g)=>{var D=f=>{try{b(s.next(f))}catch(R){g(R)}},O=f=>{try{b(s.throw(f))}catch(R){g(R)}},b=f=>f.done?a(f.value):Promise.resolve(f.value).then(D,O);b((s=s.apply(d,c)).next())});const Ae=d=>{var c,s;const{mappingData:a,size:g,config:D,checkMode:O,afterImgOnLoad:b,shouldExcludePointCloudBoxListUpdate:f}=d,{selectBoxVisibleSwitch:R}=ke(),V=(c=a==null?void 0:a.url)!=null?c:"",w=(s=a==null?void 0:a.fallbackUrl)!=null?s:"",{pointCloudBoxList:j,setPointCloudResult:E,defaultAttribute:k,rectList:B,addRectIn2DView:ce,updateRectIn2DView:se,removeRectIn2DView:ue,updateRectListByReducer:de,selectedIDs:m,setSelectedIDs:N,selectedID:x}=Ie(we),{value:U}=Ee(),ae=oe(m),{update2DViewRect:fe,remove2DViewRect:pe}=Ce(),M=J.useRef(null),n=$(null),K=q(fe),y=q(pe),P=$(null),[me,Q]=L(!0),[W,X]=L(""),[ve,z]=L(!1),[ge,A]=L(!0),h=_e(()=>B==null?void 0:B.filter(e=>e.imageName===(a==null?void 0:a.path)),[a==null?void 0:a.path,B]),Y=$(h),S=oe(a==null?void 0:a.path),T=De(e=>G(void 0,null,function*(){try{const o=ae.current.slice(0),r=yield Promise.resolve(e());if(!r||r.length===0)return r;if(o.length){const t=new Set(o),i=r.filter(l=>t.has(l.id)).map(l=>l.id);N(i)}return r}catch(o){}}),[N]),Z=e=>{const{boxID:o}=e;if(!f&&o){T(()=>{const r=K==null?void 0:K(e);return r?(P.current=r,E(r),r):null});return}se(e,!0)},ee=e=>{S.current&&ce(C(v({},e),{imageName:S.current}))},te=e=>{if(e.length===0)return;if(!f){const r=e.find(t=>t.boxID);if(r){T(()=>{const t=y==null?void 0:y(r);return t?(P.current=t,E(t),I(),t):null});return}}const o=e.find(r=>r.extId);o&&T(()=>{const{imageName:r,extId:t}=o,i=y==null?void 0:y({boxID:t,imageName:r});return i?(P.current=i,E(i),i):null}),ue(e)},Re=q(()=>{let e=[];return j.forEach(o=>{const{rects:r=[],id:t,attribute:i,trackID:l}=o,u=r.find(F=>F.imageName===S.current),_=t+"_"+S.current;u&&(e=[...e,C(v({},u),{boxID:t,id:_,attribute:i,order:l})])}),e}),I=Ve(()=>{var e,o,r,t,i;const l=f?[]:Re(),u=(e=n.current)==null?void 0:e.selectedRectID,_=m.slice(0),F=R?Oe(_,l,h):[...l,...h];let ne=[];!R&&(m==null?void 0:m.length)&&(ne=l.filter(H=>u?m.includes(H.boxID)&&!u.includes(H.boxID):m.includes(H.boxID))),(o=n.current)==null||o.setHighLightRectList(ne),(r=n.current)==null||r.setResult(F),W?((t=n.current)==null||t.setSelectedRectID(W),X("")):ve&&u&&((i=n.current)==null||i.setSelectedRectID(u),z(!1))}),re=({targetId:e,id:o})=>{A(!1),N(e),X(o)};return p(()=>{if(M.current){const e=new Pe({container:M.current,size:g,config:C(v({},D),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:O});return n.current=e,n.current.init(),n.current.on("updateDragResult",Z),n.current.on("afterAddingDrawingRect",ee),n.current.on("deleteSelectedRects",te),n.current.on("onRightClick",re),()=>{var o,r,t,i,l;(o=n.current)==null||o.unbind("updateDragResult",Z),(r=n.current)==null||r.unbind("afterAddingDrawingRect",ee),(t=n.current)==null||t.unbind("deleteSelectedRects",te),(i=n.current)==null||i.unbind("onRightClick",re),(l=n.current)==null||l.destroy()}}},[]),p(()=>{const e=r=>G(void 0,null,function*(){try{return yield Le.load(r)}catch(t){return console.error("Error loading image:",t),null}}),o=()=>G(void 0,null,function*(){var r;Q(!0);let t=yield e(V);!t&&w&&(t=yield e(w)),t&&((r=n.current)==null||r.setImgNode(t),b(t)),Q(!1)});n.current&&(V||w)&&o()},[V,w]),p(()=>{var e;(e=n.current)==null||e.setSize(g)},[g]),p(()=>{j!==P.current&&I()},[j]),p(()=>{var e,o;const r=h.find(t=>t.id===n.current.selectedRectID);(o=(e=n.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,k),r&&de(t=>{var i;const l=[];let u=null;return t.forEach(_=>{_.id!==n.current.selectedRectID?l.push(_):u=_}),r.extId===void 0&&(u=(i=n.current)==null?void 0:i.selectedRect),[...l,C(v({},u||{}),{attribute:k})]}),z(!0),I()},[k]),p(()=>{const e=Y.current;je.isEqual(e,h)||(z(!0),I(),Y.current=h)},[h]),p(()=>{I()},[f]),p(()=>{var e,o,r,t;const i=(o=(e=n.current)==null?void 0:e.config)!=null?o:{},l=C(v({},i),{attributeList:(r=D.attributeList)!=null?r:[]});(t=n.current)==null||t.setConfig(JSON.stringify(l))},[D.attributeList]),p(()=>{var e;(e=n.current)==null||e.setEnableAddRect(m.length===0),I()},[m]),p(()=>{if(!x||!ge){A(!0);return}const{rectList:e,size:o,zoom:r}=n.current,t=e.find(u=>u.boxID===x||u.extId===x);if(!t){A(!0);return}const i={x:t.x+t.width/2,y:t.y+t.height/2},l=Se.getCurrentPosFromRectCenter(o,i,r);n.current.setHoverRectID(t.id),n.current.setCurrentPos(l),n.current.renderBasicCanvas(),n.current.render()},[x]),p(()=>{const{hiddenText:e}=U||{};if(e===void 0)return;const o=n.current;if(!o)return;const r=v(v({},o.style),U);o.setStyle(r)},[U]),p(()=>{I()},[R]),J.createElement(he,{spinning:me},J.createElement("div",{ref:M,style:v({position:"relative"},g)}))};var Te=be(xe,null,null,{context:ye})(Ae);export{Te as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as w}from"../../utils/dom.js";import s,{useRef as
|
|
1
|
+
import{getClassName as w}from"../../utils/dom.js";import s,{useRef as j,useState as G,useContext as J,useMemo as K,useCallback as M,useEffect as Q}from"react";import W from"../AnnotationView/index.js";import X from"../../hooks/useSize.js";import{useSingleBox as Y}from"./hooks/useSingleBox.js";import{EPointCloudName as Z}from"@labelbee/lb-annotation";import{useHighlight as $}from"./hooks/useHighlight.js";import oo from"./components/HighlightVisible/index.js";import{PointCloudContext as to}from"./PointCloudContext.js";import eo from"./hooks/useDataLinkSwitch.js";import no from"../pointCloud2DRectOperationView/index.js";import{useToolStyleContext as io}from"../../hooks/useToolStyle.js";var lo=(o,u,i)=>new Promise((a,r)=>{var f=t=>{try{l(i.next(t))}catch(n){r(n)}},d=t=>{try{l(i.throw(t))}catch(n){r(n)}},l=t=>t.done?a(t.value):Promise.resolve(t.value).then(f,d);l((i=i.apply(o,u)).next())});const so=({view2dData:o,setSelectedID:u,currentData:i,showEnlarge:a,checkMode:r=!1,measureVisible:f})=>{var d,l;const t=j(null),n=j(),{selectedBox:m}=Y(),p=X(t),{url:b,fallbackUrl:x,calib:C,path:v}=o,{toggle2dVisible:B,isHighlightVisible:I}=$({currentData:i}),[_,k]=G(!1),{highlight2DLoading:z,setHighlight2DLoading:S,cuboidBoxIn2DView:h,cacheImageNodeSize:N,setSelectedIDs:O,pointCloudBoxList:R}=J(to),{value:E}=io(),{hiddenText:H}=E||{},T=!o,U=K(()=>({zIndex:a?-1:101,is2DView:!h,imageName:o.path}),[a,h,o.path]),{rendered:A,isLinking:D}=eo(U),L=e=>{g(),N({path:v,imgNode:e})},g=M(()=>{var e,y;const P=(e=n.current)==null?void 0:e.toolInstance;if(u(""),!m||!P)return;const c=o.annotations.find(q=>q.annotation.id===m.info.id);let V="";c&&((y=c==null?void 0:c.annotation.pointList)==null?void 0:y.length)>0&&(P.focusPositionByPointList(c==null?void 0:c.annotation.pointList),V=m.info.id,u(V))},[m,n.current,o.annotations]);Q(()=>{g()},[g]);const F=()=>lo(void 0,null,function*(){k(!0),S(!0);try{yield B(b,x!=null?x:"",C)}catch(e){console.error("highlightOnClick error:",e)}finally{k(!1),S(!1)}});return s.createElement("div",{className:w("point-cloud-2d-image"),ref:t},h?s.createElement(W,{src:(d=o==null?void 0:o.url)!=null?d:"",fallbackSrc:(l=o==null?void 0:o.fallbackUrl)!=null?l:"",annotations:o.annotations,size:p,ref:n,globalStyle:{display:T?"none":"block"},afterImgOnLoad:L,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:f,onRightClick:({targetId:e})=>O(e),pointCloudBoxList:R,hiddenText:H,renderToolName:Z.PointCloud}):s.createElement(s.Fragment,null,s.createElement(no,{shouldExcludePointCloudBoxListUpdate:!D,mappingData:o,size:p,checkMode:r,afterImgOnLoad:L}),!r&&A),C&&s.createElement(oo,{visible:I(b),onClick:F,loading:_,disabled:z,style:{position:"absolute",right:16,top:16,zIndex:a?-1:101}}))};export{so as default};
|
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.137",
|
|
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.68",
|
|
47
47
|
"@labelbee/lb-utils": "1.19.0-alpha.26",
|
|
48
48
|
"@labelbee/wavesurfer": "1.1.0-alpha.1",
|
|
49
49
|
"@types/react-dom": "^18.2.7",
|