Commit f981f077 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files
parent 2c2a0b6e
......@@ -20,7 +20,7 @@ EXAMPLE start:
export TANGO_HOST=srv-tango-padres-01:20000
./bin/i0mapmon pfe_f02/diagnostics/fel_iom_pfe_f02.01 srv-tango-srf-01:20000/f/misc/beam_status_f
./bin/i0mapmon-gui pfe_f02/diagnostics/fel_iom_pfe_f02.01 padres/felmapmon/values
......
......@@ -5,7 +5,7 @@ include($${CUMBIA_ROOT}/include/quapps/quapps.pri)
CONFIG += debug
DEFINES -= QT_NO_DEBUG_OUTPUT
# DEFINES -= QT_NO_DEBUG_OUTPUT
# RESOURCES +=
......
......@@ -47,8 +47,14 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) :
QuWatcher *w = new QuWatcher(this, cumbia_pool, m_ctrl_factory_pool);
w->setSingleShot(true);
w->setAutoDestroy(true);
w->attach(this, SLOT(onNamesReady(QStringList)));
w->setSource("$1/name");
w->attach(this, SLOT(onLabelReady(QStringList)));
w->setSource("$1/label");
QuWatcher *nw = new QuWatcher(this, cumbia_pool, m_ctrl_factory_pool);
nw->setSingleShot(true);
nw->setAutoDestroy(true);
nw->attach(&m_ynames);
nw->setSource("$1/name");
connect(ui->pbApplyWlenWei, SIGNAL(clicked()), this, SLOT(applyWavelenX()));
connect(ui->pbApplyWlens, SIGNAL(clicked()), this, SLOT(applyWavelenX()));
......@@ -83,6 +89,7 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) :
connect(ui->cbYAuto, SIGNAL(toggled(bool)), ui->leyMax, SLOT(setDisabled(bool)));
connect(ui->pbApplyBounds, SIGNAL(clicked()), this, SLOT(setYMinMax()));
connect(ui->cbYAuto, SIGNAL(toggled(bool)), ui->plot, SLOT(setYBoundsAuto(bool)));
connect(ui->cbLogScale, SIGNAL(toggled(bool)), ui->plot, SLOT(setYLogScale(bool)));
ui->cbYAuto->setChecked(true); // disable y bounds line edits
}
}
......@@ -92,7 +99,7 @@ I0mapmon::~I0mapmon()
delete ui;
}
void I0mapmon::onNamesReady(const QStringList &n) {
void I0mapmon::onLabelReady(const QStringList &n) {
qDebug() << __PRETTY_FUNCTION__ << n;
ui->qucby->clear();
ui->qucby->insertItems(0, n);
......@@ -194,5 +201,7 @@ void I0mapmon::m_plot_reconf() {
const QString& srcx = ui->qucbx->itemData(ui->qucbx->currentIndex(), Qt::UserRole + 1).toString();
const QString devy = ui->quionSamples->source().remove("/" + ui->quionSamples->source().section('/',- 1));
printf("\e[1;32mI0mapmon.m_plot_reconf x \"%s\" y \"%s\"\e[0m\n", qstoc(srcx), qstoc(devy));
ui->plot->setSources(srcx, devy + '/' + ui->qucby->currentText(), m_selected_wlens(), ui->quionSamples->findChild<QuLabel *>()->text().toInt());
qDebug() << __PRETTY_FUNCTION__ << m_ynames;
if(m_ynames.size() > ui->qucby->currentIndex())
ui->plot->setSources(srcx, devy + '/' + m_ynames[ui->qucby->currentIndex()], m_selected_wlens(), ui->quionSamples->findChild<QuLabel *>()->text().toInt());
}
......@@ -25,7 +25,7 @@ public:
~I0mapmon();
private slots:
void onNamesReady(const QStringList& n);
void onLabelReady(const QStringList& n);
void applyWavelenX();
void onYChanged(const QString& y);
void onWlensChanged(const CuData &s);
......@@ -51,6 +51,7 @@ private:
void m_setup_x_list();
QMap<int, double> m_selected_wlens() const;
QStringList m_ynames;
};
#endif // I0mapmon_H
......@@ -7,17 +7,20 @@
<x>0</x>
<y>0</y>
<width>1184</width>
<height>563</height>
<height>614</height>
</rect>
</property>
<property name="windowTitle">
<string>I0mapmon</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="0" colspan="8">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="5" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Threshold</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
......@@ -43,28 +46,86 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<item row="1" column="0" colspan="9">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="I0MMonPlot" name="plot" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbConfPlot">
<property name="title">
<string>Plot configuration</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Wavelengths:</string>
<string>Y min:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QPushButton" name="pbApplyWlens">
<item row="0" column="3">
<widget class="QLabel" name="label_8">
<property name="text">
<string>APPLY</string>
<string>Y max:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QuLabel" name="qulWlens"/>
<item row="0" column="4">
<widget class="QLineEdit" name="leyMax">
<property name="text">
<string>10</string>
</property>
</widget>
</item>
<item row="4" column="5">
<widget class="QuLabel" name="qulWlenWei"/>
<item row="0" column="0">
<widget class="QCheckBox" name="cbYAuto">
<property name="text">
<string>Y auto scale</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="pbApplyBounds">
<property name="text">
<string>APPLY BOUNDS</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="leyMin">
<property name="text">
<string>-10</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QCheckBox" name="cbLogScale">
<property name="text">
<string>Log Scale</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="4" column="6">
<widget class="QuLineEdit" name="quleWlenWei"/>
......@@ -76,6 +137,23 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="8">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Wavelengths:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QLabel" name="label_5">
<property name="text">
......@@ -89,13 +167,10 @@
<item row="4" column="2">
<widget class="QuLineEdit" name="quleWlens"/>
</item>
<item row="4" column="8">
<widget class="QPushButton" name="pbConfPlot">
<item row="4" column="3">
<widget class="QPushButton" name="pbApplyWlens">
<property name="text">
<string>Configure Plot</string>
</property>
<property name="checkable">
<bool>true</bool>
<string>APPLY</string>
</property>
</widget>
</item>
......@@ -192,82 +267,37 @@
</item>
</layout>
</item>
<item row="1" column="0" colspan="9">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="I0MMonPlot" name="plot" native="true">
<item row="4" column="5">
<widget class="QuLabel" name="qulWlenWei"/>
</item>
<item row="4" column="1">
<widget class="QuLabel" name="qulWlens"/>
</item>
<item row="5" column="1">
<widget class="QuInputOutput" name="quInputOutput">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gbConfPlot">
<property name="title">
<string>Plot configuration</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="cbYAuto">
<property name="text">
<string>Y auto scale</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Y min:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="leyMin">
<property name="text">
<string>-10</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Y max:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="source">
<string>$1/IntensityRelThreshold</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLineEdit" name="leyMax">
<item row="5" column="7">
<widget class="QPushButton" name="pbConfPlot">
<property name="text">
<string>10</string>
<string>Configure Plot</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="pbApplyBounds">
<property name="text">
<string>APPLY BOUNDS</string>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
......
......@@ -6,6 +6,7 @@
#include <qwt_symbol.h>
#include <qwt_legend.h>
#include <qwt_date_scale_engine.h>
#include <qwt_transform.h>
#include <cupluginloader.h>
#include <qumultireaderplugininterface.h>
......@@ -18,6 +19,17 @@
#include <cutreader.h>
#endif
class LogTransform : public QwtLogTransform {
public:
LogTransform() : QwtLogTransform() { printf("LOG TRANSFORM\n"); }
// QwtTransform interface
public:
double bounded(double v) const{
return qBound(0.01, v, LogMax);
}
};
I0MMonPlot::I0MMonPlot(QWidget *parent, CumbiaPool *cup, const CuControlsFactoryPool &fpoo)
: QuPlotBase(parent),
m_symstyles (QList<QwtSymbol::Style> () << QwtSymbol::Ellipse
......@@ -29,6 +41,7 @@ I0MMonPlot::I0MMonPlot(QWidget *parent, CumbiaPool *cup, const CuControlsFactory
m_time_mode = m_empty = true;
m_numsamples = 1;
m_ymin = m_ymax = 0;
m_log_scale = false;
CuPluginLoader plo;
QObject *plugin_qob;
m_multiread_plu_i = plo.get<QuMultiReaderPluginInterface>("libcumbia-multiread-plugin.so", &plugin_qob);
......@@ -44,6 +57,9 @@ I0MMonPlot::I0MMonPlot(QWidget *parent, CumbiaPool *cup, const CuControlsFactory
setXAxisAutoscaleEnabled(false);
setYAxisAutoscaleEnabled(false);
insertLegend( new QwtLegend() );
m_colormap << "#ff5555" << "#c8ff00" << "#2882ff" << "#7fffff" ;
}
I0MMonPlot::~I0MMonPlot() {
......@@ -68,7 +84,7 @@ 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;
int la = 1, cc = 0;;
foreach(double l, lambdamap.values()) {
QString cuna = QString("lambda %1").arg(l);
QuPlotCurve *crv = curve(cuna);
......@@ -76,9 +92,11 @@ void I0MMonPlot::setSources(const QString &x, const QString &y, const QMap<int,
crv = new QuPlotCurve(cuna);
addCurve(cuna, crv);
QPen p = crv->pen();
p.setColor(m_colormap[cc % m_colormap.size()]);
p.setWidthF(2.5);
crv->setPen(p);
crv->setTitle(QString("λ %1").arg(la++));
cc++;
}
m_curvesymap[cuna] = m_symstyles[m_curvesymap.size() % m_symstyles.size()];
}
......@@ -95,6 +113,7 @@ void I0MMonPlot::setSources(const QString &x, const QString &y, const QMap<int,
m_multiread_plu_i->insertSource(y, 1);
}
}
updateLegend();
}
void I0MMonPlot::setYBounds(double ymi, double yma) {
......@@ -113,6 +132,18 @@ void I0MMonPlot::setYBoundsAuto(bool a) {
}
}
void I0MMonPlot::setYLogScale(bool a) {
m_log_scale = a;
QwtScaleEngine *se;
a ? se = new QwtLogScaleEngine : se = new QwtLinearScaleEngine;
if(a) {
se->setTransformation(new LogTransform);
setYLowerBound(yLowerBound() <=0 ? 0.01 : yLowerBound());
}
setAxisScaleEngine(QwtPlot::yLeft, se);
replot();
}
void I0MMonPlot::m_set_bounds(const QVector<double> &xv, const QVector<double> &yv)
{
qDebug() << __PRETTY_FUNCTION__ << "y" << m_ymin << m_ymax << "m_empty ? " << m_empty << yv;
......@@ -135,7 +166,7 @@ void I0MMonPlot::m_set_bounds(const QVector<double> &xv, const QVector<double> &
}
if(ylb != yLowerBound())
setYLowerBound(ylb);
setYLowerBound( (m_log_scale && ylb) <= 0 ? 0.01 : ylb);
if(yub != yUpperBound())
setYUpperBound(yub);
qDebug() << __PRETTY_FUNCTION__ << "y" << ylb << "->" << yub << "ym, yM" << *ym << *yM;
......
......@@ -28,6 +28,7 @@ public slots:
void setSources(const QString& x, const QString& y, const QMap<int, double> lambdamap, int nsamples);
void setYBounds(double ymi, double yma);
void setYBoundsAuto(bool a);
void setYLogScale(bool a);
private:
......@@ -45,9 +46,10 @@ private:
const QList<QwtSymbol::Style> m_symstyles;
bool m_time_mode, m_empty;
bool m_time_mode, m_empty, m_log_scale;
double m_ymin, m_ymax;
QList<QColor> m_colormap;
};
#endif // I0MMONPLOT_H
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