Skip to content

Commit

Permalink
feat: 🎸 Make arrow only complete on text entry, and allow blank (#1270)
Browse files Browse the repository at this point in the history
Make arrow only complete on text entry, and allow blank labels via a
configuration option.
  • Loading branch information
JamesAPetts authored Jul 24, 2020
1 parent 0868812 commit 271a974
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions src/tools/annotation/ArrowAnnotateTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default class ArrowAnnotateTool extends BaseAnnotationTool {
hideHandlesIfMoving: false,
arrowFirst: true,
renderDashed: false,
allowEmptyLabel: false,
},
svgCursor: arrowAnnotateCursor,
};
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down

0 comments on commit 271a974

Please sign in to comment.