Marble

FogLayer.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2006-2007 Torsten Rahn <tackat@kde.org>
4// SPDX-FileCopyrightText: 2007 Inge Wallin <ingwa@kde.org>
5// SPDX-FileCopyrightText: 2008, 2009, 2010 Jens-Michael Hoffmann <jmho@c-xx.com>
6// SPDX-FileCopyrightText: 2008-2009 Patrick Spendrin <ps_ml@gmx.de>
7//
8
9#include "FogLayer.h"
10
11#include "GeoPainter.h"
12#include "ViewportParams.h"
13#include "RenderState.h"
14
15namespace Marble
16{
17
18QStringList FogLayer::renderPosition() const
19{
20 return QStringList(QStringLiteral("ATMOSPHERE"));
21}
22
23bool FogLayer::render( GeoPainter *painter,
24 ViewportParams *viewParams,
25 const QString &renderPos,
26 GeoSceneLayer *layer )
27{
28 Q_UNUSED(renderPos)
29 Q_UNUSED(layer)
30
31 // FIXME: The fog layer is really slow. That's why we defer it to
32 // PrintQuality. Either cache on a pixmap - or maybe
33 // better: Add to GlobeScanlineTextureMapper.
34 if ( painter->mapQuality() != PrintQuality )
35 return true;
36
37 if ( viewParams->projection() != Spherical)
38 return true;
39
40 // No use to draw the fog if it's not visible in the area.
41 if ( viewParams->mapCoversViewport() )
42 return true;
43
44 int imgWidth2 = viewParams->width() / 2;
45 int imgHeight2 = viewParams->height() / 2;
46
47 int radius = viewParams->radius();
48
49 // Recalculate the atmosphere effect and paint it to canvasImage.
50 QRadialGradient grad1( QPointF( imgWidth2, imgHeight2 ), radius );
51
52 // FIXME: Add a cosine relationship
53 grad1.setColorAt( 0.85, QColor( 255, 255, 255, 0 ) );
54 grad1.setColorAt( 1.00, QColor( 255, 255, 255, 64 ) );
55
56 QBrush brush1( grad1 );
57 QPen pen1( Qt::NoPen );
58
59 painter->save();
60
61 painter->setBrush( brush1 );
62 painter->setPen( pen1 );
63 painter->setRenderHint( QPainter::Antialiasing, false );
64
65 // FIXME: Cut out what's really needed
66 painter->drawEllipse( imgWidth2 - radius,
67 imgHeight2 - radius,
68 2 * radius,
69 2 * radius );
70
71 painter->restore();
72
73 return true;
74}
75
76RenderState FogLayer::renderState() const
77{
78 return RenderState(QStringLiteral("Fog"));
79}
80
81}
This file contains the headers for ViewportParams.
Binds a QML item to a specific geodetic location in screen coordinates.
@ Spherical
Spherical projection ("Orthographic")
@ PrintQuality
Print quality.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.