[Marble-devel] [PATCH 08/13] SunLocator: remove dead code.

Jens-Michael Hoffmann jensmh at gmx.de
Tue Mar 30 20:34:12 CEST 2010


SunLocator: remove dead code.

Some of this code was moved to SunLightBlending, other parts (shadePixel comes
to mind) have to be reintegrated.
---
 marble/src/lib/SunLocator.cpp |   83 -----------------------------------------
 marble/src/lib/SunLocator.h   |    5 --
 2 files changed, 0 insertions(+), 88 deletions(-)

diff --git a/marble/src/lib/SunLocator.cpp b/marble/src/lib/SunLocator.cpp
index 223a17c..16cd7fd 100644
--- a/marble/src/lib/SunLocator.cpp
+++ b/marble/src/lib/SunLocator.cpp
@@ -148,89 +148,6 @@ void SunLocator::updatePosition()
     d->m_lat = delta_sun;
 }
 
-
-qreal SunLocator::shading(qreal lon, qreal a, qreal c) const
-{
-    // haversine formula
-    qreal b = sin((lon-d->m_lon)/2.0);
-//    qreal g = sin((lat-d->m_lat)/2.0);
-//    qreal h = (g*g)+cos(lat)*cos(d->m_lat)*(b*b); 
-    qreal h = (a*a) + c * (b*b); 
-
-    /*
-      h = 0.0 // directly beneath sun
-      h = 0.5 // sunrise/sunset line
-      h = 1.0 // opposite side of earth to the sun
-      theta = 2*asin(sqrt(h))
-    */
-
-    qreal twilightZone = 0.0;
-
-    if ( d->m_planet->id() == "earth" || d->m_planet->id() == "venus" ) {
-        twilightZone = 0.1; // this equals 18 deg astronomical twilight.
-    }
-
-    qreal brightness;
-    if ( h <= 0.5 - twilightZone / 2.0 )
-        brightness = 1.0;
-    else if ( h >= 0.5 + twilightZone / 2.0 )
-        brightness = 0.0;
-    else
-        brightness = ( 0.5 + twilightZone/2.0 - h ) / twilightZone;
-
-    return brightness;
-}
-
-void SunLocator::shadePixel(QRgb& pixcol, qreal brightness) const
-{
-    // daylight - no change
-    if ( brightness > 0.99999 )
-        return;
-
-    if ( brightness < 0.00001 ) {
-        // night
-        //      Doing  "pixcol = qRgb(r/2, g/2, b/2);" by shifting some electrons around ;)
-        // by shifting some electrons around ;)
-        pixcol = qRgb(qRed(pixcol) * 0.35, qGreen(pixcol) * 0.35, qBlue(pixcol)  * 0.35);
-        // pixcol = (pixcol & 0xff000000) | ((pixcol >> 1) & 0x7f7f7f);
-    } else {
-        // gradual shadowing
-        int r = qRed( pixcol );
-        int g = qGreen( pixcol );
-        int b = qBlue( pixcol );
-        qreal  d = 0.65 * brightness + 0.35;
-        pixcol = qRgb((int)(d * r), (int)(d * g), (int)(d * b));
-    }
-}
-
-void SunLocator::shadePixelComposite(QRgb& pixcol, QRgb& dpixcol,
-                                     qreal brightness) const
-{
-    // daylight - no change
-    if ( brightness > 0.99999 )
-        return;
-
-    if ( brightness < 0.00001 ) {
-        // night
-        pixcol = dpixcol;
-    } else {
-        // gradual shadowing
-        qreal& d = brightness;
-
-        int r = qRed( pixcol );
-        int g = qGreen( pixcol );
-        int b = qBlue( pixcol );
-
-        int dr = qRed( dpixcol );
-        int dg = qGreen( dpixcol );
-        int db = qBlue( dpixcol );
-
-        pixcol = qRgb( (int)( d * r + (1 - d) * dr ),
-                       (int)( d * g + (1 - d) * dg ),
-                       (int)( d * b + (1 - d) * db ) );
-    }
-}
-
 void SunLocator::update()
 {
     updatePosition();
diff --git a/marble/src/lib/SunLocator.h b/marble/src/lib/SunLocator.h
index f7e591f..49fc9d9 100644
--- a/marble/src/lib/SunLocator.h
+++ b/marble/src/lib/SunLocator.h
@@ -20,7 +20,6 @@
 
 #include <QtCore/QObject>
 #include <QtCore/QString>
-#include <QtGui/QColor>
 
 //FIXME: This class shouldn't be exposed but is needed by the worldclock plasmoid
 #include "marble_export.h"
@@ -44,10 +43,6 @@ class MARBLE_EXPORT SunLocator : public QObject
     SunLocator(ExtDateTime *dateTime, Planet *planet);
     virtual ~SunLocator();
 
-    qreal shading(qreal lon, qreal a, qreal c) const;
-    void  shadePixel(QRgb& pixcol, qreal shade) const;
-    void  shadePixelComposite(QRgb& pixcol, QRgb& dpixcol, qreal shade) const;
-
     void  setShow(bool show);
     void  setCitylights(bool show);
     void  setCentered(bool show);
-- 
1.7.0.3



More information about the Marble-devel mailing list