Commit 58e74052 authored by Giacomo Strangolino's avatar Giacomo Strangolino
Browse files

progress

parent 34e7cd22
......@@ -11,10 +11,12 @@ DEFINES -= QT_NO_DEBUG_OUTPUT
SOURCES += src/main.cpp \
src/checkablecomboboxmodel.cpp \
src/i0mapmon.cpp
src/i0mapmon.cpp \
src/i0mmonplot.cpp
HEADERS += src/i0mapmon.h \
src/checkablecomboboxmodel.h
src/checkablecomboboxmodel.h \
src/i0mmonplot.h
# cuuimake runs uic
# FORMS = src/i0mapmon.ui
......
......@@ -59,12 +59,12 @@ I0mapmon::I0mapmon(CumbiaPool *cumbia_pool, QWidget *parent) :
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);
ui->plot->setYLowerBound(-1.0);
ui->plot->setYUpperBound(1.0);
ui->plot->setXLowerBound(-1.0);
ui->plot->setXUpperBound(1.0);
// autoscale
ui->quSpectrumPlot->setYAxisAutoscaleEnabled(true);
ui->plot->setYAxisAutoscaleEnabled(true);
m_setup_x_list();
......@@ -79,6 +79,7 @@ I0mapmon::~I0mapmon()
}
void I0mapmon::onNamesReady(const QStringList &n) {
qDebug() << __PRETTY_FUNCTION__ << n;
ui->qucby->clear();
ui->qucby->insertItems(0, n);
if(n.size()) {
......@@ -101,9 +102,7 @@ void I0mapmon::applyWavelenX() {
}
void I0mapmon::onYChanged(const QString &y) {
ui->quSpectrumPlot->unsetSources();
ui->quSpectrumPlot->clearPlot();
ui->quSpectrumPlot->setSource("$1/" + y);
}
void I0mapmon::onWlensChanged(const CuData &da) {
......@@ -126,6 +125,7 @@ void I0mapmon::onWlenSelectionChanged(const QString& , bool ) {
wlens.append(it->text());
}
ui->quleWlens->setText(wlens.join(","));
ui->qucblambda->setItemText(0, ui->quleWlens->text());
}
void I0mapmon::m_setup_x_list() {
......@@ -140,20 +140,28 @@ void I0mapmon::m_setup_x_list() {
// "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->setItemData(ui->qucbx->count() - 1, "pos/diagnostics/photo_current_pos.01->GetArea3", Qt::UserRole + 1);
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->setItemData(ui->qucbx->count() - 1, "pos/diagnostics/photo_current_pos.01->GetArea2", Qt::UserRole + 1);
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->setItemData(ui->qucbx->count() - 1, "srv-tf-srf:20000/ec-tf-esa-01/v1720/1000000->GetArea4", Qt::UserRole + 1);
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->setItemData(ui->qucbx->count() - 1, "pos/pesp/ccd-pesp_pos.01/Intensity", Qt::UserRole + 1);
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->setItemData(ui->qucbx->count() - 1, "pos/diagnostics/pico_pos.01/GetIc", Qt::UserRole + 1);
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);
ui->qucbx->setItemData(ui->qucbx->count() - 1, "pos/diagnostics/pico_pos.01/GetId", Qt::UserRole + 1);
}
QList<int> I0mapmon::m_selected_wlens() const {
QList<int> idxs;
for(int i = 0; i < m_cb_model->rowCount(); i++)
if(m_cb_model->item(i)->data(Qt::CheckStateRole).toBool()) idxs << i;
return idxs;
}
void I0mapmon::m_plot_reconf() {
qDebug() << __PRETTY_FUNCTION__ << "reconfiguring plot with X " << ui->qucbx->currentText()
<< ui->qucby->currentText() << ui->quleWlens->text();
const QString& srcx = ui->qucbx->itemData(ui->qucbx->currentIndex(), Qt::UserRole + 1).toString();
const QString& devy = ui->quionSamples->source().section('/', 0, 2);
ui->plot->setSources(srcx, devy + '/' + ui->qucby->currentText(), m_selected_wlens(), ui->quionSamples->findChild<QuLabel *>()->text().toInt());
}
......@@ -48,6 +48,8 @@ private:
// methods
void m_setup_x_list();
constexpr QList<int> m_selected_wlens() const;
};
#endif // I0mapmon_H
......@@ -46,6 +46,12 @@
</item>
<item row="0" column="1" colspan="5">
<widget class="QLabel" name="lTitle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
......@@ -153,19 +159,29 @@
</widget>
</item>
<item>
<widget class="QuInputOutput" name="quInputOutput">
<widget class="QuInputOutput" name="quionSamples">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="source">
<string>$1/numAverage</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="6">
<widget class="QuSpectrumPlot" name="quSpectrumPlot"/>
<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>
</layout>
</widget>
......@@ -181,11 +197,6 @@
<extends>QComboBox</extends>
<header>qucombobox.h</header>
</customwidget>
<customwidget>
<class>QuSpectrumPlot</class>
<extends>QFrame</extends>
<header>quspectrumplot.h</header>
</customwidget>
<customwidget>
<class>QuInputOutput</class>
<extends>QFrame</extends>
......@@ -196,6 +207,12 @@
<extends>QLineEdit</extends>
<header>qulineedit.h</header>
</customwidget>
<customwidget>
<class>I0MMonPlot</class>
<extends>QWidget</extends>
<header>i0mmonplot.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
#include "i0mmonplot.h"
#include <cumbiapool.h>
#include <cucontrolsfactorypool.h>
#include <quplotcurve.h>
#include <cupluginloader.h>
#include <qumultireaderplugininterface.h>
#include <cumacros.h>
#include <QtDebug>
#ifdef QUMBIA_TANGO_CONTROLS_VERSION
#include <cutreader.h>
#endif
I0MMonPlot::I0MMonPlot(QWidget *parent, CumbiaPool *cup, const CuControlsFactoryPool &fpoo)
: QuPlotBase(parent) {
m_ctrl_fpool = fpoo;
m_cu_poo = cup;
CuPluginLoader plo;
QObject *plugin_qob;
m_multiread_plu_i = plo.get<QuMultiReaderPluginInterface>("libcumbia-multiread-plugin.so", &plugin_qob);
if(!m_multiread_plu_i)
perr("I0MMonPlot: failed to load plugin \"libcumbia-multiread-plugin.so\"");
else {
int mode = 0;
#ifdef QUMBIA_TANGO_CONTROLS_VERSION
mode = CuTReader::Manual;
#endif
m_multiread_plu_i->init(cup, fpoo, mode); // 0 sync mode
connect(m_multiread_plu_i->get_qobject(), SIGNAL(onSeqReadComplete(const QList<CuData> &)),
this, SLOT(onDataReady(const QList<CuData> &)));
}
}
bool I0MMonPlot::pluginLoaded() const {
return m_multiread_plu_i != nullptr;
}
void I0MMonPlot::onDataReady(const QList<CuData> &dl) {
foreach(const CuData& d, dl)
printf("- %s\n", datos(d));
}
void I0MMonPlot::setSources(const QString &x, const QString &y, QList<int> lambda_idxs, int nsamples)
{
qDebug() << __PRETTY_FUNCTION__ << x << y << lambda_idxs;
QuPlotBase::clearPlot();
QuPlotCurve *c = new QuPlotCurve(y);
if(m_multiread_plu_i ) {
m_multiread_plu_i->insertSource(x, 0);
m_multiread_plu_i->insertSource(y, 1);
}
}
#ifndef I0MMONPLOT_H
#define I0MMONPLOT_H
#include <cucontrolsfactorypool.h>
#include <quplot_base.h>
#include <cudata.h>
#include <QString>
class CumbiaPool;
class QuMultiReaderPluginInterface;
class I0MMonPlot : public QuPlotBase
{
Q_OBJECT
public:
explicit I0MMonPlot(QWidget *parent, CumbiaPool *cup, const CuControlsFactoryPool & fpoo);
bool pluginLoaded() const;
signals:
public slots:
void onDataReady(const QList<CuData> & dl);
void setSources(const QString& x, const QString& y, QList<int> lambda_idxs, int nsamples);
private:
CumbiaPool *m_cu_poo;
CuControlsFactoryPool m_ctrl_fpool;
QuMultiReaderPluginInterface *m_multiread_plu_i;
};
#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