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

#include <dot.h>

Public Member Functions

 DotInclDepGraph (FileDef *fd, bool inverse)
 
 ~DotInclDepGraph ()
 
QCString writeGraph (FTextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const char *path, const char *fileName, const char *relPath, bool writeImageMap=TRUE, int graphId=-1) const
 
bool isTrivial () const
 
bool isTooBig () const
 
QCString diskName () const
 
void writeXML (FTextStream &t)
 
void writeDocbook (FTextStream &t)
 

Private Member Functions

void buildGraph (DotNode *n, FileDef *fd, int distance)
 
void determineVisibleNodes (QList< DotNode > &queue, int &maxNodes)
 
void determineTruncatedNodes (QList< DotNode > &queue)
 

Private Attributes

DotNodem_startNode
 
QDict< DotNode > * m_usedNodes
 
QCString m_diskName
 
bool m_inverse
 

Static Private Attributes

static int m_curNodeNumber = 0
 

Detailed Description

Representation of an include dependency graph

Definition at line 201 of file dot.h.

Constructor & Destructor Documentation

DotInclDepGraph::DotInclDepGraph ( FileDef fd,
bool  inverse 
)

Definition at line 3458 of file dot.cpp.

3459 {
3460  m_inverse = inverse;
3461  ASSERT(fd!=0);
3462  m_diskName = fd->getFileBase().copy();
3463  QCString tmp_url=fd->getReference()+"$"+fd->getFileBase();
3465  fd->docName(),
3466  "",
3467  tmp_url.data(),
3468  TRUE // root node
3469  );
3471  m_usedNodes = new QDict<DotNode>(1009);
3472  m_usedNodes->insert(fd->absFilePath(),m_startNode);
3473  buildGraph(m_startNode,fd,1);
3474 
3475  static int nodes = Config_getInt("DOT_GRAPH_MAX_NODES");
3476  int maxNodes = nodes;
3477  //int directChildNodes = 1;
3478  //if (m_startNode->m_children!=0)
3479  // directChildNodes+=m_startNode->m_children->count();
3480  //if (directChildNodes>maxNodes) maxNodes=directChildNodes;
3481  QList<DotNode> openNodeQueue;
3482  openNodeQueue.append(m_startNode);
3483  determineVisibleNodes(openNodeQueue,maxNodes);
3484  openNodeQueue.clear();
3485  openNodeQueue.append(m_startNode);
3486  determineTruncatedNodes(openNodeQueue);
3487 }
virtual QCString getReference() const
void append(const type *d)
Definition: qlist.h:73
void determineTruncatedNodes(QList< DotNode > &queue)
Definition: dot.cpp:3432
QCString m_diskName
Definition: dot.h:222
DotNode * m_startNode
Definition: dot.h:219
Definition: dot.h:60
void buildGraph(DotNode *n, FileDef *fd, int distance)
Definition: dot.cpp:3344
QCString getFileBase() const
Definition: filedef.h:88
QDict< DotNode > * m_usedNodes
Definition: dot.h:220
QCString copy() const
Definition: qcstring.h:250
#define Config_getInt(val)
Definition: config.cpp:661
#define nodes
void setDistance(int distance)
Definition: dot.cpp:1559
void clear()
Definition: qlist.h:82
const char * data() const
Definition: qcstring.h:207
QCString absFilePath() const
Definition: filedef.h:96
bool m_inverse
Definition: dot.h:223
static int m_curNodeNumber
Definition: dot.h:221
void determineVisibleNodes(QList< DotNode > &queue, int &maxNodes)
Definition: dot.cpp:3408
const QCString & docName() const
Definition: filedef.h:99
const bool TRUE
Definition: qglobal.h:371
#define ASSERT(x)
Definition: qglobal.h:590
DotInclDepGraph::~DotInclDepGraph ( )

Definition at line 3489 of file dot.cpp.

3490 {
3492  delete m_usedNodes;
3493 }
DotNode * m_startNode
Definition: dot.h:219
QDict< DotNode > * m_usedNodes
Definition: dot.h:220
static void deleteNodes(DotNode *node, SDict< DotNode > *skipNodes=0)
Definition: dot.cpp:1443

Member Function Documentation

void DotInclDepGraph::buildGraph ( DotNode n,
FileDef fd,
int  distance 
)
private

Definition at line 3344 of file dot.cpp.

3345 {
3346  QList<IncludeInfo> *includeFiles =
3348  if (includeFiles)
3349  {
3350  QListIterator<IncludeInfo> ili(*includeFiles);
3351  IncludeInfo *ii;
3352  for (;(ii=ili.current());++ili)
3353  {
3354  FileDef *bfd = ii->fileDef;
3355  QCString in = ii->includeName;
3356  //printf(">>>> in=`%s' bfd=%p\n",ii->includeName.data(),bfd);
3357  bool doc=TRUE,src=FALSE;
3358  if (bfd)
3359  {
3360  in = bfd->absFilePath();
3361  doc = bfd->isLinkable() && !bfd->isHidden();
3362  src = bfd->generateSourceFile();
3363  }
3364  if (doc || src || !Config_getBool("HIDE_UNDOC_RELATIONS"))
3365  {
3366  QCString url="";
3367  if (bfd) url=bfd->getOutputFileBase().copy();
3368  if (!doc && src)
3369  {
3370  url=bfd->getSourceFileBase();
3371  }
3372  DotNode *bn = m_usedNodes->find(in);
3373  if (bn) // file is already a node in the graph
3374  {
3375  n->addChild(bn,0,0,0);
3376  bn->addParent(n);
3377  bn->setDistance(distance);
3378  }
3379  else
3380  {
3381  QCString tmp_url;
3382  QCString tooltip;
3383  if (bfd)
3384  {
3385  tmp_url=doc || src ? bfd->getReference()+"$"+url : QCString();
3386  tooltip = bfd->briefDescriptionAsTooltip();
3387  }
3388  bn = new DotNode(
3389  m_curNodeNumber++, // n
3390  ii->includeName, // label
3391  tooltip, // tip
3392  tmp_url, // url
3393  FALSE, // rootNode
3394  0 // cd
3395  );
3396  n->addChild(bn,0,0,0);
3397  bn->addParent(n);
3398  m_usedNodes->insert(in,bn);
3399  bn->setDistance(distance);
3400 
3401  if (bfd) buildGraph(bn,bfd,distance+1);
3402  }
3403  }
3404  }
3405  }
3406 }
void addParent(DotNode *n)
Definition: dot.cpp:1507
virtual QCString getReference() const
bool isLinkable() const
Definition: filedef.h:117
bool generateSourceFile() const
Definition: filedef.cpp:1396
Definition: dot.h:60
const bool FALSE
Definition: qglobal.h:370
void buildGraph(DotNode *n, FileDef *fd, int distance)
Definition: dot.cpp:3344
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
QDict< DotNode > * m_usedNodes
Definition: dot.h:220
QCString copy() const
Definition: qcstring.h:250
QCString getSourceFileBase() const
Definition: filedef.cpp:1771
QList< IncludeInfo > * includeFileList() const
Definition: filedef.h:124
void setDistance(int distance)
Definition: dot.cpp:1559
QCString includeName
Definition: filedef.h:50
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
#define Config_getBool(val)
Definition: config.cpp:664
QCString absFilePath() const
Definition: filedef.h:96
QCString getOutputFileBase() const
Definition: filedef.h:83
bool m_inverse
Definition: dot.h:223
bool isHidden() const
FileDef * fileDef
Definition: filedef.h:49
QList< IncludeInfo > * includedByFileList() const
Definition: filedef.h:125
static int m_curNodeNumber
Definition: dot.h:221
QCString doc
QCString briefDescriptionAsTooltip() const
const bool TRUE
Definition: qglobal.h:371
void DotInclDepGraph::determineTruncatedNodes ( QList< DotNode > &  queue)
private

Definition at line 3432 of file dot.cpp.

3433 {
3434  while (queue.count()>0)
3435  {
3436  DotNode *n = queue.take(0);
3437  if (n->isVisible() && n->isTruncated()==DotNode::Unknown)
3438  {
3439  bool truncated = FALSE;
3440  if (n->m_children)
3441  {
3443  DotNode *dn;
3444  for (li.toFirst();(dn=li.current());++li)
3445  {
3446  if (!dn->isVisible())
3447  truncated = TRUE;
3448  else
3449  queue.append(dn);
3450  }
3451  }
3452  n->markAsTruncated(truncated);
3453  }
3454  }
3455 }
void append(const type *d)
Definition: qlist.h:73
Definition: dot.h:60
TruncState isTruncated() const
Definition: dot.h:90
const bool FALSE
Definition: qglobal.h:370
uint count() const
Definition: qlist.h:66
std::void_t< T > n
QList< DotNode > * m_children
list of child nodes (outgoing arrows)
Definition: dot.h:108
void markAsTruncated(bool b=TRUE)
Definition: dot.h:102
type * take(uint i)
Definition: qlist.h:81
bool isVisible() const
Definition: dot.h:89
const bool TRUE
Definition: qglobal.h:371
void DotInclDepGraph::determineVisibleNodes ( QList< DotNode > &  queue,
int &  maxNodes 
)
private

Definition at line 3408 of file dot.cpp.

3409 {
3410  while (queue.count()>0 && maxNodes>0)
3411  {
3412  static int maxDistance = Config_getInt("MAX_DOT_GRAPH_DEPTH");
3413  DotNode *n = queue.take(0);
3414  if (!n->isVisible() && n->distance()<=maxDistance) // not yet processed
3415  {
3416  n->markAsVisible();
3417  maxNodes--;
3418  // add direct children
3419  if (n->m_children)
3420  {
3422  DotNode *dn;
3423  for (li.toFirst();(dn=li.current());++li)
3424  {
3425  queue.append(dn);
3426  }
3427  }
3428  }
3429  }
3430 }
void append(const type *d)
Definition: qlist.h:73
Definition: dot.h:60
int distance() const
Definition: dot.h:91
#define Config_getInt(val)
Definition: config.cpp:661
uint count() const
Definition: qlist.h:66
std::void_t< T > n
QList< DotNode > * m_children
list of child nodes (outgoing arrows)
Definition: dot.h:108
void markAsVisible(bool b=TRUE)
Definition: dot.h:101
type * take(uint i)
Definition: qlist.h:81
bool isVisible() const
Definition: dot.h:89
QCString DotInclDepGraph::diskName ( ) const

Definition at line 3495 of file dot.cpp.

3496 {
3498  if (m_inverse) result+="_dep";
3499  result+="_incl";
3500  return convertNameToFile(result);
3501 }
static QCString result
QCString m_diskName
Definition: dot.h:222
QCString copy() const
Definition: qcstring.h:250
bool m_inverse
Definition: dot.h:223
QCString convertNameToFile(const char *name, bool allowDots, bool allowUnderscore)
Definition: util.cpp:5354
bool DotInclDepGraph::isTooBig ( ) const

Definition at line 3641 of file dot.cpp.

3642 {
3643  static int maxNodes = Config_getInt("DOT_GRAPH_MAX_NODES");
3644  int numNodes = m_startNode->m_children ? m_startNode->m_children->count() : 0;
3645  return numNodes>=maxNodes;
3646 }
DotNode * m_startNode
Definition: dot.h:219
#define Config_getInt(val)
Definition: config.cpp:661
uint count() const
Definition: qlist.h:66
QList< DotNode > * m_children
list of child nodes (outgoing arrows)
Definition: dot.h:108
bool DotInclDepGraph::isTrivial ( ) const

Definition at line 3636 of file dot.cpp.

3637 {
3638  return m_startNode->m_children==0;
3639 }
DotNode * m_startNode
Definition: dot.h:219
QList< DotNode > * m_children
list of child nodes (outgoing arrows)
Definition: dot.h:108
void DotInclDepGraph::writeDocbook ( FTextStream t)

Definition at line 3658 of file dot.cpp.

3659 {
3660  QDictIterator<DotNode> dni(*m_usedNodes);
3661  DotNode *node;
3662  for (;(node=dni.current());++dni)
3663  {
3664  node->writeDocbook(t,FALSE);
3665  }
3666 }
Definition: dot.h:60
const bool FALSE
Definition: qglobal.h:370
void writeDocbook(FTextStream &t, bool isClassGraph)
Definition: dot.cpp:2033
QDict< DotNode > * m_usedNodes
Definition: dot.h:220
QCString DotInclDepGraph::writeGraph ( FTextStream t,
GraphOutputFormat  gf,
EmbeddedOutputFormat  ef,
const char *  path,
const char *  fileName,
const char *  relPath,
bool  writeImageMap = TRUE,
int  graphId = -1 
) const

Definition at line 3503 of file dot.cpp.

3512 {
3513  QDir d(path);
3514  // store the original directory
3515  if (!d.exists())
3516  {
3517  err("Output dir %s does not exist!\n",path); exit(1);
3518  }
3519  static bool usePDFLatex = Config_getBool("USE_PDFLATEX");
3520 
3522  if (m_inverse) baseName+="_dep";
3523  baseName+="_incl";
3524  baseName=convertNameToFile(baseName);
3526  if (m_inverse) mapName+="dep";
3527 
3528  QCString imgExt = getDotImageExtension();
3529  QCString imgFmt = Config_getEnum("DOT_IMAGE_FORMAT");
3530  QCString absBaseName = d.absPath().utf8()+"/"+baseName;
3531  QCString absDotName = absBaseName+".dot";
3532  QCString absMapName = absBaseName+".map";
3533  QCString absPdfName = absBaseName+".pdf";
3534  QCString absEpsName = absBaseName+".eps";
3535  QCString absImgName = absBaseName+"."+imgExt;
3536 
3537  bool regenerate = FALSE;
3540  absBaseName,
3541  graphFormat,
3542  FALSE, // lrRank
3543  FALSE, // renderParents
3544  m_inverse, // backArrows
3545  m_startNode->label()
3546  ) ||
3547  !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName :
3548  usePDFLatex ? absPdfName : absEpsName,
3549  graphFormat==GOF_BITMAP && generateImageMap ? absMapName : QCString())
3550  )
3551  {
3552  regenerate=TRUE;
3553  if (graphFormat==GOF_BITMAP)
3554  {
3555  // run dot to create a bitmap image
3556  DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),TRUE,absImgName);
3557  dotRun->addJob(imgFmt,absImgName);
3558  if (generateImageMap) dotRun->addJob(MAP_CMD,absMapName);
3559  DotManager::instance()->addRun(dotRun);
3560  }
3561  else if (graphFormat==GOF_EPS)
3562  {
3563  DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),FALSE);
3564  if (usePDFLatex)
3565  {
3566  dotRun->addJob("pdf",absPdfName);
3567  }
3568  else
3569  {
3570  dotRun->addJob("ps",absEpsName);
3571  }
3572  DotManager::instance()->addRun(dotRun);
3573  }
3574  }
3575  Doxygen::indexList->addImageFile(baseName+"."+imgExt);
3576 
3577  if (graphFormat==GOF_BITMAP && textFormat==EOF_DocBook)
3578  {
3579  out << "<para>" << endl;
3580  out << " <figure>" << endl;
3581  out << " <title>Dependency diagram";
3582  out << "</title>" << endl;
3583  out << " <mediaobject>" << endl;
3584  out << " <imageobject>" << endl;
3585  out << " <imagedata";
3586  out << " width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"1\" fileref=\"" << relPath << baseName << "." << imgExt << "\">";
3587  out << "</imagedata>" << endl;
3588  out << " </imageobject>" << endl;
3589  out << " </mediaobject>" << endl;
3590  out << " </figure>" << endl;
3591  out << "</para>" << endl;
3592  }
3593  else if (graphFormat==GOF_BITMAP && generateImageMap)
3594  {
3595  if (imgExt=="svg") // Scalable vector graphics
3596  {
3597  out << "<div class=\"center\">";
3598  if (regenerate || !writeSVGFigureLink(out,relPath,baseName,absImgName)) // need to patch the links in the generated SVG file
3599  {
3600  if (regenerate)
3601  {
3602  DotManager::instance()->addSVGConversion(absImgName,relPath,FALSE,QCString(),TRUE,graphId);
3603  }
3604  int mapId = DotManager::instance()->addSVGObject(fileName,baseName,absImgName,relPath);
3605  out << "<!-- SVG " << mapId << " -->" << endl;
3606  }
3607  out << "</div>" << endl;
3608  }
3609  else // bitmap graphics
3610  {
3611  out << "<div class=\"center\"><img src=\"" << relPath << baseName << "." << imgExt << "\" border=\"0\" usemap=\"#" << mapName << "\" alt=\"\"/>";
3612  out << "</div>" << endl;
3613 
3614  QCString absMapName = absBaseName+".map";
3615  if (regenerate || !insertMapFile(out,absMapName,relPath,mapName))
3616  {
3617  int mapId = DotManager::instance()->addMap(fileName,absMapName,relPath,
3618  FALSE,QCString(),mapName);
3619  out << "<!-- MAP " << mapId << " -->" << endl;
3620  }
3621  }
3622  }
3623  else if (graphFormat==GOF_EPS) // encapsulated postscript
3624  {
3625  if (regenerate || !writeVecGfxFigure(out,baseName,absBaseName))
3626  {
3627  int figId = DotManager::instance()->addFigure(fileName,baseName,absBaseName,FALSE);
3628  out << endl << "% FIG " << figId << endl;
3629  }
3630  }
3631  if (!regenerate) removeDotGraph(absDotName);
3632 
3633  return baseName;
3634 }
Traverses directory structures and contents in a platform-independent way.
Definition: qdir.h:52
int addSVGConversion(const QCString &file, const QCString &relPath, bool urlOnly, const QCString &context, bool zoomable, int graphId)
Definition: dot.cpp:1292
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
Definition: dot.h:356
static bool checkDeliverables(const QCString &file1, const QCString &file2=QCString())
Definition: dot.cpp:758
QCString m_diskName
Definition: dot.h:222
DotNode * m_startNode
Definition: dot.h:219
static DotManager * instance()
Definition: dot.cpp:1221
const bool FALSE
Definition: qglobal.h:370
QCString label() const
Definition: dot.h:87
int addMap(const QCString &file, const QCString &mapFile, const QCString &relPath, bool urlOnly, const QCString &context, const QCString &label)
Definition: dot.cpp:1267
#define Config_getEnum(val)
Definition: config.cpp:663
static void removeDotGraph(const QCString &dotName)
Definition: dot.cpp:714
fileName
Definition: dumpTree.py:9
static bool updateDotGraph(DotNode *root, DotNode::GraphType gt, const QCString &baseName, GraphOutputFormat format, bool lrRank, bool renderParents, bool backArrows, const QCString &title=QCString())
Definition: dot.cpp:3088
static bool writeVecGfxFigure(FTextStream &out, const QCString &baseName, const QCString &figureName)
Definition: dot.cpp:518
int addFigure(const QCString &file, const QCString &baseName, const QCString &figureName, bool heightCheck)
Definition: dot.cpp:1280
void addImageFile(const char *name)
Definition: index.h:147
#define Config_getBool(val)
Definition: config.cpp:664
QCString getDotImageExtension(void)
Definition: util.cpp:8562
#define MAP_CMD
Definition: dot.cpp:51
Definition: dot.h:42
void err(const char *fmt,...)
Definition: message.cpp:226
int addSVGObject(const QCString &file, const QCString &baseName, const QCString &figureNAme, const QCString &relPath)
Definition: dot.cpp:1305
bool m_inverse
Definition: dot.h:223
void addJob(const char *format, const char *output)
Definition: dot.cpp:807
static bool writeSVGFigureLink(FTextStream &out, const QCString &relPath, const QCString &baseName, const QCString &absImgName)
Definition: dot.cpp:618
QCString convertNameToFile(const char *name, bool allowDots, bool allowUnderscore)
Definition: util.cpp:5354
QCString m_label
label text
Definition: dot.h:104
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)
void DotInclDepGraph::writeXML ( FTextStream t)

Definition at line 3648 of file dot.cpp.

3649 {
3650  QDictIterator<DotNode> dni(*m_usedNodes);
3651  DotNode *node;
3652  for (;(node=dni.current());++dni)
3653  {
3654  node->writeXML(t,FALSE);
3655  }
3656 }
Definition: dot.h:60
const bool FALSE
Definition: qglobal.h:370
QDict< DotNode > * m_usedNodes
Definition: dot.h:220
void writeXML(FTextStream &t, bool isClassGraph)
Definition: dot.cpp:1964

Member Data Documentation

int DotInclDepGraph::m_curNodeNumber = 0
staticprivate

Definition at line 221 of file dot.h.

QCString DotInclDepGraph::m_diskName
private

Definition at line 222 of file dot.h.

bool DotInclDepGraph::m_inverse
private

Definition at line 223 of file dot.h.

DotNode* DotInclDepGraph::m_startNode
private

Definition at line 219 of file dot.h.

QDict<DotNode>* DotInclDepGraph::m_usedNodes
private

Definition at line 220 of file dot.h.


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