2013-12-22 07:08:39 +00:00
|
|
|
from ..Qt import QtGui
|
|
|
|
from .. import functions as fn
|
2012-11-29 03:56:31 +00:00
|
|
|
|
2013-12-22 07:08:39 +00:00
|
|
|
class FillBetweenItem(QtGui.QGraphicsPathItem):
|
2012-11-29 03:56:31 +00:00
|
|
|
"""
|
|
|
|
GraphicsItem filling the space between two PlotDataItems.
|
|
|
|
"""
|
|
|
|
def __init__(self, p1, p2, brush=None):
|
2013-12-22 07:08:39 +00:00
|
|
|
QtGui.QGraphicsPathItem.__init__(self)
|
2012-11-29 03:56:31 +00:00
|
|
|
self.p1 = p1
|
|
|
|
self.p2 = p2
|
|
|
|
p1.sigPlotChanged.connect(self.updatePath)
|
|
|
|
p2.sigPlotChanged.connect(self.updatePath)
|
|
|
|
if brush is not None:
|
2013-12-22 07:08:39 +00:00
|
|
|
self.setBrush(fn.mkBrush(brush))
|
2012-11-29 03:56:31 +00:00
|
|
|
self.setZValue(min(p1.zValue(), p2.zValue())-1)
|
|
|
|
self.updatePath()
|
|
|
|
|
|
|
|
def updatePath(self):
|
|
|
|
p1 = self.p1.curve.path
|
|
|
|
p2 = self.p2.curve.path
|
2013-12-22 07:08:39 +00:00
|
|
|
path = QtGui.QPainterPath()
|
2012-11-29 03:56:31 +00:00
|
|
|
path.addPolygon(p1.toSubpathPolygons()[0] + p2.toReversed().toSubpathPolygons()[0])
|
|
|
|
self.setPath(path)
|