From 79dbe2743024663f300c67e25665690912721168 Mon Sep 17 00:00:00 2001 From: Davide Brembilla Date: Tue, 1 Oct 2024 14:16:50 +0200 Subject: [PATCH 1/6] Adds annotation shortcut --- .../components/annotationCanvas/measureInteraction.vue | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue b/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue index c97dc4c42..182065eab 100644 --- a/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue +++ b/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue @@ -69,6 +69,12 @@ export default { this.setMeasureFeature(undefined); measureLayer.getSource().clear(); this.cantConvertMeasureFeature = true; + }, + + toggleCreateAnnotationFromMeasurement() { + if (this.isMeasuring) { + this.resetInteractionMode(); + } } }, watch: { @@ -110,6 +116,7 @@ export default { measureInteraction.on('drawstart', this.handleMeasureDrawStart); measureInteraction.on('drawend', this.handleMeasureDrawEnd); Keyboard.on('Shift+f', this.toggleMeasuring, 0, this.listenerSet); + Keyboard.on('Enter', this.toggleCreateAnnotationFromMeasurement, 0, this.listenerSet ) // Do not make this reactive. // See: https://github.com/biigle/annotations/issues/108 From 9c8125ffbe4189af5da1ee4ea22e49eab710a3b8 Mon Sep 17 00:00:00 2001 From: Davide Brembilla Date: Wed, 2 Oct 2024 09:59:59 +0200 Subject: [PATCH 2/6] Adds Enter interaction for annotations This commit introduces the capability of toggling the creation an annotation with Enter when doing measurements. Since this could cause Biigle to bug when using it without having closed the annotation, a new info message is instroduced when trying to do that. --- resources/assets/js/annotations/annotatorContainer.vue | 3 +++ .../js/annotations/components/annotationCanvas.vue | 3 +++ .../components/annotationCanvas/measureInteraction.vue | 10 +++------- resources/assets/js/videos/videoContainer.vue | 3 +++ resources/views/annotations/show.blade.php | 1 + resources/views/videos/show/content.blade.php | 1 + 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/resources/assets/js/annotations/annotatorContainer.vue b/resources/assets/js/annotations/annotatorContainer.vue index a19df869b..fb292ac12 100644 --- a/resources/assets/js/annotations/annotatorContainer.vue +++ b/resources/assets/js/annotations/annotatorContainer.vue @@ -562,6 +562,9 @@ export default { Messages.info('Please select a label first.'); this.$refs.sidebar.$emit('open', 'labels'); }, + handleRequiresClosedLine() { + Messages.info('Please close the line with a double click before assigning a label.'); + }, maybeShowTilingInProgressMessage: function() { if (this.image.tilingInProgress) { Messages.warning('This image is currently being processed. Please retry later.'); diff --git a/resources/assets/js/annotations/components/annotationCanvas.vue b/resources/assets/js/annotations/components/annotationCanvas.vue index 4484b7d98..a34bd441a 100644 --- a/resources/assets/js/annotations/components/annotationCanvas.vue +++ b/resources/assets/js/annotations/components/annotationCanvas.vue @@ -583,6 +583,9 @@ export default { this.resetInteractionMode(); } }, + requireClosedLine(){ + this.$emit('requires-closed-line') + }, fireImageSourceChanged() { const source = this.imageLayer?.getSource(); if (source) { diff --git a/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue b/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue index 182065eab..348745a7f 100644 --- a/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue +++ b/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue @@ -59,6 +59,8 @@ export default { convertMeasurement() { if (!this.hasSelectedLabel) { this.requireSelectedLabel(false); + } else if (this.cantConvertMeasureFeature) { + this.requireClosedLine(); } else { this.annotationSource.addFeature(this.measureFeature); this.handleNewFeature({feature: this.measureFeature}); @@ -69,12 +71,6 @@ export default { this.setMeasureFeature(undefined); measureLayer.getSource().clear(); this.cantConvertMeasureFeature = true; - }, - - toggleCreateAnnotationFromMeasurement() { - if (this.isMeasuring) { - this.resetInteractionMode(); - } } }, watch: { @@ -116,7 +112,7 @@ export default { measureInteraction.on('drawstart', this.handleMeasureDrawStart); measureInteraction.on('drawend', this.handleMeasureDrawEnd); Keyboard.on('Shift+f', this.toggleMeasuring, 0, this.listenerSet); - Keyboard.on('Enter', this.toggleCreateAnnotationFromMeasurement, 0, this.listenerSet ) + Keyboard.on('Enter', this.convertMeasurement, 0, this.listenerSet) // Do not make this reactive. // See: https://github.com/biigle/annotations/issues/108 diff --git a/resources/assets/js/videos/videoContainer.vue b/resources/assets/js/videos/videoContainer.vue index 65372e326..1382976f1 100644 --- a/resources/assets/js/videos/videoContainer.vue +++ b/resources/assets/js/videos/videoContainer.vue @@ -491,6 +491,9 @@ export default { Messages.info('Please select a label first.'); this.$refs.sidebar.$emit('open', 'labels'); }, + handleRequiresClosedLine() { + Messages.info('Please close the line with a double click before assigning a label.'); + }, startUpdateTimelineHeight(e) { e.preventDefault(); this.resizingTimeline = true; diff --git a/resources/views/annotations/show.blade.php b/resources/views/annotations/show.blade.php index cca57c664..174e4b665 100644 --- a/resources/views/annotations/show.blade.php +++ b/resources/views/annotations/show.blade.php @@ -95,6 +95,7 @@ v-on:delete="handleDeleteAnnotations" v-on:measuring="fetchImagesArea" v-on:requires-selected-label="handleRequiresSelectedLabel" + v-on:requires-closed-line="handleRequiresClosedLine" v-on:is-invalid-shape="handleInvalidShape" ref="canvas" inline-template> diff --git a/resources/views/videos/show/content.blade.php b/resources/views/videos/show/content.blade.php index 2a75a4c39..80a46a80f 100644 --- a/resources/views/videos/show/content.blade.php +++ b/resources/views/videos/show/content.blade.php @@ -58,6 +58,7 @@ v-on:delete="deleteAnnotationsOrKeyframes" v-on:moveend="updateMapUrlParams" v-on:requires-selected-label="handleRequiresSelectedLabel" + v-on:requires-closed-line="handleRequiresClosedLine" v-on:previous="showPreviousVideo" v-on:next="showNextVideo" v-on:attaching-active="handleAttachingLabelActive" From 64cf8be8b85738cd353c5dd9289f330d01609957 Mon Sep 17 00:00:00 2001 From: Davide Brembilla Date: Wed, 2 Oct 2024 10:21:37 +0200 Subject: [PATCH 3/6] Fixes bug when pressing Enter while not measuring When using other buttons and measuring, the function convertMeasurement gets triggered. This caused the error message to get triggered. --- .../annotationCanvas/measureInteraction.vue | 19 ++++++++++--------- .../show/annotationCanvas.blade.php | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue b/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue index 348745a7f..923940751 100644 --- a/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue +++ b/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue @@ -57,15 +57,16 @@ export default { } }, convertMeasurement() { - if (!this.hasSelectedLabel) { - this.requireSelectedLabel(false); - } else if (this.cantConvertMeasureFeature) { - this.requireClosedLine(); - } else { - this.annotationSource.addFeature(this.measureFeature); - this.handleNewFeature({feature: this.measureFeature}); - this.clearMeasureFeature(); - } + if (this.isMeasuring) { + if (!this.hasSelectedLabel) { + this.requireSelectedLabel(false); + } else if (this.cantConvertMeasureFeature) { + this.requireClosedLine(); + } else { + this.annotationSource.addFeature(this.measureFeature); + this.handleNewFeature({feature: this.measureFeature}); + this.clearMeasureFeature(); + }} }, clearMeasureFeature() { this.setMeasureFeature(undefined); diff --git a/resources/views/annotations/show/annotationCanvas.blade.php b/resources/views/annotations/show/annotationCanvas.blade.php index 107b3d570..bfa40cd2a 100644 --- a/resources/views/annotations/show/annotationCanvas.blade.php +++ b/resources/views/annotations/show/annotationCanvas.blade.php @@ -32,7 +32,7 @@ - + From 87befc67a6178405cfeb9ee6a1c2dc30f7c9899a Mon Sep 17 00:00:00 2001 From: Davide Brembilla Date: Wed, 2 Oct 2024 11:55:43 +0200 Subject: [PATCH 4/6] Adds annotation shortcut in list of annotation shortcuts --- .../tutorials/annotations/shortcuts.blade.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/resources/views/manual/tutorials/annotations/shortcuts.blade.php b/resources/views/manual/tutorials/annotations/shortcuts.blade.php index c9b4e9c71..9fbe58659 100644 --- a/resources/views/manual/tutorials/annotations/shortcuts.blade.php +++ b/resources/views/manual/tutorials/annotations/shortcuts.blade.php @@ -145,6 +145,25 @@ +

+ When the ruler tool is activated: +

+ + + + + + + + + + + + + + +
KeyFunction
EnterAnnotate selection with label
+

When Volare (cycle through annotations) is activated:

From 572e4a27a3bfd1c33d6988f90884b0a93e7a2685 Mon Sep 17 00:00:00 2001 From: Davide Brembilla Date: Mon, 7 Oct 2024 13:52:06 +0200 Subject: [PATCH 5/6] Removes error message when trying to add an annotation and the line is not closed As per review, removes the error message --- resources/assets/js/annotations/annotatorContainer.vue | 3 --- .../assets/js/annotations/components/annotationCanvas.vue | 3 --- .../components/annotationCanvas/measureInteraction.vue | 4 +--- resources/assets/js/videos/videoContainer.vue | 3 --- resources/views/annotations/show.blade.php | 1 - resources/views/videos/show/content.blade.php | 1 - 6 files changed, 1 insertion(+), 14 deletions(-) diff --git a/resources/assets/js/annotations/annotatorContainer.vue b/resources/assets/js/annotations/annotatorContainer.vue index fb292ac12..a19df869b 100644 --- a/resources/assets/js/annotations/annotatorContainer.vue +++ b/resources/assets/js/annotations/annotatorContainer.vue @@ -562,9 +562,6 @@ export default { Messages.info('Please select a label first.'); this.$refs.sidebar.$emit('open', 'labels'); }, - handleRequiresClosedLine() { - Messages.info('Please close the line with a double click before assigning a label.'); - }, maybeShowTilingInProgressMessage: function() { if (this.image.tilingInProgress) { Messages.warning('This image is currently being processed. Please retry later.'); diff --git a/resources/assets/js/annotations/components/annotationCanvas.vue b/resources/assets/js/annotations/components/annotationCanvas.vue index a34bd441a..4484b7d98 100644 --- a/resources/assets/js/annotations/components/annotationCanvas.vue +++ b/resources/assets/js/annotations/components/annotationCanvas.vue @@ -583,9 +583,6 @@ export default { this.resetInteractionMode(); } }, - requireClosedLine(){ - this.$emit('requires-closed-line') - }, fireImageSourceChanged() { const source = this.imageLayer?.getSource(); if (source) { diff --git a/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue b/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue index 923940751..c5aa6afb0 100644 --- a/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue +++ b/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue @@ -57,11 +57,9 @@ export default { } }, convertMeasurement() { - if (this.isMeasuring) { + if (this.isMeasuring && !this.cantConvertMeasureFeature) { if (!this.hasSelectedLabel) { this.requireSelectedLabel(false); - } else if (this.cantConvertMeasureFeature) { - this.requireClosedLine(); } else { this.annotationSource.addFeature(this.measureFeature); this.handleNewFeature({feature: this.measureFeature}); diff --git a/resources/assets/js/videos/videoContainer.vue b/resources/assets/js/videos/videoContainer.vue index 1382976f1..65372e326 100644 --- a/resources/assets/js/videos/videoContainer.vue +++ b/resources/assets/js/videos/videoContainer.vue @@ -491,9 +491,6 @@ export default { Messages.info('Please select a label first.'); this.$refs.sidebar.$emit('open', 'labels'); }, - handleRequiresClosedLine() { - Messages.info('Please close the line with a double click before assigning a label.'); - }, startUpdateTimelineHeight(e) { e.preventDefault(); this.resizingTimeline = true; diff --git a/resources/views/annotations/show.blade.php b/resources/views/annotations/show.blade.php index 174e4b665..cca57c664 100644 --- a/resources/views/annotations/show.blade.php +++ b/resources/views/annotations/show.blade.php @@ -95,7 +95,6 @@ v-on:delete="handleDeleteAnnotations" v-on:measuring="fetchImagesArea" v-on:requires-selected-label="handleRequiresSelectedLabel" - v-on:requires-closed-line="handleRequiresClosedLine" v-on:is-invalid-shape="handleInvalidShape" ref="canvas" inline-template> diff --git a/resources/views/videos/show/content.blade.php b/resources/views/videos/show/content.blade.php index 80a46a80f..2a75a4c39 100644 --- a/resources/views/videos/show/content.blade.php +++ b/resources/views/videos/show/content.blade.php @@ -58,7 +58,6 @@ v-on:delete="deleteAnnotationsOrKeyframes" v-on:moveend="updateMapUrlParams" v-on:requires-selected-label="handleRequiresSelectedLabel" - v-on:requires-closed-line="handleRequiresClosedLine" v-on:previous="showPreviousVideo" v-on:next="showNextVideo" v-on:attaching-active="handleAttachingLabelActive" From 27dc8ca23b0490fa35d0794fe79c782d0074eced Mon Sep 17 00:00:00 2001 From: Martin Zurowietz Date: Mon, 7 Oct 2024 14:48:46 +0200 Subject: [PATCH 6/6] Apply suggestions from code review --- .../components/annotationCanvas/measureInteraction.vue | 3 ++- .../views/manual/tutorials/annotations/shortcuts.blade.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue b/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue index c5aa6afb0..11cb74882 100644 --- a/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue +++ b/resources/assets/js/annotations/components/annotationCanvas/measureInteraction.vue @@ -64,7 +64,8 @@ export default { this.annotationSource.addFeature(this.measureFeature); this.handleNewFeature({feature: this.measureFeature}); this.clearMeasureFeature(); - }} + } + } }, clearMeasureFeature() { this.setMeasureFeature(undefined); diff --git a/resources/views/manual/tutorials/annotations/shortcuts.blade.php b/resources/views/manual/tutorials/annotations/shortcuts.blade.php index 9fbe58659..881868cfb 100644 --- a/resources/views/manual/tutorials/annotations/shortcuts.blade.php +++ b/resources/views/manual/tutorials/annotations/shortcuts.blade.php @@ -159,7 +159,7 @@ Enter - Annotate selection with label + Convert measurement to a line string annotation