[Marble-commits] branches/KDE/4.6/kdeedu/marble/src/lib
Bernhard Beschow
bbeschow at cs.tu-berlin.de
Wed Dec 29 23:03:37 CET 2010
SVN commit 1210168 by beschow:
backport of trunk-r1209046: move responsibility of maximum tile level calculation from AbstractScanlineTextureMapper to StackedTileLoader
* TODO: Move this responsibility to TileLoader once there is a 1:1 relation between GeoSceneTextures and TileLoaders.
Since this property is specific for a given GeoSceneTexture and only the TileLoader should know how to load tiles from disk,
it really belongs there.
M +2 -21 AbstractScanlineTextureMapper.cpp
M +0 -6 AbstractScanlineTextureMapper.h
M +30 -10 StackedTileLoader.cpp
M +1 -1 StackedTileLoader.h
M +0 -1 TextureLayer.cpp
--- branches/KDE/4.6/kdeedu/marble/src/lib/AbstractScanlineTextureMapper.cpp #1210167:1210168
@@ -41,7 +41,6 @@
m_tile( 0 ),
m_previousRadius( 0 ),
m_tileLevel( 0 ),
- m_maxTileLevel( 0 ),
m_globalWidth( 0 ),
m_globalHeight( 0 ),
m_normGlobalWidth( 0.0 ),
@@ -49,11 +48,6 @@
m_mapThemeIdHash( qHash( textureLayer->sourceDir() ) )
{
Q_ASSERT( textureLayer ); // just for documentation
-
- connect( m_tileLoader, SIGNAL( tileUpdateAvailable() ),
- this, SLOT( notifyMapChanged() ) );
-
- detectMaxTileLevel();
}
@@ -81,8 +75,8 @@
// mDebug() << "tileLevelF: " << tileLevelF << " tileLevel: " << tileLevel;
- if ( tileLevel > m_maxTileLevel )
- tileLevel = m_maxTileLevel;
+ if ( tileLevel > m_tileLoader->maximumTileLevel() )
+ tileLevel = m_tileLoader->maximumTileLevel();
if ( tileLevel != m_tileLevel ) {
m_tileLoader->flush();
@@ -564,19 +558,6 @@
posY = lat - m_tilePosY;
}
-void AbstractScanlineTextureMapper::notifyMapChanged()
-{
- detectMaxTileLevel();
- //mDebug() << "AbstractScanlineTextureMapper: emitting mapChanged";
- emit mapChanged();
-}
-
-void AbstractScanlineTextureMapper::detectMaxTileLevel()
-{
- m_maxTileLevel = StackedTileLoader::maximumTileLevel( m_textureLayer );
-// mDebug() << "MaxTileLevel: " << m_maxTileLevel;
-}
-
void AbstractScanlineTextureMapper::initGlobalWidth()
{
m_globalWidth = m_tileSize.width()
--- branches/KDE/4.6/kdeedu/marble/src/lib/AbstractScanlineTextureMapper.h #1210167:1210168
@@ -47,12 +47,8 @@
int tileZoomLevel() const;
Q_SIGNALS:
- void mapChanged();
void tileLevelChanged( int newTileLevel );
- private Q_SLOTS:
- void notifyMapChanged();
-
protected:
void pixelValueF( const qreal lon, const qreal lat,
QRgb* const scanLine );
@@ -73,7 +69,6 @@
void nextTile( qreal& posx, qreal& posy );
void selectTileLevel( ViewParams * const viewParams );
- void detectMaxTileLevel();
void tileLevelInit( const int tileLevel );
int globalWidth() const;
@@ -132,7 +127,6 @@
int m_previousRadius;
int m_tileLevel;
- int m_maxTileLevel;
int m_globalWidth;
int m_globalHeight;
qreal m_normGlobalWidth;
--- branches/KDE/4.6/kdeedu/marble/src/lib/StackedTileLoader.cpp #1210167:1210168
@@ -64,14 +64,18 @@
StackedTileLoaderPrivate( TileLoader *tileLoader, SunLocator *sunLocator )
: m_datasetProvider( 0 ),
m_layerDecorator( tileLoader, sunLocator ),
- m_tileLoader( tileLoader )
+ m_tileLoader( tileLoader ),
+ m_maxTileLevel( 0 )
{
m_tileCache.setMaxCost( 20000 * 1024 ); // Cache size measured in bytes
}
+ void detectMaxTileLevel();
+
DatasetProvider *m_datasetProvider;
MergedLayerDecorator m_layerDecorator;
TileLoader *m_tileLoader;
+ int m_maxTileLevel;
QVector<GeoSceneTexture const *> m_textureLayers;
QHash <TileId, StackedTile*> m_tilesOnDisplay;
QCache <TileId, StackedTile> m_tileCache;
@@ -101,6 +105,8 @@
d->m_tilesOnDisplay.clear();
d->m_tileCache.clear();
+
+ d->detectMaxTileLevel();
}
void StackedTileLoader::setShowTileId( bool show )
@@ -286,15 +292,26 @@
return result;
}
-int StackedTileLoader::maximumTileLevel( GeoSceneTexture const * const texture )
+int StackedTileLoader::maximumTileLevel() const
{
- if ( !texture )
- return -1;
+ return d->m_maxTileLevel;
+}
+void StackedTileLoaderPrivate::detectMaxTileLevel()
+{
+ if ( m_textureLayers.isEmpty() ) {
+ m_maxTileLevel = -1;
+ return;
+ }
+
+ GeoSceneTexture const * const texture = m_textureLayers.at( 0 );
+
// if maximum tile level is configured in the DGML files,
// then use it, otherwise use old detection code.
- if ( texture->maximumTileLevel() >= 0 )
- return texture->maximumTileLevel();
+ if ( texture->maximumTileLevel() >= 0 ) {
+ m_maxTileLevel = texture->maximumTileLevel();
+ return;
+ }
int maximumTileLevel = -1;
QString tilepath = MarbleDirs::path( texture->themeStr() );
@@ -302,19 +319,19 @@
QStringList leveldirs = QDir( tilepath ).entryList( QDir::AllDirs | QDir::NoSymLinks
| QDir::NoDotAndDotDot );
- bool ok = true;
-
QStringList::const_iterator it = leveldirs.constBegin();
QStringList::const_iterator const end = leveldirs.constEnd();
for (; it != end; ++it ) {
- int value = (*it).toInt( &ok, 10 );
+ bool ok = true;
+ const int value = (*it).toInt( &ok, 10 );
+
if ( ok && value > maximumTileLevel )
maximumTileLevel = value;
}
// mDebug() << "Detected maximum tile level that contains data: "
// << maxtilelevel;
- return maximumTileLevel + 1;
+ m_maxTileLevel = maximumTileLevel + 1;
}
bool StackedTileLoader::baseTilesAvailable( GeoSceneLayer * layer )
@@ -352,6 +369,9 @@
void StackedTileLoader::updateTile( TileId const & stackedTileId, TileId const & tileId )
{
Q_UNUSED(tileId);
+
+ d->detectMaxTileLevel();
+
StackedTile * const displayedTile = d->m_tilesOnDisplay.value( stackedTileId, 0 );
if ( displayedTile ) {
displayedTile->initResultTile();
--- branches/KDE/4.6/kdeedu/marble/src/lib/StackedTileLoader.h #1210167:1210168
@@ -122,7 +122,7 @@
* Returns the highest level in which some tiles are theoretically
* available for the given @p texture layer.
*/
- static int maximumTileLevel( GeoSceneTexture const * const textureLayer );
+ int maximumTileLevel() const;
/**
* Returns whether the mandatory most basic tile level is fully available for
--- branches/KDE/4.6/kdeedu/marble/src/lib/TextureLayer.cpp #1210167:1210168
@@ -253,7 +253,6 @@
}
Q_ASSERT( d->m_texmapper );
connect( d->m_texmapper, SIGNAL( tileLevelChanged( int )), SIGNAL( tileLevelChanged( int )));
- connect( d->m_texmapper, SIGNAL( mapChanged() ), SLOT( mapChanged() ) );
d->m_justModified = true;
}
More information about the Marble-commits
mailing list