Skip to content
Snippets Groups Projects
Commit 865ea534 authored by André Offringa's avatar André Offringa
Browse files

Fix aoqplot -save producing incorrect pdfs

parent 2ae4762a
No related branches found
No related tags found
No related merge requests found
...@@ -144,7 +144,7 @@ void AOQPlotPageController::SavePdf( ...@@ -144,7 +144,7 @@ void AOQPlotPageController::SavePdf(
updatePlotForSettings(kinds, pols, phases); updatePlotForSettings(kinds, pols, phases);
_plot.SavePdf(filename); _plot.SavePdf(filename, 640, 480);
} }
void AOQPlotPageController::SetStatistics( void AOQPlotPageController::SetStatistics(
......
#include "plotbase.h" #include "plotbase.h"
PlotBase::PlotBase() PlotBase::PlotBase() {
: _xZoomStart(0.0), _xZoomEnd(1.0), _yZoomStart(0.0), _yZoomEnd(1.0) {
_horizontalScale.SignalLinkedRedraw().connect(_signalLinkedRedraw); _horizontalScale.SignalLinkedRedraw().connect(_signalLinkedRedraw);
} }
......
...@@ -71,10 +71,10 @@ class PlotBase { ...@@ -71,10 +71,10 @@ class PlotBase {
virtual void SavePng(const std::string& filename, size_t width, virtual void SavePng(const std::string& filename, size_t width,
size_t height) = 0; size_t height) = 0;
protected:
size_t Width() const { return _width; } size_t Width() const { return _width; }
size_t Height() const { return _height; } size_t Height() const { return _height; }
protected:
struct Rectangle { struct Rectangle {
double x, y; double x, y;
double width, height; double width, height;
...@@ -96,13 +96,13 @@ class PlotBase { ...@@ -96,13 +96,13 @@ class PlotBase {
sigc::signal<void> _onZoomChanged; sigc::signal<void> _onZoomChanged;
/** /**
* Values between 0.0 and 1.0 indication the zoom. * Values between 0.0 and 1.0 indicating the zoom.
* @{ * @{
*/ */
double _xZoomStart, _xZoomEnd; double _xZoomStart = 0.0, _xZoomEnd = 1.0;
double _yZoomStart, _yZoomEnd; double _yZoomStart = 0.0, _yZoomEnd = 1.0;
size_t _width, _height;
/** @} */ /** @} */
size_t _width = 0, _height = 0;
}; };
#endif // PLOT_PLOTBASE_H #endif // PLOT_PLOTBASE_H
...@@ -308,10 +308,10 @@ void PlotPropertiesWindow::onExportClicked() { ...@@ -308,10 +308,10 @@ void PlotPropertiesWindow::onExportClicked() {
if (result == Gtk::RESPONSE_OK) { if (result == Gtk::RESPONSE_OK) {
const Glib::RefPtr<Gtk::FileFilter> filter = dialog.get_filter(); const Glib::RefPtr<Gtk::FileFilter> filter = dialog.get_filter();
if (filter->get_name() == pdfName) if (filter->get_name() == pdfName)
_plot.SavePdf(dialog.get_filename()); _plot.SavePdf(dialog.get_filename(), _plot.Width(), _plot.Height());
else if (filter->get_name() == svgName) else if (filter->get_name() == svgName)
_plot.SaveSvg(dialog.get_filename()); _plot.SaveSvg(dialog.get_filename(), _plot.Width(), _plot.Height());
else else
_plot.SavePng(dialog.get_filename()); _plot.SavePng(dialog.get_filename(), _plot.Width(), _plot.Height());
} }
} }
...@@ -13,7 +13,7 @@ void XYPlot::Clear() { ...@@ -13,7 +13,7 @@ void XYPlot::Clear() {
XYPointSet& XYPlot::StartLine(const std::string& label, XYPointSet& XYPlot::StartLine(const std::string& label,
const std::string& xDesc, const std::string& xDesc,
const std::string& yDesc, const std::string& yDesc,
enum XYPointSet::DrawingStyle drawingStyle) { XYPointSet::DrawingStyle drawingStyle) {
_pointSets.emplace_back(std::make_unique<XYPointSet>(_pointSets.size())); _pointSets.emplace_back(std::make_unique<XYPointSet>(_pointSets.size()));
XYPointSet& newSet = *_pointSets.back(); XYPointSet& newSet = *_pointSets.back();
newSet.SetLabel(label); newSet.SetLabel(label);
...@@ -27,7 +27,7 @@ void XYPlot::SavePdf(const std::string& filename, size_t width, size_t height) { ...@@ -27,7 +27,7 @@ void XYPlot::SavePdf(const std::string& filename, size_t width, size_t height) {
const Cairo::RefPtr<Cairo::PdfSurface> surface = const Cairo::RefPtr<Cairo::PdfSurface> surface =
Cairo::PdfSurface::create(filename, width, height); Cairo::PdfSurface::create(filename, width, height);
const Cairo::RefPtr<Cairo::Context> cairo = Cairo::Context::create(surface); const Cairo::RefPtr<Cairo::Context> cairo = Cairo::Context::create(surface);
Draw(cairo); PlotBase::Draw(cairo, width, height);
cairo->show_page(); cairo->show_page();
surface->finish(); surface->finish();
} }
...@@ -36,7 +36,7 @@ void XYPlot::SaveSvg(const std::string& filename, size_t width, size_t height) { ...@@ -36,7 +36,7 @@ void XYPlot::SaveSvg(const std::string& filename, size_t width, size_t height) {
const Cairo::RefPtr<Cairo::SvgSurface> surface = const Cairo::RefPtr<Cairo::SvgSurface> surface =
Cairo::SvgSurface::create(filename, width, height); Cairo::SvgSurface::create(filename, width, height);
const Cairo::RefPtr<Cairo::Context> cairo = Cairo::Context::create(surface); const Cairo::RefPtr<Cairo::Context> cairo = Cairo::Context::create(surface);
Draw(cairo); PlotBase::Draw(cairo, width, height);
cairo->show_page(); cairo->show_page();
surface->finish(); surface->finish();
} }
...@@ -45,7 +45,7 @@ void XYPlot::SavePng(const std::string& filename, size_t width, size_t height) { ...@@ -45,7 +45,7 @@ void XYPlot::SavePng(const std::string& filename, size_t width, size_t height) {
const Cairo::RefPtr<Cairo::ImageSurface> surface = const Cairo::RefPtr<Cairo::ImageSurface> surface =
Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, width, height); Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, width, height);
const Cairo::RefPtr<Cairo::Context> cairo = Cairo::Context::create(surface); const Cairo::RefPtr<Cairo::Context> cairo = Cairo::Context::create(surface);
Draw(cairo); PlotBase::Draw(cairo, width, height);
surface->write_to_png(filename); surface->write_to_png(filename);
} }
......
...@@ -114,15 +114,6 @@ class XYPlot final : public PlotBase { ...@@ -114,15 +114,6 @@ class XYPlot final : public PlotBase {
size_t height) override; size_t height) override;
void SavePng(const std::string& filename, size_t width, void SavePng(const std::string& filename, size_t width,
size_t height) override; size_t height) override;
void SavePdf(const std::string& filename) {
SavePdf(filename, Width(), Height());
}
void SaveSvg(const std::string& filename) {
SaveSvg(filename, Width(), Height());
}
void SavePng(const std::string& filename) {
SavePng(filename, Width(), Height());
}
const std::string& GetTitle() const { return _title.Text(); } const std::string& GetTitle() const { return _title.Text(); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment