dlgbeacon1.cpp

来自「VC&Matlab混合编程实现无线电导航指示器」· C++ 代码 · 共 128 行

CPP
128
字号
// DlgBeacon1.cpp : implementation file
//

#include "stdafx.h"
#include "RADIO.h"
#include "DlgBeacon1.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgBeacon1 dialog


CDlgBeacon1::CDlgBeacon1(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgBeacon1::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgBeacon1)
	m_beaconLa = 120.0;
	m_beaconPhi = 30.0;
	m_beaconH = 0.0;
	//}}AFX_DATA_INIT
	
}


void CDlgBeacon1::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgBeacon1)
	DDX_Control(pDX, IDC_BEACONLIST, m_beaconListBox);
	DDX_Control(pDX, IDC_BEACONCOMBO, m_beaconComboType);
	DDX_Text(pDX, IDC_BEACONLA, m_beaconLa);
	DDX_Text(pDX, IDC_BEACONPHI, m_beaconPhi);
	DDX_Text(pDX, IDC_BEACONH, m_beaconH);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgBeacon1, CDialog)
	//{{AFX_MSG_MAP(CDlgBeacon1)
	ON_BN_CLICKED(IDC_ADDBEACON, OnAddbeacon)
	ON_BN_CLICKED(IDC_DELBEACON, OnDelbeacon)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgBeacon1 message handlers

void CDlgBeacon1::OnAddbeacon() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	UINT iType;
	CString str,strType; 
	switch(m_beaconComboType.GetCurSel()){
	case 0:
		strType="地面";iType=GROUND;
		break;
	case 1:
		strType="空中";iType=AIR;
		break;
	default:;
	}
	str.Format(_T("No.%3d.      %6.3lf       %6.3lf       %6.3lf         %s"),m_beaconListBox.GetCount()+1,m_beaconLa,m_beaconPhi,m_beaconH,strType);
    m_beaconListBox.AddString( str );

	BEACON bea={m_beaconLa,m_beaconPhi,m_beaconH,iType};
	m_tempBeaconList.Add(bea);
}


BOOL CDlgBeacon1::OnInitDialog()
{
	CDialog::OnInitDialog();
	m_beaconComboType.SetCurSel(0);
	return TRUE;
}

void CDlgBeacon1::UpdateListBox()
{
	int i;
	CString str,strType("error");
	m_beaconListBox.ResetContent();
	
	for(i=0;i<m_tempBeaconList.GetSize();i++){
		switch(m_tempBeaconList[i].type){
		case GROUND:
			strType="地面";
			break;
		case AIR:
			strType="空中";
			break;
		default:;
		}		
		str.Format(_T("No.%3d.      %6.3lf       %6.3lf       %6.3lf         %s"),m_beaconListBox.GetCount()+1,m_tempBeaconList[i].pos.x,m_tempBeaconList[i].pos.y,m_tempBeaconList[i].pos.z,strType);
		m_beaconListBox.AddString(str);
	}
}


void CDlgBeacon1::OnDelbeacon() 
{
    UpdateData(TRUE);
	CString str,strType; 
	
	//得到所有选择项
	int nCount = m_beaconListBox.GetSelCount();
	CArray<int,int> aryListBoxSel;	
	aryListBoxSel.SetSize(nCount);
	int nSel=m_beaconListBox.GetSelItems(nCount, aryListBoxSel.GetData()); 
	//
	for(int i=0;i<nSel;i++){
      m_tempBeaconList.RemoveAt(aryListBoxSel[i]-i);//小心删掉一个序号就变了。
	}
	UpdateListBox();
}


void CDlgBeacon1::OnOK() 
{
	// TODO: Add extra validation here

}

⌨️ 快捷键说明

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