My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
DotGroupCollaboration Class Reference

#include <dot.h>

Classes

class  Edge
 
class  Link
 

Public Types

enum  EdgeType {
  tmember = 0, tclass, tnamespace, tfile,
  tpages, tdir, thierarchy
}
 

Public Member Functions

 DotGroupCollaboration (GroupDef *gd)
 
 ~DotGroupCollaboration ()
 
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 (GroupDef *gd)
 
bool isTrivial () const
 

Static Public Member Functions

static void resetNumbering ()
 

Private Member Functions

void addCollaborationMember (Definition *def, QCString &url, EdgeType eType)
 
void addMemberList (class MemberList *ml)
 
void writeGraphHeader (FTextStream &t, const QCString &title) const
 
EdgeaddEdge (DotNode *_pNStart, DotNode *_pNEnd, EdgeType _eType, const QCString &_label, const QCString &_url)
 

Private Attributes

DotNodem_rootNode
 
QDict< DotNode > * m_usedNodes
 
QCString m_diskName
 
QList< Edgem_edges
 

Static Private Attributes

static int m_curNodeNumber = 0
 

Detailed Description

Representation of a group collaboration graph

Definition at line 278 of file dot.h.

Member Enumeration Documentation

Enumerator
tmember 
tclass 
tnamespace 
tfile 
tpages 
tdir 
thierarchy 

Definition at line 281 of file dot.h.

Constructor & Destructor Documentation

DotGroupCollaboration::DotGroupCollaboration ( GroupDef gd)

Definition at line 4258 of file dot.cpp.

References buildGraph(), GroupDef::getOutputFileBase(), Definition::getReference(), GroupDef::groupTitle(), m_curNodeNumber, m_diskName, m_edges, m_rootNode, m_usedNodes, DotNode::markAsVisible(), and Definition::name().

{
QCString tmp_url = gd->getReference()+"$"+gd->getOutputFileBase();
m_usedNodes = new QDict<DotNode>(1009);
m_rootNode = new DotNode(m_curNodeNumber++, gd->groupTitle(), "", tmp_url, TRUE );
m_rootNode->markAsVisible();
m_usedNodes->insert(gd->name(), m_rootNode );
m_edges.setAutoDelete(TRUE);
buildGraph( gd );
}
DotGroupCollaboration::~DotGroupCollaboration ( )

Definition at line 4272 of file dot.cpp.

References m_usedNodes.

{
delete m_usedNodes;
}

Member Function Documentation

void DotGroupCollaboration::addCollaborationMember ( Definition def,
QCString &  url,
EdgeType  eType 
)
private

Definition at line 4441 of file dot.cpp.

References addEdge(), m_curNodeNumber, m_rootNode, m_usedNodes, DotNode::markAsVisible(), Definition::partOfGroups(), and Definition::qualifiedName().

Referenced by addMemberList(), and buildGraph().

{
// Create group nodes
if ( !def->partOfGroups() )
return;
QCString tmp_str;
for (;(d=gli.current());++gli)
{
DotNode* nnode = m_usedNodes->find(d->name());
if ( nnode != m_rootNode )
{
if ( nnode==0 )
{ // add node
tmp_str = d->getReference()+"$"+d->getOutputFileBase();
QCString tooltip = d->briefDescriptionAsTooltip();
nnode = new DotNode(m_curNodeNumber++, d->groupTitle(), tooltip, tmp_str );
nnode->markAsVisible();
m_usedNodes->insert(d->name(), nnode );
}
tmp_str = def->qualifiedName();
addEdge( m_rootNode, nnode, eType, tmp_str, url );
}
}
}
DotGroupCollaboration::Edge * DotGroupCollaboration::addEdge ( DotNode _pNStart,
DotNode _pNEnd,
EdgeType  _eType,
const QCString &  _label,
const QCString &  _url 
)
private

Definition at line 4410 of file dot.cpp.

References DotGroupCollaboration::Edge::eType, DotGroupCollaboration::Edge::links, m_edges, DotGroupCollaboration::Edge::pNEnd, and DotGroupCollaboration::Edge::pNStart.

Referenced by addCollaborationMember(), and buildGraph().

{
// search a existing link.
QListIterator<Edge> lli(m_edges);
Edge* newEdge = 0;
for ( lli.toFirst(); (newEdge=lli.current()); ++lli)
{
if ( newEdge->pNStart==_pNStart &&
newEdge->pNEnd==_pNEnd &&
newEdge->eType==_eType
)
{ // edge already found
break;
}
}
if ( newEdge==0 ) // new link
{
newEdge = new Edge(_pNStart,_pNEnd,_eType);
m_edges.append( newEdge );
}
if (!_label.isEmpty())
{
newEdge->links.append(new Link(_label,_url));
}
return newEdge;
}
void DotGroupCollaboration::addMemberList ( class MemberList ml)
private

Definition at line 4397 of file dot.cpp.

References addCollaborationMember(), MemberDef::anchor(), MemberList::count(), MemberDef::getOutputFileBase(), MemberDef::getReference(), Doxygen::htmlFileExtension, and tmember.

Referenced by buildGraph().

{
if ( !( ml && ml->count()) ) return;
MemberListIterator defli(*ml);
MemberDef *def;
for (;(def=defli.current());++defli)
{
QCString tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension
+"#"+def->anchor();
}
}
void DotGroupCollaboration::buildGraph ( GroupDef gd)

Definition at line 4277 of file dot.cpp.

References addCollaborationMember(), addEdge(), addMemberList(), Definition::briefDescriptionAsTooltip(), SDict< T >::count(), GroupDef::getClasses(), GroupDef::getDirs(), GroupDef::getFiles(), GroupDef::getMemberList(), GroupDef::getNamespaces(), GroupDef::getOutputFileBase(), GroupDef::getPages(), ClassDef::getReference(), Definition::getReference(), GroupDef::getSubGroups(), GroupDef::groupTitle(), Doxygen::htmlFileExtension, SDict< PageDef >::Iterator, SDict< ClassDef >::Iterator, SDict< NamespaceDef >::Iterator, m_curNodeNumber, m_rootNode, m_usedNodes, DotNode::markAsVisible(), MemberListType_allMembersList, Definition::name(), Definition::partOfGroups(), tclass, tdir, tfile, thierarchy, tnamespace, and tpages.

Referenced by DotGroupCollaboration().

{
QCString tmp_url;
//===========================
// hierarchy.
// Write parents
GroupList *groups = gd->partOfGroups();
if ( groups )
{
GroupListIterator gli(*groups);
for (gli.toFirst();(d=gli.current());++gli)
{
DotNode* nnode = m_usedNodes->find(d->name());
if ( !nnode )
{ // add node
tmp_url = d->getReference()+"$"+d->getOutputFileBase();
QCString tooltip = d->briefDescriptionAsTooltip();
nnode = new DotNode(m_curNodeNumber++, d->groupTitle(), tooltip, tmp_url );
nnode->markAsVisible();
m_usedNodes->insert(d->name(), nnode );
}
tmp_url = "";
}
}
// Add subgroups
if ( gd->getSubGroups() && gd->getSubGroups()->count() )
{
QListIterator<GroupDef> defli(*gd->getSubGroups());
GroupDef *def;
for (;(def=defli.current());++defli)
{
DotNode* nnode = m_usedNodes->find(def->name());
if ( !nnode )
{ // add node
tmp_url = def->getReference()+"$"+def->getOutputFileBase();
QCString tooltip = def->briefDescriptionAsTooltip();
nnode = new DotNode(m_curNodeNumber++, def->groupTitle(), tooltip, tmp_url );
nnode->markAsVisible();
m_usedNodes->insert(def->name(), nnode );
}
tmp_url = "";
}
}
//=======================
// Write collaboration
// Add members
// Add classes
if ( gd->getClasses() && gd->getClasses()->count() )
{
ClassDef *def;
for (;(def=defli.current());++defli)
{
tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension;
if (!def->anchor().isEmpty())
{
tmp_url+="#"+def->anchor();
}
}
}
// Add namespaces
if ( gd->getNamespaces() && gd->getNamespaces()->count() )
{
for (;(def=defli.current());++defli)
{
tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension;
}
}
// Add files
if ( gd->getFiles() && gd->getFiles()->count() )
{
QListIterator<FileDef> defli(*gd->getFiles());
FileDef *def;
for (;(def=defli.current());++defli)
{
tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension;
}
}
// Add pages
if ( gd->getPages() && gd->getPages()->count() )
{
PageDef *def;
for (;(def=defli.current());++defli)
{
tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension;
}
}
// Add directories
if ( gd->getDirs() && gd->getDirs()->count() )
{
QListIterator<DirDef> defli(*gd->getDirs());
DirDef *def;
for (;(def=defli.current());++defli)
{
tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension;
}
}
}
bool DotGroupCollaboration::isTrivial ( ) const

Definition at line 4690 of file dot.cpp.

References m_usedNodes.

Referenced by ModuleContext::Private::hasGroupGraph(), and GroupDef::writeGroupGraph().

{
return m_usedNodes->count() <= 1;
}
void DotGroupCollaboration::resetNumbering ( )
static

Definition at line 4253 of file dot.cpp.

References m_curNodeNumber.

Referenced by resetDotNodeNumbering().

{
}
QCString DotGroupCollaboration::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 4470 of file dot.cpp.

References DotManager::addFigure(), DotRunner::addJob(), DotManager::addMap(), DotManager::addRun(), DotManager::addSVGConversion(), DotManager::addSVGObject(), checkAndUpdateMd5Signature(), checkDeliverables(), DotNode::clearWriteFlag(), Config_getBool, Config_getEnum, endl(), EOF_DocBook, err(), escapeCharsInString(), getDotImageExtension(), GOF_BITMAP, GOF_EPS, DotNode::Inheritance, insertMapFile(), DotManager::instance(), DotNode::label(), m_diskName, m_edges, m_rootNode, m_usedNodes, MAP_CMD, removeDotGraph(), DotNode::write(), DotGroupCollaboration::Edge::write(), writeGraphFooter(), writeGraphHeader(), writeSVGFigureLink(), and writeVecGfxFigure().

Referenced by LatexGenerator::endGroupCollaboration(), HtmlGenerator::endGroupCollaboration(), and ModuleContext::Private::groupGraph().

{
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);
QGString theGraph;
FTextStream md5stream(&theGraph);
// clean write flags
QDictIterator<DotNode> dni(*m_usedNodes);
DotNode *pn;
for (dni.toFirst();(pn=dni.current());++dni)
{
}
// write other nodes.
for (dni.toFirst();(pn=dni.current());++dni)
{
pn->write(md5stream,DotNode::Inheritance,graphFormat,TRUE,FALSE,FALSE);
}
// write edges
QListIterator<Edge> eli(m_edges);
Edge* edge;
for (eli.toFirst();(edge=eli.current());++eli)
{
edge->write( md5stream );
}
writeGraphFooter(md5stream);
uchar md5_sig[16];
QCString sigStr(33);
MD5Buffer((const unsigned char *)theGraph.data(),theGraph.length(),md5_sig);
MD5SigToString(md5_sig,sigStr.rawData(),33);
QCString imgExt = getDotImageExtension();
QCString imgFmt = Config_getEnum(DOT_IMAGE_FORMAT);
QCString baseName = m_diskName;
QCString imgName = baseName+"."+imgExt;
QCString absPath = d.absPath().data();
QCString absBaseName = absPath+"/"+baseName;
QCString absDotName = absBaseName+".dot";
QCString absImgName = absBaseName+"."+imgExt;
QCString absMapName = absBaseName+".map";
QCString absPdfName = absBaseName+".pdf";
QCString absEpsName = absBaseName+".eps";
bool regenerate=FALSE;
if (checkAndUpdateMd5Signature(absBaseName,sigStr) ||
!checkDeliverables(graphFormat==GOF_BITMAP ? absImgName :
usePDFLatex ? absPdfName : absEpsName,
graphFormat==GOF_BITMAP /*&& generateImageMap*/ ? absMapName : QCString())
)
{
regenerate=TRUE;
QFile dotfile(absDotName);
if (dotfile.open(IO_WriteOnly))
{
FTextStream tdot(&dotfile);
tdot << theGraph;
dotfile.close();
}
if (graphFormat==GOF_BITMAP) // run dot to create a bitmap image
{
DotRunner *dotRun = new DotRunner(absDotName,d.absPath().data(),FALSE);
dotRun->addJob(imgFmt,absImgName);
if (writeImageMap) 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);
}
}
}
if (graphFormat==GOF_BITMAP && textFormat==EOF_DocBook)
{
t << "<para>" << endl;
t << " <figure>" << endl;
t << " <title>Group Collaboration diagram";
t << "</title>" << endl;
t << " <mediaobject>" << endl;
t << " <imageobject>" << endl;
t << " <imagedata";
t << " width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"1\" fileref=\"" << relPath << baseName << "." << imgExt << "\">";
t << "</imagedata>" << endl;
t << " </imageobject>" << endl;
t << " </mediaobject>" << endl;
t << " </figure>" << endl;
t << "</para>" << endl;
}
else if (graphFormat==GOF_BITMAP && writeImageMap)
{
QCString mapLabel = escapeCharsInString(baseName,FALSE);
t << "<center><table><tr><td>";
if (imgExt=="svg")
{
t << "<div class=\"center\">";
if (regenerate || !writeSVGFigureLink(t,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);
t << "<!-- SVG " << mapId << " -->" << endl;
}
t << "</div>" << endl;
}
else
{
t << "<img src=\"" << relPath << imgName
<< "\" border=\"0\" alt=\"\" usemap=\"#"
<< mapLabel << "\"/>" << endl;
if (regenerate || !insertMapFile(t,absMapName,relPath,mapLabel))
{
int mapId = DotManager::instance()->addMap(fileName,absMapName,relPath,
FALSE,QCString(),mapLabel);
t << "<!-- MAP " << mapId << " -->" << endl;
}
}
t << "</td></tr></table></center>" << endl;
}
else if (graphFormat==GOF_EPS)
{
if (regenerate || !writeVecGfxFigure(t,baseName,absBaseName))
{
int figId = DotManager::instance()->addFigure(fileName,baseName,absBaseName,FALSE);
t << endl << "% FIG " << figId << endl;
}
}
if (!regenerate) removeDotGraph(absDotName);
return baseName;
}
void DotGroupCollaboration::writeGraphHeader ( FTextStream t,
const QCString &  title 
) const
private

Definition at line 4695 of file dot.cpp.

References Config_getBool, convertToXML(), endl(), FONTNAME, and FONTSIZE.

Referenced by writeGraph().

{
t << "digraph ";
if (title.isEmpty())
{
t << "\"Dot Graph\"";
}
else
{
t << "\"" << convertToXML(title) << "\"";
}
t << endl;
t << "{" << endl;
if (Config_getBool(DOT_TRANSPARENT))
{
t << " bgcolor=\"transparent\";" << endl;
}
t << " edge [fontname=\"" << FONTNAME << "\",fontsize=\"" << FONTSIZE << "\","
"labelfontname=\"" << FONTNAME << "\",labelfontsize=\"" << FONTSIZE << "\"];\n";
t << " node [fontname=\"" << FONTNAME << "\",fontsize=\"" << FONTSIZE << "\",shape=record];\n";
t << " rankdir=LR;\n";
}

Member Data Documentation

int DotGroupCollaboration::m_curNodeNumber = 0
staticprivate

Definition at line 331 of file dot.h.

Referenced by addCollaborationMember(), buildGraph(), DotGroupCollaboration(), and resetNumbering().

QCString DotGroupCollaboration::m_diskName
private

Definition at line 333 of file dot.h.

Referenced by DotGroupCollaboration(), and writeGraph().

QList<Edge> DotGroupCollaboration::m_edges
private

Definition at line 334 of file dot.h.

Referenced by addEdge(), DotGroupCollaboration(), and writeGraph().

DotNode* DotGroupCollaboration::m_rootNode
private

Definition at line 330 of file dot.h.

Referenced by addCollaborationMember(), buildGraph(), DotGroupCollaboration(), and writeGraph().

QDict<DotNode>* DotGroupCollaboration::m_usedNodes
private

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