Merge branch 'termim-fixes' into develop
This commit is contained in:
commit
83621e816f
@ -11,6 +11,7 @@ pyqtgraph-0.9.9 [unreleased]
|
|||||||
- Speed improvements in functions.makeARGB
|
- Speed improvements in functions.makeARGB
|
||||||
- ImageItem is faster by avoiding makeQImage(transpose=True)
|
- ImageItem is faster by avoiding makeQImage(transpose=True)
|
||||||
- ComboBox will raise error when adding multiple items of the same name
|
- 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 Features:
|
||||||
- New HDF5 example for working with very large datasets
|
- New HDF5 example for working with very large datasets
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"""
|
"""
|
||||||
Display an animated arrowhead following a curve.
|
Display an animated arrowhead following a curve.
|
||||||
This example uses the CurveArrow class, which is a combination
|
This example uses the CurveArrow class, which is a combination
|
||||||
of ArrowItem and CurvePoint.
|
of ArrowItem and CurvePoint.
|
||||||
|
|
||||||
To place a static arrow anywhere in a scene, use ArrowItem.
|
To place a static arrow anywhere in a scene, use ArrowItem.
|
||||||
To attach other types of item to a curve, use CurvePoint.
|
To attach other types of item to a curve, use CurvePoint.
|
||||||
@ -45,6 +45,7 @@ p.setRange(QtCore.QRectF(-20, -10, 60, 20))
|
|||||||
## Animated arrow following curve
|
## 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)))
|
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 = pg.CurveArrow(c)
|
||||||
|
a.setStyle(headLen=40)
|
||||||
p2.addItem(a)
|
p2.addItem(a)
|
||||||
anim = a.makeAnimation(loop=-1)
|
anim = a.makeAnimation(loop=-1)
|
||||||
anim.start()
|
anim.start()
|
||||||
|
@ -1,15 +1,10 @@
|
|||||||
import initExample ## Add path to library (just for examples; you do not need this)
|
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 pyqtgraph as pg
|
||||||
import numpy as np
|
import numpy as np
|
||||||
plt = pg.plot(np.random.normal(size=100), title="Simplest possible plotting example")
|
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__':
|
if __name__ == '__main__':
|
||||||
import sys
|
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_()
|
pg.QtGui.QApplication.exec_()
|
||||||
|
@ -16,12 +16,14 @@ class ArrowItem(QtGui.QGraphicsPathItem):
|
|||||||
Arrows can be initialized with any keyword arguments accepted by
|
Arrows can be initialized with any keyword arguments accepted by
|
||||||
the setStyle() method.
|
the setStyle() method.
|
||||||
"""
|
"""
|
||||||
|
self.opts = {}
|
||||||
QtGui.QGraphicsPathItem.__init__(self, opts.get('parent', None))
|
QtGui.QGraphicsPathItem.__init__(self, opts.get('parent', None))
|
||||||
|
|
||||||
if 'size' in opts:
|
if 'size' in opts:
|
||||||
opts['headLen'] = opts['size']
|
opts['headLen'] = opts['size']
|
||||||
if 'width' in opts:
|
if 'width' in opts:
|
||||||
opts['headWidth'] = opts['width']
|
opts['headWidth'] = opts['width']
|
||||||
defOpts = {
|
defaultOpts = {
|
||||||
'pxMode': True,
|
'pxMode': True,
|
||||||
'angle': -150, ## If the angle is 0, the arrow points left
|
'angle': -150, ## If the angle is 0, the arrow points left
|
||||||
'pos': (0,0),
|
'pos': (0,0),
|
||||||
@ -33,12 +35,9 @@ class ArrowItem(QtGui.QGraphicsPathItem):
|
|||||||
'pen': (200,200,200),
|
'pen': (200,200,200),
|
||||||
'brush': (50,50,200),
|
'brush': (50,50,200),
|
||||||
}
|
}
|
||||||
defOpts.update(opts)
|
defaultOpts.update(opts)
|
||||||
|
|
||||||
self.setStyle(**defOpts)
|
self.setStyle(**defaultOpts)
|
||||||
|
|
||||||
self.setPen(fn.mkPen(defOpts['pen']))
|
|
||||||
self.setBrush(fn.mkBrush(defOpts['brush']))
|
|
||||||
|
|
||||||
self.rotate(self.opts['angle'])
|
self.rotate(self.opts['angle'])
|
||||||
self.moveBy(*self.opts['pos'])
|
self.moveBy(*self.opts['pos'])
|
||||||
@ -60,9 +59,9 @@ class ArrowItem(QtGui.QGraphicsPathItem):
|
|||||||
specified, ot overrides headWidth. default=25
|
specified, ot overrides headWidth. default=25
|
||||||
baseAngle Angle of the base of the arrow head. Default is
|
baseAngle Angle of the base of the arrow head. Default is
|
||||||
0, which means that the base of the arrow head
|
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
|
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.
|
this value is None, no tail will be drawn.
|
||||||
default=None
|
default=None
|
||||||
tailWidth Width of the tail. default=3
|
tailWidth Width of the tail. default=3
|
||||||
@ -70,13 +69,16 @@ class ArrowItem(QtGui.QGraphicsPathItem):
|
|||||||
brush The brush used to fill the arrow.
|
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']])
|
opt = dict([(k,self.opts[k]) for k in ['headLen', 'tipAngle', 'baseAngle', 'tailLen', 'tailWidth']])
|
||||||
self.path = fn.makeArrowPath(**opt)
|
self.path = fn.makeArrowPath(**opt)
|
||||||
self.setPath(self.path)
|
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)
|
self.setFlags(self.flags() | self.ItemIgnoresTransformations)
|
||||||
else:
|
else:
|
||||||
self.setFlags(self.flags() & ~self.ItemIgnoresTransformations)
|
self.setFlags(self.flags() & ~self.ItemIgnoresTransformations)
|
||||||
@ -121,4 +123,4 @@ class ArrowItem(QtGui.QGraphicsPathItem):
|
|||||||
return pad
|
return pad
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ class AxisItem(GraphicsWidget):
|
|||||||
## determine mapping between tick values and local coordinates
|
## determine mapping between tick values and local coordinates
|
||||||
dif = self.range[1] - self.range[0]
|
dif = self.range[1] - self.range[0]
|
||||||
if dif == 0:
|
if dif == 0:
|
||||||
xscale = 1
|
xScale = 1
|
||||||
offset = 0
|
offset = 0
|
||||||
else:
|
else:
|
||||||
if axis == 0:
|
if axis == 0:
|
||||||
@ -806,10 +806,10 @@ class AxisItem(GraphicsWidget):
|
|||||||
## measure all text, make sure there's enough room
|
## measure all text, make sure there's enough room
|
||||||
if axis == 0:
|
if axis == 0:
|
||||||
textSize = np.sum([r.height() for r in textRects])
|
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:
|
else:
|
||||||
textSize = np.sum([r.width() for r in textRects])
|
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.
|
## If the strings are too crowded, stop drawing text now.
|
||||||
## We use three different crowding limits based on the number
|
## We use three different crowding limits based on the number
|
||||||
|
@ -112,6 +112,6 @@ class CurveArrow(CurvePoint):
|
|||||||
self.arrow = ArrowItem.ArrowItem(**opts)
|
self.arrow = ArrowItem.ArrowItem(**opts)
|
||||||
self.arrow.setParentItem(self)
|
self.arrow.setParentItem(self)
|
||||||
|
|
||||||
def setStyle(**opts):
|
def setStyle(self, **opts):
|
||||||
return self.arrow.setStyle(**opts)
|
return self.arrow.setStyle(**opts)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user