📄 gsdlg.cpp
字号:
// GSDlg.cpp : implementation file
//
#include "stdafx.h"
#include "GS.h"
#include "GSDlg.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()
/////////////////////////////////////////////////////////////////////////////
// CGSDlg dialog
CGSDlg::CGSDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGSDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGSDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CGSDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGSDlg)
DDX_Control(pDX, IDC_D2, m_d2);
DDX_Control(pDX, IDC_D1, m_d1);
DDX_Control(pDX, IDC_RADIO4, m_r2);
DDX_Control(pDX, IDC_RADIO1, m_r1);
DDX_Control(pDX, IDC_EDIT3, m_l);
DDX_Control(pDX, IDC_EDIT2, m_b);
DDX_Control(pDX, IDC_EDIT6, m_y);
DDX_Control(pDX, IDC_EDIT5, m_x);
DDX_Control(pDX, IDC_EDIT1, m_zxjd);
DDX_Control(pDX, IDC_STATIC6, m_s6);
DDX_Control(pDX, IDC_STATIC5, m_s5);
DDX_Control(pDX, IDC_STATIC4, m_s4);
DDX_Control(pDX, IDC_STATIC3, m_s3);
DDX_Control(pDX, IDC_STATIC2, m_s2);
DDX_Control(pDX, IDC_STATIC1, m_s1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGSDlg, CDialog)
//{{AFX_MSG_MAP(CGSDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGSDlg message handlers
BOOL CGSDlg::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_r1.SetCheck(1);
m_r2.SetCheck(1);
OnRadio4();
OnRadio1();
return TRUE; // return TRUE unless you set the focus to a control
}
void CGSDlg::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 CGSDlg::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 CGSDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CGSDlg::OnRadio4()
{
// TODO: Add your control notification handler code here
m_s1.SetWindowText("B:");
m_s2.SetWindowText("L:");
m_s3.SetWindowText("H:");
m_s4.SetWindowText("X:");
m_s5.SetWindowText("Y:");
m_s6.SetWindowText("H:");
m_d1.SetWindowText("单位 (度)");
m_d2.SetWindowText("单位 (米)");
operation = 0;
}
void CGSDlg::OnRadio5()
{
// TODO: Add your control notification handler code here
m_s4.SetWindowText("B:");
m_s5.SetWindowText("L:");
m_s6.SetWindowText("H:");
m_s1.SetWindowText("X:");
m_s2.SetWindowText("Y:");
m_s3.SetWindowText("H:");
m_d1.SetWindowText("单位 (米)");
m_d2.SetWindowText("单位 (度)");
operation = 1;
}
void CGSDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
a = 6378245;
b = a - 1/298.3*a;
e = (a*a-b*b)/a/a;
}
void CGSDlg::OnRadio2()
{
// TODO: Add your control notification handler code here
a = 6378140;
b = a - 1/298.257*a;
e = (a*a-b*b)/a/a;
}
void CGSDlg::OnRadio3()
{
// TODO: Add your control notification handler code here
a = 6378137;
b = a - 1/298.257223563*a;
e = (a*a-b*b)/a/a;
}
void CGSDlg::OnButton1()
{
// TODO: Add your control notification handler code here
double pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
CString str;
if(operation==0)
{
double a0,a2,a4,a6,a8,X;
double B;
m_b.GetWindowText(str);
B = atof(str)*pi/180;
a0 = a*(1-e*e)*(1+3.0/4.0*e*e+45.0/64.0*pow(e,4)+
350.0/512.0*pow(e,6)+11025.0/16384.0*pow(e,8));
a2 = -1/2.0*a*(1-e*e)*(3.0/4.0*e*e+60.0/64.0*pow(e,4)+
525.0/512.0*pow(e,6)+17640.0/16384.0*pow(e,8));
a4 = 1/4.0*a*(1-e*e)*(15.0/64.0*pow(e,4)+210.0/512.0*pow(e,6)
+8820.0/16384.0*pow(e,8));
a6 = -1/6.0*a*(1-e*e)*(35.0/512.0*pow(e,6) + 2520.0/16384.0*pow(e,8));
a8 = 1/8.0*a*(1-e*e)*(315.0/16384.0*pow(e,8));
X = a0*B + a2*sin(2*B) + a4*sin(4*B) +a6*sin(6*B) + a8*sin(8*B);
double p,t,n,V,N,c,l0,L0,L00,e1;
m_l.GetWindowText(str);
L0 = atof(str);
m_zxjd.GetWindowText(str);
L00 = atof(str);
t = tan(B);
e1 = sqrt((a*a-b*b)/(b*b));
n = sqrt(e1*e1*cos(B)*cos(B));
V = sqrt(1+n*n);
c = a/sqrt(1-e*e);
l0 = L0-L00;
N = c/V;
p = cos(B)*l0/(180/pi);
double x,y;
x = X + N *t *(1+((5-pow(t,2)+(9+4*n*n)*n*n)+(61+(t*t-58)*t*t)*p*p/30)*p*p/12.0)*p*p/2.0;
y = N*(1+((1-t*t+n*n) + (5+t*t*(t*t-18-58*n*n)+14*n*n)*p*p/20.0)*p*p/6)*p+500000;
char buf[15];
sprintf(buf,"%f",x);
m_x.SetWindowText(buf);
sprintf(buf,"%f",y);
m_y.SetWindowText(buf);
}
else if(operation == 1)
{
double e1,a0,x;
m_b.GetWindowText(str);
x = atof(str);
CString str;
m_b.GetWindowText(str);
x = atof(str);
e1 = sqrt((a*a-b*b)/b/b);
a0 = a*(1-e*e)*(1+3.0/4.0*e*e+45.0/64.0*pow(e,4)+350.0/512.0*pow(e,6)
+11025.0/16384.0*pow(e,8));
double q0,q2,q4,q6,q8;
q0 = 1/a0;
q2 = 1.0/2.0*(3.0/4.0*pow(e,2)+45.0/64.0*pow(e,4) + 350.0/512.0*pow(e,6)
+ 11025.0/16384.0*pow(e,8));
q4 = -1.0/3.0*(63.0/64.0*pow(e,4) + 1108.0/512.0 * pow(e,6)
+ 58239.0/16384.0* pow(e,8));
q6 = 1/3.0*(604.0/512.0 * pow(e,6) + 68484.0/16384.0 * pow(e,8));
q8 = 1.0/3.0*(26328.0/16384*pow(e,8));
double B0,Bf;;
B0 = x*q0;
Bf = B0+sin(2*B0)*(q2 + pow(sin(B0),2)*(q4+sin(B0)*sin(B0)*(q6+q8*sin(B0)*sin(B0))));
double tf,nf,Vf,Nf,c;
c = a/sqrt(1-e*e);
tf = tan(Bf);
nf = sqrt(e1*e1*cos(Bf)*cos(Bf));
Vf = sqrt(1+nf*nf);
Nf = c/Vf;
double q,y;
m_l.GetWindowText(str);
y = atof(str);
q = (y-500000)/Nf;
double k;
m_zxjd.GetWindowText(str);
k = atof(str);
double Bm = Bf*180/pi - 180/pi * Vf*Vf*tf*(1+(-(5+3*tf*tf+nf*nf*(1-9*tf*tf))+(61
+45*tf*tf*(2+tf*tf))*q*q/30)*q*q/12)*q*q/2;
double lm = 180/pi*q/cos(Bf)*(1+(-(1+2*tf*tf+nf*nf) + (5+4*tf*tf*(7+6*tf*tf)
+ 2*nf*nf*(3+4*tf*tf))*q*q/20)*q*q/6) + k;
char buf[15];
sprintf(buf,"%f",Bm);
m_x.SetWindowText(buf);
sprintf(buf,"%f",lm);
m_y.SetWindowText(buf);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -