Main Page ? Class Hierarchy ? Compound List ? File List ? Compound Members ? File Members ?

dot.cxx

Go to the documentation of this file.
00001 
00002 #include "dot.h"
00003 
00004 void DotGenerator::run (tree_node& top_node, 
00005                         const cmt_string& direction,
00006                         bool collapsed,
00007                         const cmt_string& tags)
00008 {
00009   int i;
00010 
00012   top_node.reduce ();
00013 
00014   cmt_string cmt_version;
00015   CmtSystem::get_cmt_version (cmt_version);
00016   Package& cmt_package = Package::create ("CMT", cmt_version, "");
00017 
00018   cmt_string output;
00019 
00021   output += "digraph GC {\n";
00022     //output += "  rankdir=TB;\n";
00023   output += "  rankdir=LR;\n";
00024   output += "  node [shape=box];\n";
00025   output += "  \n";
00026 
00028   Package::database db = Package::get_database ();
00029   for (i = 0; i < db.size (); i++)
00030     {
00031       Package& p = db[i];
00032 
00033       cmt_string cluster = p.get_cluster_name ();
00034 
00035       if (cluster == "") cluster = "top";
00036 
00037       if (collapsed)
00038         {
00039           if (cluster != "")
00040             {
00041               output += "  ";
00042               output += cluster;
00043               output += " [label = \"";
00044               output += cluster;
00045               if (tags != "")
00046                 {
00047                   output += "(";
00048                   output += tags;
00049                   output += ")";
00050                 }
00051               output += "\"];\n";
00052             }
00053           else
00054             {
00055               if (i == 0)
00056                 {
00058                   output += "  ";
00059                   output += p.get_dot_name ();
00060                   output += " [label = \"";
00061                   output += p.get_dot_label ();
00062                   output += "\" color=blue ];\n";
00063                 }
00064               else if (p != cmt_package)
00065                 {
00066                   if (!p.is_done ()) continue;
00067                   output += "  ";
00068                   output += p.get_dot_name ();
00069                   output += " [label = \"";
00070                   output += p.get_dot_label ();
00071                   output += "\"];\n";
00072                 }
00073             }
00074         }
00075       else
00076         {
00077           if (cluster != "")
00078             {
00079               output += "  subgraph cluster";
00080               output += cluster;
00081               output += " {\n";
00082               output += "  label=\"";
00083               output += cluster;
00084               if (tags != "")
00085                 {
00086                   output += "(";
00087                   output += tags;
00088                   output += ")";
00089                 }
00090               output += "\";\n";
00091             }
00092 
00093             //if ((p == cmt_package) || p.is_done ()) 
00094           if (p == cmt_package)
00095             {
00096               if (cluster != "")
00097                 {
00098                   output += "  }\n";
00099                 }
00100               continue;
00101             }
00102 
00103           output += "  ";
00104           output += p.get_dot_name ();
00105           output += " [shape=record label = \"";
00106 
00107           output += p.get_dot_label ();
00108 
00109           cmt_string modifiers;
00110           bool has_modifiers = false;
00111 
00112           modifiers += "|{";
00113           if (!p.is_public ()) 
00114             {
00115               modifiers += "Pr";
00116               has_modifiers = true;
00117             }
00118           modifiers += "|";
00119           if (!p.auto_imports ()) 
00120             {
00121               modifiers += "noAI";
00122               has_modifiers = true;
00123             }
00124           modifiers += "|";
00125           if (!p.has_version_directory ()) 
00126             {
00127               modifiers += "NoVe";
00128               has_modifiers = true;
00129             }
00130           modifiers += "}";
00131 
00132           if (has_modifiers) output += modifiers;
00133 
00134           output += "\"";
00135 
00136           if (i == 0)
00137             {
00139               output += " color=blue";
00140             }
00141 
00142           output += " ];\n";
00143           
00144           if (cluster != "")
00145             {
00146               output += "  }\n";
00147             }
00148         }
00149 
00150     }
00151   output += "  \n";
00152   
00154 
00155   int links = top_node.show_tree (output, direction, collapsed);
00156 
00157   if (links == 0)
00158     {
00166       output += "  ";
00167       output += cmt_package.get_dot_name ();
00168       output += " [label = \"";
00169       output += cmt_package.get_dot_label ();
00170       output += "\"];\n";
00171 
00172       for (i = 0; i < db.size (); i++)
00173         {
00174           const Package& p = db[i];
00175           if (p == cmt_package) continue;
00176           if (!p.is_unreachable ())
00177             {
00178               output += "  ";
00179               output += p.get_dot_name ();
00180               output += " -> ";
00181               output += cmt_package.get_dot_name ();
00182               output += ";\n";
00183               links++;
00184             }
00185         }
00186     }
00187   
00188   if (links == 0)
00189     {
00194       output += "  ";
00195       output += cmt_package.get_dot_name ();
00196       output += " -> ";
00197       output += cmt_package.get_dot_name ();
00198       output += ";\n";
00199     }
00200   
00201   output += "}\n";
00202 
00209   cmt_string file_name = top_node.get_name ();
00210 
00211   file_name += ".dot";
00212 
00213   output.write (file_name);
00214 
00215   cmt_string command;
00216 
00217   command = "dot -Tgif ";
00218   //command = "\"C:\\Program files\\graphviz\\bin\\dot\" -Tgif ";
00219   command += file_name;
00220   command += " -o ";
00221   command += top_node.get_name ();
00222   command += ".gif";
00223 
00224     //cout << command << endl;
00225 
00226   CmtSystem::execute (command);
00227 }
00228 

Generated at Fri Apr 12 16:18:12 2002 for cmtgrapher by 1.2.3 written by , ??1997-2000