My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static 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)
 

Static Public Member Functions

static void resetNumbering ()
 

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 232 of file dot.h.

Constructor & Destructor Documentation

DotCallGraph::DotCallGraph ( MemberDef md,
bool  inverse 
)

Definition at line 3721 of file dot.cpp.

References MemberDef::anchor(), buildGraph(), Config_getBool, Config_getInt, determineTruncatedNodes(), determineVisibleNodes(), Definition::getLanguage(), Definition::getOuterScope(), MemberDef::getOutputFileBase(), MemberDef::getReference(), linkToText(), m_curNodeNumber, m_diskName, m_inverse, m_scope, m_startNode, m_usedNodes, Definition::name(), MemberDef::qualifiedName(), and DotNode::setDistance().

{
m_inverse = inverse;
m_diskName = md->getOutputFileBase()+"_"+md->anchor();
QCString uniqueId;
uniqueId = md->getReference()+"$"+
md->getOutputFileBase()+"#"+md->anchor();
QCString name;
if (Config_getBool(HIDE_SCOPE_NAMES))
{
name = md->name();
}
else
{
name = md->qualifiedName();
}
linkToText(md->getLanguage(),name,FALSE),
"",
uniqueId.data(),
TRUE // root node
);
m_usedNodes = new QDict<DotNode>(1009);
m_usedNodes->insert(uniqueId,m_startNode);
static int nodes = Config_getInt(DOT_GRAPH_MAX_NODES);
int maxNodes = nodes;
//int directChildNodes = 1;
//if (m_startNode->m_children!=0)
// directChildNodes+=m_startNode->m_children->count();
//if (directChildNodes>maxNodes) maxNodes=directChildNodes;
QList<DotNode> openNodeQueue;
openNodeQueue.append(m_startNode);
determineVisibleNodes(openNodeQueue,maxNodes);
openNodeQueue.clear();
openNodeQueue.append(m_startNode);
determineTruncatedNodes(openNodeQueue);
}
DotCallGraph::~DotCallGraph ( )

Definition at line 3763 of file dot.cpp.

References deleteNodes(), m_startNode, and m_usedNodes.

Member Function Documentation

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

Definition at line 3612 of file dot.cpp.

References DotNode::addChild(), DotNode::addParent(), MemberDef::anchor(), Definition::briefDescriptionAsTooltip(), Config_getBool, Definition::getLanguage(), Definition::getOuterScope(), MemberDef::getOutputFileBase(), MemberDef::getReference(), Definition::getReferencedByMembers(), Definition::getReferencesMembers(), SDict< MemberDef >::Iterator, linkToText(), m_curNodeNumber, m_inverse, m_scope, m_usedNodes, Definition::name(), MemberDef::qualifiedName(), DotNode::setDistance(), and MemberDef::showInCallGraph().

Referenced by DotCallGraph().

{
if (refs)
{
MemberDef *rmd;
for (;(rmd=mri.current());++mri)
{
if (rmd->showInCallGraph())
{
QCString uniqueId;
uniqueId=rmd->getReference()+"$"+
rmd->getOutputFileBase()+"#"+rmd->anchor();
DotNode *bn = m_usedNodes->find(uniqueId);
if (bn) // file is already a node in the graph
{
n->addChild(bn,0,0,0);
bn->addParent(n);
bn->setDistance(distance);
}
else
{
QCString name;
if (Config_getBool(HIDE_SCOPE_NAMES))
{
name = rmd->getOuterScope()==m_scope ?
rmd->name() : rmd->qualifiedName();
}
else
{
name = rmd->qualifiedName();
}
QCString tooltip = rmd->briefDescriptionAsTooltip();
bn = new DotNode(
linkToText(rmd->getLanguage(),name,FALSE),
tooltip,
uniqueId,
0 //distance
);
n->addChild(bn,0,0,0);
bn->addParent(n);
bn->setDistance(distance);
m_usedNodes->insert(uniqueId,bn);
buildGraph(bn,rmd,distance+1);
}
}
}
}
}
void DotCallGraph::determineTruncatedNodes ( QList< DotNode > &  queue)

Definition at line 3689 of file dot.cpp.

References DotNode::isTruncated(), DotNode::isVisible(), DotNode::m_children, DotNode::markAsTruncated(), and DotNode::Unknown.

Referenced by DotCallGraph().

{
while (queue.count()>0)
{
DotNode *n = queue.take(0);
{
bool truncated = FALSE;
if (n->m_children)
{
QListIterator<DotNode> li(*n->m_children);
DotNode *dn;
for (li.toFirst();(dn=li.current());++li)
{
if (!dn->isVisible())
truncated = TRUE;
else
queue.append(dn);
}
}
n->markAsTruncated(truncated);
}
}
}
void DotCallGraph::determineVisibleNodes ( QList< DotNode > &  queue,
int &  maxNodes 
)

Definition at line 3665 of file dot.cpp.

References Config_getInt, DotNode::distance(), DotNode::isVisible(), DotNode::m_children, and DotNode::markAsVisible().

Referenced by DotCallGraph().

{
while (queue.count()>0 && maxNodes>0)
{
static int maxDistance = Config_getInt(MAX_DOT_GRAPH_DEPTH);
DotNode *n = queue.take(0);
if (!n->isVisible() && n->distance()<=maxDistance) // not yet processed
{
maxNodes--;
// add direct children
if (n->m_children)
{
QListIterator<DotNode> li(*n->m_children);
DotNode *dn;
for (li.toFirst();(dn=li.current());++li)
{
queue.append(dn);
}
}
}
}
}
bool DotCallGraph::isTooBig ( ) const

Definition at line 3904 of file dot.cpp.

References Config_getInt, DotNode::m_children, and m_startNode.

Referenced by MemberDef::_writeCallerGraph(), MemberDef::_writeCallGraph(), MemberContext::Private::hasCallerGraph(), and MemberContext::Private::hasCallGraph().

{
static int maxNodes = Config_getInt(DOT_GRAPH_MAX_NODES);
int numNodes = m_startNode->m_children ? m_startNode->m_children->count() : 0;
return numNodes>=maxNodes;
}
bool DotCallGraph::isTrivial ( ) const
void DotCallGraph::resetNumbering ( )
static

Definition at line 3716 of file dot.cpp.

References m_curNodeNumber.

Referenced by resetDotNodeNumbering().

{
}
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 3769 of file dot.cpp.

References DotManager::addFigure(), IndexList::addImageFile(), DotRunner::addJob(), DotManager::addMap(), DotManager::addRun(), DotManager::addSVGConversion(), DotManager::addSVGObject(), DotNode::CallGraph, checkDeliverables(), Config_getBool, Config_getEnum, endl(), EOF_DocBook, err(), getDotImageExtension(), GOF_BITMAP, GOF_EPS, Doxygen::indexList, insertMapFile(), DotManager::instance(), DotNode::label(), m_diskName, m_inverse, m_startNode, MAP_CMD, removeDotGraph(), updateDotGraph(), writeSVGFigureLink(), and writeVecGfxFigure().

Referenced by MemberContext::Private::callerGraph(), MemberContext::Private::callGraph(), RTFGenerator::endCallGraph(), LatexGenerator::endCallGraph(), and HtmlGenerator::endCallGraph().

{
QDir d(path);
// store the original directory
if (!d.exists())
{
err("Output dir %s does not exist!\n",path); exit(1);
}
static bool usePDFLatex = Config_getBool(USE_PDFLATEX);
QCString baseName = m_diskName + (m_inverse ? "_icgraph" : "_cgraph");
QCString mapName = baseName;
QCString imgExt = getDotImageExtension();
QCString imgFmt = Config_getEnum(DOT_IMAGE_FORMAT);
QCString absBaseName = d.absPath().utf8()+"/"+baseName;
QCString absDotName = absBaseName+".dot";
QCString absMapName = absBaseName+".map";
QCString absPdfName = absBaseName+".pdf";
QCString absEpsName = absBaseName+".eps";
QCString absImgName = absBaseName+"."+imgExt;
bool regenerate = FALSE;
absBaseName,
graphFormat,
TRUE, // lrRank
FALSE, // renderParents
m_inverse, // backArrows
) ||
!checkDeliverables(graphFormat==GOF_BITMAP ? absImgName :
usePDFLatex ? absPdfName : absEpsName,
graphFormat==GOF_BITMAP && generateImageMap ? absMapName : QCString())
)
{
regenerate=TRUE;
if (graphFormat==GOF_BITMAP)
{
// run dot to create a bitmap image
DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),TRUE,absImgName);
dotRun->addJob(imgFmt,absImgName);
if (generateImageMap) dotRun->addJob(MAP_CMD,absMapName);
}
else if (graphFormat==GOF_EPS)
{
// run dot to create a .eps image
DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),FALSE);
if (usePDFLatex)
{
dotRun->addJob("pdf",absPdfName);
}
else
{
dotRun->addJob("ps",absEpsName);
}
}
}
Doxygen::indexList->addImageFile(baseName+"."+imgExt);
if (graphFormat==GOF_BITMAP && textFormat==EOF_DocBook)
{
out << "<para>" << endl;
out << " <figure>" << endl;
out << " <title>Call diagram";
out << "</title>" << endl;
out << " <mediaobject>" << endl;
out << " <imageobject>" << endl;
out << " <imagedata";
out << " width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"1\" fileref=\"" << relPath << baseName << "." << imgExt << "\">";
out << "</imagedata>" << endl;
out << " </imageobject>" << endl;
out << " </mediaobject>" << endl;
out << " </figure>" << endl;
out << "</para>" << endl;
}
else if (graphFormat==GOF_BITMAP && generateImageMap)
{
if (imgExt=="svg") // Scalable vector graphics
{
out << "<div class=\"center\">";
if (regenerate || !writeSVGFigureLink(out,relPath,baseName,absImgName)) // need to patch the links in the generated SVG file
{
if (regenerate)
{
DotManager::instance()->addSVGConversion(absImgName,relPath,FALSE,QCString(),TRUE,graphId);
}
int mapId = DotManager::instance()->addSVGObject(fileName,baseName,absImgName,relPath);
out << "<!-- SVG " << mapId << " -->" << endl;
}
out << "</div>" << endl;
}
else // bitmap graphics
{
out << "<div class=\"center\"><img src=\"" << relPath << baseName << "."
<< imgExt << "\" border=\"0\" usemap=\"#"
<< mapName << "\" alt=\"";
out << "\"/>";
out << "</div>" << endl;
if (regenerate || !insertMapFile(out,absMapName,relPath,mapName))
{
int mapId = DotManager::instance()->addMap(fileName,absMapName,relPath,
FALSE,QCString(),mapName);
out << "<!-- MAP " << mapId << " -->" << endl;
}
}
}
else if (graphFormat==GOF_EPS) // encapsulated postscript
{
if (regenerate || !writeVecGfxFigure(out,baseName,absBaseName))
{
int figId = DotManager::instance()->addFigure(fileName,baseName,absBaseName,FALSE);
out << endl << "% FIG " << figId << endl;
}
}
if (!regenerate) removeDotGraph(absDotName);
return baseName;
}

Member Data Documentation

int DotCallGraph::m_curNodeNumber = 0
staticprivate

Definition at line 250 of file dot.h.

Referenced by buildGraph(), DotCallGraph(), and resetNumbering().

QCString DotCallGraph::m_diskName
private

Definition at line 253 of file dot.h.

Referenced by DotCallGraph(), and writeGraph().

bool DotCallGraph::m_inverse
private

Definition at line 252 of file dot.h.

Referenced by buildGraph(), DotCallGraph(), and writeGraph().

Definition* DotCallGraph::m_scope
private

Definition at line 254 of file dot.h.

Referenced by buildGraph(), and DotCallGraph().

DotNode* DotCallGraph::m_startNode
private

Definition at line 249 of file dot.h.

Referenced by DotCallGraph(), isTooBig(), isTrivial(), writeGraph(), and ~DotCallGraph().

QDict<DotNode>* DotCallGraph::m_usedNodes
private

Definition at line 251 of file dot.h.

Referenced by buildGraph(), DotCallGraph(), and ~DotCallGraph().


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