📄 mycoordinateconvdlg.cpp
字号:
// MyCoordinateConvDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MyCoordinateConv.h"
#include "MyCoordinateConvDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyCoordinateConvDlg dialog
CMyCoordinateConvDlg::CMyCoordinateConvDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyCoordinateConvDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyCoordinateConvDlg)
m_dlLatB1 = 38.7;
m_dlLonB1 = 121.4;
m_dlC1 = 90.0;
m_dlV1 = 10.0;
m_dlLatE1 = 0.0;
m_dlLonE1 = 0.0;
m_dlLatB2 = 38.6;
m_dlLonB2 = 121.7;
m_dlC2 = 90.0;
m_dlV2 = 20.0;
m_dlLatE2 = 0.0;
m_dlLonE2 = 0.0;
m_dlT = 0.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMyCoordinateConvDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyCoordinateConvDlg)
DDX_Text(pDX, IDC_LATB1, m_dlLatB1);
DDX_Text(pDX, IDC_LONB1, m_dlLonB1);
DDX_Text(pDX, IDC_C1, m_dlC1);
DDX_Text(pDX, IDC_V1, m_dlV1);
DDX_Text(pDX, IDC_LATE1, m_dlLatE1);
DDX_Text(pDX, IDC_LONE1, m_dlLonE1);
DDX_Text(pDX, IDC_LATB2, m_dlLatB2);
DDX_Text(pDX, IDC_LONB2, m_dlLonB2);
DDX_Text(pDX, IDC_C2, m_dlC2);
DDX_Text(pDX, IDC_V2, m_dlV2);
DDX_Text(pDX, IDC_LATE2, m_dlLatE2);
DDX_Text(pDX, IDC_LONE2, m_dlLonE2);
DDX_Text(pDX, IDC_TIMER, m_dlT);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyCoordinateConvDlg, CDialog)
//{{AFX_MSG_MAP(CMyCoordinateConvDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyCoordinateConvDlg message handlers
BOOL CMyCoordinateConvDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// SetIcon(m_hIcon, TRUE); // Set small icon
// TODO: Add extra initialization here
InitCoordinateConvDll();
return TRUE; // return TRUE unless you set the focus to a control
}
void CMyCoordinateConvDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMyCoordinateConvDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMyCoordinateConvDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMyCoordinateConvDlg::OnButton1()
{
// TODO: Add your control notification handler code here
int nProjection,iXMin,iYMin;
double dlScale,dlBaseLat;
InitChart(&nProjection,&iXMin,&iYMin,&dlScale,&dlBaseLat);
// SetMapParm(dlScale,nProjection,dlBaseLat,0,0,iXMin,iYMin);
/*
m_dlLonB1 = 121.4;
m_dlLonb2 = 121.7;
m_dlLone1 = 0.0;
m_dlLone2 = 0.0;
m_dlV1 = 10.0;
m_dlV2 = 20.0;
m_dlLatb1 = 38.7;
m_dlLatb2 = 38.6;
*/
// double dlX,dlY;
// LongLatToXY(&dlX,&dlY,m_dlLatb1,m_dlLonB1);
SetTimer(1,1000,NULL);
}
void CMyCoordinateConvDlg::InitChart(int* nProjection,int* iXMin,int* iYMin,double* dlScale,double* dlBaseLat)
{
FILE* fl = fopen("ChtHead.HAD","rt");
if(fl == NULL) return;
char strBuf[256];
CString strTmp,strDat;
int iData;
CString strTemp,strData;
while(!feof(fl))
{
fscanf(fl,"%s",strBuf);
strTmp = strBuf;
if(strTmp == "[投影类型]")
{
fscanf(fl,"%d",nProjection);
continue;
}
if(strTmp == "[最小控制点值]")
{
fscanf(fl,"%s",strBuf);
strTemp = strBuf;
iData = strTemp.Find(",");
strData = strTemp.Left(iData);
*iXMin = atoi(strData.GetBuffer(30));
strTemp = strTemp.Right(strTemp.GetLength() - iData -1);
*iYMin = atoi(strTemp.GetBuffer(30));
continue;
}
if(strTmp == "[投影常数]")
{
fscanf(fl,"%s,",strBuf);
strTemp = strBuf;
iData = strTemp.Find(",");
strData = strTemp.Left(iData);
*dlBaseLat = atof(strData.GetBuffer(30));
}
if(strTmp == "[海图比例尺]")
{
float flData;
fscanf(fl,"%f",&flData);
*dlScale = flData;
continue;
}
}
fclose(fl);
}
void CMyCoordinateConvDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
m_dlT++;
StartLatLonCSToEndLatLon(m_dlLatB1,m_dlLonB1,m_dlC1,m_dlV1*m_dlT/3600,&m_dlLatE1,&m_dlLonE1);
StartLatLonCSToEndLatLon(m_dlLatB2,m_dlLonB2,m_dlC2,m_dlV2*m_dlT/3600,&m_dlLatE2,&m_dlLonE2);
double t=m_dlLonB1;
char szBuf[128];
sprintf(szBuf,"%f",m_dlLatE1);
GetDlgItem(IDC_LATE1)->SetWindowText(szBuf);
sprintf(szBuf,"%f",m_dlLonE1);
GetDlgItem(IDC_LONE1)->SetWindowText(szBuf);
sprintf(szBuf,"%f",m_dlLatE2);
GetDlgItem(IDC_LATE2)->SetWindowText(szBuf);
sprintf(szBuf,"%f",m_dlLonE2);
GetDlgItem(IDC_LONE2)->SetWindowText(szBuf);
sprintf(szBuf,"%f",m_dlT);
GetDlgItem(IDC_TIMER)->SetWindowText(szBuf);
CDialog::OnTimer(nIDEvent);
}
//DEL void CMyCoordinateConvDlg::OnCancelMode()
//DEL {
//DEL CDialog::OnCancelMode();
//DEL
//DEL // TODO: Add your message handler code here
//DEL
//DEL }
//DEL void CMyCoordinateConvDlg::OnCaptureChanged(CWnd *pWnd)
//DEL {
//DEL // TODO: Add your message handler code here
//DEL }
//DEL void CMyCoordinateConvDlg::OnCancelMode()
//DEL {
//DEL CDialog::OnCancelMode();
//DEL
//DEL // TODO: Add your message handler code here
//DEL
//DEL }
void CMyCoordinateConvDlg::OnCancel()
{
// TODO: Add extra cleanup here
ExitCoordinateConvDll();
CDialog::OnCancel();
}
void CMyCoordinateConvDlg::OnOK()
{
// TODO: Add extra validation here
ExitCoordinateConvDll();
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -