@@ -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,33 @@ 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 around a memory
139
+ # leak bug in QImage() under PySide on Python 3.x
140
+ if QT_API == 'PySide' and six .PY3 :
141
+ ctypes .c_long .from_address (id (stringBuffer )).value = 1
142
+
143
+ pixmap = QtGui .QPixmap .fromImage (qImage )
144
+ p .drawPixmap (QtCore .QPoint (l , self .renderer .height - t ), pixmap )
143
145
144
146
# draw the zoom rectangle to the QPainter
145
147
if self ._drawRect is not None :
146
148
p .setPen (QtGui .QPen (QtCore .Qt .black , 1 , QtCore .Qt .DotLine ))
147
149
x , y , w , h = self ._drawRect
148
150
p .drawRect (x , y , w , h )
151
+
149
152
p .end ()
150
- self .blitbox = None
151
153
152
154
def draw (self ):
153
155
"""
@@ -190,7 +192,7 @@ def blit(self, bbox=None):
190
192
if bbox is None and self .figure :
191
193
bbox = self .figure .bbox
192
194
193
- self .blitbox = bbox
195
+ self .blitbox . append ( bbox )
194
196
l , b , w , h = bbox .bounds
195
197
t = b + h
196
198
self .repaint (l , self .renderer .height - t , w , h )
@@ -218,7 +220,7 @@ def __init__(self, figure):
218
220
print ('FigureCanvasQtAgg: ' , figure )
219
221
super (FigureCanvasQTAgg , self ).__init__ (figure = figure )
220
222
self ._drawRect = None
221
- self .blitbox = None
223
+ self .blitbox = []
222
224
self .setAttribute (QtCore .Qt .WA_OpaquePaintEvent )
223
225
224
226
0 commit comments