dia.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  *
4  *
5  * Copyright (C) 1997-2015 by Dimitri van Heesch.
6  *
7  * Permission to use, copy, modify, and distribute this software and its
8  * documentation under the terms of the GNU General Public License is hereby
9  * granted. No representations are made about the suitability of this software
10  * for any purpose. It is provided "as is" without express or implied warranty.
11  * See the GNU General Public License for more details.
12  *
13  * Documents produced by Doxygen are derivative works derived from the
14  * input used in their production; they are not affected by this license.
15  *
16  */
17 
18 #include "dia.h"
19 #include "portable.h"
20 #include "config.h"
21 #include "message.h"
22 #include "util.h"
23 
24 #include <qdir.h>
25 
26 static const int maxCmdLine = 40960;
27 
28 void writeDiaGraphFromFile(const char *inFile,const char *outDir,
29  const char *outFile,DiaOutputFormat format)
30 {
31  QCString absOutFile = outDir;
32  absOutFile+=portable_pathSeparator();
33  absOutFile+=outFile;
34 
35  // chdir to the output dir, so dot can find the font file.
36  QCString oldDir = QDir::currentDirPath().utf8();
37  // go to the html output directory (i.e. path)
38  QDir::setCurrent(outDir);
39  //printf("Going to dir %s\n",QDir::currentDirPath().data());
40  QCString diaExe = Config_getString("DIA_PATH")+"dia"+portable_commandExtension();
41  QCString diaArgs;
42  QCString extension;
43  diaArgs+="-n ";
44  if (format==DIA_BITMAP)
45  {
46  diaArgs+="-t png-libart";
47  extension=".png";
48  }
49  else if (format==DIA_EPS)
50  {
51  diaArgs+="-t eps";
52  extension=".eps";
53  }
54 
55  diaArgs+=" -e \"";
56  diaArgs+=outFile;
57  diaArgs+=extension+"\"";
58 
59  diaArgs+=" \"";
60  diaArgs+=inFile;
61  diaArgs+="\"";
62 
63  int exitCode;
64  //printf("*** running: %s %s outDir:%s %s\n",diaExe.data(),diaArgs.data(),outDir,outFile);
66  if ((exitCode=portable_system(diaExe,diaArgs,FALSE))!=0)
67  {
69  goto error;
70  }
72  if ( (format==DIA_EPS) && (Config_getBool("USE_PDFLATEX")) )
73  {
74  QCString epstopdfArgs(maxCmdLine);
75  epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",
76  outFile,outFile);
78  if (portable_system("epstopdf",epstopdfArgs)!=0)
79  {
80  err("Problems running epstopdf. Check your TeX installation!\n");
81  }
83  }
84 
85 error:
86  QDir::setCurrent(oldDir);
87 }
88 
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
void portable_sysTimerStart()
Definition: portable.cpp:410
static QString currentDirPath()
Definition: qdir_unix.cpp:141
A bunch of utility functions.
static const int maxCmdLine
Definition: dia.cpp:26
#define Config_getString(val)
Definition: config.cpp:660
#define Config_getBool(val)
Definition: config.cpp:664
void err(const char *fmt,...)
Definition: message.cpp:226
QCString & sprintf(const char *format,...)
Definition: qcstring.cpp:27
TFile * inFile
Definition: makeDST.cxx:36
void writeDiaGraphFromFile(const char *inFile, const char *outDir, const char *outFile, DiaOutputFormat format)
Definition: dia.cpp:28
DiaOutputFormat
Definition: dia.h:24
const char * portable_commandExtension()
Definition: portable.cpp:382
char portable_pathSeparator()
Definition: portable.cpp:355
Definition: dia.h:24
QCString utf8() const
Definition: qstring.cpp:14507
Definition: dia.h:24
Portable versions of functions that are platform dependent.
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