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()

static 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 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}
#define err(fmt,...)
Definition message.h:127
FILE * fopen(const QCString &fileName, const QCString &mode)
Definition portable.cpp:366
int fclose(FILE *f)
Definition portable.cpp:386

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}
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:91
QCString left(size_t len) const
Definition qcstring.h:214

References QCString::findRev(), and QCString::left().

Referenced by DotRunner::run().

◆ resetPDFSize()

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

Definition at line 98 of file dotrunner.cpp.

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}
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:537
#define MAX_LATEX_GRAPH_INCH
Definition dotrunner.cpp:59
std::ifstream openInputStream(const QCString &name, bool binary=false, bool openAtEnd=false)
Definition portable.cpp:676
std::ofstream openOutputStream(const QCString &name, bool append=false)
Definition portable.cpp:665
#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().