?? projection2dlg.cpp
字號:
// projection2Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "projection2.h"
#include "projection2Dlg.h"
#include <math.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()
/////////////////////////////////////////////////////////////////////////////
// CProjection2Dlg dialog
CProjection2Dlg::CProjection2Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CProjection2Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CProjection2Dlg)
m_radio = -1;
m_L0_degree = 105.0;
m_L0_minute = 0.0;
m_L0_second = 0.0;
m_B0_degree = 15.0;
m_B0_minute = 0.0;
m_B0_second = 0.0;
m_scale = 1000000.0;
m_B_degree = 0.0;
m_B_minute = 0.0;
m_B_second = 0.0;
m_L_degree = 0.0;
m_L_minute = 0.0;
m_L_second = 0.0;
m_Bs = 0.0;
m_Lw = 105.0;
m_Bn = 25.0;
m_Le = 125.0;
m_deltaB = 5.0;
m_deltaL = 5.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CProjection2Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProjection2Dlg)
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Radio(pDX, IDC_RADIO1, m_radio);
DDX_Text(pDX, IDC_EDIT1, m_L0_degree);
DDX_Text(pDX, IDC_EDIT2, m_L0_minute);
DDX_Text(pDX, IDC_EDIT3, m_L0_second);
DDX_Text(pDX, IDC_EDIT4, m_B0_degree);
DDX_Text(pDX, IDC_EDIT5, m_B0_minute);
DDX_Text(pDX, IDC_EDIT6, m_B0_second);
DDX_Text(pDX, IDC_EDIT7, m_scale);
DDX_Text(pDX, IDC_EDIT8, m_B_degree);
DDX_Text(pDX, IDC_EDIT9, m_B_minute);
DDX_Text(pDX, IDC_EDIT10, m_B_second);
DDX_Text(pDX, IDC_EDIT11, m_L_degree);
DDX_Text(pDX, IDC_EDIT12, m_L_minute);
DDX_Text(pDX, IDC_EDIT13, m_L_second);
DDX_Text(pDX, IDC_EDIT14, m_Bs);
DDX_Text(pDX, IDC_EDIT15, m_Lw);
DDX_Text(pDX, IDC_EDIT16, m_Bn);
DDX_Text(pDX, IDC_EDIT17, m_Le);
DDX_Text(pDX, IDC_EDIT18, m_deltaB);
DDX_Text(pDX, IDC_EDIT19, m_deltaL);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CProjection2Dlg, CDialog)
//{{AFX_MSG_MAP(CProjection2Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnTransfer)
ON_BN_CLICKED(IDC_RADIO1, OnRadio)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CProjection2Dlg message handlers
BOOL CProjection2Dlg::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
// TODO: Add extra initialization here
m_list.InsertColumn(1,"序號",LVCFMT_CENTER);
m_list.InsertColumn(2,"緯度B",LVCFMT_CENTER);
m_list.InsertColumn(3,"經度L",LVCFMT_CENTER);
m_list.InsertColumn(4,"X",LVCFMT_CENTER);
m_list.InsertColumn(5,"Y",LVCFMT_CENTER);
m_list.InsertColumn(6,"u1",LVCFMT_CENTER);
m_list.InsertColumn(7,"u2",LVCFMT_CENTER);
m_list.InsertColumn(8,"p",LVCFMT_CENTER);
m_list.SetColumnWidth(0,100);
m_list.SetColumnWidth(1,100);
m_list.SetColumnWidth(2,100);
m_list.SetColumnWidth(3,100);
m_list.SetColumnWidth(4,100);
m_list.SetColumnWidth(5,100);
m_list.SetColumnWidth(6,100);
m_list.SetColumnWidth(7,100);
LONG lStyle = m_list.SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE);
lStyle |= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES |
LVS_EX_HEADERDRAGDROP;
m_list.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, (LPARAM)lStyle);
return TRUE; // return TRUE unless you set the focus to a control
}
void CProjection2Dlg::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 CProjection2Dlg::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 CProjection2Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CProjection2Dlg::OnTransfer()
{
// TODO: Add your control notification handler code here
UpdateData(true);
double L,B; //要進行計算的經緯度
double L0,B0; //中央子午線經度及標準緯線緯度
double f,d;
double X,Y;
double P,U1,U2; //變形
if(m_radio==0) //單點
{
m_list.DeleteAllItems();
L=(m_L_degree+m_L_minute/60+m_L_second/3600)*3.1415926/180; //將輸入的經緯度轉化成弧度
B=(m_B_degree+m_B_minute/60+m_B_second/3600)*3.1415926/180;
L0=(m_L0_degree+m_L0_minute/60+m_L0_second/3600)*3.1415926/180; //中央子午線
B0=(m_B0_degree+m_B0_minute/60+m_B0_second/3600)*3.1415926/180; //標準緯線
f=asin(0.00669342162297*sin(B));
X=100*6378245*cos(B0)*log((tan(3.1415926/4+B/2))/(tan(3.1415926/4+f/2)))*(1.0/1000000);
Y=100*6378245*cos(B0)*(L-L0)*(1.0/1000000);
U1=U2=6378245*cos(B0)/6378245*cos(B);
P=U1*U1;
CString str;
m_list.InsertItem(0,str);
m_list.SetItemText(0,0,"1");
str.Format("%f",B*180/3.1415926);
m_list.SetItemText(0,1,str);
str.Format("%f",L*180/3.1415926);
m_list.SetItemText(0,2,str);
str.Format("%f",X);
m_list.SetItemText(0,3,str);
str.Format("%f",Y);
m_list.SetItemText(0,4,str);
str.Format("%f",U1);
m_list.SetItemText(0,5,str);
str.Format("%f",U2);
m_list.SetItemText(0,6,str);
str.Format("%f",P);
m_list.SetItemText(0,7,str);
}
else
if(m_radio==1) //批量處理
{
m_list.DeleteAllItems();
int i=0;
double Bs=m_Bs*3.1415926/180;
double Bn=m_Bn*3.1415926/180;
double Lw=m_Lw*3.1415926/180;
double Le=m_Le*3.1415926/180;
double deltaB=m_deltaB*3.1415926/180;
double deltaL=m_deltaL*3.1415926/180;
for(B=Bs;B<(Bn+0.0000000001);B+=deltaB)
for (L=Lw;L<(Le+0.0000000001);L+=deltaL)
{
L0=105*3.1415926/180;
B0=15*3.1415926/180;
f=asin(0.00669342162297*sin(Bs*3.1415926/180));
X=100*6378245*cos(B0)*log((tan(3.1415926/4+B/2))/(tan(3.1415926/4+f/2)))*(1.0/1000000);
Y=100*6378245*cos(B0)*(L-L0)*(1.0/1000000);
// U1=U2=6378245*cos(B0*3.1415926/180)/6378245*cos(B);
U1=U2=(6378245*cos(B0)/sqrt((1-0.00699342162297*(sin(L0))*sin(L0))))/(6378245*cos(B )/sqrt((1-0.00699342162297*(sin( B )*sin( B )))));
P=U1*U1;
CString str;
m_list.InsertItem(i,str);
str.Format("%d",i);
m_list.SetItemText(i,0,str);
str.Format("%f",B*180/3.1415926);
m_list.SetItemText(i,1,str);
str.Format("%f",L*180/3.1415926);
m_list.SetItemText(i,2,str);
str.Format("%f",X);
m_list.SetItemText(i,3,str);
str.Format("%f",Y);
m_list.SetItemText(i,4,str);
str.Format("%f",U1);
m_list.SetItemText(i,5,str);
str.Format("%f",U2);
m_list.SetItemText(i,6,str);
str.Format("%f",P);
m_list.SetItemText(i,7,str);
i++;
}
}
else
MessageBox("請選擇單點轉換或者多點轉換");
UpdateData(false );
}
void CProjection2Dlg::OnRadio()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_EDIT8)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT9)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT10)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT11)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT12)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT13)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT14)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT15)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT16)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT17)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT18)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT19)->EnableWindow(FALSE);
}
void CProjection2Dlg::OnRadio2()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_EDIT14)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT15)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT16)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT17)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT18)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT19)->EnableWindow(TRUE);
GetDlgItem(IDC_EDIT8)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT9)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT10)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT11)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT12)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT13)->EnableWindow(FALSE);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -