[Marble-commits] KDE/kdeedu/marble/src/lib
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Sun Nov 7 10:43:29 CET 2010
SVN commit 1193818 by beschow:
implement athmosphere as a layer
* still draw it manually instead of adding it to the LayerManager
* TODO: once layers are moved to MarbleMap, add it to the LayerManager and pass the ViewParams in the constructor
A AtmosphereLayer.cpp [License: LGPL]
A AtmosphereLayer.h [License: LGPL]
M +1 -0 CMakeLists.txt
M +6 -51 MarbleModel.cpp
M +0 -1 MarbleModel.h
--- trunk/KDE/kdeedu/marble/src/lib/CMakeLists.txt #1193817:1193818
@@ -119,6 +119,7 @@
PlacemarkLayout.cpp
PlacemarkPainter.cpp
PlacemarkInfoDialog.cpp
+ AtmosphereLayer.cpp
GeometryLayer.cpp
Planet.cpp
Quaternion.cpp
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1193817:1193818
@@ -61,6 +61,7 @@
#include "MergedLayerDecorator.h"
#include "FileManager.h"
#include "GeoDataTreeModel.h"
+#include "AtmosphereLayer.h"
#include "GeometryLayer.h"
#include "PlacemarkManager.h"
#include "PlacemarkLayout.h"
@@ -124,7 +125,6 @@
void notifyModelChanged();
GeoSceneGroup * textureLayerProperties() const;
- void drawAtmosphere( QPainter *painter, ViewParams *viewParams );
void drawFog( QPainter *painter, ViewParams *viewParams );
MarbleModel *m_parent;
@@ -161,6 +161,7 @@
PlacemarkLayout *m_placemarkLayout;
QSortFilterProxyModel *m_popSortModel;
GeometryLayer *m_geometryLayer;
+ AtmosphereLayer m_atmosphereLayer;
// Misc stuff.
MarbleClock *m_clock;
@@ -621,10 +622,12 @@
if ( d->m_backgroundVisible ) {
renderPositions << "STARS" << "BEHIND_TARGET";
d->m_layerManager->renderLayers( painter, viewParams, renderPositions );
+
+ if ( viewParams->showAtmosphere() ) {
+ d->m_atmosphereLayer.render( painter, viewParams->viewport() );
}
+ }
- d->drawAtmosphere( painter, viewParams );
-
if ( redrawBackground ) {
if ( d->m_mapTheme->map()->hasTextureLayers() ) {
@@ -827,54 +830,6 @@
painter->restore();
}
-void MarbleModelPrivate::drawAtmosphere( QPainter *painter,
- ViewParams *viewParams )
-{
- if( !viewParams->showAtmosphere() ) {
- return;
- }
-
- // Only draw an atmosphere if planet is earth
- GeoSceneDocument *mapTheme = viewParams->mapTheme();
- if ( mapTheme ) {
- if ( mapTheme->head()->target() != "earth" )
- return;
- }
-
- // Only draw an atmosphere if projection is spherical
- if ( viewParams->projection() != Spherical )
- return;
-
- // No use to draw atmosphere if it's not visible in the area.
- if ( viewParams->viewport()->mapCoversViewport() )
- return;
-
- // Ok, now we know that at least a little of the atmosphere is
- // visible, if nothing else in the corners. Draw the atmosphere
- // by using a circular gradient. This is a pure visual effect and
- // has nothing to do with real physics.
-
- int imageHalfWidth = viewParams->width() / 2;
- int imageHalfHeight = viewParams->height() / 2;
-
- // Recalculate the atmosphere effect and paint it to canvasImage.
- QRadialGradient grad1( QPointF( imageHalfWidth, imageHalfHeight ),
- 1.05 * viewParams->radius() );
- grad1.setColorAt( 0.91, QColor( 255, 255, 255, 255 ) );
- grad1.setColorAt( 1.00, QColor( 255, 255, 255, 0 ) );
-
- QBrush brush1( grad1 );
- QPen pen1( Qt::NoPen );
-
- painter->setBrush( brush1 );
- painter->setPen( pen1 );
- painter->setRenderHint( QPainter::Antialiasing, false );
- painter->drawEllipse( imageHalfWidth - (int) ( (qreal) ( viewParams->radius() ) * 1.05 ),
- imageHalfHeight - (int) ( (qreal) ( viewParams->radius() ) * 1.05 ),
- (int) ( 2.1 * (qreal) ( viewParams->radius()) ),
- (int) ( 2.1 * (qreal) ( viewParams->radius()) ) );
-}
-
void MarbleModel::update()
{
mDebug() << "MarbleModel::update()";
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.h #1193817:1193818
@@ -214,7 +214,6 @@
* @brief Return the downloadmanager to load missing tiles
* @return the HttpDownloadManager instance.
*/
-
HttpDownloadManager* downloadManager() const;
/**
More information about the Marble-commits
mailing list