📄 dspview.cpp
字号:
// DSPView.cpp : implementation of the CDSPView class
//
#include "stdafx.h"
#include "DSP.h"
#include "DSPDoc.h"
#include "DSPView.h"
#include "dlg01.h"
#include "dlg02.h"
#include "dlg03.h"
#include "dlg04.h"
#include "dlg05.h"
#include "dlg06.h"
#include "dlg07.h"
#include "dlg08.h"
#include "dlg09.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDSPView
IMPLEMENT_DYNCREATE(CDSPView, CView)
BEGIN_MESSAGE_MAP(CDSPView, CView)
//{{AFX_MSG_MAP(CDSPView)
ON_COMMAND(IDM_ONE_ONE, OnOneOne)
ON_WM_MOUSEMOVE()
ON_COMMAND(IDM_ONE_TWO, OnOneTwo)
ON_COMMAND(IDM_ONE_THREE, OnOneThree)
ON_COMMAND(IDM_TWO_ONE, OnTwoOne)
ON_COMMAND(IDM_TWO_TWO, OnTwoTwo)
ON_COMMAND(IDM_TWO_THREE, OnTwoThree)
ON_COMMAND(IDM_THREE_ONE, OnThreeOne)
ON_COMMAND(IDM_THREE_TWO, OnThreeTwo)
ON_COMMAND(IDM_THREE_THREE, OnThreeThree)
ON_COMMAND(IDR_BACK, OnBack)
ON_WM_LBUTTONDOWN()
ON_WM_MOVE()
ON_WM_LBUTTONUP()
ON_WM_RBUTTONDOWN()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CDSPView construction/destruction
CDSPView::CDSPView()
{
// TODO: add construction code here
drawdiscrete=FALSE;
Xmax=1.0;
Xmin=0.0;
}
CDSPView::~CDSPView()
{
}
BOOL CDSPView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDSPView drawing
void CDSPView::OnDraw(CDC* pDC)
{
CDSPDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
SgnMaxNum=sgn.maxnum();
SgnMinNum=sgn.minnum();
RECT rect;
GetWindowRect(&rect);
WinXwidth=rect.right-rect.left;
WinYwidth=rect.bottom-rect.top;
PointXpixel=(WinXwidth-40.0)/sgn.length;
if (SgnMaxNum==SgnMinNum)
{
if (SgnMaxNum==0)
{
PointYpixel=0;
}
else
{
SgnMinNum=SgnMaxNum-WinYwidth/2;
PointYpixel=((WinYwidth-40.0)/(WinYwidth/1.0));
}
}
else
{
PointYpixel=(WinYwidth-40.0)/(SgnMaxNum-SgnMinNum);
}
pDC->MoveTo(20,20);
pDC->LineTo(20,WinYwidth-20);
pDC->MoveTo(20,WinYwidth-20);
pDC->LineTo(WinXwidth-20,WinYwidth-20);
if (!drawdiscrete)
DrawContinue(pDC);
else DrawDiscrete(pDC);
}
void CDSPView::DrawContinue(CDC* pDC)
{
pDC->MoveTo(20,WinYwidth-20);
for(int i=0;i<sgn.length;i++)
{
pDC->LineTo((int)(PointXpixel*i)+20,WinYwidth-20-(int)((sgn.sgnt[i]-SgnMinNum)*PointYpixel));
pDC->MoveTo((int)(PointXpixel*i)+20,WinYwidth-20-(int)((sgn.sgnt[i]-SgnMinNum)*PointYpixel));
}
}
void CDSPView::DrawDiscrete(CDC* pDC)
{
pDC->MoveTo(20,WinYwidth-20);
for(int i=0;i<sgn.length;i++)
{
pDC->MoveTo((int)(PointXpixel*i)+20,WinYwidth-20);
pDC->LineTo((int)(PointXpixel*i)+20,WinYwidth-20-(int)((sgn.sgnt[i]-SgnMinNum)*PointYpixel));
pDC->Ellipse((int)(PointXpixel*i)+18,WinYwidth-22-(int)((sgn.sgnt[i]-SgnMinNum)*PointYpixel),(int)(PointXpixel*i)+22,WinYwidth-18-(int)((sgn.sgnt[i]-SgnMinNum)*PointYpixel));
}
}
/////////////////////////////////////////////////////////////////////////////
// CDSPView printing
BOOL CDSPView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDSPView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDSPView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CDSPView diagnostics
#ifdef _DEBUG
void CDSPView::AssertValid() const
{
CView::AssertValid();
}
void CDSPView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CDSPDoc* CDSPView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDSPDoc)));
return (CDSPDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDSPView message handlers
void CDSPView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CString str;
double x=0.0;
double y=0.0;
double xtopi=0.0;
x=(point.x-20)/PointXpixel*(Xmax-Xmin)/sgn.length+Xmin;
xtopi=x/M_PI;
if (SgnMaxNum==sgn.minnum())
{
y=SgnMaxNum;
}
else
y=(WinYwidth-20-point.y)/PointYpixel+SgnMinNum;
str.Format("x=%4f(%4fpi),y=%4f",x,xtopi,y);
str=SgnTitle+str;
((CMainFrame *)GetParent())->m_wndStatusBar.SetPaneText(0,str);
CView::OnMouseMove(nFlags, point);
}
void CDSPView::OnOneOne()
{
// TODO: Add your command handler code here
CDlg01 dlg;
dlg.DoModal();
sgn=dlg.sgn;
drawdiscrete=dlg.drawdiscrete;
Xmax=sgn.length;
Xmin=0;
Invalidate();
}
void CDSPView::OnOneTwo()
{
// TODO: Add your command handler code here
CDlg02 dlg;
dlg.DoModal();
sgn=dlg.sgn;
drawdiscrete=dlg.drawdiscrete;
Xmax=sgn.length;
Xmin=0;
Invalidate();
}
void CDSPView::OnOneThree()
{
// TODO: Add your command handler code here
CDlg03 dlg;
dlg.DoModal();
sgn=dlg.sgn;
drawdiscrete=dlg.drawdiscrete;
Xmax=sgn.length;
Xmin=0;
Invalidate();
}
void CDSPView::OnTwoOne()
{
// TODO: Add your command handler code here
CDlg04 dlg;
dlg.DoModal();
sgn=dlg.sgn;
drawdiscrete=dlg.drawdiscrete;
Invalidate();
Xmax=2*M_PI;
Xmin=0;
}
void CDSPView::OnTwoTwo()
{
// TODO: Add your command handler code here
CDlg05 dlg;
dlg.DoModal();
sgn=dlg.sgn;
drawdiscrete=dlg.drawdiscrete;
Xmax=2*M_PI;
Xmin=0;
Invalidate();
}
void CDSPView::OnTwoThree()
{
// TODO: Add your command handler code here
CDlg06 dlg;
dlg.DoModal();
Invalidate();
}
void CDSPView::OnThreeOne()
{
// TODO: Add your command handler code here
CDlg07 dlg;
dlg.DoModal();
sgn=dlg.sgn;
drawdiscrete=dlg.drawdiscrete;
Xmax=2*M_PI;
Xmin=0;
Invalidate();
}
void CDSPView::OnThreeTwo()
{
// TODO: Add your command handler code here
CDlg08 dlg;
dlg.DoModal();
sgn=dlg.sgn;
drawdiscrete=dlg.drawdiscrete;
Xmax=2*M_PI;
Xmin=0;
Invalidate();
}
void CDSPView::OnThreeThree()
{
// TODO: Add your command handler code here
CDlg09 dlg;
dlg.DoModal();
sgn=dlg.sgn;
drawdiscrete=dlg.drawdiscrete;
Xmax=2*M_PI;
Xmin=0;
Invalidate();
}
void CDSPView::OnBack()
{
// TODO: Add your command handler code here
sgn=sgnback;
Invalidate();
}
void CDSPView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_ptOrign=point;
CView::OnLButtonDown(nFlags, point);
}
void CDSPView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
Dsignal sgntemp;
sgnback=sgn;
sgntemp=sgn;
int left;
int right;
if (point.x<m_ptOrign.x)
{
left=point.x;
right=m_ptOrign.x;
}
else
{
right=point.x;
left=m_ptOrign.x;
}
right=(int)floor(((right-20)/PointXpixel));
left=(int)ceil(((left-20)/PointXpixel));
sgntemp.Mid(left,right);
sgn=sgntemp;
Xmax=(Xmax-Xmin)/sgnback.length*right+Xmin;
Xmin=(Xmax-Xmin)/sgnback.length*left+Xmin;
Invalidate();
CView::OnRButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -