Marble

FpsLayer.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2006-2009 Torsten Rahn <tackat@kde.org>
4// SPDX-FileCopyrightText: 2011, 2012 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
5//
6
7
8#include "FpsLayer.h"
9
10#include <QPoint>
11#include <QElapsedTimer>
12#include <QFont>
13#include <QPainter>
14
15namespace Marble
16{
17
18FpsLayer::FpsLayer( QElapsedTimer *time )
19 : m_time( time )
20{
21}
22
23void FpsLayer::paint( QPainter *painter ) const
24{
25 const qreal fps = 1000.0 / (qreal)( m_time->elapsed() );
26 const QString fpsString = QString("Speed: %1 fps").arg(fps, 5, 'f', 1, QLatin1Char(' '));
27
28 const QPoint fpsLabelPos( 10, 20 );
29
30 painter->setFont( QFont( QStringLiteral( "Sans Serif" ), 10 ) );
31
32 painter->setPen( Qt::black );
33 painter->setBrush( Qt::black );
34 painter->drawText( fpsLabelPos, fpsString );
35
36 painter->setPen( Qt::white );
37 painter->setBrush( Qt::white );
38 painter->drawText( fpsLabelPos.x() - 1, fpsLabelPos.y() - 1, fpsString );
39}
40
41}
Binds a QML item to a specific geodetic location in screen coordinates.
void drawText(const QPoint &position, const QString &text)
void setBrush(Qt::BrushStyle style)
void setFont(const QFont &font)
void setPen(Qt::PenStyle style)
QString arg(Args &&... args) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:00:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.