Skip to content

Commit

Permalink
feat(Annotation textbox): Add textBoxVisibility (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlopes90 committed Sep 12, 2023
1 parent 96dc177 commit c1981a1
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ level to check.
colorLocked: 'rgb(255, 255, 0)',
lineWidth: '1',
lineDash: '',
textBoxVisibility: true,
textBoxFontFamily: 'Helvetica Neue, Helvetica, Arial, sans-serif',
textBoxFontSize: '14px',
textBoxColor: 'rgb(255, 255, 0)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ToolStyle {
lineWidth: '1',
lineDash: '',
shadow: true,
textBoxVisibility: true,
textBoxFontFamily: 'Helvetica Neue, Helvetica, Arial, sans-serif',
textBoxFontSize: '14px',
textBoxColor: 'rgb(255, 255, 0)',
Expand Down
17 changes: 16 additions & 1 deletion packages/tools/src/tools/annotation/AngleTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,21 @@ class AngleTool extends AnnotationTool {
continue;
}

const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
if (!options.visibility) {
data.handles.textBox = {
hasMoved: false,
worldPosition: <Types.Point3>[0, 0, 0],
worldBoundingBox: {
topLeft: <Types.Point3>[0, 0, 0],
topRight: <Types.Point3>[0, 0, 0],
bottomLeft: <Types.Point3>[0, 0, 0],
bottomRight: <Types.Point3>[0, 0, 0],
},
};
continue;
}

const textLines = this.configuration.getTextLines(data, targetId);

if (!data.handles.textBox.hasMoved) {
Expand All @@ -768,7 +783,7 @@ class AngleTool extends AnnotationTool {
textBoxPosition,
canvasCoordinates,
{},
this.getLinkedTextBoxStyle(styleSpecifier, annotation)
options
);

const { x: left, y: top, width, height } = boundingBox;
Expand Down
17 changes: 16 additions & 1 deletion packages/tools/src/tools/annotation/ArrowAnnotateTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,21 @@ class ArrowAnnotateTool extends AnnotationTool {
continue;
}

const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
if (!options.visibility) {
data.handles.textBox = {
hasMoved: false,
worldPosition: <Types.Point3>[0, 0, 0],
worldBoundingBox: {
topLeft: <Types.Point3>[0, 0, 0],
topRight: <Types.Point3>[0, 0, 0],
bottomLeft: <Types.Point3>[0, 0, 0],
bottomRight: <Types.Point3>[0, 0, 0],
},
};
continue;
}

// Need to update to sync w/ annotation while unlinked/not moved
if (!data.handles.textBox.hasMoved) {
// linked to the point that doesn't have the arrowhead by default
Expand All @@ -798,7 +813,7 @@ class ArrowAnnotateTool extends AnnotationTool {
textBoxPosition,
canvasCoordinates,
{},
this.getLinkedTextBoxStyle(styleSpecifier, annotation)
options
);

const { x: left, y: top, width, height } = boundingBox;
Expand Down
19 changes: 17 additions & 2 deletions packages/tools/src/tools/annotation/BidirectionalTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1162,11 +1162,26 @@ class BidirectionalTool extends AnnotationTool {

renderStatus = true;

const textLines = this.configuration.getTextLines(data, targetId);
const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
if (!options.visibility) {
data.handles.textBox = {
hasMoved: false,
worldPosition: <Types.Point3>[0, 0, 0],
worldBoundingBox: {
topLeft: <Types.Point3>[0, 0, 0],
topRight: <Types.Point3>[0, 0, 0],
bottomLeft: <Types.Point3>[0, 0, 0],
bottomRight: <Types.Point3>[0, 0, 0],
},
};
continue;
}

const textLines = this.configuration.getTextLines(data, targetId);
if (!textLines || textLines.length === 0) {
continue;
}

let canvasTextBoxCoords;

if (!data.handles.textBox.hasMoved) {
Expand All @@ -1189,7 +1204,7 @@ class BidirectionalTool extends AnnotationTool {
textBoxPosition,
canvasCoordinates,
{},
this.getLinkedTextBoxStyle(styleSpecifier, annotation)
options
);

const { x: left, y: top, width, height } = boundingBox;
Expand Down
17 changes: 16 additions & 1 deletion packages/tools/src/tools/annotation/CircleROITool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,21 @@ class CircleROITool extends AnnotationTool {

renderStatus = true;

const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
if (!options.visibility) {
data.handles.textBox = {
hasMoved: false,
worldPosition: <Types.Point3>[0, 0, 0],
worldBoundingBox: {
topLeft: <Types.Point3>[0, 0, 0],
topRight: <Types.Point3>[0, 0, 0],
bottomLeft: <Types.Point3>[0, 0, 0],
bottomRight: <Types.Point3>[0, 0, 0],
},
};
continue;
}

const textLines = this.configuration.getTextLines(data, targetId);
if (!textLines || textLines.length === 0) {
continue;
Expand Down Expand Up @@ -854,7 +869,7 @@ class CircleROITool extends AnnotationTool {
textBoxPosition,
canvasCoordinates,
{},
this.getLinkedTextBoxStyle(styleSpecifier, annotation)
options
);

const { x: left, y: top, width, height } = boundingBox;
Expand Down
17 changes: 16 additions & 1 deletion packages/tools/src/tools/annotation/CobbAngleTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,21 @@ class CobbAngleTool extends AnnotationTool {
continue;
}

const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
if (!options.visibility) {
data.handles.textBox = {
hasMoved: false,
worldPosition: <Types.Point3>[0, 0, 0],
worldBoundingBox: {
topLeft: <Types.Point3>[0, 0, 0],
topRight: <Types.Point3>[0, 0, 0],
bottomLeft: <Types.Point3>[0, 0, 0],
bottomRight: <Types.Point3>[0, 0, 0],
},
};
continue;
}

const textLines = this.configuration.getTextLines(data, targetId);

if (!data.handles.textBox.hasMoved) {
Expand All @@ -792,7 +807,7 @@ class CobbAngleTool extends AnnotationTool {
textBoxPosition,
canvasCoordinates,
{},
this.getLinkedTextBoxStyle(styleSpecifier, annotation)
options
);

const { x: left, y: top, width, height } = boundingBox;
Expand Down
17 changes: 16 additions & 1 deletion packages/tools/src/tools/annotation/EllipticalROITool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,21 @@ class EllipticalROITool extends AnnotationTool {

renderStatus = true;

const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
if (!options.visibility) {
data.handles.textBox = {
hasMoved: false,
worldPosition: <Types.Point3>[0, 0, 0],
worldBoundingBox: {
topLeft: <Types.Point3>[0, 0, 0],
topRight: <Types.Point3>[0, 0, 0],
bottomLeft: <Types.Point3>[0, 0, 0],
bottomRight: <Types.Point3>[0, 0, 0],
},
};
continue;
}

const textLines = this.configuration.getTextLines(data, targetId);
if (!textLines || textLines.length === 0) {
continue;
Expand Down Expand Up @@ -978,7 +993,7 @@ class EllipticalROITool extends AnnotationTool {
textBoxPosition,
canvasCoordinates,
{},
this.getLinkedTextBoxStyle(styleSpecifier, annotation)
options
);

const { x: left, y: top, width, height } = boundingBox;
Expand Down
17 changes: 16 additions & 1 deletion packages/tools/src/tools/annotation/LengthTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,21 @@ class LengthTool extends AnnotationTool {
return renderStatus;
}

const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
if (!options.visibility) {
data.handles.textBox = {
hasMoved: false,
worldPosition: <Types.Point3>[0, 0, 0],
worldBoundingBox: {
topLeft: <Types.Point3>[0, 0, 0],
topRight: <Types.Point3>[0, 0, 0],
bottomLeft: <Types.Point3>[0, 0, 0],
bottomRight: <Types.Point3>[0, 0, 0],
},
};
continue;
}

const textLines = this.configuration.getTextLines(data, targetId);

// Need to update to sync with annotation while unlinked/not moved
Expand All @@ -755,7 +770,7 @@ class LengthTool extends AnnotationTool {
textBoxPosition,
canvasCoordinates,
{},
this.getLinkedTextBoxStyle(styleSpecifier, annotation)
options
);

const { x: left, y: top, width, height } = boundingBox;
Expand Down
19 changes: 12 additions & 7 deletions packages/tools/src/tools/annotation/PlanarFreehandROITool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,17 @@ class PlanarFreehandROITool extends AnnotationTool {
const data = annotation.data;
const targetId = this.getTargetId(viewport);

const styleSpecifier: AnnotationStyle.StyleSpecifier = {
toolGroupId: this.toolGroupId,
toolName: this.getToolName(),
viewportId: enabledElement.viewport.id,
};

const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
if (!options.visibility) {
return;
}

const textLines = this.configuration.getTextLines(data, targetId);
if (!textLines || textLines.length === 0) {
return;
Expand All @@ -901,12 +912,6 @@ class PlanarFreehandROITool extends AnnotationTool {
data.handles.textBox.worldPosition
);

const styleSpecifier: AnnotationStyle.StyleSpecifier = {
toolGroupId: this.toolGroupId,
toolName: this.getToolName(),
viewportId: enabledElement.viewport.id,
};

const textBoxUID = '1';
const boundingBox = drawLinkedTextBox(
svgDrawingHelper,
Expand All @@ -916,7 +921,7 @@ class PlanarFreehandROITool extends AnnotationTool {
textBoxPosition,
canvasCoordinates,
{},
this.getLinkedTextBoxStyle(styleSpecifier, annotation)
options
);

const { x: left, y: top, width, height } = boundingBox;
Expand Down
7 changes: 6 additions & 1 deletion packages/tools/src/tools/annotation/ProbeTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,11 @@ class ProbeTool extends AnnotationTool {

renderStatus = true;

const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
if (!options.visibility) {
continue;
}

const textLines = this.configuration.getTextLines(data, targetId);
if (textLines) {
const textCanvasCoordinates = [
Expand All @@ -541,7 +546,7 @@ class ProbeTool extends AnnotationTool {
textUID,
textLines,
[textCanvasCoordinates[0], textCanvasCoordinates[1]],
this.getLinkedTextBoxStyle(styleSpecifier, annotation)
options
);
}
}
Expand Down
17 changes: 16 additions & 1 deletion packages/tools/src/tools/annotation/RectangleROITool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,21 @@ class RectangleROITool extends AnnotationTool {

renderStatus = true;

const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
if (!options.visibility) {
data.handles.textBox = {
hasMoved: false,
worldPosition: <Types.Point3>[0, 0, 0],
worldBoundingBox: {
topLeft: <Types.Point3>[0, 0, 0],
topRight: <Types.Point3>[0, 0, 0],
bottomLeft: <Types.Point3>[0, 0, 0],
bottomRight: <Types.Point3>[0, 0, 0],
},
};
continue;
}

const textLines = this.configuration.getTextLines(data, targetId);
if (!textLines || textLines.length === 0) {
continue;
Expand All @@ -816,7 +831,7 @@ class RectangleROITool extends AnnotationTool {
textBoxPosition,
canvasCoordinates,
{},
this.getLinkedTextBoxStyle(styleSpecifier, annotation)
options
);

const { x: left, y: top, width, height } = boundingBox;
Expand Down
5 changes: 5 additions & 0 deletions packages/tools/src/tools/base/AnnotationTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ abstract class AnnotationTool extends AnnotationDisplayTool {
// for the textBox.

return {
visibility: this.getStyle(
'textBoxVisibility',
specifications,
annotation
),
fontFamily: this.getStyle(
'textBoxFontFamily',
specifications,
Expand Down

0 comments on commit c1981a1

Please sign in to comment.