📄 moniview.cpp
字号:
// moniView.cpp : implementation of the CMoniView class
//
#include "stdafx.h"
#include "moni.h"
#include "moniDoc.h"
#include "moniView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define N2 2
#define N3 3
#define EXMAX 1500
#define NLINE 10
/////////////////////////////////////////////////////////////////////////////
// CMoniView
IMPLEMENT_DYNCREATE(CMoniView, CView)
BEGIN_MESSAGE_MAP(CMoniView, CView)
//{{AFX_MSG_MAP(CMoniView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMoniView construction/destruction
CMoniView::CMoniView()
{
// TODO: add construction code here
}
CMoniView::~CMoniView()
{
}
BOOL CMoniView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMoniView drawing
void CMoniView::OnDraw(CDC* pDC)
{
CMoniDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
int cxDot,cxDotSpacing ,cyDot,cxGraph,cyGraph,y,i;
int DATAMAX=7000;
int DATANUM=2000;
RECT rc;
CPen pen(PS_SOLID,0,RGB(255,0,0));//red pen
CPen*pOldPen=pDC->SelectObject(&pen);
cxGraph=2200;
cyGraph=DATAMAX;
this->GetClientRect(&rc);
pDC->SetMapMode(MM_ANISOTROPIC);
pDC->SetWindowOrg(0,0);
pDC->SetViewportOrg(40,rc.bottom-15);
pDC->SetWindowExt(cxGraph,cyGraph);
pDC->SetViewportExt(rc.right-20,-(rc.bottom-20));
cxDotSpacing=(2*cxGraph)/(3*DATANUM);
cxDot=cxDotSpacing/2;
if(cxDot<3) cxDot=3;
cyDot=cxDot;
pDC->MoveTo(0,0);
pDC->LineTo(0,cyGraph);
pDC->MoveTo(0,0);
pDC->LineTo(cxGraph,0);
char str[20];
for(i=1,y=200;i<=DATANUM;i++,y=y+200)//纵轴标注
{
wsprintf(str,"%2d",y);
pDC->TextOut(-75,y,str);
}
for(i=0;i<=DATANUM;i=i+100)//横轴标注
{
wsprintf(str,"%2d",i);
pDC->TextOut(i,-5,str);
}
for(i=0;i<pDoc->TotalChannel;i++)
{
if(i==1)pDC->MoveTo(i,pDoc->Data[i]);
else pDC->LineTo(i,pDoc->Data[i]);
}
pDC->SelectObject(pOldPen);
}
/////////////////////////////////////////////////////////////////////////////
// CMoniView printing
BOOL CMoniView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMoniView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMoniView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMoniView diagnostics
#ifdef _DEBUG
void CMoniView::AssertValid() const
{
CView::AssertValid();
}
void CMoniView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMoniDoc* CMoniView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMoniDoc)));
return (CMoniDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMoniView message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -