Commit b2cb6638 authored by Guillaume Poulin's avatar Guillaume Poulin
Browse files

merge inp

parents dfa2c8a5 88158946
......@@ -13,6 +13,7 @@ Contributors:
Michael Cristopher Hogg
Ulrich Leutner
Felix Schill
Guillaume Poulin
PyQt 4.7+ or PySide
# -*- coding: utf-8 -*-
Demonstrate use of GLLinePlotItem to draw cross-sections of a surface.
## Add path to library (just for examples; you do not need this)
import initExample
from pyqtgraph.Qt import QtCore, QtGui
import pyqtgraph.opengl as gl
import pyqtgraph as pg
import numpy as np
app = QtGui.QApplication([])
w = gl.GLViewWidget()
w.opts['distance'] = 40
w.setWindowTitle('pyqtgraph example: GLBarGraphItem')
gx = gl.GLGridItem()
gx.rotate(90, 0, 1, 0)
gx.translate(-10, 0, 10)
gy = gl.GLGridItem()
gy.rotate(90, 1, 0, 0)
gy.translate(0, -10, 10)
gz = gl.GLGridItem()
gz.translate(0, 0, 0)
# regular grid of starting positions
pos = np.mgrid[0:10, 0:10, 0:1].reshape(3,10,10).transpose(1,2,0)
# fixed widths, random heights
size = np.empty((10,10,3))
size[...,0:2] = 0.4
size[...,2] = np.random.normal(size=(10,10))
bg = gl.GLBarGraphItem(pos, size)
## Start Qt event loop unless running in interactive mode.
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
......@@ -15,6 +15,7 @@ class PlotData(object):
- removal of nan/inf values
- option for single value shared by entire column
- cached downsampling
- cached min / max / hasnan / isuniform
def __init__(self):
self.fields = {}
......@@ -316,7 +316,7 @@ def dbg():
Create a console window and begin watching for exceptions.
import console
from . import console
c = console.ConsoleWidget()
......@@ -205,7 +205,11 @@ class RemoteEventHandler(object):
fnkwds[k] = np.fromstring(byteData[ind], dtype=dtype).reshape(shape)
if len(fnkwds) == 0: ## need to do this because some functions do not allow keyword arguments.
result = obj(*fnargs)
result = obj(*fnargs)
print("Failed to call object %s: %d, %s" % (obj, len(fnargs), fnargs[1:]))
result = obj(*fnargs, **fnkwds)
......@@ -932,9 +936,9 @@ class ObjectProxy(object):
def __ilshift__(self, *args):
return self._getSpecialAttr('__ilshift__')(*args, _callSync='off')
#def __eq__(self, *args):
# return self._getSpecialAttr('__eq__')(*args)
def __eq__(self, *args):
return self._getSpecialAttr('__eq__')(*args)
def __ne__(self, *args):
return self._getSpecialAttr('__ne__')(*args)
......@@ -1010,6 +1014,10 @@ class ObjectProxy(object):
def __rmod__(self, *args):
return self._getSpecialAttr('__rmod__')(*args)
def __hash__(self):
## Required for python3 since __eq__ is defined.
return id(self)
class DeferredObjectProxy(ObjectProxy):
This class represents an attribute (or sub-attribute) of a proxied object.
......@@ -40,6 +40,7 @@ class GLGraphicsItem(QtCore.QObject):
self.__glOpts = {}
def setParentItem(self, item):
"""Set this item's parent in the scenegraph hierarchy."""
if self.__parent is not None:
if item is not None:
......@@ -98,9 +99,11 @@ class GLGraphicsItem(QtCore.QObject):
def parentItem(self):
"""Return a this item's parent in the scenegraph hierarchy."""
return self.__parent
def childItems(self):
"""Return a list of this item's children in the scenegraph hierarchy."""
return list(self.__children)
def _setView(self, v):
......@@ -124,10 +127,15 @@ class GLGraphicsItem(QtCore.QObject):
return self.__depthValue
def setTransform(self, tr):
"""Set the local transform for this object.
Must be a :class:`Transform3D <pyqtgraph.Transform3D>` instance. This transform
determines how the local coordinate system of the item is mapped to the coordinate
system of its parent."""
self.__transform = Transform3D(tr)
def resetTransform(self):
"""Reset this item's transform to an identity transformation."""
......@@ -148,9 +156,12 @@ class GLGraphicsItem(QtCore.QObject):
self.setTransform(tr * self.transform())
def transform(self):
"""Return this item's transform object."""
return self.__transform
def viewTransform(self):
"""Return the transform mapping this item's local coordinate system to the
view coordinate system."""
tr = self.__transform
p = self
while True:
......@@ -190,16 +201,24 @@ class GLGraphicsItem(QtCore.QObject):
def hide(self):
"""Hide this item.
This is equivalent to setVisible(False)."""
def show(self):
"""Make this item visible if it was previously hidden.
This is equivalent to setVisible(True)."""
def setVisible(self, vis):
"""Set the visibility of this item."""
self.__visible = vis
def visible(self):
"""Return True if the item is currently set to be visible.
Note that this does not guarantee that the item actually appears in the
view, as it may be obscured or outside of the current view area."""
return self.__visible
......@@ -237,6 +256,10 @@ class GLGraphicsItem(QtCore.QObject):
def update(self):
Indicates that this item needs to be redrawn, and schedules an update
with the view it is displayed in.
v = self.view()
if v is None:
......@@ -247,9 +247,9 @@ class MeshData(object):
return self._faceNormals
elif indexed == 'faces':
if self._faceNormalsIndexedByFaces is None:
norms = np.empty((self._faceNormals.shape[0], 3, 3))
norms[:] = self._faceNormals[:,np.newaxis,:]
self._faceNormalsIndexedByFaces = norms
norms = np.empty((self._faceNormals.shape[0], 3, 3))
norms[:] = self._faceNormals[:,np.newaxis,:]
self._faceNormalsIndexedByFaces = norms
return self._faceNormalsIndexedByFaces
raise Exception("Invalid indexing mode. Accepts: None, 'faces'")
......@@ -69,7 +69,11 @@ class GLMeshItem(GLGraphicsItem):
def shader(self):
return shaders.getShaderProgram(self.opts['shader'])
shader = self.opts['shader']
if isinstance(shader, shaders.ShaderProgram):
return shader
return shaders.getShaderProgram(shader)
def setColor(self, c):
"""Set the default color to use when no vertex or face colors are specified."""
......@@ -223,7 +223,7 @@ class Shader(object):
self.compiled = shaders.compileShader(self.code, self.shaderType)
except NullFunctionError:
raise Exception("This OpenGL implementation does not support shader programs; many features on pyqtgraph will not work.")
raise Exception("This OpenGL implementation does not support shader programs; many OpenGL features in pyqtgraph will not work.")
except RuntimeError as exc:
## Format compile errors a bit more nicely
if len(exc.args) == 3:
from pyqtgraph.Qt import QtCore, QtGui
from pyqtgraph.Qt import QtOpenGL
from OpenGL.GL import *
except ImportError:
......@@ -59,7 +60,6 @@ class RawImageWidget(QtGui.QWidget):
from OpenGL.GL import *
class RawImageGLWidget(QtOpenGL.QGLWidget):
Similar to RawImageWidget, but uses a GL widget to do all drawing.
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