Skip to content

Commit

Permalink
Keyboard shortcut for change shape type (Alt + 1,2,3,4) (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored and nmanovic committed Feb 8, 2019
1 parent cdc34f6 commit 19573c8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- OpenVINO auto annotation: it is possible to upload a custom model and annotate images automatically.
- Ability to rotate images/video in the client part (Ctrl+R, Shift+Ctrl+R shortcuts) (#305)
- The ReID application for automatic bounding box merging has been added (#299)
- Keyboard shortcuts to switch next/previous default shape type (box, polygon etc) [Alt + <, Alt + >] (#316)


### Changed
- Propagation setup has been moved from settings to bottom player panel
Expand Down
27 changes: 27 additions & 0 deletions cvat/apps/engine/static/engine/js/shapeCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,30 @@ class ShapeCollectionController {
}
}.bind(this));

let nextShapeType = Logger.shortkeyLogDecorator(function(e) {
if (window.cvat.mode === null) {
let next = $('#shapeTypeSelector option:selected').next();
if (!next.length) {
next = $('#shapeTypeSelector option').first();
}

next.prop('selected', true);
next.trigger('change');
}
}.bind(this));

let prevShapeType = Logger.shortkeyLogDecorator(function(e) {
if (window.cvat.mode === null) {
let prev = $('#shapeTypeSelector option:selected').prev();
if (!prev.length) {
prev = $('#shapeTypeSelector option').last();
}

prev.prop('selected', true);
prev.trigger('change');
}
}.bind(this));

let shortkeys = window.cvat.config.shortkeys;
Mousetrap.bind(shortkeys["switch_lock_property"].value, switchLockHandler.bind(this), 'keydown');
Mousetrap.bind(shortkeys["switch_all_lock_property"].value, switchAllLockHandler.bind(this), 'keydown');
Expand All @@ -977,6 +1001,9 @@ class ShapeCollectionController {
Mousetrap.bind(shortkeys["change_shape_label"].value, switchLabelHandler.bind(this), 'keydown');
Mousetrap.bind(shortkeys["delete_shape"].value, removeActiveHandler.bind(this), 'keydown');
Mousetrap.bind(shortkeys["change_shape_color"].value, changeShapeColorHandler.bind(this), 'keydown');
Mousetrap.bind(shortkeys['next_shape_type'].value, nextShapeType.bind(this), 'keydown');
Mousetrap.bind(shortkeys['prev_shape_type'].value, prevShapeType.bind(this), 'keydown');


if (window.cvat.job.z_order) {
Mousetrap.bind(shortkeys["inc_z"].value, incZHandler.bind(this), 'keydown');
Expand Down
12 changes: 12 additions & 0 deletions cvat/apps/engine/static/engine/js/userConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,18 @@ class Config {
view_value: 'Ctrl + Shift + R',
description: 'counter clockwise image rotation'
},

next_shape_type: {
value: ['alt+.'],
view_value: 'Alt + >',
description: 'switch next default shape type'
},

prev_shape_type: {
value: ['alt+,'],
view_value: 'Alt + <',
description: 'switch previous default shape type'
},
};

if (window.cvat && window.cvat.job && window.cvat.job.z_order) {
Expand Down

0 comments on commit 19573c8

Please sign in to comment.