Skip to content

Commit fccd144

Browse files
committed
feat: Add configuration for viewport indicators in CrosshairsTool
1 parent e81f9be commit fccd144

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

packages/tools/src/tools/CrosshairsTool.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ class CrosshairsTool extends AnnotationTool {
143143
// renders a colored circle on top right of the viewports whose color
144144
// matches the color of the reference line
145145
viewportIndicators: true,
146+
147+
viewportIndicatorsConfig: {
148+
radius: 5,
149+
x: null,
150+
y: null,
151+
},
146152
// Auto pan is a configuration which will update pan
147153
// other viewports in the toolGroup if the center of the crosshairs
148154
// is outside of the viewport. This might be useful for the case
@@ -1449,21 +1455,24 @@ class CrosshairsTool extends AnnotationTool {
14491455
data.handles.slabThicknessPoints = newStpoints;
14501456

14511457
if (this.configuration.viewportIndicators) {
1452-
// render a circle to pin point the viewport color
1453-
// TODO: This should not be part of the tool, and definitely not part of the renderAnnotation loop
1458+
const { viewportIndicatorsConfig } = this.configuration;
1459+
1460+
const xOffset = viewportIndicatorsConfig?.xOffset || 0.95;
1461+
const yOffset = viewportIndicatorsConfig?.yOffset || 0.05;
14541462
const referenceColorCoordinates = [
1455-
clientWidth * 0.95,
1456-
clientHeight * 0.05,
1457-
] as Types.Point2;
1463+
clientWidth * xOffset,
1464+
clientHeight * yOffset,
1465+
];
1466+
14581467
const circleRadius =
1459-
(canvasDiagonalLength / window.devicePixelRatio || 1) * 0.01;
1468+
viewportIndicatorsConfig?.circleRadius || canvasDiagonalLength * 0.01;
14601469

14611470
const circleUID = '0';
14621471
drawCircleSvg(
14631472
svgDrawingHelper,
14641473
annotationUID,
14651474
circleUID,
1466-
referenceColorCoordinates,
1475+
referenceColorCoordinates as Types.Point2,
14671476
circleRadius,
14681477
{ color, fill: color }
14691478
);

0 commit comments

Comments
 (0)