Fix line width in a few examples
This commit is contained in:
parent
7e40b329e9
commit
52d7f2142c
@ -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)
|
||||
|
@ -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.
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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])
|
||||
|
Loading…
Reference in New Issue
Block a user