WIP position market offscreen nav

pause_feeds_on_sym_switch
Tyler Goodlet 2021-06-23 10:06:05 -04:00
parent ad174c5c21
commit fd5c72f97d
1 changed files with 45 additions and 35 deletions

View File

@ -352,6 +352,21 @@ class LevelLine(pg.InfiniteLine):
return up_to_l1_sc return up_to_l1_sc
def marker_right_points(self) -> (float, float, float):
chart = self._chart
l1_len = chart._max_l1_line_len
ryaxis = chart.getAxis('right')
r_axis_x = ryaxis.pos().x()
up_to_l1_sc = r_axis_x - l1_len
size = self._default_mkr_size
marker_right = up_to_l1_sc - (1.375 * 2*size)
line_end = marker_right - (6/16 * size)
return line_end, marker_right, r_axis_x
def paint( def paint(
self, self,
p: QtGui.QPainter, p: QtGui.QPainter,
@ -366,26 +381,14 @@ class LevelLine(pg.InfiniteLine):
# these are in viewbox coords # these are in viewbox coords
vb_left, vb_right = self._endPoints vb_left, vb_right = self._endPoints
chart = self._chart
l1_len = chart._max_l1_line_len
ryaxis = chart.getAxis('right')
r_axis_x = ryaxis.pos().x()
up_to_l1_sc = r_axis_x - l1_len
vb = self.getViewBox() vb = self.getViewBox()
size = self._default_mkr_size line_end, marker_right, r_axis_x = self.marker_right_points()
marker_right = up_to_l1_sc - (1.375 * 2*size)
line_end = marker_right - (6/16 * size)
if self.show_markers and self.markers: if self.show_markers and self.markers:
size = self.markers[0][2]
p.setPen(self.pen) p.setPen(self.pen)
size = qgo_draw_markers( qgo_draw_markers(
self.markers, self.markers,
self.pen.color(), self.pen.color(),
p, p,
@ -438,9 +441,8 @@ class LevelLine(pg.InfiniteLine):
path: QtWidgets.QGraphicsPathItem, path: QtWidgets.QGraphicsPathItem,
) -> None: ) -> None:
# chart = self._chart # add path to scene
vb = self.getViewBox() self.getViewBox().scene().addItem(path)
vb.scene().addItem(path)
self._marker = path self._marker = path
@ -758,27 +760,31 @@ def position_line(
vr = vb.state['viewRange'] vr = vb.state['viewRange']
ymn, ymx = vr[1] ymn, ymx = vr[1]
level = line.value() level = line.value()
path = line._marker
if gt := level > ymx or (lt := level < ymn):
if chartview.mode.name == 'order':
# provide "nav hub" like indicator for where # provide "nav hub" like indicator for where
# the position is on the y-dimension # the position is on the y-dimension
if gt: # print(path._height)
# pin to top of view since position is above current # print(vb.shape())
# y-range # print(vb.boundingRect())
pass # print(vb.height())
_, marker_right, _ = line.marker_right_points()
elif lt: if level > ymx: # pin to top of view
# pin to bottom of view since position is above path.setPos(
# below y-range QPointF(
pass marker_right,
2 + path._height,
)
)
else: elif level < ymn: # pin to bottom of view
# order mode is not active path.setPos(
# so hide the pp market QPointF(
line._marker.hide() marker_right,
vb.height() - 16 + path._height,
)
)
else: else:
# pp line is viewable so show marker # pp line is viewable so show marker
@ -812,6 +818,10 @@ def position_line(
style = '>|' style = '>|'
arrow_path = mk_marker(style, size=arrow_size) arrow_path = mk_marker(style, size=arrow_size)
# monkey-cache height for sizing on pp nav-hub
arrow_path._height = arrow_path.boundingRect().height()
# XXX: uses new marker drawing approach # XXX: uses new marker drawing approach
line.add_marker(arrow_path) line.add_marker(arrow_path)
line.set_level(level) line.set_level(level)