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 DString &path)
static void unsetDotFontPath ()
void writeDotGraphFromFile (const DString &inFile, const DString &outDir, const DString &outFile, GraphOutputFormat format, const DString &srcFile, int srcLine, bool toIndex)
void writeDotImageMapFromFile (TextStream &t, const DString &inFile, const DString &outDir, const DString &relPath, const DString &baseName, const DString &context, int graphId, const DString &srcFile, int srcLine, bool newFile)

Variables

static DString 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 writeDotImageMapFromFile().

Function Documentation

◆ setDotFontPath()

void setDotFontPath ( const DString & path)
static

Definition at line 42 of file dot.cpp.

43{
45 g_dotFontPath = Portable::getenv("DOTFONTPATH");
46 DString newFontPath = Config_getString(DOT_FONTPATH);
47 if (!newFontPath.empty() && !path.empty())
48 {
49 newFontPath.prepend(path+Portable::pathListSeparator());
50 }
51 else if (newFontPath.empty() && !path.empty())
52 {
53 newFontPath=path;
54 }
55 else
56 {
57 Portable::unsetenv("DOTFONTPATH");
58 return;
59 }
60 Portable::setenv("DOTFONTPATH",newFontPath);
61}
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:89
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:153
DString & prepend(const char *s)
Definition dstring.h:504
#define Config_getString(name)
Definition config.h:32
static DString g_dotFontPath
Definition dot.cpp:38
#define ASSERT(x)
Definition dstring.h:29
void setenv(const DString &variable, const DString &value)
Definition portable.cpp:286
DString getenv(const DString &variable)
Definition portable.cpp:321
DString pathListSeparator()
Definition portable.cpp:383
void unsetenv(const DString &variable)
Definition portable.cpp:301

References ASSERT, Config_getString, DString::empty(), g_dotFontPath, Portable::getenv(), Portable::pathListSeparator(), DString::prepend(), setDotFontPath(), Portable::setenv(), and Portable::unsetenv().

Referenced by DotManager::run(), and setDotFontPath().

◆ unsetDotFontPath()

void unsetDotFontPath ( )
static

Definition at line 63 of file dot.cpp.

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

References DString::empty(), g_dotFontPath, Portable::setenv(), unsetDotFontPath(), and Portable::unsetenv().

Referenced by DotManager::run(), and unsetDotFontPath().

◆ writeDotGraphFromFile()

void writeDotGraphFromFile ( const DString & inFile,
const DString & outDir,
const DString & outFile,
GraphOutputFormat format,
const DString & srcFile,
int srcLine,
bool toIndex )

Definition at line 196 of file dot.cpp.

199{
200 Dir d(outDir.str());
201 if (!d.exists())
202 {
203 term("Output dir {} does not exist!\n",outDir);
204 }
205
206 DString imgExt = getDotImageExtension();
207 DString imgName = outFile+"."+imgExt;
208 DString absImgName = d.absPath()+"/"+imgName;
209 DString absOutFile = d.absPath()+"/"+outFile;
210
211 DString dotArgs;
212 if (format==GraphOutputFormat::BITMAP)
213 {
214 dotArgs = DString("-T") + Config_getEnumAsString(DOT_IMAGE_FORMAT) + " -o \"" + absImgName + "\" \"" + inFile + "\"";
215 }
216 else // format==GraphOutputFormat::EPS
217 {
218 if (Config_getBool(USE_PDFLATEX))
219 {
220 dotArgs = DString("-Tpdf -o \"") + absOutFile + ".pdf\" \"" + inFile + "\"";
221 }
222 else
223 {
224 dotArgs = DString("-Teps -o \"") + absOutFile + ".eps\" \"" + inFile + "\"";
225 }
226 }
227
228 if (Portable::system(Doxygen::verifiedDotPath, dotArgs, false) != 0)
229 {
230 return;
231 }
232
233 if (toIndex) Doxygen::indexList->addImageFile(imgName);
234
235}
DString()=default
const std::string & str() const
Definition dstring.h:634
Class representing a directory in the file system.
Definition dir.h:75
static DString verifiedDotPath
Definition doxygen.h:137
static IndexList * indexList
Definition doxygen.h:132
void addImageFile(const DString &name)
Definition indexlist.h:123
#define Config_getEnumAsString(name)
Definition config.h:36
#define Config_getBool(name)
Definition config.h:33
#define term(fmt,...)
Definition message.h:137
int system(const DString &command, const DString &args, bool commandHasConsole=true)
Definition portable.cpp:105
DString getDotImageExtension()
Definition util.cpp:5630

References Dir::absPath(), IndexList::addImageFile(), BITMAP, Config_getBool, Config_getEnumAsString, DString::DString(), Dir::exists(), getDotImageExtension(), Doxygen::indexList, DString::str(), Portable::system(), term, Doxygen::verifiedDotPath, and writeDotGraphFromFile().

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

◆ writeDotImageMapFromFile()

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

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
newFilesignal whether or not the file has been generated before (value false) or not.

Definition at line 249 of file dot.cpp.

254{
255
256 Dir d(outDir.str());
257 if (!d.exists())
258 {
259 term("Output dir {} does not exist!\n",outDir);
260 }
261
262 DString mapName = baseName+".cmapx";
263 DString imgExt = getDotImageExtension();
264 DString imgName = baseName+"."+imgExt;
265 DString absOutFile = d.absPath()+"/"+mapName;
266
267 DString dotArgs = DString("-T" MAP_CMD " -o \"") + absOutFile + "\" \"" + inFile + "\"";
268 if (Portable::system(Doxygen::verifiedDotPath, dotArgs, false) != 0)
269 {
270 return;
271 }
272
273 if (imgExt=="svg") // vector graphics
274 {
275 DString svgName = outDir+"/"+baseName+".svg";
276 DotFilePatcher::writeSVGFigureLink(t,relPath,baseName,svgName);
277 if (newFile)
278 {
279 DotFilePatcher patcher(svgName);
280 patcher.addSVGConversion("",true,context,true,graphId);
281 patcher.run();
282 }
283 }
284 else // bitmap graphics
285 {
286 TextStream tt;
287 t << "<img src=\"" << relPath << imgName << "\" alt=\""
288 << imgName << "\" border=\"0\" usemap=\"#" << mapName << "\"/>\n";
289 DotFilePatcher::convertMapFile(tt, absOutFile, relPath ,true, context);
290 if (!tt.empty())
291 {
292 t << "<map name=\"" << mapName << "\" id=\"" << mapName << "\">";
293 t << tt.str();
294 t << "</map>\n";
295 }
296 }
297 d.remove(absOutFile.str());
298}
DString & remove(size_t index, size_t len)
Definition dstring.h:524
Helper class to insert a set of map file into an output file.
static bool writeSVGFigureLink(TextStream &out, const DString &relPath, const DString &baseName, const DString &absImgName)
Check if a reference to a SVG figure can be written and do so if possible.
static bool convertMapFile(TextStream &t, const DString &mapName, const DString &relPath, bool urlOnly=false, const DString &context=DString())
Text streaming class that buffers data.
Definition textstream.h:36
bool empty() const
Returns true iff the buffer is empty.
Definition textstream.h:256
std::string str() const
Return the contents of the buffer as a std::string object.
Definition textstream.h:232
#define MAP_CMD
Definition dot.cpp:34

References Dir::absPath(), DotFilePatcher::addSVGConversion(), DotFilePatcher::convertMapFile(), DString::DString(), TextStream::empty(), Dir::exists(), getDotImageExtension(), MAP_CMD, Dir::remove(), DotFilePatcher::run(), DString::str(), TextStream::str(), Portable::system(), term, Doxygen::verifiedDotPath, writeDotImageMapFromFile(), and DotFilePatcher::writeSVGFigureLink().

Referenced by HtmlDocVisitor::writeDotFile(), and writeDotImageMapFromFile().

Variable Documentation

◆ g_dotFontPath

DString 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::addJob(), and DotManager::createFilePatcher().