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

#include <dot.h>

Public Member Functions

 DotCallGraph (MemberDef *md, bool inverse)
 
 ~DotCallGraph ()
 
QCString writeGraph (FTextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const char *path, const char *fileName, const char *relPath, bool writeImageMap=TRUE, int graphId=-1) const
 
void buildGraph (DotNode *n, MemberDef *md, int distance)
 
bool isTrivial () const
 
bool isTooBig () const
 
void determineVisibleNodes (QList< DotNode > &queue, int &maxNodes)
 
void determineTruncatedNodes (QList< DotNode > &queue)
 

Private Attributes

DotNodem_startNode
 
QDict< DotNode > * m_usedNodes
 
bool m_inverse
 
QCString m_diskName
 
Definitionm_scope
 

Static Private Attributes

static int m_curNodeNumber = 0
 

Detailed Description

Representation of an call graph

Definition at line 227 of file dot.h.

Constructor & Destructor Documentation

DotCallGraph::DotCallGraph ( MemberDef md,
bool  inverse 
)

Definition at line 3776 of file dot.cpp.

3777 {
3778  m_inverse = inverse;
3779  m_diskName = md->getOutputFileBase()+"_"+md->anchor();
3780  m_scope = md->getOuterScope();
3781  QCString uniqueId;
3782  uniqueId = md->getReference()+"$"+
3783  md->getOutputFileBase()+"#"+md->anchor();
3784  QCString name;
3785  if (Config_getBool("HIDE_SCOPE_NAMES"))
3786  {
3787  name = md->name();
3788  }
3789  else
3790  {
3791  name = md->qualifiedName();
3792  }
3795  "",
3796  uniqueId.data(),
3797  TRUE // root node
3798  );
3800  m_usedNodes = new QDict<DotNode>(1009);
3801  m_usedNodes->insert(uniqueId,m_startNode);
3802  buildGraph(m_startNode,md,1);
3803 
3804  static int nodes = Config_getInt("DOT_GRAPH_MAX_NODES");
3805  int maxNodes = nodes;
3806  //int directChildNodes = 1;
3807  //if (m_startNode->m_children!=0)
3808  // directChildNodes+=m_startNode->m_children->count();
3809  //if (directChildNodes>maxNodes) maxNodes=directChildNodes;
3810  QList<DotNode> openNodeQueue;
3811  openNodeQueue.append(m_startNode);
3812  determineVisibleNodes(openNodeQueue,maxNodes);
3813  openNodeQueue.clear();
3814  openNodeQueue.append(m_startNode);
3815  determineTruncatedNodes(openNodeQueue);
3816 }
static QCString name
Definition: declinfo.cpp:673
QCString getReference() const
Definition: memberdef.cpp:1001
void append(const type *d)
Definition: qlist.h:73
void determineVisibleNodes(QList< DotNode > &queue, int &maxNodes)
Definition: dot.cpp:3725
QCString m_diskName
Definition: dot.h:247
QDict< DotNode > * m_usedNodes
Definition: dot.h:245
Definition: dot.h:60
const bool FALSE
Definition: qglobal.h:370
#define Config_getInt(val)
Definition: config.cpp:661
const QCString & name() const
Definition: definition.h:114
void determineTruncatedNodes(QList< DotNode > &queue)
Definition: dot.cpp:3749
#define nodes
QCString linkToText(SrcLangExt lang, const char *link, bool isFileName)
Definition: util.cpp:4659
void setDistance(int distance)
Definition: dot.cpp:1559
SrcLangExt getLanguage() const
Definition * m_scope
Definition: dot.h:248
void clear()
Definition: qlist.h:82
const char * data() const
Definition: qcstring.h:207
QCString anchor() const
Definition: memberdef.cpp:1031
#define Config_getBool(val)
Definition: config.cpp:664
bool m_inverse
Definition: dot.h:246
virtual Definition * getOuterScope() const
QCString qualifiedName() const
Definition: memberdef.cpp:3968
static int m_curNodeNumber
Definition: dot.h:244
QCString getOutputFileBase() const
Definition: memberdef.cpp:941
DotNode * m_startNode
Definition: dot.h:243
const bool TRUE
Definition: qglobal.h:371
void buildGraph(DotNode *n, MemberDef *md, int distance)
Definition: dot.cpp:3672
DotCallGraph::~DotCallGraph ( )

Definition at line 3818 of file dot.cpp.

3819 {
3821  delete m_usedNodes;
3822 }
QDict< DotNode > * m_usedNodes
Definition: dot.h:245
static void deleteNodes(DotNode *node, SDict< DotNode > *skipNodes=0)
Definition: dot.cpp:1443
DotNode * m_startNode
Definition: dot.h:243

Member Function Documentation

void DotCallGraph::buildGraph ( DotNode n,
MemberDef md,
int  distance 
)

Definition at line 3672 of file dot.cpp.

3673 {
3675  if (refs)
3676  {
3677  MemberSDict::Iterator mri(*refs);
3678  MemberDef *rmd;
3679  for (;(rmd=mri.current());++mri)
3680  {
3681  if (rmd->showInCallGraph())
3682  {
3683  QCString uniqueId;
3684  uniqueId=rmd->getReference()+"$"+
3685  rmd->getOutputFileBase()+"#"+rmd->anchor();
3686  DotNode *bn = m_usedNodes->find(uniqueId);
3687  if (bn) // file is already a node in the graph
3688  {
3689  n->addChild(bn,0,0,0);
3690  bn->addParent(n);
3691  bn->setDistance(distance);
3692  }
3693  else
3694  {
3695  QCString name;
3696  if (Config_getBool("HIDE_SCOPE_NAMES"))
3697  {
3698  name = rmd->getOuterScope()==m_scope ?
3699  rmd->name() : rmd->qualifiedName();
3700  }
3701  else
3702  {
3703  name = rmd->qualifiedName();
3704  }
3705  QCString tooltip = rmd->briefDescriptionAsTooltip();
3706  bn = new DotNode(
3707  m_curNodeNumber++,
3708  linkToText(rmd->getLanguage(),name,FALSE),
3709  tooltip,
3710  uniqueId,
3711  0 //distance
3712  );
3713  n->addChild(bn,0,0,0);
3714  bn->addParent(n);
3715  bn->setDistance(distance);
3716  m_usedNodes->insert(uniqueId,bn);
3717 
3718  buildGraph(bn,rmd,distance+1);
3719  }
3720  }
3721  }
3722  }
3723 }
static QCString name
Definition: declinfo.cpp:673
void addParent(DotNode *n)
Definition: dot.cpp:1507
QCString getReference() const
Definition: memberdef.cpp:1001
QDict< DotNode > * m_usedNodes
Definition: dot.h:245
Definition: dot.h:60
const bool FALSE
Definition: qglobal.h:370
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
MemberSDict * getReferencesMembers() const
MemberSDict * getReferencedByMembers() const
const QCString & name() const
Definition: definition.h:114
QCString linkToText(SrcLangExt lang, const char *link, bool isFileName)
Definition: util.cpp:4659
void setDistance(int distance)
Definition: dot.cpp:1559
SrcLangExt getLanguage() const
Definition * m_scope
Definition: dot.h:248
QCString anchor() const
Definition: memberdef.cpp:1031
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
#define Config_getBool(val)
Definition: config.cpp:664
bool m_inverse
Definition: dot.h:246
virtual Definition * getOuterScope() const
bool showInCallGraph() const
Definition: memberdef.cpp:4458
QCString qualifiedName() const
Definition: memberdef.cpp:3968
static int m_curNodeNumber
Definition: dot.h:244
QCString getOutputFileBase() const
Definition: memberdef.cpp:941
friend class Iterator
Definition: sortdict.h:289
QCString briefDescriptionAsTooltip() const
void buildGraph(DotNode *n, MemberDef *md, int distance)
Definition: dot.cpp:3672
void DotCallGraph::determineTruncatedNodes ( QList< DotNode > &  queue)

Definition at line 3749 of file dot.cpp.

3750 {
3751  while (queue.count()>0)
3752  {
3753  DotNode *n = queue.take(0);
3754  if (n->isVisible() && n->isTruncated()==DotNode::Unknown)
3755  {
3756  bool truncated = FALSE;
3757  if (n->m_children)
3758  {
3760  DotNode *dn;
3761  for (li.toFirst();(dn=li.current());++li)
3762  {
3763  if (!dn->isVisible())
3764  truncated = TRUE;
3765  else
3766  queue.append(dn);
3767  }
3768  }
3769  n->markAsTruncated(truncated);
3770  }
3771  }
3772 }
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 DotCallGraph::determineVisibleNodes ( QList< DotNode > &  queue,
int &  maxNodes 
)

Definition at line 3725 of file dot.cpp.

3726 {
3727  while (queue.count()>0 && maxNodes>0)
3728  {
3729  static int maxDistance = Config_getInt("MAX_DOT_GRAPH_DEPTH");
3730  DotNode *n = queue.take(0);
3731  if (!n->isVisible() && n->distance()<=maxDistance) // not yet processed
3732  {
3733  n->markAsVisible();
3734  maxNodes--;
3735  // add direct children
3736  if (n->m_children)
3737  {
3739  DotNode *dn;
3740  for (li.toFirst();(dn=li.current());++li)
3741  {
3742  queue.append(dn);
3743  }
3744  }
3745  }
3746  }
3747 }
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
bool DotCallGraph::isTooBig ( ) const

Definition at line 3959 of file dot.cpp.

3960 {
3961  static int maxNodes = Config_getInt("DOT_GRAPH_MAX_NODES");
3962  int numNodes = m_startNode->m_children ? m_startNode->m_children->count() : 0;
3963  return numNodes>=maxNodes;
3964 }
#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
DotNode * m_startNode
Definition: dot.h:243
bool DotCallGraph::isTrivial ( ) const

Definition at line 3954 of file dot.cpp.

3955 {
3956  return m_startNode->m_children==0;
3957 }
QList< DotNode > * m_children
list of child nodes (outgoing arrows)
Definition: dot.h:108
DotNode * m_startNode
Definition: dot.h:243
QCString DotCallGraph::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 3824 of file dot.cpp.

3829 {
3830  QDir d(path);
3831  // store the original directory
3832  if (!d.exists())
3833  {
3834  err("Output dir %s does not exist!\n",path); exit(1);
3835  }
3836  static bool usePDFLatex = Config_getBool("USE_PDFLATEX");
3837 
3838  QCString baseName = m_diskName + (m_inverse ? "_icgraph" : "_cgraph");
3839  QCString mapName = baseName;
3840 
3841  QCString imgExt = getDotImageExtension();
3842  QCString imgFmt = Config_getEnum("DOT_IMAGE_FORMAT");
3843  QCString absBaseName = d.absPath().utf8()+"/"+baseName;
3844  QCString absDotName = absBaseName+".dot";
3845  QCString absMapName = absBaseName+".map";
3846  QCString absPdfName = absBaseName+".pdf";
3847  QCString absEpsName = absBaseName+".eps";
3848  QCString absImgName = absBaseName+"."+imgExt;
3849 
3850  bool regenerate = FALSE;
3853  absBaseName,
3854  graphFormat,
3855  TRUE, // lrRank
3856  FALSE, // renderParents
3857  m_inverse, // backArrows
3858  m_startNode->label()
3859  ) ||
3860  !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName :
3861  usePDFLatex ? absPdfName : absEpsName,
3862  graphFormat==GOF_BITMAP && generateImageMap ? absMapName : QCString())
3863  )
3864  {
3865  regenerate=TRUE;
3866  if (graphFormat==GOF_BITMAP)
3867  {
3868  // run dot to create a bitmap image
3869  DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),TRUE,absImgName);
3870  dotRun->addJob(imgFmt,absImgName);
3871  if (generateImageMap) dotRun->addJob(MAP_CMD,absMapName);
3872  DotManager::instance()->addRun(dotRun);
3873 
3874  }
3875  else if (graphFormat==GOF_EPS)
3876  {
3877  // run dot to create a .eps image
3878  DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),FALSE);
3879  if (usePDFLatex)
3880  {
3881  dotRun->addJob("pdf",absPdfName);
3882  }
3883  else
3884  {
3885  dotRun->addJob("ps",absEpsName);
3886  }
3887  DotManager::instance()->addRun(dotRun);
3888 
3889  }
3890  }
3891  Doxygen::indexList->addImageFile(baseName+"."+imgExt);
3892 
3893  if (graphFormat==GOF_BITMAP && textFormat==EOF_DocBook)
3894  {
3895  out << "<para>" << endl;
3896  out << " <figure>" << endl;
3897  out << " <title>Call diagram";
3898  out << "</title>" << endl;
3899  out << " <mediaobject>" << endl;
3900  out << " <imageobject>" << endl;
3901  out << " <imagedata";
3902  out << " width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"1\" fileref=\"" << relPath << baseName << "." << imgExt << "\">";
3903  out << "</imagedata>" << endl;
3904  out << " </imageobject>" << endl;
3905  out << " </mediaobject>" << endl;
3906  out << " </figure>" << endl;
3907  out << "</para>" << endl;
3908  }
3909  else if (graphFormat==GOF_BITMAP && generateImageMap)
3910  {
3911  if (imgExt=="svg") // Scalable vector graphics
3912  {
3913  out << "<div class=\"center\">";
3914  if (regenerate || !writeSVGFigureLink(out,relPath,baseName,absImgName)) // need to patch the links in the generated SVG file
3915  {
3916  if (regenerate)
3917  {
3918  DotManager::instance()->addSVGConversion(absImgName,relPath,FALSE,QCString(),TRUE,graphId);
3919  }
3920  int mapId = DotManager::instance()->addSVGObject(fileName,baseName,absImgName,relPath);
3921  out << "<!-- SVG " << mapId << " -->" << endl;
3922  }
3923  out << "</div>" << endl;
3924  }
3925  else // bitmap graphics
3926  {
3927  out << "<div class=\"center\"><img src=\"" << relPath << baseName << "."
3928  << imgExt << "\" border=\"0\" usemap=\"#"
3929  << mapName << "\" alt=\"";
3930  out << "\"/>";
3931  out << "</div>" << endl;
3932 
3933  if (regenerate || !insertMapFile(out,absMapName,relPath,mapName))
3934  {
3935  int mapId = DotManager::instance()->addMap(fileName,absMapName,relPath,
3936  FALSE,QCString(),mapName);
3937  out << "<!-- MAP " << mapId << " -->" << endl;
3938  }
3939  }
3940  }
3941  else if (graphFormat==GOF_EPS) // encapsulated postscript
3942  {
3943  if (regenerate || !writeVecGfxFigure(out,baseName,absBaseName))
3944  {
3945  int figId = DotManager::instance()->addFigure(fileName,baseName,absBaseName,FALSE);
3946  out << endl << "% FIG " << figId << endl;
3947  }
3948  }
3949  if (!regenerate) removeDotGraph(absDotName);
3950 
3951  return baseName;
3952 }
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
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:247
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
bool m_inverse
Definition: dot.h:246
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
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
static QCString baseName
Definition: scanner.cpp:10890
DotNode * m_startNode
Definition: dot.h:243
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)

Member Data Documentation

int DotCallGraph::m_curNodeNumber = 0
staticprivate

Definition at line 244 of file dot.h.

QCString DotCallGraph::m_diskName
private

Definition at line 247 of file dot.h.

bool DotCallGraph::m_inverse
private

Definition at line 246 of file dot.h.

Definition* DotCallGraph::m_scope
private

Definition at line 248 of file dot.h.

DotNode* DotCallGraph::m_startNode
private

Definition at line 243 of file dot.h.

QDict<DotNode>* DotCallGraph::m_usedNodes
private

Definition at line 245 of file dot.h.


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