Commit f6307344 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

Switching to relative imports to allow pyqtgraph to be imported under other names.

finished top-level files and graphicsItems
parent 34889108
from pyqtgraph.Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
from .UIGraphicsItem import * from .UIGraphicsItem import *
import numpy as np import numpy as np
from pyqtgraph.Point import Point from ..Point import Point
import pyqtgraph.functions as fn from .. import functions as fn
__all__ = ['GridItem'] __all__ = ['GridItem']
class GridItem(UIGraphicsItem): class GridItem(UIGraphicsItem):
......
...@@ -3,8 +3,8 @@ GraphicsWidget displaying an image histogram along with gradient editor. Can be ...@@ -3,8 +3,8 @@ GraphicsWidget displaying an image histogram along with gradient editor. Can be
""" """
from pyqtgraph.Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
import pyqtgraph.functions as fn from .. import functions as fn
from .GraphicsWidget import GraphicsWidget from .GraphicsWidget import GraphicsWidget
from .ViewBox import * from .ViewBox import *
from .GradientEditorItem import * from .GradientEditorItem import *
...@@ -12,10 +12,10 @@ from .LinearRegionItem import * ...@@ -12,10 +12,10 @@ from .LinearRegionItem import *
from .PlotDataItem import * from .PlotDataItem import *
from .AxisItem import * from .AxisItem import *
from .GridItem import * from .GridItem import *
from pyqtgraph.Point import Point from ..Point import Point
import pyqtgraph.functions as fn from .. import functions as fn
import numpy as np import numpy as np
import pyqtgraph.debug as debug from .. import debug as debug
__all__ = ['HistogramLUTItem'] __all__ = ['HistogramLUTItem']
......
from pyqtgraph.Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
import numpy as np import numpy as np
import collections import collections
import pyqtgraph.functions as fn from .. import functions as fn
import pyqtgraph.debug as debug from .. import debug as debug
from .GraphicsObject import GraphicsObject from .GraphicsObject import GraphicsObject
__all__ = ['ImageItem'] __all__ = ['ImageItem']
......
from pyqtgraph.Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
from pyqtgraph.Point import Point from ..Point import Point
from .GraphicsObject import GraphicsObject from .GraphicsObject import GraphicsObject
import pyqtgraph.functions as fn from .. import functions as fn
import numpy as np import numpy as np
import weakref import weakref
......
from .GraphicsObject import * from .GraphicsObject import *
import pyqtgraph.functions as fn from .. import functions as fn
from pyqtgraph.Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
class IsocurveItem(GraphicsObject): class IsocurveItem(GraphicsObject):
......
from pyqtgraph.Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
from .GraphicsObject import GraphicsObject from .GraphicsObject import GraphicsObject
__all__ = ['ItemGroup'] __all__ = ['ItemGroup']
......
from pyqtgraph.Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
import pyqtgraph.functions as fn from .. import functions as fn
import pyqtgraph as pg
from .GraphicsWidget import GraphicsWidget from .GraphicsWidget import GraphicsWidget
from .GraphicsWidgetAnchor import GraphicsWidgetAnchor from .GraphicsWidgetAnchor import GraphicsWidgetAnchor
from .. import getConfigOption
__all__ = ['LabelItem'] __all__ = ['LabelItem']
...@@ -54,7 +54,7 @@ class LabelItem(GraphicsWidget, GraphicsWidgetAnchor): ...@@ -54,7 +54,7 @@ class LabelItem(GraphicsWidget, GraphicsWidgetAnchor):
color = self.opts['color'] color = self.opts['color']
if color is None: if color is None:
color = pg.getConfigOption('foreground') color = getConfigOption('foreground')
color = fn.mkColor(color) color = fn.mkColor(color)
optlist.append('color: #' + fn.colorStr(color)[:6]) optlist.append('color: #' + fn.colorStr(color)[:6])
if 'size' in opts: if 'size' in opts:
......
...@@ -3,8 +3,9 @@ from .LabelItem import LabelItem ...@@ -3,8 +3,9 @@ from .LabelItem import LabelItem
from ..Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
from .. import functions as fn from .. import functions as fn
from ..Point import Point from ..Point import Point
from .ScatterPlotItem import ScatterPlotItem
from .PlotDataItem import PlotDataItem
from .GraphicsWidgetAnchor import GraphicsWidgetAnchor from .GraphicsWidgetAnchor import GraphicsWidgetAnchor
import pyqtgraph as pg
__all__ = ['LegendItem'] __all__ = ['LegendItem']
class LegendItem(GraphicsWidget, GraphicsWidgetAnchor): class LegendItem(GraphicsWidget, GraphicsWidgetAnchor):
...@@ -152,21 +153,21 @@ class ItemSample(GraphicsWidget): ...@@ -152,21 +153,21 @@ class ItemSample(GraphicsWidget):
p.setPen(fn.mkPen(None)) p.setPen(fn.mkPen(None))
p.drawPolygon(QtGui.QPolygonF([QtCore.QPointF(2,18), QtCore.QPointF(18,2), QtCore.QPointF(18,18)])) p.drawPolygon(QtGui.QPolygonF([QtCore.QPointF(2,18), QtCore.QPointF(18,2), QtCore.QPointF(18,18)]))
if not isinstance(self.item, pg.ScatterPlotItem): if not isinstance(self.item, ScatterPlotItem):
p.setPen(fn.mkPen(opts['pen'])) p.setPen(fn.mkPen(opts['pen']))
p.drawLine(2, 18, 18, 2) p.drawLine(2, 18, 18, 2)
symbol = opts.get('symbol', None) symbol = opts.get('symbol', None)
if symbol is not None: if symbol is not None:
if isinstance(self.item, pg.PlotDataItem): if isinstance(self.item, PlotDataItem):
opts = self.item.scatter.opts opts = self.item.scatter.opts
pen = pg.mkPen(opts['pen']) pen = fn.mkPen(opts['pen'])
brush = pg.mkBrush(opts['brush']) brush = fn.mkBrush(opts['brush'])
size = opts['size'] size = opts['size']
p.translate(10,10) p.translate(10,10)
path = pg.graphicsItems.ScatterPlotItem.drawSymbol(p, symbol, size, pen, brush) path = ScatterPlotItem.drawSymbol(p, symbol, size, pen, brush)
......
from pyqtgraph.Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
from .UIGraphicsItem import UIGraphicsItem from .UIGraphicsItem import UIGraphicsItem
from .InfiniteLine import InfiniteLine from .InfiniteLine import InfiniteLine
import pyqtgraph.functions as fn from .. import functions as fn
import pyqtgraph.debug as debug from .. import debug as debug
__all__ = ['LinearRegionItem'] __all__ = ['LinearRegionItem']
......
from pyqtgraph.Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
try: try:
from pyqtgraph.Qt import QtOpenGL from ..Qt import QtOpenGL
HAVE_OPENGL = True HAVE_OPENGL = True
except: except:
HAVE_OPENGL = False HAVE_OPENGL = False
import numpy as np import numpy as np
from .GraphicsObject import GraphicsObject from .GraphicsObject import GraphicsObject
import pyqtgraph.functions as fn from .. import functions as fn
from pyqtgraph import debug from ..Point import Point
from pyqtgraph.Point import Point
import pyqtgraph as pg
import struct, sys import struct, sys
from .. import getConfigOption
from .. import debug
__all__ = ['PlotCurveItem'] __all__ = ['PlotCurveItem']
class PlotCurveItem(GraphicsObject): class PlotCurveItem(GraphicsObject):
...@@ -65,7 +65,7 @@ class PlotCurveItem(GraphicsObject): ...@@ -65,7 +65,7 @@ class PlotCurveItem(GraphicsObject):
'brush': None, 'brush': None,
'stepMode': False, 'stepMode': False,
'name': None, 'name': None,
'antialias': pg.getConfigOption('antialias'), 'antialias': getConfigOption('antialias'),
'connect': 'all', 'connect': 'all',
'mouseWidth': 8, # width of shape responding to mouse click 'mouseWidth': 8, # width of shape responding to mouse click
} }
...@@ -399,13 +399,13 @@ class PlotCurveItem(GraphicsObject): ...@@ -399,13 +399,13 @@ class PlotCurveItem(GraphicsObject):
self._mouseShape = None self._mouseShape = None
return self.path return self.path
@pg.debug.warnOnException ## raising an exception here causes crash @debug.warnOnException ## raising an exception here causes crash
def paint(self, p, opt, widget): def paint(self, p, opt, widget):
profiler = debug.Profiler() profiler = debug.Profiler()
if self.xData is None: if self.xData is None:
return return
if HAVE_OPENGL and pg.getConfigOption('enableExperimental') and isinstance(widget, QtOpenGL.QGLWidget): if HAVE_OPENGL and getConfigOption('enableExperimental') and isinstance(widget, QtOpenGL.QGLWidget):
self.paintGL(p, opt, widget) self.paintGL(p, opt, widget)
return return
......
import pyqtgraph.metaarray as metaarray from .. import metaarray as metaarray
from pyqtgraph.Qt import QtCore from ..Qt import QtCore
from .GraphicsObject import GraphicsObject from .GraphicsObject import GraphicsObject
from .PlotCurveItem import PlotCurveItem from .PlotCurveItem import PlotCurveItem
from .ScatterPlotItem import ScatterPlotItem from .ScatterPlotItem import ScatterPlotItem
import numpy as np import numpy as np
import pyqtgraph.functions as fn from .. import functions as fn
import pyqtgraph.debug as debug from .. import debug as debug
import pyqtgraph as pg from .. import getConfigOption
class PlotDataItem(GraphicsObject): class PlotDataItem(GraphicsObject):
""" """
...@@ -152,7 +152,7 @@ class PlotDataItem(GraphicsObject): ...@@ -152,7 +152,7 @@ class PlotDataItem(GraphicsObject):
'symbolBrush': (50, 50, 150), 'symbolBrush': (50, 50, 150),
'pxMode': True, 'pxMode': True,
'antialias': pg.getConfigOption('antialias'), 'antialias': getConfigOption('antialias'),
'pointMode': None, 'pointMode': None,
'downsample': 1, 'downsample': 1,
......
...@@ -12,16 +12,16 @@ The ROI class is meant to serve as the base for more specific types; see several ...@@ -12,16 +12,16 @@ The ROI class is meant to serve as the base for more specific types; see several
of how to build an ROI at the bottom of the file. of how to build an ROI at the bottom of the file.
""" """
from pyqtgraph.Qt import QtCore, QtGui from ..Qt import QtCore, QtGui
#if not hasattr(QtCore, 'Signal'): #if not hasattr(QtCore, 'Signal'):
#QtCore.Signal = QtCore.pyqtSignal #QtCore.Signal = QtCore.pyqtSignal
import numpy as np import numpy as np
from numpy.linalg import norm from numpy.linalg import norm
import scipy.ndimage as ndimage import scipy.ndimage as ndimage
from pyqtgraph.Point import * from ..Point import *
from pyqtgraph.SRTTransform import SRTTransform from ..SRTTransform import SRTTransform
from math import cos, sin from math import cos, sin
import pyqtgraph.functions as fn from .. import functions as fn
from .GraphicsObject import GraphicsObject from .GraphicsObject import GraphicsObject
from .UIGraphicsItem import UIGraphicsItem from .UIGraphicsItem import UIGraphicsItem
......
from pyqtgraph.Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
from .GraphicsObject import * from .GraphicsObject import *
from .GraphicsWidgetAnchor import * from .GraphicsWidgetAnchor import *
from .TextItem import TextItem from .TextItem import TextItem
import numpy as np import numpy as np
import pyqtgraph.functions as fn from .. import functions as fn
import pyqtgraph as pg from .. import getConfigOption
__all__ = ['ScaleBar'] __all__ = ['ScaleBar']
...@@ -19,7 +19,7 @@ class ScaleBar(GraphicsObject, GraphicsWidgetAnchor): ...@@ -19,7 +19,7 @@ class ScaleBar(GraphicsObject, GraphicsWidgetAnchor):
self.setAcceptedMouseButtons(QtCore.Qt.NoButton) self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
if brush is None: if brush is None:
brush = pg.getConfigOption('foreground') brush = getConfigOption('foreground')
self.brush = fn.mkBrush(brush) self.brush = fn.mkBrush(brush)
self.pen = fn.mkPen(pen) self.pen = fn.mkPen(pen)
self._width = width self._width = width
......
from pyqtgraph.Qt import QtGui, QtCore, USE_PYSIDE from ..Qt import QtGui, QtCore, USE_PYSIDE
from pyqtgraph.Point import Point from ..Point import Point
import pyqtgraph.functions as fn from .. import functions as fn
from .GraphicsItem import GraphicsItem from .GraphicsItem import GraphicsItem
from .GraphicsObject import GraphicsObject from .GraphicsObject import GraphicsObject
import numpy as np import numpy as np
import weakref import weakref
import pyqtgraph.debug as debug from .. import getConfigOption
from pyqtgraph.pgcollections import OrderedDict from .. import debug as debug
import pyqtgraph as pg from ..pgcollections import OrderedDict
#import pyqtgraph as pg from .. import debug
__all__ = ['ScatterPlotItem', 'SpotItem'] __all__ = ['ScatterPlotItem', 'SpotItem']
...@@ -233,7 +233,7 @@ class ScatterPlotItem(GraphicsObject): ...@@ -233,7 +233,7 @@ class ScatterPlotItem(GraphicsObject):
self.opts = { self.opts = {
'pxMode': True, 'pxMode': True,
'useCache': True, ## If useCache is False, symbols are re-drawn on every paint. 'useCache': True, ## If useCache is False, symbols are re-drawn on every paint.
'antialias': pg.getConfigOption('antialias'), 'antialias': getConfigOption('antialias'),
'name': None, 'name': None,
} }
...@@ -693,7 +693,7 @@ class ScatterPlotItem(GraphicsObject): ...@@ -693,7 +693,7 @@ class ScatterPlotItem(GraphicsObject):
GraphicsObject.setExportMode(self, *args, **kwds) GraphicsObject.setExportMode(self, *args, **kwds)
self.invalidate() self.invalidate()
@pg.debug.warnOnException ## raising an exception here causes crash @debug.warnOnException ## raising an exception here causes crash
def paint(self, p, *args): def paint(self, p, *args):
#p.setPen(fn.mkPen('r')) #p.setPen(fn.mkPen('r'))
......
from pyqtgraph.Qt import QtCore, QtGui from ..Qt import QtCore, QtGui
import pyqtgraph as pg from ..Point import Point
from .UIGraphicsItem import * from .UIGraphicsItem import *
import pyqtgraph.functions as fn from .. import functions as fn
class TextItem(UIGraphicsItem): class TextItem(UIGraphicsItem):
""" """
...@@ -27,7 +27,7 @@ class TextItem(UIGraphicsItem): ...@@ -27,7 +27,7 @@ class TextItem(UIGraphicsItem):
#*angle* Angle in degrees to rotate text (note that the rotation assigned in this item's #*angle* Angle in degrees to rotate text (note that the rotation assigned in this item's
#transformation will be ignored) #transformation will be ignored)
self.anchor = pg.Point(anchor) self.anchor = Point(anchor)
#self.angle = 0 #self.angle = 0
UIGraphicsItem.__init__(self) UIGraphicsItem.__init__(self)
self.textItem = QtGui.QGraphicsTextItem() self.textItem = QtGui.QGraphicsTextItem()
...@@ -38,13 +38,13 @@ class TextItem(UIGraphicsItem): ...@@ -38,13 +38,13 @@ class TextItem(UIGraphicsItem):
self.setText(text, color) self.setText(text, color)
else: else:
self.setHtml(html) self.setHtml(html)
self.fill = pg.mkBrush(fill) self.fill = fn.mkBrush(fill)
self.border = pg.mkPen(border) self.border = fn.mkPen(border)
self.rotate(angle) self.rotate(angle)
self.setFlag(self.ItemIgnoresTransformations) ## This is required to keep the text unscaled inside the viewport self.setFlag(self.ItemIgnoresTransformations) ## This is required to keep the text unscaled inside the viewport
def setText(self, text, color=(200,200,200)): def setText(self, text, color=(200,200,200)):
color = pg.mkColor(color) color = fn.mkColor(color)
self.textItem.setDefaultTextColor(color) self.textItem.setDefaultTextColor(color)
self.textItem.setPlainText(text) self.textItem.setPlainText(text)
self.updateText() self.updateText()
...@@ -89,7 +89,7 @@ class TextItem(UIGraphicsItem): ...@@ -89,7 +89,7 @@ class TextItem(UIGraphicsItem):
#br = self.textItem.mapRectToParent(self.textItem.boundingRect()) #br = self.textItem.mapRectToParent(self.textItem.boundingRect())
self.textItem.setPos(0,0) self.textItem.setPos(0,0)
br = self.textItem.boundingRect() br = self.textItem.boundingRect()
apos = self.textItem.mapToParent(pg.Point(br.width()*self.anchor.x(), br.height()*self.anchor.y())) apos = self.textItem.mapToParent(Point(br.width()*self.anchor.x(), br.height()*self.anchor.y()))
#print br, apos #print br, apos
self.textItem.setPos(-apos.x(), -apos.y()) self.textItem.setPos(-apos.x(), -apos.y())
......
from pyqtgraph.Qt import QtGui, QtCore, USE_PYSIDE from ..Qt import QtGui, QtCore, USE_PYSIDE
import weakref import weakref
from .GraphicsObject import GraphicsObject from .GraphicsObject import GraphicsObject
if not USE_PYSIDE: if not USE_PYSIDE:
......
...@@ -3,8 +3,8 @@ if __name__ == '__main__': ...@@ -3,8 +3,8 @@ if __name__ == '__main__':
path = os.path.abspath(os.path.dirname(__file__)) path = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(path, '..', '..')) sys.path.insert(0, os.path.join(path, '..', '..'))
from pyqtgraph.Qt import QtGui, QtCore from ..Qt import QtGui, QtCore
import pyqtgraph.functions as fn from .. import functions as fn
import weakref import weakref
from .UIGraphicsItem import UIGraphicsItem from .UIGraphicsItem import UIGraphicsItem
...@@ -96,18 +96,4 @@ class VTickGroup(UIGraphicsItem): ...@@ -96,18 +96,4 @@ class VTickGroup(UIGraphicsItem):
p.setPen(self.pen) p.setPen(self.pen)
p.drawPath(self.path) p.drawPath(self.path)
if __name__ == '__main__':
app = QtGui.QApplication([])
import pyqtgraph as pg
vt = VTickGroup([1,3,4,7,9], [0.8, 1.0])
p = pg.plot()
p.addItem(vt)
if sys.flags.interactive == 0:
app.exec_()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment