• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • layers
FpsLayer.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2006-2009 Torsten Rahn <tackat@kde.org>
9 // Copyright 2011,2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
10 //
11 
12 
13 #include "FpsLayer.h"
14 
15 #include <QPoint>
16 #include <QTime>
17 #include <QFont>
18 #include <QPainter>
19 
20 namespace Marble
21 {
22 
23 FpsLayer::FpsLayer( QTime *time )
24  : m_time( time )
25 {
26 }
27 
28 void FpsLayer::paint( QPainter *painter ) const
29 {
30  const qreal fps = 1000.0 / (qreal)( m_time->elapsed() );
31  const QString fpsString = QString( "Speed: %1 fps" ).arg( fps, 5, 'f', 1, QChar(' ') );
32 
33  const QPoint fpsLabelPos( 10, 20 );
34 
35  painter->setFont( QFont( "Sans Serif", 10 ) );
36 
37  painter->setPen( Qt::black );
38  painter->setBrush( Qt::black );
39  painter->drawText( fpsLabelPos, fpsString );
40 
41  painter->setPen( Qt::white );
42  painter->setBrush( Qt::white );
43  painter->drawText( fpsLabelPos.x() - 1, fpsLabelPos.y() - 1, fpsString );
44 }
45 
46 }
Marble::FpsLayer::paint
void paint(QPainter *painter) const
Definition: FpsLayer.cpp:28
FpsLayer.h
QChar
QFont
QPoint
QTime
QPoint::x
int x() const
QPoint::y
int y() const
QPainter::setFont
void setFont(const QFont &font)
QTime::elapsed
int elapsed() const
QPainter::setPen
void setPen(const QColor &color)
QPainter
QPainter::setBrush
void setBrush(const QBrush &brush)
QPainter::drawText
void drawText(const QPointF &position, const QString &text)
QString
Marble::FpsLayer::FpsLayer
FpsLayer(QTime *time)
Definition: FpsLayer.cpp:23
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal