📄 projection1dlg.cpp
字号:
// projection1Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "projection1.h"
#include "projection1Dlg.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()
/////////////////////////////////////////////////////////////////////////////
// CProjection1Dlg dialog
CProjection1Dlg::CProjection1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CProjection1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CProjection1Dlg)
m_jingdu_fen = 0.0;
m_jingdu_miao = 0.0;
m_weidu_fen = 0.0;
m_weidu_miao = 0.0;
m_x = 0.0;
m_y = 0.0;
m_L0 = 0.0;
m_B0 = 0.0;
m_u1 = 0.0;
m_u2 = 0.0;
m_z = 0.0;
m_jingdu_du = 0.0;
m_weidu_du = 0.0;
m_Delta_B = 0.0;
m_Delta_L = 0.0;
m_jdbx_fen = 0;
m_jdbx_miao = 0;
m_jdbx_du = 0;
m_a = 0.0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CProjection1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CProjection1Dlg)
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Text(pDX, IDC_EDIT_jingdu_fen, m_jingdu_fen);
DDV_MinMaxDouble(pDX, m_jingdu_fen, 0., 60.);
DDX_Text(pDX, IDC_EDIT_jingdu_miao, m_jingdu_miao);
DDV_MinMaxDouble(pDX, m_jingdu_miao, 0., 60.);
DDX_Text(pDX, IDC_EDIT_weidu_fen, m_weidu_fen);
DDV_MinMaxDouble(pDX, m_weidu_fen, 0., 60.);
DDX_Text(pDX, IDC_EDIT_weidu_miao, m_weidu_miao);
DDV_MinMaxDouble(pDX, m_weidu_miao, 0., 60.);
DDX_Text(pDX, IDC_EDIT_x, m_x);
DDX_Text(pDX, IDC_EDIT_y, m_y);
DDX_Text(pDX, IDC_L0, m_L0);
DDX_Text(pDX, IDC_B0, m_B0);
DDX_Text(pDX, IDC_u1, m_u1);
DDX_Text(pDX, IDC_u2, m_u2);
DDX_Text(pDX, IDC_tiandingju, m_z);
DDX_Text(pDX, IDC_EDIT_jingdu_du, m_jingdu_du);
DDX_Text(pDX, IDC_EDIT_weidu_du, m_weidu_du);
DDX_Text(pDX, IDC_Delta_B, m_Delta_B);
DDX_Text(pDX, IDC_Delta_L, m_Delta_L);
DDX_Text(pDX, IDC_EDIT21, m_jdbx_fen);
DDX_Text(pDX, IDC_EDIT22, m_jdbx_miao);
DDX_Text(pDX, IDC_EDIT20, m_jdbx_du);
DDX_Text(pDX, IDC_EDIT1, m_a);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CProjection1Dlg, CDialog)
//{{AFX_MSG_MAP(CProjection1Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_Transfer_MultiPoint, OnTransferMultiPoint)
ON_BN_CLICKED(IDC_transfer_onepoint, OnTransferOnePoint)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CProjection1Dlg message handlers
BOOL CProjection1Dlg::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
//设置list control 控件
m_list.InsertColumn(1,"纬度B");
m_list.InsertColumn(2,"经度L");
m_list.InsertColumn(3,"X");
m_list.InsertColumn(4,"Y");
m_list.InsertColumn(5,"u1");
m_list.InsertColumn(6,"u2");
m_list.InsertColumn(7,"m_z");
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 CProjection1Dlg::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 CProjection1Dlg::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 CProjection1Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CProjection1Dlg::OnTransferOnePoint(double L,double B)
{
// TODO: Add your control notification handler code here
UpdateData(true);
double M=0.0000001;
int R=6371116;
m_B0=30;m_L0=105;
double Q=3.1415926,T=Q/180;
double r=0,s=0,t=0,L1,B1;
m_B=m_weidu_du+m_weidu_fen/60+m_weidu_miao/3600;
m_L=m_jingdu_du+m_jingdu_fen/60+m_jingdu_miao/3600;
m_z=acos(r)/T;
double z,a1,p,m_a1,m_b1,m_c1,m_d1,m_anglechange;
m_a1=m_B*3.1415926/180;
m_b1=m_L*3.1415926/180;
m_c1=(m_B0 )*3.1415926/180;
m_d1=(m_L0 )*3.1415926/180;
z=acos(sin(m_a1)*sin(m_c1)+cos(m_a1)*cos(m_c1)*cos(m_b1-m_d1));
if(m_b1==m_d1)
{
a1=0;
}
else
a1=atan(1/(tan(m_a1)*cos(m_c1)*(1/sin(m_b1-m_d1))-sin(m_c1)*(1/tan(m_b1-m_d1))));
if((m_a1-m_c1)!=0)
{
if((m_a1-m_c1)>0)
{
if((m_b1-m_d1)>0)
a1=a1;
else
a1=a1+2*3.1415926;
}
else
a1=3.1415926+a1;
}
p=200*6371116*sin(z/2)*M;
m_u1=cos(z/2);
m_u2=1/m_u1;
m_anglechange=(m_u1-m_u2)/(m_u1+m_u2);
m_jdbx_du=asin(m_anglechange);
m_jdbx_fen=((asin(m_anglechange))*60);
m_jdbx_miao=(int (asin(m_anglechange)*100)%3600);
m_x=p*cos(a1);
m_y=p*sin(a1);
UpdateData(FALSE);
}
void CProjection1Dlg::OnTransferMultiPoint()
{
// TODO: Add your control notification handler code here
double M=0.0000001; //比例尺
int R=6371116; //半径
int i=0;
char str[20];
double m=0.0;
double n=0.0;
double b,l,m_P;
double e=3.14159265/180;
UpdateData();
if(m_Delta_B<=0||m_Delta_L<=0)
{
MessageBox("△L或△B输入有误!");
return;
}
double z,a1,p,m_a1,m_b1,m_c1,m_d1;
m_a1=m_B*3.1415926/180;
m_b1=m_L*3.1415926/180;
m_c1=(m_B0)*3.1415926/180;
m_d1=(m_L0)*3.1415926/180;
for(m_a1=5;m_a1<=55;m_a1=m_a1+m_Delta_B)
{
for(m_b1=70;m_b1<=140;m_b1=m_b1+m_Delta_L)
{
z=acos(sin(m_a1)*sin(m_c1)+cos(m_a1)*cos(m_c1)*cos(m_b1-m_d1));
if(m_b1==m_d1)
{
a1=0;
}
else
a1=atan(1/(tan(m_a1)*cos(m_c1)*(1/sin(m_b1-m_d1))-sin(m_c1)*(1/tan(m_b1-m_d1))));
if((m_a1-m_c1)!=0)
{
if((m_a1-m_c1)>0)
{
if((m_b1-m_d1)>0)
a1=a1;
else
a1=a1+2*3.1415926;
}
else
a1=3.1415926+a1;
}
p=200*6371116*sin(z/2)*M;
m_u1=cos(z/2);
m_u2=1/m_u1;
m_x=p*cos(a1);
m_y=p*sin(a1);
CString str;
str.Format("%d", i);
m_list.InsertItem(i, str);
str.Format("%f",m_a1);
m_list.SetItemText(i,0,str);
str.Format("%f",m_b1);
m_list.SetItemText(i,1,str);
str.Format("%f",m_x);
m_list.SetItemText(i,2,str);
str.Format("%f",m_y);
m_list.SetItemText(i,3,str);
str.Format("%f",m_u1);
m_list.SetItemText(i,4,str);
str.Format("%f",m_u2);
m_list.SetItemText(i,5,str);
i++;
}
}
UpdateData(FALSE);
}
void CProjection1Dlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -