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

📄 geocomputerdlg.cpp

📁 我是测绘学院的学生
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// GeoComputerDlg.cpp : implementation file
//

#include "stdafx.h"
#include "GeoComputer.h"
#include "GeoComputerDlg.h"
#include "fstream.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "math.h"
#include "string.h"
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
#include "ToolTipWnd.h"
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()

/////////////////////////////////////////////////////////////////////////////
// CGeoComputerDlg dialog

CGeoComputerDlg::CGeoComputerDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CGeoComputerDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CGeoComputerDlg)
	m_CompType = 0;
	m_Check = FALSE;
	m_Bx =0.0;// 3380330.773069;
	m_Ly = 0.0;//320089.969307;
	m_EllipType = 0;
	m_InB = _T("30.45.25.4425");
	m_InL = _T("111.17.58.3596");
	pdlg=NULL;
	m_Belt = 19;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	m_Bd = 0.0;
	m_Bm = 0.0;
	m_Bs = 0.0;
	m_Ld = 0.0;
	m_Lm = 0.0;
	m_Ls = 0.0;
}

void CGeoComputerDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CGeoComputerDlg)
	DDX_Control(pDX, IDC_LIST2, m_ListXY);
	DDX_Control(pDX, IDC_LIST1, m_ListBL);
	DDX_Radio(pDX, IDC_RADIO3, m_CompType);
	DDX_Check(pDX, IDC_CHECKTOL, m_Check);
	DDX_Text(pDX, IDC_EDITBx, m_Bx);
	DDX_Text(pDX, IDC_EDITLy, m_Ly);
	DDX_Radio(pDX, IDC_RADIO1, m_EllipType);
	DDX_Text(pDX, IDC_INPUTB, m_InB);
	DDX_Text(pDX, IDC_INPUTL, m_InL);
	DDX_Text(pDX, IDC_EDIT1, m_Belt);
	DDV_MinMaxInt(pDX, m_Belt, 0, 120);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CGeoComputerDlg, CDialog)
	//{{AFX_MSG_MAP(CGeoComputerDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTCOMPUTE, OnButtcompute)
	ON_BN_CLICKED(IDC_CHECKTOL, OnChecktol)
	ON_BN_CLICKED(IDC_RADIO4, OnRadioFansuan)
	ON_BN_CLICKED(IDC_RADIO3, OnRadioZHENGSUAN)
	ON_BN_CLICKED(IDC_BUTTSAVE, OnButtsave)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGeoComputerDlg message handlers

BOOL CGeoComputerDlg::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

//////////////////////////////////
	m_ToolTip.Create(this);
	m_ToolTip.SetWidth(200);
	m_ToolTip.SetBkColor(RGB(213,253,224)); //RGB(210,210,255) violet
	m_ToolTip.SetFrameColor(RGB(0,106,53));
	m_ToolTip.AddTool(GetDlgItem(IDC_INPUTB),"正算B坐标,度分秒以.号隔开:", RGB(255,0,0));
	m_ToolTip.AddTool(GetDlgItem(IDC_EDITBx),"输入反算x坐标:", RGB(255,0,0));
	m_ToolTip.AddTool(GetDlgItem(IDC_INPUTL),"正算L坐标,度分秒以.号隔开:", RGB(255,0,0));
	m_ToolTip.AddTool(GetDlgItem(IDC_EDITLy),"输入反算y坐标:", RGB(255,0,0));

	m_ToolTip.AddTool(GetDlgItem(IDC_RADIO1),"选择克拉索夫斯基椭球", RGB(255,0,0));
	m_ToolTip.AddTool(GetDlgItem(IDC_RADIO2),"选择1975国际椭球:", RGB(255,0,0));
	m_ToolTip.AddTool(GetDlgItem(IDC_RADIO3),"选择正算:", RGB(255,0,0));
	m_ToolTip.AddTool(GetDlgItem(IDC_RADIO4),"选择反算:", RGB(255,0,0));
/*-----------------------------------*/
		CWnd*pWnd=GetDlgItem(IDC_EDITBx);
		pWnd->EnableWindow(false);
		pWnd=GetDlgItem(IDC_EDITLy);
		pWnd->EnableWindow(false);
		pWnd=GetDlgItem(IDC_STATICPARA);
		pWnd->SetWindowText("正算角度按(°′″)输入:");
/*----------设置列表项--------*/
	LVCOLUMN column;
	column.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
	column.fmt=LVCFMT_LEFT;       // 左对齐
	column.cx=50;       // 宽度
	column.iSubItem=0;        // 第1列
	column.pszText="点号";     // 标题
	m_ListXY.InsertColumn(0, &column);	 // 设置第1列
	column.cx=120;       // 宽度
	column.iSubItem=1;
	column.pszText="x坐标";
	m_ListXY.InsertColumn(1, &column);  // 设置第2列
	column.iSubItem=2;
	column.pszText="y坐标";
	m_ListXY.InsertColumn(2, &column);  // 设置第3列
	column.cx=140;       // 宽度
	column.iSubItem=3;
	column.pszText="计算类型:";
	m_ListXY.InsertColumn(3, &column);  // 设置第4列
//输入BL坐标;
	column.cx=50;       // 宽度
	column.iSubItem=0;        // 第1列
	column.pszText="点号";     // 标题
	m_ListBL.InsertColumn(0, &column);	 // 设置第1列
	column.cx=130;       // 宽度
	column.iSubItem=1;
	column.pszText="纬度B(°′″)";
	m_ListBL.InsertColumn(1, &column);  // 设置第2列
	column.iSubItem=2;
	column.pszText="经度L(°′″)";
	m_ListBL.InsertColumn(2, &column);  // 设置第3列
	column.iSubItem=3;
	column.pszText="纬度B(弧度)";
	m_ListBL.InsertColumn(3, &column);  // 设置第4列
	column.iSubItem=4;
	column.pszText="经度L(弧度)";
	m_ListBL.InsertColumn(4, &column);  // 设置第5列
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CGeoComputerDlg::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 CGeoComputerDlg::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 CGeoComputerDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}
void CGeoComputerDlg::OnRadioFansuan() 
{
	// TODO: Add your control notification handler code her
	//获得正算最后一组xy值输入编辑框:
		int num=m_ListBL.GetItemCount();
		m_Bx=atof(m_ListXY.GetItemText(num-1,1));
		m_Ly=atof(m_ListXY.GetItemText(num-1,2));
		CString strX,strY;
		strX.Format("%10.10f",m_Bx);
		strY.Format("%10.10f",m_Ly);
		CWnd*pWnd=GetDlgItem(IDC_EDITBx);
		pWnd->SetWindowText(strX);
		pWnd->EnableWindow();
		pWnd=GetDlgItem(IDC_EDITLy);
		pWnd->EnableWindow();
		pWnd->SetWindowText(strY);
		pWnd=GetDlgItem(IDC_INPUTB);		
		pWnd->EnableWindow(false);
		pWnd=GetDlgItem(IDC_INPUTL);
		pWnd->EnableWindow(false);
		pWnd=GetDlgItem(IDC_STATICPARA);
		pWnd->SetWindowText("反算坐标输入:");

}

void CGeoComputerDlg::OnRadioZHENGSUAN() 
{
	// TODO: Add your control notification handler code here
	CWnd*pWnd=GetDlgItem(IDC_EDITBx);		
		pWnd->EnableWindow(false);
		pWnd=GetDlgItem(IDC_EDITLy);
		pWnd->EnableWindow(false);
		pWnd=GetDlgItem(IDC_INPUTB);		
		pWnd->EnableWindow();
		pWnd=GetDlgItem(IDC_INPUTL);
		pWnd->EnableWindow();
		pWnd=GetDlgItem(IDC_STATICPARA);
		pWnd->SetWindowText("正算角度按(°′″)输入:");

}
void CGeoComputerDlg::OnChecktol() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);

	if(m_Check==false)
	{
		CEdit* mCheck=(CEdit*)GetDlgItem(IDC_EDITBx);
		mCheck->EnableWindow(true);
		 mCheck=(CEdit*)GetDlgItem(IDC_EDITLy);
		mCheck->EnableWindow(true);

	}
	if(m_Check==true)
	{
		CEdit* mCheck=(CEdit*)GetDlgItem(IDC_EDITBx);
		mCheck->EnableWindow(false);
		 mCheck=(CEdit*)GetDlgItem(IDC_EDITLy);
		mCheck->EnableWindow(false);

	CFileDialog dlg(TRUE,NULL, NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"数据文件(*.dat)|*.dat|All files(*.*)|*.*||");
	pdlg=&dlg;
	pdlg->DoModal();
	sPath=pdlg->GetPathName();	
	}
}
void CGeoComputerDlg::OnButtcompute() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	GetBLFromEDIT(m_InB,  m_InL);

if(m_Check==false)
{
	this->PrepareData();
	//克氏椭球正算
	if(m_CompType==0&&m_EllipType==0)	
	{
		double S=(m_Bd*3600+m_Bm*60+m_Bs)/p;
		resultX=6367558.4969*S-(a0-(0.5+(a4+a6*l*l)*l*l)*l*l*N)*sin(B)*cos(B);
		resultY=(1+(a3+a5*l*l)*l*l)*l*N*cos(B);
		int  num=m_ListXY.GetItemCount( ); 
		InsertBLxy(B,L,resultX,resultY,num+1,KE_FOR);
	}
	//国际椭球正算
	if(m_CompType==0&&m_EllipType==1)
	{
		double S=(m_Bd*3600+m_Bm*60+m_Bs)/p;
		resultX=6367452.1328*S-(a0-(0.5+(a4+a6*l*l)*l*l)*l*l*N)*sin(B)*cos(B);
		resultY=(1+(a3+a5*l*l)*l*l)*l*N*cos(B);
		int  num=m_ListXY.GetItemCount( ); 
		InsertBLxy(B,L,resultX,resultY,num+1,IN_FOR);
	}
	//克氏椭球反算
	if(m_CompType==1&&m_EllipType==0)
	{
		///注意单位的转化;
		resultB=(Bf-(1-(b4-0.12*Z*Z)*Z*Z)*Z*Z*b2*p)/p;
		resultL=(L0*3600+(1-(b3-b5*Z*Z)*Z*Z)*Z*p)/p;
		int  num=m_ListXY.GetItemCount( ); 
		InsertBLxy(resultB,resultL,m_Bx,m_Ly,num+1,KE_BAC);	

	}
//国际椭球反算;
	if(m_CompType==1&&m_EllipType==1)	
	{
		///注意单位的转化;
		resultB=(Bf-(1-(b4-0.147*Z*Z)*Z*Z)*Z*Z*b2*p)/p;
		resultL=(L0*3600+(1-(b3-b5*Z*Z)*Z*Z)*Z*p)/p;
		int  num=m_ListXY.GetItemCount( ); 
		InsertBLxy(resultB,resultL,m_Bx,m_Ly,num+1,IN_BAC);		
	}
}
//进行批量计算:
if(m_Check==true)
{	
		int number;
		char *st=new char[50];
		char *stBx=new char[30];
		char *stLy=new char[30];
		char *stNum=new char[10];
		char c;
	//克氏椭球正算
	if(m_CompType==0&&m_EllipType==0)
	{
		fp=fopen(sPath,"r");
		fgets(st,50,fp);
		int t=strcmp(st,"latitude and longitude");
		if(this->strcmp(st,"latitude and longitude")!=1)
		{
			AfxMessageBox("数据类型不符,请选择大地坐标文件!");
			return;
		}
		for(;feof(fp)!=1;)
		{
			fgets(st,50,fp);
/*-计算-*/	if(st[0]=='e')return ;
			ExtractBLdata(m_Bd,m_Bm,m_Bs,m_Ld,m_Lm,m_Ls,number,st);
			this->PrepareData();
			double S=(m_Bd*3600+m_Bm*60+m_Bs)/p;
			resultX=6367558.4969*S-(a0-(0.5+(a4+a6*l*l)*l*l)*l*l*N)*sin(B)*cos(B);
			resultY=(1+(a3+a5*l*l)*l*l)*l*N*cos(B);
			int  num=m_ListXY.GetItemCount( ); 
			InsertBLxy(B,L,resultX,resultY,num+1,KE_FOR);

		}

	}
	//国际椭球正算
	if(m_CompType==0&&m_EllipType==1)
	{
		fp=fopen(sPath,"r");
		fgets(st,50,fp);
		if(this->strcmp(st,"latitude and longitude")!=1)
		{
			AfxMessageBox("数据类型不符,请选择大地坐标文件!");
			return;
		}
		for(;feof(fp)!=1;)
		{
			fgets(st,50,fp);
/*-计算-*/	if(st[0]=='e')return ;
			ExtractBLdata(m_Bd,m_Bm,m_Bs,m_Ld,m_Lm,m_Ls,number,st);
			this->PrepareData();
			double S=(m_Bd*3600+m_Bm*60+m_Bs)/p;
			resultX=6367452.1328*S-(a0-(0.5+(a4+a6*l*l)*l*l)*l*l*N)*sin(B)*cos(B);
			resultY=(1+(a3+a5*l*l)*l*l)*l*N*cos(B);
			int  num=m_ListXY.GetItemCount( ); 
			InsertBLxy(B,L,resultX,resultY,num+1,IN_FOR);
		}
	}

	//克氏椭球反算
	if(m_CompType==1&&m_EllipType==0)
	{
///////////////////文件操作:
		fp=fopen(sPath,"r");
		fgets(st,50,fp);
		if(this->strcmp(st,"coordinate(x,y):")!=1)
		{
			AfxMessageBox("数据类型不符,请选择高斯平面坐标文件!");
			return;
		}
		for(;feof(fp)!=1;)
		{
			fgets(st,50,fp);
/*-计算-*/	if(st[0]=='e')return ;
			ExtracteXYData(number,m_Bx,m_Ly,st);
			this->PrepareData();
			resultB=(Bf-(1-(b4-0.12*Z*Z)*Z*Z)*Z*Z*b2*p)/p;
			resultL=(L0*3600+(1-(b3-b5*Z*Z)*Z*Z)*Z*p)/p;

⌨️ 快捷键说明

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