Introduced osgTerrain::WhiteListTileLoadedCallback for the management of options terrain layers

This commit is contained in:
Robert Osfield
2008-09-11 13:21:58 +00:00
parent a214a677f8
commit ff299eb104
4 changed files with 305 additions and 192 deletions

View File

@@ -354,6 +354,18 @@ class OSGTERRAIN_EXPORT ProxyLayer : public Layer
META_Object(osgTerrain, ProxyLayer);
/** Return image associated with layer if supported. */
virtual osg::Image* getImage()
{
return _implementation.valid() ? _implementation->getImage() : 0;
}
/** Return const image associated with layer if supported. */
virtual const osg::Image* getImage() const
{
return _implementation.valid() ? _implementation->getImage() : 0;
}
/** Set the implementation layer that does the actual work.*/
void setImplementation(Layer* layer) { _implementation = layer; }
@@ -485,6 +497,22 @@ class OSGTERRAIN_EXPORT SwitchLayer : public CompositeLayer
void setActiveLayer(int i) { _activeLayer = i; }
int getActiveLayer() const { return _activeLayer; }
/** Return image associated with layer if supported. */
virtual osg::Image* getImage()
{
if (_activeLayer < 0) return 0;
if (_activeLayer >= static_cast<int>(getNumLayers())) return 0;
return _layers[_activeLayer].layer->getImage();
}
/** Return const image associated with layer if supported. */
virtual const osg::Image* getImage() const
{
if (_activeLayer < 0) return 0;
if (_activeLayer >= static_cast<int>(getNumLayers())) return 0;
return _layers[_activeLayer].layer->getImage();
}
protected:
virtual ~SwitchLayer() {}

View File

@@ -208,6 +208,45 @@ class OSGTERRAIN_EXPORT TerrainTile : public osg::Group
bool _treatBoundariesToValidDataAsDefaultValue;
};
/** Helper callback for managing optional sets of layers, that loading of is deffered to this callback,
* with this callback working out which layers to load, and how to create fallback versions of the layers.
*/
class OSGTERRAIN_EXPORT WhiteListTileLoadedCallback : public TerrainTile::TileLoadedCallback
{
public:
WhiteListTileLoadedCallback();
void allow(const std::string& setname) { _setWhiteList.insert(setname); }
void setMinimumNumOfLayers(unsigned int numLayers) { _minumumNumberOfLayers = numLayers; }
unsigned int getMinimumNumOfLayers() const { return _minumumNumberOfLayers; }
void setReplaceSwitchLayer(bool replaceSwitchLayer) { _replaceSwitchLayer = replaceSwitchLayer; }
bool getReplaceSwitchLayer() const { return _replaceSwitchLayer; }
void setAllowAll(bool allowAll) { _allowAll = allowAll; }
bool getAllowAll() const { return _allowAll; }
bool layerAcceptable(const std::string& setname) const;
bool readImageLayer(osgTerrain::ImageLayer* imageLayer, const osgDB::ReaderWriter::Options* options) const;
virtual bool deferExternalLayerLoading() const;
virtual void loaded(osgTerrain::TerrainTile* tile, const osgDB::ReaderWriter::Options* options) const;
protected:
virtual ~WhiteListTileLoadedCallback();
typedef std::set<std::string> SetWhiteList;
SetWhiteList _setWhiteList;
unsigned int _minumumNumberOfLayers;
bool _replaceSwitchLayer;
bool _allowAll;
};
}
#endif