Skip to content
Permalink
Browse files

[Globe] Make the reload button rebuild the entire qgis layer to recov…

…er from cases where osgEarth loses control over its tiles
  • Loading branch information
manisandro committed Jun 22, 2016
1 parent e92e7fe commit 740d9fb388d3aafb65dee32b07e2e9d654cbe4ec
Showing with 24 additions and 1 deletion.
  1. +23 −1 src/plugins/globe/globe_plugin.cpp
  2. +1 −0 src/plugins/globe/globe_plugin.h
@@ -322,7 +322,7 @@ void GlobePlugin::run()
connect( mDockWidget, SIGNAL( destroyed( QObject* ) ), this, SLOT( reset() ) );
connect( mDockWidget, SIGNAL( layersChanged() ), this, SLOT( updateLayers() ) );
connect( mDockWidget, SIGNAL( showSettings() ), this, SLOT( showSettings() ) );
connect( mDockWidget, SIGNAL( refresh() ), this, SLOT( updateLayers() ) );
connect( mDockWidget, SIGNAL( refresh() ), this, SLOT( rebuildQGISLayer() ) );
connect( mDockWidget, SIGNAL( syncExtent() ), this, SLOT( syncExtent() ) );
mQGisIface->addDockWidget( Qt::RightDockWidgetArea, mDockWidget );

@@ -1018,6 +1018,27 @@ void GlobePlugin::layerChanged( QgsMapLayer* mapLayer )
}
}

void GlobePlugin::rebuildQGISLayer()
{
if ( mMapNode )
{
mMapNode->getMap()->removeImageLayer( mQgisMapLayer );
mLayerExtents.clear();

osgEarth::TileSourceOptions opts;
opts.L2CacheSize() = 0;
opts.tileSize() = 128;
mTileSource = new QgsGlobeTileSource( mQGisIface->mapCanvas(), opts );

osgEarth::ImageLayerOptions options( "QGIS" );
options.driver()->L2CacheSize() = 0;
options.cachePolicy() = osgEarth::CachePolicy::USAGE_NO_CACHE;
mQgisMapLayer = new osgEarth::ImageLayer( options, mTileSource );
mMapNode->getMap()->addImageLayer( mQgisMapLayer );
updateLayers();
}
}

void GlobePlugin::setGlobeEnabled( bool enabled )
{
if ( enabled )
@@ -1055,6 +1076,7 @@ void GlobePlugin::reset()
mDockWidget = 0;
mImagerySources.clear();
mElevationSources.clear();
mLayerExtents.clear();
#ifdef GLOBE_SHOW_TILE_STATS
disconnect( QgsGlobeTileStatistics::instance(), SIGNAL( changed( int, int ) ), this, SLOT( updateTileStats( int, int ) ) );
delete QgsGlobeTileStatistics::instance();
@@ -164,6 +164,7 @@ class GLOBE_EXPORT GlobePlugin : public QObject, public QgisPlugin
void projectRead();
void applySettings();
void layerChanged( QgsMapLayer* mapLayer = 0 );
void rebuildQGISLayer();
void refreshQGISMapLayer( QgsRectangle rect = QgsRectangle() );
void updateTileStats( int queued, int tot );

0 comments on commit 740d9fb

Please sign in to comment.
You can’t perform that action at this time.