Add level line flag to allow tracking its marker x-position
parent
ad2100fe3f
commit
44c6f6dfda
|
@ -117,6 +117,7 @@ class LevelMarker(QGraphicsPathItem):
|
|||
|
||||
self.get_level = get_level
|
||||
self._on_paint = on_paint
|
||||
|
||||
self.scene_x = lambda: chart.marker_right_points()[1]
|
||||
self.level: float = 0
|
||||
self.keep_in_view = keep_in_view
|
||||
|
@ -152,11 +153,7 @@ class LevelMarker(QGraphicsPathItem):
|
|||
def w(self) -> float:
|
||||
return self.path_br().width()
|
||||
|
||||
def position_in_view(
|
||||
self,
|
||||
# level: float,
|
||||
|
||||
) -> None:
|
||||
def position_in_view(self) -> None:
|
||||
'''
|
||||
Show a pp off-screen indicator for a level label.
|
||||
|
||||
|
@ -190,7 +187,6 @@ class LevelMarker(QGraphicsPathItem):
|
|||
)
|
||||
|
||||
elif level < ymn: # pin to bottom of view
|
||||
|
||||
self.setPos(
|
||||
QPointF(
|
||||
x,
|
||||
|
@ -240,11 +236,12 @@ def qgo_draw_markers(
|
|||
right_offset: float,
|
||||
|
||||
) -> float:
|
||||
"""Paint markers in ``pg.GraphicsItem`` style by first
|
||||
'''
|
||||
Paint markers in ``pg.GraphicsItem`` style by first
|
||||
removing the view transform for the painter, drawing the markers
|
||||
in scene coords, then restoring the view coords.
|
||||
|
||||
"""
|
||||
'''
|
||||
# paint markers in native coordinate system
|
||||
orig_tr = p.transform()
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ class LevelLine(pg.InfiniteLine):
|
|||
self._marker = None
|
||||
self.only_show_markers_on_hover = only_show_markers_on_hover
|
||||
self.show_markers: bool = True # presuming the line is hovered at init
|
||||
self.track_marker_pos: bool = False
|
||||
|
||||
# should line go all the way to far end or leave a "margin"
|
||||
# space for other graphics (eg. L1 book)
|
||||
|
@ -329,7 +330,7 @@ class LevelLine(pg.InfiniteLine):
|
|||
from pg..
|
||||
|
||||
'''
|
||||
p.setRenderHint(p.Antialiasing)
|
||||
# p.setRenderHint(p.Antialiasing)
|
||||
|
||||
# these are in viewbox coords
|
||||
vb_left, vb_right = self._endPoints
|
||||
|
@ -355,14 +356,18 @@ 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:
|
||||
if self.track_marker_pos:
|
||||
# make the line end at the marker's x pos
|
||||
line_end = self._marker.pos().x()
|
||||
|
||||
# TODO: make this label update part of a scene-aware-marker
|
||||
# composed annotation
|
||||
self._marker.setPos(
|
||||
QPointF(marker_right, self.scene_y())
|
||||
)
|
||||
if hasattr(self._marker, 'label'):
|
||||
self._marker.label.update()
|
||||
else:
|
||||
# TODO: make this label update part of a scene-aware-marker
|
||||
# composed annotation
|
||||
self._marker.setPos(
|
||||
QPointF(marker_right, self.scene_y())
|
||||
)
|
||||
if hasattr(self._marker, 'label'):
|
||||
self._marker.label.update()
|
||||
|
||||
elif not self.use_marker_margin:
|
||||
# basically means **don't** shorten the line with normally
|
||||
|
@ -525,9 +530,10 @@ def level_line(
|
|||
**kwargs,
|
||||
|
||||
) -> LevelLine:
|
||||
"""Convenience routine to add a styled horizontal line to a plot.
|
||||
'''
|
||||
Convenience routine to add a styled horizontal line to a plot.
|
||||
|
||||
"""
|
||||
'''
|
||||
hl_color = color + '_light' if highlight_on_hover else color
|
||||
|
||||
line = LevelLine(
|
||||
|
|
Loading…
Reference in New Issue