My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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