Ejemplo n.º 1
0
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);
    }
}
Ejemplo n.º 2
0
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 );
    }
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
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 );
    }
}