From 21fc2fae8d8a0c649a93baee95932ea36532ab5c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 3 Sep 2014 15:54:47 +0000 Subject: [PATCH] Added setting of the IsoSurfaceProperty in VolumeSettings git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14436 16af8721-9629-0410-8352-f15c8da7e697 --- include/osgVolume/VolumeSettings | 25 +++++++++++------ .../deprecated/SlideShowConstructor.cpp | 2 +- src/osgVolume/VolumeSettings.cpp | 27 ++++++++++++++----- .../serializers/osgVolume/VolumeSettings.cpp | 1 + 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/include/osgVolume/VolumeSettings b/include/osgVolume/VolumeSettings index bd14adda1..f343fe781 100644 --- a/include/osgVolume/VolumeSettings +++ b/include/osgVolume/VolumeSettings @@ -59,25 +59,33 @@ class OSGVOLUME_EXPORT VolumeSettings : public Property void setSampleRatio(float sr) { _sampleRatioProperty->setValue(sr); dirty(); } float getSampleRatio() const { return _sampleRatioProperty->getValue(); } - SampleRatioProperty* getSampleRatioProperty() { return _sampleRatioProperty.get(); } - const SampleRatioProperty* getSampleRatioProperty() const { return _sampleRatioProperty.get(); } void setSampleRatioWhenMoving(float sr) { _sampleRatioWhenMovingProperty->setValue(sr); dirty(); } float getSampleRatioWhenMoving() const { return _sampleRatioWhenMovingProperty->getValue(); } - SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() { return _sampleRatioWhenMovingProperty.get(); } - const SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() const { return _sampleRatioWhenMovingProperty.get(); } - void setCutoff(float co) { _cutoffProperty->setValue(co); dirty(); } + void setCutoff(float co); float getCutoff() const { return _cutoffProperty->getValue(); } - AlphaFuncProperty* getCutoffProperty() { return _cutoffProperty.get(); } - const AlphaFuncProperty* getCutoffProperty() const { return _cutoffProperty.get(); } void setTransparency(float t) { _transparencyProperty->setValue(t); dirty(); } float getTransparency() const { return _transparencyProperty->getValue(); } + + + SampleRatioProperty* getSampleRatioProperty() { return _sampleRatioProperty.get(); } + const SampleRatioProperty* getSampleRatioProperty() const { return _sampleRatioProperty.get(); } + + SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() { return _sampleRatioWhenMovingProperty.get(); } + const SampleRatioWhenMovingProperty* getSampleRatioWhenMovingProperty() const { return _sampleRatioWhenMovingProperty.get(); } + + AlphaFuncProperty* getCutoffProperty() { return _cutoffProperty.get(); } + const AlphaFuncProperty* getCutoffProperty() const { return _cutoffProperty.get(); } + TransparencyProperty* getTransparencyProperty() { return _transparencyProperty.get(); } const TransparencyProperty* getTransparencyProperty() const { return _transparencyProperty.get(); } - protected: + IsoSurfaceProperty* getIsoSurfaceProperty() { return _isoSurfaceProperty.get(); } + const IsoSurfaceProperty* getIsoSurfaceProperty() const { return _isoSurfaceProperty.get(); } + +protected: virtual ~VolumeSettings() {} @@ -90,6 +98,7 @@ class OSGVOLUME_EXPORT VolumeSettings : public Property osg::ref_ptr _sampleRatioWhenMovingProperty; osg::ref_ptr _cutoffProperty; osg::ref_ptr _transparencyProperty; + osg::ref_ptr _isoSurfaceProperty; }; } diff --git a/src/osgPresentation/deprecated/SlideShowConstructor.cpp b/src/osgPresentation/deprecated/SlideShowConstructor.cpp index ff17ebbd1..391067721 100644 --- a/src/osgPresentation/deprecated/SlideShowConstructor.cpp +++ b/src/osgPresentation/deprecated/SlideShowConstructor.cpp @@ -2927,7 +2927,7 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position { // Isosurface - osgVolume::IsoSurfaceProperty* isp = new osgVolume::IsoSurfaceProperty(0.1); + osgVolume::IsoSurfaceProperty* isp = vs.valid() ? vs->getIsoSurfaceProperty() : new osgVolume::IsoSurfaceProperty(0.1); setUpVolumeScalarProperty(tile.get(), isp, volumeData.alphaValue); sp->addProperty(isp); diff --git a/src/osgVolume/VolumeSettings.cpp b/src/osgVolume/VolumeSettings.cpp index 11e1fe973..0930182cc 100644 --- a/src/osgVolume/VolumeSettings.cpp +++ b/src/osgVolume/VolumeSettings.cpp @@ -21,7 +21,8 @@ VolumeSettings::VolumeSettings(): _sampleRatioProperty(new SampleRatioProperty(1.0f)), _sampleRatioWhenMovingProperty(new SampleRatioWhenMovingProperty(1.0f)), _cutoffProperty(new AlphaFuncProperty(0.0f)), - _transparencyProperty(new TransparencyProperty(1.0f)) + _transparencyProperty(new TransparencyProperty(1.0f)), + _isoSurfaceProperty(new IsoSurfaceProperty(0.0f)) { } @@ -33,7 +34,8 @@ VolumeSettings::VolumeSettings(const VolumeSettings& vs,const osg::CopyOp& copyo _sampleRatioProperty(osg::clone(vs._sampleRatioProperty.get(), copyop)), _sampleRatioWhenMovingProperty(osg::clone(vs._sampleRatioWhenMovingProperty.get(), copyop)), _cutoffProperty(osg::clone(vs._cutoffProperty.get(), copyop)), - _transparencyProperty(osg::clone(vs._transparencyProperty.get(), copyop)) + _transparencyProperty(osg::clone(vs._transparencyProperty.get(), copyop)), + _isoSurfaceProperty(osg::clone(vs._isoSurfaceProperty.get(), copyop)) { } @@ -44,8 +46,21 @@ void VolumeSettings::accept(PropertyVisitor& pv) void VolumeSettings::traverse(PropertyVisitor& pv) { - _sampleRatioProperty->accept(pv); - _sampleRatioWhenMovingProperty->accept(pv); - _cutoffProperty->accept(pv); - _transparencyProperty->accept(pv); + if (_sampleRatioProperty.valid()) _sampleRatioProperty->accept(pv); + if (_sampleRatioWhenMovingProperty.valid()) _sampleRatioWhenMovingProperty->accept(pv); + if (_cutoffProperty.valid()) _cutoffProperty->accept(pv); + if (_transparencyProperty.valid()) _transparencyProperty->accept(pv); + if (_isoSurfaceProperty.valid() && _shadingModel==Isosurface) _isoSurfaceProperty->accept(pv); +} + +void VolumeSettings::setCutoff(float co) +{ + _cutoffProperty->setValue(co); + if (_isoSurfaceProperty.valid()) + { + OSG_NOTICE<<"Setting IsoSurface value to "<setValue(co); + } + + dirty(); } diff --git a/src/osgWrappers/serializers/osgVolume/VolumeSettings.cpp b/src/osgWrappers/serializers/osgVolume/VolumeSettings.cpp index 41849effe..cf38db438 100644 --- a/src/osgWrappers/serializers/osgVolume/VolumeSettings.cpp +++ b/src/osgWrappers/serializers/osgVolume/VolumeSettings.cpp @@ -33,6 +33,7 @@ REGISTER_OBJECT_WRAPPER( osgVolume_VolumeSettings, ADD_OBJECT_SERIALIZER_NO_SET( SampleRatioWhenMovingProperty, osgVolume::SampleRatioWhenMovingProperty, NULL ); ADD_OBJECT_SERIALIZER_NO_SET( CutoffProperty, osgVolume::AlphaFuncProperty, NULL ); ADD_OBJECT_SERIALIZER_NO_SET( TransparencyProperty, osgVolume::TransparencyProperty, NULL ); + ADD_OBJECT_SERIALIZER_NO_SET( IsoSurfaceProperty, osgVolume::IsoSurfaceProperty, NULL ); }