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

Jens-Michael Hoffmann jensmh at gmx.de
Mon Apr 26 12:28:33 CEST 2010


SVN commit 1118964 by jmhoffmann:

Add "download region" feature.

Most of the necessary bits (download queues, tileloader refactoring)
for this are already committed, so this is mostly about UI parts
and does not touch existing code too much.

 M  +12 -0     lib/AbstractScanlineTextureMapper.h  
 M  +10 -0     lib/CMakeLists.txt  
 A             lib/DownloadRegionDialog.cpp   [License: LGPL (v2.1+)]
 A             lib/DownloadRegionDialog.h   [License: LGPL (v2.1+)]
 A             lib/LatLonBoxWidget.cpp   [License: LGPL (v2.1+)]
 A             lib/LatLonBoxWidget.h   [License: LGPL (v2.1+)]
 A             lib/LatLonBoxWidget.ui  
 M  +18 -0     lib/MarbleModel.cpp  
 M  +2 -0      lib/MarbleModel.h  
 A             lib/TileCoordsPyramid.cpp   [License: LGPL (v2.1+)]
 A             lib/TileCoordsPyramid.h   [License: LGPL (v2.1+)]
 A             lib/TileLevelRangeWidget.cpp   [License: LGPL (v2.1+)]
 A             lib/TileLevelRangeWidget.h   [License: LGPL (v2.1+)]
 A             lib/TileLevelRangeWidget.ui  
 M  +24 -0     marble_part.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/AbstractScanlineTextureMapper.h #1118963:1118964
@@ -48,6 +48,8 @@
     bool interlaced() const;
     void setInterlaced( bool enabled );
     int tileZoomLevel() const;
+    QSize tileSize() const;
+    GeoSceneTexture const * textureLayer() const;
 
  Q_SIGNALS:
     void mapChanged();
@@ -169,6 +171,16 @@
     m_interlaced = enabled;
 }
 
+inline QSize AbstractScanlineTextureMapper::tileSize() const
+{
+    return m_tileSize;
+}
+
+inline GeoSceneTexture const * AbstractScanlineTextureMapper::textureLayer() const
+{
+    return m_textureLayer;
+}
+
 inline int AbstractScanlineTextureMapper::globalWidth() const
 {
     return m_globalWidth;
--- trunk/KDE/kdeedu/marble/src/lib/CMakeLists.txt #1118963:1118964
@@ -63,6 +63,8 @@
     blendings/BlendingAlgorithms.cpp
     blendings/BlendingFactory.cpp
     blendings/SunLightBlending.cpp
+    DownloadRegionDialog.cpp
+    LatLonBoxWidget.cpp
     MarbleWidget.cpp
     MarbleModel.cpp
     MarbleMap.cpp
@@ -80,6 +82,8 @@
     MarbleDataFacade.cpp
     MarbleDebug.cpp
     TextureTile.cpp
+    TileCoordsPyramid.cpp
+    TileLevelRangeWidget.cpp
     TileLoader.cpp
     QtMarbleConfigDialog.cpp
     ClipPainter.cpp
@@ -209,6 +213,7 @@
 )
 
 set (marblewidget_UI
+    LatLonBoxWidget.ui
     MarbleControlBox.ui
     MarbleNavigator.ui
     MarbleViewSettingsWidget.ui
@@ -216,6 +221,7 @@
     MarbleCacheSettingsWidget.ui
     MarblePluginSettingsWidget.ui
     TileCreatorDialog.ui
+    TileLevelRangeWidget.ui
     PlacemarkInfoDialog.ui
     MarbleAboutDialog.ui
     SunControlWidget.ui
@@ -289,6 +295,8 @@
 else (APPLE AND QTONLY)
   install( FILES
     ${graphicsview_HDRS}
+    DownloadRegionDialog.h
+    LatLonBoxWidget.h
     MarbleWidget.h
     MarbleMap.h
     MarbleModel.h
@@ -299,6 +307,8 @@
     MapThemeManager.h
     MarbleAboutDialog.h
     MarbleWidgetInputHandler.h
+    TileCoordsPyramid.h
+    TileLevelRangeWidget.h
     TinyWebBrowser.h
     QtMarbleConfigDialog.h
     global.h
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1118963:1118964
@@ -70,6 +70,7 @@
 #include "SunLocator.h"
 #include "TextureColorizer.h"
 #include "StackedTile.h"
+#include "TileCoordsPyramid.h"
 #include "TileCreator.h"
 #include "TileCreatorDialog.h"
 #include "StackedTileLoader.h"
@@ -923,6 +924,23 @@
     }
 }
 
+void MarbleModel::downloadRegion( QString const & mapThemeId,
+                                  TileCoordsPyramid const & pyramid ) const
+{
+    Q_ASSERT( d->m_tileLoader );
+    for ( int level = pyramid.topLevel(); level <= pyramid.bottomLevel(); ++level ) {
+        QRect const coords = pyramid.coords( level );
+        mDebug() << "MarbleModel::downloadRegion level:" << level << "tile coords:" << coords;
+        int x1, y1, x2, y2;
+        coords.getCoords( &x1, &y1, &x2, &y2 );
+        for ( int x = x1; x <= x2; ++x )
+            for ( int y = y1; y <= y2; ++y ) {
+                TileId const tileId( mapThemeId, level, x, y );
+                d->m_tileLoader->reloadTile( tileId, DownloadBulk );
+            }
+    }
+}
+
 void MarbleModel::addDownloadPolicies( GeoSceneDocument *mapTheme )
 {
     if ( !mapTheme )
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.h #1118963:1118964
@@ -49,6 +49,7 @@
 class AbstractDataPluginItem;
 class AbstractScanlineTextureMapper;
 class GeoPainter;
+class TileCoordsPyramid;
 class FileViewModel;
 class GpsLayer;
 class GpxFileModel;
@@ -305,6 +306,7 @@
     int tileZoomLevel() const;
 
     void reloadMap() const;
+    void downloadRegion( QString const & mapThemeId, TileCoordsPyramid const & ) const;
 
  public Q_SLOTS:
     void clearVolatileTileCache();
--- trunk/KDE/kdeedu/marble/src/marble_part.cpp #1118963:1118964
@@ -55,9 +55,11 @@
 // Marble library classes
 #include "AbstractFloatItem.h"
 #include "AbstractDataPlugin.h"
+#include "DownloadRegionDialog.h"
 #include "GeoDataCoordinates.h"
 #include "HttpDownloadManager.h"
 #include "MarbleCacheSettingsWidget.h"
+#include "MarbleDebug.h"
 #include "MarbleDirs.h"
 #include "MarbleLocale.h"
 #include "MarbleMap.h"
@@ -65,6 +67,9 @@
 #include "MarblePluginSettingsWidget.h"
 #include "SunControlWidget.h"
 #include "SunLocator.h"
+#include "TileCoordsPyramid.h"
+#include "ViewParams.h"
+#include "ViewportParams.h"
 
 // Marble non-library classes
 #include "ControlView.h"
@@ -965,7 +970,26 @@
 
 void MarblePart::showDownloadRegionDialog()
 {
+    ViewportParams * const viewport = m_controlView->marbleWidget()->map()->viewParams()->viewport();
+    MarbleModel * const model = m_controlView->marbleWidget()->map()->model();
+    QPointer<DownloadRegionDialog> dialog = new DownloadRegionDialog( viewport,
+                                                                      model->textureMapper() );
+    // FIXME: get allowed range from current map theme
+    dialog->setAllowedTileLevelRange( 0, 18 );
+    QString const mapThemeId = m_controlView->marbleWidget()->mapThemeId();
+    QString const sourceDir = mapThemeId.left( mapThemeId.lastIndexOf( '/' ));
+    mDebug() << "showDownloadRegionDialog mapThemeId:" << mapThemeId << sourceDir;
+
+    if ( dialog->exec() == QDialog::Accepted ) {
+        // FIXME: use lazy evaluation to not generate up to 100k tiles in one go
+        // this can take considerable time even on very fast systems
+        // in contrast generating the TileIds on the fly when they are needed
+        // does not seem to affect download speed.
+        TileCoordsPyramid const pyramid = dialog->region();
+        model->downloadRegion( sourceDir, pyramid );
 }
+    delete dialog;
+}
 
 void MarblePart::showStatusBarContextMenu( const QPoint& pos )
 {


More information about the Marble-commits mailing list