From ccc5e6274a3771cfefa6df5dd2fef9b9e6832804 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Thu, 7 Nov 2013 12:05:05 -0500 Subject: [PATCH] Fixes: - GraphItem reports pixel margins to improve auto-range - ViewBox.setRange is more careful about disabling auto range for axes that are set --- pyqtgraph/graphicsItems/GraphItem.py | 5 +++++ pyqtgraph/graphicsItems/ViewBox/ViewBox.py | 16 +++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pyqtgraph/graphicsItems/GraphItem.py b/pyqtgraph/graphicsItems/GraphItem.py index 79f8804a..b1f34baa 100644 --- a/pyqtgraph/graphicsItems/GraphItem.py +++ b/pyqtgraph/graphicsItems/GraphItem.py @@ -110,6 +110,11 @@ class GraphItem(GraphicsObject): def boundingRect(self): return self.scatter.boundingRect() + def dataBounds(self, *args, **kwds): + return self.scatter.dataBounds(*args, **kwds) + + def pixelPadding(self): + return self.scatter.pixelPadding() diff --git a/pyqtgraph/graphicsItems/ViewBox/ViewBox.py b/pyqtgraph/graphicsItems/ViewBox/ViewBox.py index 419b6306..5f59d8bc 100644 --- a/pyqtgraph/graphicsItems/ViewBox/ViewBox.py +++ b/pyqtgraph/graphicsItems/ViewBox/ViewBox.py @@ -394,6 +394,8 @@ class ViewBox(GraphicsWidget): """ #print self.name, "ViewBox.setRange", rect, xRange, yRange, padding + #import traceback + #traceback.print_stack() changes = {} # axes setRequested = [False, False] @@ -454,15 +456,11 @@ class ViewBox(GraphicsWidget): lockY = False self.updateViewRange(lockX, lockY) - # Disable auto-range if needed + # Disable auto-range for each axis that was requested to be set if disableAutoRange: - if all(changed): - ax = ViewBox.XYAxes - elif changed[0]: - ax = ViewBox.XAxis - elif changed[1]: - ax = ViewBox.YAxis - self.enableAutoRange(ax, False) + xOff = False if setRequested[0] else None + yOff = False if setRequested[1] else None + self.enableAutoRange(x=xOff, y=yOff) changed.append(True) # If nothing has changed, we are done. @@ -1376,7 +1374,7 @@ class ViewBox(GraphicsWidget): def updateMatrix(self, changed=None): ## Make the childGroup's transform match the requested viewRange. - + #print self.name, "updateMAtrix", self.state['targetRange'] #if changed is None: #changed = [False, False] #changed = list(changed)