Skip to content

Commit

Permalink
Merge pull request #520 from lihqi/lhq-alpha-0712
Browse files Browse the repository at this point in the history
feat: Audio tool secondary attribute optimizatio
  • Loading branch information
lihqi authored Jul 15, 2024
2 parents 0129698 + a7002ad commit 4e6e23f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import { DEFAULT_FONT, ELineTypes, SEGMENT_NUMBER } from '@/constant/tool';
import { DEFAULT_TEXT_SHADOW, DEFAULT_TEXT_OFFSET, TEXT_ATTRIBUTE_OFFSET } from '@/constant/annotation';
import ImgUtils, { cropAndEnlarge } from '@/utils/ImgUtils';
import CanvasUtils from '@/utils/tool/CanvasUtils';
import TagUtils from '@/utils/tool/TagUtils';
import { BasicToolOperation, IBasicToolOperationProps } from './basicToolOperation';
import { pointCloudLidar2image } from '../pointCloud/matrix';
import TagUtils from '@/utils/tool/TagUtils';

const newScope = 3;
const DEFAULT_RADIUS = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
height: 100%;
border: 1px solid transparent;
font-size: 12px;
overflow-y: auto;
.loop {
position: absolute;
width: 18px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import LoopIcon from '@/assets/annotation/audio/loop.svg';
import { Typography } from 'antd';
import { useClickAway } from 'ahooks';
import { classnames } from '@/utils';
import { IAudioTimeSlice, ITextConfigItem } from '@labelbee/lb-utils';
import { IAudioTimeSlice, IInputList, ITextConfigItem } from '@labelbee/lb-utils';

import styles from './index.module.scss';
import { useTranslation } from 'react-i18next';
import { TagUtils } from '@labelbee/lb-annotation';

interface IProps {
/** 挂载到目标元素 */
Expand All @@ -35,6 +36,38 @@ interface IProps {
}

const { Paragraph } = Typography;

const SubAttributeShowText = ({
result,
subAttributeList,
textStyle,
}: {
result: { [key: string]: string };
subAttributeList: IInputList[];
textStyle: {
color: string;
backgroundColor: string;
};
}) => {
const list = TagUtils.getTagNameList(result, subAttributeList);
return (
<div>
{list.map((i, index) => {
return (
<Paragraph
ellipsis={{ rows: 2 }}
className={styles.text}
key={index}
style={{ ...textStyle, marginBottom: 0 }}
>
{`${i.keyName}${i.value.join(`、`)}`}
</Paragraph>
);
})}
</div>
);
};

/** 展示在音频图上的截取片段 */
const ClipRegion = (props: IProps) => {
const { t } = useTranslation();
Expand All @@ -45,11 +78,13 @@ const ClipRegion = (props: IProps) => {
clipTextConfigurable,
selectedRegion,
clipTextList,
secondaryAttributeConfigurable,
subAttributeList,
} = audioClipState;

const ref = useRef(null);
const { el, region, edgeAdsorption, clipping, instance } = props;
const { attribute = '', text = '', id, start, end } = region;
const { attribute = '', text = '', id, start, end, subAttribute } = region;

const { id: selectedId } = selectedRegion;
const attributeColor = getAttributeColor(attribute, clipAttributeList);
Expand Down Expand Up @@ -116,6 +151,13 @@ const ClipRegion = (props: IProps) => {
<div style={textStyle} className={styles.attribute}>
{getAttributeShowText(attribute, [{ value: '', key: '无属性' }, ...clipAttributeList])}
</div>
{secondaryAttributeConfigurable && subAttribute && subAttributeList && (
<SubAttributeShowText
result={subAttribute}
subAttributeList={subAttributeList}
textStyle={textStyle}
/>
)}
</div>
)}

Expand Down

0 comments on commit 4e6e23f

Please sign in to comment.