From 37cd80013507f588591b079e07a42933246e59c4 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 22 Jul 2021 18:17:42 -0400 Subject: [PATCH] Add a scene bounding rect getter to our label --- piker/ui/_label.py | 6 ++++++ piker/ui/_lines.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/piker/ui/_label.py b/piker/ui/_label.py index cfe1351c..e2b3634e 100644 --- a/piker/ui/_label.py +++ b/piker/ui/_label.py @@ -135,6 +135,12 @@ class Label: def w(self) -> float: return self.txt.boundingRect().width() + def scene_br(self) -> QRectF: + txt = self.txt + return txt.mapToScene( + txt.boundingRect() + ).boundingRect() + @property def h(self) -> float: return self.txt.boundingRect().height() diff --git a/piker/ui/_lines.py b/piker/ui/_lines.py index c873857e..680a5604 100644 --- a/piker/ui/_lines.py +++ b/piker/ui/_lines.py @@ -314,9 +314,11 @@ class LevelLine(pg.InfiniteLine): def paint( self, + p: QtGui.QPainter, opt: QtWidgets.QStyleOptionGraphicsItem, w: QtWidgets.QWidget + ) -> None: """Core paint which we override (yet again) from pg.. @@ -348,6 +350,8 @@ class LevelLine(pg.InfiniteLine): # order lines.. not sure wtf is up with that. # for now we're just using it on the position line. elif self._marker: + # print('we have a marker?') + # self._chart.view.locate(self._marker) # TODO: make this label update part of a scene-aware-marker # composed annotation