Added preliminary support for writing VolumeSettings to disk from within Present3D in response to pressing and releasing 'Ctrl-S'.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14363 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
parent
70f9bdc6e1
commit
f2d11bb46e
@ -292,11 +292,11 @@ public:
|
|||||||
useTabbedDragger(false),
|
useTabbedDragger(false),
|
||||||
useTrackballDragger(false),
|
useTrackballDragger(false),
|
||||||
region_in_pixel_coords(false),
|
region_in_pixel_coords(false),
|
||||||
alphaValue("1.0"),
|
alphaValue(),
|
||||||
cutoffValue("0.1"),
|
cutoffValue(),
|
||||||
exteriorTransparencyFactorValue(""),
|
exteriorTransparencyFactorValue(),
|
||||||
sampleDensityValue("0.005"),
|
sampleDensityValue(),
|
||||||
sampleRatioValue("1.0"),
|
sampleRatioValue(),
|
||||||
colorSpaceOperation(osg::NO_COLOR_SPACE_OPERATION),
|
colorSpaceOperation(osg::NO_COLOR_SPACE_OPERATION),
|
||||||
colorModulate(1.0f,1.0f,1.0f,1.0f),
|
colorModulate(1.0f,1.0f,1.0f,1.0f),
|
||||||
technique(osgVolume::VolumeSettings::RayTraced)
|
technique(osgVolume::VolumeSettings::RayTraced)
|
||||||
|
@ -40,6 +40,7 @@ class SampleDensityProperty;
|
|||||||
class SampleDensityWhenMovingProperty;
|
class SampleDensityWhenMovingProperty;
|
||||||
class TransparencyProperty;
|
class TransparencyProperty;
|
||||||
class ExteriorTransparencyFactorProperty;
|
class ExteriorTransparencyFactorProperty;
|
||||||
|
class VolumeSettings;
|
||||||
|
|
||||||
class OSGVOLUME_EXPORT PropertyVisitor
|
class OSGVOLUME_EXPORT PropertyVisitor
|
||||||
{
|
{
|
||||||
@ -49,24 +50,24 @@ class OSGVOLUME_EXPORT PropertyVisitor
|
|||||||
|
|
||||||
virtual ~PropertyVisitor() {}
|
virtual ~PropertyVisitor() {}
|
||||||
|
|
||||||
virtual void apply(Property&) {}
|
virtual void apply(Property&);
|
||||||
virtual void apply(CompositeProperty&);
|
virtual void apply(CompositeProperty&);
|
||||||
virtual void apply(SwitchProperty&);
|
virtual void apply(SwitchProperty&);
|
||||||
virtual void apply(TransferFunctionProperty&) {}
|
virtual void apply(TransferFunctionProperty&);
|
||||||
virtual void apply(ScalarProperty&) {}
|
virtual void apply(ScalarProperty&);
|
||||||
virtual void apply(IsoSurfaceProperty&) {}
|
virtual void apply(IsoSurfaceProperty&);
|
||||||
virtual void apply(AlphaFuncProperty&) {}
|
virtual void apply(AlphaFuncProperty&);
|
||||||
virtual void apply(MaximumIntensityProjectionProperty&) {}
|
virtual void apply(MaximumIntensityProjectionProperty&);
|
||||||
virtual void apply(LightingProperty&) {}
|
virtual void apply(LightingProperty&);
|
||||||
virtual void apply(SampleRatioProperty&) {}
|
virtual void apply(SampleRatioProperty&);
|
||||||
virtual void apply(SampleRatioWhenMovingProperty&) {}
|
virtual void apply(SampleRatioWhenMovingProperty&);
|
||||||
virtual void apply(SampleDensityProperty&) {}
|
virtual void apply(SampleDensityProperty&);
|
||||||
virtual void apply(SampleDensityWhenMovingProperty&) {}
|
virtual void apply(SampleDensityWhenMovingProperty&);
|
||||||
virtual void apply(TransparencyProperty&) {}
|
virtual void apply(TransparencyProperty&);
|
||||||
virtual void apply(ExteriorTransparencyFactorProperty&) {}
|
virtual void apply(ExteriorTransparencyFactorProperty&);
|
||||||
|
virtual void apply(VolumeSettings&);
|
||||||
|
|
||||||
bool _traverseOnlyActiveChildren;
|
bool _traverseOnlyActiveChildren;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -82,6 +83,7 @@ class OSGVOLUME_EXPORT Property : public osg::Object
|
|||||||
META_Object(osgVolume, Property);
|
META_Object(osgVolume, Property);
|
||||||
|
|
||||||
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
||||||
|
virtual void traverse(PropertyVisitor& pv) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -101,6 +103,16 @@ class OSGVOLUME_EXPORT CompositeProperty : public Property
|
|||||||
|
|
||||||
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
||||||
|
|
||||||
|
virtual void traverse(PropertyVisitor& pv)
|
||||||
|
{
|
||||||
|
for(Properties::iterator itr = _properties.begin();
|
||||||
|
itr != _properties.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
(*itr)->accept(pv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
typedef std::vector< osg::ref_ptr<Property> > Properties;
|
typedef std::vector< osg::ref_ptr<Property> > Properties;
|
||||||
@ -139,6 +151,22 @@ class OSGVOLUME_EXPORT SwitchProperty : public CompositeProperty
|
|||||||
|
|
||||||
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
||||||
|
|
||||||
|
virtual void traverse(PropertyVisitor& pv)
|
||||||
|
{
|
||||||
|
if (pv._traverseOnlyActiveChildren)
|
||||||
|
{
|
||||||
|
if (_activeProperty>=0 && static_cast<unsigned int>(_activeProperty)<=getNumProperties())
|
||||||
|
{
|
||||||
|
_properties[_activeProperty]->accept(pv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CompositeProperty::traverse(pv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Set which child property is active.
|
/** Set which child property is active.
|
||||||
* -1 disables all children.*/
|
* -1 disables all children.*/
|
||||||
void setActiveProperty(int i) { _activeProperty = i; }
|
void setActiveProperty(int i) { _activeProperty = i; }
|
||||||
@ -411,7 +439,6 @@ class OSGVOLUME_EXPORT CollectPropertiesVisitor : public osgVolume::PropertyVisi
|
|||||||
|
|
||||||
CollectPropertiesVisitor(bool traverseOnlyActiveChildren=true);
|
CollectPropertiesVisitor(bool traverseOnlyActiveChildren=true);
|
||||||
|
|
||||||
virtual void apply(Property&);
|
|
||||||
virtual void apply(TransferFunctionProperty&);
|
virtual void apply(TransferFunctionProperty&);
|
||||||
virtual void apply(ScalarProperty&);
|
virtual void apply(ScalarProperty&);
|
||||||
virtual void apply(IsoSurfaceProperty& iso);
|
virtual void apply(IsoSurfaceProperty& iso);
|
||||||
|
@ -31,6 +31,7 @@ class OSGVOLUME_EXPORT VolumeSettings : public Property
|
|||||||
META_Object(osgVolume, VolumeSettings);
|
META_Object(osgVolume, VolumeSettings);
|
||||||
|
|
||||||
virtual void accept(PropertyVisitor& pv);
|
virtual void accept(PropertyVisitor& pv);
|
||||||
|
virtual void traverse(PropertyVisitor& pv);
|
||||||
|
|
||||||
enum Technique
|
enum Technique
|
||||||
{
|
{
|
||||||
|
@ -1432,10 +1432,19 @@ void ReaderWriterP3DXML::parseVolume(osgPresentation::SlideShowConstructor& cons
|
|||||||
if (getProperty(cur, "vs", vs) || getProperty(cur, "VolumeSettings", vs))
|
if (getProperty(cur, "vs", vs) || getProperty(cur, "VolumeSettings", vs))
|
||||||
{
|
{
|
||||||
volumeData.volumeSettings = osgDB::readFile<osgVolume::VolumeSettings>(vs);
|
volumeData.volumeSettings = osgDB::readFile<osgVolume::VolumeSettings>(vs);
|
||||||
OSG_NOTICE<<"VolumeSetting read "<<vs<<" "<<volumeData.volumeSettings.get()<<std::endl;
|
if (volumeData.volumeSettings.valid())
|
||||||
|
{
|
||||||
|
OSG_NOTICE<<"VolumeSetting read "<<vs<<" "<<volumeData.volumeSettings.get()<<std::endl;
|
||||||
|
volumeData.volumeSettings->setName(vs);
|
||||||
|
OSG_NOTICE<<" assigned name to VS "<<volumeData.volumeSettings->getName()<<std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!volumeData.volumeSettings) volumeData.volumeSettings = new osgVolume::VolumeSettings;
|
if (!volumeData.volumeSettings)
|
||||||
|
{
|
||||||
|
OSG_NOTICE<<"VolumeSetting fallback has been created"<<std::endl;
|
||||||
|
volumeData.volumeSettings = new osgVolume::VolumeSettings;
|
||||||
|
}
|
||||||
|
|
||||||
// check the rendering technique/shading model to use
|
// check the rendering technique/shading model to use
|
||||||
std::string technique;
|
std::string technique;
|
||||||
|
@ -2510,6 +2510,82 @@ protected:
|
|||||||
std::string _source;
|
std::string _source;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CollectVolumeSettingsVisitor : public osgVolume::PropertyVisitor
|
||||||
|
{
|
||||||
|
CollectVolumeSettingsVisitor():
|
||||||
|
osgVolume::PropertyVisitor(false) {}
|
||||||
|
|
||||||
|
virtual void apply(osgVolume::VolumeSettings& vs)
|
||||||
|
{
|
||||||
|
_vsList.push_back(&vs);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef std::vector< osg::ref_ptr<osgVolume::VolumeSettings> > VolumeSettingsList;
|
||||||
|
VolumeSettingsList _vsList;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct VolumeSettingsCallback : public osgGA::GUIEventHandler
|
||||||
|
{
|
||||||
|
|
||||||
|
VolumeSettingsCallback():
|
||||||
|
_saveKey(19), // Ctril-S
|
||||||
|
_editKey(05) // Ctrl-E
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int _saveKey;
|
||||||
|
int _editKey;
|
||||||
|
|
||||||
|
bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa, osg::Object* object, osg::NodeVisitor* nv)
|
||||||
|
{
|
||||||
|
if (ea.getHandled()) return false;
|
||||||
|
|
||||||
|
osgVolume::VolumeTile* tile = dynamic_cast<osgVolume::VolumeTile*>(object);
|
||||||
|
if (!tile)
|
||||||
|
{
|
||||||
|
OSG_NOTICE<<"Warning: VolumeSettingsCallback assigned to a node other than VolumeTile, cannot operate edit/save."<<std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (ea.getEventType()==osgGA::GUIEventAdapter::KEYUP)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (ea.getKey()==_saveKey)
|
||||||
|
{
|
||||||
|
CollectVolumeSettingsVisitor cvsv;
|
||||||
|
tile->getLayer()->getProperty()->accept(cvsv);
|
||||||
|
|
||||||
|
for(CollectVolumeSettingsVisitor::VolumeSettingsList::iterator itr = cvsv._vsList.begin();
|
||||||
|
itr != cvsv._vsList.end();
|
||||||
|
++itr)
|
||||||
|
{
|
||||||
|
osgVolume::VolumeSettings* vs = itr->get();
|
||||||
|
std::string filename = vs->getName();
|
||||||
|
if (!filename.empty())
|
||||||
|
{
|
||||||
|
OSG_NOTICE<<"Save VolumeSettings "<<vs<<" to filename "<<filename<<std::endl;
|
||||||
|
osgDB::writeObjectFile(*vs, filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OSG_NOTICE<<"VolumeSettings "<<vs<<" with blank filename, saving to 'no_filename_vs.osgt'"<<std::endl;
|
||||||
|
osgDB::writeObjectFile(*vs, "no_filename_vs.osgt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (ea.getKey()==_editKey)
|
||||||
|
{
|
||||||
|
OSG_NOTICE<<"Need to edit VolumeSettings "<<std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void SlideShowConstructor::setUpVolumeScalarProperty(osgVolume::VolumeTile* tile, osgVolume::ScalarProperty* property, const std::string& source)
|
void SlideShowConstructor::setUpVolumeScalarProperty(osgVolume::VolumeTile* tile, osgVolume::ScalarProperty* property, const std::string& source)
|
||||||
{
|
{
|
||||||
if (!source.empty())
|
if (!source.empty())
|
||||||
@ -2726,17 +2802,33 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position
|
|||||||
|
|
||||||
tile->setLayer(layer.get());
|
tile->setLayer(layer.get());
|
||||||
|
|
||||||
|
osg::ref_ptr<osgVolume::CompositeProperty> groupPropetry = new osgVolume::CompositeProperty;
|
||||||
|
|
||||||
osg::ref_ptr<osgVolume::SwitchProperty> sp = new osgVolume::SwitchProperty;
|
osg::ref_ptr<osgVolume::SwitchProperty> sp = new osgVolume::SwitchProperty;
|
||||||
sp->setActiveProperty(0);
|
sp->setActiveProperty(0);
|
||||||
|
groupPropetry->addProperty(sp.get());
|
||||||
|
|
||||||
|
|
||||||
|
osg::ref_ptr<osgVolume::VolumeSettings> vs = volumeData.volumeSettings;
|
||||||
|
|
||||||
osg::ref_ptr<osgVolume::AlphaFuncProperty> ap = new osgVolume::AlphaFuncProperty(0.1f);
|
osg::ref_ptr<osgVolume::AlphaFuncProperty> ap = vs.valid() ? vs->getCutoffProperty() : new osgVolume::AlphaFuncProperty(0.1f);
|
||||||
setUpVolumeScalarProperty(tile.get(), ap.get(), volumeData.cutoffValue);
|
setUpVolumeScalarProperty(tile.get(), ap.get(), volumeData.cutoffValue);
|
||||||
|
|
||||||
osg::ref_ptr<osgVolume::TransparencyProperty> tp = new osgVolume::TransparencyProperty(1.0f);
|
osg::ref_ptr<osgVolume::TransparencyProperty> tp = vs.valid() ? vs->getTransparencyProperty() : new osgVolume::TransparencyProperty(1.0f);
|
||||||
setUpVolumeScalarProperty(tile.get(), tp.get(), volumeData.alphaValue);
|
setUpVolumeScalarProperty(tile.get(), tp.get(), volumeData.alphaValue);
|
||||||
|
|
||||||
|
osg::ref_ptr<osgVolume::SampleRatioProperty> sr = vs.valid() ? vs->getSampleRatioProperty() : new osgVolume::SampleRatioProperty(1.0);
|
||||||
|
setUpVolumeScalarProperty(tile.get(), sr.get(), volumeData.sampleRatioValue);
|
||||||
|
|
||||||
|
osg::ref_ptr<osgVolume::SampleRatioWhenMovingProperty> srm = vs.valid() ? vs->getSampleRatioWhenMovingProperty() : 0;
|
||||||
|
if (!volumeData.sampleRatioWhenMovingValue.empty())
|
||||||
|
{
|
||||||
|
srm = new osgVolume::SampleRatioWhenMovingProperty(0.5);
|
||||||
|
setUpVolumeScalarProperty(tile.get(), srm.get(), volumeData.sampleRatioWhenMovingValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// part of hull implementation.
|
||||||
osg::ref_ptr<osgVolume::ExteriorTransparencyFactorProperty> etfp;
|
osg::ref_ptr<osgVolume::ExteriorTransparencyFactorProperty> etfp;
|
||||||
if (!volumeData.exteriorTransparencyFactorValue.empty())
|
if (!volumeData.exteriorTransparencyFactorValue.empty())
|
||||||
{
|
{
|
||||||
@ -2744,6 +2836,7 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position
|
|||||||
setUpVolumeScalarProperty(tile.get(), etfp.get(), volumeData.exteriorTransparencyFactorValue);
|
setUpVolumeScalarProperty(tile.get(), etfp.get(), volumeData.exteriorTransparencyFactorValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deprecated, used by old RayTracedTechnique
|
||||||
osg::ref_ptr<osgVolume::SampleDensityProperty> sd = new osgVolume::SampleDensityProperty(0.005);
|
osg::ref_ptr<osgVolume::SampleDensityProperty> sd = new osgVolume::SampleDensityProperty(0.005);
|
||||||
setUpVolumeScalarProperty(tile.get(), sd.get(), volumeData.sampleDensityValue);
|
setUpVolumeScalarProperty(tile.get(), sd.get(), volumeData.sampleDensityValue);
|
||||||
|
|
||||||
@ -2754,30 +2847,67 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position
|
|||||||
setUpVolumeScalarProperty(tile.get(), sdm.get(), volumeData.sampleDensityWhenMovingValue);
|
setUpVolumeScalarProperty(tile.get(), sdm.get(), volumeData.sampleDensityWhenMovingValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
osg::ref_ptr<osgVolume::SampleRatioProperty> sr = new osgVolume::SampleRatioProperty(1.0);
|
|
||||||
setUpVolumeScalarProperty(tile.get(), sr.get(), volumeData.sampleRatioValue);
|
|
||||||
|
|
||||||
osg::ref_ptr<osgVolume::SampleRatioWhenMovingProperty> srm;
|
|
||||||
if (!volumeData.sampleRatioWhenMovingValue.empty())
|
|
||||||
{
|
|
||||||
srm = new osgVolume::SampleRatioWhenMovingProperty(0.5);
|
|
||||||
setUpVolumeScalarProperty(tile.get(), srm.get(), volumeData.sampleRatioWhenMovingValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
osg::ref_ptr<osgVolume::TransferFunctionProperty> tfp = volumeData.transferFunction.valid() ? new osgVolume::TransferFunctionProperty(volumeData.transferFunction.get()) : 0;
|
osg::ref_ptr<osgVolume::TransferFunctionProperty> tfp = volumeData.transferFunction.valid() ? new osgVolume::TransferFunctionProperty(volumeData.transferFunction.get()) : 0;
|
||||||
|
|
||||||
|
if (volumeData.volumeSettings.valid())
|
||||||
|
{
|
||||||
|
groupPropetry->addProperty(volumeData.volumeSettings.get());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ap.valid()) groupPropetry->addProperty(ap.get());
|
||||||
|
if (tp.valid()) groupPropetry->addProperty(tp.get());
|
||||||
|
|
||||||
|
if (sr.valid()) groupPropetry->addProperty(sr.get());
|
||||||
|
if (srm.valid()) groupPropetry->addProperty(srm.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (sd.valid()) groupPropetry->addProperty(sd.get());
|
||||||
|
if (sdm.valid()) groupPropetry->addProperty(sdm.get());
|
||||||
|
|
||||||
|
if (tfp.valid()) groupPropetry->addProperty(tfp.get());
|
||||||
|
if (etfp.valid()) groupPropetry->addProperty(etfp.get());
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
{
|
||||||
|
// Standard
|
||||||
|
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
|
||||||
|
|
||||||
|
sp->addProperty(cp);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Light
|
||||||
|
sp->addProperty(new osgVolume::LightingProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Isosurface
|
||||||
|
osgVolume::IsoSurfaceProperty* isp = new osgVolume::IsoSurfaceProperty(0.1);
|
||||||
|
setUpVolumeScalarProperty(tile.get(), isp, volumeData.alphaValue);
|
||||||
|
|
||||||
|
sp->addProperty(isp);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// MaximumIntensityProjection
|
||||||
|
sp->addProperty(new osgVolume::MaximumIntensityProjectionProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
{
|
{
|
||||||
// Standard
|
// Standard
|
||||||
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
|
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
|
||||||
cp->addProperty(ap.get());
|
cp->addProperty(ap.get());
|
||||||
cp->addProperty(tp.get());
|
cp->addProperty(tp.get());
|
||||||
if (sd.valid()) cp->addProperty(sd.get());
|
|
||||||
if (sdm.valid()) cp->addProperty(sdm.get());
|
|
||||||
if (sr.valid()) cp->addProperty(sr.get());
|
|
||||||
if (srm.valid()) cp->addProperty(srm.get());
|
|
||||||
if (tfp.valid()) cp->addProperty(tfp.get());
|
|
||||||
if (etfp.valid()) cp->addProperty(etfp.get());
|
|
||||||
|
|
||||||
sp->addProperty(cp);
|
sp->addProperty(cp);
|
||||||
}
|
}
|
||||||
@ -2841,9 +2971,13 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position
|
|||||||
case(osgVolume::VolumeSettings::Isosurface): sp->setActiveProperty(2); break;
|
case(osgVolume::VolumeSettings::Isosurface): sp->setActiveProperty(2); break;
|
||||||
case(osgVolume::VolumeSettings::MaximumIntensityProjection): sp->setActiveProperty(3); break;
|
case(osgVolume::VolumeSettings::MaximumIntensityProjection): sp->setActiveProperty(3); break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
layer->addProperty(groupPropetry.get());
|
||||||
|
#else
|
||||||
layer->addProperty(sp.get());
|
layer->addProperty(sp.get());
|
||||||
|
#endif
|
||||||
switch(volumeData.technique)
|
switch(volumeData.technique)
|
||||||
{
|
{
|
||||||
case(osgVolume::VolumeSettings::FixedFunction):
|
case(osgVolume::VolumeSettings::FixedFunction):
|
||||||
@ -2914,6 +3048,8 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position
|
|||||||
model = group.get();
|
model = group.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tile->addEventCallback(new VolumeSettingsCallback());
|
||||||
|
|
||||||
ModelData modelData;
|
ModelData modelData;
|
||||||
addModel(model.get(), positionData, modelData, scriptData);
|
addModel(model.get(), positionData, modelData, scriptData);
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,11 @@
|
|||||||
#include <osgVolume/Property>
|
#include <osgVolume/Property>
|
||||||
#include <osgVolume/VolumeTile>
|
#include <osgVolume/VolumeTile>
|
||||||
#include <osgVolume/RayTracedTechnique>
|
#include <osgVolume/RayTracedTechnique>
|
||||||
|
#include <osgVolume/VolumeSettings>
|
||||||
|
|
||||||
using namespace osgVolume;
|
using namespace osgVolume;
|
||||||
|
|
||||||
|
|
||||||
Property::Property()
|
Property::Property()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -261,31 +263,22 @@ PropertyVisitor::PropertyVisitor(bool traverseOnlyActiveChildren):
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertyVisitor::apply(CompositeProperty& cp)
|
void PropertyVisitor::apply(Property& p) { p.traverse(*this); }
|
||||||
{
|
void PropertyVisitor::apply(CompositeProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
for(unsigned int i=0; i<cp.getNumProperties(); ++i)
|
void PropertyVisitor::apply(SwitchProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
{
|
void PropertyVisitor::apply(TransferFunctionProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
cp.getProperty(i)->accept(*this);
|
void PropertyVisitor::apply(ScalarProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
}
|
void PropertyVisitor::apply(IsoSurfaceProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
}
|
void PropertyVisitor::apply(AlphaFuncProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
|
void PropertyVisitor::apply(MaximumIntensityProjectionProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
void PropertyVisitor::apply(SwitchProperty& sp)
|
void PropertyVisitor::apply(LightingProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
{
|
void PropertyVisitor::apply(SampleRatioProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
if (_traverseOnlyActiveChildren)
|
void PropertyVisitor::apply(SampleRatioWhenMovingProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
{
|
void PropertyVisitor::apply(SampleDensityProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
if (sp.getActiveProperty()>=0 && sp.getActiveProperty()<static_cast<int>(sp.getNumProperties()))
|
void PropertyVisitor::apply(SampleDensityWhenMovingProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
{
|
void PropertyVisitor::apply(TransparencyProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
sp.getProperty(sp.getActiveProperty())->accept(*this);
|
void PropertyVisitor::apply(ExteriorTransparencyFactorProperty& p) { apply(static_cast<Property&>(p)); }
|
||||||
}
|
void PropertyVisitor::apply(VolumeSettings& p) { apply(static_cast<Property&>(p)); }
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for(unsigned int i=0; i<sp.getNumProperties(); ++i)
|
|
||||||
{
|
|
||||||
sp.getProperty(i)->accept(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
@ -297,7 +290,6 @@ CollectPropertiesVisitor::CollectPropertiesVisitor(bool traverseOnlyActiveChildr
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CollectPropertiesVisitor::apply(Property&) {}
|
|
||||||
void CollectPropertiesVisitor::apply(TransferFunctionProperty& tf) { _tfProperty = &tf; }
|
void CollectPropertiesVisitor::apply(TransferFunctionProperty& tf) { _tfProperty = &tf; }
|
||||||
void CollectPropertiesVisitor::apply(ScalarProperty&) {}
|
void CollectPropertiesVisitor::apply(ScalarProperty&) {}
|
||||||
void CollectPropertiesVisitor::apply(IsoSurfaceProperty& iso) { _isoProperty = &iso; }
|
void CollectPropertiesVisitor::apply(IsoSurfaceProperty& iso) { _isoProperty = &iso; }
|
||||||
@ -311,7 +303,6 @@ void CollectPropertiesVisitor::apply(SampleRatioWhenMovingProperty& srp) { _samp
|
|||||||
void CollectPropertiesVisitor::apply(TransparencyProperty& tp) { _transparencyProperty = &tp; }
|
void CollectPropertiesVisitor::apply(TransparencyProperty& tp) { _transparencyProperty = &tp; }
|
||||||
void CollectPropertiesVisitor::apply(ExteriorTransparencyFactorProperty& etfp) { _exteriorTransparencyFactorProperty = &etfp; }
|
void CollectPropertiesVisitor::apply(ExteriorTransparencyFactorProperty& etfp) { _exteriorTransparencyFactorProperty = &etfp; }
|
||||||
|
|
||||||
|
|
||||||
class CycleSwitchVisitor : public osgVolume::PropertyVisitor
|
class CycleSwitchVisitor : public osgVolume::PropertyVisitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -37,6 +37,11 @@ VolumeSettings::VolumeSettings(const VolumeSettings& vs,const osg::CopyOp& copyo
|
|||||||
}
|
}
|
||||||
|
|
||||||
void VolumeSettings::accept(PropertyVisitor& pv)
|
void VolumeSettings::accept(PropertyVisitor& pv)
|
||||||
|
{
|
||||||
|
pv.apply(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VolumeSettings::traverse(PropertyVisitor& pv)
|
||||||
{
|
{
|
||||||
_sampleRatioProperty->accept(pv);
|
_sampleRatioProperty->accept(pv);
|
||||||
_sampleRatioWhenMovingProperty->accept(pv);
|
_sampleRatioWhenMovingProperty->accept(pv);
|
||||||
|
Loading…
Reference in New Issue
Block a user