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:
@@ -314,40 +314,34 @@ 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 (sp.getNumProperties()>1)
|
||||
{
|
||||
if (_delta>0)
|
||||
{
|
||||
int newValue = sp.getActiveProperty()+_delta;
|
||||
if (newValue<static_cast<int>(sp.getNumProperties()))
|
||||
{
|
||||
sp.setActiveProperty(newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
sp.setActiveProperty(0);
|
||||
}
|
||||
int newValue = static_cast<int>(sp.getActiveProperty())+_delta;
|
||||
if (newValue >= static_cast<int>(sp.getNumProperties())) newValue = 0;
|
||||
if (newValue < 0) newValue = sp.getNumProperties()-1;
|
||||
|
||||
_switchModified = true;
|
||||
}
|
||||
else // _delta<0
|
||||
{
|
||||
int newValue = sp.getActiveProperty()+_delta;
|
||||
if (newValue>=0)
|
||||
{
|
||||
sp.setActiveProperty(newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
sp.setActiveProperty(sp.getNumProperties()-1);
|
||||
}
|
||||
sp.setActiveProperty(newValue);
|
||||
|
||||
_switchModified = true;
|
||||
}
|
||||
OSG_NOTICE<<"CycleSwitchVisitor::apply(SwitchProperty&) "<<newValue<<std::endl;
|
||||
|
||||
_switchModified = true;
|
||||
}
|
||||
|
||||
PropertyVisitor::apply(sp);
|
||||
|
||||
Reference in New Issue
Block a user