Use `Curve.x_last()` for zoom focal point
parent
fe932a96a9
commit
4d2b5c8f86
|
@ -35,7 +35,7 @@ import trio
|
||||||
from ..log import get_logger
|
from ..log import get_logger
|
||||||
from .._profile import Profiler
|
from .._profile import Profiler
|
||||||
from .._profile import pg_profile_enabled, ms_slower_then
|
from .._profile import pg_profile_enabled, ms_slower_then
|
||||||
# from ._style import _min_points_to_show
|
from ._style import _min_points_to_show
|
||||||
from ._editors import SelectRect
|
from ._editors import SelectRect
|
||||||
from . import _event
|
from . import _event
|
||||||
|
|
||||||
|
@ -492,18 +492,20 @@ class ChartView(ViewBox):
|
||||||
chart = self.linked.chart
|
chart = self.linked.chart
|
||||||
|
|
||||||
# don't zoom more then the min points setting
|
# don't zoom more then the min points setting
|
||||||
out = l, lbar, rbar, r = chart.get_viz(chart.name).bars_range()
|
viz = chart.get_viz(chart.name)
|
||||||
# vl = r - l
|
vl, lbar, rbar, vr = viz.bars_range()
|
||||||
|
rl = vr - vl
|
||||||
|
|
||||||
# if ev.delta() > 0 and vl <= _min_points_to_show:
|
# TODO: max/min zoom limits incorporating time step size.
|
||||||
# log.debug("Max zoom bruh...")
|
# if ev.delta() > 0 and rl <= _min_points_to_show:
|
||||||
|
# log.warning("Max zoom bruh...")
|
||||||
# return
|
# return
|
||||||
|
|
||||||
# if (
|
# if (
|
||||||
# ev.delta() < 0
|
# ev.delta() < 0
|
||||||
# and vl >= len(chart._vizs[chart.name].shm.array) + 666
|
# and rl >= len(chart._vizs[chart.name].shm.array) + 666
|
||||||
# ):
|
# ):
|
||||||
# log.debug("Min zoom bruh...")
|
# log.warning("Min zoom bruh...")
|
||||||
# return
|
# return
|
||||||
|
|
||||||
# actual scaling factor
|
# actual scaling factor
|
||||||
|
@ -552,8 +554,7 @@ class ChartView(ViewBox):
|
||||||
|
|
||||||
# This seems like the most "intuitive option, a hybrid of
|
# This seems like the most "intuitive option, a hybrid of
|
||||||
# tws and tv styles
|
# tws and tv styles
|
||||||
last_bar = pg.Point(int(rbar)) + 1
|
# last_bar = pg.Point(int(rbar)) + 1
|
||||||
|
|
||||||
ryaxis = chart.getAxis('right')
|
ryaxis = chart.getAxis('right')
|
||||||
r_axis_x = ryaxis.pos().x()
|
r_axis_x = ryaxis.pos().x()
|
||||||
|
|
||||||
|
@ -561,21 +562,21 @@ class ChartView(ViewBox):
|
||||||
round(
|
round(
|
||||||
chart.cv.mapToView(
|
chart.cv.mapToView(
|
||||||
pg.Point(r_axis_x - chart._max_l1_line_len)
|
pg.Point(r_axis_x - chart._max_l1_line_len)
|
||||||
# QPointF(chart._max_l1_line_len, 0)
|
|
||||||
).x()
|
).x()
|
||||||
)
|
)
|
||||||
) # .x()
|
).x()
|
||||||
|
|
||||||
# self.state['viewRange'][0][1] = end_of_l1
|
# self.state['viewRange'][0][1] = end_of_l1
|
||||||
# focal = pg.Point((last_bar.x() + end_of_l1)/2)
|
# focal = pg.Point((last_bar.x() + end_of_l1)/2)
|
||||||
|
|
||||||
focal = min(
|
|
||||||
last_bar,
|
|
||||||
end_of_l1,
|
|
||||||
key=lambda p: p.x()
|
|
||||||
)
|
|
||||||
# focal = pg.Point(last_bar.x() + end_of_l1)
|
# focal = pg.Point(last_bar.x() + end_of_l1)
|
||||||
|
|
||||||
|
# use right-most point of current curve graphic
|
||||||
|
xl = viz.graphics.x_last()
|
||||||
|
focal = min(
|
||||||
|
xl,
|
||||||
|
end_of_l1,
|
||||||
|
)
|
||||||
|
|
||||||
self._resetTarget()
|
self._resetTarget()
|
||||||
self.scaleBy(s, focal)
|
self.scaleBy(s, focal)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue