Skip to content

Commit

Permalink
fix(pointcloud-segment): Forbid updating attribute & sub in checkStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
laoluo committed Sep 25, 2023
1 parent 3519826 commit e7a513e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface IProps {
updateColorConfig?: (value: string, color: string) => void;
updateSize?: (size: IDefaultSize) => void;
attributeLockChange?: (list: any) => void;
forbidShowLimitPopover?: boolean;
}

const AttributeList = React.forwardRef((props: IProps, ref) => {
Expand Down Expand Up @@ -93,7 +94,7 @@ const AttributeList = React.forwardRef((props: IProps, ref) => {
// Determine if a scope configuration exists
const hasLimit =
i?.limit?.positionLimit || defaultSize || sizeRange || logicalCondition?.length > 0;
const showLimitPopover = isChosen && hasLimit;
const showLimitPopover = isChosen && hasLimit && props.forbidShowLimitPopover !== true;

return (
<Radio value={i.value} ref={radioRef} key={i.label + index}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
IDefaultSize,
EPointCloudSegmentStatus,
IPointCloudSegmentation,
EPointCloudPattern,
} from '@labelbee/lb-utils';
import AttributeList from '@/components/attributeList';
import { useAttribute } from '@/components/pointCloudView/hooks/useAttribute';
Expand Down Expand Up @@ -211,6 +212,22 @@ const BoxTrackIDInput = () => {
);
};

/**
* Determine if the
*/
const isAllowUpdateInSegment = ({
segmentStatus,
globalPattern,
}: {
segmentStatus: EPointCloudSegmentStatus;
globalPattern: EPointCloudPattern;
}) => {
return (
globalPattern === EPointCloudPattern.Segmentation &&
![EPointCloudSegmentStatus.Edit, EPointCloudSegmentStatus.Ready].includes(segmentStatus)
);
};

const AttributeUpdater = ({
attributeList,
subAttributeList,
Expand Down Expand Up @@ -241,6 +258,7 @@ const AttributeUpdater = ({
const { t } = useTranslation();
const { defaultAttribute } = useAttribute();
const pointCloudViews = usePointCloudViews();
const { isPointCloudSegmentationPattern } = useStatus();

const dispatch = useDispatch();

Expand Down Expand Up @@ -298,10 +316,28 @@ const AttributeUpdater = ({
};

const setAttribute = (attribute: string) => {
if (
isAllowUpdateInSegment({
globalPattern: ptx.globalPattern,
segmentStatus: segmentData.segmentStatus,
})
) {
return;
}

toolInstance.setDefaultAttribute(attribute);
};

const setSubAttribute = (key: string, value: string) => {
if (
isAllowUpdateInSegment({
globalPattern: ptx.globalPattern,
segmentStatus: segmentData.segmentStatus,
})
) {
return;
}

toolInstance.setSubAttribute(key, value);
};

Expand All @@ -313,6 +349,13 @@ const AttributeUpdater = ({
isDefault: i?.isDefault,
}));

const isSelected =
selectedBox ||
(segmentData.cacheSegData && segmentData.segmentStatus === EPointCloudSegmentStatus.Edit);

// Just segment pattern forbid limitPopover
const forbidShowLimitPopover = isPointCloudSegmentationPattern;

return (
<div>
<div style={titleStyle}>{t('Attribute')}</div>
Expand All @@ -324,10 +367,10 @@ const AttributeUpdater = ({
updateColorConfig={updateColorConfig}
enableColorPicker={enableColorPicker}
updateSize={updateSize}
forbidShowLimitPopover={true}
forbidShowLimitPopover={forbidShowLimitPopover}
/>
<Divider style={{ margin: 0 }} />
{(selectedBox || segmentData.cacheSegData) && (
{isSelected && (
<>
{subAttributeList.map(
(subAttribute) =>
Expand Down

0 comments on commit e7a513e

Please sign in to comment.