root/OpenSceneGraph/trunk/src/osgPlugins/dot/SimpleDotVisitor.cpp @ 13041

Revision 13041, 3.4 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#include "SimpleDotVisitor.h"
15
16namespace osgDot {
17
18  SimpleDotVisitor::SimpleDotVisitor() {
19  }
20
21  SimpleDotVisitor::~SimpleDotVisitor() {
22  }
23
24  void SimpleDotVisitor::handle(osg::Node& node, int id) {
25    std::stringstream label;
26    label << "<top> Node";
27    if ( !node.getName().empty() ) { label << "| " << node.getName(); }
28    drawNode( id, "record", "solid", label.str(), "black", "white" );
29  }
30
31  void SimpleDotVisitor::handle(osg::Geode& node, int id) {
32    std::stringstream label;
33    label << "<top> " << node.className();
34    if ( !node.getName().empty() ) { label << "| " << node.getName(); }
35    drawNode( id, "record", "solid", label.str(), "brown", "white" );
36  }
37
38  void SimpleDotVisitor::handle(osg::Group& node, int id) {
39    std::stringstream label;
40    label << "<top> " << node.className();
41    if ( !node.getName().empty() ) { label << "| " << node.getName(); }
42    drawNode( id, "record", "solid", label.str(), "black", "white" );
43  }
44
45  void SimpleDotVisitor::handle(osg::Group& parent, osg::Node& child, int parentID, int childID ) {
46    drawEdge( parentID, childID, "setlinewidth(2)" );
47  }
48
49  void SimpleDotVisitor::handle(osg::StateSet& stateset, int id) {
50    std::stringstream label;
51    label << "<top> " << stateset.className();
52    if ( !stateset.getName().empty() ) { label << "| " << stateset.getName(); }
53    drawNode( id, "Mrecord", "solid", label.str(), "green", "white" );
54  }
55
56  void SimpleDotVisitor::handle(osg::Node& node, osg::StateSet& stateset, int parentID, int childID ) {
57    drawEdge( parentID, childID, "dashed" );
58  }
59
60  void SimpleDotVisitor::handle(osg::Drawable& drawable, int id) {
61    std::stringstream label;
62    label << "<top> " << drawable.className();
63    if ( !drawable.getName().empty() ) { label << "| " << drawable.getName(); }
64    drawNode( id, "record", "solid", label.str(), "blue", "white" );
65  }
66
67  void SimpleDotVisitor::handle(osg::Geode& geode, osg::Drawable& drawable, int parentID, int childID ) {
68    drawEdge( parentID, childID, "dashed" );
69  }
70
71  void SimpleDotVisitor::handle(osg::Drawable& drawable, osg::StateSet& stateset, int parentID, int childID ) {
72    drawEdge( parentID, childID, "dashed" );
73  }
74
75  void SimpleDotVisitor::drawNode( int id, const std::string& shape, const std::string& style, const std::string& label, const std::string& color, const std::string& fillColor ) {
76    _nodes << id <<
77      "[shape=\"" << shape <<
78      "\" ,label=\"" << label <<
79      "\" ,style=\"" << style <<
80      "\" ,color=\"" << color <<
81      "\" ,fillColor=\"" << fillColor <<
82      "\"]" << std::endl;
83  }
84
85  void SimpleDotVisitor::drawEdge( int sourceId, int sinkId, const std::string& style ) {
86    _edges
87      << sourceId << ":top -> "
88      << sinkId   << ":top [style=\""
89      << style    << "\"];"
90      << std::endl;
91  }
92
93} // namespace osgDot
Note: See TracBrowser for help on using the browser.