Skip to content

Commit

Permalink
Fixed a bug with ReferenceLinesTool
Browse files Browse the repository at this point in the history
In some medical imaging the "reference Lines Tool" does not get the intersection coordinates correctly with the "show Full Dimension" option turned on, causing the tool not to work properly.

I added a fallback action to it
  • Loading branch information
Steven-DD committed Jul 11, 2024
1 parent 979c403 commit 98915b9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/tools/src/tools/ReferenceLinesTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,24 +246,30 @@ class ReferenceLines extends AnnotationDisplayTool {
const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
const color = this.getStyle('color', styleSpecifier, annotation);
const shadow = this.getStyle('shadow', styleSpecifier, annotation);

let canvasCoordinates = [lineStartWorld, lineEndWorld].map((world) =>
const canvasCoords = [lineStartWorld, lineEndWorld].map((world) =>
targetViewport.worldToCanvas(world)
);
if (canvasCoords.length < 2) {
return renderStatus;
}


let canvasCoordinates: Types.Point2[] = [];
// If the full dimension is enabled, we need to calculate the intersection
if (this.configuration.showFullDimension) {
canvasCoordinates = this.handleFullDimension(
targetViewport,
lineStartWorld,
viewPlaneNormal,
viewUp,
lineEndWorld,
canvasCoordinates
canvasCoords
);
}

// If the full dimension is not enabled or the intersection is not found
if (canvasCoordinates.length < 2) {
return renderStatus;
canvasCoordinates = canvasCoords;
}

const dataId = `${annotationUID}-line`;
Expand Down

0 comments on commit 98915b9

Please sign in to comment.