⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 curve.cpp

📁 波峰焊后台控制软件-中文版
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// Curve.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "Curve.h"
#include "FLADS.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CCurve
extern CFLADSApp theApp;
CCurve::CCurve()
{
	init_flash=0;
	newx=0;
	lastx=0;
	newy=0;
	lasty=0;
	set_curve_flag=0;
    set_curve_point.x=0;
    set_curve_point.y=0;
    old_set_curve_point.x = 0;
    old_set_curve_point.y = 0;
	old_set_curve_flag    = set_curve_flag;
	keycount=0;
    set_num=0;
	flash_face=0;
}

CCurve::~CCurve()
{

}


BEGIN_MESSAGE_MAP(CCurve, CStatic)
	//{{AFX_MSG_MAP(CCurve)
	ON_WM_PAINT()
	ON_WM_TIMER()
	ON_WM_DESTROY()
	ON_WM_LBUTTONDBLCLK()
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCurve message handlers

void CCurve::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	CPen* pOldPen;
	CPen  *pGPen;
	CPen *pgrayPen;
	int OldMode;

	CRect rect;
	CRect   mm_rect;
	CPen	*pPen1;
	CPen	*pPen2;
	CPen	*pPen3;
	CPen	*pPen4;
	CPen	*pPen5;
	CPen	*pPen6;
	CPen	*pPen7;
	CPen	*pPen8;
	LOGFONT *lf;
	CFont *pFont, *pSFont, *pMFont, *PtrOldFont;



	COLORREF color[]={
						RGB(255, 0,   0),
						RGB(0,   255, 0),
						RGB(64,   128, 255),
						RGB(0,   255, 255),
						RGB(255, 255, 0),
						RGB(255, 0, 255)
					};


	CString  string;
	int i,j,k,m;
	double  dx,dy,dz,dt,xx,yy,dtt;
	CFont *pOldFont = NULL;
    CBrush *pbrush;
    mm_rect.left=0;
    mm_rect.right=0;
    mm_rect.top=0;
    mm_rect.bottom=0;

    if(theApp.curve_flash!=0)
	{
         theApp.curve_flash=0;
         init_flash=0;
	}
    GetClientRect(&m_rectClient);
    rect=m_rectClient;
	dc.SetBkMode(TRANSPARENT);
	dc.SetTextColor(  RGB(0,0,255) );

	x=(rect.Width()-8)/1000.0;
	y=(rect.Height()-50)/120.0;

//  xx=x/6.0*10.0;  //100对应30秒
	xx=80.0/60.0;

	pGPen=new CPen(PS_SOLID, 1, RGB(0, 255, 80));//绿色
	pgrayPen=new CPen(PS_SOLID, 1, RGB(128, 128, 128));
 	pbrush=new CBrush(RGB(0, 0, 0));

    if(flash_face==0)init_flash=0;
    if((init_flash==0)||(theApp.init_curve_flag!=0))
	{//初始化

				theApp.init_curve_flag=0;

				dc.FillRect(m_rectClient, pbrush);//背景

				pOldPen = dc.SelectObject(pGPen);//--
				dc.MoveTo(rect.left+30,  rect.bottom-25);
				dc.LineTo(rect.right-10, rect.bottom-25);
				dc.MoveTo(rect.left+30,  rect.top+5);
				dc.LineTo(rect.left+30,  rect.bottom-25);

				dc.MoveTo(rect.left+30,  rect.top+5);
				dc.LineTo(rect.left+27,  rect.top+10);
				dc.MoveTo(rect.left+30,  rect.top+5);
				dc.LineTo(rect.left+33,  rect.top+10);

				dc.MoveTo(rect.right-15, rect.bottom-28);
				dc.LineTo(rect.right-10, rect.bottom-25);
				dc.MoveTo(rect.right-15, rect.bottom-22);
				dc.LineTo(rect.right-10, rect.bottom-25);

				for (i=1; i<90; i++)
				{
					 dc.MoveTo(rect.left+30+int(i*10*x), rect.bottom-25);
					 dc.LineTo(rect.left+30+int(i*10*x), rect.bottom-32);   
				}

				for (i=1; i<60; i++)
				{
					 dc.MoveTo(rect.left+30, rect.top+25+int(i*2*y));
					 dc.LineTo(rect.left+35, rect.top+25+int(i*2*y));
				}
				dc.SelectObject(pOldPen);//++


				pOldPen = dc.SelectObject(pgrayPen);//--
				for (i=1; i<19; i++)
				{
					   if((i%2)==0)
					   {
							  dx=50.0*x;
							  dx=dx*(double)i;
							  if(i>=10)dx--;
							  dc.MoveTo(rect.left+30+(int)(dx), rect.top+25);
							  dc.LineTo(rect.left+30+(int)(dx), rect.bottom-25);
					   }
				}
				for (i=0; i<6; i++)
				{
					dc.MoveTo(rect.left+30, rect.top+25+int(i*20*y));
					dc.LineTo(rect.right-56, rect.top+25+int(i*20*y));   
				}
				dc.SelectObject(pOldPen);//++

				dc.SetBkMode(TRANSPARENT);
				dc.SetTextColor(RGB(255, 0, 0));

				string = _T("C");
				ExtTextOut(dc,rect.left+40, rect.top+10,ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);
				string = _T("sec");
				ExtTextOut(dc,rect.right-24, rect.bottom-20,ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);

				for(i=0;i<7;i++)
				{
					dc.SetTextColor(RGB(255-i*40, 0, i*40));
					string.Format(_T("%3d"), (6-i)*50);
					ExtTextOut(dc,rect.left+3,rect.top+18+int(i*20*y),ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);
				}
				dc.SetTextColor(RGB(255, 255, 0));

				for (i=0; i<10; i++)
				{
					if(i<4)  k=4;
					   else  k=0;
					m=i*30;
					string.Format(_T("%01d"), m);
					ExtTextOut(dc,rect.left+int(i*100*x)+20+k, rect.bottom-20,ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);
				}

				for (i=0; i<3; i++)
				{
  					dc.SetTextColor(color[i]);
					string.Format(_T("Test%2d"),i+1);
					ExtTextOut(dc,rect.left+60+i*50,rect.top+6,ETO_OPAQUE,&mm_rect,string, string.GetLength(),NULL);
				}
	};


	pPen1=new CPen(PS_SOLID, 1, RGB(255, 0, 0));
	pPen2=new CPen(PS_SOLID, 1, RGB(0,   255, 0));
	pPen3=new CPen(PS_SOLID, 1, RGB(64,   128, 255));
	pPen4=new CPen(PS_SOLID, 1, RGB(0,   0, 0));
	pPen5=new CPen(PS_SOLID, 1, RGB(0,   255, 255));
	pPen6=new CPen(PS_SOLID, 1, RGB(255,   255, 0));
	pPen7=new CPen(PS_SOLID, 1, RGB(255,   0,    255));


	pFont=new CFont;
	lf=   new LOGFONT;

	dc.SetBkColor(RGB(0, 0, 0));
	dc.SetBkMode(OPAQUE);


	memset(lf, 0, sizeof(LOGFONT));
	lf->lfHeight = 16;
	lstrcpy(lf->lfFaceName, _T("宋体"));
	pFont->CreateFontIndirect(lf); 


	PtrOldFont =dc.SelectObject(pFont);//---------
	dc.SetTextColor(RGB(255, 0, 0));
//	string.Format(_T("20%02d-%02d-%02d %02d-%02d-%02d"), theApp.Year,theApp.Month,theApp.Day,theApp.Hour,theApp.Minute,theApp.Second);
//	ExtTextOut(dc,rect.left+420,rect.top+6, ETO_OPAQUE,&mm_rect, string, string.GetLength(),NULL);


	if((theApp.TDisplayfg!=0)||(theApp.TSamplefg!=0))
	{
			if(theApp.test_flag[0]!=0)
			{
				pOldPen=dc.SelectObject(pPen1);//--
				for (i=0; i<600; i++)
				{					   
						if((theApp.TEMT[0][i]!=0)&&(theApp.TEMT[0][i+1]!=0))
						{
							 dtt=(double)i;
							dc.MoveTo(rect.left+30+int(dtt*xx),     rect.top+25+int((300-theApp.TEMT[0][i])*0.4*y));
							dc.LineTo(rect.left+30+int((dtt+1)*xx), rect.top+25+int((300-theApp.TEMT[0][i+1])*0.4*y));
						}else i=600;
				}
				dc.SelectObject(pOldPen);//++
			}

			if(theApp.test_flag[1]!=0)
			{
				pOldPen=dc.SelectObject(pPen2);//--
				for (i=0; i<600; i++)
				{
						if((theApp.TEMT[1][i]!=0)&&(theApp.TEMT[1][i+1]!=0))
						{
								dtt=(double)i;
								dc.MoveTo(rect.left+30+int(dtt*xx),     rect.top+25+int((300-theApp.TEMT[1][i])*0.4*y));
								dc.LineTo(rect.left+30+int((dtt+1)*xx), rect.top+25+int((300-theApp.TEMT[1][i+1])*0.4*y));	
						}else i=600;
				}
				dc.SelectObject(pOldPen);//++
			}

			if(theApp.test_flag[2]!=0)
			{
				pOldPen=dc.SelectObject(pPen3);//--
				for (i=0; i<600; i++)
				{
						if((theApp.TEMT[2][i]!=0)&&(theApp.TEMT[2][i+1]!=0))
						{
							dtt=(double)i;
							dc.MoveTo(rect.left+30+int(dtt*xx),     rect.top+25+int((300-theApp.TEMT[2][i])*0.4*y));
							dc.LineTo(rect.left+30+int((dtt+1)*xx), rect.top+25+int((300-theApp.TEMT[2][i+1])*0.4*y));	
						}else i=600;
				}
				dc.SelectObject(pOldPen);//++
			}
			theApp.TDisplayfg--;
	}

	if(theApp.vTESTfg!=0)
	{//垂直

			GetCursorPos(&Cursor);
			newx=Cursor.x;

			if(newx<rect.left+30)   newx=rect.left+30;
			if(newx>rect.right-52)  newx=rect.right-52;
			if(newx!=lastx)
			{
				pOldPen = dc.SelectObject(pGPen);//--
				dc.MoveTo(rect.left+30,  rect.bottom-25);
				dc.LineTo(rect.right-10, rect.bottom-25);
				dc.MoveTo(rect.left+30,  rect.top+5);
				dc.LineTo(rect.left+30,  rect.bottom-25);

				dc.MoveTo(rect.left+30,  rect.top+5);
				dc.LineTo(rect.left+27,  rect.top+10);
				dc.MoveTo(rect.left+30,  rect.top+5);
				dc.LineTo(rect.left+33,  rect.top+10);

				dc.MoveTo(rect.right-15, rect.bottom-28);
				dc.LineTo(rect.right-10, rect.bottom-25);
				dc.MoveTo(rect.right-15, rect.bottom-22);
				dc.LineTo(rect.right-10, rect.bottom-25);

				for (i=1; i<90; i++)
				{
					 dc.MoveTo(rect.left+30+int(i*10*x), rect.bottom-25);
					 dc.LineTo(rect.left+30+int(i*10*x), rect.bottom-32);   
				}

				for (i=1; i<60; i++)
				{
					 dc.MoveTo(rect.left+30, rect.top+25+int(i*2*y));
					 dc.LineTo(rect.left+35, rect.top+25+int(i*2*y));
				}
				dc.SelectObject(pOldPen);//++


				pOldPen = dc.SelectObject(pgrayPen);//--
				for (i=1; i<19; i++)
				{
					   if((i%2)==0)
					   {
							  dx=50.0*x;
							  dx=dx*(double)i;
							  if(i>=10)dx--;
							  dc.MoveTo(rect.left+30+(int)(dx), rect.top+25);
							  dc.LineTo(rect.left+30+(int)(dx), rect.bottom-25);
					   }
				}
				for (i=0; i<6; i++)
				{
					dc.MoveTo(rect.left+30, rect.top+25+int(i*20*y));
					dc.LineTo(rect.right-56, rect.top+25+int(i*20*y));   
				}
				dc.SelectObject(pOldPen);//++

/*					dx=(double)((Cursor.x-48)*500.0/77.0);
					if(dx<0)dx=0;
					str.Format("%03.1f",dx);
					dc.SetTextColor(RGB(255, 255, 0));
					if(dx<1000)
					{
						   str="0"+str;
						   if(dx<100) 
						   {
								   str="0"+str;
								   if (dx<10) str="0"+str;
						   }
					}
				    str=str+"mm";
					dc.TextOut((int)(rect.left+737), int(bottom-90), str, str.GetLength());

					dy=(double)tcurvespeed;
					if(dy==0)dy=(double)FilePtr->TransConSpeed;
                    dx=(double)((Cursor.x-48)*500.0/77.0)/dy*60.0;
					if(dx<0)  dx=0;
               		str.Format("%3.1f",dx);
					if(dx<1000)
					{
						   str="0"+str;
						   if(dx<100) 
						   {
										   str="0"+str;
										   if (dx<10) str="0"+str;
						   }									     
					}
				    str=str+" S";
					dc.SetTextColor(RGB(0, 255, 255));
					dc.TextOut((int)(left+737), int(bottom-70), str, str.GetLength());
*/



					if(set_curve_flag!=0)
					{							 
							OldMode = dc.SetROP2 (R2_XORPEN);
							pPen8=new CPen(PS_SOLID, 1, RGB(255, 0, 0));
							pOldPen=dc.SelectObject(pPen8);//--
							dc.MoveTo(set_curve_point.x,  rect.top+26);
							dc.LineTo(set_curve_point.x,  rect.bottom-25);
							dc.SelectObject(pOldPen);     //++
							old_set_curve_point=set_curve_point;
							delete  pPen8;
							dc.SetROP2 (OldMode);
							
/*							OldMode = dc.SetROP2 (R2_XORPEN);
							pPen8=new CPen(PS_SOLID, 1, RGB(255, 0, 0));
							pOldPen=dc.SelectObject(pPen8);//--
							dc.MoveTo(old_set_curve_point.x,  rect.top+26);
							dc.LineTo(old_set_curve_point.x,  rect.bottom-25);
							dc.SelectObject(pOldPen);     //++
							delete  pPen8;
							dc.SetROP2 (OldMode);*/

					}else set_num=0;


					pOldPen=dc.SelectObject(pPen4);//--黑
					dc.MoveTo(lastx,     (rect.top+26));
					dc.LineTo(lastx,     (rect.bottom-25));	
					dc.SelectObject(pOldPen);//++

					pOldPen=dc.SelectObject(pPen1);//--红
					dc.MoveTo(newx,      (rect.top+26));
					dc.LineTo(newx,      (rect.bottom-25));	
					dc.SelectObject(pOldPen);//++
					if(set_curve_flag!=0)
					{							 
							OldMode = dc.SetROP2 (R2_XORPEN);
							pPen8=new CPen(PS_SOLID, 1, RGB(255, 0, 0));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -