radioviz.geometry.angle_selector

Interactive angle selector for matplotlib plots.

This module provides a selector that captures three points to define an angle. The selector supports interactive editing of the three vertices and can snap movements to horizontal/vertical directions when the user holds the control key.

Classes

AngleGeometry(p1, p2, p3)

Represents the geometric properties of an angle.

AngleSelector(ax, /, *[, color, linewidth, ...])

Interactive selector for defining an angle with three points.

class radioviz.geometry.angle_selector.AngleGeometry(p1: tuple[float, float], p2: tuple[float, float], p3: tuple[float, float])[source]

Bases: object

Represents the geometric properties of an angle.

The angle is defined by three points where p2 is the vertex.

as_points() tuple[tuple[float, float], tuple[float, float], tuple[float, float]][source]

Return the points in a tuple.

Returns:

Tuple of (p1, p2, p3)

Return type:

tuple[tuple[float, float], tuple[float, float], tuple[float, float]]

p1: tuple[float, float]

First point of the angle as (x, y) coordinates.

p2: tuple[float, float]

Vertex point of the angle as (x, y) coordinates.

p3: tuple[float, float]

Third point of the angle as (x, y) coordinates.

class radioviz.geometry.angle_selector.AngleSelector(ax: Axes, /, *, color: str = 'orange', linewidth: float = 2.0, handle_size: float = 8.0, picker_tol: float = 10.0, snap_deg: float = 90.0)[source]

Bases: QObject

Interactive selector for defining an angle with three points.

The selector workflow is: 1) Click three points to define the angle. 2) Edit points by dragging handles. 3) Press Enter to accept or Escape to cancel.

Initialize the AngleSelector.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib axes object where the selector will be displayed

  • color (str) – Color for the selector lines and handles

  • linewidth (float) – Line width for selector segments

  • handle_size (float) – Size of the handle markers in points

  • picker_tol (float) – Tolerance for handle picking in pixels

  • snap_deg (float) – Angle snapping step in degrees

_on_accept() None[source]

Accept the current selection and emit the corresponding signal.

_on_key_press(event: object) None[source]

Handle key press events.

Parameters:

event (matplotlib.backend_bases.KeyEvent) – Key event data

_on_key_release(event: object) None[source]

Handle key release events.

Parameters:

event (matplotlib.backend_bases.KeyEvent) – Key event data

_on_motion(event: object) None[source]

Handle mouse motion events.

Parameters:

event (matplotlib.backend_bases.MouseEvent) – Mouse motion event data

_on_pick(event: object) None[source]

Handle pick events (clicking on handles).

Parameters:

event (matplotlib.backend_bases.PickEvent) – Pick event data

_on_press(event: object) None[source]

Handle mouse press events.

Parameters:

event (matplotlib.backend_bases.MouseEvent) – Mouse event data

_on_release(event: object) None[source]

Handle mouse release events.

Parameters:

event (matplotlib.backend_bases.MouseEvent) – Mouse release event data

_promote_first_segment() None[source]

Keep the first segment visible after the second click.

_restore_focus() None[source]

Restore focus to the previously focused widget.

clear() None[source]

Clear the selector and reset to idle state.

disconnect_signals() None[source]

Disconnect all event signals and restore focus.

property geometry: AngleGeometry | None

Get the current angle geometry.

Returns:

Current angle geometry or None if not set

Return type:

Optional[AngleGeometry]

selector_accepted

Signal emitted when the selector is accepted.

selector_canceled

Signal emitted when the selector is canceled.

selector_created

Signal emitted when a new selector is created.