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 "RenderState.h"
13#include "ViewportParams.h"
14
15namespace Marble
16{
17
18QStringList FogLayer::renderPosition() const
19{
20 return QStringList(QStringLiteral("ATMOSPHERE"));
21}
22
23bool FogLayer::render(GeoPainter *painter, ViewportParams *viewParams, const QString &renderPos, GeoSceneLayer *layer)
24{
25 Q_UNUSED(renderPos)
26 Q_UNUSED(layer)
27
28 // FIXME: The fog layer is really slow. That's why we defer it to
29 // PrintQuality. Either cache on a pixmap - or maybe
30 // better: Add to GlobeScanlineTextureMapper.
31 if (painter->mapQuality() != PrintQuality)
32 return true;
33
34 if (viewParams->projection() != Spherical)
35 return true;
36
37 // No use to draw the fog if it's not visible in the area.
38 if (viewParams->mapCoversViewport())
39 return true;
40
41 int imgWidth2 = viewParams->width() / 2;
42 int imgHeight2 = viewParams->height() / 2;
43
44 int radius = viewParams->radius();
45
46 // Recalculate the atmosphere effect and paint it to canvasImage.
47 QRadialGradient grad1(QPointF(imgWidth2, imgHeight2), radius);
48
49 // FIXME: Add a cosine relationship
50 grad1.setColorAt(0.85, QColor(255, 255, 255, 0));
51 grad1.setColorAt(1.00, QColor(255, 255, 255, 64));
52
53 QBrush brush1(grad1);
54 QPen pen1(Qt::NoPen);
55
56 painter->save();
57
58 painter->setBrush(brush1);
59 painter->setPen(pen1);
60 painter->setRenderHint(QPainter::Antialiasing, false);
61
62 // FIXME: Cut out what's really needed
63 painter->drawEllipse(imgWidth2 - radius, imgHeight2 - radius, 2 * radius, 2 * radius);
64
65 painter->restore();
66
67 return true;
68}
69
70RenderState FogLayer::renderState() const
71{
72 return RenderState(QStringLiteral("Fog"));
73}
74
75}
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 Mon Nov 4 2024 16:37:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.