Doxygen
Loading...
Searching...
No Matches
DotGraph Class Referenceabstract

A dot graph. More...

#include <src/dotgraph.h>

+ Inheritance diagram for DotGraph:
+ Collaboration diagram for DotGraph:

Public Member Functions

 DotGraph ()
 
virtual ~DotGraph ()=default
 

Protected Member Functions

int getNextNodeNumber ()
 returns the node number.
 
int getNextEdgeNumber ()
 returns the edge number.
 
QCString writeGraph (TextStream &t, GraphOutputFormat gf, EmbeddedOutputFormat ef, const QCString &path, const QCString &fileName, const QCString &relPath, bool writeImageMap=TRUE, int graphId=-1)
 
virtual QCString getBaseName () const =0
 
virtual QCString absMapName () const
 
virtual QCString getMapLabel () const =0
 
virtual QCString getImgAltText () const
 
virtual void computeTheGraph ()=0
 
QCString absBaseName () const
 
QCString absDotName () const
 
QCString imgName () const
 
QCString absImgName () const
 
QCString relImgName () const
 

Static Protected Member Functions

static void writeGraphHeader (TextStream &t, const QCString &title=QCString())
 
static void writeGraphFooter (TextStream &t)
 
static void computeGraph (DotNode *root, GraphType gt, GraphOutputFormat format, const QCString &rank, bool renderParents, bool backArrows, const QCString &title, QCString &graphStr)
 

Protected Attributes

GraphOutputFormat m_graphFormat = GraphOutputFormat::BITMAP
 
EmbeddedOutputFormat m_textFormat = EmbeddedOutputFormat::Html
 
Dir m_dir
 
QCString m_fileName
 
QCString m_relPath
 
bool m_generateImageMap = false
 
int m_graphId = 0
 
QCString m_absPath
 
QCString m_baseName
 
QCString m_theGraph
 
bool m_regenerate = false
 
bool m_doNotAddImageToIndex = false
 
bool m_noDivTag = false
 
bool m_zoomable = true
 
bool m_urlOnly = false
 

Private Member Functions

bool prepareDotFile ()
 
void generateCode (TextStream &t)
 

Private Attributes

int m_curNodeNumber = 0
 
int m_curEdgeNumber = 0
 

Friends

class DotNode
 

Detailed Description

A dot graph.

Definition at line 34 of file dotgraph.h.

Constructor & Destructor Documentation

◆ DotGraph()

DotGraph::DotGraph ( )
inline

Definition at line 38 of file dotgraph.h.

bool m_noDivTag
Definition dotgraph.h:98
bool m_urlOnly
Definition dotgraph.h:100
bool m_doNotAddImageToIndex
Definition dotgraph.h:97
bool m_zoomable
Definition dotgraph.h:99
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34

References FALSE, m_doNotAddImageToIndex, m_noDivTag, m_urlOnly, m_zoomable, and TRUE.

Referenced by ~DotGraph().

◆ ~DotGraph()

virtual DotGraph::~DotGraph ( )
virtualdefault

References DotGraph().

Member Function Documentation

◆ absBaseName()

QCString DotGraph::absBaseName ( ) const
inlineprotected

Definition at line 78 of file dotgraph.h.

78{ return m_absPath + m_baseName; }
QCString m_absPath
Definition dotgraph.h:93
QCString m_baseName
Definition dotgraph.h:94

References m_absPath, and m_baseName.

Referenced by generateCode(), prepareDotFile(), and DotLegendGraph::writeGraph().

◆ absDotName()

QCString DotGraph::absDotName ( ) const
inlineprotected

Definition at line 79 of file dotgraph.h.

79{ return m_absPath + m_baseName + ".dot"; }

References m_absPath, and m_baseName.

Referenced by prepareDotFile().

◆ absImgName()

QCString DotGraph::absImgName ( ) const
inlineprotected

Definition at line 81 of file dotgraph.h.

81{ return m_absPath + imgName(); }
QCString imgName() const
Definition dotgraph.cpp:107

References imgName(), and m_absPath.

Referenced by generateCode(), prepareDotFile(), and DotLegendGraph::writeGraph().

◆ absMapName()

virtual QCString DotGraph::absMapName ( ) const
inlineprotectedvirtual

Definition at line 72 of file dotgraph.h.

72{ return m_absPath + m_baseName + ".map"; }

References m_absPath, and m_baseName.

Referenced by generateCode(), and prepareDotFile().

◆ computeGraph()

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

Definition at line 306 of file dotgraph.cpp.

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}
static void writeGraphFooter(TextStream &t)
Definition dotgraph.cpp:301
static void writeGraphHeader(TextStream &t, const QCString &title=QCString())
Definition dotgraph.cpp:276
void write(TextStream &t, GraphType gt, GraphOutputFormat f, bool topDown, bool toChildren, bool backArrows)
Definition dotnode.cpp:630
void clearWriteFlag()
Definition dotnode.cpp:863
const DotNodeRefVector & parents() const
Definition dotnode.h:123
void writeArrow(TextStream &t, GraphType gt, GraphOutputFormat f, const DotNode *cn, const EdgeInfo *ei, bool topDown, bool pointBack=TRUE) const
Definition dotnode.cpp:579
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
std::string str() const
Return the contents of the buffer as a std::string object.
Definition textstream.h:229
@ Dependency
Definition dotgraph.h:31
@ CallGraph
Definition dotgraph.h:31

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().

◆ computeTheGraph()

virtual void DotGraph::computeTheGraph ( )
protectedpure virtual

◆ generateCode()

void DotGraph::generateCode ( TextStream & t)
private

Definition at line 212 of file dotgraph.cpp.

213{
214 QCString imgExt = getDotImageExtension();
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()) << "\" alt=\"" << getImgAltText() << "\"/>";
253 if (!m_noDivTag) t << "</div>";
254 t << "\n";
256 {
257 int mapId = DotManager::instance()->
258 createFilePatcher(m_fileName)->
259 addMap(absMapName(), m_relPath, m_urlOnly, QCString(), getMapLabel());
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}
static bool writeVecGfxFigure(TextStream &out, const QCString &baseName, const QCString &figureName)
static bool writeSVGFigureLink(TextStream &out, const QCString &relPath, const QCString &baseName, const QCString &absImgName)
Check if a reference to a SVG figure can be written and do so if possible.
QCString absBaseName() const
Definition dotgraph.h:78
virtual QCString absMapName() const
Definition dotgraph.h:72
int m_graphId
Definition dotgraph.h:91
EmbeddedOutputFormat m_textFormat
Definition dotgraph.h:86
QCString m_fileName
Definition dotgraph.h:88
QCString absImgName() const
Definition dotgraph.h:81
GraphOutputFormat m_graphFormat
Definition dotgraph.h:85
virtual QCString getImgAltText() const
Definition dotgraph.h:74
QCString relImgName() const
Definition dotgraph.h:82
virtual QCString getMapLabel() const =0
bool m_regenerate
Definition dotgraph.h:96
bool m_generateImageMap
Definition dotgraph.h:90
QCString m_relPath
Definition dotgraph.h:89
static DotManager * instance()
Definition dot.cpp:78
static bool insertMapFile(TextStream &out, const QCString &mapFile, const QCString &relPath, const QCString &mapLabel)
Definition dotgraph.cpp:86
QCString correctId(const QCString &s)
Definition util.cpp:4259
QCString getDotImageExtension()
Definition util.cpp:6617

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().

◆ getBaseName()

virtual QCString DotGraph::getBaseName ( ) const
protectedpure virtual

◆ getImgAltText()

virtual QCString DotGraph::getImgAltText ( ) const
inlineprotectedvirtual

Reimplemented in DotClassGraph, and DotDirDeps.

Definition at line 74 of file dotgraph.h.

74{ return ""; }

Referenced by generateCode().

◆ getMapLabel()

virtual QCString DotGraph::getMapLabel ( ) const
protectedpure virtual

◆ getNextEdgeNumber()

int DotGraph::getNextEdgeNumber ( )
inlineprotected

returns the edge number.

Definition at line 47 of file dotgraph.h.

47{ return ++m_curEdgeNumber; }
int m_curEdgeNumber
Definition dotgraph.h:108

References m_curEdgeNumber.

◆ getNextNodeNumber()

int DotGraph::getNextNodeNumber ( )
inlineprotected

returns the node number.

Definition at line 45 of file dotgraph.h.

45{ return ++m_curNodeNumber; }
int m_curNodeNumber
Definition dotgraph.h:107

References m_curNodeNumber.

◆ imgName()

QCString DotGraph::imgName ( ) const
protected

Definition at line 107 of file dotgraph.cpp.

108{
110 ("." + getDotImageExtension()) : (Config_getBool(USE_PDFLATEX) ? ".pdf" : ".eps"));
111}
#define Config_getBool(name)
Definition config.h:33

References BITMAP, Config_getBool, getDotImageExtension(), m_baseName, and m_graphFormat.

Referenced by absImgName(), relImgName(), and writeGraph().

◆ prepareDotFile()

bool DotGraph::prepareDotFile ( )
private

Definition at line 151 of file dotgraph.cpp.

152{
153 if (!m_dir.exists())
154 {
155 term("Output dir %s does not exist!\n", m_dir.path().c_str());
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 %s for writing\n",qPrint(absDotName()));
184 return TRUE;
185 }
186 f << m_theGraph;
187 f.close();
188
190 {
191 // run dot to create a bitmap image
192 DotRunner * dotRun = DotManager::instance()->createRunner(absDotName(), sigStr);
193 dotRun->addJob(Config_getEnumAsString(DOT_IMAGE_FORMAT), absImgName(), absDotName(), 1);
195 }
197 {
198 // run dot to create a .eps image
199 DotRunner *dotRun = DotManager::instance()->createRunner(absDotName(), sigStr);
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}
Dir m_dir
Definition dotgraph.h:87
QCString absDotName() const
Definition dotgraph.h:79
QCString m_theGraph
Definition dotgraph.h:95
DotRunner * createRunner(const QCString &absDotName, const QCString &md5Hash)
Definition dot.cpp:92
void addJob(const QCString &format, const QCString &output, const QCString &srcFile, int srcLine)
Adds an additional job to the run.
#define Config_getEnumAsString(name)
Definition config.h:36
#define MAP_CMD
Definition dot.cpp:34
static bool sameMd5Signature(const QCString &baseName, const QCString &md5)
Definition dotgraph.cpp:43
static bool deliverablesPresent(const QCString &file1, const QCString &file2)
Definition dotgraph.cpp:69
#define err(fmt,...)
Definition message.h:84
#define term(fmt,...)
Definition message.h:94
std::ofstream openOutputStream(const QCString &name, bool append=false)
Definition portable.cpp:665
const char * qPrint(const char *s)
Definition qcstring.h:672

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(), qPrint(), sameMd5Signature(), term, and TRUE.

Referenced by writeGraph().

◆ relImgName()

QCString DotGraph::relImgName ( ) const
inlineprotected

Definition at line 82 of file dotgraph.h.

82{ 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

Definition at line 115 of file dotgraph.cpp.

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);
144 }
145
146 generateCode(t);
147
148 return m_baseName;
149}
virtual QCString getBaseName() const =0
void generateCode(TextStream &t)
Definition dotgraph.cpp:212
bool prepareDotFile()
Definition dotgraph.cpp:151
virtual void computeTheGraph()=0
static IndexList * indexList
Definition doxygen.h:134
void addImageFile(const QCString &name)
Definition indexlist.h:126
const std::string & str() const
Definition qcstring.h:537
std::mutex g_dotIndexListMutex
Definition dotgraph.cpp:113

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().

◆ writeGraphFooter()

void DotGraph::writeGraphFooter ( TextStream & t)
staticprotected

◆ writeGraphHeader()

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

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}
#define Config_getString(name)
Definition config.h:32
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:4266

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

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

Friends And Related Symbol Documentation

◆ DotNode

Member Data Documentation

◆ 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_curEdgeNumber

int DotGraph::m_curEdgeNumber = 0
private

Definition at line 108 of file dotgraph.h.

Referenced by getNextEdgeNumber().

◆ m_curNodeNumber

int DotGraph::m_curNodeNumber = 0
private

Definition at line 107 of file dotgraph.h.

Referenced by getNextNodeNumber().

◆ 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

◆ 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.

Referenced by generateCode(), prepareDotFile(), and writeGraph().

◆ m_graphFormat

◆ m_graphId

int DotGraph::m_graphId = 0
protected

Definition at line 91 of file dotgraph.h.

Referenced by generateCode(), and writeGraph().

◆ m_noDivTag

bool DotGraph::m_noDivTag = false
protected

Definition at line 98 of file dotgraph.h.

Referenced by DotGfxHierarchyTable::createGraph(), DotGraph(), and generateCode().

◆ m_regenerate

bool DotGraph::m_regenerate = false
protected

Definition at line 96 of file dotgraph.h.

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

Definition at line 86 of file dotgraph.h.

Referenced by generateCode(), and writeGraph().

◆ m_theGraph

◆ m_urlOnly

bool DotGraph::m_urlOnly = false
protected

Definition at line 100 of file dotgraph.h.

Referenced by DotGraph(), generateCode(), and DotDirDeps::writeGraph().

◆ m_zoomable

bool DotGraph::m_zoomable = true
protected

Definition at line 99 of file dotgraph.h.

Referenced by DotGfxHierarchyTable::createGraph(), DotGraph(), and generateCode().


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