Added support for osgVolume::Property classes
This commit is contained in:
@@ -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 )
|
||||
|
||||
60
src/osgPlugins/osgVolume/CompositeProperty.cpp
Normal file
60
src/osgPlugins/osgVolume/CompositeProperty.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
#include <osgVolume/Property>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
#include <osgDB/ParameterOutput>
|
||||
|
||||
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<osgVolume::CompositeProperty&>(obj);
|
||||
|
||||
bool itrAdvanced = false;
|
||||
|
||||
osg::ref_ptr<osg::Object> readObject;
|
||||
do
|
||||
{
|
||||
readObject = fr.readObjectOfType(osgDB::type_wrapper<osgVolume::Property>());
|
||||
if (readObject.valid()) itrAdvanced = true;
|
||||
|
||||
osgVolume::Property* property = dynamic_cast<osgVolume::Property*>(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<const osgVolume::CompositeProperty&>(obj);
|
||||
|
||||
|
||||
for(unsigned int i=0; i<cp.getNumProperties(); ++i)
|
||||
{
|
||||
fw.writeObject(*cp.getProperty(i));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -35,6 +35,12 @@ bool ImageLayer_readLocalData(osg::Object& obj, osgDB::Input &fr)
|
||||
|
||||
bool itrAdvanced = false;
|
||||
|
||||
osg::ref_ptr<osg::Object> readObject = fr.readObjectOfType(osgDB::type_wrapper<osgVolume::Property>());
|
||||
if (readObject.valid()) itrAdvanced = true;
|
||||
|
||||
osgVolume::Property* property = dynamic_cast<osgVolume::Property*>(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<const osgVolume::ImageLayer&>(obj);
|
||||
|
||||
if (layer.getProperty())
|
||||
{
|
||||
fw.writeObject(*layer.getProperty());
|
||||
}
|
||||
|
||||
if (!layer.getFileName().empty())
|
||||
{
|
||||
fw.indent()<<"file "<< layer.getFileName() << std::endl;
|
||||
|
||||
54
src/osgPlugins/osgVolume/Property.cpp
Normal file
54
src/osgPlugins/osgVolume/Property.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <osgVolume/Property>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
#include <osgDB/ParameterOutput>
|
||||
|
||||
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;
|
||||
}
|
||||
89
src/osgPlugins/osgVolume/ScalarProperty.cpp
Normal file
89
src/osgPlugins/osgVolume/ScalarProperty.cpp
Normal file
@@ -0,0 +1,89 @@
|
||||
#include <osgVolume/Property>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
#include <osgDB/ParameterOutput>
|
||||
|
||||
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<osgVolume::ScalarProperty&>(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<const osgVolume::ScalarProperty&>(obj);
|
||||
|
||||
fw.indent()<<"value "<<sp.getValue()<<std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
52
src/osgPlugins/osgVolume/SwitchProperty.cpp
Normal file
52
src/osgPlugins/osgVolume/SwitchProperty.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <osgVolume/Property>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Vec4>
|
||||
#include <osg/io_utils>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/Input>
|
||||
#include <osgDB/Output>
|
||||
#include <osgDB/ParameterOutput>
|
||||
|
||||
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<osgVolume::SwitchProperty&>(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<const osgVolume::SwitchProperty&>(obj);
|
||||
|
||||
fw.indent()<<"activeProperty "<<sp.getActiveProperty()<<std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user