Added tag popover template
parent
b3f7f5b8bc
commit
6acda049a8
@ -0,0 +1,48 @@
|
|||||||
|
// Copyright (C) 2020 Intel Corporation
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import {
|
||||||
|
Popover,
|
||||||
|
Icon,
|
||||||
|
} from 'antd';
|
||||||
|
|
||||||
|
import { Canvas } from 'cvat-canvas';
|
||||||
|
import { TagIcon } from 'icons';
|
||||||
|
|
||||||
|
import SetupTagPopoverContainer from 'containers/annotation-page/standard-workspace/controls-side-bar/setup-tag-popover';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
canvasInstance: Canvas;
|
||||||
|
isDrawing: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
function SetupTagControl(props: Props): JSX.Element {
|
||||||
|
const {
|
||||||
|
isDrawing,
|
||||||
|
} = props;
|
||||||
|
|
||||||
|
const dynamcPopoverPros = isDrawing ? {
|
||||||
|
overlayStyle: {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
|
} : {};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Popover
|
||||||
|
{...dynamcPopoverPros}
|
||||||
|
placement='right'
|
||||||
|
overlayClassName='cvat-draw-shape-popover'
|
||||||
|
content={(
|
||||||
|
<SetupTagPopoverContainer />
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Icon
|
||||||
|
component={TagIcon}
|
||||||
|
/>
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default React.memo(SetupTagControl);
|
||||||
@ -0,0 +1,73 @@
|
|||||||
|
// Copyright (C) 2020 Intel Corporation
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import {
|
||||||
|
Row,
|
||||||
|
Col,
|
||||||
|
Select,
|
||||||
|
Button,
|
||||||
|
} from 'antd';
|
||||||
|
|
||||||
|
import Text from 'antd/lib/typography/Text';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
labels: any[];
|
||||||
|
selectedLabeID: number;
|
||||||
|
onChangeLabel(value: string): void;
|
||||||
|
onSetup(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupTagPopover(props: Props): JSX.Element {
|
||||||
|
const {
|
||||||
|
labels,
|
||||||
|
selectedLabeID,
|
||||||
|
onChangeLabel,
|
||||||
|
onSetup,
|
||||||
|
} = props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className='cvat-draw-shape-popover-content'>
|
||||||
|
<Row type='flex' justify='start'>
|
||||||
|
<Col>
|
||||||
|
<Text className='cvat-text-color' strong>Setup tag</Text>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<Row type='flex' justify='start'>
|
||||||
|
<Col>
|
||||||
|
<Text className='cvat-text-color'>Label</Text>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<Row type='flex' justify='center'>
|
||||||
|
<Col span={24}>
|
||||||
|
<Select
|
||||||
|
value={`${selectedLabeID}`}
|
||||||
|
onChange={onChangeLabel}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
labels.map((label: any) => (
|
||||||
|
<Select.Option
|
||||||
|
key={label.id}
|
||||||
|
value={`${label.id}`}
|
||||||
|
>
|
||||||
|
{label.name}
|
||||||
|
</Select.Option>
|
||||||
|
))
|
||||||
|
}
|
||||||
|
</Select>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
<Row type='flex' justify='space-around'>
|
||||||
|
<Col span={24}>
|
||||||
|
<Button onClick={onSetup}>
|
||||||
|
Tag
|
||||||
|
</Button>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default React.memo(setupTagPopover);
|
||||||
@ -0,0 +1,101 @@
|
|||||||
|
// Copyright (C) 2020 Intel Corporation
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
import {
|
||||||
|
CombinedState,
|
||||||
|
} from 'reducers/interfaces';
|
||||||
|
|
||||||
|
import { Canvas } from 'cvat-canvas';
|
||||||
|
import SetupTagPopoverComponent from 'components/annotation-page/standard-workspace/controls-side-bar/setup-tag-popover';
|
||||||
|
|
||||||
|
interface DispatchToProps {
|
||||||
|
onTagSetup(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StateToProps {
|
||||||
|
canvasInstance: Canvas;
|
||||||
|
labels: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapDispatchToProps(dispatch: any): DispatchToProps {
|
||||||
|
return {
|
||||||
|
onTagSetup(): void {
|
||||||
|
dispatch();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapStateToProps(state: CombinedState): StateToProps {
|
||||||
|
const {
|
||||||
|
annotation: {
|
||||||
|
canvas: {
|
||||||
|
instance: canvasInstance,
|
||||||
|
},
|
||||||
|
job: {
|
||||||
|
labels,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} = state;
|
||||||
|
|
||||||
|
return {
|
||||||
|
canvasInstance,
|
||||||
|
labels,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
type Props = StateToProps;
|
||||||
|
|
||||||
|
interface State {
|
||||||
|
selectedLabelID: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DrawShapePopoverContainer extends React.PureComponent<Props, State> {
|
||||||
|
constructor(props: Props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
const defaultLabelID = props.labels[0].id;
|
||||||
|
this.state = {
|
||||||
|
selectedLabelID: defaultLabelID,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private onChangeLabel = (value: string): void => {
|
||||||
|
this.setState({
|
||||||
|
selectedLabelID: +value,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
private onSetup(): void {
|
||||||
|
const { canvasInstance } = this.props;
|
||||||
|
|
||||||
|
canvasInstance.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public render(): JSX.Element {
|
||||||
|
const {
|
||||||
|
selectedLabelID,
|
||||||
|
} = this.state;
|
||||||
|
|
||||||
|
const {
|
||||||
|
labels,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SetupTagPopoverComponent
|
||||||
|
labels={labels}
|
||||||
|
selectedLabeID={selectedLabelID}
|
||||||
|
onChangeLabel={this.onChangeLabel}
|
||||||
|
onSetup={this.onSetup}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps,
|
||||||
|
)(DrawShapePopoverContainer);
|
||||||
Loading…
Reference in New Issue