diff --git a/resources/assets/js/annotations/components/annotationCanvas.vue b/resources/assets/js/annotations/components/annotationCanvas.vue index 884d9ae1b..fccac1fc5 100644 --- a/resources/assets/js/annotations/components/annotationCanvas.vue +++ b/resources/assets/js/annotations/components/annotationCanvas.vue @@ -44,8 +44,8 @@ import ZoomLevel from './annotationCanvas/zoomLevel.vue'; import ZoomToExtentControl from '@biigle/ol/control/ZoomToExtent'; import ZoomToNativeControl from '../ol/ZoomToNativeControl.js'; import { isInvalidShape } from '../utils.js'; -import {click as clickCondition} from '@biigle/ol/events/condition'; -import {defaults as defaultInteractions} from '@biigle/ol/interaction' +import {click as clickCondition, noModifierKeys} from '@biigle/ol/events/condition'; +import {defaults as defaultInteractions, DragPan} from '@biigle/ol/interaction'; import {getCenter} from '@biigle/ol/extent'; import {markRaw} from 'vue'; import {shiftKeyOnly as shiftKeyOnlyCondition} from '@biigle/ol/events/condition'; @@ -155,7 +155,7 @@ export default { }, draftAnnotationUsesLabelColor: { type: Boolean, - default: true, + default: true, }, }, data() { @@ -245,6 +245,12 @@ export default { return 'Next image'; } }, + isBrushOrWandMode() { + return this.interactionMode === 'polygonBrush' + || this.interactionMode === 'polygonEraser' + || this.interactionMode === 'polygonFill' + || this.interactionMode === 'magicWand'; + }, }, methods: { createMap() { @@ -283,6 +289,18 @@ export default { }, })); + map.addInteraction(new DragPan({ + condition: (mapBrowserEvent) => { + return mapBrowserEvent.originalEvent.button === 2 && noModifierKeys(mapBrowserEvent) && this.isBrushOrWandMode; + }, + })); + + map.getViewport().addEventListener('contextmenu', (e) => { + if (this.isBrushOrWandMode) { + e.preventDefault(); + } + }); + control = new ZoomToNativeControl({ // fontawesome expand icon label: '\uf065' diff --git a/resources/assets/js/annotations/components/annotationCanvas/polygonBrushInteraction.vue b/resources/assets/js/annotations/components/annotationCanvas/polygonBrushInteraction.vue index fe6f2bdde..372b2dd9d 100644 --- a/resources/assets/js/annotations/components/annotationCanvas/polygonBrushInteraction.vue +++ b/resources/assets/js/annotations/components/annotationCanvas/polygonBrushInteraction.vue @@ -64,6 +64,7 @@ export default { style: Styles.editing, brushRadius: brushRadius, resizeCondition: altKeyOnly, + condition: (event) => event.originalEvent.button !== 2 }); currentInteraction.on('drawend', this.handleNewFeature); this.map.addInteraction(currentInteraction); @@ -78,7 +79,7 @@ export default { brushRadius: brushRadius, allowRemove: false, addCondition: never, - subtractCondition: noModifierKeys, + subtractCondition: (event) => noModifierKeys(event) && event.originalEvent.button !== 2, resizeCondition: altKeyOnly, }); currentInteraction.on('modifystart', this.handleFeatureModifyStart); @@ -93,7 +94,7 @@ export default { features: this.selectInteraction.getFeatures(), style: Styles.editing, brushRadius: brushRadius, - addCondition: noModifierKeys, + addCondition: (event) => noModifierKeys(event) && event.originalEvent.button !== 2, subtractCondition: never, resizeCondition: altKeyOnly, }); diff --git a/resources/assets/js/annotations/ol/MagicWandInteraction.js b/resources/assets/js/annotations/ol/MagicWandInteraction.js index 90d7b675c..14c81166b 100644 --- a/resources/assets/js/annotations/ol/MagicWandInteraction.js +++ b/resources/assets/js/annotations/ol/MagicWandInteraction.js @@ -189,7 +189,7 @@ class MagicWandInteraction extends PointerInteraction { // Add feature to annotation source to prevent flickering feature this.source.addFeature(this.sketchFeature); } - + this.sketchSource.removeFeature(this.sketchFeature); this.sketchFeature = null; @@ -205,6 +205,9 @@ class MagicWandInteraction extends PointerInteraction { * Start drawing of a sketch. */ handleDownEvent(e) { + if (e.originalEvent.button === 2) { + return false; + } this.downPoint[0] = Math.round(e.coordinate[0]); this.downPoint[1] = Math.round(e.coordinate[1]); this.drawSketch(); diff --git a/resources/assets/js/videos/components/videoScreen.vue b/resources/assets/js/videos/components/videoScreen.vue index a59c7f437..e403db131 100644 --- a/resources/assets/js/videos/components/videoScreen.vue +++ b/resources/assets/js/videos/components/videoScreen.vue @@ -108,7 +108,7 @@ icon="fa-check" title="Disable the single-frame annotation option to create multi-frame annotations" :disabled="true" - > + > + > + > { + return mapBrowserEvent.originalEvent.button === 2 && noModifierKeys(mapBrowserEvent) && this.isBrushOrWandMode; + }, + })); + + map.getViewport().addEventListener('contextmenu', (e) => { + if (this.isBrushOrWandMode) { + e.preventDefault(); + } + }); + control = new ZoomToNativeControl({ // fontawesome expand icon label: '\uf065' diff --git a/resources/assets/js/videos/components/videoScreen/drawInteractions.vue b/resources/assets/js/videos/components/videoScreen/drawInteractions.vue index 773b9eb01..835aaf0b1 100644 --- a/resources/assets/js/videos/components/videoScreen/drawInteractions.vue +++ b/resources/assets/js/videos/components/videoScreen/drawInteractions.vue @@ -185,7 +185,7 @@ export default { style: Styles.editing, indicatorPointStyle: Styles.editing, indicatorCrossStyle: Styles.cross, - simplifyTolerant: 0.1, + simplifyTolerant: 0.1 }); } else { this.drawInteraction = new DrawInteraction({ diff --git a/resources/assets/js/videos/components/videoScreen/polygonBrushInteractions.vue b/resources/assets/js/videos/components/videoScreen/polygonBrushInteractions.vue index 03bcd81f5..cd21095f1 100644 --- a/resources/assets/js/videos/components/videoScreen/polygonBrushInteractions.vue +++ b/resources/assets/js/videos/components/videoScreen/polygonBrushInteractions.vue @@ -66,6 +66,7 @@ export default { style: Styles.editing, brushRadius: this.polygonBrushRadius, resizeCondition: altKeyOnlyCondition, + condition: (event) => event.originalEvent.button !== 2 }); this.polygonBrushInteraction.on('drawend', this.extendPendingAnnotation); this.pendingAnnotation.shape = 'Polygon'; @@ -85,7 +86,7 @@ export default { brushRadius: this.polygonBrushRadius, allowRemove: false, addCondition: neverCondition, - subtractCondition: noModifierKeysCondition, + subtractCondition: (event) => noModifierKeysCondition(event) && event.originalEvent.button !== 2, resizeCondition: altKeyOnlyCondition, }); this.polygonEraserInteraction.on('modifystart', this.handleModifyStart); @@ -106,7 +107,7 @@ export default { style: Styles.editing, brushRadius: this.polygonBrushRadius, allowRemove: false, - addCondition: noModifierKeysCondition, + addCondition: (event) => noModifierKeysCondition(event) && event.originalEvent.button !== 2, subtractCondition: neverCondition, resizeCondition: altKeyOnlyCondition, }); diff --git a/resources/views/partials/image-annotation-shortcuts.blade.php b/resources/views/partials/image-annotation-shortcuts.blade.php index ed1a53f08..9768e46ba 100644 --- a/resources/views/partials/image-annotation-shortcuts.blade.php +++ b/resources/views/partials/image-annotation-shortcuts.blade.php @@ -158,6 +158,25 @@ +

+ When any of the polygon brush/fill/eraser tools or the magic wand tool is active: +

+ + + + + + + + + + + + + + +
KeyFunction
Right click (held)Drag the map
+

When the ruler tool is activated:

diff --git a/resources/views/partials/video-annotation-shortcuts.blade.php b/resources/views/partials/video-annotation-shortcuts.blade.php index d705f439b..9fb8b9745 100644 --- a/resources/views/partials/video-annotation-shortcuts.blade.php +++ b/resources/views/partials/video-annotation-shortcuts.blade.php @@ -172,6 +172,25 @@ +

+ When any of the polygon brush/fill/eraser tools or the magic wand tool is active: +

+ + + + + + + + + + + + + + +
KeyFunction
Right click (held)Drag the map
+

When any of the rectangle, line string or polygon annotation tools are activated: