Commit 4d1a5ded authored by Luke Campagnola's avatar Luke Campagnola
Browse files

bugfixes

MetaArray update - no longer subclass of ndarray
parent 194f90aa
......@@ -16,11 +16,12 @@ class GraphicsWidget(GraphicsItem, QtGui.QGraphicsWidget):
GraphicsItem.__init__(self)
GraphicsScene.registerObject(self) ## workaround for pyqt bug in graphicsscene.items()
def itemChange(self, change, value):
ret = QtGui.QGraphicsWidget.itemChange(self, change, value)
if change in [self.ItemParentHasChanged, self.ItemSceneHasChanged]:
self._updateView()
return ret
## Removed because this causes segmentation faults. Don't know why.
# def itemChange(self, change, value):
# ret = QtGui.QGraphicsWidget.itemChange(self, change, value) ## segv occurs here
# if change in [self.ItemParentHasChanged, self.ItemSceneHasChanged]:
# self._updateView()
# return ret
#def getMenu(self):
#pass
......
......@@ -22,7 +22,7 @@ class GridItem(UIGraphicsItem):
def viewRangeChanged(self):
GraphicsObject.viewRangeChanged(self)
UIGraphicsItem.viewRangeChanged(self)
self.picture = None
#UIGraphicsItem.viewRangeChanged(self)
#self.update()
......
try:
import metaarray
HAVE_METAARRAY = True
except:
HAVE_METAARRAY = False
import pyqtgraph.metaarray as metaarray
from pyqtgraph.Qt import QtCore
from .GraphicsObject import GraphicsObject
from .PlotCurveItem import PlotCurveItem
......@@ -252,6 +247,7 @@ class PlotDataItem(GraphicsObject):
if len(args) == 1:
data = args[0]
dt = dataType(data)
print "plot:", dt, type(data)
if dt == 'empty':
pass
elif dt == 'listOfValues':
......@@ -493,9 +489,10 @@ def dataType(obj):
return 'empty'
if isSequence(obj):
first = obj[0]
if isinstance(obj, np.ndarray):
if HAVE_METAARRAY and isinstance(obj, metaarray.MetaArray):
return 'MetaArray'
if isinstance(obj, metaarray.MetaArray):
return 'MetaArray'
elif isinstance(obj, np.ndarray):
if obj.ndim == 1:
if obj.dtype.names is None:
return 'listOfValues'
......@@ -514,7 +511,7 @@ def dataType(obj):
def isSequence(obj):
return isinstance(obj, list) or isinstance(obj, np.ndarray)
return isinstance(obj, list) or isinstance(obj, np.ndarray) or isinstance(obj, metaarray.MetaArray)
......
......@@ -29,6 +29,13 @@ import pyqtgraph.debug as debug
from pyqtgraph.SignalProxy import SignalProxy
try:
import pyqtgraph.metaarray as metaarray
HAVE_METAARRAY = True
except:
HAVE_METAARRAY = False
class PlotROI(ROI):
def __init__(self, size):
ROI.__init__(self, pos=[0,0], size=size, scaleSnap=True, translateSnap=True)
......@@ -188,6 +195,9 @@ class ImageView(QtGui.QWidget):
"""
prof = debug.Profiler('ImageView.setImage', disabled=True)
if HAVE_METAARRAY and isinstance(img, metaarray.MetaArray):
img = img.asarray()
if not isinstance(img, np.ndarray):
raise Exception("Image must be specified as ndarray.")
self.image = img
......
This diff is collapsed.
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