RegPtDLG.cpp
上传用户:lbr_007
上传日期:2019-05-31
资源大小:282k
文件大小:3k
- // RegPtDLG.cpp : implementation file
- //
- #include "stdafx.h"
- #include "tiffsample.h"
- #include "RegPtDLG.h"
- #include <geo.h>
- #include <StringUtil.h>
- using namespace std;
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- namespace RPTSettings {
- double alt = 5000;
- int num = 1;
- };
- /////////////////////////////////////////////////////////////////////////////
- // RegPtDLG dialog
- RegPtDLG::RegPtDLG(CWnd* pParent /*=NULL*/)
- : CDialog(RegPtDLG::IDD, pParent)
- {
- //{{AFX_DATA_INIT(RegPtDLG)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- m_alt = m_lat = m_lon = 0.0;
- }
- void RegPtDLG::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(RegPtDLG)
- DDX_Control(pDX, IDC_ALT_EDIT, m_altEdit);
- DDX_Control(pDX, IDC_NAME_EDIT, m_nameEdit);
- DDX_Control(pDX, IDC_LON_EDIT, m_lonEdit);
- DDX_Control(pDX, IDC_LAT_EDIT, m_latEdit);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(RegPtDLG, CDialog)
- //{{AFX_MSG_MAP(RegPtDLG)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // RegPtDLG message handlers
- BOOL RegPtDLG::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- string s;
- GeoCalc::EncodeLatitude(m_lat, s);
- m_latEdit.SetWindowText(s.c_str());
- GeoCalc::EncodeLongitude(m_lon, s);
- m_lonEdit.SetWindowText(s.c_str());
- char txt[24];
- if (m_alt < 0.10)
- sprintf(txt,"%1.f",RPTSettings::alt);
- else
- sprintf(txt,"%.1f",m_alt);
- m_altEdit.SetWindowText(txt);
- if (m_name.length() == 0)
- sprintf(txt,"P%d",RPTSettings::num++);
- else
- sprintf(txt,"%s",m_name.c_str());
- m_nameEdit.SetWindowText(txt);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void RegPtDLG::OnOK()
- {
- CString cs;
- m_nameEdit.GetWindowText(cs);
- if (cs.GetLength() > 0)
- {
- m_name = (const char *)(LPCTSTR)cs;
- m_latEdit.GetWindowText(cs);
- m_lat = GeoCalc::DecodeLatitude((LPCTSTR)cs);
- m_lonEdit.GetWindowText(cs);
- m_lon = GeoCalc::DecodeLongitude((LPCTSTR)cs);
- m_altEdit.GetWindowText(cs);
- string s = (LPCTSTR)cs;
- if (StringUtil::IsFloatNumber(s))
- {
- m_alt = atof(s.c_str());
- RPTSettings::alt = m_alt;
- }
- else
- {
- AfxMessageBox("Altitude must be a real number",MB_ICONERROR);
- return;
- }
- }
- else
- {
- AfxMessageBox("You must enter a name for this click-point",MB_ICONERROR);
- return;
- }
-
- CDialog::OnOK();
- }