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

📄 qgps_satmap.cc

📁 在linux系统下开发的GPS接收程序,具有良好的图形操作界面.
💻 CC
字号:
//------------------------------------------------------------------------// qgpssatmap.cc: implementation of QGpsSatMap class////	- programmed by Boyoon Jung//------------------------------------------------------------------------#include "qgps_satmap.h"#include <qpainter.h>#include <cmath>// constructorQGpsSatMap::QGpsSatMap(QWidget *parent, const char *name, WFlags f)	: QFrame(parent, name, f){    // initialization    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);    setBackgroundMode(NoBackground);}// destructorQGpsSatMap::~QGpsSatMap(void){}// when the size of window changesvoid QGpsSatMap::resizeEvent (QResizeEvent *e){    // resize the local data buffer    _pixmap.resize(e->size());    // resize north/south indicators    cx = e->size().width() / 2;    cy = e->size().height() / 2;    radius = (cx < cy) ? (cx-20) : (cy-20);	// boundary: 10 pixels}// draw contentsvoid QGpsSatMap::drawContents(QPainter *p){    const static int unitR = 100;    // for double buffering    _painter.begin(&_pixmap);    // clear the buffer    _painter.setPen(NoPen);    _painter.setBrush(darkBlue);    _painter.drawRect(0, 0, _pixmap.size().width(), _pixmap.size().height());    // set the coordinates    _painter.translate(cx, cy);    // draw the center position    _painter.setPen(darkGray);    _painter.setBrush(NoBrush);    _painter.drawLine(-3,0, 3,0);    _painter.drawLine(0,-3, 0,3);    // draw concentric circles    for (double i=radius/4; i<=radius; i+=radius/4)	_painter.drawEllipse(-i,-i, 2*i,2*i);    // draw E/W/S/N marks    _painter.save();    _painter.drawText(0, -radius-5, "N");    _painter.rotate(90);    _painter.drawText(0, -radius-5, "E");    _painter.rotate(90);    _painter.drawText(0, -radius-5, "S");    _painter.rotate(90);    _painter.drawText(0, -radius-5, "W");    _painter.restore();    // draw satellites    QString prn;    for (int i=0; i<nsat; i++)    {	// set color based on if it is in use or not	if (active[i]) {	    _painter.setPen(red);	    _painter.setBrush(red);	}	else {	    _painter.setPen(white);	    _painter.setBrush(white);	}	// compute the position of satellites in image coordinates	double d = radius * cos(sat[i].elevation*M_PI/180);	int x = int(d * cos((sat[i].azimuth-90)*M_PI/180));	int y = int(d * sin((sat[i].azimuth-90)*M_PI/180));	_painter.drawEllipse(x-5,y-5, 10,10);	_painter.drawText(x+5, y, prn.setNum(sat[i].prn));    }    // draw them on the screen    _painter.end();    p->drawPixmap(0, 0, _pixmap);}// inline function to check if a PRN is activeinline bool is_active(int prn, int used[]){    for (int i=0; i<12 && used[i] >= 0; i++)	if (used[i] == prn) return true;    return false;}// update infovoid QGpsSatMap::updateSatellites(int nsat, satinfo_t sat[], int prn_used[]){    // store the information    this->nsat = nsat;    for (int i=0; i<nsat; i++) {	this->sat[i] = sat[i];	this->active[i] = is_active(sat[i].prn, prn_used);    }    // update the screen    update();}

⌨️ 快捷键说明

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