Commit c4bfd4e3 authored by ics's avatar ics
Browse files

Add dpi option for save offscreen picture

parent 6c117e42
/autom4te.cache/
/bin/
/build/
/Makefile.in
/aclocal.m4
/compile
/config.guess
/config.sub
/configure
/configure.ac
/depcomp
/install-sh
/ltmain.sh
/missing
......@@ -136,13 +136,17 @@ void OffScreenPlotManager::savePlot(string pbfilename, string path) {
ostringstream plotkey;
plotkey << pbfilename;
uint32 dpi = 100;
if (data.type() == buffer::Data::Spy) {
dpi = 30;
}
if ((data.xdata_size() > 0) && (data.ydata_size() > 0) && (data.zdata_size() > 0)) {
// 2D
for (int32 i = 0; i < data.xdata_size(); ++i) {
try {
plot::offscreen::OffScreenPlot2D plot(m_Figure, plotkey.str(), m_Mpl, i, &data);
plot.display();
plot.save(pbfile.parent_path().parent_path().string());
plot.save(pbfile.parent_path().parent_path().string(), dpi);
m_Figure->clear();
} catch (Error& e) {
Error("OffScreenPlotManager", "savePlot", "Failed create 2d plot", plotkey.str());
......@@ -154,7 +158,7 @@ void OffScreenPlotManager::savePlot(string pbfilename, string path) {
try {
plot::offscreen::OffScreenPlot1D plot(m_Figure, plotkey.str(), m_Mpl, i, &data);
plot.display();
plot.save(pbfile.parent_path().parent_path().string());
plot.save(pbfile.parent_path().parent_path().string(), dpi);
m_Figure->clear();
} catch (Error& e) {
Error("OffScreenPlotManager", "savePlot", "Failed create 1d plot", plotkey.str());
......@@ -164,7 +168,7 @@ void OffScreenPlotManager::savePlot(string pbfilename, string path) {
try {
plot::offscreen::OffScreenEmptyPlot plot(m_Figure, plotkey.str(), m_Mpl, 0, &data);
plot.display();
plot.save(pbfile.parent_path().parent_path().string());
plot.save(pbfile.parent_path().parent_path().string(), dpi);
m_Figure->clear();
} catch (Error& e) {
Error("OffScreenPlotManager", "savePlot", "Failed create empty plot", plotkey.str());
......
......@@ -75,10 +75,10 @@ void OffScreenEmptyPlot::display() throw (Error) {
/*
* save
*/
void OffScreenEmptyPlot::save(const std::string& imagepath) throw (Error) {
void OffScreenEmptyPlot::save(const std::string& imagepath, uint32 dpi) throw (Error) {
ostringstream filename;
filename << imagepath << "/" << m_PlotKey;
m_Mpl->savefig(m_Figure->getFigure(), filename.str());
m_Mpl->savefig(m_Figure->getFigure(), filename.str(), dpi);
}
}
......
......@@ -57,7 +57,7 @@ public:
* \brief Display plot
* \throws Error
*/
virtual void save(const std::string& imagepath) throw (Error);
virtual void save(const std::string& imagepath, uint32 dpi) throw (Error);
private:
......
......@@ -48,7 +48,6 @@ string OffScreenPlot::getPlotTitle() {
title << " - " << m_Data->extratitle();
}
}
title << " - Empty Data";
return title.str();
}
......
......@@ -56,7 +56,7 @@ public:
* \brief Display plot
* \throws Error
*/
virtual void save(const std::string& imagepath) throw (Error) = 0;
virtual void save(const std::string& imagepath, uint32 dpi) throw (Error) = 0;
protected:
......
......@@ -71,10 +71,10 @@ void OffScreenPlot1D::display() throw (Error) {
/*
* save
*/
void OffScreenPlot1D::save(const std::string& imagepath) throw (Error) {
void OffScreenPlot1D::save(const std::string& imagepath, uint32 dpi) throw (Error) {
ostringstream filename;
filename << imagepath << "/" << m_PlotKey;
m_Mpl->savefig(m_Figure->getFigure(), filename.str());
m_Mpl->savefig(m_Figure->getFigure(), filename.str(), dpi);
}
/*
......
......@@ -53,7 +53,7 @@ public:
*/
virtual void display() throw (Error);
virtual void save(const std::string& imagepath) throw (Error);
virtual void save(const std::string& imagepath, uint32 dpi) throw (Error);
private:
......
......@@ -84,10 +84,10 @@ void OffScreenPlot2D::display() throw (Error) {
/*
* save
*/
void OffScreenPlot2D::save(const std::string& imagepath) throw (Error) {
void OffScreenPlot2D::save(const std::string& imagepath, uint32 dpi) throw (Error) {
ostringstream filename;
filename << imagepath << "/" << m_PlotKey;
m_Mpl->savefig(m_Figure->getFigure(), filename.str());
m_Mpl->savefig(m_Figure->getFigure(), filename.str(), dpi);
}
/*
......
......@@ -57,7 +57,7 @@ public:
* \brief Display plot
* \throws Error
*/
virtual void save(const std::string& imagepath) throw (Error);
virtual void save(const std::string& imagepath, uint32 dpi) throw (Error);
/*!
* \brief Update projection plots
......
......@@ -209,11 +209,12 @@ void Mpl::grid(const bp::object& axis, bool show) throw (Error) {
/*
* savefig
*/
void Mpl::savefig(const bp::object& figure, const std::string& filename) throw (Error) {
void Mpl::savefig(const bp::object& figure, const std::string& filename, uint32 dpi) throw (Error) {
mpl::MplLock lock;
auto args = bp::make_tuple(filename);
bp::dict kwargs;
kwargs["format"] = "png";
kwargs["dpi"] = dpi;
try {
figure.attr("savefig")(*args, **kwargs);
} catch (...) {
......
......@@ -162,7 +162,7 @@ public:
* \param[in] filename the file name for image
* \throws Error
*/
void savefig(const bp::object& figure, const std::string& filename) throw (Error);
void savefig(const bp::object& figure, const std::string& filename, uint32 dpi) throw (Error);
/*!
* \brief Get the current axis
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment