-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
React UI: Semi-automatic segmentation (#1398)
* implemented checked * Implemented plugin * Added dialog windows * Updated changelo * Added cancel request
- Loading branch information
Showing
10 changed files
with
369 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
cvat-ui/src/components/annotation-page/standard-workspace/controls-side-bar/dextr-plugin.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// Copyright (C) 2020 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
import React, { useState } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import Checkbox, { CheckboxChangeEvent } from 'antd/lib/checkbox'; | ||
import Tooltip from 'antd/lib/tooltip'; | ||
|
||
import { Canvas } from 'cvat-canvas'; | ||
import { CombinedState } from 'reducers/interfaces'; | ||
import { activate as activatePlugin, deactivate as deactivatePlugin } from 'utils/dextr-utils'; | ||
|
||
|
||
interface StateToProps { | ||
pluginEnabled: boolean; | ||
canvasInstance: Canvas; | ||
} | ||
|
||
interface DispatchToProps { | ||
activate(canvasInstance: Canvas): void; | ||
deactivate(canvasInstance: Canvas): void; | ||
} | ||
|
||
function mapStateToProps(state: CombinedState): StateToProps { | ||
const { | ||
plugins: { | ||
list, | ||
}, | ||
annotation: { | ||
canvas: { | ||
instance: canvasInstance, | ||
}, | ||
}, | ||
} = state; | ||
|
||
return { | ||
canvasInstance, | ||
pluginEnabled: list.DEXTR_SEGMENTATION, | ||
}; | ||
} | ||
|
||
function mapDispatchToProps(): DispatchToProps { | ||
return { | ||
activate(canvasInstance: Canvas): void { | ||
activatePlugin(canvasInstance); | ||
}, | ||
deactivate(canvasInstance: Canvas): void { | ||
deactivatePlugin(canvasInstance); | ||
}, | ||
}; | ||
} | ||
|
||
function DEXTRPlugin(props: StateToProps & DispatchToProps): JSX.Element | null { | ||
const { | ||
pluginEnabled, | ||
canvasInstance, | ||
activate, | ||
deactivate, | ||
} = props; | ||
const [pluginActivated, setActivated] = useState(false); | ||
|
||
return ( | ||
pluginEnabled ? ( | ||
<Tooltip title='Make AI polygon from at least 4 extreme points using deep extreme cut'> | ||
<Checkbox | ||
style={{ marginTop: 5 }} | ||
checked={pluginActivated} | ||
onChange={(event: CheckboxChangeEvent): void => { | ||
setActivated(event.target.checked); | ||
if (event.target.checked) { | ||
activate(canvasInstance); | ||
} else { | ||
deactivate(canvasInstance); | ||
} | ||
}} | ||
> | ||
Make AI polygon | ||
</Checkbox> | ||
</Tooltip> | ||
) : null | ||
); | ||
} | ||
|
||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
)(DEXTRPlugin); | ||
|
||
// TODO: Add dialog window with cancel button |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.