From bd51fa7c87d749217bb2d79b28be69f8ddb2ccf7 Mon Sep 17 00:00:00 2001 From: Etienne Dumur Date: Wed, 23 Sep 2020 09:27:23 +0200 Subject: [PATCH] Clean code, improve boundingRect --- doc/source/graphicsItems/pcolormeshitem.rst | 8 ++++++++ pyqtgraph/graphicsItems/PColorMeshItem.py | 18 ++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 doc/source/graphicsItems/pcolormeshitem.rst diff --git a/doc/source/graphicsItems/pcolormeshitem.rst b/doc/source/graphicsItems/pcolormeshitem.rst new file mode 100644 index 00000000..6a06f7d5 --- /dev/null +++ b/doc/source/graphicsItems/pcolormeshitem.rst @@ -0,0 +1,8 @@ +PColorMeshItem +============== + +.. autoclass:: pyqtgraph.PColorMeshItem + :members: + + .. automethod:: pyqtgraph.PColorMeshItem.__init__ + diff --git a/pyqtgraph/graphicsItems/PColorMeshItem.py b/pyqtgraph/graphicsItems/PColorMeshItem.py index 3ec77765..9ca21102 100644 --- a/pyqtgraph/graphicsItems/PColorMeshItem.py +++ b/pyqtgraph/graphicsItems/PColorMeshItem.py @@ -24,9 +24,6 @@ class PColorMeshItem(GraphicsObject): **Bases:** :class:`GraphicsObject ` """ - sigImageChanged = QtCore.Signal() - sigRemoveRequested = QtCore.Signal(object) # self; emitted when 'remove' is selected from context menu - def __init__(self, *args, **kwargs): """ @@ -47,13 +44,13 @@ class PColorMeshItem(GraphicsObject): 2D array containing the value which will be maped into the polygons colors. If x and y is None, the polygons will be displaced on a grid - otherwise x and y will be used as polygons vertices coordinates as: + otherwise x and y will be used as polygons vertices coordinates as:: - (x[i+1, j], y[i+1, j]) (x[i+1, j+1], y[i+1, j+1]) - +---------+ - | z[i, j] | - +---------+ - (x[i, j], y[i, j]) (x[i, j+1], y[i, j+1]) + (x[i+1, j], y[i+1, j]) (x[i+1, j+1], y[i+1, j+1]) + +---------+ + | z[i, j] | + +---------+ + (x[i, j], y[i, j]) (x[i, j+1], y[i, j+1]) "ASCII from: https://matplotlib.org/3.2.1/api/_as_gen/ matplotlib.pyplot.pcolormesh.html". cmap : str, default 'viridis @@ -213,6 +210,7 @@ class PColorMeshItem(GraphicsObject): if shapeChanged: self.informViewBoundsChanged() + self.prepareGeometryChange() @@ -250,4 +248,4 @@ class PColorMeshItem(GraphicsObject): def boundingRect(self): if self.qpicture is None: return QtCore.QRectF(0., 0., 0., 0.) - return QtCore.QRectF(0., 0., float(self.width()), float(self.height())) + return QtCore.QRectF(self.qpicture.boundingRect())