?? detaildisp.cpp
字號:
// DetailDisp.cpp : implementation file
//
#include "stdafx.h"
#include "mcds.h"
#include "DetailDisp.h"
#include "GlobalVar.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDetailDisp
IMPLEMENT_DYNCREATE(CDetailDisp, CView)
CDetailDisp::CDetailDisp()
{
}
CDetailDisp::~CDetailDisp()
{
}
BEGIN_MESSAGE_MAP(CDetailDisp, CView)
//{{AFX_MSG_MAP(CDetailDisp)
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDetailDisp drawing
void CDetailDisp::OnDraw(CDC* pDC)
{
CDocument* pDoc = GetDocument();
// TODO: add draw code here
}
/////////////////////////////////////////////////////////////////////////////
// CDetailDisp diagnostics
#ifdef _DEBUG
void CDetailDisp::AssertValid() const
{
CView::AssertValid();
}
void CDetailDisp::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
/*CMcdsDoc* CDetailDisp::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMcdsDoc)));
return (CMcdsDoc*)m_pDocument;
}*/
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDetailDisp message handlers
void CDetailDisp::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
Invalidate(FALSE);
}
void CDetailDisp::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rect;
GetClientRect(&rect);
CDC memDC;
CBitmap memBit;
CPen Pen;
memDC.CreateCompatibleDC(&dc);
memBit.CreateCompatibleBitmap(&dc,rect.Width(),rect.Height());
CBitmap *pOldBit = memDC.SelectObject(&memBit);
memDC.FillSolidRect(0,0,rect.Width(),
rect.Height(),RGB(20,100,200)); //繪制背景
CPen CurPen;
CurPen.CreatePen(PS_SOLID,1,RGB(255,255,255));//繪制光標
CPen * pCurPen=memDC.SelectObject(&CurPen);
memDC.MoveTo(Channel2Point(rect,nNumInfo[12]).x,0);
memDC.LineTo(Channel2Point(rect,nNumInfo[12]).x,rect.Height());
Pen.CreatePen(PS_SOLID,1,RGB(255,255,0));
CPen * pPen=memDC.SelectObject(&Pen);
int i;
int nChannelNum=atoi(nNumInfo[21])-atoi(nNumInfo[20])+1;
for(i=0;i<=nChannelNum-1;i++)
{
memDC.MoveTo(Data2Point(rect,i).x-(int)(scalex(rect)/2),Data2Point(rect,i).y);
memDC.LineTo(Data2Point(rect,i).x+(int)(scalex(rect)/2),Data2Point(rect,i).y);
}
pPen->DeleteObject();
Pen.DeleteObject();
dc.BitBlt(rect.left,rect.top,rect.Width(),rect.Height(),
&memDC,rect.left,rect.top,SRCCOPY);
memDC.DeleteDC();
// Do not call CView::OnPaint() for painting messages
}
double CDetailDisp::scalex(CRect rect)//每道多少像素
{
return rect.Width()/(double)(atoi(nNumInfo[21])-atoi(nNumInfo[20])+1);
}
double CDetailDisp::scaley(CRect rect)//每計數(shù)多少像素
{
if(nNumInfo[15]=="256")return rect.Height()/(double)256;
else if(nNumInfo[15]=="512")return rect.Height()/(double)512;
else if(nNumInfo[15]=="1K")return rect.Height()/(double)1024;
else if(nNumInfo[15]=="2K")return rect.Height()/(double)2048;
else if(nNumInfo[15]=="4K")return rect.Height()/(double)4096;
else if(nNumInfo[15]=="8K")return rect.Height()/(double)8192;
else if(nNumInfo[15]=="16K")return rect.Height()/(double)16384;
else if(nNumInfo[15]=="32K")return rect.Height()/(double)32786;
else if(nNumInfo[15]=="64K")return rect.Height()/(double)65536;
return 0;
}
CPoint CDetailDisp::Data2Point(CRect rect,int i)
{
CPoint point;
point.x=(int)(i*scalex(rect)+scalex(rect)/2);
point.y=(int)(rect.Height()-m_data[i+atoi(nNumInfo[20])]*scaley(rect));
return point;
}
CString CDetailDisp::Point2Channel(CRect rect,CPoint point)
{
int c=(int)((point.x-scalex(rect)/2)/scalex(rect))+atoi(nNumInfo[20]);
char temp[15];
_itoa(c,temp,10);
CString str=temp;
return str;
}
CPoint CDetailDisp::Channel2Point(CRect rect,CString channel)
{
CPoint point;
point.x=(int)(((atoi(channel)-atoi(nNumInfo[20]))*scalex(rect))+scalex(rect)/2);
point.y=0;
return point;
}
void CDetailDisp::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CRect rect;
GetClientRect(&rect);
char temp[15];
nNumInfo[12]=Point2Channel(rect,point);
_itoa(m_data[atoi(nNumInfo[12])],temp,10);
nNumInfo[13]=temp;
lsUpdate[12]=true;
lsUpdate[13]=true;
((CMainFrame *)AfxGetApp()->m_pMainWnd)->GetActiveDocument()->UpdateAllViews(NULL);
CView::OnLButtonDown(nFlags, point);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -