1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 00:45:36 +00: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; vector<string> commandBack;
string path, terminalBack, outputBack, gpCommand, scriptName; string path, terminalBack, outputBack, gpCommand, scriptName;
@ -692,23 +692,26 @@ void Plot::save(string dirName)
mode755 = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH; 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 // generate directory
if (mkdir(dirName)) if (mkdir(dirName))
{ {
LATAN_ERROR(Io, "impossible to create directory '" + dirName + "'"); LATAN_ERROR(Io, "impossible to create directory '" + dirName + "'");
} }
// backup I/O parameters
terminalBack = options_.terminal;
outputBack = options_.output;
commandBack = plotCommand_;
// save PDF // save PDF
if (savePdf)
{
options_.terminal = "pdf"; options_.terminal = "pdf";
options_.output = dirName + "/plot.pdf"; options_.output = dirName + "/plot.pdf";
display(); display();
options_.terminal = terminalBack; options_.terminal = terminalBack;
options_.output = outputBack; options_.output = outputBack;
}
// save script and datafiles // save script and datafiles
for (unsigned int i = 0; i < tmpFileName_.size(); ++i) for (unsigned int i = 0; i < tmpFileName_.size(); ++i)

View File

@ -377,7 +377,7 @@ public:
Plot & operator<<(PlotModifier &&modifier); Plot & operator<<(PlotModifier &&modifier);
// plot parsing and output // plot parsing and output
void display(void); 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); friend std::ostream & operator<<(std::ostream &out, const Plot &plot);
// plot reset // plot reset
void reset(void); void reset(void);