精通
英语
和
开源
,
擅长
开发
与
培训
,
胸怀四海
第一信赖
锐英源精品原创,禁止转载和任何形式的非法内容使用,违者必究
PGL is a library that encapsulates plot capabilities in a MFC project for VC6 and VC7. It is designed to be able to easily plot data generated in a project without the need of any external software. In fact, with CView and CDialog derived classes, you can have your app display chart in 5 minutes. PGL是适用于VC6和VC7平台下的MFC项目库,它封装曲线绘制的能力。它被设计成能够容易地把项目中数据绘制为曲线,且无需任何外部的软件。事实上,用CView和CDialog的 派生类,你可以在5分钟内,让您的应用程序显示曲线图
The aim of PGL is not to have a user-friendly environment but rather being able to generate any plot from the source code. PGL的目的不是提供一个用户友好的环境,而是能够产生任何曲线绘制的源代码。
PGL was originally using OpenGL to raster graphics but now it uses GDI+ (so you need to install Microsoft SDK to compile PGL). PGL最初是使用OpenGL库,但现在它使用GDI +(所以你需要安装Microsoft SDK来编译PGL)。
Features特点
Installation安装
Here are the installation steps to use PGL in one of your projects要在您的项目中使用 PGL,下面是安装步骤:
That's it! 这就够了!
#include "PGL.h"
ULONG_PTR m_ulGdiplusToken;
// initialize <code>GDI+ (gdi+ is in Gdiplus namespace) Gdiplus::GdiplusStartupInput gdiplusStartupInput; Gdiplus::GdiplusStartup(&m_ulGdiplusToken, &gdiplusStartupInput, NULL);
// shutdown GDI+ Gdiplus::GdiplusShutdown(m_ulGdiplusToken);
Your project should work fine now. 您的项目现在应该可以正常工作
All these examples are accessible in the source. See the example menu of TestPGL. 所有这些例子都可以在源代码中找到。请参阅TestPGL例子提供的菜单。
This is a first explanatory example. We suppose that the points (x,y) of the line have been generated and are stored in two array pX,pY of size nPoints ( note that you can also pass data as std::vector<double> to PGL).
这是第一个说明的例子。我们假设线上点(x,y)已经生成并存储在两个数组pX和pY里,数组大小是 npoints(请注意,您还可以通过 std :: vector<double>来向PGL传递数据)。
Here's the code I used to generate the data: a simple sinusoid. Note that the y are in [-1.1, 1.1] but PGL will handle axe labelling the have nice units. 下面是我使用的代码生成的数据:一个简单的正弦曲线。需要注意的是y轴在[-1.1,1.1]之间,但,PGL将处理轴使标记有很好的单位。
// generate data int nPoints = 50 double* pX=new double[nPoints]; double* pY=new double[nPoints]; for (UINT i=0;i< nPoints;i++) { pX[i]=i; pY[i]=sin(i/(double)nPoints*2*3.14)*1.1; }
CPGLGraph* pGraph = new CPGLGraph;
Note that you can check all PGL object with ASSERT_VALID since they all inherit from CObject. 请注意,您可以用 ASSERT_VALID检查所有的PGL对象,因为他们都继承自 CObject
CPGLLine2D* pLine = new CPGLLine2D;
pLine->SetDatas( nPoints /* number of points */, pX /* x(i) */, pY /* y(i) */);
pGraph->AddObject(pLine);
pGraph->ZoomAll();
CPGLGraphBitDlg graphdlg(this, pGraph); graphdlg.DoModal();
You should have the same as the image above. Note that this image (PNG) has been generated by PGL.你应该有和上面的图片一样的图形了。请注意,PGL已经生成图像(PNG)了。