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

Static Public Member Functions

static void resetNumbering ()
 

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_inclDepFileName
 
QCString m_inclByDepFileName
 
bool m_inverse
 

Static Private Attributes

static int m_curNodeNumber = 0
 

Detailed Description

Representation of an include dependency graph

Definition at line 203 of file dot.h.

Constructor & Destructor Documentation

DotInclDepGraph::DotInclDepGraph ( FileDef fd,
bool  inverse 
)

Definition at line 3402 of file dot.cpp.

References FileDef::absFilePath(), buildGraph(), Config_getInt, determineTruncatedNodes(), determineVisibleNodes(), FileDef::docName(), FileDef::getOutputFileBase(), Definition::getReference(), FileDef::includedByDependencyGraphFileName(), FileDef::includeDependencyGraphFileName(), m_curNodeNumber, m_inclByDepFileName, m_inclDepFileName, m_inverse, m_startNode, m_usedNodes, and DotNode::setDistance().

{
m_inverse = inverse;
ASSERT(fd!=0);
QCString tmp_url=fd->getReference()+"$"+fd->getOutputFileBase();
fd->docName(),
"",
tmp_url.data(),
TRUE // root node
);
m_usedNodes = new QDict<DotNode>(1009);
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);
}
DotInclDepGraph::~DotInclDepGraph ( )

Definition at line 3434 of file dot.cpp.

References deleteNodes(), m_startNode, and m_usedNodes.

Member Function Documentation

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

Definition at line 3282 of file dot.cpp.

References FileDef::absFilePath(), DotNode::addChild(), DotNode::addParent(), Definition::briefDescriptionAsTooltip(), Config_getBool, doc, IncludeInfo::fileDef, FileDef::generateSourceFile(), FileDef::getOutputFileBase(), Definition::getReference(), FileDef::getSourceFileBase(), FileDef::includedByFileList(), FileDef::includeFileList(), IncludeInfo::includeName, Definition::isHidden(), FileDef::isLinkable(), m_curNodeNumber, m_inverse, m_usedNodes, and DotNode::setDistance().

Referenced by DotInclDepGraph().

{
QList<IncludeInfo> *includeFiles =
if (includeFiles)
{
QListIterator<IncludeInfo> ili(*includeFiles);
for (;(ii=ili.current());++ili)
{
FileDef *bfd = ii->fileDef;
QCString in = ii->includeName;
//printf(">>>> in=`%s' bfd=%p\n",ii->includeName.data(),bfd);
bool doc=TRUE,src=FALSE;
if (bfd)
{
in = bfd->absFilePath();
doc = bfd->isLinkable() && !bfd->isHidden();
src = bfd->generateSourceFile();
}
if (doc || src || !Config_getBool(HIDE_UNDOC_RELATIONS))
{
QCString url="";
if (bfd) url=bfd->getOutputFileBase().copy();
if (!doc && src)
{
url=bfd->getSourceFileBase();
}
DotNode *bn = m_usedNodes->find(in);
if (bn) // file is already a node in the graph
{
n->addChild(bn,0,0,0);
bn->addParent(n);
bn->setDistance(distance);
}
else
{
QCString tmp_url;
QCString tooltip;
if (bfd)
{
tmp_url=doc || src ? bfd->getReference()+"$"+url : QCString();
tooltip = bfd->briefDescriptionAsTooltip();
}
bn = new DotNode(
ii->includeName, // label
tooltip, // tip
tmp_url, // url
FALSE, // rootNode
0 // cd
);
n->addChild(bn,0,0,0);
bn->addParent(n);
m_usedNodes->insert(in,bn);
bn->setDistance(distance);
if (bfd) buildGraph(bn,bfd,distance+1);
}
}
}
}
}
void DotInclDepGraph::determineTruncatedNodes ( QList< DotNode > &  queue)
private

Definition at line 3370 of file dot.cpp.

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

Referenced by DotInclDepGraph().

{
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 DotInclDepGraph::determineVisibleNodes ( QList< DotNode > &  queue,
int &  maxNodes 
)
private

Definition at line 3346 of file dot.cpp.

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

Referenced by DotInclDepGraph().

{
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);
}
}
}
}
}
QCString DotInclDepGraph::diskName ( ) const
bool DotInclDepGraph::isTooBig ( ) const

Definition at line 3583 of file dot.cpp.

References Config_getInt, DotNode::m_children, and m_startNode.

Referenced by FileContext::Private::hasIncludedByGraph(), FileContext::Private::hasIncludeGraph(), FileDef::writeIncludedByGraph(), and FileDef::writeIncludeGraph().

{
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 DotInclDepGraph::isTrivial ( ) const
void DotInclDepGraph::resetNumbering ( )
static

Definition at line 3397 of file dot.cpp.

References m_curNodeNumber.

Referenced by resetDotNodeNumbering().

{
}
void DotInclDepGraph::writeDocbook ( FTextStream t)

Definition at line 3600 of file dot.cpp.

References m_usedNodes, and DotNode::writeDocbook().

{
QDictIterator<DotNode> dni(*m_usedNodes);
DotNode *node;
for (;(node=dni.current());++dni)
{
node->writeDocbook(t,FALSE);
}
}
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 3440 of file dot.cpp.

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

Referenced by RTFGenerator::endInclDepGraph(), LatexGenerator::endInclDepGraph(), HtmlGenerator::endInclDepGraph(), FileContext::Private::includedByGraph(), and FileContext::Private::includeGraph().

{
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;
if (m_inverse)
{
}
else
{
}
QCString mapName=escapeCharsInString(m_startNode->m_label,FALSE);
if (m_inverse) mapName+="dep";
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,
FALSE, // 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)
{
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>Dependency 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 << "</div>" << endl;
QCString absMapName = absBaseName+".map";
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;
}
void DotInclDepGraph::writeXML ( FTextStream t)

Definition at line 3590 of file dot.cpp.

References m_usedNodes, and DotNode::writeXML().

Referenced by generateXMLForFile().

{
QDictIterator<DotNode> dni(*m_usedNodes);
DotNode *node;
for (;(node=dni.current());++dni)
{
node->writeXML(t,FALSE);
}
}

Member Data Documentation

int DotInclDepGraph::m_curNodeNumber = 0
staticprivate

Definition at line 225 of file dot.h.

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

QCString DotInclDepGraph::m_inclByDepFileName
private

Definition at line 227 of file dot.h.

Referenced by DotInclDepGraph(), and writeGraph().

QCString DotInclDepGraph::m_inclDepFileName
private

Definition at line 226 of file dot.h.

Referenced by DotInclDepGraph(), and writeGraph().

bool DotInclDepGraph::m_inverse
private

Definition at line 228 of file dot.h.

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

DotNode* DotInclDepGraph::m_startNode
private

Definition at line 223 of file dot.h.

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

QDict<DotNode>* DotInclDepGraph::m_usedNodes
private

Definition at line 224 of file dot.h.

Referenced by buildGraph(), DotInclDepGraph(), writeDocbook(), writeXML(), and ~DotInclDepGraph().


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