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
# RESOURCES +=
SOURCES += src/main.cpp \
src/checkablecomboboxmodel.cpp \
src/i0mapmon.cpp
HEADERS += src/i0mapmon.h
HEADERS += src/i0mapmon.h \
src/checkablecomboboxmodel.h
# cuuimake runs uic
# 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 @@
#include <quwatcher.h>
#include <qulineedit.h>
#include <qustring.h>
#include "checkablecomboboxmodel.h"
I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) :
QWidget(parent)
......@@ -17,13 +20,13 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) :
// cumbia
CuModuleLoader mloader(cumbia_pool, &m_ctrl_factory_pool, &m_log_impl);
cu_pool = cumbia_pool;
ui = new Ui::I0mapmon;
ui->setupUi(this, cu_pool, m_ctrl_factory_pool);
// mloader.modules() to get the list of loaded modules
// cumbia
m_fel0x = 0;
for(int i = 1; i < qApp->arguments().size() && m_fel0x < 1; i++) {
if(qApp->arguments()[i].contains("f01")) m_fel0x = 1;
......@@ -34,6 +37,10 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) :
else {
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
QuWatcher *w = new QuWatcher(this, cumbia_pool, m_ctrl_factory_pool);
w->setSingleShot(true);
......@@ -41,22 +48,28 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) :
w->attach(this, SLOT(onNamesReady(QStringList)));
w->setSource("$1/name");
connect(ui->pbApplyWlens, SIGNAL(clicked()), this, SLOT(applyWavelenX()));
connect(ui->pbApplyWlenWei, SIGNAL(clicked()), this, SLOT(applyWavelenX()));
// 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));
// label
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));
connect(ui->qulWlens, SIGNAL(newData(CuData)), this, SLOT(onWlensChanged(CuData)));
// plot
ui->quSpectrumPlot->setYLowerBound(-1.0);
ui->quSpectrumPlot->setYUpperBound(1.0);
ui->quSpectrumPlot->setXLowerBound(-1.0);
ui->quSpectrumPlot->setXUpperBound(1.0);
// autoscale
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()
}
void I0mapmon::onNamesReady(const QStringList &n) {
ui->qucbx->clear();
ui->qucbx->insertItems(0, n);
ui->qucby->clear();
ui->qucby->insertItems(0, n);
if(n.size()) {
onXChanged(n.first());
// onYChanged(n.first());
// 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() {
bool ok;
QString tgt, txt;
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*")))
if(v.toDouble(&ok) && ok) vals.push_back(v.toDouble());
sender()->objectName() == "pbApplyWlens" ? tgt = QString("$2/FEL0%1_IOM_wavelengths").arg(m_fel0x) :
......@@ -87,8 +100,60 @@ void I0mapmon::applyWavelenX() {
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->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 @@
#include <qulogimpl.h>
#include <cucontrolsfactorypool.h>
class CumbiaPool;
class CuData;
// cumbia
class CheckableComboBoxModel;
namespace Ui {
class I0mapmon;
}
......@@ -24,7 +27,11 @@ public:
private slots:
void onNamesReady(const QStringList& n);
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:
Ui::I0mapmon *ui;
......@@ -36,6 +43,11 @@ private:
// cumbia
int m_fel0x;
CheckableComboBoxModel* m_cb_model;
// methods
void m_setup_x_list();
};
#endif // I0mapmon_H
......@@ -14,10 +14,59 @@
<string>I0mapmon</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0" colspan="4">
<widget class="QuSpectrumPlot" name="quSpectrumPlot"/>
<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="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 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">
<item>
<widget class="QLabel" name="label_2">
......@@ -60,9 +109,9 @@
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="label_6">
<property name="text">
<string>N. Samples:</string>
<string>lambdas</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
......@@ -70,78 +119,53 @@
</widget>
</item>
<item>
<widget class="QuInputOutput" name="quInputOutput">
<widget class="QuComboBox" name="qucblambda">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" 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>
<item>
<widget class="QLabel" name="quleWlens">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QuLabel" name="qulWlens"/>
</item>
<item row="3" column="2">
<widget class="QuLineEdit" name="quleWlens"/>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="pbApplyWlens">
<item>
<widget class="QPushButton" name="pbPlotReconf">
<property name="text">
<string>APPLY</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Wavelen weights:</string>
<string>N. Samples:</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="qulWlenWei"/>
</item>
<item row="4" column="2">
<widget class="QuLineEdit" name="quleWlenWei"/>
</item>
<item row="4" column="3">
<widget class="QPushButton" name="pbApplyWlenWei">
<property name="text">
<string>APPLY</string>
<item>
<widget class="QuInputOutput" name="quInputOutput">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<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>
</layout>
</item>
<item row="1" column="0" colspan="6">
<widget class="QuSpectrumPlot" name="quSpectrumPlot"/>
</item>
</layout>
</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