Added support for MinLevel and MaxLevel for ProxyLayer

This commit is contained in:
Robert Osfield 2008-01-08 13:56:21 +00:00
parent ff565128af
commit c37e5eaf18
2 changed files with 90 additions and 5 deletions

View File

@ -41,6 +41,18 @@ bool CompositeLayer_readLocalData(osg::Object& obj, osgDB::Input &fr)
locator = dynamic_cast<osgTerrain::Locator*>(readObject.get());
if (readObject.valid()) itrAdvanced = true;
unsigned int minLevel=0;
if (fr.read("MinLevel",minLevel))
{
itrAdvanced = true;
}
unsigned int maxLevel = MAXIMUM_NUMBER_OF_LEVELS;
if (fr.read("MaxLevel",maxLevel))
{
itrAdvanced = true;
}
if (fr.matchSequence("file %s") || fr.matchSequence("file %w") )
{
layer.addLayer(fr[1].getStr());
@ -60,6 +72,9 @@ bool CompositeLayer_readLocalData(osg::Object& obj, osgDB::Input &fr)
locator = 0;
}
if (minLevel!=0) proxyLayer->setMinLevel(minLevel);
if (maxLevel!=MAXIMUM_NUMBER_OF_LEVELS) proxyLayer->setMaxLevel(maxLevel);
layer.addLayer(proxyLayer);
}
@ -73,12 +88,16 @@ bool CompositeLayer_readLocalData(osg::Object& obj, osgDB::Input &fr)
osgTerrain::Layer* readLayer = dynamic_cast<osgTerrain::Layer*>(readObject.get());
if (readLayer)
{
layer.addLayer(readLayer);
if (locator.valid())
{
readLayer->setLocator(locator.get());
locator = 0;
}
if (minLevel!=0) readLayer->setMinLevel(minLevel);
if (maxLevel!=MAXIMUM_NUMBER_OF_LEVELS) readLayer->setMaxLevel(maxLevel);
layer.addLayer(readLayer);
}
if (readObject.valid()) itrAdvanced = true;
@ -109,6 +128,16 @@ bool CompositeLayer_writeLocalData(const osg::Object& obj, osgDB::Output& fw)
{
fw.writeObject(*locator);
}
if (proxyLayer->getMinLevel()!=0)
{
fw.indent()<<"MinLevel "<<layer.getMinLevel()<<std::endl;
}
if (proxyLayer->getMaxLevel()!=MAXIMUM_NUMBER_OF_LEVELS)
{
fw.indent()<<"MaxLevel "<<layer.getMaxLevel()<<std::endl;
}
fw.indent()<<"ProxyLayer "<<proxyLayer->getFileName()<<std::endl;
}

View File

@ -131,13 +131,28 @@ bool Terrain_readLocalData(osg::Object& obj, osgDB::Input &fr)
osgTerrain::Locator* locator = dynamic_cast<osgTerrain::Locator*>(readObject.get());
if (readObject.valid()) localAdvanced = true;
unsigned int minLevel=0;
if (fr.read("MinLevel",minLevel))
{
itrAdvanced = true;
}
unsigned int maxLevel = MAXIMUM_NUMBER_OF_LEVELS;
if (fr.read("MaxLevel",maxLevel))
{
itrAdvanced = true;
}
if (fr.matchSequence("ProxyLayer %s") || fr.matchSequence("ProxyLayer %w") )
{
osg::ref_ptr<osg::Object> image = osgDB::readObjectFile(std::string(fr[1].getStr())+".gdal");
osgTerrain::ProxyLayer* proxyLayer = dynamic_cast<osgTerrain::ProxyLayer*>(image.get());
if (proxyLayer)
{
proxyLayer->setLocator(locator);
if (locator) proxyLayer->setLocator(locator);
if (minLevel!=0) proxyLayer->setMinLevel(minLevel);
if (maxLevel!=MAXIMUM_NUMBER_OF_LEVELS) proxyLayer->setMaxLevel(maxLevel);
terrain.setElevationLayer(proxyLayer);
}
@ -151,7 +166,10 @@ bool Terrain_readLocalData(osg::Object& obj, osgDB::Input &fr)
osgTerrain::Layer* readLayer = dynamic_cast<osgTerrain::Layer*>(readObject.get());
if (readLayer)
{
readLayer->setLocator(locator);
if (locator) readLayer->setLocator(locator);
if (minLevel!=0) readLayer->setMinLevel(minLevel);
if (maxLevel!=MAXIMUM_NUMBER_OF_LEVELS) readLayer->setMaxLevel(maxLevel);
terrain.setElevationLayer(readLayer);
}
@ -185,13 +203,28 @@ bool Terrain_readLocalData(osg::Object& obj, osgDB::Input &fr)
osgTerrain::Locator* locator = dynamic_cast<osgTerrain::Locator*>(readObject.get());
if (readObject.valid()) localAdvanced = true;
unsigned int minLevel=0;
if (fr.read("MinLevel",minLevel))
{
itrAdvanced = true;
}
unsigned int maxLevel = MAXIMUM_NUMBER_OF_LEVELS;
if (fr.read("MaxLevel",maxLevel))
{
itrAdvanced = true;
}
if (fr.matchSequence("ProxyFile %s") || fr.matchSequence("ProxyFile %w") )
{
osg::ref_ptr<osg::Object> image = osgDB::readObjectFile(std::string(fr[1].getStr())+".gdal");
osgTerrain::ProxyLayer* proxyLayer = dynamic_cast<osgTerrain::ProxyLayer*>(image.get());
if (proxyLayer)
{
proxyLayer->setLocator(locator);
if (locator) proxyLayer->setLocator(locator);
if (minLevel!=0) proxyLayer->setMinLevel(minLevel);
if (maxLevel!=MAXIMUM_NUMBER_OF_LEVELS) proxyLayer->setMaxLevel(maxLevel);
terrain.setColorLayer(layerNum, proxyLayer);
}
@ -205,7 +238,10 @@ bool Terrain_readLocalData(osg::Object& obj, osgDB::Input &fr)
osgTerrain::Layer* readLayer = dynamic_cast<osgTerrain::Layer*>(readObject.get());
if (readLayer)
{
readLayer->setLocator(locator);
if (locator) readLayer->setLocator(locator);
if (minLevel!=0) readLayer->setMinLevel(minLevel);
if (maxLevel!=MAXIMUM_NUMBER_OF_LEVELS) readLayer->setMaxLevel(maxLevel);
terrain.setColorLayer(layerNum, readLayer);
}
@ -293,6 +329,16 @@ bool Terrain_writeLocalData(const osg::Object& obj, osgDB::Output& fw)
fw.writeObject(*locator);
}
if (proxyLayer->getMinLevel()!=0)
{
fw.indent()<<"MinLevel "<<proxyLayer->getMinLevel()<<std::endl;
}
if (proxyLayer->getMaxLevel()!=MAXIMUM_NUMBER_OF_LEVELS)
{
fw.indent()<<"MaxLevel "<<proxyLayer->getMaxLevel()<<std::endl;
}
fw.indent()<<"ProxyLayer "<<proxyLayer->getFileName()<<std::endl;
}
}
@ -331,6 +377,16 @@ bool Terrain_writeLocalData(const osg::Object& obj, osgDB::Output& fw)
fw.writeObject(*locator);
}
if (proxyLayer->getMinLevel()!=0)
{
fw.indent()<<"MinLevel "<<proxyLayer->getMinLevel()<<std::endl;
}
if (proxyLayer->getMaxLevel()!=MAXIMUM_NUMBER_OF_LEVELS)
{
fw.indent()<<"MaxLevel "<<proxyLayer->getMaxLevel()<<std::endl;
}
if (!proxyLayer->getFileName().empty()) fw.indent()<<"ProxyLayer "<<proxyLayer->getFileName()<<std::endl;
}
else if (layer)