Skip to content

Qt5: Add flag that informs paintEvent if the agg buffer needs to updated, fix rubberband #4962

New issue

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

Closed
wants to merge 3 commits into from
Closed

Conversation

pwuertz
Copy link
Contributor

@pwuertz pwuertz commented Aug 19, 2015

Added a flag for determining if paintEvent needs to update the agg buffer or not. The buffer is updated when draw_idle triggers the paintEvent and the buffer is considered valid after using draw and when using blit.

Discussion in #4943, Speed up Example in #4947

@@ -71,7 +71,11 @@ def paintEvent(self, e):
In Qt, all drawing should be done inside of here when a widget is
shown onscreen.
"""
FigureCanvasAgg.draw(self)
if not hasattr(self, "_agg_redraw_flag"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go in the init so it is always defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should, but this is seems to be a Mixin for which the init method is not called at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we should fix that problem as well.

@tacaswell tacaswell added this to the next point release milestone Aug 19, 2015
@pwuertz pwuertz changed the title Qt5: Add flag that informs paintEvent if the agg buffer needs to updated Qt5: Add flag that informs paintEvent if the agg buffer needs to updated, fix rubberband Aug 20, 2015
@pwuertz
Copy link
Contributor Author

pwuertz commented Aug 20, 2015

Added two new commits for fixing the rubberband in qt. The first adds a remove_rubberband() handler to backend_bases that is invoked when the zoom rectangle is released.

The other commit changes the rubberband handling in the qt backend to utilize the rubberband removal handler. The previous solution was to simply remove the rectangle after each draw. This method fails when there is an additional paintEvent between two draw_rubberband() calls because it clears the rubberband while it is still being dragged (flicker). Also, there is the chance that the paintEvent requested by the last draw_rubberband() call before releasing the mouse might get delayed until after the draw_idle() call for zooming in. This causes the rubberband to be drawn on top of the zoomed-in figure (bad) and since there are no more events after the release the rubberband will stay on screen (worse).

Also, changing the state of the rubberband doesn't trigger an agg buffer redraw anymore, freeing some CPU cycles while dragging.

@pwuertz
Copy link
Contributor Author

pwuertz commented Aug 20, 2015

Moving on to #4972

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants