diff --git a/examples/ViewBox.py b/examples/ViewBox.py index 3a66afe3..2ba2094c 100644 --- a/examples/ViewBox.py +++ b/examples/ViewBox.py @@ -42,7 +42,7 @@ class movableRect(QtGui.QGraphicsRectItem): self.setAcceptHoverEvents(True) def hoverEnterEvent(self, ev): self.savedPen = self.pen() - self.setPen(QtGui.QPen(QtGui.QColor(255, 255, 255))) + self.setPen(pg.mkPen(255, 255, 255)) ev.ignore() def hoverLeaveEvent(self, ev): self.setPen(self.savedPen) @@ -57,7 +57,7 @@ class movableRect(QtGui.QGraphicsRectItem): self.setPos(self.mapToParent(ev.pos()) - self.pressDelta) rect = movableRect(QtCore.QRectF(0, 0, 1, 1)) -rect.setPen(QtGui.QPen(QtGui.QColor(100, 200, 100))) +rect.setPen(pg.mkPen(100, 200, 100)) vb.addItem(rect) l.addItem(vb, 0, 1) diff --git a/pyqtgraph/graphicsItems/FillBetweenItem.py b/pyqtgraph/graphicsItems/FillBetweenItem.py index 6f21df56..a82af2da 100644 --- a/pyqtgraph/graphicsItems/FillBetweenItem.py +++ b/pyqtgraph/graphicsItems/FillBetweenItem.py @@ -7,7 +7,7 @@ class FillBetweenItem(QtGui.QGraphicsPathItem): """ GraphicsItem filling the space between two PlotDataItems. """ - def __init__(self, curve1=None, curve2=None, brush=None): + def __init__(self, curve1=None, curve2=None, brush=None, pen=None): QtGui.QGraphicsPathItem.__init__(self) self.curves = None if curve1 is not None and curve2 is not None: @@ -16,8 +16,15 @@ class FillBetweenItem(QtGui.QGraphicsPathItem): raise Exception("Must specify two curves to fill between.") if brush is not None: - self.setBrush(fn.mkBrush(brush)) + self.setBrush(brush) + self.setPen(pen) self.updatePath() + + def setBrush(self, *args, **kwds): + QtGui.QGraphicsPathItem.setBrush(self, fn.mkBrush(*args, **kwds)) + + def setPen(self, *args, **kwds): + QtGui.QGraphicsPathItem.setPen(self, fn.mkPen(*args, **kwds)) def setCurves(self, curve1, curve2): """Set the curves to fill between. diff --git a/pyqtgraph/graphicsItems/InfiniteLine.py b/pyqtgraph/graphicsItems/InfiniteLine.py index dfe2a4c1..2aff75f8 100644 --- a/pyqtgraph/graphicsItems/InfiniteLine.py +++ b/pyqtgraph/graphicsItems/InfiniteLine.py @@ -61,7 +61,6 @@ class InfiniteLine(GraphicsObject): pen = (200, 200, 100) self.setPen(pen) self.currentPen = self.pen - #self.setFlag(self.ItemSendsScenePositionChanges) def setMovable(self, m): """Set whether the line is movable by the user.""" @@ -176,7 +175,6 @@ class InfiniteLine(GraphicsObject): br = self.boundingRect() p.setPen(self.currentPen) p.drawLine(Point(br.right(), 0), Point(br.left(), 0)) - #p.drawRect(self.boundingRect()) def dataBounds(self, axis, frac=1.0, orthoRange=None): if axis == 0: @@ -184,25 +182,6 @@ class InfiniteLine(GraphicsObject): else: return (0,0) - #def mousePressEvent(self, ev): - #if self.movable and ev.button() == QtCore.Qt.LeftButton: - #ev.accept() - #self.pressDelta = self.mapToParent(ev.pos()) - QtCore.QPointF(*self.p) - #else: - #ev.ignore() - - #def mouseMoveEvent(self, ev): - #self.setPos(self.mapToParent(ev.pos()) - self.pressDelta) - ##self.emit(QtCore.SIGNAL('dragged'), self) - #self.sigDragged.emit(self) - #self.hasMoved = True - - #def mouseReleaseEvent(self, ev): - #if self.hasMoved and ev.button() == QtCore.Qt.LeftButton: - #self.hasMoved = False - ##self.emit(QtCore.SIGNAL('positionChangeFinished'), self) - #self.sigPositionChangeFinished.emit(self) - def mouseDragEvent(self, ev): if self.movable and ev.button() == QtCore.Qt.LeftButton: if ev.isStart(): @@ -214,15 +193,11 @@ class InfiniteLine(GraphicsObject): if not self.moving: return - #pressDelta = self.mapToParent(ev.buttonDownPos()) - Point(self.p) self.setPos(self.cursorOffset + self.mapToParent(ev.pos())) self.sigDragged.emit(self) if ev.isFinish(): self.moving = False self.sigPositionChangeFinished.emit(self) - #else: - #print ev - def mouseClickEvent(self, ev): if self.moving and ev.button() == QtCore.Qt.RightButton: @@ -248,30 +223,3 @@ class InfiniteLine(GraphicsObject): else: self.currentPen = self.pen self.update() - - #def hoverEnterEvent(self, ev): - #print "line hover enter" - #ev.ignore() - #self.updateHoverPen() - - #def hoverMoveEvent(self, ev): - #print "line hover move" - #ev.ignore() - #self.updateHoverPen() - - #def hoverLeaveEvent(self, ev): - #print "line hover leave" - #ev.ignore() - #self.updateHoverPen(False) - - #def updateHoverPen(self, hover=None): - #if hover is None: - #scene = self.scene() - #hover = scene.claimEvent(self, QtCore.Qt.LeftButton, scene.Drag) - - #if hover: - #self.currentPen = fn.mkPen(255, 0,0) - #else: - #self.currentPen = self.pen - #self.update() - diff --git a/pyqtgraph/imageview/ImageView.py b/pyqtgraph/imageview/ImageView.py index c7c3206e..5836a39f 100644 --- a/pyqtgraph/imageview/ImageView.py +++ b/pyqtgraph/imageview/ImageView.py @@ -24,9 +24,7 @@ from ..graphicsItems.ROI import * from ..graphicsItems.LinearRegionItem import * from ..graphicsItems.InfiniteLine import * from ..graphicsItems.ViewBox import * -#from widgets import ROI import sys -#from numpy import ndarray from .. import ptime as ptime import numpy as np from .. import debug as debug @@ -38,12 +36,6 @@ try: except ImportError: from numpy import nanmin, nanmax -#try: - #from .. import metaarray as metaarray - #HAVE_METAARRAY = True -#except: - #HAVE_METAARRAY = False - class PlotROI(ROI): def __init__(self, size): @@ -119,13 +111,13 @@ class ImageView(QtGui.QWidget): self.view.addItem(self.roi) self.roi.hide() self.normRoi = PlotROI(10) - self.normRoi.setPen(QtGui.QPen(QtGui.QColor(255,255,0))) + self.normRoi.setPen('y') self.normRoi.setZValue(20) self.view.addItem(self.normRoi) self.normRoi.hide() self.roiCurve = self.ui.roiPlot.plot() self.timeLine = InfiniteLine(0, movable=True) - self.timeLine.setPen(QtGui.QPen(QtGui.QColor(255, 255, 0, 200))) + self.timeLine.setPen((255, 255, 0, 200)) self.timeLine.setZValue(1) self.ui.roiPlot.addItem(self.timeLine) self.ui.splitter.setSizes([self.height()-35, 35])