# Thread: Ideas for a project using a 2D plot

1. Beginner
Join Date
Nov 2015
Posts
2
Thanks
1
Qt products
Platforms

## Ideas for a project using a 2D plot

Hello everyone, I'm totally new with Qt and I have a project assigned of making a wave-expansion simulator often known as "ripple tank". The software should allow the user to visualize sound waves expanding in a room, getting reflected, etc...
Also the user should be able to insert walls and sound sources in the scene and those walls and sound sources need also to be printed on top of the image.
The representation has to be a plot with every pixel representing a node. Every node has a determined pressure level which varies during the time.

The idea is:
1-Calculation of the value of every node in the graph (float)
2-Assign an RGB value to every presure value
3-Print the matrix

.The matrix (graph) could be around 1000*1000 pixels
.The frame rate should be minimum 30 fps

A lot of CPU is used for the calculation of the pressure values itself.

My main question is which function could I use to represent the matrix. I tried draw2Dpixels but I have seen in many places that this is a slow solution. Does someone have a good tip?

I link an applet which makes a very similar function to the program I must implement.

2. ## Re: Ideas for a project using a 2D plot

You might look at Qwt, especially the QwtPlotSpectrogram class. There is a learning curve for Qwt, but maybe you can adapt the example program for your needs.

You will have a very difficult time to calculate 1 million pressure values at a 30fps rate, and an even more difficult time to update a plot with that many values so quickly. I know from experience in trying to perform bilinear interpolation on a 2D data array of 1000 x 1000 pixels that it can take a second or more for *one* update, and bilinear interpolation is a much simpler computational problem than you face with multiple sound sources, walls, reflections, multiple frequencies and amplitudes, and so forth.

Have fun.

Edit: I am surprised that the applet can run so quickly. There must be tricks to the computation that aren't obvious, or maybe the applet is using the GPU to perform some of the calculation.

3. ## The following user says thank you to d_stranz for this useful post:

noobsOfQt (16th November 2015)

4. Beginner
Join Date
Nov 2015
Posts
2
Thanks
1
Qt products
Platforms

## Re: Ideas for a project using a 2D plot

Thanks d_stranz, sorry for replaying so late I did not get a notification of your answer to my mail. You are right, the applet runs really fast. For the calculation I use the TLM method which simplifies a lot everything. You basically actualize the values of each pixel having a source (field[source_position]=field[source_position]+sin(xxxx)) and then you go from pixel to pixel and their value is "spreaded" to the North, west, east and south pixels. You don't simulate each "ray" independently so it is basically not heavier having reflections or more sources. You did scare me with the one second
I'll check Qwt then.