mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
gui works, including clone plots
This commit is contained in:
@ -1,165 +1,82 @@
|
||||
#include "qCloneWidget.h"
|
||||
#include "qDefs.h"
|
||||
#include "SlsQt1DPlot.h"
|
||||
#include "SlsQt2DPlotLayout.h"
|
||||
#include "SlsQt2DPlot.h"
|
||||
|
||||
#include "qwt_symbol.h"
|
||||
#include <QWidget>
|
||||
#include <QCloseEvent>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QAction>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QPushButton>
|
||||
#include <QSpacerItem>
|
||||
#include <QFileDialog>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include <qwt_text.h>
|
||||
|
||||
qCloneWidget::qCloneWidget(QWidget *parent, int id, QString title, QString xTitle, QString yTitle, QString zTitle,
|
||||
int numDim, QString fPath, QString fName, int iIndex, bool displayStats, QString min, QString max, QString sum) :
|
||||
QMainWindow(parent), id(id), filePath(fPath), fileName(fName), imageIndex(iIndex), cloneplot1D(nullptr), cloneplot2D(nullptr),
|
||||
marker(nullptr), nomarker(nullptr), mainLayout(nullptr), boxPlot(nullptr), lblHistTitle(nullptr) {
|
||||
// Window title
|
||||
char winTitle[300], currTime[50];
|
||||
strcpy(currTime, NowTime().c_str());
|
||||
sprintf(winTitle, "Snapshot:%d - %s", id, currTime);
|
||||
setWindowTitle(QString(winTitle));
|
||||
int qCloneWidget::NumClones{0};
|
||||
|
||||
marker = new QwtSymbol();
|
||||
nomarker = new QwtSymbol();
|
||||
marker->setStyle(QwtSymbol::Cross);
|
||||
marker->setSize(5, 5);
|
||||
|
||||
// Set up widget
|
||||
SetupWidgetWindow(title, xTitle, yTitle, zTitle, numDim);
|
||||
qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot* p1, SlsQt2DPlot* p2, SlsQt2DPlot* gp,
|
||||
QString title, QString fPath, QString fName, int64_t aIndex,
|
||||
bool displayStats, QString min, QString max, QString sum):
|
||||
QMainWindow(parent), plot1d(p1), plot2d(p2), gainplot2d(gp), filePath(fPath), fileName(fName), acqIndex(aIndex) {
|
||||
setupUi(this);
|
||||
id = qCloneWidget::NumClones++;
|
||||
SetupWidgetWindow(title);
|
||||
DisplayStats(displayStats, min, max, sum);
|
||||
}
|
||||
|
||||
qCloneWidget::~qCloneWidget() {
|
||||
if (cloneplot1D)
|
||||
delete cloneplot1D;
|
||||
if (cloneplot2D)
|
||||
delete cloneplot2D;
|
||||
cloneplot1D_hists.clear();
|
||||
if (marker)
|
||||
delete marker;
|
||||
if (nomarker)
|
||||
delete nomarker;
|
||||
if (mainLayout)
|
||||
delete mainLayout;
|
||||
if (boxPlot)
|
||||
delete boxPlot;
|
||||
if (lblHistTitle)
|
||||
delete lblHistTitle;
|
||||
if (plot1d)
|
||||
delete plot1d;
|
||||
if (plot2d)
|
||||
delete plot2d;
|
||||
if (gainplot2d)
|
||||
delete gainplot2d;
|
||||
}
|
||||
|
||||
SlsQt1DPlot* qCloneWidget::Get1dPlot() {
|
||||
return cloneplot1D;
|
||||
}
|
||||
void qCloneWidget::SetupWidgetWindow(QString title) {
|
||||
|
||||
void qCloneWidget::SetupWidgetWindow(QString title, QString xTitle, QString yTitle, QString zTitle, int numDim) {
|
||||
|
||||
QMenuBar* menubar = new QMenuBar(this);
|
||||
QAction* actionSave = new QAction("&Save", this);
|
||||
menubar->addAction(actionSave);
|
||||
setMenuBar(menubar);
|
||||
|
||||
//Main Window Layout
|
||||
QWidget *centralWidget = new QWidget(this);
|
||||
mainLayout = new QGridLayout(centralWidget);
|
||||
centralWidget->setLayout(mainLayout);
|
||||
|
||||
//plot group box
|
||||
boxPlot = new QGroupBox(this);
|
||||
QGridLayout* plotLayout = new QGridLayout(boxPlot);
|
||||
boxPlot->setLayout(plotLayout);
|
||||
boxPlot->setAlignment(Qt::AlignHCenter);
|
||||
boxPlot->setFont(QFont("Sans Serif", 11, QFont::Normal));
|
||||
boxPlot->setTitle(title);
|
||||
boxPlot->setContentsMargins(0, 0, 0, 0);
|
||||
std::string winTitle = std::string("Snapshot:") + std::to_string(id) + std::string(" - ") + NowTime();
|
||||
setWindowTitle(QString(winTitle.c_str()));
|
||||
|
||||
// According to dimensions, create appropriate 1D or 2Dplot
|
||||
if (numDim == 1) {
|
||||
cloneplot1D = new SlsQt1DPlot(boxPlot);
|
||||
|
||||
cloneplot1D->setFont(QFont("Sans Serif", 9, QFont::Normal));
|
||||
cloneplot1D->SetXTitle(xTitle.toAscii().constData());
|
||||
cloneplot1D->SetYTitle(yTitle.toAscii().constData());
|
||||
|
||||
boxPlot->setFlat(false);
|
||||
boxPlot->setContentsMargins(0, 30, 0, 0);
|
||||
plotLayout->addWidget(cloneplot1D, 0, 0);
|
||||
|
||||
lblHistTitle = new QLabel("");
|
||||
mainLayout->addWidget(lblHistTitle, 0, 0);
|
||||
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
boxPlot->setTitle(title);
|
||||
|
||||
// 1d
|
||||
if (plot1d != nullptr) {
|
||||
plotLayout->addWidget(plot1d);
|
||||
}
|
||||
// 2d
|
||||
else {
|
||||
if (gainplot2d == nullptr) {
|
||||
plotLayout->addWidget(plot2d);
|
||||
} else {
|
||||
gainplot2d->setFixedWidth(plot2d->width() / 4);
|
||||
gainplot2d->setFixedHeight(plot2d->height() / 4);
|
||||
plotLayout->addWidget(plot2d, 0, 0, 4, 4);
|
||||
plotLayout->addWidget(gainplot2d, 0, 4, 1, 1);
|
||||
}
|
||||
}
|
||||
connect(actionSaveClone, SIGNAL(triggered()), this, SLOT(SavePlot()));
|
||||
}
|
||||
|
||||
void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString sum) {
|
||||
if (enable) {
|
||||
lblMinDisp->setText(QString("%1").arg(min));
|
||||
lblMaxDisp->setText(QString("%1").arg(max));
|
||||
lblSumDisp->setText(QString("%1").arg(sum));
|
||||
widgetStatistics->show();
|
||||
} else {
|
||||
cloneplot2D = new SlsQt2DPlotLayout(boxPlot);
|
||||
cloneplot2D->setFont(QFont("Sans Serif", 9, QFont::Normal));
|
||||
cloneplot2D->SetXTitle(xTitle);
|
||||
cloneplot2D->SetYTitle(yTitle);
|
||||
cloneplot2D->SetZTitle(zTitle);
|
||||
cloneplot2D->setAlignment(Qt::AlignLeft);
|
||||
|
||||
boxPlot->setFlat(true);
|
||||
boxPlot->setContentsMargins(0, 20, 0, 0);
|
||||
plotLayout->addWidget(cloneplot2D, 0, 0);
|
||||
}
|
||||
|
||||
// main window widgets
|
||||
mainLayout->addWidget(boxPlot, 1, 0);
|
||||
setCentralWidget(centralWidget);
|
||||
|
||||
// Save
|
||||
connect(actionSave, SIGNAL(triggered()), this, SLOT(SavePlot()));
|
||||
|
||||
setMinimumHeight(300);
|
||||
resize(500, 350);
|
||||
}
|
||||
|
||||
void qCloneWidget::SetCloneHists(unsigned int nHists, int histNBins, double *histXAxis, std::vector<double*> histYAxis, QString histTitle, bool lines, bool markers) {
|
||||
//for each plot, create hists
|
||||
for (unsigned int hist_num = 0; hist_num < nHists; ++hist_num) {
|
||||
SlsQtH1D *h = new SlsQtH1D("1d plot", histNBins, histXAxis, histYAxis[hist_num]);
|
||||
h->SetLineColor(0);
|
||||
h->setStyle(lines ? QwtPlotCurve::Lines : QwtPlotCurve::Dots);
|
||||
#if QWT_VERSION < 0x060000
|
||||
h->setSymbol(markers ? *marker : *nomarker);
|
||||
#else
|
||||
h->setSymbol(markers ? marker : nomarker);
|
||||
#endif
|
||||
cloneplot1D_hists.append(h);
|
||||
h->Attach(cloneplot1D);
|
||||
|
||||
lblHistTitle->setText(histTitle);
|
||||
widgetStatistics->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void qCloneWidget::SetCloneHists2D(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double *d, QString frameIndexTitle, bool isZmax, bool isZmin, double zmin, double zmax) {
|
||||
cloneplot2D->GetPlot()->SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d);
|
||||
cloneplot2D->setTitle(frameIndexTitle.toAscii().constData());
|
||||
cloneplot2D->SetZRange(isZmin, isZmax, zmin, zmax);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void qCloneWidget::SavePlot() {
|
||||
char cID[10];
|
||||
sprintf(cID, "%d", id);
|
||||
//title
|
||||
QString fName = filePath + QString('/') + fileName + QString('_') + imageIndex + QString('_') + QString(NowTime().c_str()) + QString(".png");
|
||||
FILE_LOG(logDEBUG) << "fname:" << fName.toAscii().constData();
|
||||
QString fName = filePath + QString('/') + fileName + QString("_clone") + QString("%1").arg(id) + QString("_acq") + QString("%1").arg(acqIndex) + QString(".png");
|
||||
FILE_LOG(logINFO) << "Saving Clone:" << fName.toAscii().constData();
|
||||
//save
|
||||
QImage img(boxPlot->size().width(), boxPlot->size().height(), QImage::Format_RGB32);
|
||||
QImage img(centralwidget->size().width(), centralwidget->size().height(), QImage::Format_RGB32);
|
||||
QPainter painter(&img);
|
||||
boxPlot->render(&painter);
|
||||
centralwidget->render(&painter);
|
||||
|
||||
fName = QFileDialog::getSaveFileName(this, tr("Save Snapshot "), fName, tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), 0, QFileDialog::ShowDirsOnly);
|
||||
if (!fName.isEmpty()) {
|
||||
@ -172,63 +89,3 @@ void qCloneWidget::SavePlot() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int qCloneWidget::SavePlotAutomatic() {
|
||||
char cID[10];
|
||||
sprintf(cID, "%d", id);
|
||||
//title
|
||||
QString fName = filePath + QString('/') + fileName + QString('_') + imageIndex + QString('_') + QString(NowTime().c_str()) + QString(".png");
|
||||
FILE_LOG(logDEBUG) << "fname:" << fName.toAscii().constData();
|
||||
//save
|
||||
QImage img(boxPlot->size().width(), boxPlot->size().height(), QImage::Format_RGB32);
|
||||
QPainter painter(&img);
|
||||
boxPlot->render(&painter);
|
||||
if (img.save(fName))
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
void qCloneWidget::closeEvent(QCloseEvent *event) {
|
||||
emit CloneClosedSignal(id);
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString sum) {
|
||||
if (enable) {
|
||||
QWidget *widgetStatistics = new QWidget(this);
|
||||
widgetStatistics->setFixedHeight(15);
|
||||
QHBoxLayout *hl1 = new QHBoxLayout;
|
||||
hl1->setSpacing(0);
|
||||
hl1->setContentsMargins(0, 0, 0, 0);
|
||||
QLabel *lblMin = new QLabel("Min: ");
|
||||
lblMin->setFixedWidth(40);
|
||||
lblMin->setAlignment(Qt::AlignRight);
|
||||
QLabel *lblMax = new QLabel("Max: ");
|
||||
lblMax->setFixedWidth(40);
|
||||
lblMax->setAlignment(Qt::AlignRight);
|
||||
QLabel *lblSum = new QLabel("Sum: ");
|
||||
lblSum->setFixedWidth(40);
|
||||
lblSum->setAlignment(Qt::AlignRight);
|
||||
QLabel *lblMinDisp = new QLabel(min);
|
||||
lblMinDisp->setAlignment(Qt::AlignLeft);
|
||||
QLabel *lblMaxDisp = new QLabel(max);
|
||||
lblMaxDisp->setAlignment(Qt::AlignLeft);
|
||||
QLabel *lblSumDisp = new QLabel(sum);
|
||||
lblSumDisp->setAlignment(Qt::AlignLeft);
|
||||
hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
hl1->addWidget(lblMin);
|
||||
hl1->addWidget(lblMinDisp);
|
||||
hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
hl1->addWidget(lblMax);
|
||||
hl1->addWidget(lblMaxDisp);
|
||||
hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
hl1->addWidget(lblSum);
|
||||
hl1->addWidget(lblSumDisp);
|
||||
hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
widgetStatistics->setLayout(hl1);
|
||||
mainLayout->addWidget(widgetStatistics, 2, 0);
|
||||
widgetStatistics->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
93
slsDetectorGui/src/qDacWidget.cpp
Executable file
93
slsDetectorGui/src/qDacWidget.cpp
Executable file
@ -0,0 +1,93 @@
|
||||
#include "qDacWidget.h"
|
||||
#include "qDefs.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
qDacWidget::qDacWidget(QWidget *parent, multiSlsDetector *detector, bool d, std::string n, slsDetectorDefs::dacIndex i, bool t) :
|
||||
QWidget(parent), myDet(detector), isDac(d), index(i), isMillideg(t) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow(n);
|
||||
}
|
||||
|
||||
qDacWidget::~qDacWidget() {}
|
||||
|
||||
void qDacWidget::SetupWidgetWindow(std::string name) {
|
||||
lblDac->setText(name.c_str());
|
||||
if (isDac) {
|
||||
spinDac->setDecimals(0);
|
||||
} else {
|
||||
spinDac->setSuffix(0x00b0 + QString("C"));
|
||||
spinDac->setReadOnly(true);
|
||||
lblDacmV->setMinimumWidth(0);
|
||||
lblDacmV->setMaximumWidth(0);
|
||||
}
|
||||
Initialization();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
void qDacWidget::Initialization() {
|
||||
if (isDac) {
|
||||
connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
|
||||
}
|
||||
}
|
||||
|
||||
void qDacWidget::SetDetectorIndex(int id) {
|
||||
detectorIndex = id;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void qDacWidget::GetDac() {
|
||||
FILE_LOG(logDEBUG) << "Getting Dac " << index;
|
||||
|
||||
disconnect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
|
||||
try {
|
||||
// dac units
|
||||
auto retval = myDet->setDAC(-1, index, 0, detectorIndex);
|
||||
spinDac->setValue(retval);
|
||||
// mv
|
||||
retval = myDet->setDAC(-1, index, 1, detectorIndex);
|
||||
lblDacmV->setText(QString("%1mV").arg(retval -10));
|
||||
} CATCH_DISPLAY(std::string("Could not get dac ") + std::to_string(index), "qDacWidget::GetDac")
|
||||
|
||||
connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
|
||||
}
|
||||
|
||||
|
||||
void qDacWidget::SetDac() {
|
||||
int val = (int)spinDac->value();
|
||||
FILE_LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data() << " : " << val;
|
||||
|
||||
try {
|
||||
myDet->setDAC(val, index, 0, detectorIndex);
|
||||
} CATCH_DISPLAY (std::string("Could not set dac ") + std::to_string(index), "qDacWidget::SetDac")
|
||||
|
||||
// update mV anyway
|
||||
GetDac();
|
||||
}
|
||||
|
||||
void qDacWidget::GetAdc() {
|
||||
FILE_LOG(logDEBUG) << "Getting ADC " << index;
|
||||
|
||||
try {
|
||||
auto retval = myDet->getADC(index, detectorIndex);
|
||||
if (retval == -1 && detectorIndex == -1) {
|
||||
spinDac->setValue(-1);
|
||||
} else {
|
||||
if (isMillideg) {
|
||||
retval /= 1000.00;
|
||||
}
|
||||
spinDac->setValue(retval);
|
||||
}
|
||||
} CATCH_DISPLAY (std::string("Could not get adc ") + std::to_string(index), "qDacWidget::GetAdc")
|
||||
|
||||
}
|
||||
|
||||
void qDacWidget::Refresh() {
|
||||
if (isDac) {
|
||||
GetDac();
|
||||
} else {
|
||||
GetAdc();
|
||||
}
|
||||
}
|
||||
|
@ -142,6 +142,7 @@ qDetectorMain::~qDetectorMain() {
|
||||
}
|
||||
|
||||
void qDetectorMain::SetUpWidgetWindow() {
|
||||
setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
|
||||
// plot setup
|
||||
myPlot = new qDrawPlot(dockWidgetPlot, myDet);
|
||||
|
@ -1,20 +1,18 @@
|
||||
#include "qDrawPlot.h"
|
||||
|
||||
#include "SlsQt1DPlot.h"
|
||||
#include "SlsQt2DPlotLayout.h"
|
||||
#include "SlsQt2DPlot.h"
|
||||
#include "detectorData.h"
|
||||
#include "qCloneWidget.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QFileDialog>
|
||||
#include <QPainter>
|
||||
#include <QtConcurrentRun>
|
||||
|
||||
|
||||
|
||||
qDrawPlot::qDrawPlot(QWidget *parent, multiSlsDetector *detector)
|
||||
: QWidget(parent), myDet(detector) {
|
||||
qDrawPlot::qDrawPlot(QWidget *parent, multiSlsDetector *detector) : QWidget(parent), myDet(detector) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logINFO) << "Plots ready";
|
||||
}
|
||||
@ -46,39 +44,11 @@ qDrawPlot::~qDrawPlot() {
|
||||
if (pedestalVals)
|
||||
delete [] pedestalVals;
|
||||
if (tempPedestalVals)
|
||||
delete [] tempPedestalVals;
|
||||
|
||||
for (auto &it : cloneWidgets) {
|
||||
delete it;
|
||||
}
|
||||
|
||||
if (lblFrameIndexTitle1d)
|
||||
delete lblFrameIndexTitle1d;
|
||||
if (boxPlot)
|
||||
delete boxPlot;
|
||||
if (layout)
|
||||
delete layout;
|
||||
if (plotLayout)
|
||||
delete plotLayout;
|
||||
if (widgetStatistics)
|
||||
delete widgetStatistics;
|
||||
if (lblMinDisp)
|
||||
delete lblMinDisp;
|
||||
if (lblMaxDisp)
|
||||
delete lblMaxDisp;
|
||||
if (lblSumDisp)
|
||||
delete lblSumDisp;
|
||||
delete [] tempPedestalVals;
|
||||
}
|
||||
|
||||
void qDrawPlot::SetupWidgetWindow() {
|
||||
|
||||
detType = myDet->getDetectorTypeAsEnum();
|
||||
pthread_mutex_init(&lastImageCompleteMutex, NULL);
|
||||
|
||||
// frame index 1d
|
||||
lblFrameIndexTitle1d = new QLabel("");
|
||||
lblFrameIndexTitle1d->setFixedHeight(10);
|
||||
|
||||
// save
|
||||
try {
|
||||
std::string temp = myDet->getFilePath();
|
||||
@ -92,11 +62,9 @@ void qDrawPlot::SetupWidgetWindow() {
|
||||
}
|
||||
|
||||
SetupPlots();
|
||||
SetupStatistics();
|
||||
SetDataCallBack(true);
|
||||
myDet->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), this);
|
||||
myDet->registerProgressCallback(&(GetProgressCallBack), this);
|
||||
|
||||
// future watcher to watch result of AcquireThread only because it uses signals/slots to handle acquire exception
|
||||
acqResultWatcher = new QFutureWatcher<std::string>();
|
||||
|
||||
@ -108,44 +76,8 @@ void qDrawPlot::Initialization() {
|
||||
connect(acqResultWatcher, SIGNAL(finished()), this, SLOT(AcquireFinished()));
|
||||
}
|
||||
|
||||
void qDrawPlot::SetupStatistics() {
|
||||
widgetStatistics = new QWidget(this);
|
||||
widgetStatistics->setFixedHeight(15);
|
||||
QHBoxLayout *hl1 = new QHBoxLayout;
|
||||
hl1->setSpacing(0);
|
||||
hl1->setContentsMargins(0, 0, 0, 0);
|
||||
QLabel *lblMin = new QLabel("Min: ");
|
||||
lblMin->setFixedWidth(40);
|
||||
lblMin->setAlignment(Qt::AlignRight);
|
||||
QLabel *lblMax = new QLabel("Max: ");
|
||||
lblMax->setFixedWidth(40);
|
||||
lblMax->setAlignment(Qt::AlignRight);
|
||||
QLabel *lblSum = new QLabel("Sum: ");
|
||||
lblSum->setFixedWidth(40);
|
||||
lblSum->setAlignment(Qt::AlignRight);
|
||||
lblMinDisp = new QLabel("-");
|
||||
lblMinDisp->setAlignment(Qt::AlignLeft);
|
||||
lblMaxDisp = new QLabel("-");
|
||||
lblMaxDisp->setAlignment(Qt::AlignLeft);
|
||||
lblSumDisp = new QLabel("-");
|
||||
lblSumDisp->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
lblSumDisp->setAlignment(Qt::AlignLeft);
|
||||
hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
hl1->addWidget(lblMin);
|
||||
hl1->addWidget(lblMinDisp);
|
||||
hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
hl1->addWidget(lblMax);
|
||||
hl1->addWidget(lblMaxDisp);
|
||||
hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
hl1->addWidget(lblSum);
|
||||
hl1->addWidget(lblSumDisp);
|
||||
hl1->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
widgetStatistics->setLayout(hl1);
|
||||
layout->addWidget(widgetStatistics, 2, 0);
|
||||
widgetStatistics->hide();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetupPlots() {
|
||||
setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
// default image size
|
||||
nPixelsX = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::X);
|
||||
nPixelsY = myDet->getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::Y);
|
||||
@ -158,17 +90,8 @@ void qDrawPlot::SetupPlots() {
|
||||
FILE_LOG(logINFO) << "nPixelsX:" << nPixelsX;
|
||||
FILE_LOG(logINFO) << "nPixelsY:" << nPixelsY;
|
||||
|
||||
// plot layout
|
||||
layout = new QGridLayout;
|
||||
this->setLayout(layout);
|
||||
setFont(QFont("Sans Serif", 9));
|
||||
boxPlot = new QGroupBox("");
|
||||
layout->addWidget(boxPlot, 1, 0);
|
||||
boxPlot->setAlignment(Qt::AlignHCenter);
|
||||
boxPlot->setFont(QFont("Sans Serif", 11, QFont::Normal));
|
||||
boxPlot->setTitle("Sample Plot");
|
||||
boxPlot->setFlat(true);
|
||||
boxPlot->setContentsMargins(0, 15, 0, 0);
|
||||
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
widgetStatistics->hide();
|
||||
|
||||
// setup 1d data
|
||||
if (datax1d)
|
||||
@ -194,9 +117,13 @@ void qDrawPlot::SetupPlots() {
|
||||
hists1d.append(h);
|
||||
// setup 1d plot
|
||||
plot1d = new SlsQt1DPlot(boxPlot);
|
||||
plot1d->setFont(QFont("Sans Serif", 9, QFont::Normal));
|
||||
plot1d->SetXTitle(xTitle1d.toAscii().constData());
|
||||
plot1d->SetYTitle(yTitle1d.toAscii().constData());
|
||||
plot1d->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
plot1d->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
plot1d->SetXFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
plot1d->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
plot1d->SetTitle("--");
|
||||
plot1d->SetXTitle(xTitle1d);
|
||||
plot1d->SetYTitle(yTitle1d);
|
||||
plot1d->hide();
|
||||
h->Attach(plot1d);
|
||||
|
||||
@ -222,29 +149,30 @@ void qDrawPlot::SetupPlots() {
|
||||
pow(double(py) - nPixelsY / 2, 2) / pow(nPixelsY / 2, 2)) /
|
||||
sqrt(2);
|
||||
// setup 2d plot
|
||||
plot2d = new SlsQt2DPlotLayout(boxPlot);
|
||||
plot2d->setFont(QFont("Sans Serif", 9, QFont::Normal));
|
||||
plot2d->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY,
|
||||
plot2d = new SlsQt2DPlot(boxPlot);
|
||||
plot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY,
|
||||
-0.5, nPixelsY - 0.5, data2d);
|
||||
plot2d->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
plot2d->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
plot2d->SetXFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
plot2d->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
plot2d->SetZFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
plot2d->setTitle("");
|
||||
plot2d->SetXTitle(xTitle2d);
|
||||
plot2d->SetYTitle(yTitle2d);
|
||||
plot2d->SetZTitle(zTitle2d);
|
||||
plot2d->setAlignment(Qt::AlignLeft);
|
||||
gainplot2d = new SlsQt2DPlotLayout(boxPlot);
|
||||
gainplot2d->setFont(QFont("Sans Serif", 9, QFont::Normal));
|
||||
gainplot2d->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY,
|
||||
plot2d->SetZTitle(zTitle2d);
|
||||
|
||||
gainplot2d = new SlsQt2DPlot(boxPlot);
|
||||
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY,
|
||||
-0.5, nPixelsY - 0.5, gainData);
|
||||
gainplot2d->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
gainplot2d->setTitle("");
|
||||
gainplot2d->setAlignment(Qt::AlignLeft);
|
||||
gainplot2d->GetPlot()->enableAxis(0, false);
|
||||
gainplot2d->GetPlot()->enableAxis(1, false);
|
||||
gainplot2d->GetPlot()->enableAxis(2, false);
|
||||
gainplot2d->enableAxis(0, false);
|
||||
gainplot2d->enableAxis(1, false);
|
||||
gainplot2d->enableAxis(2, false);
|
||||
gainplot2d->hide();
|
||||
|
||||
// layout of plots
|
||||
plotLayout = new QGridLayout(boxPlot);
|
||||
plotLayout->setContentsMargins(0, 0, 0, 0);
|
||||
plotLayout->addWidget(plot1d, 0, 0, 4, 4);
|
||||
plotLayout->addWidget(plot2d, 0, 0, 4, 4);
|
||||
plotLayout->addWidget(gainplot2d, 0, 4, 1, 1);
|
||||
@ -270,24 +198,18 @@ void qDrawPlot::Select1dPlot(bool enable) {
|
||||
if (enable) {
|
||||
is1d = true;
|
||||
// DetachHists(); it clears the last measurement
|
||||
plot1d->SetXTitle(xTitle1d.toAscii().constData());
|
||||
plot1d->SetYTitle(yTitle1d.toAscii().constData());
|
||||
plot1d->SetXTitle(xTitle1d);
|
||||
plot1d->SetYTitle(yTitle1d);
|
||||
plot1d->show();
|
||||
plot2d->hide();
|
||||
boxPlot->setFlat(false);
|
||||
layout->addWidget(lblFrameIndexTitle1d, 0, 0);
|
||||
plotLayout->setContentsMargins(10, 10, 10, 10);
|
||||
} else {
|
||||
is1d = false;
|
||||
plot2d->SetTitle("");
|
||||
plot2d->SetXTitle(xTitle2d);
|
||||
plot2d->SetYTitle(yTitle2d);
|
||||
plot2d->SetZTitle(zTitle2d);
|
||||
plot1d->hide();
|
||||
plot2d->show();
|
||||
boxPlot->setFlat(true);
|
||||
lblFrameIndexTitle1d->setText("");
|
||||
layout->removeWidget(lblFrameIndexTitle1d);
|
||||
plotLayout->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,28 +261,28 @@ double qDrawPlot::GetXMinimum() {
|
||||
if (is1d)
|
||||
return plot1d->GetXMinimum();
|
||||
else
|
||||
return plot2d->GetPlot()->GetXMinimum();
|
||||
return plot2d->GetXMinimum();
|
||||
}
|
||||
|
||||
double qDrawPlot::GetXMaximum() {
|
||||
if (is1d)
|
||||
return plot1d->GetXMaximum();
|
||||
else
|
||||
return plot2d->GetPlot()->GetXMaximum();
|
||||
return plot2d->GetXMaximum();
|
||||
}
|
||||
|
||||
double qDrawPlot::GetYMinimum() {
|
||||
if (is1d)
|
||||
return plot1d->GetYMinimum();
|
||||
else
|
||||
return plot2d->GetPlot()->GetYMinimum();
|
||||
return plot2d->GetYMinimum();
|
||||
}
|
||||
|
||||
double qDrawPlot::GetYMaximum() {
|
||||
if (is1d)
|
||||
return plot1d->GetYMaximum();
|
||||
else
|
||||
return plot2d->GetPlot()->GetYMaximum();
|
||||
return plot2d->GetYMaximum();
|
||||
}
|
||||
|
||||
void qDrawPlot::SetDataCallBack(bool enable) {
|
||||
@ -391,7 +313,7 @@ void qDrawPlot::SetLines(bool enable) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Lines to " << std::boolalpha << enable << std::noboolalpha;
|
||||
isLines = enable;
|
||||
for (unsigned int i = 0; i < nHists; ++i) {
|
||||
for (int i = 0; i < nHists; ++i) {
|
||||
SlsQtH1D* h = hists1d.at(i);
|
||||
h->setStyleLinesorDots(isLines);
|
||||
}
|
||||
@ -401,7 +323,7 @@ void qDrawPlot::SetMarkers(bool enable) {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
FILE_LOG(logINFO) << "Setting Markers to " << std::boolalpha << enable << std::noboolalpha;
|
||||
isMarkers = enable;
|
||||
for (unsigned int i = 0; i < nHists; ++i) {
|
||||
for (int i = 0; i < nHists; ++i) {
|
||||
SlsQtH1D* h = hists1d.at(i);
|
||||
h->setSymbolMarkers(isMarkers);
|
||||
}
|
||||
@ -474,71 +396,60 @@ void qDrawPlot::SetSaveFileName(QString val) {
|
||||
|
||||
void qDrawPlot::ClonePlot() {
|
||||
std::lock_guard<std::mutex> lock(mPlots);
|
||||
|
||||
SlsQt1DPlot* cloneplot1D = nullptr;
|
||||
SlsQt2DPlot* cloneplot2D = nullptr;
|
||||
SlsQt2DPlot* clonegainplot2D = nullptr;
|
||||
|
||||
int index = 0;
|
||||
if (is1d) {
|
||||
FILE_LOG(logINFO) << "Cloning 1D Image";
|
||||
qCloneWidget *q = new qCloneWidget(
|
||||
this, cloneWidgets.size(), boxPlot->title(), xTitle1d, yTitle1d, "", 1,
|
||||
fileSavePath, fileSaveName, currentFrame, displayStatistics, lblMinDisp->text(),
|
||||
lblMaxDisp->text(), lblSumDisp->text());
|
||||
cloneWidgets.push_back(q);
|
||||
index = cloneWidgets.size();
|
||||
cloneWidgets[index]->SetCloneHists(nHists, nPixelsX, datax1d, datay1d,
|
||||
lblFrameIndexTitle1d->text(), isLines, isMarkers);
|
||||
FILE_LOG(logDEBUG) << "Cloning 1D Image";
|
||||
cloneplot1D = new SlsQt1DPlot();
|
||||
cloneplot1D->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
cloneplot1D->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
cloneplot1D->SetXFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
cloneplot1D->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
cloneplot1D->SetTitle(plot1d->title().text());
|
||||
cloneplot1D->SetXTitle(xTitle1d);
|
||||
cloneplot1D->SetYTitle(yTitle1d);
|
||||
QVector<SlsQtH1D *> cloneplotHists1D;
|
||||
for (int iHist = 0; iHist < nHists; ++iHist) {
|
||||
SlsQtH1D *h = new SlsQtH1D("", nPixelsX, datax1d, datay1d[iHist]);
|
||||
h->SetLineColor(iHist);
|
||||
h->setStyleLinesorDots(isLines);
|
||||
h->setSymbolMarkers(isMarkers);
|
||||
cloneplotHists1D.append(h);
|
||||
h->Attach(cloneplot1D);
|
||||
}
|
||||
} else {
|
||||
FILE_LOG(logINFO) << "Cloning 2D Image";
|
||||
qCloneWidget *q = new qCloneWidget(
|
||||
this, cloneWidgets.size(), boxPlot->title(), xTitle2d, yTitle2d, zTitle2d, 2,
|
||||
fileSavePath, fileSaveName, currentFrame, displayStatistics, lblMinDisp->text(),
|
||||
lblMaxDisp->text(), lblSumDisp->text());
|
||||
cloneWidgets.push_back(q);
|
||||
index = cloneWidgets.size();
|
||||
cloneWidgets[index]->SetCloneHists2D(nPixelsX, -0.5, nPixelsX - 0.5,
|
||||
nPixelsY, -0.5, nPixelsY - 0.5,
|
||||
data2d, plot2d->title(), isZRange[0], isZRange[1], zRange[0], zRange[1]);
|
||||
}
|
||||
FILE_LOG(logDEBUG) << "Cloning 2D Image";
|
||||
cloneplot2D = new SlsQt2DPlot();
|
||||
cloneplot2D->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
cloneplot2D->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
cloneplot2D->SetXFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
cloneplot2D->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
cloneplot2D->SetZFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
cloneplot2D->setTitle(plot2d->title().text());
|
||||
cloneplot2D->SetXTitle(xTitle2d);
|
||||
cloneplot2D->SetYTitle(yTitle2d);
|
||||
cloneplot2D->SetZTitle(zTitle2d);
|
||||
cloneplot2D->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, data2d);
|
||||
cloneplot2D->SetZRange(isZRange[0], isZRange[1], zRange[0], zRange[1]);
|
||||
|
||||
cloneWidgets[index]->show();
|
||||
|
||||
// to remember which all clone widgets were closed
|
||||
connect(cloneWidgets[index], SIGNAL(CloneClosedSignal(int)), this, SLOT(CloneCloseEvent(int)));
|
||||
}
|
||||
|
||||
void qDrawPlot::CloseClones() {
|
||||
FILE_LOG(logDEBUG) << "Closing all Clones";
|
||||
for (auto &it : cloneWidgets) {
|
||||
it->close();
|
||||
}
|
||||
}
|
||||
|
||||
void qDrawPlot::CloneCloseEvent(int id) {
|
||||
FILE_LOG(logDEBUG) << "Closing Clone " << id;
|
||||
cloneWidgets.erase(cloneWidgets.begin() + id);
|
||||
}
|
||||
|
||||
void qDrawPlot::SaveClones() {
|
||||
FILE_LOG(logINFO) << "Saving all Clones";
|
||||
char errID[200];
|
||||
std::string errMessage = "The Snapshots with ID's: ";
|
||||
bool success = true;
|
||||
for (unsigned int i = 0; i < cloneWidgets.size(); ++i) {
|
||||
if (cloneWidgets[i]->SavePlotAutomatic()) {
|
||||
success = false;
|
||||
sprintf(errID, "%d", i);
|
||||
errMessage.append(std::string(errID) + std::string(", "));
|
||||
if (isGainDataExtracted) {
|
||||
clonegainplot2D = new SlsQt2DPlot();
|
||||
clonegainplot2D->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
|
||||
clonegainplot2D->enableAxis(0, false);
|
||||
clonegainplot2D->enableAxis(1, false);
|
||||
clonegainplot2D->enableAxis(2, false);
|
||||
clonegainplot2D->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData);
|
||||
clonegainplot2D->SetTitle(gainplot2d->title().text());
|
||||
}
|
||||
}
|
||||
if (success) {
|
||||
qDefs::Message(
|
||||
qDefs::INFORMATION,
|
||||
"The Snapshots have all been saved successfully in .png.", "Dock");
|
||||
} else {
|
||||
qDefs::Message(qDefs::WARNING,
|
||||
errMessage + std::string("were not saved."),
|
||||
"qDrawPlot::SaveClones");
|
||||
FILE_LOG(logWARNING) << errMessage << "were not saved";
|
||||
}
|
||||
|
||||
qCloneWidget* q = new qCloneWidget(this, cloneplot1D, cloneplot2D, clonegainplot2D,
|
||||
boxPlot->title(), fileSavePath, fileSaveName, currentAcqIndex,
|
||||
displayStatistics, lblMinDisp->text(), lblMaxDisp->text(), lblSumDisp->text());
|
||||
q->show();
|
||||
}
|
||||
|
||||
void qDrawPlot::SavePlot() {
|
||||
@ -547,10 +458,13 @@ void qDrawPlot::SavePlot() {
|
||||
QPainter painter(&savedImage);
|
||||
render(&painter);
|
||||
|
||||
QString fName = fileSavePath + QString('/') + fileSaveName + QString('_') + currentFrame + QString('_') + QString(NowTime().c_str()) + QString(".png");
|
||||
fName = QFileDialog::getSaveFileName(
|
||||
0, tr("Save Image"), fName,
|
||||
tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), 0,
|
||||
QString fName = fileSavePath + QString('/') +
|
||||
fileSaveName +
|
||||
QString('_') + (is1d ? plot1d->title().text() : plot2d->title().text()) +
|
||||
QString('_') + QString("%1").arg(currentAcqIndex) +
|
||||
QString(".png");
|
||||
|
||||
fName = QFileDialog::getSaveFileName(0, tr("Save Image"), fName, tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), 0,
|
||||
QFileDialog::ShowDirsOnly);
|
||||
|
||||
if (!fName.isEmpty()) {
|
||||
@ -699,6 +613,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra
|
||||
<< " ]";
|
||||
|
||||
progress = (int)data->progressIndex;
|
||||
currentAcqIndex = data->fileIndex;
|
||||
currentFrame = frameIndex;
|
||||
FILE_LOG(logDEBUG) << "[ Progress:" << progress << ", Frame:" << currentFrame << " ]";
|
||||
|
||||
@ -774,11 +689,6 @@ void qDrawPlot::Get1dData(double* rawData) {
|
||||
// allocate
|
||||
for(int i = datay1d.size(); i <= persistency; ++i) {
|
||||
datay1d.push_back(new double [nPixelsX]);
|
||||
SlsQtH1D* h = new SlsQtH1D("", nPixelsX, datax1d, datay1d[i]);
|
||||
h->SetLineColor(i);
|
||||
h->setStyleLinesorDots(isLines);
|
||||
h->setSymbolMarkers(isMarkers);
|
||||
hists1d.append(h);
|
||||
}
|
||||
// copy previous data
|
||||
for (int i = currentPersistency; i > 0; --i)
|
||||
@ -848,12 +758,22 @@ void qDrawPlot::Get2dData(double* rawData) {
|
||||
|
||||
void qDrawPlot::Update1dPlot() {
|
||||
DetachHists();
|
||||
plot1d->SetXTitle(xTitle1d.toAscii().constData());
|
||||
plot1d->SetYTitle(yTitle1d.toAscii().constData());
|
||||
for (unsigned int i = 0; i < nHists; ++i) {
|
||||
SlsQtH1D* h = hists1d.at(i);
|
||||
h->SetData(nPixelsX, datax1d, datay1d[i]);
|
||||
h->Attach(plot1d);
|
||||
plot1d->SetTitle(indexTitle);
|
||||
plot1d->SetXTitle(xTitle1d);
|
||||
plot1d->SetYTitle(yTitle1d);
|
||||
for (int i = 0; i < nHists; ++i) {
|
||||
if (i < hists1d.size()) {
|
||||
SlsQtH1D* h = hists1d.at(i);
|
||||
h->SetData(nPixelsX, datax1d, datay1d[i]);
|
||||
h->Attach(plot1d);
|
||||
} else {
|
||||
SlsQtH1D* h = new SlsQtH1D("", nPixelsX, datax1d, datay1d[i]);
|
||||
h->SetLineColor(i);
|
||||
h->setStyleLinesorDots(isLines);
|
||||
h->setSymbolMarkers(isMarkers);
|
||||
hists1d.append(h);
|
||||
h->Attach(plot1d);
|
||||
}
|
||||
}
|
||||
if (xyRangeChanged) {
|
||||
Update1dXYRange();
|
||||
@ -863,13 +783,15 @@ void qDrawPlot::Update1dPlot() {
|
||||
}
|
||||
|
||||
void qDrawPlot::Update2dPlot() {
|
||||
plot2d->SetTitle(indexTitle);
|
||||
plot2d->SetXTitle(xTitle2d);
|
||||
plot2d->SetYTitle(yTitle2d);
|
||||
plot2d->SetZTitle(zTitle2d);
|
||||
plot2d->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5,
|
||||
plot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5,
|
||||
nPixelsY, -0.5, nPixelsY - 0.5, data2d);
|
||||
if (isGainDataExtracted) {
|
||||
gainplot2d->GetPlot()->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY,
|
||||
gainplot2d->SetTitle(indexTitle);
|
||||
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY,
|
||||
-0.5, nPixelsY - 0.5, gainData);
|
||||
gainplot2d->setFixedWidth(plot2d->width() / 4);
|
||||
gainplot2d->setFixedHeight(plot2d->height() / 4);
|
||||
@ -881,7 +803,7 @@ void qDrawPlot::Update2dPlot() {
|
||||
Update2dXYRange();
|
||||
xyRangeChanged = false;
|
||||
}
|
||||
plot2d->GetPlot()->DisableZoom(disableZoom);
|
||||
plot2d->DisableZoom(disableZoom);
|
||||
plot2d->SetZRange(isZRange[0], isZRange[1], zRange[0], zRange[1]);
|
||||
}
|
||||
|
||||
@ -906,21 +828,21 @@ void qDrawPlot::Update1dXYRange() {
|
||||
|
||||
void qDrawPlot::Update2dXYRange() {
|
||||
if (!isXYRange[qDefs::XMIN] && !isXYRange[qDefs::XMAX]) {
|
||||
plot2d->GetPlot()->EnableXAutoScaling();
|
||||
plot2d->EnableXAutoScaling();
|
||||
} else {
|
||||
double xmin = (isXYRange[qDefs::XMIN] ? xyRange[qDefs::XMIN] : plot2d->GetPlot()->GetXMinimum());
|
||||
double xmax = (isXYRange[qDefs::XMAX] ? xyRange[qDefs::XMAX] : plot2d->GetPlot()->GetXMaximum());
|
||||
plot2d->GetPlot()->SetXMinMax(xmin, xmax);
|
||||
double xmin = (isXYRange[qDefs::XMIN] ? xyRange[qDefs::XMIN] : plot2d->GetXMinimum());
|
||||
double xmax = (isXYRange[qDefs::XMAX] ? xyRange[qDefs::XMAX] : plot2d->GetXMaximum());
|
||||
plot2d->SetXMinMax(xmin, xmax);
|
||||
}
|
||||
|
||||
if (!isXYRange[qDefs::YMIN] && !isXYRange[qDefs::YMAX]) {
|
||||
plot2d->GetPlot()->EnableYAutoScaling();
|
||||
plot2d->EnableYAutoScaling();
|
||||
} else {
|
||||
double ymin = (isXYRange[qDefs::YMIN] ? xyRange[qDefs::YMIN] : plot2d->GetPlot()->GetYMinimum());
|
||||
double ymax = (isXYRange[qDefs::YMAX] ? xyRange[qDefs::YMAX] : plot2d->GetPlot()->GetYMaximum());
|
||||
plot2d->GetPlot()->SetYMinMax(ymin, ymax);
|
||||
double ymin = (isXYRange[qDefs::YMIN] ? xyRange[qDefs::YMIN] : plot2d->GetYMinimum());
|
||||
double ymax = (isXYRange[qDefs::YMAX] ? xyRange[qDefs::YMAX] : plot2d->GetYMaximum());
|
||||
plot2d->SetYMinMax(ymin, ymax);
|
||||
}
|
||||
plot2d->GetPlot()->Update();
|
||||
plot2d->Update();
|
||||
}
|
||||
|
||||
void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest) {
|
||||
@ -1000,12 +922,8 @@ void qDrawPlot::UpdatePlot() {
|
||||
|
||||
boxPlot->setTitle(plotTitle);
|
||||
if (is1d) {
|
||||
lblFrameIndexTitle1d->setText(indexTitle);
|
||||
Update1dPlot();
|
||||
} else {
|
||||
plot2d->setTitle(indexTitle.toAscii().constData());
|
||||
if (isGainDataExtracted)
|
||||
gainplot2d->setTitle(indexTitle.toAscii().constData());
|
||||
Update2dPlot();
|
||||
}
|
||||
|
||||
|
@ -1,166 +1,122 @@
|
||||
#include "qTabDeveloper.h"
|
||||
#include "qDefs.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QScrollArea>
|
||||
#include <QTimer>
|
||||
#include <QString>
|
||||
#include <QPalette>
|
||||
#include <QDoubleValidator>
|
||||
#include <QSpacerItem>
|
||||
#include <QString>
|
||||
#include "qDacWidget.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
qTabDeveloper::qTabDeveloper(QWidget *parent, multiSlsDetector *detector) :
|
||||
QWidget(parent), myDet(detector), detType(slsDetectorDefs::GENERIC), numDACWidgets(0), numADCWidgets(0),
|
||||
boxDacs(nullptr), boxAdcs(nullptr), lblHV(nullptr), comboHV(nullptr), spinHV(nullptr), dacLayout(nullptr), comboDetector(nullptr), layout(nullptr) {
|
||||
qTabDeveloper::qTabDeveloper(QWidget *parent, multiSlsDetector *detector) : QWidget(parent), myDet(detector) {
|
||||
setupUi(this);
|
||||
SetupWidgetWindow();
|
||||
FILE_LOG(logDEBUG) << "Developer ready";
|
||||
}
|
||||
|
||||
qTabDeveloper::~qTabDeveloper() {
|
||||
for (size_t i = 0; i < lblDacs.size(); ++i) {
|
||||
delete lblDacs[i];
|
||||
delete lblDacsmV[i];
|
||||
delete spinDacs[i];
|
||||
}
|
||||
for (size_t i = 0; i < lblAdcs.size(); ++i) {
|
||||
delete lblAdcs[i];
|
||||
delete spinAdcs[i];
|
||||
}
|
||||
if (boxDacs)
|
||||
delete boxDacs;
|
||||
if (boxAdcs)
|
||||
delete boxAdcs;
|
||||
if (lblHV)
|
||||
delete lblHV;
|
||||
if (comboHV)
|
||||
delete comboHV;
|
||||
if (spinHV)
|
||||
delete spinHV;
|
||||
if (dacLayout)
|
||||
delete dacLayout;
|
||||
if (comboDetector)
|
||||
delete comboDetector;
|
||||
if (layout)
|
||||
delete layout;
|
||||
}
|
||||
qTabDeveloper::~qTabDeveloper() {}
|
||||
|
||||
void qTabDeveloper::SetupWidgetWindow() {
|
||||
detType = myDet->getDetectorTypeAsEnum();
|
||||
switch (detType) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
numDACWidgets = 17;
|
||||
numADCWidgets = 6;
|
||||
dacNames.push_back("v SvP:");
|
||||
dacNames.push_back("v SvN");
|
||||
dacNames.push_back("v Vrf:");
|
||||
dacNames.push_back("v Vrs:");
|
||||
dacNames.push_back("v Vtr:");
|
||||
dacNames.push_back("v Vtgstv:");
|
||||
dacNames.push_back("v cal:");
|
||||
dacNames.push_back("v Vcp");
|
||||
dacNames.push_back("v Vcn:");
|
||||
dacNames.push_back("v Vis:");
|
||||
dacNames.push_back("v rxb_lb:");
|
||||
dacNames.push_back("v rxb_rb:");
|
||||
dacNames.push_back("v Vcmp_ll:");
|
||||
dacNames.push_back("v Vcmp_lr:");
|
||||
dacNames.push_back("v Vcmp_rl:");
|
||||
dacNames.push_back("v Vcmp_rr:");
|
||||
dacNames.push_back("v threshold:");
|
||||
adcNames.push_back("Temperature FPGA Ext:");
|
||||
adcNames.push_back("Temperature 10GE:");
|
||||
adcNames.push_back("Temperature DCDC:");
|
||||
adcNames.push_back("Temperature SODL:");
|
||||
adcNames.push_back("Temperature SODR:");
|
||||
adcNames.push_back("Temperature FPGA:");
|
||||
break;
|
||||
case slsDetectorDefs::GOTTHARD:
|
||||
numDACWidgets = 8;
|
||||
numADCWidgets = 2;
|
||||
dacNames.push_back("v Reference:");
|
||||
dacNames.push_back("v Cascode n:");
|
||||
dacNames.push_back("v Cascode p:");
|
||||
dacNames.push_back("v Comp. Output:");
|
||||
dacNames.push_back("v Cascode out");
|
||||
dacNames.push_back("v Comp. Input:");
|
||||
dacNames.push_back("v Comp. Ref:");
|
||||
dacNames.push_back("i Base Test:");
|
||||
adcNames.push_back("Temperature ADC:");
|
||||
adcNames.push_back("Temperature FPGA:");
|
||||
break;
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
numDACWidgets = 8;
|
||||
numADCWidgets = 1;
|
||||
dacNames.push_back("v vb comp:");
|
||||
dacNames.push_back("v vdd prot:");
|
||||
dacNames.push_back("v vin com:");
|
||||
dacNames.push_back("v vref prech:");
|
||||
dacNames.push_back("v vb pixbuf:");
|
||||
dacNames.push_back("v vb ds:");
|
||||
dacNames.push_back("v vref ds:");
|
||||
dacNames.push_back("i vref comp:");
|
||||
adcNames.push_back("Temperature ADC/FPGA:");
|
||||
break;
|
||||
case slsDetectorDefs::MOENCH:
|
||||
numDACWidgets = 8;
|
||||
numADCWidgets = 0;
|
||||
dacNames.push_back("v Dac 0:");
|
||||
dacNames.push_back("v Dac 1:");
|
||||
dacNames.push_back("v Dac 2:");
|
||||
dacNames.push_back("v Dac 3:");
|
||||
dacNames.push_back("v Dac 4:");
|
||||
dacNames.push_back("v Dac 5:");
|
||||
dacNames.push_back("v Dac 6:");
|
||||
dacNames.push_back("i Dac 7:");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
int tempid = 0;
|
||||
|
||||
comboHV->hide();
|
||||
lblComboHV->hide();
|
||||
lblSpinHV->hide();
|
||||
spinHV->hide();
|
||||
|
||||
try{
|
||||
slsDetectorDefs::detectorType detType = myDet->getDetectorTypeAsEnum();
|
||||
switch (detType) {
|
||||
case slsDetectorDefs::EIGER:
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v SvP: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v SvN ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vrf: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vrs: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vtr: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vtgstv: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v cal: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vcp ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vcn: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vis: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v rxb_lb: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v rxb_rb: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vcmp_ll: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vcmp_lr: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vcmp_rl: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Vcmp_rr: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v threshold: ", getSLSIndex(detType, tempid++), false));
|
||||
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature FPGA Ext: ", getSLSIndex(detType, tempid++), true));
|
||||
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature 10GE: ", getSLSIndex(detType, tempid++), true));
|
||||
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature DCDC: ", getSLSIndex(detType, tempid++), true));
|
||||
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature SODL: ", getSLSIndex(detType, tempid++), true));
|
||||
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature SODR: ", getSLSIndex(detType, tempid++), true));
|
||||
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature FPGA: ", getSLSIndex(detType, tempid++), true));
|
||||
break;
|
||||
|
||||
case slsDetectorDefs::GOTTHARD:
|
||||
comboHV->show();
|
||||
lblComboHV->show();
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Reference: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Cascode n: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Cascode p: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Comp. Output: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Cascode out ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Comp. Input: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Comp. Ref: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "i Base Test: ", getSLSIndex(detType, tempid++), false));
|
||||
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature ADC: ", getSLSIndex(detType, tempid++), false));
|
||||
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature FPGA: ", getSLSIndex(detType, tempid++), false));
|
||||
break;
|
||||
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
lblSpinHV->show();
|
||||
spinHV->show();
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vb comp: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vdd prot: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vin com: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vref prech: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vb pixbuf: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vb ds: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v vref ds: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "i vref comp: ", getSLSIndex(detType, tempid++), false));
|
||||
adcWidgets.push_back(new qDacWidget(this, myDet, false, "Temperature ADC/FPGA: ", getSLSIndex(detType, tempid++), true));
|
||||
break;
|
||||
|
||||
case slsDetectorDefs::MOENCH:
|
||||
lblSpinHV->show();
|
||||
spinHV->show();
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 0: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 1: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 2: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 3: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 4: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 5: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "v Dac 6: ", getSLSIndex(detType, tempid++), false));
|
||||
dacWidgets.push_back(new qDacWidget(this, myDet, true, "i Dac 7: ", getSLSIndex(detType, tempid++), false));
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} CATCH_DISPLAY (std::string("Could not get dac/ adc index ") + std::to_string(tempid), "qTabDeveloper::SetupWidgetWindow")
|
||||
|
||||
for (size_t i = 0; i < dacWidgets.size(); ++i) {
|
||||
gridlayoutDac->addWidget(dacWidgets[i], i / 2, i % 2);
|
||||
}
|
||||
gridlayoutDac->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Expanding),dacWidgets.size(), 0);
|
||||
for (size_t i = 0; i < adcWidgets.size(); ++i) {
|
||||
gridlayoutAdc->addWidget(adcWidgets[i], i / 2, i % 2);
|
||||
}
|
||||
gridlayoutAdc->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Expanding),adcWidgets.size(), 0);
|
||||
|
||||
setFixedWidth(765);
|
||||
setFixedHeight(20 + 50 + (numDACWidgets / 2) * 35);
|
||||
QScrollArea* scroll = new QScrollArea;
|
||||
scroll->setWidget(this);
|
||||
scroll->setWidgetResizable(true);
|
||||
layout = new QGridLayout(scroll);
|
||||
layout->setContentsMargins(20, 10, 10, 5);
|
||||
setLayout(layout);
|
||||
|
||||
comboDetector = new QComboBox(this);
|
||||
tabWidget->setCurrentIndex(0);
|
||||
|
||||
PopulateDetectors();
|
||||
|
||||
CreateDACWidgets();
|
||||
CreateHVWidget();
|
||||
layout->addWidget(comboDetector, 0, 0);
|
||||
layout->addWidget(boxDacs, 1, 0);
|
||||
CreateADCWidgets();
|
||||
|
||||
Initialization();
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
void qTabDeveloper::Initialization() {
|
||||
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(Refresh()));
|
||||
for (int i = 0; i < numDACWidgets; ++i)
|
||||
connect(spinDacs[i], SIGNAL(editingFinished(int)), this, SLOT(SetDac(int)));
|
||||
if (comboHV != nullptr) {
|
||||
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
|
||||
}
|
||||
if (spinHV != nullptr) {
|
||||
connect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage()));
|
||||
}
|
||||
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
|
||||
connect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage()));
|
||||
}
|
||||
|
||||
void qTabDeveloper::PopulateDetectors() {
|
||||
@ -172,185 +128,22 @@ void qTabDeveloper::PopulateDetectors() {
|
||||
for (int i = 0; i < myDet->getNumberOfDetectors(); ++i)
|
||||
comboDetector->addItem(QString(myDet->getHostname(i).c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void qTabDeveloper::CreateDACWidgets() {
|
||||
boxDacs = new QGroupBox("Dacs", this);
|
||||
boxDacs->setFixedHeight(25 + (numDACWidgets / 2) * 35);
|
||||
dacLayout = new QGridLayout(boxDacs);
|
||||
|
||||
for (int i = 0; i < numDACWidgets; ++i) {
|
||||
lblDacs.push_back(new QLabel(QString(dacNames[i].c_str()), boxDacs));
|
||||
spinDacs.push_back(new MyDoubleSpinBox(i, boxDacs));
|
||||
spinDacs[i]->setMinimum(-1);
|
||||
spinDacs[i]->setMaximum(10000);
|
||||
lblDacsmV.push_back(new QLabel("", boxDacs));
|
||||
|
||||
dacLayout->addWidget(lblDacs[i], (int)(i / 2), ((i % 2) == 0) ? 1 : 5);
|
||||
dacLayout->addWidget(spinDacs[i], (int)(i / 2), ((i % 2) == 0) ? 2 : 6);
|
||||
dacLayout->addWidget(lblDacsmV[i], (int)(i / 2), ((i % 2) == 0) ? 3 : 7);
|
||||
if (!(i % 2)) {
|
||||
dacLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 0);
|
||||
dacLayout->addItem(new QSpacerItem(60, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 4);
|
||||
dacLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void qTabDeveloper::CreateADCWidgets() {
|
||||
if (!numADCWidgets)
|
||||
return;
|
||||
|
||||
int rows = numADCWidgets / 2;
|
||||
if (numADCWidgets % 2)
|
||||
rows++;
|
||||
setFixedHeight(20 + (50 + (numDACWidgets / 2) * 35) + (50 + rows * 35));
|
||||
boxAdcs = new QGroupBox("ADCs", this);
|
||||
boxAdcs->setFixedHeight(25 + rows * 35);
|
||||
|
||||
QGridLayout *adcLayout = new QGridLayout(boxAdcs);
|
||||
|
||||
for (int i = 0; i < numADCWidgets; ++i) {
|
||||
lblAdcs.push_back(new QLabel(QString(adcNames[i].c_str()), boxAdcs));
|
||||
spinAdcs.push_back(new QLineEdit(boxAdcs));
|
||||
spinAdcs[i]->setReadOnly(true);
|
||||
|
||||
adcLayout->addWidget(lblAdcs[i], (int)(i / 2), ((i % 2) == 0) ? 1 : 4);
|
||||
adcLayout->addWidget(spinAdcs[i], (int)(i / 2), ((i % 2) == 0) ? 2 : 5);
|
||||
if (!(i % 2)) {
|
||||
adcLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 0);
|
||||
adcLayout->addItem(new QSpacerItem(60, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 3);
|
||||
adcLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), (int)(i / 2), 6);
|
||||
}
|
||||
}
|
||||
|
||||
//to make the adcs at the bottom most
|
||||
if (detType != slsDetectorDefs::EIGER) {
|
||||
int diff = 340 - height();
|
||||
setFixedHeight(340);
|
||||
layout->setVerticalSpacing(diff / 2);
|
||||
}
|
||||
|
||||
layout->addWidget(boxAdcs, 2, 0);
|
||||
}
|
||||
|
||||
void qTabDeveloper::CreateHVWidget() {
|
||||
|
||||
switch(detType) {
|
||||
case slsDetectorDefs::GOTTHARD:
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
case slsDetectorDefs::MOENCH:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
boxDacs->setFixedHeight(boxDacs->height() + 35);
|
||||
lblHV = new QLabel("High Voltage", boxDacs);
|
||||
dacLayout->addWidget(lblHV, (int)(numDACWidgets / 2), 1);
|
||||
|
||||
comboHV = nullptr;
|
||||
spinHV = nullptr;
|
||||
|
||||
// drop down with specific values
|
||||
if (detType == slsDetectorDefs::GOTTHARD) {
|
||||
comboHV = new QComboBox(boxDacs);
|
||||
comboHV->addItem("0");
|
||||
comboHV->addItem("90");
|
||||
comboHV->addItem("110");
|
||||
comboHV->addItem("120");
|
||||
comboHV->addItem("150");
|
||||
comboHV->addItem("180");
|
||||
comboHV->addItem("200");
|
||||
comboHV->setToolTip("<nobr>Set high voltage to 0, 90, 110, 120, 150 or 200V.</nobr>");
|
||||
lblHV->setToolTip(comboHV->toolTip());
|
||||
dacLayout->addWidget(comboHV, (int)(numDACWidgets / 2), 2);
|
||||
}
|
||||
|
||||
// jungfrau, moench (range of values)
|
||||
else {
|
||||
spinHV = new QSpinBox(boxDacs);
|
||||
spinHV->setMinimum(-1);
|
||||
spinHV->setMaximum(HV_MAX);
|
||||
spinHV->setToolTip("<nobr>Set high voltage to 0 or 60 - 200V</nobr>");
|
||||
lblHV->setToolTip(spinHV->toolTip());
|
||||
dacLayout->addWidget(spinHV, (int)(numDACWidgets / 2), 2);
|
||||
}
|
||||
}
|
||||
|
||||
void qTabDeveloper::GetDac(int id) {
|
||||
FILE_LOG(logDEBUG) << "Getting Dac " << id;
|
||||
|
||||
disconnect(spinDacs[id], SIGNAL(editingFinished(int)), this, SLOT(SetDac(int)));
|
||||
try {
|
||||
// dac units
|
||||
auto retval = myDet->setDAC(-1, getSLSIndex(id), 0, comboDetector->currentIndex() - 1);
|
||||
spinDacs[id]->setValue(retval);
|
||||
// mv
|
||||
retval = myDet->setDAC(-1, getSLSIndex(id), 1, comboDetector->currentIndex() - 1);
|
||||
lblDacsmV[id]->setText(QString("%1mV").arg(retval -10));
|
||||
} CATCH_DISPLAY("Could not get dac.", "qTabDeveloper::GetDac")
|
||||
|
||||
connect(spinDacs[id], SIGNAL(editingFinished(int)), this, SLOT(SetDac(int)));
|
||||
}
|
||||
|
||||
void qTabDeveloper::GetDacs() {
|
||||
FILE_LOG(logDEBUG) << "Getting All Dacs";
|
||||
|
||||
for (int i = 0; i < numDACWidgets; ++i) {
|
||||
GetDac(i);
|
||||
}
|
||||
}
|
||||
|
||||
void qTabDeveloper::SetDac(int id) {
|
||||
int val = spinDacs[id]->value();
|
||||
FILE_LOG(logINFO) << "Setting dac:" << dacNames[id] << " : " << val;
|
||||
|
||||
try {
|
||||
myDet->setDAC(val, getSLSIndex(id), 0, comboDetector->currentIndex() - 1);
|
||||
} CATCH_DISPLAY ("Could not set dac.", "qTabDeveloper::SetDac")
|
||||
|
||||
// update mV anyway
|
||||
GetDac(id);
|
||||
}
|
||||
|
||||
void qTabDeveloper::GetAdcs() {
|
||||
FILE_LOG(logDEBUG) << "Getting ADCs";
|
||||
|
||||
auto moduleId = comboDetector->currentIndex() - 1;
|
||||
for (int i = 0; i < numADCWidgets; ++i) {
|
||||
try {
|
||||
auto retval = myDet->getADC(getSLSIndex(i + numDACWidgets), moduleId);
|
||||
if (retval == -1 && moduleId == -1) {
|
||||
spinAdcs[i]->setText(QString("Different values"));
|
||||
} else {
|
||||
if (detType == slsDetectorDefs::EIGER || detType == slsDetectorDefs::JUNGFRAU) {
|
||||
retval /= 1000.00;
|
||||
}
|
||||
spinAdcs[i]->setText(QString::number(retval, 'f', 2) + 0x00b0 + QString("C"));
|
||||
}
|
||||
} CATCH_DISPLAY ("Could not get adcs.", "qTabDeveloper::GetAdcs")
|
||||
}
|
||||
comboDetector->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void qTabDeveloper::GetHighVoltage() {
|
||||
// not enabled for this detector type
|
||||
if (comboHV == nullptr && spinHV == nullptr)
|
||||
// not enabled for eiger
|
||||
if (!comboHV->isVisible() && !spinHV->isVisible())
|
||||
return;
|
||||
|
||||
FILE_LOG(logDEBUG) << "Getting High Voltage";
|
||||
if (spinHV != nullptr) {
|
||||
disconnect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage()));
|
||||
}
|
||||
if (comboHV != nullptr) {
|
||||
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
|
||||
}
|
||||
disconnect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage()));
|
||||
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
|
||||
|
||||
try {
|
||||
// dac units
|
||||
auto retval = myDet->setDAC(-1, slsDetectorDefs::HIGH_VOLTAGE, 0, comboDetector->currentIndex() - 1);
|
||||
if (spinHV != nullptr) {
|
||||
if (spinHV->isVisible()) {
|
||||
if (retval != 0 && retval != -1 && retval < HV_MIN && retval > HV_MAX) {
|
||||
qDefs::Message(qDefs::WARNING, std::string("Unknown High Voltage: ") + std::to_string(retval), "qTabDeveloper::GetHighVoltage");
|
||||
} else{
|
||||
@ -390,16 +183,12 @@ void qTabDeveloper::GetHighVoltage() {
|
||||
|
||||
} CATCH_DISPLAY ("Could not get high voltage.", "qTabDeveloper::GetHighVoltage")
|
||||
|
||||
if (spinHV != nullptr) {
|
||||
connect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage()));
|
||||
}
|
||||
if (comboHV != nullptr) {
|
||||
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
|
||||
}
|
||||
connect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage()));
|
||||
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage()));
|
||||
}
|
||||
|
||||
void qTabDeveloper::SetHighVoltage() {
|
||||
int val = (comboHV ? comboHV->currentText().toInt() : spinHV->value());
|
||||
int val = (comboHV->isVisible() ? comboHV->currentText().toInt() : spinHV->value());
|
||||
FILE_LOG(logINFO) << "Setting high voltage:" << val;
|
||||
|
||||
try {
|
||||
@ -408,8 +197,7 @@ void qTabDeveloper::SetHighVoltage() {
|
||||
this, &qTabDeveloper::GetHighVoltage)
|
||||
}
|
||||
|
||||
|
||||
slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
|
||||
slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
|
||||
switch (detType) {
|
||||
|
||||
case slsDetectorDefs::EIGER:
|
||||
@ -492,35 +280,33 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(int index) {
|
||||
break;
|
||||
|
||||
case slsDetectorDefs::JUNGFRAU:
|
||||
if (index >= 0 && index < numDACWidgets) {
|
||||
if (index >= 0 && index < (int)dacWidgets.size()) {
|
||||
return (slsDetectorDefs::dacIndex)index;
|
||||
}
|
||||
if (index == numDACWidgets) {
|
||||
if (index == (int)dacWidgets.size()) {
|
||||
return slsDetectorDefs::TEMPERATURE_ADC;
|
||||
} else {
|
||||
throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index));
|
||||
}
|
||||
break;
|
||||
}
|
||||
throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index));
|
||||
|
||||
case slsDetectorDefs::MOENCH:
|
||||
if (index >= 0 && index < numDACWidgets) {
|
||||
if (index >= 0 && index < (int)dacWidgets.size()) {
|
||||
return (slsDetectorDefs::dacIndex)index;
|
||||
} else {
|
||||
throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index));
|
||||
}
|
||||
break;
|
||||
}
|
||||
throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index));
|
||||
|
||||
default:
|
||||
break;
|
||||
throw sls::RuntimeError(std::string("Unknown detector type"));
|
||||
}
|
||||
|
||||
return (slsDetectorDefs::dacIndex)0;
|
||||
}
|
||||
|
||||
void qTabDeveloper::Refresh() {
|
||||
FILE_LOG(logDEBUG) << "**Updating Developer Tab\n";
|
||||
GetDacs();
|
||||
GetAdcs();
|
||||
for (const auto &it : dacWidgets) {
|
||||
it->SetDetectorIndex(comboDetector->currentIndex() - 1);
|
||||
}
|
||||
for (const auto &it : adcWidgets) {
|
||||
it->SetDetectorIndex(comboDetector->currentIndex() - 1);
|
||||
}
|
||||
GetHighVoltage();
|
||||
FILE_LOG(logDEBUG) << "**Updated Developer Tab";
|
||||
}
|
||||
|
@ -130,13 +130,9 @@ void qTabPlot::Initialization() {
|
||||
if (chkGapPixels->isEnabled())
|
||||
connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool)));
|
||||
|
||||
// Save
|
||||
// Save, clone
|
||||
connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot()));
|
||||
|
||||
// Snapshot box
|
||||
connect(btnClone, SIGNAL(clicked()), myPlot, SLOT(ClonePlot()));
|
||||
connect(btnCloseClones, SIGNAL(clicked()), myPlot, SLOT(CloseClones()));
|
||||
connect(btnSaveClones, SIGNAL(clicked()), myPlot, SLOT(SaveClones()));
|
||||
|
||||
// Plot Axis
|
||||
connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
|
||||
@ -195,7 +191,6 @@ void qTabPlot::SetPlot() {
|
||||
box1D->setEnabled(plotEnable);
|
||||
box2D->setEnabled(plotEnable);
|
||||
boxSave->setEnabled(plotEnable);
|
||||
boxSnapshot->setEnabled(plotEnable);
|
||||
boxPlotAxis->setEnabled(plotEnable);
|
||||
|
||||
if (plotEnable) {
|
||||
|
Reference in New Issue
Block a user