You are not logged in.

1

Saturday, March 3rd 2012, 3:07pm

Drawing a custom function with mouse -> put in in the table - C/C++

Hi,

I need to write a program to draw a graph (a function) by hand on a PC-
the user with his mouse have to have the ability to move freely points -
after he is done the graph would be saved to a file or sent using
sockets over the internet. Don't know yet what to X and Y resolution to
choose - it's irrelevant for now. Every point of the function in the
graph will be connected with the previous and next one.

So it would be basicly moving points on the application - it would draw and refresh the function - and after the user is satisfied it could be sent over the internet or saved to a file.

Would it be possible to connect those points not using linerar interpolation (simply by joining the points with lines) but polymonial or spline function to get a nicer lookin plot?

Could you please give me some idea how to do it in QT, what libraries, widgets etc to use ? or perphaps suggest any other IDE.

thanks for any help
best regards

2

Saturday, March 3rd 2012, 6:25pm

you can use qgraphicsview/scene/items easily to allow user to add/modify position of some markers relative to some axes.

qwt library will plot the data easily. I'm not sure if you can specify that it should allow quadratic/cubic spline between points. You can research qwt for yourself.

http://qwt.sourceforge.net/class_qwt_spline.html#_details
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

3

Saturday, March 3rd 2012, 10:49pm

hi,
thanks :)
already found some video tutorials on YT - by VoidRealms

http://www.youtube.com/watch?v=b35JF4LqtBs

i'll try do write the code in couple of days, and perhaps then post here again if encountered any problems :)

best regards