| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | #pragma once |
|---|
| 14 | #ifndef __DOTBASEVISITOR_H__ |
|---|
| 15 | #define __DOTBASEVISITOR_H__ |
|---|
| 16 | |
|---|
| 17 | #ifndef __cplusplus |
|---|
| 18 | #error "this is a c++ - header!" |
|---|
| 19 | #endif |
|---|
| 20 | |
|---|
| 21 | #include <sstream> |
|---|
| 22 | |
|---|
| 23 | #include <osg/NodeVisitor> |
|---|
| 24 | #include <osg/Drawable> |
|---|
| 25 | #include <osg/Group> |
|---|
| 26 | #include <osg/Geode> |
|---|
| 27 | #include <osg/ref_ptr> |
|---|
| 28 | |
|---|
| 29 | #include <osgDB/Options> |
|---|
| 30 | |
|---|
| 31 | namespace osgDot { |
|---|
| 32 | |
|---|
| 33 | class BaseDotVisitor : public osg::NodeVisitor { |
|---|
| 34 | public: |
|---|
| 35 | typedef std::map< osg::Object*, int > ObjectMap; |
|---|
| 36 | |
|---|
| 37 | public: |
|---|
| 38 | BaseDotVisitor(); |
|---|
| 39 | |
|---|
| 40 | virtual ~BaseDotVisitor(); |
|---|
| 41 | |
|---|
| 42 | void setOptions(const osgDB::Options* options); |
|---|
| 43 | |
|---|
| 44 | bool run( osg::Node& root, std::ostream* ostream ); |
|---|
| 45 | |
|---|
| 46 | virtual void apply(osg::Node& node); |
|---|
| 47 | |
|---|
| 48 | virtual void apply(osg::Geode& node); |
|---|
| 49 | |
|---|
| 50 | virtual void apply(osg::Group& node); |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | protected: |
|---|
| 54 | |
|---|
| 55 | void handleNodeAndTraverse(osg::Node& node, int id); |
|---|
| 56 | |
|---|
| 57 | virtual void handle(osg::Node& node, int id); |
|---|
| 58 | virtual void handle(osg::Geode& node, int id); |
|---|
| 59 | virtual void handle(osg::Group& node, int id); |
|---|
| 60 | virtual void handle(osg::StateSet& stateset, int id); |
|---|
| 61 | virtual void handle(osg::Drawable& drawable, int id); |
|---|
| 62 | |
|---|
| 63 | virtual void handle(osg::Node& node, osg::StateSet& stateset, int parentID, int childID); |
|---|
| 64 | virtual void handle(osg::Group& parent, osg::Node& child, int parentID, int childID); |
|---|
| 65 | virtual void handle(osg::Geode& geode, osg::Drawable& drawable, int parentID, int childID); |
|---|
| 66 | virtual void handle(osg::Drawable& drawable, osg::StateSet& stateset, int parentID, int childID ); |
|---|
| 67 | |
|---|
| 68 | osg::ref_ptr<osgDB::Options> _options; |
|---|
| 69 | |
|---|
| 70 | std::string _rankdir; |
|---|
| 71 | |
|---|
| 72 | std::stringstream _nodes; |
|---|
| 73 | std::stringstream _edges; |
|---|
| 74 | |
|---|
| 75 | private: |
|---|
| 76 | bool getOrCreateId( osg::Object* object, int& id ); |
|---|
| 77 | |
|---|
| 78 | ObjectMap _objectMap; |
|---|
| 79 | |
|---|
| 80 | }; |
|---|
| 81 | |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | #endif // __DOTBASEVISITOR_H__ |
|---|