浏览该文件的文档.
29 #define MAX_LATEX_GRAPH_INCH 150
30 #define MAX_LATEX_GRAPH_SIZE (MAX_LATEX_GRAPH_INCH * 72)
42 if (fread(data,1,4,f)==4)
44 if (!(data[1]==
'P' && data[2]==
'N' && data[3]==
'G'))
46 err(
"Image '%s' produced by dot is not a valid PNG!\n"
47 "You should either select a different format "
48 "(DOT_IMAGE_FORMAT in the config file) or install a more "
49 "recent version of graphviz (1.7+)\n",
qPrint(imgName)
55 err(
"Could not read image '%s' generated by dot!\n",
qPrint(imgName));
61 err(
"Could not open image '%s' generated by dot!\n",
qPrint(imgName));
67 std::string tmpName = base.
str()+
".tmp";
68 std::string patchFile = base.
str()+
".dot";
70 if (!thisDir.
rename(patchFile,tmpName))
72 err(
"Failed to rename file %s to %s!\n",
qPrint(patchFile),
qPrint(tmpName));
75 std::ifstream fi(tmpName,std::ifstream::in);
76 std::ofstream t(patchFile,std::ofstream::out | std::ofstream::binary);
79 err(
"problem opening file %s for patching!\n",
qPrint(tmpName));
80 thisDir.
rename(tmpName,patchFile);
85 err(
"problem opening file %s for patching!\n",
qPrint(patchFile));
86 thisDir.
rename(tmpName,patchFile);
90 while (getline(fi,line))
92 if (line.find(
"LATEX_PDF_SIZE") != std::string::npos)
95 t <<
" size=\""<<width/scale <<
"," <<height/scale <<
"\";\n";
109 const char *bb = isEps ?
"%%PageBoundingBox:" :
"/MediaBox [";
110 int bblen = (int)strlen(bb);
117 const int maxLineLen=1024;
118 char buf[maxLineLen];
119 while (fgets(buf,maxLineLen,f)!=NULL)
121 const char *p = strstr(buf,bb);
126 if (sscanf(p+bblen,
"%d %d %d %d",&x,&y,width,height)!=4)
134 err(
"Failed to extract bounding box from generated diagram file %s\n",
qPrint(fileName));
151 const QCString &srcFile,
int srcLine)
156 if (s.format != format)
continue;
157 if (s.output != output)
continue;
161 auto args =
QCString(
"-T") + format +
" -o \"" + output +
"\"";
162 m_jobs.emplace_back(format.
str(), output, args, srcFile, srcLine);
167 int index = output.
findRev(
'.');
168 if (index < 0)
return output;
169 return output.
left(index);
192 srcFile =
m_jobs.front().srcFile;
193 srcLine =
m_jobs.front().srcLine;
212 if (s.format.left(3)==
"pdf")
214 int width=0,height=0;
224 if (s.format.left(3)==
"png")
250 err_full(srcFile,srcLine,
"Problems running dot: exit code=%d, command='%s', arguments='%s'\n",
260 std::lock_guard<std::mutex> locker(
m_mutex);
267 std::unique_lock<std::mutex> locker(
m_mutex);
279 std::lock_guard<std::mutex> locker(
m_mutex);
bool run()
Runs dot for all jobs added.
FILE * fopen(const QCString &fileName, const QCString &mode)
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Class representing a directory in the file system
Helper class to run dot from doxygen from multiple threads.
int findRev(char c, int index=-1, bool cs=TRUE) const
bool isEmpty() const
Returns TRUE iff the string is empty
void err(const char *fmt,...)
std::queue< DotRunner * > m_queue
void addJob(const QCString &format, const QCString &output, const QCString &srcFile, int srcLine)
Adds an additional job to the run.
#define MAX_LATEX_GRAPH_SIZE
static bool readBoundingBox(const QCString &fileName, int *width, int *height, bool isEps)
bool rename(const std::string &orgName, const std::string &newName, bool acceptsAbsPath=true) const
QCString left(size_t len) const
void enqueue(DotRunner *runner)
Queue of dot jobs to run.
#define MAX_LATEX_GRAPH_INCH
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
DotRunner(const QCString &absDotName, const QCString &md5Hash=QCString())
Creates a runner for a dot file.
static bool resetPDFSize(const int width, const int height, const QCString &base)
DotWorkerThread(DotRunnerQueue *queue)
#define Config_getBool(name)
std::vector< DotJob > m_jobs
const char * qPrint(const char *s)
#define Config_getString(name)
void err_full(const QCString &file, int line, const char *fmt,...)
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string
std::unique_ptr< std::thread > m_thread
Portable versions of functions that are platform dependent.
void unlink(const QCString &fileName)
std::condition_variable m_bufferNotEmpty
A bunch of utility functions.
QCString getBaseNameOfOutput(const QCString &output)
static void checkPngResult(const QCString &imgName)
This is an alternative implementation of QCString.