@labelbee/lb-components 1.23.0-alpha.126 → 1.23.0-alpha.128
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/_virtual/2DViewWorker.js +1 -1
- package/dist/components/LLMMultiWheelView/dialogView/index.js +1 -1
- package/dist/components/LLMToolView/questionView/components/imgView/index.js +1 -1
- package/dist/components/markdownView/index.js +1 -1
- package/dist/components/pointCloudView/PointCloudListener.js +1 -1
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/components/pointCloudView/hooks/useUpdatePointCloudColor.js +1 -0
- package/dist/index.css +0 -4
- package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +18 -0
- package/dist/types/components/pointCloudView/hooks/useUpdatePointCloudColor.d.ts +4 -0
- package/dist/types/utils/ToolPointCloudBoxRenderHelper.d.ts +2 -1
- package/dist/utils/ToolPointCloudBoxRenderHelper.js +1 -1
- package/es/_virtual/2DViewWorker.js +1 -1
- package/es/components/LLMMultiWheelView/dialogView/index.js +1 -1
- package/es/components/LLMToolView/questionView/components/imgView/index.js +1 -1
- package/es/components/markdownView/index.js +1 -1
- package/es/components/pointCloudView/PointCloudListener.js +1 -1
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/hooks/useUpdatePointCloudColor.js +1 -0
- package/es/index.css +0 -4
- package/es/utils/ToolPointCloudBoxRenderHelper.js +1 -1
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getTextControlByConfig as P,RenderAnswer as I}from"../../LLMToolView/questionView/index.js";import{RenderQuestion as N}from"../../LLMToolView/questionView/components/header/index.js";import V from"../../LLMToolView/questionView/components/imgView/index.js";import j from"../../../store/LLMMultiWheel/index.js";import{classnames as h}from"../../../utils/index.js";import{Button as n}from"antd";import e from"react";var x=Object.defineProperty,D=Object.defineProperties,M=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable,
|
|
1
|
+
import{getTextControlByConfig as P,RenderAnswer as I}from"../../LLMToolView/questionView/index.js";import{RenderQuestion as N}from"../../LLMToolView/questionView/components/header/index.js";import V from"../../LLMToolView/questionView/components/imgView/index.js";import j from"../../../store/LLMMultiWheel/index.js";import{classnames as h}from"../../../utils/index.js";import{Button as n}from"antd";import e from"react";var x=Object.defineProperty,D=Object.defineProperties,M=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable,u=(o,t,r)=>t in o?x(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,B=(o,t)=>{for(var r in t||(t={}))F.call(t,r)&&u(o,r,t[r]);if(c)for(var r of c(t))q.call(t,r)&&u(o,r,t[r]);return o},C=(o,t)=>D(o,M(t));const T=o=>{const{id:t,answerList:r,question:d,index:p,name:f="",answerIsImg:w,questionIsImg:E,LLMConfig:v}=o,{dataFormatType:s,selectedID:_,setSelectedID:g}=j(),a=p+1,y=f||`\u5BF9\u8BDD${a}`;return e.createElement("div",{key:t,onClick:()=>g(t),className:h({dialog:!0,selected:t===_})},e.createElement("div",{className:"header"},e.createElement("span",{className:"order"},a),e.createElement("div",{className:"name"},e.createElement("div",{className:"show-name"},y),e.createElement("div",{className:"tips"},"\uFF08\u9009\u4E2D\u6807\u6CE8\uFF09"))),e.createElement("div",{className:"dialog-question"},e.createElement(n,{type:"primary"},"\u9898\u76EE",a),e.createElement("div",null,e.createElement(N,{question:d,dataFormatType:s,isImg:E}))),e.createElement("div",{className:"dialog-answer"},w?e.createElement(e.Fragment,null,e.createElement(n,{type:"primary"},"\u7B54\u6848"),e.createElement(V,{answerList:r})):r==null?void 0:r.map((L,i)=>{const l=i+1,m=C(B({},L),{order:l}),O=P(m,v);return e.createElement("div",{key:i},e.createElement(n,{type:"primary"},"\u7B54\u6848",l),e.createElement(I,{i:m,isTextControl:O,dataFormatType:s}))})))};export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"react";import{Tag as i,Image as c}from"antd";import{prefix as
|
|
1
|
+
import t from"react";import{Tag as i,Image as c}from"antd";import{prefix as d}from"../../../../../constant/index.js";import g from"classnames";import u from"../../../../../assets/annotation/LLMTool/imgFail_cn.svg.js";import f from"../../../../../assets/annotation/LLMTool/imgFail_en.svg.js";import{i18n as p}from"@labelbee/lb-utils";import a from"./index.module.scss.js";const o=`${d}-LLMView`,v=m=>{const{answerList:s,hoverKey:l}=m,n=p.language==="en"?f:u;return t.createElement("div",{className:a.imgView},s==null?void 0:s.map((e,r)=>t.createElement("div",{key:r,className:g({[`${a.item}`]:!0,[`${o}__contentActive`]:l===(e==null?void 0:e.order)})},t.createElement(i,{className:`${o}-tag`},e==null?void 0:e.order),t.createElement("div",{className:a.image},t.createElement(c,{src:e==null?void 0:e.url,fallback:n,style:{objectFit:"contain"}})))))};export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import n from"react";import
|
|
1
|
+
import n from"react";import v from"react-markdown";import P from"remark-math";import O from"rehype-katex";import k from"rehype-raw";import x from"react-syntax-highlighter";import{docco as b}from"react-syntax-highlighter/dist/esm/styles/hljs";import j from"remark-gfm";import"github-markdown-css";import E from"./index.module.scss.js";import{classnames as N}from"../../utils/index.js";var S=Object.defineProperty,I=Object.defineProperties,M=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,g=(r,e,t)=>e in r?S(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,m=(r,e)=>{for(var t in e||(e={}))f.call(e,t)&&g(r,t,e[t]);if(o)for(var t of o(e))d.call(e,t)&&g(r,t,e[t]);return r},h=(r,e)=>I(r,M(e)),R=(r,e)=>{var t={};for(var a in r)f.call(r,a)&&e.indexOf(a)<0&&(t[a]=r[a]);if(r!=null&&o)for(var a of o(r))e.indexOf(a)<0&&d.call(r,a)&&(t[a]=r[a]);return t};const V=r=>{const{value:e,transformImageUri:t,transformLinkUri:a,components:_}=r,w=u=>{var i=u,{node:D,inline:y,className:s,children:l}=i,p=R(i,["node","inline","className","children"]);const c=/language-(\w+)/.exec(s||"");return!y&&c?n.createElement(x,h(m({},p),{className:"markdown-code-viewer",language:c[1],style:b,PreTag:"div"}),String(l).replace(/\n$/,"")):n.createElement("code",h(m({},p),{className:s}),l)};return n.createElement(v,{className:N({"markdown-body":!0,[E.markdownView]:!0}),remarkPlugins:[j,P],rehypePlugins:[k,[O,{output:"mathml"}]],transformImageUri:t,transformLinkUri:a,components:m({code:w},_)},e)};export{V as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PointCloudContext as
|
|
1
|
+
import{PointCloudContext as re}from"./PointCloudContext.js";import{useRotate as se}from"./hooks/useRotate.js";import{useRotateEdge as ne}from"./hooks/useRotateEdge.js";import{useBoxes as ie}from"./hooks/useBoxes.js";import{useSingleBox as ae}from"./hooks/useSingleBox.js";import{useSphere as ue}from"./hooks/useSphere.js";import{useContext as le,useEffect as d}from"react";import{CommonToolUtils as ce,AttributeUtils as de,EToolName as f,cTool as pe}from"@labelbee/lb-annotation";import{message as g}from"antd";import{connect as me}from"react-redux";import{a2MapStateToProps as be}from"../../store/annotation/map.js";import{useStatus as fe}from"./hooks/useStatus.js";import{usePointCloudViews as Pe}from"./hooks/usePointCloudViews.js";import{LabelBeeContext as ye}from"../../store/ctx.js";import{useHistory as ve}from"./hooks/useHistory.js";import{useAttribute as we}from"./hooks/useAttribute.js";import{useConfig as Ce}from"./hooks/useConfig.js";import{usePolygon as he}from"./hooks/usePolygon.js";import{useLine as ge}from"./hooks/useLine.js";import{useUpdatePointCloudColor as Se}from"./hooks/useUpdatePointCloudColor.js";import{useTranslation as ke}from"react-i18next";import{useLatest as j}from"ahooks";var xe=Object.defineProperty,_e=Object.defineProperties,Ve=Object.getOwnPropertyDescriptors,I=Object.getOwnPropertySymbols,Be=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable,A=(n,r,a)=>r in n?xe(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,P=(n,r)=>{for(var a in r||(r={}))Be.call(r,a)&&A(n,a,r[a]);if(I)for(var a of I(r))Le.call(r,a)&&A(n,a,r[a]);return n},y=(n,r)=>_e(n,Ve(r));const{EPolygonPattern:Oe}=pe,je=({currentData:n,config:r,checkMode:a,configString:E,imgIndex:S,toolInstanceRef:i,setResourceLoading:k})=>{const e=le(re),{changeSelectedBoxValid:T,selectNextBox:D,selectPrevBox:H,updateSelectedBox:K,deleteSelectedPointCloudBoxAndPolygon:N}=ae(),{selectedSphere:v,updatePointCloudSphere:U}=ue(),{clearAllResult:w,updatePointCloudPattern:z}=fe(),{copySelectedBoxes:R,pasteSelectedBoxes:F,copiedBoxes:Ae}=ie({config:r,currentData:n}),{updateRotate:x}=se({currentData:n}),{updateRotateEdge:q}=ne({currentData:n}),{updatePointCloudData:m,topViewSelectedChanged:G}=Pe({setResourceLoading:k}),{redo:_,undo:V,pushHistoryWithList:M,pushHistoryUnderUpdatePolygon:W,pushHistoryUnderUpdateLine:Y}=ve(),{syncThreeViewsAttribute:B}=we(),{syncAllViewsConfig:$,reRenderTopViewRange:J}=Ce(),{selectedPolygon:L}=he(),{selectedLine:O}=ge(),{t:C}=ke(),{updatePointCloudColor:Q}=Se(k,r),X=j(n),b=t=>{var o;const{topViewInstance:s}=e;!s||(o=s.pointCloud2dOperation)==null||o.updateSelectedPolygonsPoints(t)},Z=(t,o)=>{var s,u;const{topViewInstance:c,mainViewInstance:l}=e;if(!c)return;const{pointCloud2dOperation:h}=c;switch(t){case"q":{x(e.rectRotateSensitivity);break}case"e":x(-Number(e.rectRotateSensitivity));break;case"g":q(-90);break;case"u":{const p=h.pattern===Oe.Normal?f.Rect:f.Polygon;z(p);const oe={[f.Polygon]:C("PolygonPattern"),[f.Rect]:C("RectPattern")};g.success(C("ChangePatternMsg",{pattern:oe[p]})),h.clearActiveStatus(),h.clearDrawingStatus()}break;case"+":l==null||l.updatePointSize({zoomIn:!0});break;case"-":l==null||l.updatePointSize({zoomIn:!1});break;case"v":e.setPointCloudValid(!e.valid);break;case"tab":if(o.shiftKey){H();break}D(),o.preventDefault();break;case"f":T();break;case"arrowup":b({y:-1});break;case"arrowdown":b({y:1});break;case"arrowleft":b({x:-1});break;case"arrowright":b({x:1});break;case"delete":N(X.current);break;default:{if(((s=r.attributeList)==null?void 0:s.length)>0){const p=de.getAttributeByKeycode(o.keyCode,r.attributeList);p!==void 0&&((u=i.current)==null||u.setDefaultAttribute(p))}return}}},ee=(t,o)=>{switch(t){case"c":R();break;case"v":F();break;case"a":o.preventDefault(),e.selectedAllBoxes();break;case"z":{o.shiftKey?_():V();break}}},te=j(t=>{if(!ce.hotkeyFilter(t)||a===!0)return;const o=t.key.toLocaleLowerCase();if(t.ctrlKey){ee(o,t);return}Z(o,t)});return d(()=>{if(!e.topViewInstance)return;const{addEventListener:o}=e.windowKeydownListenerHook;return o(c=>te.current(c))},[e,e.topViewInstance,e.windowKeydownListenerHook]),d(()=>{$(r)},[E]),d(()=>{(r==null?void 0:r.radius)&&J(r==null?void 0:r.radius)},[r==null?void 0:r.radius]),d(()=>{m==null||m()},[S,e.mainViewInstance]),d(()=>{e.setHideAttributes([])},[S]),d(()=>{i.current.setDefaultAttribute=t=>{var o;if(B(t),Q(t),L&&W(y(P({},L),{attribute:t})),O&&Y(y(P({},O),{attribute:t})),v){const s=U(y(P({},v),{attribute:t}));e.mainViewInstance&&((o=e.mainViewInstance)==null||o.generateSpheres(s),G({newSelectedSphere:v,newSphereList:s}))}},i.current.setSubAttribute=(t,o)=>{var s;const u=e.selectedPointCloudBox;if(u){const c=(s=u==null?void 0:u.subAttribute)!=null?s:{};u.subAttribute=y(P({},c),{[t]:o}),K(u),e.mainViewInstance&&e.selectedPointCloudBox&&e.mainViewInstance.generateBox(e.selectedPointCloudBox)}},i.current.clearResult=()=>{w==null||w()},i.current.redo=()=>{_()},i.current.undo=()=>{V()},i.current.setValid=t=>{i.current.valid=t,setTimeout(()=>{e.setPointCloudValid(t),t===!1&&w()})},i.current.setForbidOperation=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setForbidOperation(t),t===!0&&e.setSelectedIDs(void 0)},i.current.setShowDefaultCursor=t=>{var o,s;(s=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null||s.setShowDefaultCursor(t)},i.current.asyncData=t=>{setTimeout(()=>{m==null||m(t)})}},[e.pointCloudBoxList,e.pointCloudSphereList,e.selectedID,e.selectedIDs,e.valid,e.polygonList,e.lineList,e.mainViewInstance,e.ptSegmentInstance]),d(()=>{i.current.updateSegmentTool=t=>{var o;(o=e.ptSegmentInstance)==null||o.emit(t)},i.current.segmentInstance=e.ptSegmentInstance},[e.ptSegmentInstance]),d(()=>{i.current.history={pushHistory:t=>{M({pointCloudBoxList:t})},initRecord:()=>{}}},[]),d(()=>{var t;const o=(t=e.topViewInstance)==null?void 0:t.toolInstance;if(!o||a)return;const s=l=>{B(l)},u=l=>{g.error(l)},c=l=>{g.info(l)};return o.on("syncAttribute",s),o.on("messageError",u),o.on("messageInfo",c),()=>{o.unbind("syncAttribute",s),o.unbind("messageError",u),o.unbind("messageInfo",c)}},[e.topViewInstance]),null};var Ie=me(be,null,null,{context:ye})(je);export{Ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as Q,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as mt,useCallback as xt}from"react";import{PointCloudContext as ht}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as rt}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as lt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as dt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as $}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,ho=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,L=(e,n)=>{for(var t in n||(n={}))xo.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))ho.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((c,p)=>{var o=a=>{try{u(t.next(a))}catch(x){p(x)}},f=a=>{try{u(t.throw(a))}catch(x){p(x)}},u=a=>a.done?c(a.value):Promise.resolve(a.value).then(o,f);u((t=t.apply(e,n)).next())});const tt=5,ot=90,wt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(e,n,t,c,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,a={center:{x:o,y:f,z:u},id:e.id},x=c?L(L({},c),a):A(L({},a),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},ct=(e,n,t,c,p,o)=>{let f=e.pointList.map(I=>O.transferCanvas2World(I,n)),u=0,a=1,x={};if(t){const I=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&I.fittedCoordinates.length>0&&(f=I.fittedCoordinates),u=(I.maxZ+I.minZ)/2,a=I.maxZ-I.minZ,x={count:I.zCount}}const[P,v,T]=f,_=w.getLineCenterPoint([P,T]),D=w.getLineLength(P,v),U=w.getLineLength(v,T),N=w.getRadiusFromQuadrangle(e.pointList);c&&(u=c.center.z,a=c.depth);const z={center:{x:_.x,y:_.y,z:u},width:o?U+wt:U,height:o?D+wt:D,depth:a,rotation:N,id:e.id},j=L(c?L(L({},c),z):A(L({},z),{attribute:"",valid:!0}),x);p&&Object.assign(j,p);const M=f.map(I=>O.transferWorld2Canvas(I,n));return{boxParams:j,newPointList:M}},It=(e,n,t)=>{const c={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x-c.x,y:t.center.y,z:t.center.z-c.y}})},Dt=(e,n,t,c)=>{const[p,o,f]=e.pointList,[u,a,x]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,x]),_={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,a),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(a,x),M=z-j,{newBoxParams:I}=c.getNewBoxBySideUpdate(_,M,N,t);return I},Lo=(e,n,t)=>{const c={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x,y:t.center.y-c.x,z:t.center.z-c.y}})},vo=(e,n,t,c)=>{const[p,o,f]=e.pointList,[u,a,x]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,x]),_={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,a),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(a,x),M=z-j;let{newBoxParams:I}=c.getNewBoxByBackUpdate(_,M,N,t);return I},St=(e,n,t,c,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(c,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,Q.Left);u.setInitCameraPosition(a);const{point2d:x,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,c)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(c,e,{width:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,Q.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,c,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(c,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:a}=u.updateOrthoCameraBySphere(e,Q.Back);u.setInitCameraPosition(a);const{point2d:x,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,c)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(c,e,{height:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,Q.Back);o.setInitCameraPosition(f);const{polygon2d:u,zoom:a}=o.getBoxBackPolygon2DCoordinate(e);o.camera.zoom=a,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(a),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},kt=(e,n,t,c)=>{if(!t||!c)return;c.generateSphere(e),c.updateCameraBySphere(e,Q.Top),c.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(a=>a.id===n.id?A(L(L({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):a);p.setResult(u),p.setSelectedID(n.id)},ut=(e,n,t,c)=>{var p,o;if(!t||!c)return;c.generateBox(e,n.id),c.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:a}=u.getBoxTopPolygon2DCoordinate(e),x=[...f.polygonList],P=x.find(v=>v.id===n.id);P?(P.pointList=a,P.valid=(p=e.valid)!=null?p:!0):x.push({id:n.id,pointList:a,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(x,n.id)},yo=e=>{const n=mt(ht),{topViewInstance:t,sideViewInstance:c,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:a,selectedIDs:x,pointCloudBoxList:P,pointCloudSphereList:v,hideAttributes:T,setHighlight2DDataList:_,cuboidBoxIn2DView:D,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:M,pushHistoryUnderUpdatePolygon:I}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:pt,selectedSphere:X}=ro(),{currentData:H,config:B}=ao(s=>{const{stepList:i,step:d,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:lt(uo.getCurrentStepInfo(d,i).config)}}),F=co(),Tt=$(D),Ut=$(z),zt=xt((s,i)=>{const d=Ut.current,r=i.id;return s.filter(g=>{if(!g)return!1;const C=d.get(g.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),et=s=>{const{enableAutoMap2DRect:i=!1}=B;if(!Tt.current||i){const{mappingImgList:d=[]}=H;po({pointCloudBox:s,mappingImgList:d,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:nt,getPointCloudByID:jt}=so({generateRects:et}),gt=k==null?void 0:k.info;if(!t||!c||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:it}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:s,size:i,zoom:d,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const C=at(s,i,it,void 0,g);a(s.id);const m=u(C);Y(y.Top,s,C,d,m,B),j({newSphereParams:C})},Ft=({polygon:s,size:i,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,m,b;const V={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(V,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:v})});const R=t==null?void 0:t.toolInstance,S=L({},s);let{boxParams:h,newPointList:E}=ct(S,i,it,void 0,V,g);h=F(dt({tool:st.PointCloud,dataList:[h],stepConfig:B,action:"viewUpdateBox"}))[0],g&&(E==null?void 0:E.length)&&(S.pointList=E);const W=T.includes(S.attribute);et(h);const J=f(h),q=(m=n==null?void 0:n.polygonList)!=null?m:[];h.subAttribute=oo.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(b=B==null?void 0:B.inputList)!=null?b:[]:[]),t==null||t.updatePolygonList(J!=null?J:[],q),W?a([]):(a(h.id),R.selection.setSelectedIDs(S.id),Z({omitView:y.Top,polygon:S,boxParams:h,zoom:l,newPointCloudBoxList:J}),g&&ut(h,S,t,o)),j({newBoxParams:h})},Ht=s=>{const{boxID:i,imageName:d,width:r,height:l,x:g,y:C}=s,m=P.find(h=>h.id===i);if(!(m==null?void 0:m.rects)||!m.rects.find(h=>h.imageName===d))return;const V=m.rects.map(h=>h.imageName===d?A(L({},h),{width:r,height:l,x:g,y:C}):h),R=A(L({},m),{rects:V}),S=P.map(h=>h.id===i?R:h);return t==null||t.updatePolygonList(S!=null?S:[]),S},Wt=s=>{const{boxID:i,imageName:d}=s,r=P.find(m=>m.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(m=>m.imageName!==d),g=A(L({},r),{rects:l}),C=P.map(m=>m.id===i?g:m);return t==null||t.updatePolygonList(C!=null?C:[]),C},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:d,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(x.length===0||!g)){if(s||(k==null?void 0:k.info)){const C=s!=null?s:k==null?void 0:k.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(x[0]);const m=g.selectedPolygon;if(x.length===1&&C){Z({omitView:y.Top,polygon:m,boxParams:C,newPointCloudBoxList:i});return}}if((d||X)&&x.length===1){const C=d!=null?d:X;g.setSelectedID(x[0]);const m=g.selectedPoint;C&&Y(y.Top,m,C,void 0,r,B)}}},ft=(s,i,d)=>{if(gt){let r,l;switch(d){case y.Back:r=vo;break;case y.Side:r=Dt;break;default:r=Dt;break}if(l=r(s,i,gt,c.pointCloudInstance),o){const{count:V}=o.getSensesPointZAxisInPolygon(eo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=A(L({},l),{count:V})}const C=F(dt({tool:st.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],m=l.valid!==C.valid;l=C;const b=Nt(l);return l=b.find(V=>V.id===l.id),Z({omitView:m?void 0:d,polygon:s,boxParams:l,newPointCloudBoxList:b}),b}},Ct=(s,i,d)=>{if(X){let r,l;switch(d){case y.Back:r=Lo;break;case y.Side:r=It;break;default:r=It;break}l=r(s,i,X);const g=pt(l);return Y(d,s,l,void 0,g,B),g}},Gt=(s,i)=>{Ct(s,i,y.Side)},Jt=(s,i)=>{Ct(s,i,y.Back)},Qt=(s,i)=>{ft(s,i,y.Side)},Xt=(s,i)=>{ft(s,i,y.Back)},Yt=(s,i)=>{const d=At(s.id),r=at(s,i,it,d),l=pt(r);Y(y.Top,s,r,void 0,l,B)},qt=(s,i)=>{if(Ot){const r=L({},s[0].newPolygon);r.pointList=r.pointList.map(l=>O.transferCanvas2World(l,i)),I(r);return}let d=s.map(({newPolygon:r})=>{const l=jt(r.id),{boxParams:g}=ct(r,i,t.pointCloudInstance,l);return g});if(d=F(dt({tool:st.PointCloud,dataList:d,stepConfig:B,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=s[0],l=nt(d);Z({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=nt(d);r&&n.syncAllViewPointCloudColor(rt.MultiMove,r)}},Kt=s=>{var i,d,r,l,g;if(k){const C=Number(s.widthDefault),m=Number(s.depthDefault),b=Number(s.heightDefault),V=k==null?void 0:k.info.trackID,S=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(K=>(K==null?void 0:K.trackID)===V),h={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},E=S.pointList.map(K=>O.transferCanvas2World(K,h)),G=w.getModifiedRectangleCoordinates(E,b,C),W=G[0],J=G[2],q=w.getLineCenterPoint([W,J]),$t=k.info.center.z-k.info.depth/2,Pt=A(L({},k.info),{center:{x:q.x,y:q.y,z:$t+m/2},width:C,height:b,depth:m,valid:!0}),to=nt([Pt]);Z({omitView:y["3D"],polygon:S,boxParams:Pt,newPointCloudBoxList:to})}},Y=(s,i,d,r,l,g)=>bt(void 0,null,function*(){const C=H==null?void 0:H.url,m={[y.Side]:()=>{St(d,i,c,C,g)},[y.Back]:()=>{p&&_t(d,i,p,C,g)},[y.Top]:()=>{kt(d,i,t,o)}};Object.keys(m).forEach(b=>{b!==s&&m[b]()}),r&&(o==null||o.updateCameraZoom(r)),Et(d)}),Z=s=>{const{omitView:i,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:g}=s,C=H==null?void 0:H.url;g&&n.syncAllViewPointCloudColor(rt.Single,g);const m={[y.Side]:()=>{Rt(r,d,c,C)},[y.Back]:()=>{p&&Vt(r,d,p,C)},[y.Top]:()=>{ut(r,d,t,o)}};Object.keys(m).forEach(b=>{b!==i&&m[b]()}),l&&(o==null||o.updateCameraZoom(l))};return{topViewAddSphere:Mt,topViewAddBox:Ft,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=H){var d,r,l,g,C,m,b,V;if(!(i==null?void 0:i.url)||!o)return;_([]),Lt(F,!0),vt(F,!0),(d=e==null?void 0:e.setResourceLoading)==null||d.call(e,!0),yield o.loadPCDFile(i.url,(r=B==null?void 0:B.radius)!=null?r:ot),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let R=[],S=[],h=[],E=[];o.updateTopCamera();const G=(g=(l=lt(i.result))==null?void 0:l.valid)!=null?g:!0;if(n.setPointCloudValid(G),(C=n.sideViewInstance)==null||C.clearAllData(),(m=n.backViewInstance)==null||m.clearAllData(),i.result){if(R=O.getBoxParamsFromResultList(i.result),(R==null?void 0:R.length)>0&&i.isPreResult&&(B==null?void 0:B.lowerLimitPointsNumInBox)>0){R=yield o==null?void 0:o.filterPreResult(i.url,B,R);const W=lt(i.result);W[no].result=R,i.result=JSON.stringify(W),n.setPointCloudResult(R)}h=O.getPolygonListFromResultList(i.result),S=O.getLineListFromResultList(i.result),E=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(b=B==null?void 0:B.radius)!=null?b:ot}),o==null||o.generateBoxes(R),o==null||o.generateSpheres(E),yield n.syncAllViewPointCloudColor(rt.Default,R,[])}M({pointCloudBoxList:R,polygonList:h,lineList:S,pointCloudSphereList:E}),Lt(F,!1),vt(F,!1),(V=e==null?void 0:e.setResourceLoading)==null||V.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:et,update2DViewRect:Ht,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(ht),c=$(e),p=$(n);return{syncToPointCloudBoxList:xt(()=>{const f=c.current,u=p.current;if(u.length===0)return null;const a=new Map,x=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const v=P.extId,T=P.imageName,_=lo(P,["x","y","width","height"]);let D=a.get(v);D||(D=new Map,a.set(v,D)),D.set(T,_),x.add(v)}),a.size){const P=f.map(v=>{var T;const _=v.id;if(x.has(_)){const D=L({},v);return(T=D.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=a.get(_))==null?void 0:N.get(z))}),D}return v});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ut as synchronizeTopView,at as topViewPoint2PointCloud,ct as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
|
|
1
|
+
import{EPointCloudName as st,TagUtils as oo,MathUtils as w,getCuboidFromPointCloudBox as eo}from"@labelbee/lb-annotation";import{EPerspectiveView as X,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as no,DEFAULT_SPHERE_PARAMS as io}from"@labelbee/lb-utils";import{useContext as mt,useCallback as xt}from"react";import{PointCloudContext as ht}from"../PointCloudContext.js";import{useSingleBox as so}from"./useSingleBox.js";import{useSphere as ro}from"./useSphere.js";import{pick as lo}from"lodash";import{useSelector as ao,useDispatch as co}from"../../../store/ctx.js";import uo from"../../../utils/StepUtils.js";import{EPointCloudBoxRenderTrigger as rt}from"../../../utils/ToolPointCloudBoxRenderHelper.js";import{jsonParser as lt,generatePointCloudBoxRects as po}from"../../../utils/index.js";import{PreDataProcess as dt,SetAnnotationLoading as Lt,SetLoadPCDFileLoading as vt}from"../../../store/annotation/actionCreators.js";import{useHistory as go}from"./useHistory.js";import{usePolygon as fo}from"./usePolygon.js";import{useLatest as $}from"ahooks";var Co=Object.defineProperty,Po=Object.defineProperties,mo=Object.getOwnPropertyDescriptors,yt=Object.getOwnPropertySymbols,xo=Object.prototype.hasOwnProperty,ho=Object.prototype.propertyIsEnumerable,Bt=(e,n,t)=>n in e?Co(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,L=(e,n)=>{for(var t in n||(n={}))xo.call(n,t)&&Bt(e,t,n[t]);if(yt)for(var t of yt(n))ho.call(n,t)&&Bt(e,t,n[t]);return e},A=(e,n)=>Po(e,mo(n)),bt=(e,n,t)=>new Promise((c,p)=>{var o=d=>{try{u(t.next(d))}catch(x){p(x)}},f=d=>{try{u(t.throw(d))}catch(x){p(x)}},u=d=>d.done?c(d.value):Promise.resolve(d.value).then(o,f);u((t=t.apply(e,n)).next())});const tt=5,ot=90,wt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},at=(e,n,t,c,p)=>{const{x:o,y:f}=O.transferCanvas2World(e,n),{defaultZ:u}=io,d={center:{x:o,y:f,z:u},id:e.id},x=c?L(L({},c),d):A(L({},d),{attribute:"",valid:!0});return p&&Object.assign(x,p),x},ct=(e,n,t,c,p,o)=>{let f=e.pointList.map(I=>O.transferCanvas2World(I,n)),u=0,d=1,x={};if(t){const I=t.getSensesPointZAxisInPolygon(f,void 0,o);o&&I.fittedCoordinates.length>0&&(f=I.fittedCoordinates),u=(I.maxZ+I.minZ)/2,d=I.maxZ-I.minZ,x={count:I.zCount}}const[P,v,T]=f,V=w.getLineCenterPoint([P,T]),D=w.getLineLength(P,v),U=w.getLineLength(v,T),N=w.getRadiusFromQuadrangle(e.pointList);c&&(u=c.center.z,d=c.depth);const z={center:{x:V.x,y:V.y,z:u},width:o?U+wt:U,height:o?D+wt:D,depth:d,rotation:N,id:e.id},j=L(c?L(L({},c),z):A(L({},z),{attribute:"",valid:!0}),x);p&&Object.assign(j,p);const M=f.map(I=>O.transferWorld2Canvas(I,n));return{boxParams:j,newPointList:M}},It=(e,n,t)=>{const c={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x-c.x,y:t.center.y,z:t.center.z-c.y}})},Dt=(e,n,t,c)=>{const[p,o,f]=e.pointList,[u,d,x]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,x]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,d),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(d,x),M=z-j,{newBoxParams:I}=c.getNewBoxBySideUpdate(V,M,N,t);return I},Lo=(e,n,t)=>{const c={x:e.x-n.x,y:e.y-n.y};return A(L({},t),{center:{x:t.center.x,y:t.center.y-c.x,z:t.center.z-c.y}})},vo=(e,n,t,c)=>{const[p,o,f]=e.pointList,[u,d,x]=n.pointList,P=w.getLineCenterPoint([p,f]),v=w.getLineCenterPoint([u,x]),V={x:{x:P.x-v.x,y:P.y-v.y}.x,y:0,z:P.y-v.y},D=w.getLineLength(p,o),U=w.getLineLength(u,d),N=D-U,z=w.getLineLength(o,f),j=w.getLineLength(d,x),M=z-j;let{newBoxParams:I}=c.getNewBoxByBackUpdate(V,M,N,t);return I},St=(e,n,t,c,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(c,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:d}=u.updateOrthoCameraBySphere(e,X.Left);u.setInitCameraPosition(d);const{point2d:x,zoom:P}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Rt=(e,n,t,c)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(c,e,{width:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Left);o.setInitCameraPosition(f);const{polygon2d:u,zoom:d}=o.getBoxSidePolygon2DCoordinate(e);o.camera.zoom=d,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},_t=(e,n,t,c,p)=>{var o;if(!t)return;const{toolInstance:f,pointCloudInstance:u}=t;u.loadPCDFile(c,(o=p==null?void 0:p.radius)!=null?o:ot);const{cameraPositionVector:d}=u.updateOrthoCameraBySphere(e,X.Back);u.setInitCameraPosition(d);const{point2d:x,zoom:P}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=P,u.camera.updateProjectionMatrix(),u.render(),f.initPosition(),f.zoomChangeOnCenter(P),f.setResult([A(L(L({},n),x),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),f.setSelectedID(n.id)},Vt=(e,n,t,c)=>{if(!t)return;const{pointCloud2dOperation:p,pointCloudInstance:o}=t;o.loadPCDFileByBox(c,e,{height:tt,depth:tt});const{cameraPositionVector:f}=o.updateOrthoCamera(e,X.Back);o.setInitCameraPosition(f);const{polygon2d:u,zoom:d}=o.getBoxBackPolygon2DCoordinate(e);o.camera.zoom=d,o.camera.updateProjectionMatrix(),o.render(),p.initPosition(),p.zoomChangeOnCenter(d),p.setResultAndSelectedID([{id:n.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],n.id)},kt=(e,n,t,c)=>{if(!t||!c)return;c.generateSphere(e),c.updateCameraBySphere(e,X.Top),c.render();const{toolInstance:p,pointCloudInstance:o}=t,{point2d:f}=o.getSphereTopPoint2DCoordinate(e),u=[...p.pointList].map(d=>d.id===n.id?A(L(L({},n),f),{valid:e.valid,textAttribute:"",attribute:e.attribute}):d);p.setResult(u),p.setSelectedID(n.id)},ut=(e,n,t,c)=>{var p,o;if(!t||!c)return;c.generateBox(e,n.id),c.render();const{pointCloud2dOperation:f,pointCloudInstance:u}=t,{polygon2d:d}=u.getBoxTopPolygon2DCoordinate(e),x=[...f.polygonList],P=x.find(v=>v.id===n.id);P?(P.pointList=d,P.valid=(p=e.valid)!=null?p:!0):x.push({id:n.id,pointList:d,textAttribute:"",isRect:!0,valid:(o=e.valid)!=null?o:!0}),f.setResultAndSelectedID(x,n.id)},yo=e=>{const n=mt(ht),{topViewInstance:t,sideViewInstance:c,backViewInstance:p,mainViewInstance:o,addPointCloudBox:f,addPointCloudSphere:u,setSelectedIDs:d,selectedIDs:x,pointCloudBoxList:P,pointCloudSphereList:v,hideAttributes:T,setHighlight2DDataList:V,cuboidBoxIn2DView:D,imageSizes:U,history:N,linkageImageNameRectMap:z}=n,{addHistory:j,initHistory:M,pushHistoryUnderUpdatePolygon:I}=go(),{selectedPolygon:Ot}=fo(),{getPointCloudSphereByID:At,updatePointCloudSphere:pt,selectedSphere:Y}=ro(),{currentData:H,config:B}=ao(s=>{const{stepList:i,step:a,imgList:r,imgIndex:l}=s.annotation;return{currentData:r[l],config:lt(uo.getCurrentStepInfo(a,i).config)}}),F=co(),Tt=$(D),Ut=$(z),zt=xt((s,i)=>{const a=Ut.current,r=i.id;return s.filter(g=>{if(!g)return!1;const C=a.get(g.imageName);return C===void 0?!0:Boolean(C.get(r))})},[]),et=s=>{const{enableAutoMap2DRect:i=!1}=B;if(!Tt.current||i){const{mappingImgList:a=[]}=H;po({pointCloudBox:s,mappingImgList:a,imageSizes:U},{prepareRectsFn:zt})}},{selectedBox:k,updateSelectedBox:Nt,updateSelectedBoxes:nt,getPointCloudByID:jt}=so({generateRects:et}),gt=k==null?void 0:k.info;if(!t||!c||!p)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:it}=t,Et=s=>{o==null||o.generateSphere(s),o==null||o.controls.update(),o==null||o.render()},Mt=({newPoint:s,size:i,zoom:a,trackConfigurable:r})=>{var l;const g={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(g,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const C=at(s,i,it,void 0,g);d(s.id);const m=u(C);G(y.Top,s,C,a,m,B),j({newSphereParams:C})},Ft=({polygon:s,size:i,imgList:a,trackConfigurable:r,zoom:l,intelligentFit:g})=>{var C,m,b;const S={attribute:(C=t.toolInstance.defaultAttribute)!=null?C:""};r===!0&&Object.assign(S,{trackID:O.getNextTrackID({imgList:[],extraBoxList:P,extraSphereList:v})});const _=t==null?void 0:t.toolInstance,R=L({},s);let{boxParams:h,newPointList:E}=ct(R,i,it,void 0,S,g);h=F(dt({tool:st.PointCloud,dataList:[h],stepConfig:B,action:"viewUpdateBox"}))[0],g&&(E==null?void 0:E.length)&&(R.pointList=E);const Z=T.includes(R.attribute);et(h);const Q=f(h),q=(m=n==null?void 0:n.polygonList)!=null?m:[];h.subAttribute=oo.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(b=B==null?void 0:B.inputList)!=null?b:[]:[]),t==null||t.updatePolygonList(Q!=null?Q:[],q),Z?d([]):(d(h.id),_.selection.setSelectedIDs(R.id),W({omitView:y.Top,polygon:R,boxParams:h,zoom:l,newPointCloudBoxList:Q}),g&&ut(h,R,t,o)),j({newBoxParams:h})},Ht=s=>{const{boxID:i,imageName:a,width:r,height:l,x:g,y:C}=s,m=P.find(h=>h.id===i);if(!(m==null?void 0:m.rects)||!m.rects.find(h=>h.imageName===a))return;const S=m.rects.map(h=>h.imageName===a?A(L({},h),{width:r,height:l,x:g,y:C}):h),_=A(L({},m),{rects:S}),R=P.map(h=>h.id===i?_:h);return t==null||t.updatePolygonList(R!=null?R:[]),R},Wt=s=>{const{boxID:i,imageName:a}=s,r=P.find(m=>m.id===i);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(m=>m.imageName!==a),g=A(L({},r),{rects:l}),C=P.map(m=>m.id===i?g:m);return t==null||t.updatePolygonList(C!=null?C:[]),C},Zt=({newSelectedBox:s,newPointCloudList:i,newSelectedSphere:a,newSphereList:r})=>{var l;const g=t==null?void 0:t.toolInstance;if(!(x.length===0||!g)){if(s||(k==null?void 0:k.info)){const C=s!=null?s:k==null?void 0:k.info;(l=g==null?void 0:g.selection)==null||l.setSelectedIDs(x[0]);const m=g.selectedPolygon;if(x.length===1&&C){W({omitView:y.Top,polygon:m,boxParams:C,newPointCloudBoxList:i});return}}if((a||Y)&&x.length===1){const C=a!=null?a:Y;g.setSelectedID(x[0]);const m=g.selectedPoint;C&&G(y.Top,m,C,void 0,r,B)}}},ft=(s,i,a)=>{if(gt){let r,l;switch(a){case y.Back:r=vo;break;case y.Side:r=Dt;break;default:r=Dt;break}if(l=r(s,i,gt,c.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(eo(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=A(L({},l),{count:S})}const C=F(dt({tool:st.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],m=l.valid!==C.valid;l=C;const b=Nt(l);return l=b.find(S=>S.id===l.id),W({omitView:m?void 0:a,polygon:s,boxParams:l,newPointCloudBoxList:b}),b}},Ct=(s,i,a)=>{if(Y){let r,l;switch(a){case y.Back:r=Lo;break;case y.Side:r=It;break;default:r=It;break}l=r(s,i,Y);const g=pt(l);return G(a,s,l,void 0,g,B),g}},Gt=(s,i)=>{Ct(s,i,y.Side)},Jt=(s,i)=>{Ct(s,i,y.Back)},Qt=(s,i)=>{ft(s,i,y.Side)},Xt=(s,i)=>{ft(s,i,y.Back)},Yt=(s,i)=>{const a=At(s.id),r=at(s,i,it,a),l=pt(r);G(y.Top,s,r,void 0,l,B)},qt=(s,i)=>{if(Ot){const r=L({},s[0].newPolygon);r.pointList=r.pointList.map(l=>O.transferCanvas2World(l,i)),I(r);return}let a=s.map(({newPolygon:r})=>{const l=jt(r.id),{boxParams:g}=ct(r,i,t.pointCloudInstance,l);return g});if(a=F(dt({tool:st.PointCloud,dataList:a,stepConfig:B,action:"viewUpdateBox"})),a.length===1){const{newPolygon:r}=s[0],l=nt(a);W({polygon:r,boxParams:a[0],newPointCloudBoxList:l})}else{const r=nt(a);r&&n.syncAllViewPointCloudColor(rt.MultiMove,r)}},Kt=s=>{var i,a,r,l,g;if(k){const C=Number(s.widthDefault),m=Number(s.depthDefault),b=Number(s.heightDefault),S=k==null?void 0:k.info.trackID,R=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(K=>(K==null?void 0:K.trackID)===S),h={width:(r=(a=t==null?void 0:t.toolInstance)==null?void 0:a.basicImgInfo)==null?void 0:r.width,height:(g=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:g.height},E=R.pointList.map(K=>O.transferCanvas2World(K,h)),J=w.getModifiedRectangleCoordinates(E,b,C),Z=J[0],Q=J[2],q=w.getLineCenterPoint([Z,Q]),$t=k.info.center.z-k.info.depth/2,Pt=A(L({},k.info),{center:{x:q.x,y:q.y,z:$t+m/2},width:C,height:b,depth:m,valid:!0}),to=nt([Pt]);W({omitView:y["3D"],polygon:R,boxParams:Pt,newPointCloudBoxList:to})}},G=(s,i,a,r,l,g)=>bt(void 0,null,function*(){const C=H==null?void 0:H.url,m={[y.Side]:()=>{St(a,i,c,C,g)},[y.Back]:()=>{p&&_t(a,i,p,C,g)},[y.Top]:()=>{kt(a,i,t,o)}};Object.keys(m).forEach(b=>{b!==s&&m[b]()}),r&&(o==null||o.updateCameraZoom(r)),Et(a)}),W=(s,i=rt.Default)=>{const{omitView:a,polygon:r,boxParams:l,zoom:g,newPointCloudBoxList:C}=s,m=H==null?void 0:H.url;C&&n.syncAllViewPointCloudColor(i,C);const b={[y.Side]:()=>{Rt(l,r,c,m)},[y.Back]:()=>{p&&Vt(l,r,p,m)},[y.Top]:()=>{ut(l,r,t,o)}};Object.keys(b).forEach(S=>{S!==a&&b[S]()}),g&&(o==null||o.updateCameraZoom(g))};return{topViewAddSphere:Mt,topViewAddBox:Ft,topViewSelectedChanged:Zt,topViewUpdatePoint:Yt,sideViewUpdatePoint:Gt,backViewUpdatePoint:Jt,topViewUpdateBox:qt,sideViewUpdateBox:Qt,backViewUpdateBox:Xt,syncPointCloudViews:W,syncPointCloudPoint:G,pointCloudBoxListUpdated:s=>{t.updatePolygonList(s),o==null||o.generateBoxes(s)},initPointCloud3d:s=>{if(!o)return;const i=O.getDefaultOrthographicParams(s);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...s)=>bt(void 0,[...s],function*(i=H){var a,r,l,g,C,m,b,S;if(!(i==null?void 0:i.url)||!o)return;V([]),Lt(F,!0),vt(F,!0),(a=e==null?void 0:e.setResourceLoading)==null||a.call(e,!0),yield o.loadPCDFile(i.url,(r=B==null?void 0:B.radius)!=null?r:ot),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let _=[],R=[],h=[],E=[];o.updateTopCamera();const J=(g=(l=lt(i.result))==null?void 0:l.valid)!=null?g:!0;if(n.setPointCloudValid(J),(C=n.sideViewInstance)==null||C.clearAllData(),(m=n.backViewInstance)==null||m.clearAllData(),i.result){if(_=O.getBoxParamsFromResultList(i.result),(_==null?void 0:_.length)>0&&i.isPreResult&&(B==null?void 0:B.lowerLimitPointsNumInBox)>0){_=yield o==null?void 0:o.filterPreResult(i.url,B,_);const Z=lt(i.result);Z[no].result=_,i.result=JSON.stringify(Z),n.setPointCloudResult(_)}h=O.getPolygonListFromResultList(i.result),R=O.getLineListFromResultList(i.result),E=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(b=B==null?void 0:B.radius)!=null?b:ot}),o==null||o.generateBoxes(_),o==null||o.generateSpheres(E),yield n.syncAllViewPointCloudColor(rt.Default,_,[])}M({pointCloudBoxList:_,polygonList:h,lineList:R,pointCloudSphereList:E}),Lt(F,!1),vt(F,!1),(S=e==null?void 0:e.setResourceLoading)==null||S.call(e,!1)}),updateViewsByDefaultSize:Kt,generateRects:et,update2DViewRect:Ht,remove2DViewRect:Wt}},Bo=()=>{const{pointCloudBoxList:e,rectList:n,setPointCloudResult:t}=mt(ht),c=$(e),p=$(n);return{syncToPointCloudBoxList:xt(()=>{const f=c.current,u=p.current;if(u.length===0)return null;const d=new Map,x=new Set;if(u.filter(P=>P.extId!==void 0).forEach(P=>{const v=P.extId,T=P.imageName,V=lo(P,["x","y","width","height"]);let D=d.get(v);D||(D=new Map,d.set(v,D)),D.set(T,V),x.add(v)}),d.size){const P=f.map(v=>{var T;const V=v.id;if(x.has(V)){const D=L({},v);return(T=D.rects)==null||T.forEach(U=>{var N;const z=U.imageName;Object.assign(U,(N=d.get(V))==null?void 0:N.get(z))}),D}return v});return t(P),P}return null},[])}};export{_t as syncBackViewByPoint,St as syncSideViewByPoint,kt as syncTopViewByPoint,Vt as synchronizeBackView,Rt as synchronizeSideView,ut as synchronizeTopView,at as topViewPoint2PointCloud,ct as topViewPolygon2PointCloud,yo as usePointCloudViews,Bo as useSyncRectPositionDimensionToPointCloudList};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useContext as w}from"react";import{useDispatch as D}from"../../../store/ctx.js";import{useSingleBox as b}from"./useSingleBox.js";import{PointCloudContext as T}from"../PointCloudContext.js";import{EPointCloudName as R}from"@labelbee/lb-annotation";import{PreDataProcess as E}from"../../../store/annotation/actionCreators.js";import{usePointCloudViews as H}from"./usePointCloudViews.js";import{useSphere as L}from"./useSphere.js";import{useHistory as _}from"./useHistory.js";import{EPointCloudBoxRenderTrigger as f}from"../../../utils/ToolPointCloudBoxRenderHelper.js";const P={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},k=(v,a)=>{const r=w(T),{topViewInstance:d,selectedIDs:e,pointCloudBoxList:l,mainViewInstance:c,selectedID:g}=r,h=D(),{selectedSphere:p}=L(),{syncPointCloudViews:C,syncPointCloudPoint:m,generateRects:V}=H({setResourceLoading:v}),{selectedBox:u,updateSelectedBox:j}=b({generateRects:V}),{pushHistoryWithList:x}=_(),y=({newSelectedSphere:n,newSphereList:o})=>{const t=d==null?void 0:d.toolInstance;if((n||p)&&e.length===1){const i=n!=null?n:p;t.setSelectedID(e[0]);const s=t.selectedPoint;i&&(m==null||m(P.Top,s,i,void 0,o,a))}},I=({trigger:n,newSelectedBox:o})=>{const t=d==null?void 0:d.toolInstance;if(!(e.length===0||!t)&&(o||(u==null?void 0:u.info))){const i=o!=null?o:u==null?void 0:u.info,s=o;if(i){C==null||C({omitView:P.Top,polygon:s,boxParams:i},n);return}}};return{updatePointCloudColor:n=>{if(l.forEach(o=>{var t,i,s;if(o&&e.includes(o.id)){o.attribute=n;const S=h(E({tool:R.PointCloud,dataList:[o],stepConfig:a,action:"viewUpdateBox"}));o.valid=S[0].valid,j(o),(s=(i=(t=r==null?void 0:r.topViewInstance)==null?void 0:t.pointCloud2dOperation)==null?void 0:i.setPolygonValidAndRender)==null||s.call(i,o.id,!0,o.valid),y({})}}),c){const o=e&&e.length>1?f.MulitSelect:f.Single;r.syncAllViewPointCloudColor(o,l),l.forEach(t=>{I({trigger:o,newSelectedBox:t})}),c.generateBoxes(l)}g||x({pointCloudBoxList:l})}}};export{k as useUpdatePointCloudColor};
|
package/es/index.css
CHANGED
|
@@ -8,13 +8,9 @@
|
|
|
8
8
|
}
|
|
9
9
|
.index-module_imgView__wmxDk .index-module_item__-80YI {
|
|
10
10
|
margin: 0px 40px 40px 0px;
|
|
11
|
-
width: 400px;
|
|
12
11
|
display: flex;
|
|
13
|
-
height: 300px;
|
|
14
12
|
}
|
|
15
13
|
.index-module_imgView__wmxDk .index-module_item__-80YI .index-module_image__V49oW {
|
|
16
|
-
height: 260px;
|
|
17
|
-
min-width: 300px;
|
|
18
14
|
flex: 1;
|
|
19
15
|
background: #E9EBF1;
|
|
20
16
|
display: flex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCuboidFromPointCloudBox as l}from"@labelbee/lb-annotation";var i;(function(t){t.Default="Default",t.UndoRedo="UndoRedo",t.ClearAll="ClearAll",t.Single="Single",t.SingleDelete="SingleDelete",t.SingleToggleValid="SingleToggleValid",t.SingleRotate="SingleRotate",t.MultiPaste="MultiPaste",t.MultiMove="MultiMove"})(i||(i={}));var d;(function(t){t.ChangeAttribute="ChangeAttribute",t.Move="Move",t.ChangeDepth="ChangeDepth",t.ChangeSize="ChangeSize",t.ToggleValid="ToggleValid"})(d||(d={}));const
|
|
1
|
+
import{getCuboidFromPointCloudBox as l}from"@labelbee/lb-annotation";var i;(function(t){t.Default="Default",t.UndoRedo="UndoRedo",t.ClearAll="ClearAll",t.Single="Single",t.SingleDelete="SingleDelete",t.SingleToggleValid="SingleToggleValid",t.SingleRotate="SingleRotate",t.MultiPaste="MultiPaste",t.MultiMove="MultiMove",t.MulitSelect="MulitSelect"})(i||(i={}));var d;(function(t){t.ChangeAttribute="ChangeAttribute",t.Move="Move",t.ChangeDepth="ChangeDepth",t.ChangeSize="ChangeSize",t.ToggleValid="ToggleValid"})(d||(d={}));const A=(t,n)=>{const o=u(t).concat(u(n));for(const e of o){const s=g(t,e),r=g(n,e);if(!y(s,r))return!1}return!0},u=t=>{const n=[];for(let o=0;o<t.length;o++){const e=t[o],s=t[(o+1)%t.length],r={x:s.x-e.x,y:s.y-e.y},c={x:-r.y,y:r.x};n.push(c)}return n},g=(t,n)=>{let o=h(t[0],n),e=o;for(const s of t){const r=h(s,n);r<o&&(o=r),r>e&&(e=r)}return{min:o,max:e}},y=(t,n)=>!(t.max<n.min||n.max<t.min),h=(t,n)=>t.x*n.x+t.y*n.y,M=(t,n)=>{const o=[];return n.forEach(e=>{const{polygonPointList:s}=l(e);A(t,s)&&o.push(e.id)}),o},S=(t,n)=>{const o=t.map(s=>s.id),e=n.map(s=>s.id);return o.find(s=>!e.includes(s))||""},v=(t,n)=>{const o=t.map(e=>e.id);return n.find(e=>!o.includes(e.id))},x=(t,n)=>t.find(e=>{const s=n.find(r=>r.id===e.id);return s&&s.valid!==e.valid}),B=(t,n)=>t.find(e=>{const s=n.find(r=>r.id===e.id);return s&&s.rotation!==e.rotation}),f=(t,n)=>{const{polygonPointList:o}=l(t);return{ids:M(o,n.filter(s=>s.id!==t.id)),rect:o}},D=(t,n)=>{const o=(e,s)=>e.attribute===s.attribute&&e.center.x===s.center.x&&e.center.y===s.center.y&&e.depth===s.depth&&e.width===s.width&&e.height===s.height;for(const e of t){const s=n.find(r=>r.id===e.id);if(s&&!o(e,s)){let r;if(s.attribute!==e.attribute?r=d.ChangeAttribute:s.center.x!==e.center.x||s.center.y!==e.center.y?r=d.Move:s.depth!==e.depth?r=d.ChangeDepth:(s.width!==e.width||s.height!==e.height)&&(r=d.ChangeSize),r!==void 0)return{modifiedType:r,box:e}}}},C=(t,n,o)=>{try{switch(t){case i.Single:if(n.length>o.length){const e=S(n,o);return e?{modifiedBoxIds:[e],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}else{const e=[],s=[],r=D(n,o);if(r&&(e.push(r.box.id),r.modifiedType===d.ChangeSize||r.modifiedType===d.Move)){const c=o.find(I=>I.id===r.box.id),{ids:a,rect:m}=f(c,n);e.push(...a),s.push(m)}return{modifiedBoxIds:e,resetAreas:s}}case i.SingleDelete:if(n.length<o.length){const e=v(n,o);if(e){const r=[l(e).polygonPointList],c=[];if(n.length>1){const{ids:a}=f(e,n);a.length&&c.push(...a)}return{modifiedBoxIds:c,resetAreas:r}}return{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case i.SingleRotate:if(B(n,o)){const e=B(n,o);if(e){const s=o.find(a=>a.id===e.id),{ids:r,rect:c}=f(s,n);return{modifiedBoxIds:[e.id,...r],resetAreas:[c]}}}return{modifiedBoxIds:[],resetAreas:[]};case i.SingleToggleValid:if(x(n,o)){const e=x(n,o);return e?{modifiedBoxIds:[e.id],resetAreas:[]}:{modifiedBoxIds:[],resetAreas:[]}}return{modifiedBoxIds:[],resetAreas:[]};case i.MulitSelect:return{modifiedBoxIds:k(n,o),resetAreas:[]};case i.MultiPaste:case i.MultiMove:case i.Default:case i.UndoRedo:case i.ClearAll:default:return{modifiedBoxIds:[],resetAreas:[]}}}catch(e){return console.error("calcResetAreasAndBoxIds error:",e),{modifiedBoxIds:[],resetAreas:[]}}},p=(t,n)=>{if(t===n)return!0;if(typeof t!="object"||typeof n!="object"||t===null||n===null)return!1;const o=Object.keys(t),e=Object.keys(n);if(o.length!==e.length)return!1;for(const s of o)if(!p(t[s],n[s]))return!1;return!0},k=(t,n)=>{const o=new Map;for(const e of n)o.set(e.id,e);return t.filter(e=>{const s=o.get(e.id);return!s||!p(e,s)}).map(e=>e.id)};export{i as EPointCloudBoxRenderTrigger,d as EPointCloudBoxSingleModifiedType,C as calcResetAreasAndBoxIds};
|
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.128",
|
|
4
4
|
"description": "Provide a complete library of annotation components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"es": "./es/index.js",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
"redux-actions": "^2.6.5",
|
|
68
68
|
"redux-thunk": "^2.3.0",
|
|
69
69
|
"rehype-katex": "^6.0.3",
|
|
70
|
+
"rehype-raw": "^7.0.0",
|
|
70
71
|
"remark-gfm": "^3.0.1",
|
|
71
72
|
"remark-math": "^5.1.1",
|
|
72
73
|
"resize-observer-polyfill": "^1.5.1",
|