Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crosshair coordinates don't follow plot coordinates #1040

Open
ivan-usov opened this issue Oct 4, 2023 · 1 comment
Open

Crosshair coordinates don't follow plot coordinates #1040

ivan-usov opened this issue Oct 4, 2023 · 1 comment

Comments

@ivan-usov
Copy link

Describe the bug
The crosshair feature on a pydm plot (via enableCrosshair method) doesn't return x,y coordinates in units of corresponding plot axes, even though there only is a single y-axis present.

Expected behavior
Crosshair coordinates should follow plot coordinates in case there are no multiple y-axis.

Steps to Reproduce
Here is a simple example to demonstrate the issue:

from pydm import Display
from pydm.widgets import PyDMWaveformPlot
from qtpy.QtCore import Slot
from qtpy.QtWidgets import QApplication, QVBoxLayout


class TestScreen(Display):
    def __init__(self, parent=None, args=None, macros=None):
        super().__init__(parent=parent, args=args, macros=macros)
        self.app = QApplication.instance()
        main_layout = QVBoxLayout()
        self.setLayout(main_layout)
        plot = PyDMWaveformPlot()
        plot.addChannel()
        plot.enableCrosshair(is_enabled=True, starting_x_pos=0, starting_y_pos=0)
        plot.crosshair_position_updated.connect(print_coords)
        main_layout.addWidget(plot)


@Slot(float, float)
def print_coords(x, y):
    print(f"{x=:.2}", f"{y=:.2}")

starting the corresponding code via pydm, zooming in/out and moving a mouse prints unrelated x,y coordinates in terminal.

Possible Solution
It seems that the issue stems from the fact that all pydm plots are MultiAxisPlots, and that there are multiple ViewBoxes that are kept in a custom property to support this functionality:

self.stackedViews = weakref.WeakSet()

It's their ranges that reflect ranges of the corresponding axes, while the default vb seems to have an arbitrary range to which the crosshair gets hooked. It's clear, that in multi axis use case a single pair of x,y coordinates would be ambiguous. But it seems buggy when the same is happening also with a plot with only a single y-axis. Alternatively, this issue could be considered as a feature request for a more useful crosshair :)

My Platform
image

@jbellister-slac
Copy link
Collaborator

Thanks for the report and investigation into the issue! Agreed that it is definitely a MultiAxisPlot/ViewBox issue and at a minimum we will get the crosshair working again for plots with a single y axis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants