-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the feature to Remove annotation objects in a specified range of frames #3617
Changes from 21 commits
25527db
aab67f4
a085554
7839fe8
c092a56
4d39b94
cde900f
5ed81c3
6f5b922
d47db3c
25bbb49
6dba4e8
d72833d
abca64f
fb30089
2e714f1
88d1ec1
6cc2403
5317c04
c7a4a03
e5c23b0
455466f
a313f46
8b0dc67
96e73a7
b92b93c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,8 @@ | |
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
|
||
import Menu from 'antd/lib/menu'; | ||
import Modal from 'antd/lib/modal'; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
|
@@ -11,6 +12,8 @@ import { MenuInfo } from 'rc-menu/lib/interface'; | |
import LoadSubmenu from 'components/actions-menu/load-submenu'; | ||
import { DimensionType } from '../../../reducers/interfaces'; | ||
|
||
import RemoveAnnotationsRangeComponent from './remove-range-confirm'; | ||
|
||
interface Props { | ||
taskMode: string; | ||
loaders: any[]; | ||
|
@@ -20,6 +23,8 @@ interface Props { | |
jobInstance: any; | ||
onClickMenu(params: MenuInfo): void; | ||
onUploadAnnotations(format: string, file: File): void; | ||
stopFrame: number; | ||
removeRange(startnumber: number, endnumber: number, deltrack_keyframes_only:boolean): void; | ||
setForceExitAnnotationFlag(forceExit: boolean): void; | ||
saveAnnotations(jobInstance: any, afterSave?: () => void): void; | ||
} | ||
|
@@ -41,12 +46,16 @@ export default function AnnotationMenuComponent(props: Props): JSX.Element { | |
loadActivity, | ||
isReviewer, | ||
jobInstance, | ||
stopFrame, | ||
onClickMenu, | ||
onUploadAnnotations, | ||
removeRange, | ||
setForceExitAnnotationFlag, | ||
saveAnnotations, | ||
} = props; | ||
|
||
const [openRemoveRangeComponent, toggleOpenRemoveRangeComponent] = useState(false); | ||
|
||
const jobStatus = jobInstance.status; | ||
const taskID = jobInstance.task.id; | ||
|
||
|
@@ -81,19 +90,40 @@ export default function AnnotationMenuComponent(props: Props): JSX.Element { | |
|
||
if (params.key === Actions.REMOVE_ANNO) { | ||
Modal.confirm({ | ||
title: 'All the annotations will be removed', | ||
title: 'Remove Annotations', | ||
content: | ||
'You are going to remove all the annotations from the client. ' + | ||
'Select whether to remove all annotations from the job or remove within a range\n' + | ||
'It will stay on the server till you save the job. Continue?', | ||
className: 'cvat-modal-confirm-remove-annotation', | ||
onOk: () => { | ||
onClickMenu(params); | ||
Modal.confirm({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest following: pseudocode
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you do not need remove-range-confirm.tsx Component. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I'll try this approach. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you also suggest clubbing the removeAnnotationsAsync and removeAnnotationsinRangeAsync actions as one action There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, I think yes. They are very similar each other. |
||
title: 'All the annotations will be removed', | ||
content: | ||
'You are going to remove all the annotations from the client. ' + | ||
'It will stay on the server till you save the job. Continue?', | ||
className: 'cvat-modal-confirm-remove-annotation', | ||
onOk: () => { | ||
onClickMenu(params); | ||
}, | ||
okButtonProps: { | ||
type: 'primary', | ||
danger: true, | ||
}, | ||
okText: 'Delete', | ||
}); | ||
}, | ||
okButtonProps: { | ||
type: 'primary', | ||
danger: true, | ||
}, | ||
okText: 'Delete', | ||
okText: 'Remove All', | ||
onCancel: () => { | ||
toggleOpenRemoveRangeComponent(!openRemoveRangeComponent); | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not think it is the best solution. Cancel button is not obvious to do action you programmed. |
||
cancelText: 'Select Range', | ||
cancelButtonProps: { | ||
type: 'primary', | ||
}, | ||
}); | ||
} else if (params.key === Actions.REQUEST_REVIEW) { | ||
checkUnsavedChanges(params); | ||
|
@@ -127,7 +157,7 @@ export default function AnnotationMenuComponent(props: Props): JSX.Element { | |
const is2d = jobInstance.task.dimension === DimensionType.DIM_2D; | ||
|
||
return ( | ||
<Menu onClick={onClickMenuWrapper} className='cvat-annotation-menu' selectable={false}> | ||
<Menu onClick={(params: MenuInfo) => onClickMenuWrapper(params)} className='cvat-annotation-menu' selectable={false}> | ||
{LoadSubmenu({ | ||
loaders, | ||
loadActivity, | ||
|
@@ -164,6 +194,12 @@ export default function AnnotationMenuComponent(props: Props): JSX.Element { | |
<Menu.Item key={Actions.SUBMIT_REVIEW}>Submit the review</Menu.Item> | ||
)} | ||
{jobStatus === 'completed' && <Menu.Item key={Actions.RENEW_JOB}>Renew the job</Menu.Item>} | ||
<RemoveAnnotationsRangeComponent | ||
visible={openRemoveRangeComponent} | ||
removeinRange={removeRange} | ||
stopFrame={stopFrame} | ||
cancel={() => { toggleOpenRemoveRangeComponent(!openRemoveRangeComponent); }} | ||
/> | ||
</Menu> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import React, { useState } from 'react'; | ||
|
||
import Modal from 'antd/lib/modal'; | ||
import InputNumber from 'antd/lib/input-number'; | ||
import Text from 'antd/lib/typography/Text'; | ||
import Checkbox from 'antd/lib/checkbox'; | ||
import { clamp } from 'utils/math'; | ||
|
||
interface Props { | ||
visible: boolean; | ||
stopFrame: number; | ||
removeinRange(startnumber:number, endnumber:number, delTrackKeyframesOnly:boolean): void; | ||
cancel(): void; | ||
} | ||
|
||
export default function RemoveRangeConfirmComponent(props: Props): JSX.Element { | ||
const { | ||
visible, | ||
stopFrame, | ||
removeinRange, | ||
cancel, | ||
} = props; | ||
|
||
const minStartFrames = 0; | ||
|
||
const [startFrame, managestart] = useState<number>(0); | ||
const [endFrame, manageend] = useState<number>(1); | ||
const [delTrackKeyframesOnly, managedelTrackKeyframesOnly] = useState<boolean>(false); | ||
|
||
const minEndFrames = Math.max(startFrame, 1); | ||
|
||
return ( | ||
<Modal | ||
okType='primary' | ||
okText='Yes' | ||
cancelText='Cancel' | ||
onOk={() => { | ||
removeinRange(startFrame, endFrame, delTrackKeyframesOnly); | ||
cancel(); | ||
}} | ||
onCancel={cancel} | ||
title='Confirm to remove annotations in range' | ||
visible={visible} | ||
> | ||
<div className='cvat-propagate-confirm'> | ||
<Text>Do you want to remove the annotations on</Text> | ||
<InputNumber | ||
className='cvat-propagate-confirm-object-on-frames' | ||
size='small' | ||
min={minStartFrames} | ||
max={stopFrame} | ||
value={startFrame} | ||
onChange={(value: number | undefined | string) => { | ||
if (typeof value !== 'undefined') { | ||
const newvalue = Math.floor(clamp(+value, 0, stopFrame - 1)); | ||
managestart(newvalue); | ||
} | ||
}} | ||
/> | ||
{startFrame > 1 ? <Text> frames </Text> : <Text> frame </Text>} | ||
<Text>up to the </Text> | ||
<InputNumber | ||
className='cvat-propagate-confirm-object-up-to-frame' | ||
size='small' | ||
min={minEndFrames} | ||
max={stopFrame} | ||
value={endFrame} | ||
onChange={(value: number | undefined | string) => { | ||
if (typeof value !== 'undefined') { | ||
const newvalue = Math.floor(clamp(+value, 1, stopFrame)); | ||
manageend(newvalue); | ||
} | ||
}} | ||
/> | ||
<Text>frame</Text> | ||
, | ||
<br /> | ||
<br /> | ||
<Checkbox onChange={() => { managedelTrackKeyframesOnly(!delTrackKeyframesOnly); }}> | ||
Delete only track keyframes | ||
</Checkbox> | ||
</div> | ||
</Modal> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it is unused variable