| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -58,20 +58,26 @@ class FigureCanvasQTAggBase(object): | |
|
|
||
| Public attribute | ||
|
|
||
| figure - A Figure instance | ||
| """ | ||
| figure - A Figure instance | ||
| """ | ||
|
|
||
| def __init__(self, figure): | ||
| super(FigureCanvasQTAggBase, self).__init__(figure=figure) | ||
| self._agg_redraw_flag = True | ||
|
|
||
| def drawRectangle(self, rect): | ||
| self._drawRect = rect | ||
| self.draw_idle() | ||
| self.update() | ||
|
|
||
| def paintEvent(self, e): | ||
| """ | ||
| Copy the image from the Agg canvas to the qt.drawable. | ||
| In Qt, all drawing should be done inside of here when a widget is | ||
| shown onscreen. | ||
| """ | ||
| FigureCanvasAgg.draw(self) | ||
| if self._agg_redraw_flag: | ||
| self._agg_redraw_flag = False | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityplease flip the order on these lines so it is only cleared after the Agg draw has succeeded with out exception.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI would have, but I'm still confused about these draw_idle callbacks from within the draw call. If there is a reason for those you cannot clear the flag after draw since it might have been re-set during draw on purpose.
Sorry, something went wrong.
All reactions
|
||
| FigureCanvasAgg.draw(self) | ||
|
|
||
| # FigureCanvasQT.paintEvent(self, e) | ||
| if DEBUG: | ||
| Expand Down Expand Up | @@ -134,9 +140,14 @@ def paintEvent(self, e): | |
| pixmap = QtGui.QPixmap.fromImage(qImage) | ||
| p = QtGui.QPainter(self) | ||
| p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap) | ||
|
|
||
| # draw the zoom rectangle to the QPainter | ||
| if self._drawRect is not None: | ||
| p.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.DotLine)) | ||
| x, y, w, h = self._drawRect | ||
| p.drawRect(x, y, w, h) | ||
| p.end() | ||
| self.blitbox = None | ||
| self._drawRect = None | ||
|
|
||
| def draw(self): | ||
| """ | ||
| Expand All | @@ -147,6 +158,11 @@ def draw(self): | |
| # causes problems with code that uses the result of the | ||
| # draw() to update plot elements. | ||
| FigureCanvasAgg.draw(self) | ||
| self._agg_redraw_flag = False | ||
| self.update() | ||
|
|
||
| def draw_idle(self): | ||
| self._agg_redraw_flag = True | ||
| self.update() | ||
|
|
||
| def blit(self, bbox=None): | ||
| Expand All | @@ -161,15 +177,16 @@ def blit(self, bbox=None): | |
| self.blitbox = bbox | ||
| l, b, w, h = bbox.bounds | ||
| t = b + h | ||
| self._agg_redraw_flag = False # don't repaint the agg buffer in blit() | ||
| self.repaint(l, self.renderer.height-t, w, h) | ||
|
|
||
| def print_figure(self, *args, **kwargs): | ||
| FigureCanvasAgg.print_figure(self, *args, **kwargs) | ||
| self.draw() | ||
|
|
||
|
|
||
| class FigureCanvasQTAgg(FigureCanvasQTAggBase, | ||
| FigureCanvasQT, FigureCanvasAgg): | ||
| class FigureCanvasQTAgg(FigureCanvasQT, FigureCanvasQTAggBase, | ||
| FigureCanvasAgg): | ||
| """ | ||
| The canvas the figure renders into. Calls the draw and print fig | ||
| methods, creates the renderers, etc. | ||
| Expand All | @@ -184,8 +201,7 @@ class FigureCanvasQTAgg(FigureCanvasQTAggBase, | |
| def __init__(self, figure): | ||
| if DEBUG: | ||
| print('FigureCanvasQtAgg: ', figure) | ||
| FigureCanvasQT.__init__(self, figure) | ||
| FigureCanvasAgg.__init__(self, figure) | ||
| super(FigureCanvasQTAgg, self).__init__(figure=figure) | ||
| self._drawRect = None | ||
| self.blitbox = None | ||
| self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent) | ||
| Expand Down | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis should probably stay, do we want to fallback to the base implementation of draw_idle?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIts not really clear to me what's the idea of the split between qt5 and qt5agg. Draw is defined in qt5agg, draw_idle is defined in qt5. It seems reasonable to have both at the same spot where the whole draw mechanism is implemented. Its not gone, it just moved from qt5 to qt5agg.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.