Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Merge branch 'relative_imports' into develop
Browse files Browse the repository at this point in the history
This merge converts all absolute imports into relative imports throughout pyqtgraph.
This allows pyqtgraph to be embedded as a sub-package of larger packages.
  • Loading branch information
campagnola committed Dec 23, 2013
2 parents 3488910 + f21e0b8 commit a61b375
Show file tree
Hide file tree
Showing 144 changed files with 733 additions and 793 deletions.
21 changes: 7 additions & 14 deletions pyqtgraph/GraphicsScene/GraphicsScene.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
from pyqtgraph.Qt import QtCore, QtGui

from pyqtgraph.python2_3 import sortList
#try:
#from PyQt4 import QtOpenGL
#HAVE_OPENGL = True
#except ImportError:
#HAVE_OPENGL = False

from ..Qt import QtCore, QtGui
from ..python2_3 import sortList
import weakref
from pyqtgraph.Point import Point
import pyqtgraph.functions as fn
import pyqtgraph.ptime as ptime
from ..Point import Point
from .. import functions as fn
from .. import ptime as ptime
from .mouseEvents import *
import pyqtgraph.debug as debug
from . import exportDialog
from .. import debug as debug

if hasattr(QtCore, 'PYQT_VERSION'):
try:
Expand Down Expand Up @@ -552,6 +544,7 @@ def getContextMenus(self, event):

def showExportDialog(self):
if self.exportDialog is None:
from . import exportDialog
self.exportDialog = exportDialog.ExportDialog(self)
self.exportDialog.show(self.contextMenuItem)

Expand Down
18 changes: 10 additions & 8 deletions pyqtgraph/GraphicsScene/exportDialog.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from pyqtgraph.Qt import QtCore, QtGui, USE_PYSIDE
import pyqtgraph as pg
import pyqtgraph.exporters as exporters
from ..Qt import QtCore, QtGui, USE_PYSIDE
from .. import exporters as exporters
from .. import functions as fn
from ..graphicsItems.ViewBox import ViewBox
from ..graphicsItems.PlotItem import PlotItem

if USE_PYSIDE:
from . import exportDialogTemplate_pyside as exportDialogTemplate
Expand All @@ -18,7 +20,7 @@ def __init__(self, scene):
self.scene = scene

self.selectBox = QtGui.QGraphicsRectItem()
self.selectBox.setPen(pg.mkPen('y', width=3, style=QtCore.Qt.DashLine))
self.selectBox.setPen(fn.mkPen('y', width=3, style=QtCore.Qt.DashLine))
self.selectBox.hide()
self.scene.addItem(self.selectBox)

Expand All @@ -35,10 +37,10 @@ def __init__(self, scene):
def show(self, item=None):
if item is not None:
## Select next exportable parent of the item originally clicked on
while not isinstance(item, pg.ViewBox) and not isinstance(item, pg.PlotItem) and item is not None:
while not isinstance(item, ViewBox) and not isinstance(item, PlotItem) and item is not None:
item = item.parentItem()
## if this is a ViewBox inside a PlotItem, select the parent instead.
if isinstance(item, pg.ViewBox) and isinstance(item.parentItem(), pg.PlotItem):
if isinstance(item, ViewBox) and isinstance(item.parentItem(), PlotItem):
item = item.parentItem()
self.updateItemList(select=item)
self.setVisible(True)
Expand All @@ -64,9 +66,9 @@ def updateItemList(self, select=None):

def updateItemTree(self, item, treeItem, select=None):
si = None
if isinstance(item, pg.ViewBox):
if isinstance(item, ViewBox):
si = QtGui.QTreeWidgetItem(['ViewBox'])
elif isinstance(item, pg.PlotItem):
elif isinstance(item, PlotItem):
si = QtGui.QTreeWidgetItem(['Plot'])

if si is not None:
Expand Down
2 changes: 1 addition & 1 deletion pyqtgraph/GraphicsScene/exportDialogTemplate.ui
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<customwidget>
<class>ParameterTree</class>
<extends>QTreeWidget</extends>
<header>pyqtgraph.parametertree</header>
<header>..parametertree</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
33 changes: 21 additions & 12 deletions pyqtgraph/GraphicsScene/exportDialogTemplate_pyqt.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file './GraphicsScene/exportDialogTemplate.ui'
# Form implementation generated from reading ui file './pyqtgraph/GraphicsScene/exportDialogTemplate.ui'
#
# Created: Wed Jan 30 21:02:28 2013
# by: PyQt4 UI code generator 4.9.3
# Created: Mon Dec 23 10:10:52 2013
# by: PyQt4 UI code generator 4.10
#
# WARNING! All changes made in this file will be lost!

Expand All @@ -12,7 +12,16 @@
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
_fromUtf8 = lambda s: s
def _fromUtf8(s):
return s

try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)

class Ui_Form(object):
def setupUi(self, Form):
Expand Down Expand Up @@ -57,12 +66,12 @@ def setupUi(self, Form):
QtCore.QMetaObject.connectSlotsByName(Form)

def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Export", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("Form", "Item to export:", None, QtGui.QApplication.UnicodeUTF8))
self.label_2.setText(QtGui.QApplication.translate("Form", "Export format", None, QtGui.QApplication.UnicodeUTF8))
self.exportBtn.setText(QtGui.QApplication.translate("Form", "Export", None, QtGui.QApplication.UnicodeUTF8))
self.closeBtn.setText(QtGui.QApplication.translate("Form", "Close", None, QtGui.QApplication.UnicodeUTF8))
self.label_3.setText(QtGui.QApplication.translate("Form", "Export options", None, QtGui.QApplication.UnicodeUTF8))
self.copyBtn.setText(QtGui.QApplication.translate("Form", "Copy", None, QtGui.QApplication.UnicodeUTF8))
Form.setWindowTitle(_translate("Form", "Export", None))
self.label.setText(_translate("Form", "Item to export:", None))
self.label_2.setText(_translate("Form", "Export format", None))
self.exportBtn.setText(_translate("Form", "Export", None))
self.closeBtn.setText(_translate("Form", "Close", None))
self.label_3.setText(_translate("Form", "Export options", None))
self.copyBtn.setText(_translate("Form", "Copy", None))

from pyqtgraph.parametertree import ParameterTree
from ..parametertree import ParameterTree
8 changes: 4 additions & 4 deletions pyqtgraph/GraphicsScene/exportDialogTemplate_pyside.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file './GraphicsScene/exportDialogTemplate.ui'
# Form implementation generated from reading ui file './pyqtgraph/GraphicsScene/exportDialogTemplate.ui'
#
# Created: Wed Jan 30 21:02:28 2013
# by: pyside-uic 0.2.13 running on PySide 1.1.1
# Created: Mon Dec 23 10:10:53 2013
# by: pyside-uic 0.2.14 running on PySide 1.1.2
#
# WARNING! All changes made in this file will be lost!

Expand Down Expand Up @@ -60,4 +60,4 @@ def retranslateUi(self, Form):
self.label_3.setText(QtGui.QApplication.translate("Form", "Export options", None, QtGui.QApplication.UnicodeUTF8))
self.copyBtn.setText(QtGui.QApplication.translate("Form", "Copy", None, QtGui.QApplication.UnicodeUTF8))

from pyqtgraph.parametertree import ParameterTree
from ..parametertree import ParameterTree
6 changes: 3 additions & 3 deletions pyqtgraph/GraphicsScene/mouseEvents.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pyqtgraph.Point import Point
from pyqtgraph.Qt import QtCore, QtGui
from ..Point import Point
from ..Qt import QtCore, QtGui
import weakref
import pyqtgraph.ptime as ptime
from .. import ptime as ptime

class MouseDragEvent(object):
"""
Expand Down
5 changes: 2 additions & 3 deletions pyqtgraph/SRTTransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from .Qt import QtCore, QtGui
from .Point import Point
import numpy as np
import pyqtgraph as pg

class SRTTransform(QtGui.QTransform):
"""Transform that can always be represented as a combination of 3 matrices: scale * rotate * translate
Expand Down Expand Up @@ -77,7 +76,7 @@ def setFromQTransform(self, tr):
self.update()

def setFromMatrix4x4(self, m):
m = pg.SRTTransform3D(m)
m = SRTTransform3D(m)
angle, axis = m.getRotation()
if angle != 0 and (axis[0] != 0 or axis[1] != 0 or axis[2] != 1):
print("angle: %s axis: %s" % (str(angle), str(axis)))
Expand Down Expand Up @@ -256,4 +255,4 @@ def update():
w1.sigRegionChanged.connect(update)
#w2.sigRegionChanged.connect(update2)

from .SRTTransform3D import SRTTransform3D
26 changes: 13 additions & 13 deletions pyqtgraph/SRTTransform3D.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# -*- coding: utf-8 -*-
from .Qt import QtCore, QtGui
from .Vector import Vector
from .SRTTransform import SRTTransform
import pyqtgraph as pg
from .Transform3D import Transform3D
from .Vector import Vector
import numpy as np
import scipy.linalg

class SRTTransform3D(pg.Transform3D):
class SRTTransform3D(Transform3D):
"""4x4 Transform matrix that can always be represented as a combination of 3 matrices: scale * rotate * translate
This transform has no shear; angles are always preserved.
"""
def __init__(self, init=None):
pg.Transform3D.__init__(self)
Transform3D.__init__(self)
self.reset()
if init is None:
return
Expand Down Expand Up @@ -44,14 +44,14 @@ def __init__(self, init=None):


def getScale(self):
return pg.Vector(self._state['scale'])
return Vector(self._state['scale'])

def getRotation(self):
"""Return (angle, axis) of rotation"""
return self._state['angle'], pg.Vector(self._state['axis'])
return self._state['angle'], Vector(self._state['axis'])

def getTranslation(self):
return pg.Vector(self._state['pos'])
return Vector(self._state['pos'])

def reset(self):
self._state = {
Expand Down Expand Up @@ -169,7 +169,7 @@ def setFromMatrix(self, m):

def as2D(self):
"""Return a QTransform representing the x,y portion of this transform (if possible)"""
return pg.SRTTransform(self)
return SRTTransform(self)

#def __div__(self, t):
#"""A / B == B^-1 * A"""
Expand Down Expand Up @@ -202,11 +202,11 @@ def restoreState(self, state):
self.update()

def update(self):
pg.Transform3D.setToIdentity(self)
Transform3D.setToIdentity(self)
## modifications to the transform are multiplied on the right, so we need to reverse order here.
pg.Transform3D.translate(self, *self._state['pos'])
pg.Transform3D.rotate(self, self._state['angle'], *self._state['axis'])
pg.Transform3D.scale(self, *self._state['scale'])
Transform3D.translate(self, *self._state['pos'])
Transform3D.rotate(self, self._state['angle'], *self._state['axis'])
Transform3D.scale(self, *self._state['scale'])

def __repr__(self):
return str(self.saveState())
Expand Down Expand Up @@ -311,4 +311,4 @@ def update():
w1.sigRegionChanged.connect(update)
#w2.sigRegionChanged.connect(update2)

from .SRTTransform import SRTTransform
2 changes: 1 addition & 1 deletion pyqtgraph/ThreadsafeTimer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pyqtgraph.Qt import QtCore, QtGui
from .Qt import QtCore, QtGui

class ThreadsafeTimer(QtCore.QObject):
"""
Expand Down
4 changes: 2 additions & 2 deletions pyqtgraph/Transform3D.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from .Qt import QtCore, QtGui
import pyqtgraph as pg
from . import functions as fn
import numpy as np

class Transform3D(QtGui.QMatrix4x4):
Expand All @@ -26,7 +26,7 @@ def map(self, obj):
Extends QMatrix4x4.map() to allow mapping (3, ...) arrays of coordinates
"""
if isinstance(obj, np.ndarray) and obj.ndim >= 2 and obj.shape[0] in (2,3):
return pg.transformCoordinates(self, obj)
return fn.transformCoordinates(self, obj)
else:
return QtGui.QMatrix4x4.map(self, obj)

Expand Down
20 changes: 6 additions & 14 deletions pyqtgraph/canvas/Canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,21 @@
import sys, os
md = os.path.dirname(os.path.abspath(__file__))
sys.path = [os.path.dirname(md), os.path.join(md, '..', '..', '..')] + sys.path
#print md


#from pyqtgraph.GraphicsView import GraphicsView
#import pyqtgraph.graphicsItems as graphicsItems
#from pyqtgraph.PlotWidget import PlotWidget
from pyqtgraph.Qt import QtGui, QtCore, USE_PYSIDE
from pyqtgraph.graphicsItems.ROI import ROI
from pyqtgraph.graphicsItems.ViewBox import ViewBox
from pyqtgraph.graphicsItems.GridItem import GridItem
from ..Qt import QtGui, QtCore, USE_PYSIDE
from ..graphicsItems.ROI import ROI
from ..graphicsItems.ViewBox import ViewBox
from ..graphicsItems.GridItem import GridItem

if USE_PYSIDE:
from .CanvasTemplate_pyside import *
else:
from .CanvasTemplate_pyqt import *

#import DataManager
import numpy as np
from pyqtgraph import debug
#import pyqtgraph as pg
from .. import debug
import weakref
from .CanvasManager import CanvasManager
#import items
from .CanvasItem import CanvasItem, GroupCanvasItem

class Canvas(QtGui.QWidget):
Expand Down Expand Up @@ -605,4 +597,4 @@ def __init__(self, scalable=False):





Loading

0 comments on commit a61b375

Please sign in to comment.