]> Devoid-pointer.net GitWeb - anyanka.git/commitdiff
- Generate human readable signal name from the signal
authorMichal Malý <madcatxster@devoid-pointer.net>
Fri, 17 Apr 2015 18:27:17 +0000 (20:27 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Fri, 17 Apr 2015 18:27:17 +0000 (20:27 +0200)
- Add an option to return descriptive name as std::string

datamanager.cpp
helpers.cpp
helpers.h
signal.cpp
signal.h

index 2f9f69df07adc80fed65597a6a6de67c6c966f27..8757f13cc3fdee7ebf3b009d78a4f5f48ffe5dd8 100644 (file)
@@ -196,8 +196,8 @@ void DataManager::processDataExport(GeneratorFunc genfunc)
   m_exportRawDataDialog.removeAllSignals();
   c1 = connect(&m_exportRawDataDialog, SIGNAL(fileNameChanged(QString)), &exporter, SLOT(guessFormatFromSuffix(QString)));
   c2 = connect(&exporter, SIGNAL(formatChanged(int)), &m_exportRawDataDialog, SLOT(onFormatChanged(int)));
-  for (const std::string& s : sr->allKeys())
-    m_exportRawDataDialog.addAvailableSignal(Helpers::signalTagToHumanReadable(s), s);
+  for (const auto& sm : sr->allSignals())
+    m_exportRawDataDialog.addAvailableSignal(sm.second->readableName(), sm.second->rawDescriptiveName());
 
   do {
     int dret = m_exportRawDataDialog.exec();
@@ -390,8 +390,8 @@ std::shared_ptr<SingleRunData> DataManager::loadSingleRun(QDir& dir)
 
     _c = std::shared_ptr<SignalController>(new SignalController(_s));
 
-    sigs[_s->descriptiveName().toStdString()] = _s;
-    ctrls[_s->descriptiveName().toStdString()] = _c;
+    sigs[_s->rawDescriptiveName()] = _s;
+    ctrls[_s->rawDescriptiveName()] = _c;
     hpcs_free_mdata(md);
   }
 
index 8b915ea8c72f65e58392be2e166368c188459218..5a39c5de9ce69a05f7402797b1e6e21128437946 100644 (file)
@@ -60,12 +60,3 @@ QString Helpers::getFileNameSuffix(const QString& name)
 
   return name.mid(dotIdx+1).toLower();
 }
-
-QString Helpers::signalTagToHumanReadable(const std::string& tag)
-{
-  QString hr = QString::fromStdString(tag);
-
-  hr.replace("_", " ");
-
-  return hr;
-}
index 21da5ad7bd6e612b2105d60ab72bb2790baf8154..20d978a162001e5f6354d5e74418b5f476b72062 100644 (file)
--- a/helpers.h
+++ b/helpers.h
@@ -36,7 +36,6 @@ public:
   static int dpiY();
   static double firstTick(const double from, const double step);
   static QString getFileNameSuffix(const QString& name);
-  static QString signalTagToHumanReadable(const std::string& tag);
 
   template <typename T> static T average(T* vals, size_t len)
   {
index 6d8aadf8c2bf39a2d79c995002211c737a685c35..0b64ef48c5ec4864f88c0d9069e898db52fe6807 100644 (file)
@@ -72,10 +72,15 @@ Signal::Signal(const Equipment equipment, const Resource resource, const double
 
 QString Signal::descriptiveName() const
 {
-  QString name = resourceAsString();
+  return QString(rawDescriptiveName().c_str());
+}
+
+std::string Signal::rawDescriptiveName() const
+{
+  std::string name = resourceAsString().toStdString();
   if (m_resource == Resource::CE_DAD)
-    name += "_SIG" + QString::number(m_wavelengthMeasured) + "-" + QString::number(m_wavelengthMeasuredInterval) +  "_REF" +
-            QString::number(m_wavelengthReference) + "-" + QString::number(m_wavelengthReferenceInterval);
+    name += "_SIG" + std::to_string(m_wavelengthMeasured) + "-" + std::to_string(m_wavelengthMeasuredInterval) +  "_REF" +
+            std::to_string(m_wavelengthReference) + "-" + std::to_string(m_wavelengthReferenceInterval);
   return name;
 }
 
@@ -92,6 +97,15 @@ Signal::TimeValuePair Signal::pairAt(const size_t idx) const
     return m_values.at(idx);
 }
 
+QString Signal::readableName() const
+{
+  QString name = resourceAsString();
+  if (m_resource == Resource::CE_DAD) {
+    return name + QString(" (Measured: %1/%2 nm, Reference %3/%4 nm)").arg(m_wavelengthMeasured).arg(m_wavelengthMeasuredInterval).arg(m_wavelengthReference).arg(m_wavelengthReferenceInterval);
+  }
+  return name;
+}
+
 QString Signal::resourceAsString() const {
   switch (m_resource) {
     case Resource::CE_CCD:
index 9c285c99f3b5e8ae7673080590558a722a41f5a5..2e13de9a8dc2b068ddefe14b2f8923dfc36062e6 100644 (file)
--- a/signal.h
+++ b/signal.h
@@ -73,6 +73,8 @@ public:
   double maximum() const { return m_max; }
   double minimum() const { return m_min; }
   TimeValuePair pairAt(const size_t idx) const;
+  std::string rawDescriptiveName() const;
+  QString readableName() const;
   Resource resource() const { return m_resource; }
   QString resourceAsString() const;
   double timeAt(const size_t idx) const;