Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Audio tool secondary attribute optimizatio #520

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading