-
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 all 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,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(); | ||
| } | ||
| }); | ||
|
|
||
|
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
|
||||||
| }); | ||||||
| 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, | ||||||
| }); | ||||||
|
|
||||||
| 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'; | ||
|
|
||
| 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,18 @@ 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) => { | ||
| if (this.isBrushOrWandMode) { | ||
| e.preventDefault(); | ||
| } | ||
| }); | ||
|
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' | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -185,7 +185,7 @@ export default { | |||||
| style: Styles.editing, | ||||||
| indicatorPointStyle: Styles.editing, | ||||||
| indicatorCrossStyle: Styles.cross, | ||||||
| simplifyTolerant: 0.1, | ||||||
| simplifyTolerant: 0.1 | ||||||
|
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. The codebase prefers trailing commas everywhere.
Suggested change
|
||||||
| }); | ||||||
| } else { | ||||||
| this.drawInteraction = new DrawInteraction({ | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,6 +158,25 @@ | |
| </tbody> | ||
| </table> | ||
|
|
||
| <p> | ||
| When any of the polygon brush/fill/eraser tools or the magic wand tool is active: | ||
| </p> | ||
|
|
||
| <table class="table"> | ||
| <thead> | ||
| <tr> | ||
| <th>Key</th> | ||
| <th>Function</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <tr> | ||
| <td><kbd>Right click</kbd> (held)</td> | ||
| <td>Drag the map<br></td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
|
Comment on lines
+161
to
+179
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'm not sure about this. Some kind of documentation is good but this is not really a keyboard shortcut. Maybe we should rather add a note about it to the manual articles on creating/editing annotations. |
||
| <p> | ||
| When the ruler tool is activated: | ||
| </p> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,6 +172,25 @@ | |
| </tbody> | ||
| </table> | ||
|
|
||
| <p> | ||
| When any of the polygon brush/fill/eraser tools or the magic wand tool is active: | ||
| </p> | ||
|
|
||
| <table class="table"> | ||
| <thead> | ||
| <tr> | ||
| <th>Key</th> | ||
| <th>Function</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <tr> | ||
| <td><kbd>Right click</kbd> (held)</td> | ||
| <td>Drag the map<br></td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
|
Comment on lines
+175
to
+193
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. See above. |
||
| <p> | ||
| When any of the rectangle, line string or polygon annotation tools are activated: | ||
| </p> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.