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

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • layers
FogLayer.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-2007 Torsten Rahn <tackat@kde.org>
9 // Copyright 2007 Inge Wallin <ingwa@kde.org>
10 // Copyright 2008, 2009, 2010 Jens-Michael Hoffmann <jmho@c-xx.com>
11 // Copyright 2008-2009 Patrick Spendrin <ps_ml@gmx.de>
12 //
13 
14 #include "FogLayer.h"
15 
16 #include "GeoPainter.h"
17 #include "ViewportParams.h"
18 
19 namespace Marble
20 {
21 
22 QStringList FogLayer::renderPosition() const
23 {
24  return QStringList() << "ATMOSPHERE";
25 }
26 
27 bool FogLayer::render( GeoPainter *painter,
28  ViewportParams *viewParams,
29  const QString &renderPos,
30  GeoSceneLayer *layer )
31 {
32  Q_UNUSED(renderPos)
33  Q_UNUSED(layer)
34 
35  // FIXME: The fog layer is really slow. That's why we defer it to
36  // PrintQuality. Either cache on a pixmap - or maybe
37  // better: Add to GlobeScanlineTextureMapper.
38  if ( painter->mapQuality() != PrintQuality )
39  return true;
40 
41  if ( viewParams->projection() != Spherical)
42  return true;
43 
44  // No use to draw the fog if it's not visible in the area.
45  if ( viewParams->mapCoversViewport() )
46  return true;
47 
48  int imgWidth2 = viewParams->width() / 2;
49  int imgHeight2 = viewParams->height() / 2;
50 
51  int radius = viewParams->radius();
52 
53  // Recalculate the atmosphere effect and paint it to canvasImage.
54  QRadialGradient grad1( QPointF( imgWidth2, imgHeight2 ), radius );
55 
56  // FIXME: Add a cosine relationship
57  grad1.setColorAt( 0.85, QColor( 255, 255, 255, 0 ) );
58  grad1.setColorAt( 1.00, QColor( 255, 255, 255, 64 ) );
59 
60  QBrush brush1( grad1 );
61  QPen pen1( Qt::NoPen );
62 
63  painter->save();
64 
65  painter->setBrush( brush1 );
66  painter->setPen( pen1 );
67  painter->setRenderHint( QPainter::Antialiasing, false );
68 
69  // FIXME: Cut out what's really needed
70  painter->drawEllipse( imgWidth2 - radius,
71  imgHeight2 - radius,
72  2 * radius,
73  2 * radius );
74 
75  painter->restore();
76 
77  return true;
78 }
79 
80 }
Marble::GeoPainter
A painter that allows to draw geometric primitives on the map.
Definition: GeoPainter.h:98
Marble::PrintQuality
Print quality.
Definition: MarbleGlobal.h:85
Marble::ViewportParams::projection
Projection projection() const
Definition: ViewportParams.cpp:129
Marble::GeoPainter::drawEllipse
void drawEllipse(const GeoDataCoordinates &centerPosition, qreal width, qreal height, bool isGeoProjected=false)
Draws an ellipse at the given position. The ellipse is placed with its center located at the given ce...
Definition: GeoPainter.cpp:289
Marble::FogLayer::render
virtual bool render(GeoPainter *painter, ViewportParams *viewport, const QString &renderPos="NONE", GeoSceneLayer *layer=0)
Renders the content provided by the layer on the viewport.
Definition: FogLayer.cpp:27
Marble::ViewportParams::height
int height() const
Definition: ViewportParams.cpp:255
Marble::GeoSceneLayer
Layer of a GeoScene document.
Definition: GeoSceneLayer.h:43
Marble::ViewportParams::width
int width() const
Definition: ViewportParams.cpp:250
Marble::ViewportParams::mapCoversViewport
bool mapCoversViewport() const
Definition: ViewportParams.cpp:398
GeoPainter.h
Marble::ViewportParams
A public class that controls what is visible in the viewport of a Marble map.
Definition: ViewportParams.h:44
ViewportParams.h
This file contains the headers for ViewportParams.
Marble::ViewportParams::radius
int radius() const
Definition: ViewportParams.cpp:195
Marble::FogLayer::renderPosition
virtual QStringList renderPosition() const
Preferred level in the layer stack for the rendering.
Definition: FogLayer.cpp:22
Marble::GeoPainter::mapQuality
MapQuality mapQuality() const
Returns the map quality.
Definition: GeoPainter.cpp:191
Marble::Spherical
Spherical projection.
Definition: MarbleGlobal.h:45
FogLayer.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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