From 59774df46e26b57ef4c1a9b65b24194db4e6c27e Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Fri, 4 Jun 2021 15:31:22 +0300 Subject: [PATCH 1/8] Fixed cuboid redraw --- cvat-ui/src/actions/annotation-actions.ts | 5 ++++- .../controls-side-bar/draw-shape-popover.tsx | 5 ++++- cvat-ui/src/reducers/interfaces.ts | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cvat-ui/src/actions/annotation-actions.ts b/cvat-ui/src/actions/annotation-actions.ts index 4e346c13e5a..8573ba5d2d0 100644 --- a/cvat-ui/src/actions/annotation-actions.ts +++ b/cvat-ui/src/actions/annotation-actions.ts @@ -7,7 +7,7 @@ import { ActionCreator, AnyAction, Dispatch, Store, } from 'redux'; import { ThunkAction } from 'utils/redux'; -import { RectDrawingMethod, Canvas } from 'cvat-canvas-wrapper'; +import { RectDrawingMethod, CuboidDrawingMethod, Canvas } from 'cvat-canvas-wrapper'; import getCore from 'cvat-core-wrapper'; import logger, { LogType } from 'cvat-logger'; import { getCVATStore } from 'cvat-store'; @@ -1144,6 +1144,7 @@ export function rememberObject(createParams: { activeShapeType?: ShapeType; activeNumOfPoints?: number; activeRectDrawingMethod?: RectDrawingMethod; + activeCuboidDrawingMethod?: CuboidDrawingMethod; }): AnyAction { return { type: AnnotationActionTypes.REMEMBER_CREATED_OBJECT, @@ -1490,6 +1491,7 @@ export function repeatDrawShapeAsync(): ThunkAction { activeShapeType, activeNumOfPoints, activeRectDrawingMethod, + activeCuboidDrawingMethod, }, } = getStore().getState().annotation; @@ -1544,6 +1546,7 @@ export function repeatDrawShapeAsync(): ThunkAction { canvasInstance.draw({ enabled: true, rectDrawingMethod: activeRectDrawingMethod, + cuboidDrawingMethod: activeCuboidDrawingMethod, numberOfPoints: activeNumOfPoints, shapeType: activeShapeType, crosshair: [ShapeType.RECTANGLE, ShapeType.CUBOID].includes(activeShapeType), diff --git a/cvat-ui/src/containers/annotation-page/standard-workspace/controls-side-bar/draw-shape-popover.tsx b/cvat-ui/src/containers/annotation-page/standard-workspace/controls-side-bar/draw-shape-popover.tsx index 18eaf9801eb..ca5ce632b54 100644 --- a/cvat-ui/src/containers/annotation-page/standard-workspace/controls-side-bar/draw-shape-popover.tsx +++ b/cvat-ui/src/containers/annotation-page/standard-workspace/controls-side-bar/draw-shape-popover.tsx @@ -23,6 +23,7 @@ interface DispatchToProps { objectType: ObjectType, points?: number, rectDrawingMethod?: RectDrawingMethod, + cuboidDrawingMethod?: CuboidDrawingMethod, ): void; } @@ -42,6 +43,7 @@ function mapDispatchToProps(dispatch: any): DispatchToProps { objectType: ObjectType, points?: number, rectDrawingMethod?: RectDrawingMethod, + cuboidDrawingMethod?: CuboidDrawingMethod, ): void { dispatch( rememberObject({ @@ -50,6 +52,7 @@ function mapDispatchToProps(dispatch: any): DispatchToProps { activeLabelID: labelID, activeNumOfPoints: points, activeRectDrawingMethod: rectDrawingMethod, + activeCuboidDrawingMethod: cuboidDrawingMethod, }), ); }, @@ -127,7 +130,7 @@ class DrawShapePopoverContainer extends React.PureComponent { crosshair: [ShapeType.RECTANGLE, ShapeType.CUBOID].includes(shapeType), }); - onDrawStart(shapeType, selectedLabelID, objectType, numberOfPoints, rectDrawingMethod); + onDrawStart(shapeType, selectedLabelID, objectType, numberOfPoints, rectDrawingMethod, cuboidDrawingMethod); } private onChangeRectDrawingMethod = (event: RadioChangeEvent): void => { diff --git a/cvat-ui/src/reducers/interfaces.ts b/cvat-ui/src/reducers/interfaces.ts index fc8a40340d9..13cf947545e 100644 --- a/cvat-ui/src/reducers/interfaces.ts +++ b/cvat-ui/src/reducers/interfaces.ts @@ -4,7 +4,7 @@ import { MutableRefObject } from 'react'; import { Canvas3d } from 'cvat-canvas3d/src/typescript/canvas3d'; -import { Canvas, RectDrawingMethod } from 'cvat-canvas-wrapper'; +import { Canvas, RectDrawingMethod, CuboidDrawingMethod } from 'cvat-canvas-wrapper'; import { IntelligentScissors } from 'utils/opencv-wrapper/intelligent-scissors'; import { KeyMap } from 'utils/mousetrap-react'; @@ -445,6 +445,7 @@ export interface AnnotationState { activeInteractor?: Model | OpenCVTool; activeShapeType: ShapeType; activeRectDrawingMethod?: RectDrawingMethod; + activeCuboidDrawingMethod?: CuboidDrawingMethod; activeNumOfPoints?: number; activeLabelID: number; activeObjectType: ObjectType; From e3ddaee321b05bfca2390883e1717db3f99e9e38 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Wed, 9 Jun 2021 14:54:08 +0300 Subject: [PATCH 2/8] Updated version & changelog --- CHANGELOG.md | 2 +- cvat-ui/package-lock.json | 2 +- cvat-ui/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17b69252b52..6ffcf372f14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Filter `is_active` for user list () - Ability to export/import tasks () - ### Changed - Updated manifest format, added meta with related images () @@ -36,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix CLI create an infinite loop if git repository responds with failure () - Bug with sidebar & fullscreen () - 504 Gateway Time-out on `data/meta` requests () +- TypeError: Cannot read property 'clientX' of undefined when draw cuboids with hotkeys () ### Security diff --git a/cvat-ui/package-lock.json b/cvat-ui/package-lock.json index 137df02c974..a85cd7bec9f 100644 --- a/cvat-ui/package-lock.json +++ b/cvat-ui/package-lock.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.20.3", + "version": "1.20.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/cvat-ui/package.json b/cvat-ui/package.json index 9a36d5d6e53..ed722f38386 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.20.3", + "version": "1.20.4", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { From 0e9279484d5157b514ecc4c53c8a21b939c65fb2 Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Wed, 9 Jun 2021 17:40:23 +0300 Subject: [PATCH 3/8] Fixed duplicated cuboid --- cvat-canvas/src/typescript/drawHandler.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cvat-canvas/src/typescript/drawHandler.ts b/cvat-canvas/src/typescript/drawHandler.ts index 735f68ad424..445a2f0740d 100644 --- a/cvat-canvas/src/typescript/drawHandler.ts +++ b/cvat-canvas/src/typescript/drawHandler.ts @@ -574,7 +574,7 @@ export class DrawHandlerImpl implements DrawHandler { .on('drawstop', (e: Event): void => { const bbox = (e.target as SVGRectElement).getBBox(); const [xtl, ytl, xbr, ybr] = this.getFinalRectCoordinates(bbox); - const { shapeType } = this.drawData; + const { shapeType, redraw: clientID } = this.drawData; this.release(); if (this.canceled) return; @@ -584,6 +584,7 @@ export class DrawHandlerImpl implements DrawHandler { { shapeType, points: cuboidFrom4Points([xtl, ybr, xbr, ybr, xbr, ytl, xbr + d.x, ytl - d.y]), + clientID, }, Date.now() - this.startTimestamp, ); From 8cead0a6354104fca2031e83c5aba5340ba2d0de Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Wed, 9 Jun 2021 17:43:04 +0300 Subject: [PATCH 4/8] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ffcf372f14..55861ee136b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bug with sidebar & fullscreen () - 504 Gateway Time-out on `data/meta` requests () - TypeError: Cannot read property 'clientX' of undefined when draw cuboids with hotkeys () +- Duplication of the cuboids when redraw them () ### Security From 945556c12bef891e87d8504db48ac39f418255bb Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Wed, 9 Jun 2021 18:03:01 +0300 Subject: [PATCH 5/8] Do not skip test for cuboid --- .../integration/actions_objects/case_54_redraw_feature.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/integration/actions_objects/case_54_redraw_feature.js b/tests/cypress/integration/actions_objects/case_54_redraw_feature.js index f64c3ca7e9c..5ded43663f5 100644 --- a/tests/cypress/integration/actions_objects/case_54_redraw_feature.js +++ b/tests/cypress/integration/actions_objects/case_54_redraw_feature.js @@ -129,7 +129,7 @@ context('Redraw feature.', () => { }); }); - it.skip('Draw and redraw a cuboid.', () => { + it('Draw and redraw a cuboid.', () => { // Need to fix issue https://github.com/openvinotoolkit/cvat/issues/2873 cy.createCuboid(createCuboidShape2Points); cy.get('.cvat-canvas-container').trigger('mousemove', 300, 400); From bb27d4e29888423c77b039f54f1535af210e0aaa Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Wed, 9 Jun 2021 18:03:56 +0300 Subject: [PATCH 6/8] Removed comment --- .../integration/actions_objects/case_54_redraw_feature.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/cypress/integration/actions_objects/case_54_redraw_feature.js b/tests/cypress/integration/actions_objects/case_54_redraw_feature.js index 5ded43663f5..f5a85f52725 100644 --- a/tests/cypress/integration/actions_objects/case_54_redraw_feature.js +++ b/tests/cypress/integration/actions_objects/case_54_redraw_feature.js @@ -130,7 +130,6 @@ context('Redraw feature.', () => { }); it('Draw and redraw a cuboid.', () => { - // Need to fix issue https://github.com/openvinotoolkit/cvat/issues/2873 cy.createCuboid(createCuboidShape2Points); cy.get('.cvat-canvas-container').trigger('mousemove', 300, 400); cy.get('#cvat_canvas_shape_5').should('have.class', 'cvat_canvas_shape_activated'); From caf5bf441f9f90d0da3520a6b7bda385c1b2bded Mon Sep 17 00:00:00 2001 From: Boris Sekachev Date: Tue, 15 Jun 2021 19:29:06 +0300 Subject: [PATCH 7/8] Fixed one more case --- cvat-canvas/src/typescript/drawHandler.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cvat-canvas/src/typescript/drawHandler.ts b/cvat-canvas/src/typescript/drawHandler.ts index 445a2f0740d..8bf38eee1d4 100644 --- a/cvat-canvas/src/typescript/drawHandler.ts +++ b/cvat-canvas/src/typescript/drawHandler.ts @@ -311,8 +311,9 @@ export class DrawHandlerImpl implements DrawHandler { // We check if it is activated with remember function if (this.drawInstance.remember('_paintHandler')) { if ( - this.drawData.shapeType !== 'rectangle' - && this.drawData.cuboidDrawingMethod !== CuboidDrawingMethod.CLASSIC + ['polygon', 'polyline', 'points'].includes(this.drawData.shapeType) + || (this.drawData.shapeType === 'cuboid' + && this.drawData.cuboidDrawingMethod === CuboidDrawingMethod.CORNER_POINTS) ) { // Check for unsaved drawn shapes this.drawInstance.draw('done'); From 7a2cb4d4bab9e1fdcf879b069d05d9e7a19b1141 Mon Sep 17 00:00:00 2001 From: dvkruchinin Date: Wed, 16 Jun 2021 10:56:35 +0300 Subject: [PATCH 8/8] Case 54. Add checking issue 3219 --- .../actions_objects/case_54_redraw_feature.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/cypress/integration/actions_objects/case_54_redraw_feature.js b/tests/cypress/integration/actions_objects/case_54_redraw_feature.js index f5a85f52725..9bb6e647807 100644 --- a/tests/cypress/integration/actions_objects/case_54_redraw_feature.js +++ b/tests/cypress/integration/actions_objects/case_54_redraw_feature.js @@ -137,6 +137,15 @@ context('Redraw feature.', () => { cy.get('.cvat-canvas-container') .click(createCuboidShape2Points.firstX, createCuboidShape2Points.firstY - 50) .click(createCuboidShape2Points.secondX, createCuboidShape2Points.secondY - 50); + // Check issue 3219. Press "N" during the redrawing of the cuboid + cy.get('.cvat-canvas-container').trigger('mousemove', 350, 300); + cy.get('#cvat_canvas_shape_5').should('have.class', 'cvat_canvas_shape_activated'); + cy.get('body').trigger('keydown', { keyCode: keyCodeN, shiftKey: true }); // Start redraw the cuboid + cy.get('.cvat-canvas-container') + .click(createCuboidShape2Points.firstX, createCuboidShape2Points.firstY - 100) + .trigger('mousemove', createCuboidShape2Points.secondX, createCuboidShape2Points.secondY - 100); + cy.get('body').trigger('keydown', { keyCode: keyCodeN }); + cy.get('.cvat_canvas_shape_drawing').should('not.exist'); cy.get('.cvat_canvas_shape').then(($shape) => { expect($shape.length).to.be.equal(5); });