From 64df851ad1e9f4f52caf943e02db7a83210ef2da Mon Sep 17 00:00:00 2001
From: Giacomo Strangolino <giacomo.strangolino@elettra.eu>
Date: Mon, 27 Sep 2021 14:54:40 +0200
Subject: [PATCH] fix: lambda curve color and style linked to lambda 1,2,3...
 number

---
 i0mapmon.pro       |  2 +-
 src/i0mmonplot.cpp | 13 ++++++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/i0mapmon.pro b/i0mapmon.pro
index 95c6279..2ad1bd0 100644
--- a/i0mapmon.pro
+++ b/i0mapmon.pro
@@ -5,7 +5,7 @@ include($${CUMBIA_ROOT}/include/quapps/quapps.pri)
 
 CONFIG += debug
 
-# DEFINES -= QT_NO_DEBUG_OUTPUT
+DEFINES -= QT_NO_DEBUG_OUTPUT
 
 # RESOURCES +=
 
diff --git a/src/i0mmonplot.cpp b/src/i0mmonplot.cpp
index bdb0d96..bc4eecc 100644
--- a/src/i0mmonplot.cpp
+++ b/src/i0mmonplot.cpp
@@ -75,6 +75,7 @@ bool I0MMonPlot::yAutoScale() const {
 }
 void I0MMonPlot::setSources(const QString &x, const QString &y, const QMap<int, double> lambdamap, int nsamples)
 {
+    qDebug() << __PRETTY_FUNCTION__ << lambdamap;
     m_multiread_plu_i->unsetSources();
     foreach(const QString& cn, m_curvesymap.keys())
         removeCurve(cn);
@@ -84,21 +85,20 @@ void I0MMonPlot::setSources(const QString &x, const QString &y, const QMap<int,
     m_lambdas = lambdamap;
     m_time_mode = (x == "time");
     m_reset_scales();
-    int la = 1, cc = 0;;
     foreach(double l, lambdamap.values()) {
         QString cuna = QString("lambda %1").arg(l);
         QuPlotCurve *crv = curve(cuna);
+        const int lambdai = lambdamap.key(l) + 1; // from 1
         if(!crv) {
             crv = new QuPlotCurve(cuna);
             addCurve(cuna, crv);
             QPen p = crv->pen();
-            p.setColor(m_colormap[cc % m_colormap.size()]);
+            p.setColor(m_colormap[(lambdai - 1) % m_colormap.size()]); // colormap lambdai - 1, from 0
             p.setWidthF(2.5);
             crv->setPen(p);
-            crv->setTitle(QString("λ %1").arg(la++));
-            cc++;
+            crv->setTitle(QString("λ %1").arg(lambdai));
         }
-        m_curvesymap[cuna] = m_symstyles[m_curvesymap.size() % m_symstyles.size()];
+        m_curvesymap[cuna] = m_symstyles[(lambdai-1) % m_symstyles.size()];
     }
     qDebug() << __PRETTY_FUNCTION__ << "settings sources: x " <<  x << " y " << y  << "time mode" << m_time_mode;
     if(m_time_mode) {
@@ -114,6 +114,9 @@ void I0MMonPlot::setSources(const QString &x, const QString &y, const QMap<int,
         }
     }
     updateLegend();
+    printf("I0MMonPlot::setSources curvesSize %d\n", curves().size());
+    foreach(QwtPlotCurve *c, curves())
+        printf("- %s\n", qstoc(c->title().text()));
 }
 
 void I0MMonPlot::setYBounds(double ymi, double yma) {
-- 
GitLab