54
54
#include < osgEarth/TileSource>
55
55
#include < osgEarthUtil/AutoClipPlaneHandler>
56
56
#include < osgEarthDrivers/gdal/GDALOptions>
57
- #include " WorldWindOptions"
58
57
#include < osgEarthDrivers/tms/TMSOptions>
59
58
60
59
using namespace osgEarth ::Drivers;
@@ -165,7 +164,7 @@ struct RefreshControlHandler : public ControlEventHandler
165
164
RefreshControlHandler ( GlobePlugin* globe ) : mGlobe ( globe ) { }
166
165
virtual void onClick ( Control* /* control*/ , int /* mouseButtonMask*/ )
167
166
{
168
- mGlobe ->layersChanged ();
167
+ mGlobe ->imageLayersChanged ();
169
168
}
170
169
private:
171
170
GlobePlugin* mGlobe ;
@@ -203,9 +202,9 @@ void GlobePlugin::initGui()
203
202
connect ( mQGisIface ->mapCanvas () , SIGNAL ( extentsChanged () ),
204
203
this , SLOT ( extentsChanged () ) );
205
204
connect ( mQGisIface ->mapCanvas (), SIGNAL ( layersChanged () ),
206
- this , SLOT ( layersChanged () ) );
205
+ this , SLOT ( imageLayersChanged () ) );
207
206
connect ( mSettingsDialog , SIGNAL ( elevationDatasourcesChanged () ),
208
- this , SLOT ( layersChanged () ) );
207
+ this , SLOT ( elevationLayersChanged () ) );
209
208
connect ( mQGisIface ->mainWindow (), SIGNAL ( projectRead () ), this ,
210
209
SLOT ( projectReady () ) );
211
210
connect ( mQGisIface , SIGNAL ( newProjectCreated () ), this ,
@@ -325,13 +324,6 @@ void GlobePlugin::setupMap()
325
324
imagery.url () = " http://readymap.org/readymap/tiles/1.0.0/7/" ;
326
325
map->addImageLayer ( new ImageLayer ( " Imagery" , imagery ) );
327
326
328
- // add a TMS elevation layer:
329
- /*
330
- TMSOptions elevation;
331
- elevation.url() = "http://readymap.org/readymap/tiles/1.0.0/9/";
332
- map->addElevationLayer( new ElevationLayer("Elevation", elevation) );
333
- */
334
-
335
327
MapNodeOptions nodeOptions;
336
328
// nodeOptions.proxySettings() =
337
329
// nodeOptions.enableLighting() = false;
@@ -340,22 +332,26 @@ void GlobePlugin::setupMap()
340
332
TerrainOptions terrainOptions;
341
333
// terrainOptions.loadingPolicy() = loadingPolicy;
342
334
terrainOptions.compositingTechnique () = TerrainOptions::COMPOSITING_MULTITEXTURE_FFP;
335
+ // terrainOptions.lodFallOff() = 6.0;
343
336
nodeOptions.setTerrainOptions ( terrainOptions );
344
337
345
338
// The MapNode will render the Map object in the scene graph.
346
339
mMapNode = new osgEarth::MapNode ( map, nodeOptions );
347
340
348
341
// prefill cache
342
+ /*
349
343
if ( !QFile::exists( cacheDirectory + "/worldwind_srtm" ) )
350
344
{
351
345
copyFolder( QgsApplication::pkgDataPath() + "/globe/data/worldwind_srtm", cacheDirectory + "/globe/worldwind_srtm" );
352
346
}
347
+ */
353
348
354
349
mRootNode = new osg::Group ();
355
350
mRootNode ->addChild ( mMapNode );
356
351
357
352
// Add layers to the map
358
- layersChanged ();
353
+ imageLayersChanged ();
354
+ elevationLayersChanged ();
359
355
360
356
// model placement utils
361
357
mElevationManager = new osgEarth::Util::ElevationManager ( mMapNode ->getMap () );
@@ -392,8 +388,7 @@ void GlobePlugin::projectReady()
392
388
393
389
void GlobePlugin::blankProjectReady ()
394
390
{ // needs at least http://trac.osgeo.org/qgis/changeset/14452
395
- mSettingsDialog ->elevationDatasources ()->clearContents ();
396
- mSettingsDialog ->elevationDatasources ()->setRowCount ( 0 );
391
+ mSettingsDialog ->resetElevationDatasources ();
397
392
}
398
393
399
394
void GlobePlugin::showCurrentCoordinates ( double lon, double lat )
@@ -714,14 +709,50 @@ void GlobePlugin::extentsChanged()
714
709
QgsDebugMsg ( " extentsChanged: " + mQGisIface ->mapCanvas ()->extent ().toString () );
715
710
}
716
711
717
- void GlobePlugin::layersChanged ()
712
+ void GlobePlugin::imageLayersChanged ()
713
+ {
714
+ if ( mIsGlobeRunning )
715
+ {
716
+ QgsDebugMsg ( " imageLayersChanged: Globe Running, executing" );
717
+ osg::ref_ptr<Map> map = mMapNode ->getMap ();
718
+
719
+ if ( map->getNumImageLayers () > 1 )
720
+ {
721
+ mOsgViewer ->getDatabasePager ()->clear ();
722
+ }
723
+
724
+ // remove QGIS layer
725
+ if ( mQgisMapLayer )
726
+ {
727
+ QgsDebugMsg ( " removeMapLayer" );
728
+ map->removeImageLayer ( mQgisMapLayer );
729
+ }
730
+
731
+ // add QGIS layer
732
+ QgsDebugMsg ( " addMapLayer" );
733
+ mTileSource = new QgsOsgEarthTileSource ( mQGisIface );
734
+ mTileSource ->initialize ( " " , 0 );
735
+ ImageLayerOptions options ( " QGIS" );
736
+ mQgisMapLayer = new ImageLayer ( options, mTileSource );
737
+ map->addImageLayer ( mQgisMapLayer );
738
+ mQgisMapLayer ->setCache ( 0 ); // disable caching
739
+ }
740
+ else
741
+ {
742
+ QgsDebugMsg ( " layersChanged: Globe NOT running, skipping" );
743
+ return ;
744
+ }
745
+ }
746
+
747
+
748
+ void GlobePlugin::elevationLayersChanged ()
718
749
{
719
750
if ( mIsGlobeRunning )
720
751
{
721
- QgsDebugMsg ( " layersChanged : Globe Running, executing" );
752
+ QgsDebugMsg ( " elevationLayersChanged : Globe Running, executing" );
722
753
osg::ref_ptr<Map> map = mMapNode ->getMap ();
723
754
724
- if ( map->getNumImageLayers () > 1 || map-> getNumElevationLayers () > 1 )
755
+ if ( map->getNumElevationLayers () > 1 )
725
756
{
726
757
mOsgViewer ->getDatabasePager ()->clear ();
727
758
}
@@ -751,15 +782,6 @@ void GlobePlugin::layersChanged()
751
782
options.url () = uri.toStdString ();
752
783
layer = new osgEarth::ElevationLayer ( uri.toStdString (), options );
753
784
}
754
- else if ( " Worldwind" == type )
755
- {
756
- WorldWindOptions options;
757
- options.elevationCachePath () = cacheDirectory.toStdString () + " /globe/worldwind_srtm" ;
758
- layer = new osgEarth::ElevationLayer ( " WorldWind bil" , options );
759
- TerrainEngineNode* terrainEngineNode = mMapNode ->getTerrainEngine ();
760
- terrainEngineNode->setVerticalScale ( 2 );
761
- terrainEngineNode->setElevationSamplingRatio ( 0.25 );
762
- }
763
785
else if ( " TMS" == type )
764
786
{
765
787
TMSOptions options;
@@ -770,22 +792,6 @@ void GlobePlugin::layersChanged()
770
792
771
793
if ( !cache || type == " Worldwind" ) layer->setCache ( 0 ); // no tms cache for worldwind (use worldwind_cache)
772
794
}
773
-
774
- // remove QGIS layer
775
- if ( mQgisMapLayer )
776
- {
777
- QgsDebugMsg ( " removeMapLayer" );
778
- map->removeImageLayer ( mQgisMapLayer );
779
- }
780
-
781
- // add QGIS layer
782
- QgsDebugMsg ( " addMapLayer" );
783
- mTileSource = new QgsOsgEarthTileSource ( mQGisIface );
784
- mTileSource ->initialize ( " " , 0 );
785
- ImageLayerOptions options ( " QGIS" );
786
- mQgisMapLayer = new ImageLayer ( options, mTileSource );
787
- map->addImageLayer ( mQgisMapLayer );
788
- mQgisMapLayer ->setCache ( 0 ); // disable caching
789
795
}
790
796
else
791
797
{
0 commit comments