[Marble-commits] KDE/kdeedu/marble
Jens-Michael Hoffmann
jensmh at gmx.de
Sat Apr 10 02:13:31 CEST 2010
SVN commit 1113106 by jmhoffmann:
Fix clouds regression, make it possible again to switch clouds on/off.
Squashed commit of the following:
- GeoSceneSettings::group: implement non-const variant by means of const variant.
For a detailed explanation, see "Effective C++" (third edition).
- bluemarble.dgml: replace clouds property with "Texture Layers" group
including a "clouds_data" property.
- Connect signal GeoSceneGroup::valueChanged to slot StackedTileLoader::reset.
- GeoSceneGroup: emit signal valueChanged in method setPropertyValue.
- ViewParams: use GeoSceneSettings/GeoSceneGroup to store clouds settings.
- GeoSceneSettings: add non-const variant of method group.
TODO: clean up before commiting to kde repository. (done)
M +7 -4 data/maps/earth/bluemarble/bluemarble.dgml
M +4 -6 src/lib/MarbleMap.cpp
M +17 -2 src/lib/MarbleModel.cpp
M +46 -6 src/lib/StackedTileLoader.cpp
M +5 -0 src/lib/StackedTileLoader.h
M +35 -0 src/lib/ViewParams.cpp
M +3 -0 src/lib/ViewParams.h
M +1 -0 src/lib/geodata/scene/GeoSceneGroup.cpp
M +9 -0 src/lib/geodata/scene/GeoSceneSettings.cpp
M +1 -0 src/lib/geodata/scene/GeoSceneSettings.h
--- trunk/KDE/kdeedu/marble/data/maps/earth/bluemarble/bluemarble.dgml #1113105:1113106
@@ -154,10 +154,13 @@
</property>
</group>
- <property name="clouds">
- <value>true</value>
- <available>true</available>
- </property>
+ <group name="Texture Layers">
+ <property name="clouds_data">
+ <value>true</value>
+ <available>true</available>
+ </property>
+ </group>
+
<property name="coordinate-grid">
<value>true</value>
<available>true</available>
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #1113105:1113106
@@ -635,8 +635,7 @@
bool MarbleMap::showClouds() const
{
- // TODO
- return true;
+ return d->m_viewParams.showClouds();
}
bool MarbleMap::showAtmosphere() const
@@ -1034,16 +1033,15 @@
void MarbleMap::setShowClouds( bool visible )
{
- // TODO
+ d->m_viewParams.setShowClouds( visible );
+ setNeedsUpdate();
}
void MarbleMap::setShowTileId( bool visible )
{
-
d->m_model->layerDecorator()->setShowTileId( visible );
-
-
}
+
void MarbleMap::setShowGrid( bool visible )
{
setPropertyValue( "coordinate-grid", visible );
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1113105:1113106
@@ -34,6 +34,7 @@
#include "GeoSceneLayer.h"
#include "GeoSceneMap.h"
#include "GeoScenePalette.h"
+#include "GeoSceneSettings.h"
#include "GeoSceneTexture.h"
#include "GeoSceneVector.h"
#include "GeoSceneXmlDataSource.h"
@@ -104,6 +105,7 @@
void resize( int width, int height );
void notifyModelChanged();
+ GeoSceneGroup * textureLayerProperties() const;
static QAtomicInt refCounter;
MarbleModel *m_parent;
@@ -152,6 +154,18 @@
TextureColorizer *MarbleModelPrivate::m_texcolorizer = 0;
QAtomicInt MarbleModelPrivate::refCounter(0);
+GeoSceneGroup * MarbleModelPrivate::textureLayerProperties() const
+{
+ if ( !m_mapTheme )
+ return 0;
+
+ GeoSceneSettings * const settings = m_mapTheme->settings();
+ if ( !settings )
+ return 0;
+
+ return settings->group( "Texture Layers" );
+}
+
MarbleModel::MarbleModel( QObject *parent )
: QObject( parent ),
d( new MarbleModelPrivate( this ) )
@@ -161,8 +175,8 @@
MarbleModelPrivate::refCounter.ref();
d->m_dataFacade = new MarbleDataFacade( this );
- d->m_tileLoader = new StackedTileLoader( d->m_mapThemeManager, d->m_downloadManager, this );
-
+ d->m_tileLoader = new StackedTileLoader( d->m_mapThemeManager, d->textureLayerProperties(),
+ d->m_downloadManager, this );
d->m_texmapper = 0;
d->m_fileManager = new FileManager();
@@ -310,6 +324,7 @@
{
d->m_mapTheme = mapTheme;
addDownloadPolicies( d->m_mapTheme );
+ d->m_tileLoader->setTextureLayerSettings( d->textureLayerProperties() );
// Some output to show how to use this stuff ...
mDebug() << "DGML2 Name : " << d->m_mapTheme->head()->name();
--- trunk/KDE/kdeedu/marble/src/lib/StackedTileLoader.cpp #1113105:1113106
@@ -25,6 +25,7 @@
#include "DatasetProvider.h"
#include "GeoSceneDocument.h"
+#include "GeoSceneGroup.h"
#include "GeoSceneHead.h"
#include "GeoSceneLayer.h"
#include "GeoSceneMap.h"
@@ -58,14 +59,17 @@
class StackedTileLoaderPrivate
{
public:
- StackedTileLoaderPrivate()
+ explicit StackedTileLoaderPrivate( GeoSceneGroup * const textureLayerSettings )
: m_datasetProvider( 0 ),
m_mapThemeManager( 0 ),
- m_tileLoader( 0 )
+ m_tileLoader( 0 ),
+ m_textureLayerSettings( textureLayerSettings )
{
m_tileCache.setMaxCost( 20000 * 1024 ); // Cache size measured in bytes
}
+ bool isTextureLayerEnabled( QString const & name ) const;
+
DatasetProvider *m_datasetProvider;
MapThemeManager const *m_mapThemeManager;
// TODO: comment about uint hash key
@@ -74,13 +78,24 @@
TileLoader *m_tileLoader;
QHash <TileId, StackedTile*> m_tilesOnDisplay;
QCache <TileId, StackedTile> m_tileCache;
+ // we cannot use a const GeoSceneGroup because of QObject connects/disconnects
+ GeoSceneGroup * m_textureLayerSettings;
};
+bool StackedTileLoaderPrivate::isTextureLayerEnabled( QString const & name ) const
+{
+ if ( !m_textureLayerSettings )
+ return true;
+ bool enabled;
+ m_textureLayerSettings->propertyValue( name, enabled );
+ return enabled;
+}
StackedTileLoader::StackedTileLoader( MapThemeManager const * const mapThemeManager,
+ GeoSceneGroup * const textureLayerSettings,
HttpDownloadManager * const downloadManager,
MarbleModel * const model )
- : d( new StackedTileLoaderPrivate ),
+ : d( new StackedTileLoaderPrivate( textureLayerSettings )),
m_parent( model )
{
d->m_mapThemeManager = mapThemeManager;
@@ -104,6 +119,16 @@
{
}
+void StackedTileLoader::setTextureLayerSettings( GeoSceneGroup * const textureLayerSettings )
+{
+ if ( d->m_textureLayerSettings )
+ d->m_textureLayerSettings->disconnect( this );
+ d->m_textureLayerSettings = textureLayerSettings;
+ if ( d->m_textureLayerSettings )
+ connect( d->m_textureLayerSettings, SIGNAL( valueChanged( QString, bool )),
+ this, SLOT( reset() ));
+}
+
void StackedTileLoader::resetTilehash()
{
QHash<TileId, StackedTile*>::const_iterator it = d->m_tilesOnDisplay.constBegin();
@@ -334,6 +359,13 @@
return noerr;
}
+void StackedTileLoader::reset()
+{
+ mDebug() << "StackedTileLoader::reset";
+ d->m_tilesOnDisplay.clear();
+ d->m_tileCache.clear();
+}
+
void StackedTileLoader::setVolatileCacheLimit( quint64 kiloBytes )
{
mDebug() << QString("Setting tile cache to %1 kilobytes.").arg( kiloBytes );
@@ -400,10 +432,18 @@
QVector<GeoSceneAbstractDataset*>::const_iterator const end = textureLayers.constEnd();
for (; pos != end; ++pos ) {
GeoSceneTexture const * const candidate = dynamic_cast<GeoSceneTexture const *>( *pos );
- if ( candidate && ( !candidate->hasMaximumTileLevel()
- || stackedTileId.zoomLevel() <= candidate->maximumTileLevel() )) {
+ // check if layer is enabled. A layer is considered to be enabled if one of the
+ // following conditions is true:
+ // 1) it is the first layer
+ // 2) there are no settings available (group "Texture Layers" not defined in DGML)
+ // 3) the layer is configured and enabled in the settings
+ // also check, if layer provides tiles for the current level
+ if ( candidate
+ && ( pos == textureLayers.constBegin()
+ || d->isTextureLayerEnabled( candidate->name() ))
+ && ( !candidate->hasMaximumTileLevel()
+ || stackedTileId.zoomLevel() <= candidate->maximumTileLevel() ))
result.append( candidate );
- }
}
return result;
}
--- trunk/KDE/kdeedu/marble/src/lib/StackedTileLoader.h #1113105:1113106
@@ -37,6 +37,7 @@
class HttpDownloadManager;
class MapThemeManager;
class MarbleModel;
+class GeoSceneGroup;
class GeoSceneLayer;
class GeoSceneTexture;
@@ -67,6 +68,7 @@
* the tiles from a remote resource.
*/
StackedTileLoader( MapThemeManager const * const mapThemeManager,
+ GeoSceneGroup * const textureLayerSettings,
HttpDownloadManager * const downloadManager, MarbleModel * const model );
virtual ~StackedTileLoader();
@@ -75,6 +77,7 @@
* tiles from a remote resource.
*/
void setDownloadManager( HttpDownloadManager *downloadManager );
+ void setTextureLayerSettings( GeoSceneGroup * const textureLayerSettings );
/**
* Loads a tile and returns it.
@@ -132,6 +135,8 @@
static bool baseTilesAvailable( GeoSceneLayer * layer );
public Q_SLOTS:
+ void reset();
+
/**
* @brief Set the limit of the volatile (in RAM) cache.
* @param bytes The limit in kilobytes.
--- trunk/KDE/kdeedu/marble/src/lib/ViewParams.cpp #1113105:1113106
@@ -17,6 +17,7 @@
#include "MarbleDebug.h"
#include "AbstractProjection.h"
#include "GeoSceneDocument.h"
+#include "GeoSceneGroup.h"
#include "GeoSceneSettings.h"
#include "MapThemeManager.h"
#include "ViewportParams.h"
@@ -298,6 +299,40 @@
d->m_showAtmosphere = showAtmosphere;
}
+bool ViewParams::showClouds() const
+{
+ // returns false, if settings are not available
+ if ( !d->m_mapTheme )
+ return false;
+
+ GeoSceneSettings const * const settings = d->m_mapTheme->settings();
+ if ( !settings )
+ return false;
+
+ GeoSceneGroup const * const textureLayerSettings = settings->group( "Texture Layers" );
+ if ( !textureLayerSettings )
+ return false;
+
+ bool cloudsEnabled = false;
+ textureLayerSettings->propertyValue( "clouds_data", cloudsEnabled );
+ return cloudsEnabled;
+}
+
+void ViewParams::setShowClouds( bool const showClouds )
+{
+ if ( !d->m_mapTheme )
+ return;
+
+ GeoSceneSettings * const settings = d->m_mapTheme->settings();
+ if ( !settings )
+ return;
+
+ GeoSceneGroup * const textureLayerSettings = settings->group( "Texture Layers" );
+ if ( !textureLayerSettings )
+ return;
+ textureLayerSettings->setPropertyValue( "clouds_data", showClouds );
+}
+
Quaternion ViewParams::planetAxisUpdated() const
{
return d->m_planetAxisUpdated;
--- trunk/KDE/kdeedu/marble/src/lib/ViewParams.h #1113105:1113106
@@ -117,6 +117,9 @@
bool showAtmosphere() const;
void setShowAtmosphere( bool );
+ bool showClouds() const;
+ void setShowClouds( bool const );
+
// FIXME: We should try to get rid of these
int radiusUpdated() const;
void setRadiusUpdated( const int );
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneGroup.cpp #1113105:1113106
@@ -61,6 +61,7 @@
for (; it != end; ++it) {
if ( (*it)->name() == name ) {
(*it)->setValue( value );
+ emit valueChanged( name, value );
return true;
}
}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneSettings.cpp #1113105:1113106
@@ -56,6 +56,7 @@
bool GeoSceneSettings::propertyAvailable( const QString& name, bool& available )
{
+ mDebug() << "GeoSceneSettings::propertyAvailable" << name;
QVector<GeoSceneProperty*>::const_iterator it = d->m_properties.constBegin();
QVector<GeoSceneProperty*>::const_iterator propEnd = d->m_properties.constEnd();
for (; it != propEnd; ++it) {
@@ -106,6 +107,7 @@
bool GeoSceneSettings::propertyValue( const QString& name, bool& value )
{
+ mDebug() << "GeoSceneSettings::propertyValue" << name;
QVector<GeoSceneProperty*>::const_iterator it = d->m_properties.constBegin();
QVector<GeoSceneProperty*>::const_iterator propEnd = d->m_properties.constEnd();
for (; it != propEnd; ++it) {
@@ -185,6 +187,13 @@
return group;
}
+// implement non-const method by means of const method,
+// for details, see "Effective C++" (third edition)
+GeoSceneGroup* GeoSceneSettings::group( const QString& name )
+{
+ return const_cast<GeoSceneGroup*>( static_cast<GeoSceneSettings const *>( this )->group( name ));
+}
+
void GeoSceneSettings::addProperty( GeoSceneProperty* property )
{
// Remove any property that has the same name
--- trunk/KDE/kdeedu/marble/src/lib/geodata/scene/GeoSceneSettings.h #1113105:1113106
@@ -93,6 +93,7 @@
* @param name the name of the group
*/
const GeoSceneGroup* group( const QString& name ) const;
+ GeoSceneGroup* group( const QString& name );
/**
* @brief Add a property to the settings
More information about the Marble-commits
mailing list