bec_widgets.utils.crosshair =========================== .. py:module:: bec_widgets.utils.crosshair Classes ------- .. autoapisummary:: bec_widgets.utils.crosshair.Crosshair bec_widgets.utils.crosshair.CrosshairScatterItem Module Contents --------------- .. py:class:: Crosshair(plot_item: pyqtgraph.PlotItem, precision: int | None = None, *, min_precision: int = 2, parent=None) Bases: :py:obj:`qtpy.QtCore.QObject` Crosshair for 1D and 2D plots. :param plot_item: The plot item to which the crosshair will be attached. :type plot_item: pyqtgraph.PlotItem :param precision: Fixed number of decimal places to display. If *None*, precision is chosen dynamically from the current view range. :type precision: int | None, optional :param min_precision: The lower bound (in decimal places) used when dynamic precision is enabled. Defaults to 2. :type min_precision: int, optional :param parent: Parent object for the QObject. Defaults to None. :type parent: QObject, optional .. py:method:: _connect_to_theme_change() Connect to the theme change signal. .. py:method:: _current_precision() -> int Get the current precision based on the view range or fixed precision. .. py:method:: _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 .. py:method:: _update_theme(theme: str | None = None) Update the theme. .. py:method:: apply_theme(theme: str) Apply the theme to the plot. .. py:method:: check_derivatives() Checks if the derivatives are enabled and updates the internal state accordingly. .. py:method:: check_log() Checks if the x or y axis is in log scale and updates the internal state accordingly. .. py:method:: cleanup() .. py:method:: clear_markers() Clears the markers from the plot. .. py:method:: 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. :param input_x: Input value :type input_x: float :param list_x: List of x values :type list_x: list :param list_y: List of y values :type list_y: list :returns: Closest x and y value :rtype: tuple .. py:method:: mouse_clicked(event) Handles the mouse clicked event, updating the crosshair position and emitting signals. :param event: The mouse clicked event .. py:method:: mouse_moved(event=None, manual_pos=None) Handles the mouse moved event, updating the crosshair position and emitting signals. :param event: The mouse moved event, which contains the scene position. :type event: object :param manual_pos: A tuple containing the (x, y) coordinates to manually set the crosshair position. :type manual_pos: tuple, optional .. py:method:: reset() Resets the crosshair to its initial state. .. py:method:: scale_emitted_coordinates(x, y) Scales the emitted coordinates if the axes are in log scale. :param x: The x-coordinate :type x: float :param y: The y-coordinate :type y: float :returns: The scaled x and y coordinates :rtype: tuple .. py:method:: 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. :param x: The x-coordinate of the mouse cursor :type x: float :param y: The y-coordinate of the mouse cursor :type y: float :returns: x and y values snapped to the nearest data :rtype: tuple .. py:method:: update_coord_label(pos: tuple) Updates the coordinate label based on the crosshair position and axis scales. :param pos: The (x, y) position of the crosshair. :type pos: tuple .. py:method:: update_highlighted_curve(curve_index: int) Update the highlighted curve in the case of multiple curves in a plot item. :param curve_index: The index of curve to highlight :type curve_index: int .. py:method:: update_markers() Update the markers for the crosshair, creating new ones if necessary. .. py:method:: update_markers_on_image_change() Update markers when the image changes, e.g. when the image shape or transformation changes. .. py:attribute:: coord_label .. py:attribute:: coordinatesChanged1D .. py:attribute:: coordinatesChanged2D .. py:attribute:: coordinatesClicked1D .. py:attribute:: coordinatesClicked2D .. py:attribute:: crosshairChanged .. py:attribute:: crosshairClicked .. py:attribute:: h_line .. py:attribute:: highlighted_curve_index :value: None .. py:attribute:: is_derivative :value: None .. py:attribute:: is_log_x :value: None .. py:attribute:: is_log_y :value: None .. py:attribute:: items :value: [] .. py:attribute:: marker_2d_col :value: None .. py:attribute:: marker_2d_row :value: None .. py:attribute:: marker_clicked_1d .. py:attribute:: marker_moved_1d .. py:property:: min_precision :type: int Lower bound on decimals when dynamic precision is used. .. py:attribute:: plot_item .. py:attribute:: positionChanged .. py:attribute:: positionClicked .. py:property:: precision :type: int | None Fixed number of decimals; ``None`` enables dynamic mode. .. py:attribute:: proxy .. py:attribute:: v_line .. py:class:: CrosshairScatterItem(*args, **kargs) Bases: :py:obj:`pyqtgraph.ScatterPlotItem` Displays 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() .. py:method:: setAlpha(*args, **kwargs) .. py:method:: setClipToView(state) .. py:method:: setDownsampling(ds=None, auto=None, method=None)