Doxygen
dia.cpp
浏览该文件的文档.
1 /******************************************************************************
2  *
3  * Copyright (C) 1997-2021 by Dimitri van Heesch.
4  *
5  * Permission to use, copy, modify, and distribute this software and its
6  * documentation under the terms of the GNU General Public License is hereby
7  * granted. No representations are made about the suitability of this software
8  * for any purpose. It is provided "as is" without express or implied warranty.
9  * See the GNU General Public License for more details.
10  *
11  * Documents produced by Doxygen are derivative works derived from the
12  * input used in their production; they are not affected by this license.
13  *
14  */
15 
16 #include "dia.h"
17 #include "portable.h"
18 #include "config.h"
19 #include "message.h"
20 #include "util.h"
21 #include "dir.h"
22 
23 
24 static const int maxCmdLine = 40960;
25 
26 void writeDiaGraphFromFile(const QCString &inFile,const QCString &outDir,
27  const QCString &outFile,DiaOutputFormat format,
28  const QCString &srcFile,int srcLine)
29 {
30  QCString absOutFile = outDir;
31  absOutFile+=Portable::pathSeparator();
32  absOutFile+=outFile;
33 
34  // chdir to the output dir, so dot can find the font file.
35  std::string oldDir = Dir::currentDirPath();
36  // go to the html output directory (i.e. path)
37  Dir::setCurrent(outDir.str());
38  //printf("Going to dir %s\n",Dir::currentDirPath().c_str());
39  QCString diaExe = Config_getString(DIA_PATH)+"dia"+Portable::commandExtension();
40  QCString diaArgs;
41  QCString extension;
42  diaArgs+="-n ";
43  if (format==DIA_BITMAP)
44  {
45  diaArgs+="-t png-libart";
46  extension=".png";
47  }
48  else if (format==DIA_EPS)
49  {
50  diaArgs+="-t eps";
51  extension=".eps";
52  }
53 
54  diaArgs+=" -e \"";
55  diaArgs+=outFile;
56  diaArgs+=extension+"\"";
57 
58  diaArgs+=" \"";
59  diaArgs+=inFile;
60  diaArgs+="\"";
61 
62  int exitCode;
63  //printf("*** running: %s %s outDir:%s %s\n",qPrint(diaExe),qPrint(diaArgs),outDir,outFile);
65  if ((exitCode=Portable::system(diaExe,diaArgs,FALSE))!=0)
66  {
67  err_full(srcFile,srcLine,"Problems running %s. Check your installation or look typos in you dia file %s\n",
68  qPrint(diaExe),qPrint(inFile));
70  goto error;
71  }
73  if ( (format==DIA_EPS) && (Config_getBool(USE_PDFLATEX)) )
74  {
75  QCString epstopdfArgs(maxCmdLine);
76  epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",
77  qPrint(outFile),qPrint(outFile));
79  if (Portable::system("epstopdf",epstopdfArgs)!=0)
80  {
81  err("Problems running epstopdf. Check your TeX installation!\n");
82  }
84  }
85 
86 error:
87  Dir::setCurrent(oldDir);
88 }
89 
writeDiaGraphFromFile
void writeDiaGraphFromFile(const QCString &inFile, const QCString &outDir, const QCString &outFile, DiaOutputFormat format, const QCString &srcFile, int srcLine)
Definition: dia.cpp:26
Dir::currentDirPath
static std::string currentDirPath()
Definition: dir.cpp:282
maxCmdLine
static const int maxCmdLine
Definition: dia.cpp:24
Portable::pathSeparator
QCString pathSeparator()
Definition: portable.cpp:347
DIA_EPS
@ DIA_EPS
Definition: dia.h:23
DIA_BITMAP
@ DIA_BITMAP
Definition: dia.h:23
QCString::str
std::string str() const
Definition: qcstring.h:442
err
void err(const char *fmt,...)
Definition: message.cpp:203
message.h
Portable::sysTimerStart
void sysTimerStart()
Definition: portable.cpp:470
Portable::system
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
Definition: portable.cpp:42
Dir::setCurrent
static bool setCurrent(const std::string &path)
Definition: dir.cpp:290
dia.h
Config_getBool
#define Config_getBool(name)
Definition: config.h:33
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
Config_getString
#define Config_getString(name)
Definition: config.h:32
config.h
err_full
void err_full(const QCString &file, int line, const char *fmt,...)
Definition: message.cpp:212
Portable::sysTimerStop
void sysTimerStop()
Definition: portable.cpp:475
Portable::commandExtension
const char * commandExtension()
Definition: portable.cpp:434
portable.h
Portable versions of functions that are platform dependent.
DiaOutputFormat
DiaOutputFormat
Definition: dia.h:23
dir.h
util.h
A bunch of utility functions.
QCString::sprintf
QCString & sprintf(const char *format,...)
Definition: qcstring.cpp:24
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108