|
我在控件上画图,第一页显示正常可就是不能画出地二页图象
代码如下:
void editprogram::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
m_tmpDC=new CClientDC(GetDlgItem(IDC_LIST1));
GetClientRect(&rectClient1);
File.graph(m_tmpDC);
}
File::graph(CDC *m_tmpDC1)//图形绘图时绘制曲线
{
//for(int i=0;i<=1190;i++)
double TemporaryT=0,TemporaryG=0,intt=10,count=239,n=2,low;
CString emp,time;
for(int i=1;i
{
if(appFile->stepBacks.type==1)
{
m_tmpDC1->MoveTo((i-1)*80,count-(TemporaryT)*n);
m_tmpDC1->LineTo(((i-1)*80)+intt,count-(appFile->stepBacks.Ttemp)*n);//画斜线
m_tmpDC1->LineTo(i*80,count-(appFile->stepBacks.Ttemp)*n);//画直线
if(TemporaryG!=0)//如果上一步有剃度则画剃度的低温线
{
m_tmpDC1->MoveTo((i-1)*80,count-(TemporaryG)*n);
m_tmpDC1->LineTo(((i-1)*80)+intt,count-(appFile->stepBacks.Ttemp)*n);//画斜线
m_tmpDC1->LineTo(i*80,count-(appFile->stepBacks.Ttemp)*n);//画直线
}
TemporaryT=appFile->stepBacks.Ttemp;
TemporaryG=0;
m_tmpDC1->MoveTo((i-1)*80,0);
m_tmpDC1->LineTo((i-1)*80,600);//画分界线
emp.Format(_T("%d"),i);
emp=_T("Step ")+emp;
m_tmpDC1->ExtTextOut((i-1)*80+15,2,ETO_CLIPPED,NULL,emp,wcslen(emp),NULL);
emp.Format(_T("%.1f"),TemporaryT);//去小数点后一位小数
emp=emp+_T("C");
m_tmpDC1->ExtTextOut((i-1)*80+25,count-(appFile->stepBacks.Ttemp)*n-15,ETO_CLIPPED,NULL,emp,wcslen(emp),NULL);
time.Format(_T("%d"), appFile->stepBacks.Ttime/3600);
emp=time+_T(":");
time.Format(_T("%d"), (appFile->stepBacks.Ttime%3600)/60);
emp=emp+time+_T(":");
time.Format(_T("%d"), (appFile->stepBacks.Ttime%3600)%60);
emp=emp+time;
m_tmpDC1->ExtTextOut((i-1)*80+25,count-(appFile->stepBacks.Ttemp)*n+3,ETO_CLIPPED,NULL,emp,wcslen(emp),NULL);
}
else if(appFile->stepBacks.type==2)
{
// AfxMessageBox(_T("grad"));
if(appFile->stepBacks.GHtemp-appFile->stepBacks.GLtemp<10)
low=appFile->stepBacks.GHtemp-10;
else
low=appFile->stepBacks.GLtemp;
if((i-1)>=1)
{
if(appFile->stepBacks[i-1].type==1)//如果上一步是温度步
{
m_tmpDC1->MoveTo((i-1)*80,count-(TemporaryT)*n);
m_tmpDC1->LineTo(((i-1)*80)+intt,count-(low)*n);//画低温度线
m_tmpDC1->LineTo((i*80),count-(low)*n);
m_tmpDC1->MoveTo((i-1)*80,count-(TemporaryT)*n);
m_tmpDC1->LineTo(((i-1)*80)+intt,count-(appFile->stepBacks.GHtemp)*n);//画高温度线
m_tmpDC1->LineTo((i*80),count-(appFile->stepBacks.GHtemp)*n);
}
else if(appFile->stepBacks[i-1].type==2)
{
m_tmpDC1->MoveTo((i-1)*80,count-TemporaryT*n);
m_tmpDC1->LineTo(((i-1)*80)+intt,count-(low)*n);//画低温度线
m_tmpDC1->LineTo((i*80),count-(low)*n);
m_tmpDC1->MoveTo((i-1)*80,count-TemporaryG*n);
m_tmpDC1->LineTo(((i-1)*80)+intt,count-appFile->stepBacks.GHtemp*n);//画高温度线
m_tmpDC1->LineTo((i*80),count-appFile->stepBacks.GHtemp*n);
}
}
else
{
m_tmpDC1->MoveTo((i-1)*80,count-(TemporaryT)*n);
m_tmpDC1->LineTo(((i-1)*80)+intt,count-(low)*n);//画低温度线
m_tmpDC1->LineTo((i*80),count-(low)*n);
// AfxMessageBox(_T("dadada"));
m_tmpDC1->MoveTo((i-1)*80,count-(TemporaryT)*n);
m_tmpDC1->LineTo(((i-1)*80)+intt,count-(appFile->stepBacks.GHtemp)*n);//画高温度线
m_tmpDC1->LineTo((i*80),count-(appFile->stepBacks.GHtemp)*n);
}
TemporaryT=low;//保存数据
TemporaryG=appFile->stepBacks.GHtemp;
m_tmpDC1->MoveTo((i-1)*80,0);
m_tmpDC1->LineTo((i-1)*80,600);//画分界线
emp.Format(_T("%d"),i);
emp=_T("Step ")+emp;
m_tmpDC1->ExtTextOut((i-1)*80+15,2,ETO_CLIPPED,NULL,emp,wcslen(emp),NULL);
emp.Format(_T("%.1f"),appFile->stepBacks.GHtemp);//去小数点后一位小数
emp=emp+_T("C");
m_tmpDC1->ExtTextOut((i-1)*80+25,count-(appFile->stepBacks.GHtemp)*n-15,ETO_CLIPPED,NULL,emp,wcslen(emp),NULL);
emp.Format(_T("%.1f"),appFile->stepBacks.GLtemp);//去小数点后一位小数
emp=emp+_T("C");
m_tmpDC1->ExtTextOut((i-1)*80+25,count-(low)*n-15,ETO_CLIPPED,NULL,emp,wcslen(emp),NULL);
time.Format(_T("%d"), appFile->stepBacks.Gtime/3600);
emp=time+_T(":");
time.Format(_T("%d"), (appFile->stepBacks.Gtime%3600)/60);
emp=emp+time+_T(":");
time.Format(_T("%d"), (appFile->stepBacks.Gtime%3600)%60);
emp=emp+time;
m_tmpDC1->ExtTextOut((i-1)*80+25,count-(low)*n+3,ETO_CLIPPED,NULL,emp,wcslen(emp),NULL);
}
// m_tmpDC1->MoveTo(i,i*3);
//m_tmpDC1->LineTo(i+1,(i+1)*3);
}
}
|
|