Skip to content

Commit

Permalink
[Globe] Make the reload button rebuild the entire qgis layer to recov…
Browse files Browse the repository at this point in the history
…er from cases where osgEarth loses control over its tiles
  • Loading branch information
manisandro committed Jun 22, 2016
1 parent e92e7fe commit 740d9fb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/plugins/globe/globe_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/plugins/globe/globe_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down

0 comments on commit 740d9fb

Please sign in to comment.