@labelbee/lb-components 1.23.0-alpha.4 → 1.23.0-alpha.40
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/App.js +1 -1
- package/dist/assets/annotation/icon_link.svg.js +1 -0
- package/dist/assets/annotation/icon_unlink.svg.js +1 -0
- package/dist/assets/annotation/pointCloudTool/leftArrow.svg.js +1 -1
- package/dist/assets/annotation/pointCloudTool/rightArrow.svg.js +1 -1
- package/dist/components/LLMToolView/index.js +1 -1
- package/dist/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
- package/dist/components/LLMToolView/sidebar/components/textEditor/index.module.scss.js +1 -1
- package/dist/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
- package/dist/components/LLMToolView/sidebar/index.js +1 -1
- package/dist/components/LLMToolView/utils/data.js +1 -1
- package/dist/components/NLPToolView/index.js +1 -1
- package/dist/components/NLPToolView/textContent/index.js +1 -1
- package/dist/components/audioAnnotate/audioContext/index.js +1 -1
- package/dist/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
- package/dist/components/audioAnnotate/index.js +1 -1
- package/dist/components/audioAnnotate/textInput/index.js +1 -1
- package/dist/components/audioAnnotate/textInput/index.module.scss.js +1 -1
- package/dist/components/audioAnnotate/utils/dataTransform.js +1 -0
- package/dist/components/audioPlayer/clipRegion/index.js +1 -1
- package/dist/components/audioPlayer/index.js +1 -1
- package/dist/components/audioPlayer/useAudioCombine/index.js +3 -2
- package/dist/components/audioPlayer/useAudioSegment/index.js +1 -1
- package/dist/components/longText/index.js +1 -1
- package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
- package/dist/components/pointCloudView/PointCloud2DSingleView.js +1 -1
- package/dist/components/pointCloudView/PointCloud2DView.js +1 -1
- package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
- package/dist/components/pointCloudView/PointCloudContext.js +1 -1
- package/dist/components/pointCloudView/hooks/useDataLinkSwitch.js +1 -0
- package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/dist/components/pointCloudView/hooks/useStatus.js +1 -1
- package/dist/components/pointCloudView/index.js +1 -1
- package/dist/components/subAttributeList/index.js +1 -0
- package/dist/components/videoAnnotate/videoClipTool/index.js +1 -1
- package/dist/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
- package/dist/index.css +31 -9
- package/dist/index.js +1 -1
- package/dist/store/Actions.js +1 -1
- package/dist/store/annotation/actionCreators.js +1 -1
- package/dist/store/annotation/reducer.js +1 -1
- package/dist/types/App.d.ts +3 -1
- package/dist/types/components/LLMToolView/utils/data.d.ts +1 -1
- package/dist/types/components/audioAnnotate/audioContext/index.d.ts +10 -2
- package/dist/types/components/audioAnnotate/textInput/index.d.ts +1 -0
- package/dist/types/components/audioAnnotate/utils/dataTransform.d.ts +9 -0
- package/dist/types/components/audioPlayer/index.d.ts +28 -21
- package/dist/types/components/longText/index.d.ts +1 -0
- package/dist/types/components/pointCloud2DRectOperationView/index.d.ts +1 -0
- package/dist/types/components/pointCloudView/PointCloud2DView.d.ts +1 -1
- package/dist/types/components/pointCloudView/PointCloudContext.d.ts +12 -1
- package/dist/types/components/pointCloudView/hooks/useDataLinkSwitch.d.ts +21 -0
- package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +5 -0
- package/dist/types/components/subAttributeList/index.d.ts +10 -0
- package/dist/types/components/videoAnnotate/index.d.ts +2 -1
- package/dist/types/components/videoAnnotate/videoClipTool/index.d.ts +2 -1
- package/dist/types/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.d.ts +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/store/Actions.d.ts +1 -0
- package/dist/types/store/annotation/actionCreators.d.ts +3 -2
- package/dist/types/store/annotation/reducer.d.ts +1 -0
- package/dist/types/store/annotation/types.d.ts +9 -2
- package/dist/types/utils/AnnotationDataUtils.d.ts +57 -1
- package/dist/types/utils/index.d.ts +25 -1
- package/dist/types/views/MainView/sidebar/TextToolSidebar/index.d.ts +1 -1
- package/dist/types/views/MainView/toolFooter/index.d.ts +1 -1
- package/dist/types/views/MainView/toolHeader/StepSwitch/index.d.ts +1 -1
- package/dist/types/views/MainView/toolHeader/index.d.ts +1 -1
- package/dist/utils/AnnotationDataUtils.js +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/views/MainView/index.js +1 -1
- package/dist/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
- package/dist/views/MainView/sidebar/NLPSidebar/NLPAnnotatedList.js +1 -1
- package/dist/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/dist/views/MainView/sidebar/TagSidebar/index.js +1 -1
- package/dist/views/MainView/sidebar/TextToolSidebar/index.js +1 -1
- package/es/App.js +1 -1
- package/es/assets/annotation/icon_link.svg.js +1 -0
- package/es/assets/annotation/icon_unlink.svg.js +1 -0
- package/es/assets/annotation/pointCloudTool/leftArrow.svg.js +1 -1
- package/es/assets/annotation/pointCloudTool/rightArrow.svg.js +1 -1
- package/es/components/LLMToolView/index.js +1 -1
- package/es/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
- package/es/components/LLMToolView/sidebar/components/textEditor/index.module.scss.js +1 -1
- package/es/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
- package/es/components/LLMToolView/sidebar/index.js +1 -1
- package/es/components/LLMToolView/utils/data.js +1 -1
- package/es/components/NLPToolView/index.js +1 -1
- package/es/components/NLPToolView/textContent/index.js +1 -1
- package/es/components/audioAnnotate/audioContext/index.js +1 -1
- package/es/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
- package/es/components/audioAnnotate/index.js +1 -1
- package/es/components/audioAnnotate/textInput/index.js +1 -1
- package/es/components/audioAnnotate/textInput/index.module.scss.js +1 -1
- package/es/components/audioAnnotate/utils/dataTransform.js +1 -0
- package/es/components/audioPlayer/clipRegion/index.js +1 -1
- package/es/components/audioPlayer/index.js +1 -1
- package/es/components/audioPlayer/useAudioCombine/index.js +3 -2
- package/es/components/audioPlayer/useAudioSegment/index.js +1 -1
- package/es/components/longText/index.js +1 -1
- package/es/components/pointCloud2DRectOperationView/index.js +1 -1
- package/es/components/pointCloudView/PointCloud2DSingleView.js +1 -1
- package/es/components/pointCloudView/PointCloud2DView.js +1 -1
- package/es/components/pointCloudView/PointCloud3DView.js +1 -1
- package/es/components/pointCloudView/PointCloudContext.js +1 -1
- package/es/components/pointCloudView/hooks/useDataLinkSwitch.js +1 -0
- package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
- package/es/components/pointCloudView/hooks/useStatus.js +1 -1
- package/es/components/pointCloudView/index.js +1 -1
- package/es/components/subAttributeList/index.js +1 -0
- package/es/components/videoAnnotate/videoClipTool/index.js +1 -1
- package/es/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
- package/es/index.css +31 -9
- package/es/index.js +1 -1
- package/es/store/Actions.js +1 -1
- package/es/store/annotation/actionCreators.js +1 -1
- package/es/store/annotation/reducer.js +1 -1
- package/es/utils/AnnotationDataUtils.js +1 -1
- package/es/utils/index.js +1 -1
- package/es/views/MainView/index.js +1 -1
- package/es/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
- package/es/views/MainView/sidebar/NLPSidebar/NLPAnnotatedList.js +1 -1
- package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
- package/es/views/MainView/sidebar/TagSidebar/index.js +1 -1
- package/es/views/MainView/sidebar/TextToolSidebar/index.js +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var React=require("react"),antd=require("antd"),ahooks=require("ahooks"),index=require("../../constant/index.js"),icons=require("@ant-design/icons");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const longTextCls=`${index.prefix}-longText`,
|
|
1
|
+
"use strict";var React=require("react"),antd=require("antd"),ahooks=require("ahooks"),index=require("../../constant/index.js"),icons=require("@ant-design/icons");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__objRest=(e,t)=>{var r={};for(var n in e)__hasOwnProp.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&__getOwnPropSymbols)for(var n of __getOwnPropSymbols(e))t.indexOf(n)<0&&__propIsEnum.call(e,n)&&(r[n]=e[n]);return r};const longTextCls=`${index.prefix}-longText`,TextDom=React.forwardRef((e,t)=>{var r=e,{text:n,overflowMaxLines:c,style:o}=r,f=__objRest(r,["text","overflowMaxLines","style"]);const a={whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},l={display:"-webkit-box",WebkitLineClamp:c,WebkitBoxOrient:"vertical",overflow:"hidden"},u=c>1?l:a,s=__spreadValues(__spreadValues({},u),o!=null?o:{});return React__default.default.createElement("div",__spreadValues({style:s,ref:t},f),n)}),LongText=e=>{const{text:t,placement:r="bottom",icon:n=React__default.default.createElement(icons.SearchOutlined,null),openByText:c,style:o,isToolTips:f,overflowMaxLines:a=1}=e,l=React.useRef(null),u=ahooks.useSize(l),s=React.useMemo(()=>{var i,d,v,p;return a>1?l.current&&((i=l.current)==null?void 0:i.clientHeight)<((d=l.current)==null?void 0:d.scrollHeight):l.current&&((v=l.current)==null?void 0:v.clientWidth)<((p=l.current)==null?void 0:p.scrollWidth)},[u]);if(c){let i={placement:r,overlayClassName:`${longTextCls}-popover`,content:t,key:`${s}`};return s||Object.assign(i,{open:!1}),f?React__default.default.createElement(antd.Tooltip,__spreadProps(__spreadValues({},i),{title:t}),React__default.default.createElement(TextDom,{overflowMaxLines:a,style:o,ref:l,text:t})):React__default.default.createElement(antd.Popover,__spreadValues({},i),React__default.default.createElement(TextDom,{overflowMaxLines:a,style:o,ref:l,text:t}))}return React__default.default.createElement("div",{className:longTextCls,style:o},React__default.default.createElement(TextDom,{overflowMaxLines:a,style:o,ref:l,text:t}),s&&React__default.default.createElement(antd.Popover,{placement:r,overlayClassName:`${longTextCls}-popover`,content:t},n))};module.exports=LongText;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(
|
|
1
|
+
"use strict";var ahooks=require("ahooks"),es=require("antd/es"),React=require("react"),reactRedux=require("react-redux"),usePointCloudViews=require("../pointCloudView/hooks/usePointCloudViews.js"),PointCloudContext=require("../pointCloudView/PointCloudContext.js"),map=require("../../store/annotation/map.js"),ctx=require("../../store/ctx.js"),lbAnnotation=require("@labelbee/lb-annotation");function _interopDefaultLegacy(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(u,i,n)=>i in u?__defProp(u,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):u[i]=n,__spreadValues=(u,i)=>{for(var n in i||(i={}))__hasOwnProp.call(i,n)&&__defNormalProp(u,n,i[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(i))__propIsEnum.call(i,n)&&__defNormalProp(u,n,i[n]);return u},__spreadProps=(u,i)=>__defProps(u,__getOwnPropDescs(i));const PointCloud2DRectOperationView=u=>{var i;const{mappingData:n,size:s,config:p,checkMode:E,afterImgOnLoad:S,shouldExcludePointCloudBoxListUpdate:d}=u,v=(i=n==null?void 0:n.url)!=null?i:"",{pointCloudBoxList:R,setPointCloudResult:P,defaultAttribute:_,rectList:g,addRectIn2DView:j,updateRectIn2DView:C,removeRectIn2DView:q}=React.useContext(PointCloudContext.PointCloudContext),{update2DViewRect:B,remove2DViewRect:M}=usePointCloudViews.usePointCloudViews(),m=React__default.default.useRef(null),r=React.useRef(null),I=ahooks.useMemoizedFn(B),x=ahooks.useMemoizedFn(M),D=React.useRef(null),[z,h]=React.useState(!0),b=React.useMemo(()=>g==null?void 0:g.filter(e=>e.imageName===(n==null?void 0:n.path)),[n==null?void 0:n.path,g]),f=ahooks.useLatest(n==null?void 0:n.path),O=e=>{const{boxID:o}=e;if(!d&&o){const t=I==null?void 0:I(e);D.current=t,P(t);return}C(e,!0)},L=e=>{f.current&&j(__spreadProps(__spreadValues({},e),{imageName:f.current}))},V=e=>{if(!d){const o=e.find(t=>t.boxID);if(o){const t=x==null?void 0:x(o);D.current=t,P(t),l();return}}q(e)},A=ahooks.useMemoizedFn(()=>{let e=[];return R.forEach(o=>{const{rects:t=[],id:c,attribute:a,trackID:w}=o,y=t.find(N=>N.imageName===f.current),F=c+"_"+f.current;y&&(e=[...e,__spreadProps(__spreadValues({},y),{boxID:c,id:F,attribute:a,order:w})])}),e}),l=ahooks.useMemoizedFn(()=>{var e,o,t;const c=d?[]:A(),a=(e=r.current)==null?void 0:e.selectedRectID;(o=r.current)==null||o.setResult([...c,...b]),a&&((t=r.current)==null||t.setSelectedRectID(a))});return React.useEffect(()=>{if(m.current){const e=new lbAnnotation.PointCloud2DRectOperation({container:m.current,size:s,config:__spreadProps(__spreadValues({},p),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:E});return r.current=e,r.current.init(),r.current.on("updateDragResult",O),r.current.on("afterAddingDrawingRect",L),r.current.on("deleteSelectedRects",V),()=>{var o,t,c,a;(o=r.current)==null||o.unbind("updateDragResult",O),(t=r.current)==null||t.unbind("afterAddingDrawingRect",L),(c=r.current)==null||c.unbind("deleteSelectedRects",V),(a=r.current)==null||a.destroy()}}},[]),React.useEffect(()=>{h(!0),r.current&&v&&lbAnnotation.ImgUtils.load(v).then(e=>{r.current.setImgNode(e),S(e),h(!1)})},[v]),React.useEffect(()=>{var e;(e=r.current)==null||e.setSize(s)},[s]),React.useEffect(()=>{R!==D.current&&l()},[R]),React.useEffect(()=>{var e,o,t;const c=b.find(a=>a.id===r.current.selectedRectID);(o=(e=r.current)==null?void 0:e.setDefaultAttribute)==null||o.call(e,_),c&&C(__spreadProps(__spreadValues({},(t=r.current)==null?void 0:t.selectedRect),{attribute:_})),l()},[_]),React.useEffect(()=>{l()},[b]),React.useEffect(()=>{l()},[d]),React.useEffect(()=>{var e,o,t,c;const a=(o=(e=r.current)==null?void 0:e.config)!=null?o:{},w=__spreadProps(__spreadValues({},a),{attributeList:(t=p.attributeList)!=null?t:[]});(c=r.current)==null||c.setConfig(JSON.stringify(w))},[p.attributeList]),React__default.default.createElement(es.Spin,{spinning:z},React__default.default.createElement("div",{ref:m,style:__spreadValues({position:"relative"},s)}))};var PointCloud2DRectOperationView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DRectOperationView);module.exports=PointCloud2DRectOperationView$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var dom=require("../../utils/dom.js"),React=require("react"),index=require("../AnnotationView/index.js"),useSize=require("../../hooks/useSize.js"),useSingleBox=require("./hooks/useSingleBox.js"),useHighlight=require("./hooks/useHighlight.js"),index$2=require("./components/HighlightVisible/index.js"),PointCloudContext=require("./PointCloudContext.js"),index$1=require("../pointCloud2DRectOperationView/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__async=(e,
|
|
1
|
+
"use strict";var dom=require("../../utils/dom.js"),React=require("react"),index=require("../AnnotationView/index.js"),useSize=require("../../hooks/useSize.js"),useSingleBox=require("./hooks/useSingleBox.js"),useHighlight=require("./hooks/useHighlight.js"),index$2=require("./components/HighlightVisible/index.js"),PointCloudContext=require("./PointCloudContext.js"),useDataLinkSwitch=require("./hooks/useDataLinkSwitch.js"),index$1=require("../pointCloud2DRectOperationView/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__async=(e,a,i)=>new Promise((s,u)=>{var d=t=>{try{o(i.next(t))}catch(n){u(n)}},r=t=>{try{o(i.throw(t))}catch(n){u(n)}},o=t=>t.done?s(t.value):Promise.resolve(t.value).then(d,r);o((i=i.apply(e,a)).next())});const PointCloud2DSingleView=({view2dData:e,setSelectedID:a,currentData:i,showEnlarge:s,checkMode:u=!1,measureVisible:d})=>{var r;const o=React.useRef(null),t=React.useRef(),{selectedBox:n}=useSingleBox.useSingleBox(),g=useSize(o),{url:m,calib:p,path:b}=e,{toggle2dVisible:S,isHighlightVisible:y}=useHighlight.useHighlight({currentData:i}),[j,x]=React.useState(!1),{cuboidBoxIn2DView:f,cacheImageNodeSize:q}=React.useContext(PointCloudContext.PointCloudContext),P=!e,B=React.useMemo(()=>({zIndex:s?-1:101,is2DView:!f,imageName:e.path}),[s,f,e.path]),{rendered:V,isLinking:_}=useDataLinkSwitch(B),v=c=>{h(),q({path:b,imgNode:c})},h=React.useCallback(()=>{var c,C;const k=(c=t.current)==null?void 0:c.toolInstance;if(a(""),!n||!k)return;const l=e.annotations.find(I=>I.annotation.id===n.info.id);let L="";l&&((C=l==null?void 0:l.annotation.pointList)==null?void 0:C.length)>0&&(k.focusPositionByPointList(l==null?void 0:l.annotation.pointList),L=n.info.id,a(L))},[n,t.current,e.annotations]);React.useEffect(()=>{h()},[h]);const z=()=>__async(void 0,null,function*(){x(!0),yield S(m,p),x(!1)});return React__default.default.createElement("div",{className:dom.getClassName("point-cloud-2d-image"),ref:o},f?React__default.default.createElement(index,{src:(r=e==null?void 0:e.url)!=null?r:"",annotations:e.annotations,size:g,ref:t,globalStyle:{display:P?"none":"block"},afterImgOnLoad:v,zoomInfo:{min:.01,max:1e3,ratio:.4},measureVisible:d}):React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{shouldExcludePointCloudBoxListUpdate:!_,mappingData:e,size:g,checkMode:u,afterImgOnLoad:v}),V),p&&React__default.default.createElement(index$2,{visible:y(m),onClick:z,loading:j,style:{position:"absolute",right:16,top:16,zIndex:s?-1:101}}))};module.exports=PointCloud2DSingleView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var dom=require("../../utils/dom.js"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),reactRedux=require("react-redux"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),map=require("../../store/annotation/map.js"),lbUtils=require("@labelbee/lb-utils"),PointCloud2DSingleView=require("./PointCloud2DSingleView.js"),index=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons"),classNames=require("classnames"),icon_esc=require("../../assets/annotation/common/icon_esc.svg.js"),icon_left_squareOutlined=require("../../assets/annotation/common/icon_left_squareOutlined.svg.js"),icon_right_squareOutlined=require("../../assets/annotation/common/icon_right_squareOutlined.svg.js"),_=require("lodash");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,l,
|
|
1
|
+
"use strict";var dom=require("../../utils/dom.js"),React=require("react"),PointCloudLayout=require("./PointCloudLayout.js"),PointCloudContext=require("./PointCloudContext.js"),reactRedux=require("react-redux"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),map=require("../../store/annotation/map.js"),lbUtils=require("@labelbee/lb-utils"),PointCloud2DSingleView=require("./PointCloud2DSingleView.js"),index$1=require("./components/TitleButton/index.js"),icons=require("@ant-design/icons"),classNames=require("classnames"),icon_esc=require("../../assets/annotation/common/icon_esc.svg.js"),icon_left_squareOutlined=require("../../assets/annotation/common/icon_left_squareOutlined.svg.js"),icon_right_squareOutlined=require("../../assets/annotation/common/icon_right_squareOutlined.svg.js"),_=require("lodash"),index=require("../../utils/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,l,n)=>l in e?__defProp(e,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[l]=n,__spreadValues=(e,l)=>{for(var n in l||(l={}))__hasOwnProp.call(l,n)&&__defNormalProp(e,n,l[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(l))__propIsEnum.call(l,n)&&__defNormalProp(e,n,l[n]);return e},__spreadProps=(e,l)=>__defProps(e,__getOwnPropDescs(l));const EKeyCode=lbAnnotation.cKeyCode.default,ContainerTitle=({showEnlarge:e,isEnlargeTopView:l,data:n,setIsEnlarge:m,setCurIndex:f,curIndex:p=0,index:w,annotations2d:b})=>l?React__default.default.createElement(index$1,{title:n==null?void 0:n.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):e?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{m(!1),f(void 0)}}),React__default.default.createElement("span",null,n==null?void 0:n.calName),React__default.default.createElement("span",{style:{marginLeft:"8px"}},p+1,"/",b==null?void 0:b.length)):React__default.default.createElement(index$1,{title:n==null?void 0:n.calName,onClick:()=>{m(!0),f(w)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),PointCloud2DView=({currentData:e,config:l,thumbnailWidth:n,isEnlargeTopView:m,highlightAttribute:f,loadPCDFileLoading:p,checkMode:w,measureVisible:b})=>{var I;const[d,M]=React.useState([]),{topViewInstance:U,displayPointCloudList:F,polygonList:O,imageSizes:x,selectedIDs:k}=React.useContext(PointCloudContext.PointCloudContext),[P,B]=React.useState(""),[y,L]=React.useState(!1),[s,E]=React.useState(void 0);React.useEffect(()=>{var o;if(!p&&U&&(e==null?void 0:e.mappingImgList)&&((o=e==null?void 0:e.mappingImgList)==null?void 0:o.length)>0){const i={fill:"transparent",color:"green"};let r=[];e==null||e.mappingImgList.forEach(t=>{var v,R,V;const A=F.reduce((a,c)=>{var g,u;const h=c.id===P||f===c.attribute,{transferViewData:q,viewRangePointList:C}=(g=lbAnnotation.pointCloudLidar2image(c,t.calib,{createRange:h}))!=null?g:{};if(!q||!C)return[];const W=q.reduce((H,$)=>$.type==="line"?[...H,...$.pointList]:H,[]),X=__spreadProps(__spreadValues({},index.getBoundingRect(W)),{imageName:t.path});if(!index.isBoundingRectInImage(X,t.path,x))return a;const T=(u=lbUtils.toolStyleConverter.getColorFromConfig({attribute:c.attribute},__spreadProps(__spreadValues({},l),{attributeConfigurable:!0}),{}))==null?void 0:u.stroke,Y=G({viewDataPointList:q,pointCloudBox:c,defaultViewStyle:i,stroke:T}),K=[...a,...Y];return(C==null?void 0:C.length)>0&&K.unshift({type:"polygon",annotation:__spreadProps(__spreadValues({id:P,pointList:C},i),{stroke:T,fill:"rgba(255, 255, 255, 0.6)"})}),K},[]),z=x[(v=t==null?void 0:t.path)!=null?v:""];z&&_.isNumber((R=t==null?void 0:t.calib)==null?void 0:R.groundHeight)&&O.forEach(a=>{const c=a.pointList.map(u=>{var h;return __spreadProps(__spreadValues({},u),{z:(h=t==null?void 0:t.calib)==null?void 0:h.groundHeight})}),g=lbAnnotation.pointListLidar2Img(c,t==null?void 0:t.calib,z);if(g){const u=lbUtils.toolStyleConverter.getColorFromConfig({attribute:a.attribute},__spreadProps(__spreadValues({},l),{attributeConfigurable:!0}),{});A.push({type:"polygon",annotation:__spreadProps(__spreadValues({id:a.id,pointList:g},i),{stroke:u==null?void 0:u.stroke,fill:k.includes(a.id)?u==null?void 0:u.fill:"rgba(255, 255, 255, 0.6)"})})}}),r.push({annotations:A,url:t==null?void 0:t.url,calName:(V=t==null?void 0:t.calib)==null?void 0:V.calName,calib:t==null?void 0:t.calib,path:t==null?void 0:t.path})}),M(r)}},[F,e==null?void 0:e.mappingImgList,P,f,p,O,x,k]),React.useEffect(()=>(window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S)}),[s]);const S=o=>{const{keyCode:i}=o;switch(i){case EKeyCode.Esc:y&&L(!1);break;case EKeyCode.Left:j();break;case EKeyCode.Right:N();break}},j=()=>{s===void 0||!y||Number(s)>0&&E(s-1)},N=()=>{s===void 0||!y||Number(s)<(d==null?void 0:d.length)-1&&E(s+1)},G=({viewDataPointList:o,pointCloudBox:i,defaultViewStyle:r,stroke:t})=>o?o.map(v=>({type:v.type,annotation:__spreadProps(__spreadValues({id:i.id,pointList:v.pointList},r),{stroke:t})})):[],J=!e||!(e==null?void 0:e.mappingImgList)||!(((I=e==null?void 0:e.mappingImgList)==null?void 0:I.length)>0),Q=React__default.default.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},React__default.default.createElement("img",{src:icon_left_squareOutlined,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>j()}),React__default.default.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),React__default.default.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),React__default.default.createElement("img",{src:icon_right_squareOutlined,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>N()}),React__default.default.createElement("img",{src:icon_esc,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{L(!1),E(void 0)}}),React__default.default.createElement("span",null,"\u952E\u9000\u51FA"));return(d==null?void 0:d.length)>0?React__default.default.createElement(React__default.default.Fragment,null,d.map((o,i)=>{const r=y&&i===s;return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-2d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:r}),title:React__default.default.createElement(ContainerTitle,{showEnlarge:r,isEnlargeTopView:m,data:o,setIsEnlarge:L,setCurIndex:E,curIndex:s,index:i,annotations2d:d}),titleOnSurface:!r,style:{display:J?"none":"flex",width:r?"100%":n},key:i,toolbar:Q},(o==null?void 0:o.annotations)&&(o==null?void 0:o.url)&&React__default.default.createElement(PointCloud2DSingleView,{key:o.url,currentData:e,view2dData:o,setSelectedID:B,showEnlarge:r,checkMode:w,measureVisible:b}))})):null};var PointCloud2DView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloud2DView);module.exports=PointCloud2DView$1;
|
|
@@ -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");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,o,i)=>o in t?__defProp(t,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[o]=i,__spreadValues=(t,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(t,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(t,i,o[i]);return t},__spreadProps=(t,o)=>__defProps(t,__getOwnPropDescs(o));const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:t})=>{const{isActive:o,setTarget3DView:i}=React.useContext(PointCloud3DContext),n=u=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",u)]:!0,active:o});return React__default.default.createElement("span",{onClick:()=>{i(lbUtils.EPerspectiveView[t])},className:n(t.toLocaleLowerCase())})},PointCloud3DSideBar=({isEnlarge:t})=>{const{reset3DView:o,followTopView:i}=React.useContext(PointCloud3DContext),{t:n}=reactI18next.useTranslation(),u=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"})),p=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Tooltip,{title:n("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{i()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{o()},className:dom.getClassName("point-cloud-3d-view","reset")}));return t?React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebarZoom")},p,u):React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},u,p)},PointCloud3D=({currentData:t,config:o,highlightAttribute:i})=>{const n=React.useContext(PointCloudContext.PointCloudContext),[u,p]=React.useState(!0),[d,
|
|
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");function _interopDefaultLegacy(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var classNames__default=_interopDefaultLegacy(classNames),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(t,o,i)=>o in t?__defProp(t,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[o]=i,__spreadValues=(t,o)=>{for(var i in o||(o={}))__hasOwnProp.call(o,i)&&__defNormalProp(t,i,o[i]);if(__getOwnPropSymbols)for(var i of __getOwnPropSymbols(o))__propIsEnum.call(o,i)&&__defNormalProp(t,i,o[i]);return t},__spreadProps=(t,o)=>__defProps(t,__getOwnPropDescs(o));const EKeyCode=lbAnnotation.cKeyCode.default,pointCloudID="LABELBEE-POINTCLOUD",PointCloud3DContext=React__default.default.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),PointCloudViewIcon=({perspectiveView:t})=>{const{isActive:o,setTarget3DView:i}=React.useContext(PointCloud3DContext),n=u=>classNames__default.default({[dom.getClassName("point-cloud-3d-view",u)]:!0,active:o});return React__default.default.createElement("span",{onClick:()=>{i(lbUtils.EPerspectiveView[t])},className:n(t.toLocaleLowerCase())})},PointCloud3DSideBar=({isEnlarge:t})=>{const{reset3DView:o,followTopView:i}=React.useContext(PointCloud3DContext),{t:n}=reactI18next.useTranslation(),u=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"})),p=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(antd.Tooltip,{title:n("CameraFollowTopView")},React__default.default.createElement("span",{onClick:()=>{i()},className:dom.getClassName("point-cloud-3d-view","followTop")})),React__default.default.createElement("span",{onClick:()=>{o()},className:dom.getClassName("point-cloud-3d-view","reset")}));return t?React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebarZoom")},p,u):React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-sidebar")},u,p)},PointCloud3D=({currentData:t,config:o,highlightAttribute:i})=>{const n=React.useContext(PointCloudContext.PointCloudContext),[u,p]=React.useState(!0),[d,C]=React.useState(!1),m=React.useRef(null),{initPointCloud3d:E}=usePointCloudViews.usePointCloudViews(),f=useSize(m),{t:g}=reactI18next.useTranslation();React.useEffect(()=>{!n.mainViewInstance||E==null||E(f)},[f]);const{selectedBox:c}=useSingleBox.useSingleBox(),{selectedSphere:v}=useSphere.useSphere(),V=e=>{var a,l;const r=c==null?void 0:c.info;if(r){const s=__spreadValues({},r.center);s.x=s.x-.01,s.z=1e3;const w=e===lbUtils.EPerspectiveView.Top;(a=n.mainViewInstance)==null||a.updateCameraByBox(r,e,w?s:void 0)}v&&((l=n.mainViewInstance)==null||l.updateCameraBySphere(v,e))},_=()=>{var e;(e=n.mainViewInstance)==null||e.resetCamera()},h=()=>{var e,a;const l=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance.camera;l&&((a=n.mainViewInstance)==null||a.applyCameraTarget(l))};React.useEffect(()=>{if(m.current&&(t==null?void 0:t.url)){let e=n.mainViewInstance;!e&&f.width&&(e=new lbAnnotation.PointCloud({container:m.current,isOrthographicCamera:!0,orthographicParams:lbUtils.PointCloudUtils.getDefaultOrthographicParams(f),config:o}),n.setMainViewInstance(e))}},[f,t]),React.useEffect(()=>{var e;if(m.current&&(t==null?void 0:t.url)&&t.result&&n.mainViewInstance){let a=n.mainViewInstance;const l=lbUtils.PointCloudUtils.getBoxParamsFromResultList(t.result);l.forEach(s=>{var w;const b=(w=lbUtils.toolStyleConverter.getColorFromConfig({attribute:s.attribute},__spreadProps(__spreadValues({},o),{attributeConfigurable:!0}),{}))==null?void 0:w.hex;a==null||a.addBoxToSense(s,b)}),a.render(),n.setPointCloudResult(l);const r=lbUtils.PointCloudUtils.getRectParamsFromResultList(t.result);n.setRectList(r),n.setPointCloudValid((e=index.jsonParser(t.result))==null?void 0:e.valid)}},[t,n.mainViewInstance]),React.useEffect(()=>{var e,a,l,r;if(c){V(lbUtils.EPerspectiveView.Top);const s=(l=(a=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?l:1;(r=n.mainViewInstance)==null||r.updateCameraZoom(s)}},[c]),React.useEffect(()=>{var e,a,l,r;if(v){V(lbUtils.EPerspectiveView.Top);const s=(l=(a=(e=n.topViewInstance)==null?void 0:e.pointCloudInstance)==null?void 0:a.camera.zoom)!=null?l:1;(r=n.mainViewInstance)==null||r.updateCameraZoom(s)}},[v]),React.useEffect(()=>(window.addEventListener("keydown",P),()=>{window.removeEventListener("keydown",P)}),[]);const P=e=>{if(e.keyCode===EKeyCode.Esc){C(!1);return}},x=React.useMemo(()=>({reset3DView:_,setTarget3DView:V,isActive:!!c,followTopView:h}),[c,n.mainViewInstance]);React.useEffect(()=>{var e,a,l;const r=n.pointCloudBoxList.filter(s=>s.attribute===i);(r==null?void 0:r.length)>0&&((e=n.mainViewInstance)==null||e.clearHighlightBoxes(),(a=n.mainViewInstance)==null||a.highlightBoxes(r)),r.length===0&&((l=n.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[i,n.mainViewInstance]);const I=React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(index$1,{onChange:e=>{var a;(a=n.mainViewInstance)==null||a.updatePointSize({customSize:e})}}),React__default.default.createElement("span",{style:{marginRight:8}},g("ShowArrows")),React__default.default.createElement(antd.Switch,{size:"small",checked:u,onChange:e=>{var a;p(e),(a=n.mainViewInstance)==null||a.setShowDirection(e)}}),d&&React__default.default.createElement(PointCloud3DContext.Provider,{value:x},React__default.default.createElement(PointCloud3DSideBar,{isEnlarge:d})));return React__default.default.createElement(PointCloudLayout.PointCloudContainer,{className:classNames__default.default({[dom.getClassName("point-cloud-3d-container")]:!0,[dom.getClassName("point-cloud-container","zoom")]:d}),title:d?React__default.default.createElement("div",{style:{display:"flex",alignItems:"center"}},React__default.default.createElement(icons.LeftOutlined,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{C(!1)}}),g("3DView")):React__default.default.createElement(index$2,{title:g("3DView"),onClick:()=>{C(!0)}}),toolbar:I},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-content")},!d&&React__default.default.createElement(PointCloud3DContext.Provider,{value:x},React__default.default.createElement(PointCloud3DSideBar,null)),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-3d-view"),id:pointCloudID,ref:m})))};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"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),actionCreators=require("../../store/annotation/actionCreators.js"),index=require("../../store/annotatedBox/index.js");function _interopDefaultLegacy(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbUtils=require("@labelbee/lb-utils"),React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),ctx=require("../../store/ctx.js"),actionCreators=require("../../store/annotation/actionCreators.js"),index=require("../../store/annotatedBox/index.js"),_=require("lodash");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,e,l)=>e in o?__defProp(o,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):o[e]=l,__spreadValues=(o,e)=>{for(var l in e||(e={}))__hasOwnProp.call(e,l)&&__defNormalProp(o,l,e[l]);if(__getOwnPropSymbols)for(var l of __getOwnPropSymbols(e))__propIsEnum.call(e,l)&&__defNormalProp(o,l,e[l]);return o},__spreadProps=(o,e)=>__defProps(o,__getOwnPropDescs(e)),__async=(o,e,l)=>new Promise((w,x)=>{var A=f=>{try{S(l.next(f))}catch(b){x(b)}},H=f=>{try{S(l.throw(f))}catch(b){x(b)}},S=f=>f.done?w(f.value):Promise.resolve(f.value).then(A,H);S((l=l.apply(o,e)).next())});const pickRectObject=o=>___default.default.pick(o,["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,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},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:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:o=>{},imageSizes:{},cacheImageNodeSize:()=>{},unlinkImageItems:[],addRectFromPointCloudBoxByImageName:o=>!1,removeRectBySpecifyId:(o,e,l)=>!1,removeRectByPointCloudBoxId:o=>!1}),PointCloudProvider=({children:o})=>{const[e,l]=React.useState([]),[w,x]=React.useState([]),[A,H]=React.useState([]),[S,f]=React.useState([]),[b,ut]=React.useState([]),[m,E]=React.useState([]),[R,j]=React.useState([]),[Z,ct]=React.useState(!0),[U,ft]=React.useState(!0),[J,pt]=React.useState(1),[p,K]=React.useState(),[Q,W]=React.useState(),[X,Y]=React.useState(),[u,$]=React.useState(),[tt,gt]=React.useState(""),[k,ht]=React.useState(lbAnnotation.EToolName.Rect),vt=React.useRef(new lbAnnotation.ActionsHistory).current,[g,F]=React.useState([]),[et,mt]=React.useState(""),[q,Pt]=React.useState(lbUtils.EPointCloudPattern.Detection),[L,nt]=React.useState(void 0),[z,It]=React.useState([]),[M,St]=React.useState([]),h=index(),[it,bt]=React.useState({}),Ct=ctx.useDispatch(),yt=s=>{const{imgNode:r,path:i}=s;i&&r&&bt(c=>__spreadProps(__spreadValues({},c),{[i]:{width:r.width,height:r.height}}))},ot=React.useMemo(()=>m.length===1?m[0]:"",[m]),V=React.useCallback((s,r,i="extId")=>{const c=i||"id",d=new Set(r);return f(v=>{let C=!1;const y=v.filter(O=>{const G=O[c],N=d.has(G)?O.imageName!==s:!0;return N||(C=!0),N});return C?y:v}),!0},[]),st=React.useCallback(s=>{const r=e.map(i=>i.id);return V(s,r,"extId")},[e,V]),rt=React.useCallback(s=>{if(!s)return!1;const r=e.filter(i=>Array.isArray(i.rects)).map(i=>{const{id:c,attribute:d,trackID:v}=i,C=i.rects.find(y=>y.imageName===s);if(C){const y=___default.default.pick(C,["width","height","x","y","imageName"]);return __spreadProps(__spreadValues({},y),{id:lbAnnotation.uuid(),attribute:d,order:v,extId:c,lineDash:[]})}return null}).filter(i=>i!==null);return r.length?(f(i=>{const c=new Set(i.filter(v=>s===v.imageName).map(v=>v.extId)),d=r.filter(v=>c.has(v.extId)===!1);return d.length?[...i,...d]:i}),!0):!1},[e]),B=React.useMemo(()=>{const s=e.find(t=>t.id===ot),r=t=>{const n=e.concat(t);return l(n),n},i=t=>{const n=w.concat(t);return x(n),n},c=t=>{ct(t!==!1)},d=t=>{t===void 0&&E([]),typeof t=="string"&&E([t]),Array.isArray(t)&&E(Array.from(new Set(t)))},v=t=>{m.includes(t)?d(m.filter(n=>n!==t)):d([...m,t])},C=t=>{const n=pickRectObject(t);f(a=>[...a,n])},y=(t,n=!1)=>{const a=pickRectObject(t);f(I=>I.map(P=>P.id===t.id?n?__spreadValues(__spreadValues({},P),a):a:P))},O=t=>{f(n=>n.filter(a=>!t.find(I=>I.id===a.id)))},G=t=>{R.includes(t)?j([]):j([t])},N=()=>{if(k===lbAnnotation.EToolName.Rect){const t=e.map(n=>n.id);d(t),p==null||p.pointCloud2dOperation.setSelectedIDs(t)}},Lt=t=>{d(e.filter(n=>n.attribute===t).map(n=>n.id))},T=e.filter(t=>!g.includes(t.attribute)),lt=w.filter(t=>!g.includes(t.attribute)),at=b.filter(t=>t.attribute&&!g.includes(t.attribute)),Dt=t=>{if(g.includes(t))F(g.filter(n=>n!==t));else{const n=g.concat(t);F(n)}},xt=(()=>{const t=T.map(a=>a.id),n=new Set(t);return S.filter(a=>a.extId&&n.has(a.extId)).map(a=>a.imageName)})(),_t=(t=T,n=A,a=lt,I=at,P=z)=>{var D;u==null||u.clearAllBox(),u==null||u.clearAllSphere(),p==null||p.updatePolygonList(t,n),p==null||p.updatePointList(a),p==null||p.updateLineList(I),u==null||u.generateBoxes(t),u==null||u.generateSpheres(a),(D=L==null?void 0:L.store)==null||D.updateCurrentSegment(P),dt(t)},At=()=>{K(void 0),W(void 0),Y(void 0),$(void 0)},dt=(t,n)=>__async(void 0,null,function*(){var a;if(!u)return;const I=u.pointCloudObject;if(!!I)try{const P=yield u.getHighlightIndexByMappingImgList({mappingImgList:n!=null?n:M,points:I.geometry.attributes.position.array}),D=yield u==null?void 0:u.highlightOriginPointCloud(t,P);return D&&((a=p==null?void 0:p.pointCloudInstance)==null||a.updateColor(D)),D}catch(P){console.error(P)}});return{selectedID:ot,pointCloudBoxList:e,pointCloudSphereList:w,displayPointCloudList:T,displaySphereList:lt,displayLineList:at,selectedIDs:m,setPointCloudResult:l,setSelectedIDs:d,addPointCloudBox:r,addPointCloudSphere:i,setPointCloudSphereList:x,valid:Z,selectedPointCloudBox:s,setPointCloudValid:c,addSelectedID:v,addHighlightID:G,selectedAllBoxes:N,topViewInstance:p,setTopViewInstance:K,sideViewInstance:Q,setSideViewInstance:W,backViewInstance:X,setBackViewInstance:Y,mainViewInstance:u,setMainViewInstance:$,polygonList:A,setPolygonList:H,rectList:S,setRectList:f,addRectIn2DView:C,removeRectIn2DView:O,updateRectIn2DView:y,lineList:b,setLineList:ut,zoom:J,setZoom:pt,history:vt,toggleAttributesVisible:Dt,hideAttributes:g,setHideAttributes:F,reRender:_t,attrPanelLayout:et,setAttrPanelLayout:mt,syncAllViewPointCloudColor:dt,defaultAttribute:tt,setDefaultAttribute:gt,pointCloudPattern:k,setPointCloudPattern:ht,selectSpecAttr:Lt,globalPattern:q,setGlobalPattern:t=>{q!==t&&(Ct(actionCreators.ChangeSave),Pt(t),t===lbUtils.EPointCloudPattern.Detection&&nt(void 0))},ptSegmentInstance:L,setPtSegmentInstance:nt,segmentation:z,setSegmentation:It,clearAllDetectionInstance:At,highlight2DDataList:M,setHighlight2DDataList:St,cuboidBoxIn2DView:U,setCuboidBoxIn2DView:ft,imageSizes:it,cacheImageNodeSize:yt,highlightIDs:R,setHighlightIDs:j,unlinkImageItems:xt,removeRectByPointCloudBoxId:st,removeRectBySpecifyId:V,addRectFromPointCloudBoxByImageName:rt}},[Z,m,e,w,A,b,S,p,Q,X,u,J,g,et,tt,k,q,L,z,M,U,it,R,st,V,rt]);React.useEffect(()=>{var s,r,i;(s=h==null?void 0:h.setPointCloudBoxList)==null||s.call(h,e),(r=h==null?void 0:h.setHighlightIDs)==null||r.call(h,R),(i=h==null?void 0:h.setSelectedIDs)==null||i.call(h,m)},[e,m,R]),React.useEffect(()=>{var s;(s=h==null?void 0:h.setPtCtx)==null||s.call(h,B)},[B]);const wt=()=>{const s=e.filter(d=>g.includes(d.attribute)),{setSelectedIDs:r,reRender:i}=B,c=s.map(d=>d.id);c.length>0&&r(m.filter(d=>!c.includes(d))),i()};return React.useEffect(()=>{var s,r,i,c;wt(),(r=(s=p==null?void 0:p.toolInstance)==null?void 0:s.setHiddenAttributes)==null||r.call(s,g),(c=(i=L==null?void 0:L.store)==null?void 0:i.setHiddenAttributes)==null||c.call(i,g)},[g]),React__default.default.createElement(PointCloudContext.Provider,{value:B},o)};exports.PointCloudContext=PointCloudContext,exports.PointCloudProvider=PointCloudProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var React=require("react"),ahooks=require("ahooks"),PointCloudContext=require("../PointCloudContext.js"),icon_link=require("../../../assets/annotation/icon_link.svg.js"),icon_unlink=require("../../../assets/annotation/icon_unlink.svg.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React);const iconSize={width:16,height:16},useDataLinkSwitch=e=>{e.imageName||console.warn("missing imageName");const[n,l]=React.useState(!0),r=React.useRef(e.imageName);r.current=e.imageName;const{unlinkImageItems:c,addRectFromPointCloudBoxByImageName:d,removeRectByPointCloudBoxId:m}=React.useContext(PointCloudContext.PointCloudContext),g=ahooks.useLatest(d),f=ahooks.useLatest(m),i=React.useCallback(t=>{const a=r.current;if(!a){console.warn("invalid image name");return}l(t),t?f.current(a):g.current(a)},[]),u=React.useCallback(()=>{i(!n)},[i,n]),h=React.useMemo(()=>{var t;if(!e.is2DView)return null;const o={zIndex:(t=e.zIndex)!=null?t:999,position:"absolute",top:16,right:16+28+12,background:"rgba(0, 0, 0, 0.74)",color:"white",borderRadius:2,padding:6,display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,cursor:"pointer"};return React__default.default.createElement("div",{style:o,onClick:u},n&&React__default.default.createElement("img",{src:icon_link,style:iconSize}),!n&&React__default.default.createElement("img",{src:icon_unlink,style:iconSize}))},[n,e.is2DView,e.zIndex,u]),s=React.useCallback(()=>{if(!e.is2DView)return;const t=r.current;if(!t){console.warn("invalid image name");return}const o=new Set(c).has(t)===!1;i(o)},[e.is2DView,c,i]);return React.useEffect(()=>{s()},[s]),{rendered:h,isLinking:n,swapSwitch:i,syncIsLinking:s}};module.exports=useDataLinkSwitch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__spreadValues=(e,t)=>{for(var n in t||(t={}))__hasOwnProp.call(t,n)&&__defNormalProp(e,n,t[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(t))__propIsEnum.call(t,n)&&__defNormalProp(e,n,t[n]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,n)=>new Promise((a,o)=>{var d=u=>{try{c(n.next(u))}catch(f){o(f)}},P=u=>{try{c(n.throw(u))}catch(f){o(f)}},c=u=>u.done?a(u.value):Promise.resolve(u.value).then(d,P);c((n=n.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,n,a,o)=>{const{x:d,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,u={center:{x:d,y:P,z:c},id:e.id},f=a?__spreadValues(__spreadValues({},a),u):__spreadProps(__spreadValues({},u),{attribute:"",valid:!0});return o&&Object.assign(f,o),f},topViewPolygon2PointCloud=(e,t,n,a,o,d)=>{let P=e.pointList.map(y=>lbUtils.PointCloudUtils.transferCanvas2World(y,t)),c=0,u=1,f={};if(n){const y=n.getSensesPointZAxisInPolygon(P,void 0,d);d&&y.fittedCoordinates.length>0&&(P=y.fittedCoordinates),c=(y.maxZ+y.minZ)/2,u=y.maxZ-y.minZ,f={count:y.zCount}}const[v,B,j]=P,_=lbAnnotation.MathUtils.getLineCenterPoint([v,j]),O=lbAnnotation.MathUtils.getLineLength(v,B),I=lbAnnotation.MathUtils.getLineLength(B,j),A=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);a&&(c=a.center.z,u=a.depth);const k={center:{x:_.x,y:_.y,z:c},width:d?I+INTELLIGENT_FIT_MARGIN:I,height:d?O+INTELLIGENT_FIT_MARGIN:O,depth:u,rotation:A,id:e.id},R=__spreadValues(a?__spreadValues(__spreadValues({},a),k):__spreadProps(__spreadValues({},k),{attribute:"",valid:!0}),f);o&&Object.assign(R,o);const z=P.map(y=>lbUtils.PointCloudUtils.transferWorld2Canvas(y,t));return{boxParams:R,newPointList:z}},sideViewPoint2PointCloud=(e,t,n)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},n),{center:{x:n.center.x-a.x,y:n.center.y,z:n.center.z-a.y}})},sideViewPolygon2PointCloud=(e,t,n,a)=>{const[o,d,P]=e.pointList,[c,u,f]=t.pointList,v=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),B=lbAnnotation.MathUtils.getLineCenterPoint([c,f]),_={x:{x:v.x-B.x,y:v.y-B.y}.x,y:0,z:v.y-B.y},O=lbAnnotation.MathUtils.getLineLength(o,d),I=lbAnnotation.MathUtils.getLineLength(c,u),A=O-I,k=lbAnnotation.MathUtils.getLineLength(d,P),R=lbAnnotation.MathUtils.getLineLength(u,f),z=k-R,{newBoxParams:y}=a.getNewBoxBySideUpdate(_,z,A,n);return y},backViewPoint2PointCloud=(e,t,n)=>{const a={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},n),{center:{x:n.center.x,y:n.center.y-a.x,z:n.center.z-a.y}})},backViewPolygon2PointCloud=(e,t,n,a)=>{const[o,d,P]=e.pointList,[c,u,f]=t.pointList,v=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),B=lbAnnotation.MathUtils.getLineCenterPoint([c,f]),_={x:{x:v.x-B.x,y:v.y-B.y}.x,y:0,z:v.y-B.y},O=lbAnnotation.MathUtils.getLineLength(o,d),I=lbAnnotation.MathUtils.getLineLength(c,u),A=O-I,k=lbAnnotation.MathUtils.getLineLength(d,P),R=lbAnnotation.MathUtils.getLineLength(u,f),z=k-R;let{newBoxParams:y}=a.getNewBoxByBackUpdate(_,z,A,n);return y},syncSideViewByPoint=(e,t,n,a,o)=>{var d;if(!n)return;const{toolInstance:P,pointCloudInstance:c}=n;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(u);const{point2d:f,zoom:v}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=v,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(v),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),f),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,n,a)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=n;d.loadPCDFileByBox(a,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxSidePolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,n,a,o)=>{var d;if(!n)return;const{toolInstance:P,pointCloudInstance:c}=n;c.loadPCDFile(a,(d=o==null?void 0:o.radius)!=null?d:DEFAULT_RADIUS);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(u);const{point2d:f,zoom:v}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=v,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(v),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),f),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,n,a)=>{if(!n)return;const{pointCloud2dOperation:o,pointCloudInstance:d}=n;d.loadPCDFileByBox(a,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=d.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);d.setInitCameraPosition(P);const{polygon2d:c,zoom:u}=d.getBoxBackPolygon2DCoordinate(e);d.camera.zoom=u,d.camera.updateProjectionMatrix(),d.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,n,a)=>{if(!n||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),a.render();const{toolInstance:o,pointCloudInstance:d}=n,{point2d:P}=d.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},synchronizeTopView=(e,t,n,a)=>{var o,d;if(!n||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=n,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),f=[...P.polygonList],v=f.find(B=>B.id===t.id);v?(v.pointList=u,v.valid=(o=e.valid)!=null?o:!0):f.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(d=e.valid)!=null?d:!0}),P.setResultAndSelectedID(f,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:n,backViewInstance:a,mainViewInstance:o,addPointCloudBox:d,addPointCloudSphere:P,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:f,pointCloudSphereList:v,hideAttributes:B,setHighlight2DDataList:j,cuboidBoxIn2DView:_,imageSizes:O}=e,{addHistory:I,initHistory:A,pushHistoryUnderUpdatePolygon:k}=useHistory.useHistory(),{selectedPolygon:R}=usePolygon.usePolygon(),{getPointCloudSphereByID:z,updatePointCloudSphere:y,selectedSphere:q}=useSphere.useSphere(),{currentData:M,config:w}=ctx.useSelector(i=>{const{stepList:s,step:p,imgList:l,imgIndex:r}=i.annotation;return{currentData:l[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(p,s).config)}}),T=ctx.useDispatch(),tt=ahooks.useLatest(_),W=i=>{if(!tt.current){const{mappingImgList:s=[]}=M,p=s.map(l=>index.getRectPointCloudBox({pointCloudBox:i,mappingData:l,imageSizes:O}));Object.assign(i,{rects:p.filter(l=>l!==void 0)})}},{selectedBox:S,updateSelectedBox:ot,updateSelectedBoxes:Z,getPointCloudByID:et}=useSingleBox.useSingleBox({generateRects:W}),Q=S==null?void 0:S.info;if(!t||!n||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,it=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},nt=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},st=({newPoint:i,size:s,zoom:p,trackConfigurable:l})=>{var r;const C={attribute:(r=t.toolInstance.defaultAttribute)!=null?r:""};l===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const h=topViewPoint2PointCloud(i,s,G,void 0,C);c(i.id);const x=P(h);F(PointCloudView.Top,i,h,p,x,w),I({newSphereParams:h})},lt=({polygon:i,size:s,imgList:p,trackConfigurable:l,zoom:r,intelligentFit:C})=>{var h,x;const g={attribute:(h=t.toolInstance.defaultAttribute)!=null?h:""};l===!0&&Object.assign(g,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:f,extraSphereList:v})});const b=t==null?void 0:t.toolInstance,m=__spreadValues({},i);let{boxParams:L,newPointList:D}=topViewPolygon2PointCloud(m,s,G,void 0,g,C);L=T(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[L],stepConfig:w,action:"viewUpdateBox"}))[0],C&&(D==null?void 0:D.length)&&(m.pointList=D);const U=B.includes(m.attribute);W(L);const N=d(L),J=(x=e==null?void 0:e.polygonList)!=null?x:[];t==null||t.updatePolygonList(N!=null?N:[],J),U?c([]):(c(L.id),b.selection.setSelectedIDs(m.id),E({omitView:PointCloudView.Top,polygon:m,boxParams:L,zoom:r,newPointCloudBoxList:N}),C&&synchronizeTopView(L,m,t,o)),I({newBoxParams:L})},rt=i=>{const{boxID:s,imageName:p,width:l,height:r,x:C,y:h}=i,x=f.find(g=>g.id===s);if(x==null?void 0:x.rects){const{rects:g=[]}=x,b=g.find(m=>m.imageName===p);if(b){let m=g;const L=__spreadProps(__spreadValues({},b),{width:l,height:r,x:C,y:h});m=g.map(U=>U===b?L:U);const D=__spreadProps(__spreadValues({},x),{rects:m}),V=f.map(U=>U===x?D:U);return t==null||t.updatePolygonList(V!=null?V:[]),V}}},at=({newSelectedBox:i,newPointCloudList:s,newSelectedSphere:p,newSphereList:l})=>{var r;const C=t==null?void 0:t.toolInstance;if(!(u.length===0||!C)){if(i||(S==null?void 0:S.info)){const h=i!=null?i:S==null?void 0:S.info;(r=C==null?void 0:C.selection)==null||r.setSelectedIDs(u[0]);const x=C.selectedPolygon;if(u.length===1&&h){E({omitView:PointCloudView.Top,polygon:x,boxParams:h,newPointCloudBoxList:s});return}}if((p||q)&&u.length===1){const h=p!=null?p:q;C.setSelectedID(u[0]);const x=C.selectedPoint;h&&F(PointCloudView.Top,x,h,void 0,l,w)}}},X=(i,s,p)=>{if(Q){let l,r;switch(p){case PointCloudView.Back:l=backViewPolygon2PointCloud;break;case PointCloudView.Side:l=sideViewPolygon2PointCloud;break;default:l=sideViewPolygon2PointCloud;break}if(r=l(i,s,Q,n.pointCloudInstance),o){const{count:b}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:b})}const h=T(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:w,action:"viewUpdateBox"}))[0],x=r.valid!==h.valid;r=h;const g=ot(r);return r=g.find(b=>b.id===r.id),E({omitView:x?void 0:p,polygon:i,boxParams:r,newPointCloudBoxList:g}),g}},Y=(i,s,p)=>{if(q){let l,r;switch(p){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}r=l(i,s,q);const C=y(r);return F(p,i,r,void 0,C,w),C}},dt=(i,s)=>{Y(i,s,PointCloudView.Side)},ct=(i,s)=>{Y(i,s,PointCloudView.Back)},ut=(i,s)=>{X(i,s,PointCloudView.Side)},pt=(i,s)=>{X(i,s,PointCloudView.Back)},Pt=(i,s)=>{const p=z(i.id),l=topViewPoint2PointCloud(i,s,G,p),r=y(l);F(PointCloudView.Top,i,l,void 0,r,w)},Ct=(i,s)=>{if(R){const l=__spreadValues({},i[0].newPolygon);l.pointList=l.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,s)),k(l);return}let p=i.map(({newPolygon:l})=>{const r=et(l.id),{boxParams:C}=topViewPolygon2PointCloud(l,s,t.pointCloudInstance,r);return C});if(p=T(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:p,stepConfig:w,action:"viewUpdateBox"})),p.length===1){const{newPolygon:l}=i[0],r=Z(p);E({polygon:l,boxParams:p[0],newPointCloudBoxList:r})}else{const l=Z(p);l&&e.syncAllViewPointCloudColor(l)}},gt=i=>{var s,p,l,r,C;if(S){const h=Number(i.widthDefault),x=Number(i.depthDefault),g=Number(i.heightDefault),b=S==null?void 0:S.info.trackID,L=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(H=>(H==null?void 0:H.trackID)===b),D={width:(l=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:l.width,height:(C=(r=t==null?void 0:t.toolInstance)==null?void 0:r.basicImgInfo)==null?void 0:C.height},V=L.pointList.map(H=>lbUtils.PointCloudUtils.transferCanvas2World(H,D)),U=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(V,g,h),N=U[0],J=U[2],K=lbAnnotation.MathUtils.getLineCenterPoint([N,J]),ht=S.info.center.z-S.info.depth/2,$=__spreadProps(__spreadValues({},S.info),{center:{x:K.x,y:K.y,z:ht+x/2},width:h,height:g,depth:x,valid:!0}),ft=Z([$]);E({omitView:PointCloudView["3D"],polygon:L,boxParams:$,newPointCloudBoxList:ft})}},F=(i,s,p,l,r,C)=>__async(void 0,null,function*(){const h=M==null?void 0:M.url,x={[PointCloudView.Side]:()=>{syncSideViewByPoint(p,s,n,h,C)},[PointCloudView.Back]:()=>{a&&syncBackViewByPoint(p,s,a,h,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(p,s,t,o)}};Object.keys(x).forEach(g=>{g!==i&&x[g]()}),l&&(o==null||o.updateCameraZoom(l)),nt(p)}),E=i=>__async(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:l,zoom:r,newPointCloudBoxList:C}=i,h=M==null?void 0:M.url;C&&(yield e.syncAllViewPointCloudColor(C));const x={[PointCloudView.Side]:()=>{synchronizeSideView(l,p,n,h)},[PointCloudView.Back]:()=>{a&&synchronizeBackView(l,p,a,h)},[PointCloudView.Top]:()=>{synchronizeTopView(l,p,t,o)}};Object.keys(x).forEach(g=>{g!==s&&x[g]()}),r&&(o==null||o.updateCameraZoom(r)),it(l)});return{topViewAddSphere:st,topViewAddBox:lt,topViewSelectedChanged:at,topViewUpdatePoint:Pt,sideViewUpdatePoint:dt,backViewUpdatePoint:ct,topViewUpdateBox:Ct,sideViewUpdateBox:ut,backViewUpdateBox:pt,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const s=lbUtils.PointCloudUtils.getDefaultOrthographicParams(i);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>__async(void 0,[...i],function*(s=M){var p,l,r,C,h,x;if(!(s==null?void 0:s.url)||!o)return;j([]),actionCreators.SetPointCloudLoading(T,!0),actionCreators.SetLoadPCDFileLoading(T,!0),yield o.loadPCDFile(s.url,(p=w==null?void 0:w.radius)!=null?p:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let g=[],b=[],m=[],L=[];o.updateTopCamera();const D=(r=(l=index.jsonParser(s.result))==null?void 0:l.valid)!=null?r:!0;if(e.setPointCloudValid(D),(C=e.sideViewInstance)==null||C.clearAllData(),(h=e.backViewInstance)==null||h.clearAllData(),s.result){if(g=lbUtils.PointCloudUtils.getBoxParamsFromResultList(s.result),(g==null?void 0:g.length)>0&&s.isPreResult&&(w==null?void 0:w.lowerLimitPointsNumInBox)>0){g=yield o==null?void 0:o.filterPreResult(s.url,w,g);const V=index.jsonParser(s.result);V[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=g,s.result=JSON.stringify(V),e.setPointCloudResult(g)}m=lbUtils.PointCloudUtils.getPolygonListFromResultList(s.result),b=lbUtils.PointCloudUtils.getLineListFromResultList(s.result),L=lbUtils.PointCloudUtils.getSphereParamsFromResultList(s.result),t.updateData(s.url,s.result,{radius:(x=w==null?void 0:w.radius)!=null?x:DEFAULT_RADIUS}),o==null||o.generateBoxes(g),o==null||o.generateSpheres(L),yield e.syncAllViewPointCloudColor(g,[])}A({pointCloudBoxList:g,polygonList:m,lineList:b,pointCloudSphereList:L}),actionCreators.SetPointCloudLoading(T,!1),actionCreators.SetLoadPCDFileLoading(T,!1)}),updateViewsByDefaultSize:gt,generateRects:W,update2DViewRect:rt}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),React=require("react"),PointCloudContext=require("../PointCloudContext.js"),useSingleBox=require("./useSingleBox.js"),useSphere=require("./useSphere.js"),ctx=require("../../../store/ctx.js"),StepUtils=require("../../../utils/StepUtils.js"),index=require("../../../utils/index.js"),actionCreators=require("../../../store/annotation/actionCreators.js"),useHistory=require("./useHistory.js"),usePolygon=require("./usePolygon.js"),ahooks=require("ahooks"),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,s)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,__spreadValues=(e,t)=>{for(var s in t||(t={}))__hasOwnProp.call(t,s)&&__defNormalProp(e,s,t[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(t))__propIsEnum.call(t,s)&&__defNormalProp(e,s,t[s]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,s)=>new Promise((d,o)=>{var u=p=>{try{c(s.next(p))}catch(h){o(h)}},P=p=>{try{c(s.throw(p))}catch(h){o(h)}},c=p=>p.done?d(p.value):Promise.resolve(p.value).then(u,P);c((s=s.apply(e,t)).next())});const DEFAULT_SCOPE=5,DEFAULT_RADIUS=90,INTELLIGENT_FIT_MARGIN=.01,PointCloudView={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},topViewPoint2PointCloud=(e,t,s,d,o)=>{const{x:u,y:P}=lbUtils.PointCloudUtils.transferCanvas2World(e,t),{defaultZ:c}=lbUtils.DEFAULT_SPHERE_PARAMS,p={center:{x:u,y:P,z:c},id:e.id},h=d?__spreadValues(__spreadValues({},d),p):__spreadProps(__spreadValues({},p),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},topViewPolygon2PointCloud=(e,t,s,d,o,u)=>{let P=e.pointList.map(m=>lbUtils.PointCloudUtils.transferCanvas2World(m,t)),c=0,p=1,h={};if(s){const m=s.getSensesPointZAxisInPolygon(P,void 0,u);u&&m.fittedCoordinates.length>0&&(P=m.fittedCoordinates),c=(m.maxZ+m.minZ)/2,p=m.maxZ-m.minZ,h={count:m.zCount}}const[y,b,T]=P,U=lbAnnotation.MathUtils.getLineCenterPoint([y,T]),I=lbAnnotation.MathUtils.getLineLength(y,b),D=lbAnnotation.MathUtils.getLineLength(b,T),R=lbAnnotation.MathUtils.getRadiusFromQuadrangle(e.pointList);d&&(c=d.center.z,p=d.depth);const V={center:{x:U.x,y:U.y,z:c},width:u?D+INTELLIGENT_FIT_MARGIN:D,height:u?I+INTELLIGENT_FIT_MARGIN:I,depth:p,rotation:R,id:e.id},_=__spreadValues(d?__spreadValues(__spreadValues({},d),V):__spreadProps(__spreadValues({},V),{attribute:"",valid:!0}),h);o&&Object.assign(_,o);const k=P.map(m=>lbUtils.PointCloudUtils.transferWorld2Canvas(m,t));return{boxParams:_,newPointList:k}},sideViewPoint2PointCloud=(e,t,s)=>{const d={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x-d.x,y:s.center.y,z:s.center.z-d.y}})},sideViewPolygon2PointCloud=(e,t,s,d)=>{const[o,u,P]=e.pointList,[c,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),U={x:{x:y.x-b.x,y:y.y-b.y}.x,y:0,z:y.y-b.y},I=lbAnnotation.MathUtils.getLineLength(o,u),D=lbAnnotation.MathUtils.getLineLength(c,p),R=I-D,V=lbAnnotation.MathUtils.getLineLength(u,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_,{newBoxParams:m}=d.getNewBoxBySideUpdate(U,k,R,s);return m},backViewPoint2PointCloud=(e,t,s)=>{const d={x:e.x-t.x,y:e.y-t.y};return __spreadProps(__spreadValues({},s),{center:{x:s.center.x,y:s.center.y-d.x,z:s.center.z-d.y}})},backViewPolygon2PointCloud=(e,t,s,d)=>{const[o,u,P]=e.pointList,[c,p,h]=t.pointList,y=lbAnnotation.MathUtils.getLineCenterPoint([o,P]),b=lbAnnotation.MathUtils.getLineCenterPoint([c,h]),U={x:{x:y.x-b.x,y:y.y-b.y}.x,y:0,z:y.y-b.y},I=lbAnnotation.MathUtils.getLineLength(o,u),D=lbAnnotation.MathUtils.getLineLength(c,p),R=I-D,V=lbAnnotation.MathUtils.getLineLength(u,P),_=lbAnnotation.MathUtils.getLineLength(p,h),k=V-_;let{newBoxParams:m}=d.getNewBoxByBackUpdate(U,k,R,s);return m},syncSideViewByPoint=(e,t,s,d,o)=>{var u;if(!s)return;const{toolInstance:P,pointCloudInstance:c}=s;c.loadPCDFile(d,(u=o==null?void 0:o.radius)!=null?u:DEFAULT_RADIUS);const{cameraPositionVector:p}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Left);c.setInitCameraPosition(p);const{point2d:h,zoom:y}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=y,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeSideView=(e,t,s,d)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:u}=s;u.loadPCDFileByBox(d,e,{width:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=u.updateOrthoCamera(e,lbUtils.EPerspectiveView.Left);u.setInitCameraPosition(P);const{polygon2d:c,zoom:p}=u.getBoxSidePolygon2DCoordinate(e);u.camera.zoom=p,u.camera.updateProjectionMatrix(),u.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncBackViewByPoint=(e,t,s,d,o)=>{var u;if(!s)return;const{toolInstance:P,pointCloudInstance:c}=s;c.loadPCDFile(d,(u=o==null?void 0:o.radius)!=null?u:DEFAULT_RADIUS);const{cameraPositionVector:p}=c.updateOrthoCameraBySphere(e,lbUtils.EPerspectiveView.Back);c.setInitCameraPosition(p);const{point2d:h,zoom:y}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=y,c.camera.updateProjectionMatrix(),c.render(),P.initPosition(),P.zoomChangeOnCenter(y),P.setResult([__spreadProps(__spreadValues(__spreadValues({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),P.setSelectedID(t.id)},synchronizeBackView=(e,t,s,d)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:u}=s;u.loadPCDFileByBox(d,e,{height:DEFAULT_SCOPE,depth:DEFAULT_SCOPE});const{cameraPositionVector:P}=u.updateOrthoCamera(e,lbUtils.EPerspectiveView.Back);u.setInitCameraPosition(P);const{polygon2d:c,zoom:p}=u.getBoxBackPolygon2DCoordinate(e);u.camera.zoom=p,u.camera.updateProjectionMatrix(),u.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},syncTopViewByPoint=(e,t,s,d)=>{if(!s||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,lbUtils.EPerspectiveView.Top),d.render();const{toolInstance:o,pointCloudInstance:u}=s,{point2d:P}=u.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(p=>p.id===t.id?__spreadProps(__spreadValues(__spreadValues({},t),P),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(c),o.setSelectedID(t.id)},synchronizeTopView=(e,t,s,d)=>{var o,u;if(!s||!d)return;d.generateBox(e,t.id),d.render();const{pointCloud2dOperation:P,pointCloudInstance:c}=s,{polygon2d:p}=c.getBoxTopPolygon2DCoordinate(e),h=[...P.polygonList],y=h.find(b=>b.id===t.id);y?(y.pointList=p,y.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(u=e.valid)!=null?u:!0}),P.setResultAndSelectedID(h,t.id)},usePointCloudViews=()=>{const e=React.useContext(PointCloudContext.PointCloudContext),{topViewInstance:t,sideViewInstance:s,backViewInstance:d,mainViewInstance:o,addPointCloudBox:u,addPointCloudSphere:P,setSelectedIDs:c,selectedIDs:p,pointCloudBoxList:h,pointCloudSphereList:y,hideAttributes:b,setHighlight2DDataList:T,cuboidBoxIn2DView:U,imageSizes:I}=e,{addHistory:D,initHistory:R,pushHistoryUnderUpdatePolygon:V}=useHistory.useHistory(),{selectedPolygon:_}=usePolygon.usePolygon(),{getPointCloudSphereByID:k,updatePointCloudSphere:m,selectedSphere:N}=useSphere.useSphere(),{currentData:j,config:L}=ctx.useSelector(n=>{const{stepList:i,step:a,imgList:l,imgIndex:r}=n.annotation;return{currentData:l[r],config:index.jsonParser(StepUtils.getCurrentStepInfo(a,i).config)}}),A=ctx.useDispatch(),tt=ahooks.useLatest(U),W=n=>{const{enableAutoMap2DRect:i=!1}=L;if(!tt.current||i){const{mappingImgList:a=[]}=j;index.generatePointCloudBoxRects({pointCloudBox:n,mappingImgList:a,imageSizes:I})}},{selectedBox:S,updateSelectedBox:ot,updateSelectedBoxes:Z,getPointCloudByID:et}=useSingleBox.useSingleBox({generateRects:W}),X=S==null?void 0:S.info;if(!t||!s||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:G}=t,it=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},nt=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},st=({newPoint:n,size:i,zoom:a,trackConfigurable:l})=>{var r;const C={attribute:(r=t.toolInstance.defaultAttribute)!=null?r:""};l===!0&&Object.assign(C,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:y})});const f=topViewPoint2PointCloud(n,i,G,void 0,C);c(n.id);const g=P(f);q(PointCloudView.Top,n,f,a,g,L),D({newSphereParams:f})},lt=({polygon:n,size:i,imgList:a,trackConfigurable:l,zoom:r,intelligentFit:C})=>{var f,g,v;const w={attribute:(f=t.toolInstance.defaultAttribute)!=null?f:""};l===!0&&Object.assign(w,{trackID:lbUtils.PointCloudUtils.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:y})});const z=t==null?void 0:t.toolInstance,B=__spreadValues({},n);let{boxParams:x,newPointList:O}=topViewPolygon2PointCloud(B,i,G,void 0,w,C);x=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[x],stepConfig:L,action:"viewUpdateBox"}))[0],C&&(O==null?void 0:O.length)&&(B.pointList=O);const Q=b.includes(B.attribute);W(x);const E=u(x),F=(g=e==null?void 0:e.polygonList)!=null?g:[];x.subAttribute=lbAnnotation.TagUtils.getDefaultResultByConfig((L==null?void 0:L.secondaryAttributeConfigurable)?(v=L==null?void 0:L.inputList)!=null?v:[]:[]),t==null||t.updatePolygonList(E!=null?E:[],F),Q?c([]):(c(x.id),z.selection.setSelectedIDs(B.id),M({omitView:PointCloudView.Top,polygon:B,boxParams:x,zoom:r,newPointCloudBoxList:E}),C&&synchronizeTopView(x,B,t,o)),D({newBoxParams:x})},rt=n=>{const{boxID:i,imageName:a,width:l,height:r,x:C,y:f}=n,g=h.find(x=>x.id===i);if(!(g==null?void 0:g.rects)||!g.rects.find(x=>x.imageName===a))return;const w=g.rects.map(x=>x.imageName===a?__spreadProps(__spreadValues({},x),{width:l,height:r,x:C,y:f}):x),z=__spreadProps(__spreadValues({},g),{rects:w}),B=h.map(x=>x.id===i?z:x);return t==null||t.updatePolygonList(B!=null?B:[]),B},at=n=>{const{boxID:i,imageName:a}=n,l=h.find(g=>g.id===i);if(!(l==null?void 0:l.rects))return;const r=l.rects.filter(g=>g.imageName!==a),C=__spreadProps(__spreadValues({},l),{rects:r}),f=h.map(g=>g.id===i?C:g);return t==null||t.updatePolygonList(f!=null?f:[]),f},dt=({newSelectedBox:n,newPointCloudList:i,newSelectedSphere:a,newSphereList:l})=>{var r;const C=t==null?void 0:t.toolInstance;if(!(p.length===0||!C)){if(n||(S==null?void 0:S.info)){const f=n!=null?n:S==null?void 0:S.info;(r=C==null?void 0:C.selection)==null||r.setSelectedIDs(p[0]);const g=C.selectedPolygon;if(p.length===1&&f){M({omitView:PointCloudView.Top,polygon:g,boxParams:f,newPointCloudBoxList:i});return}}if((a||N)&&p.length===1){const f=a!=null?a:N;C.setSelectedID(p[0]);const g=C.selectedPoint;f&&q(PointCloudView.Top,g,f,void 0,l,L)}}},Y=(n,i,a)=>{if(X){let l,r;switch(a){case PointCloudView.Back:l=backViewPolygon2PointCloud;break;case PointCloudView.Side:l=sideViewPolygon2PointCloud;break;default:l=sideViewPolygon2PointCloud;break}if(r=l(n,i,X,s.pointCloudInstance),o){const{count:w}=o.getSensesPointZAxisInPolygon(lbAnnotation.getCuboidFromPointCloudBox(r).polygonPointList,[r.center.z-r.depth/2,r.center.z+r.depth/2]);r=__spreadProps(__spreadValues({},r),{count:w})}const f=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:[r],stepConfig:L,action:"viewUpdateBox"}))[0],g=r.valid!==f.valid;r=f;const v=ot(r);return r=v.find(w=>w.id===r.id),M({omitView:g?void 0:a,polygon:n,boxParams:r,newPointCloudBoxList:v}),v}},K=(n,i,a)=>{if(N){let l,r;switch(a){case PointCloudView.Back:l=backViewPoint2PointCloud;break;case PointCloudView.Side:l=sideViewPoint2PointCloud;break;default:l=sideViewPoint2PointCloud;break}r=l(n,i,N);const C=m(r);return q(a,n,r,void 0,C,L),C}},ut=(n,i)=>{K(n,i,PointCloudView.Side)},ct=(n,i)=>{K(n,i,PointCloudView.Back)},pt=(n,i)=>{Y(n,i,PointCloudView.Side)},Pt=(n,i)=>{Y(n,i,PointCloudView.Back)},Ct=(n,i)=>{const a=k(n.id),l=topViewPoint2PointCloud(n,i,G,a),r=m(l);q(PointCloudView.Top,n,l,void 0,r,L)},gt=(n,i)=>{if(_){const l=__spreadValues({},n[0].newPolygon);l.pointList=l.pointList.map(r=>lbUtils.PointCloudUtils.transferCanvas2World(r,i)),V(l);return}let a=n.map(({newPolygon:l})=>{const r=et(l.id),{boxParams:C}=topViewPolygon2PointCloud(l,i,t.pointCloudInstance,r);return C});if(a=A(actionCreators.PreDataProcess({tool:lbAnnotation.EPointCloudName.PointCloud,dataList:a,stepConfig:L,action:"viewUpdateBox"})),a.length===1){const{newPolygon:l}=n[0],r=Z(a);M({polygon:l,boxParams:a[0],newPointCloudBoxList:r})}else{const l=Z(a);l&&e.syncAllViewPointCloudColor(l)}},ft=n=>{var i,a,l,r,C;if(S){const f=Number(n.widthDefault),g=Number(n.depthDefault),v=Number(n.heightDefault),w=S==null?void 0:S.info.trackID,B=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(H=>(H==null?void 0:H.trackID)===w),x={width:(l=(a=t==null?void 0:t.toolInstance)==null?void 0:a.basicImgInfo)==null?void 0:l.width,height:(C=(r=t==null?void 0:t.toolInstance)==null?void 0:r.basicImgInfo)==null?void 0:C.height},O=B.pointList.map(H=>lbUtils.PointCloudUtils.transferCanvas2World(H,x)),J=lbAnnotation.MathUtils.getModifiedRectangleCoordinates(O,v,f),Q=J[0],E=J[2],F=lbAnnotation.MathUtils.getLineCenterPoint([Q,E]),ht=S.info.center.z-S.info.depth/2,$=__spreadProps(__spreadValues({},S.info),{center:{x:F.x,y:F.y,z:ht+g/2},width:f,height:v,depth:g,valid:!0}),vt=Z([$]);M({omitView:PointCloudView["3D"],polygon:B,boxParams:$,newPointCloudBoxList:vt})}},q=(n,i,a,l,r,C)=>__async(void 0,null,function*(){const f=j==null?void 0:j.url,g={[PointCloudView.Side]:()=>{syncSideViewByPoint(a,i,s,f,C)},[PointCloudView.Back]:()=>{d&&syncBackViewByPoint(a,i,d,f,C)},[PointCloudView.Top]:()=>{syncTopViewByPoint(a,i,t,o)}};Object.keys(g).forEach(v=>{v!==n&&g[v]()}),l&&(o==null||o.updateCameraZoom(l)),nt(a)}),M=n=>__async(void 0,null,function*(){const{omitView:i,polygon:a,boxParams:l,zoom:r,newPointCloudBoxList:C}=n,f=j==null?void 0:j.url;C&&(yield e.syncAllViewPointCloudColor(C));const g={[PointCloudView.Side]:()=>{synchronizeSideView(l,a,s,f)},[PointCloudView.Back]:()=>{d&&synchronizeBackView(l,a,d,f)},[PointCloudView.Top]:()=>{synchronizeTopView(l,a,t,o)}};Object.keys(g).forEach(v=>{v!==i&&g[v]()}),r&&(o==null||o.updateCameraZoom(r)),it(l)});return{topViewAddSphere:st,topViewAddBox:lt,topViewSelectedChanged:dt,topViewUpdatePoint:Ct,sideViewUpdatePoint:ut,backViewUpdatePoint:ct,topViewUpdateBox:gt,sideViewUpdateBox:pt,backViewUpdateBox:Pt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const i=lbUtils.PointCloudUtils.getDefaultOrthographicParams(n);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>__async(void 0,[...n],function*(i=j){var a,l,r,C,f,g;if(!(i==null?void 0:i.url)||!o)return;T([]),actionCreators.SetPointCloudLoading(A,!0),actionCreators.SetLoadPCDFileLoading(A,!0),yield o.loadPCDFile(i.url,(a=L==null?void 0:L.radius)!=null?a:DEFAULT_RADIUS),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let v=[],w=[],z=[],B=[];o.updateTopCamera();const x=(r=(l=index.jsonParser(i.result))==null?void 0:l.valid)!=null?r:!0;if(e.setPointCloudValid(x),(C=e.sideViewInstance)==null||C.clearAllData(),(f=e.backViewInstance)==null||f.clearAllData(),i.result){if(v=lbUtils.PointCloudUtils.getBoxParamsFromResultList(i.result),(v==null?void 0:v.length)>0&&i.isPreResult&&(L==null?void 0:L.lowerLimitPointsNumInBox)>0){v=yield o==null?void 0:o.filterPreResult(i.url,L,v);const O=index.jsonParser(i.result);O[lbUtils.POINT_CLOUD_DEFAULT_STEP].result=v,i.result=JSON.stringify(O),e.setPointCloudResult(v)}z=lbUtils.PointCloudUtils.getPolygonListFromResultList(i.result),w=lbUtils.PointCloudUtils.getLineListFromResultList(i.result),B=lbUtils.PointCloudUtils.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(g=L==null?void 0:L.radius)!=null?g:DEFAULT_RADIUS}),o==null||o.generateBoxes(v),o==null||o.generateSpheres(B),yield e.syncAllViewPointCloudColor(v,[])}R({pointCloudBoxList:v,polygonList:z,lineList:w,pointCloudSphereList:B}),actionCreators.SetPointCloudLoading(A,!1),actionCreators.SetLoadPCDFileLoading(A,!1)}),updateViewsByDefaultSize:ft,generateRects:W,update2DViewRect:rt,remove2DViewRect:at}};exports.syncBackViewByPoint=syncBackViewByPoint,exports.syncSideViewByPoint=syncSideViewByPoint,exports.syncTopViewByPoint=syncTopViewByPoint,exports.synchronizeBackView=synchronizeBackView,exports.synchronizeSideView=synchronizeSideView,exports.synchronizeTopView=synchronizeTopView,exports.topViewPoint2PointCloud=topViewPoint2PointCloud,exports.topViewPolygon2PointCloud=topViewPolygon2PointCloud,exports.usePointCloudViews=usePointCloudViews;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useHistory=require("./useHistory.js"),lbUtils=require("@labelbee/lb-utils");const{EToolName,EPolygonPattern}=lbAnnotation.cTool,useStatus=()=>{const{topViewInstance:i,sideViewInstance:r,backViewInstance:u,mainViewInstance:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),PointCloudContext=require("../PointCloudContext.js"),lbAnnotation=require("@labelbee/lb-annotation"),useHistory=require("./useHistory.js"),lbUtils=require("@labelbee/lb-utils");const{EToolName,EPolygonPattern}=lbAnnotation.cTool,useStatus=()=>{const{topViewInstance:i,sideViewInstance:r,backViewInstance:u,mainViewInstance:e,setPointCloudResult:d,setPointCloudSphereList:P,setPolygonList:C,setRectList:v,pointCloudPattern:a,setPointCloudPattern:o,syncAllViewPointCloudColor:b,globalPattern:n,setLineList:h}=React.useContext(PointCloudContext.PointCloudContext),{pushHistoryWithList:p}=useHistory.useHistory(),y=()=>{e==null||e.clearAllBox(),e==null||e.clearAllSphere(),e==null||e.render(),d([]),C([]),P([]),h([]),v([]),i==null||i.toolScheduler.clearStatusAndResult(),b([]),p({pointCloudBoxList:[],polygonList:[],pointCloudSphereList:[]})},l=()=>{r==null||r.toolInstance.clearResult(),u==null||u.toolInstance.clearResult()},L=c=>{if(c===a)return;const s=[i,r,u];switch(c){case EToolName.Rect:l(),s.forEach(t=>{t==null||t.switchToCanvas(EToolName.PointCloudPolygon),t==null||t.toolInstance.setPattern(EPolygonPattern.Rect)}),o(EToolName.Rect);break;case EToolName.Polygon:l(),s.forEach(t=>{t==null||t.switchToCanvas(EToolName.PointCloudPolygon),t==null||t.toolInstance.setPattern(EPolygonPattern.Normal)}),o(EToolName.Polygon);break;case EToolName.Point:l(),s.forEach(t=>{t==null||t.switchToCanvas(EToolName.Point)}),o(EToolName.Point);break;case EToolName.Line:l(),s.forEach(t=>{t==null||t.switchToCanvas(EToolName.Line)}),o(EToolName.Line);break}},w=React.useMemo(()=>n===lbUtils.EPointCloudPattern.Detection,[n]),R=React.useMemo(()=>n===lbUtils.EPointCloudPattern.Segmentation,[n]);return{clearAllResult:y,updatePointCloudPattern:L,pointCloudPattern:a,isPointCloudDetectionPattern:w,isPointCloudSegmentationPattern:R}};exports.useStatus=useStatus;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var dom=require("../../utils/dom.js"),React=require("react"),PointCloud3DView=require("./PointCloud3DView.js"),PointCloudBackView=require("./PointCloudBackView.js"),PointCloudTopView=require("./PointCloudTopView.js"),PointCloudSideView=require("./PointCloudSideView.js"),PointCloud2DView=require("./PointCloud2DView.js"),PointCloudListener=require("./PointCloudListener.js"),PointCloudSegmentListener=require("./PointCloudSegmentListener.js"),PointCloudSegment=require("./PointCloudSegment.js"),PointCloudSegmentStatus=require("./PointCloudSegmentStatus.js"),PointCloudSegmentToolbar=require("./PointCloudSegmentToolbar.js"),PointCloudSegment2DView=require("./PointCloudSegment2DView.js"),reactRedux=require("react-redux"),ctx=require("../../store/ctx.js"),index$1=require("../../views/MainView/toolFooter/AnnotatedAttributes/index.js"),PointCloudContext=require("./PointCloudContext.js"),lbUtils=require("@labelbee/lb-utils"),annotation=require("../../hooks/annotation.js"),index=require("../../utils/index.js"),map=require("../../store/annotation/map.js"),classNames=require("classnames"),index$2=require("./components/sideAndBackOverView/index.js"),actionCreators=require("../../store/annotation/actionCreators.js");function _interopDefaultLegacy(
|
|
1
|
+
"use strict";var dom=require("../../utils/dom.js"),React=require("react"),PointCloud3DView=require("./PointCloud3DView.js"),PointCloudBackView=require("./PointCloudBackView.js"),PointCloudTopView=require("./PointCloudTopView.js"),PointCloudSideView=require("./PointCloudSideView.js"),PointCloud2DView=require("./PointCloud2DView.js"),PointCloudListener=require("./PointCloudListener.js"),PointCloudSegmentListener=require("./PointCloudSegmentListener.js"),PointCloudSegment=require("./PointCloudSegment.js"),PointCloudSegmentStatus=require("./PointCloudSegmentStatus.js"),PointCloudSegmentToolbar=require("./PointCloudSegmentToolbar.js"),PointCloudSegment2DView=require("./PointCloudSegment2DView.js"),reactRedux=require("react-redux"),ctx=require("../../store/ctx.js"),index$1=require("../../views/MainView/toolFooter/AnnotatedAttributes/index.js"),PointCloudContext=require("./PointCloudContext.js"),lbUtils=require("@labelbee/lb-utils"),annotation=require("../../hooks/annotation.js"),index=require("../../utils/index.js"),map=require("../../store/annotation/map.js"),classNames=require("classnames"),index$2=require("./components/sideAndBackOverView/index.js"),actionCreators=require("../../store/annotation/actionCreators.js");function _interopDefaultLegacy(a){return a&&typeof a=="object"&&"default"in a?a:{default:a}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames);const PointCloudView=a=>{const{currentData:i,imgList:P,drawLayerSlot:c,checkMode:n,intelligentFit:v,imgIndex:p,config:L,measureVisible:E}=a,e=React.useContext(PointCloudContext.PointCloudContext),{globalPattern:m,setGlobalPattern:x,selectedIDs:C}=e,S=ctx.useDispatch(),[l,f]=React.useState(!1),q=(C==null?void 0:C.length)>0&&l,b=index.jsonParser(i.result),{toolInstanceRef:o,clearToolInstance:j}=annotation.useCustomToolInstance({basicInfo:b});if(React.useEffect(()=>{o.current.setPointCloudGlobalPattern=t=>{t!==m&&(x(t),e.clearAllDetectionInstance(),j())}},[m]),React.useEffect(()=>{var t;if(actionCreators.SetLoadPCDFileLoading(S,!0),i){const{boxParamsList:r,polygonList:s,lineList:u,sphereParamsList:d,segmentation:w,rectList:N}=lbUtils.PointCloudUtils.parsePointCloudCurrentResult((t=i==null?void 0:i.result)!=null?t:"");e.setPointCloudResult(r),e.setPolygonList(s),e.setLineList(u),e.setPointCloudSphereList(d),e.setRectList(N),e.setSegmentation(w)}},[p]),React.useEffect(()=>{o.current.exportData=()=>[e.pointCloudBoxList,{valid:e.valid}],o.current.exportCustomData=()=>{var t,r,s,u,d;return{resultPolygon:(t=e.polygonList)!=null?t:[],resultLine:(r=e.lineList)!=null?r:[],resultPoint:(s=e.pointCloudSphereList)!=null?s:[],resultRect:(u=e.rectList)!=null?u:[],segmentation:(d=e.segmentation)!=null?d:[]}}},[e.pointCloudBoxList,e.rectList,e.valid,e.polygonList,e.lineList,e.pointCloudSphereList,e.ptSegmentInstance,e.segmentation]),P.length===0)return null;if(m===lbUtils.EPointCloudPattern.Segmentation)return React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(PointCloudSegmentListener,{checkMode:n,toolInstanceRef:o}),React__default.default.createElement(PointCloudSegmentToolbar,null),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-layout")},React__default.default.createElement(PointCloudSegment,{checkMode:n}),React__default.default.createElement(PointCloudSegment2DView,null)),React__default.default.createElement(PointCloudSegmentStatus,{config:L}),c==null?void 0:c({direct:!0}));let g=React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","left-bottom")},React__default.default.createElement(PointCloudBackView,{checkMode:n}),React__default.default.createElement(PointCloudSideView,{checkMode:n}));return l&&(g=React__default.default.createElement(index$2,{selectAndEnlarge:q,checkMode:n})),React__default.default.createElement(React__default.default.Fragment,null,React__default.default.createElement(PointCloudListener,{checkMode:n,toolInstanceRef:o}),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-layout"),onContextMenu:t=>t.preventDefault()},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-wrapper")},React__default.default.createElement(index$1.AnnotatedAttributesPanelFixedLeft,null),React__default.default.createElement("div",{className:dom.getClassName("point-cloud-content")},React__default.default.createElement("div",{className:dom.getClassName("point-cloud-container","left")},React__default.default.createElement(PointCloud3DView,null),g),React__default.default.createElement("div",{className:classNames__default.default({[dom.getClassName("point-cloud-container","right")]:!0,[dom.getClassName("point-cloud-container","rightZoom")]:l})},React__default.default.createElement(PointCloudTopView,{drawLayerSlot:c,checkMode:n,intelligentFit:v,setIsEnlargeTopView:f,onExitZoom:()=>{f(!1)},isEnlargeTopView:l}),React__default.default.createElement("div",{className:classNames__default.default({[dom.getClassName("point-cloud-container","right-bottom")]:!l,[dom.getClassName("point-cloud-container","right-bottom-floatLeft")]:l})},React__default.default.createElement(PointCloud2DView,{isEnlargeTopView:l,thumbnailWidth:l?300:455,checkMode:n,measureVisible:E})))),React__default.default.createElement(index$1.AnnotatedAttributesPanelFixedRight,null))))};var PointCloudView$1=reactRedux.connect(map.a2MapStateToProps,null,null,{context:ctx.LabelBeeContext})(PointCloudView);module.exports=PointCloudView$1;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var React=require("react"),antd=require("antd"),reactI18next=require("react-i18next"),index=require("../attributeList/index.js"),lbUtils=require("@labelbee/lb-utils");function _interopDefaultLegacy(l){return l&&typeof l=="object"&&"default"in l?l:{default:l}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(l,r,t)=>r in l?__defProp(l,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):l[r]=t,__spreadValues=(l,r)=>{for(var t in r||(r={}))__hasOwnProp.call(r,t)&&__defNormalProp(l,t,r[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(r))__propIsEnum.call(r,t)&&__defNormalProp(l,t,r[t]);return l};const subTitleStyle={margin:"12px 20px 8px",fontSize:14,fontWeight:500,wordWrap:"break-word"},SubAttributeList=l=>{const{subAttributeList:r,setSubAttribute:t,getValue:o,lang:i}=l,{t:u}=reactI18next.useTranslation();React.useEffect(()=>{var e;i&&((e=lbUtils.i18n)==null||e.changeLanguage(i))},[]);const d=(e,n)=>{if(Array.isArray(n)){t(e,n.join(";"));return}t(e,n)},c=e=>{const n=o(e);return(e==null?void 0:e.isMulti)?n?n==null?void 0:n.split(";"):[]:n};return React__default.default.createElement(React__default.default.Fragment,null,r.map(e=>{var n;return(e==null?void 0:e.subSelected)&&React__default.default.createElement("div",{style:{marginTop:12},key:e.value},React__default.default.createElement("div",{style:subTitleStyle},u("SubAttribute"),"-",e.key),((n=e.subSelected)==null?void 0:n.length)<5?(e==null?void 0:e.isMulti)?React__default.default.createElement(antd.Checkbox.Group,{style:{padding:"0px 20px 16px 16px"},options:e.subSelected.map(a=>({label:a.key,value:a.value})),value:c(e),onChange:a=>d(e.value,a)}):React__default.default.createElement(index.default,{list:e.subSelected.map(a=>({label:a.key,value:a.value})),selectedAttribute:o(e),num:"-",forbidColor:!0,forbidDefault:!0,attributeChanged:a=>t(e.value,a),style:{marginBottom:12}}):React__default.default.createElement(antd.Select,{style:{margin:"0px 20px 16px 16px",width:"87%"},mode:(e==null?void 0:e.isMulti)?"multiple":void 0,value:c(e),placeholder:u("PleaseSelect"),onChange:a=>d(e.value,a),allowClear:!0},e.subSelected.map(a=>React__default.default.createElement(antd.Select.Option,{key:a.value,value:a.value},a.key))),React__default.default.createElement(antd.Divider,{style:{margin:0}}))}))},WrapSubAttributeList=l=>React__default.default.createElement(reactI18next.I18nextProvider,{i18n:lbUtils.i18n},React__default.default.createElement(SubAttributeList,__spreadValues({},l)));module.exports=WrapSubAttributeList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index$2=require("../../../utils/index.js"),audio=require("../../../utils/audio.js"),antd=require("antd"),_=require("lodash"),React=require("react"),index_module=require("./index.module.scss.js"),VideoClipToolContext=require("./VideoClipToolContext.js"),constant=require("./constant.js"),index=require("../../videoPlayer/index.js"),index$1=require("./components/videoTimeSlicesOverVideo/index.js"),icon_videoCutting=require("../../../assets/annotation/video/icon_videoCutting.svg.js"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(S){return S&&typeof S=="object"&&"default"in S?S:{default:S}}var ___default=_interopDefaultLegacy(_),React__default=_interopDefaultLegacy(React);class VideoClipTool extends React__default.default.Component{constructor(r){super(r);this.fns=new Map,this.throttledUpdateTime=___default.default.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(s=>s.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:a,start:n,type:l}=this.state.result[this.selectedSliceIndex],u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[0,audio.precisionMinus(l===constant.ETimeSliceType.Time?s:a,constant.PER_SLICE_CHANGE)]);this.updateSelectedSliceTimeProperty(u,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=this.state.result[this.selectedSliceIndex],a=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(s.type===constant.ETimeSliceType.Time){antd.message.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:n,start:l}=s,u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[audio.precisionAdd(l,constant.PER_SLICE_CHANGE),a]);this.updateSelectedSliceTimeProperty(u,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:___default.default.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-constant.PER_SLICE_CHANGE);break;case"=":this.updateSelectedSliceTimeStartByPer(constant.PER_SLICE_CHANGE);break;case"[":this.updateSelectedSliceTimeEndByPer(-constant.PER_SLICE_CHANGE);break;case"]":this.updateSelectedSliceTimeEndByPer(constant.PER_SLICE_CHANGE);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:s}=this.state;s===constant.EClipStatus.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==constant.EClipStatus.Clipping)return;const s=t.findIndex(a=>a.id===e);s>-1&&(t.splice(s,1),this.setState({result:t,selectedID:"",clipStatus:constant.EClipStatus.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i,s;if(this.disabled)return;const{clipStatus:a,selectedAttribute:n}=this.state,l=a!==constant.EClipStatus.Clipping;let u=l?constant.EClipStatus.Clipping:constant.EClipStatus.Stop,{result:d,selectedID:o,textValue:p}=this.state;const c=___default.default.cloneDeep(d),h=t||((e=this.videoPlayer)==null?void 0:e.currentTime),f=(i=this.videoPlayer)==null?void 0:i.duration;if(f===void 0||h===void 0)return;const C=utils.decimalReserved(h,2);if(l){const m=lbAnnotation.uuid();o=m,c.push({start:C,end:null,attribute:n,textAttribute:this.defaultTextAttribute,duration:f,id:m,type:constant.ETimeSliceType.Period}),p=this.defaultTextAttribute}else{const m=c.findIndex(v=>v.id===o),g=c[m];g&&(h-g.start<constant.SLICE_MIN_TIME?(c.splice(m,1),antd.message.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${constant.SLICE_MIN_TIME}s`),u=constant.EClipStatus.Stop,o="",p=""):(c[m].end=utils.decimalReserved(h,2),(s=this.videoPlayer)==null||s.pause(),antd.message.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${d.length}`)))}this.setState({clipStatus:u,result:c,selectedID:o,textValue:p}),this.updateSidebar()},this.addTime=()=>{var t,e,i,s;if(this.disabled)return;const{result:a,selectedAttribute:n,selectedID:l}=this.state,u=lbAnnotation.uuid(),d=___default.default.cloneDeep(a),o=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;d.push({start:o,end:o,attribute:n,textAttribute:this.defaultTextAttribute,id:u,type:constant.ETimeSliceType.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const p={result:d,selectedID:u,textValue:this.defaultTextAttribute},c=d.find(h=>h.id===l);this.isClipping&&c?(delete p.selectedID,delete p.textValue,antd.message.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${d.length-1}`)):(s=this.videoPlayer)==null||s.pause(),this.setState(p),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===constant.EClipStatus.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var s,a;const{result:n}=this.state,l=n.find(u=>u.id===t);if(l){const u=l.duration,d=e==="left",o=d?"start":"end",p=d?-u*i:u*i,c=d?[0,Math.max(((s=l.end)!=null?s:0)-constant.SLICE_MIN_TIME,0)]:[l.start+constant.SLICE_MIN_TIME,u],h=lbAnnotation.MathUtils.withinRange(p+((a=l==null?void 0:l[o])!=null?a:0),c);l[o]=h,this.throttledUpdateTime(h)}this.setState({result:[...n]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:s}=this.props,{result:a,videoError:n,valid:l,currentTime:u}=this.state;return React__default.default.createElement("div",{className:index_module.clipContainer},React__default.default.createElement(index.VideoPlayer,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:s,pageForward:e,pageJump:i,valid:l,setVideoRef:d=>{this.videoPlayer=d},showVideoTrack:!n,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),React__default.default.createElement(index$1,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:a,currentTime:u,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&React__default.default.createElement("i",{className:index_module.clipping,style:{backgroundImage:icon_videoCutting}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,s=e.findIndex(a=>a.id===t.id);s>-1&&(e.splice(s,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:s}=e;if(!s[i])return;const n=index$2.jsonParser(s[i].result)[`step_${this.stepInfo().step}`],l=(n==null?void 0:n.result)||[],u=audio.isImageValue(s[i].result||"[]");this.setState({result:l,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:constant.EClipStatus.Stop,valid:u},()=>{this.updateSidebar(),u||antd.message.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,s=e.find(a=>a.id===i);s&&i&&(s.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const s=e.find(a=>a.id===i);s&&(s.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:constant.EClipStatus.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var r;const{imgIndex:t,imgList:e}=this.props;return((r=e[t])==null?void 0:r.url)||""}get isClipping(){return this.state.clipStatus===constant.EClipStatus.Clipping}get resultJSON(){const{imgIndex:r,imgList:t}=this.props;return t.length===0||!t[r]?"[]":t[r].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return lbAnnotation.AttributeUtils.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(r=>r.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty}}get valid(){return this.state.valid}get config(){var r;return index$2.jsonParser((r=this.props.stepInfo)==null?void 0:r.config)}get selectedText(){var r,t;return(t=(r=this.state.result)==null?void 0:r[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(r,t){const e=r.imgIndex-this.props.imgIndex,i=r.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,r),i!==0&&this.setState({loading:!1})),!0}singleOn(r,t){this.fns.set(r,[t])}on(r,t){this.singleOn(r,t)}unbindAll(r){this.fns.delete(r)}render(){const{selectedID:r,result:t,clipStatus:e,selectedAttribute:i}=this.state;return React__default.default.createElement(VideoClipToolContext.VideoClipToolContextProvider,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:r,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}module.exports=VideoClipTool;
|
|
1
|
+
"use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index$2=require("../../../utils/index.js"),audio=require("../../../utils/audio.js"),antd=require("antd"),_=require("lodash"),React=require("react"),index_module=require("./index.module.scss.js"),VideoClipToolContext=require("./VideoClipToolContext.js"),constant=require("./constant.js"),index=require("../../videoPlayer/index.js"),index$1=require("./components/videoTimeSlicesOverVideo/index.js"),icon_videoCutting=require("../../../assets/annotation/video/icon_videoCutting.svg.js"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(S){return S&&typeof S=="object"&&"default"in S?S:{default:S}}var ___default=_interopDefaultLegacy(_),React__default=_interopDefaultLegacy(React);class VideoClipTool extends React__default.default.Component{constructor(r){super(r);this.fns=new Map,this.throttledUpdateTime=___default.default.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(s=>s.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:a,start:n,type:l}=this.state.result[this.selectedSliceIndex],u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[0,audio.precisionMinus(l===constant.ETimeSliceType.Time?s:a,constant.PER_SLICE_CHANGE)]);this.updateSelectedSliceTimeProperty(u,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=this.state.result[this.selectedSliceIndex],a=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(s.type===constant.ETimeSliceType.Time){antd.message.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:n,start:l}=s,u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[audio.precisionAdd(l,constant.PER_SLICE_CHANGE),a]);this.updateSelectedSliceTimeProperty(u,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:___default.default.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-constant.PER_SLICE_CHANGE);break;case"=":this.updateSelectedSliceTimeStartByPer(constant.PER_SLICE_CHANGE);break;case"[":this.updateSelectedSliceTimeEndByPer(-constant.PER_SLICE_CHANGE);break;case"]":this.updateSelectedSliceTimeEndByPer(constant.PER_SLICE_CHANGE);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:s}=this.state;s===constant.EClipStatus.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==constant.EClipStatus.Clipping)return;const s=t.findIndex(a=>a.id===e);s>-1&&(t.splice(s,1),this.setState({result:t,selectedID:"",clipStatus:constant.EClipStatus.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i;if(typeof((e=this.props)==null?void 0:e.annotationBefore)=="function"){(i=this.props)==null||i.annotationBefore(()=>this.setClipResult(t));return}this.setClipResult(t)},this.setClipResult=t=>{var e,i,s;if(this.disabled)return;const{clipStatus:a,selectedAttribute:n}=this.state,l=a!==constant.EClipStatus.Clipping;let u=l?constant.EClipStatus.Clipping:constant.EClipStatus.Stop,{result:d,selectedID:o,textValue:p}=this.state;const c=___default.default.cloneDeep(d),h=t||((e=this.videoPlayer)==null?void 0:e.currentTime),v=(i=this.videoPlayer)==null?void 0:i.duration;if(v===void 0||h===void 0)return;const C=utils.decimalReserved(h,2);if(l){const f=lbAnnotation.uuid();o=f,c.push({start:C,end:null,attribute:n,textAttribute:this.defaultTextAttribute,duration:v,id:f,type:constant.ETimeSliceType.Period}),p=this.defaultTextAttribute}else{const f=c.findIndex(g=>g.id===o),m=c[f];m&&(h-m.start<constant.SLICE_MIN_TIME?(c.splice(f,1),antd.message.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${constant.SLICE_MIN_TIME}s`),u=constant.EClipStatus.Stop,o="",p=""):(c[f].end=utils.decimalReserved(h,2),(s=this.videoPlayer)==null||s.pause(),antd.message.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${d.length}`)))}this.setState({clipStatus:u,result:c,selectedID:o,textValue:p}),this.updateSidebar()},this.addTime=()=>{var t,e,i,s;if(this.disabled)return;const{result:a,selectedAttribute:n,selectedID:l}=this.state,u=lbAnnotation.uuid(),d=___default.default.cloneDeep(a),o=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;d.push({start:o,end:o,attribute:n,textAttribute:this.defaultTextAttribute,id:u,type:constant.ETimeSliceType.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const p={result:d,selectedID:u,textValue:this.defaultTextAttribute},c=d.find(h=>h.id===l);this.isClipping&&c?(delete p.selectedID,delete p.textValue,antd.message.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${d.length-1}`)):(s=this.videoPlayer)==null||s.pause(),this.setState(p),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===constant.EClipStatus.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var s,a;const{result:n}=this.state,l=n.find(u=>u.id===t);if(l){const u=l.duration,d=e==="left",o=d?"start":"end",p=d?-u*i:u*i,c=d?[0,Math.max(((s=l.end)!=null?s:0)-constant.SLICE_MIN_TIME,0)]:[l.start+constant.SLICE_MIN_TIME,u],h=lbAnnotation.MathUtils.withinRange(p+((a=l==null?void 0:l[o])!=null?a:0),c);l[o]=h,this.throttledUpdateTime(h)}this.setState({result:[...n]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:s}=this.props,{result:a,videoError:n,valid:l,currentTime:u}=this.state;return React__default.default.createElement("div",{className:index_module.clipContainer},React__default.default.createElement(index.VideoPlayer,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:s,pageForward:e,pageJump:i,valid:l,setVideoRef:d=>{this.videoPlayer=d},showVideoTrack:!n,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),React__default.default.createElement(index$1,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:a,currentTime:u,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&React__default.default.createElement("i",{className:index_module.clipping,style:{backgroundImage:icon_videoCutting}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,s=e.findIndex(a=>a.id===t.id);s>-1&&(e.splice(s,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:s}=e;if(!s[i])return;const n=index$2.jsonParser(s[i].result)[`step_${this.stepInfo().step}`],l=(n==null?void 0:n.result)||[],u=audio.isImageValue(s[i].result||"[]");this.setState({result:l,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:constant.EClipStatus.Stop,valid:u},()=>{this.updateSidebar(),u||antd.message.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,s=e.find(a=>a.id===i);s&&i&&(s.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const s=e.find(a=>a.id===i);s&&(s.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:constant.EClipStatus.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var r;const{imgIndex:t,imgList:e}=this.props;return((r=e[t])==null?void 0:r.url)||""}get isClipping(){return this.state.clipStatus===constant.EClipStatus.Clipping}get resultJSON(){const{imgIndex:r,imgList:t}=this.props;return t.length===0||!t[r]?"[]":t[r].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return lbAnnotation.AttributeUtils.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(r=>r.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty}}get valid(){return this.state.valid}get config(){var r;return index$2.jsonParser((r=this.props.stepInfo)==null?void 0:r.config)}get selectedText(){var r,t;return(t=(r=this.state.result)==null?void 0:r[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(r,t){const e=r.imgIndex-this.props.imgIndex,i=r.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,r),i!==0&&this.setState({loading:!1})),!0}singleOn(r,t){this.fns.set(r,[t])}on(r,t){this.singleOn(r,t)}unbindAll(r){this.fns.delete(r)}render(){const{selectedID:r,result:t,clipStatus:e,selectedAttribute:i}=this.state;return React__default.default.createElement(VideoClipToolContext.VideoClipToolContextProvider,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:r,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}module.exports=VideoClipTool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),index=require("../../../utils/index.js"),index$1=require("../../videoPlayer/index.js"),VideoTagLayer=require("../../videoPlayer/VideoTagLayer.js"),_=require("lodash"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),index=require("../../../utils/index.js"),index$1=require("../../videoPlayer/index.js"),VideoTagLayer=require("../../videoPlayer/VideoTagLayer.js"),_=require("lodash"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(h){return h&&typeof h=="object"&&"default"in h?h:{default:h}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_);class TagToolInstanceAdaptor extends React__default.default.Component{constructor(e){super(e);this.fns={},this.labelSelectedList=[],this.clearResult=(t=!0,s)=>{const n=s?this.state.tagResult.map(i=>((i==null?void 0:i.result[s])&&delete i.result[s],i)):[];this.setState({tagResult:n},()=>this.emitEvent("render"))},this.exportData=()=>{var t,s;const n=(s=(t=this.videoPlayer)==null?void 0:t.duration)!=null?s:0;return[this.state.tagResult,{valid:this.state.valid,duration:n}]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.combineResult=(t,s={})=>{var n,i;const l=_.cloneDeep(s),{isMulti:o}=t,{key:a,value:u}=t.value;if(o){let r=(i=(n=l[a])==null?void 0:n.split(";"))!=null?i:[];r.includes(u)?r=r.filter(c=>c!==u):r.push(u);const d=new Set(r);return l[a]=Array.from(d).join(";"),___default.default.pickBy(l,c=>c)}return l[a]=l[a]===u?void 0:u,___default.default.pickBy(l,r=>r)},this.setResult=t=>{this.setState({tagResult:t}),this.fns.render&&this.fns.render()},this.setLabel=(t,s)=>{this.setLabelBySelectedList(t,s)},this.keydown=t=>{var s;const n=utils.getKeyCodeNumber(t.keyCode);if(n){const i=n-1;if(((s=this.config.inputList)==null?void 0:s.length)===1){this.labelSelectedList=[0,i],this.setLabel(0,i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],i],this.setLabel(this.labelSelectedList[0],i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500)):(this.labelSelectedList=[i],this.emitEvent("expend"))}},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({tagResult:[]}),this.emitEvent("render")},this.setResultFromImgList=t=>{const{imgList:s,imgIndex:n,stepInfo:i}=t;if(!s[n])return;const l=index.jsonParser(s[n].result),o=l[`step_${i.step}`],a=this.getInitResultList();this.setState({tagResult:o?o==null?void 0:o.result:a,valid:(l==null?void 0:l.valid)===void 0?!0:l.valid},()=>this.emitEvent("render"))},this.getInitResultList=()=>{var t;return lbAnnotation.TagUtils.getDefaultTagResult((t=this.config.inputList)!=null?t:[],[])},this.state={tagResult:[],labelSelectedList:[],valid:!0}}get config(){var e;return index.jsonParser((e=this.props.stepInfo)==null?void 0:e.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get currentTagResult(){var e;return(e=this.state.tagResult[0])!=null?e:{}}get valid(){return this.state.valid}singleOn(e,t){this.fns[e]=t}on(e,t){this.singleOn(e,t)}unbindAll(e){delete this.fns[e]}getTagResultByCode(e,t){var s,n,i;try{const l=(n=(s=this.config)==null?void 0:s.inputList)!=null?n:[],o=(l==null?void 0:l.length)>1,a=t!==void 0?e:0,u=t!==void 0?t:e,r=o?l[a]:l[0],d=((i=r.subSelected)!=null?i:[])[u];if(r&&d)return{value:{key:r.value,value:d.value},isMulti:r.isMulti}}catch(l){return}}setLabelBySelectedList(e,t){var s,n,i,l,o,a;const u=this.getTagResultByCode(e,t);if(u){const r=this.combineResult(u,(n=(s=this.state.tagResult[0])==null?void 0:s.result)!=null?n:{}),d=[{sourceID:lbAnnotation.CommonToolUtils.getSourceID(),id:(l=(i=this.currentTagResult)==null?void 0:i.id)!=null?l:lbAnnotation.uuid(8,62),result:r}];if(typeof((o=this.props)==null?void 0:o.annotationBefore)=="function"){(a=this.props)==null||a.annotationBefore(()=>this.setState({tagResult:d},()=>this.emitEvent("render")));return}this.setState({tagResult:d},()=>this.emitEvent("render"))}}componentDidMount(){document.addEventListener("keydown",this.keydown),this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){document.addEventListener("keydown",this.keydown),this.props.onUnmounted()}shouldComponentUpdate(e){return e.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(e),!0}render(){var e;const{imgIndex:t,imgList:s,pageForward:n,pageJump:i,pageBackward:l}=this.props,{tagResult:o,valid:a}=this.state;return React__default.default.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},React__default.default.createElement(index$1.VideoPlayer,{imgIndex:t,imgList:s,pageBackward:l,pageForward:n,pageJump:i,valid:a,setVideoRef:u=>{this.videoPlayer=u},dataLoaded:this.props.onVideoLoaded,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer}),React__default.default.createElement(VideoTagLayer.VideoTagLayer,{result:o,inputList:(e=this.config)==null?void 0:e.inputList,hasPromptLayer:!!this.props.drawLayerSlot}))}}exports.TagToolInstanceAdaptor=TagToolInstanceAdaptor;
|
package/dist/index.css
CHANGED
|
@@ -132,6 +132,12 @@
|
|
|
132
132
|
.index-module_outputDisplay__5dS48 .index-module_content__Iml6l .markdown-body {
|
|
133
133
|
font-size: 14px;
|
|
134
134
|
}
|
|
135
|
+
|
|
136
|
+
.index-module_tip__NFru6 {
|
|
137
|
+
margin-bottom: 8px;
|
|
138
|
+
color: rgba(0, 0, 0, 0.45);
|
|
139
|
+
font-size: 14px;
|
|
140
|
+
}
|
|
135
141
|
.index-module_tagList__cvWor {
|
|
136
142
|
padding: 0px 16px 16px 16px;
|
|
137
143
|
}
|
|
@@ -720,6 +726,16 @@
|
|
|
720
726
|
font-family: SourceHanSansCN-Medium;
|
|
721
727
|
font-size: 14px;
|
|
722
728
|
}
|
|
729
|
+
.index-module_label__xE6hM .index-module_labelText__Zg1c4 {
|
|
730
|
+
display: flex;
|
|
731
|
+
overflow: hidden;
|
|
732
|
+
width: 60%;
|
|
733
|
+
align-items: center;
|
|
734
|
+
}
|
|
735
|
+
.index-module_label__xE6hM .index-module_labelText__Zg1c4 .index-module_titleText__BRM44 {
|
|
736
|
+
max-width: calc(100% - 20px);
|
|
737
|
+
overflow: hidden;
|
|
738
|
+
}
|
|
723
739
|
.index-module_label__xE6hM .index-module_required__iElYl::before {
|
|
724
740
|
display: inline-block;
|
|
725
741
|
margin-right: 4px;
|
|
@@ -732,6 +748,7 @@
|
|
|
732
748
|
.index-module_label__xE6hM .index-module_extra__PW5Qk {
|
|
733
749
|
float: right;
|
|
734
750
|
margin-right: 5px;
|
|
751
|
+
width: 40%;
|
|
735
752
|
}
|
|
736
753
|
|
|
737
754
|
.index-module_textareaContainer__dTIv4 {
|
|
@@ -862,6 +879,7 @@
|
|
|
862
879
|
flex-wrap: wrap;
|
|
863
880
|
align-items: center;
|
|
864
881
|
justify-content: center;
|
|
882
|
+
overflow: hidden;
|
|
865
883
|
}
|
|
866
884
|
.index-module_placeholderHotkey__0SKPo .text {
|
|
867
885
|
color: #333;
|
|
@@ -878,7 +896,10 @@
|
|
|
878
896
|
|
|
879
897
|
.index-module_attribute__g8Vbl {
|
|
880
898
|
height: 22px;
|
|
881
|
-
padding:
|
|
899
|
+
padding: 0px 8px;
|
|
900
|
+
width: max-content;
|
|
901
|
+
max-width: 100%;
|
|
902
|
+
margin-left: auto;
|
|
882
903
|
}
|
|
883
904
|
|
|
884
905
|
.index-module_clearIcon__ZBZqI {
|
|
@@ -1141,7 +1162,8 @@
|
|
|
1141
1162
|
}
|
|
1142
1163
|
.index-module_clipSidebar__z2E8x .index-module_attributeList__2wnCE {
|
|
1143
1164
|
flex: 1;
|
|
1144
|
-
overflow:
|
|
1165
|
+
overflow-x: hidden;
|
|
1166
|
+
overflow-y: auto;
|
|
1145
1167
|
}
|
|
1146
1168
|
.index-module_clipSidebar__z2E8x .index-module_attributeList__2wnCE .sensebee-radio-group,
|
|
1147
1169
|
.index-module_clipSidebar__z2E8x .index-module_attributeList__2wnCE .sensebee-radio-group-no-limit-height .ant-radio-group {
|
|
@@ -1870,11 +1892,14 @@
|
|
|
1870
1892
|
-ms-user-select: none;
|
|
1871
1893
|
user-select: none;
|
|
1872
1894
|
}
|
|
1895
|
+
.generalOperation .generalOperation-col {
|
|
1896
|
+
display: flex;
|
|
1897
|
+
justify-content: center;
|
|
1898
|
+
}
|
|
1873
1899
|
.generalOperation .item {
|
|
1874
1900
|
text-align: center;
|
|
1875
|
-
flex: 1;
|
|
1876
1901
|
box-sizing: border-box;
|
|
1877
|
-
width:
|
|
1902
|
+
width: 100px;
|
|
1878
1903
|
height: 100%;
|
|
1879
1904
|
display: flex;
|
|
1880
1905
|
flex-direction: column;
|
|
@@ -3077,15 +3102,12 @@
|
|
|
3077
3102
|
display: block;
|
|
3078
3103
|
}
|
|
3079
3104
|
.bee-sidebar__content__NLPList__item__text {
|
|
3080
|
-
flex: 1 1;
|
|
3081
|
-
padding: 16px;
|
|
3082
3105
|
font-weight: 400;
|
|
3083
3106
|
font-size: 12px;
|
|
3084
3107
|
line-height: 20px;
|
|
3085
3108
|
color: #666666;
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
white-space: nowrap;
|
|
3109
|
+
padding: 16px;
|
|
3110
|
+
width: 100%;
|
|
3089
3111
|
}
|
|
3090
3112
|
.bee-sidebar__content__NLPList__item__active {
|
|
3091
3113
|
background-color: #eeefff;
|