Skip to content

Commit

Permalink
fixed navigation with deleted frames
Browse files Browse the repository at this point in the history
  • Loading branch information
klakhov committed Jun 21, 2023
1 parent 290634a commit 9ba5934
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
3 changes: 2 additions & 1 deletion cvat-core/src/frames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,8 @@ export async function findFrame(jobID, frameFrom, frameTo, filters) {
let lastUndeletedFrame = null;
const check = (frame): boolean => {
if (meta.included_frames) {
return (meta.included_frames.includes(frame)) && !(frame in meta.deleted_frames);
return (meta.included_frames.includes(frame)) &&
(!filters.notDeleted || !(frame in meta.deleted_frames));
}
if (filters.notDeleted) {
return !(frame in meta.deleted_frames);
Expand Down
20 changes: 9 additions & 11 deletions cvat-ui/src/actions/annotation-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1602,18 +1602,16 @@ export function deleteFrameAsync(frame: number): ThunkAction {
},
});

if (!showDeletedFrames) {
let notDeletedFrame = await jobInstance.frames.search(
{ notDeleted: true }, frame, jobInstance.stopFrame,
let notDeletedFrame = await jobInstance.frames.search(
{ notDeleted: !showDeletedFrames }, frame, jobInstance.stopFrame,
);
if (notDeletedFrame === null && jobInstance.startFrame !== frame) {
notDeletedFrame = await jobInstance.frames.search(
{ notDeleted: !showDeletedFrames }, frame, jobInstance.startFrame,
);
if (notDeletedFrame === null && jobInstance.startFrame !== frame) {
notDeletedFrame = await jobInstance.frames.search(
{ notDeleted: true }, frame, jobInstance.startFrame,
);
}
if (notDeletedFrame !== null) {
dispatch(changeFrameAsync(notDeletedFrame));
}
}
if (notDeletedFrame !== null) {
dispatch(changeFrameAsync(notDeletedFrame));
}
} catch (error) {
dispatch({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface StateToProps {
keyMap: KeyMap;
normalizedKeyMap: Record<string, string>;
frameData: any;
showDeletedFrames: boolean;
}

interface DispatchToProps {
Expand All @@ -59,6 +60,9 @@ function mapStateToProps(state: CombinedState): StateToProps {
job: { instance: jobInstance, labels },
},
shortcuts: { keyMap, normalizedKeyMap },
settings: {
player: { showDeletedFrames },
},
} = state;

return {
Expand All @@ -69,6 +73,7 @@ function mapStateToProps(state: CombinedState): StateToProps {
keyMap,
normalizedKeyMap,
frameData,
showDeletedFrames,
};
}

Expand Down Expand Up @@ -101,6 +106,7 @@ function TagAnnotationSidebar(props: StateToProps & DispatchToProps): JSX.Elemen
createAnnotations,
keyMap,
frameData,
showDeletedFrames,
} = props;

const preventDefault = (event: KeyboardEvent | undefined): void => {
Expand Down Expand Up @@ -174,10 +180,13 @@ function TagAnnotationSidebar(props: StateToProps & DispatchToProps): JSX.Elemen
if (objectState) removeObject(objectState);
};

const onChangeFrame = (): void => {
const frame = Math.min(jobInstance.stopFrame, frameNumber + 1);

if (isAbleToChangeFrame()) {
const onChangeFrame = async (): Promise<void> => {
const frame = await jobInstance.frames.search(
{ notDeleted: !showDeletedFrames },
frameNumber + 1,
jobInstance.stopFrame,
);
if (frame !== null && isAbleToChangeFrame()) {
changeFrame(frame);
}
};
Expand Down
9 changes: 5 additions & 4 deletions cvat-ui/src/containers/annotation-page/top-bar/top-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ class AnnotationTopBarContainer extends React.PureComponent<Props, State> {
frameNumber, jobInstance, playing, onSwitchPlay, showDeletedFrames,
} = this.props;

const newFrame = showDeletedFrames ? jobInstance.startFrame :
await jobInstance.frames.search({ notDeleted: true }, jobInstance.startFrame, frameNumber);
const newFrame =
await jobInstance.frames.search({ notDeleted: !showDeletedFrames }, jobInstance.startFrame, frameNumber);
if (newFrame !== frameNumber && newFrame !== null) {
if (playing) {
onSwitchPlay(false);
Expand Down Expand Up @@ -347,6 +347,7 @@ class AnnotationTopBarContainer extends React.PureComponent<Props, State> {
frameFrom,
jobInstance.startFrame,
);

if (newFrame !== frameNumber && newFrame !== null) {
if (playing) {
onSwitchPlay(false);
Expand Down Expand Up @@ -414,8 +415,8 @@ class AnnotationTopBarContainer extends React.PureComponent<Props, State> {
frameNumber, jobInstance, playing, onSwitchPlay, showDeletedFrames,
} = this.props;

const newFrame = showDeletedFrames ? jobInstance.stopFrame :
await jobInstance.frames.search({ notDeleted: true }, jobInstance.stopFrame, frameNumber);
const newFrame =
await jobInstance.frames.search({ notDeleted: !showDeletedFrames }, jobInstance.stopFrame, frameNumber);
if (newFrame !== frameNumber && frameNumber !== null) {
if (playing) {
onSwitchPlay(false);
Expand Down

0 comments on commit 9ba5934

Please sign in to comment.