概述
void FSpaceAnalyseDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用 CDialog::OnPaint()
theApp.DrawBmpFormFile(dc.m_hDC, 0, 0, L"SpaceAnalyse.bmp");
//绘制空间分析示意图
//CClientDC dc(this);
//dc.SetPixel(120,120,RGB(0,0,0));
dc.Ellipse(60,60,180,180);//画圆
dc.Ellipse(80,80,160,160);
dc.Ellipse(100,100,140,140);
dc.MoveTo(60,120); //画水平线
dc.LineTo(180,120);
dc.MoveTo(120,60); //画垂线
dc.LineTo(120,180);
//绘制信噪比基准线
CPen pen(PS_SOLID,1,RGB(255,255,255));
dc.SelectObject(&pen);
dc.MoveTo(10,200);
dc.LineTo(230,200);
dc.MoveTo(10,230);
dc.LineTo(230,230);
dc.MoveTo(10,260);
dc.LineTo(230,260);
dc.SetTextColor(RGB(255,255,255));//设置字体颜色
dc.SetBkMode(TRANSPARENT);//设置背景透明
//显示N,E,S,W
CString label;
label = "N";
CRect rc1(110,45,130,60);
dc.DrawTextW(label,&rc1,DT_CENTER);
label = "E";
CRect rc2(180,110,200,130);
dc.DrawTextW(label,&rc2,DT_CENTER);
label = "S";
CRect rc3(110,180,130,200);
dc.DrawTextW(label,&rc3,DT_CENTER);
label = "W";
CRect rc4(40,110,60,130);
dc.DrawTextW(label,&rc4,DT_CENTER);
DisPlay();
}
void FSpaceAnalyseDlg::DisPlay()
{
//获取GPS位置
//获取app的FGPS
FGPS * pGps = ((CNavTongApp*)AfxGetApp())->getGPS();
//GPS打开的时候显示星位图
if (pGps->IsGpsOpen())
{
GPS_POSITION position;
double x[12],y[12];
int r = 60;
if (pGps->getGpsPosition(position) == ERROR_SUCCESS)
{
//获取卫星位置坐标
for(int i = 0;i<12;i++)
{
if(position.rgdwSatellitesInViewAzimuth[i] > 0 && position.rgdwSatellitesInViewAzimuth[i] < 90)
{
x[i] = 120 + (60 * cos(position.rgdwSatellitesInViewElevation[i])) * cos(position.rgdwSatellitesInViewAzimuth[i]);
y[i] = 120 + (60 * cos(position.rgdwSatellitesInViewElevation[i])) * sin(position.rgdwSatellitesInViewAzimuth[i]);
}
else if(position.rgdwSatellitesInViewAzimuth[i] >= 90 && position.rgdwSatellitesInViewAzimuth[i] < 180 )
{
x[i] = 120 + (60 * cos(position.rgdwSatellitesInViewElevation[i])) * cos(180 - position.rgdwSatellitesInViewAzimuth[i]);
y[i] = 120 + (60 * cos(position.rgdwSatellitesInViewElevation[i])) * sin(180 - position.rgdwSatellitesInViewAzimuth[i]);
}
else if(position.rgdwSatellitesInViewAzimuth[i] >= 180 && position.rgdwSatellitesInViewAzimuth[i] < 270 )
{
x[i] = 120 + (60 * cos(position.rgdwSatellitesInViewElevation[i])) * cos(position.rgdwSatellitesInViewAzimuth[i] - 180);
y[i] = 120 + (60 * cos(position.rgdwSatellitesInViewElevation[i])) * sin(position.rgdwSatellitesInViewAzimuth[i] - 180);
}
else
{
x[i] = 120 + (60 * cos(position.rgdwSatellitesInViewElevation[i])) * sin(position.rgdwSatellitesInViewAzimuth[i] - 270);
y[i] = 120 + (60 * cos(position.rgdwSatellitesInViewElevation[i])) * cos(position.rgdwSatellitesInViewAzimuth[i] - 270);
}
//显示GPS卫星分布图
CClientDC dc(this);
dc.SelectStockObject(WHITE_BRUSH);
CBrush cbBrush(RGB(255,0,0));
CBrush *poldBrush = (CBrush*) dc.SelectObject(&cbBrush);
dc.Ellipse(int(x[i] - 8),int(y[i] - 8),int(x[i] + 8),int(y[i] + 8));
//显示GPS卫星信噪比
double temp;
temp = (60/50) * position.rgdwSatellitesInViewSignalToNoiseRatio[i];
dc.Rectangle(10 + 15 * i ,int(260 - temp), 23 + 15 * i ,260);
dc.SelectObject(poldBrush);
//分别在二个区域显示GPS卫星编号
dc.SetTextColor(COLORREF(RGB(0,255,0)));//设置字体颜色
dc.SetBkMode(TRANSPARENT);//设置背景透明
CRect rc1(int(x[i] - 8),int(y[i] + 8),int(x[i] + 8),int(y[i] + 20 ));
CRect rc2(10 + 15 * i ,260, 23 + 15 * i,275);
CString label;
label.Format(_T("%d"),position.rgdwSatellitesInViewPRNs[i]);
dc.DrawTextW(label,&rc1,DT_CENTER);
dc.DrawTextW(label,&rc2,DT_CENTER);
}
}
else
{
MessageBox(_T("信号不好,GPS获取不到数据!"));
}
}
}
最后
以上就是细腻小熊猫为你收集整理的GPS星卫图及信噪比图的设计的全部内容,希望文章能够帮你解决GPS星卫图及信噪比图的设计所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复