[Marble-commits] KDE/kdeedu/marble/src/lib

Bernhard Beschow bbeschow at cs.tu-berlin.de
Sun Nov 7 10:43:31 CET 2010


SVN commit 1193819 by beschow:

implement fog 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

 M  +1 -0      CMakeLists.txt  
 A             FogLayer.cpp   [License: LGPL]
 A             FogLayer.h   [License: LGPL]
 M  +3 -43     MarbleModel.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/CMakeLists.txt #1193818:1193819
@@ -120,6 +120,7 @@
     PlacemarkPainter.cpp
     PlacemarkInfoDialog.cpp
     AtmosphereLayer.cpp
+    FogLayer.cpp
     GeometryLayer.cpp
     Planet.cpp
     Quaternion.cpp
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1193818:1193819
@@ -62,6 +62,7 @@
 #include "FileManager.h"
 #include "GeoDataTreeModel.h"
 #include "AtmosphereLayer.h"
+#include "FogLayer.h"
 #include "GeometryLayer.h"
 #include "PlacemarkManager.h"
 #include "PlacemarkLayout.h"
@@ -125,8 +126,6 @@
     void notifyModelChanged();
     GeoSceneGroup * textureLayerProperties() const;
 
-    void drawFog( QPainter *painter, ViewParams *viewParams );
-
     MarbleModel             *m_parent;
     MarbleDataFacade        *m_dataFacade;
 
@@ -162,6 +161,7 @@
     QSortFilterProxyModel   *m_popSortModel;
     GeometryLayer           *m_geometryLayer;
     AtmosphereLayer          m_atmosphereLayer;
+    FogLayer                 m_fogLayer;
 
     // Misc stuff.
     MarbleClock             *m_clock;
@@ -715,7 +715,7 @@
     //        better: Add to GlobeScanlineTextureMapper.
 
     if ( viewParams->mapQuality() == PrintQuality )
-        d->drawFog( painter, viewParams );
+        d->m_fogLayer.render( painter, viewParams->viewport() );
 
     renderPositions.clear();
     renderPositions << "ATMOSPHERE"
@@ -790,46 +790,6 @@
     emit m_parent->modelChanged();
 }
 
-void MarbleModelPrivate::drawFog( QPainter *painter,
-                                  ViewParams *viewParams )
-{
-    if ( viewParams->projection() != Spherical)
-        return;
-
-    // No use to draw the fog if it's not visible in the area.
-    if ( viewParams->viewport()->mapCoversViewport() )
-        return;
-
-    int imgWidth2  = viewParams->width() / 2;
-    int imgHeight2 = viewParams->height() / 2;
-
-    int radius = viewParams->radius();
-
-    // Recalculate the atmosphere effect and paint it to canvasImage.
-    QRadialGradient grad1( QPointF( imgWidth2, imgHeight2 ), radius );
-
-    // FIXME: Add a cosine relationship
-    grad1.setColorAt( 0.85, QColor( 255, 255, 255, 0 ) );
-    grad1.setColorAt( 1.00, QColor( 255, 255, 255, 64 ) );
-
-    QBrush    brush1( grad1 );
-    QPen      pen1( Qt::NoPen );
-
-    painter->save();
-
-    painter->setBrush( brush1 );
-    painter->setPen( pen1 );
-    painter->setRenderHint( QPainter::Antialiasing, false );
-
-    // FIXME: Cut out what's really needed
-    painter->drawEllipse( imgWidth2  - radius,
-                         imgHeight2 - radius,
-                         2 * radius,
-                         2 * radius );
-
-    painter->restore();
-}
-
 void MarbleModel::update()
 {
     mDebug() << "MarbleModel::update()";


More information about the Marble-commits mailing list