Commit 8551a990 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

Merged ViewBox bugfix from Kratz

parents 8b950e80 c039074e
...@@ -1017,6 +1017,7 @@ class ViewBox(GraphicsWidget): ...@@ -1017,6 +1017,7 @@ class ViewBox(GraphicsWidget):
frac = (1.0, 1.0) frac = (1.0, 1.0)
xr = item.dataBounds(0, frac=frac[0], orthoRange=orthoRange[0]) xr = item.dataBounds(0, frac=frac[0], orthoRange=orthoRange[0])
yr = item.dataBounds(1, frac=frac[1], orthoRange=orthoRange[1]) yr = item.dataBounds(1, frac=frac[1], orthoRange=orthoRange[1])
#print " xr:", xr, " yr:", yr
if xr is None or xr == (None, None): if xr is None or xr == (None, None):
useX = False useX = False
xr = (0,0) xr = (0,0)
...@@ -1025,6 +1026,7 @@ class ViewBox(GraphicsWidget): ...@@ -1025,6 +1026,7 @@ class ViewBox(GraphicsWidget):
yr = (0,0) yr = (0,0)
bounds = QtCore.QRectF(xr[0], yr[0], xr[1]-xr[0], yr[1]-yr[0]) bounds = QtCore.QRectF(xr[0], yr[0], xr[1]-xr[0], yr[1]-yr[0])
#print " xr:", xr, " yr:", yr
#print " item real:", bounds #print " item real:", bounds
else: else:
if int(item.flags() & item.ItemHasNoContents) > 0: if int(item.flags() & item.ItemHasNoContents) > 0:
...@@ -1038,7 +1040,7 @@ class ViewBox(GraphicsWidget): ...@@ -1038,7 +1040,7 @@ class ViewBox(GraphicsWidget):
bounds = self.mapFromItemToView(item, bounds).boundingRect() bounds = self.mapFromItemToView(item, bounds).boundingRect()
#print " ", bounds #print " ", bounds
#print " useX:", useX, " useY:", useY
if not any([useX, useY]): if not any([useX, useY]):
continue continue
...@@ -1047,12 +1049,14 @@ class ViewBox(GraphicsWidget): ...@@ -1047,12 +1049,14 @@ class ViewBox(GraphicsWidget):
if ang == 0 or ang == 180: if ang == 0 or ang == 180:
pass pass
elif ang == 90 or ang == 270: elif ang == 90 or ang == 270:
tmp = useX useX, useY = useY, useX
useY = useX
useX = tmp
else: else:
continue ## need to check for item rotations and decide how best to apply this boundary. continue ## need to check for item rotations and decide how best to apply this boundary.
#print " useX:", useX, " useY:", useY
#print " range:", range
#print " bounds (r,l,t,b):", bounds.right(), bounds.left(), bounds.top(), bounds.bottom()
if useY: if useY:
if range[1] is not None: if range[1] is not None:
...@@ -1064,6 +1068,8 @@ class ViewBox(GraphicsWidget): ...@@ -1064,6 +1068,8 @@ class ViewBox(GraphicsWidget):
range[0] = [min(bounds.left(), range[0][0]), max(bounds.right(), range[0][1])] range[0] = [min(bounds.left(), range[0][0]), max(bounds.right(), range[0][1])]
else: else:
range[0] = [bounds.left(), bounds.right()] range[0] = [bounds.left(), bounds.right()]
#print " range:", range
return range return range
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment