Doxygen
Loading...
Searching...
No Matches
dotgroupcollaboration.cpp
Go to the documentation of this file.
1/******************************************************************************
2*
3* Copyright (C) 1997-2019 by Dimitri van Heesch.
4*
5* Permission to use, copy, modify, and distribute this software and its
6* documentation under the terms of the GNU General Public License is hereby
7* granted. No representations are made about the suitability of this software
8* for any purpose. It is provided "as is" without express or implied warranty.
9* See the GNU General Public License for more details.
10*
11* Documents produced by Doxygen are derivative works derived from the
12* input used in their production; they are not affected by this license.
13*
14*/
15
17#include "classlist.h"
18#include "doxygen.h"
19#include "namespacedef.h"
20#include "pagedef.h"
21#include "util.h"
22#include "config.h"
23#include "textstream.h"
24
26{
27 QCString tmp_url = gd->getReference()+"$"+gd->getOutputFileBase();
28 QCString tooltip = gd->briefDescriptionAsTooltip();
29 m_rootNode = new DotNode(this, gd->groupTitle(), tooltip, tmp_url, TRUE );
30 m_rootNode->markAsVisible();
31 m_usedNodes.emplace(gd->name().str(), m_rootNode);
32
34
35 buildGraph( gd );
36}
37
39{
40 // delete all created Nodes saved in m_usedNodes map
41 for (const auto &[name,node] : m_usedNodes)
42 {
43 delete node;
44 }
45}
46
47static void makeURL(const Definition *def,QCString &url)
48{
49 QCString fn = def->getOutputFileBase();
51 url = def->getReference()+"$"+fn;
52 if (!def->anchor().isEmpty())
53 {
54 url+="#"+def->anchor();
55 }
56}
57
59{
60 QCString url;
61 //===========================
62 // hierarchy.
63
64 // Write parents
65 for (const auto &d : gd->partOfGroups())
66 {
67 DotNode *nnode = nullptr;
68 auto it = m_usedNodes.find(d->name().str());
69 if ( it==m_usedNodes.end())
70 { // add node
71 makeURL(d,url);
72 QCString tooltip = d->briefDescriptionAsTooltip();
73 nnode = new DotNode(this, d->groupTitle(), tooltip, url );
74 nnode->markAsVisible();
75 m_usedNodes.emplace(d->name().str(), nnode);
76 }
77 else
78 {
79 nnode = it->second;
80 }
81 url = "";
83 }
84
85 // Add subgroups
86 for (const auto &def : gd->getSubGroups())
87 {
88 DotNode *nnode = nullptr;
89 auto it = m_usedNodes.find(def->name().str());
90 if ( it==m_usedNodes.end())
91 { // add node
92 makeURL(def,url);
93 QCString tooltip = def->briefDescriptionAsTooltip();
94 nnode = new DotNode(this, def->groupTitle(), tooltip, url );
95 nnode->markAsVisible();
96 m_usedNodes.emplace(def->name().str(), nnode);
97 }
98 else
99 {
100 nnode = it->second;
101 }
102 url = "";
104 }
105
106 //=======================
107 // Write collaboration
108
109 // Add members
110 addMemberList( gd->getMemberList(MemberListType::AllMembersList()) );
111
112 // Add classes
113 for (const auto &def : gd->getClasses())
114 {
115 makeURL(def,url);
117 }
118
119 // Add namespaces
120 for (const auto &def : gd->getNamespaces())
121 {
122 makeURL(def,url);
124 }
125
126 // Add files
127 for (const auto &def : gd->getFiles())
128 {
129 makeURL(def,url);
131 }
132
133 // Add pages
134 for (const auto &def : gd->getPages())
135 {
136 makeURL(def,url);
138 }
139
140 // Add directories
141 if ( !gd->getDirs().empty() )
142 {
143 for(const auto def : gd->getDirs())
144 {
145 makeURL(def,url);
147 }
148 }
149}
150
152{
153 QCString url;
154 if ( ml==nullptr || ml->empty() ) return;
155 for (const auto &def : *ml)
156 {
157 makeURL(def,url);
159 }
160}
161
163 DotNode* _pNStart, DotNode* _pNEnd, EdgeType _eType,
164 const QCString& _label, const QCString& _url )
165{
166 // search a existing link.
167 auto it = std::find_if(m_edges.begin(),m_edges.end(),
168 [&_pNStart,&_pNEnd,&_eType](const auto &edge)
169 { return edge->pNStart==_pNStart && edge->pNEnd==_pNEnd && edge->eType==_eType; });
170
171 if (it==m_edges.end()) // new link
172 {
173 m_edges.emplace_back(std::make_unique<Edge>(_pNStart,_pNEnd,_eType));
174 it = m_edges.end()-1;
175 }
176
177 if (!_label.isEmpty()) // add label
178 {
179 (*it)->links.emplace_back(_label,_url);
180 }
181
182 // return found or added edge
183 return (*it).get();
184}
185
187 const Definition* def, QCString& url, EdgeType eType )
188{
189 // Create group nodes
190 QCString tmp_str;
191 for (const auto &d : def->partOfGroups())
192 {
193 auto it = m_usedNodes.find(d->name().str());
194 DotNode* nnode = it!=m_usedNodes.end() ? it->second : nullptr;
195 if ( nnode != m_rootNode )
196 {
197 if ( nnode==nullptr )
198 { // add node
199 tmp_str = d->getReference()+"$"+d->getOutputFileBase();
200 QCString tooltip = d->briefDescriptionAsTooltip();
201 nnode = new DotNode(this, d->groupTitle(), tooltip, tmp_str );
202 nnode->markAsVisible();
203 m_usedNodes.emplace(d->name().str(), nnode);
204 }
205 tmp_str = def->qualifiedName();
206 addEdge( m_rootNode, nnode, eType, tmp_str, url );
207 }
208 }
209}
210
215
217{
218 TextStream md5stream;
219 writeGraphHeader(md5stream,m_rootNode->label());
220
221 // clean write flags
222 for (const auto &[name,node] : m_usedNodes)
223 {
224 node->clearWriteFlag();
225 }
226
227 // write other nodes.
228 for (const auto &[name,node] : m_usedNodes)
229 {
230 node->write(md5stream,GraphType::Inheritance,m_graphFormat,TRUE,FALSE,FALSE);
231 }
232
233 // write edges
234 for (const auto &edge : m_edges)
235 {
236 edge->write( md5stream );
237 }
238
239 writeGraphFooter(md5stream);
240
241 m_theGraph = md5stream.str();
242}
243
248
250 GraphOutputFormat graphFormat, EmbeddedOutputFormat textFormat,
251 const QCString &path, const QCString &fileName, const QCString &relPath,
252 bool generateImageMap,int graphId)
253{
255
256 return DotGraph::writeGraph(t, graphFormat, textFormat, path, fileName, relPath, generateImageMap, graphId);
257}
258
260{
261 const char* linkTypeColor[] = {
262 "darkorchid3"
263 ,"orange"
264 ,"blueviolet"
265 ,"darkgreen"
266 ,"firebrick4"
267 ,"grey75"
268 ,"midnightblue"
269 };
270 QCString arrowStyle = "dir=\"none\", style=\"dashed\"";
271 t << " Node" << pNStart->number();
272 t << "->";
273 t << "Node" << pNEnd->number();
274
275 t << " [shape=plaintext";
276 if (!links.empty()) // there are links
277 {
278 t << ", ";
279 // HTML-like edge labels crash on my Mac with Graphviz 2.0! and
280 // are not supported by older version of dot.
281 //
282 //t << label=<<TABLE BORDER=\"0\" CELLBORDER=\"0\">";
283 //for (const auto &link : links)
284 //{
285 // t << "<TR><TD";
286 // if ( !link.url.isEmpty() )
287 // t << " HREF=\"" << link.url << "\"";
288 // t << ">" << DotNode::convertLabel(link->label) << "</TD></TR>";
289 //}
290 //t << "</TABLE>>";
291
292 t << "label=\"";
293 bool first=TRUE;
294 int count=0;
295 const int maxLabels = 10;
296 for (const auto &link : links)
297 {
298 if (first) first=FALSE; else t << "\\n";
299 t << DotNode::convertLabel(link.label);
300 count++;
301 }
302 if (count==maxLabels) t << "\\n...";
303 t << "\"";
304
305 }
306 switch( eType )
307 {
308 case thierarchy:
309 arrowStyle = "dir=\"back\", style=\"solid\"";
310 break;
311 default:
312 t << ", color=\"" << linkTypeColor[static_cast<int>(eType)] << "\"";
313 break;
314 }
315 t << ", " << arrowStyle;
316 t << "];\n";
317}
318
320{
321 return m_usedNodes.size() <= 1;
322}
323
325{
326 return numNodes()>=Config_getInt(DOT_GRAPH_MAX_NODES);
327}
328
330{
331 return static_cast<int>(m_usedNodes.size());
332}
333
335{
337 t << " rankdir=LR;\n";
338}
The common base class of all entity definitions found in the sources.
Definition definition.h:76
virtual QCString anchor() const =0
virtual QCString briefDescriptionAsTooltip() const =0
virtual QCString getReference() const =0
virtual const GroupList & partOfGroups() const =0
virtual QCString qualifiedName() const =0
virtual QCString getOutputFileBase() const =0
virtual const QCString & name() const =0
static void writeGraphFooter(TextStream &t)
Definition dotgraph.cpp:301
GraphOutputFormat m_graphFormat
Definition dotgraph.h:85
static void writeGraphHeader(TextStream &t, const QCString &title=QCString())
Definition dotgraph.cpp:276
bool m_doNotAddImageToIndex
Definition dotgraph.h:97
QCString m_theGraph
Definition dotgraph.h:95
QCString m_baseName
Definition dotgraph.h:94
QCString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)
Definition dotgraph.cpp:115
friend class DotNode
Definition dotgraph.h:36
std::vector< std::unique_ptr< Edge > > m_edges
QCString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)
DotGroupCollaboration(const GroupDef *gd)
QCString getMapLabel() const override
void addMemberList(class MemberList *ml)
void writeGraphHeader(TextStream &t, const QCString &title) const
void addCollaborationMember(const Definition *def, QCString &url, EdgeType eType)
Edge * addEdge(DotNode *_pNStart, DotNode *_pNEnd, EdgeType _eType, const QCString &_label, const QCString &_url)
QCString getBaseName() const override
void buildGraph(const GroupDef *gd)
void markAsVisible(bool b=TRUE)
Definition dotnode.h:120
static QCString convertLabel(const QCString &, bool htmlLike=false)
Definition dotnode.cpp:196
A model of a group of symbols.
Definition groupdef.h:52
virtual const DirList & getDirs() const =0
virtual const GroupList & getSubGroups() const =0
virtual QCString groupTitle() const =0
virtual const FileList & getFiles() const =0
virtual const PageLinkedRefMap & getPages() const =0
virtual const NamespaceLinkedRefMap & getNamespaces() const =0
virtual const ClassLinkedRefMap & getClasses() const =0
virtual MemberList * getMemberList(MemberListType lt) const =0
A list of MemberDef objects as shown in documentation sections.
Definition memberlist.h:108
bool empty() const noexcept
Definition memberlist.h:59
This is an alternative implementation of QCString.
Definition qcstring.h:101
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
const std::string & str() const
Definition qcstring.h:537
Text streaming class that buffers data.
Definition textstream.h:36
std::string str() const
Return the contents of the buffer as a std::string object.
Definition textstream.h:229
#define Config_getInt(name)
Definition config.h:34
@ Inheritance
Definition dotgraph.h:31
EmbeddedOutputFormat
Definition dotgraph.h:30
GraphOutputFormat
Definition dotgraph.h:29
static void makeURL(const Definition *def, QCString &url)
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
void write(TextStream &t) const
QCString escapeCharsInString(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:3684
void addHtmlExtensionIfMissing(QCString &fName)
Definition util.cpp:5243
A bunch of utility functions.