1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-09-19 21:25:36 +01:00

saving PDF is optional when saving plot

This commit is contained in:
Antonin Portelli 2020-01-09 13:42:59 +00:00
parent c81316ef32
commit 97267c196f
2 changed files with 15 additions and 12 deletions

View File

@ -683,7 +683,7 @@ void Plot::display(void)
}
}
void Plot::save(string dirName)
void Plot::save(string dirName, bool savePdf)
{
vector<string> commandBack;
string path, terminalBack, outputBack, gpCommand, scriptName;
@ -691,11 +691,6 @@ void Plot::save(string dirName)
ofstream script;
mode755 = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
// backup I/O parameters
terminalBack = options_.terminal;
outputBack = options_.output;
commandBack = plotCommand_;
// generate directory
if (mkdir(dirName))
@ -703,12 +698,20 @@ void Plot::save(string dirName)
LATAN_ERROR(Io, "impossible to create directory '" + dirName + "'");
}
// backup I/O parameters
terminalBack = options_.terminal;
outputBack = options_.output;
commandBack = plotCommand_;
// save PDF
options_.terminal = "pdf";
options_.output = dirName + "/plot.pdf";
display();
options_.terminal = terminalBack;
options_.output = outputBack;
if (savePdf)
{
options_.terminal = "pdf";
options_.output = dirName + "/plot.pdf";
display();
options_.terminal = terminalBack;
options_.output = outputBack;
}
// save script and datafiles
for (unsigned int i = 0; i < tmpFileName_.size(); ++i)

View File

@ -377,7 +377,7 @@ public:
Plot & operator<<(PlotModifier &&modifier);
// plot parsing and output
void display(void);
void save(std::string dirName);
void save(std::string dirName, bool savePdf = true);
friend std::ostream & operator<<(std::ostream &out, const Plot &plot);
// plot reset
void reset(void);