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

📄 btworthfilterview.cpp

📁 Butterworth算法的图形化显示
💻 CPP
字号:
// BtworthFilterView.cpp : implementation of the CBtworthFilterView class
//

#include "stdafx.h"
#include "BtworthFilter.h"

#include "BtworthFilterDoc.h"
#include "BtworthFilterView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CBtworthFilterView

IMPLEMENT_DYNCREATE(CBtworthFilterView, CView)

BEGIN_MESSAGE_MAP(CBtworthFilterView, CView)
	//{{AFX_MSG_MAP(CBtworthFilterView)
	ON_COMMAND(ID_BUTTON32771, OnButton32771)
	//}}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()

/////////////////////////////////////////////////////////////////////////////
// CBtworthFilterView construction/destruction

CBtworthFilterView::CBtworthFilterView()
{
	// TODO: add construction code here

}

CBtworthFilterView::~CBtworthFilterView()
{
}

BOOL CBtworthFilterView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CBtworthFilterView drawing

void CBtworthFilterView::OnDraw(CDC* pDC)
{
	CBtworthFilterDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CBtworthFilterView printing

BOOL CBtworthFilterView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CBtworthFilterView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CBtworthFilterView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CBtworthFilterView diagnostics

#ifdef _DEBUG
void CBtworthFilterView::AssertValid() const
{
	CView::AssertValid();
}

void CBtworthFilterView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CBtworthFilterDoc* CBtworthFilterView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBtworthFilterDoc)));
	return (CBtworthFilterDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CBtworthFilterView message handlers

void CBtworthFilterView::OnButton32771() 
{
	CPen curPen(PS_SOLID,1,RGB(0,0,0));
	
	CClientDC	theClientDC(this);	
	theClientDC.MoveTo(0,400) ;
	theClientDC.LineTo(900,400);
	for(int i=0;i<=300;i+=60)
	{
		theClientDC.MoveTo(i*3,400-20) ;
		theClientDC.LineTo(i*3,400+20) ;
	}

	CButterworthDesigner ButterworthDesigner;
	double x[300];
	double y[300];
	double b[200];
	double a[200];

//	ButterworthDesigner.ButterworthLowPassDesign(512.0,b,a);
//	ButterworthDesigner.ButterworthGainC(b,a,2,x,y); 
//	theClientDC.MoveTo(0*3,400-(int)(x[0]*300.0)) ;
//	for(i=0;i<300;i++)
//	{
//		theClientDC.LineTo(i*3,400-(int)(x[i]*300.0)) ;
//	}

	ButterworthDesigner.ButterworthBandPassDesign(0.0,31.0,b,a);
	ButterworthDesigner.ButterworthGainC(b,a,4,x,y); 
	theClientDC.MoveTo(0,400-(int)(x[0]*300.0)) ;
	for(i=0;i<300;i++)
	{
		theClientDC.LineTo(i*3,400-(int)(x[i]*300.0)) ;
	}

}

⌨️ 快捷键说明

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