@labelbee/lb-components 1.24.0-alpha.22 → 1.24.0-alpha.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
- package/dist/components/pointCloudView/PointCloudContext.js +1 -1
- package/dist/components/pointCloudView/PointCloudTopView.js +1 -1
- package/dist/components/pointCloudView/hooks/useHighlight.js +1 -1
- package/es/components/pointCloudView/PointCloud3DView.js +1 -1
- package/es/components/pointCloudView/PointCloudContext.js +1 -1
- package/es/components/pointCloudView/PointCloudTopView.js +1 -1
- package/es/components/pointCloudView/hooks/useHighlight.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),classNames=require("classnames"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),index=require("../../utils/index.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index$1=require("./components/PointCloudSizeSlider/index.js"),index$2=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons"),useToolStyle=require("../../hooks/useToolStyle.js"),usePointCloudAttribute=require("./hooks/usePointCloudAttribute.js");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,i,a)=>i in n?__defProp(n,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[i]=a,__spreadValues=(n,i)=>{for(var a in i||(i={}))__hasOwnProp.call(i,a)&&__defNormalProp(n,a,i[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(i))__propIsEnum.call(i,a)&&__defNormalProp(n,a,i[a]);return n};const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:n})=>{const{isActive:i,setTarget3DView:a}=React.useContext(PointCloud3DContext),m=d=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",d)]:!0,active:i});return React__default.default.createElement("span",{onClick:()=>{a(lbUtils.EPerspectiveView[n])},className:m(n.toLocaleLowerCase())})},PointCloud3DSideBar=({isEnlarge:n})=>{const{reset3DView:i,followTopView:a}=React.useContext(PointCloud3DContext),{t:m}=reactI18next.useTranslation(),d=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Top"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Front"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Left"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Back"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Right"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"LFT"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"RBT"})),e=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Tooltip,{title:m("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{a()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{i()},className:dom.getClassName("point-cloud-3d-view","reset")}));return n?React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebarZoom")},e,d):React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},d,e)},PointCloud3D=({currentData:n,config:i,highlightAttribute:a,setResourceLoading:m})=>{var d;const e=React.useContext(PointCloudContext.PointCloudContext),{setIsLargeStatus:P}=e,[y,B]=React.useState(!0),[f,V]=React.useState(!1),v=React.useRef(null),{initPointCloud3d:x,generateRects:L}=usePointCloudViews.usePointCloudViews(),p=useSize(v),{t:g}=reactI18next.useTranslation(),{value:I}=useToolStyle.useToolStyleContext(),{hiddenText:h}=I||{},{updatePointCloudAttribute:N}=usePointCloudAttribute.usePointCloudAttribute(m,i),{updateSelectedBox:q}=useSingleBox.useSingleBox({generateRects:L});React.useEffect(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(h,e.pointCloudBoxList)},[I]),React.useEffect(()=>{!e.mainViewInstance||x==null||x(p)},[p]);const{selectedBox:c}=useSingleBox.useSingleBox(),{selectedSphere:w}=useSphere.useSphere(),[j,_]=React.useState(!0),E=t=>{var o,l;const s=c==null?void 0:c.info;if(s){const r=__spreadValues({},s.center);r.x=r.x-.01,r.z=1e3;const u=t===lbUtils.EPerspectiveView.Top;(o=e.mainViewInstance)==null||o.updateCameraByBox(s,t,u?r:void 0)}w&&((l=e.mainViewInstance)==null||l.updateCameraBySphere(w,t))},D=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},R=()=>{var t,o;const l=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;l&&((o=e.mainViewInstance)==null||o.applyCameraTarget(l))};React.useEffect(()=>{if(v.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&p.width&&(t=new lbAnnotation.PointCloud({container:v.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(p),config:i,hiddenText:h}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:_}),e.setMainViewInstance(t))}},[p,n]),React.useEffect(()=>{var t,o;if(v.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let l=e.mainViewInstance;const s=lbUtils.PointCloudUtils.getRectParamsFromResultList(n.result),r=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),u=r.find(C=>C.id===e.selectedID);u&&((t=e.topViewInstance)==null||t.updatePolygonList(r,void 0),N(u.attribute),q(u),e.setSelectedIDs(u.id)),e.setPointCloudValid((o=index.jsonParser(n.result))==null?void 0:o.valid),e.setPointCloudResult(r),e.setRectList(s),l.generateBoxes(r)}},[n.result,e.mainViewInstance]),React.useEffect(()=>{var t,o,l,s,r,u,C;const b=(t=c==null?void 0:c.info)==null?void 0:t.id;if(!j){_(!0);return}if(b!==void 0){E(lbUtils.EPerspectiveView.Top);const z=(s=(l=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:l.camera.zoom)!=null?s:1;(r=e.mainViewInstance)==null||r.updateCameraZoom(z)}(u=e.mainViewInstance)==null||u.setHighlightColor(b),(C=e.mainViewInstance)==null||C.render()},[(d=c==null?void 0:c.info)==null?void 0:d.id]),React.useEffect(()=>{var t,o,l,s;if(w){E(lbUtils.EPerspectiveView.Top);const r=(l=(o=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:o.camera.zoom)!=null?l:1;(s=e.mainViewInstance)==null||s.updateCameraZoom(r)}},[w]),React.useEffect(()=>(window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S)}),[]);const S=t=>{if(t.keyCode===EKeyCode.Esc){V(!1);return}},T=React.useMemo(()=>({reset3DView:D,setTarget3DView:E,isActive:!!c,followTopView:R}),[c,e.mainViewInstance]);React.useEffect(()=>{var t,o,l;const s=e.pointCloudBoxList.filter(r=>r.attribute===a);(s==null?void 0:s.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(o=e.mainViewInstance)==null||o.highlightBoxes(s)),s.length===0&&((l=e.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[a,e.mainViewInstance]);const k=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:t=>{var o;(o=e.mainViewInstance)==null||o.updatePointSize({customSize:t})}}),React__default.default.createElement("span",{style:{marginRight:8}},g("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:y,onChange:t=>{var o;B(t),(o=e.mainViewInstance)==null||o.setShowDirection(t)}}),f&&React__default.default.createElement(PointCloud3DContext.Provider,{value:T},React__default.default.createElement(PointCloud3DSideBar,{isEnlarge:f})));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-3d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:f}),title:f?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{P(!1),V(!1)}}),g("3DView")):React__default.default.createElement(index$2,{title:g("3DView"),onClick:()=>{P(!0),V(!0)}}),toolbar:k},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},!f&&React__default.default.createElement(PointCloud3DContext.Provider,{value:T},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:v})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
|
|
1
|
+
"use strict";var dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),classNames=require("classnames"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),index=require("../../utils/index.js"),useSingleBox=require("./hooks/useSingleBox.js"),useSphere=require("./hooks/useSphere.js"),antd=require("antd"),useSize=require("../../hooks/useSize.js"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index$1=require("./components/PointCloudSizeSlider/index.js"),index$2=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons"),useToolStyle=require("../../hooks/useToolStyle.js"),usePointCloudAttribute=require("./hooks/usePointCloudAttribute.js");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(n,i,a)=>i in n?__defProp(n,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[i]=a,__spreadValues=(n,i)=>{for(var a in i||(i={}))__hasOwnProp.call(i,a)&&__defNormalProp(n,a,i[a]);if(__getOwnPropSymbols)for(var a of __getOwnPropSymbols(i))__propIsEnum.call(i,a)&&__defNormalProp(n,a,i[a]);return n};const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:n})=>{const{isActive:i,setTarget3DView:a}=React.useContext(PointCloud3DContext),m=d=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",d)]:!0,active:i});return React__default.default.createElement("span",{onClick:()=>{a(lbUtils.EPerspectiveView[n])},className:m(n.toLocaleLowerCase())})},PointCloud3DSideBar=({isEnlarge:n})=>{const{reset3DView:i,followTopView:a}=React.useContext(PointCloud3DContext),{t:m}=reactI18next.useTranslation(),d=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Top"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Front"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Left"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Back"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"Right"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"LFT"}),React__default.default.createElement(PointCloudViewIcon,{perspectiveView:"RBT"})),e=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Tooltip,{title:m("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{a()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{i()},className:dom.getClassName("point-cloud-3d-view","reset")}));return n?React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebarZoom")},e,d):React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},d,e)},PointCloud3D=({currentData:n,config:i,highlightAttribute:a,setResourceLoading:m})=>{var d;const e=React.useContext(PointCloudContext.PointCloudContext),{setIsLargeStatus:P}=e,[y,B]=React.useState(!0),[f,V]=React.useState(!1),v=React.useRef(null),{initPointCloud3d:x,generateRects:L}=usePointCloudViews.usePointCloudViews(),p=useSize(v),{t:g}=reactI18next.useTranslation(),{value:I}=useToolStyle.useToolStyleContext(),{hiddenText:h}=I||{},{updatePointCloudAttribute:N}=usePointCloudAttribute.usePointCloudAttribute(m,i),{updateSelectedBox:q}=useSingleBox.useSingleBox({generateRects:L});React.useEffect(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(h,e.pointCloudBoxList)},[I]),React.useEffect(()=>{!e.mainViewInstance||x==null||x(p)},[p]);const{selectedBox:c}=useSingleBox.useSingleBox(),{selectedSphere:w}=useSphere.useSphere(),[j,_]=React.useState(!0),E=t=>{var o,l;const s=c==null?void 0:c.info;if(s){const r=__spreadValues({},s.center);r.x=r.x-.01,r.z=1e3;const u=t===lbUtils.EPerspectiveView.Top;(o=e.mainViewInstance)==null||o.updateCameraByBox(s,t,u?r:void 0)}w&&((l=e.mainViewInstance)==null||l.updateCameraBySphere(w,t))},D=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},R=()=>{var t,o;const l=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;l&&((o=e.mainViewInstance)==null||o.applyCameraTarget(l))};React.useEffect(()=>{if(v.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&p.width&&(t=new lbAnnotation.PointCloud({container:v.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(p),config:i,hiddenText:h,view:"3DView"}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:_}),e.setMainViewInstance(t))}},[p,n]),React.useEffect(()=>{var t,o;if(v.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let l=e.mainViewInstance;const s=lbUtils.PointCloudUtils.getRectParamsFromResultList(n.result),r=lbUtils.PointCloudUtils.getBoxParamsFromResultList(n.result),u=r.find(C=>C.id===e.selectedID);u&&((t=e.topViewInstance)==null||t.updatePolygonList(r,void 0),N(u.attribute),q(u),e.setSelectedIDs(u.id)),e.setPointCloudValid((o=index.jsonParser(n.result))==null?void 0:o.valid),e.setPointCloudResult(r),e.setRectList(s),l.generateBoxes(r)}},[n.result,e.mainViewInstance]),React.useEffect(()=>{var t,o,l,s,r,u,C;const b=(t=c==null?void 0:c.info)==null?void 0:t.id;if(!j){_(!0);return}if(b!==void 0){E(lbUtils.EPerspectiveView.Top);const z=(s=(l=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null?void 0:l.camera.zoom)!=null?s:1;(r=e.mainViewInstance)==null||r.updateCameraZoom(z)}(u=e.mainViewInstance)==null||u.setHighlightColor(b),(C=e.mainViewInstance)==null||C.render()},[(d=c==null?void 0:c.info)==null?void 0:d.id]),React.useEffect(()=>{var t,o,l,s;if(w){E(lbUtils.EPerspectiveView.Top);const r=(l=(o=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:o.camera.zoom)!=null?l:1;(s=e.mainViewInstance)==null||s.updateCameraZoom(r)}},[w]),React.useEffect(()=>(window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S)}),[]);const S=t=>{if(t.keyCode===EKeyCode.Esc){V(!1);return}},T=React.useMemo(()=>({reset3DView:D,setTarget3DView:E,isActive:!!c,followTopView:R}),[c,e.mainViewInstance]);React.useEffect(()=>{var t,o,l;const s=e.pointCloudBoxList.filter(r=>r.attribute===a);(s==null?void 0:s.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(o=e.mainViewInstance)==null||o.highlightBoxes(s)),s.length===0&&((l=e.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[a,e.mainViewInstance]);const k=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:t=>{var o;(o=e.mainViewInstance)==null||o.updatePointSize({customSize:t})}}),React__default.default.createElement("span",{style:{marginRight:8}},g("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:y,onChange:t=>{var o;B(t),(o=e.mainViewInstance)==null||o.setShowDirection(t)}}),f&&React__default.default.createElement(PointCloud3DContext.Provider,{value:T},React__default.default.createElement(PointCloud3DSideBar,{isEnlarge:f})));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-3d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:f}),title:f?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{P(!1),V(!1)}}),g("3DView")):React__default.default.createElement(index$2,{title:g("3DView"),onClick:()=>{P(!0),V(!0)}}),toolbar:k},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},!f&&React__default.default.createElement(PointCloud3DContext.Provider,{value:T},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:v})))};var PointCloud3DView=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud3D);module.exports=PointCloud3DView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),React=require("react"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),actionCreators=require("../../store/annotation/actionCreators.js"),index=require("../../store/annotatedBox/index.js"),_=require("lodash"),map=require("./utils/map.js"),useTimeoutFunc=require("./hooks/useTimeoutFunc.js"),useWindowKeydownListener=require("./hooks/useWindowKeydownListener.js");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}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=(r,s,c)=>s in r?__defProp(r,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):r[s]=c,__spreadValues=(r,s)=>{for(var c in s||(s={}))__hasOwnProp.call(s,c)&&__defNormalProp(r,c,s[c]);if(__getOwnPropSymbols)for(var c of __getOwnPropSymbols(s))__propIsEnum.call(s,c)&&__defNormalProp(r,c,s[c]);return r},__spreadProps=(r,s)=>__defProps(r,__getOwnPropDescs(s)),__async=(r,s,c)=>new Promise((x,B)=>{var D=u=>{try{P(c.next(u))}catch(R){B(R)}},E=u=>{try{P(c.throw(u))}catch(R){B(R)}},P=u=>u.done?x(u.value):Promise.resolve(u.value).then(D,E);P((c=c.apply(r,s)).next())});const pickRectObject=r=>___default.default.pick(r,["id","attribute","width","height","x","y","imageName"]),PointCloudContext=React__default.default.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,visibleBatchSetValid:!1,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setBatchSetValidModal:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new lbAnnotation.ActionsHistory,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:lbAnnotation.EToolName.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:lbUtils.EPointCloudPattern.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:r=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:r=>!1,removeRectBySpecifyId:(r,s,c)=>!1,removeRectByPointCloudBoxId:r=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:useWindowKeydownListener.getEmptyUseWindowKeydownListener(),isLargeStatus:!1,setIsLargeStatus:()=>{}}),PointCloudProvider=({children:r})=>{const[s,c]=React.useState([]),[x,B]=React.useState([]),[D,E]=React.useState([]),[P,u]=React.useState([]),[R,Be]=React.useState([]),[v,K]=React.useState([]),[A,O]=React.useState([]),[U,De]=React.useState(!0),[Z,Ae]=React.useState(2),[J,_e]=React.useState(!0),[Q,Ve]=React.useState(1),[f,X]=React.useState(),[Y,$]=React.useState(),[ee,te]=React.useState(),[g,oe]=React.useState(),[ne,Ne]=React.useState(""),[j,He]=React.useState(lbAnnotation.EToolName.Rect),F=React.useRef(new lbAnnotation.ActionsHistory).current,[h,q]=React.useState([]),[ie,Me]=React.useState(""),[T,ke]=React.useState(lbUtils.EPointCloudPattern.Detection),[L,se]=React.useState(void 0),[z,Ee]=React.useState([]),[W,Oe]=React.useState([]),[re,je]=React.useState(!1),[ae,le]=React.useState(!1),p=index(),[de,Fe]=React.useState(!1),[ce,qe]=React.useState({}),Te=ctx.useDispatch(),ze=o=>{const{imgNode:n,path:t}=o;t&&n&&qe(l=>__spreadProps(__spreadValues({},l),{[t]:{width:n.width,height:n.height}}))},ue=React.useMemo(()=>v.length===1?v[0]:"",[v]),ge=useWindowKeydownListener.default(),N=React.useCallback((o,n,t="extId")=>{const l=t||"id",d=new Set(n);return u(a=>{let I=!1;const S=a.filter(M=>{const G=M[l],k=d.has(G)?M.imageName!==o:!0;return k||(I=!0),k});return I?S:a}),!0},[]),fe=React.useCallback(o=>{const n=s.map(t=>t.id);return N(o,n,"extId")},[s,N]),he=React.useCallback(o=>{if(!o)return!1;const n=s.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:l,attribute:d,trackID:a}=t,I=t.rects.find(S=>S.imageName===o);if(I){const S=___default.default.pick(I,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},S),{id:lbAnnotation.uuid(),attribute:d,order:a,extId:l,lineDash:[]})}return null}).filter(t=>t!==null);return n.length?(u(t=>{const l=new Set(t.filter(a=>o===a.imageName).map(a=>a.extId)),d=n.filter(a=>l.has(a.extId)===!1);return d.length?[...t,...d]:t}),!0):!1},[s]),pe=React.useMemo(()=>s.filter(n=>Array.isArray(n.rects)&&n.rects.length>0).reduce((n,t)=>{var l;return(l=t.rects)==null||l.forEach(d=>{const{imageName:a}=d;if(!a){console.warn("Missing image name"),console.trace(d,t);return}map.addMapIndirectWeakSetItem(n,a,t.id,t)}),n},new Map),[s]),me=React.useCallback(o=>{u(n=>o(n,pickRectObject))},[pickRectObject]),ve=React.useMemo(()=>P.filter(o=>o.extId!==void 0&&o.id!==void 0).reduce((o,n)=>{const t=n.imageName;return t?(map.addMapIndirectWeakSetItem(o,t,n.extId,n),o):(console.warn("missing image name"),console.log(n,P),o)},new Map),[P]),{fn:We}=useTimeoutFunc.default(o=>{K(n=>{const t=o,l=new Set(t);let d=!1;const a=n.filter(I=>{const S=l.has(I);return S||(d=!0),S});return d?a:n})},200),Se=React.useCallback(o=>{const n=o.map(t=>t.id);c(o),We(n)},[]),H=React.useMemo(()=>{const o=s.find(e=>e.id===ue),n=e=>{const i=s.concat(e);return Se(i),i},t=e=>{const i=x.concat(e);return B(i),i},l=e=>{De(e!==!1)},d=e=>{Fe(e)},a=e=>{let i=[];e===void 0||e===""?i=[]:typeof e=="string"?i=[e]:Array.isArray(e)&&(i=e.length>1?Array.from(new Set(e)):e),K(i)},I=e=>{v.includes(e)?a(v.filter(i=>i!==e)):a([...v,e])},S=e=>{const i=pickRectObject(e);u(m=>[...m,i])},M=(e,i=!1)=>{const m=pickRectObject(e);u(C=>C.map(w=>w.id===e.id?i?__spreadValues(__spreadValues({},w),m):m:w))},G=e=>{u(i=>i.filter(m=>!e.find(C=>C.id===m.id)))},k=e=>{A.includes(e)?O([]):O([e])},Ke=()=>{if(j===lbAnnotation.EToolName.Rect){const e=s.map(i=>i.id);a(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},Ue=e=>{a(s.filter(i=>i.attribute===e).map(i=>i.id))},Pe=s.filter(e=>!h.includes(e.attribute)),Ie=x.filter(e=>!h.includes(e.attribute)),Ce=R.filter(e=>e.attribute&&!h.includes(e.attribute)),Ze=e=>{if(h.includes(e))q(h.filter(i=>i!==e));else{const i=h.concat(e);q(i)}},Je=(e=Pe,i=D,m=Ie,C=Ce,w=z)=>{var V;g==null||g.clearAllBox(),g==null||g.clearAllSphere(),f==null||f.updatePolygonList(e,i),f==null||f.updatePointList(m),f==null||f.updateLineList(C),g==null||g.generateBoxes(e),g==null||g.generateSpheres(m),(V=L==null?void 0:L.store)==null||V.updateCurrentSegment(w),we(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},Qe=()=>{X(void 0),$(void 0),te(void 0),oe(void 0)},we=(e,i,m)=>__async(void 0,null,function*(){var C,w,V;if(!g)return;const be=g.pointCloudObject;if(!be)return;let ye=[],Re=[];try{if(i&&F.record.length){const{record:b,recordIndex:y}=F;let xe=y;y>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&i.length===((C=b[y])==null?void 0:C.pointCloudBoxList.length))&&(xe=y-1);let Xe=(w=b[xe])==null?void 0:w.pointCloudBoxList;const Le=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,i,Xe);ye=Le.modifiedBoxIds,Re=Le.resetAreas}}catch(b){console.error("call calcResetAreasAndBoxIds error",b)}try{const b=yield g.getHighlightIndexByMappingImgList({mappingImgList:m!=null?m:W,points:be.geometry.attributes.position.array}),y=yield g==null?void 0:g.highlightOriginPointCloud(i,b,{modifiedBoxIds:ye,resetAreas:Re});return y&&((V=f==null?void 0:f.pointCloudInstance)==null||V.updateColor(y)),y}catch(b){console.error("call highlightOriginPointCloud error",b)}});return{selectedID:ue,pointCloudBoxList:s,pointCloudSphereList:x,displayPointCloudList:Pe,displaySphereList:Ie,displayLineList:Ce,selectedIDs:v,setPointCloudResult:Se,setSelectedIDs:a,addPointCloudBox:n,addPointCloudSphere:t,setPointCloudSphereList:B,valid:U,visibleBatchSetValid:de,selectedPointCloudBox:o,setPointCloudValid:l,setBatchSetValidModal:d,addSelectedID:I,addHighlightID:k,selectedAllBoxes:Ke,topViewInstance:f,setTopViewInstance:X,sideViewInstance:Y,setSideViewInstance:$,backViewInstance:ee,setBackViewInstance:te,mainViewInstance:g,setMainViewInstance:oe,polygonList:D,setPolygonList:E,rectList:P,setRectList:u,addRectIn2DView:S,removeRectIn2DView:G,updateRectIn2DView:M,lineList:R,setLineList:Be,zoom:Q,setZoom:Ve,history:F,toggleAttributesVisible:Ze,hideAttributes:h,setHideAttributes:q,reRender:Je,attrPanelLayout:ie,setAttrPanelLayout:Me,syncAllViewPointCloudColor:we,defaultAttribute:ne,setDefaultAttribute:Ne,pointCloudPattern:j,setPointCloudPattern:He,selectSpecAttr:Ue,globalPattern:T,setGlobalPattern:e=>{T!==e&&(Te(actionCreators.ChangeSave),ke(e),e===lbUtils.EPointCloudPattern.Detection&&se(void 0))},ptSegmentInstance:L,setPtSegmentInstance:se,segmentation:z,setSegmentation:Ee,clearAllDetectionInstance:Qe,highlight2DDataList:W,setHighlight2DDataList:Oe,highlight2DLoading:re,setHighlight2DLoading:je,cuboidBoxIn2DView:J,setCuboidBoxIn2DView:_e,imageSizes:ce,cacheImageNodeSize:ze,highlightIDs:A,setHighlightIDs:O,removeRectByPointCloudBoxId:fe,removeRectBySpecifyId:N,addRectFromPointCloudBoxByImageName:he,rectRotateSensitivity:Z,setRectRotateSensitivity:Ae,imageNamePointCloudBoxMap:pe,linkageImageNameRectMap:ve,updateRectListByReducer:me,windowKeydownListenerHook:ge,isLargeStatus:ae,setIsLargeStatus:le}},[U,de,v,s,x,D,R,P,f,Y,ee,g,Q,h,ie,ne,j,T,L,z,W,re,J,ce,A,fe,N,he,Z,pe,ve,me,ge,ae,le]);React.useEffect(()=>{var o,n,t;(o=p==null?void 0:p.setPointCloudBoxList)==null||o.call(p,s),(n=p==null?void 0:p.setHighlightIDs)==null||n.call(p,A),(t=p==null?void 0:p.setSelectedIDs)==null||t.call(p,v)},[s,v,A]),React.useEffect(()=>{var o;(o=p==null?void 0:p.setPtCtx)==null||o.call(p,H)},[H]);const Ge=()=>{const o=s.filter(d=>h.includes(d.attribute)),{setSelectedIDs:n,reRender:t}=H,l=o.map(d=>d.id);l.length>0&&n(v.filter(d=>!l.includes(d))),t()};return React.useEffect(()=>{var o,n,t,l;Ge(),(n=(o=f==null?void 0:f.toolInstance)==null?void 0:o.setHiddenAttributes)==null||n.call(o,h),(l=(t=L==null?void 0:L.store)==null?void 0:t.setHiddenAttributes)==null||l.call(t,h)},[h]),React__default.default.createElement(PointCloudContext.Provider,{value:H},r)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),React=require("react"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),actionCreators=require("../../store/annotation/actionCreators.js"),index=require("../../store/annotatedBox/index.js"),_=require("lodash"),map=require("./utils/map.js"),useTimeoutFunc=require("./hooks/useTimeoutFunc.js"),useWindowKeydownListener=require("./hooks/useWindowKeydownListener.js");function _interopDefaultLegacy(r){return r&&typeof r=="object"&&"default"in r?r:{default:r}}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=(r,s,c)=>s in r?__defProp(r,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):r[s]=c,__spreadValues=(r,s)=>{for(var c in s||(s={}))__hasOwnProp.call(s,c)&&__defNormalProp(r,c,s[c]);if(__getOwnPropSymbols)for(var c of __getOwnPropSymbols(s))__propIsEnum.call(s,c)&&__defNormalProp(r,c,s[c]);return r},__spreadProps=(r,s)=>__defProps(r,__getOwnPropDescs(s)),__async=(r,s,c)=>new Promise((x,B)=>{var A=u=>{try{P(c.next(u))}catch(y){B(y)}},O=u=>{try{P(c.throw(u))}catch(y){B(y)}},P=u=>u.done?x(u.value):Promise.resolve(u.value).then(A,O);P((c=c.apply(r,s)).next())});const pickRectObject=r=>___default.default.pick(r,["id","attribute","width","height","x","y","imageName"]),PointCloudContext=React__default.default.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,visibleBatchSetValid:!1,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setBatchSetValidModal:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new lbAnnotation.ActionsHistory,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:lbAnnotation.EToolName.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:lbUtils.EPointCloudPattern.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:r=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:r=>!1,removeRectBySpecifyId:(r,s,c)=>!1,removeRectByPointCloudBoxId:r=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:useWindowKeydownListener.getEmptyUseWindowKeydownListener(),isLargeStatus:!1,setIsLargeStatus:()=>{}}),PointCloudProvider=({children:r})=>{const[s,c]=React.useState([]),[x,B]=React.useState([]),[A,O]=React.useState([]),[P,u]=React.useState([]),[y,Be]=React.useState([]),[v,Z]=React.useState([]),[V,j]=React.useState([]),[J,Ae]=React.useState(!0),[Q,_e]=React.useState(2),[X,Ve]=React.useState(!0),[Y,Ne]=React.useState(1),[f,$]=React.useState(),[ee,te]=React.useState(),[oe,ne]=React.useState(),[g,ie]=React.useState(),[se,He]=React.useState(""),[F,Me]=React.useState(lbAnnotation.EToolName.Rect),q=React.useRef(new lbAnnotation.ActionsHistory).current,[h,T]=React.useState([]),[re,ke]=React.useState(""),[z,Ee]=React.useState(lbUtils.EPointCloudPattern.Detection),[L,ae]=React.useState(void 0),[W,Oe]=React.useState([]),[G,je]=React.useState([]),[le,Fe]=React.useState(!1),[de,ce]=React.useState(!1),p=index(),[ue,qe]=React.useState(!1),[ge,Te]=React.useState({}),ze=ctx.useDispatch(),We=o=>{const{imgNode:n,path:t}=o;t&&n&&Te(l=>__spreadProps(__spreadValues({},l),{[t]:{width:n.width,height:n.height}}))},fe=React.useMemo(()=>v.length===1?v[0]:"",[v]),he=useWindowKeydownListener.default(),H=React.useCallback((o,n,t="extId")=>{const l=t||"id",d=new Set(n);return u(a=>{let I=!1;const S=a.filter(k=>{const K=k[l],E=d.has(K)?k.imageName!==o:!0;return E||(I=!0),E});return I?S:a}),!0},[]),pe=React.useCallback(o=>{const n=s.map(t=>t.id);return H(o,n,"extId")},[s,H]),me=React.useCallback(o=>{if(!o)return!1;const n=s.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:l,attribute:d,trackID:a}=t,I=t.rects.find(S=>S.imageName===o);if(I){const S=___default.default.pick(I,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},S),{id:lbAnnotation.uuid(),attribute:d,order:a,extId:l,lineDash:[]})}return null}).filter(t=>t!==null);return n.length?(u(t=>{const l=new Set(t.filter(a=>o===a.imageName).map(a=>a.extId)),d=n.filter(a=>l.has(a.extId)===!1);return d.length?[...t,...d]:t}),!0):!1},[s]),ve=React.useMemo(()=>s.filter(n=>Array.isArray(n.rects)&&n.rects.length>0).reduce((n,t)=>{var l;return(l=t.rects)==null||l.forEach(d=>{const{imageName:a}=d;if(!a){console.warn("Missing image name"),console.trace(d,t);return}map.addMapIndirectWeakSetItem(n,a,t.id,t)}),n},new Map),[s]),Se=React.useCallback(o=>{u(n=>o(n,pickRectObject))},[pickRectObject]),Pe=React.useMemo(()=>P.filter(o=>o.extId!==void 0&&o.id!==void 0).reduce((o,n)=>{const t=n.imageName;return t?(map.addMapIndirectWeakSetItem(o,t,n.extId,n),o):(console.warn("missing image name"),console.log(n,P),o)},new Map),[P]),{fn:Ge}=useTimeoutFunc.default(o=>{Z(n=>{const t=o,l=new Set(t);let d=!1;const a=n.filter(I=>{const S=l.has(I);return S||(d=!0),S});return d?a:n})},200),Ie=React.useCallback(o=>{const n=o.map(t=>t.id);c(o),Ge(n)},[]),M=React.useMemo(()=>{const o=s.find(e=>e.id===fe),n=e=>{const i=s.concat(e);return Ie(i),i},t=e=>{const i=x.concat(e);return B(i),i},l=e=>{Ae(e!==!1)},d=e=>{qe(e)},a=e=>{let i=[];e===void 0||e===""?i=[]:typeof e=="string"?i=[e]:Array.isArray(e)&&(i=e.length>1?Array.from(new Set(e)):e),Z(i)},I=e=>{v.includes(e)?a(v.filter(i=>i!==e)):a([...v,e])},S=e=>{const i=pickRectObject(e);u(m=>[...m,i])},k=(e,i=!1)=>{const m=pickRectObject(e);u(C=>C.map(w=>w.id===e.id?i?__spreadValues(__spreadValues({},w),m):m:w))},K=e=>{u(i=>i.filter(m=>!e.find(C=>C.id===m.id)))},E=e=>{V.includes(e)?j([]):j([e])},Ue=()=>{if(F===lbAnnotation.EToolName.Rect){const e=s.map(i=>i.id);a(e),f==null||f.pointCloud2dOperation.setSelectedIDs(e)}},Ze=e=>{a(s.filter(i=>i.attribute===e).map(i=>i.id))},Ce=s.filter(e=>!h.includes(e.attribute)),we=x.filter(e=>!h.includes(e.attribute)),be=y.filter(e=>e.attribute&&!h.includes(e.attribute)),Je=e=>{if(h.includes(e))T(h.filter(i=>i!==e));else{const i=h.concat(e);T(i)}},Qe=(e=Ce,i=A,m=we,C=be,w=W)=>{var N;g==null||g.clearAllBox(),g==null||g.clearAllSphere(),f==null||f.updatePolygonList(e,i),f==null||f.updatePointList(m),f==null||f.updateLineList(C),g==null||g.generateBoxes(e),g==null||g.generateSpheres(m),(N=L==null?void 0:L.store)==null||N.updateCurrentSegment(w),ye(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,e)},Xe=()=>{$(void 0),te(void 0),ne(void 0),ie(void 0)},ye=(e,i,m)=>__async(void 0,null,function*(){var C,w,N;if(!g)return;const Re=g.pointCloudObject;if(!Re)return;let xe=[],Le=[];try{if(i&&q.record.length){const{record:b,recordIndex:R}=q;let D=R;R>0&&(e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleToggleValid||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.SingleRotate||e===ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single&&i.length===((C=b[R])==null?void 0:C.pointCloudBoxList.length))&&(D=R-1);let U=(w=b[D])==null?void 0:w.pointCloudBoxList;const De=ToolPointCloudBoxRenderHelper.calcResetAreasAndBoxIds(e,i,U);xe=De.modifiedBoxIds,Le=De.resetAreas}}catch(b){console.error("call calcResetAreasAndBoxIds error",b)}try{const b=yield g.getHighlightIndexByMappingImgList({mappingImgList:m!=null?m:G,points:Re.geometry.attributes.position.array}),R=yield g==null?void 0:g.highlightOriginPointCloud(i,b,{modifiedBoxIds:xe,resetAreas:Le}),{color:D,currentPCDSrc:U}=R!=null?R:{};return D&&((N=f==null?void 0:f.pointCloudInstance)==null||N.updateColor(D,U)),D}catch(b){console.error("call highlightOriginPointCloud error",b)}});return{selectedID:fe,pointCloudBoxList:s,pointCloudSphereList:x,displayPointCloudList:Ce,displaySphereList:we,displayLineList:be,selectedIDs:v,setPointCloudResult:Ie,setSelectedIDs:a,addPointCloudBox:n,addPointCloudSphere:t,setPointCloudSphereList:B,valid:J,visibleBatchSetValid:ue,selectedPointCloudBox:o,setPointCloudValid:l,setBatchSetValidModal:d,addSelectedID:I,addHighlightID:E,selectedAllBoxes:Ue,topViewInstance:f,setTopViewInstance:$,sideViewInstance:ee,setSideViewInstance:te,backViewInstance:oe,setBackViewInstance:ne,mainViewInstance:g,setMainViewInstance:ie,polygonList:A,setPolygonList:O,rectList:P,setRectList:u,addRectIn2DView:S,removeRectIn2DView:K,updateRectIn2DView:k,lineList:y,setLineList:Be,zoom:Y,setZoom:Ne,history:q,toggleAttributesVisible:Je,hideAttributes:h,setHideAttributes:T,reRender:Qe,attrPanelLayout:re,setAttrPanelLayout:ke,syncAllViewPointCloudColor:ye,defaultAttribute:se,setDefaultAttribute:He,pointCloudPattern:F,setPointCloudPattern:Me,selectSpecAttr:Ze,globalPattern:z,setGlobalPattern:e=>{z!==e&&(ze(actionCreators.ChangeSave),Ee(e),e===lbUtils.EPointCloudPattern.Detection&&ae(void 0))},ptSegmentInstance:L,setPtSegmentInstance:ae,segmentation:W,setSegmentation:Oe,clearAllDetectionInstance:Xe,highlight2DDataList:G,setHighlight2DDataList:je,highlight2DLoading:le,setHighlight2DLoading:Fe,cuboidBoxIn2DView:X,setCuboidBoxIn2DView:Ve,imageSizes:ge,cacheImageNodeSize:We,highlightIDs:V,setHighlightIDs:j,removeRectByPointCloudBoxId:pe,removeRectBySpecifyId:H,addRectFromPointCloudBoxByImageName:me,rectRotateSensitivity:Q,setRectRotateSensitivity:_e,imageNamePointCloudBoxMap:ve,linkageImageNameRectMap:Pe,updateRectListByReducer:Se,windowKeydownListenerHook:he,isLargeStatus:de,setIsLargeStatus:ce}},[J,ue,v,s,x,A,y,P,f,ee,oe,g,Y,h,re,se,F,z,L,W,G,le,X,ge,V,pe,H,me,Q,ve,Pe,Se,he,de,ce]);React.useEffect(()=>{var o,n,t;(o=p==null?void 0:p.setPointCloudBoxList)==null||o.call(p,s),(n=p==null?void 0:p.setHighlightIDs)==null||n.call(p,V),(t=p==null?void 0:p.setSelectedIDs)==null||t.call(p,v)},[s,v,V]),React.useEffect(()=>{var o;(o=p==null?void 0:p.setPtCtx)==null||o.call(p,M)},[M]);const Ke=()=>{const o=s.filter(d=>h.includes(d.attribute)),{setSelectedIDs:n,reRender:t}=M,l=o.map(d=>d.id);l.length>0&&n(v.filter(d=>!l.includes(d))),t()};return React.useEffect(()=>{var o,n,t,l;Ke(),(n=(o=f==null?void 0:f.toolInstance)==null?void 0:o.setHiddenAttributes)==null||n.call(o,h),(l=(t=L==null?void 0:L.store)==null?void 0:t.setHiddenAttributes)==null||l.call(t,h)},[h]),React__default.default.createElement(PointCloudContext.Provider,{value:M},r)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var dom=require("../../utils/dom.js"),index$3=require("../../views/MainView/toolFooter/index.js"),index$4=require("../../views/MainView/toolFooter/ZoomController/index.js"),icons=require("@ant-design/icons"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudInfos=require("./PointCloudInfos.js"),usePolygon=require("./hooks/usePolygon.js"),useSphere=require("./hooks/useSphere.js"),useZoom=require("./hooks/useZoom.js"),antd=require("antd"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index=require("../../utils/index.js"),ToolUtils=require("../../utils/ToolUtils.js"),_=require("lodash"),index$2=require("./components/PointCloudSizeSlider/index.js"),useHistory=require("./hooks/useHistory.js"),index$1=require("./components/TitleButton/index.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}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=(o,s,l)=>s in o?__defProp(o,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[s]=l,__spreadValues=(o,s)=>{for(var l in s||(s={}))__hasOwnProp.call(s,l)&&__defNormalProp(o,l,s[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(s))__propIsEnum.call(s,l)&&__defNormalProp(o,l,s[l]);return o},__spreadProps=(o,s)=>__defProps(o,__getOwnPropDescs(s));const{EPolygonPattern,EToolName}=lbAnnotation.cTool,{ESortDirection}=lbAnnotation.cAnnotation,EKeyCode=lbAnnotation.cKeyCode.default,TransferCanvas2WorldOffset=(o,s,l=1)=>{const{width:C,height:p}=s,w={x:o.x+C*l/2,y:o.y+p*l/2},x={x:s.width/2,y:s.height/2};return{offsetX:(x.x-w.x)/l,offsetY:-(x.y-w.y)/l}},TopViewToolbar=({currentData:o})=>{var s,l;const{zoom:C,zoomIn:p,zoomOut:w,initialPosition:x}=useZoom.useZoom(),{selectNextBox:L,selectPrevBox:b}=useSingleBox.useSingleBox(),{switchToNextSphere:S}=useSphere.useSphere(),{updateRotate:E}=useRotate.useRotate({currentData:o}),{updateRotateEdge:O}=useRotateEdge.useRotateEdge({currentData:o}),g=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:I}=g,f=(l=(s=g==null?void 0:g.topViewInstance)==null?void 0:s.toolScheduler)==null?void 0:l.getCurrentToolName(),e=()=>{E(-Number(g.rectRotateSensitivity))},u=()=>{E(g.rectRotateSensitivity)},v=()=>{O(-90)};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$2,{onChange:T=>{var y;(y=I==null?void 0:I.pointCloudInstance)==null||y.updatePointSize({customSize:T})}}),React__default.default.createElement("span",{onClick:u,className:dom.getClassName("point-cloud","rotate-reserve")}),React__default.default.createElement("span",{onClick:e,className:dom.getClassName("point-cloud","rotate")}),React__default.default.createElement("span",{onClick:v,className:dom.getClassName("point-cloud","rotate-90")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(icons.UpSquareOutlined,{onClick:()=>{if(f===EToolName.Point){S(ESortDirection.descend);return}b(!0)},className:dom.getClassName("point-cloud","prev")}),React__default.default.createElement(icons.DownSquareOutlined,{onClick:()=>{if(f===EToolName.Point){S(ESortDirection.ascend);return}L(!0)},className:dom.getClassName("point-cloud","next")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(index$4.ZoomController,{initialPosition:x,zoomIn:p,zoomOut:w,zoom:C}))},ZAxisSlider=({setZAxisLimit:o,zAxisLimit:s,checkMode:l})=>l?null:React__default.default.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},React__default.default.createElement(antd.Slider,{vertical:!0,step:.5,max:10,min:.5,defaultValue:s,onAfterChange:C=>{o(C)}})),PointCloudTopView=({currentData:o,imgList:s,stepInfo:l,drawLayerSlot:C,checkMode:p,intelligentFit:w,setIsEnlargeTopView:x,isEnlargeTopView:L,onExitZoom:b,highlightAttribute:S})=>{var E,O;const[g,I]=React.useState({zoom:1,currentPos:{x:0,y:0}}),f=React.useRef(null),e=React.useContext(PointCloudContext.PointCloudContext),u=useSize(f),v=index.jsonParser(l.config),{setZoom:T,syncTopviewToolZoom:y}=useZoom.useZoom(),{hideAttributes:U,setIsLargeStatus:Z,selectedID:z,pointCloudBoxList:H}=e,{addPolygon:F,deletePolygon:W}=usePolygon.usePolygon(),{deletePointCloudSphere:$}=useSphere.useSphere(),{deletePointCloudBox:M,changeValidByID:K}=useSingleBox.useSingleBox(),[B,X]=React.useState(10),{t:D}=reactI18next.useTranslation(),m=usePointCloudViews.usePointCloudViews(),{pushHistoryWithList:Y}=useHistory.useHistory(),[G,q]=React.useState(!0),[N,k]=React.useState(!1);React.useLayoutEffect(()=>{if(!e.topViewInstance&&f.current&&(o==null?void 0:o.url)&&(o==null?void 0:o.result)){const n={width:f.current.clientWidth,height:f.current.clientHeight},r=new lbAnnotation.PointCloudAnnotation({container:f.current,size:n,pcdPath:o.url,config:__spreadProps(__spreadValues({},v),{pointCloudPattern:e.pointCloudPattern}),checkMode:p,toolName:ToolUtils.getPointCloudToolList(),proxyMode:p});e.setTopViewInstance(r)}},[o]),React.useEffect(()=>{N&&z&&(e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single,H),k(!1))},[N]),React.useEffect(()=>{if(!u||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:n}=e.topViewInstance;n.singleOn("dataUpdated",(t,i)=>{const d=___default.default.cloneDeep(t).map(a=>__spreadProps(__spreadValues({},a),{pointList:lbUtils.PointCloudUtils.pointListTransferCanvas2World(a.pointList,u)}));e.setSelectedIDs(i),e.setLineList(d),Y({lineList:d})}),n.singleOn("pointCreated",(t,i)=>{m.topViewAddSphere({newPoint:t,size:u,trackConfigurable:v.trackConfigurable,zoom:i})}),n.singleOn("pointDeleted",t=>{$(t)}),n.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),n.singleOn("updatePointByDrag",(t,i)=>{var d;(d=m.topViewUpdatePoint)==null||d.call(m,t,u)}),n.singleOn("polygonCreated",(t,i)=>{if(n.pattern===EPolygonPattern.Normal||!(o==null?void 0:o.url)){const d=__spreadProps(__spreadValues({},t),{pointList:t.pointList.map(a=>lbUtils.PointCloudUtils.transferCanvas2World(a,u))});F(d),e.setSelectedIDs(U.includes(t.attribute)?"":t.id);return}q(!1),m.topViewAddBox({polygon:t,size:u,imgList:s,trackConfigurable:v.trackConfigurable,zoom:i,intelligentFit:w}),k(!0)}),n.singleOn("deletedObject",({id:t})=>{M(t),W(t)}),n.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),n.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),n.singleOn("setSelectedIDs",t=>{q(!1),e.setSelectedIDs(t)}),n.singleOn("updatePolygonByDrag",t=>{var i;(i=m.topViewUpdateBox)==null||i.call(m,t,u)});const r=t=>{var i;const d=K(t);d&&e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,d),e.polygonList.find(a=>a.id===t)&&((i=e.topViewInstance)==null||i.toolInstance.setPolygonValidAndRender(t,!0))};return n.on("validUpdate",r),()=>{n.unbind("validUpdate",r)}},[e,u,o,m,e.polygonList,e.lineList,(E=e.topViewInstance)==null?void 0:E.toolInstance]),React.useEffect(()=>{var n,r;if(!(u==null?void 0:u.width)||!e.topViewInstance)return;const t=(r=(n=v==null?void 0:v.attributeList)==null?void 0:n[0])==null?void 0:r.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(u),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:i,toolInstance:d}}=e;d.singleOn("renderZoom",(a,c)=>{const{offsetX:h,offsetY:V}=TransferCanvas2WorldOffset(c,u,a);if(i.camera.zoom=a,c){const{x:P,y:j,z:R}=i.initCameraPosition;i.camera.position.set(P+V,j-h,R)}i.camera.updateProjectionMatrix(),i.render(),T(a),y(c,a,u),I({zoom:a,currentPos:c})}),d.singleOn("dragMove",({currentPos:a,zoom:c})=>{const{offsetX:h,offsetY:V}=TransferCanvas2WorldOffset(a,u,c);i.camera.zoom=c;const{x:P,y:j,z:R}=i.initCameraPosition;i.camera.position.set(P+V,j-h,R),i.render(),y(a,c,u),I({zoom:c,currentPos:a})})},[u,e.topViewInstance,(O=e.topViewInstance)==null?void 0:O.toolInstance]),React.useEffect(()=>{var n,r;(r=(n=e.topViewInstance)==null?void 0:n.pointCloudInstance)==null||r.applyZAxisPoints(B)},[B]),React.useEffect(()=>{var n,r,t,i;m.topViewSelectedChanged({}),(i=(t=(r=(n=e.topViewInstance)==null?void 0:n.toolInstance)==null?void 0:r.selection)==null?void 0:t.hardSetSelectedIDs)==null||i.call(t,e.selectedIDs)},[e.selectedIDs]),React.useEffect(()=>{const{topViewInstance:n,selectedID:r,selectedPointCloudBox:t,zoom:i}=e;if(!n||!r||!t||!G){q(!0);return}const{center:d}=t,{pointCloudInstance:a,toolInstance:c}=n,h=c.polygonList.find(Q=>Q.id===e.selectedID);if(!h){q(!0);return}const V=lbAnnotation.MathUtils.getRectCenterPoint(h.pointList),P=lbAnnotation.MathUtils.getCurrentPosFromRectCenter(c.size,V,i);c.setCurrentPos(P),c.render();const{x:j,y:R,z:J}=a.initCameraPosition;a.camera.position.set(d.x,d.y,J),a.render(),y(P,i,u),I({zoom:i,currentPos:P})},[e.selectedID]),React.useEffect(()=>(window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}),[]);const A=n=>{const{keyCode:r}=n;r===EKeyCode.Esc&&b()};return React.useEffect(()=>{var n,r,t;(t=(r=(n=e.topViewInstance)==null?void 0:n.pointCloud2dOperation)==null?void 0:r.setHighlightAttribute)==null||t.call(r,S)},[e.topViewInstance,S]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","top-view"),title:L?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{b()}}),React__default.default.createElement("span",null,D("TopView")),React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:p,config:v,style:{display:"flex",position:"initial",margin:"0px 20px"}})):React__default.default.createElement(index$1,{title:D("TopView"),onClick:()=>{Z(!0),x(!0)}}),toolbar:React__default.default.createElement(TopViewToolbar,{currentData:o})},React__default.default.createElement("div",{style:{position:"relative",flex:1}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"},ref:f},C==null?void 0:C(g)),!L&&React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:p,config:v}),React__default.default.createElement(ZAxisSlider,{checkMode:p,zAxisLimit:B,setZAxisLimit:X}),React__default.default.createElement(PointCloudInfos.PointCloudValidity,null)))};var PointCloudTopView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudTopView);module.exports=PointCloudTopView$1;
|
|
1
|
+
"use strict";var dom=require("../../utils/dom.js"),index$3=require("../../views/MainView/toolFooter/index.js"),index$4=require("../../views/MainView/toolFooter/ZoomController/index.js"),icons=require("@ant-design/icons"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),ToolPointCloudBoxRenderHelper=require("../../utils/ToolPointCloudBoxRenderHelper.js"),React=require("react"),PointCloudContext=require("./PointCloudContext.js"),useRotate=require("./hooks/useRotate.js"),useRotateEdge=require("./hooks/useRotateEdge.js"),useSingleBox=require("./hooks/useSingleBox.js"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudInfos=require("./PointCloudInfos.js"),usePolygon=require("./hooks/usePolygon.js"),useSphere=require("./hooks/useSphere.js"),useZoom=require("./hooks/useZoom.js"),antd=require("antd"),map=require("../../store/annotation/map.js"),reactRedux=require("react-redux"),usePointCloudViews=require("./hooks/usePointCloudViews.js"),useSize=require("../../hooks/useSize.js"),reactI18next=require("react-i18next"),ctx=require("../../store/ctx.js"),index=require("../../utils/index.js"),ToolUtils=require("../../utils/ToolUtils.js"),_=require("lodash"),index$2=require("./components/PointCloudSizeSlider/index.js"),useHistory=require("./hooks/useHistory.js"),index$1=require("./components/TitleButton/index.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}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=(o,s,l)=>s in o?__defProp(o,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[s]=l,__spreadValues=(o,s)=>{for(var l in s||(s={}))__hasOwnProp.call(s,l)&&__defNormalProp(o,l,s[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(s))__propIsEnum.call(s,l)&&__defNormalProp(o,l,s[l]);return o},__spreadProps=(o,s)=>__defProps(o,__getOwnPropDescs(s));const{EPolygonPattern,EToolName}=lbAnnotation.cTool,{ESortDirection}=lbAnnotation.cAnnotation,EKeyCode=lbAnnotation.cKeyCode.default,TransferCanvas2WorldOffset=(o,s,l=1)=>{const{width:C,height:p}=s,w={x:o.x+C*l/2,y:o.y+p*l/2},x={x:s.width/2,y:s.height/2};return{offsetX:(x.x-w.x)/l,offsetY:-(x.y-w.y)/l}},TopViewToolbar=({currentData:o})=>{var s,l;const{zoom:C,zoomIn:p,zoomOut:w,initialPosition:x}=useZoom.useZoom(),{selectNextBox:L,selectPrevBox:b}=useSingleBox.useSingleBox(),{switchToNextSphere:S}=useSphere.useSphere(),{updateRotate:V}=useRotate.useRotate({currentData:o}),{updateRotateEdge:O}=useRotateEdge.useRotateEdge({currentData:o}),g=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:I}=g,f=(l=(s=g==null?void 0:g.topViewInstance)==null?void 0:s.toolScheduler)==null?void 0:l.getCurrentToolName(),e=()=>{V(-Number(g.rectRotateSensitivity))},u=()=>{V(g.rectRotateSensitivity)},v=()=>{O(-90)};return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$2,{onChange:T=>{var y;(y=I==null?void 0:I.pointCloudInstance)==null||y.updatePointSize({customSize:T})}}),React__default.default.createElement("span",{onClick:u,className:dom.getClassName("point-cloud","rotate-reserve")}),React__default.default.createElement("span",{onClick:e,className:dom.getClassName("point-cloud","rotate")}),React__default.default.createElement("span",{onClick:v,className:dom.getClassName("point-cloud","rotate-90")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(icons.UpSquareOutlined,{onClick:()=>{if(f===EToolName.Point){S(ESortDirection.descend);return}b(!0)},className:dom.getClassName("point-cloud","prev")}),React__default.default.createElement(icons.DownSquareOutlined,{onClick:()=>{if(f===EToolName.Point){S(ESortDirection.ascend);return}L(!0)},className:dom.getClassName("point-cloud","next")}),React__default.default.createElement(index$3.FooterDivider,null),React__default.default.createElement(index$4.ZoomController,{initialPosition:x,zoomIn:p,zoomOut:w,zoom:C}))},ZAxisSlider=({setZAxisLimit:o,zAxisLimit:s,checkMode:l})=>l?null:React__default.default.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},React__default.default.createElement(antd.Slider,{vertical:!0,step:.5,max:10,min:.5,defaultValue:s,onAfterChange:C=>{o(C)}})),PointCloudTopView=({currentData:o,imgList:s,stepInfo:l,drawLayerSlot:C,checkMode:p,intelligentFit:w,setIsEnlargeTopView:x,isEnlargeTopView:L,onExitZoom:b,highlightAttribute:S})=>{var V,O;const[g,I]=React.useState({zoom:1,currentPos:{x:0,y:0}}),f=React.useRef(null),e=React.useContext(PointCloudContext.PointCloudContext),u=useSize(f),v=index.jsonParser(l.config),{setZoom:T,syncTopviewToolZoom:y}=useZoom.useZoom(),{hideAttributes:U,setIsLargeStatus:Z,selectedID:z,pointCloudBoxList:H}=e,{addPolygon:F,deletePolygon:W}=usePolygon.usePolygon(),{deletePointCloudSphere:$}=useSphere.useSphere(),{deletePointCloudBox:M,changeValidByID:K}=useSingleBox.useSingleBox(),[B,X]=React.useState(10),{t:D}=reactI18next.useTranslation(),m=usePointCloudViews.usePointCloudViews(),{pushHistoryWithList:Y}=useHistory.useHistory(),[G,q]=React.useState(!0),[N,k]=React.useState(!1);React.useLayoutEffect(()=>{if(!e.topViewInstance&&f.current&&(o==null?void 0:o.url)&&(o==null?void 0:o.result)){const n={width:f.current.clientWidth,height:f.current.clientHeight},r=new lbAnnotation.PointCloudAnnotation({container:f.current,size:n,pcdPath:o.url,config:__spreadProps(__spreadValues({},v),{pointCloudPattern:e.pointCloudPattern}),checkMode:p,toolName:ToolUtils.getPointCloudToolList(),proxyMode:p,view:"topView"});e.setTopViewInstance(r)}},[o]),React.useEffect(()=>{N&&z&&(e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Single,H),k(!1))},[N]),React.useEffect(()=>{if(!u||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:n}=e.topViewInstance;n.singleOn("dataUpdated",(t,i)=>{const d=___default.default.cloneDeep(t).map(a=>__spreadProps(__spreadValues({},a),{pointList:lbUtils.PointCloudUtils.pointListTransferCanvas2World(a.pointList,u)}));e.setSelectedIDs(i),e.setLineList(d),Y({lineList:d})}),n.singleOn("pointCreated",(t,i)=>{m.topViewAddSphere({newPoint:t,size:u,trackConfigurable:v.trackConfigurable,zoom:i})}),n.singleOn("pointDeleted",t=>{$(t)}),n.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),n.singleOn("updatePointByDrag",(t,i)=>{var d;(d=m.topViewUpdatePoint)==null||d.call(m,t,u)}),n.singleOn("polygonCreated",(t,i)=>{if(n.pattern===EPolygonPattern.Normal||!(o==null?void 0:o.url)){const d=__spreadProps(__spreadValues({},t),{pointList:t.pointList.map(a=>lbUtils.PointCloudUtils.transferCanvas2World(a,u))});F(d),e.setSelectedIDs(U.includes(t.attribute)?"":t.id);return}q(!1),m.topViewAddBox({polygon:t,size:u,imgList:s,trackConfigurable:v.trackConfigurable,zoom:i,intelligentFit:w}),k(!0)}),n.singleOn("deletedObject",({id:t})=>{M(t),W(t)}),n.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),n.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),n.singleOn("setSelectedIDs",t=>{q(!1),e.setSelectedIDs(t)}),n.singleOn("updatePolygonByDrag",t=>{var i;(i=m.topViewUpdateBox)==null||i.call(m,t,u)});const r=t=>{var i;const d=K(t);d&&e.syncAllViewPointCloudColor(ToolPointCloudBoxRenderHelper.EPointCloudBoxRenderTrigger.Default,d),e.polygonList.find(a=>a.id===t)&&((i=e.topViewInstance)==null||i.toolInstance.setPolygonValidAndRender(t,!0))};return n.on("validUpdate",r),()=>{n.unbind("validUpdate",r)}},[e,u,o,m,e.polygonList,e.lineList,(V=e.topViewInstance)==null?void 0:V.toolInstance]),React.useEffect(()=>{var n,r;if(!(u==null?void 0:u.width)||!e.topViewInstance)return;const t=(r=(n=v==null?void 0:v.attributeList)==null?void 0:n[0])==null?void 0:r.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(u),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:i,toolInstance:d}}=e;d.singleOn("renderZoom",(a,c)=>{const{offsetX:h,offsetY:E}=TransferCanvas2WorldOffset(c,u,a);if(i.camera.zoom=a,c){const{x:P,y:j,z:R}=i.initCameraPosition;i.camera.position.set(P+E,j-h,R)}i.camera.updateProjectionMatrix(),i.render(),T(a),y(c,a,u),I({zoom:a,currentPos:c})}),d.singleOn("dragMove",({currentPos:a,zoom:c})=>{const{offsetX:h,offsetY:E}=TransferCanvas2WorldOffset(a,u,c);i.camera.zoom=c;const{x:P,y:j,z:R}=i.initCameraPosition;i.camera.position.set(P+E,j-h,R),i.render(),y(a,c,u),I({zoom:c,currentPos:a})})},[u,e.topViewInstance,(O=e.topViewInstance)==null?void 0:O.toolInstance]),React.useEffect(()=>{var n,r;(r=(n=e.topViewInstance)==null?void 0:n.pointCloudInstance)==null||r.applyZAxisPoints(B)},[B]),React.useEffect(()=>{var n,r,t,i;m.topViewSelectedChanged({}),(i=(t=(r=(n=e.topViewInstance)==null?void 0:n.toolInstance)==null?void 0:r.selection)==null?void 0:t.hardSetSelectedIDs)==null||i.call(t,e.selectedIDs)},[e.selectedIDs]),React.useEffect(()=>{const{topViewInstance:n,selectedID:r,selectedPointCloudBox:t,zoom:i}=e;if(!n||!r||!t||!G){q(!0);return}const{center:d}=t,{pointCloudInstance:a,toolInstance:c}=n,h=c.polygonList.find(Q=>Q.id===e.selectedID);if(!h){q(!0);return}const E=lbAnnotation.MathUtils.getRectCenterPoint(h.pointList),P=lbAnnotation.MathUtils.getCurrentPosFromRectCenter(c.size,E,i);c.setCurrentPos(P),c.render();const{x:j,y:R,z:J}=a.initCameraPosition;a.camera.position.set(d.x,d.y,J),a.render(),y(P,i,u),I({zoom:i,currentPos:P})},[e.selectedID]),React.useEffect(()=>(window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}),[]);const A=n=>{const{keyCode:r}=n;r===EKeyCode.Esc&&b()};return React.useEffect(()=>{var n,r,t;(t=(r=(n=e.topViewInstance)==null?void 0:n.pointCloud2dOperation)==null?void 0:r.setHighlightAttribute)==null||t.call(r,S)},[e.topViewInstance,S]),React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:dom.getClassName("point-cloud-container","top-view"),title:L?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{b()}}),React__default.default.createElement("span",null,D("TopView")),React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:p,config:v,style:{display:"flex",position:"initial",margin:"0px 20px"}})):React__default.default.createElement(index$1,{title:D("TopView"),onClick:()=>{Z(!0),x(!0)}}),toolbar:React__default.default.createElement(TopViewToolbar,{currentData:o})},React__default.default.createElement("div",{style:{position:"relative",flex:1}},React__default.default.createElement("div",{style:{width:"100%",height:"100%"},ref:f},C==null?void 0:C(g)),!L&&React__default.default.createElement(PointCloudInfos.BoxInfos,{checkMode:p,config:v}),React__default.default.createElement(ZAxisSlider,{checkMode:p,zAxisLimit:B,setZAxisLimit:X}),React__default.default.createElement(PointCloudInfos.PointCloudValidity,null)))};var PointCloudTopView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudTopView);module.exports=PointCloudTopView$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),__async=(s,u,t)=>new Promise((g,a)=>{var n=i=>{try{o(t.next(i))}catch(l){a(l)}},d=i=>{try{o(t.throw(i))}catch(l){a(l)}},o=i=>i.done?g(i.value):Promise.resolve(i.value).then(n,d);o((t=t.apply(s,u)).next())});const useHighlight=({currentData:s})=>{var u;const{mainViewInstance:t,topViewInstance:g,pointCloudBoxList:a,highlight2DDataList:n,setHighlight2DDataList:d}=React.useContext(PointCloudContext.PointCloudContext),o=(u=s==null?void 0:s.mappingImgList)!=null?u:[],i=(r,c,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),__async=(s,u,t)=>new Promise((g,a)=>{var n=i=>{try{o(t.next(i))}catch(l){a(l)}},d=i=>{try{o(t.throw(i))}catch(l){a(l)}},o=i=>i.done?g(i.value):Promise.resolve(i.value).then(n,d);o((t=t.apply(s,u)).next())});const useHighlight=({currentData:s})=>{var u;const{mainViewInstance:t,topViewInstance:g,pointCloudBoxList:a,highlight2DDataList:n,setHighlight2DDataList:d}=React.useContext(PointCloudContext.PointCloudContext),o=(u=s==null?void 0:s.mappingImgList)!=null?u:[],i=(r,c,f)=>__async(void 0,null,function*(){var p;let h=[...n];if(n.find(e=>e.url===r)?h=n.filter(e=>e.url!==r):h.push({url:r,fallbackUrl:c,calib:f}),d(h),!t||(o==null?void 0:o.length)===0)return;const v=t.pointCloudObject;if(!v)return;const m=yield t.getHighlightIndexByMappingImgList({mappingImgList:h,points:v.geometry.attributes.position.array});try{const e=yield t.highlightOriginPointCloud(a,m),{color:C}=e!=null?e:{};C&&((p=g==null?void 0:g.pointCloudInstance)==null||p.updateColor(C))}catch(e){console.error("toggle2dVisible highlightOriginPointCloud error:",e)}}),l=React.useCallback(r=>n.findIndex(c=>c.url===r)>=0,[n]);return{toggle2dVisible:i,isHighlightVisible:l}};exports.useHighlight=useHighlight;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as u}from"../../utils/dom.js";import{cKeyCode as ee,PointCloud as te}from"@labelbee/lb-annotation";import{PointCloudUtils as T,EPerspectiveView as E}from"@labelbee/lb-utils";import O from"classnames";import o,{useContext as b,useState as y,useRef as oe,useEffect as p,useMemo as ne}from"react";import{PointCloudContainer as ie}from"./PointCloudLayout.js";import{PointCloudContext as le}from"./PointCloudContext.js";import{a2MapStateToProps as se}from"../../store/annotation/map.js";import{connect as re}from"react-redux";import{jsonParser as ae}from"../../utils/index.js";import{useSingleBox as A}from"./hooks/useSingleBox.js";import{useSphere as ce}from"./hooks/useSphere.js";import{Switch as de,Tooltip as ue}from"antd";import me from"../../hooks/useSize.js";import{usePointCloudViews as pe}from"./hooks/usePointCloudViews.js";import{useTranslation as F}from"react-i18next";import{LabelBeeContext as we}from"../../store/ctx.js";import ve from"./components/PointCloudSizeSlider/index.js";import fe from"./components/TitleButton/index.js";import{LeftOutlined as Ce}from"@ant-design/icons";import{useToolStyleContext as Ve}from"../../hooks/useToolStyle.js";import{usePointCloudAttribute as ge}from"./hooks/usePointCloudAttribute.js";var Ie=Object.defineProperty,H=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,U=(n,l,s)=>l in n?Ie(n,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[l]=s,he=(n,l)=>{for(var s in l||(l={}))Pe.call(l,s)&&U(n,s,l[s]);if(H)for(var s of H(l))Ee.call(l,s)&&U(n,s,l[s]);return n};const xe=ee.default,_e="LABELBEE-POINTCLOUD",h=o.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),v=({perspectiveView:n})=>{const{isActive:l,setTarget3DView:s}=b(h),f=w=>O({[u("point-cloud-3d-view",w)]:!0,active:l});return o.createElement("span",{onClick:()=>{s(E[n])},className:f(n.toLocaleLowerCase())})},K=({isEnlarge:n})=>{const{reset3DView:l,followTopView:s}=b(h),{t:f}=F(),w=o.createElement(o.Fragment,null,o.createElement(v,{perspectiveView:"Top"}),o.createElement(v,{perspectiveView:"Front"}),o.createElement(v,{perspectiveView:"Left"}),o.createElement(v,{perspectiveView:"Back"}),o.createElement(v,{perspectiveView:"Right"}),o.createElement(v,{perspectiveView:"LFT"}),o.createElement(v,{perspectiveView:"RBT"})),e=o.createElement(o.Fragment,null,o.createElement(ue,{title:f("CameraFollowTopView")},o.createElement("span",{onClick:()=>{s()},className:u("point-cloud-3d-view","followTop")})),o.createElement("span",{onClick:()=>{l()},className:u("point-cloud-3d-view","reset")}));return n?o.createElement("div",{className:u("point-cloud-3d-sidebarZoom")},e,w):o.createElement("div",{className:u("point-cloud-3d-sidebar")},w,e)},Se=({currentData:n,config:l,highlightAttribute:s,setResourceLoading:f})=>{var w;const e=b(le),{setIsLargeStatus:B}=e,[M,Z]=y(!0),[C,x]=y(!1),V=oe(null),{initPointCloud3d:L,generateRects:q}=pe(),g=me(V),{t:_}=F(),{value:j}=Ve(),{hiddenText:D}=j||{},{updatePointCloudAttribute:G}=ge(f,l),{updateSelectedBox:J}=A({generateRects:q});p(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(D,e.pointCloudBoxList)},[j]),p(()=>{!e.mainViewInstance||L==null||L(g)},[g]);const{selectedBox:m}=A(),{selectedSphere:I}=ce(),[Q,z]=y(!0),S=t=>{var i,r;const a=m==null?void 0:m.info;if(a){const c=he({},a.center);c.x=c.x-.01,c.z=1e3;const d=t===E.Top;(i=e.mainViewInstance)==null||i.updateCameraByBox(a,t,d?c:void 0)}I&&((r=e.mainViewInstance)==null||r.updateCameraBySphere(I,t))},W=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},X=()=>{var t,i;const r=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;r&&((i=e.mainViewInstance)==null||i.applyCameraTarget(r))};p(()=>{if(V.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&g.width&&(t=new te({container:V.current,isOrthographicCamera:!0,orthographicParams:T.getDefaultOrthographicParams(g),config:l,hiddenText:D}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:z}),e.setMainViewInstance(t))}},[g,n]),p(()=>{var t,i;if(V.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let r=e.mainViewInstance;const a=T.getRectParamsFromResultList(n.result),c=T.getBoxParamsFromResultList(n.result),d=c.find(P=>P.id===e.selectedID);d&&((t=e.topViewInstance)==null||t.updatePolygonList(c,void 0),G(d.attribute),J(d),e.setSelectedIDs(d.id)),e.setPointCloudValid((i=ae(n.result))==null?void 0:i.valid),e.setPointCloudResult(c),e.setRectList(a),r.generateBoxes(c)}},[n.result,e.mainViewInstance]),p(()=>{var t,i,r,a,c,d,P;const R=(t=m==null?void 0:m.info)==null?void 0:t.id;if(!Q){z(!0);return}if(R!==void 0){S(E.Top);const $=(a=(r=(i=e.topViewInstance)==null?void 0:i.pointCloudInstance)==null?void 0:r.camera.zoom)!=null?a:1;(c=e.mainViewInstance)==null||c.updateCameraZoom($)}(d=e.mainViewInstance)==null||d.setHighlightColor(R),(P=e.mainViewInstance)==null||P.render()},[(w=m==null?void 0:m.info)==null?void 0:w.id]),p(()=>{var t,i,r,a;if(I){S(E.Top);const c=(r=(i=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?r:1;(a=e.mainViewInstance)==null||a.updateCameraZoom(c)}},[I]),p(()=>(window.addEventListener("keydown",k),()=>{window.removeEventListener("keydown",k)}),[]);const k=t=>{if(t.keyCode===xe.Esc){x(!1);return}},N=ne(()=>({reset3DView:W,setTarget3DView:S,isActive:!!m,followTopView:X}),[m,e.mainViewInstance]);p(()=>{var t,i,r;const a=e.pointCloudBoxList.filter(c=>c.attribute===s);(a==null?void 0:a.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(i=e.mainViewInstance)==null||i.highlightBoxes(a)),a.length===0&&((r=e.mainViewInstance)==null||r.clearHighlightBoxesAndRender())},[s,e.mainViewInstance]);const Y=o.createElement(o.Fragment,null,o.createElement(ve,{onChange:t=>{var i;(i=e.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),o.createElement("span",{style:{marginRight:8}},_("ShowArrows")),o.createElement(de,{size:"small",checked:M,onChange:t=>{var i;Z(t),(i=e.mainViewInstance)==null||i.setShowDirection(t)}}),C&&o.createElement(h.Provider,{value:N},o.createElement(K,{isEnlarge:C})));return o.createElement(ie,{className:O({[u("point-cloud-3d-container")]:!0,[u("point-cloud-container","zoom")]:C}),title:C?o.createElement("div",{style:{display:"flex",alignItems:"center"}},o.createElement(Ce,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{B(!1),x(!1)}}),_("3DView")):o.createElement(fe,{title:_("3DView"),onClick:()=>{B(!0),x(!0)}}),toolbar:Y},o.createElement("div",{className:u("point-cloud-3d-content")},!C&&o.createElement(h.Provider,{value:N},o.createElement(K,null)),o.createElement("div",{className:u("point-cloud-3d-view"),id:_e,ref:V})))};var Te=re(se,null,null,{context:we})(Se);export{Te as default};
|
|
1
|
+
import{getClassName as u}from"../../utils/dom.js";import{cKeyCode as ee,PointCloud as te}from"@labelbee/lb-annotation";import{PointCloudUtils as T,EPerspectiveView as E}from"@labelbee/lb-utils";import O from"classnames";import o,{useContext as b,useState as y,useRef as oe,useEffect as p,useMemo as ne}from"react";import{PointCloudContainer as ie}from"./PointCloudLayout.js";import{PointCloudContext as le}from"./PointCloudContext.js";import{a2MapStateToProps as se}from"../../store/annotation/map.js";import{connect as re}from"react-redux";import{jsonParser as ae}from"../../utils/index.js";import{useSingleBox as A}from"./hooks/useSingleBox.js";import{useSphere as ce}from"./hooks/useSphere.js";import{Switch as de,Tooltip as ue}from"antd";import me from"../../hooks/useSize.js";import{usePointCloudViews as pe}from"./hooks/usePointCloudViews.js";import{useTranslation as F}from"react-i18next";import{LabelBeeContext as we}from"../../store/ctx.js";import ve from"./components/PointCloudSizeSlider/index.js";import fe from"./components/TitleButton/index.js";import{LeftOutlined as Ce}from"@ant-design/icons";import{useToolStyleContext as Ve}from"../../hooks/useToolStyle.js";import{usePointCloudAttribute as ge}from"./hooks/usePointCloudAttribute.js";var Ie=Object.defineProperty,H=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Ee=Object.prototype.propertyIsEnumerable,U=(n,l,s)=>l in n?Ie(n,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[l]=s,he=(n,l)=>{for(var s in l||(l={}))Pe.call(l,s)&&U(n,s,l[s]);if(H)for(var s of H(l))Ee.call(l,s)&&U(n,s,l[s]);return n};const xe=ee.default,_e="LABELBEE-POINTCLOUD",h=o.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),v=({perspectiveView:n})=>{const{isActive:l,setTarget3DView:s}=b(h),f=w=>O({[u("point-cloud-3d-view",w)]:!0,active:l});return o.createElement("span",{onClick:()=>{s(E[n])},className:f(n.toLocaleLowerCase())})},K=({isEnlarge:n})=>{const{reset3DView:l,followTopView:s}=b(h),{t:f}=F(),w=o.createElement(o.Fragment,null,o.createElement(v,{perspectiveView:"Top"}),o.createElement(v,{perspectiveView:"Front"}),o.createElement(v,{perspectiveView:"Left"}),o.createElement(v,{perspectiveView:"Back"}),o.createElement(v,{perspectiveView:"Right"}),o.createElement(v,{perspectiveView:"LFT"}),o.createElement(v,{perspectiveView:"RBT"})),e=o.createElement(o.Fragment,null,o.createElement(ue,{title:f("CameraFollowTopView")},o.createElement("span",{onClick:()=>{s()},className:u("point-cloud-3d-view","followTop")})),o.createElement("span",{onClick:()=>{l()},className:u("point-cloud-3d-view","reset")}));return n?o.createElement("div",{className:u("point-cloud-3d-sidebarZoom")},e,w):o.createElement("div",{className:u("point-cloud-3d-sidebar")},w,e)},Se=({currentData:n,config:l,highlightAttribute:s,setResourceLoading:f})=>{var w;const e=b(le),{setIsLargeStatus:B}=e,[M,Z]=y(!0),[C,x]=y(!1),V=oe(null),{initPointCloud3d:L,generateRects:q}=pe(),g=me(V),{t:_}=F(),{value:j}=Ve(),{hiddenText:D}=j||{},{updatePointCloudAttribute:G}=ge(f,l),{updateSelectedBox:J}=A({generateRects:q});p(()=>{let t=e.mainViewInstance;t&&t.updateHiddenTextAndRender(D,e.pointCloudBoxList)},[j]),p(()=>{!e.mainViewInstance||L==null||L(g)},[g]);const{selectedBox:m}=A(),{selectedSphere:I}=ce(),[Q,z]=y(!0),S=t=>{var i,r;const a=m==null?void 0:m.info;if(a){const c=he({},a.center);c.x=c.x-.01,c.z=1e3;const d=t===E.Top;(i=e.mainViewInstance)==null||i.updateCameraByBox(a,t,d?c:void 0)}I&&((r=e.mainViewInstance)==null||r.updateCameraBySphere(I,t))},W=()=>{var t;(t=e.mainViewInstance)==null||t.resetCamera()},X=()=>{var t,i;const r=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance.camera;r&&((i=e.mainViewInstance)==null||i.applyCameraTarget(r))};p(()=>{if(V.current&&(n==null?void 0:n.url)){let t=e.mainViewInstance;!t&&g.width&&(t=new te({container:V.current,isOrthographicCamera:!0,orthographicParams:T.getDefaultOrthographicParams(g),config:l,hiddenText:D,view:"3DView"}),t.setHandlerPipe({setSelectedIDs:e.setSelectedIDs,setNeedUpdateCenter:z}),e.setMainViewInstance(t))}},[g,n]),p(()=>{var t,i;if(V.current&&(n==null?void 0:n.url)&&n.result&&e.mainViewInstance){let r=e.mainViewInstance;const a=T.getRectParamsFromResultList(n.result),c=T.getBoxParamsFromResultList(n.result),d=c.find(P=>P.id===e.selectedID);d&&((t=e.topViewInstance)==null||t.updatePolygonList(c,void 0),G(d.attribute),J(d),e.setSelectedIDs(d.id)),e.setPointCloudValid((i=ae(n.result))==null?void 0:i.valid),e.setPointCloudResult(c),e.setRectList(a),r.generateBoxes(c)}},[n.result,e.mainViewInstance]),p(()=>{var t,i,r,a,c,d,P;const R=(t=m==null?void 0:m.info)==null?void 0:t.id;if(!Q){z(!0);return}if(R!==void 0){S(E.Top);const $=(a=(r=(i=e.topViewInstance)==null?void 0:i.pointCloudInstance)==null?void 0:r.camera.zoom)!=null?a:1;(c=e.mainViewInstance)==null||c.updateCameraZoom($)}(d=e.mainViewInstance)==null||d.setHighlightColor(R),(P=e.mainViewInstance)==null||P.render()},[(w=m==null?void 0:m.info)==null?void 0:w.id]),p(()=>{var t,i,r,a;if(I){S(E.Top);const c=(r=(i=(t=e.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?r:1;(a=e.mainViewInstance)==null||a.updateCameraZoom(c)}},[I]),p(()=>(window.addEventListener("keydown",k),()=>{window.removeEventListener("keydown",k)}),[]);const k=t=>{if(t.keyCode===xe.Esc){x(!1);return}},N=ne(()=>({reset3DView:W,setTarget3DView:S,isActive:!!m,followTopView:X}),[m,e.mainViewInstance]);p(()=>{var t,i,r;const a=e.pointCloudBoxList.filter(c=>c.attribute===s);(a==null?void 0:a.length)>0&&((t=e.mainViewInstance)==null||t.clearHighlightBoxes(),(i=e.mainViewInstance)==null||i.highlightBoxes(a)),a.length===0&&((r=e.mainViewInstance)==null||r.clearHighlightBoxesAndRender())},[s,e.mainViewInstance]);const Y=o.createElement(o.Fragment,null,o.createElement(ve,{onChange:t=>{var i;(i=e.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),o.createElement("span",{style:{marginRight:8}},_("ShowArrows")),o.createElement(de,{size:"small",checked:M,onChange:t=>{var i;Z(t),(i=e.mainViewInstance)==null||i.setShowDirection(t)}}),C&&o.createElement(h.Provider,{value:N},o.createElement(K,{isEnlarge:C})));return o.createElement(ie,{className:O({[u("point-cloud-3d-container")]:!0,[u("point-cloud-container","zoom")]:C}),title:C?o.createElement("div",{style:{display:"flex",alignItems:"center"}},o.createElement(Ce,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{B(!1),x(!1)}}),_("3DView")):o.createElement(fe,{title:_("3DView"),onClick:()=>{B(!0),x(!0)}}),toolbar:Y},o.createElement("div",{className:u("point-cloud-3d-content")},!C&&o.createElement(h.Provider,{value:N},o.createElement(K,null)),o.createElement("div",{className:u("point-cloud-3d-view"),id:_e,ref:V})))};var Te=re(se,null,null,{context:we})(Se);export{Te as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EPointCloudPattern as
|
|
1
|
+
import{EPointCloudPattern as $}from"@labelbee/lb-utils";import je,{useState as r,useRef as pt,useMemo as F,useCallback as H,useEffect as ee}from"react";import{EPointCloudBoxRenderTrigger as E,calcResetAreasAndBoxIds as mt}from"../../utils/ToolPointCloudBoxRenderHelper.js";import{ActionsHistory as ke,EToolName as te,uuid as ht}from"@labelbee/lb-annotation";import{useDispatch as It}from"../../store/ctx.js";import{ChangeSave as vt}from"../../store/annotation/actionCreators.js";import Pt from"../../store/annotatedBox/index.js";import Fe from"lodash";import{addMapIndirectWeakSetItem as Ee}from"./utils/map.js";import wt from"./hooks/useTimeoutFunc.js";import St,{getEmptyUseWindowKeydownListener as yt}from"./hooks/useWindowKeydownListener.js";var Ct=Object.defineProperty,Lt=Object.defineProperties,bt=Object.getOwnPropertyDescriptors,ze=Object.getOwnPropertySymbols,Rt=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable,Ge=(c,s,u)=>s in c?Ct(c,s,{enumerable:!0,configurable:!0,writable:!0,value:u}):c[s]=u,z=(c,s)=>{for(var u in s||(s={}))Rt.call(s,u)&&Ge(c,u,s[u]);if(ze)for(var u of ze(s))xt.call(s,u)&&Ge(c,u,s[u]);return c},Ke=(c,s)=>Lt(c,bt(s)),Dt=(c,s,u)=>new Promise((x,A)=>{var V=g=>{try{w(u.next(g))}catch(b){A(b)}},K=g=>{try{w(u.throw(g))}catch(b){A(b)}},w=g=>g.done?x(g.value):Promise.resolve(g.value).then(V,K);w((u=u.apply(c,s)).next())});const G=c=>Fe.pick(c,["id","attribute","width","height","x","y","imageName"]),Te=je.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,visibleBatchSetValid:!1,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setBatchSetValidModal:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new ke,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:te.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:$.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},highlight2DLoading:!1,setHighlight2DLoading:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:c=>{},imageSizes:{},cacheImageNodeSize:()=>{},addRectFromPointCloudBoxByImageName:c=>!1,removeRectBySpecifyId:(c,s,u)=>!1,removeRectByPointCloudBoxId:c=>!1,rectRotateSensitivity:2,setRectRotateSensitivity:()=>{},imageNamePointCloudBoxMap:new Map,linkageImageNameRectMap:new Map,updateRectListByReducer:()=>{},windowKeydownListenerHook:yt(),isLargeStatus:!1,setIsLargeStatus:()=>{}}),Bt=({children:c})=>{const[s,u]=r([]),[x,A]=r([]),[V,K]=r([]),[w,g]=r([]),[b,We]=r([]),[v,oe]=r([]),[_,T]=r([]),[ne,Ze]=r(!0),[ie,Ue]=r(2),[se,qe]=r(!0),[re,Je]=r(1),[p,le]=r(),[ae,de]=r(),[ce,ue]=r(),[f,ge]=r(),[fe,Qe]=r(""),[W,Xe]=r(te.Rect),Z=pt(new ke).current,[m,U]=r([]),[pe,Ye]=r(""),[q,$e]=r($.Detection),[D,me]=r(void 0),[J,et]=r([]),[Q,tt]=r([]),[he,ot]=r(!1),[Ie,ve]=r(!1),h=Pt(),[Pe,nt]=r(!1),[we,it]=r({}),st=It(),rt=o=>{const{imgNode:n,path:t}=o;t&&n&&it(a=>Ke(z({},a),{[t]:{width:n.width,height:n.height}}))},Se=F(()=>v.length===1?v[0]:"",[v]),ye=St(),O=H((o,n,t="extId")=>{const a=t||"id",d=new Set(n);return g(l=>{let S=!1;const P=l.filter(j=>{const X=j[a],k=d.has(X)?j.imageName!==o:!0;return k||(S=!0),k});return S?P:l}),!0},[]),Ce=H(o=>{const n=s.map(t=>t.id);return O(o,n,"extId")},[s,O]),Le=H(o=>{if(!o)return!1;const n=s.filter(t=>Array.isArray(t.rects)).map(t=>{const{id:a,attribute:d,trackID:l}=t,S=t.rects.find(P=>P.imageName===o);if(S){const P=Fe.pick(S,["width","height","x","y","imageName"]);return Ke(z({},P),{id:ht(),attribute:d,order:l,extId:a,lineDash:[]})}return null}).filter(t=>t!==null);return n.length?(g(t=>{const a=new Set(t.filter(l=>o===l.imageName).map(l=>l.extId)),d=n.filter(l=>a.has(l.extId)===!1);return d.length?[...t,...d]:t}),!0):!1},[s]),be=F(()=>s.filter(n=>Array.isArray(n.rects)&&n.rects.length>0).reduce((n,t)=>{var a;return(a=t.rects)==null||a.forEach(d=>{const{imageName:l}=d;if(!l){console.warn("Missing image name"),console.trace(d,t);return}Ee(n,l,t.id,t)}),n},new Map),[s]),Re=H(o=>{g(n=>o(n,G))},[G]),xe=F(()=>w.filter(o=>o.extId!==void 0&&o.id!==void 0).reduce((o,n)=>{const t=n.imageName;return t?(Ee(o,t,n.extId,n),o):(console.warn("missing image name"),console.log(n,w),o)},new Map),[w]),{fn:lt}=wt(o=>{oe(n=>{const t=o,a=new Set(t);let d=!1;const l=n.filter(S=>{const P=a.has(S);return P||(d=!0),P});return d?l:n})},200),De=H(o=>{const n=o.map(t=>t.id);u(o),lt(n)},[]),M=F(()=>{const o=s.find(e=>e.id===Se),n=e=>{const i=s.concat(e);return De(i),i},t=e=>{const i=x.concat(e);return A(i),i},a=e=>{Ze(e!==!1)},d=e=>{nt(e)},l=e=>{let i=[];e===void 0||e===""?i=[]:typeof e=="string"?i=[e]:Array.isArray(e)&&(i=e.length>1?Array.from(new Set(e)):e),oe(i)},S=e=>{v.includes(e)?l(v.filter(i=>i!==e)):l([...v,e])},P=e=>{const i=G(e);g(I=>[...I,i])},j=(e,i=!1)=>{const I=G(e);g(y=>y.map(C=>C.id===e.id?i?z(z({},C),I):I:C))},X=e=>{g(i=>i.filter(I=>!e.find(y=>y.id===I.id)))},k=e=>{_.includes(e)?T([]):T([e])},dt=()=>{if(W===te.Rect){const e=s.map(i=>i.id);l(e),p==null||p.pointCloud2dOperation.setSelectedIDs(e)}},ct=e=>{l(s.filter(i=>i.attribute===e).map(i=>i.id))},Be=s.filter(e=>!m.includes(e.attribute)),Ae=x.filter(e=>!m.includes(e.attribute)),Ve=b.filter(e=>e.attribute&&!m.includes(e.attribute)),ut=e=>{if(m.includes(e))U(m.filter(i=>i!==e));else{const i=m.concat(e);U(i)}},gt=(e=Be,i=V,I=Ae,y=Ve,C=J)=>{var N;f==null||f.clearAllBox(),f==null||f.clearAllSphere(),p==null||p.updatePolygonList(e,i),p==null||p.updatePointList(I),p==null||p.updateLineList(y),f==null||f.generateBoxes(e),f==null||f.generateSpheres(I),(N=D==null?void 0:D.store)==null||N.updateCurrentSegment(C),_e(E.Default,e)},ft=()=>{le(void 0),de(void 0),ue(void 0),ge(void 0)},_e=(e,i,I)=>Dt(void 0,null,function*(){var y,C,N;if(!f)return;const Ne=f.pointCloudObject;if(!Ne)return;let He=[],Oe=[];try{if(i&&Z.record.length){const{record:L,recordIndex:R}=Z;let B=R;R>0&&(e===E.SingleToggleValid||e===E.SingleRotate||e===E.Single&&i.length===((y=L[R])==null?void 0:y.pointCloudBoxList.length))&&(B=R-1);let Y=(C=L[B])==null?void 0:C.pointCloudBoxList;const Me=mt(e,i,Y);He=Me.modifiedBoxIds,Oe=Me.resetAreas}}catch(L){console.error("call calcResetAreasAndBoxIds error",L)}try{const L=yield f.getHighlightIndexByMappingImgList({mappingImgList:I!=null?I:Q,points:Ne.geometry.attributes.position.array}),R=yield f==null?void 0:f.highlightOriginPointCloud(i,L,{modifiedBoxIds:He,resetAreas:Oe}),{color:B,currentPCDSrc:Y}=R!=null?R:{};return B&&((N=p==null?void 0:p.pointCloudInstance)==null||N.updateColor(B,Y)),B}catch(L){console.error("call highlightOriginPointCloud error",L)}});return{selectedID:Se,pointCloudBoxList:s,pointCloudSphereList:x,displayPointCloudList:Be,displaySphereList:Ae,displayLineList:Ve,selectedIDs:v,setPointCloudResult:De,setSelectedIDs:l,addPointCloudBox:n,addPointCloudSphere:t,setPointCloudSphereList:A,valid:ne,visibleBatchSetValid:Pe,selectedPointCloudBox:o,setPointCloudValid:a,setBatchSetValidModal:d,addSelectedID:S,addHighlightID:k,selectedAllBoxes:dt,topViewInstance:p,setTopViewInstance:le,sideViewInstance:ae,setSideViewInstance:de,backViewInstance:ce,setBackViewInstance:ue,mainViewInstance:f,setMainViewInstance:ge,polygonList:V,setPolygonList:K,rectList:w,setRectList:g,addRectIn2DView:P,removeRectIn2DView:X,updateRectIn2DView:j,lineList:b,setLineList:We,zoom:re,setZoom:Je,history:Z,toggleAttributesVisible:ut,hideAttributes:m,setHideAttributes:U,reRender:gt,attrPanelLayout:pe,setAttrPanelLayout:Ye,syncAllViewPointCloudColor:_e,defaultAttribute:fe,setDefaultAttribute:Qe,pointCloudPattern:W,setPointCloudPattern:Xe,selectSpecAttr:ct,globalPattern:q,setGlobalPattern:e=>{q!==e&&(st(vt),$e(e),e===$.Detection&&me(void 0))},ptSegmentInstance:D,setPtSegmentInstance:me,segmentation:J,setSegmentation:et,clearAllDetectionInstance:ft,highlight2DDataList:Q,setHighlight2DDataList:tt,highlight2DLoading:he,setHighlight2DLoading:ot,cuboidBoxIn2DView:se,setCuboidBoxIn2DView:qe,imageSizes:we,cacheImageNodeSize:rt,highlightIDs:_,setHighlightIDs:T,removeRectByPointCloudBoxId:Ce,removeRectBySpecifyId:O,addRectFromPointCloudBoxByImageName:Le,rectRotateSensitivity:ie,setRectRotateSensitivity:Ue,imageNamePointCloudBoxMap:be,linkageImageNameRectMap:xe,updateRectListByReducer:Re,windowKeydownListenerHook:ye,isLargeStatus:Ie,setIsLargeStatus:ve}},[ne,Pe,v,s,x,V,b,w,p,ae,ce,f,re,m,pe,fe,W,q,D,J,Q,he,se,we,_,Ce,O,Le,ie,be,xe,Re,ye,Ie,ve]);ee(()=>{var o,n,t;(o=h==null?void 0:h.setPointCloudBoxList)==null||o.call(h,s),(n=h==null?void 0:h.setHighlightIDs)==null||n.call(h,_),(t=h==null?void 0:h.setSelectedIDs)==null||t.call(h,v)},[s,v,_]),ee(()=>{var o;(o=h==null?void 0:h.setPtCtx)==null||o.call(h,M)},[M]);const at=()=>{const o=s.filter(d=>m.includes(d.attribute)),{setSelectedIDs:n,reRender:t}=M,a=o.map(d=>d.id);a.length>0&&n(v.filter(d=>!a.includes(d))),t()};return ee(()=>{var o,n,t,a;at(),(n=(o=p==null?void 0:p.toolInstance)==null?void 0:o.setHiddenAttributes)==null||n.call(o,m),(a=(t=D==null?void 0:D.store)==null?void 0:t.setHiddenAttributes)==null||a.call(t,m)},[m]),je.createElement(Te.Provider,{value:M},c)};export{Te as PointCloudContext,Bt as PointCloudProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getClassName as _}from"../../utils/dom.js";import{FooterDivider as K}from"../../views/MainView/toolFooter/index.js";import{ZoomController as Ie}from"../../views/MainView/toolFooter/ZoomController/index.js";import{LeftOutlined as ye,UpSquareOutlined as xe,DownSquareOutlined as
|
|
1
|
+
import{getClassName as _}from"../../utils/dom.js";import{FooterDivider as K}from"../../views/MainView/toolFooter/index.js";import{ZoomController as Ie}from"../../views/MainView/toolFooter/ZoomController/index.js";import{LeftOutlined as ye,UpSquareOutlined as xe,DownSquareOutlined as Ve}from"@ant-design/icons";import{cKeyCode as he,PointCloudAnnotation as Se,MathUtils as M,cTool as _e,cAnnotation as Ee}from"@labelbee/lb-annotation";import{PointCloudUtils as X}from"@labelbee/lb-utils";import{EPointCloudBoxRenderTrigger as Y}from"../../utils/ToolPointCloudBoxRenderHelper.js";import s,{useState as B,useRef as Le,useContext as q,useLayoutEffect as be,useEffect as P}from"react";import{PointCloudContext as $}from"./PointCloudContext.js";import{useRotate as Oe}from"./hooks/useRotate.js";import{useRotateEdge as je}from"./hooks/useRotateEdge.js";import{useSingleBox as G}from"./hooks/useSingleBox.js";import{PointCloudContainer as Te}from"./PointCloudLayout.js";import{BoxInfos as J,PointCloudValidity as De}from"./PointCloudInfos.js";import{usePolygon as Re}from"./hooks/usePolygon.js";import{useSphere as Q}from"./hooks/useSphere.js";import{useZoom as ee}from"./hooks/useZoom.js";import{Slider as ke}from"antd";import{a2MapStateToProps as Be}from"../../store/annotation/map.js";import{connect as Ae}from"react-redux";import{usePointCloudViews as Ne}from"./hooks/usePointCloudViews.js";import Ue from"../../hooks/useSize.js";import{useTranslation as ze}from"react-i18next";import{LabelBeeContext as Ze}from"../../store/ctx.js";import{jsonParser as He}from"../../utils/index.js";import Fe from"../../utils/ToolUtils.js";import We from"lodash";import Ke from"./components/PointCloudSizeSlider/index.js";import{useHistory as Me}from"./hooks/useHistory.js";import Xe from"./components/TitleButton/index.js";var Ye=Object.defineProperty,qe=Object.defineProperties,$e=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertySymbols,Ge=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,oe=(i,l,r)=>l in i?Ye(i,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[l]=r,U=(i,l)=>{for(var r in l||(l={}))Ge.call(l,r)&&oe(i,r,l[r]);if(te)for(var r of te(l))Je.call(l,r)&&oe(i,r,l[r]);return i},z=(i,l)=>qe(i,$e(l));const{EPolygonPattern:Qe,EToolName:ne}=_e,{ESortDirection:ie}=Ee,et=he.default,se=(i,l,r=1)=>{const{width:v,height:m}=l,y={x:i.x+v*r/2,y:i.y+m*r/2},x={x:l.width/2,y:l.height/2};return{offsetX:(x.x-y.x)/r,offsetY:-(x.y-y.y)/r}},tt=({currentData:i})=>{var l,r;const{zoom:v,zoomIn:m,zoomOut:y,initialPosition:x}=ee(),{selectNextBox:O,selectPrevBox:j}=G(),{switchToNextSphere:E}=Q(),{updateRotate:L}=Oe({currentData:i}),{updateRotateEdge:T}=je({currentData:i}),g=q($),{topViewInstance:V}=g,f=(r=(l=g==null?void 0:g.topViewInstance)==null?void 0:l.toolScheduler)==null?void 0:r.getCurrentToolName(),e=()=>{L(-Number(g.rectRotateSensitivity))},d=()=>{L(g.rectRotateSensitivity)},C=()=>{T(-90)};return s.createElement(s.Fragment,null,s.createElement(Ke,{onChange:A=>{var h;(h=V==null?void 0:V.pointCloudInstance)==null||h.updatePointSize({customSize:A})}}),s.createElement("span",{onClick:d,className:_("point-cloud","rotate-reserve")}),s.createElement("span",{onClick:e,className:_("point-cloud","rotate")}),s.createElement("span",{onClick:C,className:_("point-cloud","rotate-90")}),s.createElement(K,null),s.createElement(xe,{onClick:()=>{if(f===ne.Point){E(ie.descend);return}j(!0)},className:_("point-cloud","prev")}),s.createElement(Ve,{onClick:()=>{if(f===ne.Point){E(ie.ascend);return}O(!0)},className:_("point-cloud","next")}),s.createElement(K,null),s.createElement(Ie,{initialPosition:x,zoomIn:m,zoomOut:y,zoom:v}))},ot=({setZAxisLimit:i,zAxisLimit:l,checkMode:r})=>r?null:s.createElement("div",{style:{position:"absolute",top:128,right:8,height:"50%",zIndex:20}},s.createElement(ke,{vertical:!0,step:.5,max:10,min:.5,defaultValue:l,onAfterChange:v=>{i(v)}})),nt=({currentData:i,imgList:l,stepInfo:r,drawLayerSlot:v,checkMode:m,intelligentFit:y,setIsEnlargeTopView:x,isEnlargeTopView:O,onExitZoom:j,highlightAttribute:E})=>{var L,T;const[g,V]=B({zoom:1,currentPos:{x:0,y:0}}),f=Le(null),e=q($),d=Ue(f),C=He(r.config),{setZoom:A,syncTopviewToolZoom:h}=ee(),{hideAttributes:le,setIsLargeStatus:re,selectedID:ae,pointCloudBoxList:ce}=e,{addPolygon:de,deletePolygon:ue}=Re(),{deletePointCloudSphere:pe}=Q(),{deletePointCloudBox:me,changeValidByID:fe}=G(),[N,Ce]=B(10),{t:Z}=ze(),w=Ne(),{pushHistoryWithList:ve}=Me(),[we,D]=B(!0),[H,F]=B(!1);be(()=>{if(!e.topViewInstance&&f.current&&(i==null?void 0:i.url)&&(i==null?void 0:i.result)){const o={width:f.current.clientWidth,height:f.current.clientHeight},a=new Se({container:f.current,size:o,pcdPath:i.url,config:z(U({},C),{pointCloudPattern:e.pointCloudPattern}),checkMode:m,toolName:Fe.getPointCloudToolList(),proxyMode:m,view:"topView"});e.setTopViewInstance(a)}},[i]),P(()=>{H&&ae&&(e.syncAllViewPointCloudColor(Y.Single,ce),F(!1))},[H]),P(()=>{if(!d||!e.topViewInstance||!e.sideViewInstance)return;const{toolInstance:o}=e.topViewInstance;o.singleOn("dataUpdated",(t,n)=>{const u=We.cloneDeep(t).map(c=>z(U({},c),{pointList:X.pointListTransferCanvas2World(c.pointList,d)}));e.setSelectedIDs(n),e.setLineList(u),ve({lineList:u})}),o.singleOn("pointCreated",(t,n)=>{w.topViewAddSphere({newPoint:t,size:d,trackConfigurable:C.trackConfigurable,zoom:n})}),o.singleOn("pointDeleted",t=>{pe(t)}),o.singleOn("pointSelected",t=>{e.setSelectedIDs([t])}),o.singleOn("updatePointByDrag",(t,n)=>{var u;(u=w.topViewUpdatePoint)==null||u.call(w,t,d)}),o.singleOn("polygonCreated",(t,n)=>{if(o.pattern===Qe.Normal||!(i==null?void 0:i.url)){const u=z(U({},t),{pointList:t.pointList.map(c=>X.transferCanvas2World(c,d))});de(u),e.setSelectedIDs(le.includes(t.attribute)?"":t.id);return}D(!1),w.topViewAddBox({polygon:t,size:d,imgList:l,trackConfigurable:C.trackConfigurable,zoom:n,intelligentFit:y}),F(!0)}),o.singleOn("deletedObject",({id:t})=>{me(t),ue(t)}),o.singleOn("deleteSelectedIDs",()=>{e.setSelectedIDs([])}),o.singleOn("addSelectedIDs",t=>{e.addSelectedID(t)}),o.singleOn("setSelectedIDs",t=>{D(!1),e.setSelectedIDs(t)}),o.singleOn("updatePolygonByDrag",t=>{var n;(n=w.topViewUpdateBox)==null||n.call(w,t,d)});const a=t=>{var n;const u=fe(t);u&&e.syncAllViewPointCloudColor(Y.Default,u),e.polygonList.find(c=>c.id===t)&&((n=e.topViewInstance)==null||n.toolInstance.setPolygonValidAndRender(t,!0))};return o.on("validUpdate",a),()=>{o.unbind("validUpdate",a)}},[e,d,i,w,e.polygonList,e.lineList,(L=e.topViewInstance)==null?void 0:L.toolInstance]),P(()=>{var o,a;if(!(d==null?void 0:d.width)||!e.topViewInstance)return;const t=(a=(o=C==null?void 0:C.attributeList)==null?void 0:o[0])==null?void 0:a.value;t&&e.topViewInstance.toolInstance.setDefaultAttribute(t),e.topViewInstance.initSize(d),e.topViewInstance.updatePolygonList(e.displayPointCloudList,e.polygonList),e.topViewInstance.updatePointList(e.displaySphereList),e.topViewInstance.updateLineList(e.displayLineList);const{topViewInstance:{pointCloudInstance:n,toolInstance:u}}=e;u.singleOn("renderZoom",(c,p)=>{const{offsetX:S,offsetY:b}=se(p,d,c);if(n.camera.zoom=c,p){const{x:I,y:R,z:k}=n.initCameraPosition;n.camera.position.set(I+b,R-S,k)}n.camera.updateProjectionMatrix(),n.render(),A(c),h(p,c,d),V({zoom:c,currentPos:p})}),u.singleOn("dragMove",({currentPos:c,zoom:p})=>{const{offsetX:S,offsetY:b}=se(c,d,p);n.camera.zoom=p;const{x:I,y:R,z:k}=n.initCameraPosition;n.camera.position.set(I+b,R-S,k),n.render(),h(c,p,d),V({zoom:p,currentPos:c})})},[d,e.topViewInstance,(T=e.topViewInstance)==null?void 0:T.toolInstance]),P(()=>{var o,a;(a=(o=e.topViewInstance)==null?void 0:o.pointCloudInstance)==null||a.applyZAxisPoints(N)},[N]),P(()=>{var o,a,t,n;w.topViewSelectedChanged({}),(n=(t=(a=(o=e.topViewInstance)==null?void 0:o.toolInstance)==null?void 0:a.selection)==null?void 0:t.hardSetSelectedIDs)==null||n.call(t,e.selectedIDs)},[e.selectedIDs]),P(()=>{const{topViewInstance:o,selectedID:a,selectedPointCloudBox:t,zoom:n}=e;if(!o||!a||!t||!we){D(!0);return}const{center:u}=t,{pointCloudInstance:c,toolInstance:p}=o,S=p.polygonList.find(ge=>ge.id===e.selectedID);if(!S){D(!0);return}const b=M.getRectCenterPoint(S.pointList),I=M.getCurrentPosFromRectCenter(p.size,b,n);p.setCurrentPos(I),p.render();const{x:R,y:k,z:Pe}=c.initCameraPosition;c.camera.position.set(u.x,u.y,Pe),c.render(),h(I,n,d),V({zoom:n,currentPos:I})},[e.selectedID]),P(()=>(window.addEventListener("keydown",W),()=>{window.removeEventListener("keydown",W)}),[]);const W=o=>{const{keyCode:a}=o;a===et.Esc&&j()};return P(()=>{var o,a,t;(t=(a=(o=e.topViewInstance)==null?void 0:o.pointCloud2dOperation)==null?void 0:a.setHighlightAttribute)==null||t.call(a,E)},[e.topViewInstance,E]),s.createElement(Te,{className:_("point-cloud-container","top-view"),title:O?s.createElement("div",{style:{display:"flex",alignItems:"center",position:"relative"}},s.createElement(ye,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{j()}}),s.createElement("span",null,Z("TopView")),s.createElement(J,{checkMode:m,config:C,style:{display:"flex",position:"initial",margin:"0px 20px"}})):s.createElement(Xe,{title:Z("TopView"),onClick:()=>{re(!0),x(!0)}}),toolbar:s.createElement(tt,{currentData:i})},s.createElement("div",{style:{position:"relative",flex:1}},s.createElement("div",{style:{width:"100%",height:"100%"},ref:f},v==null?void 0:v(g)),!O&&s.createElement(J,{checkMode:m,config:C}),s.createElement(ot,{checkMode:m,zAxisLimit:N,setZAxisLimit:Ce}),s.createElement(De,null)))};var it=Ae(Be,null,null,{context:Ze})(nt);export{it 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,g,t)=>new Promise((u,a)=>{var o=i=>{try{e(t.next(i))}catch(l){a(l)}},d=i=>{try{e(t.throw(i))}catch(l){a(l)}},e=i=>i.done?u(i.value):Promise.resolve(i.value).then(o,d);e((t=t.apply(s,g)).next())});const b=({currentData:s})=>{var g;const{mainViewInstance:t,topViewInstance:u,pointCloudBoxList:a,highlight2DDataList:o,setHighlight2DDataList:d}=I(x),e=(g=s==null?void 0:s.mappingImgList)!=null?g:[],i=(r,c,v)=>L(void 0,null,function*(){var p;let h=[...o];if(o.find(n=>n.url===r)?h=o.filter(n=>n.url!==r):h.push({url:r,fallbackUrl:c,calib:v}),d(h),!t||(e==null?void 0:e.length)===0)return;const m=t.pointCloudObject;if(!m)return;const C=yield t.getHighlightIndexByMappingImgList({mappingImgList:h,points:m.geometry.attributes.position.array});try{const n=yield t.highlightOriginPointCloud(a,C),{color:f}=n!=null?n:{};f&&((p=u==null?void 0:u.pointCloudInstance)==null||p.updateColor(f))}catch(n){console.error("toggle2dVisible highlightOriginPointCloud error:",n)}}),l=y(r=>o.findIndex(c=>c.url===r)>=0,[o]);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.24.0-alpha.
|
|
3
|
+
"version": "1.24.0-alpha.24",
|
|
4
4
|
"description": "Provide a complete library of annotation components",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"es": "./es/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@ant-design/icons": "^4.6.2",
|
|
46
|
-
"@labelbee/lb-annotation": "1.28.0-alpha.
|
|
46
|
+
"@labelbee/lb-annotation": "1.28.0-alpha.13",
|
|
47
47
|
"@labelbee/lb-utils": "1.20.0-alpha.1",
|
|
48
48
|
"@labelbee/wavesurfer": "1.1.0",
|
|
49
49
|
"@types/react-dom": "18.3.1",
|