⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlgidwt.cpp

📁 这是一个有关一维信号小波分解与重构的VC++源程序
💻 CPP
字号:
// DlgIDWT.cpp : implementation file
//

#include "stdafx.h"
#include "wavelet.h"
#include "DlgIDWT.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgIDWT dialog


CDlgIDWT::CDlgIDWT(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgIDWT::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgIDWT)
	m_low1 = 1.0;
	m_low2 = 1.0;
	m_low3 = 1.0;
	m_low4 = 1.0;
	m_low5 = 1.0;
	m_low6 = 1.0;
	m_low7 = 1.0;
	m_low8 = 1.0;
	m_low9 = 1.0;
	m_low10 = 1.0;
	m_high1 = 1.0;
	m_high2 = 1.0;
	m_high3 = 1.0;
	m_high4 = 1.0;
	m_high5 = 1.0;
	m_high6 = 1.0;
	m_high7 = 1.0;
	m_high8 = 1.0;
	m_high9 = 1.0;
	m_high10 = 1.0;
	m_string = _T("");
	//}}AFX_DATA_INIT
	
	
}


void CDlgIDWT::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgIDWT)
	DDX_Text(pDX, IDC_EDIT1, m_low1);
	DDX_Text(pDX, IDC_EDIT3, m_low2);
	DDX_Text(pDX, IDC_EDIT5, m_low3);
	DDX_Text(pDX, IDC_EDIT7, m_low4);
	DDX_Text(pDX, IDC_EDIT9, m_low5);
	DDX_Text(pDX, IDC_EDIT11, m_low6);
	DDX_Text(pDX, IDC_EDIT13, m_low7);
	DDX_Text(pDX, IDC_EDIT15, m_low8);
	DDX_Text(pDX, IDC_EDIT17, m_low9);
	DDX_Text(pDX, IDC_EDIT19, m_low10);
	DDX_Text(pDX, IDC_EDIT2, m_high1);
	DDX_Text(pDX, IDC_EDIT4, m_high2);
	DDX_Text(pDX, IDC_EDIT6, m_high3);
	DDX_Text(pDX, IDC_EDIT8, m_high4);
	DDX_Text(pDX, IDC_EDIT10, m_high5);
	DDX_Text(pDX, IDC_EDIT12, m_high6);
	DDX_Text(pDX, IDC_EDIT14, m_high7);
	DDX_Text(pDX, IDC_EDIT16, m_high8);
	DDX_Text(pDX, IDC_EDIT18, m_high9);
	DDX_Text(pDX, IDC_EDIT20, m_high10);
	DDX_Text(pDX, IDC_EDIT21, m_string);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgIDWT, CDialog)
	//{{AFX_MSG_MAP(CDlgIDWT)
	ON_BN_CLICKED(IDC_BUTTON1, OnInput)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgIDWT message handlers

void CDlgIDWT::OnOK() 
{
		
	UpdateData(true);
	low1=m_low1;
	low2=m_low2;
	low3=m_low3;
	low4=m_low4;
	low5=m_low5;
	low6=m_low6;
	low7=m_low7;
	low8=m_low8;
	low9=m_low9;
	low10=m_low10;
	
	high1=m_high1;
	high2=m_high2;
	high3=m_high3;
	high4=m_high4;
	high5=m_high5;
	high6=m_high6;
	high7=m_high7;
	high8=m_high8;
	high9=m_high9;
	high10=m_high10;
	
	int tmpDataLength,tmp,Jtmp;
	int i,j;
	
	if(low1!=1.0||high1!=1.0)
	{
		Jtmp=0;
		tmpDataLength=0;
		for(i=1;i<=1;i++)
		{
			tmp=1<<i;
			tmpDataLength+=DataLength*2/tmp;
		}
		for (i = 0; i <DataLength/tmp; i ++)
		{	
			c[i+tmpDataLength]=c[i+tmpDataLength]*low1;
			d[i+tmpDataLength]=d[i+tmpDataLength]*high1;
			
		}  
	}	

	if(low2!=1.0||high2!=1.0)
	{
		Jtmp=0;
		tmpDataLength=0;
		for(i=1;i<=2;i++)
		{
			tmp=1<<i;
			tmpDataLength+=DataLength*2/tmp;
		}
		for (i = 0; i <DataLength/tmp; i ++)
		{	
			c[i+tmpDataLength]=c[i+tmpDataLength]*low2;
			d[i+tmpDataLength]=d[i+tmpDataLength]*high2;
			
		}  
	}	

	if(low3!=1.0||high3!=1.0)
	{
		Jtmp=0;
		tmpDataLength=0;
		for(i=1;i<=3;i++)
		{
			tmp=1<<i;
			tmpDataLength+=DataLength*2/tmp;
		}
		for (i = 0; i <DataLength/tmp; i ++)
		{	
			c[i+tmpDataLength]=c[i+tmpDataLength]*low3;
			d[i+tmpDataLength]=d[i+tmpDataLength]*high3;
			
		}  
	}	

	if(low4!=1.0||high4!=1.0)
	{
		Jtmp=0;
		tmpDataLength=0;
		for(i=1;i<=4;i++)
		{
			tmp=1<<i;
			tmpDataLength+=DataLength*2/tmp;
		}
		for (i = 0; i <DataLength/tmp; i ++)
		{	
			c[i+tmpDataLength]=c[i+tmpDataLength]*low4;
			d[i+tmpDataLength]=d[i+tmpDataLength]*high4;
			
		}  
	}	

	if(low5!=1.0||high5!=1.0)
	{
		Jtmp=0;
		tmpDataLength=0;
		for(i=1;i<=5;i++)
		{
			tmp=1<<i;
			tmpDataLength+=DataLength*2/tmp;
		}
		for (i = 0; i <DataLength/tmp; i ++)
		{	
			c[i+tmpDataLength]=c[i+tmpDataLength]*low5;
			d[i+tmpDataLength]=d[i+tmpDataLength]*high5;
			
		}  
	}	

	if(low6!=1.0||high6!=1.0)
	{
		Jtmp=0;
		tmpDataLength=0;
		for(i=1;i<=6;i++)
		{
			tmp=1<<i;
			tmpDataLength+=DataLength*2/tmp;
		}
		for (i = 0; i <DataLength/tmp; i ++)
		{	
			c[i+tmpDataLength]=c[i+tmpDataLength]*low6;
			d[i+tmpDataLength]=d[i+tmpDataLength]*high6;
			
		}  
	}	

	if(low7!=1.0||high7!=1.0)
	{
		Jtmp=0;
		tmpDataLength=0;
		for(i=1;i<=7;i++)
		{
			tmp=1<<i;
			tmpDataLength+=DataLength*2/tmp;
		}
		for (i = 0; i <DataLength/tmp; i ++)
		{	
			c[i+tmpDataLength]=c[i+tmpDataLength]*low7;
			d[i+tmpDataLength]=d[i+tmpDataLength]*high7;
			
		}  
	}	

	if(low8!=1.0||high8!=1.0)
	{
		Jtmp=0;
		tmpDataLength=0;
		for(i=1;i<=8;i++)
		{
			tmp=1<<i;
			tmpDataLength+=DataLength*2/tmp;
		}
		for (i = 0; i <DataLength/tmp; i ++)
		{	
			c[i+tmpDataLength]=c[i+tmpDataLength]*low8;
			d[i+tmpDataLength]=d[i+tmpDataLength]*high8;
			
		}  
	}	

	if(low9!=1.0||high9!=1.0)
	{
		Jtmp=0;
		tmpDataLength=0;
		for(i=1;i<=9;i++)
		{
			tmp=1<<i;
			tmpDataLength+=DataLength*2/tmp;
		}
		for (i = 0; i <DataLength/tmp; i ++)
		{	
			c[i+tmpDataLength]=c[i+tmpDataLength]*low9;
			d[i+tmpDataLength]=d[i+tmpDataLength]*high9;
			
		}  
	}	
	
	CDialog::OnOK();
}

void CDlgIDWT::OnInput() 
{
	/*
	UpdateData(true);
		low1=m_low1;
		low2=m_low2;
		low3=m_low3;
		low4=m_low4;
		low5=m_low5;
		low6=m_low6;
		low7=m_low7;
		low8=m_low8;
		low9=m_low9;
		low10=m_low10;
		
		high1=m_high1;
		high2=m_high2;
		high3=m_high3;
		high4=m_high4;
		high5=m_high5;
		high6=m_high6;
		high7=m_high7;
		high8=m_high8;
		high9=m_high9;
		high10=m_high10;
		
		int tmpDataLength,tmp,Jtmp;
		int i,j;
	//	double temp1,temp2;
		CString str1,str2;
		
		char ctemp[5]="low0",dtemp[5]="hig0";
		
		Jtmp=0;
		tmpDataLength=0;
		for(j=0;j<9;j++)
		{
			ctemp[3]++;
			dtemp[3]++;
			str1.Format("%s",ctemp);
			str2.Format("%s",dtemp);
			str1="0.0";
			str2="0.0";
	        double temp1=atof(str1.GetBuffer(0));
			double temp2=atof(str2.GetBuffer(0));
			
			Jtmp++;
			
			for(i=1;i<=Jtmp;i++)
			{
				tmp=1<<i;
				tmpDataLength+=DataLength*2/tmp;
			}
			for (i = 0; i <DataLength/tmp; i ++)
			{	
				c[i+tmpDataLength]=c[i+tmpDataLength]*temp1;
				d[i+tmpDataLength]=d[i+tmpDataLength]*temp2;
				
			}  
			
			
		}*/
	
 	
}

BOOL CDlgIDWT::PreCreateWindow(CREATESTRUCT& cs) 
{
	CWnd* pWnd = GetDlgItem(IDC_EDIT21);
	// 指针
	CDC* pDC = pWnd->GetDC();
	pWnd->Invalidate();
	pWnd->UpdateWindow();

	// TODO: Add your specialized code here and/or call the base class
//	CStatic *pTxt=(CStatic *)GetDlgItem(IDC_STATIC);
//	CDC *pDC=pTxt->GetDC();
//	CRect rc;
//	pTxt->GetClientRect(&rc);
//	pDC->DrawText("123",&rc,DT_CENTER|DT_SINGLELINE|DT_VCENTER);
	pDC->TextOut(10,10,"6");
//	pTxt->ReleaseDC(pDC);
	
	return CDialog::PreCreateWindow(cs);
}

BOOL CDlgIDWT::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgIDWT::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	CString strTmp;
	CString str("    说明:你对曲线进行了 ");
	strTmp.Format("%d",J);
    str+=strTmp;
	str+=" 层小波分解,所以";
	str+="";
	str+="你最多只能对第 ";
    str+=strTmp;
	str+=" 层小波系数进行操作!";
	m_string=str;

	UpdateData(false);
/*
	CWnd* pWnd = GetDlgItem(IDC_EDIT21);
	// 指针
	CDC* pDC = pWnd->GetDC();
	pWnd->Invalidate();
	pWnd->UpdateWindow();
	*/

	// TODO: Add your specialized code here and/or call the base class
	//	CStatic *pTxt=(CStatic *)GetDlgItem(IDC_STATIC);
	//	CDC *pDC=pTxt->GetDC();
	//	CRect rc;
	//	pTxt->GetClientRect(&rc);
	//	pDC->DrawText("123",&rc,DT_CENTER|DT_SINGLELINE|DT_VCENTER);
//	pDC->TextOut(0,0,str);
	//	pTxt->ReleaseDC(pDC);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -