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// own header
17#include "dia.h"
18
19// other headers
20#include "config.h"
21#include "dir.h"
22#include "doxygen.h"
23#include "indexlist.h"
24#include "message.h"
25#include "portable.h"
26
27static const int maxCmdLine = 40960;
28
29void writeDiaGraphFromFile(const DString &inFile,const DString &outDir,
30 const DString &outFile,DiaOutputFormat format,
31 const DString &srcFile,int srcLine,bool toIndex)
32{
33 DString absOutFile = outDir;
34 absOutFile+=Portable::pathSeparator();
35 absOutFile+=outFile;
36
37 // chdir to the output dir, so dot can find the font file.
38 std::string oldDir = Dir::currentDirPath();
39 // go to the html output directory (i.e. path)
40 Dir::setCurrent(outDir.str());
41 //printf("Going to dir %s\n",Dir::currentDirPath().c_str());
42 DString diaExe = Config_getString(DIA_PATH)+"dia"+Portable::commandExtension();
43 DString diaArgs;
44 DString extension;
45 diaArgs+="-n ";
46 if (format==DiaOutputFormat::BITMAP)
47 {
48 diaArgs+="-t png-libart";
49 extension=".png";
50 }
51 else if (format==DiaOutputFormat::EPS)
52 {
53 diaArgs+="-t eps";
54 extension=".eps";
55 }
56
57 diaArgs+=" -e \"";
58 diaArgs+=outFile;
59 diaArgs+=extension+"\"";
60
61 diaArgs+=" \"";
62 diaArgs+=inFile;
63 diaArgs+="\"";
64
65 //printf("*** running: %s %s outDir:%s %s\n",qPrint(diaExe),qPrint(diaArgs),outDir,outFile);
66 if (Portable::system(diaExe,diaArgs,false)!=0)
67 {
68 err_full(srcFile,srcLine,"Problems running {}. Check your installation or look typos in you dia file {}",
69 diaExe,inFile);
70 goto error;
71 }
72 if ( (format==DiaOutputFormat::EPS) && (Config_getBool(USE_PDFLATEX)) )
73 {
75 epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",
76 qPrint(outFile),qPrint(outFile));
77 if (Portable::system("epstopdf",epstopdfArgs)!=0)
78 {
79 err("Problems running epstopdf. Check your TeX installation!\n");
80 }
81 else
82 {
83 Dir().remove(outFile.str()+".eps");
84 }
85 }
86 if (toIndex) Doxygen::indexList->addImageFile(outFile+extension);
87
88error:
89 Dir::setCurrent(oldDir);
90}
91
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:84
DString & sprintf(const char *format,...)
Definition dstring.cpp:34
@ ExplicitSize
Definition dstring.h:131
const std::string & str() const
Definition dstring.h:645
Class representing a directory in the file system.
Definition dir.h:73
static std::string currentDirPath()
Definition dir.cpp:348
bool remove(const std::string &path, bool acceptsAbsPath=true) const
Definition dir.cpp:320
static bool setCurrent(const std::string &path)
Definition dir.cpp:356
static IndexList * indexList
Definition doxygen.h:125
void addImageFile(const DString &name)
Definition indexlist.h:124
#define Config_getBool(name)
Definition config.h:33
#define Config_getString(name)
Definition config.h:32
void writeDiaGraphFromFile(const DString &inFile, const DString &outDir, const DString &outFile, DiaOutputFormat format, const DString &srcFile, int srcLine, bool toIndex)
Definition dia.cpp:29
static const int maxCmdLine
Definition dia.cpp:27
DiaOutputFormat
Definition dia.h:21
const char * qPrint(const char *s)
Definition dstring.h:783
#define err(fmt,...)
Definition message.h:127
#define err_full(file, line, fmt,...)
Definition message.h:132
int system(const DString &command, const DString &args, bool commandHasConsole=true)
Definition portable.cpp:121
DString pathSeparator()
Definition portable.cpp:390
const char * commandExtension()
Definition portable.cpp:477
Portable versions of functions that are platform dependent.