Fixes:
- ROI updates on sigTransformChanged - ViewBox is more careful about accepting all auto-range changes up to the point it is disabled, even if the auto-range calculation is deferred.
This commit is contained in:
parent
0daae425a3
commit
96a4ff7cd5
@ -27,7 +27,7 @@ arr += np.random.normal(size=(100,100))
|
||||
|
||||
## create GUI
|
||||
app = QtGui.QApplication([])
|
||||
w = pg.GraphicsWindow(size=(800,800), border=True)
|
||||
w = pg.GraphicsWindow(size=(1000,800), border=True)
|
||||
w.setWindowTitle('pyqtgraph example: ROI Examples')
|
||||
|
||||
text = """Data Selection From Image.<br>\n
|
||||
|
@ -23,7 +23,9 @@ p2 = win.addPlot(row=2, col=0)
|
||||
|
||||
region = pg.LinearRegionItem()
|
||||
region.setZValue(10)
|
||||
p2.addItem(region)
|
||||
# Add the LinearRegionItem to the ViewBox, but tell the ViewBox to exclude this
|
||||
# item when doing auto-range calculations.
|
||||
p2.addItem(region, ignoreBounds=True)
|
||||
|
||||
#pg.dbg()
|
||||
p1.setAutoVisible(y=True)
|
||||
|
@ -1320,7 +1320,6 @@ class Handle(UIGraphicsItem):
|
||||
## determine rotation of transform
|
||||
#m = self.sceneTransform() ## Qt bug: do not access sceneTransform() until we know this object has a scene.
|
||||
#mi = m.inverted()[0]
|
||||
|
||||
dt = self.deviceTransform()
|
||||
|
||||
if dt is None:
|
||||
@ -1339,10 +1338,10 @@ class Handle(UIGraphicsItem):
|
||||
return dti.map(tr.map(self.path))
|
||||
|
||||
|
||||
def viewRangeChanged(self):
|
||||
GraphicsObject.viewRangeChanged(self)
|
||||
def viewTransformChanged(self):
|
||||
GraphicsObject.viewTransformChanged(self)
|
||||
self._shape = None ## invalidate shape, recompute later if requested.
|
||||
#self.updateShape()
|
||||
self.update()
|
||||
|
||||
#def itemChange(self, change, value):
|
||||
#if change == self.ItemScenePositionHasChanged:
|
||||
|
@ -213,8 +213,9 @@ class ViewBox(GraphicsWidget):
|
||||
return ret
|
||||
|
||||
def prepareForPaint(self):
|
||||
autoRangeEnabled = (self.state['autoRange'][0] is not False) or (self.state['autoRange'][1] is not False)
|
||||
if self._autoRangeNeedsUpdate and autoRangeEnabled:
|
||||
#autoRangeEnabled = (self.state['autoRange'][0] is not False) or (self.state['autoRange'][1] is not False)
|
||||
# don't check whether auto range is enabled here--only check when setting dirty flag.
|
||||
if self._autoRangeNeedsUpdate: # and autoRangeEnabled:
|
||||
self.updateAutoRange()
|
||||
if self._matrixNeedsUpdate:
|
||||
self.updateMatrix()
|
||||
@ -332,22 +333,15 @@ class ViewBox(GraphicsWidget):
|
||||
ch.setParentItem(None)
|
||||
|
||||
def resizeEvent(self, ev):
|
||||
#print self.name, "ViewBox.resizeEvent", self.size()
|
||||
#self.setRange(self.range, padding=0)
|
||||
#x,y = self.targetRange()
|
||||
#self.setRange(xRange=x, yRange=y, padding=0)
|
||||
self.linkedXChanged()
|
||||
self.linkedYChanged()
|
||||
self.updateAutoRange()
|
||||
self.updateViewRange()
|
||||
#self.updateMatrix()
|
||||
self.sigStateChanged.emit(self)
|
||||
self.background.setRect(self.rect())
|
||||
#self._itemBoundsCache.clear()
|
||||
#self.linkedXChanged()
|
||||
#self.linkedYChanged()
|
||||
self.sigResized.emit(self)
|
||||
|
||||
|
||||
def viewRange(self):
|
||||
"""Return a the view's visible range as a list: [[xmin, xmax], [ymin, ymax]]"""
|
||||
return [x[:] for x in self.state['viewRange']] ## return copy
|
||||
@ -485,10 +479,10 @@ class ViewBox(GraphicsWidget):
|
||||
|
||||
# If ortho axes have auto-visible-only, update them now
|
||||
# Note that aspect ratio constraints and auto-visible probably do not work together..
|
||||
if changed[0] and self.state['autoVisibleOnly'][1]:
|
||||
if changed[0] and self.state['autoVisibleOnly'][1] and (self.state['autoRange'][0] is not False):
|
||||
self._autoRangeNeedsUpdate = True
|
||||
#self.updateAutoRange() ## Maybe just indicate that auto range needs to be updated?
|
||||
elif changed[1] and self.state['autoVisibleOnly'][0]:
|
||||
elif changed[1] and self.state['autoVisibleOnly'][0] and (self.state['autoRange'][1] is not False):
|
||||
self._autoRangeNeedsUpdate = True
|
||||
#self.updateAutoRange()
|
||||
|
||||
@ -662,11 +656,18 @@ class ViewBox(GraphicsWidget):
|
||||
|
||||
for ax in axes:
|
||||
if self.state['autoRange'][ax] != enable:
|
||||
# If we are disabling, do one last auto-range to make sure that
|
||||
# previously scheduled auto-range changes are enacted
|
||||
if enable is False and self._autoRangeNeedsUpdate:
|
||||
self.updateAutoRange()
|
||||
|
||||
self.state['autoRange'][ax] = enable
|
||||
needAutoRangeUpdate |= (enable is not False)
|
||||
|
||||
if needAutoRangeUpdate:
|
||||
self.updateAutoRange()
|
||||
self._autoRangeNeedsUpdate |= (enable is not False)
|
||||
self.update()
|
||||
|
||||
|
||||
#if needAutoRangeUpdate:
|
||||
# self.updateAutoRange()
|
||||
|
||||
self.sigStateChanged.emit(self)
|
||||
|
||||
@ -901,8 +902,9 @@ class ViewBox(GraphicsWidget):
|
||||
|
||||
def itemBoundsChanged(self, item):
|
||||
self._itemBoundsCache.pop(item, None)
|
||||
self._autoRangeNeedsUpdate = True
|
||||
self.update()
|
||||
if (self.state['autoRange'][0] is not False) or (self.state['autoRange'][1] is not False):
|
||||
self._autoRangeNeedsUpdate = True
|
||||
self.update()
|
||||
#self.updateAutoRange()
|
||||
|
||||
def invertY(self, b=True):
|
||||
|
Loading…
Reference in New Issue
Block a user