From 8602da72f16fcc4e337664479f819b2a3e397f97 Mon Sep 17 00:00:00 2001 From: Dmitry Kalinin Date: Fri, 6 Mar 2020 17:27:36 +0300 Subject: [PATCH] Fixed copying/pasting actions --- cvat-ui/src/actions/annotation-actions.ts | 61 ++++++++++--------- cvat-ui/src/base.scss | 1 + .../objects-side-bar/object-item.tsx | 36 ++++++----- .../objects-side-bar/styles.scss | 1 + .../objects-side-bar/object-item.tsx | 12 ---- 5 files changed, 56 insertions(+), 55 deletions(-) diff --git a/cvat-ui/src/actions/annotation-actions.ts b/cvat-ui/src/actions/annotation-actions.ts index be23e67f..f0208701 100644 --- a/cvat-ui/src/actions/annotation-actions.ts +++ b/cvat-ui/src/actions/annotation-actions.ts @@ -542,31 +542,10 @@ export function editShape(enabled: boolean): 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 { type: AnnotationActionTypes.COPY_SHAPE, payload: { - activeControl, + objectState, }, }; } @@ -1175,11 +1154,25 @@ export function searchAnnotationsAsync( export function pasteShapeAsync(): ThunkAction, {}, {}, AnyAction> { return async (dispatch: ActionCreator): Promise => { 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) { - let activeControl = ActiveControl.DRAW_RECTANGLE; - if (initialState.shapeType === ShapeType.POINTS) { + let activeControl = ActiveControl.CURSOR; + if (initialState.shapeType === ShapeType.RECTANGLE) { + activeControl = ActiveControl.DRAW_RECTANGLE; + } else if (initialState.shapeType === ShapeType.POINTS) { activeControl = ActiveControl.DRAW_POINTS; } else if (initialState.shapeType === ShapeType.POLYGON) { activeControl = ActiveControl.DRAW_POLYGON; @@ -1195,10 +1188,20 @@ export function pasteShapeAsync(): ThunkAction, {}, {}, AnyAction> }); canvasInstance.cancel(); - canvasInstance.draw({ - enabled: true, - initialState, - }); + if (initialState.objectType === ObjectType.TAG) { + const state = new cvat.classes.ObjectState({ + objectType: initialState.objectType, + label: initialState.label, + frame: frameNumber, + + }); + dispatch(createAnnotationsAsync(jobInstance, frameNumber, [state])); + } else { + canvasInstance.draw({ + enabled: true, + initialState, + }); + } } }; } diff --git a/cvat-ui/src/base.scss b/cvat-ui/src/base.scss index 6f545305..99649cf4 100644 --- a/cvat-ui/src/base.scss +++ b/cvat-ui/src/base.scss @@ -22,6 +22,7 @@ $info-icon-color: #0074D9; $objects-bar-tabs-color: #BEBEBE; $objects-bar-icons-color: #242424; // #6E6E6E $active-object-item-background-color: #D8ECFF; +$default-object-colorpicker-item-background-color: #D8D8D8; $slider-color: #1890FF; $monospaced-fonts-stack: Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace; diff --git a/cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/object-item.tsx b/cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/object-item.tsx index ce0f69db..fbe21a8d 100644 --- a/cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/object-item.tsx +++ b/cvat-ui/src/components/annotation-page/standard-workspace/objects-side-bar/object-item.tsx @@ -719,21 +719,29 @@ function ObjectItemComponent(props: Props): JSX.Element { return (
- + )} + > +
+ + ) : ( +
- )} - > -
- + ) + }
{ const { objectState, copyShape, - jobInstance, - frameNumber, - createAnnotations, } = this.props; 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 => {