From 19573c81b70b73b1394a55707bcc221d2b0d1025 Mon Sep 17 00:00:00 2001 From: Boris Sekachev <40690378+bsekachev@users.noreply.github.com> Date: Fri, 8 Feb 2019 16:13:06 +0300 Subject: [PATCH] Keyboard shortcut for change shape type (Alt + 1,2,3,4) (#316) --- CHANGELOG.md | 2 ++ .../static/engine/js/shapeCollection.js | 27 +++++++++++++++++++ .../engine/static/engine/js/userConfig.js | 12 +++++++++ 3 files changed, 41 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2bf4c9b..d577d5ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cvat/apps/engine/static/engine/js/shapeCollection.js b/cvat/apps/engine/static/engine/js/shapeCollection.js index df0cc61a..14a2027b 100644 --- a/cvat/apps/engine/static/engine/js/shapeCollection.js +++ b/cvat/apps/engine/static/engine/js/shapeCollection.js @@ -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'); @@ -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'); diff --git a/cvat/apps/engine/static/engine/js/userConfig.js b/cvat/apps/engine/static/engine/js/userConfig.js index 3e0329bd..a7dec874 100644 --- a/cvat/apps/engine/static/engine/js/userConfig.js +++ b/cvat/apps/engine/static/engine/js/userConfig.js @@ -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) {