From 271a974f3da3cf58008d3501f45a0a8a13eb2e35 Mon Sep 17 00:00:00 2001 From: James Petts Date: Fri, 24 Jul 2020 12:06:41 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20Make=20arrow=20only=20co?= =?UTF-8?q?mplete=20on=20text=20entry,=20and=20allow=20blank=20(#1270)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make arrow only complete on text entry, and allow blank labels via a configuration option. --- src/tools/annotation/ArrowAnnotateTool.js | 43 ++++++++++------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/src/tools/annotation/ArrowAnnotateTool.js b/src/tools/annotation/ArrowAnnotateTool.js index 444545477..fc973b94a 100644 --- a/src/tools/annotation/ArrowAnnotateTool.js +++ b/src/tools/annotation/ArrowAnnotateTool.js @@ -44,6 +44,7 @@ export default class ArrowAnnotateTool extends BaseAnnotationTool { hideHandlesIfMoving: false, arrowFirst: true, renderDashed: false, + allowEmptyLabel: false, }, svgCursor: arrowAnnotateCursor, }; @@ -257,6 +258,8 @@ export default class ArrowAnnotateTool extends BaseAnnotationTool { const element = evt.detail.element; const measurementData = this.createNewMeasurement(evt); + const { allowEmptyLabel } = this.configuration; + // Associate this data with this imageId so we can render it and manipulate it addToolState(element, this.name, measurementData); external.cornerstone.updateImage(element); @@ -272,36 +275,28 @@ export default class ArrowAnnotateTool extends BaseAnnotationTool { if (success) { if (measurementData.text === undefined) { this.configuration.getTextCallback(text => { - if (text) { + if (text || allowEmptyLabel) { measurementData.text = text; + measurementData.active = false; + + const modifiedEventData = { + toolName: this.name, + toolType: this.name, // Deprecation notice: toolType will be replaced by toolName + element, + measurementData, + }; + + external.cornerstone.updateImage(element); + triggerEvent( + element, + EVENTS.MEASUREMENT_COMPLETED, + modifiedEventData + ); } else { removeToolState(element, this.name, measurementData); } - - measurementData.active = false; - external.cornerstone.updateImage(element); - - triggerEvent(element, EVENTS.MEASUREMENT_MODIFIED, { - toolName: this.name, - toolType: this.name, // Deprecation notice: toolType will be replaced by toolName - element, - measurementData, - }); }, evt.detail); } - - const modifiedEventData = { - toolName: this.name, - toolType: this.name, // Deprecation notice: toolType will be replaced by toolName - element, - measurementData, - }; - - triggerEvent( - element, - EVENTS.MEASUREMENT_COMPLETED, - modifiedEventData - ); } else { removeToolState(element, this.name, measurementData); }