@@ -32,17 +32,7 @@ class FigureCanvasQTAggBase(FigureCanvasAgg):
32
32
33
33
def __init__ (self , figure ):
34
34
super (FigureCanvasQTAggBase , self ).__init__ (figure = figure )
35
- self .setAttribute (QtCore .Qt .WA_OpaquePaintEvent )
36
- self ._agg_draw_pending = False
37
35
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 ()
46
36
47
37
def paintEvent (self , e ):
48
38
"""Copy the image from the Agg canvas to the qt.drawable.
@@ -77,49 +67,10 @@ def paintEvent(self, e):
77
67
if QT_API == 'PySide' and six .PY3 :
78
68
ctypes .c_long .from_address (id (buf )).value = 1
79
69
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 )
87
71
88
72
painter .end ()
89
73
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
-
123
74
def blit (self , bbox = None ):
124
75
"""Blit the region in bbox.
125
76
"""
0 commit comments