Doxygen
Loading...
Searching...
No Matches
dotincldepgraph.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
16#include "dotincldepgraph.h"
17#include "dotnode.h"
18#include "util.h"
19#include "config.h"
20#include "textstream.h"
21
22void DotInclDepGraph::buildGraph(DotNode *n,const FileDef *fd,int distance)
23{
24 const IncludeInfoList &includeFiles = m_inverse ? fd->includedByFileList() : fd->includeFileList();
25 for (const auto &ii : includeFiles)
26 {
27 const FileDef *bfd = ii.fileDef;
28 QCString in = ii.includeName;
29 //printf(">>>> in='%s' bfd=%p\n",qPrint(ii->includeName),bfd);
30 bool doc=TRUE,src=FALSE;
31 if (bfd)
32 {
33 in = bfd->absFilePath();
34 doc = bfd->isLinkable() && !bfd->isHidden();
35 src = bfd->generateSourceFile();
36 }
37 if (doc || src || !Config_getBool(HIDE_UNDOC_RELATIONS))
38 {
39 QCString url="";
40 if (bfd) url=bfd->getOutputFileBase();
41 if (!doc && src)
42 {
43 url=bfd->getSourceFileBase();
44 }
45 auto it = m_usedNodes.find(in.str());
46 if (it!=m_usedNodes.end()) // file is already a node in the graph
47 {
48 DotNode *bn = it->second;
50 bn->addParent(n);
51 bn->setDistance(distance);
52 }
53 else
54 {
55 QCString tmp_url;
56 QCString tooltip;
57 if (bfd)
58 {
59 tmp_url=doc || src ? bfd->getReference()+"$"+url : QCString();
60 tooltip = bfd->briefDescriptionAsTooltip();
61 }
62 DotNode *bn = new DotNode(this,
63 ii.includeName, // label
64 tooltip, // tip
65 tmp_url, // url
66 FALSE, // rootNode
67 nullptr); // cd
69 bn->addParent(n);
70 m_usedNodes.emplace(in.str(),bn);
71 bn->setDistance(distance);
72
73 if (bfd) buildGraph(bn,bfd,distance+1);
74 }
75 }
76 }
77}
78
80{
81 while (!queue.empty() && maxNodes>0)
82 {
83 DotNode *n = queue.front();
84 queue.pop_front();
85 if (!n->isVisible() && n->distance()<=Config_getInt(MAX_DOT_GRAPH_DEPTH)) // not yet processed
86 {
87 n->markAsVisible();
88 maxNodes--;
89 // add direct children
90 for (const auto &dn : n->children())
91 {
92 queue.push_back(dn);
93 }
94 }
95 }
96}
97
99{
100 while (!queue.empty())
101 {
102 DotNode *n = queue.front();
103 queue.pop_front();
104 if (n->isVisible() && n->isTruncated()==DotNode::Unknown)
105 {
106 bool truncated = FALSE;
107 for (const auto &dn : n->children())
108 {
109 if (!dn->isVisible())
110 {
111 truncated = TRUE;
112 }
113 else
114 {
115 queue.push_back(dn);
116 }
117 }
118 n->markAsTruncated(truncated);
119 }
120 }
121}
122
124{
125 m_inverse = inverse;
126 ASSERT(fd!=nullptr);
129 QCString tmp_url=fd->getReference()+"$"+fd->getOutputFileBase();
130 QCString tooltip = fd->briefDescriptionAsTooltip();
131 m_startNode = new DotNode(this,
132 fd->docName(),
133 tooltip,
134 tmp_url,
135 TRUE); // root node
136 m_startNode->setDistance(0);
137 m_usedNodes.emplace(fd->absFilePath().str(),m_startNode);
139
140 int maxNodes = Config_getInt(DOT_GRAPH_MAX_NODES);
141 DotNodeDeque openNodeQueue;
142 openNodeQueue.push_back(m_startNode);
143 determineVisibleNodes(openNodeQueue,maxNodes);
144 openNodeQueue.clear();
145 openNodeQueue.push_back(m_startNode);
146 determineTruncatedNodes(openNodeQueue);
147}
148
153
155{
156 if (m_inverse)
157 {
158 return m_inclByDepFileName;
159 }
160 else
161 {
162 return m_inclDepFileName;
163 }
164}
165
171
173{
174 if (m_inverse)
175 {
176 return escapeCharsInString(m_startNode->label(),FALSE) + "dep";
177 }
178 else
179 {
180 return escapeCharsInString(m_startNode->label(),FALSE);
181 }
182}
183
185 GraphOutputFormat graphFormat,
186 EmbeddedOutputFormat textFormat,
187 const QCString &path,
188 const QCString &fileName,
189 const QCString &relPath,
190 bool generateImageMap,
191 int graphId)
192{
193 return DotGraph::writeGraph(out, graphFormat, textFormat, path, fileName, relPath, generateImageMap, graphId);
194}
195
197{
198 return m_startNode->children().empty();
199}
200
202{
203 return numNodes()>=Config_getInt(DOT_GRAPH_MAX_NODES);
204}
205
207{
208 return static_cast<int>(m_startNode->children().size());
209}
210
212{
213 for (const auto &[name,node] : m_usedNodes)
214 {
215 node->writeXML(t,FALSE);
216 }
217}
218
220{
221 for (const auto &[name,node] : m_usedNodes)
222 {
223 node->writeDocbook(t,FALSE);
224 }
225}
virtual bool isLinkable() const =0
virtual QCString briefDescriptionAsTooltip() const =0
virtual bool isHidden() const =0
virtual QCString getReference() const =0
virtual QCString getSourceFileBase() const =0
virtual QCString getOutputFileBase() const =0
static void computeGraph(DotNode *root, GraphType gt, GraphOutputFormat format, const QCString &rank, bool renderParents, bool backArrows, const QCString &title, QCString &graphStr)
Definition dotgraph.cpp:306
GraphOutputFormat m_graphFormat
Definition dotgraph.h:85
QCString m_theGraph
Definition dotgraph.h:95
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
void computeTheGraph() override
QCString writeGraph(TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)
void determineVisibleNodes(DotNodeDeque &queue, int &maxNodes)
void writeXML(TextStream &t)
DotNodeMap m_usedNodes
QCString m_inclDepFileName
void determineTruncatedNodes(DotNodeDeque &queue)
void writeDocbook(TextStream &t)
DotInclDepGraph(const FileDef *fd, bool inverse)
bool isTooBig() const
DotNode * m_startNode
QCString getBaseName() const override
void buildGraph(DotNode *n, const FileDef *fd, int distance)
QCString getMapLabel() const override
~DotInclDepGraph() override
QCString m_inclByDepFileName
bool isTrivial() const
int distance() const
Definition dotnode.h:106
void setDistance(int distance)
Definition dotnode.cpp:366
void markAsVisible(bool b=TRUE)
Definition dotnode.h:120
DotNode & markAsTruncated(bool b=TRUE)
Definition dotnode.h:121
static void deleteNodes(DotNode *node)
Definition dotnode.cpp:380
void addParent(DotNode *n)
Definition dotnode.cpp:331
bool isVisible() const
Definition dotnode.h:104
@ Unknown
Definition dotnode.h:76
void addChild(DotNode *n, EdgeInfo::Colors edgeColor=EdgeInfo::Purple, EdgeInfo::Styles edgeStyle=EdgeInfo::Solid, const QCString &edgeLab=QCString(), const QCString &edgeURL=QCString(), int edgeLabCol=-1)
Definition dotnode.cpp:314
const DotNodeRefVector & children() const
Definition dotnode.h:122
TruncState isTruncated() const
Definition dotnode.h:105
@ Solid
Definition dotnode.h:36
A model of a file symbol.
Definition filedef.h:99
virtual bool generateSourceFile() const =0
virtual QCString absFilePath() const =0
virtual QCString includedByDependencyGraphFileName() const =0
virtual const IncludeInfoList & includeFileList() const =0
virtual const QCString & docName() const =0
virtual QCString includeDependencyGraphFileName() const =0
virtual const IncludeInfoList & includedByFileList() const =0
This is an alternative implementation of QCString.
Definition qcstring.h:101
const std::string & str() const
Definition qcstring.h:537
Text streaming class that buffers data.
Definition textstream.h:36
#define Config_getInt(name)
Definition config.h:34
#define Config_getBool(name)
Definition config.h:33
@ Dependency
Definition dotgraph.h:31
EmbeddedOutputFormat
Definition dotgraph.h:30
GraphOutputFormat
Definition dotgraph.h:29
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
#define ASSERT(x)
Definition qcstring.h:39
QCString escapeCharsInString(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:3684
A bunch of utility functions.