@@ -79,7 +79,8 @@ class ShapeCreatorModel extends Listener {
79
79
this . _shapeCollection . update ( ) ;
80
80
}
81
81
82
- switchCreateMode ( forceClose ) {
82
+ switchCreateMode ( forceClose , usingShortkey ) {
83
+ this . _usingShortkey = usingShortkey ;
83
84
// if parameter force (bool) setup to true, current result will not save
84
85
if ( ! forceClose ) {
85
86
this . _createMode = ! this . _createMode && window . cvat . mode == null ;
@@ -113,6 +114,10 @@ class ShapeCreatorModel extends Listener {
113
114
return this . _createMode ;
114
115
}
115
116
117
+ get usingShortkey ( ) {
118
+ return this . _usingShortkey ;
119
+ }
120
+
116
121
get defaultType ( ) {
117
122
return this . _defaultType ;
118
123
}
@@ -146,15 +151,15 @@ class ShapeCreatorController {
146
151
let shortkeys = window . cvat . config . shortkeys ;
147
152
148
153
let switchDrawHandler = Logger . shortkeyLogDecorator ( function ( ) {
149
- this . switchCreateMode ( false ) ;
154
+ this . switchCreateMode ( false , true ) ;
150
155
} . bind ( this ) ) ;
151
156
152
157
Mousetrap . bind ( shortkeys [ "switch_draw_mode" ] . value , switchDrawHandler . bind ( this ) , 'keydown' ) ;
153
158
}
154
159
}
155
160
156
- switchCreateMode ( force ) {
157
- this . _model . switchCreateMode ( force ) ;
161
+ switchCreateMode ( force , usingShortkey = false ) {
162
+ this . _model . switchCreateMode ( force , usingShortkey ) ;
158
163
}
159
164
160
165
setDefaultShapeType ( type ) {
@@ -261,6 +266,23 @@ class ShapeCreatorView {
261
266
this . _polyShapeSizeInput . on ( 'keydown' , function ( e ) {
262
267
e . stopPropagation ( ) ;
263
268
} ) ;
269
+
270
+ this . _playerFrame . on ( 'mousemove.shapeCreatorAIM' , ( e ) => {
271
+ if ( ! [ 'polygon' , 'polyline' , 'points' ] . includes ( this . _type ) ) {
272
+ this . _aimCoord = window . cvat . translate . point . clientToCanvas ( this . _frameContent . node , e . clientX , e . clientY ) ;
273
+ if ( this . _aim ) {
274
+ this . _aim . x . attr ( {
275
+ y1 : this . _aimCoord . y ,
276
+ y2 : this . _aimCoord . y ,
277
+ } ) ;
278
+
279
+ this . _aim . y . attr ( {
280
+ x1 : this . _aimCoord . x ,
281
+ x2 : this . _aimCoord . x ,
282
+ } ) ;
283
+ }
284
+ }
285
+ } ) ;
264
286
}
265
287
266
288
@@ -324,7 +346,6 @@ class ShapeCreatorView {
324
346
}
325
347
} ) ;
326
348
327
-
328
349
this . _frameContent . on ( 'mousemove.shapeCreator' , ( e ) => {
329
350
if ( e . shiftKey && [ 'polygon' , 'polyline' ] . includes ( this . _type ) ) {
330
351
if ( lastPoint . x === null || lastPoint . y === null ) {
@@ -388,7 +409,6 @@ class ShapeCreatorView {
388
409
} . bind ( this ) ) ;
389
410
}
390
411
391
-
392
412
_create ( ) {
393
413
let sizeUI = null ;
394
414
switch ( this . _type ) {
@@ -517,34 +537,21 @@ class ShapeCreatorView {
517
537
this . _mode = model . defaultMode ;
518
538
519
539
if ( ! [ 'polygon' , 'polyline' , 'points' ] . includes ( this . _type ) ) {
540
+ if ( ! model . usingShortkey ) {
541
+ this . _aimCoord = {
542
+ x : 0 ,
543
+ y : 0
544
+ } ;
545
+ }
520
546
this . _drawAim ( ) ;
521
- this . _playerFrame . on ( 'mousemove.shapeCreatorAIM' , ( e ) => {
522
- this . _aimCoord = window . cvat . translate . point . clientToCanvas ( this . _frameContent . node , e . clientX , e . clientY ) ;
523
- if ( this . _aim ) {
524
- this . _aim . x . attr ( {
525
- y1 : this . _aimCoord . y ,
526
- y2 : this . _aimCoord . y ,
527
- } ) ;
528
-
529
- this . _aim . y . attr ( {
530
- x1 : this . _aimCoord . x ,
531
- x2 : this . _aimCoord . x ,
532
- } ) ;
533
- }
534
- } ) ;
535
547
}
536
548
537
549
this . _createButton . text ( "Stop Creation" ) ;
538
550
document . oncontextmenu = ( ) => false ;
539
551
this . _create ( ) ;
540
552
}
541
553
else {
542
- this . _playerFrame . off ( 'mousemove.shapeCreatorAIM' ) ;
543
554
this . _removeAim ( ) ;
544
- this . _aimCoord = {
545
- x : 0 ,
546
- y : 0
547
- } ;
548
555
this . _cancel = true ;
549
556
this . _createButton . text ( "Create Shape" ) ;
550
557
document . oncontextmenu = null ;
0 commit comments