Merge branch 'termim-fixes' into develop

This commit is contained in:
Luke Campagnola 2014-02-02 10:49:17 -05:00
commit 83621e816f
6 changed files with 21 additions and 22 deletions

View File

@ -11,6 +11,7 @@ pyqtgraph-0.9.9 [unreleased]
- Speed improvements in functions.makeARGB
- ImageItem is faster by avoiding makeQImage(transpose=True)
- ComboBox will raise error when adding multiple items of the same name
- ArrowItem.setStyle now updates style options rather than replacing them
New Features:
- New HDF5 example for working with very large datasets

View File

@ -45,6 +45,7 @@ p.setRange(QtCore.QRectF(-20, -10, 60, 20))
## Animated arrow following curve
c = p2.plot(x=np.sin(np.linspace(0, 2*np.pi, 1000)), y=np.cos(np.linspace(0, 6*np.pi, 1000)))
a = pg.CurveArrow(c)
a.setStyle(headLen=40)
p2.addItem(a)
anim = a.makeAnimation(loop=-1)
anim.start()

View File

@ -1,15 +1,10 @@
import initExample ## Add path to library (just for examples; you do not need this)
from pyqtgraph.Qt import QtGui, QtCore
import pyqtgraph as pg
import numpy as np
plt = pg.plot(np.random.normal(size=100), title="Simplest possible plotting example")
plt.getAxis('bottom').setTicks([[(x*20, str(x*20)) for x in range(6)]])
## Start Qt event loop unless running in interactive mode or using pyside.
ex = pg.exporters.SVGExporter.SVGExporter(plt.plotItem.scene())
ex.export('/home/luke/tmp/test.svg')
if __name__ == '__main__':
import sys
if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'):
if sys.flags.interactive != 1 or not hasattr(pg.QtCore, 'PYQT_VERSION'):
pg.QtGui.QApplication.exec_()

View File

@ -16,12 +16,14 @@ class ArrowItem(QtGui.QGraphicsPathItem):
Arrows can be initialized with any keyword arguments accepted by
the setStyle() method.
"""
self.opts = {}
QtGui.QGraphicsPathItem.__init__(self, opts.get('parent', None))
if 'size' in opts:
opts['headLen'] = opts['size']
if 'width' in opts:
opts['headWidth'] = opts['width']
defOpts = {
defaultOpts = {
'pxMode': True,
'angle': -150, ## If the angle is 0, the arrow points left
'pos': (0,0),
@ -33,12 +35,9 @@ class ArrowItem(QtGui.QGraphicsPathItem):
'pen': (200,200,200),
'brush': (50,50,200),
}
defOpts.update(opts)
defaultOpts.update(opts)
self.setStyle(**defOpts)
self.setPen(fn.mkPen(defOpts['pen']))
self.setBrush(fn.mkBrush(defOpts['brush']))
self.setStyle(**defaultOpts)
self.rotate(self.opts['angle'])
self.moveBy(*self.opts['pos'])
@ -60,9 +59,9 @@ class ArrowItem(QtGui.QGraphicsPathItem):
specified, ot overrides headWidth. default=25
baseAngle Angle of the base of the arrow head. Default is
0, which means that the base of the arrow head
is perpendicular to the arrow shaft.
is perpendicular to the arrow tail.
tailLen Length of the arrow tail, measured from the base
of the arrow head to the tip of the tail. If
of the arrow head to the end of the tail. If
this value is None, no tail will be drawn.
default=None
tailWidth Width of the tail. default=3
@ -70,13 +69,16 @@ class ArrowItem(QtGui.QGraphicsPathItem):
brush The brush used to fill the arrow.
================= =================================================
"""
self.opts = opts
self.opts.update(opts)
opt = dict([(k,self.opts[k]) for k in ['headLen', 'tipAngle', 'baseAngle', 'tailLen', 'tailWidth']])
self.path = fn.makeArrowPath(**opt)
self.setPath(self.path)
if opts['pxMode']:
self.setPen(fn.mkPen(self.opts['pen']))
self.setBrush(fn.mkBrush(self.opts['brush']))
if self.opts['pxMode']:
self.setFlags(self.flags() | self.ItemIgnoresTransformations)
else:
self.setFlags(self.flags() & ~self.ItemIgnoresTransformations)

View File

@ -688,7 +688,7 @@ class AxisItem(GraphicsWidget):
## determine mapping between tick values and local coordinates
dif = self.range[1] - self.range[0]
if dif == 0:
xscale = 1
xScale = 1
offset = 0
else:
if axis == 0:
@ -806,10 +806,10 @@ class AxisItem(GraphicsWidget):
## measure all text, make sure there's enough room
if axis == 0:
textSize = np.sum([r.height() for r in textRects])
textSize2 = np.max([r.width() for r in textRects])
textSize2 = np.max([r.width() for r in textRects]) if textRects else 0
else:
textSize = np.sum([r.width() for r in textRects])
textSize2 = np.max([r.height() for r in textRects])
textSize2 = np.max([r.height() for r in textRects]) if textRects else 0
## If the strings are too crowded, stop drawing text now.
## We use three different crowding limits based on the number

View File

@ -112,6 +112,6 @@ class CurveArrow(CurvePoint):
self.arrow = ArrowItem.ArrowItem(**opts)
self.arrow.setParentItem(self)
def setStyle(**opts):
def setStyle(self, **opts):
return self.arrow.setStyle(**opts)