You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
167 lines
3.4 KiB
C++
167 lines
3.4 KiB
C++
// TargetDlg.cpp : 实现文件
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "TargetDlg.h"
|
|
#include "afxdialogex.h"
|
|
#include "Globe.h"
|
|
|
|
#include "MapElevation.h"
|
|
|
|
MapElevation m_mapElevation1;
|
|
|
|
// CTargetDlg 对话框
|
|
|
|
IMPLEMENT_DYNAMIC(CTargetDlg, CDialogEx)
|
|
|
|
CTargetDlg::CTargetDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialogEx(CTargetDlg::IDD, pParent)
|
|
, m_targetID(1)
|
|
, m_targetLon(0)
|
|
, m_targetLat(0)
|
|
, m_targetAlt(0)
|
|
{
|
|
|
|
}
|
|
|
|
CTargetDlg::~CTargetDlg()
|
|
{
|
|
}
|
|
|
|
void CTargetDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialogEx::DoDataExchange(pDX);
|
|
DDX_Text(pDX, IDC_EDIT_TARGET_ID, m_targetID);
|
|
DDV_MinMaxInt(pDX, m_targetID, 1, 255);
|
|
DDX_Text(pDX, IDC_EDIT_TARGET_LON, m_targetLon);
|
|
DDV_MinMaxDouble(pDX, m_targetLon, -180.0, 180.0);
|
|
DDX_Text(pDX, IDC_EDIT_TARGET_LAT, m_targetLat);
|
|
DDV_MinMaxDouble(pDX, m_targetLat, -90.0, 90.0);
|
|
DDX_Text(pDX, IDC_EDIT_TARGET_ALT, m_targetAlt);
|
|
DDV_MinMaxDouble(pDX, m_targetAlt, 0, 9999);
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CTargetDlg, CDialogEx)
|
|
ON_BN_CLICKED(IDC_BUTTON_ADD_TARGET, &CTargetDlg::OnBnClickedButtonAddTarget)
|
|
ON_WM_SHOWWINDOW()
|
|
ON_BN_CLICKED(IDC_BUTTON_SELECT_TARGET, &CTargetDlg::OnBnClickedButtonSelectTarget)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// CTargetDlg 消息处理程序
|
|
|
|
|
|
BOOL CTargetDlg::OnInitDialog()
|
|
{
|
|
CDialogEx::OnInitDialog();
|
|
|
|
m_targetCount = 0;
|
|
m_targetID = m_targetCount+1;
|
|
for (int i = 0;i<255;i++)
|
|
{
|
|
m_bExistFlags[i] = false;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void CTargetDlg::SetTargetCount(int count)
|
|
{
|
|
m_targetCount = count;
|
|
}
|
|
|
|
void CTargetDlg::SetExistFlag(int id,bool b)
|
|
{
|
|
if (id>0&&id<255)
|
|
{
|
|
m_bExistFlags[id-1] = b;
|
|
}
|
|
}
|
|
|
|
void CTargetDlg::GetTargetLLA(int &id,double &lon,double &lat,double &alt)
|
|
{
|
|
id = m_targetID;
|
|
lon = m_targetLon;
|
|
lat = m_targetLat;
|
|
alt = m_targetAlt;
|
|
}
|
|
|
|
//添加目标点
|
|
void CTargetDlg::OnBnClickedButtonAddTarget()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
CString strID;
|
|
strID.Format("%d",m_targetID);
|
|
|
|
CString strLon = "";
|
|
strLon.Format("%.5f",m_targetLon);
|
|
|
|
CString strLat = "";
|
|
strLat.Format("%.5f",m_targetLat);
|
|
|
|
CString strAlt = "";
|
|
strAlt.Format("%.0f",m_targetAlt);
|
|
|
|
CString fileName = GetSoftwareCurrentDirectory() + "\\target.ini";
|
|
|
|
WritePrivateProfileString(strID,"lon",strLon.GetBuffer(), fileName);
|
|
WritePrivateProfileString(strID,"lat",strLat.GetBuffer(), fileName);
|
|
WritePrivateProfileString(strID,"alt",strAlt.GetBuffer(), fileName);
|
|
|
|
::SendMessage(g_mapHwnd,WM_DRAW_TARGET,NULL,NULL);
|
|
|
|
m_targetCount++;
|
|
|
|
CDialog::OnCancel();
|
|
}
|
|
|
|
|
|
void CTargetDlg::OnShowWindow(BOOL bShow, UINT nStatus)
|
|
{
|
|
CDialogEx::OnShowWindow(bShow, nStatus);
|
|
|
|
// TODO: 在此处添加消息处理程序代码
|
|
for(int i=0;i<255;i++)
|
|
{
|
|
if (m_bExistFlags[i] == false)
|
|
{
|
|
m_targetID = i+1;
|
|
break;
|
|
}
|
|
}
|
|
m_targetLon = 0.0;
|
|
m_targetLat = 0.0;
|
|
m_targetAlt = 0.0;
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
//在地图上选点
|
|
void CTargetDlg::OnBnClickedButtonSelectTarget()
|
|
{
|
|
::SendMessage(g_mapHwnd,WM_SEND_SELECTTARGET,0,0);
|
|
}
|
|
|
|
//在对话框里显示选择点的坐标和高程
|
|
void CTargetDlg::ShowPointPosition(double ptLon, double ptLat)
|
|
{
|
|
CString str;
|
|
|
|
str.Format(_T("%.7f"),ptLon);
|
|
GetDlgItem(IDC_EDIT_TARGET_LON)->SetWindowText(str);
|
|
|
|
str.Format(_T("%.7f"),ptLat);
|
|
GetDlgItem(IDC_EDIT_TARGET_LAT)->SetWindowText(str);
|
|
|
|
//获取高程
|
|
float ptAlt = 0.0f;
|
|
if(!m_mapElevation1.getElevation(ptAlt, ptLon, ptLat))
|
|
{
|
|
ptAlt = 0.0f;
|
|
}
|
|
|
|
str.Format(_T("%.1f"),ptAlt);
|
|
GetDlgItem(IDC_EDIT_TARGET_ALT)->SetWindowText(str);
|
|
}
|