⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gsdlg.cpp

📁 一个简单的visual c++程序
💻 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

/////////////////////////////////////////////////////////////////////////////
// CGsDlg dialog

CGsDlg::CGsDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CGsDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CGsDlg)
	L_var = 0.0;
	B_var = 0.0;
	L0_var = 0.0;
	x=0.0;
	y=0.0;
	L=0.0;
	B=0.0;
	L0=0.0;
	Bf=0.0;
	Nf=0.0;
	//}}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_Text(pDX, IDC_EDIT1, L_var);
	DDX_Text(pDX, IDC_EDIT4, B_var);
	DDX_Text(pDX, IDC_EDIT7, L0_var);
	DDX_Text(pDX, IDC_EDIT14, L);
	DDX_Text(pDX, IDC_EDIT13, B);
	DDX_Text(pDX, IDC_EDIT10, L0);
	DDX_Text(pDX, IDC_EDIT11, x);
	DDX_Text(pDX, IDC_EDIT12, y);
	DDX_Text(pDX, IDC_EDIT15, Bf);
	DDX_Text(pDX, IDC_EDIT16, Nf);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CGsDlg, CDialog)
	//{{AFX_MSG_MAP(CGsDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	ON_WM_CLOSE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGsDlg message handlers

BOOL CGsDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 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
	p=180/PI*3600.0;
	CheckRadioButton(IDC_RADIO1,IDC_RADIO2,IDC_RADIO1);
	return TRUE;  // return TRUE  unless you set the focus to a control
}

// 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::OnOK() 
{
	if(Positive_b)
	{
		Positive();
	}
	else
	{
		Negative();
	}

	//CDialog::OnOK();
}



void CGsDlg::OnRadio1() 
{
	// TODO: Add your control notification handler code here
	GetDlgItem(IDC_STATICB)->SetWindowText("* B="); 
	GetDlgItem(IDC_STATICL)->SetWindowText("* L=");
	GetDlgItem(IDC_STATICx)->SetWindowText("x=");
	GetDlgItem(IDC_STATICy)->SetWindowText("y=");
	GetDlgItem(IDOK)->SetWindowText("正算");
	Positive_b=TRUE;
}

void CGsDlg::OnRadio2() 
{
	// TODO: Add your control notification handler code here
	GetDlgItem(IDC_STATICB)->SetWindowText("B="); 
	GetDlgItem(IDC_STATICL)->SetWindowText("L=");
	GetDlgItem(IDC_STATICx)->SetWindowText("* x=");
	GetDlgItem(IDC_STATICy)->SetWindowText("* y="); 
	GetDlgItem(IDOK)->SetWindowText("反算");
	Positive_b=FALSE;
}

void CGsDlg::Negative()
{
		UpdateData();
	// TODO: Add extra validation here
	L0_ang.angle=L0_var;
	L0_ang.SetAngle(2);
	//setAngle(0,L_var,L_ang.deg,L_ang.min,L_ang.sec);
	L0=(L0_ang.deg*3600+L0_ang.min*60+L0_ang.sec)/p;

	s=x/6367558.4969;

	Bf=s+(50221746+(293622+(2350+22*cos(s)*cos(s))*cos(s)*cos(s))*cos(s)*cos(s)) *1e-10*sin(s)*cos(s);
	
	Nf=6399698.902-(21562.267-(108.973-0.612*cos(Bf)*cos(Bf))*cos(Bf)*cos(Bf))*cos(Bf)*cos(Bf);
	//cout<<"Nf="<<Nf<<endl;
	
	Z=y/(Nf*cos(Bf));

	b2=(0.5+0.003369*cos(Bf)*cos(Bf))*cos(Bf)*sin(Bf);

	b3=0.333333-(0.166667-0.001123*cos(Bf)*cos(Bf))*cos(Bf)*cos(Bf);

	b4=0.25+(0.16161+0.00562*cos(Bf)*cos(Bf))*cos(Bf)*cos(Bf);

	b5=0.2-(0.1667-0.0088*cos(Bf)*cos(Bf))*cos(Bf)*cos(Bf);

	B=Bf-(1-(b4-0.12*Z*Z)*Z*Z)*Z*Z*b2;

	l=(1-(b3-b5*Z*Z)*Z*Z)*Z;

	B_ang.deg=int(B*p/3600);B_ang.min=int((B*p-B_ang.deg*3600)/60);B_ang.sec=B*p-B_ang.deg*3600-B_ang.min*60;

	L=l+L0;

	L_ang.deg=int(L*p/3600);L_ang.min=int((L*p-L_ang.deg*3600)/60);L_ang.sec=L*p-L_ang.deg*3600-L_ang.min*60;

	B_ang.Arc2Angle();
	L_ang.Arc2Angle();

	B_var=B_ang.angle;
	L_var=L_ang.angle;

	UpdateData(0);
}

void CGsDlg::Positive()
{
		UpdateData();
	// TODO: Add extra validation here
	L_ang.angle=L_var;
	L_ang.SetAngle(0);
	B_ang.angle=B_var;
	B_ang.SetAngle(1);
	L0_ang.angle=L0_var;
	L0_ang.SetAngle(2);
	//setAngle(0,L_var,L_ang.deg,L_ang.min,L_ang.sec);
	L=(L_ang.deg*3600+L_ang.min*60+L_ang.sec)/p;

	B=(B_ang.deg*3600+B_ang.min*60+B_ang.sec)/p;

	L0=(L0_ang.deg*3600+L0_ang.min*60+L0_ang.sec)/p;

	l=L-L0;

	N=6399698.902-(21562.267-(108.973-0.612*cos(B)*cos(B))*cos(B)*cos(B))*cos(B)*cos(B);

	a0=32140.404-(135.3302-(0.7092-0.0040*cos(B)*cos(B))*cos(B)*cos(B))*cos(B)*cos(B);

	a4=(0.25+0.00252*cos(B)*cos(B))*cos(B)*cos(B)-0.04166;

	a6=(0.166*cos(B)*cos(B)-0.084)*cos(B)*cos(B);

	a3=(0.3333333+0.001123*cos(B)*cos(B))*cos(B)*cos(B)-0.1666667;

	a5=0.0083-(0.1667-(0.1968+0.004*cos(B)*cos(B))*cos(B)*cos(B))*cos(B)*cos(B);

	x=(6367558.4969*B-(a0-(0.5+(a4+a6*l*l)*l*l)*l*l*N)*sin(B)*cos(B))/1000;

	y=((1+(a3+a5*l*l)*l*l)*l*N*cos(B))/1000;

	UpdateData(0);
}

void CGsDlg::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	
	CDialog::OnOK();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -