Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(crosshairs): configurable viewportIndicators #1268

Merged
merged 3 commits into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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