Fixed copying/pasting actions

main
Dmitry Kalinin 6 years ago
parent 4746574ff1
commit 8602da72f1

@ -542,31 +542,10 @@ export function editShape(enabled: boolean): AnyAction {
} }
export function copyShape(objectState: any): AnyAction { export function copyShape(objectState: any): AnyAction {
const state = getStore().getState();
state.annotation.canvas.instance.cancel();
if (objectState.objectType !== ObjectType.TAG) {
state.annotation.canvas.instance.draw({
enabled: true,
initialState: objectState,
});
}
let activeControl = ActiveControl.CURSOR;
if (objectState.shapeType === ShapeType.RECTANGLE) {
activeControl = ActiveControl.DRAW_RECTANGLE;
} else if (objectState.shapeType === ShapeType.POINTS) {
activeControl = ActiveControl.DRAW_POINTS;
} else if (objectState.shapeType === ShapeType.POLYGON) {
activeControl = ActiveControl.DRAW_POLYGON;
} else if (objectState.shapeType === ShapeType.POLYLINE) {
activeControl = ActiveControl.DRAW_POLYLINE;
}
return { return {
type: AnnotationActionTypes.COPY_SHAPE, type: AnnotationActionTypes.COPY_SHAPE,
payload: { payload: {
activeControl, objectState,
}, },
}; };
} }
@ -1175,11 +1154,25 @@ export function searchAnnotationsAsync(
export function pasteShapeAsync(): ThunkAction<Promise<void>, {}, {}, AnyAction> { export function pasteShapeAsync(): ThunkAction<Promise<void>, {}, {}, AnyAction> {
return async (dispatch: ActionCreator<Dispatch>): Promise<void> => { return async (dispatch: ActionCreator<Dispatch>): Promise<void> => {
const initialState = getStore().getState().annotation.drawing.activeInitialState; const initialState = getStore().getState().annotation.drawing.activeInitialState;
const { instance: canvasInstance } = getStore().getState().annotation.canvas; const {
canvas: {
instance: canvasInstance,
},
job: {
instance: jobInstance,
},
player: {
frame: {
number: frameNumber,
},
},
} = getStore().getState().annotation;
if (initialState) { if (initialState) {
let activeControl = ActiveControl.DRAW_RECTANGLE; let activeControl = ActiveControl.CURSOR;
if (initialState.shapeType === ShapeType.POINTS) { if (initialState.shapeType === ShapeType.RECTANGLE) {
activeControl = ActiveControl.DRAW_RECTANGLE;
} else if (initialState.shapeType === ShapeType.POINTS) {
activeControl = ActiveControl.DRAW_POINTS; activeControl = ActiveControl.DRAW_POINTS;
} else if (initialState.shapeType === ShapeType.POLYGON) { } else if (initialState.shapeType === ShapeType.POLYGON) {
activeControl = ActiveControl.DRAW_POLYGON; activeControl = ActiveControl.DRAW_POLYGON;
@ -1195,10 +1188,20 @@ export function pasteShapeAsync(): ThunkAction<Promise<void>, {}, {}, AnyAction>
}); });
canvasInstance.cancel(); canvasInstance.cancel();
canvasInstance.draw({ if (initialState.objectType === ObjectType.TAG) {
enabled: true, const state = new cvat.classes.ObjectState({
initialState, objectType: initialState.objectType,
}); label: initialState.label,
frame: frameNumber,
});
dispatch(createAnnotationsAsync(jobInstance, frameNumber, [state]));
} else {
canvasInstance.draw({
enabled: true,
initialState,
});
}
} }
}; };
} }

@ -22,6 +22,7 @@ $info-icon-color: #0074D9;
$objects-bar-tabs-color: #BEBEBE; $objects-bar-tabs-color: #BEBEBE;
$objects-bar-icons-color: #242424; // #6E6E6E $objects-bar-icons-color: #242424; // #6E6E6E
$active-object-item-background-color: #D8ECFF; $active-object-item-background-color: #D8ECFF;
$default-object-colorpicker-item-background-color: #D8D8D8;
$slider-color: #1890FF; $slider-color: #1890FF;
$monospaced-fonts-stack: Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace; $monospaced-fonts-stack: Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace;

@ -719,21 +719,29 @@ function ObjectItemComponent(props: Props): JSX.Element {
return ( return (
<div style={{ display: 'flex' }}> <div style={{ display: 'flex' }}>
<Popover {
placement='left' objectType !== ObjectType.TAG ? (
trigger='click' <Popover
content={( placement='left'
<ColorChanger trigger='click'
onChange={changeColor} content={(
colors={colors} <ColorChanger
onChange={changeColor}
colors={colors}
/>
)}
>
<div
className='cvat-objects-sidebar-state-item-color'
style={{ background: ` ${color}` }}
/>
</Popover>
) : (
<div
className='cvat-objects-sidebar-state-item-color'
/> />
)} )
> }
<div
className='cvat-objects-sidebar-state-item-color'
style={{ background: ` ${color}` }}
/>
</Popover>
<div <div
onMouseEnter={activate} onMouseEnter={activate}

@ -121,6 +121,7 @@
.cvat-objects-sidebar-state-item-color { .cvat-objects-sidebar-state-item-color {
width: 7px; width: 7px;
opacity: 1; opacity: 1;
background-color: $default-object-colorpicker-item-background-color;
&:hover { &:hover {
opacity: 0.7; opacity: 0.7;

@ -226,21 +226,9 @@ class ObjectItemContainer extends React.PureComponent<Props> {
const { const {
objectState, objectState,
copyShape, copyShape,
jobInstance,
frameNumber,
createAnnotations,
} = this.props; } = this.props;
copyShape(objectState); copyShape(objectState);
if (objectState.objectType === ObjectType.TAG) {
const state = new cvat.classes.ObjectState({
objectType: objectState.objectType,
label: objectState.label,
frame: frameNumber,
});
createAnnotations(jobInstance, frameNumber, [state]);
}
}; };
private propagate = (): void => { private propagate = (): void => {

Loading…
Cancel
Save