Skip to content

Commit

Permalink
feat(probe): isPointNearTool for probe tool, and use line width from …
Browse files Browse the repository at this point in the history
…config (#1721)
  • Loading branch information
IbrahimCSAE authored Dec 20, 2024
1 parent dcac6b4 commit 90c1a98
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common/reviews/api/tools.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4464,7 +4464,7 @@ export class ProbeTool extends AnnotationTool {
// (undocumented)
isHandleOutsideImage: boolean;
// (undocumented)
isPointNearTool(): boolean;
isPointNearTool(element: HTMLDivElement, annotation: ProbeAnnotation, canvasCoords: Types_2.Point2, proximity: number): boolean;
// (undocumented)
static probeDefaults: {
supportedInteractionTypes: string[];
Expand Down
25 changes: 19 additions & 6 deletions packages/tools/src/tools/annotation/ProbeTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,20 @@ class ProbeTool extends AnnotationTool {
);
}

// Not necessary for this tool but needs to be defined since it's an abstract
// method from the parent class.
isPointNearTool(): boolean {
return false;
isPointNearTool(
element: HTMLDivElement,
annotation: ProbeAnnotation,
canvasCoords: Types.Point2,
proximity: number
): boolean {
const enabledElement = getEnabledElement(element);
const { viewport } = enabledElement;

const { data } = annotation;
const point = data.handles.points[0];
const annotationCanvasCoordinate = viewport.worldToCanvas(point);

return vec2.distance(canvasCoords, annotationCanvasCoordinate) < proximity;
}

toolSelectedCallback() {}
Expand Down Expand Up @@ -471,7 +481,10 @@ class ProbeTool extends AnnotationTool {

styleSpecifier.annotationUID = annotationUID;

const { color } = this.getAnnotationStyle({ annotation, styleSpecifier });
const { color, lineWidth } = this.getAnnotationStyle({
annotation,
styleSpecifier,
});

if (!data.cachedStats) {
data.cachedStats = {};
Expand Down Expand Up @@ -545,7 +558,7 @@ class ProbeTool extends AnnotationTool {
annotationUID,
handleGroupUID,
[canvasCoordinates],
{ color }
{ color, lineWidth }
);

renderStatus = true;
Expand Down

0 comments on commit 90c1a98

Please sign in to comment.