]> Devoid-pointer.net GitWeb - anyanka.git/commitdiff
Store settings from "Export graph as image" dialog
authorMichal Malý <madcatxster@prifuk.cz>
Sat, 15 Mar 2014 18:06:17 +0000 (19:06 +0100)
committerMichal Malý <madcatxster@prifuk.cz>
Sat, 15 Mar 2014 18:06:17 +0000 (19:06 +0100)
datamanager.cpp
datamanager.h
gui/exportgraphtoimagedialog.cpp
gui/exportgraphtoimagedialog.h

index 81ed7afee269bc38ed7e9b65988f15544970c837..f420616480dd2a3ace97d315af1fd4ec23eca910 100644 (file)
@@ -23,8 +23,6 @@
 #include "datamanager.h"
 #include "imagedrawer.h"
 #include "logger.h"
-#include "gui/exportgraphtoimagedialog.h"
-#include "gui/exportrawdatadialog.h"
 #include <QtWidgets/QMessageBox>
 
 #include <QDebug>
@@ -46,6 +44,8 @@ DataManager::DataManager(QObject* parent) :
   m_sequences.push_back(std::make_pair<const QString, std::shared_ptr<Sequence>>("Single runs", std::shared_ptr<Sequence>(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<SignalController> ctrl)
 
 void DataManager::onExportGraphToImage()
 {
-  ExportGraphToImageDialog dlg(ImageDrawer::supportedImageFormats());
+  ExportGraphToImageDialog dlg(ImageDrawer::supportedImageFormats(), m_oldExportToImageParams);
   std::shared_ptr<SingleRunData> sr;
   int ret = 1;
 
@@ -510,6 +510,8 @@ void DataManager::onExportGraphToImage()
     } else
       break;
   } while (ret == 1);
+
+  m_oldExportToImageParams = dlg.parameters();
 }
 
 void DataManager::onExportPeaks()
index f095e859fc137d3ef52516a2d445cfa54d406d41..48671662b0e78b740ee4a9c61f78812f2db51af8 100644 (file)
@@ -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<NameSequencePair> 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[];
index c16bb3f1c902e0bb5ab22da5cd5cdf8971f2b33e..22d186bb08e9928bd1b5c3ba45b2e7fd553b5a0f 100644 (file)
@@ -28,7 +28,7 @@
 
 /* Public functions */
 
-ExportGraphToImageDialog::ExportGraphToImageDialog(QList<QByteArray> formats, QWidget *parent) :
+ExportGraphToImageDialog::ExportGraphToImageDialog(QList<QByteArray> formats, Parameters params, QWidget *parent) :
   QDialog(parent),
   m_curKey(""),
   ui(new Ui::ExportGraphToImageDialog)
@@ -43,6 +43,11 @@ ExportGraphToImageDialog::ExportGraphToImageDialog(QList<QByteArray> 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();
index 64b2212fcb286a247ea0a26c3c24e99d09c05f9f..3530451b94738ec7fcc81c27509ac9374f5c9fc9 100644 (file)
@@ -38,7 +38,18 @@ class ExportGraphToImageDialog : public QDialog
   typedef std::tuple<double, double, double, double> Bounds;
 
 public:
-  explicit ExportGraphToImageDialog(QList<QByteArray> 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<QByteArray> 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;