radioviz.models.mouse_state
Mouse state management module for radioviz application.
This module provides functionality for handling mouse events in matplotlib figures. It defines a set of mouse button constants and a data class for representing mouse events with both pixel and data coordinates.
Added in version 1.0.0.
Classes
|
Enumeration of mouse button constants. |
|
Data class representing a mouse event. |
- class radioviz.models.mouse_state.MouseButton(*values)[source]
Bases:
IntEnumEnumeration of mouse button constants.
This enumeration maps standard mouse button values to named constants that can be used throughout the application for consistent mouse event handling.
- class radioviz.models.mouse_state.MouseEvent(x_pixel: int = 0, y_pixel: int = 0, x_data: float = 0.0, y_data: float = 0.0, button: MouseButton = MouseButton.Left, key: str = '', target_axis: str = '')[source]
Bases:
objectData class representing a mouse event.
This class encapsulates all relevant information about a mouse event, including pixel coordinates, data coordinates, button pressed, keyboard modifier keys, and the target axis.
- classmethod from_mpl_mouse_event(event: MouseEvent) MouseEvent[source]
Create a MouseEvent instance from a matplotlib MouseEvent.
Convert a matplotlib MouseEvent object into a radioviz MouseEvent data class, mapping the relevant attributes and handling button conversion properly.
- Parameters:
event (MPL_MouseEvent) – The matplotlib mouse event to convert
- Returns:
A new MouseEvent instance with converted values
- Return type:
- button: MouseButton = 1
MouseButton: The mouse button that was pressed.
- key: str = ''
str: Keyboard modifier key pressed during the event.
- target_axis: str = ''
str: Name of the target axis where the event occurred.
- x_data: float = 0.0
float: X coordinate in data units.
- x_pixel: int = 0
int: X coordinate in pixel units.
- y_data: float = 0.0
float: Y coordinate in data units.
- y_pixel: int = 0
int: Y coordinate in pixel units.