doxygen  1.8.18
About: Doxygen is a source code documentation generator tool for C++, C, Objective-C, C#, PHP, Java, Python, IDL (diverse flavors), Fortran, VHDL, Tcl, and to some extent D. Different output formats are supported.
  Fossies Dox: doxygen-1.8.18.src.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

dotgroupcollaboration.cpp
Go to the documentation of this file.
1 
16 #include "dotgroupcollaboration.h"
17 
18 #include "dotnode.h"
19 #include "classlist.h"
20 #include "doxygen.h"
21 #include "namespacedef.h"
22 #include "pagedef.h"
23 #include "util.h"
24 #include "config.h"
25 
26 #define DOT_TRANSPARENT Config_getBool(DOT_TRANSPARENT)
27 
29 {
30  QCString tmp_url = gd->getReference()+"$"+gd->getOutputFileBase();
31  m_usedNodes = new QDict<DotNode>(1009);
32  QCString tooltip = gd->briefDescriptionAsTooltip();
33  m_rootNode = new DotNode(getNextNodeNumber(), gd->groupTitle(), tooltip, tmp_url, TRUE );
35  m_usedNodes->insert(gd->name(), m_rootNode );
36  m_edges.setAutoDelete(TRUE);
37 
39 
40  buildGraph( gd );
41 }
42 
44 {
45  // delete all created Nodes saved in m_usedNodes:QDict
46  if(m_usedNodes != NULL)
47  {
49  for(;it.current(); ++it)
50  {
51  delete it.current();
52  }
53  }
54 
55  delete m_usedNodes;
56 }
57 
59 {
60  QCString tmp_url;
61  //===========================
62  // hierarchy.
63 
64  // Write parents
65  const GroupList *groups = gd->partOfGroups();
66  if ( groups )
67  {
68  GroupListIterator gli(*groups);
69  const GroupDef *d;
70  for (gli.toFirst();(d=gli.current());++gli)
71  {
72  DotNode* nnode = m_usedNodes->find(d->name());
73  if ( !nnode )
74  { // add node
75  tmp_url = d->getReference()+"$"+d->getOutputFileBase();
76  QCString tooltip = d->briefDescriptionAsTooltip();
77  nnode = new DotNode(getNextNodeNumber(), d->groupTitle(), tooltip, tmp_url );
78  nnode->markAsVisible();
79  m_usedNodes->insert(d->name(), nnode );
80  }
81  tmp_url = "";
82  addEdge( nnode, m_rootNode, DotGroupCollaboration::thierarchy, tmp_url, tmp_url );
83  }
84  }
85 
86  // Add subgroups
87  if ( gd->getSubGroups() && gd->getSubGroups()->count() )
88  {
90  const GroupDef *def;
91  for (;(def=defli.current());++defli)
92  {
93  DotNode* nnode = m_usedNodes->find(def->name());
94  if ( !nnode )
95  { // add node
96  tmp_url = def->getReference()+"$"+def->getOutputFileBase();
97  QCString tooltip = def->briefDescriptionAsTooltip();
98  nnode = new DotNode(getNextNodeNumber(), def->groupTitle(), tooltip, tmp_url );
99  nnode->markAsVisible();
100  m_usedNodes->insert(def->name(), nnode );
101  }
102  tmp_url = "";
103  addEdge( m_rootNode, nnode, DotGroupCollaboration::thierarchy, tmp_url, tmp_url );
104  }
105  }
106 
107  //=======================
108  // Write collaboration
109 
110  // Add members
112 
113  // Add classes
114  if ( gd->getClasses() && gd->getClasses()->count() )
115  {
116  ClassSDict::Iterator defli(*gd->getClasses());
117  ClassDef *def;
118  for (;(def=defli.current());++defli)
119  {
120  tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension;
121  if (!def->anchor().isEmpty())
122  {
123  tmp_url+="#"+def->anchor();
124  }
126  }
127  }
128 
129  // Add namespaces
130  if ( gd->getNamespaces() && gd->getNamespaces()->count() )
131  {
133  NamespaceDef *def;
134  for (;(def=defli.current());++defli)
135  {
136  tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension;
138  }
139  }
140 
141  // Add files
142  if ( gd->getFiles() && gd->getFiles()->count() )
143  {
144  QListIterator<FileDef> defli(*gd->getFiles());
145  const FileDef *def;
146  for (;(def=defli.current());++defli)
147  {
148  tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension;
150  }
151  }
152 
153  // Add pages
154  if ( gd->getPages() && gd->getPages()->count() )
155  {
156  PageSDict::Iterator defli(*gd->getPages());
157  PageDef *def;
158  for (;(def=defli.current());++defli)
159  {
160  tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension;
162  }
163  }
164 
165  // Add directories
166  if ( gd->getDirs() && gd->getDirs()->count() )
167  {
168  QListIterator<DirDef> defli(*gd->getDirs());
169  const DirDef *def;
170  for (;(def=defli.current());++defli)
171  {
172  tmp_url = def->getReference()+"$"+def->getOutputFileBase()+Doxygen::htmlFileExtension;
174  }
175  }
176 }
177 
179 {
180  if ( !( ml && ml->count()) ) return;
181  MemberListIterator defli(*ml);
182  MemberDef *def;
183  for (;(def=defli.current());++defli)
184  {
186  +"#"+def->anchor();
188  }
189 }
190 
192  DotNode* _pNStart, DotNode* _pNEnd, EdgeType _eType,
193  const QCString& _label, const QCString& _url )
194 {
195  // search a existing link.
197  Edge* newEdge = 0;
198  for ( lli.toFirst(); (newEdge=lli.current()); ++lli)
199  {
200  if ( newEdge->pNStart==_pNStart &&
201  newEdge->pNEnd==_pNEnd &&
202  newEdge->eType==_eType
203  )
204  { // edge already found
205  break;
206  }
207  }
208  if ( newEdge==0 ) // new link
209  {
210  newEdge = new Edge(_pNStart,_pNEnd,_eType);
211  m_edges.append( newEdge );
212  }
213 
214  if (!_label.isEmpty())
215  {
216  newEdge->links.append(new Link(_label,_url));
217  }
218 
219  return newEdge;
220 }
221 
223  const Definition* def, QCString& url, EdgeType eType )
224 {
225  // Create group nodes
226  if ( !def->partOfGroups() )
227  return;
228  GroupListIterator gli(*def->partOfGroups());
229  GroupDef *d;
230  QCString tmp_str;
231  for (;(d=gli.current());++gli)
232  {
233  DotNode* nnode = m_usedNodes->find(d->name());
234  if ( nnode != m_rootNode )
235  {
236  if ( nnode==0 )
237  { // add node
238  tmp_str = d->getReference()+"$"+d->getOutputFileBase();
239  QCString tooltip = d->briefDescriptionAsTooltip();
240  nnode = new DotNode(getNextNodeNumber(), d->groupTitle(), tooltip, tmp_str );
241  nnode->markAsVisible();
242  m_usedNodes->insert(d->name(), nnode );
243  }
244  tmp_str = def->qualifiedName();
245  addEdge( m_rootNode, nnode, eType, tmp_str, url );
246  }
247  }
248 }
249 
251 {
252  return m_diskName;
253 }
254 
256 {
257  FTextStream md5stream(&m_theGraph);
258  writeGraphHeader(md5stream,m_rootNode->label());
259 
260  // clean write flags
262  DotNode *pn;
263  for (dni.toFirst();(pn=dni.current());++dni)
264  {
265  pn->clearWriteFlag();
266  }
267 
268  // write other nodes.
269  for (dni.toFirst();(pn=dni.current());++dni)
270  {
272  }
273 
274  // write edges
276  Edge* edge;
277  for (eli.toFirst();(edge=eli.current());++eli)
278  {
279  edge->write( md5stream );
280  }
281 
282  writeGraphFooter(md5stream);
283 
284 }
285 
287 {
289 }
290 
292  GraphOutputFormat graphFormat, EmbeddedOutputFormat textFormat,
293  const char *path, const char *fileName, const char *relPath,
294  bool generateImageMap,int graphId)
295 {
297 
298  return DotGraph::writeGraph(t, graphFormat, textFormat, path, fileName, relPath, generateImageMap, graphId);
299 }
300 
302 {
303  const char* linkTypeColor[] = {
304  "darkorchid3"
305  ,"orange"
306  ,"blueviolet"
307  ,"darkgreen"
308  ,"firebrick4"
309  ,"grey75"
310  ,"midnightblue"
311  };
312  QCString arrowStyle = "dir=\"none\", style=\"dashed\"";
313  t << " Node" << pNStart->number();
314  t << "->";
315  t << "Node" << pNEnd->number();
316 
317  t << " [shape=plaintext";
318  if (links.count()>0) // there are links
319  {
320  t << ", ";
321  // HTML-like edge labels crash on my Mac with Graphviz 2.0! and
322  // are not supported by older version of dot.
323  //
324  //t << label=<<TABLE BORDER=\"0\" CELLBORDER=\"0\">";
325  //QListIterator<Link> lli(links);
326  //Link *link;
327  //for( lli.toFirst(); (link=lli.current()); ++lli)
328  //{
329  // t << "<TR><TD";
330  // if ( !link->url.isEmpty() )
331  // t << " HREF=\"" << link->url << "\"";
332  // t << ">" << link->label << "</TD></TR>";
333  //}
334  //t << "</TABLE>>";
335 
336  t << "label=\"";
338  Link *link;
339  bool first=TRUE;
340  int count=0;
341  const int maxLabels = 10;
342  for( lli.toFirst(); (link=lli.current()) && count<maxLabels; ++lli,++count)
343  {
344  if (first) first=FALSE; else t << "\\n";
345  t << DotNode::convertLabel(link->label);
346  }
347  if (count==maxLabels) t << "\\n...";
348  t << "\"";
349 
350  }
351  switch( eType )
352  {
353  case thierarchy:
354  arrowStyle = "dir=\"back\", style=\"solid\"";
355  break;
356  default:
357  t << ", color=\"" << linkTypeColor[(int)eType] << "\"";
358  break;
359  }
360  t << ", " << arrowStyle;
361  t << "];" << endl;
362 }
363 
365 {
366  return m_usedNodes->count() <= 1;
367 }
368 
370 {
371  int fontSize = Config_getInt(DOT_FONTSIZE);
372  QCString fontName = Config_getString(DOT_FONTNAME);
373  t << "digraph ";
374  if (title.isEmpty())
375  {
376  t << "\"Dot Graph\"";
377  }
378  else
379  {
380  t << "\"" << convertToXML(title) << "\"";
381  }
382  t << endl;
383  t << "{" << endl;
384  if (DOT_TRANSPARENT)
385  {
386  t << " bgcolor=\"transparent\";" << endl;
387  }
388  t << " edge [fontname=\"" << fontName << "\",fontsize=\"" << fontSize << "\","
389  "labelfontname=\"" << fontName << "\",labelfontsize=\"" << fontSize << "\"];\n";
390  t << " node [fontname=\"" << fontName << "\",fontsize=\"" << fontSize << "\",shape=box];\n";
391  t << " rankdir=LR;\n";
392 }
DotNode::markAsVisible
void markAsVisible(bool b=TRUE)
Definition: dotnode.h:102
QDictIterator
The QDictIterator class provides an iterator for QDict collections.
GroupDef::getClasses
virtual ClassSDict * getClasses() const =0
MemberDef::getReference
virtual QCString getReference() const =0
ClassDef::anchor
virtual QCString anchor() const =0
Definition::partOfGroups
virtual GroupList * partOfGroups() const =0
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition: qcstring.h:191
MemberListIterator
An iterator for MemberDef objects in a MemberList.
Definition: memberlist.h:124
DotNode::clearWriteFlag
void clearWriteFlag()
Definition: dotnode.cpp:814
PageDef
A model of a page symbol.
Definition: pagedef.h:30
DotGroupCollaboration::addEdge
Edge * addEdge(DotNode *_pNStart, DotNode *_pNEnd, EdgeType _eType, const QCString &_label, const QCString &_url)
Definition: dotgroupcollaboration.cpp:191
DotGroupCollaboration::thierarchy
@ thierarchy
Definition: dotgroupcollaboration.h:48
DotGroupCollaboration::getBaseName
virtual QCString getBaseName() const
Definition: dotgroupcollaboration.cpp:250
DotGroupCollaboration::Edge::eType
EdgeType eType
Definition: dotgroupcollaboration.h:66
ClassDef
A abstract class representing of a compound symbol.
Definition: classdef.h:61
pagedef.h
DotGroupCollaboration::m_edges
QList< Edge > m_edges
Definition: dotgroupcollaboration.h:82
MemberList::count
uint count() const
Definition: memberlist.cpp:277
dotnode.h
DotNode::convertLabel
static QCString convertLabel(const QCString &l)
Definition: dotnode.cpp:177
GroupDef::getFiles
virtual FileList * getFiles() const =0
FTextStream
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:12
MemberListType_allMembersList
@ MemberListType_allMembersList
Definition: types.h:147
escapeCharsInString
QCString escapeCharsInString(const char *name, bool allowDots, bool allowUnderscore)
Definition: util.cpp:4837
namespacedef.h
DotGraph::m_baseName
QCString m_baseName
Definition: dotgraph.h:87
QListIterator< GroupDef >
PageDef::getOutputFileBase
virtual QCString getOutputFileBase() const =0
DotGraph::m_graphFormat
GraphOutputFormat m_graphFormat
Definition: dotgraph.h:78
GroupDef::getPages
virtual PageSDict * getPages() const =0
DotGroupCollaboration::writeGraph
QCString writeGraph(FTextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const char *path, const char *fileName, const char *relPath, bool writeImageMap=TRUE, int graphId=-1)
Definition: dotgroupcollaboration.cpp:291
DotGroupCollaboration::EdgeType
EdgeType
Definition: dotgroupcollaboration.h:41
MemberDef::anchor
virtual QCString anchor() const =0
MemberDef::getOutputFileBase
virtual QCString getOutputFileBase() const =0
config.h
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:134
GroupDef::getOutputFileBase
virtual QCString getOutputFileBase() const =0
GroupDef
A model of a group of symbols.
Definition: groupdef.h:48
FileDef
A model of a file symbol.
Definition: filedef.h:65
Config_getString
#define Config_getString(val)
Definition: config.h:34
DotNode::write
void write(FTextStream &t, GraphType gt, GraphOutputFormat f, bool topDown, bool toChildren, bool backArrows) const
Definition: dotnode.cpp:555
DotGroupCollaboration::Edge
Definition: dotgroupcollaboration.h:59
MemberDef
A model of a class/file/namespace member symbol.
Definition: memberdef.h:45
TRUE
@ TRUE
Definition: mscgen_bool.h:29
FALSE
@ FALSE
Definition: mscgen_bool.h:28
convertToXML
QCString convertToXML(const char *s, bool keepEntities)
Definition: util.cpp:5386
classlist.h
DotGraph::m_theGraph
QGString m_theGraph
Definition: dotgraph.h:88
Doxygen::htmlFileExtension
static QCString htmlFileExtension
Definition: doxygen.h:119
DotGroupCollaboration::tnamespace
@ tnamespace
Definition: dotgroupcollaboration.h:44
NamespaceDef::getOutputFileBase
virtual QCString getOutputFileBase() const =0
dotgroupcollaboration.h
DotGroupCollaboration::Edge::links
QList< Link > links
Definition: dotgroupcollaboration.h:68
DotGroupCollaboration::~DotGroupCollaboration
~DotGroupCollaboration()
Definition: dotgroupcollaboration.cpp:43
NamespaceDef
An abstract interface of a namespace symbol.
Definition: namespacedef.h:38
GroupDef::getMemberList
virtual MemberList * getMemberList(MemberListType lt) const =0
doxygen.h
DotGroupCollaboration::tpages
@ tpages
Definition: dotgroupcollaboration.h:46
QList::count
uint count() const
Definition: qlist.h:66
QListIterator::current
type * current() const
Definition: qlist.h:147
Definition
The common base class of all entity definitions found in the sources.
Definition: definition.h:100
Definition::getReference
virtual QCString getReference() const =0
DotGroupCollaboration::tfile
@ tfile
Definition: dotgroupcollaboration.h:45
DotGraph::m_doNotAddImageToIndex
bool m_doNotAddImageToIndex
Definition: dotgraph.h:90
ClassDef::getReference
virtual QCString getReference() const =0
If this class originated from a tagfile, this will return the tag file reference.
FileDef::getOutputFileBase
virtual QCString getOutputFileBase() const =0
DotNode::number
int number() const
Definition: dotnode.h:84
DotGroupCollaboration::DotGroupCollaboration
DotGroupCollaboration(const GroupDef *gd)
Definition: dotgroupcollaboration.cpp:28
GroupListIterator
An iterator for GroupDef objects in a GroupList.
Definition: groupdef.h:137
DirDef
A model of a directory symbol.
Definition: dirdef.h:45
DOT_TRANSPARENT
#define DOT_TRANSPARENT
Copyright (C) 1997-2019 by Dimitri van Heesch.
Definition: dotgroupcollaboration.cpp:26
DotGroupCollaboration::buildGraph
void buildGraph(const GroupDef *gd)
Definition: dotgroupcollaboration.cpp:58
DotGroupCollaboration::m_usedNodes
QDict< DotNode > * m_usedNodes
Definition: dotgroupcollaboration.h:80
DotGraph::writeGraph
QCString writeGraph(FTextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const char *path, const char *fileName, const char *relPath, bool writeImageMap=TRUE, int graphId=-1)
Definition: dotgraph.cpp:114
QListIterator::toFirst
type * toFirst()
Definition: qlist.h:136
DotGroupCollaboration::tdir
@ tdir
Definition: dotgroupcollaboration.h:47
SDict< ClassDef >::Iterator
friend class Iterator
Definition: sortdict.h:285
DotGroupCollaboration::Edge::pNEnd
DotNode * pNEnd
Definition: dotgroupcollaboration.h:65
SDict::count
uint count() const
Definition: sortdict.h:280
DotGroupCollaboration::writeGraphHeader
void writeGraphHeader(FTextStream &t, const QCString &title) const
Definition: dotgroupcollaboration.cpp:369
GroupDef::getSubGroups
virtual GroupList * getSubGroups() const =0
GroupDef::groupTitle
virtual const char * groupTitle() const =0
DotGroupCollaboration::m_rootNode
DotNode * m_rootNode
Definition: dotgroupcollaboration.h:79
DotNode
A node in a dot graph.
Definition: dotnode.h:51
DotGroupCollaboration::addCollaborationMember
void addCollaborationMember(const Definition *def, QCString &url, EdgeType eType)
Definition: dotgroupcollaboration.cpp:222
Inheritance
@ Inheritance
Definition: dotgraph.h:28
DotGroupCollaboration::Edge::pNStart
DotNode * pNStart
Definition: dotgroupcollaboration.h:64
GroupDef::getDirs
virtual DirList * getDirs() const =0
GroupDef::getNamespaces
virtual NamespaceSDict * getNamespaces() const =0
EmbeddedOutputFormat
EmbeddedOutputFormat
Definition: dotgraph.h:27
GraphOutputFormat
GraphOutputFormat
Definition: dotgraph.h:26
DotGroupCollaboration::addMemberList
void addMemberList(class MemberList *ml)
Definition: dotgroupcollaboration.cpp:178
DotNode::label
QCString label() const
Definition: dotnode.h:83
GroupList
A list of GroupDef objects.
Definition: groupdef.h:127
DotGroupCollaboration::isTrivial
bool isTrivial() const
Definition: dotgroupcollaboration.cpp:364
DotGroupCollaboration::tmember
@ tmember
Definition: dotgroupcollaboration.h:42
Definition::name
virtual QCString name() const =0
DotGraph::writeGraphFooter
static void writeGraphFooter(FTextStream &t)
Definition: dotgraph.cpp:305
Config_getInt
#define Config_getInt(val)
Definition: config.h:36
Definition::briefDescriptionAsTooltip
virtual QCString briefDescriptionAsTooltip() const =0
endl
QTextStream & endl(QTextStream &s)
Definition: qtextstream.cpp:2030
QDict< DotNode >
DotGroupCollaboration::Edge::write
void write(FTextStream &t) const
Definition: dotgroupcollaboration.cpp:301
util.h
Copyright (C) 1997-2015 by Dimitri van Heesch.
Definition::qualifiedName
virtual QCString qualifiedName() const =0
ClassDef::getOutputFileBase
virtual QCString getOutputFileBase() const =0
Returns the unique base name (without extension) of the class's file on disk.
DotGroupCollaboration::tclass
@ tclass
Definition: dotgroupcollaboration.h:43
DotGroupCollaboration::computeTheGraph
virtual void computeTheGraph()
Definition: dotgroupcollaboration.cpp:255
MemberList
A list of MemberDef objects.
Definition: memberlist.h:32
DotGroupCollaboration::m_diskName
QCString m_diskName
Definition: dotgroupcollaboration.h:81
DotGraph::getNextNodeNumber
int getNextNodeNumber()
returns node numbers.
Definition: dotgraph.h:40
DotGroupCollaboration::getMapLabel
virtual QCString getMapLabel() const
Definition: dotgroupcollaboration.cpp:286
DirDef::getOutputFileBase
virtual QCString getOutputFileBase() const =0