📄 wavereduceview.cpp
字号:
// WaveReduceView.cpp : implementation of the CWaveReduceView class
//
#include "stdafx.h"
#include "math.h"
#include "WaveReduce.h"
#include "diang1.h"
#include "WaveReduceDoc.h"
#include "WaveReduceView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWaveReduceView
IMPLEMENT_DYNCREATE(CWaveReduceView, CView)
BEGIN_MESSAGE_MAP(CWaveReduceView, CView)
//{{AFX_MSG_MAP(CWaveReduceView)
ON_COMMAND(AFX_IDD_Wave, OnIDDWave)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWaveReduceView construction/destruction
CWaveReduceView::CWaveReduceView()
{
// TODO: add construction code here
int i=0;
for (i=0;i<11;i++)
Wave[i]=0;
}
CWaveReduceView::~CWaveReduceView()
{
}
BOOL CWaveReduceView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CWaveReduceView drawing
void CWaveReduceView::OnDraw(CDC* pDC)
{
CWaveReduceDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
//**********************************************************************
long int x,y;
int i;
long coordinate_origin_x=30;
long coordinate_origin_y=680;
char *coordinate[]={"","100","200","300","400","500","600","700","800","900","1000","1100","1200","1300"};
//横竖暗黄线
x=0;
y=0;
for( x=0; x<1024; x=x+100)
{
for (y=0;y<1024;y++)
{pDC->SetPixel(coordinate_origin_x+x,coordinate_origin_y-y,RGB(255,255,100));}
y=0;
}
x=0;
y=0;
for( y=0; y<1024; y=y+100)
{
for (x=0;x<1024;x++)
{pDC->SetPixel(coordinate_origin_x+x,coordinate_origin_y-y,RGB(255,255,100));}
x=0;
}
//横竖坐标
x=0;
for( x=0; x<1200; x++)
{pDC->SetPixel(x,coordinate_origin_y,RGB(255,0,0));}
y=0;
for( y=0; y<700; y++)
{pDC->SetPixel(coordinate_origin_x,y,RGB(255,0,0));}
//横竖坐标数字
x=0;
y=0;
i=0;
for( x=0; x<1024; x=x+100)
{
for (y=0;y<10;y++)
{
pDC->SetPixel(coordinate_origin_x+x,coordinate_origin_y-y,RGB(255,0,0));
}
pDC->TextOut(coordinate_origin_x+x-10,coordinate_origin_y+5,coordinate[i]);
i++;
y=0;
}
x=0;
y=0;
i=0;
for( y=0; y<1024; y=y+100)
{
for (x=0;x<10;x++)
{
pDC->SetPixel(coordinate_origin_x+x,coordinate_origin_y-y,RGB(255,0,0));
}
pDC->TextOut(coordinate_origin_x-25,coordinate_origin_y-y-10,coordinate[i]);
i++;
x=0;
}
//*********************************************************************************
//绘制各种波形Wave
//sin()
x=0;
y=0;
i=0;
long int wwww=100;//角速度倍数的倒数
long int VMax=200;//振幅
long int WW=10;//角速度
long int WWW=0;//初相
long int coordinate_origin_y_sin=300;//SIN 波形Y轴初始位置
double xx;//函数必须是双字节的数
//脉冲波
if( Wave[0]>0)
{
for( x=0; x<1024; x++)
{
xx=x;
if (sin(xx/wwww)>0)
{
y= coordinate_origin_y-coordinate_origin_y_sin - VMax;
pDC->SetPixel(coordinate_origin_x+x,y, RGB(255,0,0));
}
if (sin(xx/wwww)<0)
{
y= coordinate_origin_y-coordinate_origin_y_sin + VMax;
pDC->SetPixel(coordinate_origin_x+x,y, RGB(255,0,0));
}
if (sin(xx/wwww)>-0.005 && sin(xx/wwww)<0.005)
{
for (y=-1*VMax;y<VMax;y++)
{
pDC->SetPixel(coordinate_origin_x+x,
coordinate_origin_y-coordinate_origin_y_sin
+ y
,
RGB(255,0,0));
}
}
}
}
//正玄波
if( Wave[1]>0)
{
for( x=0; x<1024; x++)
{
xx=x;
y=coordinate_origin_y-coordinate_origin_y_sin - int(VMax*sin(xx/wwww));
pDC->SetPixel(coordinate_origin_x+x,y , RGB(255,0,0));
}
}
//3次谐波
if( Wave[2]>0)
{
for( x=0; x<1024; x++)
{
xx=x;
y=coordinate_origin_y-coordinate_origin_y_sin - int(VMax*sin(3*xx/wwww)/3);
pDC->SetPixel(coordinate_origin_x+x,y , RGB(255,0,0));
}
}
//5次谐波
if( Wave[3]>0)
{
for( x=0; x<1024; x++)
{
xx=x;
y=coordinate_origin_y-coordinate_origin_y_sin - int(VMax*sin(5*xx/wwww)/5);
pDC->SetPixel(coordinate_origin_x+x,y , RGB(255,0,0));
}
}
//7次谐波
if( Wave[4]>0)
{
for( x=0; x<1024; x++)
{
xx=x;
y=coordinate_origin_y-coordinate_origin_y_sin - int(VMax*sin(7*xx/wwww)/7);
pDC->SetPixel(coordinate_origin_x+x,y , RGB(255,0,0));
}
}
//9次谐波
if( Wave[5]>0)
{
for( x=0; x<1024; x++)
{
xx=x;
y=coordinate_origin_y-coordinate_origin_y_sin -int(VMax*sin(9*xx/wwww)/9);
pDC->SetPixel(coordinate_origin_x+x,y , RGB(255,0,0));
}
}
//合成波
if (Wave[6]+Wave[7]+Wave[8]+Wave[9]+Wave[10]>0)
{
for( x=0; x<1024; x++)
{
xx=x;
y=coordinate_origin_y-coordinate_origin_y_sin -int(VMax*sin(xx/wwww)) *Wave[6]
-int(VMax*sin(3*xx/wwww)/3)*Wave[7]
-int(VMax*sin(5*xx/wwww)/5)*Wave[8]
-int(VMax*sin(7*xx/wwww)/7)*Wave[9]
-int(VMax*sin(9*xx/wwww)/9)*Wave[10]
;
pDC->SetPixel(coordinate_origin_x+x,y , RGB(255,0,0));
}
}
//*********************************************************************
}
/////////////////////////////////////////////////////////////////////////////
// CWaveWaveView diagnostics
#ifdef _DEBUG
void CWaveReduceView::AssertValid() const
{
CView::AssertValid();
}
void CWaveReduceView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CWaveReduceDoc* CWaveReduceView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWaveReduceDoc)));
return (CWaveReduceDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CWaveReduceView message handlers
void CWaveReduceView::OnIDDWave()
{
// TODO: Add your command handler code here
CWaveReduceDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
Cdiang1 dlg;
//Reduce[i]=0;
//Wave[i]=0
if (Wave[0]>0)
{dlg.m_check1=TRUE;}
else
{dlg.m_check1=FALSE;}
if (Wave[1]>0)
{dlg.m_check2=TRUE;}
else
{dlg.m_check2=FALSE;}
if (Wave[2]>0)
{dlg.m_check3=TRUE;}
else
{dlg.m_check3=FALSE;}
if (Wave[3]>0)
{dlg.m_check4=TRUE;}
else
{dlg.m_check4=FALSE;}
if (Wave[4]>0)
{dlg.m_check5=TRUE;}
else
{dlg.m_check5=FALSE;}
if (Wave[5]>0)
{dlg.m_check6=TRUE;}
else
{dlg.m_check6=FALSE;}
if (Wave[6]>0)
{dlg.m_check7=TRUE;}
else
{dlg.m_check7=FALSE;}
if (Wave[7]>0)
{dlg.m_check8=TRUE;}
else
{dlg.m_check8=FALSE;}
if (Wave[8]>0)
{dlg.m_check9=TRUE;}
else
{dlg.m_check9=FALSE;}
if (Wave[9]>0)
{dlg.m_check10=TRUE;}
else
{dlg.m_check10=FALSE;}
if (Wave[10]>0)
{dlg.m_check11=TRUE;}
else
{dlg.m_check11=FALSE;}
int nResponse = dlg.DoModal();
if (nResponse == IDCANCEL)
{return;
}
if (dlg.m_check1==TRUE)
{Wave[0]=1;}
else
{Wave[0]=0;}
if (dlg.m_check2==TRUE)
{Wave[1]=1;}
else
{Wave[1]=0;}
if (dlg.m_check3==TRUE)
{Wave[2]=1;}
else
{Wave[2]=0;}
if (dlg.m_check4==TRUE)
{Wave[3]=1;}
else
{Wave[3]=0;}
if (dlg.m_check5==TRUE)
{Wave[4]=1;}
else
{Wave[4]=0;}
if (dlg.m_check6==TRUE)
{Wave[5]=1;}
else
{Wave[5]=0;}
if (dlg.m_check7==TRUE)
{Wave[6]=1;}
else
{Wave[6]=0;}
if (dlg.m_check8==TRUE)
{Wave[7]=1;}
else
{Wave[7]=0;}
if (dlg.m_check9==TRUE)
{Wave[8]=1;}
else
{Wave[8]=0;}
if (dlg.m_check10==TRUE)
{Wave[9]=1;}
else
{Wave[9]=0;}
if (dlg.m_check11==TRUE)
{Wave[10]=1;}
else
{Wave[10]=0;}
OnUpdate(NULL,NULL,NULL);
//pDoc->UpdateALLViews();
//*********************************************
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -