开发者

C++ library for drawing graphics [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 5 years ago.

Improve this question

Someone can suggest me a good, free, easy to use library for c++ that allow to draw a mathematical function in a window for microsoft windows? (e.g. the p开发者_如何学Goarabola x^2+5x+3=0)


Since you need a ready-made plotting widget, use Qwt.

It uses Qt.

You could use Qt directly as in contero's answer, without Qwt, as the task is simple enough. However, Qwt has lots of graph features built in, and the usage is straightforward.

C++ library for drawing graphics [closed]


I wrote a program similar to this using Qt. Qt is wonderful once you get it set up, but it may take a bit of effort if you've never used it (as will OpenGL, DirectX, etc..).

You can create a QImage and set it to whatever background color you want, then run your program through the width of the image pixel by pixel calling your function to get the y value. Roughly:

for (int i = 0; i < imageWidth; i++) {
   image->setPixel(i, yourFunction(i), lineColor);
}

Once you've created your QImage, you can attach it to a QLabel using setPixmap(). Once you've attached it you can then display the image in a layout.


Another option is wxMathPlot which is wxWidgets based.
From it's website:
wxMathPlot main features:

  • Completely mouse-driven view control: pan, zoom, scroll, box positioning.
  • Printing class.
  • Screenshot saving of plot window (BMP, PNG and JPEG formats).
  • Overlay movable boxes with legend or mouse coordinate display.
  • Can set margins to avoid plots to cover axis labels.
  • Flexible axis positioning
  • A series of useful layer to directly plot data from STL vector, movable objects, covariance ellipse, bitmaps, etc.
  • Multi-platform: runs everywhere wxWidgets does.


Another wxWidgets-based option is wxArt2D, It has got tons of good features for drawing mathematical functions as curves, like you could easily pass this y=140*cos(x/20) + 80*cos(x*2/20) + 40*cos(x*4/20)" to a curve object and it will get drawn, it's amazing! Check out these screenshots there are some curves drawn by equations in string format!


You mention your language (C++) and platform (Windows), but there are frameworks available for writing a Windows C++ application: Qt, MFC, C++Builder... Additionally, C and C++ can interface with just about anything. So your decision for which plotting library to use will depend on what framework you're using for your UI and on what kind of external interfaces or dependencies you're willing to introduce:

  • If you're using Qt, you should use Qwt, as Stefan Monov said.
  • If you're using C++Builder, you should try TeeChart or TMS Advanced Charts.
  • For wxWidgets, try wxMathPlot or wxArt2D, recommended by Eugen Constantin Dinca's answer and Parsa Jamshidi's answer.
  • If you don't mind calling an external program to do your plotting, then Gnuplot is a popular and powerful solution. C and C++ libraries exist to simplify calling Gnuplot.
  • If you're willing to embed Python, then Matplotlib is very popular, and Python could simplify the development of some of your charts.
  • For an atypical solution, you could have your C++ library generate a jqPlot web page then point an embedded web browser at it.
  • For a framework-independent C or C++ library with no external dependencies, the most promising solution I've found is PLplot, although I haven't yet had a chance to use it.


You can use GDI/+, OpenGL, Direct3D, Direct2D as well if you're using Vista/7. There's plenty out there.


Definitely gnuplot, and the library gnuplot++


I created a tool to plot graphics and published it several hours ago.

https://www.youtube.com/watch?v=xD080qQVaD8&feature=youtu.be

https://github.com/burlachenkok/plotter_plusplus

To use this tool you can use desktop computer to show graphics.

Your target project can be run anywhere in any language in any platform - to update graphics just send data over the network.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜