-
Notifications
You must be signed in to change notification settings - Fork 22
Right click drag for polygon brush tools #1470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 10 commits
980ecf0
acb1934
d1ac17b
ef3be7c
c4e9919
edff36d
feb1a98
fba81f2
ea5f71d
3d1d18f
789dc1e
326eb51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,25 @@ export default { | |
| }, | ||
| })); | ||
|
|
||
| map.addInteraction(new DragPan({ | ||
| condition: (mapBrowserEvent) => { | ||
| return mapBrowserEvent.originalEvent.button === 2 && noModifierKeys(mapBrowserEvent) && this.isBrushOrWandMode; | ||
| }, | ||
| })); | ||
|
|
||
| map.getViewport().addEventListener('contextmenu', (e) => { | ||
| switch (this.interactionMode) { | ||
| case 'default': | ||
| case 'translate': | ||
| case 'swap': | ||
| case 'force-swap': | ||
| case 'attach': | ||
| break; | ||
| default: | ||
| e.preventDefault(); | ||
|
yannik131 marked this conversation as resolved.
Outdated
|
||
| } | ||
| }); | ||
|
yannik131 marked this conversation as resolved.
|
||
|
|
||
|
Comment on lines
248
to
+303
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest to put this into the |
||
| control = new ZoomToNativeControl({ | ||
| // fontawesome expand icon | ||
| label: '\uf065' | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -64,6 +64,7 @@ export default { | |||||
| style: Styles.editing, | ||||||
| brushRadius: brushRadius, | ||||||
| resizeCondition: altKeyOnly, | ||||||
| condition: (event) => event.originalEvent.button !== 2 | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we could also use the existing Example:
Suggested change
|
||||||
| }); | ||||||
|
yannik131 marked this conversation as resolved.
|
||||||
| 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, | ||||||
|
yannik131 marked this conversation as resolved.
|
||||||
| }); | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
| } | ||
|
Comment on lines
+208
to
+210
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe implement this as a generic |
||
| this.downPoint[0] = Math.round(e.coordinate[0]); | ||
| this.downPoint[1] = Math.round(e.coordinate[1]); | ||
| this.drawSketch(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,7 +108,7 @@ | |
| icon="fa-check" | ||
| title="Disable the single-frame annotation option to create multi-frame annotations" | ||
| :disabled="true" | ||
| ></control-button> | ||
| ></control-button> | ||
| <control-button | ||
| v-else | ||
| icon="fa-check" | ||
|
|
@@ -122,7 +122,7 @@ | |
| icon="fa-project-diagram" | ||
| title="Disable the single-frame annotation option to track annotations" | ||
| :disabled="true" | ||
| ></control-button> | ||
| ></control-button> | ||
| <control-button | ||
| v-else | ||
| icon="fa-project-diagram" | ||
|
|
@@ -197,7 +197,7 @@ | |
| icon="fa-project-diagram" | ||
| title="Disable the single-frame annotation option to track annotations" | ||
| :disabled="true" | ||
| ></control-button> | ||
| ></control-button> | ||
| <control-button | ||
| v-else | ||
| icon="fa-project-diagram" | ||
|
|
@@ -429,8 +429,9 @@ import ZoomToExtentControl from '@biigle/ol/control/ZoomToExtent'; | |
| import ZoomToNativeControl from '@/annotations/ol/ZoomToNativeControl.js'; | ||
| import {click as clickCondition} from '@biigle/ol/events/condition'; | ||
| import {containsCoordinate} from '@biigle/ol/extent'; | ||
| import {defaults as defaultInteractions} from '@biigle/ol/interaction'; | ||
| import {defaults as defaultInteractions, DragPan} from '@biigle/ol/interaction'; | ||
| import {markRaw} from 'vue'; | ||
| import { noModifierKeys } from '@biigle/ol/events/condition.js'; | ||
|
yannik131 marked this conversation as resolved.
Outdated
|
||
|
|
||
| export default { | ||
| emits: [ | ||
|
|
@@ -611,6 +612,12 @@ export default { | |
| isDefaultInteractionMode() { | ||
| return this.interactionMode === 'default'; | ||
| }, | ||
| isBrushOrWandMode() { | ||
| return this.interactionMode === 'polygonBrush' | ||
| || this.interactionMode === 'polygonEraser' | ||
| || this.interactionMode === 'polygonFill' | ||
| || this.interactionMode === 'drawMagicWand'; | ||
| }, | ||
| styleObject() { | ||
| if (this.heightOffset !== 0) { | ||
| return `height: calc(65% + ${this.heightOffset}px);`; | ||
|
|
@@ -653,6 +660,26 @@ export default { | |
| }), | ||
| }); | ||
|
|
||
| map.addInteraction(new DragPan({ | ||
| condition: (mapBrowserEvent) => { | ||
| return mapBrowserEvent.originalEvent.button === 2 && noModifierKeys(mapBrowserEvent) && this.isBrushOrWandMode; | ||
| }, | ||
| })); | ||
|
yannik131 marked this conversation as resolved.
|
||
|
|
||
| map.getViewport().addEventListener('contextmenu', (e) => { | ||
| switch (this.interactionMode) { | ||
|
yannik131 marked this conversation as resolved.
Outdated
|
||
| case 'default': | ||
| case 'translate': | ||
| case 'swapLabel': | ||
| case 'forceSwapLabel': | ||
| case 'attachLabel': | ||
| case 'drawWholeFrame': | ||
| break; | ||
| default: | ||
| e.preventDefault(); | ||
|
yannik131 marked this conversation as resolved.
Outdated
|
||
| } | ||
| }); | ||
|
Comment on lines
615
to
+673
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again maybe move this to the mixin files? |
||
|
|
||
| control = new ZoomToNativeControl({ | ||
| // fontawesome expand icon | ||
| label: '\uf065' | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.