📄 waveletcoi.cpp
字号:
// WaveletCoi.cpp : implementation file
//
#include "stdafx.h"
#include "小波变换.h"
#include "WaveletCoi.h"
#include "math.h"
#include "Daubechiesdlg.h"
#include "Symletsdlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
const double pi=3.1415926535;
/////////////////////////////////////////////////////////////////////////////
// CWaveletCoi dialog
CWaveletCoi::CWaveletCoi(CWnd* pParent /*=NULL*/)
: CDialog(CWaveletCoi::IDD, pParent)
{
//{{AFX_DATA_INIT(CWaveletCoi)
m_waveletfunction = -1;
m_waveletlength = 0;
//}}AFX_DATA_INIT
}
void CWaveletCoi::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWaveletCoi)
DDX_Radio(pDX, IDC_SHANNON, m_waveletfunction);
DDX_Text(pDX, IDC_WAVELETLENGTH, m_waveletlength);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CWaveletCoi, CDialog)
//{{AFX_MSG_MAP(CWaveletCoi)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_DAUBECHIES, OnDaubechies)
ON_BN_CLICKED(IDC_MORLET, OnMorlet)
ON_BN_CLICKED(IDC_MEXICANHAT, OnMexicanhat)
ON_BN_CLICKED(IDC_MEYER, OnMeyer)
ON_BN_CLICKED(IDC_BSPLINE, OnBspline)
ON_BN_CLICKED(IDC_SYMLETS, OnSymlets)
ON_BN_CLICKED(IDC_COIFLETS, OnCoiflets)
ON_BN_CLICKED(IDC_SHANNON, OnShannon)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWaveletCoi message handlers
BOOL CWaveletCoi::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
GetDlgItem(IDC_FUNCTIONIMAGE)->GetWindowRect(&m_prectfunction);
ScreenToClient(&m_prectfunction);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CWaveletCoi::OnShannon()
{
// TODO: Add your control notification handler code here
if(IsDlgButtonChecked(IDC_SHANNON))
{
m_bitmap.LoadBitmap(IDB_SHANNON);
m_strlength="0000";
InvalidateRect(&m_prectfunction);
UpdateWindow();
}
}
void CWaveletCoi::OnDaubechies()
{
// TODO: Add your control notification handler code here
if(IsDlgButtonChecked(IDC_DAUBECHIES))
{
CDaubechiesdlg daudlg;
if(daudlg.DoModal()==IDOK)
{
int i;
i=daudlg.m_nlength;
switch(i)
{
case 1:
m_bitmap.LoadBitmap(IDB_DAUBECHIES1);
break;
case 4:
m_bitmap.LoadBitmap(IDB_DAUBECHIES4);
break;
case 6:
m_bitmap.LoadBitmap(IDB_DAUBECHIES6);
break;
case 8:
m_bitmap.LoadBitmap(IDB_DAUBECHIES8);
break;
default:
m_bitmap.LoadBitmap(IDB_DAUBECHIES);
break;
}
m_strlength.Format("%d",2*i);
InvalidateRect(&m_prectfunction);
UpdateWindow();
}
}
}
void CWaveletCoi::OnMorlet()
{
// TODO: Add your control notification handler code here
if(IsDlgButtonChecked(IDC_MORLET))
{
m_bitmap.LoadBitmap(IDB_MORLET);
m_strlength="0000";
InvalidateRect(&m_prectfunction);
UpdateWindow();
}
}
void CWaveletCoi::OnMexicanhat()
{
// TODO: Add your control notification handler code here
if(IsDlgButtonChecked(IDC_MEXICANHAT))
{
m_bitmap.LoadBitmap(IDB_MEXICANHAT);
m_strlength="0000";
InvalidateRect(&m_prectfunction);
UpdateWindow();
}
}
void CWaveletCoi::OnMeyer()
{
// TODO: Add your control notification handler code here
if(IsDlgButtonChecked(IDC_MEYER))
{
m_bitmap.LoadBitmap(IDB_MEYER);
m_strlength="0000";
InvalidateRect(&m_prectfunction);
UpdateWindow();
}
}
void CWaveletCoi::OnBspline()
{
// TODO: Add your control notification handler code here
if(IsDlgButtonChecked(IDC_BSPLINE))
{
m_bitmap.LoadBitmap(IDB_BSPLINE);
m_strlength="0000";
InvalidateRect(&m_prectfunction);
UpdateWindow();
}
}
void CWaveletCoi::OnSymlets()
{
// TODO: Add your control notification handler code here
if(IsDlgButtonChecked(IDC_SYMLETS))
{
CSymletsdlg symdlg;
if(symdlg.DoModal()==IDOK)
{
int i;
i=symdlg.m_symlength;
switch(i)
{
case 4:
m_bitmap.LoadBitmap(IDB_SYMLETS4);
break;
case 6:
m_bitmap.LoadBitmap(IDB_SYMLETS6);
break;
case 8:
m_bitmap.LoadBitmap(IDB_SYMLETS8);
break;
default:
m_bitmap.LoadBitmap(IDB_SYMLETS);
break;
}
m_strlength.Format("%d",i*2);
InvalidateRect(&m_prectfunction);
UpdateWindow();
}
}
}
void CWaveletCoi::OnCoiflets()
{
// TODO: Add your control notification handler code here
if(IsDlgButtonChecked(IDC_COIFLETS))
{
m_bitmap.LoadBitmap(IDB_COIFLETS);
m_strlength="8";
InvalidateRect(&m_prectfunction);
UpdateWindow();
}
}
void CWaveletCoi::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
UpdateData(TRUE);
if((m_waveletfunction>=0)&&(m_waveletfunction<=7))
{
CDC dcmem;
dcmem.CreateCompatibleDC(&dc);
BITMAP bmp;
m_bitmap.GetBitmap(&bmp);
dcmem.SelectObject(m_bitmap);
double h,v;
h=double(bmp.bmWidth)/double(m_prectfunction.Width());
v=double(bmp.bmHeight)/double(m_prectfunction.Height());
if((h<=1)&&(v<=1))
{
dc.BitBlt(m_prectfunction.left+(m_prectfunction.Width()-bmp.bmWidth)/2,
m_prectfunction.top+(m_prectfunction.Height()-bmp.bmHeight)/2,
bmp.bmWidth,bmp.bmHeight,&dcmem,0,0,SRCCOPY);
}
else
{
if(h>v)
dc.StretchBlt(m_prectfunction.left,
m_prectfunction.top+int(m_prectfunction.Height()-bmp.bmHeight/h)/2,
m_prectfunction.Width(),int(bmp.bmHeight/h),
&dcmem,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
else
dc.StretchBlt(m_prectfunction.left+int(m_prectfunction.Width()-bmp.bmWidth/v)/2,
m_prectfunction.top,
int(bmp.bmWidth/v),m_prectfunction.Height(),
&dcmem,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
}
GetDlgItem(IDC_WAVELETLENGTH)->SetWindowText(m_strlength);
GetDlgItem(IDOK)->EnableWindow(TRUE);
m_bitmap.DeleteObject();
}
// Do not call CDialog::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -