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

Torsten Rahn tackat at kde.org
Fri Jul 17 18:48:49 CEST 2009


SVN commit 998440 by rahn:

Backport of 998435.



 M  +41 -13    MarbleMap.cpp  
 M  +1 -0      MarbleMap_p.h  
 M  +15 -7     MarbleWidget.cpp  
 M  +6 -6      MergedLayerDecorator.cpp  
 M  +2 -1      Projections/SphericalProjection.cpp  
 M  +1 -2      SunLocator.cpp  


--- branches/KDE/4.3/kdeedu/marble/src/lib/MarbleMap.cpp #998439:998440
@@ -90,7 +90,8 @@
                        m_parent, SLOT( updateChangedMap() ) );
 
     m_justModified = false;
-
+    m_dirtyAtmosphere = false;
+    
     m_measureTool = new MeasureTool( m_model, m_parent );
 
     m_parent->connect( m_model, SIGNAL( timeout() ),
@@ -136,7 +137,7 @@
                                              QImage::Format_RGB32 ));
 
     if ( m_viewParams.showAtmosphere() ) {
-        drawAtmosphere();
+        m_dirtyAtmosphere=true;
     }
 
     // Recreate the 
@@ -265,6 +266,11 @@
         return;
     }
 
+    if ( m_dirtyAtmosphere ) {
+        drawAtmosphere();
+        m_dirtyAtmosphere = false;
+    }
+
     m_model->paintGlobe( &painter,
                          m_parent->width(), m_parent->height(), &m_viewParams,
                          m_parent->needsUpdate() || m_viewParams.canvasImage()->isNull(),
@@ -504,6 +510,13 @@
     setRadius( (int)( model()->planet()->radius() * 0.4
             / distance
             / tan( 0.5 * VIEW_ANGLE * DEG2RAD ) ) );
+
+    // We don't do this on every paintEvent to improve performance.
+    // Redrawing the atmosphere is only needed if the size of the
+    // globe changes.
+    if ( d->m_viewParams.showAtmosphere() ) {
+        d->m_dirtyAtmosphere=true;
+    }            
 }
 
 qreal MarbleMap::centerLatitude() const
@@ -709,10 +722,10 @@
     setRadius( d->fromLogScale( newZoom ) );
 
     // We don't do this on every paintEvent to improve performance.
-    // Redrawing the atmosphere is only needed if the size of the 
+    // Redrawing the atmosphere is only needed if the size of the
     // globe changes.
     if ( d->m_viewParams.showAtmosphere() ) {
-        d->drawAtmosphere();
+        d->m_dirtyAtmosphere=true;
     }
 
     emit zoomChanged( newZoom );
@@ -804,7 +817,7 @@
     d->m_viewParams.setProjection( projection );
  
     if ( d->m_viewParams.showAtmosphere() ) {
-        d->drawAtmosphere();
+        d->m_dirtyAtmosphere=true;
     }
 
     d->m_model->setupTextureMapper( projection );
@@ -895,7 +908,7 @@
 {
     QTime t;
     t.start();
-
+    
     d->paintGround( painter, dirtyRect );
     customPaint( &painter );
     d->paintOverlay( painter, dirtyRect );
@@ -939,7 +952,15 @@
     GeoSceneDocument *mapTheme = d->m_viewParams.mapTheme();
 
     d->m_model->setMapTheme( mapTheme, d->m_viewParams.projection() );
+    
+    // We don't do this on every paintEvent to improve performance.
+    // Redrawing the atmosphere is only needed if the size of the
+    // globe changes.
+    d->doResize();
+    d->m_dirtyAtmosphere=true;
 
+    centerSun();
+
     // Update texture map during the repaint that follows:
     setNeedsUpdate();
 }
@@ -967,9 +988,14 @@
 
 void MarbleMap::setShowAtmosphere( bool visible )
 {
-    d->m_viewParams.setShowAtmosphere( visible );
-    // Quick and dirty way to force a whole update of the view
-    d->doResize();
+    bool previousVisible = showAtmosphere();
+
+    if ( visible != previousVisible ) {
+        d->m_viewParams.setShowAtmosphere( visible );
+
+        // Quick and dirty way to force a whole update of the view
+        d->doResize();
+    }
 }
 
 void MarbleMap::setShowCrosshairs( bool visible )
@@ -1248,11 +1274,13 @@
 {
     SunLocator  *sunLocator = d->m_model->sunLocator();
 
-    qreal  lon = sunLocator->getLon();
-    qreal  lat = sunLocator->getLat();
-    centerOn( lon, lat );
+    if ( sunLocator && sunLocator->getCentered() ) {
+        qreal  lon = sunLocator->getLon();
+        qreal  lat = sunLocator->getLat();
+        centerOn( lon, lat );
 
-    qDebug() << "Centering on Sun at " << lat << lon;
+        qDebug() << "Centering on Sun at " << lat << lon;
+    }
 }
 
 SunLocator* MarbleMap::sunLocator()
--- branches/KDE/4.3/kdeedu/marble/src/lib/MarbleMap_p.h #998439:998440
@@ -61,6 +61,7 @@
     int              m_height;
     ViewParams       m_viewParams;
     bool             m_justModified; // FIXME: Rename to isDirty
+    bool             m_dirtyAtmosphere;
 
     // The home position
     GeoDataCoordinates     m_homePoint;
--- branches/KDE/4.3/kdeedu/marble/src/lib/MarbleWidget.cpp #998439:998440
@@ -817,14 +817,20 @@
 
 void MarbleWidget::setMapThemeId( const QString& mapThemeId )
 {
-    qDebug() << "MapThemeId" << mapThemeId;
     if ( !mapThemeId.isEmpty() && mapThemeId == d->m_model->mapThemeId() )
         return;
-
+    
     d->m_map->setMapThemeId( mapThemeId );
-
+    
     // Update texture map during the repaint that follows:
     setNeedsUpdate();
+
+    // Now we want a full repaint as the atmosphere might differ
+    setAttribute( Qt::WA_NoSystemBackground,
+                  false );
+
+    centerSun();
+
     repaint();
 }
 
@@ -1194,11 +1200,13 @@
 {
     SunLocator  *sunLocator = d->m_model->sunLocator();
 
-    qreal  lon = sunLocator->getLon();
-    qreal  lat = sunLocator->getLat();
-    centerOn( lon, lat );
+    if ( sunLocator && sunLocator->getCentered() ) {
+        qreal  lon = sunLocator->getLon();
+        qreal  lat = sunLocator->getLat();
+        centerOn( lon, lat );
 
-    disableInput();
+        disableInput();
+    }
 }
 
 SunLocator* MarbleWidget::sunLocator()
--- branches/KDE/4.3/kdeedu/marble/src/lib/MergedLayerDecorator.cpp #998439:998440
@@ -102,7 +102,7 @@
             paintClouds();
         }
     }
-    if ( m_sunLocator->getShow() && mapTheme && mapTheme->head()->target() == "earth" ) {
+    if ( m_sunLocator->getShow() && mapTheme ) {
 
         // Initialize citylights layer if it hasn't happened already
         if ( !m_cityLightsTheme ) {
@@ -196,7 +196,7 @@
 {
     if ( m_tile->depth() != 32 )
         return;
-	
+
     // TODO add support for 8-bit maps?
     // add sun shading
     const qreal  global_width  = m_tile->width()
@@ -221,8 +221,8 @@
             return;
         for ( int cur_y = 0; cur_y < tileHeight; ++cur_y ) {
             qreal lat = lat_scale * ( m_y * tileHeight + cur_y ) - 0.5*M_PI;
-            qreal a = sin( ( lat-DEG2RAD * m_sunLocator->getLat() )/2.0 );
-            qreal c = cos(lat)*cos( DEG2RAD * m_sunLocator->getLat() );
+            qreal a = sin( ( lat+DEG2RAD * m_sunLocator->getLat() )/2.0 );
+            qreal c = cos(lat)*cos( -DEG2RAD * m_sunLocator->getLat() );
 
             QRgb* scanline  = (QRgb*)m_tile->scanLine( cur_y );
             QRgb* nscanline = (QRgb*)nighttile.scanLine( cur_y );
@@ -285,8 +285,8 @@
     } else {
         for ( int cur_y = 0; cur_y < tileHeight; ++cur_y ) {
             qreal lat = lat_scale * ( m_y * tileHeight + cur_y ) - 0.5*M_PI;
-            qreal a = sin( (lat-DEG2RAD * m_sunLocator->getLat() )/2.0 );
-            qreal c = cos(lat)*cos( DEG2RAD * m_sunLocator->getLat() );
+            qreal a = sin( (lat+DEG2RAD * m_sunLocator->getLat() )/2.0 );
+            qreal c = cos(lat)*cos( -DEG2RAD * m_sunLocator->getLat() );
 
             QRgb* scanline = (QRgb*)m_tile->scanLine( cur_y );
 
--- branches/KDE/4.3/kdeedu/marble/src/lib/Projections/SphericalProjection.cpp #998439:998440
@@ -232,7 +232,6 @@
     { 
         // Unless the planetaxis is in the screen plane the allowed longitude range
         // covers full -180 deg to +180 deg:
-
         if ( pitch > 0.0 && pitch < +M_PI ) {
             latLonAltBox.setWest(  -M_PI );
             latLonAltBox.setEast(  +M_PI );
@@ -253,6 +252,8 @@
             qreal yaw = viewport->planetAxis().yaw();
             latLonAltBox.setWest( GeoDataPoint::normalizeLon( yaw - M_PI / 2.0 ) );
             latLonAltBox.setEast( GeoDataPoint::normalizeLon( yaw + M_PI / 2.0 ) );
+            latLonAltBox.setNorth( +M_PI / 2.0 );
+            latLonAltBox.setSouth( -M_PI / 2.0 );
         }
     }
 
--- branches/KDE/4.3/kdeedu/marble/src/lib/SunLocator.cpp #998439:998440
@@ -144,8 +144,7 @@
     while(d->m_lon < 0)
         d->m_lon += 2*M_PI;
 
-    // convert positive north to positive south
-    d->m_lat = -delta_sun;
+    d->m_lat = delta_sun;
 }
 
 


More information about the Marble-commits mailing list