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 return;
83 }
84
85 if (!(data[1] == 'P' && data[2] == 'N' && data[3] == 'G'))
86 {
87 err("Image '{}' produced by dot is not a valid PNG!\n"
88 "You should either select a different format "
89 "(DOT_IMAGE_FORMAT in the config file) or install a more "
90 "recent version of graphviz (1.7+)\n", imgName);
91 }
92
93 fclose(f);
94}
#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 282 of file dotrunner.cpp.

283{
284 int index = output.findRev('.');
285 if (index < 0) return output;
286 return output.left(index);
287}
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 96 of file dotrunner.cpp.

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