Added PrintProperties visitor
This commit is contained in:
parent
ccf7bbdb50
commit
856ec46467
@ -34,6 +34,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
osgViewer::Viewer viewer(arguments);
|
osgViewer::Viewer viewer(arguments);
|
||||||
|
|
||||||
|
#if 0
|
||||||
typedef std::list< osg::ref_ptr<osg::Script> > Scripts;
|
typedef std::list< osg::ref_ptr<osg::Script> > Scripts;
|
||||||
Scripts scripts;
|
Scripts scripts;
|
||||||
|
|
||||||
@ -44,10 +45,6 @@ int main(int argc, char** argv)
|
|||||||
if (script.valid()) scripts.push_back(script.get());
|
if (script.valid()) scripts.push_back(script.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the model
|
|
||||||
osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments);
|
|
||||||
if (!model) return 1;
|
|
||||||
|
|
||||||
// assgin script engine to scene graphs
|
// assgin script engine to scene graphs
|
||||||
model->getOrCreateUserDataContainer()->addUserObject(osgDB::readFile<osg::ScriptEngine>("ScriptEngine.lua"));
|
model->getOrCreateUserDataContainer()->addUserObject(osgDB::readFile<osg::ScriptEngine>("ScriptEngine.lua"));
|
||||||
model->getOrCreateUserDataContainer()->addUserObject(osgDB::readFile<osg::ScriptEngine>("ScriptEngine.python"));
|
model->getOrCreateUserDataContainer()->addUserObject(osgDB::readFile<osg::ScriptEngine>("ScriptEngine.python"));
|
||||||
@ -61,7 +58,6 @@ int main(int argc, char** argv)
|
|||||||
model->addUpdateCallback(new osg::ScriptCallback(itr->get()));
|
model->addUpdateCallback(new osg::ScriptCallback(itr->get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
std::string str;
|
std::string str;
|
||||||
osg::ref_ptr<osg::ScriptEngine> luaScriptEngine = osgDB::readFile<osg::ScriptEngine>("ScriptEngine.lua");
|
osg::ref_ptr<osg::ScriptEngine> luaScriptEngine = osgDB::readFile<osg::ScriptEngine>("ScriptEngine.lua");
|
||||||
if (luaScriptEngine.valid())
|
if (luaScriptEngine.valid())
|
||||||
@ -110,14 +106,14 @@ int main(int argc, char** argv)
|
|||||||
osg::ref_ptr<osgPresentation::Layer> layer = new osgPresentation::Layer;
|
osg::ref_ptr<osgPresentation::Layer> layer = new osgPresentation::Layer;
|
||||||
osg::ref_ptr<osgPresentation::Group> group = new osgPresentation::Group;
|
osg::ref_ptr<osgPresentation::Group> group = new osgPresentation::Group;
|
||||||
osg::ref_ptr<osgPresentation::Element> element = new osgPresentation::Element;
|
osg::ref_ptr<osgPresentation::Element> element = new osgPresentation::Element;
|
||||||
osg::ref_ptr<osgPresentation::Element> text = new osgPresentation::Text;
|
osg::ref_ptr<osgPresentation::Text> text = new osgPresentation::Text;
|
||||||
|
osg::ref_ptr<osgPresentation::Model> model = new osgPresentation::Model;
|
||||||
presentation->addChild(slide.get());
|
presentation->addChild(slide.get());
|
||||||
slide->addChild(layer.get());
|
slide->addChild(layer.get());
|
||||||
//layer->addChild(element.get());
|
//layer->addChild(element.get());
|
||||||
layer->addChild(group.get());
|
layer->addChild(group.get());
|
||||||
group->addChild(element.get());
|
group->addChild(element.get());
|
||||||
element->addChild(model.get());
|
group->addChild(model.get());
|
||||||
group->addChild(new osgPresentation::Model);
|
|
||||||
group->addChild(text.get());
|
group->addChild(text.get());
|
||||||
group->addChild(new osgPresentation::Audio);
|
group->addChild(new osgPresentation::Audio);
|
||||||
group->addChild(new osgPresentation::Movie);
|
group->addChild(new osgPresentation::Movie);
|
||||||
@ -129,10 +125,16 @@ int main(int argc, char** argv)
|
|||||||
text->setProperty("character_size",2.2);
|
text->setProperty("character_size",2.2);
|
||||||
text->setProperty("width",std::string("103.2"));
|
text->setProperty("width",std::string("103.2"));
|
||||||
|
|
||||||
|
model->setProperty("filename", std::string("dumptruck.osgt"));
|
||||||
|
model->setProperty("scale",2.0);
|
||||||
|
|
||||||
|
|
||||||
osgPresentation::PrintSupportedProperties psp(std::cout);
|
osgPresentation::PrintSupportedProperties psp(std::cout);
|
||||||
presentation->accept(psp);
|
presentation->accept(psp);
|
||||||
|
|
||||||
|
osgPresentation::PrintProperties pp(std::cout);
|
||||||
|
presentation->accept(pp);
|
||||||
|
|
||||||
osgPresentation::LoadAction load;
|
osgPresentation::LoadAction load;
|
||||||
presentation->accept( load );
|
presentation->accept( load );
|
||||||
|
|
||||||
|
@ -83,7 +83,16 @@ struct OSGPRESENTATION_EXPORT PlayAction : public Action
|
|||||||
void apply(osgPresentation::Element& element);
|
void apply(osgPresentation::Element& element);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PrintSupportedProperties : public osgPresentation::Action
|
struct OSGPRESENTATION_EXPORT PrintProperties : public osgPresentation::Action
|
||||||
|
{
|
||||||
|
PrintProperties(std::ostream& output) : osgPresentation::Action(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), _output(output) {}
|
||||||
|
|
||||||
|
void apply(osgPresentation::Group& group);
|
||||||
|
|
||||||
|
std::ostream& _output;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct OSGPRESENTATION_EXPORT PrintSupportedProperties : public osgPresentation::Action
|
||||||
{
|
{
|
||||||
PrintSupportedProperties(std::ostream& output) : osgPresentation::Action(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), _output(output) {}
|
PrintSupportedProperties(std::ostream& output) : osgPresentation::Action(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), _output(output) {}
|
||||||
|
|
||||||
|
@ -31,6 +31,12 @@ class OSGPRESENTATION_EXPORT Model : public osgPresentation::Element
|
|||||||
|
|
||||||
META_Presentation(Model);
|
META_Presentation(Model);
|
||||||
|
|
||||||
|
/** load the text subgraph.*/
|
||||||
|
virtual bool load();
|
||||||
|
|
||||||
|
/** Get all types of Properties supported by Presentation Object type, return true if the Properties are supported, false otherwise.*/
|
||||||
|
virtual bool getSupportedProperties(PropertyList&);
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
|
|
||||||
virtual ~Model() {}
|
virtual ~Model() {}
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#include <osgPresentation/Slide>
|
#include <osgPresentation/Slide>
|
||||||
#include <osgPresentation/Presentation>
|
#include <osgPresentation/Presentation>
|
||||||
|
|
||||||
|
#include <osg/io_utils>
|
||||||
|
|
||||||
using namespace osgPresentation;
|
using namespace osgPresentation;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -120,9 +122,62 @@ void PlayAction::apply(osgPresentation::Element& element)
|
|||||||
element.play();
|
element.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct PrintValueVisitor: public osg::ValueObject::GetValueVisitor
|
||||||
|
{
|
||||||
|
PrintValueVisitor(std::ostream& output) : _output(output) {}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void print(const T& value) { _output << value; }
|
||||||
|
|
||||||
|
virtual void apply(bool value) { print(value); }
|
||||||
|
virtual void apply(char value) { print(value); }
|
||||||
|
virtual void apply(unsigned char value) { print(value); }
|
||||||
|
virtual void apply(short value) { print(value); }
|
||||||
|
virtual void apply(unsigned short value) { print(value); }
|
||||||
|
virtual void apply(int value) { print(value); }
|
||||||
|
virtual void apply(unsigned int value) { print(value); }
|
||||||
|
virtual void apply(float value) { print(value); }
|
||||||
|
virtual void apply(double value) { print(value); }
|
||||||
|
virtual void apply(const std::string& value) { print(value); }
|
||||||
|
virtual void apply(const osg::Vec2f& value) { print(value); }
|
||||||
|
virtual void apply(const osg::Vec3f& value) { print(value); }
|
||||||
|
virtual void apply(const osg::Vec4f& value) { print(value); }
|
||||||
|
virtual void apply(const osg::Vec2d& value) { print(value); }
|
||||||
|
virtual void apply(const osg::Vec3d& value) { print(value); }
|
||||||
|
virtual void apply(const osg::Vec4d& value) { print(value); }
|
||||||
|
virtual void apply(const osg::Quat& value) { print(value); }
|
||||||
|
virtual void apply(const osg::Plane& value) { print(value); }
|
||||||
|
virtual void apply(const osg::Matrixf& value) { print(value); }
|
||||||
|
virtual void apply(const osg::Matrixd& value) { print(value); }
|
||||||
|
|
||||||
|
std::ostream& _output;
|
||||||
|
};
|
||||||
|
|
||||||
|
void PrintProperties::apply(osgPresentation::Group& group)
|
||||||
|
{
|
||||||
|
_output<<"PrintProperties osgPresentation object : "<<group.className()<<std::endl;
|
||||||
|
osg::UserDataContainer* udc = group.getUserDataContainer();
|
||||||
|
if (udc)
|
||||||
|
{
|
||||||
|
PrintValueVisitor pvv(_output);
|
||||||
|
|
||||||
|
for(unsigned i=0; i<udc->getNumUserObjects(); ++i)
|
||||||
|
{
|
||||||
|
osg::ValueObject* value_object = dynamic_cast<osg::ValueObject*>(udc->getUserObject(i));
|
||||||
|
if (value_object)
|
||||||
|
{
|
||||||
|
_output<<" "<<value_object->className()<<" : "<<value_object->getName()<<" : ";
|
||||||
|
value_object->get(pvv);
|
||||||
|
_output<<std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
traverse(group);
|
||||||
|
}
|
||||||
|
|
||||||
void PrintSupportedProperties::apply(osgPresentation::Group& group)
|
void PrintSupportedProperties::apply(osgPresentation::Group& group)
|
||||||
{
|
{
|
||||||
_output<<"osgPresentation object : "<<group.className()<<std::endl;
|
_output<<"PrintSupportedProperties osgPresentation object : "<<group.className()<<std::endl;
|
||||||
osgPresentation::PropertyList properties;
|
osgPresentation::PropertyList properties;
|
||||||
if (group.getSupportedProperties(properties))
|
if (group.getSupportedProperties(properties))
|
||||||
{
|
{
|
||||||
@ -135,5 +190,6 @@ void PrintSupportedProperties::apply(osgPresentation::Group& group)
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
traverse(group);
|
traverse(group);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ SET(TARGET_SRC
|
|||||||
Group.cpp
|
Group.cpp
|
||||||
Element.cpp
|
Element.cpp
|
||||||
Text.cpp
|
Text.cpp
|
||||||
|
Model.cpp
|
||||||
|
|
||||||
deprecated/AnimationMaterial.cpp
|
deprecated/AnimationMaterial.cpp
|
||||||
deprecated/CompileSlideCallback.cpp
|
deprecated/CompileSlideCallback.cpp
|
||||||
|
Loading…
Reference in New Issue
Block a user