📄 dlg06.cpp
字号:
// Dlg06.cpp : implementation file
//
#include "stdafx.h"
#include "DSP.h"
#include "Dlg06.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlg06 dialog
CDlg06::CDlg06(CWnd* pParent /*=NULL*/)
: CDialog(CDlg06::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlg06)
m_sgn = _T("");
m_dft = 0.0;
m_fft = 0.0;
m_N = 0;
//}}AFX_DATA_INIT
}
void CDlg06::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlg06)
DDX_Text(pDX, IDC_EDIT1, m_sgn);
DDX_Text(pDX, IDC_EDIT3, m_dft);
DDX_Text(pDX, IDC_EDIT4, m_fft);
DDX_Control(pDX, IDC_MSFLEXGRID1, m_grid);
DDX_Text(pDX, IDC_EDIT2, m_N);
DDV_MinMaxInt(pDX, m_N, 1, 5000);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlg06, CDialog)
//{{AFX_MSG_MAP(CDlg06)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlg06 message handlers
void CDlg06::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData();
int i;
int m_fftn=m_N;
sgntemp.CStringToSignal(m_sgn);
sgntemp.fitForLen(m_N);
sgndft=sgntemp;
CycleCountStart();
CDFT::DFT(sgndft.sgnt,sgndft.sgnw,sgndft.length);
CycleCountEnd();
m_dft=CycleCountElapse();
while (!CFFT::IS2N(m_fftn))
{
m_fftn++;
}
sgntemp.fitForLen(m_fftn);
sgnfft=sgntemp;
CycleCountStart();
CFFT::FFT(sgnfft.sgnt,sgnfft.sgnw,sgnfft.length);
CycleCountEnd();
m_fft=CycleCountElapse();
CDC* pDC = GetDC();
m_grid.SetRows(4);
m_grid.SetCols(sgntemp.length+1);
for (i=1;i<=m_fftn;i++)
{
m_grid.SetColWidth ( i,( long ) ( 144 * 1440.0 / pDC->GetDeviceCaps(LOGPIXELSX) ) );
}
m_grid.SetTextMatrix(1,0,"Time");
m_grid.SetTextMatrix(2,0,"Dft");
m_grid.SetTextMatrix(3,0,"Dft");
CString str;
CString str1;
for (i=0;i<m_N;i++)
{ str.Empty();
str.Format("%d",i+1);
m_grid.SetTextMatrix(0,i+1,str);
str.Empty();
str1.Empty();
str.Format("%4.4f",sgndft.sgnw[i].real);
str1.Format("%4.4f",sgndft.sgnw[i].imag);
if (sgndft.sgnw[i].imag>0)
str=str+'+'+str1+'i';
else
str=str+str1+'i';
m_grid.SetTextMatrix(2,i+1,str);
}
for (i=0;i<m_fftn;i++)
{
str.Empty();
str.Format("%4.4f",sgntemp.sgnt[i]);
m_grid.SetTextMatrix(1,i+1,str);
str.Empty();
str1.Empty();
str.Format("%4.4f",sgnfft.sgnw[i].real);
str1.Format("%4.4f",sgnfft.sgnw[i].imag);
if (sgnfft.sgnw[i].imag>0)
str=str+'+'+str1+'i';
else
str=str+str1+'i';
m_grid.SetTextMatrix(3,i+1,str);
}
UpdateData(FALSE);
}
void CDlg06::OnCancel()
{
// TODO: Add extra cleanup here
MessageBox("真的要退出吗?");
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -