Commit 34e7cd22 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

Saved work

parent ab498e51
...@@ -10,9 +10,11 @@ DEFINES -= QT_NO_DEBUG_OUTPUT ...@@ -10,9 +10,11 @@ DEFINES -= QT_NO_DEBUG_OUTPUT
# RESOURCES += # RESOURCES +=
SOURCES += src/main.cpp \ SOURCES += src/main.cpp \
src/checkablecomboboxmodel.cpp \
src/i0mapmon.cpp src/i0mapmon.cpp
HEADERS += src/i0mapmon.h HEADERS += src/i0mapmon.h \
src/checkablecomboboxmodel.h
# cuuimake runs uic # cuuimake runs uic
# FORMS = src/i0mapmon.ui # FORMS = src/i0mapmon.ui
......
#include "checkablecomboboxmodel.h"
#include <QStandardItem>
#include <QtDebug>
CheckableComboBoxModel::CheckableComboBoxModel(QObject *parent) : QStandardItemModel(parent) {
connect(this, SIGNAL(itemChanged(QStandardItem *)), this, SLOT(onItemChanged(QStandardItem *)));
}
QStandardItem* CheckableComboBoxModel::addItem(const QString &i, bool checkable)
{
setRowCount(rowCount() + 1);
QStandardItem* item = new QStandardItem(i);
if(checkable) {
item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
item->setData(Qt::Unchecked, Qt::CheckStateRole);
}
setItem(rowCount() -1, 0, item);
return item;
}
void CheckableComboBoxModel::onItemChanged(QStandardItem *it)
{
qDebug() << __PRETTY_FUNCTION__ << it;
emit itemChecked(it->text(), it->data(Qt::CheckStateRole).toBool());
}
#ifndef CHECKABLECOMBOBOXMODEL_H
#define CHECKABLECOMBOBOXMODEL_H
#include <QStandardItemModel>
class CheckableComboBoxModel : public QStandardItemModel
{
Q_OBJECT
public:
enum DataRole { SrcRole = Qt::UserRole + 1 };
explicit CheckableComboBoxModel(QObject *parent);
QStandardItem *addItem(const QString& i, bool checkable = true);
private slots:
void onItemChanged(QStandardItem * it);
signals:
void itemChecked(const QString& text, bool checked);
};
#endif // CHECKABLECOMBOBOXMODEL_H
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
#include <quwatcher.h> #include <quwatcher.h>
#include <qulineedit.h> #include <qulineedit.h>
#include <qustring.h>
#include "checkablecomboboxmodel.h"
I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) : I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) :
QWidget(parent) QWidget(parent)
...@@ -17,13 +20,13 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) : ...@@ -17,13 +20,13 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) :
// cumbia // cumbia
CuModuleLoader mloader(cumbia_pool, &m_ctrl_factory_pool, &m_log_impl); CuModuleLoader mloader(cumbia_pool, &m_ctrl_factory_pool, &m_log_impl);
cu_pool = cumbia_pool; cu_pool = cumbia_pool;
ui = new Ui::I0mapmon; ui = new Ui::I0mapmon;
ui->setupUi(this, cu_pool, m_ctrl_factory_pool); ui->setupUi(this, cu_pool, m_ctrl_factory_pool);
// mloader.modules() to get the list of loaded modules // mloader.modules() to get the list of loaded modules
// cumbia // cumbia
m_fel0x = 0; m_fel0x = 0;
for(int i = 1; i < qApp->arguments().size() && m_fel0x < 1; i++) { for(int i = 1; i < qApp->arguments().size() && m_fel0x < 1; i++) {
if(qApp->arguments()[i].contains("f01")) m_fel0x = 1; if(qApp->arguments()[i].contains("f01")) m_fel0x = 1;
...@@ -34,6 +37,10 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) : ...@@ -34,6 +37,10 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) :
else { else {
ui->lTitle->setText(ui->lTitle->text() + QString(" FEL0%1").arg(m_fel0x)); ui->lTitle->setText(ui->lTitle->text() + QString(" FEL0%1").arg(m_fel0x));
m_cb_model = new CheckableComboBoxModel(ui->qucby);
connect(m_cb_model, SIGNAL(itemChecked(QString,bool)), this, SLOT(onWlenSelectionChanged(QString, bool)));
ui->qucblambda->setModel(m_cb_model);
// continue setup // continue setup
QuWatcher *w = new QuWatcher(this, cumbia_pool, m_ctrl_factory_pool); QuWatcher *w = new QuWatcher(this, cumbia_pool, m_ctrl_factory_pool);
w->setSingleShot(true); w->setSingleShot(true);
...@@ -41,22 +48,28 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) : ...@@ -41,22 +48,28 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) :
w->attach(this, SLOT(onNamesReady(QStringList))); w->attach(this, SLOT(onNamesReady(QStringList)));
w->setSource("$1/name"); w->setSource("$1/name");
connect(ui->pbApplyWlens, SIGNAL(clicked()), this, SLOT(applyWavelenX()));
connect(ui->pbApplyWlenWei, SIGNAL(clicked()), this, SLOT(applyWavelenX())); connect(ui->pbApplyWlenWei, SIGNAL(clicked()), this, SLOT(applyWavelenX()));
// qu-line edit for wavelen / wavelen weights // qu-line edit for wavelen / wavelen weights
ui->quleWlens->setTarget(QString("$2/FEL0%1_IOM_wavelengths").arg(m_fel0x));
ui->quleWlenWei->setTarget(QString("$2/FEL0%1_IOM_wavelength_weights").arg(m_fel0x)); ui->quleWlenWei->setTarget(QString("$2/FEL0%1_IOM_wavelength_weights").arg(m_fel0x));
// label // label
ui->qulWlens->setSource(QString("$2/FEL0%1_IOM_wavelengths").arg(m_fel0x)); ui->qulWlens->setSource(QString("$2/FEL0%1_IOM_wavelengths").arg(m_fel0x));
ui->qulWlenWei->setSource(QString("$2/FEL0%1_IOM_wavelength_weights").arg(m_fel0x)); ui->qulWlenWei->setSource(QString("$2/FEL0%1_IOM_wavelength_weights").arg(m_fel0x));
connect(ui->qulWlens, SIGNAL(newData(CuData)), this, SLOT(onWlensChanged(CuData)));
// plot // plot
ui->quSpectrumPlot->setYLowerBound(-1.0); ui->quSpectrumPlot->setYLowerBound(-1.0);
ui->quSpectrumPlot->setYUpperBound(1.0); ui->quSpectrumPlot->setYUpperBound(1.0);
ui->quSpectrumPlot->setXLowerBound(-1.0);
ui->quSpectrumPlot->setXUpperBound(1.0);
// autoscale // autoscale
ui->quSpectrumPlot->setYAxisAutoscaleEnabled(true); ui->quSpectrumPlot->setYAxisAutoscaleEnabled(true);
m_setup_x_list();
// trigger plot reconf
connect(ui->pbPlotReconf, SIGNAL(clicked()), this, SLOT(m_plot_reconf()));
} }
} }
...@@ -66,12 +79,12 @@ I0mapmon::~I0mapmon() ...@@ -66,12 +79,12 @@ I0mapmon::~I0mapmon()
} }
void I0mapmon::onNamesReady(const QStringList &n) { void I0mapmon::onNamesReady(const QStringList &n) {
ui->qucbx->clear(); ui->qucby->clear();
ui->qucbx->insertItems(0, n); ui->qucby->insertItems(0, n);
if(n.size()) { if(n.size()) {
onXChanged(n.first()); // onYChanged(n.first());
// X combo box // X combo box
connect(ui->qucbx, SIGNAL(currentTextChanged(QString)), this, SLOT(onXChanged(QString))); connect(ui->qucby, SIGNAL(currentTextChanged(QString)), this, SLOT(onYChanged(QString)));
} }
} }
...@@ -79,7 +92,7 @@ void I0mapmon::applyWavelenX() { ...@@ -79,7 +92,7 @@ void I0mapmon::applyWavelenX() {
bool ok; bool ok;
QString tgt, txt; QString tgt, txt;
QVector<double> vals; QVector<double> vals;
sender()->objectName() == "pbApplyWlens" ? txt = ui->quleWlens->text() : txt = ui->quleWlenWei->text(); txt = ui->quleWlenWei->text();
foreach(const QString& v, txt.split(QRegularExpression(",\\s*"))) foreach(const QString& v, txt.split(QRegularExpression(",\\s*")))
if(v.toDouble(&ok) && ok) vals.push_back(v.toDouble()); if(v.toDouble(&ok) && ok) vals.push_back(v.toDouble());
sender()->objectName() == "pbApplyWlens" ? tgt = QString("$2/FEL0%1_IOM_wavelengths").arg(m_fel0x) : sender()->objectName() == "pbApplyWlens" ? tgt = QString("$2/FEL0%1_IOM_wavelengths").arg(m_fel0x) :
...@@ -87,8 +100,60 @@ void I0mapmon::applyWavelenX() { ...@@ -87,8 +100,60 @@ void I0mapmon::applyWavelenX() {
qDebug() << __PRETTY_FUNCTION__ << "*WOULD WRITE ON* target" << tgt << "values" << vals; qDebug() << __PRETTY_FUNCTION__ << "*WOULD WRITE ON* target" << tgt << "values" << vals;
} }
void I0mapmon::onXChanged(const QString &x) { void I0mapmon::onYChanged(const QString &y) {
ui->quSpectrumPlot->unsetSources(); ui->quSpectrumPlot->unsetSources();
ui->quSpectrumPlot->clearPlot(); ui->quSpectrumPlot->clearPlot();
ui->quSpectrumPlot->setSource("$1/" + x); ui->quSpectrumPlot->setSource("$1/" + y);
}
void I0mapmon::onWlensChanged(const CuData &da) {
ui->qucblambda->setEnabled(!da["err"].toBool());
if(ui->qucblambda->isEnabled()) {
m_cb_model->clear();
m_cb_model->addItem("select...", false);
foreach(const QString& wl, QuString(da["value"].toString()).split(",")) {
m_cb_model->addItem(wl);
}
}
ui->qucblambda->setCurrentIndex(0);
}
void I0mapmon::onWlenSelectionChanged(const QString& , bool ) {
QStringList wlens;
for(int i = 0; i < m_cb_model->rowCount(); i++) {
QStandardItem *it = m_cb_model->item(i);
if(it->data(Qt::CheckStateRole).toBool())
wlens.append(it->text());
}
ui->quleWlens->setText(wlens.join(","));
}
void I0mapmon::m_setup_x_list() {
ui->qucbx->insertItem(0, "time");
// "PM2a Ni Photocurrent (a.u.)" /pos/diagnostics/photo_current_pos.01 None GetArea3
// "PM2a Ca Photocurrent (a.u.)" pos/diagnostics/photo_current_pos.01 None GetArea2
// "PM2a OLD Photocurrent" srv-tf-srf:20000/ec-tf-esa-01/v1720/1000000 None GetArea4
// "PRESTO Intensity" pos/pesp/ccd-pesp_pos.01 Intensity None
// "TARDI Intensity" pos_mag/pesp/ccd-pesp_pos_mag.01 Intensity None
// "DPI Photodiode (Beamline Transmission)" pos/diagnostics/pico_pos.01 None GetIc
// "LDM Photodiode (Beamline Transmission)" pos/diagnostics/pico_pos.01 None GetId
ui->qucbx->insertItem(ui->qucbx->count(), "PM2a Ni Photocurrent (a.u.)");
ui->qucbx->setItemData(ui->qucbx->count() - 1, "pos/diagnostics/photo_current_pos.01/GetArea3", CheckableComboBoxModel::SrcRole);
ui->qucbx->insertItem(ui->qucbx->count(), "PM2a Ca Photocurrent (a.u.)");
ui->qucbx->setItemData(ui->qucbx->count() - 1, "pos/diagnostics/photo_current_pos.01/GetArea2", CheckableComboBoxModel::SrcRole);
ui->qucbx->insertItem(ui->qucbx->count(), "PM2a OLD Photocurrent");
ui->qucbx->setItemData(ui->qucbx->count() - 1, "srv-tf-srf:20000/ec-tf-esa-01/v1720/1000000/GetArea4", CheckableComboBoxModel::SrcRole);
ui->qucbx->insertItem(ui->qucbx->count(), "PRESTO Intensity");
ui->qucbx->setItemData(ui->qucbx->count() - 1, "pos/pesp/ccd-pesp_pos.01/Intensity", CheckableComboBoxModel::SrcRole);
ui->qucbx->insertItem(ui->qucbx->count(), "DPI Photodiode (Beamline Transmission)");
ui->qucbx->setItemData(ui->qucbx->count() - 1, "pos/diagnostics/pico_pos.01/GetIc", CheckableComboBoxModel::SrcRole);
ui->qucbx->insertItem(ui->qucbx->count(), "LDM Photodiode (Beamline Transmission)");
ui->qucbx->setItemData(ui->qucbx->count() - 1, "pos/diagnostics/pico_pos.01/GetId", CheckableComboBoxModel::SrcRole);
}
void I0mapmon::m_plot_reconf() {
qDebug() << __PRETTY_FUNCTION__ << "reconfiguring plot with X " << ui->qucbx->currentText()
<< ui->qucby->currentText() << ui->quleWlens->text();
} }
...@@ -7,8 +7,11 @@ ...@@ -7,8 +7,11 @@
#include <qulogimpl.h> #include <qulogimpl.h>
#include <cucontrolsfactorypool.h> #include <cucontrolsfactorypool.h>
class CumbiaPool; class CumbiaPool;
class CuData;
// cumbia // cumbia
class CheckableComboBoxModel;
namespace Ui { namespace Ui {
class I0mapmon; class I0mapmon;
} }
...@@ -24,7 +27,11 @@ public: ...@@ -24,7 +27,11 @@ public:
private slots: private slots:
void onNamesReady(const QStringList& n); void onNamesReady(const QStringList& n);
void applyWavelenX(); void applyWavelenX();
void onXChanged(const QString& x); void onYChanged(const QString& y);
void onWlensChanged(const CuData &s);
void onWlenSelectionChanged(const QString &wl, bool enab);
void m_plot_reconf();
private: private:
Ui::I0mapmon *ui; Ui::I0mapmon *ui;
...@@ -36,6 +43,11 @@ private: ...@@ -36,6 +43,11 @@ private:
// cumbia // cumbia
int m_fel0x; int m_fel0x;
CheckableComboBoxModel* m_cb_model;
// methods
void m_setup_x_list();
}; };
#endif // I0mapmon_H #endif // I0mapmon_H
...@@ -14,10 +14,59 @@ ...@@ -14,10 +14,59 @@
<string>I0mapmon</string> <string>I0mapmon</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="4"> <item row="4" column="0">
<widget class="QuSpectrumPlot" name="quSpectrumPlot"/> <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="5">
<widget class="QPushButton" name="pbApplyWlenWei">
<property name="text">
<string>APPLY</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QuLabel" name="qulWlenWei"/>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Wavelen weights:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item> </item>
<item row="2" column="0" colspan="4"> <item row="0" column="1" colspan="5">
<widget class="QLabel" name="lTitle">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Real time</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="4" column="4">
<widget class="QuLineEdit" name="quleWlenWei"/>
</item>
<item row="4" column="2">
<widget class="QuLabel" name="qulWlens"/>
</item>
<item row="2" column="0" colspan="6">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
...@@ -60,9 +109,9 @@ ...@@ -60,9 +109,9 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
<string>N. Samples:</string> <string>lambdas</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
...@@ -70,78 +119,53 @@ ...@@ -70,78 +119,53 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QuInputOutput" name="quInputOutput"> <widget class="QuComboBox" name="qucblambda">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch> <horstretch>2</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item>
</item> <widget class="QLabel" name="quleWlens">
<item row="3" column="0"> <property name="frameShape">
<widget class="QLabel" name="label_4"> <enum>QFrame::Box</enum>
<property name="text">
<string>Wavelengths:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item>
<widget class="QuLabel" name="qulWlens"/> <widget class="QPushButton" name="pbPlotReconf">
</item>
<item row="3" column="2">
<widget class="QuLineEdit" name="quleWlens"/>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="pbApplyWlens">
<property name="text"> <property name="text">
<string>APPLY</string> <string>APPLY</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item>
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Wavelen weights:</string> <string>N. Samples:</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item>
<widget class="QuLabel" name="qulWlenWei"/> <widget class="QuInputOutput" name="quInputOutput">
</item> <property name="sizePolicy">
<item row="4" column="2"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<widget class="QuLineEdit" name="quleWlenWei"/> <horstretch>1</horstretch>
</item> <verstretch>0</verstretch>
<item row="4" column="3"> </sizepolicy>
<widget class="QPushButton" name="pbApplyWlenWei">
<property name="text">
<string>APPLY</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0" colspan="4"> </layout>
<widget class="QLabel" name="lTitle"> </item>
<property name="font"> <item row="1" column="0" colspan="6">
<font> <widget class="QuSpectrumPlot" name="quSpectrumPlot"/>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Real time</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
......
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