From d5b41e12c56d0268d7234e5142c6a0703e03bd2f Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 21 Feb 2021 11:45:24 -0500 Subject: [PATCH] Add crosshair hide/show convenience methods --- piker/ui/_graphics/_cursor.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/piker/ui/_graphics/_cursor.py b/piker/ui/_graphics/_cursor.py index 6b6f9697..e8cd8892 100644 --- a/piker/ui/_graphics/_cursor.py +++ b/piker/ui/_graphics/_cursor.py @@ -24,7 +24,7 @@ import inspect import numpy as np import pyqtgraph as pg from PyQt5 import QtCore, QtGui -from PyQt5.QtCore import QPointF +from PyQt5.QtCore import QPointF, QRectF from .._style import ( _xaxis_at, @@ -413,8 +413,23 @@ class Cursor(pg.GraphicsObject): self._datum_xy = ix, iy - def boundingRect(self): + def boundingRect(self) -> QRectF: try: return self.active_plot.boundingRect() except AttributeError: return self.plots[0].boundingRect() + + def show_xhair(self) -> None: + plot = self.active_plot + g = self.graphics[self.active_plot] + # show horiz line and y-label + g['hl'].show() + g['vl'].show() + g['yl'].show() + + def hide_xhair(self) -> None: + plot = self.active_plot + g = self.graphics[self.active_plot] + g['hl'].hide() + g['vl'].hide() + g['yl'].hide()