@@ -84,7 +84,7 @@ def paintEvent(self, e):
84
84
print ('FigureCanvasQtAgg.paintEvent: ' , self ,
85
85
self .get_width_height ())
86
86
87
- if self .blitbox is None :
87
+ if len ( self .blitbox ) == 0 :
88
88
# matplotlib is in rgba byte order. QImage wants to put the bytes
89
89
# into argb format and is in a 4 byte unsigned int. Little endian
90
90
# system is LSB first and expects the bytes in reverse order
@@ -123,31 +123,34 @@ def paintEvent(self, e):
123
123
if refcnt != sys .getrefcount (stringBuffer ):
124
124
_decref (stringBuffer )
125
125
else :
126
- bbox = self .blitbox
127
- l , b , r , t = bbox .extents
128
- w = int (r ) - int (l )
129
- h = int (t ) - int (b )
130
- t = int (b ) + h
131
- reg = self .copy_from_bbox (bbox )
132
- stringBuffer = reg .to_string_argb ()
133
- qImage = QtGui .QImage (stringBuffer , w , h ,
134
- QtGui .QImage .Format_ARGB32 )
135
- # Adjust the stringBuffer reference count to work around a memory
136
- # leak bug in QImage() under PySide on Python 3.x
137
- if QT_API == 'PySide' and six .PY3 :
138
- ctypes .c_long .from_address (id (stringBuffer )).value = 1
139
-
140
- pixmap = QtGui .QPixmap .fromImage (qImage )
141
126
p = QtGui .QPainter (self )
142
- p .drawPixmap (QtCore .QPoint (l , self .renderer .height - t ), pixmap )
127
+
128
+ while len (self .blitbox ):
129
+ bbox = self .blitbox .pop ()
130
+ l , b , r , t = bbox .extents
131
+ w = int (r ) - int (l )
132
+ h = int (t ) - int (b )
133
+ t = int (b ) + h
134
+ reg = self .copy_from_bbox (bbox )
135
+ stringBuffer = reg .to_string_argb ()
136
+ qImage = QtGui .QImage (stringBuffer , w , h ,
137
+ QtGui .QImage .Format_ARGB32 )
138
+ # Adjust the stringBuffer reference count to work
139
+ # around a memory leak bug in QImage() under PySide on
140
+ # Python 3.x
141
+ if QT_API == 'PySide' and six .PY3 :
142
+ ctypes .c_long .from_address (id (stringBuffer )).value = 1
143
+
144
+ pixmap = QtGui .QPixmap .fromImage (qImage )
145
+ p .drawPixmap (QtCore .QPoint (l , self .renderer .height - t ), pixmap )
143
146
144
147
# draw the zoom rectangle to the QPainter
145
148
if self ._drawRect is not None :
146
149
p .setPen (QtGui .QPen (QtCore .Qt .black , 1 , QtCore .Qt .DotLine ))
147
150
x , y , w , h = self ._drawRect
148
151
p .drawRect (x , y , w , h )
152
+
149
153
p .end ()
150
- self .blitbox = None
151
154
152
155
def draw (self ):
153
156
"""
@@ -190,7 +193,7 @@ def blit(self, bbox=None):
190
193
if bbox is None and self .figure :
191
194
bbox = self .figure .bbox
192
195
193
- self .blitbox = bbox
196
+ self .blitbox . append ( bbox )
194
197
l , b , w , h = bbox .bounds
195
198
t = b + h
196
199
self .repaint (l , self .renderer .height - t , w , h )
@@ -218,7 +221,7 @@ def __init__(self, figure):
218
221
print ('FigureCanvasQtAgg: ' , figure )
219
222
super (FigureCanvasQTAgg , self ).__init__ (figure = figure )
220
223
self ._drawRect = None
221
- self .blitbox = None
224
+ self .blitbox = []
222
225
self .setAttribute (QtCore .Qt .WA_OpaquePaintEvent )
223
226
224
227
0 commit comments