Skip to content

Fix lag on linked axes.#452

Merged
swharden merged 7 commits intoScottPlot:masterfrom
StendProg:LinkedAxesFix
Jun 9, 2020
Merged

Fix lag on linked axes.#452
swharden merged 7 commits intoScottPlot:masterfrom
StendProg:LinkedAxesFix

Conversation

@StendProg
Copy link
Contributor

@StendProg StendProg commented Jun 8, 2020

Purpose:
Fix linked axes lagging. #451
The reasone is full Render() loop in second formsPlot on each mouse move.
This PR add skipIfCurrentRendered = true to demo,
Add extra param to Render(bool processEvents). This param allow to make Application.DoEvents() in Render() for not interactive formsPlot (no mouse pan on zoom).

Resize() in MatchAxis() was commented. I have no idea why it was implemented in this method, But it create new bitmaps for all layers on each MatchAxis() call.

//TODO
Demo contain not optimal render call in formsPlot2.AxisChanged().
This is for demonstration benefits of this PR. It must be changed to optimal before merge.

New functionality (code):
Extra parameter in Render() to process events in not interacted formsPlot.
Combined with skipIfCurrentlyRendered=true this allow multiple Render calls without lagging for not interactive formsPlots. This param may be usefull not only for linked axes plots.

formsPlot.Render(true, true, processEvents: true)

New functionality (image):
Linked Axes demo demonstrates this PR.
Interactions on upper formsPlot1 contain this PR changes.
Interactions on lower formsPlot2 use old implementation.

@StendProg
Copy link
Contributor Author

It looks like Azure dislike imports ordering in whole project. I think it's bad idea fix it in this PR.

swharden added a commit that referenced this pull request Jun 8, 2020
@swharden
Copy link
Member

swharden commented Jun 8, 2020

It looks like Azure dislike imports ordering in whole project.

This is surprising! It looks like the command dotnet format now sorts using statements, but it previously did not do this 🤔

It looks like I fixed it: I ran dotnet format on the master branch (04e4f5c), then re-ran the Azure Pipelines job on this PR. All green! 👍

Note to self: setting up the auto-formatter is discussed in #425:

dotnet tool install --global dotnet-format
dotnet format

@swharden swharden closed this in faca8cf Jun 9, 2020
@swharden swharden reopened this Jun 9, 2020
@swharden swharden mentioned this pull request Jun 9, 2020
@swharden
Copy link
Member

swharden commented Jun 9, 2020

Application.DoEvents

I like your processEvents argument. I'm not happy with this system as a long-term solution, but this argument is an excellent immediate improvement! Thank you for this PR - it may have taken me a long time to figure this one out.

Resize() in MatchAxis()

The intended purpose of Resize() was to match the layout (padding and tick density), not just axis limits. A changed layout means new bitmaps, so this is necessary when the source layout changes. This is what it looks when you zoom out really far on the top graph:

image

However, the invention of an improved layout system #156 meant that TightenLayout() served this function (layout wasn't recalculated on every resize). The Render() you found was old, and has been changed to TightenLayout() (which also calls Render()) to properly resize the layout after the axis changes.

Big Picture

ScottPlot has evolved so much over the last year that its architecture drifted from what the original user controls had in mind when they were designed. This is a topic for another discussion, but my point is there is much room for improvement by refactoring how ScottPlot handles bitmaps (e.g., they should not be stored or resized, IDisposable objects should be better respected, and using separate Bitmaps for the frame vs. data is a bad idea). I plan to improve these things incrementally, but hopefully there will be more time when active issues/PRs slow down again.

swharden added 2 commits June 8, 2020 22:42
This was the original intent of calling Resize(), as a long time ago Resize() performed the function of layout tightening. This modification not only improves functionality, but is more expressive. ScottPlot#452
@swharden swharden merged commit fe52b6b into ScottPlot:master Jun 9, 2020
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