📄 mdifftview.cpp
字号:
// mdiFFTView.cpp : implementation of the CMdiFFTView class
//
#include "stdafx.h"
#include "mdiFFT.h"
#include<math.h>
#include "mdiFFTDoc.h"
#include "mdiFFTView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMdiFFTView
IMPLEMENT_DYNCREATE(CMdiFFTView, CView)
BEGIN_MESSAGE_MAP(CMdiFFTView, CView)
//{{AFX_MSG_MAP(CMdiFFTView)
// 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()
/////////////////////////////////////////////////////////////////////////////
// CMdiFFTView construction/destruction
CMdiFFTView::CMdiFFTView()
{
// TODO: add construction code here
}
CMdiFFTView::~CMdiFFTView()
{
}
BOOL CMdiFFTView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMdiFFTView drawing
void CMdiFFTView::OnDraw(CDC* pDC)
{
CMdiFFTDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CPen pRed,pBlue,pGreen;
pRed.CreatePen(PS_SOLID,1,RGB(245,0,0));
pBlue.CreatePen(PS_SOLID,1,RGB(0,0,250));
pGreen.CreatePen(PS_SOLID,1,RGB(0,200,0));
int i,md=1<<pDoc->m_power;
const int fonH=18; //文字高度
pDC->SelectObject(pGreen);
pDC->TextOut(0,0,"原序列");
for(i=0;i<md;i++)
{
pDC->MoveTo(i,100+fonH);
pDC->LineTo(i,floor(100+fonH-pDoc->source[i].Re));
}
pDC->SelectObject(pRed);
pDC->TextOut(0,200+fonH,"两次变换后的序列");
for(i=0;i<md;i++)
{
pDC->MoveTo(i,300+fonH*2);
pDC->LineTo(i,floor(300+fonH*2-pDoc->afterifft[i].Re));
}
////////afterfft////////////////
RECT lpRect;
this->GetClientRect(&lpRect);
long double zoom = (lpRect.bottom - lpRect.top) / pDoc->m_amax; //放大倍数
int vcenter = (lpRect.bottom + lpRect.top) / 2; //中心位置
pDC->SelectObject(pBlue);
pDC->TextOut(450,0,"频谱");
for(i=0;i<md;i++)
{
pDC->MoveTo(i+400,vcenter);
pDC->LineTo(i+400,floor(vcenter-pDoc->afterfft[i].abs()*zoom));
}
}
/////////////////////////////////////////////////////////////////////////////
// CMdiFFTView printing
BOOL CMdiFFTView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMdiFFTView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMdiFFTView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMdiFFTView diagnostics
#ifdef _DEBUG
void CMdiFFTView::AssertValid() const
{
CView::AssertValid();
}
void CMdiFFTView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMdiFFTDoc* CMdiFFTView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMdiFFTDoc)));
return (CMdiFFTDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMdiFFTView message handlers
void CMdiFFTView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
Invalidate();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -