19,468
社区成员
发帖
与我相关
我的任务
分享
void Ccurve::addtaxis(int data,int *path) //data为画图数据的帧数
{
//内存绘图相关
pWnd1 = GetDlgItem(IDC_STATIC_view);//控件ID
pDC1=pWnd1->GetDC();
pWnd1->GetWindowRect(&rect1);//rc为控件的大小
W=rect1.Width()-50;
H=rect1.Height();
m=H/40;
bmp1=new Bitmap(W+50-2,H-1); //内存位图H
Pen pen(Color(0,0, 0), 3);//边框粗线
Pen spen(Color(0,0, 0), 1);//边框细线
Gdiplus::Font myFont(L"Arial", 8);
SolidBrush brushB(Color(255,0,0,0));
Graphics graphics(bmp1);
HatchBrush newBrush( HatchStyleCross, Color(2555, 255, 255, 255), Color(255, 255, 255,255));//白色
graphics.FillRectangle(&newBrush, 0, 0, rect1.Width(),H);//给画图区域填充白色背
for(int i=0;i<25;i++)
{
graphics.DrawLine(&spen,W*i/24+40,0,W*i/24+40,H); //竖细线
if(i%4==0)
graphics.DrawLine(&pen,W*i/24+40,0,W*i/24+40,H); //纵向粗线
}
for(int j=1;j<=400;j++)
{
if(0==(deepth- data+j)%10) //整数米的位置
{
graphics.DrawLine(&spen,40,H*j/400,W+40,H*j/400); //横细线
if((deepth- data+j)%100==0) //十米整的位置
{
graphics.DrawLine(&pen,40,H*j/400,W+40,H*j/400); //横粗线
WCHAR buf[160];
wsprintfW(buf, L"%d", (deepth- data+j)/10); //注意是反图,上面数字大,下面数字小,+40是因最开始一屏是空的,附加上去没用
graphics.DrawString(buf, -1, &myFont, PointF(0,H*j/400-10), &brushB); //每一个格十米,添加纵向坐标数据
}
}
}
addcurve(graphics , pen0,0,path,data);
addcurve(graphics , pen1,1,path+1,data);
addcurve(graphics , pen2,2,path+2,data);
addcurve(graphics , pen3,3,path+3,data);
addcurve(graphics , pen4,4,path+4,data);
addcurve(graphics , pen5,5,path+5,data);
addcurve(graphics , pen6,6,path+6,data);
addcurve(graphics , pen7,7,path+7,data);
addcurve(graphics , pen8,8,path+8,data);
addcurve(graphics , pen9,9,path+9,data);
addcurve(graphics , pen10,10,path+10,data);
addcurve(graphics , pen11,11,path+11,data);
Graphics gr(pDC1->m_hDC);
gr.DrawImage(bmp1,1,1,0,0,W+50,H-2,UnitPixel);
ReleaseDC(pDC1); //释放DC;
delete bmp1;
bmp1 =NULL;
}