From e53c2165e6cde30784bb28f7fb51af197811ba1e Mon Sep 17 00:00:00 2001 From: Luke Campagnola <> Date: Tue, 12 Jun 2012 16:02:48 -0400 Subject: [PATCH] Bugfixes: - added workaround for Qt bug: https://bugreports.qt-project.org/browse/QTBUG-18616 - allow pxMode argument in PlotDataItem.setData() --- graphicsItems/GraphicsObject.py | 7 +++++++ graphicsItems/GraphicsWidget.py | 7 +++++++ graphicsItems/PlotDataItem.py | 9 +++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/graphicsItems/GraphicsObject.py b/graphicsItems/GraphicsObject.py index 54df1156..f932f1ce 100644 --- a/graphicsItems/GraphicsObject.py +++ b/graphicsItems/GraphicsObject.py @@ -19,3 +19,10 @@ class GraphicsObject(GraphicsItem, QtGui.QGraphicsObject): return ret + + def setParentItem(self, parent): + ## Workaround for Qt bug: https://bugreports.qt-project.org/browse/QTBUG-18616 + pscene = parent.scene() + if pscene is not None and self.scene() is not pscene: + pscene.addItem(self) + return QtGui.QGraphicsObject.setParentItem(self, parent) diff --git a/graphicsItems/GraphicsWidget.py b/graphicsItems/GraphicsWidget.py index bd9c0396..0af64f3f 100644 --- a/graphicsItems/GraphicsWidget.py +++ b/graphicsItems/GraphicsWidget.py @@ -52,3 +52,10 @@ class GraphicsWidget(GraphicsItem, QtGui.QGraphicsWidget): return p + + def setParentItem(self, parent): + ## Workaround for Qt bug: https://bugreports.qt-project.org/browse/QTBUG-18616 + pscene = parent.scene() + if pscene is not None and self.scene() is not pscene: + pscene.addItem(self) + return QtGui.QGraphicsWidget.setParentItem(self, parent) diff --git a/graphicsItems/PlotDataItem.py b/graphicsItems/PlotDataItem.py index 572c2c65..5f6f4ea6 100644 --- a/graphicsItems/PlotDataItem.py +++ b/graphicsItems/PlotDataItem.py @@ -128,7 +128,7 @@ class PlotDataItem(GraphicsObject): 'symbolSize': 10, 'symbolPen': (200,200,200), 'symbolBrush': (50, 50, 150), - 'identical': False, + 'pxMode': True, 'data': None, } @@ -355,7 +355,7 @@ class PlotDataItem(GraphicsObject): curveArgs[v] = self.opts[k] scatterArgs = {} - for k,v in [('symbolPen','pen'), ('symbolBrush','brush'), ('symbol','symbol'), ('symbolSize', 'size'), ('data', 'data')]: + for k,v in [('symbolPen','pen'), ('symbolBrush','brush'), ('symbol','symbol'), ('symbolSize', 'size'), ('data', 'data'), ('pxMode', 'pxMode')]: if k in self.opts: scatterArgs[v] = self.opts[k] @@ -371,6 +371,7 @@ class PlotDataItem(GraphicsObject): #self.curves.append(curve) if scatterArgs['symbol'] is not None: + print scatterArgs self.scatter.setData(x=x, y=y, **scatterArgs) self.scatter.show() else: @@ -489,7 +490,7 @@ def dataType(obj): if isSequence(obj): first = obj[0] - if isinstance(obj, metaarray.MetaArray): + if (hasattr(obj, 'implements') and obj.implements('MetaArray')): return 'MetaArray' elif isinstance(obj, np.ndarray): if obj.ndim == 1: @@ -510,7 +511,7 @@ def dataType(obj): def isSequence(obj): - return isinstance(obj, list) or isinstance(obj, np.ndarray) or isinstance(obj, metaarray.MetaArray) + return isinstance(obj, list) or isinstance(obj, np.ndarray) or (hasattr(obj, 'implements') and obj.implements('MetaArray'))