www.pudn.com > RADAR-ALARM.rar > ParInfoGraph.cpp, change:2011-07-30,size:5034b


#include "StdAfx.h" 
#include "ParInfoGraph.h" 
 
CParInfoGraph::CParInfoGraph(void) 
: m_GraphMode(true) 
{ 
	 
} 
 
CParInfoGraph::~CParInfoGraph(void) 
{ 
} 
 
void CParInfoGraph::Draw(CDC* pDC) 
{   
	CRect m_FrameRect; 
	this->GetClientRect(m_FrameRect); 
    CBrush BGBrush,Brush;//底色涂黑 
    CBrush*OldBrush; 
    BGBrush.CreateSolidBrush(RGB(0,0,0)); 
    OldBrush=pDC->SelectObject(&BGBrush); 
    pDC->Rectangle(&m_FrameRect); 
	pDC->SelectObject(&OldBrush); 
 
	InitColor(); 
	 
	int nXoffset = 5; 
	int nYoffset = 5; 
	CString strInfo; 
     
	 
	 
	 
		if(m_GraphMode==0) 
		{   
			 
			pDC->TextOut(nXoffset,nYoffset,_T("强度")); 
	        nYoffset +=20; 
			CBrush brush,*pOldBrush;    
			 
			   for(int i=0;i<15;i++) 
				{ 
					brush.CreateSolidBrush(RGB(DataClrNum[i].r,DataClrNum[i].g,DataClrNum[i].b)); 
					pOldBrush = pDC->SelectObject(&brush); 
					pDC->Rectangle(CRect(CPoint(nXoffset,nYoffset+i*20),CPoint(nXoffset+40,nYoffset+(i+1)*20))); 
					brush.DeleteObject(); 
					pDC->SelectObject(pOldBrush); 
				} 
			   for(int i=0;i<15;i++) 
					{ 
						strInfo.Format(_T("%6.2f"),Datathreshold[i]); 
						pDC->TextOut(nXoffset+50,nYoffset+i*20,strInfo); 
					} 
		} 
		if(m_GraphMode==1) 
		{    
			 
			pDC->TextOut(nXoffset,nYoffset,_T("速度")); 
			 nYoffset +=20; 
			CBrush brush,*pOldBrush;    
			   for(int i=0;i<14;i++) 
				{ 
					brush.CreateSolidBrush(RGB(DataClrNumV[i].r,DataClrNumV[i].g,DataClrNumV[i].b)); 
					pOldBrush = pDC->SelectObject(&brush); 
					pDC->Rectangle(CRect(CPoint(nXoffset,nYoffset+i*20),CPoint(nXoffset+40,nYoffset+(i+1)*20))); 
					brush.DeleteObject(); 
					pDC->SelectObject(pOldBrush); 
				} 
			     for(int i=0;i<14;i++) 
					{ 
						strInfo.Format(_T("%6.2f"),DatathresholdV[i]); 
						pDC->TextOut(nXoffset+50,nYoffset+i*20-5,strInfo); 
					} 
		} 
 
	 
	 
	 
} 
 
void CParInfoGraph::InitColor(void) 
{ 
	DataClrNum[0].r = 0; 
	DataClrNum[0].g = 0; 
	DataClrNum[0].b = 0; 
	DataClrNum[1].r = 0; 
	DataClrNum[1].g = 230; 
	DataClrNum[1].b = 255; 
	DataClrNum[2].r = 0; 
	DataClrNum[2].g = 150; 
	DataClrNum[2].b = 255; 
	DataClrNum[3].r = 0; 
	DataClrNum[3].g = 0; 
	DataClrNum[3].b = 255; 
	DataClrNum[4].r = 0; 
	DataClrNum[4].g = 255; 
	DataClrNum[4].b = 0; 
	DataClrNum[5].r = 0; 
	DataClrNum[5].g = 200; 
	DataClrNum[5].b = 0; 
	DataClrNum[6].r = 0; 
	DataClrNum[6].g = 128; 
	DataClrNum[6].b = 0; 
	DataClrNum[7].r = 255; 
	DataClrNum[7].g = 255; 
	DataClrNum[7].b = 0; 
	DataClrNum[8].r = 220; 
	DataClrNum[8].g = 180; 
	DataClrNum[8].b = 0; 
	DataClrNum[9].r = 255; 
	DataClrNum[9].g = 180; 
	DataClrNum[9].b = 0; 
	DataClrNum[10].r = 255; 
	DataClrNum[10].g = 0; 
	DataClrNum[10].b = 0; 
	DataClrNum[11].r = 170; 
	DataClrNum[11].g = 0; 
	DataClrNum[11].b = 0; 
	DataClrNum[12].r = 100; 
	DataClrNum[12].g = 0; 
	DataClrNum[12].b = 0; 
	DataClrNum[13].r = 255; 
	DataClrNum[13].g = 0; 
	DataClrNum[13].b = 255; 
	DataClrNum[14].r = 255; 
	DataClrNum[14].g = 180; 
	DataClrNum[14].b = 255; 
 
	Datathreshold[0] = -5; 
	Datathreshold[1] = 0; 
	Datathreshold[2] = 5; 
	Datathreshold[3] = 10; 
	Datathreshold[4] = 15; 
	Datathreshold[5] = 20; 
	Datathreshold[6] = 25; 
	Datathreshold[7] = 30; 
	Datathreshold[8] = 35; 
	Datathreshold[9] = 40; 
	Datathreshold[10] = 45; 
	Datathreshold[11] = 50; 
	Datathreshold[12] = 55; 
	Datathreshold[13] = 60; 
	Datathreshold[14] = 65; 
 
	DataClrNumV[0].r = 126; 
	DataClrNumV[0].g = 244; 
	DataClrNumV[0].b = 254; 
	DataClrNumV[1].r = 0; 
	DataClrNumV[1].g = 224; 
	DataClrNumV[1].b = 254; 
	DataClrNumV[2].r = 0; 
	DataClrNumV[2].g = 176; 
	DataClrNumV[2].b = 176; 
	DataClrNumV[3].r = 0; 
	DataClrNumV[3].g = 254; 
	DataClrNumV[3].b = 0; 
	DataClrNumV[4].r = 0; 
	DataClrNumV[4].g = 196; 
	DataClrNumV[4].b = 0; 
	DataClrNumV[5].r = 0; 
	DataClrNumV[5].g = 128; 
	DataClrNumV[5].b = 0; 
	DataClrNumV[6].r = 254; 
	DataClrNumV[6].g = 254; 
	DataClrNumV[6].b = 254; 
	DataClrNumV[7].r = 252; 
	DataClrNumV[7].g = 252; 
	DataClrNumV[7].b = 252; 
	DataClrNumV[8].r = 254; 
	DataClrNumV[8].g = 0; 
	DataClrNumV[8].b = 0; 
	DataClrNumV[9].r = 254; 
	DataClrNumV[9].g = 88; 
	DataClrNumV[9].b = 88; 
	DataClrNumV[10].r = 254; 
	DataClrNumV[10].g = 176; 
	DataClrNumV[10].b = 176; 
	DataClrNumV[11].r = 254; 
	DataClrNumV[11].g = 124; 
	DataClrNumV[11].b = 0; 
	DataClrNumV[12].r = 254; 
	DataClrNumV[12].g = 210; 
	DataClrNumV[12].b = 0; 
	DataClrNumV[13].r = 254; 
	DataClrNumV[13].g = 254; 
	DataClrNumV[13].b = 0; 
 
	 DatathresholdV[0] = -128; 
	DatathresholdV[1] = -27; 
	DatathresholdV[2] = -20; 
	DatathresholdV[3] = -15; 
	DatathresholdV[4] = -10; 
	DatathresholdV[5] = -5; 
	DatathresholdV[6] = -1; 
	DatathresholdV[7] = 0; 
	DatathresholdV[8] = 1; 
	DatathresholdV[9] = 5; 
	DatathresholdV[10] = 10; 
	DatathresholdV[11] = 15; 
	DatathresholdV[12] = 20; 
	DatathresholdV[13] = 27; 
  
} 
BEGIN_MESSAGE_MAP(CParInfoGraph, CStatic) 
	ON_WM_PAINT() 
END_MESSAGE_MAP() 
 
void CParInfoGraph::OnPaint() 
{ 
	CPaintDC dc(this); // device context for painting 
	CDC *pDC = GetDC(); 
	Draw(pDC); 
}