osgEarth 2.1.1
|
00001 /* -*-c++-*- */ 00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph 00003 * Copyright 2008-2010 Pelican Mapping 00004 * http://osgearth.org 00005 * 00006 * osgEarth is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/> 00018 */ 00019 00020 #ifndef OSGEARTH_ELEVATION_TERRAIN_LAYER_H 00021 #define OSGEARTH_ELEVATION_TERRAIN_LAYER_H 1 00022 00023 #include <osgEarth/Common> 00024 #include <osgEarth/Config> 00025 #include <osgEarth/Caching> 00026 #include <osgEarth/Profile> 00027 #include <osgEarth/TileSource> 00028 #include <osgEarth/TerrainLayer> 00029 00030 namespace osgEarth 00031 { 00035 class OSGEARTH_EXPORT ElevationLayerOptions : public TerrainLayerOptions 00036 { 00037 public: 00039 ElevationLayerOptions( const ConfigOptions& options =ConfigOptions() ); 00040 00042 ElevationLayerOptions( const std::string& name, const TileSourceOptions& driverOptions ); 00043 00044 public: 00045 virtual Config getConfig() const; 00046 virtual void mergeConfig( const Config& conf ); 00047 00048 private: 00049 void fromConfig( const Config& conf ); 00050 void setDefaults(); 00051 }; 00052 00053 //-------------------------------------------------------------------- 00054 00058 struct ElevationLayerCallback : public TerrainLayerCallback 00059 { 00060 //TODO 00061 }; 00062 00063 typedef void (ElevationLayerCallback::*ElevationLayerCallbackMethodPtr)(class ElevationLayer* layer); 00064 00065 typedef std::list< osg::ref_ptr<ElevationLayerCallback> > ElevationLayerCallbackList; 00066 00067 00068 //-------------------------------------------------------------------- 00069 00073 class OSGEARTH_EXPORT ElevationLayer : public TerrainLayer 00074 { 00075 public: 00080 ElevationLayer( const ElevationLayerOptions& options ); 00081 00086 ElevationLayer( const std::string& name, const TileSourceOptions& driverOptions ); 00087 00092 ElevationLayer( const ElevationLayerOptions& options, TileSource* tileSource ); 00093 00095 const ElevationLayerOptions& getElevationLayerOptions() const { return _runtimeOptions; } 00096 virtual const TerrainLayerOptions& getTerrainLayerOptions() const { return _runtimeOptions; } 00097 00099 void addCallback( ElevationLayerCallback* cb ); 00100 00102 void removeCallback( ElevationLayerCallback* cb ); 00103 00104 public: // methods 00105 00111 osg::HeightField* createHeightField( 00112 const TileKey& key, 00113 ProgressCallback* progress =0L ); 00114 00115 protected: 00116 00117 virtual GeoHeightField createGeoHeightField( const TileKey& key, ProgressCallback* progress); 00118 00119 virtual std::string suggestCacheFormat() const; 00120 00121 virtual void initTileSource(); 00122 00123 private: 00124 ElevationLayerOptions _runtimeOptions; 00125 00126 ElevationLayerCallbackList _callbacks; 00127 virtual void fireCallback( TerrainLayerCallbackMethodPtr method ); 00128 virtual void fireCallback( ElevationLayerCallbackMethodPtr method ); 00129 00130 osg::ref_ptr<TileSource::HeightFieldOperation> _preCacheOp; 00131 00132 void init(); 00133 }; 00134 00135 typedef std::vector< osg::ref_ptr<ElevationLayer> > ElevationLayerVector; 00136 00137 } // namespace osgEarth 00138 00139 #endif // OSGEARTH_ELEVATION_TERRAIN_LAYER_H