Doxygen
Loading...
Searching...
No Matches
dot.cpp File Reference
#include <cstdlib>
#include <cassert>
#include <sstream>
#include <algorithm>
#include <mutex>
#include "config.h"
#include "dot.h"
#include "dotrunner.h"
#include "dotfilepatcher.h"
#include "util.h"
#include "portable.h"
#include "message.h"
#include "doxygen.h"
#include "language.h"
#include "indexlist.h"
#include "dir.h"
+ Include dependency graph for dot.cpp:

Go to the source code of this file.

Macros

#define MAP_CMD   "cmapx"
 

Functions

static void setDotFontPath (const QCString &path)
 
static void unsetDotFontPath ()
 
void writeDotGraphFromFile (const QCString &inFile, const QCString &outDir, const QCString &outFile, GraphOutputFormat format, const QCString &srcFile, int srcLine)
 
void writeDotImageMapFromFile (TextStream &t, const QCString &inFile, const QCString &outDir, const QCString &relPath, const QCString &baseName, const QCString &context, int graphId, const QCString &srcFile, int srcLine)
 

Variables

static QCString g_dotFontPath
 
static std::mutex g_dotManagerMutex
 

Macro Definition Documentation

◆ MAP_CMD

#define MAP_CMD   "cmapx"

Definition at line 34 of file dot.cpp.

Referenced by DotGraph::prepareDotFile(), and writeDotImageMapFromFile().

Function Documentation

◆ setDotFontPath()

static void setDotFontPath ( const QCString & path)
static

Definition at line 42 of file dot.cpp.

43{
44 ASSERT(g_dotFontPath.isEmpty());
45 g_dotFontPath = Portable::getenv("DOTFONTPATH");
46 QCString newFontPath = Config_getString(DOT_FONTPATH);
47 if (!newFontPath.isEmpty() && !path.isEmpty())
48 {
49 newFontPath.prepend(path+Portable::pathListSeparator());
50 }
51 else if (newFontPath.isEmpty() && !path.isEmpty())
52 {
53 newFontPath=path;
54 }
55 else
56 {
57 Portable::unsetenv("DOTFONTPATH");
58 return;
59 }
60 Portable::setenv("DOTFONTPATH",newFontPath);
61}
This is an alternative implementation of QCString.
Definition qcstring.h:101
QCString & prepend(const char *s)
Definition qcstring.h:407
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
#define Config_getString(name)
Definition config.h:32
static QCString g_dotFontPath
Definition dot.cpp:38
QCString pathListSeparator()
Definition portable.cpp:400
void setenv(const QCString &variable, const QCString &value)
Definition portable.cpp:303
void unsetenv(const QCString &variable)
Definition portable.cpp:318
QCString getenv(const QCString &variable)
Definition portable.cpp:338
#define ASSERT(x)
Definition qcstring.h:39

References ASSERT, Config_getString, g_dotFontPath, Portable::getenv(), QCString::isEmpty(), Portable::pathListSeparator(), QCString::prepend(), Portable::setenv(), and Portable::unsetenv().

Referenced by DotManager::run().

◆ unsetDotFontPath()

static void unsetDotFontPath ( )
static

Definition at line 63 of file dot.cpp.

64{
65 if (g_dotFontPath.isEmpty())
66 {
67 Portable::unsetenv("DOTFONTPATH");
68 }
69 else
70 {
71 Portable::setenv("DOTFONTPATH",g_dotFontPath);
72 }
74}

References g_dotFontPath, Portable::setenv(), and Portable::unsetenv().

Referenced by DotManager::run().

◆ writeDotGraphFromFile()

void writeDotGraphFromFile ( const QCString & inFile,
const QCString & outDir,
const QCString & outFile,
GraphOutputFormat format,
const QCString & srcFile,
int srcLine )

Definition at line 230 of file dot.cpp.

233{
234 Dir d(outDir.str());
235 if (!d.exists())
236 {
237 term("Output dir %s does not exist!\n",qPrint(outDir));
238 }
239
241 QCString imgName = QCString(outFile)+"."+imgExt;
242 QCString absImgName = QCString(d.absPath())+"/"+imgName;
243 QCString absOutFile = QCString(d.absPath())+"/"+outFile;
244
245 DotRunner dotRun(inFile);
246 if (format==GraphOutputFormat::BITMAP)
247 {
248 dotRun.addJob(Config_getEnumAsString(DOT_IMAGE_FORMAT),absImgName,srcFile,srcLine);
249 }
250 else // format==GraphOutputFormat::EPS
251 {
252 if (Config_getBool(USE_PDFLATEX))
253 {
254 dotRun.addJob("pdf",absOutFile+".pdf",srcFile,srcLine);
255 }
256 else
257 {
258 dotRun.addJob("ps",absOutFile+".eps",srcFile,srcLine);
259 }
260 }
261
262 dotRun.preventCleanUp();
263 if (!dotRun.run())
264 {
265 return;
266 }
267
268 Doxygen::indexList->addImageFile(imgName);
269
270}
Class representing a directory in the file system.
Definition dir.h:75
Helper class to run dot from doxygen from multiple threads.
Definition dotrunner.h:31
static IndexList * indexList
Definition doxygen.h:134
const std::string & str() const
Definition qcstring.h:537
#define Config_getEnumAsString(name)
Definition config.h:36
#define Config_getBool(name)
Definition config.h:33
#define term(fmt,...)
Definition message.h:94
const char * qPrint(const char *s)
Definition qcstring.h:672
QCString getDotImageExtension()
Definition util.cpp:6617

References Dir::absPath(), DotRunner::addJob(), BITMAP, Config_getBool, Config_getEnumAsString, Dir::exists(), getDotImageExtension(), Doxygen::indexList, DotRunner::preventCleanUp(), qPrint(), DotRunner::run(), QCString::str(), and term.

Referenced by DocbookDocVisitor::startDotFile(), LatexDocVisitor::startDotFile(), DocbookDocVisitor::writeDotFile(), HtmlDocVisitor::writeDotFile(), and RTFDocVisitor::writeDotFile().

◆ writeDotImageMapFromFile()

void writeDotImageMapFromFile ( TextStream & t,
const QCString & inFile,
const QCString & outDir,
const QCString & relPath,
const QCString & baseName,
const QCString & context,
int graphId,
const QCString & srcFile,
int srcLine )

Writes user defined image map to the output.

Parameters
ttext stream to write to
inFilejust the basename part of the filename
outDiroutput directory
relPathrelative path the to root of the output dir
baseNamethe base name of the output files
contextthe scope in which this graph is found (for resolving links)
graphIda unique id for this graph, use for dynamic sections
srcFilethe source file
srcLinethe line number in the source file

Definition at line 283 of file dot.cpp.

288{
289
290 Dir d(outDir.str());
291 if (!d.exists())
292 {
293 term("Output dir %s does not exist!\n",qPrint(outDir));
294 }
295
296 QCString mapName = baseName+".map";
298 QCString imgName = baseName+"."+imgExt;
299 QCString absOutFile = QCString(d.absPath())+"/"+mapName;
300
301 DotRunner dotRun(inFile);
302 dotRun.addJob(MAP_CMD,absOutFile,srcFile,srcLine);
303 dotRun.preventCleanUp();
304 if (!dotRun.run())
305 {
306 return;
307 }
308
309 if (imgExt=="svg") // vector graphics
310 {
311 QCString svgName = outDir+"/"+baseName+".svg";
312 DotFilePatcher::writeSVGFigureLink(t,relPath,baseName,svgName);
313 DotFilePatcher patcher(svgName);
314 patcher.addSVGConversion("",TRUE,context,TRUE,graphId);
315 patcher.run();
316 }
317 else // bitmap graphics
318 {
319 TextStream tt;
320 t << "<img src=\"" << relPath << imgName << "\" alt=\""
321 << imgName << "\" border=\"0\" usemap=\"#" << mapName << "\"/>\n";
322 DotFilePatcher::convertMapFile(tt, absOutFile, relPath ,TRUE, context);
323 if (!tt.empty())
324 {
325 t << "<map name=\"" << mapName << "\" id=\"" << mapName << "\">";
326 t << tt.str();
327 t << "</map>\n";
328 }
329 }
330 d.remove(absOutFile.str());
331}
Helper class to insert a set of map file into an output file.
static bool convertMapFile(TextStream &t, const QCString &mapName, const QCString &relPath, bool urlOnly=FALSE, const QCString &context=QCString())
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.
Text streaming class that buffers data.
Definition textstream.h:36
bool empty() const
Returns true iff the buffer is empty.
Definition textstream.h:253
std::string str() const
Return the contents of the buffer as a std::string object.
Definition textstream.h:229
#define MAP_CMD
Definition dot.cpp:34
#define TRUE
Definition qcstring.h:37

References Dir::absPath(), DotRunner::addJob(), DotFilePatcher::addSVGConversion(), DotFilePatcher::convertMapFile(), TextStream::empty(), Dir::exists(), getDotImageExtension(), MAP_CMD, DotRunner::preventCleanUp(), qPrint(), Dir::remove(), DotFilePatcher::run(), DotRunner::run(), QCString::str(), TextStream::str(), term, TRUE, and DotFilePatcher::writeSVGFigureLink().

Referenced by HtmlDocVisitor::writeDotFile().

Variable Documentation

◆ g_dotFontPath

QCString g_dotFontPath
static

Definition at line 38 of file dot.cpp.

Referenced by setDotFontPath(), and unsetDotFontPath().

◆ g_dotManagerMutex

std::mutex g_dotManagerMutex
static

Definition at line 40 of file dot.cpp.

Referenced by DotManager::createFilePatcher(), and DotManager::createRunner().