Improved handling of VolumeSettings

git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14427 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
Robert Osfield 2014-08-28 09:42:01 +00:00
parent 2f10db8f11
commit d97081fe7f
2 changed files with 34 additions and 33 deletions

View File

@ -2938,6 +2938,12 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position
sp->addProperty(new osgVolume::MaximumIntensityProjectionProperty);
}
if (volumeData.volumeSettings.valid())
{
sp->setActiveProperty(volumeData.volumeSettings->getShadingModel());
}
else
{
switch(volumeData.shadingModel)
{
case(osgVolume::VolumeSettings::Standard): sp->setActiveProperty(0); break;
@ -2945,6 +2951,7 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position
case(osgVolume::VolumeSettings::Isosurface): sp->setActiveProperty(2); break;
case(osgVolume::VolumeSettings::MaximumIntensityProjection): sp->setActiveProperty(3); break;
}
}
#else
{
// Standard

View File

@ -314,41 +314,35 @@ class CycleSwitchVisitor : public osgVolume::PropertyVisitor
CycleSwitchVisitor(int delta):
PropertyVisitor(false),
_delta(delta),
_switchModified(true) {}
_switchModified(false) {}
virtual void apply(VolumeSettings& vs)
{
int newValue = static_cast<int>(vs.getShadingModel())+_delta;
if (newValue<0) newValue = VolumeSettings::MaximumIntensityProjection;
else if (newValue>VolumeSettings::MaximumIntensityProjection) newValue = 0;
vs.setShadingModel(static_cast<VolumeSettings::ShadingModel>(newValue));
OSG_NOTICE<<"CycleSwitchVisitor::apply(VolumeSettings&) "<<newValue<<std::endl;
_switchModified = true;
PropertyVisitor::apply(vs);
}
virtual void apply(SwitchProperty& sp)
{
if (sp.getNumProperties()>=2)
{
if (_delta>0)
{
int newValue = sp.getActiveProperty()+_delta;
if (newValue<static_cast<int>(sp.getNumProperties()))
if (sp.getNumProperties()>1)
{
int newValue = static_cast<int>(sp.getActiveProperty())+_delta;
if (newValue >= static_cast<int>(sp.getNumProperties())) newValue = 0;
if (newValue < 0) newValue = sp.getNumProperties()-1;
sp.setActiveProperty(newValue);
}
else
{
sp.setActiveProperty(0);
}
OSG_NOTICE<<"CycleSwitchVisitor::apply(SwitchProperty&) "<<newValue<<std::endl;
_switchModified = true;
}
else // _delta<0
{
int newValue = sp.getActiveProperty()+_delta;
if (newValue>=0)
{
sp.setActiveProperty(newValue);
}
else
{
sp.setActiveProperty(sp.getNumProperties()-1);
}
_switchModified = true;
}
}
PropertyVisitor::apply(sp);
}