Doxygen
Loading...
Searching...
No Matches
dia.cpp
Go to the documentation of this file.
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
24static const int maxCmdLine = 40960;
25
26void 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==DiaOutputFormat::BITMAP)
44 {
45 diaArgs+="-t png-libart";
46 extension=".png";
47 }
48 else if (format==DiaOutputFormat::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 //printf("*** running: %s %s outDir:%s %s\n",qPrint(diaExe),qPrint(diaArgs),outDir,outFile);
63 if (Portable::system(diaExe,diaArgs,FALSE)!=0)
64 {
65 err_full(srcFile,srcLine,"Problems running %s. Check your installation or look typos in you dia file %s",
66 qPrint(diaExe),qPrint(inFile));
67 goto error;
68 }
69 if ( (format==DiaOutputFormat::EPS) && (Config_getBool(USE_PDFLATEX)) )
70 {
72 epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",
73 qPrint(outFile),qPrint(outFile));
74 if (Portable::system("epstopdf",epstopdfArgs)!=0)
75 {
76 err("Problems running epstopdf. Check your TeX installation!\n");
77 }
78 else
79 {
80 Dir().remove(outFile.str()+".eps");
81 }
82 }
83
84error:
85 Dir::setCurrent(oldDir);
86}
87
Class representing a directory in the file system.
Definition dir.h:75
static std::string currentDirPath()
Definition dir.cpp:340
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:314
static bool setCurrent(const std::string &path)
Definition dir.cpp:348
This is an alternative implementation of QCString.
Definition qcstring.h:101
const std::string & str() const
Definition qcstring.h:537
QCString & sprintf(const char *format,...)
Definition qcstring.cpp:29
@ ExplicitSize
Definition qcstring.h:133
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
void writeDiaGraphFromFile(const QCString &inFile, const QCString &outDir, const QCString &outFile, DiaOutputFormat format, const QCString &srcFile, int srcLine)
Definition dia.cpp:26
static const int maxCmdLine
Definition dia.cpp:24
DiaOutputFormat
Definition dia.h:23
#define err(fmt,...)
Definition message.h:84
#define err_full(file, line, fmt,...)
Definition message.h:89
QCString pathSeparator()
Definition portable.cpp:391
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
Definition portable.cpp:106
const char * commandExtension()
Definition portable.cpp:478
Portable versions of functions that are platform dependent.
const char * qPrint(const char *s)
Definition qcstring.h:672
#define FALSE
Definition qcstring.h:34
A bunch of utility functions.