Skip to main content

The dotrunner.cpp File Reference

Included Headers

#include <cassert> #include <cmath> #include <gunzip.hh> #include "dotrunner.h" #include "util.h" #include "portable.h" #include "dot.h" #include "message.h" #include "config.h" #include "dir.h" #include "doxygen.h"

Functions Index

static voidcheckPngResult (const QCString &imgName)
static boolresetPDFSize (const int width, const int height, const QCString &base)
QCStringgetBaseNameOfOutput (const QCString &output)

Macro Definitions Index

#defineMAX_LATEX_GRAPH_INCH   150
#defineMAX_LATEX_GRAPH_SIZE   (MAX_LATEX_GRAPH_INCH * 72)
#defineDBG(x)   do {} while(0)

Functions

checkPngResult()

void checkPngResult (const QCString & imgName)
static

Definition at line 69 of file dotrunner.cpp.

69static void checkPngResult(const QCString &imgName)
70{
71 FILE *f = Portable::fopen(imgName,"rb");
72 if (f)
73 {
74 char data[4];
75 if (fread(data,1,4,f)==4)
76 {
77 if (!(data[1]=='P' && data[2]=='N' && data[3]=='G'))
78 {
79 err("Image '{}' produced by dot is not a valid PNG!\n"
80 "You should either select a different format "
81 "(DOT_IMAGE_FORMAT in the config file) or install a more "
82 "recent version of graphviz (1.7+)\n",imgName
83 );
84 }
85 }
86 else
87 {
88 err("Could not read image '{}' generated by dot!\n",imgName);
89 }
90 fclose(f);
91 }
92 else
93 {
94 err("Could not open image '{}' generated by dot!\n",imgName);
95 }
96}

References err and Portable::fopen.

Referenced by DotRunner::run.

getBaseNameOfOutput()

QCString getBaseNameOfOutput (const QCString & output)

Definition at line 284 of file dotrunner.cpp.

285{
286 int index = output.findRev('.');
287 if (index < 0) return output;
288 return output.left(index);
289}

References QCString::findRev and QCString::left.

Referenced by DotRunner::run.

resetPDFSize()

bool resetPDFSize (const int width, const int height, const QCString & base)
static

Definition at line 98 of file dotrunner.cpp.

98static bool resetPDFSize(const int width,const int height, const QCString &base)
99{
100 QCString tmpName = base+".tmp";
101 QCString patchFile = base+".dot";
102 Dir thisDir;
103 if (!thisDir.rename(patchFile.str(),tmpName.str()))
104 {
105 err("Failed to rename file {} to {}!\n",patchFile,tmpName);
106 return FALSE;
107 }
108 std::ifstream fi = Portable::openInputStream(tmpName);
109 std::ofstream t = Portable::openOutputStream(patchFile);
110 if (!fi.is_open())
111 {
112 err("problem opening file {} for patching!\n",tmpName);
113 thisDir.rename(tmpName.str(),patchFile.str());
114 return FALSE;
115 }
116 if (!t.is_open())
117 {
118 err("problem opening file {} for patching!\n",patchFile);
119 thisDir.rename(tmpName.str(),patchFile.str());
120 return FALSE;
121 }
122 std::string line;
123 while (getline(fi,line)) // foreach line
124 {
125 if (line.find("LATEX_PDF_SIZE") != std::string::npos)
126 {
127 double scale = (width > height ? width : height)/double(MAX_LATEX_GRAPH_INCH);
128 t << " size=\""<<width/scale << "," <<height/scale << "\";\n";
129 }
130 else
131 t << line << "\n";
132 }
133 fi.close();
134 t.close();
135 // remove temporary file
136 thisDir.remove(tmpName.str());
137 return TRUE;
138}

References err, FALSE, MAX_LATEX_GRAPH_INCH, Portable::openInputStream, Portable::openOutputStream, Dir::remove, Dir::rename, QCString::str and TRUE.

Referenced by DotRunner::run.

Macro Definitions

DBG

#define DBG(x)   do {} while(0)

Definition at line 63 of file dotrunner.cpp.

63#define DBG(x) do {} while(0)

Referenced by reg::Ex::match, reg::Ex::Private::matchAt and DotRunner::readBoundingBox.

MAX_LATEX_GRAPH_INCH

#define MAX_LATEX_GRAPH_INCH   150

Definition at line 59 of file dotrunner.cpp.

59#define MAX_LATEX_GRAPH_INCH 150

Referenced by resetPDFSize.

MAX_LATEX_GRAPH_SIZE

#define MAX_LATEX_GRAPH_SIZE   (MAX_LATEX_GRAPH_INCH * 72)

Definition at line 60 of file dotrunner.cpp.

60#define MAX_LATEX_GRAPH_SIZE (MAX_LATEX_GRAPH_INCH * 72)

Referenced by DotRunner::run.


Generated via doxygen2docusaurus by Doxygen 1.14.0.