Skip to main content

The DotGraph Class Reference

A dot graph. More...

Declaration

class DotGraph { ... }

Included Headers

#include <src/dotgraph.h>

Derived Classes

classDotCallGraph

Representation of an call graph. More...

classDotClassGraph

Representation of a class inheritance or dependency graph. More...

classDotDirDeps

Representation of an directory dependency graph. More...

classDotGfxHierarchyTable

Represents a graphical class hierarchy. More...

classDotGroupCollaboration

Representation of a group collaboration graph. More...

classDotInclDepGraph

Representation of an include dependency graph. More...

classDotLegendGraph

Representation of a legend explaining the meaning of boxes, arrows, and colors. More...

Friends Index

classDotNode

Public Constructors Index

DotGraph ()

Public Destructor Index

~DotGraph ()=default

Protected Member Functions Index

intgetNextNodeNumber ()

returns the node number. More...

intgetNextEdgeNumber ()

returns the edge number. More...

QCStringwriteGraph (TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)
QCStringgetBaseName () const =0
QCStringabsMapName () const
QCStringgetMapLabel () const =0
QCStringgetImgAltText () const
voidcomputeTheGraph ()=0
QCStringabsBaseName () const
QCStringabsDotName () const
QCStringimgName () const
QCStringabsImgName () const
QCStringrelImgName () const

Private Member Functions Index

boolprepareDotFile ()
voidgenerateCode (TextStream &t)

Protected Member Attributes Index

GraphOutputFormatm_graphFormat = GraphOutputFormat::BITMAP
EmbeddedOutputFormatm_textFormat = EmbeddedOutputFormat::Html
Dirm_dir
QCStringm_fileName
QCStringm_relPath
boolm_generateImageMap = false
intm_graphId = 0
QCStringm_absPath
QCStringm_baseName
QCStringm_theGraph
boolm_regenerate = false
boolm_doNotAddImageToIndex = false
boolm_noDivTag = false
boolm_zoomable = true
boolm_urlOnly = false

Private Member Attributes Index

intm_curNodeNumber = 0
intm_curEdgeNumber = 0

Protected Static Functions Index

static voidwriteGraphHeader (TextStream &t, const QCString &title=QCString())
static voidwriteGraphFooter (TextStream &t)
static voidcomputeGraph (DotNode *root, GraphType gt, GraphOutputFormat format, const QCString &rank, bool renderParents, bool backArrows, const QCString &title, QCString &graphStr)

Description

A dot graph.

Definition at line 34 of file dotgraph.h.

Public Constructors

DotGraph()

DotGraph::DotGraph ()
inline

Public Destructor

~DotGraph()

virtual DotGraph::~DotGraph ()
virtual default

Definition at line 40 of file dotgraph.h.

Reference DotGraph.

Protected Member Functions

absBaseName()

QCString DotGraph::absBaseName ()
inline protected

Definition at line 78 of file dotgraph.h.

References m_absPath and m_baseName.

Referenced by generateCode, prepareDotFile and DotLegendGraph::writeGraph.

absDotName()

QCString DotGraph::absDotName ()
inline protected

Definition at line 79 of file dotgraph.h.

79 QCString absDotName() const { return m_absPath + m_baseName + ".dot"; }

References m_absPath and m_baseName.

Referenced by prepareDotFile.

absImgName()

QCString DotGraph::absImgName ()
inline protected

Definition at line 81 of file dotgraph.h.

81 QCString absImgName() const { return m_absPath + imgName(); }

References imgName and m_absPath.

Referenced by generateCode, prepareDotFile and DotLegendGraph::writeGraph.

absMapName()

virtual QCString DotGraph::absMapName ()
inline protected virtual

Definition at line 72 of file dotgraph.h.

72 virtual QCString absMapName() const { return m_absPath + m_baseName + ".map"; }

References m_absPath and m_baseName.

Referenced by generateCode and prepareDotFile.

computeTheGraph()

virtual void DotGraph::computeTheGraph ()
protected

Definition at line 76 of file dotgraph.h.

Referenced by writeGraph.

getBaseName()

virtual QCString DotGraph::getBaseName ()
protected

Definition at line 71 of file dotgraph.h.

Referenced by writeGraph.

getImgAltText()

virtual QCString DotGraph::getImgAltText ()
inline protected virtual

Definition at line 74 of file dotgraph.h.

74 virtual QCString getImgAltText() const { return ""; }

Referenced by generateCode.

getMapLabel()

virtual QCString DotGraph::getMapLabel ()
protected

Definition at line 73 of file dotgraph.h.

Referenced by generateCode.

getNextEdgeNumber()

int DotGraph::getNextEdgeNumber ()
inline protected

returns the edge number.

Definition at line 47 of file dotgraph.h.

Reference m_curEdgeNumber.

getNextNodeNumber()

int DotGraph::getNextNodeNumber ()
inline protected

returns the node number.

Definition at line 45 of file dotgraph.h.

Reference m_curNodeNumber.

imgName()

QCString DotGraph::imgName ()
protected

Declaration at line 80 of file dotgraph.h, definition at line 107 of file dotgraph.cpp.

108{
110 ("." + getDotImageExtension()) : (Config_getBool(USE_PDFLATEX) ? ".pdf" : ".eps"));
111}

References BITMAP, Config_getBool, getDotImageExtension, m_baseName and m_graphFormat.

Referenced by absImgName, relImgName and writeGraph.

relImgName()

QCString DotGraph::relImgName ()
inline protected

Definition at line 82 of file dotgraph.h.

82 QCString relImgName() const { return m_relPath + imgName(); }

References imgName and m_relPath.

Referenced by generateCode.

writeGraph()

QCString DotGraph::writeGraph (TextStream & t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString & path, const QCString & fileName, const QCString & relPath, bool writeImageMap=TRUE, int graphId=-1)
protected

Declaration at line 49 of file dotgraph.h, definition at line 115 of file dotgraph.cpp.

116 TextStream& t, // output stream for the code file (html, ...)
117 GraphOutputFormat gf, // bitmap(png/svg) or ps(eps/pdf)
118 EmbeddedOutputFormat ef, // html, latex, ...
119 const QCString &path, // output folder
120 const QCString &fileName, // name of the code file (for code patcher)
121 const QCString &relPath, // output folder relative to code file
122 bool generateImageMap, // in case of bitmap, shall there be code generated?
123 int graphId) // number of this graph in the current code, used in svg code
124{
125 m_graphFormat = gf;
126 m_textFormat = ef;
127 m_dir = Dir(path.str());
128 m_fileName = fileName;
129 m_relPath = relPath;
130 m_generateImageMap = generateImageMap;
131 m_graphId = graphId;
132
133 m_absPath = m_dir.absPath() + "/";
135
137
139
141 {
142 std::lock_guard<std::mutex> lock(g_dotIndexListMutex);
143 Doxygen::indexList->addImageFile(imgName());
144 }
145
146 generateCode(t);
147
148 return m_baseName;
149}

References computeTheGraph, g_dotIndexListMutex, generateCode, getBaseName, imgName, Doxygen::indexList, m_absPath, m_baseName, m_dir, m_doNotAddImageToIndex, m_fileName, m_generateImageMap, m_graphFormat, m_graphId, m_regenerate, m_relPath, m_textFormat, prepareDotFile and QCString::str.

Referenced by DotGfxHierarchyTable::createGraph, DotCallGraph::writeGraph, DotClassGraph::writeGraph, DotDirDeps::writeGraph, DotGroupCollaboration::writeGraph, DotInclDepGraph::writeGraph and DotLegendGraph::writeGraph.

Private Member Functions

generateCode()

void DotGraph::generateCode (TextStream & t)

Declaration at line 105 of file dotgraph.h, definition at line 212 of file dotgraph.cpp.

213{
216 {
217 t << "<para>\n";
218 t << " <informalfigure>\n";
219 t << " <mediaobject>\n";
220 t << " <imageobject>\n";
221 t << " <imagedata";
222 t << " width=\"50%\" align=\"center\" valign=\"middle\" scalefit=\"0\" fileref=\"" << m_relPath << m_baseName << "." << imgExt << "\">";
223 t << "</imagedata>\n";
224 t << " </imageobject>\n";
225 t << " </mediaobject>\n";
226 t << " </informalfigure>\n";
227 t << "</para>\n";
228 }
229 else if (m_graphFormat==GraphOutputFormat::BITMAP && m_generateImageMap) // produce HTML to include the image
230 {
231 if (imgExt=="svg") // add link to SVG file without map file
232 {
233 if (!m_noDivTag) t << "<div class=\"center\">";
234 if (m_regenerate || !DotFilePatcher::writeSVGFigureLink(t,m_relPath,m_baseName,absImgName())) // need to patch the links in the generated SVG file
235 {
236 if (m_regenerate)
237 {
239 createFilePatcher(absImgName())->
240 addSVGConversion(m_relPath,FALSE,QCString(),m_zoomable,m_graphId);
241 }
242 int mapId = DotManager::instance()->
243 createFilePatcher(m_fileName)->
244 addSVGObject(m_baseName,absImgName(),m_relPath);
245 t << "<!-- " << "SVG " << mapId << " -->";
246 }
247 if (!m_noDivTag) t << "</div>\n";
248 }
249 else // add link to bitmap file with image map
250 {
251 if (!m_noDivTag) t << "<div class=\"center\">";
252 t << "<img src=\"" << relImgName() << "\" border=\"0\" usemap=\"#" << correctId(getMapLabel()) << "\" loading=\"lazy\" alt=\"" << getImgAltText() << "\"/>";
253 if (!m_noDivTag) t << "</div>";
254 t << "\n";
256 {
257 int mapId = DotManager::instance()->
258 createFilePatcher(m_fileName)->
260 t << "<!-- MAP " << mapId << " -->\n";
261 }
262 }
263 }
264 else if (m_graphFormat==GraphOutputFormat::EPS) // produce tex to include the .eps image
265 {
267 {
268 int figId = DotManager::instance()->
269 createFilePatcher(m_fileName)->
270 addFigure(m_baseName,absBaseName(),FALSE /*TRUE*/);
271 t << "\n% FIG " << figId << "\n";
272 }
273 }
274}

References absBaseName, absImgName, absMapName, BITMAP, correctId, DocBook, EPS, FALSE, getDotImageExtension, getImgAltText, getMapLabel, insertMapFile, DotManager::instance, m_baseName, m_fileName, m_generateImageMap, m_graphFormat, m_graphId, m_noDivTag, m_regenerate, m_relPath, m_textFormat, m_urlOnly, m_zoomable, relImgName, DotFilePatcher::writeSVGFigureLink and DotFilePatcher::writeVecGfxFigure.

Referenced by writeGraph.

prepareDotFile()

bool DotGraph::prepareDotFile ()

Declaration at line 104 of file dotgraph.h, definition at line 151 of file dotgraph.cpp.

152{
153 if (!m_dir.exists())
154 {
155 term("Output dir {} does not exist!\n", m_dir.path());
156 }
157
158 char sigStr[33];
159 uint8_t md5_sig[16];
160 // calculate md5
161 MD5Buffer(m_theGraph.data(), static_cast<unsigned int>(m_theGraph.length()), md5_sig);
162 // convert result to a string
163 MD5SigToString(md5_sig, sigStr);
164
165 // already queued files are processed again in case the output format has changed
166
167 if (sameMd5Signature(absBaseName(), sigStr) &&
170 )
171 )
172 {
173 // all needed files are there
174 return FALSE;
175 }
176
177 // need to rebuild the image
178
179 // write .dot file because image was new or has changed
180 std::ofstream f = Portable::openOutputStream(absDotName());
181 if (!f.is_open())
182 {
183 err("Could not open file {} for writing\n",absDotName());
184 return TRUE;
185 }
186 f << m_theGraph;
187 f.close();
188
190 {
191 // run dot to create a bitmap image
193 dotRun->addJob(Config_getEnumAsString(DOT_IMAGE_FORMAT), absImgName(), absDotName(), 1);
195 }
197 {
198 // run dot to create a .eps image
200 if (Config_getBool(USE_PDFLATEX))
201 {
202 dotRun->addJob("pdf",absImgName(),absDotName(),1);
203 }
204 else
205 {
206 dotRun->addJob("ps",absImgName(),absDotName(),1);
207 }
208 }
209 return TRUE;
210}

References absBaseName, absDotName, absImgName, absMapName, DotRunner::addJob, BITMAP, Config_getBool, Config_getEnumAsString, DotManager::createRunner, deliverablesPresent, EPS, err, FALSE, DotManager::instance, m_dir, m_generateImageMap, m_graphFormat, m_theGraph, MAP_CMD, Portable::openOutputStream, sameMd5Signature, term and TRUE.

Referenced by writeGraph.

Protected Member Attributes

m_absPath

QCString DotGraph::m_absPath
protected

Definition at line 93 of file dotgraph.h.

Referenced by absBaseName, absDotName, absImgName, absMapName and writeGraph.

m_baseName

m_dir

Dir DotGraph::m_dir
protected

Definition at line 87 of file dotgraph.h.

Referenced by prepareDotFile and writeGraph.

m_doNotAddImageToIndex

bool DotGraph::m_doNotAddImageToIndex = false
protected

Definition at line 97 of file dotgraph.h.

Referenced by DotGraph, DotCallGraph::writeGraph, writeGraph and DotGroupCollaboration::writeGraph.

m_fileName

QCString DotGraph::m_fileName
protected

Definition at line 88 of file dotgraph.h.

Referenced by generateCode and writeGraph.

m_generateImageMap

bool DotGraph::m_generateImageMap = false
protected

Definition at line 90 of file dotgraph.h.

90 bool m_generateImageMap = false;

Referenced by generateCode, prepareDotFile and writeGraph.

m_graphFormat

m_graphId

int DotGraph::m_graphId = 0
protected

Definition at line 91 of file dotgraph.h.

91 int m_graphId = 0;

Referenced by generateCode and writeGraph.

m_noDivTag

bool DotGraph::m_noDivTag = false
protected

Definition at line 98 of file dotgraph.h.

98 bool m_noDivTag = false;

Referenced by DotGfxHierarchyTable::createGraph, DotGraph and generateCode.

m_regenerate

bool DotGraph::m_regenerate = false
protected

Definition at line 96 of file dotgraph.h.

96 bool m_regenerate = false;

Referenced by generateCode and writeGraph.

m_relPath

QCString DotGraph::m_relPath
protected

Definition at line 89 of file dotgraph.h.

Referenced by generateCode, relImgName and writeGraph.

m_textFormat

EmbeddedOutputFormat DotGraph::m_textFormat = EmbeddedOutputFormat::Html
protected

m_theGraph

m_urlOnly

bool DotGraph::m_urlOnly = false
protected

Definition at line 100 of file dotgraph.h.

100 bool m_urlOnly = false;

Referenced by DotGraph, generateCode and DotDirDeps::writeGraph.

m_zoomable

bool DotGraph::m_zoomable = true
protected

Definition at line 99 of file dotgraph.h.

99 bool m_zoomable = true;

Referenced by DotGfxHierarchyTable::createGraph, DotGraph and generateCode.

Private Member Attributes

m_curEdgeNumber

int DotGraph::m_curEdgeNumber = 0

Definition at line 108 of file dotgraph.h.

Referenced by getNextEdgeNumber.

m_curNodeNumber

int DotGraph::m_curNodeNumber = 0

Definition at line 107 of file dotgraph.h.

Referenced by getNextNodeNumber.

Protected Static Functions

computeGraph()

void DotGraph::computeGraph (DotNode * root, GraphType gt, GraphOutputFormat format, const QCString & rank, bool renderParents, bool backArrows, const QCString & title, QCString & graphStr)
protected static

Declaration at line 61 of file dotgraph.h, definition at line 306 of file dotgraph.cpp.

307 GraphType gt,
308 GraphOutputFormat format,
309 const QCString &rank, // either "LR", "RL", or ""
310 bool renderParents,
311 bool backArrows,
312 const QCString &title,
313 QCString &graphStr)
314{
315 //printf("computeMd5Signature\n");
316 TextStream md5stream;
317 writeGraphHeader(md5stream,title);
318 if (!rank.isEmpty())
319 {
320 md5stream << " rankdir=\"" << rank << "\";\n";
321 }
322 root->clearWriteFlag();
323 root->write(md5stream, gt, format, gt!=GraphType::CallGraph && gt!=GraphType::Dependency, TRUE, backArrows);
324 if (renderParents)
325 {
326 for (const auto &pn : root->parents())
327 {
328 if (pn->isVisible())
329 {
330 const auto &children = pn->children();
331 auto child_it = std::find(children.begin(),children.end(),root);
332 size_t index = child_it - children.begin();
333 root->writeArrow(md5stream, // stream
334 gt, // graph type
335 format, // output format
336 pn, // child node
337 &pn->edgeInfo()[index], // edge info
338 FALSE, // topDown?
339 backArrows // point back?
340 );
341 }
342 pn->write(md5stream, // stream
343 gt, // graph type
344 format, // output format
345 TRUE, // topDown?
346 FALSE, // toChildren?
347 backArrows // backward pointing arrows?
348 );
349 }
350 }
351 writeGraphFooter(md5stream);
352
353 graphStr=md5stream.str();
354}

References CallGraph, DotNode::clearWriteFlag, Dependency, DotNode, FALSE, QCString::isEmpty, DotNode::parents, TextStream::str, TRUE, DotNode::write, DotNode::writeArrow, writeGraphFooter and writeGraphHeader.

Referenced by DotCallGraph::computeTheGraph, DotClassGraph::computeTheGraph and DotInclDepGraph::computeTheGraph.

writeGraphFooter()

void DotGraph::writeGraphFooter (TextStream & t)
protected static

writeGraphHeader()

void DotGraph::writeGraphHeader (TextStream & t, const QCString & title=QCString())
protected static

Declaration at line 59 of file dotgraph.h, definition at line 276 of file dotgraph.cpp.

277{
278 t << "digraph ";
279 if (title.isEmpty())
280 {
281 t << "\"Dot Graph\"";
282 }
283 else
284 {
285 t << "\"" << convertToXML(title) << "\"";
286 }
287 t << "\n{\n";
288 if (Config_getBool(INTERACTIVE_SVG)) // insert a comment to force regeneration when this
289 // option is toggled
290 {
291 t << " // INTERACTIVE_SVG=YES\n";
292 }
293 t << " // LATEX_PDF_SIZE\n"; // write placeholder for LaTeX PDF bounding box size replacement
294 t << " bgcolor=\"transparent\";\n";
295 QCString c = Config_getString(DOT_COMMON_ATTR);
296 if (!c.isEmpty()) c += ",";
297 t << " edge [" << c << Config_getString(DOT_EDGE_ATTR) << "];\n";
298 t << " node [" << c << Config_getString(DOT_NODE_ATTR) << "];\n";
299}

References Config_getBool, Config_getString, convertToXML and QCString::isEmpty.

Referenced by computeGraph, DotDirDeps::computeTheGraph, DotGfxHierarchyTable::computeTheGraph, DotLegendGraph::computeTheGraph and DotGroupCollaboration::writeGraphHeader.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.