📄 newgraph.cpp
字号:
for(i=0;i<8;i++)
{
for(j=0;j<12;j++)
{
x1 = (float)(m_iXStart+j*m_iX);
x2 = (float)(m_iXStart+(j+1)*m_iX);
y1 = (float)(m_iYStart+(m1-pr2[i][j])*m_iY/(m1-m0));
y2 = (float)(m_iYStart+(m1-pr2[i][j+1])*m_iY/(m1-m0));
if(xMin>x1) xMin = x1;
if(xMin>x2) xMin = x2;
if(xMax<x1) xMax = x1;
if(xMax<x2) xMax = x2;
if(yMin>y1) yMin = y1;
if(yMin>y2) yMin = y2;
if(yMax<y1) yMax = y1;
if(yMax<y2) yMax = y2;
}
}
/* m_ctrlPic.SetWindowPos (this,
10,
20,
(int)(xMax + 50),
(int)(yMax + 70),
SWP_NOMOVE);
*/
/* CSize sizeTotal;
sizeTotal.cx = (int)(xMax + 80);
sizeTotal.cy = (int)(yMax + 120);
SetScrollSizes(MM_TEXT, sizeTotal);
*/
//标注
CString cstrTemp;
m_ctrlPic.SetFont("宋体",12,RGB(0,0,0));
m_ctrlPic.SetFontStyle (TRUE,FALSE,FALSE);
cstrTemp = _T("产率比~孔深、孔密关系曲线");
m_ctrlPic.PicTextOut (
(long)((xMax-xMin)/2 + 50 - 5 * 22),
(long)(yMax + 50),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("孔密:8,12,16,20,24,28,32,36(shot/m)");
m_ctrlPic.PicTextOut (
(long)((xMax-xMin)/2 + 50 - 7*22),
(long)(yMin - 20),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("孔深(mm)");
m_ctrlPic.PicTextOut (
(long)((xMax-xMin)/2 + 50 - 2 * 22),
(long)(yMax + 30),
cstrTemp,
cstrTemp.GetLength ());
float fTemp;
fTemp = (float)((yMax-yMin)/4);
cstrTemp = _T("产");
m_ctrlPic.PicTextOut (
(long)(xMin - 45),
(long)(fTemp*1.5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("率");
m_ctrlPic.PicTextOut (
(long)(xMin - 45),
(long)(fTemp*2.5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("比");
m_ctrlPic.PicTextOut (
(long)(xMin - 45),
(long)(fTemp*3.5),
cstrTemp,
cstrTemp.GetLength ());
m_ctrlPic.SetFont("Times New Roman",10,RGB(0,0,0));
m_ctrlPic.SetFontStyle (FALSE,FALSE,FALSE);
cstrTemp = _T("0");
m_ctrlPic.PicTextOut (
(long)(xMin-2),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("100");
m_ctrlPic.PicTextOut (
(long)(xMin+(xMax-xMin)/6-8),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("200");
m_ctrlPic.PicTextOut (
(long)(xMin+2*(xMax-xMin)/6-8),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("300");
m_ctrlPic.PicTextOut (
(long)(xMin+3*(xMax-xMin)/6-8),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("400");
m_ctrlPic.PicTextOut (
(long)(xMin+4*(xMax-xMin)/6-8),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("500");
m_ctrlPic.PicTextOut (
(long)(xMin+5*(xMax-xMin)/6-8),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("600");
m_ctrlPic.PicTextOut (
(long)(xMax-8),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
char strTemp[10];
sprintf(strTemp,"%5.2f",m1);
cstrTemp = strTemp;
m_ctrlPic.PicTextOut (
(long)(xMin-30),
(long)yMin-5,
cstrTemp,
cstrTemp.GetLength ());
sprintf(strTemp,"%5.2f",m0);
cstrTemp = strTemp;
m_ctrlPic.PicTextOut (
(long)(xMin-30),
(long)(yMax-10),
cstrTemp,
cstrTemp.GetLength ());
//网格
m_ctrlPic.SetLine (0,2,RGB(255,0,100));
m_ctrlPic.DrawLine (
(long)xMin,
(long)yMin,
(long)xMax,
(long)yMin);
m_ctrlPic.DrawLine (
(long)xMax,
(long)yMin,
(long)xMax,
(long)yMax);
m_ctrlPic.DrawLine (
(long)xMax,
(long)yMax,
(long)xMin,
(long)yMax);
m_ctrlPic.DrawLine (
(long)xMin,
(long)yMax,
(long)xMin,
(long)yMin);
m_ctrlPic.SetLine (2,1,RGB(200,200,200));
for(i=1;i<12;i++)
{
m_ctrlPic.DrawLine (
(long)(xMin+i*m_iX),
(long)yMin,
(long)(xMin+i*m_iX),
(long)yMax);
}
fTemp = (float)(yMax-0.1*m_iY/(m1-m0));
while(fTemp>yMin)
{
m_ctrlPic.DrawLine (
(long)xMin,
(long)fTemp,
(long)xMax,
(long)fTemp);
fTemp = (float)(fTemp-0.1*m_iY/(m1-m0));
}
//
int colorTemp;
for(i=0;i<8;i++)
{
colorTemp = i;
while(colorTemp>15)
{colorTemp-=15;}
m_ctrlPic.SetLine (0,1,m_color[colorTemp]);
for(j=0;j<12;j++)
{
x1 = (float)(m_iXStart+j*m_iX);
x2 = (float)(m_iXStart+(j+1)*m_iX);
y1 = (float)(m_iYStart+(m1-pr2[i][j])*m_iY/(m1-m0));
y2 = (float)(m_iYStart+(m1-pr2[i][j+1])*m_iY/(m1-m0));
m_ctrlPic.DrawLine (
(long)x1,
(long)y1,
(long)x2,
(long)y2);
}
}
}
void CNewGraph::DrawOilKSXW()
{
float m0 = (float)5;
float m1 = (float)0;
float km,ks,kj,xw,jbj,kzr,yh,yc,wh,wc;
kj = m_fKJ ;
km = m_fKM ;
jbj = m_fJBJ ;
kzr = m_fKZR ;
yh = m_fYH ;
yc = m_fYC ;
wh = m_fWH ;
wc = m_fWC ;
float pr2[5][14];
int i,j;
for(i=0;i<5;i++)
{
xw = m_fXW[i];
for(j=0;j<13;j++)
{
ks = (float)(j*50); //0~600
if(ks<=wh)
pr2[i][j] = (float)(fnprwOil(ks,km,kj,xw,jbj,kzr,yh,yc,wh,wc)*1.1);
else //pprr?
pr2[i][j] = (float)(fnprcOil(ks,km,kj,xw,jbj,kzr,yh,yc,wh,wc)*1.1);
if(yh==0 && wh==0)
pr2[i][j] = (float)(fnprlOil(ks,km,kj,xw,jbj,kzr)*1.1);
if(pr2[i][j]<0) pr2[i][j] = (float)0;
if(pr2[i][j]>m1) m1 = pr2[i][j]; //Max
if(pr2[i][j]<m0) m0 = pr2[i][j]; //Min
}
}
//
float x1,x2,y1,y2,xMax,xMin,yMax,yMin;
xMin = (float)100000000;
xMax = (float)0;
yMin = (float)100000000;
yMax = (float)0;
for(i=0;i<5;i++)
{
for(j=0;j<12;j++)
{
x1 = (float)(m_iXStart+j*m_iX);
x2 = (float)(m_iXStart+(j+1)*m_iX);
y1 = (float)(m_iYStart+(m1-pr2[i][j])*m_iY/(m1-m0));
y2 = (float)(m_iYStart+(m1-pr2[i][j+1])*m_iY/(m1-m0));
if(xMin>x1) xMin = x1;
if(xMin>x2) xMin = x2;
if(xMax<x1) xMax = x1;
if(xMax<x2) xMax = x2;
if(yMin>y1) yMin = y1;
if(yMin>y2) yMin = y2;
if(yMax<y1) yMax = y1;
if(yMax<y2) yMax = y2;
}
}
/* m_ctrlPic.SetWindowPos (this,
10,
20,
(int)(xMax + 50),
(int)(yMax + 70),
SWP_NOMOVE);
*/
/* CSize sizeTotal;
sizeTotal.cx = (int)(xMax + 80);
sizeTotal.cy = (int)(yMax + 120);
SetScrollSizes(MM_TEXT, sizeTotal);
*/
//标注
m_ctrlPic.SetFont("宋体",12,RGB(0,0,0));
m_ctrlPic.SetFontStyle (TRUE,FALSE,FALSE);
CString cstrTemp;
cstrTemp = _T("产率比~相位角(度)关系曲线");
m_ctrlPic.PicTextOut (
(long)((xMax-xMin)/2 + 50 - 5 * 22),
(long)(yMax + 50),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("孔深(mm)");
m_ctrlPic.PicTextOut (
(long)((xMax-xMin)/2 + 50 - 2 * 22),
(long)(yMax + 30),
cstrTemp,
cstrTemp.GetLength ());
float fTemp;
fTemp = (float)((yMax-yMin)/4);
cstrTemp = _T("产");
m_ctrlPic.PicTextOut (
(long)(xMin - 45),
(long)(fTemp*1.5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("率");
m_ctrlPic.PicTextOut (
(long)(xMin - 45),
(long)(fTemp*2.5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("比");
m_ctrlPic.PicTextOut (
(long)(xMin - 45),
(long)(fTemp*3.5),
cstrTemp,
cstrTemp.GetLength ());
m_ctrlPic.SetFont("Times New Roman",10,RGB(0,0,0));
m_ctrlPic.SetFontStyle (FALSE,FALSE,FALSE);
cstrTemp = _T("0");
m_ctrlPic.PicTextOut (
(long)(xMin-2),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("100");
m_ctrlPic.PicTextOut (
(long)(xMin+(xMax-xMin)/6-8),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("200");
m_ctrlPic.PicTextOut (
(long)(xMin+2*(xMax-xMin)/6-8),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("300");
m_ctrlPic.PicTextOut (
(long)(xMin+3*(xMax-xMin)/6-8),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("400");
m_ctrlPic.PicTextOut (
(long)(xMin+4*(xMax-xMin)/6-8),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("500");
m_ctrlPic.PicTextOut (
(long)(xMin+5*(xMax-xMin)/6-8),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
cstrTemp = _T("600");
m_ctrlPic.PicTextOut (
(long)(xMax-8),
(long)(yMax+5),
cstrTemp,
cstrTemp.GetLength ());
char strTemp[10];
sprintf(strTemp,"%5.2f",m1);
cstrTemp = strTemp;
m_ctrlPic.PicTextOut (
(long)(xMin-30),
(long)yMin-4,
cstrTemp,
cstrTemp.GetLength ());
sprintf(strTemp,"%5.2f",m0);
cstrTemp = strTemp;
m_ctrlPic.PicTextOut (
(long)(xMin-30),
(long)(yMax-10),
cstrTemp,
cstrTemp.GetLength ());
//网格
j=2;
for(i=0;i<5;i++)
{
m_ctrlPic.SetLine (0,1,m_color[i]);
m_ctrlPic.SetFont ("Times New Roman",10,m_color[i]);
x1 = (float)(m_iXStart+j*m_iX);
y1 = (float)(m_iYStart+(m1-pr2[i][j])*m_iY/(m1-m0));
m_ctrlPic.DrawLine (
(long)x1,(long)y1,
(long)(x1+35*m_fScale),(long)(y1+15*m_fScale));
sprintf(strTemp,"%5.0f",m_fXW[i]);
cstrTemp = strTemp;
m_ctrlPic.PicTextOut (
(long)(x1+35*m_fScale-10),(long)(y1+15*m_fScale),
cstrTemp,cstrTemp.GetLength ());
j = j+2;
}
m_ctrlPic.SetLine (0,2,RGB(255,0,100));
m_ctrlPic.DrawLine ((long)xMin,(long)yMin,
(long)xMax,(long)yMin);
m_ctrlPic.DrawLine ((long)xMax,(long)yMin,
(long)xMax,(long)yMax);
m_ctrlPic.DrawLine ((long)xMax,(long)yMax,
(long)xMin,(long)yMax);
m_ctrlPic.DrawLine ((long)xMin,(long)yMax,
(long)xMin,(long)yMin);
m_ctrlPic.SetLine (2,1,RGB(200,200,200));
for(i=1;i<12;i++)
{
m_ctrlPic.DrawLine (
(long)(xMin+i*m_iX),(long)yMin,
(long)(xMin+i*m_iX),(long)yMax);
}
fTemp = (float)(yMax-0.1*m_iY/(m1-m0));
while(fTemp>yMin)
{
m_ctrlPic.DrawLine (
(long)xMin,(long)fTemp,
(long)xMax,(long)fTemp);
fTemp = (float)(fTemp-0.1*m_iY/(m1-m0));
}
//
for(i=0;i<5;i++)
{
m_ctrlPic.SetLine (0,1,m_color[i]);
for(j=0;j<12;j++)
{
x1 = (float)(m_iXStart+j*m_iX);
x2 = (float)(m_iXStart+(j+1)*m_iX);
y1 = (float)(m_iYStart+(m1-pr2[i][j])*m_iY/(m1-m0));
y2 = (float)(m_iYStart+(m1-pr2[i][j+1])*m_iY/(m1-m0));
m_ctrlPic.DrawLine (
(long)x1,(long)y1,
(long)x2,(long)y2);
}
}
}
void CNewGraph::DrawOilKZRXW()
{
float m0 = (float)5;
float m1 = (float)0;
float mm0 = m0;
float mm1 = m1;
float km,ks,kj,xw,jbj,kzr,yh,yc,wh,wc;
km = m_fKM ;
ks = m_fKS ;
kj = m_fKJ ;
// xw = m_fXW1 ;
jbj = m_fJBJ ;
// kzr = m_fKZR ;
yh = m_fYH ;
yc = m_fYC ;
wh = m_fWH ;
wc = m_fWC ;
//********************
float pr2[5][14];
int i,j;
for(i=0;i<5;i++)
{
xw = m_fXW[i];
for(j=0;j<13;j++)
{
kzr = (float)((j+1) * 0.1);
if(ks<=wh)
pr2[i][j] = (float)(fnprwOil(ks,km,kj,xw,jbj,kzr,yh,yc,wh,wc)*1.1);
else //pprr?
pr2[i][j] = (float)(fnprcOil(ks,km,kj,xw,jbj,kzr,yh,yc,wh,wc)*1.1);
if(yh==0 && wh==0)
pr2[i][j] = (float)(fnprlOil(ks,km,kj,xw,jbj,kzr)*1.1);
if(pr2[i][j]<0) pr2[i][j] = (float)0;
if(pr2[i][j]>m1) m1 = pr2[i][j]; //Max
if(pr2[i][j]<m0) m0 = pr2[i][j]; //Min
}
}
//**********************
float x1,x2,y1,y2,xMax,xMin,yMax,yMin;
xMin = (float)100000000;
xMax = (float)0;
yMin = (float)100000000;
yMax = (float)0;
for(i=0;i<5;i++)
{
for(j=0;j<12;j++)
{
x1 = (float)(m_iXStart+j*m_iX);
x2 = (float)(m_iXStart+(j+1)*m_iX);
y1 = (float)(m_iYStart+(m1-pr2[i][j])*m_iY/(m1-m0));
y2 = (float)(m_iYStart+(m1-pr2[i][j+1])*m_iY/(m1-m0));
if(xMin>x1) xMin = x1;
if(xMin>x2) xMin = x2;
if(xMax<x1) xMax = x1;
if(xMax<x2) xMax = x2;
if(yMin>y1) yMin = y1;
if(yMin>y2) yMin = y2;
if(yMax<y1) yMax = y1;
if(yMax<y2) yMax = y2;
}
}
/* m_ctrlPic.SetWindowPos (this,
10,
20,
(int)(xMax + 50),
(int)(yMax + 70),
SWP_NOMOVE);
*/
/* CSize sizeTotal;
sizeTotal.cx = (int)(xMax + 80);
sizeTotal.cy = (int)(yMax + 120);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -