/usr/include/osgEarth/ImageLayer is in libosgearth-dev 2.7.0+dfsg-2+b3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2015 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTH_IMAGE_TERRAIN_LAYER_H
#define OSGEARTH_IMAGE_TERRAIN_LAYER_H 1
#include <osgEarth/Common>
#include <osgEarth/Config>
#include <osgEarth/ColorFilter>
#include <osgEarth/TileSource>
#include <osgEarth/TerrainLayer>
#include <osgEarth/URI>
namespace osgEarth
{
class Profile;
/**
* Initialization options for an image layer.
*/
class OSGEARTH_EXPORT ImageLayerOptions : public TerrainLayerOptions
{
public:
/** Constructs new image layer options. */
ImageLayerOptions( const ConfigOptions& options =ConfigOptions() );
/**
* Constructs new image layer options, giving a name to the layer and specifying
* driver options to use.
*/
ImageLayerOptions( const std::string& name, const TileSourceOptions& driverOpt =TileSourceOptions() );
/** dtor */
virtual ~ImageLayerOptions() { }
public: // properties
/**
* The initial opacity of this layer
*/
optional<float>& opacity() { return _opacity; }
const optional<float>& opacity() const { return _opacity; }
/**
* The initial minimum camera range at which this layer is visible.
*/
optional<float>& minVisibleRange() { return _minRange; }
const optional<float>& minVisibleRange() const { return _minRange; }
/**
* The initial maximum camera range at which this layer is visible.
*/
optional<float>& maxVisibleRange() { return _maxRange; }
const optional<float>& maxVisibleRange() const { return _maxRange; }
/**
* Gets or sets the nodata image for this MapLayer
*/
optional<URI>& noDataImageFilename() { return _noDataImageFilename; }
const optional<URI>& noDataImageFilename() const { return _noDataImageFilename; }
/**
* Gets the transparent color of this TileSource
*/
optional<osg::Vec4ub>& transparentColor() { return _transparentColor; }
const optional<osg::Vec4ub>& transparentColor() const { return _transparentColor; }
/**
* Filters attached to this layer.
*/
ColorFilterChain& colorFilters() { return _colorFilters; }
const ColorFilterChain& colorFilters() const { return _colorFilters; }
/**
* A shared image layer is bound to its own texture image units at render
* so that all layers have access to its sampler.
*/
optional<bool>& shared() { return _shared; }
const optional<bool>& shared() const { return _shared; }
/**
* Whether this is a "coverage" layer, i.e a layer that conveys discrete semantic
* values rather than color data. This is a hint to disable any features that would
* corrupt the data, like filtering, interpolation, or lossy compression.
*/
optional<bool>& coverage() { return _coverage; }
const optional<bool>& coverage() const { return _coverage; }
/**
* Whether to feather out alpha regions for this image layer with the featherAlphaRegions function.
* Used to get proper blending when you have datasets that abutt exactly with no overlap.
*/
optional<bool>& featherPixels() { return _featherPixels; }
const optional<bool>& featherPixels() const { return _featherPixels; }
/**
* The minification filter to be applied to textures. This is the interpolation
* mechanism to use when the texture uses fewer screen pixels than are available.
*/
optional<osg::Texture::FilterMode>& minFilter() { return _minFilter; }
const optional<osg::Texture::FilterMode>& minFilter() const { return _minFilter; }
/**
* The magnification filter to be applied to textures. This is the interpolation
* mechanism to use when the texture uses more screen pixels than are available.
*/
optional<osg::Texture::FilterMode>& magFilter() { return _magFilter; }
const optional<osg::Texture::FilterMode>& magFilter() const { return _magFilter; }
/**
* Texture compression mode to use. Default is "unset", which means to
* automatically compute the best compression mode to use.
*/
optional<osg::Texture::InternalFormatMode>& textureCompression() { return _texcomp; }
const optional<osg::Texture::InternalFormatMode>& textureCompression() const { return _texcomp; }
/** For shared layer, name of hte texture sampler uniform. */
optional<std::string>& shareTexUniformName() { return _shareTexUniformName; }
const optional<std::string>& shareTexUniformName() const { return _shareTexUniformName; }
/** For shared layer, name of hte texture sampler matrix uniform. */
optional<std::string>& shareTexMatUniformName() { return _shareTexMatUniformName; }
const optional<std::string>& shareTexMatUniformName() const { return _shareTexMatUniformName; }
public:
virtual Config getConfig() const { return getConfig(false); }
virtual Config getConfig( bool isolate ) const;
virtual void mergeConfig( const Config& conf );
private:
void fromConfig( const Config& conf );
void setDefaults();
optional<float> _opacity;
optional<float> _minRange;
optional<float> _maxRange;
optional<osg::Vec4ub> _transparentColor;
optional<URI> _noDataImageFilename;
ColorFilterChain _colorFilters;
optional<bool> _shared;
optional<bool> _coverage;
optional<bool> _featherPixels;
optional<osg::Texture::FilterMode> _minFilter;
optional<osg::Texture::FilterMode> _magFilter;
optional<osg::Texture::InternalFormatMode> _texcomp;
optional<std::string> _shareTexUniformName;
optional<std::string> _shareTexMatUniformName;
};
//--------------------------------------------------------------------
/**
* Callback for receiving notification of property changes on an ImageLayer.
*/
struct ImageLayerCallback : public TerrainLayerCallback
{
virtual void onOpacityChanged( class ImageLayer* layer ) { }
virtual void onVisibleRangeChanged( class ImageLayer* layer ) {}
virtual void onColorFiltersChanged( class ImageLayer* layer ) { }
virtual ~ImageLayerCallback() { }
};
typedef void (ImageLayerCallback::*ImageLayerCallbackMethodPtr)(ImageLayer* layer);
typedef std::list< osg::ref_ptr<ImageLayerCallback> > ImageLayerCallbackList;
//--------------------------------------------------------------------
/**
* Internal utility class for post-processing image tiles that come from
* a TileSource
*/
class ImageLayerTileProcessor
{
public:
ImageLayerTileProcessor( const ImageLayerOptions& options =ImageLayerOptions() );
/** dtor */
virtual ~ImageLayerTileProcessor() { }
void init( const ImageLayerOptions& options, const osgDB::Options* dbOptions, bool layerInTargetProfile );
void process( osg::ref_ptr<osg::Image>& image ) const;
private:
ImageLayerOptions _options;
osg::Vec4f _chromaKey;
osg::ref_ptr<osg::Image> _noDataImage;
bool _layerInTargetProfile;
};
//--------------------------------------------------------------------
/**
* A map terrain layer containing bitmap image data.
*/
class OSGEARTH_EXPORT ImageLayer : public TerrainLayer
{
public:
/**
* Constructs a new image layer.
*/
ImageLayer( const ImageLayerOptions& options );
/**
* Constructs a new image layer with the given name and driver options.
*/
ImageLayer( const std::string& name, const TileSourceOptions& driverOptions );
/**
* Constructs a new image layer with a custom TileSource.
*/
ImageLayer( const ImageLayerOptions& options, TileSource* tileSource );
/** dtor */
virtual ~ImageLayer() { }
public:
/**
* Access to the initialization options used to create this image layer
*/
const ImageLayerOptions& getImageLayerOptions() const { return _runtimeOptions; }
virtual const TerrainLayerOptions& getTerrainLayerRuntimeOptions() const { return _runtimeOptions; }
/** Adds a property notification callback to this layer */
void addCallback( ImageLayerCallback* cb );
/** Removes a property notification callback from this layer */
void removeCallback( ImageLayerCallback* cb );
/** Override: see TerrainLayer */
virtual void setTargetProfileHint( const Profile* profile );
/**
* Add a color filter (to the end of the chain)
*/
void addColorFilter( ColorFilter* filter );
/**
* Remove a color filter
*/
void removeColorFilter( ColorFilter* filter );
/**
* Access the image filter chain
*/
const ColorFilterChain& getColorFilters() const;
public: // runtime properties
/**
* Sets the opacity of this image layer.
* @param opacity Opacity [0..1] -> [transparent..opaque]
*/
void setOpacity( float opacity );
float getOpacity() const { return *_runtimeOptions.opacity(); }
float getMinVisibleRange() const { return *_runtimeOptions.minVisibleRange();}
void setMinVisibleRange( float minVisibleRange );
float getMaxVisibleRange() const { return *_runtimeOptions.maxVisibleRange();}
void setMaxVisibleRange( float maxVisibleRange );
/**
* Whether this layer is marked for render sharing
*/
bool isShared() const { return *_runtimeOptions.shared() == true; }
/**
* Whether this layer represents coverage data that should not be subject
* to color-space filtering, interpolation, or compression.
*/
bool isCoverage() const { return *_runtimeOptions.coverage() == true; }
/**
* When isShared() == true, the engine will call this function to bind the
* shared layer to a texture image unit.
*/
optional<int>& shareImageUnit() { return _shareImageUnit; }
const optional<int>& shareImageUnit() const { return _shareImageUnit; }
/**
* When isShared() == true, this will return the name of the uniform holding the
* image's texture.
*/
optional<std::string>& shareTexUniformName() { return _shareTexUniformName; }
const optional<std::string>& shareTexUniformName() const { return _shareTexUniformName; }
/**
* When isShared() == true, this will return the name of the uniform holding the
* image's texture matrix.
*/
optional<std::string>& shareTexMatUniformName() { return _shareTexMatUniformName; }
const optional<std::string>& shareTexMatUniformName() const { return _shareTexMatUniformName; }
public: // methods
/**
* Creates a GeoImage from this layer corresponding to the provided key. The
* image is in the profile of the key and will be reprojected, mosaiced and
* cropped automatically.
*/
virtual GeoImage createImage( const TileKey& key, ProgressCallback* progress = 0);
/**
* Creates an image that is in the image layer's native profile.
*/
GeoImage createImageInNativeProfile(const TileKey& key, ProgressCallback* progress);
/**
* Applies the texture compression options to a texture.
*/
void applyTextureCompressionMode(osg::Texture* texture) const;
public: // TerrainLayer override
CacheBin* getCacheBin( const Profile* profile );
protected:
// Creates an image that's in the same profile as the provided key.
GeoImage createImageInKeyProfile(const TileKey& key, ProgressCallback* progress);
// Fetches an image from the underlying TileSource whose data matches that of the
// key extent.
GeoImage createImageFromTileSource(const TileKey& key, ProgressCallback* progress);
// Fetches multiple images from the TileSource; mosaics/reprojects/crops as necessary, and
// returns a single tile. This is called by createImageFromTileSource() if the key profile
// doesn't match the layer profile.
GeoImage assembleImageFromTileSource(const TileKey& key, ProgressCallback* progress);
protected:
ImageLayerOptions _runtimeOptions;
osg::ref_ptr<TileSource::ImageOperation> _preCacheOp;
Threading::Mutex _mutex;
osg::ref_ptr<osg::Image> _emptyImage;
ImageLayerCallbackList _callbacks;
optional<int> _shareImageUnit;
optional<std::string> _shareTexUniformName;
optional<std::string> _shareTexMatUniformName;
virtual void fireCallback( TerrainLayerCallbackMethodPtr method );
virtual void fireCallback( ImageLayerCallbackMethodPtr method );
void init();
TileSource::ImageOperation* getOrCreatePreCacheOp();
};
typedef std::vector< osg::ref_ptr<ImageLayer> > ImageLayerVector;
} // namespace osgEarth
#endif // OSGEARTH_IMAGE_TERRAIN_LAYER_H
|