📄 gpsnavview.cpp
字号:
// GpsNavView.cpp : implementation of the CGpsNavView class
//
#include "stdafx.h"
#include "GpsNav.h"
#include "GpsNavDoc.h"
#include "Serial.h"
#include "GpsNavView.h"
#include "WptDlg.h"
#include "SerialSetupDlg.h"
#include "SelectPointDlg.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGpsNavView
IMPLEMENT_DYNCREATE(CGpsNavView, CFormView)
BEGIN_MESSAGE_MAP(CGpsNavView, CFormView)
//{{AFX_MSG_MAP(CGpsNavView)
ON_CBN_SELCHANGE(IDC_FORMAT, OnSelchangeFormat)
ON_BN_CLICKED(IDC_START, OnStart)
ON_BN_CLICKED(IDC_TO, OnTo)
ON_BN_CLICKED(IDC_FROM, OnFrom)
ON_BN_CLICKED(IDC_WPTSET, OnWptset)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGpsNavView construction/destruction
CGpsNavView::CGpsNavView()
: CFormView(CGpsNavView::IDD)
{
//{{AFX_DATA_INIT(CGpsNavView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CGpsNavView::~CGpsNavView()
{
}
void CGpsNavView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGpsNavView)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BOOL CGpsNavView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CGpsNavView diagnostics
#ifdef _DEBUG
void CGpsNavView::AssertValid() const
{
CFormView::AssertValid();
}
void CGpsNavView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CGpsNavDoc* CGpsNavView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGpsNavDoc)));
return (CGpsNavDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CGpsNavView message handlers
void CGpsNavView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
CComboBox *CtrlDis=(CComboBox *)GetDlgItem(IDC_FORMAT);
CtrlDis->AddString(TEXT("1.Dist/Bearing"));
CtrlDis->AddString(TEXT("2.Track.&.XTE"));
CtrlDis->AddString(TEXT("3.East/North"));
CtrlDis->AddString(TEXT("4.Velocity/Time"));
CtrlDis->SetCurSel(GetDocument()->nDisFormat);
}
void CGpsNavView::OnSelchangeFormat()
{
CComboBox *CtrlDis=(CComboBox *)GetDlgItem(IDC_FORMAT);
int nIndex = CtrlDis->GetCurSel();
if (nIndex != LB_ERR)
{
GetDocument()->nDisFormat=nIndex;
}
CMainFrame *pMain =(CMainFrame *)AfxGetMainWnd();
CGpsNavDoc *pDoc=(CGpsNavDoc *)GetDocument();
if(pDoc->m_Serial!=NULL)
{
pMain->ShowDisplayView();
}
}
void CGpsNavView::OnStart()
{
CMainFrame *pMain =(CMainFrame *)AfxGetMainWnd();
CGpsNavDoc *pDoc=(CGpsNavDoc *)GetDocument();
if(pDoc->m_Serial!=NULL)
{
pMain->ShowDisplayView();
return;
}
if(pDoc->m_Way.GetFPoint()==-1)
{
::AfxMessageBox(_T("Please Select From Point!"),MB_OK);
return;
}
if(pDoc->m_Way.GetTPoint()==-1)
{
::AfxMessageBox(_T("Please Select To Point!"),MB_OK);
return;
}
if(pDoc->m_Way.GetTPoint()==pDoc->m_Way.GetFPoint())
{
::AfxMessageBox(_T("FromPoint is the same to ToPoint!"),MB_OK);
return;
}
SerialSetupDlg dlg;
if(dlg.DoModal()!=IDOK)
{
return;
}
pDoc->m_Serial=new CSerial;
if(!(pDoc->m_Serial)->OpenPort(pMain,dlg.nPort,dlg.nBaudRate))
{
//error
delete pDoc->m_Serial;
pDoc->m_Serial=NULL;
return;
}
pMain->ShowDisplayView();
}
void CGpsNavView::OnTo()
{
SelectPointDlg dlg(1);
dlg.DoModal();
CGpsNavDoc *pDoc=(CGpsNavDoc *)GetDocument();
pDoc->m_Way.SetAfterward(pDoc->m_Way.GetFPoint());
if(pDoc->m_Way.GetFPoint()<pDoc->m_Way.GetTPoint())
{
pDoc->m_Way.SetForward(pDoc->m_Way.GetAfterward()+1);
}
else
{
pDoc->m_Way.SetForward(pDoc->m_Way.GetAfterward()-1);
}
}
void CGpsNavView::OnFrom()
{
SelectPointDlg dlg(0);
dlg.DoModal();
CGpsNavDoc *pDoc=(CGpsNavDoc *)GetDocument();
pDoc->m_Way.SetAfterward(pDoc->m_Way.GetFPoint());
if(pDoc->m_Way.GetFPoint()<pDoc->m_Way.GetTPoint())
{
pDoc->m_Way.SetForward(pDoc->m_Way.GetAfterward()+1);
}
else
{
pDoc->m_Way.SetForward(pDoc->m_Way.GetAfterward()-1);
}
}
void CGpsNavView::OnWptset()
{
CWptDlg dlg;
dlg.DoModal();
}
void CGpsNavView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -