📄 oscillograph3view.cpp
字号:
// oscillograph3View.cpp : implementation of the COscillograph3View class
//
#include "stdafx.h"
#include "oscillograph3.h"
#include "oscillograph3Doc.h"
#include "oscillograph3View.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define PI 2*asin(1)
/////////////////////////////////////////////////////////////////////////////
// COscillograph3View
IMPLEMENT_DYNCREATE(COscillograph3View, CFormView)
BEGIN_MESSAGE_MAP(COscillograph3View, CFormView)
ON_MESSAGE(WM_MYBTNLBDOWN, OnMyBtnLBDown)
ON_MESSAGE(WM_CHANGEVALUE, OnChangeValue)
//{{AFX_MSG_MAP(COscillograph3View)
ON_WM_SIZE()
ON_WM_CTLCOLOR()
ON_WM_TIMER()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COscillograph3View construction/destruction
COscillograph3View::COscillograph3View()
: CFormView(COscillograph3View::IDD)
{
//{{AFX_DATA_INIT(COscillograph3View)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// TODO: add construction code here
m_dMsDiv = 0.08;
m_dMsDiv1 = 0.08;
m_dMsDiv2 = 0.08;
m_dMsDiv3 = 0.08;
m_dVDiv = 1.0;
m_dVDiv1 = 1.0;
m_dVDiv2 = 1.0;
m_dVDiv3 = 1.0;
m_nTimes1 = 0;
m_nCurrentChannel = 1;
m_bSuspend = FALSE;
m_bShow = FALSE;
}
COscillograph3View::~COscillograph3View()
{
}
void COscillograph3View::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COscillograph3View)
DDX_Control(pDX, IDC_VDIV_SLIDER, m_vDivSliderCtrl);
DDX_Control(pDX, IDC_MSDIV_SLIDER, m_msDivSliderCtrl);
//}}AFX_DATA_MAP
}
BOOL COscillograph3View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void COscillograph3View::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
//*****
m_controlpos.SetParent(this);
//
m_controlpos.AddControl(IDC_SCREEN);
m_controlpos.AddControl(IDC_MSDIV_SLIDER);
m_controlpos.AddControl(IDC_VDIV_SLIDER);
m_controlpos.AddControl(IDC_QUIT);
m_controlpos.AddControl(IDC_SUSPEND);
m_controlpos.AddControl(IDC_SHOW);
m_controlpos.AddControl(IDC_SHOWOLD);
m_controlpos.AddControl(IDC_SAVE);
m_controlpos.AddControl(IDC_SAMPLE);
m_controlpos.AddControl(IDC_CHANNEL_TITLE);
m_controlpos.AddControl(IDC_CHANNELRECT);
m_controlpos.AddControl(IDC_CHANNEL1);
m_controlpos.AddControl(IDC_CHANNEL2);
m_controlpos.AddControl(IDC_CHANNEL3);
m_controlpos.AddControl(ID_TITLE);
m_controlpos.AddControl(IDC_MSDIV_TITILE);
m_controlpos.AddControl(IDC_VDIV_TITLE);
//*****
m_oscopeCtrl.Create(this,IDC_SCREEN);
//*****
m_msDivSliderCtrl.SetCurrentValue(0.08);
m_msDivSliderCtrl.SetBkClr(RGB(166,202,240));
//*****
m_vDivSliderCtrl.SetBkClr(RGB(166,202,240));
m_vDivSliderCtrl.SetMaxValue(7.0);
m_vDivSliderCtrl.SetMinValue(0.0);
m_vDivSliderCtrl.SetPlusValue(0.5);
m_vDivSliderCtrl.SetMaxAngle(195);
m_vDivSliderCtrl.SetMinAngle(-15);
m_vDivSliderCtrl.SetCurrentValue(1.0);
//*****
m_myQuitBtn[0].Create(this,IDC_QUIT,1);
m_myQuitBtn[0].SetState(2);
m_myQuitBtn[0].SetFrontClr(RGB(67,159,180));
m_myQuitBtn[0].SetShapeClr(RGB(94,103,108));
m_myQuitBtn[1].Create(this,IDC_SUSPEND,2);
m_myQuitBtn[1].SetState(2);
m_myQuitBtn[1].SetFrontClr(RGB(67,159,180));
m_myQuitBtn[1].SetShapeClr(RGB(94,103,108));
m_myQuitBtn[2].Create(this,IDC_SHOW,3);
m_myQuitBtn[2].SetFrontClr(RGB(67,159,180));
m_myQuitBtn[2].SetShapeClr(RGB(94,103,108));
m_myQuitBtn[3].Create(this,IDC_SHOWOLD,3);
m_myQuitBtn[3].SetState(2);
m_myQuitBtn[3].SetFrontClr(RGB(67,159,180));
m_myQuitBtn[3].SetShapeClr(RGB(94,103,108));
m_myQuitBtn[4].Create(this,IDC_SAVE,3);
m_myQuitBtn[4].SetState(2);
m_myQuitBtn[4].SetFrontClr(RGB(67,159,180));
m_myQuitBtn[4].SetShapeClr(RGB(94,103,108));
m_myQuitBtn[5].Create(this,IDC_SAMPLE,3);
m_myQuitBtn[5].SetFrontClr(RGB(67,159,180));
m_myQuitBtn[5].SetShapeClr(RGB(94,103,108));
//
m_myQuitBtn[6].Create(this,IDC_CHANNEL1,3);
// m_myQuitBtn[6].SetFrontClr(RGB(67,159,180));
// m_myQuitBtn[6].SetShapeClr(RGB(128,128,128));
m_myQuitBtn[6].SetShape(2);
m_myQuitBtn[6].SetIsSelected(TRUE);
m_myQuitBtn[7].Create(this,IDC_CHANNEL2,3);
m_myQuitBtn[7].SetShape(2);
m_myQuitBtn[8].Create(this,IDC_CHANNEL3,3);
m_myQuitBtn[8].SetShape(2);
//
m_myTextBtn[0].Create(this,ID_TITLE);
m_myTextBtn[0].SetTextClr(RGB(100,166,60));
m_myTextBtn[1].Create(this,IDC_MSDIV_TITILE);
m_myTextBtn[1].SetTextString("扫描时基(ms/div)");
m_myTextBtn[1].SetTextClr(RGB(0,0,255));
CFont textFont;
LOGFONT textLogFont;
textFont.CreateFont(14, 10, 0, 0, 0, FALSE, FALSE,
0, ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH |FF_ROMAN , "宋体");
textFont.GetLogFont(&textLogFont);
m_myTextBtn[1].SetTextFont(&textLogFont);
m_myTextBtn[2].Create(this,IDC_VDIV_TITLE);
m_myTextBtn[2].SetTextString("增益(v/div)");
m_myTextBtn[2].SetTextClr(RGB(0,0,255));
m_myTextBtn[2].SetTextFont(&textLogFont);
m_myTextBtn[3].Create(this,IDC_CHANNEL_TITLE);
m_myTextBtn[3].SetTextString("通道选择");
m_myTextBtn[3].SetTextClr(RGB(0,0,255));
m_myTextBtn[3].SetTextFont(&textLogFont);
textFont.DeleteObject();
}
/////////////////////////////////////////////////////////////////////////////
// COscillograph3View printing
BOOL COscillograph3View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void COscillograph3View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void COscillograph3View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void COscillograph3View::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// COscillograph3View diagnostics
#ifdef _DEBUG
void COscillograph3View::AssertValid() const
{
CFormView::AssertValid();
}
void COscillograph3View::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
COscillograph3Doc* COscillograph3View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(COscillograph3Doc)));
return (COscillograph3Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COscillograph3View message handlers
void COscillograph3View::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
m_controlpos.MoveControls();
//
if(m_oscopeCtrl.GetSafeHwnd())
{
m_oscopeCtrl.Reset();
}
}
HBRUSH COscillograph3View::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if (nCtlColor == CTLCOLOR_DLG)
{
if(m_BkBrush.GetSafeHandle())
{
m_BkBrush.DeleteObject();
}
m_BkBrush.CreateSolidBrush(RGB(192,220,192));
hbr = (HBRUSH)m_BkBrush.GetSafeHandle();
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
LRESULT COscillograph3View::OnMyBtnLBDown(WPARAM wParam, LPARAM lParam)
{
if (wParam == IDC_QUIT)
{
AfxGetApp()->GetMainWnd()->PostMessage(WM_CLOSE);
}
if (wParam == IDC_SUSPEND)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -