Skip to main content

The msc.cpp File Reference

Included Headers

#include "msc.h" #include "portable.h" #include "config.h" #include "message.h" #include "docparser.h" #include "docnode.h" #include "doxygen.h" #include "indexlist.h" #include "util.h" #include "mscgen_api.h" #include "dir.h" #include "textstream.h" #include "stringutil.h"

Functions Index

static boolconvertMapFile (TextStream &t, const QCString &mapName, const QCString &relPath, const QCString &context, const QCString &srcFile, int srcLine)
static booldo_mscgen_generate (const QCString &inFile, const QCString &outFile, mscgen_format_t msc_format, const QCString &srcFile, int srcLine)
voidwriteMscGraphFromFile (const QCString &inFile, const QCString &outDir, const QCString &outFile, MscOutputFormat format, const QCString &srcFile, int srcLine)
static QCStringgetMscImageMapFromFile (const QCString &inFile, const QCString &, const QCString &relPath, const QCString &context, bool writeSVGMap, const QCString &srcFile, int srcLine)
voidwriteMscImageMapFromFile (TextStream &t, const QCString &inFile, const QCString &outDir, const QCString &relPath, const QCString &baseName, const QCString &context, MscOutputFormat format, const QCString &srcFile, int srcLine)

Variables Index

static const intmaxCmdLine = 40960

Functions

convertMapFile()

bool convertMapFile (TextStream & t, const QCString & mapName, const QCString & relPath, const QCString & context, const QCString & srcFile, int srcLine)
static

Definition at line 32 of file msc.cpp.

32static bool convertMapFile(TextStream &t,const QCString &mapName,const QCString &relPath,
33 const QCString &context,const QCString &srcFile,int srcLine)
34{
35 std::ifstream f = Portable::openInputStream(mapName);
36 if (!f.is_open())
37 {
38 err("failed to open map file {} for inclusion in the docs!\n"
39 "If you installed Graphviz/dot after a previous failing run, \n"
40 "try deleting the output directory and rerun doxygen.\n",mapName);
41 return false;
42 }
43 const int maxLineLen=1024;
44 char url[maxLineLen];
45 char ref[maxLineLen];
46 int x1=0, y1=0, x2=0, y2=0;
47 std::string line;
48 while (getline(f,line))
49 {
50 bool isRef = false;
51 //printf("ReadLine '%s'\n",line.c_str());
52 if (literal_at(line.c_str(),"rect"))
53 {
54 // obtain the url and the coordinates in the order used by graphviz-1.5
55 sscanf(line.c_str(),"rect %s %d,%d %d,%d",url,&x1,&y1,&x2,&y2);
56
57 if (qstrcmp(url,"\\ref")==0 || qstrcmp(url,"@ref")==0)
58 {
59 isRef = true;
60 sscanf(line.c_str(),"rect %s %s %d,%d %d,%d",ref,url,&x1,&y1,&x2,&y2);
61 }
62
63 // sanity checks
64 if (y2<y1) { int temp=y2; y2=y1; y1=temp; }
65 if (x2<x1) { int temp=x2; x2=x1; x1=temp; }
66
67
68 bool link = false;
69 if ( isRef )
70 {
71 // handle doxygen \ref tag URL reference
72
73 auto parser { createDocParser() };
74 auto dfAst { createRef( *parser.get(), url, context, srcFile, srcLine) };
75 auto dfAstImpl = dynamic_cast<const DocNodeAST*>(dfAst.get());
76 const DocRef *df = std::get_if<DocRef>(&dfAstImpl->root);
77 if (!df->file().isEmpty() || !df->anchor().isEmpty())
78 {
79 link = true;
80 t << "<area href=\"";
81 t << externalRef(relPath,df->ref(),TRUE);
82 }
83 if (!df->file().isEmpty())
84 {
85 QCString fn = df->file();
87 t << fn;
88 }
89 if (!df->anchor().isEmpty())
90 {
91 t << "#" << df->anchor();
92 }
93 }
94 else
95 {
96 link = true;
97 t << "<area href=\"";
98 t << url;
99 }
100 if (link)
101 {
102 t << "\" shape=\"rect\" coords=\""
103 << x1 << "," << y1 << "," << x2 << "," << y2 << "\""
104 << " alt=\"\"/>\n";
105 }
106 }
107 }
108
109 return true;
110}

References addHtmlExtensionIfMissing, DocRef::anchor, createDocParser, createRef, err, externalRef, DocRef::file, QCString::isEmpty, literal_at, Portable::openInputStream, qstrcmp, DocRef::ref and TRUE.

Referenced by getMscImageMapFromFile.

do_mscgen_generate()

bool do_mscgen_generate (const QCString & inFile, const QCString & outFile, mscgen_format_t msc_format, const QCString & srcFile, int srcLine)
static

Definition at line 112 of file msc.cpp.

112static bool do_mscgen_generate(const QCString& inFile,const QCString& outFile,mscgen_format_t msc_format,
113 const QCString &srcFile,int srcLine)
114{
115 auto mscgen_tool = Config_getString(MSCGEN_TOOL).stripWhiteSpace();
116 if (!mscgen_tool.isEmpty()) // use external mscgen tool
117 {
118 QCString type;
119 switch (msc_format)
120 {
121 case mscgen_format_png:
122 type = "png";
123 break;
124 case mscgen_format_eps:
125 type = "eps";
126 break;
127 case mscgen_format_svg:
128 type = "svg";
129 break;
130 case mscgen_format_pngmap:
131 case mscgen_format_svgmap:
132 type = "ismap";
133 break;
134 }
135 int exitcode = Portable::system(mscgen_tool,"-T"+type+" -o "+outFile+" "+inFile);
136 if (exitcode!=0)
137 {
138 err_full(srcFile,srcLine,"Problems running external tool {} given via MSCGEN_TOOL (exit status: {})."
139 " Look for typos in your msc file and check error messages above.",
140 mscgen_tool,exitcode);
141 return false;
142 }
143 }
144 else // use built-in mscgen tool
145 {
146 int code = mscgen_generate(inFile.data(),outFile.data(),msc_format);
147 if (code!=0)
148 {
149 err_full(srcFile,srcLine,"Problems generating msc output (error={}). Look for typos in you msc file '{}'",
150 mscgen_error2str(code),inFile);
151 return false;
152 }
153 }
154 return true;
155}

References Config_getString, QCString::data, err_full and Portable::system.

Referenced by getMscImageMapFromFile and writeMscGraphFromFile.

getMscImageMapFromFile()

QCString getMscImageMapFromFile (const QCString & inFile, const QCString &, const QCString & relPath, const QCString & context, bool writeSVGMap, const QCString & srcFile, int srcLine)
static

Definition at line 214 of file msc.cpp.

214static QCString getMscImageMapFromFile(const QCString& inFile, const QCString& /* outDir */,
215 const QCString& relPath,const QCString& context,
216 bool writeSVGMap,const QCString &srcFile,int srcLine)
217{
218 QCString outFile = inFile + ".map";
219
220 if (!do_mscgen_generate(inFile,outFile,
221 writeSVGMap ? mscgen_format_svgmap : mscgen_format_pngmap,
222 srcFile,srcLine))
223 return "";
224
225 TextStream t;
226 convertMapFile(t, outFile, relPath, context, srcFile, srcLine);
227
228 Dir().remove(outFile.str());
229
230 return t.str();
231}

References convertMapFile, do_mscgen_generate, Dir::remove, QCString::str and TextStream::str.

Referenced by writeMscImageMapFromFile.

writeMscGraphFromFile()

void writeMscGraphFromFile (const QCString & inFile, const QCString & outDir, const QCString & outFile, MscOutputFormat format, const QCString & srcFile, int srcLine)

Definition at line 157 of file msc.cpp.

157void writeMscGraphFromFile(const QCString &inFile,const QCString &outDir,
158 const QCString &outFile,MscOutputFormat format,
159 const QCString &srcFile,int srcLine
160 )
161{
162 QCString absOutFile = outDir;
163 absOutFile+=Portable::pathSeparator();
164 absOutFile+=outFile;
165
166 mscgen_format_t msc_format = mscgen_format_png;
167 QCString imgName = absOutFile;
168 switch (format)
169 {
171 msc_format = mscgen_format_png;
172 imgName+=".png";
173 break;
175 msc_format = mscgen_format_eps;
176 imgName+=".eps";
177 break;
179 msc_format = mscgen_format_svg;
180 imgName+=".svg";
181 break;
182 default:
183 return;
184 }
185 if (!do_mscgen_generate(inFile,imgName,msc_format,srcFile,srcLine))
186 {
187 return;
188 }
189
190 if ( (format==MscOutputFormat::EPS) && (Config_getBool(USE_PDFLATEX)) )
191 {
193 epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",
194 qPrint(absOutFile),qPrint(absOutFile));
195 if (Portable::system("epstopdf",epstopdfArgs)!=0)
196 {
197 err_full(srcFile,srcLine,"Problems running epstopdf when processing '{}.eps'. Check your TeX installation!", absOutFile);
198 }
199 else
200 {
201 Dir().remove((absOutFile + ".eps").data());
202 }
203 }
204
205 int i=std::max(imgName.findRev('/'),imgName.findRev('\\'));
206 if (i!=-1) // strip path
207 {
208 imgName=imgName.right(imgName.length()-i-1);
209 }
210 Doxygen::indexList->addImageFile(imgName);
211
212}

References BITMAP, Config_getBool, do_mscgen_generate, EPS, err_full, QCString::ExplicitSize, QCString::findRev, Doxygen::indexList, QCString::length, maxCmdLine, Portable::pathSeparator, qPrint, Dir::remove, QCString::right, QCString::sprintf, SVG and Portable::system.

Referenced by DocbookDocVisitor::startMscFile, LatexDocVisitor::startMscFile, DocbookDocVisitor::writeMscFile, HtmlDocVisitor::writeMscFile, LatexDocVisitor::writeMscFile and RTFDocVisitor::writeMscFile.

writeMscImageMapFromFile()

void writeMscImageMapFromFile (TextStream & t, const QCString & inFile, const QCString & outDir, const QCString & relPath, const QCString & baseName, const QCString & context, MscOutputFormat format, const QCString & srcFile, int srcLine)

Definition at line 233 of file msc.cpp.

234 const QCString &outDir,
235 const QCString &relPath,
236 const QCString &baseName,
237 const QCString &context,
238 MscOutputFormat format,
239 const QCString &srcFile,
240 int srcLine
241 )
242{
243 QCString mapName = baseName+".map";
244 t << "<img src=\"" << relPath << baseName << ".";
245 switch (format)
246 {
248 t << "png";
249 break;
251 t << "eps";
252 break;
254 t << "svg";
255 break;
256 default:
257 t << "unknown";
258 }
259 QCString imap = getMscImageMapFromFile(inFile,outDir,relPath,context,format==MscOutputFormat::SVG,srcFile,srcLine);
260 if (!imap.isEmpty())
261 {
262 t << "\" alt=\""
263 << baseName << "\" border=\"0\" usemap=\"#" << mapName << "\"/>\n";
264 t << "<map name=\"" << mapName << "\" id=\"" << mapName << "\">" << imap << "</map>\n";
265 }
266 else
267 {
268 t << "\" alt=\"" << baseName << "\" border=\"0\"/>\n";
269 }
270}

References BITMAP, EPS, getMscImageMapFromFile, QCString::isEmpty and SVG.

Referenced by HtmlDocVisitor::writeMscFile.

Variables

maxCmdLine

const int maxCmdLine = 40960
static

Definition at line 30 of file msc.cpp.

30static const int maxCmdLine = 40960;

Generated via doxygen2docusaurus by Doxygen 1.14.0.