relFromY = ctrl->valueToRel(absFromY);
relToY = ctrl->valueToRel(absToY);
- ImageDrawer imageDrawer(ctrl);
+ ImageDrawer imageDrawer(ctrl, m_graphToImageExportDialog.imageDpi());
drwRet = imageDrawer.render(m_graphToImageExportDialog.path(), m_graphToImageExportDialog.imageFormat().toLatin1(),
m_graphToImageExportDialog.imageWidth(), m_graphToImageExportDialog.imageHeight(),
relFromX, relFromY, relToX, relToY, gl);
ui->qle_destPath->setText(m_lastUsedPath);
ui->qle_width->setText(QString::number(params.width));
ui->qle_height->setText(QString::number(params.height));
+ ui->qle_dpi->setText(QString::number(params.dpi));
ui->qcbox_outputFormat->setCurrentIndex(params.formatIdx);
ui->qck_includeInteg->setChecked(params.includePeaks);
}
return ui->qck_includeInteg->isChecked();
}
+int ExportGraphToImageDialog::imageDpi() const
+{
+ bool ok;
+ int dpi = ui->qle_dpi->text().toInt(&ok);
+ if (!ok) return 0;
+ return dpi;
+}
+
int ExportGraphToImageDialog::imageHeight() const
{
bool ok;
ExportGraphToImageDialog::Parameters ExportGraphToImageDialog::parameters() const
{
- return Parameters(imageWidth(), imageHeight(), ui->qcbox_outputFormat->currentIndex(), ui->qck_includeInteg->isChecked());
+ return Parameters(imageWidth(), imageHeight(), ui->qcbox_outputFormat->currentIndex(), ui->qck_includeInteg->isChecked(), imageDpi());
}
QString ExportGraphToImageDialog::path() const
}
- m_lastUsedParameters = Parameters(imageWidth(), imageHeight(), ui->qcbox_outputFormat->currentIndex(), ui->qck_includeInteg->isChecked());
+ m_lastUsedParameters = Parameters(imageWidth(), imageHeight(), ui->qcbox_outputFormat->currentIndex(), ui->qck_includeInteg->isChecked(),
+ imageDpi());
m_lastUsedPath = ui->qle_destPath->text();
accept();
}
#ifndef EXPORTGRAPHTOIMAGEDIALOG_H
#define EXPORTGRAPHTOIMAGEDIALOG_H
+#include "helpers.h"
#include <unordered_map>
#include <QtWidgets/QDialog>
public:
struct Parameters {
- Parameters() : width(1000), height(1000), formatIdx(0), includePeaks(false) {}
- Parameters(const int width, const int height, const int formatIdx, const bool includePeaks) :
- width(width), height(height), formatIdx(formatIdx), includePeaks(includePeaks) {}
+ Parameters() : width(1000), height(1000), formatIdx(0), includePeaks(false), dpi(Helpers::dpiX()) {}
+ Parameters(const int width, const int height, const int formatIdx, const bool includePeaks, const int dpi) :
+ width(width), height(height), formatIdx(formatIdx), includePeaks(includePeaks), dpi(dpi) {}
int width;
int height;
int formatIdx;
bool includePeaks;
+ int dpi;
};
explicit ExportGraphToImageDialog(QList<QByteArray> formats, Parameters params = Parameters(), QWidget* parent = nullptr);
double fromX() const;
double fromY() const;
QString imageFormat() const;
+ int imageDpi() const;
int imageHeight() const;
bool includePeaks() const;
Parameters parameters() const;
</property>
</widget>
</item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="ql_dpi">
+ <property name="text">
+ <string>DPI:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="qle_dpi"/>
+ </item>
</layout>
</item>
<item>
*/
#include "helpers.h"
+#include <QApplication>
+#include <QDesktopWidget>
const double Helpers::EPSILON = 2e-14;
+int Helpers::dpiX()
+{
+ return qApp->desktop()->logicalDpiX();
+}
+
+int Helpers::dpiY()
+{
+ return qApp->desktop()->logicalDpiY();
+}
+
double Helpers::firstTick(const double from, const double step)
{
double ret;
public:
static const double EPSILON;
+ static int dpiX();
+ static int dpiY();
static double firstTick(const double from, const double step);
static QString getFileNameSuffix(const QString& name);
#include <QtCore/QFile>
#include <QtWidgets/QMessageBox>
-ImageDrawer::ImageDrawer(std::shared_ptr<SignalController> controller, QObject* parent) :
+ImageDrawer::ImageDrawer(std::shared_ptr<SignalController> controller, const int dpi, QObject* parent) :
QObject(parent),
- SignalDrawer(controller),
+ SignalDrawer(controller, Constraints(), dpi, dpi),
m_controller(controller)
{
m_imageWriter.setCompression(0);
E_WOULD_OVERWRITE
};
- explicit ImageDrawer(std::shared_ptr<SignalController> controller, QObject* parent = nullptr);
+ explicit ImageDrawer(std::shared_ptr<SignalController> controller, const int dpi, QObject* parent = nullptr);
ReturnCode render(const QString& filename, const QByteArray format, const int width, const int height,
const double fromX, const double fromY, const double toX, const double toY, const GraphLayers layers);