From 1c3ee03b1dd3af8e2916e048b24f0fa4b5b8b874 Mon Sep 17 00:00:00 2001 From: lihqi <455711093@qq.com> Date: Wed, 11 Dec 2024 18:43:49 +0800 Subject: [PATCH] feat(lb-components): UnifySize add current frame size --- .../components/UnifyParamsModal/index.tsx | 132 +++++++++++++----- 1 file changed, 95 insertions(+), 37 deletions(-) diff --git a/packages/lb-components/src/components/pointCloudView/components/UnifyParamsModal/index.tsx b/packages/lb-components/src/components/pointCloudView/components/UnifyParamsModal/index.tsx index a3a33e2d..4e8dd2fa 100644 --- a/packages/lb-components/src/components/pointCloudView/components/UnifyParamsModal/index.tsx +++ b/packages/lb-components/src/components/pointCloudView/components/UnifyParamsModal/index.tsx @@ -1,11 +1,10 @@ -import { ESubmitType } from '@/constant'; -import { BatchUpdateResultByTrackID, ToSubmitFileData } from '@/store/annotation/actionCreators'; +import { BatchUpdateResultByTrackID } from '@/store/annotation/actionCreators'; import { LabelBeeContext, useDispatch } from '@/store/ctx'; -import { Form, InputNumber, message, Modal, Popover, Select } from 'antd'; +import { Form, InputNumber, message, Modal, Popover, Radio, Select } from 'antd'; import React, { useCallback, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { QuestionCircleOutlined } from '@ant-design/icons'; -import { IPointCloudConfig, PointCloudUtils } from '@labelbee/lb-utils'; +import { IPointCloudBox, IPointCloudConfig, PointCloudUtils } from '@labelbee/lb-utils'; import { connect } from 'react-redux'; import { AppState } from '@/store'; import { AnnotationFileList } from '@/types/data'; @@ -49,6 +48,65 @@ const PrefixTag: React.FC<{ text: string }> = ({ text }) => { ); }; +interface ISizeShowProps { + size?: { + width: number; + height: number; + depth: number; + }; + isMax: boolean; + selectedBox?: IPointCloudBox; +} + +const SizeShow = (props: ISizeShowProps) => { + const { t } = useTranslation(); + + const { size, isMax, selectedBox } = props; + + if (!size || !selectedBox) { + return null; + } + const style = { marginRight: 16 }; + + const params = { + ...selectedBox, + ...(isMax && size), + }; + + const { length, width, height } = PointCloudUtils.transferBox2Kitti(params); + + return ( +
+ + {t('Length')}: {length.toFixed(DECIMAL_PLACES)} + + + {t('Width')}: {width.toFixed(DECIMAL_PLACES)} + + + {t('Height')}: {height.toFixed(DECIMAL_PLACES)} + + + + +
+ ); +}; + +const sizeOptions = [ + { + value: 'current', + label: '当前帧尺寸', + }, + { + value: 'max', + label: '最大尺寸', + }, +]; + const UnifyParamsModal = ({ id, visible, onCancel, config, imgList, imgIndex }: IProps) => { const dispatch = useDispatch(); const { selectedBox } = useSingleBox(); @@ -101,9 +159,18 @@ const UnifyParamsModal = ({ id, visible, onCancel, config, imgList, imgIndex }: } } - if (size) { - Object.assign(newData, size); - } + const { UnifySize } = values; + + Object.assign( + newData, + size && UnifySize === 'max' + ? size + : { + width: selectedBox?.info?.width, + height: selectedBox?.info?.height, + depth: selectedBox?.info?.depth, + }, + ); dispatch( BatchUpdateResultByTrackID(id, newData, [values.prevPage - 1, values.nextPage - 1], imgList), @@ -139,34 +206,6 @@ const UnifyParamsModal = ({ id, visible, onCancel, config, imgList, imgIndex }: const onOk = () => form.submit(); - const sizeShow = () => { - if (!size || !selectedBox?.info) { - return; - } - const style = { marginRight: 16 }; - - const { length, width, height } = PointCloudUtils.transferBox2Kitti({ - ...selectedBox?.info, // Just for the type check - ...size, - }); - - return ( -
- - {t('Length')}: {length.toFixed(DECIMAL_PLACES)} - - - {t('Width')}: {width.toFixed(DECIMAL_PLACES)} - - - {t('Height')}: {height.toFixed(DECIMAL_PLACES)} - - - - -
- ); - }; const selectStyle = { width: '200px', }; @@ -242,8 +281,27 @@ const UnifyParamsModal = ({ id, visible, onCancel, config, imgList, imgIndex }: - - {sizeShow()} + + { + form.setFieldValue('UnifySize', e.target.value); + }} + > + {sizeOptions.map((item) => { + const { value, label } = item; + return ( + +
{label}
+ +
+ ); + })} +