Skip to content

Commit cd299e4

Browse files
authored
fix(CrosshairsTool): support HPDI screens in CrosshairsTool (#1824)
fix #1822
1 parent e1b5bc6 commit cd299e4

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

packages/tools/src/tools/CrosshairsTool.ts

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ class CrosshairsTool extends AnnotationTool {
135135
enabled: false,
136136
panSize: 10,
137137
},
138+
handleRadius: 3,
139+
// Enable HDPI rendering for handles using devicePixelRatio
140+
enableHDPIHandles: false,
138141
// radius of the area around the intersection of the planes, in which
139142
// the reference lines will not be rendered. This is only used when
140143
// having 3 viewports in the toolGroup.
@@ -1270,6 +1273,15 @@ class CrosshairsTool extends AnnotationTool {
12701273
slabThicknessHandleWorldFour
12711274
);
12721275

1276+
let handleRadius =
1277+
this.configuration.handleRadius *
1278+
(this.configuration.enableHDPIHandles ? window.devicePixelRatio : 1);
1279+
let opacity = 1;
1280+
if (this.configuration.mobile?.enabled) {
1281+
handleRadius = this.configuration.mobile.handleRadius;
1282+
opacity = this.configuration.mobile.opacity;
1283+
}
1284+
12731285
if (
12741286
(lineActive || this.configuration.mobile?.enabled) &&
12751287
!rotHandlesActive &&
@@ -1286,12 +1298,8 @@ class CrosshairsTool extends AnnotationTool {
12861298
rotationHandles,
12871299
{
12881300
color,
1289-
handleRadius: this.configuration.mobile?.enabled
1290-
? this.configuration.mobile?.handleRadius
1291-
: 3,
1292-
opacity: this.configuration.mobile?.enabled
1293-
? this.configuration.mobile?.opacity
1294-
: 1,
1301+
handleRadius,
1302+
opacity,
12951303
type: 'circle',
12961304
}
12971305
);
@@ -1303,12 +1311,8 @@ class CrosshairsTool extends AnnotationTool {
13031311
slabThicknessHandles,
13041312
{
13051313
color,
1306-
handleRadius: this.configuration.mobile?.enabled
1307-
? this.configuration.mobile?.handleRadius
1308-
: 3,
1309-
opacity: this.configuration.mobile?.enabled
1310-
? this.configuration.mobile?.opacity
1311-
: 1,
1314+
handleRadius,
1315+
opacity,
13121316
type: 'rect',
13131317
}
13141318
);
@@ -1327,12 +1331,8 @@ class CrosshairsTool extends AnnotationTool {
13271331
rotationHandles,
13281332
{
13291333
color,
1330-
handleRadius: this.configuration.mobile?.enabled
1331-
? this.configuration.mobile?.handleRadius
1332-
: 3,
1333-
opacity: this.configuration.mobile?.enabled
1334-
? this.configuration.mobile?.opacity
1335-
: 1,
1334+
handleRadius,
1335+
opacity,
13361336
type: 'circle',
13371337
}
13381338
);
@@ -1351,17 +1351,18 @@ class CrosshairsTool extends AnnotationTool {
13511351
slabThicknessHandles,
13521352
{
13531353
color,
1354-
handleRadius: this.configuration.mobile?.enabled
1355-
? this.configuration.mobile?.handleRadius
1356-
: 3,
1357-
opacity: this.configuration.mobile?.enabled
1358-
? this.configuration.mobile?.opacity
1359-
: 1,
1354+
handleRadius,
1355+
opacity,
13601356
type: 'rect',
13611357
}
13621358
);
13631359
} else if (rotHandlesActive && viewportDraggableRotatable) {
13641360
const handleUID = `${lineIndex}`;
1361+
const handleRadius =
1362+
this.configuration.handleRadius *
1363+
(this.configuration.enableHDPIHandles
1364+
? window.devicePixelRatio
1365+
: 1);
13651366
// draw all rotation handles as active
13661367
drawHandlesSvg(
13671368
svgDrawingHelper,
@@ -1370,7 +1371,7 @@ class CrosshairsTool extends AnnotationTool {
13701371
rotationHandles,
13711372
{
13721373
color,
1373-
handleRadius: 2,
1374+
handleRadius,
13741375
fill: color,
13751376
type: 'circle',
13761377
}
@@ -1380,6 +1381,11 @@ class CrosshairsTool extends AnnotationTool {
13801381
selectedViewportId &&
13811382
viewportSlabThicknessControlsOn
13821383
) {
1384+
const handleRadius =
1385+
this.configuration.handleRadius *
1386+
(this.configuration.enableHDPIHandles
1387+
? window.devicePixelRatio
1388+
: 1);
13831389
// draw only the slab thickness handles for the active viewport as active
13841390
drawHandlesSvg(
13851391
svgDrawingHelper,
@@ -1388,7 +1394,7 @@ class CrosshairsTool extends AnnotationTool {
13881394
slabThicknessHandles,
13891395
{
13901396
color,
1391-
handleRadius: 2,
1397+
handleRadius,
13921398
fill: color,
13931399
type: 'rect',
13941400
}

0 commit comments

Comments
 (0)