From 6f0fba30c85d957007de29caf42622003a5ab2eb Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 7 Apr 2022 10:58:09 -0400 Subject: [PATCH] Disconnect signals in `ChartView.disable_auto_yrange()` Allows for removing resize callbacks for a flow/overlay that you wish to remove from view (eg. unit volume after dollar volume is up) and thus less general interaction callback overhead for any plot you don't wish to show or resize. Further, - drop the `autoscale_linked_plots` block for now since with multi-view-box overlays each register their own vb resize slots - pull the graphics object from the chart's `Flow` map inside `.maybe_downsample_graphics()` --- piker/ui/_interaction.py | 62 +++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/piker/ui/_interaction.py b/piker/ui/_interaction.py index f76bac00..c6411caf 100644 --- a/piker/ui/_interaction.py +++ b/piker/ui/_interaction.py @@ -780,21 +780,21 @@ class ChartView(ViewBox): # TODO: maybe should be a method on the # chart widget/item? # if False: - if autoscale_linked_plots: - # avoid recursion by sibling plots - linked = self.linkedsplits - plots = list(linked.subplots.copy().values()) - main = linked.chart - if main: - plots.append(main) + # if autoscale_linked_plots: + # # avoid recursion by sibling plots + # linked = self.linkedsplits + # plots = list(linked.subplots.copy().values()) + # main = linked.chart + # if main: + # plots.append(main) - for chart in plots: - if chart and not chart._static_yrange: - chart.cv._set_yrange( - bars_range=br, - autoscale_linked_plots=False, - ) - profiler('autoscaled linked plots') + # for chart in plots: + # if chart and not chart._static_yrange: + # chart.cv._set_yrange( + # bars_range=br, + # autoscale_linked_plots=False, + # ) + # profiler('autoscaled linked plots') if set_range: @@ -839,8 +839,17 @@ class ChartView(ViewBox): if src_vb is None: src_vb = self + # such that when a linked chart changes its range + # this local view is also automatically changed and + # resized to data. src_vb.sigXRangeChanged.connect(self._set_yrange) + # splitter(s) resizing + src_vb.sigResized.connect(self._set_yrange) + + # mouse wheel doesn't emit XRangeChanged + src_vb.sigRangeChangedManually.connect(self._set_yrange) + # TODO: a smarter way to avoid calling this needlessly? # 2 things i can think of: # - register downsample-able graphics specially and only @@ -851,17 +860,24 @@ class ChartView(ViewBox): self.maybe_downsample_graphics ) - # mouse wheel doesn't emit XRangeChanged - src_vb.sigRangeChangedManually.connect(self._set_yrange) - - # splitter(s) resizing - src_vb.sigResized.connect(self._set_yrange) - def disable_auto_yrange( self, ) -> None: - self._chart._static_yrange = 'axis' + # self._chart._static_yrange = 'axis' + + self.sigXRangeChanged.disconnect( + self._set_yrange, + ) + self.sigResized.disconnect( + self._set_yrange, + ) + self.sigRangeChangedManually.disconnect( + self.maybe_downsample_graphics + ) + self.sigRangeChangedManually.disconnect( + self._set_yrange, + ) def x_uppx(self) -> float: ''' @@ -907,8 +923,8 @@ class ChartView(ViewBox): linked = self.linkedsplits plots = linked.subplots | {chart.name: chart} for chart_name, chart in plots.items(): - for name, graphics in chart._graphics.items(): - # print(f'maybe ds chart:{name} graphic:{name}') + for name, flow in chart._flows.items(): + graphics = flow.graphics use_vr = False if isinstance(graphics, BarItems):