Bugfix: ScatterPlotItem not updating correctly when view is resized
Documentation updates (linked GLImageItem and Legend item to indexes)
This commit is contained in:
parent
65ed889a77
commit
16434272c2
@ -18,6 +18,7 @@ Contents:
|
|||||||
glgriditem
|
glgriditem
|
||||||
glmeshitem
|
glmeshitem
|
||||||
glvolumeitem
|
glvolumeitem
|
||||||
|
glimageitem
|
||||||
glaxisitem
|
glaxisitem
|
||||||
glgraphicsitem
|
glgraphicsitem
|
||||||
meshdata
|
meshdata
|
||||||
|
@ -29,6 +29,7 @@ Contents:
|
|||||||
scalebar
|
scalebar
|
||||||
labelitem
|
labelitem
|
||||||
vtickgroup
|
vtickgroup
|
||||||
|
legenditem
|
||||||
gradienteditoritem
|
gradienteditoritem
|
||||||
histogramlutitem
|
histogramlutitem
|
||||||
gradientlegend
|
gradientlegend
|
||||||
|
@ -394,14 +394,17 @@ class GraphicsItem(object):
|
|||||||
if oldView is not None:
|
if oldView is not None:
|
||||||
#print "disconnect:", self, oldView
|
#print "disconnect:", self, oldView
|
||||||
oldView.sigRangeChanged.disconnect(self.viewRangeChanged)
|
oldView.sigRangeChanged.disconnect(self.viewRangeChanged)
|
||||||
|
oldView.sigTransformChanged.disconnect(self.viewTransformChanged)
|
||||||
self._connectedView = None
|
self._connectedView = None
|
||||||
|
|
||||||
## connect to new view
|
## connect to new view
|
||||||
if view is not None:
|
if view is not None:
|
||||||
#print "connect:", self, view
|
#print "connect:", self, view
|
||||||
view.sigRangeChanged.connect(self.viewRangeChanged)
|
view.sigRangeChanged.connect(self.viewRangeChanged)
|
||||||
|
view.sigTransformChanged.connect(self.viewTransformChanged)
|
||||||
self._connectedView = weakref.ref(view)
|
self._connectedView = weakref.ref(view)
|
||||||
self.viewRangeChanged()
|
self.viewRangeChanged()
|
||||||
|
self.viewTransformChanged()
|
||||||
|
|
||||||
## inform children that their view might have changed
|
## inform children that their view might have changed
|
||||||
self._replaceView(oldView)
|
self._replaceView(oldView)
|
||||||
@ -425,3 +428,9 @@ class GraphicsItem(object):
|
|||||||
Called whenever the view coordinates of the ViewBox containing this item have changed.
|
Called whenever the view coordinates of the ViewBox containing this item have changed.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def viewTransformChanged(self):
|
||||||
|
"""
|
||||||
|
Called whenever the transformation matrix of the view has changed.
|
||||||
|
"""
|
||||||
|
pass
|
@ -642,9 +642,9 @@ class ScatterPlotItem(GraphicsObject):
|
|||||||
ymx = 0
|
ymx = 0
|
||||||
return QtCore.QRectF(xmn, ymn, xmx-xmn, ymx-ymn)
|
return QtCore.QRectF(xmn, ymn, xmx-xmn, ymx-ymn)
|
||||||
|
|
||||||
def viewRangeChanged(self):
|
def viewTransformChanged(self):
|
||||||
self.prepareGeometryChange()
|
self.prepareGeometryChange()
|
||||||
GraphicsObject.viewRangeChanged(self)
|
GraphicsObject.viewTransformChanged(self)
|
||||||
self.bounds = [None, None]
|
self.bounds = [None, None]
|
||||||
self.fragments = None
|
self.fragments = None
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ class ViewBox(GraphicsWidget):
|
|||||||
sigRangeChanged = QtCore.Signal(object, object)
|
sigRangeChanged = QtCore.Signal(object, object)
|
||||||
#sigActionPositionChanged = QtCore.Signal(object)
|
#sigActionPositionChanged = QtCore.Signal(object)
|
||||||
sigStateChanged = QtCore.Signal(object)
|
sigStateChanged = QtCore.Signal(object)
|
||||||
|
sigTransformChanged = QtCore.Signal(object)
|
||||||
|
|
||||||
## mouse modes
|
## mouse modes
|
||||||
PanMode = 3
|
PanMode = 3
|
||||||
@ -307,10 +308,6 @@ class ViewBox(GraphicsWidget):
|
|||||||
print("make qrectf failed:", self.state['viewRange'])
|
print("make qrectf failed:", self.state['viewRange'])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
#def viewportTransform(self):
|
|
||||||
##return self.itemTransform(self.childGroup)[0]
|
|
||||||
#return self.childGroup.itemTransform(self)[0]
|
|
||||||
|
|
||||||
def targetRange(self):
|
def targetRange(self):
|
||||||
return [x[:] for x in self.state['targetRange']] ## return copy
|
return [x[:] for x in self.state['targetRange']] ## return copy
|
||||||
|
|
||||||
@ -1121,29 +1118,15 @@ class ViewBox(GraphicsWidget):
|
|||||||
m = QtGui.QTransform()
|
m = QtGui.QTransform()
|
||||||
|
|
||||||
## First center the viewport at 0
|
## First center the viewport at 0
|
||||||
#self.childGroup.resetTransform()
|
|
||||||
#self.resetTransform()
|
|
||||||
#center = self.transform().inverted()[0].map(bounds.center())
|
|
||||||
center = bounds.center()
|
center = bounds.center()
|
||||||
#print " transform to center:", center
|
|
||||||
#if self.state['yInverted']:
|
|
||||||
#m.translate(center.x(), -center.y())
|
|
||||||
#print " inverted; translate", center.x(), center.y()
|
|
||||||
#else:
|
|
||||||
m.translate(center.x(), center.y())
|
m.translate(center.x(), center.y())
|
||||||
#print " not inverted; translate", center.x(), -center.y()
|
|
||||||
|
|
||||||
## Now scale and translate properly
|
## Now scale and translate properly
|
||||||
m.scale(scale[0], scale[1])
|
m.scale(scale[0], scale[1])
|
||||||
st = Point(vr.center())
|
st = Point(vr.center())
|
||||||
#st = translate
|
|
||||||
m.translate(-st[0], -st[1])
|
m.translate(-st[0], -st[1])
|
||||||
|
|
||||||
self.childGroup.setTransform(m)
|
self.childGroup.setTransform(m)
|
||||||
#self.setTransform(m)
|
|
||||||
#self.prepareGeometryChange()
|
|
||||||
|
|
||||||
#self.currentScale = scale
|
|
||||||
|
|
||||||
if changed[0]:
|
if changed[0]:
|
||||||
self.sigXRangeChanged.emit(self, tuple(self.state['viewRange'][0]))
|
self.sigXRangeChanged.emit(self, tuple(self.state['viewRange'][0]))
|
||||||
@ -1151,6 +1134,8 @@ class ViewBox(GraphicsWidget):
|
|||||||
self.sigYRangeChanged.emit(self, tuple(self.state['viewRange'][1]))
|
self.sigYRangeChanged.emit(self, tuple(self.state['viewRange'][1]))
|
||||||
if any(changed):
|
if any(changed):
|
||||||
self.sigRangeChanged.emit(self, self.state['viewRange'])
|
self.sigRangeChanged.emit(self, self.state['viewRange'])
|
||||||
|
|
||||||
|
self.sigTransformChanged.emit(self)
|
||||||
|
|
||||||
def paint(self, p, opt, widget):
|
def paint(self, p, opt, widget):
|
||||||
if self.border is not None:
|
if self.border is not None:
|
||||||
@ -1159,20 +1144,6 @@ class ViewBox(GraphicsWidget):
|
|||||||
#p.fillRect(bounds, QtGui.QColor(0, 0, 0))
|
#p.fillRect(bounds, QtGui.QColor(0, 0, 0))
|
||||||
p.drawPath(bounds)
|
p.drawPath(bounds)
|
||||||
|
|
||||||
#def saveSvg(self):
|
|
||||||
#pass
|
|
||||||
|
|
||||||
#def saveImage(self):
|
|
||||||
#pass
|
|
||||||
|
|
||||||
#def savePrint(self):
|
|
||||||
#printer = QtGui.QPrinter()
|
|
||||||
#if QtGui.QPrintDialog(printer).exec_() == QtGui.QDialog.Accepted:
|
|
||||||
#p = QtGui.QPainter(printer)
|
|
||||||
#p.setRenderHint(p.Antialiasing)
|
|
||||||
#self.scene().render(p)
|
|
||||||
#p.end()
|
|
||||||
|
|
||||||
def updateBackground(self):
|
def updateBackground(self):
|
||||||
bg = self.state['background']
|
bg = self.state['background']
|
||||||
if bg is None:
|
if bg is None:
|
||||||
|
@ -42,6 +42,7 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
enabled via enableMouse() (but ordinarily, we use ViewBox for this functionality)."""
|
enabled via enableMouse() (but ordinarily, we use ViewBox for this functionality)."""
|
||||||
|
|
||||||
sigRangeChanged = QtCore.Signal(object, object)
|
sigRangeChanged = QtCore.Signal(object, object)
|
||||||
|
sigTransformChanged = QtCore.Signal(object)
|
||||||
sigMouseReleased = QtCore.Signal(object)
|
sigMouseReleased = QtCore.Signal(object)
|
||||||
sigSceneMouseMoved = QtCore.Signal(object)
|
sigSceneMouseMoved = QtCore.Signal(object)
|
||||||
#sigRegionChanged = QtCore.Signal(object)
|
#sigRegionChanged = QtCore.Signal(object)
|
||||||
@ -212,6 +213,7 @@ class GraphicsView(QtGui.QGraphicsView):
|
|||||||
self.fitInView(self.range, QtCore.Qt.IgnoreAspectRatio)
|
self.fitInView(self.range, QtCore.Qt.IgnoreAspectRatio)
|
||||||
|
|
||||||
self.sigRangeChanged.emit(self, self.range)
|
self.sigRangeChanged.emit(self, self.range)
|
||||||
|
self.sigTransformChanged.emit(self)
|
||||||
|
|
||||||
if propagate:
|
if propagate:
|
||||||
for v in self.lockedViewports:
|
for v in self.lockedViewports:
|
||||||
|
Loading…
Reference in New Issue
Block a user