From 51403143bd552ab19b7077aadb14904b7a42e20b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 29 Jan 2009 20:34:22 +0000 Subject: [PATCH] Added support for osgVolume::Property classes --- src/osgPlugins/osgVolume/CMakeLists.txt | 4 + .../osgVolume/CompositeProperty.cpp | 60 +++++++++++++ src/osgPlugins/osgVolume/ImageLayer.cpp | 11 +++ src/osgPlugins/osgVolume/Property.cpp | 54 +++++++++++ src/osgPlugins/osgVolume/ScalarProperty.cpp | 89 +++++++++++++++++++ src/osgPlugins/osgVolume/SwitchProperty.cpp | 52 +++++++++++ 6 files changed, 270 insertions(+) create mode 100644 src/osgPlugins/osgVolume/CompositeProperty.cpp create mode 100644 src/osgPlugins/osgVolume/Property.cpp create mode 100644 src/osgPlugins/osgVolume/ScalarProperty.cpp create mode 100644 src/osgPlugins/osgVolume/SwitchProperty.cpp diff --git a/src/osgPlugins/osgVolume/CMakeLists.txt b/src/osgPlugins/osgVolume/CMakeLists.txt index c5699210f..f757445d5 100644 --- a/src/osgPlugins/osgVolume/CMakeLists.txt +++ b/src/osgPlugins/osgVolume/CMakeLists.txt @@ -6,6 +6,10 @@ SET(TARGET_SRC VolumeTile.cpp RayTracedTechnique.cpp FixedFunctionTechnique.cpp + Property.cpp + CompositeProperty.cpp + SwitchProperty.cpp + ScalarProperty.cpp ) SET(TARGET_ADDED_LIBRARIES osgVolume ) diff --git a/src/osgPlugins/osgVolume/CompositeProperty.cpp b/src/osgPlugins/osgVolume/CompositeProperty.cpp new file mode 100644 index 000000000..f11f08759 --- /dev/null +++ b/src/osgPlugins/osgVolume/CompositeProperty.cpp @@ -0,0 +1,60 @@ +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +bool CompositeProperty_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool CompositeProperty_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy CompositeProperty_Proxy +( + new osgVolume::CompositeProperty, + "CompositeProperty", + "Object CompositeProperty", + CompositeProperty_readLocalData, + CompositeProperty_writeLocalData +); + + +bool CompositeProperty_readLocalData(osg::Object& obj, osgDB::Input &fr) +{ + osgVolume::CompositeProperty& cp = static_cast(obj); + + bool itrAdvanced = false; + + osg::ref_ptr readObject; + do + { + readObject = fr.readObjectOfType(osgDB::type_wrapper()); + if (readObject.valid()) itrAdvanced = true; + + osgVolume::Property* property = dynamic_cast(readObject.get()); + if (property) cp.addProperty(property); + + } while (readObject.valid()); + + return itrAdvanced; +} + +bool CompositeProperty_writeLocalData(const osg::Object& obj, osgDB::Output& fw) +{ + const osgVolume::CompositeProperty& cp = static_cast(obj); + + + for(unsigned int i=0; i readObject = fr.readObjectOfType(osgDB::type_wrapper()); + if (readObject.valid()) itrAdvanced = true; + + osgVolume::Property* property = dynamic_cast(readObject.get()); + if (property) layer.addProperty(property); + if (fr.matchSequence("file %w") || fr.matchSequence("file %s")) { std::string filename = fr[1].getStr(); @@ -87,6 +93,11 @@ bool ImageLayer_writeLocalData(const osg::Object& obj, osgDB::Output& fw) { const osgVolume::ImageLayer& layer = static_cast(obj); + if (layer.getProperty()) + { + fw.writeObject(*layer.getProperty()); + } + if (!layer.getFileName().empty()) { fw.indent()<<"file "<< layer.getFileName() << std::endl; diff --git a/src/osgPlugins/osgVolume/Property.cpp b/src/osgPlugins/osgVolume/Property.cpp new file mode 100644 index 000000000..83d83ef45 --- /dev/null +++ b/src/osgPlugins/osgVolume/Property.cpp @@ -0,0 +1,54 @@ +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +bool Property_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool Property_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy Property_Proxy +( + new osgVolume::Property, + "Property", + "Object Property", + Property_readLocalData, + Property_writeLocalData +); + +osgDB::RegisterDotOsgWrapperProxy MaximumImageProjectionProperty_Proxy +( + new osgVolume::MaximumIntensityProjectionProperty, + "MaximumIntensityProjectionProperty", + "Object MaximumIntensityProjectionProperty", + Property_readLocalData, + Property_writeLocalData +); + +osgDB::RegisterDotOsgWrapperProxy LightingProperty_Proxy +( + new osgVolume::LightingProperty, + "LightingProperty", + "Object LightingProperty", + Property_readLocalData, + Property_writeLocalData +); + +bool Property_readLocalData(osg::Object& obj, osgDB::Input &fr) +{ + return false; +} + +bool Property_writeLocalData(const osg::Object& obj, osgDB::Output& fw) +{ + return true; +} diff --git a/src/osgPlugins/osgVolume/ScalarProperty.cpp b/src/osgPlugins/osgVolume/ScalarProperty.cpp new file mode 100644 index 000000000..c60c73173 --- /dev/null +++ b/src/osgPlugins/osgVolume/ScalarProperty.cpp @@ -0,0 +1,89 @@ +#include + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +bool ScalarProperty_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool ScalarProperty_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy ScalarProperty_Proxy +( + 0, + "ScalarProperty", + "Object ScalarProperty", + ScalarProperty_readLocalData, + ScalarProperty_writeLocalData +); + +osgDB::RegisterDotOsgWrapperProxy IsoSurfaceProperty_Proxy +( + new osgVolume::IsoSurfaceProperty, + "IsoSurfaceProperty", + "Object ScalarProperty", + ScalarProperty_readLocalData, + ScalarProperty_writeLocalData +); + +osgDB::RegisterDotOsgWrapperProxy AlphaFuncProperty_Proxy +( + new osgVolume::AlphaFuncProperty, + "AlphaFuncProperty", + "Object AlphaFuncProperty", + ScalarProperty_readLocalData, + ScalarProperty_writeLocalData +); + +osgDB::RegisterDotOsgWrapperProxy SampleDensityProperty_Proxy +( + new osgVolume::SampleDensityProperty, + "SampleDensityProperty", + "Object SampleDensityProperty", + ScalarProperty_readLocalData, + ScalarProperty_writeLocalData +); + +osgDB::RegisterDotOsgWrapperProxy TransparencyProperty_Proxy +( + new osgVolume::TransparencyProperty, + "TransparencyProperty", + "Object TransparencyProperty", + ScalarProperty_readLocalData, + ScalarProperty_writeLocalData +); + + + +bool ScalarProperty_readLocalData(osg::Object& obj, osgDB::Input &fr) +{ + osgVolume::ScalarProperty& sp = static_cast(obj); + + bool itrAdvanced = false; + + float value=0; + if (fr.read("value",value)) + { + itrAdvanced = true; + sp.setValue(value); + } + + return itrAdvanced; +} + +bool ScalarProperty_writeLocalData(const osg::Object& obj, osgDB::Output& fw) +{ + const osgVolume::ScalarProperty& sp = static_cast(obj); + + fw.indent()<<"value "< + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +bool SwitchProperty_readLocalData(osg::Object &obj, osgDB::Input &fr); +bool SwitchProperty_writeLocalData(const osg::Object &obj, osgDB::Output &fw); + +osgDB::RegisterDotOsgWrapperProxy SwitchProperty_Proxy +( + new osgVolume::SwitchProperty, + "SwitchProperty", + "Object SwitchProperty CompositeProperty", + SwitchProperty_readLocalData, + SwitchProperty_writeLocalData +); + + +bool SwitchProperty_readLocalData(osg::Object& obj, osgDB::Input &fr) +{ + osgVolume::SwitchProperty& sp = static_cast(obj); + + bool itrAdvanced = false; + + int value=0; + if (fr.read("activeProperty",value)) + { + itrAdvanced = true; + sp.setActiveProperty(value); + } + + return itrAdvanced; +} + +bool SwitchProperty_writeLocalData(const osg::Object& obj, osgDB::Output& fw) +{ + const osgVolume::SwitchProperty& sp = static_cast(obj); + + fw.indent()<<"activeProperty "<