From: Michal MalĂ˝ Date: Sat, 15 Mar 2014 18:06:17 +0000 (+0100) Subject: Store settings from "Export graph as image" dialog X-Git-Tag: 0.2e~2 X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=83afb0ce4bc59ee98fd650d7e132dbad8167afb1;p=anyanka.git Store settings from "Export graph as image" dialog --- diff --git a/datamanager.cpp b/datamanager.cpp index 81ed7af..f420616 100644 --- a/datamanager.cpp +++ b/datamanager.cpp @@ -23,8 +23,6 @@ #include "datamanager.h" #include "imagedrawer.h" #include "logger.h" -#include "gui/exportgraphtoimagedialog.h" -#include "gui/exportrawdatadialog.h" #include #include @@ -46,6 +44,8 @@ DataManager::DataManager(QObject* parent) : m_sequences.push_back(std::make_pair>("Single runs", std::shared_ptr(new Sequence()))); m_seqSelModel.setSequences(&m_sequences); m_sigNameCodec = QTextCodec::codecForName("ISO-8859-1"); + + m_oldExportToImageParams = ExportGraphToImageDialog::Parameters(); } void DataManager::saveUserDataOnExit() @@ -441,7 +441,7 @@ void DataManager::showOneSignal(std::shared_ptr ctrl) void DataManager::onExportGraphToImage() { - ExportGraphToImageDialog dlg(ImageDrawer::supportedImageFormats()); + ExportGraphToImageDialog dlg(ImageDrawer::supportedImageFormats(), m_oldExportToImageParams); std::shared_ptr sr; int ret = 1; @@ -510,6 +510,8 @@ void DataManager::onExportGraphToImage() } else break; } while (ret == 1); + + m_oldExportToImageParams = dlg.parameters(); } void DataManager::onExportPeaks() diff --git a/datamanager.h b/datamanager.h index f095e85..4867166 100644 --- a/datamanager.h +++ b/datamanager.h @@ -26,6 +26,8 @@ #include "datafileexporter.h" #include "datafilesloader.h" +#include "gui/exportgraphtoimagedialog.h" +#include "gui/exportrawdatadialog.h" #include "gui/signalview.h" #include "sequence.h" #include "sequenceselectormodel.h" @@ -72,6 +74,8 @@ private: std::vector m_sequences; DataFilesLoader m_dfl; + ExportGraphToImageDialog::Parameters m_oldExportToImageParams; + static const QString ME_SENDER_STR; static const char UNIT_KILOVOLTS_TEXT[]; static const char UNIT_MICROAMPERES_TEXT[]; diff --git a/gui/exportgraphtoimagedialog.cpp b/gui/exportgraphtoimagedialog.cpp index c16bb3f..22d186b 100644 --- a/gui/exportgraphtoimagedialog.cpp +++ b/gui/exportgraphtoimagedialog.cpp @@ -28,7 +28,7 @@ /* Public functions */ -ExportGraphToImageDialog::ExportGraphToImageDialog(QList formats, QWidget *parent) : +ExportGraphToImageDialog::ExportGraphToImageDialog(QList formats, Parameters params, QWidget *parent) : QDialog(parent), m_curKey(""), ui(new Ui::ExportGraphToImageDialog) @@ -43,6 +43,11 @@ ExportGraphToImageDialog::ExportGraphToImageDialog(QList formats, QW connect(ui->qpb_ok, SIGNAL(clicked()), this, SLOT(checkAndAccept())); connect(ui->qcbox_signal, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeBounds(QString))); connect(ui->qle_destPath, SIGNAL(textChanged(QString)), this, SLOT(onFileNameChanged(QString))); + + ui->qle_width->setText(QString::number(params.width)); + ui->qle_height->setText(QString::number(params.height)); + ui->qcbox_outputFormat->setCurrentIndex(params.formatIdx); + ui->qck_includeInteg->setChecked(params.includePeaks); } void ExportGraphToImageDialog::addSignal(const double fromX, const double fromY, const double toX, const double toY, const std::string& key) @@ -89,6 +94,11 @@ int ExportGraphToImageDialog::imageHeight() const return h; } +ExportGraphToImageDialog::Parameters ExportGraphToImageDialog::parameters() const +{ + return Parameters(imageWidth(), imageHeight(), ui->qcbox_outputFormat->currentIndex(), ui->qck_includeInteg->isChecked()); +} + QString ExportGraphToImageDialog::path() const { return ui->qle_destPath->text(); diff --git a/gui/exportgraphtoimagedialog.h b/gui/exportgraphtoimagedialog.h index 64b2212..3530451 100644 --- a/gui/exportgraphtoimagedialog.h +++ b/gui/exportgraphtoimagedialog.h @@ -38,7 +38,18 @@ class ExportGraphToImageDialog : public QDialog typedef std::tuple Bounds; public: - explicit ExportGraphToImageDialog(QList formats, QWidget* parent = nullptr); + 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) {} + + int width; + int height; + int formatIdx; + bool includePeaks; + }; + + explicit ExportGraphToImageDialog(QList formats, Parameters params = Parameters(), QWidget* parent = nullptr); ~ExportGraphToImageDialog(); void addSignal(const double fromX, const double fromY, const double toX, const double toY, const std::string& key); double fromX() const; @@ -46,6 +57,7 @@ public: QString imageFormat() const; int imageHeight() const; bool includePeaks() const; + Parameters parameters() const; QString path() const; QString selectedSignal() const; double toX() const;