Skip to content

Commit

Permalink
fix(crosshairs): configurable viewportIndicators (#1268)
Browse files Browse the repository at this point in the history
* fix pixel ratio for crosshairs

* feat: Add configuration for viewport indicators in CrosshairsTool

---------

Co-authored-by: Alireza <[email protected]>
  • Loading branch information
IbrahimCSAE and sedghi authored May 23, 2024
1 parent 5f76092 commit 268f1b1
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions packages/tools/src/tools/CrosshairsTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ class CrosshairsTool extends AnnotationTool {
// renders a colored circle on top right of the viewports whose color
// matches the color of the reference line
viewportIndicators: true,

viewportIndicatorsConfig: {
radius: 5,
x: null,
y: null,
},
// Auto pan is a configuration which will update pan
// other viewports in the toolGroup if the center of the crosshairs
// is outside of the viewport. This might be useful for the case
Expand Down Expand Up @@ -1449,20 +1455,24 @@ class CrosshairsTool extends AnnotationTool {
data.handles.slabThicknessPoints = newStpoints;

if (this.configuration.viewportIndicators) {
// render a circle to pin point the viewport color
// TODO: This should not be part of the tool, and definitely not part of the renderAnnotation loop
const { viewportIndicatorsConfig } = this.configuration;

const xOffset = viewportIndicatorsConfig?.xOffset || 0.95;
const yOffset = viewportIndicatorsConfig?.yOffset || 0.05;
const referenceColorCoordinates = [
clientWidth * 0.95,
clientHeight * 0.05,
] as Types.Point2;
const circleRadius = canvasDiagonalLength * 0.01;
clientWidth * xOffset,
clientHeight * yOffset,
];

const circleRadius =
viewportIndicatorsConfig?.circleRadius || canvasDiagonalLength * 0.01;

const circleUID = '0';
drawCircleSvg(
svgDrawingHelper,
annotationUID,
circleUID,
referenceColorCoordinates,
referenceColorCoordinates as Types.Point2,
circleRadius,
{ color, fill: color }
);
Expand Down

0 comments on commit 268f1b1

Please sign in to comment.