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

View File

@ -314,40 +314,34 @@ class CycleSwitchVisitor : public osgVolume::PropertyVisitor
CycleSwitchVisitor(int delta): CycleSwitchVisitor(int delta):
PropertyVisitor(false), PropertyVisitor(false),
_delta(delta), _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) virtual void apply(SwitchProperty& sp)
{ {
if (sp.getNumProperties()>=2) if (sp.getNumProperties()>1)
{ {
if (_delta>0) int newValue = static_cast<int>(sp.getActiveProperty())+_delta;
{ if (newValue >= static_cast<int>(sp.getNumProperties())) newValue = 0;
int newValue = sp.getActiveProperty()+_delta; if (newValue < 0) newValue = sp.getNumProperties()-1;
if (newValue<static_cast<int>(sp.getNumProperties()))
{
sp.setActiveProperty(newValue);
}
else
{
sp.setActiveProperty(0);
}
_switchModified = true; sp.setActiveProperty(newValue);
}
else // _delta<0
{
int newValue = sp.getActiveProperty()+_delta;
if (newValue>=0)
{
sp.setActiveProperty(newValue);
}
else
{
sp.setActiveProperty(sp.getNumProperties()-1);
}
_switchModified = true; OSG_NOTICE<<"CycleSwitchVisitor::apply(SwitchProperty&) "<<newValue<<std::endl;
}
_switchModified = true;
} }
PropertyVisitor::apply(sp); PropertyVisitor::apply(sp);