Skip to content

Commit

Permalink
Merge pull request #505 from sharefe-demo/feat_alpha/flush-when-chang…
Browse files Browse the repository at this point in the history
…e-context

feat(lb-components): Make the no matching-pcb rect to normal
  • Loading branch information
lihqi authored Jul 2, 2024
2 parents 7bce514 + 825ec4d commit e5bcd27
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import UnlinkIcon from '@/assets/annotation/icon_unlink.svg';
import { BatchSwitchConnectionEventBusEvent } from '@/views/MainView/toolFooter/BatchSwitchConnectIn2DView';
import { EventBus } from '@labelbee/lb-annotation';
import { useSyncRectPositionDimensionToPointCloudList } from './usePointCloudViews';
import { IPointCloud2DRectOperationViewRect, IPointCloudBoxRect } from '@labelbee/lb-utils';

const useShownIcon = (imageName?: string) => {
const { imageNamePointCloudBoxMap, linkageImageNameRectMap } = useContext(PointCloudContext);
Expand Down Expand Up @@ -81,6 +82,7 @@ const useDataLinkSwitch = (opts: UseDataLinkSwitchOptions) => {
linkageImageNameRectMap,
pointCloudBoxList,
rectList,
updateRectListByReducer,
} = useContext(PointCloudContext);

const { visible: visibleLinkageIcon, visibleRef: visibleLinkageIconRef } = useShownIcon(
Expand Down Expand Up @@ -210,6 +212,36 @@ const useDataLinkSwitch = (opts: UseDataLinkSwitchOptions) => {
syncIsLinking();
}, [syncIsLinking, pointCloudBoxList, rectList]);


// Set to normal rect when has no matching-pointCloudBox owner
useEffect(() => {
const ids = pointCloudBoxList.map(item => item.id);
const set = new Set(ids);

updateRectListByReducer((prevRectList, pickRectObject) => {
const filteredUnLinkageItems: IPointCloudBoxRect[] = [];
const otherItems: IPointCloudBoxRect[] = [];

prevRectList.forEach((item) => {
const extId = item.extId;
if (extId !== undefined && set.has(extId) === false) {
filteredUnLinkageItems.push(item);
} else {
otherItems.push(item);
}
});

if (filteredUnLinkageItems.length) {
return [
...filteredUnLinkageItems.map(item => pickRectObject(item as IPointCloud2DRectOperationViewRect)),
...otherItems
]
}

return prevRectList;
})
}, [pointCloudBoxList])

useEffect(() => {
const fn = (isConnect: boolean) => {
handleManualSwitch.current(isConnect);
Expand Down

0 comments on commit e5bcd27

Please sign in to comment.