Skip to content

Commit

Permalink
Merge pull request #2946 from hmeine/fix_rect_clash
Browse files Browse the repository at this point in the history
remove .rect member (clashes with QWidget)
  • Loading branch information
tacaswell committed Apr 27, 2014
2 parents 6ddf5c0 + 1e73388 commit 4edc4c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 4 additions & 0 deletions doc/api/api_changes.rst
Expand Up @@ -138,6 +138,10 @@ original location:
* Removed the class `FigureManagerQTAgg` and deprecated `NavigationToolbar2QTAgg`
which will be removed in 1.5.

* Removed formerly public (non-prefixed) attributes `rect` and
`drawRect` from `FigureCanvasQTAgg`; they were always an
implementation detail of the (preserved) `drawRectangle()` function.

* The function signatures of `tight_bbox.adjust_bbox` and
`tight_bbox.process_figure_for_rasterizing` have been changed. A new
`fixed_dpi` parameter allows for overriding the `figure.dpi` setting
Expand Down
14 changes: 6 additions & 8 deletions lib/matplotlib/backends/backend_qt4agg.py
Expand Up @@ -68,8 +68,7 @@ def __init__(self, figure):
print('FigureCanvasQtAgg: ', figure)
FigureCanvasQT.__init__(self, figure)
FigureCanvasAgg.__init__(self, figure)
self.drawRect = False
self.rect = []
self._drawRect = None
self.blitbox = None
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
# it has been reported that Qt is semi-broken in a windows
Expand All @@ -90,8 +89,7 @@ def __init__(self, figure):
self._priv_update = self.update

def drawRectangle(self, rect):
self.rect = rect
self.drawRect = True
self._drawRect = rect
self.repaint()

def paintEvent(self, e):
Expand Down Expand Up @@ -131,10 +129,10 @@ def paintEvent(self, e):
p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage))

# draw the zoom rectangle to the QPainter
if self.drawRect:
if self._drawRect is not None:
p.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.DotLine))
p.drawRect(self.rect[0], self.rect[1],
self.rect[2], self.rect[3])
x, y, w, h = self._drawRect
p.drawRect(x, y, w, h)
p.end()

# This works around a bug in PySide 1.1.2 on Python 3.x,
Expand All @@ -159,7 +157,7 @@ def paintEvent(self, e):
p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap)
p.end()
self.blitbox = None
self.drawRect = False
self._drawRect = None

def draw(self):
"""
Expand Down

0 comments on commit 4edc4c2

Please sign in to comment.