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

Referenced by resetPDFSize().

◆ MAX_LATEX_GRAPH_SIZE

#define MAX_LATEX_GRAPH_SIZE   (MAX_LATEX_GRAPH_INCH * 72)

Definition at line 50 of file dotrunner.cpp.

Referenced by DotRunner::run().

Function Documentation

◆ checkPngResult()

static void checkPngResult ( const QCString & imgName)
static

Definition at line 59 of file dotrunner.cpp.

60{
61 FILE *f = Portable::fopen(imgName,"rb");
62 if (f)
63 {
64 char data[4];
65 if (fread(data,1,4,f)==4)
66 {
67 if (!(data[1]=='P' && data[2]=='N' && data[3]=='G'))
68 {
69 err("Image '%s' produced by dot is not a valid PNG!\n"
70 "You should either select a different format "
71 "(DOT_IMAGE_FORMAT in the config file) or install a more "
72 "recent version of graphviz (1.7+)\n",qPrint(imgName)
73 );
74 }
75 }
76 else
77 {
78 err("Could not read image '%s' generated by dot!\n",qPrint(imgName));
79 }
80 fclose(f);
81 }
82 else
83 {
84 err("Could not open image '%s' generated by dot!\n",qPrint(imgName));
85 }
86}
#define err(fmt,...)
Definition message.h:84
FILE * fopen(const QCString &fileName, const QCString &mode)
Definition portable.cpp:366
int fclose(FILE *f)
Definition portable.cpp:386
const char * qPrint(const char *s)
Definition qcstring.h:661

References err, Portable::fopen(), and qPrint().

Referenced by DotRunner::run().

◆ getBaseNameOfOutput()

QCString getBaseNameOfOutput ( const QCString & output)

Definition at line 274 of file dotrunner.cpp.

275{
276 int index = output.findRev('.');
277 if (index < 0) return output;
278 return output.left(index);
279}
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 88 of file dotrunner.cpp.

89{
90 QCString tmpName = base+".tmp";
91 QCString patchFile = base+".dot";
92 Dir thisDir;
93 if (!thisDir.rename(patchFile.str(),tmpName.str()))
94 {
95 err("Failed to rename file %s to %s!\n",qPrint(patchFile),qPrint(tmpName));
96 return FALSE;
97 }
98 std::ifstream fi = Portable::openInputStream(tmpName);
99 std::ofstream t = Portable::openOutputStream(patchFile);
100 if (!fi.is_open())
101 {
102 err("problem opening file %s for patching!\n",qPrint(tmpName));
103 thisDir.rename(tmpName.str(),patchFile.str());
104 return FALSE;
105 }
106 if (!t.is_open())
107 {
108 err("problem opening file %s for patching!\n",qPrint(patchFile));
109 thisDir.rename(tmpName.str(),patchFile.str());
110 return FALSE;
111 }
112 std::string line;
113 while (getline(fi,line)) // foreach line
114 {
115 if (line.find("LATEX_PDF_SIZE") != std::string::npos)
116 {
117 double scale = (width > height ? width : height)/double(MAX_LATEX_GRAPH_INCH);
118 t << " size=\""<<width/scale << "," <<height/scale << "\";\n";
119 }
120 else
121 t << line << "\n";
122 }
123 fi.close();
124 t.close();
125 // remove temporary file
126 thisDir.remove(tmpName.str());
127 return TRUE;
128}
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:526
#define MAX_LATEX_GRAPH_INCH
Definition dotrunner.cpp:49
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(), qPrint(), Dir::remove(), Dir::rename(), QCString::str(), and TRUE.

Referenced by DotRunner::run().