Skip to content

Commit

Permalink
fix: 2D view image selection logic optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Original-Recipe committed Sep 18, 2024
1 parent 343927d commit 297b9d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class PointCloud2DRectOperation extends RectOperation {

public rightMouseUp(e: MouseEvent) {
const hoverRect: (IRect & { boxID?: string }) | undefined = super.rightMouseUp(e);
this.emit('onRightClick', { event: e, targetId: hoverRect?.boxID });
this.emit('onRightClick', { event: e, targetId: hoverRect?.boxID, id: hoverRect?.id });
return hoverRect;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ const PointCloud2DRectOperationView = (props: IPointCloud2DRectOperationViewProp

const [loading, setLoading] = useState(true);

const [rightClickRectId, setRightClickRectId] = useState<string>('');

const rectListInImage = useMemo(
() => rectList?.filter((item: IPointCloudBoxRect) => item.imageName === mappingData?.path),
[mappingData?.path, rectList],
Expand Down Expand Up @@ -146,7 +148,7 @@ const PointCloud2DRectOperationView = (props: IPointCloud2DRectOperationViewProp

const handleRemoveRect = (rectList: IPointCloud2DRectOperationViewRect[]) => {
if (rectList.length === 0) {
return
return;
}

if (!shouldExcludePointCloudBoxListUpdate) {
Expand All @@ -164,7 +166,7 @@ const PointCloud2DRectOperationView = (props: IPointCloud2DRectOperationViewProp
return result;
}

return null
return null;
});

return;
Expand All @@ -177,7 +179,7 @@ const PointCloud2DRectOperationView = (props: IPointCloud2DRectOperationViewProp
if (matchedExtIdIDRect) {
recoverSelectedIds(() => {
// @ts-ignore
const { imageName, extId: boxID } = matchedExtIdIDRect
const { imageName, extId: boxID } = matchedExtIdIDRect;
// NOTE maybe change selectIds
const result = remove2DViewRectFn?.({ boxID, imageName });

Expand All @@ -187,7 +189,7 @@ const PointCloud2DRectOperationView = (props: IPointCloud2DRectOperationViewProp
return result;
}

return null
return null;
});
}

Expand All @@ -209,7 +211,6 @@ const PointCloud2DRectOperationView = (props: IPointCloud2DRectOperationViewProp

const updateRectList = useUpdateRectList(() => {
const rectListByBoxList = shouldExcludePointCloudBoxListUpdate ? [] : getRectListByBoxList();
const selectedRectID = operation.current?.selectedRectID;

// Case 1: Show all ids
// const img2dResult = [...rectListByBoxList, ...rectListInImage]
Expand All @@ -223,13 +224,16 @@ const PointCloud2DRectOperationView = (props: IPointCloud2DRectOperationViewProp
);

operation.current?.setResult(img2dResult);

if (selectedRectID) {
operation.current?.setSelectedRectID(selectedRectID);
if (rightClickRectId) {
operation.current?.setSelectedRectID(rightClickRectId);
setRightClickRectId('');
}
});

const onRightClick = ({targetId}: { targetId: string }) => setSelectedIDs(targetId)
const onRightClick = ({ targetId, id }: { targetId: string; id: string }) => {
setSelectedIDs(targetId);
setRightClickRectId(id);
};

useEffect(() => {
if (ref.current) {
Expand Down Expand Up @@ -257,7 +261,6 @@ const PointCloud2DRectOperationView = (props: IPointCloud2DRectOperationViewProp
}
}, []);


useEffect(() => {
const loadImage = async (url: string) => {
try {
Expand Down

0 comments on commit 297b9d7

Please sign in to comment.