@@ -32,17 +32,7 @@ class FigureCanvasQTAggBase(FigureCanvasAgg):
3232
3333 def __init__ (self , figure ):
3434 super (FigureCanvasQTAggBase , self ).__init__ (figure = figure )
35- self .setAttribute (QtCore .Qt .WA_OpaquePaintEvent )
36- self ._agg_draw_pending = False
3735 self ._bbox_queue = []
38- self ._drawRect = None
39-
40- def drawRectangle (self , rect ):
41- if rect is not None :
42- self ._drawRect = [pt / self ._dpi_ratio for pt in rect ]
43- else :
44- self ._drawRect = None
45- self .update ()
4636
4737 def paintEvent (self , e ):
4838 """Copy the image from the Agg canvas to the qt.drawable.
@@ -77,49 +67,10 @@ def paintEvent(self, e):
7767 if QT_API == 'PySide' and six .PY3 :
7868 ctypes .c_long .from_address (id (buf )).value = 1
7969
80- # draw the zoom rectangle to the QPainter
81- if self ._drawRect is not None :
82- pen = QtGui .QPen (QtCore .Qt .black , 1 / self ._dpi_ratio ,
83- QtCore .Qt .DotLine )
84- painter .setPen (pen )
85- x , y , w , h = self ._drawRect
86- painter .drawRect (x , y , w , h )
70+ self ._draw_rect_callback (painter )
8771
8872 painter .end ()
8973
90- def draw (self ):
91- """Draw the figure with Agg, and queue a request for a Qt draw.
92- """
93- # The Agg draw is done here; delaying causes problems with code that
94- # uses the result of the draw() to update plot elements.
95- super (FigureCanvasQTAggBase , self ).draw ()
96- self .update ()
97-
98- def draw_idle (self ):
99- """Queue redraw of the Agg buffer and request Qt paintEvent.
100- """
101- # The Agg draw needs to be handled by the same thread matplotlib
102- # modifies the scene graph from. Post Agg draw request to the
103- # current event loop in order to ensure thread affinity and to
104- # accumulate multiple draw requests from event handling.
105- # TODO: queued signal connection might be safer than singleShot
106- if not self ._agg_draw_pending :
107- self ._agg_draw_pending = True
108- QtCore .QTimer .singleShot (0 , self .__draw_idle_agg )
109-
110- def __draw_idle_agg (self , * args ):
111- if self .height () < 0 or self .width () < 0 :
112- self ._agg_draw_pending = False
113- return
114- try :
115- super (FigureCanvasQTAggBase , self ).draw ()
116- self .update ()
117- except Exception :
118- # Uncaught exceptions are fatal for PyQt5, so catch them instead.
119- traceback .print_exc ()
120- finally :
121- self ._agg_draw_pending = False
122-
12374 def blit (self , bbox = None ):
12475 """Blit the region in bbox.
12576 """
0 commit comments