锐英源软件
第一信赖

精通

英语

开源

擅长

开发

培训

胸怀四海 

第一信赖

当前位置:锐英源 / 英语翻译 / VC++高级技术系列-GDI+曲线库开源项目翻译
服务方向
人工智能数据处理
人工智能培训
kaldi数据准备
小语种语音识别
语音识别标注
语音识别系统
语音识别转文字
kaldi开发技术服务
软件开发
运动控制卡上位机
机械加工软件
软件开发培训
Java 安卓移动开发
VC++
C#软件
汇编和破解
驱动开发
联系方式
固话:0371-63888850
手机:138-0381-0136
Q Q:396806883
微信:ryysoft

锐英源精品开源心得,转载请注明:“锐英源www.wisestudy.cn,孙老师作品,电话13803810136。”需要全文内容也请联系孙老师。

Snapshot

Description描述

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特点

  • line strip, fully customisable线条样式,完全可定制::
    • color (RGBA), 颜色(RGBA)
    • line dashing, 线折点格式
    • point type (circle, box, triangle, etc...) 点型(圆圈,方块,三角,等..)
    • line width, 线宽
    • filled, 填充
    • line shadow, 线阴影
    • multiple line strip, 多线条
    • etc... 等...
  • line strip with level of detail capabilities (based on Douglas-Peukler line simplification algorithm), 带多层次细节能力的线条(基于道格拉斯 - Peukler线简化算法)
  • Vector map, 矢量地图
  • Height map, 高度图
  • Text, 文本
    • variable scale, 变尺度
    • multiple fonts, 多种字体
    • orientable, 方向
  • Unlimited sub-plotting, 无限子曲线
  • Automatic axis, 自动轴
  • Time labelling, 时间标签
  • Export to EPS, SVG, JPEG, TIFF, PNG, 导出到EPS,SVG,JPEG,TIFF,PNG
  • CView derived class for fast integration in existing project, CView派生类,适用于快速整合在现有的项目
  • CDialog derived class, etc... CDialog的派生类,等等

Installation安装
Here are the installation steps to use PGL in one of your projects要在您的项目中使用 PGL,下面是安装步骤:

  • Install GDI+ (part of Microsoft SDK). 安装GDI +(微软SDK的一部分)
  • Download Gdiplus.dll and make sure it is in the path, 下载Gdiplus.dll中,并确保它通过路径可以找到
  • Recompile the source, it will build .lib in the lib directory and the .dll in the bin directory重新编译的源代码,它会在lib目录中建立lib库,在bin目录下建立dll文件
  1. Add the directory with PGL binaries to your path. (by default it is C:\Program Files\PGL\bin) 将PGL二进制文件的目录添加到您的路径。(默认情况下为C:\ Program Files\ PGL\ bin)
  • Add the include directory and lib directory to Visual C++ include/lib directories. 把include目录和lib目录添加到Visual C + +的包含目录和库目录中
  • Make sure the headers are available确保头文件可用

That's it! 这就够了!

Getting your project started让你的项目启动

  • Add the following in your StdAfx.h file向StdAfx.h文件中添加以下内容:
#include "PGL.h" 
  • Since PGL is using GDI+, you must initialize it由于PGL使用GDI +,你必须对其进行初始化:
    • Add the following variable to your CWinApp derived class下面的变量添加到您的CWinApp派生类里
ULONG_PTR m_ulGdiplusToken;
    • Add the following to the CWinApp::OnInitInstance function to initialize GDI+添加下面代码段到CWinApp :: OnInitInstance里来初始化GDI +
// initialize <code>GDI+ (gdi+ is in Gdiplus  namespace)
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_ulGdiplusToken, &gdiplusStartupInput, 
NULL);
    • Add the following to the CWinApp::OnExitInstance function to clean up GDI+.添加下面代码段到CWinApp :: OnExitInstance里来清理GDI +
// shutdown GDI+
Gdiplus::GdiplusShutdown(m_ulGdiplusToken);

Your project should work fine now. 您的项目现在应该可以正常工作

Examples实例

All these examples are accessible in the source. See the example menu of TestPGL. 所有这些例子都可以在源代码中找到。请参阅TestPGL例子提供的菜单。

Example 1 : Drawing a simple line例1:绘制一个简单的线

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传递数据)。

Snapshot
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;
}
  • First, create a graph object: 首先,创建一个图形对象
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

  • Create a 2D line: 创建一个二维线:
CPGLLine2D* pLine = new CPGLLine2D;
  • Attach the data to the line. PGL will handle the memory afterwards. That is, it will delete the pointers of data at the object destruction. This means pX,pY MUST have been allocated on the heap ! 把数据附加到线上。PGL将随后处理的内存。也就是说,它会在对象销毁时删除数据指针。这意味着PX,PY必须被分配在堆上!
pLine->SetDatas( nPoints /* number of points */, 
pX /* x(i) */, pY /* y(i) */);
  • (Optional)Change some properties of the line: (可选)更改线的某些属性:pLine->SetLineWidth(2);
  • Add the line to the graph (note that an object can be added to only one graph): 添加线到曲线图(注意,一个对象只能被添加到一个图形):
pGraph->AddObject(pLine);
  • Make PGL scale the plot (automatically) 让PGL(自动)缩放绘制
pGraph->ZoomAll();
  • Create a dialog box and display the plot: 创建一个对话框,显示图形
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)了。 

友情链接
版权所有 Copyright(c)2004-2021 锐英源软件
公司注册号:410105000449586 豫ICP备08007559号 最佳分辨率 1024*768
地址:郑州大学北校区院(文化路97号院)内