Skip to content

Commit f647564

Browse files
bsekachevChris Lee-Messer
authored and
Chris Lee-Messer
committed
React UI: Player updates (cvat-ai#1058)
* Move, zoom integration * Moving, zooming, additional canvas handler * Activating & changing for objects * Improved colors * Saving annotations on the server * Fixed size * Refactoring * Added couple of notifications * Basic shape drawing * Cancel previous drawing * Refactoring * Minor draw improvings * Merge, group, split * Improved colors
1 parent 3e5cd67 commit f647564

File tree

115 files changed

+2730
-831
lines changed

Some content is hidden

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

115 files changed

+2730
-831
lines changed

cvat-canvas/README.md

+25-56
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ Canvas itself handles:
7474
activate(clientID: number, attributeID?: number): void;
7575
rotate(rotation: Rotation, remember?: boolean): void;
7676
focus(clientID: number, padding?: number): void;
77-
fitCanvas(): void;
7877
fit(): void;
7978
grid(stepX: number, stepY: number): void;
8079

@@ -84,6 +83,10 @@ Canvas itself handles:
8483
merge(mergeData: MergeData): void;
8584
select(objectState: any): void;
8685

86+
fitCanvas(): void;
87+
dragCanvas(enable: boolean): void;
88+
zoomCanvas(enable: boolean): void;
89+
8790
cancel(): void;
8891
}
8992
```
@@ -118,6 +121,10 @@ Standard JS events are used.
118121
- canvas.groupped => {states: ObjectState[]}
119122
- canvas.merged => {states: ObjectState[]}
120123
- canvas.canceled
124+
- canvas.dragstart
125+
- canvas.dragstop
126+
- canvas.zoomstart
127+
- canvas.zoomstop
121128
```
122129

123130
### WEB
@@ -138,64 +145,26 @@ Standard JS events are used.
138145
});
139146
```
140147

141-
### TypeScript
142-
- Add to ```tsconfig.json```:
143-
```json
144-
"compilerOptions": {
145-
"paths": {
146-
"cvat-canvas.node": ["3rdparty/cvat-canvas.node"]
147-
}
148-
}
149-
```
150-
151-
- ```3rdparty``` directory contains both ```cvat-canvas.node.js``` and ```cvat-canvas.node.d.ts```.
152-
- Add alias to ```webpack.config.js```:
153-
```js
154-
module.exports = {
155-
resolve: {
156-
alias: {
157-
'cvat-canvas.node': path.resolve(__dirname, '3rdparty/cvat-canvas.node.js'),
158-
}
159-
}
160-
}
161-
```
162-
163-
Than you can use it in TypeScript:
164-
```ts
165-
import * as CANVAS from 'cvat-canvas.node';
166-
// Create an instance of a canvas
167-
const canvas = new CANVAS.Canvas();
168-
169-
// Put canvas to a html container
170-
htmlContainer.appendChild(canvas.html());
171-
172-
// Next you can use its API methods. For example:
173-
canvas.rotate(CANVAS.Rotation.CLOCKWISE90);
174-
canvas.draw({
175-
enabled: true,
176-
shapeType: 'rectangle',
177-
crosshair: true,
178-
});
179-
```
180-
181148
## States
182149

183150
![](images/states.svg)
184151

185152
## API Reaction
186153

187-
| | IDLE | GROUPING | SPLITTING | DRAWING | MERGING | EDITING |
188-
|-------------|------|----------|-----------|---------|---------|---------|
189-
| html() | + | + | + | + | + | + |
190-
| setup() | + | + | + | + | + | - |
191-
| activate() | + | - | - | - | - | - |
192-
| rotate() | + | + | + | + | + | + |
193-
| focus() | + | + | + | + | + | + |
194-
| fit() | + | + | + | + | + | + |
195-
| fitCanvas() | + | + | + | + | + | + |
196-
| grid() | + | + | + | + | + | + |
197-
| draw() | + | - | - | - | - | - |
198-
| split() | + | - | + | - | - | - |
199-
| group | + | + | - | - | - | - |
200-
| merge() | + | - | - | - | + | - |
201-
| cancel() | - | + | + | + | + | + |
154+
| | IDLE | GROUPING | SPLITTING | DRAWING | MERGING | EDITING | DRAG | ZOOM |
155+
|--------------|------|----------|-----------|---------|---------|---------|------|------|
156+
| html() | + | + | + | + | + | + | + | + |
157+
| setup() | + | + | + | + | + | - | + | + |
158+
| activate() | + | - | - | - | - | - | - | - |
159+
| rotate() | + | + | + | + | + | + | + | + |
160+
| focus() | + | + | + | + | + | + | + | + |
161+
| fit() | + | + | + | + | + | + | + | + |
162+
| grid() | + | + | + | + | + | + | + | + |
163+
| draw() | + | - | - | - | - | - | - | - |
164+
| split() | + | - | + | - | - | - | - | - |
165+
| group() | + | + | - | - | - | - | - | - |
166+
| merge() | + | - | - | - | + | - | - | - |
167+
| fitCanvas() | + | + | + | + | + | + | + | + |
168+
| dragCanvas() | + | - | - | - | - | - | + | - |
169+
| zoomCanvas() | + | - | - | - | - | - | - | + |
170+
| cancel() | - | + | + | + | + | + | + | + |

cvat-canvas/src/scss/canvas.scss

+12-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
}
44

55
.cvat_canvas_shape {
6-
fill-opacity: 0.05;
6+
fill-opacity: 0.03;
77
stroke-opacity: 1;
88
}
99

@@ -68,6 +68,12 @@ polyline.cvat_canvas_shape_merging {
6868
stroke: black;
6969
}
7070

71+
.cvat_canvas_zoom_selection {
72+
stroke: #096dd9;
73+
fill-opacity: 0;
74+
stroke-dasharray: 4;
75+
}
76+
7177
.cvat_canvas_shape_occluded {
7278
stroke-dasharray: 5;
7379
}
@@ -78,9 +84,9 @@ polyline.cvat_canvas_shape_merging {
7884
}
7985

8086
#cvat_canvas_wrapper {
81-
width: 98%;
82-
height: 98%;
83-
margin: 10px;
87+
width: calc(100% - 10px);
88+
height: calc(100% - 10px);
89+
margin: 5px;
8490
border-radius: 5px;
8591
background-color: white;
8692
overflow: hidden;
@@ -103,6 +109,7 @@ polyline.cvat_canvas_shape_merging {
103109
}
104110

105111
#cvat_canvas_text_content {
112+
text-rendering: optimizeSpeed;
106113
position: absolute;
107114
z-index: 3;
108115
pointer-events: none;
@@ -135,6 +142,7 @@ polyline.cvat_canvas_shape_merging {
135142
}
136143

137144
#cvat_canvas_content {
145+
filter: contrast(120%) saturate(150%);
138146
position: absolute;
139147
z-index: 2;
140148
outline: 10px solid black;

cvat-canvas/src/typescript/canvas.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ interface Canvas {
4444
merge(mergeData: MergeData): void;
4545
select(objectState: any): void;
4646

47+
fitCanvas(): void;
48+
dragCanvas(enable: boolean): void;
49+
zoomCanvas(enable: boolean): void;
50+
4751
cancel(): void;
4852
}
4953

@@ -73,7 +77,15 @@ class CanvasImpl implements Canvas {
7377
);
7478
}
7579

76-
public activate(clientID: number, attributeID: number = null): void {
80+
public dragCanvas(enable: boolean): void {
81+
this.model.dragCanvas(enable);
82+
}
83+
84+
public zoomCanvas(enable: boolean): void {
85+
this.model.zoomCanvas(enable);
86+
}
87+
88+
public activate(clientID: number, attributeID: number | null = null): void {
7789
this.model.activate(clientID, attributeID);
7890
}
7991

0 commit comments

Comments
 (0)