Skip to content

Commit 2329226

Browse files
authored
Merge branch 'develop' into dk/cvat-ui
2 parents 28cc028 + 5dc52f9 commit 2329226

File tree

197 files changed

+1210
-453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+1210
-453
lines changed

.vscode/settings.json

+2
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@
3232
"-s",
3333
"./datumaro",
3434
],
35+
"licenser.license": "Custom",
36+
"licenser.customHeader": "Copyright (C) @YEAR@ Intel Corporation\n\nSPDX-License-Identifier: MIT"
3537
}

CONTRIBUTING.md

+15-10
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Next steps should work on clear Ubuntu 18.04.
1515
- Install necessary dependencies:
1616

1717
```sh
18-
$ sudo apt-get install -y curl redis-server python3-dev python3-pip python3-venv libldap2-dev libsasl2-dev
18+
$ sudo apt update && apt install -y nodejs npm curl redis-server python3-dev python3-pip python3-venv libldap2-dev libsasl2-dev
1919
```
2020

2121
- Install [Visual Studio Code](https://code.visualstudio.com/docs/setup/linux#_debian-and-ubuntu-based-distributions)
@@ -45,23 +45,28 @@ Password: ***
4545
Password (again): ***
4646
```
4747

48-
- Install UI packages and start UI debug server:
48+
- Install npm packages for UI and start UI debug server (run the following command from CVAT root directory):
4949
```sh
50-
cd cvat-core && npm install
51-
cd ../cvat-canvas && npm install
52-
cd ../cvat-ui && npm install
53-
npm start
50+
npm install && \
51+
cd cvat-core && npm install && \
52+
cd ../cvat-canvas && npm install && \
53+
cd ../cvat-ui && npm install && npm start
5454
```
5555

56-
- Run Visual Studio Code from the virtual environment
56+
- Open new terminal (Ctrl + Shift + T), run Visual Studio Code from the virtual environment
5757

5858
```sh
59-
code .
59+
cd .. && source .env/bin/activate && code
6060
```
6161

62-
- Inside Visual Studio Code install [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) and [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) extensions
62+
- Install followig vscode extensions:
63+
- [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome)
64+
- [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python)
65+
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
66+
- [vscode-remark-lint](https://marketplace.visualstudio.com/items?itemName=drewbourne.vscode-remark-lint)
67+
- [licenser](https://marketplace.visualstudio.com/items?itemName=ymotongpoo.licenser)
6368

64-
- Reload Visual Studio Code
69+
- Reload Visual Studio Code from virtual environment
6570

6671
- Select `server: debug` configuration and start it (F5) to run REST server and its workers
6772

cvat-canvas/README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@ Canvas itself handles:
3232
### API Methods
3333

3434
```ts
35+
enum RectDrawingMethod {
36+
CLASSIC = 'By 2 points',
37+
EXTREME_POINTS = 'By 4 points'
38+
}
39+
3540
interface DrawData {
3641
enabled: boolean;
3742
shapeType?: string;
38-
rectDrawingMethod?: string;
43+
rectDrawingMethod?: RectDrawingMethod;
3944
numberOfPoints?: number;
4045
initialState?: any;
4146
crosshair?: boolean;
@@ -142,10 +147,10 @@ Standard JS events are used.
142147
enabled: true,
143148
shapeType: 'rectangle',
144149
crosshair: true,
150+
rectDrawingMethod: window.Canvas.RectDrawingMethod.CLASSIC,
145151
});
146152
```
147153

148-
149154
## API Reaction
150155

151156
| | IDLE | GROUPING | SPLITTING | DRAWING | MERGING | EDITING | DRAG | ZOOM |

cvat-canvas/postcss.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright (C) 2019-2020 Intel Corporation
2+
//
3+
// SPDX-License-Identifier: MIT
4+
15
/* eslint-disable */
26
module.exports = {
37
parser: false,

cvat-canvas/src/scss/canvas.scss

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright (C) 2020 Intel Corporation
2+
//
3+
// SPDX-License-Identifier: MIT
4+
15
.cvat_canvas_hidden {
26
display: none;
37
}
@@ -175,4 +179,4 @@ polyline.cvat_canvas_shape_splitting {
175179
0% {stroke-dashoffset: 1; stroke: #09c;}
176180
50% {stroke-dashoffset: 100; stroke: #f44;}
177181
100% {stroke-dashoffset: 300; stroke: #09c;}
178-
}
182+
}

cvat-canvas/src/typescript/canvas.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/*
2-
* Copyright (C) 2019 Intel Corporation
3-
* SPDX-License-Identifier: MIT
4-
*/
1+
// Copyright (C) 2019-2020 Intel Corporation
2+
//
3+
// SPDX-License-Identifier: MIT
54

65
import {
76
DrawData,
@@ -10,6 +9,7 @@ import {
109
GroupData,
1110
CanvasModel,
1211
CanvasModelImpl,
12+
RectDrawingMethod,
1313
} from './canvasModel';
1414

1515
import {
@@ -140,4 +140,5 @@ class CanvasImpl implements Canvas {
140140
export {
141141
CanvasImpl as Canvas,
142142
CanvasVersion,
143+
RectDrawingMethod,
143144
};

cvat-canvas/src/typescript/canvasController.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/*
2-
* Copyright (C) 2019 Intel Corporation
3-
* SPDX-License-Identifier: MIT
4-
*/
1+
// Copyright (C) 2019-2020 Intel Corporation
2+
//
3+
// SPDX-License-Identifier: MIT
54

65
import {
76
CanvasModel,

cvat-canvas/src/typescript/canvasModel.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
/*
2-
* Copyright (C) 2019 Intel Corporation
3-
* SPDX-License-Identifier: MIT
4-
*/
1+
// Copyright (C) 2019-2020 Intel Corporation
2+
//
3+
// SPDX-License-Identifier: MIT
54

65
import { MasterImpl } from './master';
76

8-
97
export interface Size {
108
width: number;
119
height: number;
@@ -37,10 +35,15 @@ export interface ActiveElement {
3735
attributeID: number | null;
3836
}
3937

38+
export enum RectDrawingMethod {
39+
CLASSIC = 'By 2 points',
40+
EXTREME_POINTS = 'By 4 points'
41+
}
42+
4043
export interface DrawData {
4144
enabled: boolean;
4245
shapeType?: string;
43-
rectDrawingMethod?: string;
46+
rectDrawingMethod?: RectDrawingMethod;
4447
numberOfPoints?: number;
4548
initialState?: any;
4649
crosshair?: boolean;

cvat-canvas/src/typescript/canvasView.ts

+25-21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/*
2-
* Copyright (C) 2019 Intel Corporation
3-
* SPDX-License-Identifier: MIT
4-
*/
1+
// Copyright (C) 2019-2020 Intel Corporation
2+
//
3+
// SPDX-License-Identifier: MIT
54

65
import * as SVG from 'svg.js';
76

@@ -107,11 +106,10 @@ export class CanvasViewImpl implements CanvasView, Listener {
107106
this.geometry,
108107
);
109108
} else {
109+
this.mode = Mode.IDLE;
110110
this.controller.draw({
111111
enabled: false,
112112
});
113-
114-
this.mode = Mode.IDLE;
115113
}
116114
}
117115

@@ -552,7 +550,8 @@ export class CanvasViewImpl implements CanvasView, Listener {
552550
this.grid.setAttribute('version', '2');
553551
this.gridPath.setAttribute('d', 'M 1000 0 L 0 0 0 1000');
554552
this.gridPath.setAttribute('fill', 'none');
555-
this.gridPath.setAttribute('stroke-width', '1.5');
553+
this.gridPath.setAttribute('stroke-width', `${consts.BASE_GRID_WIDTH}`);
554+
this.gridPath.setAttribute('opacity', 'inherit');
556555
this.gridPattern.setAttribute('id', 'cvat_canvas_grid_pattern');
557556
this.gridPattern.setAttribute('width', '100');
558557
this.gridPattern.setAttribute('height', '100');
@@ -627,7 +626,9 @@ export class CanvasViewImpl implements CanvasView, Listener {
627626

628627
this.content.addEventListener('mousedown', (event): void => {
629628
if ([1, 2].includes(event.which)) {
630-
self.controller.enableDrag(event.clientX, event.clientY);
629+
if (![Mode.ZOOM_CANVAS, Mode.GROUP].includes(this.mode) || event.which === 2) {
630+
self.controller.enableDrag(event.clientX, event.clientY);
631+
}
631632
event.preventDefault();
632633
}
633634
});
@@ -761,13 +762,16 @@ export class CanvasViewImpl implements CanvasView, Listener {
761762
}
762763
} else if (reason === UpdateReasons.DRAW) {
763764
const data: DrawData = this.controller.drawData;
764-
if (data.enabled) {
765+
if (data.enabled && this.mode === Mode.IDLE) {
765766
this.canvas.style.cursor = 'crosshair';
766767
this.mode = Mode.DRAW;
768+
this.drawHandler.draw(data, this.geometry);
767769
} else {
768770
this.canvas.style.cursor = '';
771+
if (this.mode !== Mode.IDLE) {
772+
this.drawHandler.draw(data, this.geometry);
773+
}
769774
}
770-
this.drawHandler.draw(data, this.geometry);
771775
} else if (reason === UpdateReasons.MERGE) {
772776
const data: MergeData = this.controller.mergeData;
773777
if (data.enabled) {
@@ -1061,24 +1065,18 @@ export class CanvasViewImpl implements CanvasView, Listener {
10611065
const [state] = this.controller.objects
10621066
.filter((_state: any): boolean => _state.clientID === clientID);
10631067

1064-
if (!state) {
1065-
return;
1066-
}
1067-
1068-
if (state.shapeType === 'points') {
1068+
if (state && state.shapeType === 'points') {
10691069
this.svgShapes[clientID].remember('_selectHandler').nested
10701070
.style('pointer-events', state.lock ? 'none' : '');
10711071
}
10721072

1073-
if (state.hidden || state.lock) {
1073+
if (!state || state.hidden || state.outside) {
10741074
return;
10751075
}
10761076

10771077
this.activeElement = { ...activeElement };
10781078
const shape = this.svgShapes[clientID];
1079-
shape.addClass('cvat_canvas_shape_activated');
10801079
let text = this.svgTexts[clientID];
1081-
// Draw text if it's hidden by default
10821080
if (!text) {
10831081
text = this.addText(state);
10841082
this.svgTexts[state.clientID] = text;
@@ -1088,7 +1086,11 @@ export class CanvasViewImpl implements CanvasView, Listener {
10881086
);
10891087
}
10901088

1091-
const self = this;
1089+
if (state.lock) {
1090+
return;
1091+
}
1092+
1093+
shape.addClass('cvat_canvas_shape_activated');
10921094
if (state.shapeType === 'points') {
10931095
this.content.append(this.svgShapes[clientID]
10941096
.remember('_selectHandler').nested.node);
@@ -1104,7 +1106,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
11041106
}).on('dragend', (e: CustomEvent): void => {
11051107
if (text) {
11061108
text.removeClass('cvat_canvas_hidden');
1107-
self.updateTextPosition(
1109+
this.updateTextPosition(
11081110
text,
11091111
shape,
11101112
);
@@ -1123,6 +1125,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
11231125
+ `${shape.attr('y') + shape.attr('height')}`,
11241126
).map((x: number): number => x - offset);
11251127

1128+
this.drawnStates[state.clientID].points = points;
11261129
this.onEditDone(state, points);
11271130
}
11281131
});
@@ -1154,7 +1157,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
11541157

11551158
if (text) {
11561159
text.removeClass('cvat_canvas_hidden');
1157-
self.updateTextPosition(
1160+
this.updateTextPosition(
11581161
text,
11591162
shape,
11601163
);
@@ -1171,6 +1174,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
11711174
+ `${shape.attr('y') + shape.attr('height')}`,
11721175
).map((x: number): number => x - offset);
11731176

1177+
this.drawnStates[state.clientID].points = points;
11741178
this.onEditDone(state, points);
11751179
}
11761180
});

cvat-canvas/src/typescript/consts.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
/*
2-
* Copyright (C) 2019 Intel Corporation
3-
* SPDX-License-Identifier: MIT
4-
*/
1+
// Copyright (C) 2019-2020 Intel Corporation
2+
//
3+
// SPDX-License-Identifier: MIT
54

65
const BASE_STROKE_WIDTH = 1.75;
7-
const BASE_GRID_WIDTH = 1;
6+
const BASE_GRID_WIDTH = 2;
87
const BASE_POINT_SIZE = 5;
98
const TEXT_MARGIN = 10;
109
const AREA_THRESHOLD = 9;

0 commit comments

Comments
 (0)