/***************************************************************************** * * Copyright (C) 1997-2019 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * * Documents produced by Doxygen are derivative works derived from the * input used in their production; they are not affected by this license. * */ #include #include #include #include #include #include #include #include #include "config.h" #include "dot.h" #include "dotrunner.h" #include "dotfilepatcher.h" #include "util.h" #include "portable.h" #include "message.h" #include "ftextstream.h" #include "doxygen.h" #include "language.h" #include "index.h" #define MAP_CMD "cmapx" static int DOT_NUM_THREADS; // will be initialized in initDot //-------------------------------------------------------------------- void initDot() { DotGraph::DOT_FONTNAME = Config_getString(DOT_FONTNAME); if (DotGraph::DOT_FONTNAME.isEmpty()) { DotGraph::DOT_FONTNAME="Helvetica"; } DotGraph::DOT_FONTSIZE = Config_getInt(DOT_FONTSIZE); if (DotGraph::DOT_FONTSIZE<4) DotGraph::DOT_FONTSIZE=4; DOT_NUM_THREADS = Config_getInt(DOT_NUM_THREADS); if (DOT_NUM_THREADS > 32) DOT_NUM_THREADS = 32; if (DOT_NUM_THREADS <= 0) DOT_NUM_THREADS = QMAX(2,QThread::idealThreadCount()+1); // these are copied to be sure to be thread save DotRunner::DOT_CLEANUP = Config_getBool(DOT_CLEANUP); DotRunner::DOT_MULTI_TARGETS = Config_getBool(DOT_MULTI_TARGETS); DotRunner::DOT_EXE.init(Config_getString(DOT_PATH) + "dot"); DotGraph::IMG_EXT = getDotImageExtension(); } static QCString g_dotFontPath; static void setDotFontPath(const char *path) { ASSERT(g_dotFontPath.isEmpty()); g_dotFontPath = portable_getenv("DOTFONTPATH"); QCString newFontPath = Config_getString(DOT_FONTPATH); QCString spath = path; if (!newFontPath.isEmpty() && !spath.isEmpty()) { newFontPath.prepend(spath+portable_pathListSeparator()); } else if (newFontPath.isEmpty() && !spath.isEmpty()) { newFontPath=path; } else { portable_unsetenv("DOTFONTPATH"); return; } portable_setenv("DOTFONTPATH",newFontPath); } static void unsetDotFontPath() { if (g_dotFontPath.isEmpty()) { portable_unsetenv("DOTFONTPATH"); } else { portable_setenv("DOTFONTPATH",g_dotFontPath); } g_dotFontPath=""; } // extract size from a dot generated SVG file static bool readSVGSize(const QCString &fileName,int *width,int *height) { bool found=FALSE; QFile f(fileName); if (!f.open(IO_ReadOnly)) { return FALSE; } const int maxLineLen=4096; char buf[maxLineLen]; while (!f.atEnd() && !found) { int numBytes = f.readLine(buf,maxLineLen-1); // read line if (numBytes>0) { buf[numBytes]='\0'; if (qstrncmp(buf,"