Skip to content

Commit

Permalink
Added PrintPropertiesAction to osgPresentation
Browse files Browse the repository at this point in the history
  • Loading branch information
robertosfield committed Sep 4, 2013
1 parent 28155c6 commit 8dca893
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
29 changes: 1 addition & 28 deletions examples/osgpresentation/osgpresentation.cpp
Expand Up @@ -27,33 +27,6 @@
#include <osgGA/TrackballManipulator>
#include <osgViewer/Viewer>

#include <osg/NodeVisitor>

class PrintSupportedProperties : public osgPresentation::Action
{
public:
PrintSupportedProperties() :
osgPresentation::Action(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}

void apply(osgPresentation::Group& group)
{
OSG_NOTICE<<"osgPresentation object : "<<group.className()<<std::endl;
osgPresentation::PropertyList properties;
if (group.getSupportedProperties(properties))
{
for(osgPresentation::PropertyList::iterator itr = properties.begin();
itr != properties.end();
++itr)
{
osgPresentation::ObjectDescription& od = *itr;
OSG_NOTICE<<" "<<od.first->className()<<" : "<<od.first->getName()<<", description = "<<od.second<<std::endl;

}
}
traverse(group);
}
};


int main(int argc, char** argv)
{
Expand Down Expand Up @@ -157,7 +130,7 @@ int main(int argc, char** argv)
text->setProperty("width",std::string("103.2"));


PrintSupportedProperties psp;
osgPresentation::PrintSupportedProperties psp(std::cout);
presentation->accept(psp);

osgPresentation::LoadAction load;
Expand Down
10 changes: 10 additions & 0 deletions include/osgPresentation/Action
Expand Up @@ -83,6 +83,16 @@ struct OSGPRESENTATION_EXPORT PlayAction : public Action
void apply(osgPresentation::Element& element);
};

struct PrintSupportedProperties : public osgPresentation::Action
{
PrintSupportedProperties(std::ostream& output) : osgPresentation::Action(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), _output(output) {}

void apply(osgPresentation::Group& group);

std::ostream& _output;
};


}

#endif
19 changes: 19 additions & 0 deletions src/osgPresentation/Action.cpp
Expand Up @@ -34,6 +34,7 @@ using namespace osgPresentation;
void Action::apply(osgPresentation::Group& group)
{
OSG_NOTICE<<"LoadAction::apply()"<<std::endl;

osg::NodeVisitor::apply(group);
}

Expand Down Expand Up @@ -118,3 +119,21 @@ void PlayAction::apply(osgPresentation::Element& element)
{
element.play();
}

void PrintSupportedProperties::apply(osgPresentation::Group& group)
{
_output<<"osgPresentation object : "<<group.className()<<std::endl;
osgPresentation::PropertyList properties;
if (group.getSupportedProperties(properties))
{
for(osgPresentation::PropertyList::iterator itr = properties.begin();
itr != properties.end();
++itr)
{
osgPresentation::ObjectDescription& od = *itr;
_output<<" "<<od.first->className()<<" : "<<od.first->getName()<<", description = "<<od.second<<std::endl;

}
}
traverse(group);
}

0 comments on commit 8dca893

Please sign in to comment.