Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
DotGfxHierarchyTable Class Reference

#include <dot.h>

Public Member Functions

 DotGfxHierarchyTable ()
 
 ~DotGfxHierarchyTable ()
 
void writeGraph (FTextStream &t, const char *path, const char *fileName) const
 
void createGraph (DotNode *rootNode, FTextStream &t, const char *path, const char *fileName, int id) const
 
const DotNodeListsubGraphs () const
 

Private Member Functions

void addHierarchy (DotNode *n, ClassDef *cd, bool hide)
 
void addClassList (ClassSDict *cl)
 

Private Attributes

QList< DotNode > * m_rootNodes
 
QDict< DotNode > * m_usedNodes
 
DotNodeListm_rootSubgraphs
 

Static Private Attributes

static int m_curNodeNumber
 

Detailed Description

Represents a graphical class hierarchy

Definition at line 148 of file dot.h.

Constructor & Destructor Documentation

DotGfxHierarchyTable::DotGfxHierarchyTable ( )

Definition at line 2515 of file dot.cpp.

2516 {
2517  m_curNodeNumber=0;
2519  m_usedNodes = new QDict<DotNode>(1009);
2520  m_usedNodes->setAutoDelete(TRUE);
2522 
2523  // build a graph with each class as a node and the inheritance relations
2524  // as edges
2529  // m_usedNodes now contains all nodes in the graph
2530 
2531  // color the graph into a set of independent subgraphs
2532  bool done=FALSE;
2533  int curColor=0;
2535  while (!done) // there are still nodes to color
2536  {
2537  DotNode *n;
2538  done=TRUE; // we are done unless there are still uncolored nodes
2539  for (dnli.toLast();(n=dnli.current());--dnli)
2540  {
2541  if (n->m_subgraphId==-1) // not yet colored
2542  {
2543  //printf("Starting at node %s (%p): %d\n",n->m_label.data(),n,curColor);
2544  done=FALSE; // still uncolored nodes
2545  n->m_subgraphId=curColor;
2546  n->markAsVisible();
2547  n->colorConnectedNodes(curColor);
2548  curColor++;
2549  const DotNode *dn=n->findDocNode();
2550  if (dn!=0)
2551  m_rootSubgraphs->inSort(dn);
2552  else
2553  m_rootSubgraphs->inSort(n);
2554  }
2555  }
2556  }
2557 
2558  //printf("Number of independent subgraphs: %d\n",curColor);
2559  //QListIterator<DotNode> dnli2(*m_rootSubgraphs);
2560  //DotNode *n;
2561  //for (dnli2.toFirst();(n=dnli2.current());++dnli2)
2562  //{
2563  // printf("Node %s color=%d (c=%d,p=%d)\n",
2564  // n->m_label.data(),n->m_subgraphId,
2565  // n->m_children?n->m_children->count():0,
2566  // n->m_parents?n->m_parents->count():0);
2567  //}
2568 }
static ClassSDict * hiddenClasses
Definition: doxygen.h:100
DotNodeList * m_rootSubgraphs
Definition: dot.h:164
Definition: dot.h:60
const DotNode * findDocNode() const
Definition: dot.cpp:2232
const bool FALSE
Definition: qglobal.h:370
QDict< DotNode > * m_usedNodes
Definition: dot.h:162
static int m_curNodeNumber
Definition: dot.h:163
QList< DotNode > * m_rootNodes
Definition: dot.h:161
void inSort(const type *d)
Definition: qlist.h:71
std::void_t< T > n
void addClassList(ClassSDict *cl)
Definition: dot.cpp:2470
void initClassHierarchy(ClassSDict *cl)
Definition: util.cpp:5211
int m_subgraphId
Definition: dot.h:82
void colorConnectedNodes(int curColor)
Definition: dot.cpp:2197
void markAsVisible(bool b=TRUE)
Definition: dot.h:101
static ClassSDict * classSDict
Definition: doxygen.h:99
const bool TRUE
Definition: qglobal.h:371
DotGfxHierarchyTable::~DotGfxHierarchyTable ( )

Definition at line 2570 of file dot.cpp.

2571 {
2572  //printf("DotGfxHierarchyTable::~DotGfxHierarchyTable\n");
2573 
2574  //QDictIterator<DotNode> di(*m_usedNodes);
2575  //DotNode *n;
2576  //for (;(n=di.current());++di)
2577  //{
2578  // printf("Node %p: %s\n",n,n->label().data());
2579  //}
2580 
2581  delete m_rootNodes;
2582  delete m_usedNodes;
2583  delete m_rootSubgraphs;
2584 }
DotNodeList * m_rootSubgraphs
Definition: dot.h:164
QDict< DotNode > * m_usedNodes
Definition: dot.h:162
QList< DotNode > * m_rootNodes
Definition: dot.h:161

Member Function Documentation

void DotGfxHierarchyTable::addClassList ( ClassSDict cl)
private

Definition at line 2470 of file dot.cpp.

2471 {
2473  ClassDef *cd;
2474  for (cli.toLast();(cd=cli.current());--cli)
2475  {
2476  //printf("Trying %s subClasses=%d\n",cd->name().data(),cd->subClasses()->count());
2477  if (cd->getLanguage()==SrcLangExt_VHDL &&
2479  )
2480  {
2481  continue;
2482  }
2483  if (!hasVisibleRoot(cd->baseClasses()) &&
2484  cd->isVisibleInHierarchy()
2485  ) // root node in the forest
2486  {
2487  QCString tmp_url="";
2488  if (cd->isLinkable() && !cd->isHidden())
2489  {
2490  tmp_url=cd->getReference()+"$"+cd->getOutputFileBase();
2491  if (!cd->anchor().isEmpty())
2492  {
2493  tmp_url+="#"+cd->anchor();
2494  }
2495  }
2496  //printf("Inserting root class %s\n",cd->name().data());
2497  QCString tooltip = cd->briefDescriptionAsTooltip();
2498  DotNode *n = new DotNode(m_curNodeNumber++,
2499  cd->displayName(),
2500  tooltip,
2501  tmp_url.data());
2502 
2503  //m_usedNodes->clear();
2504  m_usedNodes->insert(cd->name(),n);
2505  m_rootNodes->insert(0,n);
2506  if (!cd->visited && cd->subClasses())
2507  {
2508  addHierarchy(n,cd,cd->visited);
2509  cd->visited=TRUE;
2510  }
2511  }
2512  }
2513 }
BaseClassList * subClasses() const
Definition: classdef.cpp:4404
bool isEmpty() const
Definition: qcstring.h:189
Definition: dot.h:60
QDict< DotNode > * m_usedNodes
Definition: dot.h:162
QCString displayName(bool includeScope=TRUE) const
Definition: classdef.cpp:312
QCString getReference() const
Definition: classdef.cpp:3814
static int m_curNodeNumber
Definition: dot.h:163
Protection protection() const
Definition: classdef.cpp:4414
bool insert(uint i, const type *d)
Definition: qlist.h:70
def cli(ctx)
Definition: main.py:7
const QCString & name() const
Definition: definition.h:114
QList< DotNode > * m_rootNodes
Definition: dot.h:161
SrcLangExt getLanguage() const
std::void_t< T > n
void addHierarchy(DotNode *n, ClassDef *cd, bool hide)
Definition: dot.cpp:2396
QCString anchor() const
Definition: classdef.cpp:4606
const char * data() const
Definition: qcstring.h:207
bool isLinkable() const
Definition: classdef.cpp:2729
bool visited
Definition: classdef.h:402
QCString getOutputFileBase() const
Definition: classdef.cpp:3533
bool isHidden() const
bool isVisibleInHierarchy()
Definition: classdef.cpp:2743
bool hasVisibleRoot(BaseClassList *bcl)
Definition: util.cpp:5224
friend class Iterator
Definition: sortdict.h:289
QCString briefDescriptionAsTooltip() const
const bool TRUE
Definition: qglobal.h:371
BaseClassList * baseClasses() const
Definition: classdef.cpp:4399
void DotGfxHierarchyTable::addHierarchy ( DotNode n,
ClassDef cd,
bool  hide 
)
private

Definition at line 2396 of file dot.cpp.

2397 {
2398  //printf("addHierarchy `%s' baseClasses=%d\n",cd->name().data(),cd->baseClasses()->count());
2399  if (cd->subClasses())
2400  {
2401  BaseClassListIterator bcli(*cd->subClasses());
2402  BaseClassDef *bcd;
2403  for ( ; (bcd=bcli.current()) ; ++bcli )
2404  {
2405  ClassDef *bClass=bcd->classDef;
2406  //printf(" Trying sub class=`%s' usedNodes=%d\n",bClass->name().data(),m_usedNodes->count());
2407  if (bClass->isVisibleInHierarchy() && hasVisibleRoot(bClass->baseClasses()))
2408  {
2409  DotNode *bn;
2410  //printf(" Node `%s' Found visible class=`%s'\n",n->m_label.data(),
2411  // bClass->name().data());
2412  if ((bn=m_usedNodes->find(bClass->name()))) // node already present
2413  {
2414  if (n->m_children==0 || n->m_children->findRef(bn)==-1) // no arrow yet
2415  {
2416  n->addChild(bn,bcd->prot);
2417  bn->addParent(n);
2418  //printf(" Adding node %s to existing base node %s (c=%d,p=%d)\n",
2419  // n->m_label.data(),
2420  // bn->m_label.data(),
2421  // bn->m_children ? bn->m_children->count() : 0,
2422  // bn->m_parents ? bn->m_parents->count() : 0
2423  // );
2424  }
2425  //else
2426  //{
2427  // printf(" Class already has an arrow!\n");
2428  //}
2429  }
2430  else
2431  {
2432  QCString tmp_url="";
2433  if (bClass->isLinkable() && !bClass->isHidden())
2434  {
2435  tmp_url=bClass->getReference()+"$"+bClass->getOutputFileBase();
2436  if (!bClass->anchor().isEmpty())
2437  {
2438  tmp_url+="#"+bClass->anchor();
2439  }
2440  }
2441  QCString tooltip = bClass->briefDescriptionAsTooltip();
2442  bn = new DotNode(m_curNodeNumber++,
2443  bClass->displayName(),
2444  tooltip,
2445  tmp_url.data()
2446  );
2447  n->addChild(bn,bcd->prot);
2448  bn->addParent(n);
2449  //printf(" Adding node %s to new base node %s (c=%d,p=%d)\n",
2450  // n->m_label.data(),
2451  // bn->m_label.data(),
2452  // bn->m_children ? bn->m_children->count() : 0,
2453  // bn->m_parents ? bn->m_parents->count() : 0
2454  // );
2455  //printf(" inserting %s (%p)\n",bClass->name().data(),bn);
2456  m_usedNodes->insert(bClass->name(),bn); // add node to the used list
2457  }
2458  if (!bClass->visited && !hideSuper && bClass->subClasses())
2459  {
2460  bool wasVisited=bClass->visited;
2461  bClass->visited=TRUE;
2462  addHierarchy(bn,bClass,wasVisited);
2463  }
2464  }
2465  }
2466  }
2467  //printf("end addHierarchy\n");
2468 }
void addParent(DotNode *n)
Definition: dot.cpp:1507
BaseClassList * subClasses() const
Definition: classdef.cpp:4404
bool isEmpty() const
Definition: qcstring.h:189
int findRef(const type *d) const
Definition: qlist.h:89
Definition: dot.h:60
QDict< DotNode > * m_usedNodes
Definition: dot.h:162
QCString displayName(bool includeScope=TRUE) const
Definition: classdef.cpp:312
void addChild(DotNode *n, int edgeColor=EdgeInfo::Purple, int edgeStyle=EdgeInfo::Solid, const char *edgeLab=0, const char *edgeURL=0, int edgeLabCol=-1)
Definition: dot.cpp:1480
QCString getReference() const
Definition: classdef.cpp:3814
static int m_curNodeNumber
Definition: dot.h:163
const QCString & name() const
Definition: definition.h:114
void addHierarchy(DotNode *n, ClassDef *cd, bool hide)
Definition: dot.cpp:2396
QList< DotNode > * m_children
list of child nodes (outgoing arrows)
Definition: dot.h:108
QCString anchor() const
Definition: classdef.cpp:4606
const char * data() const
Definition: qcstring.h:207
bool isLinkable() const
Definition: classdef.cpp:2729
bool visited
Definition: classdef.h:402
QCString getOutputFileBase() const
Definition: classdef.cpp:3533
bool isHidden() const
bool isVisibleInHierarchy()
Definition: classdef.cpp:2743
bool hasVisibleRoot(BaseClassList *bcl)
Definition: util.cpp:5224
QCString briefDescriptionAsTooltip() const
const bool TRUE
Definition: qglobal.h:371
BaseClassList * baseClasses() const
Definition: classdef.cpp:4399
void DotGfxHierarchyTable::createGraph ( DotNode rootNode,
FTextStream t,
const char *  path,
const char *  fileName,
int  id 
) const

Definition at line 2271 of file dot.cpp.

2273 {
2274  QDir d(path);
2276  QCString imgExt = getDotImageExtension();
2277  QCString imgFmt = Config_getEnum("DOT_IMAGE_FORMAT");
2278  baseName.sprintf("inherit_graph_%d",id);
2279  QCString imgName = baseName+"."+ imgExt;
2280  QCString mapName = baseName+".map";
2281  QCString absImgName = QCString(d.absPath().data())+"/"+imgName;
2282  QCString absMapName = QCString(d.absPath().data())+"/"+mapName;
2283  QCString absBaseName = QCString(d.absPath().data())+"/"+baseName;
2285  DotNode *node;
2286 
2287  // compute md5 checksum of the graph were are about to generate
2288  QGString theGraph;
2289  FTextStream md5stream(&theGraph);
2291  md5stream << " rankdir=\"LR\";" << endl;
2292  for (dnli2.toFirst();(node=dnli2.current());++dnli2)
2293  {
2294  if (node->m_subgraphId==n->m_subgraphId)
2295  {
2296  node->clearWriteFlag();
2297  }
2298  }
2299  for (dnli2.toFirst();(node=dnli2.current());++dnli2)
2300  {
2301  if (node->m_subgraphId==n->m_subgraphId)
2302  {
2304  }
2305  }
2306  writeGraphFooter(md5stream);
2307  resetReNumbering();
2308  uchar md5_sig[16];
2309  QCString sigStr(33);
2310  MD5Buffer((const unsigned char *)theGraph.data(),theGraph.length(),md5_sig);
2311  MD5SigToString(md5_sig,sigStr.rawData(),33);
2312  bool regenerate=FALSE;
2313  if (checkAndUpdateMd5Signature(absBaseName,sigStr) ||
2314  !checkDeliverables(absImgName,absMapName))
2315  {
2316  regenerate=TRUE;
2317  // image was new or has changed
2318  QCString dotName=absBaseName+".dot";
2319  QFile f(dotName);
2320  if (!f.open(IO_WriteOnly)) return;
2321  FTextStream t(&f);
2322  t << theGraph;
2323  f.close();
2324  resetReNumbering();
2325 
2326  DotRunner *dotRun = new DotRunner(dotName,d.absPath().data(),TRUE,absImgName);
2327  dotRun->addJob(imgFmt,absImgName);
2328  dotRun->addJob(MAP_CMD,absMapName);
2329  DotManager::instance()->addRun(dotRun);
2330  }
2331  else
2332  {
2333  removeDotGraph(absBaseName+".dot");
2334  }
2335  Doxygen::indexList->addImageFile(imgName);
2336  // write image and map in a table row
2337  QCString mapLabel = escapeCharsInString(n->m_label,FALSE);
2338  if (imgExt=="svg") // vector graphics
2339  {
2340  if (regenerate || !writeSVGFigureLink(out,QCString(),baseName,absImgName))
2341  {
2342  if (regenerate)
2343  {
2345  FALSE,QCString(),FALSE,0);
2346  }
2347  int mapId = DotManager::instance()->addSVGObject(fileName,baseName,
2348  absImgName,QCString());
2349  out << "<!-- SVG " << mapId << " -->" << endl;
2350  }
2351  }
2352  else // normal bitmap
2353  {
2354  out << "<img src=\"" << imgName << "\" border=\"0\" alt=\"\" usemap=\"#"
2355  << mapLabel << "\"/>" << endl;
2356 
2357  if (regenerate || !insertMapFile(out,absMapName,QCString(),mapLabel))
2358  {
2359  int mapId = DotManager::instance()->addMap(fileName,absMapName,QCString(),
2360  FALSE,QCString(),mapLabel);
2361  out << "<!-- MAP " << mapId << " -->" << endl;
2362  }
2363  }
2364 }
Traverses directory structures and contents in a platform-independent way.
Definition: qdir.h:52
static void resetReNumbering()
Definition: dot.cpp:436
int addSVGConversion(const QCString &file, const QCString &relPath, bool urlOnly, const QCString &context, bool zoomable, int graphId)
Definition: dot.cpp:1292
char * data() const
Definition: qgstring.h:42
void clearWriteFlag()
Definition: dot.cpp:2168
QCString escapeCharsInString(const char *name, bool allowDots, bool allowUnderscore)
Definition: util.cpp:5242
static bool insertMapFile(FTextStream &out, const QCString &mapFile, const QCString &relPath, const QCString &mapLabel)
Definition: dot.cpp:694
static bool checkAndUpdateMd5Signature(const QCString &baseName, const QCString &md5)
Definition: dot.cpp:731
Definition: dot.h:356
uint length() const
Definition: qgstring.h:40
void write(FTextStream &t, GraphType gt, GraphOutputFormat f, bool topDown, bool toChildren, bool backArrows, bool reNumber)
Definition: dot.cpp:1906
static bool checkDeliverables(const QCString &file1, const QCString &file2=QCString())
Definition: dot.cpp:758
#define IO_WriteOnly
Definition: qiodevice.h:62
Definition: dot.h:60
static DotManager * instance()
Definition: dot.cpp:1221
const bool FALSE
Definition: qglobal.h:370
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
int addMap(const QCString &file, const QCString &mapFile, const QCString &relPath, bool urlOnly, const QCString &context, const QCString &label)
Definition: dot.cpp:1267
unsigned char uchar
Definition: nybbler.cc:11
static void writeGraphHeader(FTextStream &t, const QCString &title=QCString())
Definition: dot.cpp:251
#define Config_getEnum(val)
Definition: config.cpp:663
static void removeDotGraph(const QCString &dotName)
Definition: dot.cpp:714
virtual QCString trGraphicalHierarchy()=0
QList< DotNode > * m_rootNodes
Definition: dot.h:161
fileName
Definition: dumpTree.py:9
void MD5Buffer(const unsigned char *buf, unsigned int len, unsigned char sig[16])
Definition: md5.c:275
std::void_t< T > n
void addImageFile(const char *name)
Definition: index.h:147
QCString getDotImageExtension(void)
Definition: util.cpp:8562
#define MAP_CMD
Definition: dot.cpp:51
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
int addSVGObject(const QCString &file, const QCString &baseName, const QCString &figureNAme, const QCString &relPath)
Definition: dot.cpp:1305
QCString & sprintf(const char *format,...)
Definition: qcstring.cpp:27
static void writeGraphFooter(FTextStream &t)
Definition: dot.cpp:281
void addJob(const char *format, const char *output)
Definition: dot.cpp:807
void MD5SigToString(unsigned char signature[16], char *str, int len)
Definition: md5.c:285
static bool writeSVGFigureLink(FTextStream &out, const QCString &relPath, const QCString &baseName, const QCString &absImgName)
Definition: dot.cpp:618
int m_subgraphId
Definition: dot.h:82
Translator * theTranslator
Definition: language.cpp:157
static QCString baseName
Definition: scanner.cpp:10890
Definition: dot.h:42
void addRun(DotRunner *run)
Definition: dot.cpp:1262
const bool TRUE
Definition: qglobal.h:371
static IndexList * indexList
Definition: doxygen.h:149
QTextStream & endl(QTextStream &s)
const DotNodeList* DotGfxHierarchyTable::subGraphs ( ) const
inline

Definition at line 155 of file dot.h.

155 { return m_rootSubgraphs; }
DotNodeList * m_rootSubgraphs
Definition: dot.h:164
void DotGfxHierarchyTable::writeGraph ( FTextStream t,
const char *  path,
const char *  fileName 
) const

Definition at line 2366 of file dot.cpp.

2368 {
2369  //printf("DotGfxHierarchyTable::writeGraph(%s)\n",name);
2370  //printf("m_rootNodes=%p count=%d\n",m_rootNodes,m_rootNodes->count());
2371 
2372  if (m_rootSubgraphs->count()==0) return;
2373 
2374  QDir d(path);
2375  // store the original directory
2376  if (!d.exists())
2377  {
2378  err("Output dir %s does not exist!\n",path); exit(1);
2379  }
2380 
2381  // put each connected subgraph of the hierarchy in a row of the HTML output
2382  out << "<table border=\"0\" cellspacing=\"10\" cellpadding=\"0\">" << endl;
2383 
2385  DotNode *n;
2386  int count=0;
2387  for (dnli.toFirst();(n=dnli.current());++dnli)
2388  {
2389  out << "<tr><td>";
2390  createGraph(n,out,path,fileName,count++);
2391  out << "</td></tr>" << endl;
2392  }
2393  out << "</table>" << endl;
2394 }
Traverses directory structures and contents in a platform-independent way.
Definition: qdir.h:52
DotNodeList * m_rootSubgraphs
Definition: dot.h:164
Definition: dot.h:60
uint count() const
Definition: qlist.h:66
fileName
Definition: dumpTree.py:9
std::void_t< T > n
void err(const char *fmt,...)
Definition: message.cpp:226
void createGraph(DotNode *rootNode, FTextStream &t, const char *path, const char *fileName, int id) const
Definition: dot.cpp:2271
QTextStream & endl(QTextStream &s)

Member Data Documentation

int DotGfxHierarchyTable::m_curNodeNumber
staticprivate

Definition at line 163 of file dot.h.

QList<DotNode>* DotGfxHierarchyTable::m_rootNodes
private

Definition at line 161 of file dot.h.

DotNodeList* DotGfxHierarchyTable::m_rootSubgraphs
private

Definition at line 164 of file dot.h.

QDict<DotNode>* DotGfxHierarchyTable::m_usedNodes
private

Definition at line 162 of file dot.h.


The documentation for this class was generated from the following files: