void GpsSnrWidget::resizeEvent(QResizeEvent *event) { Q_UNUSED(event); scene->setSceneRect(0, 0, this->viewport()->width(), this->viewport()->height()); for (int index = 0; index < MAX_SATTELITES; index++) { drawSat(index); } }
void GpsElevationAzimuthDisplay::paintEvent( QPaintEvent *event ) { // Call paint method from QFrame otherwise the frame is not drawn. QFrame::paintEvent( event ); QPainter p(this); QFont f = font(); #ifdef ANDROID f.setPointSize(6); #else f.setPixelSize(12); #endif p.setFont(f); // copy background to widget p.drawPixmap ( contentsRect().left(), contentsRect().top(), background, 0, 0, background.width(), background.height() ); // draw satellites if( sats.count() ) { for( int i = 0; i < sats.count(); i++ ) { drawSat( &p, sats.at( i ) ); } } else { QString text( tr("No Data") ); QRect rect = p.fontMetrics().boundingRect( text ); int w = rect.width(); int h = rect.height(); p.fillRect( center.x() - w / 2, center.y() - h / 2, w, h, palette().color(QPalette::Window) ); p.drawText( center.x() - w / 2, center.y() - h / 2, w, h, Qt::AlignCenter, text ); } }
void GpsSnrWidget::updateSat(int index, int prn, int elevation, int azimuth, int snr) { if (index >= MAX_SATTELITES) { // A bit of error checking never hurts. return; } // TODO: add range checking satellites[index][0] = prn; satellites[index][1] = elevation; satellites[index][2] = azimuth; satellites[index][3] = snr; drawSat(index); }
void GpsSnrDisplay::paintEvent( QPaintEvent *event ) { // Call paint method from QFrame otherwise the frame is not drawn. QFrame::paintEvent( event ); QPainter pw(this); pw.fillRect( xoff, yoff, width, height, palette().color(QPalette::Window) ); // draw satellites if( sats.count() ) { for (int i=0; i < sats.count(); i++) { drawSat(&pw, i, sats.count(), sats.at(i)); } } else { QFont f = font(); #ifdef ANDROID f.setPointSize(6); #else f.setPixelSize(12); #endif pw.setFont(f); pw.fillRect( center.x()-23, center.y()-7, 46, 14, palette().color(QPalette::Window) ); QString text = tr("No Data"); QFontMetrics fm( font() ); int w = fm.width( text ); int h = fm.height(); pw.drawText( center.x() - w / 2, center.y() + h / 2, text ); } }