Doxygen
Loading...
Searching...
No Matches
dotrunner.cpp File Reference
#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"
Include dependency graph for dotrunner.cpp:

Go to the source code of this file.

Macros

#define MAX_LATEX_GRAPH_INCH   150
#define MAX_LATEX_GRAPH_SIZE   (MAX_LATEX_GRAPH_INCH * 72)
#define DBG(x)

Functions

static void checkPngResult (const QCString &imgName)
static bool resetPDFSize (const int width, const int height, const QCString &base)
QCString getBaseNameOfOutput (const QCString &output)

Macro Definition Documentation

◆ DBG

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

Definition at line 63 of file dotrunner.cpp.

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.

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.

Referenced by DotRunner::run().

Function Documentation

◆ checkPngResult()

void checkPngResult ( const QCString & imgName)
static

Definition at line 69 of file dotrunner.cpp.

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

References err, and Portable::fopen().

Referenced by DotRunner::run().

◆ getBaseNameOfOutput()

QCString getBaseNameOfOutput ( const QCString & output)

Definition at line 283 of file dotrunner.cpp.

284{
285 int index = output.findRev('.');
286 if (index < 0) return output;
287 return output.left(index);
288}
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:96
QCString left(size_t len) const
Definition qcstring.h:229

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 97 of file dotrunner.cpp.

98{
99 QCString tmpName = base+".tmp";
100 QCString patchFile = base+".dot";
101 Dir thisDir;
102 if (!thisDir.rename(patchFile.str(),tmpName.str()))
103 {
104 err("Failed to rename file {} to {}!\n",patchFile,tmpName);
105 return FALSE;
106 }
107 std::ifstream fi = Portable::openInputStream(tmpName);
108 std::ofstream t = Portable::openOutputStream(patchFile);
109 if (!fi.is_open())
110 {
111 err("problem opening file {} for patching!\n",tmpName);
112 thisDir.rename(tmpName.str(),patchFile.str());
113 return FALSE;
114 }
115 if (!t.is_open())
116 {
117 err("problem opening file {} for patching!\n",patchFile);
118 thisDir.rename(tmpName.str(),patchFile.str());
119 return FALSE;
120 }
121 std::string line;
122 while (getline(fi,line)) // foreach line
123 {
124 if (line.find("LATEX_PDF_SIZE") != std::string::npos)
125 {
126 double scale = (width > height ? width : height)/double(MAX_LATEX_GRAPH_INCH);
127 t << " size=\""<<width/scale << "," <<height/scale << "\";\n";
128 }
129 else
130 t << line << "\n";
131 }
132 fi.close();
133 t.close();
134 // remove temporary file
135 thisDir.remove(tmpName.str());
136 return TRUE;
137}
Class representing a directory in the file system.
Definition dir.h:75
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:314
bool rename(const std::string &orgName, const std::string &newName, bool acceptsAbsPath=true) const
Definition dir.cpp:321
This is an alternative implementation of QCString.
Definition qcstring.h:101
const std::string & str() const
Definition qcstring.h:552
#define MAX_LATEX_GRAPH_INCH
Definition dotrunner.cpp:59
std::ifstream openInputStream(const QCString &name, bool binary=false, bool openAtEnd=false)
Definition portable.cpp:660
std::ofstream openOutputStream(const QCString &name, bool append=false)
Definition portable.cpp:649
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34

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

Referenced by DotRunner::run().