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

Jens-Michael Hoffmann jensmh at gmx.de
Tue May 11 23:55:33 CEST 2010


SVN commit 1125659 by jmhoffmann:

DownloadRegionDialog: When the map theme changes, update the texture layer
and tiles count, as the tile layout might be different.
Also use the active texture mapper, not the one that was active when
creating the dialog (leftover from modal mode).

 M  +37 -17    lib/DownloadRegionDialog.cpp  
 M  +3 -3      lib/DownloadRegionDialog.h  
 M  +2 -2      marble_part.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/DownloadRegionDialog.cpp #1125658:1125659
@@ -28,6 +28,7 @@
 #include "GeoSceneTexture.h"
 #include "MarbleDebug.h"
 #include "MarbleMath.h"
+#include "MarbleModel.h"
 #include "LatLonBoxWidget.h"
 #include "TileId.h"
 #include "TileLevelRangeWidget.h"
@@ -43,7 +44,7 @@
 {
 public:
     Private( ViewportParams const * const viewport,
-             AbstractScanlineTextureMapper const * const textureMapper,
+             MarbleModel const * const model,
              QDialog * const dialog );
     QWidget * createSelectionMethodBox();
     QLayout * createTilesCounter();
@@ -51,6 +52,7 @@
 
     int rad2PixelX( qreal const lon ) const;
     int rad2PixelY( qreal const lat ) const;
+    AbstractScanlineTextureMapper const * textureMapper() const;
 
     QDialog * m_dialog;
     LatLonBoxWidget * m_latLonBoxWidget;
@@ -63,13 +65,13 @@
     int m_minimumAllowedTileLevel;
     int m_maximumAllowedTileLevel;
     ViewportParams const * const m_viewport;
-    AbstractScanlineTextureMapper const * const m_textureMapper;
-    GeoSceneTexture const * const m_textureLayer;
+    MarbleModel const * const m_model;
+    GeoSceneTexture const * m_textureLayer;
     GeoDataLatLonBox m_visibleRegion;
 };
 
 DownloadRegionDialog::Private::Private( ViewportParams const * const viewport,
-                                        AbstractScanlineTextureMapper const * const textureMapper,
+                                        MarbleModel const * const model,
                                         QDialog * const dialog )
     : m_dialog( dialog ),
       m_latLonBoxWidget( new LatLonBoxWidget ),
@@ -78,12 +80,12 @@
       m_tilesCountLimitInfo( 0 ),
       m_okButton( 0 ),
       m_applyButton( 0 ),
-      m_originatingTileLevel( textureMapper->tileZoomLevel() ),
+      m_originatingTileLevel( model->textureMapper()->tileZoomLevel() ),
       m_minimumAllowedTileLevel( -1 ),
       m_maximumAllowedTileLevel( -1 ),
       m_viewport( viewport ),
-      m_textureMapper( textureMapper ),
-      m_textureLayer( textureMapper->textureLayer() ),
+      m_model( model ),
+      m_textureLayer( model->textureMapper()->textureLayer() ),
       m_visibleRegion( viewport->viewLatLonAltBox() )
 {
     m_latLonBoxWidget->setEnabled( false );
@@ -140,7 +142,7 @@
 // copied from AbstractScanlineTextureMapper and slightly adjusted
 int DownloadRegionDialog::Private::rad2PixelX( qreal const lon ) const
 {
-    qreal const globalWidth = m_textureMapper->tileSize().width()
+    qreal const globalWidth = textureMapper()->tileSize().width()
         * TileLoaderHelper::levelToColumn( m_textureLayer->levelZeroColumns(),
                                            m_originatingTileLevel );
     return static_cast<int>( globalWidth * 0.5 + lon * ( globalWidth / ( 2.0 * M_PI ) ));
@@ -149,7 +151,7 @@
 // copied from AbstractScanlineTextureMapper and slightly adjusted
 int DownloadRegionDialog::Private::rad2PixelY( qreal const lat ) const
 {
-    qreal const globalHeight = m_textureMapper->tileSize().height()
+    qreal const globalHeight = textureMapper()->tileSize().height()
         * TileLoaderHelper::levelToRow( m_textureLayer->levelZeroRows(), m_originatingTileLevel );
     qreal const normGlobalHeight = globalHeight / M_PI;
     switch ( m_textureLayer->projection() ) {
@@ -168,11 +170,19 @@
     return 0;
 }
 
+AbstractScanlineTextureMapper const * DownloadRegionDialog::Private::textureMapper() const
+{
+    AbstractScanlineTextureMapper const * const result = m_model->textureMapper();
+    Q_ASSERT( result );
+    return result;
+}
+
+
 DownloadRegionDialog::DownloadRegionDialog( ViewportParams const * const viewport,
-                                            AbstractScanlineTextureMapper const * const textureMapper,
+                                            MarbleModel const * const model,
                                             QWidget * const parent, Qt::WindowFlags const f )
     : QDialog( parent, f ),
-      d( new Private( viewport, textureMapper, this ))
+      d( new Private( viewport, model, this ))
 {
     setWindowTitle( tr( "Download Region" ));
 
@@ -226,8 +236,9 @@
     mDebug() << "north/west (x/y):" << westX << northY;
     mDebug() << "south/east (x/y):" << eastX << southY;
 
-    int const tileWidth = d->m_textureMapper->tileSize().width();
-    int const tileHeight = d->m_textureMapper->tileSize().height();
+    int const tileWidth = d->textureMapper()->tileSize().width();
+    int const tileHeight = d->textureMapper()->tileSize().height();
+    mDebug() << "DownloadRegionDialog downloadRegion: tileSize:" << tileWidth << tileHeight;
 
     int const visibleLevelX1 = qMin( westX, eastX );
     int const visibleLevelY1 = qMin( northY, southY );
@@ -278,14 +289,23 @@
     return coordsPyramid;
 }
 
-void DownloadRegionDialog::setMapTheme( QString const & mapThemeId )
+void DownloadRegionDialog::setVisibleLatLonAltBox( GeoDataLatLonAltBox const & region )
 {
-    mDebug() << "DownloadRegionDialog::setMapTheme" << mapThemeId;
+    d->m_visibleRegion = region;
+    updateTilesCount();
 }
 
-void DownloadRegionDialog::setVisibleLatLonAltBox( GeoDataLatLonAltBox const & region )
+void DownloadRegionDialog::updateTextureLayer()
 {
-    d->m_visibleRegion = region;
+    mDebug() << "DownloadRegionDialog::updateTextureLayer";
+    AbstractScanlineTextureMapper const * const textureMapper = d->m_model->textureMapper();
+    if ( textureMapper ) {
+        d->m_textureLayer = textureMapper->textureLayer();
+    }
+    else {
+        d->m_textureLayer = 0;
+        mDebug() << "DownloadRegionDialog::updateTextureLayer: no texture mapper";
+    }
     updateTilesCount();
 }
 
--- trunk/KDE/kdeedu/marble/src/lib/DownloadRegionDialog.h #1125658:1125659
@@ -21,8 +21,8 @@
 
 namespace Marble
 {
-class AbstractScanlineTextureMapper;
 class GeoDataLatLonAltBox;
+class MarbleModel;
 class ViewportParams;
 
 class MARBLE_EXPORT DownloadRegionDialog: public QDialog
@@ -31,7 +31,7 @@
 
  public:
     DownloadRegionDialog( ViewportParams const * const viewport,
-                          AbstractScanlineTextureMapper const * const textureMapper,
+                          MarbleModel const * const model,
                           QWidget * const parent = 0, Qt::WindowFlags const f = 0 );
 
     void setAllowedTileLevelRange( int const minimumTileLevel,
@@ -41,8 +41,8 @@
     TileCoordsPyramid region() const;
 
  public Q_SLOTS:
-    void setMapTheme( QString const & );
     void setVisibleLatLonAltBox( GeoDataLatLonAltBox const & );
+    void updateTextureLayer();
 
  Q_SIGNALS:
     /// This signal is emitted when the "Apply" button is pressed.
--- trunk/KDE/kdeedu/marble/src/marble_part.cpp #1125658:1125659
@@ -977,13 +977,13 @@
     ViewportParams * const viewport = m_controlView->marbleWidget()->map()->viewParams()->viewport();
     MarbleModel * const model = m_controlView->marbleWidget()->map()->model();
     if ( !m_downloadRegionDialog ) {
-        m_downloadRegionDialog = new DownloadRegionDialog( viewport, model->textureMapper() );
+        m_downloadRegionDialog = new DownloadRegionDialog( viewport, model );
         connect( m_downloadRegionDialog, SIGNAL( accepted() ), SLOT( downloadRegion() ));
         connect( m_downloadRegionDialog, SIGNAL( applied() ), SLOT( downloadRegion() ));
         connect( m_controlView->marbleWidget(), SIGNAL( visibleLatLonAltBoxChanged( GeoDataLatLonAltBox )),
                  m_downloadRegionDialog, SLOT( setVisibleLatLonAltBox( GeoDataLatLonAltBox )));
         connect( m_controlView->marbleWidget(), SIGNAL( themeChanged( QString )),
-                 m_downloadRegionDialog, SLOT( setMapTheme( QString )));
+                 m_downloadRegionDialog, SLOT( updateTextureLayer() ));
     }
     // FIXME: get allowed range from current map theme
     m_downloadRegionDialog->setAllowedTileLevelRange( 0, 18 );


More information about the Marble-commits mailing list