def __init__(self, image=None, **kargs): """ See :func:`setImage <pyqtgraph.ImageItem.setImage>` for all allowed initialization arguments. """ GraphicsObject.__init__(self) #self.pixmapItem = QtGui.QGraphicsPixmapItem(self) #self.qimage = QtGui.QImage() #self._pixmap = None self.image = None ## original image data self.qimage = None ## rendered image for display #self.clipMask = None self.paintMode = None #self.useWeave = True self.levels = None ## [min, max] or [[redMin, redMax], ...] self.lut = None #self.clipLevel = None self.drawKernel = None self.border = None if image is not None: self.setImage(image, **kargs) else: self.setOpts(**kargs)
def __init__(self, *args, **kargs): """ Forwards all arguments to :func:`setData <pyqtgraph.PlotCurveItem.setData>`. Some extra arguments are accepted as well: ============== ======================================================= **Arguments:** parent The parent GraphicsObject (optional) clickable If True, the item will emit sigClicked when it is clicked on. Defaults to False. ============== ======================================================= """ GraphicsObject.__init__(self, kargs.get('parent', None)) self.clear() self.path = None self.fillPath = None self.exportOpts = False self.antialias = False ## this is disastrous for performance. #self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) self.metaData = {} self.opts = { 'pen': fn.mkPen('w'), 'shadowPen': None, 'fillLevel': None, 'brush': None, } self.setClickable(kargs.get('clickable', False)) self.setData(*args, **kargs)
def __init__(self, y=None, x=None, fillLevel=None, copy=False, pen=None, shadowPen=None, brush=None, parent=None, clickable=False): GraphicsObject.__init__(self, parent) self.clear() self.path = None self.fillPath = None self.exportOpts = False self.antialias = False if y is not None: self.updateData(y, x) ## this is disastrous for performance. #self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) self.metaData = {} self.opts = { #'spectrumMode': False, #'logMode': [False, False], #'downsample': False, #'alphaHint': 1.0, #'alphaMode': False, 'pen': 'w', 'shadowPen': None, 'fillLevel': fillLevel, 'brush': brush, } self.setPen(pen) self.setShadowPen(shadowPen) self.setFillLevel(fillLevel) self.setBrush(brush) self.setClickable(clickable)
def __init__(self, imageFile, width=None, parentItem=None): self.enabled = True GraphicsObject.__init__(self) self.setImageFile(imageFile) if width is not None: s = float(width) / self.pixmap.width() self.scale(s, s) if parentItem is not None: self.setParentItem(parentItem) self.setOpacity(0.7)
def __init__(self, y=None, x=None, fillLevel=None, copy=False, pen=None, shadowPen=None, brush=None, parent=None, clickable=False): """ ============== ======================================================= **Arguments:** x, y (numpy arrays) Data to show pen Pen to use when drawing. Any single argument accepted by :func:`mkPen <pyqtgraph.mkPen>` is allowed. shadowPen Pen for drawing behind the primary pen. Usually this is used to emphasize the curve by providing a high-contrast border. Any single argument accepted by :func:`mkPen <pyqtgraph.mkPen>` is allowed. fillLevel (float or None) Fill the area 'under' the curve to *fillLevel* brush QBrush to use when filling. Any single argument accepted by :func:`mkBrush <pyqtgraph.mkBrush>` is allowed. clickable If True, the item will emit sigClicked when it is clicked on. ============== ======================================================= """ GraphicsObject.__init__(self, parent) self.clear() self.path = None self.fillPath = None self.exportOpts = False self.antialias = False if y is not None: self.updateData(y, x) ## this is disastrous for performance. #self.setCacheMode(QtGui.QGraphicsItem.DeviceCoordinateCache) self.metaData = {} self.opts = { #'spectrumMode': False, #'logMode': [False, False], #'downsample': False, #'alphaHint': 1.0, #'alphaMode': False, 'pen': 'w', 'shadowPen': None, 'fillLevel': fillLevel, 'brush': brush, } self.setPen(pen) self.setShadowPen(shadowPen) self.setFillLevel(fillLevel) self.setBrush(brush) self.setClickable(clickable)
def itemChange(self, change, value): ret = GraphicsObject.itemChange(self, change, value) if change == self.ItemParentHasChanged or change == self.ItemSceneHasChanged: #print "caught parent/scene change:", self.parentItem(), self.scene() self.updateView() elif change == self.ItemScenePositionHasChanged: self.setNewBounds() return ret
def __init__(self, bounds=None, parent=None): """ Initialization Arguments: #view: The view box whose bounds will be used as a reference vor this item's bounds bounds: QRectF with coordinates relative to view box. The default is QRectF(0,0,1,1), which means the item will have the same bounds as the view. """ GraphicsObject.__init__(self, parent) self.setFlag(self.ItemSendsScenePositionChanges) self._connectedView = None if bounds is None: self._bounds = QtCore.QRectF(0, 0, 1, 1) else: self._bounds = bounds self._boundingRect = None self.updateView()
def __init__(self, view, pos, color, movable=True, scale=10, pen='w'): self.movable = movable self.moving = False self.view = weakref.ref(view) self.scale = scale self.color = color self.pen = fn.mkPen(pen) self.hoverPen = fn.mkPen(255,255,0) self.currentPen = self.pen self.pg = QtGui.QPainterPath(QtCore.QPointF(0,0)) self.pg.lineTo(QtCore.QPointF(-scale/3**0.5, scale)) self.pg.lineTo(QtCore.QPointF(scale/3**0.5, scale)) self.pg.closeSubpath() GraphicsObject.__init__(self) self.setPos(pos[0], pos[1]) if self.movable: self.setZValue(1) else: self.setZValue(0)
def __init__(self, curve, index=0, pos=None, rotate=True): """Position can be set either as an index referring to the sample number or the position 0.0 - 1.0 If *rotate* is True, then the item rotates to match the tangent of the curve. """ GraphicsObject.__init__(self) #QObjectWorkaround.__init__(self) self._rotate = rotate self.curve = weakref.ref(curve) self.setParentItem(curve) self.setProperty('position', 0.0) self.setProperty('index', 0) if hasattr(self, 'ItemHasNoContents'): self.setFlags(self.flags() | self.ItemHasNoContents) if pos is not None: self.setPos(pos) else: self.setIndex(index)
def __init__(self, *args, **kargs): """ Accepts the same arguments as setData() """ GraphicsObject.__init__(self) self.data = None self.spots = [] self.bounds = [None, None] self.opts = {} self.spotsValid = False self._spotPixmap = None self.setPen(200,200,200) self.setBrush(100,100,150) self.setSymbol('o') self.setSize(7) self.setPxMode(True) self.setIdentical(False) self.setData(*args, **kargs)
def __init__(self, size, pxMode, brush, pen, data=None, symbol=None, image=None, index=None): GraphicsObject.__init__(self) self.pxMode = pxMode try: symbol = int(symbol) except: pass if symbol is None: symbol = 'o' ## circle by default elif isinstance(symbol, int): ## allow symbols specified by integer for easy iteration symbol = ['o', 's', 't', 'd', '+'][symbol] ####print 'SpotItem symbol: ', symbol self.data = data self.pen = pen self.brush = brush self.size = size self.index = index self.symbol = symbol #s2 = size/2. self.path = Symbols[symbol] if pxMode: ## pre-render an image of the spot and display this rather than redrawing every time. if image is None: self.pixmap = self.makeSpotImage(size, pen, brush, symbol) else: self.pixmap = image ## image is already provided (probably shared with other spots) self.setFlags(self.flags() | self.ItemIgnoresTransformations | self.ItemHasNoContents) self.pi = QtGui.QGraphicsPixmapItem(self.pixmap, self) self.pi.setPos(-0.5*size, -0.5*size) else: self.scale(size, size)
def __init__(self, *args): GraphicsObject.__init__(self, *args) if hasattr(self, "ItemHasNoContents"): self.setFlag(self.ItemHasNoContents)
def __init__(self, size, pxMode, brush, pen, data=None, symbol=None, image=None, index=None): GraphicsObject.__init__(self) self.pxMode = pxMode try: symbol = int(symbol) except: pass if symbol is None: symbol = 'o' ## circle by default elif isinstance(symbol, int): ## allow symbols specified by integer for easy iteration symbol = ['o', 's', 't', 'd', '+'][symbol] ####print 'SpotItem symbol: ', symbol self.data = data self.pen = pen self.brush = brush self.size = size self.index = index self.symbol = symbol #s2 = size/2. self.path = QtGui.QPainterPath() if symbol == 'o': self.path.addEllipse(QtCore.QRectF(-0.5, -0.5, 1, 1)) elif symbol == 's': self.path.addRect(QtCore.QRectF(-0.5, -0.5, 1, 1)) elif symbol == 't' or symbol == '^': self.path.moveTo(-0.5, -0.5) self.path.lineTo(0, 0.5) self.path.lineTo(0.5, -0.5) self.path.closeSubpath() #self.path.connectPath(self.path) elif symbol == 'd': self.path.moveTo(0., -0.5) self.path.lineTo(-0.4, 0.) self.path.lineTo(0, 0.5) self.path.lineTo(0.4, 0) self.path.closeSubpath() #self.path.connectPath(self.path) elif symbol == '+': self.path.moveTo(-0.5, -0.01) self.path.lineTo(-0.5, 0.01) self.path.lineTo(-0.01, 0.01) self.path.lineTo(-0.01, 0.5) self.path.lineTo(0.01, 0.5) self.path.lineTo(0.01, 0.01) self.path.lineTo(0.5, 0.01) self.path.lineTo(0.5, -0.01) self.path.lineTo(0.01, -0.01) self.path.lineTo(0.01, -0.5) self.path.lineTo(-0.01, -0.5) self.path.lineTo(-0.01, -0.01) self.path.closeSubpath() #self.path.connectPath(self.path) #elif symbol == 'x': else: raise Exception("Unknown spot symbol '%s' (type=%s)" % (str(symbol), str(type(symbol)))) #self.path.addEllipse(QtCore.QRectF(-0.5, -0.5, 1, 1)) if pxMode: ## pre-render an image of the spot and display this rather than redrawing every time. if image is None: self.pixmap = self.makeSpotImage(size, pen, brush, symbol) else: self.pixmap = image ## image is already provided (probably shared with other spots) self.setFlags(self.flags() | self.ItemIgnoresTransformations | self.ItemHasNoContents) self.pi = QtGui.QGraphicsPixmapItem(self.pixmap, self) self.pi.setPos(-0.5*size, -0.5*size) else: self.scale(size, size)
def setPos(self, *args): GraphicsObject.setPos(self, *args) self.setNewBounds()
def __init__(self, *args, **kargs): """ There are many different ways to create a PlotDataItem: **Data initialization arguments:** (x,y data only) =================================== ====================================== PlotDataItem(xValues, yValues) x and y values may be any sequence (including ndarray) of real numbers PlotDataItem(yValues) y values only -- x will be automatically set to range(len(y)) PlotDataItem(x=xValues, y=yValues) x and y given by keyword arguments PlotDataItem(ndarray(Nx2)) numpy array with shape (N, 2) where x=data[:,0] and y=data[:,1] =================================== ====================================== **Data initialization arguments:** (x,y data AND may include spot style) =========================== ========================================= PlotDataItem(recarray) numpy array with dtype=[('x', float), ('y', float), ...] PlotDataItem(list-of-dicts) [{'x': x, 'y': y, ...}, ...] PlotDataItem(dict-of-lists) {'x': [...], 'y': [...], ...} PlotDataItem(MetaArray) 1D array of Y values with X sepecified as axis values OR 2D array with a column 'y' and extra columns as needed. =========================== ========================================= **Line style keyword arguments:** ========== ================================================ pen pen to use for drawing line between points. Default is solid grey, 1px width. Use None to disable line drawing. May be any single argument accepted by :func:`mkPen() <pyqtgraph.mkPen>` shadowPen pen for secondary line to draw behind the primary line. disabled by default. May be any single argument accepted by :func:`mkPen() <pyqtgraph.mkPen>` fillLevel fill the area between the curve and fillLevel fillBrush fill to use when fillLevel is specified May be any single argument accepted by :func:`mkBrush() <pyqtgraph.mkBrush>` ========== ================================================ **Point style keyword arguments:** ============ ================================================ symbol (str) symbol to use for drawing points OR list of symbols, one per point. Default is no symbol. options are o, s, t, d, + symbolPen outline pen for drawing points OR list of pens, one per point May be any single argument accepted by :func:`mkPen() <pyqtgraph.mkPen>` symbolBrush brush for filling points OR list of brushes, one per point May be any single argument accepted by :func:`mkBrush() <pyqtgraph.mkBrush>` symbolSize diameter of symbols OR list of diameters pxMode (bool) If True, then symbolSize is specified in pixels. If False, then symbolSize is specified in data coordinates. ============ ================================================ **Optimization keyword arguments:** ========== ================================================ identical spots are all identical. The spot image will be rendered only once and repeated for every point decimate (int) decimate data ========== ================================================ **Meta-info keyword arguments:** ========== ================================================ name name of dataset. This would appear in a legend ========== ================================================ """ GraphicsObject.__init__(self) self.setFlag(self.ItemHasNoContents) self.xData = None self.yData = None self.xDisp = None self.yDisp = None #self.curves = [] #self.scatters = [] self.curve = PlotCurveItem() self.scatter = ScatterPlotItem() self.curve.setParentItem(self) self.scatter.setParentItem(self) self.curve.sigClicked.connect(self.curveClicked) self.scatter.sigClicked.connect(self.scatterClicked) #self.clear() self.opts = { 'fftMode': False, 'logMode': [False, False], 'downsample': False, 'alphaHint': 1.0, 'alphaMode': False, 'pen': (200,200,200), 'shadowPen': None, 'fillLevel': None, 'fillBrush': None, 'symbol': None, 'symbolSize': 10, 'symbolPen': (200,200,200), 'symbolBrush': (50, 50, 150), 'identical': False, 'data': None, } self.setData(*args, **kargs)
def __init__(self, size, pxMode, brush, pen, data=None, symbol=None, image=None, index=None): GraphicsObject.__init__(self) self.pxMode = pxMode try: symbol = int(symbol) except: pass if symbol is None: symbol = 'o' ## circle by default elif isinstance( symbol, int): ## allow symbols specified by integer for easy iteration symbol = ['o', 's', 't', 'd', '+'][symbol] ####print 'SpotItem symbol: ', symbol self.data = data self.pen = pen self.brush = brush self.size = size self.index = index self.symbol = symbol #s2 = size/2. self.path = QtGui.QPainterPath() if symbol == 'o': self.path.addEllipse(QtCore.QRectF(-0.5, -0.5, 1, 1)) elif symbol == 's': self.path.addRect(QtCore.QRectF(-0.5, -0.5, 1, 1)) elif symbol == 't' or symbol == '^': self.path.moveTo(-0.5, -0.5) self.path.lineTo(0, 0.5) self.path.lineTo(0.5, -0.5) self.path.closeSubpath() #self.path.connectPath(self.path) elif symbol == 'd': self.path.moveTo(0., -0.5) self.path.lineTo(-0.4, 0.) self.path.lineTo(0, 0.5) self.path.lineTo(0.4, 0) self.path.closeSubpath() #self.path.connectPath(self.path) elif symbol == '+': self.path.moveTo(-0.5, -0.01) self.path.lineTo(-0.5, 0.01) self.path.lineTo(-0.01, 0.01) self.path.lineTo(-0.01, 0.5) self.path.lineTo(0.01, 0.5) self.path.lineTo(0.01, 0.01) self.path.lineTo(0.5, 0.01) self.path.lineTo(0.5, -0.01) self.path.lineTo(0.01, -0.01) self.path.lineTo(0.01, -0.5) self.path.lineTo(-0.01, -0.5) self.path.lineTo(-0.01, -0.01) self.path.closeSubpath() #self.path.connectPath(self.path) #elif symbol == 'x': else: raise Exception("Unknown spot symbol '%s' (type=%s)" % (str(symbol), str(type(symbol)))) #self.path.addEllipse(QtCore.QRectF(-0.5, -0.5, 1, 1)) if pxMode: ## pre-render an image of the spot and display this rather than redrawing every time. if image is None: self.pixmap = self.makeSpotImage(size, pen, brush, symbol) else: self.pixmap = image ## image is already provided (probably shared with other spots) self.setFlags(self.flags() | self.ItemIgnoresTransformations | self.ItemHasNoContents) self.pi = QtGui.QGraphicsPixmapItem(self.pixmap, self) self.pi.setPos(-0.5 * size, -0.5 * size) else: self.scale(size, size)
def __init__(self, *args, **kargs): """ There are many different ways to create a PlotDataItem: **Data initialization arguments:** (x,y data only) =================================== ====================================== PlotDataItem(xValues, yValues) x and y values may be any sequence (including ndarray) of real numbers PlotDataItem(yValues) y values only -- x will be automatically set to range(len(y)) PlotDataItem(x=xValues, y=yValues) x and y given by keyword arguments PlotDataItem(ndarray(Nx2)) numpy array with shape (N, 2) where x=data[:,0] and y=data[:,1] =================================== ====================================== **Data initialization arguments:** (x,y data AND may include spot style) =========================== ========================================= PlotDataItem(recarray) numpy array with dtype=[('x', float), ('y', float), ...] PlotDataItem(list-of-dicts) [{'x': x, 'y': y, ...}, ...] PlotDataItem(dict-of-lists) {'x': [...], 'y': [...], ...} PlotDataItem(MetaArray) 1D array of Y values with X sepecified as axis values OR 2D array with a column 'y' and extra columns as needed. =========================== ========================================= **Line style keyword arguments:** ========== ================================================ pen pen to use for drawing line between points. Default is solid grey, 1px width. Use None to disable line drawing. May be any single argument accepted by :func:`mkPen() <pyqtgraph.mkPen>` shadowPen pen for secondary line to draw behind the primary line. disabled by default. May be any single argument accepted by :func:`mkPen() <pyqtgraph.mkPen>` fillLevel fill the area between the curve and fillLevel fillBrush fill to use when fillLevel is specified May be any single argument accepted by :func:`mkBrush() <pyqtgraph.mkBrush>` ========== ================================================ **Point style keyword arguments:** ============ ================================================ symbol (str) symbol to use for drawing points OR list of symbols, one per point. Default is no symbol. options are o, s, t, d, + symbolPen outline pen for drawing points OR list of pens, one per point May be any single argument accepted by :func:`mkPen() <pyqtgraph.mkPen>` symbolBrush brush for filling points OR list of brushes, one per point May be any single argument accepted by :func:`mkBrush() <pyqtgraph.mkBrush>` symbolSize diameter of symbols OR list of diameters pxMode (bool) If True, then symbolSize is specified in pixels. If False, then symbolSize is specified in data coordinates. ============ ================================================ **Optimization keyword arguments:** ========== ================================================ identical spots are all identical. The spot image will be rendered only once and repeated for every point decimate (int) decimate data ========== ================================================ **Meta-info keyword arguments:** ========== ================================================ name name of dataset. This would appear in a legend ========== ================================================ """ GraphicsObject.__init__(self) self.setFlag(self.ItemHasNoContents) self.xData = None self.yData = None self.xDisp = None self.yDisp = None #self.curves = [] #self.scatters = [] self.curve = PlotCurveItem() self.scatter = ScatterPlotItem() self.curve.setParentItem(self) self.scatter.setParentItem(self) self.curve.sigClicked.connect(self.curveClicked) self.scatter.sigClicked.connect(self.scatterClicked) #self.clear() self.opts = { 'fftMode': False, 'logMode': [False, False], 'downsample': False, 'alphaHint': 1.0, 'alphaMode': False, 'pen': (200, 200, 200), 'shadowPen': None, 'fillLevel': None, 'fillBrush': None, 'symbol': None, 'symbolSize': 10, 'symbolPen': (200, 200, 200), 'symbolBrush': (50, 50, 150), 'identical': False, 'data': None, } self.setData(*args, **kargs)