bec_widgets.utils.crosshair#
Classes#
Crosshair for 1D and 2D plots. |
|
Displays a set of x/y points. Instances of this class are created |
Module Contents#
- class Crosshair(plot_item: pyqtgraph.PlotItem, precision: int | None = None, *, min_precision: int = 2, parent=None)#
Bases:
qtpy.QtCore.QObjectCrosshair for 1D and 2D plots.
- Parameters:
plot_item (pyqtgraph.PlotItem) – The plot item to which the crosshair will be attached.
precision (int | None, optional) – Fixed number of decimal places to display. If None, precision is chosen dynamically from the current view range.
min_precision (int, optional) – The lower bound (in decimal places) used when dynamic precision is enabled. Defaults to 2.
parent (QObject, optional) – Parent object for the QObject. Defaults to None.
- _connect_to_theme_change()#
Connect to the theme change signal.
- _current_precision() int#
Get the current precision based on the view range or fixed precision.
- _get_transformed_position(x: float, y: float, transform: qtpy.QtGui.QTransform) tuple[qtpy.QtCore.QPointF, qtpy.QtCore.QPointF]#
Maps the given x and y coordinates to the transformed position using the provided transform. :param x: The x-coordinate to transform. :type x: float :param y: The y-coordinate to transform. :type y: float :param transform: The transformation to apply. :type transform: QTransform
- _update_theme(theme: str | None = None)#
Update the theme.
- apply_theme(theme: str)#
Apply the theme to the plot.
- check_derivatives()#
Checks if the derivatives are enabled and updates the internal state accordingly.
- check_log()#
Checks if the x or y axis is in log scale and updates the internal state accordingly.
- cleanup()#
- clear_markers()#
Clears the markers from the plot.
- closest_x_y_value(input_x: float, list_x: list, list_y: list) tuple#
Find the closest x and y value to the input value.
- Parameters:
input_x (float) – Input value
list_x (list) – List of x values
list_y (list) – List of y values
- Returns:
Closest x and y value
- Return type:
tuple
- mouse_clicked(event)#
Handles the mouse clicked event, updating the crosshair position and emitting signals.
- Parameters:
event – The mouse clicked event
- mouse_moved(event=None, manual_pos=None)#
Handles the mouse moved event, updating the crosshair position and emitting signals.
- Parameters:
event (object) – The mouse moved event, which contains the scene position.
manual_pos (tuple, optional) – A tuple containing the (x, y) coordinates to manually set the crosshair position.
- reset()#
Resets the crosshair to its initial state.
- scale_emitted_coordinates(x, y)#
Scales the emitted coordinates if the axes are in log scale.
- Parameters:
x (float) – The x-coordinate
y (float) – The y-coordinate
- Returns:
The scaled x and y coordinates
- Return type:
tuple
- snap_to_data(x: float, y: float) tuple[None, None] | tuple[collections.defaultdict[Any, list], collections.defaultdict[Any, list]]#
Finds the nearest data points to the given x and y coordinates.
- Parameters:
x (float) – The x-coordinate of the mouse cursor
y (float) – The y-coordinate of the mouse cursor
- Returns:
x and y values snapped to the nearest data
- Return type:
tuple
- update_coord_label(pos: tuple)#
Updates the coordinate label based on the crosshair position and axis scales.
- Parameters:
pos (tuple) – The (x, y) position of the crosshair.
- update_highlighted_curve(curve_index: int)#
Update the highlighted curve in the case of multiple curves in a plot item.
- Parameters:
curve_index (int) – The index of curve to highlight
- update_markers()#
Update the markers for the crosshair, creating new ones if necessary.
- update_markers_on_image_change()#
Update markers when the image changes, e.g. when the image shape or transformation changes.
- coord_label#
- coordinatesChanged1D#
- coordinatesChanged2D#
- coordinatesClicked1D#
- coordinatesClicked2D#
- crosshairChanged#
- crosshairClicked#
- h_line#
- highlighted_curve_index = None#
- is_derivative = None#
- is_log_x = None#
- is_log_y = None#
- items = []#
- marker_2d_col = None#
- marker_2d_row = None#
- marker_clicked_1d#
- marker_moved_1d#
- property min_precision: int#
Lower bound on decimals when dynamic precision is used.
- plot_item#
- positionChanged#
- positionClicked#
- property precision: int | None#
Fixed number of decimals;
Noneenables dynamic mode.
- proxy#
- v_line#
- class CrosshairScatterItem(*args, **kargs)#
Bases:
pyqtgraph.ScatterPlotItemDisplays a set of x/y points. Instances of this class are created automatically as part of PlotDataItem; these rarely need to be instantiated directly.
The size, shape, pen, and fill brush may be set for each point individually or for all points.
Signals:
sigPlotChanged(self)
Emitted when the data being plotted has changed
sigClicked(self, points, ev)
Emitted when points are clicked. Sends a list of all the points under the mouse pointer.
sigHovered(self, points, ev)
Emitted when the item is hovered. Sends a list of all the points under the mouse pointer.
Accepts the same arguments as setData()
- setAlpha(*args, **kwargs)#
- setClipToView(state)#
- setDownsampling(ds=None, auto=None, method=None)#