If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Hello,
I created a wxmathplot with 62000 samples (X and Y data from csv). (http://wxmathplot.sourceforge.net/) It takes 2 seconds to zoom and fit again for every ctrl + mouse scroll to zoom in and out.
I used the exact following code except the creation of x_values and y_values vectors.
I don't think there is much you can do about it. The drawing code is not optimized and draws all 62000 samples each time.
I don't know how to do it in mathplot, but you should provide a custom function that only draws one line per physical pixel in x-direction on screen, so that you don't draw so many lines each time.
doublemax wrote: ↑Tue Sep 28, 2021 6:39 pm
I don't think there is much you can do about it. The drawing code is not optimized and draws all 62000 samples each time.
I don't know how to do it in mathplot, but you should provide a custom function that only draws one line per physical pixel in x-direction on screen, so that you don't draw so many lines each time.
Thank you for the reply.
Can you please share some link or articles to understand more on drawing per pixel if possible. Thanks again
doublemax wrote: ↑Tue Sep 28, 2021 6:39 pm
I don't think there is much you can do about it. The drawing code is not optimized and draws all 62000 samples each time.
I don't know how to do it in mathplot, but you should provide a custom function that only draws one line per physical pixel in x-direction on screen, so that you don't draw so many lines each time.
Thank you for the reply.
Can you please share some link or articles to understand more on drawing per pixel if possible. Thanks again
This is more a logical than a technical issue.
In very simplified form, the current code does something like this:
const int sampleSize = 62000;
for(int i=0; i < sampleSize; i++)
{
int x = (int)(someScaleValue * i);
int y = (int)(anotherScaleValue * samples[i]);
drawPixel(x,y);
}
Which means it draws all 62000 sample regardless of the size of the display area. Which is a waste of performance, because most of the values will overlap and overdraw.
int windowWidth = 1000;
for( int x = 0, x < windowWidth; x++)
{
y = getSample(x + offset); // this could return the nearest value, or a maximum / average over a range of values
drawPixel(x, y);
}
But i don't know how to do that with mathPlot, but i'm pretty sure it's possible.