Skip to content

Commit

Permalink
feat(pointcloud): BatchUpdate provides more params
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerwin-L committed Feb 21, 2023
1 parent f5d6902 commit 47a9047
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
31 changes: 27 additions & 4 deletions packages/lb-components/src/store/annotation/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,19 +743,31 @@ export const annotationReducer = (
case ANNOTATION_ACTIONS.BATCH_UPDATE_TRACK_ID: {
const { id, newID, rangeIndex, imgList } = action.payload;
const { imgIndex, onSubmit } = state;

// Record the updated list.
const updateImgList: Array<{ newInfo: IFileItem; imgIndex: number }> = [];
const newImgList = imgList.map((v: IFileItem, i: number) => {
if (MathUtils.isInRange(i, rangeIndex)) {
return {
const newInfo = {
...v,
result: PointCloudUtils.batchUpdateTrackID({ id, newID, result: v.result }),
};

updateImgList.push({
imgIndex: i,
newInfo,
});

return newInfo;
}
return v;
});

// Notify external data changes.
if (onSubmit) {
onSubmit([newImgList[imgIndex]], ESubmitType.BatchUpdateTrackID, imgIndex, newImgList);
onSubmit([newImgList[imgIndex]], ESubmitType.BatchUpdateTrackID, imgIndex, newImgList, {
updateImgList,
});
}

return {
Expand All @@ -767,19 +779,30 @@ export const annotationReducer = (
case ANNOTATION_ACTIONS.BATCH_UPDATE_RESULT_BY_TRACK_ID: {
const { id, newData, rangeIndex } = action.payload;
const { imgList, imgIndex, onSubmit } = state;
// Record the updated list.
const updateImgList: Array<{ newInfo: IFileItem; imgIndex: number }> = [];
const newImgList = imgList.map((v, i) => {
if (MathUtils.isInRange(i, rangeIndex)) {
return {
const newInfo = {
...v,
result: PointCloudUtils.batchUpdateResultByTrackID({ id, newData, result: v.result }),
};

updateImgList.push({
imgIndex: i,
newInfo,
});

return newInfo;
}
return v;
});

// Notify external data changes.
if (onSubmit) {
onSubmit([newImgList[imgIndex]], ESubmitType.BatchUpdateTrackID, imgIndex, newImgList);
onSubmit([newImgList[imgIndex]], ESubmitType.BatchUpdateTrackID, imgIndex, newImgList, {
updateImgList,
});
}

return {
Expand Down
2 changes: 2 additions & 0 deletions packages/lb-components/src/types/data.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export type OnSubmit = (
submitType: ESubmitType,
imgIndex: number,
imgList: IFileItem[],
// Just use it in pointCloud now.
extra?: { updateImgList: Array<{ newInfo: IFileItem; imgIndex: number }> },
) => void;

export type OnSave = (data: IFileItem, imgIndex: number, imgList: AnnotationFileList) => void;
Expand Down

0 comments on commit 47a9047

Please sign in to comment.