Commit d0adf6d4 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

fixed curve style

parent 283ce0c8
No preview for this file type
......@@ -52,67 +52,6 @@ bool I0MMonPlot::pluginLoaded() const {
bool I0MMonPlot::yAutoScale() const {
return m_ymax == m_ymin;
}
void I0MMonPlot::onDataReady(const QList<CuData> &dl) {
qDebug() << __PRETTY_FUNCTION__ << "data szi" << dl.size();
double x = 0.0;
if(!m_time_mode && dl.size() == 2) { // correlate
QVector<double> yv, xv;
const CuData& xd = dl[0];
const CuData& yd = dl[1];
printf("\e[1;35mx %s , y %s\e[0m\n", vtoc2(xd, "value"), vtoc2(yd, "value"));
if(xd.has("data_format_str", "vector")) {
// average
double sum = 0.0;
const std::vector<double> &v = xd["value"].toDoubleVector();
for(size_t i = 0; i < v.size(); i++)
sum += v[i];
x = sum / m_numsamples;
printf("x (%f) averaged across %ld samples\n", x, v.size());
}
else
x = xd["value"].toDouble();
// y
const std::vector<double> &yt = yd["value"].toDoubleVector();
foreach(int i, m_lambdas.keys()) {
if(i < static_cast<int>(yt.size()) ) {
appendData(QString("lambda %1").arg(m_lambdas[i]), x, yt[i]);
yv << yt[i];
xv << x;
}
}
m_set_bounds(xv, yv);
}
else if(m_time_mode) { // trend in time
const CuData &da = dl[0];
const std::vector<double> &ystdv = da["value"].toDoubleVector();
QVector<double> xv {0.0}; // m_set_bounds needs a vector, say 0 and data size
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
const QVector<double> yv = QVector<double>::fromStdVector(ystdv);
#else
const QVector<double> yv(ystdv.begin(), ystdv.end());
#endif
foreach(int idx, m_lambdas.keys()) {
const QString curveName = QString("lambda %1").arg(m_lambdas[idx]);
const QuPlotCurve *c = curve(curveName);
xv << c->data()->size();
if(idx < static_cast<int>(yv.size()) && curve(curveName) != nullptr ) {
m_set_bounds(xv, yv);
appendData(curveName, xv[1], yv[idx]);
}
}
m_curves_style();
}
else {
printf("\e[1;31mI0MMonPlot::onDataReady: no time mode: data size %d\e[0m\n", dl.size());
for(int i = 0; i < dl.size(); i++)
printf("\e[1;31mI0MMonPlot::onDataReady: %s\e[0m\n", datos(dl[i]));
}
m_empty = false;
}
void I0MMonPlot::setSources(const QString &x, const QString &y, const QMap<int, double> lambdamap, int nsamples)
{
qDebug() << __PRETTY_FUNCTION__ << x << y << lambdamap;
......@@ -212,6 +151,67 @@ void I0MMonPlot::m_set_bounds(const QVector<double> &xv, const QVector<double> &
setXUpperBound(xub);
}
void I0MMonPlot::onDataReady(const QList<CuData> &dl) {
qDebug() << __PRETTY_FUNCTION__ << "data szi" << dl.size();
double x = 0.0;
if(!m_time_mode && dl.size() == 2) { // correlate
QVector<double> yv, xv;
const CuData& xd = dl[0];
const CuData& yd = dl[1];
printf("\e[1;35mx %s , y %s\e[0m\n", vtoc2(xd, "value"), vtoc2(yd, "value"));
if(xd.has("data_format_str", "vector")) {
// average
double sum = 0.0;
const std::vector<double> &v = xd["value"].toDoubleVector();
for(size_t i = 0; i < v.size(); i++)
sum += v[i];
x = sum / m_numsamples;
printf("x (%f) averaged across %ld samples\n", x, v.size());
}
else
x = xd["value"].toDouble();
// y
const std::vector<double> &yt = yd["value"].toDoubleVector();
foreach(int i, m_lambdas.keys()) {
if(i < static_cast<int>(yt.size()) ) {
appendData(QString("lambda %1").arg(m_lambdas[i]), x, yt[i]);
yv << yt[i];
xv << x;
}
}
m_set_bounds(xv, yv);
}
else if(m_time_mode) { // trend in time
const CuData &da = dl[0];
const std::vector<double> &ystdv = da["value"].toDoubleVector();
QVector<double> xv {0.0}; // m_set_bounds needs a vector, say 0 and data size
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
const QVector<double> yv = QVector<double>::fromStdVector(ystdv);
#else
const QVector<double> yv(ystdv.begin(), ystdv.end());
#endif
foreach(int idx, m_lambdas.keys()) {
const QString curveName = QString("lambda %1").arg(m_lambdas[idx]);
const QuPlotCurve *c = curve(curveName);
xv << c->data()->size();
if(idx < static_cast<int>(yv.size()) && curve(curveName) != nullptr ) {
m_set_bounds(xv, yv);
appendData(curveName, xv[1], yv[idx]);
}
}
}
else {
printf("\e[1;31mI0MMonPlot::onDataReady: no time mode: data size %d\e[0m\n", dl.size());
for(int i = 0; i < dl.size(); i++)
printf("\e[1;31mI0MMonPlot::onDataReady: %s\e[0m\n", datos(dl[i]));
}
m_curves_style();
m_empty = false;
}
void I0MMonPlot::m_reset_scales() {
setXLowerBound(-0.5);
setXUpperBound(0.5);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment