Functions | Variables
msc.cpp File Reference
#include "msc.h"
#include "portable.h"
#include "config.h"
#include "message.h"
#include "docparser.h"
#include "doxygen.h"
#include "util.h"
#include "ftextstream.h"
#include <qdir.h>

Go to the source code of this file.

Functions

static bool convertMapFile (FTextStream &t, const char *mapName, const QCString relPath, const QCString &context)
 
void writeMscGraphFromFile (const char *inFile, const char *outDir, const char *outFile, MscOutputFormat format)
 
QCString getMscImageMapFromFile (const QCString &inFile, const QCString &outDir, const QCString &relPath, const QCString &context)
 
void writeMscImageMapFromFile (FTextStream &t, const QCString &inFile, const QCString &outDir, const QCString &relPath, const QCString &baseName, const QCString &context, MscOutputFormat format)
 

Variables

static const int maxCmdLine = 40960
 

Function Documentation

static bool convertMapFile ( FTextStream t,
const char *  mapName,
const QCString  relPath,
const QCString context 
)
static

Definition at line 31 of file msc.cpp.

33 {
34  QFile f(mapName);
35  if (!f.open(IO_ReadOnly))
36  {
37  err("failed to open map file %s for inclusion in the docs!\n"
38  "If you installed Graphviz/dot after a previous failing run, \n"
39  "try deleting the output directory and rerun doxygen.\n",mapName);
40  return FALSE;
41  }
42  const int maxLineLen=1024;
43  char buf[maxLineLen];
44  char url[maxLineLen];
45  char ref[maxLineLen];
46  int x1,y1,x2,y2;
47  while (!f.atEnd())
48  {
49  bool isRef = FALSE;
50  int numBytes = f.readLine(buf,maxLineLen);
51  buf[numBytes-1]='\0';
52  //printf("ReadLine `%s'\n",buf);
53  if (qstrncmp(buf,"rect",4)==0)
54  {
55  // obtain the url and the coordinates in the order used by graphviz-1.5
56  sscanf(buf,"rect %s %d,%d %d,%d",url,&x1,&y1,&x2,&y2);
57 
58  if (qstrcmp(url,"\\ref")==0 || qstrcmp(url,"@ref")==0)
59  {
60  isRef = TRUE;
61  sscanf(buf,"rect %s %s %d,%d %d,%d",ref,url,&x1,&y1,&x2,&y2);
62  }
63 
64  // sanity checks
65  if (y2<y1) { int temp=y2; y2=y1; y1=temp; }
66  if (x2<x1) { int temp=x2; x2=x1; x1=temp; }
67 
68  t << "<area href=\"";
69 
70  if ( isRef )
71  {
72  // handle doxygen \ref tag URL reference
73  DocRef *df = new DocRef( (DocNode*) 0, url, context );
74  t << externalRef(relPath,df->ref(),TRUE);
75  if (!df->file().isEmpty()) t << df->file() << Doxygen::htmlFileExtension;
76  if (!df->anchor().isEmpty()) t << "#" << df->anchor();
77  delete df;
78  }
79  else
80  {
81  t << url;
82  }
83  t << "\" shape=\"rect\" coords=\""
84  << x1 << "," << y1 << "," << x2 << "," << y2 << "\""
85  << " alt=\"\"/>" << endl;
86  }
87  }
88 
89  return TRUE;
90 }
Q_EXPORT int qstrncmp(const char *str1, const char *str2, uint len)
Definition: qcstring.h:101
QCString anchor() const
Definition: docparser.h:830
bool isEmpty() const
Definition: qcstring.h:189
static QCString htmlFileExtension
Definition: doxygen.h:130
const bool FALSE
Definition: qglobal.h:370
QCString file() const
Definition: docparser.h:827
#define IO_ReadOnly
Definition: qiodevice.h:61
QCString ref() const
Definition: docparser.h:829
void err(const char *fmt,...)
Definition: message.cpp:226
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
Q_EXPORT int qstrcmp(const char *str1, const char *str2)
Definition: qcstring.h:95
UWORD32 buf[4]
Definition: md5.h:42
const bool TRUE
Definition: qglobal.h:371
QTextStream & endl(QTextStream &s)
QCString externalRef(const QCString &relPath, const QCString &ref, bool href)
Definition: util.cpp:7856
QCString getMscImageMapFromFile ( const QCString inFile,
const QCString outDir,
const QCString relPath,
const QCString context 
)

Definition at line 156 of file msc.cpp.

158 {
159  QCString outFile = inFile + ".map";
160 
161 
162  //printf("*** running:getMscImageMapFromFile \n");
163  // chdir to the output dir, so dot can find the font file.
164  QCString oldDir = QDir::currentDirPath().utf8();
165  // go to the html output directory (i.e. path)
166  QDir::setCurrent(outDir);
167  //printf("Going to dir %s\n",QDir::currentDirPath().data());
168 
169  QCString mscExe = Config_getString("MSCGEN_PATH")+"mscgen"+portable_commandExtension();
170  QCString mscArgs = "-T ismap -i \"";
171  mscArgs+=inFile;
172  mscArgs+="\" -o \"";
173  mscArgs+=outFile + "\"";
174 
175  int exitCode;
177  if ((exitCode=portable_system(mscExe,mscArgs,FALSE))!=0)
178  {
180  QDir::setCurrent(oldDir);
181  return "";
182  }
184 
186  FTextStream tmpout(&result);
187  convertMapFile(tmpout, outFile, relPath, context);
188  QDir().remove(outFile);
189 
190  QDir::setCurrent(oldDir);
191  return result.data();
192 }
Traverses directory structures and contents in a platform-independent way.
Definition: qdir.h:52
void portable_sysTimerStop()
Definition: portable.cpp:415
char * data() const
Definition: qgstring.h:42
static QCString result
virtual bool remove(const QString &fileName, bool acceptAbsPath=TRUE)
Definition: qdir.cpp:915
const bool FALSE
Definition: qglobal.h:370
TFile * outFile
Definition: makeDST.cxx:36
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
static bool convertMapFile(FTextStream &t, const char *mapName, const QCString relPath, const QCString &context)
Definition: msc.cpp:31
void portable_sysTimerStart()
Definition: portable.cpp:410
static QString currentDirPath()
Definition: qdir_unix.cpp:141
#define Config_getString(val)
Definition: config.cpp:660
TFile * inFile
Definition: makeDST.cxx:36
const char * portable_commandExtension()
Definition: portable.cpp:382
QCString utf8() const
Definition: qstring.cpp:14507
static bool setCurrent(const QString &path)
Definition: qdir_unix.cpp:134
int portable_system(const char *command, const char *args, bool commandHasConsole)
Definition: portable.cpp:33
void writeMscGraphFromFile ( const char *  inFile,
const char *  outDir,
const char *  outFile,
MscOutputFormat  format 
)

Definition at line 92 of file msc.cpp.

94 {
95  QCString absOutFile = outDir;
96  absOutFile+=portable_pathSeparator();
97  absOutFile+=outFile;
98 
99  // chdir to the output dir, so dot can find the font file.
100  QCString oldDir = QDir::currentDirPath().utf8();
101  // go to the html output directory (i.e. path)
102  QDir::setCurrent(outDir);
103  //printf("Going to dir %s\n",QDir::currentDirPath().data());
104  QCString mscExe = Config_getString("MSCGEN_PATH")+"mscgen"+portable_commandExtension();
105  QCString mscArgs;
106  QCString extension;
107  switch (format)
108  {
109  case MSC_BITMAP:
110  mscArgs+="-T png";
111  extension=".png";
112  break;
113  case MSC_EPS:
114  mscArgs+="-T eps";
115  extension=".eps";
116  break;
117  case MSC_SVG:
118  mscArgs+="-T svg";
119  extension=".svg";
120  break;
121  default:
122  goto error; // I am not very fond of goto statements, but when in Rome...
123  }
124  mscArgs+=" -i \"";
125  mscArgs+=inFile;
126 
127  mscArgs+="\" -o \"";
128  mscArgs+=outFile;
129  mscArgs+=extension+"\"";
130  int exitCode;
131 // printf("*** running: %s %s outDir:%s %s\n",mscExe.data(),mscArgs.data(),outDir,outFile);
133  if ((exitCode=portable_system(mscExe,mscArgs,FALSE))!=0)
134  {
136  goto error;
137  }
139  if ( (format==MSC_EPS) && (Config_getBool("USE_PDFLATEX")) )
140  {
141  QCString epstopdfArgs(maxCmdLine);
142  epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",
143  outFile,outFile);
145  if (portable_system("epstopdf",epstopdfArgs)!=0)
146  {
147  err("Problems running epstopdf. Check your TeX installation!\n");
148  }
150  }
151 
152 error:
153  QDir::setCurrent(oldDir);
154 }
void portable_sysTimerStop()
Definition: portable.cpp:415
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
const bool FALSE
Definition: qglobal.h:370
error
Definition: include.cc:26
TFile * outFile
Definition: makeDST.cxx:36
static const int maxCmdLine
Definition: msc.cpp:29
void portable_sysTimerStart()
Definition: portable.cpp:410
static QString currentDirPath()
Definition: qdir_unix.cpp:141
Definition: msc.h:24
#define Config_getString(val)
Definition: config.cpp:660
Definition: msc.h:24
#define Config_getBool(val)
Definition: config.cpp:664
void err(const char *fmt,...)
Definition: message.cpp:226
TFile * inFile
Definition: makeDST.cxx:36
const char * portable_commandExtension()
Definition: portable.cpp:382
char portable_pathSeparator()
Definition: portable.cpp:355
QCString utf8() const
Definition: qstring.cpp:14507
static bool setCurrent(const QString &path)
Definition: qdir_unix.cpp:134
Definition: msc.h:24
int portable_system(const char *command, const char *args, bool commandHasConsole)
Definition: portable.cpp:33
void writeMscImageMapFromFile ( FTextStream t,
const QCString inFile,
const QCString outDir,
const QCString relPath,
const QCString baseName,
const QCString context,
MscOutputFormat  format 
)

Definition at line 194 of file msc.cpp.

201 {
202  QCString mapName = baseName+".map";
203  t << "<img src=\"" << relPath << baseName << ".";
204  switch (format)
205  {
206  case MSC_BITMAP:
207  t << "png";
208  break;
209  case MSC_EPS:
210  t << "eps";
211  break;
212  case MSC_SVG:
213  t << "svg";
214  break;
215  default:
216  t << "unknown";
217  }
218  t << "\" alt=\""
219  << baseName << "\" border=\"0\" usemap=\"#" << mapName << "\"/>" << endl;
220  QCString imap = getMscImageMapFromFile(inFile,outDir,relPath,context);
221  t << "<map name=\"" << mapName << "\" id=\"" << mapName << "\">" << imap << "</map>" << endl;
222 }
QCString getMscImageMapFromFile(const QCString &inFile, const QCString &outDir, const QCString &relPath, const QCString &context)
Definition: msc.cpp:156
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
Definition: msc.h:24
Definition: msc.h:24
Definition: msc.h:24
QTextStream & endl(QTextStream &s)

Variable Documentation

const int maxCmdLine = 40960
static

Definition at line 29 of file msc.cpp.