clang format on gui

This commit is contained in:
Erik Frojdh
2020-03-10 10:18:52 +01:00
parent bd6529a64c
commit 9ede0629ef
34 changed files with 3813 additions and 3060 deletions

8
slsDetectorGui/include/qCloneWidget.h Executable file → Normal file
View File

@ -16,10 +16,10 @@ class qCloneWidget : public QMainWindow, private Ui::ClonePlotObject {
Q_OBJECT Q_OBJECT
public: public:
qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2, SlsQt1DPlot *gp1, SlsQt2DPlot *gp, qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2,
QString title, QString filePath, QString fileName, SlsQt1DPlot *gp1, SlsQt2DPlot *gp, QString title,
int64_t aIndex, bool displayStats, QString min, QString max, QString filePath, QString fileName, int64_t aIndex,
QString sum); bool displayStats, QString min, QString max, QString sum);
~qCloneWidget(); ~qCloneWidget();

4
slsDetectorGui/include/qDacWidget.h Executable file → Normal file
View File

@ -11,7 +11,8 @@ class qDacWidget:public QWidget, private Ui::WidgetDacObject {
Q_OBJECT Q_OBJECT
public: public:
qDacWidget(QWidget *parent, sls::Detector* detector, bool d, std::string n, slsDetectorDefs::dacIndex i); qDacWidget(QWidget *parent, sls::Detector *detector, bool d, std::string n,
slsDetectorDefs::dacIndex i);
~qDacWidget(); ~qDacWidget();
void SetDetectorIndex(int id); void SetDetectorIndex(int id);
@ -30,4 +31,3 @@ private:
slsDetectorDefs::dacIndex index; slsDetectorDefs::dacIndex index;
int detectorIndex{-1}; int detectorIndex{-1};
}; };

67
slsDetectorGui/include/qDefs.h Executable file → Normal file
View File

@ -5,22 +5,28 @@
#include <QAbstractButton> #include <QAbstractButton>
#include <QMessageBox> #include <QMessageBox>
#include <chrono>
#include <iostream> #include <iostream>
#include <ostream> #include <ostream>
#include <stdint.h> #include <stdint.h>
#include <string> #include <string>
#include <chrono>
using std::chrono::duration; using std::chrono::duration;
using std::chrono::duration_cast; using std::chrono::duration_cast;
using std::chrono::nanoseconds; using std::chrono::hours;
using std::chrono::microseconds; using std::chrono::microseconds;
using std::chrono::milliseconds; using std::chrono::milliseconds;
using std::chrono::seconds;
using std::chrono::minutes; using std::chrono::minutes;
using std::chrono::hours; using std::chrono::nanoseconds;
using std::chrono::seconds;
#define CATCH_DISPLAY(m, s) catch(...) { qDefs::DisplayExceptions(m, s); } #define CATCH_DISPLAY(m, s) \
#define CATCH_HANDLE(...) catch(...) { qDefs::HandleExceptions(__VA_ARGS__); } catch (...) { \
qDefs::DisplayExceptions(m, s); \
}
#define CATCH_HANDLE(...) \
catch (...) { \
qDefs::HandleExceptions(__VA_ARGS__); \
}
class qDefs : public QWidget { class qDefs : public QWidget {
public: public:
@ -47,8 +53,8 @@ class qDefs : public QWidget {
template <class CT> struct NonDeduced { using type = CT; }; template <class CT> struct NonDeduced { using type = CT; };
template <class S, typename RT, typename... CT> template <class S, typename RT, typename... CT>
static void HandleExceptions(const std::string emsg, const std::string src, S* s, static void HandleExceptions(const std::string emsg, const std::string src,
RT (S::*somefunc)(CT...), S *s, RT (S::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) { typename NonDeduced<CT>::type... Args) {
try { try {
throw; throw;
@ -74,13 +80,20 @@ class qDefs : public QWidget {
static const char *getQFunctionNameFromEnum(enum qFuncNames func) { static const char *getQFunctionNameFromEnum(enum qFuncNames func) {
switch (func) { switch (func) {
case QF_GET_DETECTOR_STATUS: return "QF_GET_DETECTOR_STATUS"; case QF_GET_DETECTOR_STATUS:
case QF_START_ACQUISITION: return "QF_START_ACQUISITION"; return "QF_GET_DETECTOR_STATUS";
case QF_STOP_ACQUISITION: return "QF_STOP_ACQUISITION"; case QF_START_ACQUISITION:
case QF_START_AND_READ_ALL: return "QF_START_AND_READ_ALL"; return "QF_START_ACQUISITION";
case QF_EXIT_SERVER: return "QF_EXIT_SERVER"; case QF_STOP_ACQUISITION:
case QF_NUM_FUNCTIONS: return "QF_NUM_FUNCTIONS"; return "QF_STOP_ACQUISITION";
default: return "Unknown Function"; case QF_START_AND_READ_ALL:
return "QF_START_AND_READ_ALL";
case QF_EXIT_SERVER:
return "QF_EXIT_SERVER";
case QF_NUM_FUNCTIONS:
return "QF_NUM_FUNCTIONS";
default:
return "Unknown Function";
} }
}; };
@ -111,11 +124,16 @@ class qDefs : public QWidget {
static std::string getRangeAsString(enum range r) { static std::string getRangeAsString(enum range r) {
switch (r) { switch (r) {
case XMIN: return "XMIN"; case XMIN:
case XMAX: return "XMAX"; return "XMIN";
case YMIN: return "YMIN"; case XMAX:
case YMAX: return "YMAX"; return "XMAX";
default: return "Unknown"; case YMIN:
return "YMIN";
case YMAX:
return "YMAX";
default:
return "Unknown";
} }
}; };
@ -190,7 +208,8 @@ class qDefs : public QWidget {
MINUTES); MINUTES);
} }
return std::make_pair( return std::make_pair(
duration_cast<duration<double, std::ratio<3600>>>(tns).count(), HOURS); duration_cast<duration<double, std::ratio<3600>>>(tns).count(),
HOURS);
} }
/** returns the value in ns */ /** returns the value in ns */
@ -299,7 +318,9 @@ class qDefs : public QWidget {
static int ExceptionMessage(std::string message, static int ExceptionMessage(std::string message,
std::string exceptionMessage, std::string exceptionMessage,
std::string source) { std::string source) {
return Message(qDefs::WARNING, message + std::string("\nCaught exception:\n") + exceptionMessage, source); return Message(qDefs::WARNING,
message + std::string("\nCaught exception:\n") +
exceptionMessage,
source);
} }
}; };

3
slsDetectorGui/include/qDetectorMain.h Executable file → Normal file
View File

@ -20,7 +20,8 @@ class qTabMessages;
class QScrollArea; class QScrollArea;
class QResizeEvent; class QResizeEvent;
/** To Over-ride the QTabWidget class to get the tabBar protected methodTabWidget */ /** To Over-ride the QTabWidget class to get the tabBar protected
* methodTabWidget */
class MyTabWidget : public QTabWidget { class MyTabWidget : public QTabWidget {
public: public:
MyTabWidget(QWidget *parent = 0) { setParent(parent); } MyTabWidget(QWidget *parent = 0) { setParent(parent); }

13
slsDetectorGui/include/qDrawPlot.h Executable file → Normal file
View File

@ -78,11 +78,16 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void SetupPlots(); void SetupPlots();
void GetStatistics(double &min, double &max, double &sum); void GetStatistics(double &min, double &max, double &sum);
void DetachHists(); void DetachHists();
static void GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer); static void GetAcquisitionFinishedCallBack(double currentProgress,
static void GetDataCallBack(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex, void *this_pointer); int detectorStatus,
void *this_pointer);
static void GetDataCallBack(detectorData *data, uint64_t frameIndex,
uint32_t subFrameIndex, void *this_pointer);
void AcquisitionFinished(double currentProgress, int detectorStatus); void AcquisitionFinished(double currentProgress, int detectorStatus);
void GetData(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex); void GetData(detectorData *data, uint64_t frameIndex,
void toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest = NULL); uint32_t subFrameIndex);
void toDoublePixelData(double *dest, char *source, int size, int databytes,
int dr, double *gaindest = NULL);
void Get1dData(double *rawData); void Get1dData(double *rawData);
void Get2dData(double *rawData); void Get2dData(double *rawData);
void Update1dPlot(); void Update1dPlot();

2
slsDetectorGui/include/qTabAdvanced.h Executable file → Normal file
View File

@ -65,5 +65,3 @@ private:
sls::Detector *det; sls::Detector *det;
qDrawPlot *plot; qDrawPlot *plot;
}; };

6
slsDetectorGui/include/qTabDataOutput.h Executable file → Normal file
View File

@ -42,9 +42,5 @@ public:
// Button group for radiobuttons for rate // Button group for radiobuttons for rate
QButtonGroup *btnGroupRate; QButtonGroup *btnGroupRate;
// enum for the Eiger Parallel flag // enum for the Eiger Parallel flag
enum { enum { PARALLEL, NONPARALLEL };
PARALLEL,
NONPARALLEL
}; };
};

1
slsDetectorGui/include/qTabDebugging.h Executable file → Normal file
View File

@ -33,4 +33,3 @@ private:
QLabel *lblDetectorFirmware; QLabel *lblDetectorFirmware;
QLabel *lblDetectorSoftware; QLabel *lblDetectorSoftware;
}; };

14
slsDetectorGui/include/qTabDeveloper.h Executable file → Normal file
View File

@ -27,23 +27,15 @@ private:
void Initialization(); void Initialization();
void PopulateDetectors(); void PopulateDetectors();
void GetHighVoltage(); void GetHighVoltage();
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType, int index); slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType,
int index);
sls::Detector *det; sls::Detector *det;
std::vector<qDacWidget *> dacWidgets; std::vector<qDacWidget *> dacWidgets;
std::vector<qDacWidget *> adcWidgets; std::vector<qDacWidget *> adcWidgets;
enum hvVals { enum hvVals { HV_0, HV_90, HV_110, HV_120, HV_150, HV_180, HV_200 };
HV_0,
HV_90,
HV_110,
HV_120,
HV_150,
HV_180,
HV_200
};
int hvmin; int hvmin;
static const int HV_MIN = 60; static const int HV_MIN = 60;
static const int HV_MAX = 200; static const int HV_MAX = 200;
}; };

9
slsDetectorGui/include/qTabMeasurement.h Executable file → Normal file
View File

@ -74,17 +74,12 @@ private:
signals: signals:
void EnableTabsSignal(bool); void EnableTabsSignal(bool);
void FileNameChangedSignal(QString); void FileNameChangedSignal(QString);
private: private:
sls::Detector *det; sls::Detector *det;
qDrawPlot *plot; qDrawPlot *plot;
// enum for the timing mode // enum for the timing mode
enum{ enum { AUTO, TRIGGER, GATED, BURST_TRIGGER, NUMTIMINGMODES };
AUTO,
TRIGGER,
GATED,
BURST_TRIGGER,
NUMTIMINGMODES
};
QTimer *progressTimer; QTimer *progressTimer;
// tool tip variables // tool tip variables
QString acqPeriodTip; QString acqPeriodTip;

1
slsDetectorGui/include/qTabMessages.h Executable file → Normal file
View File

@ -33,4 +33,3 @@ private:
QProcess *process; QProcess *process;
QStringList lastCommand; QStringList lastCommand;
}; };

2
slsDetectorGui/include/qTabPlot.h Executable file → Normal file
View File

@ -59,5 +59,3 @@ private:
static QString defaultImageYAxisTitle; static QString defaultImageYAxisTitle;
static QString defaultImageZAxisTitle; static QString defaultImageZAxisTitle;
}; };

7
slsDetectorGui/include/qTabSettings.h Executable file → Normal file
View File

@ -53,10 +53,5 @@ private:
UNINITIALIZED, UNINITIALIZED,
NUMSETTINGS NUMSETTINGS
}; };
enum { enum { DYNAMICRANGE_32, DYNAMICRANGE_16, DYNAMICRANGE_8, DYNAMICRANGE_4 };
DYNAMICRANGE_32,
DYNAMICRANGE_16,
DYNAMICRANGE_8,
DYNAMICRANGE_4
};
}; };

View File

@ -3,31 +3,26 @@
* @author Ian Johnson * @author Ian Johnson
* @version 1.0 * @version 1.0
* Modifications: * Modifications:
* 19.06.2012: {Some functions have been added by Dhanya to enable zooming in and out * 19.06.2012: {Some functions have been added by Dhanya to enable zooming in
* without using mouse control: * and out without using mouse control: DisableZoom, SetXMinMax,SetYMinMax,
* DisableZoom,
* SetXMinMax,SetYMinMax,
* GetXMinimum,GetXMaximum,GetYMinimum,GetYMaximum} * GetXMinimum,GetXMaximum,GetYMinimum,GetYMaximum}
* */ * */
#ifndef SLSQT1DPLOT_H #ifndef SLSQT1DPLOT_H
#define SLSQT1DPLOT_H #define SLSQT1DPLOT_H
typedef double double32_t; typedef double double32_t;
typedef float float32_t; typedef float float32_t;
typedef int int32_t; typedef int int32_t;
#include "ansi.h" #include "ansi.h"
#include "SlsQt1DZoomer.h"
#include <iostream>
#include <qwt_plot.h> #include <qwt_plot.h>
#include <qwt_plot_curve.h> #include <qwt_plot_curve.h>
#include <qwt_plot_marker.h> #include <qwt_plot_marker.h>
#include <qwt_scale_div.h> #include <qwt_scale_div.h>
#include "SlsQt1DZoomer.h"
#include <iostream>
class QPen; class QPen;
class SlsQt1DPlot; class SlsQt1DPlot;
@ -71,8 +66,6 @@ class SlsQtH1D:public QwtPlotCurve{
SlsQtH1D *Add(double v); SlsQtH1D *Add(double v);
private: private:
int ndata; int ndata;
int n_array; int n_array;
@ -87,7 +80,6 @@ class SlsQtH1D:public QwtPlotCurve{
QPen *pen_ptr{nullptr}; QPen *pen_ptr{nullptr};
}; };
class SlsQtH1DList { class SlsQtH1DList {
public: public:
SlsQtH1DList(SlsQtH1D *hist = 0); SlsQtH1DList(SlsQtH1D *hist = 0);
@ -100,13 +92,11 @@ class SlsQtH1DList{
SlsQtH1D *Hist() { return the_hist; } // if no hist returns 0 SlsQtH1D *Hist() { return the_hist; } // if no hist returns 0
SlsQtH1DList *Next() { return the_next; } SlsQtH1DList *Next() { return the_next; }
private: private:
SlsQtH1DList *the_next; SlsQtH1DList *the_next;
SlsQtH1D *the_hist; SlsQtH1D *the_hist;
}; };
class SlsQt1DPlot : public QwtPlot { class SlsQt1DPlot : public QwtPlot {
Q_OBJECT Q_OBJECT
@ -126,31 +116,41 @@ class SlsQt1DPlot:public QwtPlot{
void InsertVLine(double v); void InsertVLine(double v);
void RemoveVLine(); void RemoveVLine();
/** This group of functions have been added by Dhanya on 19.06.2012 to be
/** This group of functions have been added by Dhanya on 19.06.2012 to be able to able to use zooming functionality without mouse control*/
use zooming functionality without mouse control*/
void DisableZoom(bool disable); void DisableZoom(bool disable);
void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);Update();}; void EnableXAutoScaling() {
void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);Update();}; setAxisAutoScale(QwtPlot::xBottom, true);
Update();
};
void EnableYAutoScaling() {
setAxisAutoScale(QwtPlot::yLeft, true);
Update();
};
void SetYStep(int step) { ystep = step; }; void SetYStep(int step) { ystep = step; };
void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);}; void SetXMinMax(double min, double max) {
void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);}; setAxisScale(QwtPlot::xBottom, min, max);
};
void SetYMinMax(double min, double max) {
setAxisScale(QwtPlot::yLeft, min, max);
};
double GetXMinimum() { return hist_list->Hist()->GetXMin(); }; double GetXMinimum() { return hist_list->Hist()->GetXMin(); };
double GetXMaximum() { return hist_list->Hist()->GetXMax(); }; double GetXMaximum() { return hist_list->Hist()->GetXMax(); };
double GetYMinimum() { return hist_list->Hist()->GetYMin(); }; double GetYMinimum() { return hist_list->Hist()->GetYMin(); };
double GetYMaximum() { return hist_list->Hist()->GetYMax(); }; double GetYMaximum() { return hist_list->Hist()->GetYMax(); };
/**---*/ /**---*/
void SetZoom(double xmin, double ymin, double x_width, double y_width); void SetZoom(double xmin, double ymin, double x_width, double y_width);
void SetZoomBase(double xmin,double ymin,double x_width, double y_width){ zoomer->SetZoomBase(xmin,ymin,x_width,y_width);} void SetZoomBase(double xmin, double ymin, double x_width, double y_width) {
zoomer->SetZoomBase(xmin, ymin, x_width, y_width);
}
void alignScales(); void alignScales();
void SetLogX(bool yes = 1); void SetLogX(bool yes = 1);
void SetLogY(bool yes = 1); void SetLogY(bool yes = 1);
private:
private:
SlsQtH1DList *hist_list{nullptr}; SlsQtH1DList *hist_list{nullptr};
SlsQt1DZoomer *zoomer{nullptr}; SlsQt1DZoomer *zoomer{nullptr};
QwtPlotPanner *panner{nullptr}; QwtPlotPanner *panner{nullptr};
@ -173,11 +173,9 @@ class SlsQt1DPlot:public QwtPlot{
friend void SlsQtH1D::Attach(SlsQt1DPlot *p); friend void SlsQtH1D::Attach(SlsQt1DPlot *p);
friend void SlsQtH1D::Detach(SlsQt1DPlot *p); friend void SlsQtH1D::Detach(SlsQt1DPlot *p);
public slots: public slots:
void UnZoom(); void UnZoom();
void Update(); void Update();
}; };
#endif #endif

View File

@ -7,9 +7,9 @@
#ifndef SLSQT1DZOOMER_H #ifndef SLSQT1DZOOMER_H
#define SLSQT1DZOOMER_H #define SLSQT1DZOOMER_H
#include <qwt_plot_zoomer.h>
#include <qwt_plot_panner.h>
#include <qwt_global.h> #include <qwt_global.h>
#include <qwt_plot_panner.h>
#include <qwt_plot_zoomer.h>
class SlsQtH1D; class SlsQtH1D;
@ -43,8 +43,6 @@ class SlsQt1DZoomer:public QwtPlotZoomer{
bool SetLogX(bool yes) { return xIsLog = yes; } bool SetLogX(bool yes) { return xIsLog = yes; }
bool SetLogY(bool yes) { return yIsLog = yes; } bool SetLogY(bool yes) { return yIsLog = yes; }
using QwtPlotPicker::trackerText; using QwtPlotPicker::trackerText;
virtual QwtText trackerText(const QPoint &pos) const { virtual QwtText trackerText(const QPoint &pos) const {
@ -54,7 +52,6 @@ class SlsQt1DZoomer:public QwtPlotZoomer{
text.setBackgroundBrush(QBrush(bg)); text.setBackgroundBrush(QBrush(bg));
return text; return text;
} }
}; };
#endif #endif

View File

@ -4,24 +4,20 @@
* @version 1.0 * @version 1.0
*/ */
#ifndef SLSQT2DHIST_H #ifndef SLSQT2DHIST_H
#define SLSQT2DHIST_H #define SLSQT2DHIST_H
#if QT_VERSION >= 0x040000 #if QT_VERSION >= 0x040000
#include <qprintdialog.h> #include <qprintdialog.h>
#endif #endif
#include <qwt_color_map.h> #include <qwt_color_map.h>
#include <qwt_plot_spectrogram.h> #include <qwt_plot_spectrogram.h>
#include <qwt_scale_widget.h>
#include <qwt_scale_draw.h> #include <qwt_scale_draw.h>
#include <qwt_scale_widget.h>
class SlsQt2DHist : public QwtRasterData { class SlsQt2DHist : public QwtRasterData {
private: private:
double x_min, x_max, y_min, y_max; double x_min, x_max, y_min, y_max;
double x_width, y_width; double x_width, y_width;
@ -34,12 +30,15 @@ class SlsQt2DHist: public QwtRasterData{
bool interp; bool interp;
static double value_between_points(double p1,double v1,double p2,double v2,double p){ //linear extrap static double value_between_points(double p1, double v1, double p2,
double v2, double p) { // linear extrap
return (v2 - v1) / (p2 - p1) * (p - p1) + v1; return (v2 - v1) / (p2 - p1) * (p - p1) + v1;
} }
public: public:
SlsQt2DHist(int nbinsx=10, double xmin=0, double xmax=10, int nbinsy=10, double ymin=0, double ymax=10, double* d=0,double zmin=0,double zmax=-1); SlsQt2DHist(int nbinsx = 10, double xmin = 0, double xmax = 10,
int nbinsy = 10, double ymin = 0, double ymax = 10,
double *d = 0, double zmin = 0, double zmax = -1);
virtual ~SlsQt2DHist(); virtual ~SlsQt2DHist();
double GetXMin() { return x_min; } double GetXMin() { return x_min; }
@ -60,7 +59,8 @@ class SlsQt2DHist: public QwtRasterData{
void Interpolate(bool on = 1) { interp = on; } void Interpolate(bool on = 1) { interp = on; }
void SetBinValue(int bx, int by, double v); void SetBinValue(int bx, int by, double v);
void SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax,double *d,double zmin=0, double zmax=-1); void SetData(int nbinsx, double xmin, double xmax, int nbinsy, double ymin,
double ymax, double *d, double zmin = 0, double zmax = -1);
double SetMinimumToFirstGreaterThanZero(); double SetMinimumToFirstGreaterThanZero();
void SetMinimum(double zmin) { z_min = zmin; } void SetMinimum(double zmin) { z_min = zmin; }
@ -69,15 +69,13 @@ class SlsQt2DHist: public QwtRasterData{
int FindBinIndex(double x, double y); int FindBinIndex(double x, double y);
virtual QwtRasterData *copy() const { virtual QwtRasterData *copy() const {
// this function does not create a new SlsQt2DHistData instance, // this function does not create a new SlsQt2DHistData instance,
//just passes a pointer so that data is common to both the copy and the original instance // just passes a pointer so that data is common to both the copy and the
// original instance
return (QwtRasterData *)this; return (QwtRasterData *)this;
} }
virtual QwtInterval range() const { return QwtInterval(z_min, z_max); } virtual QwtInterval range() const { return QwtInterval(z_min, z_max); }
virtual QwtInterval interval(Qt::Axis axis) const { virtual QwtInterval interval(Qt::Axis axis) const {
switch (axis) { switch (axis) {
@ -92,21 +90,26 @@ class SlsQt2DHist: public QwtRasterData{
}; };
}; };
virtual double value(double x, double y) const { virtual double value(double x, double y) const {
// if(!interp){ //default is box like plot // if(!interp){ //default is box like plot
int index = int((x-x_min)/x_width) + int((y-y_min)/y_width)*nx; int index =
if(index<0||index>nb) index = nb; int((x - x_min) / x_width) + int((y - y_min) / y_width) * nx;
if(!interp) return data[index]; if (index < 0 || index > nb)
index = nb;
if (!interp)
return data[index];
//} //}
int x_int = int((x - x_min) / x_width - 0.5); int x_int = int((x - x_min) / x_width - 0.5);
if(x_int<0) x_int = 0; else if(x_int>nx-2) x_int = nx-2; if (x_int < 0)
x_int = 0;
else if (x_int > nx - 2)
x_int = nx - 2;
int y_int = int((y - y_min) / y_width - 0.5); int y_int = int((y - y_min) / y_width - 0.5);
if(y_int<0) y_int = 0; else if(y_int>ny-2) y_int = ny-2; if (y_int < 0)
y_int = 0;
else if (y_int > ny - 2)
y_int = ny - 2;
int b00 = x_int * ny + y_int; int b00 = x_int * ny + y_int;
int b01 = x_int * ny + y_int + 1; int b01 = x_int * ny + y_int + 1;
@ -120,16 +123,12 @@ class SlsQt2DHist: public QwtRasterData{
double right_v = value_between_points(y0, data[b10], y1, data[b11], y); double right_v = value_between_points(y0, data[b10], y1, data[b11], y);
// horazontal extrap // horazontal extrap
return 0.5; return 0.5;
return value_between_points(x_min + (x_int + 0.5) * x_width, left_v, return value_between_points(x_min + (x_int + 0.5) * x_width, left_v,
x_min+(x_int+1.5)*x_width,right_v,x); x_min + (x_int + 1.5) * x_width, right_v,
x);
} }
}; };
#endif #endif

View File

@ -1,20 +1,16 @@
#pragma once #pragma once
#include <qwt_plot.h>
#include <qlist.h> #include <qlist.h>
#include <qwt_plot.h>
#include <qwt_plot_spectrogram.h> #include <qwt_plot_spectrogram.h>
#include "SlsQt2DZoomer.h"
#include "SlsQt2DHist.h" #include "SlsQt2DHist.h"
#include "SlsQt2DZoomer.h"
class QwtPlotPanner; class QwtPlotPanner;
class QwtScaleWidget; class QwtScaleWidget;
class QwtLinearColorMap; class QwtLinearColorMap;
class SlsQt2DPlot : public QwtPlot { class SlsQt2DPlot : public QwtPlot {
Q_OBJECT Q_OBJECT
@ -35,8 +31,12 @@ public:
void DisableZoom(bool disable); void DisableZoom(bool disable);
void EnableXAutoScaling() { setAxisAutoScale(QwtPlot::xBottom, true); }; void EnableXAutoScaling() { setAxisAutoScale(QwtPlot::xBottom, true); };
void EnableYAutoScaling() { setAxisAutoScale(QwtPlot::yLeft, true); }; void EnableYAutoScaling() { setAxisAutoScale(QwtPlot::yLeft, true); };
void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);}; void SetXMinMax(double min, double max) {
void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);}; setAxisScale(QwtPlot::xBottom, min, max);
};
void SetYMinMax(double min, double max) {
setAxisScale(QwtPlot::yLeft, min, max);
};
double GetXMinimum() { return hist->GetXMin(); }; double GetXMinimum() { return hist->GetXMin(); };
double GetXMaximum() { return hist->GetXMax(); }; double GetXMaximum() { return hist->GetXMax(); };
double GetYMinimum() { return hist->GetYMin(); }; double GetYMinimum() { return hist->GetYMin(); };
@ -44,10 +44,13 @@ public:
double GetZMinimum() { return hist->GetMinimum(); } double GetZMinimum() { return hist->GetMinimum(); }
double GetZMaximum() { return hist->GetMaximum(); } double GetZMaximum() { return hist->GetMaximum(); }
void SetZMinMax(double zmin = 0, double zmax = -1); void SetZMinMax(double zmin = 0, double zmax = -1);
void SetZMinimumToFirstGreaterThanZero(){hist->SetMinimumToFirstGreaterThanZero();} void SetZMinimumToFirstGreaterThanZero() {
hist->SetMinimumToFirstGreaterThanZero();
}
double GetZMean() { return hist->GetMean(); } double GetZMean() { return hist->GetMean(); }
void SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax,double *d,double zmin=0, double zmax=-1){ void SetData(int nbinsx, double xmin, double xmax, int nbinsy, double ymin,
double ymax, double *d, double zmin = 0, double zmax = -1) {
hist->SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d, zmin, zmax); hist->SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d, zmin, zmax);
} }
@ -65,12 +68,9 @@ public:
void SetZRange(bool isMin, bool isMax, double min, double max); void SetZRange(bool isMin, bool isMax, double min, double max);
void LogZ(bool on = 1); void LogZ(bool on = 1);
public slots: public slots:
void showSpectrogram(bool on); void showSpectrogram(bool on);
private: private:
void SetupZoom(); void SetupZoom();
void SetupColorMap(); void SetupColorMap();
@ -90,4 +90,3 @@ private:
bool disableZoom{false}; bool disableZoom{false};
int isLog; int isLog;
}; };

View File

@ -5,18 +5,16 @@
* Dhanya-05.12.2012- included an additional header * Dhanya-05.12.2012- included an additional header
*/ */
#ifndef SLSQT2DZOOMER_H #ifndef SLSQT2DZOOMER_H
#define SLSQT2DZOOMER_H #define SLSQT2DZOOMER_H
/**included by Dhanya on 05.12.2012 to avoid compile time errors with the latest
* gcc*/
/**included by Dhanya on 05.12.2012 to avoid compile time errors with the latest gcc*/
#include <cstdio> #include <cstdio>
/**end of Change by Dhanya*/ /**end of Change by Dhanya*/
#include <qwt_plot_zoomer.h>
#include <qwt_plot_panner.h> #include <qwt_plot_panner.h>
#include <qwt_plot_zoomer.h>
#include "SlsQt2DHist.h" #include "SlsQt2DHist.h"
@ -25,36 +23,28 @@ class SlsQt2DZoomer:public QwtPlotZoomer{
SlsQt2DHist *hist; SlsQt2DHist *hist;
public: public:
SlsQt2DZoomer(QWidget *canvas) : QwtPlotZoomer(canvas) { SlsQt2DZoomer(QWidget *canvas) : QwtPlotZoomer(canvas) {
setTrackerMode(AlwaysOn); setTrackerMode(AlwaysOn);
} }
void SetHist(SlsQt2DHist* h){ void SetHist(SlsQt2DHist *h) { hist = h; }
hist=h;
}
virtual QwtText trackerTextF(const QPointF &pos) const { virtual QwtText trackerTextF(const QPointF &pos) const {
QColor bg(Qt::white); QColor bg(Qt::white);
bg.setAlpha(200); bg.setAlpha(200);
// QwtText text = QwtPlotZoomer::trackerText(pos); // QwtText text = QwtPlotZoomer::trackerText(pos);
static QwtText text; static QwtText text;
if (hist) { if (hist) {
static char t[200]; static char t[200];
sprintf(t,"%3.2f, %3.2f, %3.2f",pos.x(),pos.y(),hist->value(pos.x(),pos.y())); sprintf(t, "%3.2f, %3.2f, %3.2f", pos.x(), pos.y(),
hist->value(pos.x(), pos.y()));
text.setText(t); text.setText(t);
} else { } else {
QPoint p = pos.toPoint(); QPoint p = pos.toPoint();
QwtText text = QwtPlotZoomer::trackerText(p); QwtText text = QwtPlotZoomer::trackerText(p);
} }
text.setBackgroundBrush(QBrush(bg)); text.setBackgroundBrush(QBrush(bg));
return text; return text;

82
slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx Executable file → Normal file
View File

@ -5,6 +5,7 @@
*/ */
#include "SlsQt1DPlot.h" #include "SlsQt1DPlot.h"
#include "qwt_symbol.h"
#include <iostream> #include <iostream>
#include <qwt_legend.h> #include <qwt_legend.h>
#include <qwt_math.h> #include <qwt_math.h>
@ -14,19 +15,18 @@
#include <qwt_scale_draw.h> #include <qwt_scale_draw.h>
#include <qwt_scale_engine.h> #include <qwt_scale_engine.h>
#include <qwt_scale_widget.h> #include <qwt_scale_widget.h>
#include "qwt_symbol.h"
#include <stdlib.h> #include <stdlib.h>
#define QwtLog10ScaleEngine QwtLogScaleEngine // hmm #define QwtLog10ScaleEngine QwtLogScaleEngine // hmm
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data)
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title), x(nullptr), y(nullptr), pen_ptr(nullptr) { : QwtPlotCurve(title), x(nullptr), y(nullptr), pen_ptr(nullptr) {
Initailize(); Initailize();
SetData(n, min, max, data); SetData(n, min, max, data);
} }
SlsQtH1D::SlsQtH1D(QString title, int n, double *data_x, double *data_y) : QwtPlotCurve(title) { SlsQtH1D::SlsQtH1D(QString title, int n, double *data_x, double *data_y)
: QwtPlotCurve(title) {
Initailize(); Initailize();
SetData(n, data_x, data_y); SetData(n, data_x, data_y);
} }
@ -139,7 +139,6 @@ void SlsQtH1D::setSymbolMarkers(bool isMarker) {
marker->setSize(5, 5); marker->setSize(5, 5);
} }
setSymbol(marker); setSymbol(marker);
} }
void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data) { void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data) {
@ -170,9 +169,7 @@ void SlsQtH1D::SetData(int n, double xmin, double xmax, double *data) {
firstYgt0 = y[i]; firstYgt0 = y[i];
} }
setRawSamples(x, y, ndata); setRawSamples(x, y, ndata);
} }
void SlsQtH1D::SetData(int n, double *data_x, double *data_y) { void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
@ -202,7 +199,6 @@ void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
firstYgt0 = y[b]; firstYgt0 = y[b];
} }
setRawSamples(x, y, ndata); setRawSamples(x, y, ndata);
} }
int SlsQtH1D::SetUpArrays(int n) { int SlsQtH1D::SetUpArrays(int n) {
@ -225,7 +221,9 @@ double SlsQtH1D::FillBin(int bx, double v) {
bx = CheckIndex(bx); bx = CheckIndex(bx);
return SetBinContent(bx, y[bx] + v); return SetBinContent(bx, y[bx] + v);
} }
double SlsQtH1D::Fill(double x, double v) { return FillBin(FindBinIndex(x), v); } double SlsQtH1D::Fill(double x, double v) {
return FillBin(FindBinIndex(x), v);
}
double SlsQtH1D::SetBinContent(int bx, double v) { double SlsQtH1D::SetBinContent(int bx, double v) {
bx = CheckIndex(bx); bx = CheckIndex(bx);
@ -241,7 +239,9 @@ double SlsQtH1D::SetBinContent(int bx, double v) {
return y[bx]; return y[bx];
} }
double SlsQtH1D::SetContent(double x, double v) { return SetBinContent(FindBinIndex(x), v); } double SlsQtH1D::SetContent(double x, double v) {
return SetBinContent(FindBinIndex(x), v);
}
int SlsQtH1D::FindBinIndex(double px) { int SlsQtH1D::FindBinIndex(double px) {
if (dx > 0) if (dx > 0)
@ -261,7 +261,9 @@ int SlsQtH1D::FindBinIndex(double px) {
return b; return b;
} }
int SlsQtH1D::CheckIndex(int bx) { return (bx < 0 || bx > ndata) ? ndata : bx; } //ndata is the overflow bin int SlsQtH1D::CheckIndex(int bx) {
return (bx < 0 || bx > ndata) ? ndata : bx;
} // ndata is the overflow bin
SlsQtH1D *SlsQtH1D::Add(double v) { SlsQtH1D *SlsQtH1D::Add(double v) {
for (int bx = 0; bx < ndata; bx++) for (int bx = 0; bx < ndata; bx++)
@ -275,10 +277,7 @@ SlsQtH1DList::SlsQtH1DList(SlsQtH1D *hist) {
the_next = 0; the_next = 0;
} }
SlsQtH1DList::~SlsQtH1DList() { SlsQtH1DList::~SlsQtH1DList() { delete the_next; }
delete the_next;
}
SlsQtH1D *SlsQtH1DList::Add(SlsQtH1D *hist) { SlsQtH1D *SlsQtH1DList::Add(SlsQtH1D *hist) {
SlsQtH1DList *hl = this; SlsQtH1DList *hl = this;
@ -304,7 +303,8 @@ void SlsQtH1DList::Print() {
SlsQtH1DList *hl = this; SlsQtH1DList *hl = this;
int i = 0; int i = 0;
while (hl) { while (hl) {
std::cout << " " << i++ << ") " << hl << " " << hl->the_hist << " " << hl->the_next << '\n'; std::cout << " " << i++ << ") " << hl << " " << hl->the_hist << " "
<< hl->the_next << '\n';
hl = hl->the_next; hl = hl->the_next;
if (i > 10) if (i > 10)
break; break;
@ -389,13 +389,9 @@ void SlsQt1DPlot::HistogramDetached(SlsQtH1D *h) {
Update(); Update();
} }
void SlsQt1DPlot::Update() { void SlsQt1DPlot::Update() { replot(); }
replot();
}
void SlsQt1DPlot::SetTitle(QString title) { void SlsQt1DPlot::SetTitle(QString title) { setTitle(title); }
setTitle(title);
}
void SlsQt1DPlot::SetXTitle(QString title) { void SlsQt1DPlot::SetXTitle(QString title) {
setAxisTitle(QwtPlot::xBottom, title); setAxisTitle(QwtPlot::xBottom, title);
@ -434,7 +430,8 @@ void SlsQt1DPlot::SetLog(int axisId, bool yes) {
zoomer->ResetZoomBase(); // needs to be done before setting Engine zoomer->ResetZoomBase(); // needs to be done before setting Engine
//the old ones are deleted by in the setAxisScaleFunction() function see: 128 of file qwt_plot_axis.cpp // the old ones are deleted by in the setAxisScaleFunction() function see:
// 128 of file qwt_plot_axis.cpp
if (yes) if (yes)
setAxisScaleEngine(axisId, new QwtLog10ScaleEngine()); setAxisScaleEngine(axisId, new QwtLog10ScaleEngine());
else else
@ -450,11 +447,13 @@ void SlsQt1DPlot::UnZoom() {
setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w()); setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w());
setAxisScale(QwtPlot::yLeft, zoomer->y(), zoomer->y() + zoomer->h()); setAxisScale(QwtPlot::yLeft, zoomer->y(), zoomer->y() + zoomer->h());
zoomer->setZoomBase(); //Call replot for the attached plot before initializing the zoomer with its scales. zoomer->setZoomBase(); // Call replot for the attached plot before
// initializing the zoomer with its scales.
Update(); Update();
} }
void SlsQt1DPlot::SetZoom(double xmin, double ymin, double x_width, double y_width) { void SlsQt1DPlot::SetZoom(double xmin, double ymin, double x_width,
double y_width) {
setAxisScale(QwtPlot::xBottom, xmin, xmin + x_width); setAxisScale(QwtPlot::xBottom, xmin, xmin + x_width);
setAxisScale(QwtPlot::yLeft, ymin, ymin + y_width); setAxisScale(QwtPlot::yLeft, ymin, ymin + y_width);
Update(); Update();
@ -503,9 +502,11 @@ void SlsQt1DPlot::SetupZoom() {
zoomer = new SlsQt1DZoomer(canvas()); zoomer = new SlsQt1DZoomer(canvas());
#if QT_VERSION < 0x040000 #if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
Qt::ControlButton);
#else #else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
Qt::ControlModifier);
#endif #endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
@ -546,32 +547,39 @@ void SlsQt1DPlot::alignScales() {
void SlsQt1DPlot::UnknownStuff() { void SlsQt1DPlot::UnknownStuff() {
// We don't need the cache here // We don't need the cache here
((QwtPlotCanvas *)canvas())->setPaintAttribute(QwtPlotCanvas::BackingStore, false); ((QwtPlotCanvas *)canvas())
->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
#ifdef Q_WS_X11 #ifdef Q_WS_X11
// Qt::WA_PaintOnScreen is only supported for X11, but leads // Qt::WA_PaintOnScreen is only supported for X11, but leads
// to substantial bugs with Qt 4.2.x/Windows // to substantial bugs with Qt 4.2.x/Windows
canvas()->setAttribute(Qt::WA_PaintOnScreen, true); canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#endif #endif
} }
//Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range has been set // Added by Dhanya on 19.06.2012 to disable zooming when any of the axes range
// has been set
void SlsQt1DPlot::DisableZoom(bool disable) { void SlsQt1DPlot::DisableZoom(bool disable) {
if (disableZoom != disable) { if (disableZoom != disable) {
disableZoom = disable; disableZoom = disable;
if (disable) { if (disable) {
if (zoomer) { if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier); Qt::NoButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::NoButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::NoButton);
} }
if (panner) if (panner)
panner->setMouseButton(Qt::NoButton); panner->setMouseButton(Qt::NoButton);
} else { } else {
if (zoomer) { if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); Qt::LeftButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
} }
if (panner) if (panner)
panner->setMouseButton(Qt::MidButton); panner->setMouseButton(Qt::MidButton);

View File

@ -4,7 +4,6 @@
* @version 1.0 * @version 1.0
*/ */
#include <iostream> #include <iostream>
#include <qwt_plot.h> #include <qwt_plot.h>
@ -13,29 +12,36 @@
#include "SlsQt1DPlot.h" #include "SlsQt1DPlot.h"
#include "SlsQt1DZoomer.h" #include "SlsQt1DZoomer.h"
void SlsQt1DZoomer::ResetZoomBase() { void SlsQt1DZoomer::ResetZoomBase() {
SetZoomBase(x0,y0,x1-x0,y1-y0); //for going between log and nonlog plots SetZoomBase(x0, y0, x1 - x0,
y1 - y0); // for going between log and nonlog plots
} }
void SlsQt1DZoomer::SetZoomBase(double xmin,double ymin,double x_width, double y_width){ void SlsQt1DZoomer::SetZoomBase(double xmin, double ymin, double x_width,
double y_width) {
if (xIsLog && xmin <= 0) { if (xIsLog && xmin <= 0) {
double xmax = xmin + x_width; double xmax = xmin + x_width;
xmin = firstXgt0 * 0.98; xmin = firstXgt0 * 0.98;
if(xmax<=xmin) x_width=firstXgt0; if (xmax <= xmin)
else x_width=xmax-xmin; x_width = firstXgt0;
else
x_width = xmax - xmin;
} }
if (yIsLog && ymin <= 0) { if (yIsLog && ymin <= 0) {
double ymax = ymin + y_width; double ymax = ymin + y_width;
ymin = firstYgt0 * 0.98; ymin = firstYgt0 * 0.98;
if(ymax<=ymin) y_width=firstYgt0; if (ymax <= ymin)
else y_width=ymax-ymin; y_width = firstYgt0;
else
y_width = ymax - ymin;
} }
if (plot()) { if (plot()) {
if (xIsLog) { if (xIsLog) {
double xmin_curr = plot()->axisScaleDiv(QwtPlot::xBottom).lowerBound(); double xmin_curr =
double xmax_curr = plot()->axisScaleDiv(QwtPlot::xBottom).upperBound(); plot()->axisScaleDiv(QwtPlot::xBottom).lowerBound();
double xmax_curr =
plot()->axisScaleDiv(QwtPlot::xBottom).upperBound();
if (xmin_curr < xmin) if (xmin_curr < xmin)
xmin_curr = xmin; xmin_curr = xmin;
if (xmax_curr > xmin + x_width) if (xmax_curr > xmin + x_width)
@ -43,8 +49,10 @@ void SlsQt1DZoomer::SetZoomBase(double xmin,double ymin,double x_width, double y
plot()->setAxisScale(QwtPlot::xBottom, xmin_curr, xmax_curr); plot()->setAxisScale(QwtPlot::xBottom, xmin_curr, xmax_curr);
} }
if (yIsLog) { if (yIsLog) {
double ymin_curr = plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound(); double ymin_curr =
double ymax_curr = plot()->axisScaleDiv(QwtPlot::yLeft).upperBound(); plot()->axisScaleDiv(QwtPlot::yLeft).lowerBound();
double ymax_curr =
plot()->axisScaleDiv(QwtPlot::yLeft).upperBound();
if (ymin_curr < ymin) if (ymin_curr < ymin)
ymin_curr = ymin; ymin_curr = ymin;
if (ymax_curr > ymin + y_width) if (ymax_curr > ymin + y_width)
@ -54,7 +62,6 @@ void SlsQt1DZoomer::SetZoomBase(double xmin,double ymin,double x_width, double y
plot()->replot(); plot()->replot();
} }
setZoomBase(QRectF(xmin, ymin, x_width, y_width)); setZoomBase(QRectF(xmin, ymin, x_width, y_width));
} }
void SlsQt1DZoomer::SetZoomBase(SlsQtH1D *h) { void SlsQt1DZoomer::SetZoomBase(SlsQtH1D *h) {
@ -75,16 +82,19 @@ void SlsQt1DZoomer::ExtendZoomBase(SlsQtH1D* h){
double h_y0 = h->GetYMin() < 0 ? h->GetYMin() * 1.02 : h->GetYMin() / 1.02; double h_y0 = h->GetYMin() < 0 ? h->GetYMin() * 1.02 : h->GetYMin() / 1.02;
double h_y1 = h->GetYMax() < 0 ? h->GetYMax() / 1.02 : h->GetYMax() * 1.02; double h_y1 = h->GetYMax() < 0 ? h->GetYMax() / 1.02 : h->GetYMax() * 1.02;
if(h_x0<x0) x0 = h_x0; if (h_x0 < x0)
if(h_x1>x1) x1 = h_x1; x0 = h_x0;
if(h_y0<y0) y0 = h_y0; if (h_x1 > x1)
if(h_y1>y1) y1 = h_y1; x1 = h_x1;
if (h_y0 < y0)
y0 = h_y0;
if (h_y1 > y1)
y1 = h_y1;
if(h->GetFirstXgtZero()<firstXgt0) firstXgt0 = h->GetFirstXgtZero(); if (h->GetFirstXgtZero() < firstXgt0)
if(h->GetFirstYgtZero()<firstYgt0) firstYgt0 = h->GetFirstYgtZero(); firstXgt0 = h->GetFirstXgtZero();
if (h->GetFirstYgtZero() < firstYgt0)
firstYgt0 = h->GetFirstYgtZero();
ResetZoomBase(); ResetZoomBase();
} }

68
slsDetectorGui/slsDetectorPlotting/src/SlsQt2DHist.cxx Executable file → Normal file
View File

@ -4,28 +4,36 @@
* @version 1.0 * @version 1.0
*/ */
#include "ansi.h"
#include <iostream>
#include <cmath>
#include "SlsQt2DHist.h" #include "SlsQt2DHist.h"
#include "ansi.h"
#include <cmath>
#include <iostream>
using std::cout; using std::cout;
using std::endl; using std::endl;
SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, double* d,double zmin,double zmax):QwtRasterData(){ SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy,
x_min=0;x_max=0;y_min=0;y_max=0; double ymin, double ymax, double *d, double zmin,
double zmax)
: QwtRasterData() {
x_min = 0;
x_max = 0;
y_min = 0;
y_max = 0;
interp = 0; interp = 0;
nx_array=ny_array=0;data=0; nx_array = ny_array = 0;
data = 0;
SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d, zmin, zmax); SetData(nbinsx, xmin, xmax, nbinsy, ymin, ymax, d, zmin, zmax);
} }
SlsQt2DHist::~SlsQt2DHist() { delete[] data; } SlsQt2DHist::~SlsQt2DHist() { delete[] data; }
int SlsQt2DHist::GetBinIndex(int bx, int by) { int SlsQt2DHist::GetBinIndex(int bx, int by) {
int b = bx * ny + by; int b = bx * ny + by;
if (b < 0 || b >= nb) { if (b < 0 || b >= nb) {
cout<<"GetBinIndex:: Incorrect indicies bx and by returning overflow bin;"<<endl; cout << "GetBinIndex:: Incorrect indicies bx and by returning overflow "
"bin;"
<< endl;
return nb; return nb;
} }
return b; return b;
@ -39,28 +47,34 @@ double SlsQt2DHist::GetBinValue(int bx,int by){
return data[GetBinIndex(bx, by)]; return data[GetBinIndex(bx, by)];
} }
void SlsQt2DHist::SetBinValue(int bx, int by, double v) { void SlsQt2DHist::SetBinValue(int bx, int by, double v) {
z_mean_has_been_calculated = 0; z_mean_has_been_calculated = 0;
data[GetBinIndex(bx, by)] = v; data[GetBinIndex(bx, by)] = v;
} }
void SlsQt2DHist::SetData(int nbinsx, double xmin, double xmax, int nbinsy,double ymin, double ymax, double *d,double zmin,double zmax){ void SlsQt2DHist::SetData(int nbinsx, double xmin, double xmax, int nbinsy,
double ymin, double ymax, double *d, double zmin,
double zmax) {
z_mean_has_been_calculated = 0; z_mean_has_been_calculated = 0;
if(xmax<xmin||ymax<ymin) cout<<"Warning input range invalid."<<endl; if (xmax < xmin || ymax < ymin)
cout << "Warning input range invalid." << endl;
x_width = (xmax - xmin) / nbinsx; x_width = (xmax - xmin) / nbinsx;
y_width = (ymax - ymin) / nbinsy; y_width = (ymax - ymin) / nbinsy;
if (x_min != xmin || x_max != xmax || y_min != ymin || y_max != ymax) { if (x_min != xmin || x_max != xmax || y_min != ymin || y_max != ymax) {
x_min=xmin;x_max=xmax; x_min = xmin;
y_min=ymin;y_max=ymax; x_max = xmax;
y_min = ymin;
y_max = ymax;
setInterval(Qt::XAxis, QwtInterval(xmin, xmax)); setInterval(Qt::XAxis, QwtInterval(xmin, xmax));
setInterval(Qt::YAxis, QwtInterval(ymin, ymax)); setInterval(Qt::YAxis, QwtInterval(ymin, ymax));
} }
if (nbinsx * nbinsy < 1) { if (nbinsx * nbinsy < 1) {
cout<<"Exitting: SlsQt2DHist::SetData() number of bins must be greater than zero."<<endl; cout << "Exitting: SlsQt2DHist::SetData() number of bins must be "
"greater than zero."
<< endl;
exit(1); exit(1);
} }
@ -91,13 +105,21 @@ void SlsQt2DHist::SetMinMax(double zmin,double zmax){
z_mean = 0; z_mean = 0;
z_max = data[0]; z_max = data[0];
for (int i = 0; i < nb; i++) { for (int i = 0; i < nb; i++) {
if(data[i]<z_min) z_min=data[i]; if (data[i] < z_min)
if(data[i]>z_max) z_max=data[i]; z_min = data[i];
if (data[i] > z_max)
z_max = data[i];
z_mean += data[i]; z_mean += data[i];
} }
z_mean /= nb; z_mean /= nb;
if(z_min>0) z_min/=1.02; else z_min*=1.02; if (z_min > 0)
if(z_max>0) z_max*=1.02; else z_max/=1.02; z_min /= 1.02;
else
z_min *= 1.02;
if (z_max > 0)
z_max *= 1.02;
else
z_max /= 1.02;
} }
setInterval(Qt::ZAxis, QwtInterval(z_min, z_max)); setInterval(Qt::ZAxis, QwtInterval(z_min, z_max));
} }
@ -106,7 +128,8 @@ double SlsQt2DHist::GetMean(){
if (!z_mean_has_been_calculated) { if (!z_mean_has_been_calculated) {
z_mean_has_been_calculated = 1; z_mean_has_been_calculated = 1;
z_mean = 0; z_mean = 0;
for(int i=0;i<nb;i++) z_mean+=data[i]; for (int i = 0; i < nb; i++)
z_mean += data[i];
z_mean /= nb; z_mean /= nb;
} }
@ -116,13 +139,10 @@ double SlsQt2DHist::GetMean(){
double SlsQt2DHist::SetMinimumToFirstGreaterThanZero() { double SlsQt2DHist::SetMinimumToFirstGreaterThanZero() {
z_min = fabs(z_max) + 1; z_min = fabs(z_max) + 1;
for (int i = 0; i < nb; i++) { for (int i = 0; i < nb; i++) {
if(data[i]>0 && data[i]<z_min) z_min=data[i]; if (data[i] > 0 && data[i] < z_min)
z_min = data[i];
} }
setInterval(Qt::ZAxis, QwtInterval(z_min, z_max)); setInterval(Qt::ZAxis, QwtInterval(z_min, z_max));
return z_min; return z_min;
} }

57
slsDetectorGui/slsDetectorPlotting/src/SlsQt2DPlot.cxx Executable file → Normal file
View File

@ -19,12 +19,8 @@
#include <qwt_scale_engine.h> #include <qwt_scale_engine.h>
#include <qwt_scale_widget.h> #include <qwt_scale_widget.h>
#define QwtLog10ScaleEngine QwtLogScaleEngine // hmm remove? #define QwtLog10ScaleEngine QwtLogScaleEngine // hmm remove?
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) { SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
isLog = 0; isLog = 0;
axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating); axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating);
@ -40,7 +36,6 @@ SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
Update(); Update();
} }
SlsQt2DPlot::~SlsQt2DPlot() { SlsQt2DPlot::~SlsQt2DPlot() {
if (d_spectrogram) { if (d_spectrogram) {
d_spectrogram->detach(); d_spectrogram->detach();
@ -53,9 +48,7 @@ SlsQt2DPlot::~SlsQt2DPlot() {
delete panner; delete panner;
} }
void SlsQt2DPlot::SetTitle(QString title) { void SlsQt2DPlot::SetTitle(QString title) { setTitle(title); }
setTitle(title);
}
void SlsQt2DPlot::SetXTitle(QString title) { void SlsQt2DPlot::SetXTitle(QString title) {
setAxisTitle(QwtPlot::xBottom, title); setAxisTitle(QwtPlot::xBottom, title);
@ -105,7 +98,6 @@ void SlsQt2DPlot::SetupColorMap() {
for (double level = 0.5; level < 10.0; level += 1.0) for (double level = 0.5; level < 10.0; level += 1.0)
(contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10; (contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10;
// A color bar on the right axis // A color bar on the right axis
rightAxis = axisWidget(QwtPlot::yRight); rightAxis = axisWidget(QwtPlot::yRight);
@ -124,7 +116,8 @@ void SlsQt2DPlot::FillTestPlot(int mode) {
double dmax = sqrt(pow(nx / 2.0 - 0.5, 2) + pow(ny / 2.0 - 0.5, 2)); double dmax = sqrt(pow(nx / 2.0 - 0.5, 2) + pow(ny / 2.0 - 0.5, 2));
for (int i = 0; i < nx; i++) { for (int i = 0; i < nx; i++) {
for (int j = 0; j < ny; j++) { for (int j = 0; j < ny; j++) {
double d = sqrt(pow(nx / 2.0 - (i + 0.5), 2) + pow(ny / 2.0 - (j + 0.5), 2)); double d = sqrt(pow(nx / 2.0 - (i + 0.5), 2) +
pow(ny / 2.0 - (j + 0.5), 2));
if (mode % 3) if (mode % 3)
the_data[i + j * nx] = 10 * d / dmax; the_data[i + j * nx] = 10 * d / dmax;
@ -146,9 +139,11 @@ void SlsQt2DPlot::SetupZoom() {
zoomer->SetHist(hist); zoomer->SetHist(hist);
#if QT_VERSION < 0x040000 #if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
Qt::ControlButton);
#else #else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
Qt::ControlModifier);
#endif #endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
@ -177,12 +172,16 @@ void SlsQt2DPlot::SetupZoom() {
void SlsQt2DPlot::UnZoom(bool replot) { void SlsQt2DPlot::UnZoom(bool replot) {
zoomer->setZoomBase(QRectF(hist->GetXMin(), hist->GetYMin(), hist->GetXMax() - hist->GetXMin(), hist->GetYMax() - hist->GetYMin())); zoomer->setZoomBase(QRectF(hist->GetXMin(), hist->GetYMin(),
zoomer->setZoomBase(replot); //Call replot for the attached plot before initializing the zoomer with its scales. hist->GetXMax() - hist->GetXMin(),
hist->GetYMax() - hist->GetYMin()));
zoomer->setZoomBase(replot); // Call replot for the attached plot before
// initializing the zoomer with its scales.
// zoomer->zoom(0); // zoomer->zoom(0);
} }
void SlsQt2DPlot::SetZoom(double xmin, double ymin, double x_width, double y_width) { void SlsQt2DPlot::SetZoom(double xmin, double ymin, double x_width,
double y_width) {
zoomer->setZoomBase(QRectF(xmin, ymin, x_width, y_width)); zoomer->setZoomBase(QRectF(xmin, ymin, x_width, y_width));
} }
@ -198,25 +197,33 @@ void SlsQt2DPlot::DisableZoom(bool disable) {
#endif #endif
if (disable) { if (disable) {
if (zoomer) { if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
Qt::NoButton);
#if QT_VERSION < 0x040000 #if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::NoButton, Qt::ControlButton);
#else #else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier); zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::NoButton, Qt::ControlModifier);
#endif #endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::NoButton);
} }
if (panner) if (panner)
panner->setMouseButton(Qt::NoButton); panner->setMouseButton(Qt::NoButton);
} else { } else {
if (zoomer) { if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
Qt::LeftButton);
#if QT_VERSION < 0x040000 #if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlButton);
#else #else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier);
#endif #endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
} }
if (panner) if (panner)
panner->setMouseButton(Qt::MidButton); panner->setMouseButton(Qt::MidButton);
@ -224,7 +231,6 @@ void SlsQt2DPlot::DisableZoom(bool disable) {
} }
} }
void SlsQt2DPlot::SetZMinMax(double zmin, double zmax) { void SlsQt2DPlot::SetZMinMax(double zmin, double zmax) {
hist->SetMinMax(zmin, zmax); hist->SetMinMax(zmin, zmax);
} }
@ -294,7 +300,8 @@ void SlsQt2DPlot::SetContour(bool enable) {
Update(); Update();
} }
void SlsQt2DPlot::SetLogz(bool enable, bool isMin, bool isMax, double min, double max) { void SlsQt2DPlot::SetLogz(bool enable, bool isMin, bool isMax, double min,
double max) {
LogZ(enable); LogZ(enable);
SetZRange(isMin, isMax, min, max); SetZRange(isMin, isMax, min, max);
} }

61
slsDetectorGui/src/qCloneWidget.cpp Executable file → Normal file
View File

@ -1,7 +1,7 @@
#include "qCloneWidget.h" #include "qCloneWidget.h"
#include "qDefs.h"
#include "SlsQt1DPlot.h" #include "SlsQt1DPlot.h"
#include "SlsQt2DPlot.h" #include "SlsQt2DPlot.h"
#include "qDefs.h"
#include <QCloseEvent> #include <QCloseEvent>
#include <QFileDialog> #include <QFileDialog>
@ -11,10 +11,13 @@
int qCloneWidget::NumClones{0}; int qCloneWidget::NumClones{0};
qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot* p1, SlsQt2DPlot* p2, SlsQt1DPlot *gp1, SlsQt2DPlot* gp, qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2,
QString title, QString fPath, QString fName, int64_t aIndex, SlsQt1DPlot *gp1, SlsQt2DPlot *gp, QString title,
bool displayStats, QString min, QString max, QString sum): QString fPath, QString fName, int64_t aIndex,
QMainWindow(parent), plot1d(p1), plot2d(p2), gainplot1d(gp1), gainplot2d(gp), filePath(fPath), fileName(fName), acqIndex(aIndex) { bool displayStats, QString min, QString max,
QString sum)
: QMainWindow(parent), plot1d(p1), plot2d(p2), gainplot1d(gp1),
gainplot2d(gp), filePath(fPath), fileName(fName), acqIndex(aIndex) {
setupUi(this); setupUi(this);
id = qCloneWidget::NumClones++; id = qCloneWidget::NumClones++;
SetupWidgetWindow(title); SetupWidgetWindow(title);
@ -34,7 +37,8 @@ qCloneWidget::~qCloneWidget() {
void qCloneWidget::SetupWidgetWindow(QString title) { void qCloneWidget::SetupWidgetWindow(QString title) {
std::string winTitle = std::string("Snapshot:") + std::to_string(id) + std::string(" - ") + NowTime(); std::string winTitle = std::string("Snapshot:") + std::to_string(id) +
std::string(" - ") + NowTime();
setWindowTitle(QString(winTitle.c_str())); setWindowTitle(QString(winTitle.c_str()));
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
@ -57,7 +61,8 @@ void qCloneWidget::SetupWidgetWindow(QString title) {
} else { } else {
int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1; int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1;
plotLayout->addWidget(plot2d, 0, 0, ratio, ratio); plotLayout->addWidget(plot2d, 0, 0, ratio, ratio);
plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1, Qt::AlignRight | Qt::AlignTop); plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1,
Qt::AlignRight | Qt::AlignTop);
} }
} }
connect(actionSaveClone, SIGNAL(triggered()), this, SLOT(SavePlot())); connect(actionSaveClone, SIGNAL(triggered()), this, SLOT(SavePlot()));
@ -65,15 +70,19 @@ void qCloneWidget::SetupWidgetWindow(QString title) {
if (gainplot1d != nullptr) { if (gainplot1d != nullptr) {
gainplot1d->setMinimumHeight(qDefs::MIN_HEIGHT_GAIN_PLOT_1D); gainplot1d->setMinimumHeight(qDefs::MIN_HEIGHT_GAIN_PLOT_1D);
gainplot1d->setFixedWidth(plot1d->width()); gainplot1d->setFixedWidth(plot1d->width());
// gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO - 1); // gainplot1d->setFixedHeight(plot1d->height() /
// qDefs::DATA_GAIN_PLOT_RATIO - 1);
} }
if (gainplot2d != nullptr) { if (gainplot2d != nullptr) {
gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot2d->setFixedWidth(plot2d->width() /
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO); qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedHeight(plot2d->height() /
qDefs::DATA_GAIN_PLOT_RATIO);
} }
} }
void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString sum) { void qCloneWidget::DisplayStats(bool enable, QString min, QString max,
QString sum) {
if (enable) { if (enable) {
lblMinDisp->setText(QString("%1").arg(min)); lblMinDisp->setText(QString("%1").arg(min));
lblMaxDisp->setText(QString("%1").arg(max)); lblMaxDisp->setText(QString("%1").arg(max));
@ -88,20 +97,31 @@ void qCloneWidget::SavePlot() {
char cID[10]; char cID[10];
sprintf(cID, "%d", id); sprintf(cID, "%d", id);
// title // title
QString fName = filePath + QString('/') + fileName + QString("_clone") + QString("%1").arg(id) + QString("_acq") + QString("%1").arg(acqIndex) + QString(".png"); 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(); FILE_LOG(logINFO) << "Saving Clone:" << fName.toAscii().constData();
// save // save
QImage img(centralwidget->size().width(), centralwidget->size().height(), QImage::Format_RGB32); QImage img(centralwidget->size().width(), centralwidget->size().height(),
QImage::Format_RGB32);
QPainter painter(&img); QPainter painter(&img);
centralwidget->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); fName = QFileDialog::getSaveFileName(
this, tr("Save Snapshot "), fName,
tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), 0,
QFileDialog::ShowDirsOnly);
if (!fName.isEmpty()) { if (!fName.isEmpty()) {
if ((img.save(fName))) { if ((img.save(fName))) {
qDefs::Message(qDefs::INFORMATION, "The SnapShot has been successfully saved", "qCloneWidget::SavePlot"); qDefs::Message(qDefs::INFORMATION,
"The SnapShot has been successfully saved",
"qCloneWidget::SavePlot");
FILE_LOG(logINFO) << "The SnapShot has been successfully saved"; FILE_LOG(logINFO) << "The SnapShot has been successfully saved";
} else { } else {
qDefs::Message(qDefs::WARNING, "Attempt to save snapshot failed.\n Formats: .png, .jpg, .xpm.", "qCloneWidget::SavePlot"); qDefs::Message(
qDefs::WARNING,
"Attempt to save snapshot failed.\n Formats: .png, .jpg, .xpm.",
"qCloneWidget::SavePlot");
FILE_LOG(logWARNING) << "Attempt to save snapshot failed"; FILE_LOG(logWARNING) << "Attempt to save snapshot failed";
} }
} }
@ -110,11 +130,14 @@ void qCloneWidget::SavePlot() {
void qCloneWidget::resizeEvent(QResizeEvent *event) { void qCloneWidget::resizeEvent(QResizeEvent *event) {
if (gainplot1d != nullptr) { if (gainplot1d != nullptr) {
gainplot1d->setFixedWidth(plot1d->width()); gainplot1d->setFixedWidth(plot1d->width());
gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot1d->setFixedHeight(plot1d->height() /
qDefs::DATA_GAIN_PLOT_RATIO);
} }
if (gainplot2d != nullptr) { if (gainplot2d != nullptr) {
gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot2d->setFixedWidth(plot2d->width() /
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO); qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedHeight(plot2d->height() /
qDefs::DATA_GAIN_PLOT_RATIO);
} }
event->accept(); event->accept();
} }

24
slsDetectorGui/src/qDacWidget.cpp Executable file → Normal file
View File

@ -3,8 +3,9 @@
#include <iostream> #include <iostream>
qDacWidget::qDacWidget(QWidget *parent, sls::Detector *detector, bool d, std::string n, slsDetectorDefs::dacIndex i) : qDacWidget::qDacWidget(QWidget *parent, sls::Detector *detector, bool d,
QWidget(parent), det(detector), isDac(d), index(i){ std::string n, slsDetectorDefs::dacIndex i)
: QWidget(parent), det(detector), isDac(d), index(i) {
setupUi(this); setupUi(this);
SetupWidgetWindow(n); SetupWidgetWindow(n);
} }
@ -25,7 +26,6 @@ void qDacWidget::SetupWidgetWindow(std::string name) {
Refresh(); Refresh();
} }
void qDacWidget::Initialization() { void qDacWidget::Initialization() {
if (isDac) { if (isDac) {
connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac())); connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
@ -48,19 +48,23 @@ void qDacWidget::GetDac() {
// mv // mv
retval = det->getDAC(index, 1, {detectorIndex}).squash(-1); retval = det->getDAC(index, 1, {detectorIndex}).squash(-1);
lblDacmV->setText(QString("%1mV").arg(retval - 10)); lblDacmV->setText(QString("%1mV").arg(retval - 10));
} CATCH_DISPLAY(std::string("Could not get dac ") + std::to_string(index), "qDacWidget::GetDac") }
CATCH_DISPLAY(std::string("Could not get dac ") + std::to_string(index),
"qDacWidget::GetDac")
connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac())); connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
} }
void qDacWidget::SetDac() { void qDacWidget::SetDac() {
int val = (int)spinDac->value(); int val = (int)spinDac->value();
FILE_LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data() << " : " << val; FILE_LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data()
<< " : " << val;
try { try {
det->setDAC(index, val, 0, {detectorIndex}); det->setDAC(index, val, 0, {detectorIndex});
} CATCH_DISPLAY (std::string("Could not set dac ") + std::to_string(index), "qDacWidget::SetDac") }
CATCH_DISPLAY(std::string("Could not set dac ") + std::to_string(index),
"qDacWidget::SetDac")
// update mV anyway // update mV anyway
GetDac(); GetDac();
@ -76,8 +80,9 @@ void qDacWidget::GetAdc() {
} else { } else {
spinDac->setValue(retval); spinDac->setValue(retval);
} }
} CATCH_DISPLAY (std::string("Could not get adc ") + std::to_string(index), "qDacWidget::GetAdc") }
CATCH_DISPLAY(std::string("Could not get adc ") + std::to_string(index),
"qDacWidget::GetAdc")
} }
void qDacWidget::Refresh() { void qDacWidget::Refresh() {
@ -87,4 +92,3 @@ void qDacWidget::Refresh() {
GetAdc(); GetAdc();
} }
} }

118
slsDetectorGui/src/qDetectorMain.cpp Executable file → Normal file
View File

@ -1,25 +1,24 @@
#include "qDetectorMain.h" #include "qDetectorMain.h"
#include "qDefs.h" #include "qDefs.h"
#include "qDrawPlot.h" #include "qDrawPlot.h"
#include "qTabMeasurement.h"
#include "qTabDataOutput.h"
#include "qTabPlot.h"
#include "qTabAdvanced.h" #include "qTabAdvanced.h"
#include "qTabSettings.h" #include "qTabDataOutput.h"
#include "qTabDebugging.h" #include "qTabDebugging.h"
#include "qTabDeveloper.h" #include "qTabDeveloper.h"
#include "qTabMeasurement.h"
#include "qTabMessages.h" #include "qTabMessages.h"
#include "qTabPlot.h"
#include "qTabSettings.h"
#include "versionAPI.h"
#include "ToString.h" #include "ToString.h"
#include "versionAPI.h"
#include <QResizeEvent>
#include <QScrollArea>
#include <QFileDialog> #include <QFileDialog>
#include <QPlastiqueStyle> #include <QPlastiqueStyle>
#include <QResizeEvent>
#include <QScrollArea>
#include <QSizePolicy> #include <QSizePolicy>
#include <iostream>
#include <getopt.h> #include <getopt.h>
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -94,7 +93,6 @@ int main(int argc, char **argv) {
} }
} }
QApplication app(argc, argv); QApplication app(argc, argv);
app.setStyle(new QPlastiqueStyle); app.setStyle(new QPlastiqueStyle);
// app.setWindowIcon(QIcon(":/icons/images/mountain.png")); // app.setWindowIcon(QIcon(":/icons/images/mountain.png"));
@ -133,7 +131,8 @@ void qDetectorMain::SetUpWidgetWindow() {
layoutTabs->addWidget(tabs.get()); layoutTabs->addWidget(tabs.get());
// creating all the other tab widgets // creating all the other tab widgets
tabMeasurement = sls::make_unique<qTabMeasurement>(this, det.get(), plot.get()); tabMeasurement =
sls::make_unique<qTabMeasurement>(this, det.get(), plot.get());
tabDataOutput = sls::make_unique<qTabDataOutput>(this, det.get()); tabDataOutput = sls::make_unique<qTabDataOutput>(this, det.get());
tabPlot = sls::make_unique<qTabPlot>(this, det.get(), plot.get()); tabPlot = sls::make_unique<qTabPlot>(this, det.get(), plot.get());
tabSettings = sls::make_unique<qTabSettings>(this, det.get()); tabSettings = sls::make_unique<qTabSettings>(this, det.get());
@ -219,7 +218,8 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
LoadConfigFile(fName); LoadConfigFile(fName);
// validate detector type (for GUI) and update menu // validate detector type (for GUI) and update menu
detType = det->getDetectorType().tsquash("Different detector type for all modules."); detType = det->getDetectorType().tsquash(
"Different detector type for all modules.");
actionLoadTrimbits->setEnabled(false); actionLoadTrimbits->setEnabled(false);
switch (detType) { switch (detType) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
@ -233,15 +233,17 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
break; break;
default: default:
std::ostringstream os; std::ostringstream os;
os << det->getHostname() << " has " << os << det->getHostname() << " has "
sls::ToString(det->getDetectorType().squash()) << " detector type (" << << sls::ToString(det->getDetectorType().squash())
std::to_string(detType) << "). Exiting GUI."; << " detector type (" << std::to_string(detType)
<< "). Exiting GUI.";
std::string errorMess = os.str(); std::string errorMess = os.str();
throw sls::RuntimeError(errorMess.c_str()); throw sls::RuntimeError(errorMess.c_str());
} }
std::ostringstream os; std::ostringstream os;
os << "SLS Detector GUI : " << sls::ToString(det->getDetectorType().squash()) os << "SLS Detector GUI : "
<< " - " << det->getHostname(); << sls::ToString(det->getDetectorType().squash()) << " - "
<< det->getHostname();
std::string title = os.str(); std::string title = os.str();
FILE_LOG(logINFO) << title; FILE_LOG(logINFO) << title;
setWindowTitle(QString(title.c_str())); setWindowTitle(QString(title.c_str()));
@ -249,27 +251,36 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
void qDetectorMain::Initialization() { void qDetectorMain::Initialization() {
// Dockable Plot // Dockable Plot
connect(dockWidgetPlot, SIGNAL(topLevelChanged(bool)), this, SLOT(ResizeMainWindow(bool))); connect(dockWidgetPlot, SIGNAL(topLevelChanged(bool)), this,
SLOT(ResizeMainWindow(bool)));
// tabs // tabs
connect(tabs.get(),SIGNAL(currentChanged(int)), this, SLOT(Refresh(int)));//( QWidget*))); connect(tabs.get(), SIGNAL(currentChanged(int)), this,
SLOT(Refresh(int))); //( QWidget*)));
// Measurement tab // Measurement tab
connect(tabMeasurement.get(), SIGNAL(EnableTabsSignal(bool)), this, SLOT(EnableTabs(bool))); connect(tabMeasurement.get(), SIGNAL(EnableTabsSignal(bool)), this,
connect(tabMeasurement.get(), SIGNAL(FileNameChangedSignal(QString)), plot.get(), SLOT(SetSaveFileName(QString))); SLOT(EnableTabs(bool)));
connect(tabMeasurement.get(), SIGNAL(FileNameChangedSignal(QString)),
plot.get(), SLOT(SetSaveFileName(QString)));
// Plot tab // Plot tab
connect(tabPlot.get(), SIGNAL(DisableZoomSignal(bool)), this, SLOT(SetZoomToolTip(bool))); connect(tabPlot.get(), SIGNAL(DisableZoomSignal(bool)), this,
SLOT(SetZoomToolTip(bool)));
// Plotting // Plotting
connect(plot.get(), SIGNAL(AcquireFinishedSignal()), tabMeasurement.get(), SLOT(AcquireFinished())); connect(plot.get(), SIGNAL(AcquireFinishedSignal()), tabMeasurement.get(),
connect(plot.get(), SIGNAL(AbortSignal()), tabMeasurement.get(), SLOT(AbortAcquire())); SLOT(AcquireFinished()));
connect(plot.get(), SIGNAL(AbortSignal()), tabMeasurement.get(),
SLOT(AbortAcquire()));
// menubar // menubar
// Modes Menu // Modes Menu
connect(menuModes, SIGNAL(triggered(QAction *)), this, SLOT(EnableModes(QAction *))); connect(menuModes, SIGNAL(triggered(QAction *)), this,
SLOT(EnableModes(QAction *)));
// Utilities Menu // Utilities Menu
connect(menuUtilities, SIGNAL(triggered(QAction *)), this, SLOT(ExecuteUtilities(QAction *))); connect(menuUtilities, SIGNAL(triggered(QAction *)), this,
SLOT(ExecuteUtilities(QAction *)));
// Help Menu // Help Menu
connect(menuHelp, SIGNAL(triggered(QAction *)), this, SLOT(ExecuteHelp(QAction *))); connect(menuHelp, SIGNAL(triggered(QAction *)), this,
SLOT(ExecuteHelp(QAction *)));
} }
void qDetectorMain::LoadConfigFile(const std::string fName) { void qDetectorMain::LoadConfigFile(const std::string fName) {
@ -302,7 +313,9 @@ void qDetectorMain::LoadConfigFile(const std::string fName) {
} else { } else {
try { try {
det->loadConfig(fName); det->loadConfig(fName);
} CATCH_DISPLAY ("Could not load config file.", "qDetectorMain::LoadConfigFile") }
CATCH_DISPLAY("Could not load config file.",
"qDetectorMain::LoadConfigFile")
} }
} }
@ -313,8 +326,7 @@ void qDetectorMain::EnableModes(QAction *action) {
if (action == actionDebug) { if (action == actionDebug) {
enable = actionDebug->isChecked(); enable = actionDebug->isChecked();
tabs->setTabEnabled(DEBUGGING, enable); tabs->setTabEnabled(DEBUGGING, enable);
FILE_LOG(logINFO) << "Debug Mode: " FILE_LOG(logINFO) << "Debug Mode: " << qDefs::stringEnable(enable);
<< qDefs::stringEnable(enable);
} }
@ -323,9 +335,9 @@ void qDetectorMain::EnableModes(QAction *action) {
enable = actionExpert->isChecked(); enable = actionExpert->isChecked();
tabs->setTabEnabled(ADVANCED, enable); tabs->setTabEnabled(ADVANCED, enable);
actionLoadTrimbits->setVisible(enable && detType == slsDetectorDefs::EIGER); actionLoadTrimbits->setVisible(enable &&
FILE_LOG(logINFO) << "Expert Mode: " detType == slsDetectorDefs::EIGER);
<< qDefs::stringEnable(enable); FILE_LOG(logINFO) << "Expert Mode: " << qDefs::stringEnable(enable);
} }
// Set DockableMode // Set DockableMode
@ -337,8 +349,7 @@ void qDetectorMain::EnableModes(QAction *action) {
dockWidgetPlot->setFloating(false); dockWidgetPlot->setFloating(false);
dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures);
} }
FILE_LOG(logINFO) << "Dockable Mode: " FILE_LOG(logINFO) << "Dockable Mode: " << qDefs::stringEnable(enable);
<< qDefs::stringEnable(enable);
} }
} }
@ -355,8 +366,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
// Gets called when cancelled as well // Gets called when cancelled as well
if (!fName.isEmpty()) { if (!fName.isEmpty()) {
refreshTabs = true; refreshTabs = true;
det->loadConfig( det->loadConfig(std::string(fName.toAscii().constData()));
std::string(fName.toAscii().constData()));
qDefs::Message(qDefs::INFORMATION, qDefs::Message(qDefs::INFORMATION,
"The Configuration Parameters have been " "The Configuration Parameters have been "
"configured successfully.", "configured successfully.",
@ -375,19 +385,18 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
// Gets called when cancelled as well // Gets called when cancelled as well
if (!fName.isEmpty()) { if (!fName.isEmpty()) {
refreshTabs = true; refreshTabs = true;
det->loadParameters( det->loadParameters(std::string(fName.toAscii().constData()));
std::string(fName.toAscii().constData()));
qDefs::Message(qDefs::INFORMATION, qDefs::Message(qDefs::INFORMATION,
"The Detector Parameters have been " "The Detector Parameters have been "
"configured successfully.", "configured successfully.",
"qDetectorMain::ExecuteUtilities"); "qDetectorMain::ExecuteUtilities");
FILE_LOG(logINFO) FILE_LOG(logINFO) << "Parameters loaded successfully";
<< "Parameters loaded successfully";
} }
} }
else if (action == actionLoadTrimbits) { else if (action == actionLoadTrimbits) {
QString fName = QString((det->getSettingsPath().squash("/tmp/")).c_str()); QString fName =
QString((det->getSettingsPath().squash("/tmp/")).c_str());
FILE_LOG(logDEBUG) << "Loading Trimbits"; FILE_LOG(logDEBUG) << "Loading Trimbits";
// so that even nonexisting files can be selected // so that even nonexisting files can be selected
QFileDialog *fileDialog = new QFileDialog( QFileDialog *fileDialog = new QFileDialog(
@ -399,18 +408,16 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
// Gets called when cancelled as well // Gets called when cancelled as well
if (!fName.isEmpty()) { if (!fName.isEmpty()) {
det->loadTrimbits( det->loadTrimbits(std::string(fName.toAscii().constData()));
std::string(fName.toAscii().constData())); qDefs::Message(qDefs::INFORMATION,
qDefs::Message(
qDefs::INFORMATION,
"The Trimbits have been loaded successfully.", "The Trimbits have been loaded successfully.",
"qDetectorMain::ExecuteUtilities"); "qDetectorMain::ExecuteUtilities");
FILE_LOG(logINFO) << "Trimbits loaded successfully"; FILE_LOG(logINFO) << "Trimbits loaded successfully";
} }
} }
}
} CATCH_DISPLAY ("Could not execute utilities.", "qDetectorMain::ExecuteUtilities") CATCH_DISPLAY("Could not execute utilities.",
"qDetectorMain::ExecuteUtilities")
Refresh(tabs->currentIndex()); Refresh(tabs->currentIndex());
if (refreshTabs) { if (refreshTabs) {
@ -429,13 +436,16 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
void qDetectorMain::ExecuteHelp(QAction *action) { void qDetectorMain::ExecuteHelp(QAction *action) {
if (action == actionAbout) { if (action == actionAbout) {
FILE_LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, Gotthard, Gotthard2 and Moench detectors"; FILE_LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, "
"Gotthard, Gotthard2 and Moench detectors";
std::string guiVersion = std::to_string(APIGUI); std::string guiVersion = std::to_string(APIGUI);
std::string clientVersion = "unknown"; std::string clientVersion = "unknown";
try { try {
clientVersion = std::to_string(det->getClientVersion()); clientVersion = std::to_string(det->getClientVersion());
} CATCH_DISPLAY ("Could not get client version.", "qDetectorMain::ExecuteHelp") }
CATCH_DISPLAY("Could not get client version.",
"qDetectorMain::ExecuteHelp")
qDefs::Message(qDefs::INFORMATION, qDefs::Message(qDefs::INFORMATION,
"<p style=\"font-family:verdana;\">" "<p style=\"font-family:verdana;\">"
@ -446,7 +456,8 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
clientVersion + clientVersion +
"<br><br>" "<br><br>"
"Common GUI to control the SLS Detectors: " "Common GUI to control the SLS Detectors: "
"Jungfrau, Eiger, Mythen3, Gotthard, Gotthard2 and Moench.<br><br>" "Jungfrau, Eiger, Mythen3, Gotthard, Gotthard2 and "
"Moench.<br><br>"
"It can be operated in parallel with the command " "It can be operated in parallel with the command "
"line interface:<br>" "line interface:<br>"
"sls_detector_put,<br>sls_detector_get,<br>sls_" "sls_detector_put,<br>sls_detector_get,<br>sls_"
@ -553,7 +564,8 @@ void qDetectorMain::EnableTabs(bool enable) {
// expert // expert
bool expertTab = enable && (actionExpert->isChecked()); bool expertTab = enable && (actionExpert->isChecked());
tabs->setTabEnabled(ADVANCED, expertTab); tabs->setTabEnabled(ADVANCED, expertTab);
actionLoadTrimbits->setVisible(expertTab && detType == slsDetectorDefs::EIGER); actionLoadTrimbits->setVisible(expertTab &&
detType == slsDetectorDefs::EIGER);
// moved to here, so that its all in order, instead of signals and different // moved to here, so that its all in order, instead of signals and different
// threads // threads

323
slsDetectorGui/src/qDrawPlot.cpp Executable file → Normal file
View File

@ -5,15 +5,16 @@
#include "detectorData.h" #include "detectorData.h"
#include "qCloneWidget.h" #include "qCloneWidget.h"
#include "detectorData.h"
#include "ToString.h" #include "ToString.h"
#include "detectorData.h"
#include <QFileDialog> #include <QFileDialog>
#include <QPainter> #include <QPainter>
#include <QtConcurrentRun>
#include <QResizeEvent> #include <QResizeEvent>
#include <QtConcurrentRun>
qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector) : QWidget(parent), det(detector) { qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector)
: QWidget(parent), det(detector) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logINFO) << "Plots ready"; FILE_LOG(logINFO) << "Plots ready";
@ -21,8 +22,8 @@ qDrawPlot::qDrawPlot(QWidget *parent, sls::Detector *detector) : QWidget(parent)
qDrawPlot::~qDrawPlot() { qDrawPlot::~qDrawPlot() {
DetachHists(); DetachHists();
for (QVector<SlsQtH1D *>::iterator h = hists1d.begin(); for (QVector<SlsQtH1D *>::iterator h = hists1d.begin(); h != hists1d.end();
h != hists1d.end(); ++h){ ++h) {
delete *h; delete *h;
} }
@ -51,14 +52,16 @@ void qDrawPlot::SetupWidgetWindow() {
gainMask = (3 << 14); gainMask = (3 << 14);
gainOffset = 14; gainOffset = 14;
FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask
<< ", Gain Mask:" << gainMask << ", Gain Offset:" << std::dec << gainOffset; << ", Gain Mask:" << gainMask
<< ", Gain Offset:" << std::dec << gainOffset;
break; break;
case slsDetectorDefs::GOTTHARD2: case slsDetectorDefs::GOTTHARD2:
pixelMask = ((1 << 12) - 1); pixelMask = ((1 << 12) - 1);
gainMask = (3 << 12); gainMask = (3 << 12);
gainOffset = 12; gainOffset = 12;
FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask FILE_LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask
<< ", Gain Mask:" << gainMask << ", Gain Offset:" << std::dec << gainOffset; << ", Gain Mask:" << gainMask
<< ", Gain Offset:" << std::dec << gainOffset;
break; break;
default: default:
break; break;
@ -70,14 +73,16 @@ void qDrawPlot::SetupWidgetWindow() {
temp = det->getFileNamePrefix().squash("xxx"); temp = det->getFileNamePrefix().squash("xxx");
fileSaveName = QString(temp.c_str()); fileSaveName = QString(temp.c_str());
} catch (const std::exception &e) { } catch (const std::exception &e) {
qDefs::ExceptionMessage("Could not get file path or file name.", e.what(), "qDrawPlot::SetupWidgetWindow"); qDefs::ExceptionMessage("Could not get file path or file name.",
e.what(), "qDrawPlot::SetupWidgetWindow");
fileSavePath = "/tmp"; fileSavePath = "/tmp";
fileSaveName = "Image"; fileSaveName = "Image";
} }
SetupPlots(); SetupPlots();
SetDataCallBack(true); SetDataCallBack(true);
det->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack), this); det->registerAcquisitionFinishedCallback(&(GetAcquisitionFinishedCallBack),
this);
Initialization(); Initialization();
} }
@ -103,7 +108,8 @@ void qDrawPlot::SetupPlots() {
--nPixelsX; --nPixelsX;
} }
} }
} CATCH_DISPLAY ("Could not get quad.", "qDrawPlot::SetupPlots") }
CATCH_DISPLAY("Could not get quad.", "qDrawPlot::SetupPlots")
break; break;
default: default:
break; break;
@ -139,7 +145,8 @@ void qDrawPlot::SetupPlots() {
// setup 1d plot // setup 1d plot
plot1d = new SlsQt1DPlot(boxPlot); plot1d = new SlsQt1DPlot(boxPlot);
plot1d->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); plot1d->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
plot1d->SetTitleFont(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->SetXFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
plot1d->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); plot1d->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
plot1d->SetTitle(""); plot1d->SetTitle("");
@ -148,7 +155,6 @@ void qDrawPlot::SetupPlots() {
h->Attach(plot1d); h->Attach(plot1d);
plot1d->hide(); plot1d->hide();
delete[] gainDatay1d; delete[] gainDatay1d;
gainDatay1d = new double[nPixelsX]; gainDatay1d = new double[nPixelsX];
// default display data // default display data
@ -162,16 +168,20 @@ void qDrawPlot::SetupPlots() {
gainhist1d->setSymbolMarkers(isMarkers); gainhist1d->setSymbolMarkers(isMarkers);
// setup 1d gain plot // setup 1d gain plot
gainplot1d = new SlsQt1DPlot(boxPlot); gainplot1d = new SlsQt1DPlot(boxPlot);
gainplot1d->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); gainplot1d->SetTitleFont(
gainplot1d->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
gainplot1d->SetYFont(
QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
gainplot1d->SetTitle(""); gainplot1d->SetTitle("");
gainplot1d->SetYTitle("Gain"); gainplot1d->SetYTitle("Gain");
// set ticks to just 3 // set ticks to just 3
QList<double> majorTicks({0, 1, 2, 3}); QList<double> majorTicks({0, 1, 2, 3});
QwtScaleDiv div(0, 3, QList<double>(), QList<double>(), majorTicks); QwtScaleDiv div(0, 3, QList<double>(), QList<double>(), majorTicks);
gainplot1d->setAxisScaleDiv(QwtPlot::yLeft, div); gainplot1d->setAxisScaleDiv(QwtPlot::yLeft, div);
//gainplot1d->axisScaleDraw(QwtPlot::xBottom)->enableComponent(QwtScaleDraw::Ticks, false); // gainplot1d->axisScaleDraw(QwtPlot::xBottom)->enableComponent(QwtScaleDraw::Ticks,
//gainplot1d->axisScaleDraw(QwtPlot::yLeft)->enableComponent(QwtScaleDraw::Labels, false); // false);
// gainplot1d->axisScaleDraw(QwtPlot::yLeft)->enableComponent(QwtScaleDraw::Labels,
// false);
gainhist1d->setItemAttribute(QwtPlotItem::Legend, false); gainhist1d->setItemAttribute(QwtPlotItem::Legend, false);
gainhist1d->Attach(gainplot1d); gainhist1d->Attach(gainplot1d);
gainplot1d->hide(); gainplot1d->hide();
@ -199,10 +209,11 @@ void qDrawPlot::SetupPlots() {
sqrt(2); sqrt(2);
// setup 2d plot // setup 2d plot
plot2d = new SlsQt2DPlot(boxPlot); plot2d = new SlsQt2DPlot(boxPlot);
plot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, plot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5,
-0.5, nPixelsY - 0.5, data2d); nPixelsY - 0.5, data2d);
plot2d->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); plot2d->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
plot2d->SetTitleFont(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->SetXFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
plot2d->SetYFont(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->SetZFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
@ -212,8 +223,10 @@ void qDrawPlot::SetupPlots() {
plot2d->SetZTitle(zTitle2d); plot2d->SetZTitle(zTitle2d);
gainplot2d = new SlsQt2DPlot(boxPlot); gainplot2d = new SlsQt2DPlot(boxPlot);
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData); gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5,
gainplot2d->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); nPixelsY - 0.5, gainData);
gainplot2d->SetTitleFont(
QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
gainplot2d->setTitle("Gain"); gainplot2d->setTitle("Gain");
gainplot2d->SetZTitle(""); gainplot2d->SetZTitle("");
gainplot2d->enableAxis(QwtPlot::yLeft, false); gainplot2d->enableAxis(QwtPlot::yLeft, false);
@ -228,36 +241,32 @@ void qDrawPlot::SetupPlots() {
plotLayout->addWidget(plot1d, 0, 0, ratio, ratio); plotLayout->addWidget(plot1d, 0, 0, ratio, ratio);
plotLayout->addWidget(plot2d, 0, 0, ratio, ratio); plotLayout->addWidget(plot2d, 0, 0, ratio, ratio);
plotLayout->addWidget(gainplot1d, ratio, 0, 1, ratio, Qt::AlignTop); plotLayout->addWidget(gainplot1d, ratio, 0, 1, ratio, Qt::AlignTop);
plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1, Qt::AlignRight | Qt::AlignTop); plotLayout->addWidget(gainplot2d, 0, ratio, 1, 1,
Qt::AlignRight | Qt::AlignTop);
} }
void qDrawPlot::resizeEvent(QResizeEvent *event) { void qDrawPlot::resizeEvent(QResizeEvent *event) {
if (gainplot2d->isVisible()) { if (gainplot2d->isVisible()) {
gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot2d->setFixedWidth(plot2d->width() /
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO); qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedHeight(plot2d->height() /
qDefs::DATA_GAIN_PLOT_RATIO);
} }
if (gainplot1d->isVisible()) { if (gainplot1d->isVisible()) {
gainplot1d->setFixedWidth(plot1d->width()); gainplot1d->setFixedWidth(plot1d->width());
gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot1d->setFixedHeight(plot1d->height() /
qDefs::DATA_GAIN_PLOT_RATIO);
} }
event->accept(); event->accept();
} }
bool qDrawPlot::GetIsRunning() { bool qDrawPlot::GetIsRunning() { return isRunning; }
return isRunning;
}
void qDrawPlot::SetRunning(bool enable) { void qDrawPlot::SetRunning(bool enable) { isRunning = enable; }
isRunning = enable;
}
int qDrawPlot::GetProgress() { int qDrawPlot::GetProgress() { return progress; }
return progress;
}
int64_t qDrawPlot::GetCurrentFrameIndex() { int64_t qDrawPlot::GetCurrentFrameIndex() { return currentFrame; }
return currentFrame;
}
void qDrawPlot::Select1dPlot(bool enable) { void qDrawPlot::Select1dPlot(bool enable) {
if (enable) { if (enable) {
@ -284,7 +293,8 @@ void qDrawPlot::SetPlotTitlePrefix(QString title) {
} }
void qDrawPlot::SetXAxisTitle(QString title) { void qDrawPlot::SetXAxisTitle(QString title) {
FILE_LOG(logINFO) << "Setting X Axis Title to " << title.toAscii().constData(); FILE_LOG(logINFO) << "Setting X Axis Title to "
<< title.toAscii().constData();
if (is1d) { if (is1d) {
xTitle1d = title; xTitle1d = title;
} else { } else {
@ -293,7 +303,8 @@ void qDrawPlot::SetXAxisTitle(QString title) {
} }
void qDrawPlot::SetYAxisTitle(QString title) { void qDrawPlot::SetYAxisTitle(QString title) {
FILE_LOG(logINFO) << "Setting Y Axis Title to " << title.toAscii().constData(); FILE_LOG(logINFO) << "Setting Y Axis Title to "
<< title.toAscii().constData();
if (is1d) { if (is1d) {
yTitle1d = title; yTitle1d = title;
} else { } else {
@ -302,7 +313,8 @@ void qDrawPlot::SetYAxisTitle(QString title) {
} }
void qDrawPlot::SetZAxisTitle(QString title) { void qDrawPlot::SetZAxisTitle(QString title) {
FILE_LOG(logINFO) << "Setting Z Axis Title to " << title.toAscii().constData(); FILE_LOG(logINFO) << "Setting Z Axis Title to "
<< title.toAscii().constData();
zTitle2d = title; zTitle2d = title;
} }
@ -313,7 +325,8 @@ void qDrawPlot::SetXYRangeChanged(bool disable, double* xy, bool* isXY) {
std::copy(xy, xy + 4, xyRange); std::copy(xy, xy + 4, xyRange);
std::copy(isXY, isXY + 4, isXYRange); std::copy(isXY, isXY + 4, isXYRange);
FILE_LOG(logDEBUG) << "Setting Disable zoom to " << std::boolalpha << disable << std::noboolalpha; FILE_LOG(logDEBUG) << "Setting Disable zoom to " << std::boolalpha
<< disable << std::noboolalpha;
disableZoom = disable; disableZoom = disable;
} }
@ -351,7 +364,8 @@ double qDrawPlot::GetYMaximum() {
} }
void qDrawPlot::SetDataCallBack(bool enable) { void qDrawPlot::SetDataCallBack(bool enable) {
FILE_LOG(logINFO) << "Setting data call back to " << std::boolalpha << enable << std::noboolalpha; FILE_LOG(logINFO) << "Setting data call back to " << std::boolalpha
<< enable << std::noboolalpha;
if (enable) { if (enable) {
isPlot = true; isPlot = true;
det->setRxZmqDataStream(true); det->setRxZmqDataStream(true);
@ -361,11 +375,11 @@ void qDrawPlot::SetDataCallBack(bool enable) {
det->setRxZmqDataStream(false); det->setRxZmqDataStream(false);
det->registerDataCallback(nullptr, this); det->registerDataCallback(nullptr, this);
} }
} }
void qDrawPlot::SetBinary(bool enable, int from, int to) { void qDrawPlot::SetBinary(bool enable, int from, int to) {
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Binary output from " << from << " to " << to; FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling")
<< " Binary output from " << from << " to " << to;
binaryFrom = from; binaryFrom = from;
binaryTo = to; binaryTo = to;
isBinary = enable; isBinary = enable;
@ -378,7 +392,8 @@ void qDrawPlot::SetPersistency(int val) {
void qDrawPlot::SetLines(bool enable) { void qDrawPlot::SetLines(bool enable) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
FILE_LOG(logINFO) << "Setting Lines to " << std::boolalpha << enable << std::noboolalpha; FILE_LOG(logINFO) << "Setting Lines to " << std::boolalpha << enable
<< std::noboolalpha;
isLines = enable; isLines = enable;
for (int i = 0; i < nHists; ++i) { for (int i = 0; i < nHists; ++i) {
SlsQtH1D *h = hists1d.at(i); SlsQtH1D *h = hists1d.at(i);
@ -388,7 +403,8 @@ void qDrawPlot::SetLines(bool enable) {
void qDrawPlot::SetMarkers(bool enable) { void qDrawPlot::SetMarkers(bool enable) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
FILE_LOG(logINFO) << "Setting Markers to " << std::boolalpha << enable << std::noboolalpha; FILE_LOG(logINFO) << "Setting Markers to " << std::boolalpha << enable
<< std::noboolalpha;
isMarkers = enable; isMarkers = enable;
for (int i = 0; i < nHists; ++i) { for (int i = 0; i < nHists; ++i) {
SlsQtH1D *h = hists1d.at(i); SlsQtH1D *h = hists1d.at(i);
@ -398,25 +414,29 @@ void qDrawPlot::SetMarkers(bool enable) {
void qDrawPlot::Set1dLogY(bool enable) { void qDrawPlot::Set1dLogY(bool enable) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
FILE_LOG(logINFO) << "Setting Log Y to " << std::boolalpha << enable << std::noboolalpha; FILE_LOG(logINFO) << "Setting Log Y to " << std::boolalpha << enable
<< std::noboolalpha;
plot1d->SetLogY(enable); plot1d->SetLogY(enable);
} }
void qDrawPlot::SetInterpolate(bool enable) { void qDrawPlot::SetInterpolate(bool enable) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
FILE_LOG(logINFO) << "Setting Interpolate to " << std::boolalpha << enable << std::noboolalpha; FILE_LOG(logINFO) << "Setting Interpolate to " << std::boolalpha << enable
<< std::noboolalpha;
plot2d->SetInterpolate(enable); plot2d->SetInterpolate(enable);
} }
void qDrawPlot::SetContour(bool enable) { void qDrawPlot::SetContour(bool enable) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
FILE_LOG(logINFO) << "Setting Countour to " << std::boolalpha << enable << std::noboolalpha; FILE_LOG(logINFO) << "Setting Countour to " << std::boolalpha << enable
<< std::noboolalpha;
plot2d->SetContour(enable); plot2d->SetContour(enable);
} }
void qDrawPlot::SetLogz(bool enable) { void qDrawPlot::SetLogz(bool enable) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
FILE_LOG(logINFO) << "Setting Log Z to " << std::boolalpha << enable << std::noboolalpha; FILE_LOG(logINFO) << "Setting Log Z to " << std::boolalpha << enable
<< std::noboolalpha;
plot2d->SetLogz(enable, isZRange[0], isZRange[1], zRange[0], zRange[1]); plot2d->SetLogz(enable, isZRange[0], isZRange[1], zRange[0], zRange[1]);
} }
@ -447,7 +467,8 @@ void qDrawPlot::ResetAccumulate() {
} }
void qDrawPlot::DisplayStatistics(bool enable) { void qDrawPlot::DisplayStatistics(bool enable) {
FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling") << " Statistics Display"; FILE_LOG(logINFO) << (enable ? "Enabling" : "Disabling")
<< " Statistics Display";
displayStatistics = enable; displayStatistics = enable;
} }
@ -462,7 +483,8 @@ void qDrawPlot::EnableGainPlot(bool enable) {
} }
void qDrawPlot::SetSaveFileName(QString val) { void qDrawPlot::SetSaveFileName(QString val) {
FILE_LOG(logDEBUG) << "Setting Clone/Save File Name to " << val.toAscii().constData(); FILE_LOG(logDEBUG) << "Setting Clone/Save File Name to "
<< val.toAscii().constData();
fileSaveName = val; fileSaveName = val;
} }
@ -477,10 +499,14 @@ void qDrawPlot::ClonePlot() {
if (is1d) { if (is1d) {
FILE_LOG(logDEBUG) << "Cloning 1D Image"; FILE_LOG(logDEBUG) << "Cloning 1D Image";
cloneplot1D = new SlsQt1DPlot(); cloneplot1D = new SlsQt1DPlot();
cloneplot1D->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); cloneplot1D->setFont(
cloneplot1D->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
cloneplot1D->SetXFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); cloneplot1D->SetTitleFont(
cloneplot1D->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); 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->SetTitle(plot1d->title().text());
cloneplot1D->SetXTitle(xTitle1d); cloneplot1D->SetXTitle(xTitle1d);
cloneplot1D->SetYTitle(yTitle1d); cloneplot1D->SetYTitle(yTitle1d);
@ -500,8 +526,10 @@ void qDrawPlot::ClonePlot() {
h->setSymbolMarkers(isMarkers); h->setSymbolMarkers(isMarkers);
h->setItemAttribute(QwtPlotItem::Legend, false); h->setItemAttribute(QwtPlotItem::Legend, false);
clonegainplot1D = new SlsQt1DPlot(); clonegainplot1D = new SlsQt1DPlot();
clonegainplot1D->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); clonegainplot1D->SetTitleFont(
clonegainplot1D->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
clonegainplot1D->SetYFont(
QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
clonegainplot1D->SetTitle(""); clonegainplot1D->SetTitle("");
clonegainplot1D->SetYTitle("Gain"); clonegainplot1D->SetYTitle("Gain");
// set ticks to just 3 // set ticks to just 3
@ -509,26 +537,32 @@ void qDrawPlot::ClonePlot() {
QwtScaleDiv div(0, 3, QList<double>(), QList<double>(), majorTicks); QwtScaleDiv div(0, 3, QList<double>(), QList<double>(), majorTicks);
clonegainplot1D->setAxisScaleDiv(QwtPlot::yLeft, div); clonegainplot1D->setAxisScaleDiv(QwtPlot::yLeft, div);
h->Attach(clonegainplot1D); h->Attach(clonegainplot1D);
} }
} else { } else {
FILE_LOG(logDEBUG) << "Cloning 2D Image"; FILE_LOG(logDEBUG) << "Cloning 2D Image";
cloneplot2D = new SlsQt2DPlot(); cloneplot2D = new SlsQt2DPlot();
cloneplot2D->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); cloneplot2D->setFont(
cloneplot2D->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
cloneplot2D->SetXFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); cloneplot2D->SetTitleFont(
cloneplot2D->SetYFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
cloneplot2D->SetZFont(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->setTitle(plot2d->title().text());
cloneplot2D->SetXTitle(xTitle2d); cloneplot2D->SetXTitle(xTitle2d);
cloneplot2D->SetYTitle(yTitle2d); cloneplot2D->SetYTitle(yTitle2d);
cloneplot2D->SetZTitle(zTitle2d); cloneplot2D->SetZTitle(zTitle2d);
cloneplot2D->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, data2d); 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]); cloneplot2D->SetZRange(isZRange[0], isZRange[1], zRange[0], zRange[1]);
if (isGainDataExtracted) { if (isGainDataExtracted) {
clonegainplot2D = new SlsQt2DPlot(); clonegainplot2D = new SlsQt2DPlot();
clonegainplot2D->SetTitleFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); clonegainplot2D->SetTitleFont(
QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
clonegainplot2D->SetTitle("Gain"); clonegainplot2D->SetTitle("Gain");
clonegainplot2D->SetZTitle(""); clonegainplot2D->SetZTitle("");
clonegainplot2D->enableAxis(QwtPlot::yLeft, false); clonegainplot2D->enableAxis(QwtPlot::yLeft, false);
@ -541,13 +575,16 @@ void qDrawPlot::ClonePlot() {
clonegainplot2D->enableAxis(0, false); clonegainplot2D->enableAxis(0, false);
clonegainplot2D->enableAxis(1, false); clonegainplot2D->enableAxis(1, false);
clonegainplot2D->enableAxis(2, false); clonegainplot2D->enableAxis(2, false);
clonegainplot2D->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData); clonegainplot2D->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY,
-0.5, nPixelsY - 0.5, gainData);
} }
} }
new qCloneWidget(this, cloneplot1D, cloneplot2D, clonegainplot1D, new qCloneWidget(this, cloneplot1D, cloneplot2D, clonegainplot1D,
clonegainplot2D, boxPlot->title(), fileSavePath, fileSaveName, currentAcqIndex, clonegainplot2D, boxPlot->title(), fileSavePath,
displayStatistics, lblMinDisp->text(), lblMaxDisp->text(), lblSumDisp->text()); fileSaveName, currentAcqIndex, displayStatistics,
lblMinDisp->text(), lblMaxDisp->text(),
lblSumDisp->text());
} }
void qDrawPlot::SavePlot() { void qDrawPlot::SavePlot() {
@ -556,26 +593,31 @@ void qDrawPlot::SavePlot() {
QPainter painter(&savedImage); QPainter painter(&savedImage);
render(&painter); render(&painter);
QString fName = fileSavePath + QString('/') + QString fName = fileSavePath + QString('/') + fileSaveName + QString('_') +
fileSaveName + (is1d ? plot1d->title().text() : plot2d->title().text()) +
QString('_') + (is1d ? plot1d->title().text() : plot2d->title().text()) +
QString('_') + QString("%1").arg(currentAcqIndex) + QString('_') + QString("%1").arg(currentAcqIndex) +
QString(".png"); QString(".png");
fName = QFileDialog::getSaveFileName(0, tr("Save Image"), fName, tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), 0, fName = QFileDialog::getSaveFileName(
0, tr("Save Image"), fName,
tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"), 0,
QFileDialog::ShowDirsOnly); QFileDialog::ShowDirsOnly);
if (!fName.isEmpty()) { if (!fName.isEmpty()) {
if (savedImage.save(fName)) { if (savedImage.save(fName)) {
qDefs::Message(qDefs::INFORMATION, "The Image has been successfully saved", "qDrawPlot::SavePlot"); qDefs::Message(qDefs::INFORMATION,
"The Image has been successfully saved",
"qDrawPlot::SavePlot");
fileSavePath = fName.section('/', 0, -2); fileSavePath = fName.section('/', 0, -2);
} else { } else {
qDefs::Message(qDefs::WARNING, "Attempt to save image failed.\n Formats: .png, .jpg, .xpm.", "qDrawPlot::SavePlot"); qDefs::Message(
qDefs::WARNING,
"Attempt to save image failed.\n Formats: .png, .jpg, .xpm.",
"qDrawPlot::SavePlot");
} }
} }
} }
void qDrawPlot::GetStatistics(double &min, double &max, double &sum) { void qDrawPlot::GetStatistics(double &min, double &max, double &sum) {
FILE_LOG(logDEBUG) << "Calculating Statistics"; FILE_LOG(logDEBUG) << "Calculating Statistics";
double *array = data2d; double *array = data2d;
@ -594,7 +636,8 @@ void qDrawPlot::GetStatistics(double &min, double &max, double &sum) {
} }
void qDrawPlot::DetachHists() { void qDrawPlot::DetachHists() {
for (QVector<SlsQtH1D *>::iterator h = hists1d.begin(); h != hists1d.end(); ++h) { for (QVector<SlsQtH1D *>::iterator h = hists1d.begin(); h != hists1d.end();
++h) {
(*h)->Detach(plot1d); (*h)->Detach(plot1d);
} }
if (gainhist1d) { if (gainhist1d) {
@ -615,7 +658,9 @@ void qDrawPlot::StartAcquisition() {
if (!det->getRxZmqDataStream().squash(false)) { if (!det->getRxZmqDataStream().squash(false)) {
det->setRxZmqDataStream(true); det->setRxZmqDataStream(true);
} }
} CATCH_DISPLAY("Could not enable data streaming in Receiver.", "qDrawPlot::StartAcquisition"); }
CATCH_DISPLAY("Could not enable data streaming in Receiver.",
"qDrawPlot::StartAcquisition");
} }
// refixing all the zooming // refixing all the zooming
@ -637,71 +682,94 @@ void qDrawPlot::AcquireThread() {
mess = std::string(e.what()); mess = std::string(e.what());
} }
FILE_LOG(logINFO) << "Acquisition Finished"; FILE_LOG(logINFO) << "Acquisition Finished";
// exception in acquire will not call acquisition finished call back, so handle it // exception in acquire will not call acquisition finished call back, so
// handle it
if (!mess.empty()) { if (!mess.empty()) {
FILE_LOG(logERROR) << "Acquisition Finished with an exception: " << mess; FILE_LOG(logERROR) << "Acquisition Finished with an exception: "
qDefs::ExceptionMessage("Acquire unsuccessful.", mess, "qDrawPlot::AcquireFinished"); << mess;
qDefs::ExceptionMessage("Acquire unsuccessful.", mess,
"qDrawPlot::AcquireFinished");
try { try {
det->stopDetector(); det->stopDetector();
} CATCH_DISPLAY("Could not stop detector acquisition.", "qDrawPlot::AcquireFinished"); }
CATCH_DISPLAY("Could not stop detector acquisition.",
"qDrawPlot::AcquireFinished");
try { try {
det->stopReceiver(); det->stopReceiver();
} CATCH_DISPLAY("Could not stop receiver.", "qDrawPlot::AcquireFinished"); }
CATCH_DISPLAY("Could not stop receiver.", "qDrawPlot::AcquireFinished");
emit AbortSignal(); emit AbortSignal();
} }
FILE_LOG(logDEBUG) << "End of Acquisition Finished"; FILE_LOG(logDEBUG) << "End of Acquisition Finished";
} }
void qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer) { void qDrawPlot::GetAcquisitionFinishedCallBack(double currentProgress,
((qDrawPlot *)this_pointer)->AcquisitionFinished(currentProgress, detectorStatus); int detectorStatus,
void *this_pointer) {
((qDrawPlot *)this_pointer)
->AcquisitionFinished(currentProgress, detectorStatus);
FILE_LOG(logDEBUG) << "Acquisition Finished Call back successful"; FILE_LOG(logDEBUG) << "Acquisition Finished Call back successful";
} }
void qDrawPlot::GetDataCallBack(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex, void *this_pointer) { void qDrawPlot::GetDataCallBack(detectorData *data, uint64_t frameIndex,
uint32_t subFrameIndex, void *this_pointer) {
((qDrawPlot *)this_pointer)->GetData(data, frameIndex, subFrameIndex); ((qDrawPlot *)this_pointer)->GetData(data, frameIndex, subFrameIndex);
FILE_LOG(logDEBUG) << "Get Data Call back successful"; FILE_LOG(logDEBUG) << "Get Data Call back successful";
} }
void qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus) { void qDrawPlot::AcquisitionFinished(double currentProgress,
int detectorStatus) {
progress = currentProgress; progress = currentProgress;
std::string status = sls::ToString(static_cast<slsDetectorDefs::runStatus>(detectorStatus)); std::string status =
sls::ToString(static_cast<slsDetectorDefs::runStatus>(detectorStatus));
if (detectorStatus == slsDetectorDefs::ERROR) { if (detectorStatus == slsDetectorDefs::ERROR) {
qDefs::Message(qDefs::WARNING, std::string("<nobr>The acquisiton has ended abruptly. Current Detector Status: ") + status + std::string(".</nobr>"), "qDrawPlot::AcquisitionFinished"); qDefs::Message(qDefs::WARNING,
std::string("<nobr>The acquisiton has ended abruptly. "
"Current Detector Status: ") +
status + std::string(".</nobr>"),
"qDrawPlot::AcquisitionFinished");
FILE_LOG(logERROR) << "Acquisition finished [Status: ERROR]"; FILE_LOG(logERROR) << "Acquisition finished [Status: ERROR]";
} else { } else {
FILE_LOG(logINFO) << "Acquisition finished [ Status:" << status << ", Progress: " << currentProgress << " ]" ; FILE_LOG(logINFO) << "Acquisition finished [ Status:" << status
<< ", Progress: " << currentProgress << " ]";
} }
emit AcquireFinishedSignal(); emit AcquireFinishedSignal();
} }
void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex) { void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
uint32_t subFrameIndex) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
FILE_LOG(logDEBUG) FILE_LOG(logDEBUG) << "* GetData Callback *" << std::endl
<< "* GetData Callback *" << std::endl
<< " frame index: " << frameIndex << std::endl << " frame index: " << frameIndex << std::endl
<< " sub frame index: " << (((int)subFrameIndex == -1) ? (int)-1 : subFrameIndex) << std::endl << " sub frame index: "
<< (((int)subFrameIndex == -1) ? (int)-1 : subFrameIndex)
<< std::endl
<< " Data [" << std::endl << " Data [" << std::endl
<< " \t progress: " << data->progressIndex << std::endl << " \t progress: " << data->progressIndex << std::endl
<< " \t file name: " << data->fileName << std::endl << " \t file name: " << data->fileName << std::endl
<< " \t nx: " << data->nx << std::endl << " \t nx: " << data->nx << std::endl
<< " \t ny: " << data->ny << std::endl << " \t ny: " << data->ny << std::endl
<< " \t data bytes: " << data->databytes << std::endl << " \t data bytes: " << data->databytes << std::endl
<< " \t dynamic range: " << data->dynamicRange << std::endl << " \t dynamic range: " << data->dynamicRange
<< std::endl
<< " \t file index: " << data->fileIndex << std::endl << " \t file index: " << data->fileIndex << std::endl
<< " ]"; << " ]";
progress = (int)data->progressIndex; progress = (int)data->progressIndex;
currentAcqIndex = data->fileIndex; currentAcqIndex = data->fileIndex;
currentFrame = frameIndex; currentFrame = frameIndex;
FILE_LOG(logDEBUG) << "[ Progress:" << progress << ", Frame:" << currentFrame << " ]"; FILE_LOG(logDEBUG) << "[ Progress:" << progress
<< ", Frame:" << currentFrame << " ]";
// 2d (only image, not gain data, not pedestalvals), // 2d (only image, not gain data, not pedestalvals),
// check if npixelsX and npixelsY is the same (quad is different) // check if npixelsX and npixelsY is the same (quad is different)
if (!is1d && (static_cast<int>(nPixelsX) != data->nx || static_cast<int>(nPixelsY) != data->ny)) { if (!is1d && (static_cast<int>(nPixelsX) != data->nx ||
static_cast<int>(nPixelsY) != data->ny)) {
nPixelsX = data->nx; nPixelsX = data->nx;
nPixelsY = data->ny; nPixelsY = data->ny;
FILE_LOG(logINFO) << "Change in Detector Shape:\n\tnPixelsX:" << nPixelsX << " nPixelsY:" << nPixelsY; FILE_LOG(logINFO) << "Change in Detector Shape:\n\tnPixelsX:"
<< nPixelsX << " nPixelsY:" << nPixelsY;
delete[] data2d; delete[] data2d;
data2d = new double[nPixelsY * nPixelsX]; data2d = new double[nPixelsY * nPixelsX];
@ -712,16 +780,18 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra
unsigned int nPixels = nPixelsX * (is1d ? 1 : nPixelsY); unsigned int nPixels = nPixelsX * (is1d ? 1 : nPixelsY);
double *rawData = new double[nPixels]; double *rawData = new double[nPixels];
if (hasGainData) { if (hasGainData) {
toDoublePixelData(rawData, data->data, nPixels, data->databytes, data->dynamicRange, toDoublePixelData(rawData, data->data, nPixels, data->databytes,
is1d ? gainDatay1d : gainData); data->dynamicRange, is1d ? gainDatay1d : gainData);
isGainDataExtracted = true; isGainDataExtracted = true;
} else { } else {
toDoublePixelData(rawData, data->data, nPixels, data->databytes, data->dynamicRange); toDoublePixelData(rawData, data->data, nPixels, data->databytes,
data->dynamicRange);
isGainDataExtracted = false; isGainDataExtracted = false;
} }
// title and frame index titles // title and frame index titles
plotTitle = plotTitlePrefix + QString(data->fileName.c_str()).section('/', -1); plotTitle =
plotTitlePrefix + QString(data->fileName.c_str()).section('/', -1);
indexTitle = QString("%1").arg(frameIndex); indexTitle = QString("%1").arg(frameIndex);
if ((int)subFrameIndex != -1) { if ((int)subFrameIndex != -1) {
indexTitle = QString("%1 %2").arg(frameIndex, subFrameIndex); indexTitle = QString("%1 %2").arg(frameIndex, subFrameIndex);
@ -750,9 +820,11 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex, uint32_t subFra
} }
// calculate the pedestal value // calculate the pedestal value
if (pedestalCount == NUM_PEDESTAL_FRAMES) { if (pedestalCount == NUM_PEDESTAL_FRAMES) {
FILE_LOG(logINFO) << "Pedestal Calculated after " << NUM_PEDESTAL_FRAMES << " frames"; FILE_LOG(logINFO) << "Pedestal Calculated after "
<< NUM_PEDESTAL_FRAMES << " frames";
for (unsigned int px = 0; px < nPixels; ++px) for (unsigned int px = 0; px < nPixels; ++px)
tempPedestalVals[px] = tempPedestalVals[px] / (double)NUM_PEDESTAL_FRAMES; tempPedestalVals[px] =
tempPedestalVals[px] / (double)NUM_PEDESTAL_FRAMES;
memcpy(pedestalVals, tempPedestalVals, nPixels * sizeof(double)); memcpy(pedestalVals, tempPedestalVals, nPixels * sizeof(double));
pedestalCount++; pedestalCount++;
} }
@ -875,7 +947,8 @@ void qDrawPlot::Update1dPlot() {
gainhist1d->Attach(gainplot1d); gainhist1d->Attach(gainplot1d);
if (!gainplot1d->isVisible()) { if (!gainplot1d->isVisible()) {
gainplot1d->setFixedWidth(plot1d->width()); gainplot1d->setFixedWidth(plot1d->width());
gainplot1d->setFixedHeight(plot1d->height() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot1d->setFixedHeight(plot1d->height() /
qDefs::DATA_GAIN_PLOT_RATIO);
gainplot1d->show(); gainplot1d->show();
} }
} else if (gainplot1d->isVisible()) { } else if (gainplot1d->isVisible()) {
@ -893,12 +966,16 @@ void qDrawPlot::Update2dPlot() {
plot2d->SetXTitle(xTitle2d); plot2d->SetXTitle(xTitle2d);
plot2d->SetYTitle(yTitle2d); plot2d->SetYTitle(yTitle2d);
plot2d->SetZTitle(zTitle2d); plot2d->SetZTitle(zTitle2d);
plot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, data2d); plot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5,
nPixelsY - 0.5, data2d);
if (isGainDataExtracted) { if (isGainDataExtracted) {
gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5, nPixelsY - 0.5, gainData); gainplot2d->SetData(nPixelsX, -0.5, nPixelsX - 0.5, nPixelsY, -0.5,
nPixelsY - 0.5, gainData);
if (!gainplot2d->isVisible()) { if (!gainplot2d->isVisible()) {
gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO); gainplot2d->setFixedWidth(plot2d->width() /
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO); qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedHeight(plot2d->height() /
qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->show(); gainplot2d->show();
} }
} else if (gainplot2d->isVisible()) { } else if (gainplot2d->isVisible()) {
@ -916,16 +993,20 @@ void qDrawPlot::Update1dXYRange() {
if (!isXYRange[qDefs::XMIN] && !isXYRange[qDefs::XMAX]) { if (!isXYRange[qDefs::XMIN] && !isXYRange[qDefs::XMAX]) {
plot1d->EnableXAutoScaling(); plot1d->EnableXAutoScaling();
} else { } else {
double xmin = (isXYRange[qDefs::XMIN] ? xyRange[qDefs::XMIN] : plot1d->GetXMinimum()); double xmin = (isXYRange[qDefs::XMIN] ? xyRange[qDefs::XMIN]
double xmax = (isXYRange[qDefs::XMAX] ? xyRange[qDefs::XMAX] : plot1d->GetXMaximum()); : plot1d->GetXMinimum());
double xmax = (isXYRange[qDefs::XMAX] ? xyRange[qDefs::XMAX]
: plot1d->GetXMaximum());
plot1d->SetXMinMax(xmin, xmax); plot1d->SetXMinMax(xmin, xmax);
} }
if (!isXYRange[qDefs::YMIN] && !isXYRange[qDefs::YMAX]) { if (!isXYRange[qDefs::YMIN] && !isXYRange[qDefs::YMAX]) {
plot1d->EnableYAutoScaling(); plot1d->EnableYAutoScaling();
} else { } else {
double ymin = (isXYRange[qDefs::YMIN] ? xyRange[qDefs::YMIN] : plot1d->GetYMinimum()); double ymin = (isXYRange[qDefs::YMIN] ? xyRange[qDefs::YMIN]
double ymax = (isXYRange[qDefs::YMAX] ? xyRange[qDefs::YMAX] : plot1d->GetYMaximum()); : plot1d->GetYMinimum());
double ymax = (isXYRange[qDefs::YMAX] ? xyRange[qDefs::YMAX]
: plot1d->GetYMaximum());
plot1d->SetYMinMax(ymin, ymax); plot1d->SetYMinMax(ymin, ymax);
} }
plot1d->Update(); plot1d->Update();
@ -935,22 +1016,27 @@ void qDrawPlot::Update2dXYRange() {
if (!isXYRange[qDefs::XMIN] && !isXYRange[qDefs::XMAX]) { if (!isXYRange[qDefs::XMIN] && !isXYRange[qDefs::XMAX]) {
plot2d->EnableXAutoScaling(); plot2d->EnableXAutoScaling();
} else { } else {
double xmin = (isXYRange[qDefs::XMIN] ? xyRange[qDefs::XMIN] : plot2d->GetXMinimum()); double xmin = (isXYRange[qDefs::XMIN] ? xyRange[qDefs::XMIN]
double xmax = (isXYRange[qDefs::XMAX] ? xyRange[qDefs::XMAX] : plot2d->GetXMaximum()); : plot2d->GetXMinimum());
double xmax = (isXYRange[qDefs::XMAX] ? xyRange[qDefs::XMAX]
: plot2d->GetXMaximum());
plot2d->SetXMinMax(xmin, xmax); plot2d->SetXMinMax(xmin, xmax);
} }
if (!isXYRange[qDefs::YMIN] && !isXYRange[qDefs::YMAX]) { if (!isXYRange[qDefs::YMIN] && !isXYRange[qDefs::YMAX]) {
plot2d->EnableYAutoScaling(); plot2d->EnableYAutoScaling();
} else { } else {
double ymin = (isXYRange[qDefs::YMIN] ? xyRange[qDefs::YMIN] : plot2d->GetYMinimum()); double ymin = (isXYRange[qDefs::YMIN] ? xyRange[qDefs::YMIN]
double ymax = (isXYRange[qDefs::YMAX] ? xyRange[qDefs::YMAX] : plot2d->GetYMaximum()); : plot2d->GetYMinimum());
double ymax = (isXYRange[qDefs::YMAX] ? xyRange[qDefs::YMAX]
: plot2d->GetYMaximum());
plot2d->SetYMinMax(ymin, ymax); plot2d->SetYMinMax(ymin, ymax);
} }
plot2d->Update(); plot2d->Update();
} }
void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest) { void qDrawPlot::toDoublePixelData(double *dest, char *source, int size,
int databytes, int dr, double *gaindest) {
int ichan = 0; int ichan = 0;
int ibyte = 0; int ibyte = 0;
int halfbyte = 0; int halfbyte = 0;
@ -1025,7 +1111,6 @@ void qDrawPlot::toDoublePixelData(double *dest, char *source, int size, int data
} }
} }
void qDrawPlot::UpdatePlot() { void qDrawPlot::UpdatePlot() {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
FILE_LOG(logDEBUG) << "Update Plot"; FILE_LOG(logDEBUG) << "Update Plot";

204
slsDetectorGui/src/qTabAdvanced.cpp Executable file → Normal file
View File

@ -1,11 +1,12 @@
#include "qTabAdvanced.h" #include "qTabAdvanced.h"
#include "network_utils.h"
#include "qDefs.h" #include "qDefs.h"
#include "qDrawPlot.h" #include "qDrawPlot.h"
#include "network_utils.h"
#include <iostream> #include <iostream>
qTabAdvanced::qTabAdvanced(QWidget *parent, sls::Detector *detector, qDrawPlot *p) qTabAdvanced::qTabAdvanced(QWidget *parent, sls::Detector *detector,
qDrawPlot *p)
: QWidget(parent), det(detector), plot(p) { : QWidget(parent), det(detector), plot(p) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
@ -88,7 +89,8 @@ void qTabAdvanced::Initialization() {
// roi // roi
if (tab_roi->isEnabled()) { if (tab_roi->isEnabled()) {
connect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI())); connect(comboReadout, SIGNAL(currentIndexChanged(int)), this,
SLOT(GetROI()));
connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(SetROI())); connect(btnSetRoi, SIGNAL(clicked()), this, SLOT(SetROI()));
connect(btnClearRoi, SIGNAL(clicked()), this, SLOT(ClearROI())); connect(btnClearRoi, SIGNAL(clicked()), this, SLOT(ClearROI()));
} }
@ -122,7 +124,8 @@ void qTabAdvanced::PopulateDetectors() {
FILE_LOG(logDEBUG) << "Populating detectors"; FILE_LOG(logDEBUG) << "Populating detectors";
disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this, disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDetector())); SLOT(SetDetector()));
disconnect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI())); disconnect(comboReadout, SIGNAL(currentIndexChanged(int)), this,
SLOT(GetROI()));
comboDetector->clear(); comboDetector->clear();
comboReadout->clear(); comboReadout->clear();
@ -136,7 +139,8 @@ void qTabAdvanced::PopulateDetectors() {
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDetector())); SLOT(SetDetector()));
connect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI())); connect(comboReadout, SIGNAL(currentIndexChanged(int)), this,
SLOT(GetROI()));
} }
void qTabAdvanced::GetControlPort() { void qTabAdvanced::GetControlPort() {
@ -147,7 +151,9 @@ void qTabAdvanced::GetControlPort() {
try { try {
int retval = det->getControlPort({comboDetector->currentIndex()})[0]; int retval = det->getControlPort({comboDetector->currentIndex()})[0];
spinControlPort->setValue(retval); spinControlPort->setValue(retval);
} CATCH_DISPLAY ("Could not get detector control port.", "qTabAdvanced::GetControlPort") }
CATCH_DISPLAY("Could not get detector control port.",
"qTabAdvanced::GetControlPort")
connect(spinControlPort, SIGNAL(valueChanged(int)), this, connect(spinControlPort, SIGNAL(valueChanged(int)), this,
SLOT(SetControlPort(int))); SLOT(SetControlPort(int)));
@ -161,7 +167,9 @@ void qTabAdvanced::GetStopPort() {
try { try {
int retval = det->getStopPort({comboDetector->currentIndex()})[0]; int retval = det->getStopPort({comboDetector->currentIndex()})[0];
spinStopPort->setValue(retval); spinStopPort->setValue(retval);
} CATCH_DISPLAY ("Could not get detector stop port.", "qTabAdvanced::GetStopPort") }
CATCH_DISPLAY("Could not get detector stop port.",
"qTabAdvanced::GetStopPort")
connect(spinStopPort, SIGNAL(valueChanged(int)), this, connect(spinStopPort, SIGNAL(valueChanged(int)), this,
SLOT(SetStopPort(int))); SLOT(SetStopPort(int)));
@ -173,9 +181,12 @@ void qTabAdvanced::GetDetectorUDPIP() {
SLOT(SetDetectorUDPIP())); SLOT(SetDetectorUDPIP()));
try { try {
auto retval = det->getSourceUDPIP({comboDetector->currentIndex()})[0].str(); auto retval =
det->getSourceUDPIP({comboDetector->currentIndex()})[0].str();
dispDetectorUDPIP->setText(QString(retval.c_str())); dispDetectorUDPIP->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get detector UDP IP.", "qTabAdvanced::GetDetectorUDPIP") }
CATCH_DISPLAY("Could not get detector UDP IP.",
"qTabAdvanced::GetDetectorUDPIP")
connect(dispDetectorUDPIP, SIGNAL(editingFinished()), this, connect(dispDetectorUDPIP, SIGNAL(editingFinished()), this,
SLOT(SetDetectorUDPIP())); SLOT(SetDetectorUDPIP()));
@ -187,9 +198,12 @@ void qTabAdvanced::GetDetectorUDPMAC() {
SLOT(SetDetectorUDPMAC())); SLOT(SetDetectorUDPMAC()));
try { try {
auto retval = det->getSourceUDPMAC({comboDetector->currentIndex()})[0].str(); auto retval =
det->getSourceUDPMAC({comboDetector->currentIndex()})[0].str();
dispDetectorUDPMAC->setText(QString(retval.c_str())); dispDetectorUDPMAC->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get detector UDP MAC.", "qTabAdvanced::GetDetectorUDPMAC") }
CATCH_DISPLAY("Could not get detector UDP MAC.",
"qTabAdvanced::GetDetectorUDPMAC")
connect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this, connect(dispDetectorUDPMAC, SIGNAL(editingFinished()), this,
SLOT(SetDetectorUDPMAC())); SLOT(SetDetectorUDPMAC()));
@ -201,10 +215,11 @@ void qTabAdvanced::GetCltZMQPort() {
SLOT(SetCltZMQPort(int))); SLOT(SetCltZMQPort(int)));
try { try {
int retval = int retval = det->getClientZmqPort({comboDetector->currentIndex()})[0];
det->getClientZmqPort({comboDetector->currentIndex()})[0];
spinZMQPort->setValue(retval); spinZMQPort->setValue(retval);
} CATCH_DISPLAY ("Could not get client zmq port.", "qTabAdvanced::GetCltZMQPort") }
CATCH_DISPLAY("Could not get client zmq port.",
"qTabAdvanced::GetCltZMQPort")
connect(spinZMQPort, SIGNAL(valueChanged(int)), this, connect(spinZMQPort, SIGNAL(valueChanged(int)), this,
SLOT(SetCltZMQPort(int))); SLOT(SetCltZMQPort(int)));
@ -218,7 +233,8 @@ void qTabAdvanced::GetCltZMQIP() {
auto retval = auto retval =
det->getClientZmqIp({comboDetector->currentIndex()})[0].str(); det->getClientZmqIp({comboDetector->currentIndex()})[0].str();
dispZMQIP->setText(QString(retval.c_str())); dispZMQIP->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get client zmq ip.", "qTabAdvanced::GetCltZMQIP") }
CATCH_DISPLAY("Could not get client zmq ip.", "qTabAdvanced::GetCltZMQIP")
connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP())); connect(dispZMQIP, SIGNAL(editingFinished()), this, SLOT(SetCltZMQIP()));
} }
@ -231,7 +247,9 @@ void qTabAdvanced::GetRxrHostname() {
try { try {
auto retval = det->getRxHostname({comboDetector->currentIndex()})[0]; auto retval = det->getRxHostname({comboDetector->currentIndex()})[0];
dispRxrHostname->setText(QString(retval.c_str())); dispRxrHostname->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get receiver hostname.", "qTabAdvanced::GetRxrHostname") }
CATCH_DISPLAY("Could not get receiver hostname.",
"qTabAdvanced::GetRxrHostname")
connect(dispRxrHostname, SIGNAL(editingFinished()), this, connect(dispRxrHostname, SIGNAL(editingFinished()), this,
SLOT(SetRxrHostname())); SLOT(SetRxrHostname()));
@ -245,7 +263,9 @@ void qTabAdvanced::GetRxrTCPPort() {
try { try {
int retval = det->getRxPort({comboDetector->currentIndex()})[0]; int retval = det->getRxPort({comboDetector->currentIndex()})[0];
spinRxrTCPPort->setValue(retval); spinRxrTCPPort->setValue(retval);
} CATCH_DISPLAY ("Could not get receiver tcp port.", "qTabAdvanced::GetRxrTCPPort") }
CATCH_DISPLAY("Could not get receiver tcp port.",
"qTabAdvanced::GetRxrTCPPort")
connect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this, connect(spinRxrTCPPort, SIGNAL(valueChanged(int)), this,
SLOT(SetRxrTCPPort(int))); SLOT(SetRxrTCPPort(int)));
@ -257,9 +277,12 @@ void qTabAdvanced::GetRxrUDPPort() {
SLOT(SetRxrUDPPort(int))); SLOT(SetRxrUDPPort(int)));
try { try {
int retval = det->getDestinationUDPPort({comboDetector->currentIndex()})[0]; int retval =
det->getDestinationUDPPort({comboDetector->currentIndex()})[0];
spinRxrUDPPort->setValue(retval); spinRxrUDPPort->setValue(retval);
} CATCH_DISPLAY ("Could not get receiver udp port.", "qTabAdvanced::GetRxrUDPPort") }
CATCH_DISPLAY("Could not get receiver udp port.",
"qTabAdvanced::GetRxrUDPPort")
connect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this, connect(spinRxrUDPPort, SIGNAL(valueChanged(int)), this,
SLOT(SetRxrUDPPort(int))); SLOT(SetRxrUDPPort(int)));
@ -271,9 +294,11 @@ void qTabAdvanced::GetRxrUDPIP() {
SLOT(SetRxrUDPIP())); SLOT(SetRxrUDPIP()));
try { try {
auto retval = det->getDestinationUDPIP({comboDetector->currentIndex()})[0].str(); auto retval =
det->getDestinationUDPIP({comboDetector->currentIndex()})[0].str();
dispRxrUDPIP->setText(QString(retval.c_str())); dispRxrUDPIP->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get receiver udp ip.", "qTabAdvanced::GetRxrUDPIP") }
CATCH_DISPLAY("Could not get receiver udp ip.", "qTabAdvanced::GetRxrUDPIP")
connect(dispRxrUDPIP, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPIP())); connect(dispRxrUDPIP, SIGNAL(editingFinished()), this, SLOT(SetRxrUDPIP()));
} }
@ -284,9 +309,12 @@ void qTabAdvanced::GetRxrUDPMAC() {
SLOT(SetRxrUDPMAC())); SLOT(SetRxrUDPMAC()));
try { try {
auto retval = det->getDestinationUDPMAC({comboDetector->currentIndex()})[0].str(); auto retval =
det->getDestinationUDPMAC({comboDetector->currentIndex()})[0].str();
dispRxrUDPMAC->setText(QString(retval.c_str())); dispRxrUDPMAC->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get receiver udp mac.", "qTabAdvanced::GetRxrUDPMAC") }
CATCH_DISPLAY("Could not get receiver udp mac.",
"qTabAdvanced::GetRxrUDPMAC")
connect(dispRxrUDPMAC, SIGNAL(editingFinished()), this, connect(dispRxrUDPMAC, SIGNAL(editingFinished()), this,
SLOT(SetRxrUDPMAC())); SLOT(SetRxrUDPMAC()));
@ -298,10 +326,11 @@ void qTabAdvanced::GetRxrZMQPort() {
SLOT(SetRxrZMQPort(int))); SLOT(SetRxrZMQPort(int)));
try { try {
int retval = int retval = det->getRxZmqPort({comboDetector->currentIndex()})[0];
det->getRxZmqPort({comboDetector->currentIndex()})[0];
spinRxrZMQPort->setValue(retval); spinRxrZMQPort->setValue(retval);
} CATCH_DISPLAY ("Could not get receiver zmq port.", "qTabAdvanced::GetRxrZMQPort") }
CATCH_DISPLAY("Could not get receiver zmq port.",
"qTabAdvanced::GetRxrZMQPort")
connect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this, connect(spinRxrZMQPort, SIGNAL(valueChanged(int)), this,
SLOT(SetRxrZMQPort(int))); SLOT(SetRxrZMQPort(int)));
@ -313,10 +342,10 @@ void qTabAdvanced::GetRxrZMQIP() {
SLOT(SetRxrZMQIP())); SLOT(SetRxrZMQIP()));
try { try {
auto retval = auto retval = det->getRxZmqIP({comboDetector->currentIndex()})[0].str();
det->getRxZmqIP({comboDetector->currentIndex()})[0].str();
dispRxrZMQIP->setText(QString(retval.c_str())); dispRxrZMQIP->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get receiver zmq ip.", "qTabAdvanced::GetRxrZMQIP") }
CATCH_DISPLAY("Could not get receiver zmq ip.", "qTabAdvanced::GetRxrZMQIP")
connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP())); connect(dispRxrZMQIP, SIGNAL(editingFinished()), this, SLOT(SetRxrZMQIP()));
} }
@ -346,7 +375,8 @@ void qTabAdvanced::SetControlPort(int port) {
FILE_LOG(logINFO) << "Setting Control Port:" << port; FILE_LOG(logINFO) << "Setting Control Port:" << port;
try { try {
det->setControlPort(port, {comboDetector->currentIndex()}); det->setControlPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE("Could not set control port.", "qTabAdvanced::SetControlPort", }
CATCH_HANDLE("Could not set control port.", "qTabAdvanced::SetControlPort",
this, &qTabAdvanced::GetControlPort) this, &qTabAdvanced::GetControlPort)
} }
@ -354,7 +384,8 @@ void qTabAdvanced::SetStopPort(int port) {
FILE_LOG(logINFO) << "Setting Stop Port:" << port; FILE_LOG(logINFO) << "Setting Stop Port:" << port;
try { try {
det->setStopPort(port, {comboDetector->currentIndex()}); det->setStopPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set stop port.", "qTabAdvanced::SetStopPort", this, }
CATCH_HANDLE("Could not set stop port.", "qTabAdvanced::SetStopPort", this,
&qTabAdvanced::GetStopPort) &qTabAdvanced::GetStopPort)
} }
@ -363,7 +394,8 @@ void qTabAdvanced::SetDetectorUDPIP() {
FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s; FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s;
try { try {
det->setSourceUDPIP(sls::IpAddr{s}, {comboDetector->currentIndex()}); det->setSourceUDPIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Detector UDP IP.", }
CATCH_HANDLE("Could not set Detector UDP IP.",
"qTabAdvanced::SetDetectorUDPIP", this, "qTabAdvanced::SetDetectorUDPIP", this,
&qTabAdvanced::GetDetectorUDPIP) &qTabAdvanced::GetDetectorUDPIP)
} }
@ -373,7 +405,8 @@ void qTabAdvanced::SetDetectorUDPMAC() {
FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s; FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s;
try { try {
det->setSourceUDPMAC(sls::MacAddr{s}, {comboDetector->currentIndex()}); det->setSourceUDPMAC(sls::MacAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Detector UDP MAC.", }
CATCH_HANDLE("Could not set Detector UDP MAC.",
"qTabAdvanced::SetDetectorUDPMAC", this, "qTabAdvanced::SetDetectorUDPMAC", this,
&qTabAdvanced::GetDetectorUDPMAC) &qTabAdvanced::GetDetectorUDPMAC)
} }
@ -382,7 +415,8 @@ void qTabAdvanced::SetCltZMQPort(int port) {
FILE_LOG(logINFO) << "Setting Client ZMQ Port:" << port; FILE_LOG(logINFO) << "Setting Client ZMQ Port:" << port;
try { try {
det->setClientZmqPort(port, {comboDetector->currentIndex()}); det->setClientZmqPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ port.", }
CATCH_HANDLE("Could not set Client ZMQ port.",
"qTabAdvanced::SetCltZMQPort", this, "qTabAdvanced::SetCltZMQPort", this,
&qTabAdvanced::GetCltZMQPort) &qTabAdvanced::GetCltZMQPort)
} }
@ -392,9 +426,9 @@ void qTabAdvanced::SetCltZMQIP() {
FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s; FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s;
try { try {
det->setClientZmqIp(sls::IpAddr{s}, {comboDetector->currentIndex()}); det->setClientZmqIp(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ IP.", }
"qTabAdvanced::SetCltZMQIP", this, CATCH_HANDLE("Could not set Client ZMQ IP.", "qTabAdvanced::SetCltZMQIP",
&qTabAdvanced::GetCltZMQIP) this, &qTabAdvanced::GetCltZMQIP)
} }
void qTabAdvanced::SetRxrHostname() { void qTabAdvanced::SetRxrHostname() {
@ -402,9 +436,9 @@ void qTabAdvanced::SetRxrHostname() {
FILE_LOG(logINFO) << "Setting Receiver Hostname:" << s; FILE_LOG(logINFO) << "Setting Receiver Hostname:" << s;
try { try {
det->setRxHostname(s, {comboDetector->currentIndex()}); det->setRxHostname(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ IP.", }
"qTabAdvanced::SetRxrHostname", this, CATCH_HANDLE("Could not set Client ZMQ IP.", "qTabAdvanced::SetRxrHostname",
&qTabAdvanced::GetRxrHostname) this, &qTabAdvanced::GetRxrHostname)
// update all network widgets (receiver mainly) // update all network widgets (receiver mainly)
SetDetector(); SetDetector();
@ -414,7 +448,8 @@ void qTabAdvanced::SetRxrTCPPort(int port) {
FILE_LOG(logINFO) << "Setting Receiver TCP Port:" << port; FILE_LOG(logINFO) << "Setting Receiver TCP Port:" << port;
try { try {
det->setRxPort(port, {comboDetector->currentIndex()}); det->setRxPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver TCP port.", }
CATCH_HANDLE("Could not set Receiver TCP port.",
"qTabAdvanced::SetRxrTCPPort", this, "qTabAdvanced::SetRxrTCPPort", this,
&qTabAdvanced::GetRxrTCPPort) &qTabAdvanced::GetRxrTCPPort)
} }
@ -423,7 +458,8 @@ void qTabAdvanced::SetRxrUDPPort(int port) {
FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port; FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port;
try { try {
det->setRxPort(port, {comboDetector->currentIndex()}); det->setRxPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP port.", }
CATCH_HANDLE("Could not set Receiver UDP port.",
"qTabAdvanced::SetRxrUDPPort", this, "qTabAdvanced::SetRxrUDPPort", this,
&qTabAdvanced::GetRxrUDPPort) &qTabAdvanced::GetRxrUDPPort)
} }
@ -432,18 +468,21 @@ void qTabAdvanced::SetRxrUDPIP() {
std::string s = dispRxrUDPIP->text().toAscii().constData(); std::string s = dispRxrUDPIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s; FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s;
try { try {
det->setDestinationUDPIP(sls::IpAddr{s}, {comboDetector->currentIndex()}); det->setDestinationUDPIP(sls::IpAddr{s},
} CATCH_HANDLE ("Could not set Receiver UDP IP.", {comboDetector->currentIndex()});
"qTabAdvanced::SetRxrUDPIP", this, }
&qTabAdvanced::GetRxrUDPIP) CATCH_HANDLE("Could not set Receiver UDP IP.", "qTabAdvanced::SetRxrUDPIP",
this, &qTabAdvanced::GetRxrUDPIP)
} }
void qTabAdvanced::SetRxrUDPMAC() { void qTabAdvanced::SetRxrUDPMAC() {
std::string s = dispRxrUDPMAC->text().toAscii().constData(); std::string s = dispRxrUDPMAC->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s; FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
try { try {
det->setDestinationUDPMAC(sls::MacAddr{s}, {comboDetector->currentIndex()}); det->setDestinationUDPMAC(sls::MacAddr{s},
} CATCH_HANDLE ("Could not set Receiver UDP MAC.", {comboDetector->currentIndex()});
}
CATCH_HANDLE("Could not set Receiver UDP MAC.",
"qTabAdvanced::SetRxrUDPMAC", this, "qTabAdvanced::SetRxrUDPMAC", this,
&qTabAdvanced::GetRxrUDPMAC) &qTabAdvanced::GetRxrUDPMAC)
} }
@ -452,7 +491,8 @@ void qTabAdvanced::SetRxrZMQPort(int port) {
FILE_LOG(logINFO) << "Setting Receiver ZMQ Port:" << port; FILE_LOG(logINFO) << "Setting Receiver ZMQ Port:" << port;
try { try {
det->setRxZmqPort(port, {comboDetector->currentIndex()}); det->setRxZmqPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver ZMQ port.", }
CATCH_HANDLE("Could not set Receiver ZMQ port.",
"qTabAdvanced::SetRxrZMQPort", this, "qTabAdvanced::SetRxrZMQPort", this,
&qTabAdvanced::GetRxrZMQPort) &qTabAdvanced::GetRxrZMQPort)
} }
@ -462,18 +502,20 @@ void qTabAdvanced::SetRxrZMQIP() {
FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s; FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
try { try {
det->setRxZmqIP(sls::IpAddr{s}, {comboDetector->currentIndex()}); det->setRxZmqIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver ZMQ IP.", }
"qTabAdvanced::SetRxrZMQIP", this, CATCH_HANDLE("Could not set Receiver ZMQ IP.", "qTabAdvanced::SetRxrZMQIP",
&qTabAdvanced::GetRxrZMQIP) this, &qTabAdvanced::GetRxrZMQIP)
} }
void qTabAdvanced::GetROI() { void qTabAdvanced::GetROI() {
FILE_LOG(logDEBUG) << "Getting ROI"; FILE_LOG(logDEBUG) << "Getting ROI";
try { try {
slsDetectorDefs::ROI roi = det->getROI({comboReadout->currentIndex()})[0]; slsDetectorDefs::ROI roi =
det->getROI({comboReadout->currentIndex()})[0];
spinXmin->setValue(roi.xmin); spinXmin->setValue(roi.xmin);
spinXmax->setValue(roi.xmax); spinXmax->setValue(roi.xmax);
} CATCH_DISPLAY ("Could not get ROI.", "qTabAdvanced::GetROI") }
CATCH_DISPLAY("Could not get ROI.", "qTabAdvanced::GetROI")
} }
void qTabAdvanced::ClearROI() { void qTabAdvanced::ClearROI() {
@ -491,11 +533,12 @@ void qTabAdvanced::SetROI() {
roi.xmax = spinXmax->value(); roi.xmax = spinXmax->value();
// set roi // set roi
FILE_LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax << "]"; FILE_LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax
<< "]";
try { try {
det->setROI(roi, {comboReadout->currentIndex()}); det->setROI(roi, {comboReadout->currentIndex()});
} CATCH_DISPLAY ("Could not set these ROIs.", }
"qTabAdvanced::SetROI") CATCH_DISPLAY("Could not set these ROIs.", "qTabAdvanced::SetROI")
// update corrected list // update corrected list
GetROI(); GetROI();
@ -509,7 +552,8 @@ void qTabAdvanced::GetAllTrimbits() {
try { try {
int retval = det->getAllTrimbits().squash(-1); int retval = det->getAllTrimbits().squash(-1);
spinSetAllTrimbits->setValue(retval); spinSetAllTrimbits->setValue(retval);
} CATCH_DISPLAY ("Could not get all trimbits.", "qTabAdvanced::GetAllTrimbits") }
CATCH_DISPLAY("Could not get all trimbits.", "qTabAdvanced::GetAllTrimbits")
connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this, connect(spinSetAllTrimbits, SIGNAL(editingFinished()), this,
SLOT(SetAllTrimbits())); SLOT(SetAllTrimbits()));
@ -521,7 +565,8 @@ void qTabAdvanced::SetAllTrimbits() {
try { try {
det->setAllTrimbits(value); det->setAllTrimbits(value);
} CATCH_HANDLE("Could not set all trimbits.", "qTabAdvanced::SetAllTrimbits", }
CATCH_HANDLE("Could not set all trimbits.", "qTabAdvanced::SetAllTrimbits",
this, &qTabAdvanced::GetAllTrimbits) this, &qTabAdvanced::GetAllTrimbits)
} }
@ -531,10 +576,11 @@ void qTabAdvanced::GetNumStoragecells() {
SLOT(SetNumStoragecells(int))); SLOT(SetNumStoragecells(int)));
try { try {
auto retval = det->getNumberOfAdditionalStorageCells().tsquash("Inconsistent values for number of addditional storage cells."); auto retval = det->getNumberOfAdditionalStorageCells().tsquash(
"Inconsistent values for number of addditional storage cells.");
spinNumStoragecells->setValue(retval); spinNumStoragecells->setValue(retval);
} CATCH_DISPLAY ( }
"Could not get number of additional storage cells.", CATCH_DISPLAY("Could not get number of additional storage cells.",
"qTabAdvanced::GetNumStoragecells") "qTabAdvanced::GetNumStoragecells")
connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this, connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this,
@ -546,8 +592,8 @@ void qTabAdvanced::SetNumStoragecells(int value) {
<< value; << value;
try { try {
det->setNumberOfAdditionalStorageCells(value); det->setNumberOfAdditionalStorageCells(value);
} CATCH_HANDLE ( }
"Could not set number of additional storage cells.", CATCH_HANDLE("Could not set number of additional storage cells.",
"qTabAdvanced::SetNumStoragecells", this, "qTabAdvanced::SetNumStoragecells", this,
&qTabAdvanced::GetNumStoragecells) &qTabAdvanced::GetNumStoragecells)
} }
@ -559,12 +605,13 @@ void qTabAdvanced::GetSubExposureTime() {
disconnect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this, disconnect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSubExposureTime())); SLOT(SetSubExposureTime()));
try { try {
auto retval = auto retval = det->getSubExptime().tsquash(
det->getSubExptime().tsquash("Subexptime is inconsistent for all detectors."); "Subexptime is inconsistent for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval); auto time = qDefs::getUserFriendlyTime(retval);
spinSubExpTime->setValue(time.first); spinSubExpTime->setValue(time.first);
comboSubExpTimeUnit->setCurrentIndex(static_cast<int>(time.second)); comboSubExpTimeUnit->setCurrentIndex(static_cast<int>(time.second));
} CATCH_DISPLAY ("Could not get sub exposure time.", }
CATCH_DISPLAY("Could not get sub exposure time.",
"qTabSettings::GetSubExposureTime") "qTabSettings::GetSubExposureTime")
connect(spinSubExpTime, SIGNAL(valueChanged(double)), this, connect(spinSubExpTime, SIGNAL(valueChanged(double)), this,
SLOT(SetSubExposureTime())); SLOT(SetSubExposureTime()));
@ -573,7 +620,9 @@ void qTabAdvanced::GetSubExposureTime() {
} }
void qTabAdvanced::SetSubExposureTime() { void qTabAdvanced::SetSubExposureTime() {
auto timeNS = qDefs::getNSTime(std::make_pair(spinSubExpTime->value(), static_cast<qDefs::timeUnit>(comboSubExpTimeUnit->currentIndex()))); auto timeNS = qDefs::getNSTime(std::make_pair(
spinSubExpTime->value(),
static_cast<qDefs::timeUnit>(comboSubExpTimeUnit->currentIndex())));
FILE_LOG(logINFO) FILE_LOG(logINFO)
<< "Setting sub frame acquisition time to " << timeNS.count() << " ns" << "Setting sub frame acquisition time to " << timeNS.count() << " ns"
<< "/" << spinSubExpTime->value() << "/" << spinSubExpTime->value()
@ -581,7 +630,8 @@ void qTabAdvanced::SetSubExposureTime() {
(qDefs::timeUnit)comboSubExpTimeUnit->currentIndex()); (qDefs::timeUnit)comboSubExpTimeUnit->currentIndex());
try { try {
det->setSubExptime(timeNS); det->setSubExptime(timeNS);
} CATCH_DISPLAY ("Could not set sub exposure time.", }
CATCH_DISPLAY("Could not set sub exposure time.",
"qTabAdvanced::SetSubExposureTime") "qTabAdvanced::SetSubExposureTime")
GetSubExposureTime(); GetSubExposureTime();
@ -594,12 +644,13 @@ void qTabAdvanced::GetSubDeadTime() {
disconnect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this, disconnect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSubDeadTime())); SLOT(SetSubDeadTime()));
try { try {
auto retval = det->getSubDeadTime().tsquash("Sub dead time is inconsistent for all detectors."); auto retval = det->getSubDeadTime().tsquash(
"Sub dead time is inconsistent for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval); auto time = qDefs::getUserFriendlyTime(retval);
spinSubDeadTime->setValue(time.first); spinSubDeadTime->setValue(time.first);
comboSubDeadTimeUnit->setCurrentIndex( comboSubDeadTimeUnit->setCurrentIndex(static_cast<int>(time.second));
static_cast<int>(time.second)); }
} CATCH_DISPLAY ("Could not get sub dead time.", CATCH_DISPLAY("Could not get sub dead time.",
"qTabSettings::GetSubDeadTime") "qTabSettings::GetSubDeadTime")
connect(spinSubDeadTime, SIGNAL(valueChanged(double)), this, connect(spinSubDeadTime, SIGNAL(valueChanged(double)), this,
SLOT(SetSubDeadTime())); SLOT(SetSubDeadTime()));
@ -608,7 +659,9 @@ void qTabAdvanced::GetSubDeadTime() {
} }
void qTabAdvanced::SetSubDeadTime() { void qTabAdvanced::SetSubDeadTime() {
auto timeNS = qDefs::getNSTime(std::make_pair(spinSubDeadTime->value(), static_cast<qDefs::timeUnit>(comboSubDeadTimeUnit->currentIndex()))); auto timeNS = qDefs::getNSTime(std::make_pair(
spinSubDeadTime->value(),
static_cast<qDefs::timeUnit>(comboSubDeadTimeUnit->currentIndex())));
FILE_LOG(logINFO) FILE_LOG(logINFO)
<< "Setting sub frame dead time to " << timeNS.count() << " ns" << "Setting sub frame dead time to " << timeNS.count() << " ns"
@ -617,7 +670,8 @@ void qTabAdvanced::SetSubDeadTime() {
(qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex()); (qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex());
try { try {
det->setSubDeadTime(timeNS); det->setSubDeadTime(timeNS);
} CATCH_DISPLAY ("Could not set sub dead time.", }
CATCH_DISPLAY("Could not set sub dead time.",
"qTabAdvanced::SetSubDeadTime") "qTabAdvanced::SetSubDeadTime")
GetSubDeadTime(); GetSubDeadTime();
} }

235
slsDetectorGui/src/qTabDataOutput.cpp Executable file → Normal file
View File

@ -1,24 +1,22 @@
#include "qTabDataOutput.h" #include "qTabDataOutput.h"
#include "qDefs.h" #include "qDefs.h"
#include <QButtonGroup>
#include <QFileDialog> #include <QFileDialog>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QButtonGroup>
#include <QString> #include <QString>
#include <iostream> #include <iostream>
#include <string> #include <string>
qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector)
qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector) : QWidget(parent), det(detector), btnGroupRate(nullptr) { : QWidget(parent), det(detector), btnGroupRate(nullptr) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "DataOutput ready"; FILE_LOG(logDEBUG) << "DataOutput ready";
} }
qTabDataOutput::~qTabDataOutput() { qTabDataOutput::~qTabDataOutput() { delete btnGroupRate; }
delete btnGroupRate;
}
void qTabDataOutput::SetupWidgetWindow() { void qTabDataOutput::SetupWidgetWindow() {
// button group for rate // button group for rate
@ -52,24 +50,34 @@ void qTabDataOutput::SetupWidgetWindow() {
void qTabDataOutput::Initialization() { void qTabDataOutput::Initialization() {
// ourdir, fileformat, overwrite enable // ourdir, fileformat, overwrite enable
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir())); connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); SLOT(GetOutputDir()));
connect(dispOutputDir, SIGNAL(editingFinished()), this,
SLOT(SetOutputDir()));
connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(BrowseOutputDir())); connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(BrowseOutputDir()));
connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this,
connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); SLOT(SetFileFormat(int)));
connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this,
SLOT(SetOverwriteEnable(bool)));
if (chkTenGiga->isEnabled()) { if (chkTenGiga->isEnabled()) {
connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool))); connect(chkTenGiga, SIGNAL(toggled(bool)), this,
SLOT(SetTenGigaEnable(bool)));
} }
// rate // rate
if (chkRate->isEnabled()) { if (chkRate->isEnabled()) {
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection())); connect(chkRate, SIGNAL(toggled(bool)), this,
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection())); SLOT(EnableRateCorrection()));
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); connect(btnGroupRate, SIGNAL(buttonClicked(int)), this,
SLOT(SetRateCorrection()));
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this,
SLOT(SetRateCorrection()));
} }
// flags, speed // flags, speed
if (widgetEiger->isEnabled()) { if (widgetEiger->isEnabled()) {
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int))); connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); SLOT(SetSpeed(int)));
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFlags()));
} }
} }
@ -90,7 +98,9 @@ void qTabDataOutput::EnableBrowse() {
FILE_LOG(logDEBUG) << "Getting browse enable"; FILE_LOG(logDEBUG) << "Getting browse enable";
try { try {
btnOutputBrowse->setEnabled(false); // exception default btnOutputBrowse->setEnabled(false); // exception default
std::string rxHostname = det->getRxHostname({comboDetector->currentIndex() - 1}).squash("none"); std::string rxHostname =
det->getRxHostname({comboDetector->currentIndex() - 1})
.squash("none");
if (rxHostname == "none") { if (rxHostname == "none") {
btnOutputBrowse->setEnabled(false); btnOutputBrowse->setEnabled(false);
} else if (rxHostname == "localhost") { } else if (rxHostname == "localhost") {
@ -109,50 +119,66 @@ void qTabDataOutput::EnableBrowse() {
btnOutputBrowse->setEnabled(false); btnOutputBrowse->setEnabled(false);
} }
} }
} CATCH_DISPLAY ("Could not get receiver hostname.", "qTabDataOutput::EnableBrowse") }
CATCH_DISPLAY("Could not get receiver hostname.",
"qTabDataOutput::EnableBrowse")
} }
void qTabDataOutput::GetFileWrite() { void qTabDataOutput::GetFileWrite() {
FILE_LOG(logDEBUG) << "Getting file write enable"; FILE_LOG(logDEBUG) << "Getting file write enable";
try { try {
boxFileWriteEnabled->setEnabled(true); // exception default boxFileWriteEnabled->setEnabled(true); // exception default
auto retval = det->getFileWrite().tsquash("File write is inconsistent for all detectors."); auto retval = det->getFileWrite().tsquash(
"File write is inconsistent for all detectors.");
boxFileWriteEnabled->setEnabled(retval); boxFileWriteEnabled->setEnabled(retval);
} CATCH_DISPLAY("Could not get file enable.", "qTabDataOutput::GetFileWrite") }
CATCH_DISPLAY("Could not get file enable.", "qTabDataOutput::GetFileWrite")
} }
void qTabDataOutput::GetFileName() { void qTabDataOutput::GetFileName() {
FILE_LOG(logDEBUG) << "Getting file name"; FILE_LOG(logDEBUG) << "Getting file name";
try { try {
auto retval = det->getFileNamePrefix().tsquash("File name is inconsistent for all detectors."); auto retval = det->getFileNamePrefix().tsquash(
"File name is inconsistent for all detectors.");
dispFileName->setText(QString(retval.c_str())); dispFileName->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get file name prefix.", "qTabDataOutput::GetFileName") }
CATCH_DISPLAY("Could not get file name prefix.",
"qTabDataOutput::GetFileName")
} }
void qTabDataOutput::GetOutputDir() { void qTabDataOutput::GetOutputDir() {
FILE_LOG(logDEBUG) << "Getting file path"; FILE_LOG(logDEBUG) << "Getting file path";
disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); disconnect(dispOutputDir, SIGNAL(editingFinished()), this,
SLOT(SetOutputDir()));
try { try {
std::string path = det->getFilePath({comboDetector->currentIndex() - 1}).tsquash("File path is different for all detectors."); std::string path =
det->getFilePath({comboDetector->currentIndex() - 1})
.tsquash("File path is different for all detectors.");
dispOutputDir->setText(QString(path.c_str())); dispOutputDir->setText(QString(path.c_str()));
} CATCH_DISPLAY ("Could not get file path.", "qTabDataOutput::GetOutputDir") }
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir())); CATCH_DISPLAY("Could not get file path.", "qTabDataOutput::GetOutputDir")
connect(dispOutputDir, SIGNAL(editingFinished()), this,
SLOT(SetOutputDir()));
} }
void qTabDataOutput::BrowseOutputDir() { void qTabDataOutput::BrowseOutputDir() {
FILE_LOG(logDEBUG) << "Browsing output directory"; FILE_LOG(logDEBUG) << "Browsing output directory";
QString directory = QFileDialog::getExistingDirectory(this, tr("Choose Output Directory "), dispOutputDir->text()); QString directory = QFileDialog::getExistingDirectory(
this, tr("Choose Output Directory "), dispOutputDir->text());
if (!directory.isEmpty()) if (!directory.isEmpty())
dispOutputDir->setText(directory); dispOutputDir->setText(directory);
} }
void qTabDataOutput::SetOutputDir() { void qTabDataOutput::SetOutputDir() {
QString path = dispOutputDir->text(); QString path = dispOutputDir->text();
FILE_LOG(logDEBUG) << "Setting output directory to " << path.toAscii().constData(); FILE_LOG(logDEBUG) << "Setting output directory to "
<< path.toAscii().constData();
// empty // empty
if (path.isEmpty()) { if (path.isEmpty()) {
qDefs::Message(qDefs::WARNING, "Invalid Output Path. Must not be empty.", "qTabDataOutput::SetOutputDir"); qDefs::Message(qDefs::WARNING,
"Invalid Output Path. Must not be empty.",
"qTabDataOutput::SetOutputDir");
FILE_LOG(logWARNING) << "Invalid Output Path. Must not be empty."; FILE_LOG(logWARNING) << "Invalid Output Path. Must not be empty.";
GetOutputDir(); GetOutputDir();
} else { } else {
@ -165,84 +191,122 @@ void qTabDataOutput::SetOutputDir() {
std::string spath = std::string(path.toAscii().constData()); std::string spath = std::string(path.toAscii().constData());
try { try {
det->setFilePath(spath, {comboDetector->currentIndex() - 1}); det->setFilePath(spath, {comboDetector->currentIndex() - 1});
} CATCH_HANDLE ("Could not set output file path.", "qTabDataOutput::SetOutputDir", this, &qTabDataOutput::GetOutputDir) }
CATCH_HANDLE("Could not set output file path.",
"qTabDataOutput::SetOutputDir", this,
&qTabDataOutput::GetOutputDir)
} }
} }
void qTabDataOutput::GetFileFormat() { void qTabDataOutput::GetFileFormat() {
FILE_LOG(logDEBUG) << "Getting File Format"; FILE_LOG(logDEBUG) << "Getting File Format";
disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFileFormat(int)));
try { try {
auto retval = det->getFileFormat().tsquash("File format is inconsistent for all detectors."); auto retval = det->getFileFormat().tsquash(
"File format is inconsistent for all detectors.");
switch (retval) { switch (retval) {
case slsDetectorDefs::BINARY: case slsDetectorDefs::BINARY:
case slsDetectorDefs::HDF5: case slsDetectorDefs::HDF5:
comboFileFormat->setCurrentIndex(static_cast<int>(retval)); comboFileFormat->setCurrentIndex(static_cast<int>(retval));
break; break;
default: default:
throw sls::RuntimeError(std::string("Unknown file format: ") + std::to_string(static_cast<int>(retval))); throw sls::RuntimeError(std::string("Unknown file format: ") +
std::to_string(static_cast<int>(retval)));
} }
} CATCH_DISPLAY("Could not get file format.", "qTabDataOutput::GetFileFormat") }
connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int))); CATCH_DISPLAY("Could not get file format.", "qTabDataOutput::GetFileFormat")
connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFileFormat(int)));
} }
void qTabDataOutput::SetFileFormat(int format) { void qTabDataOutput::SetFileFormat(int format) {
FILE_LOG(logINFO) << "Setting File Format to " << comboFileFormat->currentText().toAscii().data(); FILE_LOG(logINFO) << "Setting File Format to "
<< comboFileFormat->currentText().toAscii().data();
try { try {
det->setFileFormat(static_cast<slsDetectorDefs::fileFormat>(comboFileFormat->currentIndex())); det->setFileFormat(static_cast<slsDetectorDefs::fileFormat>(
} CATCH_HANDLE ("Could not set file format.", "qTabDataOutput::SetFileFormat", this, &qTabDataOutput::GetFileFormat) comboFileFormat->currentIndex()));
}
CATCH_HANDLE("Could not set file format.", "qTabDataOutput::SetFileFormat",
this, &qTabDataOutput::GetFileFormat)
} }
void qTabDataOutput::GetFileOverwrite() { void qTabDataOutput::GetFileOverwrite() {
FILE_LOG(logDEBUG) << "Getting File Over Write Enable"; FILE_LOG(logDEBUG) << "Getting File Over Write Enable";
disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this,
SLOT(SetOverwriteEnable(bool)));
try { try {
auto retval = det->getFileOverWrite().tsquash("File over write is inconsistent for all detectors."); auto retval = det->getFileOverWrite().tsquash(
"File over write is inconsistent for all detectors.");
chkOverwriteEnable->setChecked(retval); chkOverwriteEnable->setChecked(retval);
} CATCH_DISPLAY ("Could not get file over write enable.", "qTabDataOutput::GetFileOverwrite") }
CATCH_DISPLAY("Could not get file over write enable.",
"qTabDataOutput::GetFileOverwrite")
connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool))); connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this,
SLOT(SetOverwriteEnable(bool)));
} }
void qTabDataOutput::SetOverwriteEnable(bool enable) { void qTabDataOutput::SetOverwriteEnable(bool enable) {
FILE_LOG(logINFO) << "Setting File Over Write Enable to " << enable; FILE_LOG(logINFO) << "Setting File Over Write Enable to " << enable;
try { try {
det->setFileOverWrite(enable); det->setFileOverWrite(enable);
} CATCH_HANDLE ("Could not set file over write enable.", "qTabDataOutput::SetOverwriteEnable", this, &qTabDataOutput::GetFileOverwrite) }
CATCH_HANDLE("Could not set file over write enable.",
"qTabDataOutput::SetOverwriteEnable", this,
&qTabDataOutput::GetFileOverwrite)
} }
void qTabDataOutput::GetTenGigaEnable() { void qTabDataOutput::GetTenGigaEnable() {
FILE_LOG(logDEBUG) << "Getting 10GbE enable"; FILE_LOG(logDEBUG) << "Getting 10GbE enable";
disconnect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool))); disconnect(chkTenGiga, SIGNAL(toggled(bool)), this,
SLOT(SetTenGigaEnable(bool)));
try { try {
auto retval = det->getTenGiga().tsquash("10GbE enable is inconsistent for all detectors."); auto retval = det->getTenGiga().tsquash(
"10GbE enable is inconsistent for all detectors.");
chkTenGiga->setChecked(retval); chkTenGiga->setChecked(retval);
} CATCH_DISPLAY ("Could not get 10GbE enable.", "qTabDataOutput::GetTenGigaEnable") }
connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool))); CATCH_DISPLAY("Could not get 10GbE enable.",
"qTabDataOutput::GetTenGigaEnable")
connect(chkTenGiga, SIGNAL(toggled(bool)), this,
SLOT(SetTenGigaEnable(bool)));
} }
void qTabDataOutput::SetTenGigaEnable(bool enable) { void qTabDataOutput::SetTenGigaEnable(bool enable) {
FILE_LOG(logINFO) << "Setting 10GbE to " << enable; FILE_LOG(logINFO) << "Setting 10GbE to " << enable;
try { try {
det->setTenGiga(enable); det->setTenGiga(enable);
} CATCH_HANDLE ("Could not set 10GbE enable.", "qTabDataOutput::SetTenGigaEnable", this, &qTabDataOutput::GetTenGigaEnable) }
CATCH_HANDLE("Could not set 10GbE enable.",
"qTabDataOutput::SetTenGigaEnable", this,
&qTabDataOutput::GetTenGigaEnable)
} }
void qTabDataOutput::GetRateCorrection() { void qTabDataOutput::GetRateCorrection() {
FILE_LOG(logDEBUG) << "Getting Rate Correction"; FILE_LOG(logDEBUG) << "Getting Rate Correction";
disconnect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection())); disconnect(chkRate, SIGNAL(toggled(bool)), this,
disconnect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection())); SLOT(EnableRateCorrection()));
disconnect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); disconnect(btnGroupRate, SIGNAL(buttonClicked(int)), this,
SLOT(SetRateCorrection()));
disconnect(spinCustomDeadTime, SIGNAL(editingFinished()), this,
SLOT(SetRateCorrection()));
try { try {
spinCustomDeadTime->setValue(-1); spinCustomDeadTime->setValue(-1);
int64_t retval = det->getRateCorrection().tsquash("Rate correction (enable/tau) is inconsistent for all detectors.").count(); int64_t retval = det->getRateCorrection()
.tsquash("Rate correction (enable/tau) is "
"inconsistent for all detectors.")
.count();
chkRate->setChecked(retval == 0 ? false : true); chkRate->setChecked(retval == 0 ? false : true);
if (retval != 0) if (retval != 0)
spinCustomDeadTime->setValue(retval); spinCustomDeadTime->setValue(retval);
} CATCH_DISPLAY("Could not get rate correction.", "qTabDataOutput::GetRateCorrection") }
CATCH_DISPLAY("Could not get rate correction.",
"qTabDataOutput::GetRateCorrection")
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection())); connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection())); connect(btnGroupRate, SIGNAL(buttonClicked(int)), this,
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection())); SLOT(SetRateCorrection()));
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this,
SLOT(SetRateCorrection()));
} }
void qTabDataOutput::EnableRateCorrection() { void qTabDataOutput::EnableRateCorrection() {
@ -255,7 +319,10 @@ void qTabDataOutput::EnableRateCorrection() {
// disable // disable
try { try {
det->setRateCorrection(sls::ns(0)); det->setRateCorrection(sls::ns(0));
} CATCH_HANDLE ("Could not switch off rate correction.", "qTabDataOutput::EnableRateCorrection", this, &qTabDataOutput::GetRateCorrection) }
CATCH_HANDLE("Could not switch off rate correction.",
"qTabDataOutput::EnableRateCorrection", this,
&qTabDataOutput::GetRateCorrection)
} }
void qTabDataOutput::SetRateCorrection() { void qTabDataOutput::SetRateCorrection() {
@ -267,55 +334,77 @@ void qTabDataOutput::SetRateCorrection() {
// custom dead time // custom dead time
if (radioCustomDeadtime->isChecked()) { if (radioCustomDeadtime->isChecked()) {
int64_t deadtime = spinCustomDeadTime->value(); int64_t deadtime = spinCustomDeadTime->value();
FILE_LOG(logINFO) << "Setting Rate Correction with custom dead time: " << deadtime; FILE_LOG(logINFO)
<< "Setting Rate Correction with custom dead time: "
<< deadtime;
det->setRateCorrection(sls::ns(deadtime)); det->setRateCorrection(sls::ns(deadtime));
} }
// default dead time // default dead time
else { else {
FILE_LOG(logINFO) << "Setting Rate Correction with default dead time"; FILE_LOG(logINFO)
<< "Setting Rate Correction with default dead time";
det->setDefaultRateCorrection(); det->setDefaultRateCorrection();
} }
} CATCH_HANDLE ("Could not set rate correction.", "qTabDataOutput::SetRateCorrection", this, &qTabDataOutput::GetRateCorrection) }
CATCH_HANDLE("Could not set rate correction.",
"qTabDataOutput::SetRateCorrection", this,
&qTabDataOutput::GetRateCorrection)
} }
void qTabDataOutput::GetSpeed() { void qTabDataOutput::GetSpeed() {
FILE_LOG(logDEBUG) << "Getting Speed"; FILE_LOG(logDEBUG) << "Getting Speed";
disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int))); disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSpeed(int)));
try { try {
auto retval = det->getSpeed().tsquash("Speed is inconsistent for all detectors."); auto retval =
det->getSpeed().tsquash("Speed is inconsistent for all detectors.");
comboEigerClkDivider->setCurrentIndex(static_cast<int>(retval)); comboEigerClkDivider->setCurrentIndex(static_cast<int>(retval));
} CATCH_DISPLAY ("Could not get speed.", "qTabDataOutput::GetSpeed") }
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int))); CATCH_DISPLAY("Could not get speed.", "qTabDataOutput::GetSpeed")
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSpeed(int)));
} }
void qTabDataOutput::SetSpeed(int speed) { void qTabDataOutput::SetSpeed(int speed) {
FILE_LOG(logINFO) << "Setting Speed to " << comboEigerClkDivider->currentText().toAscii().data();; FILE_LOG(logINFO) << "Setting Speed to "
<< comboEigerClkDivider->currentText().toAscii().data();
;
try { try {
det->setSpeed(static_cast<slsDetectorDefs::speedLevel>(speed)); det->setSpeed(static_cast<slsDetectorDefs::speedLevel>(speed));
} CATCH_HANDLE ("Could not set speed.", "qTabDataOutput::SetSpeed", this, &qTabDataOutput::GetSpeed) }
CATCH_HANDLE("Could not set speed.", "qTabDataOutput::SetSpeed", this,
&qTabDataOutput::GetSpeed)
} }
void qTabDataOutput::GetFlags() { void qTabDataOutput::GetFlags() {
FILE_LOG(logDEBUG) << "Getting readout flags"; FILE_LOG(logDEBUG) << "Getting readout flags";
disconnect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); disconnect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFlags()));
try { try {
auto retval = det->getParallelMode().tsquash("Parallel Flag is inconsistent for all detectors."); auto retval = det->getParallelMode().tsquash(
"Parallel Flag is inconsistent for all detectors.");
// parallel or non parallel // parallel or non parallel
if (retval) if (retval)
comboEigerParallelFlag->setCurrentIndex(PARALLEL); comboEigerParallelFlag->setCurrentIndex(PARALLEL);
else else
comboEigerParallelFlag->setCurrentIndex(NONPARALLEL); comboEigerParallelFlag->setCurrentIndex(NONPARALLEL);
} CATCH_DISPLAY ("Could not get flags.", "qTabDataOutput::GetFlags") }
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags())); CATCH_DISPLAY("Could not get flags.", "qTabDataOutput::GetFlags")
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFlags()));
} }
void qTabDataOutput::SetFlags() { void qTabDataOutput::SetFlags() {
auto mode = comboEigerParallelFlag->currentIndex() == PARALLEL ? true : false; auto mode =
comboEigerParallelFlag->currentIndex() == PARALLEL ? true : false;
try { try {
FILE_LOG(logINFO) << "Setting Readout Flags to " << comboEigerParallelFlag->currentText().toAscii().data(); FILE_LOG(logINFO)
<< "Setting Readout Flags to "
<< comboEigerParallelFlag->currentText().toAscii().data();
det->setParallelMode(mode); det->setParallelMode(mode);
} CATCH_HANDLE ("Could not set readout flags.", "qTabDataOutput::SetFlags", this, &qTabDataOutput::GetFlags) }
CATCH_HANDLE("Could not set readout flags.", "qTabDataOutput::SetFlags",
this, &qTabDataOutput::GetFlags)
} }
void qTabDataOutput::Refresh() { void qTabDataOutput::Refresh() {

96
slsDetectorGui/src/qTabDebugging.cpp Executable file → Normal file
View File

@ -9,8 +9,10 @@
#include <iostream> #include <iostream>
qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector) : qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector)
QWidget(parent), det(detector), treeDet(nullptr), lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr), lblDetectorSoftware(nullptr) { : QWidget(parent), det(detector), treeDet(nullptr),
lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr),
lblDetectorSoftware(nullptr) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Debugging ready"; FILE_LOG(logDEBUG) << "Debugging ready";
@ -23,7 +25,6 @@ qTabDebugging::~qTabDebugging() {
delete lblDetectorSoftware; delete lblDetectorSoftware;
} }
void qTabDebugging::SetupWidgetWindow() { void qTabDebugging::SetupWidgetWindow() {
// enabling according to det type // enabling according to det type
if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) { if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
@ -40,9 +41,9 @@ void qTabDebugging::SetupWidgetWindow() {
Refresh(); Refresh();
} }
void qTabDebugging::Initialization() { void qTabDebugging::Initialization() {
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetDetectorStatus())); connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(GetDetectorStatus()));
connect(btnGetInfo, SIGNAL(clicked()), this, SLOT(GetInfo())); connect(btnGetInfo, SIGNAL(clicked()), this, SLOT(GetInfo()));
if (btnTest->isEnabled()) { if (btnTest->isEnabled()) {
connect(btnTest, SIGNAL(clicked()), this, SLOT(TestDetector())); connect(btnTest, SIGNAL(clicked()), this, SLOT(TestDetector()));
@ -63,11 +64,13 @@ void qTabDebugging::GetDetectorStatus() {
FILE_LOG(logDEBUG) << "Getting Status"; FILE_LOG(logDEBUG) << "Getting Status";
try { try {
std::string status = sls::ToString(det->getDetectorStatus({comboDetector->currentIndex()})[0]); std::string status = sls::ToString(
det->getDetectorStatus({comboDetector->currentIndex()})[0]);
lblStatus->setText(QString(status.c_str()).toUpper()); lblStatus->setText(QString(status.c_str()).toUpper());
} CATCH_DISPLAY ("Could not get detector status.", "qTabDebugging::GetDetectorStatus")
} }
CATCH_DISPLAY("Could not get detector status.",
"qTabDebugging::GetDetectorStatus")
}
void qTabDebugging::GetInfo() { void qTabDebugging::GetInfo() {
FILE_LOG(logDEBUG) << "Getting Readout Info"; FILE_LOG(logDEBUG) << "Getting Readout Info";
@ -86,34 +89,45 @@ void qTabDebugging::GetInfo() {
// to make sure the size is constant // to make sure the size is constant
lblDetectorFirmware->setFixedWidth(100); lblDetectorFirmware->setFixedWidth(100);
layout->addWidget(dispFrame, 0, 1); layout->addWidget(dispFrame, 0, 1);
QString detName = QString(sls::ToString(det->getDetectorType().squash()).c_str()); QString detName =
QString(sls::ToString(det->getDetectorType().squash()).c_str());
switch (det->getDetectorType().squash()) { switch (det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
formLayout->addWidget(new QLabel("Half Module:"), 0, 0); formLayout->addWidget(new QLabel("Half Module:"), 0, 0);
formLayout->addItem(new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 1); formLayout->addItem(
new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0,
1);
formLayout->addWidget(lblDetectorHostname, 0, 2); formLayout->addWidget(lblDetectorHostname, 0, 2);
formLayout->addWidget(new QLabel("Half Module Firmware Version:"), 1, 0); formLayout->addWidget(new QLabel("Half Module Firmware Version:"), 1,
0);
formLayout->addWidget(lblDetectorFirmware, 1, 2); formLayout->addWidget(lblDetectorFirmware, 1, 2);
formLayout->addWidget(new QLabel("Half Module Software Version:"), 2, 0); formLayout->addWidget(new QLabel("Half Module Software Version:"), 2,
0);
formLayout->addWidget(lblDetectorSoftware, 2, 2); formLayout->addWidget(lblDetectorSoftware, 2, 2);
treeDet->setHeaderLabel("Eiger Detector"); treeDet->setHeaderLabel("Eiger Detector");
// get num modules // get num modules
for (int i = 0; i < comboDetector->count() / 2; ++i) for (int i = 0; i < comboDetector->count() / 2; ++i)
items.append(new QTreeWidgetItem((QTreeWidget *)0, QStringList(QString("Module %1").arg(i)))); items.append(new QTreeWidgetItem(
(QTreeWidget *)0, QStringList(QString("Module %1").arg(i))));
treeDet->insertTopLevelItems(0, items); treeDet->insertTopLevelItems(0, items);
// gets det names // gets det names
for (int i = 0; i < comboDetector->count(); ++i) { for (int i = 0; i < comboDetector->count(); ++i) {
QList<QTreeWidgetItem *> childItems; QList<QTreeWidgetItem *> childItems;
childItems.append(new QTreeWidgetItem((QTreeWidget *)0, QStringList(QString("Half Module (%1)").arg(comboDetector->itemText(i))))); childItems.append(new QTreeWidgetItem(
(QTreeWidget *)0,
QStringList(QString("Half Module (%1)")
.arg(comboDetector->itemText(i)))));
treeDet->topLevelItem(i * 2)->insertChildren(0, childItems); treeDet->topLevelItem(i * 2)->insertChildren(0, childItems);
} }
break; break;
default: default:
formLayout->addWidget(new QLabel("Module:"), 0, 0); formLayout->addWidget(new QLabel("Module:"), 0, 0);
formLayout->addItem(new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 1); formLayout->addItem(
new QSpacerItem(15, 20, QSizePolicy::Fixed, QSizePolicy::Fixed), 0,
1);
formLayout->addWidget(lblDetectorHostname, 0, 2); formLayout->addWidget(lblDetectorHostname, 0, 2);
formLayout->addWidget(new QLabel("Module Firmware Version:"), 1, 0); formLayout->addWidget(new QLabel("Module Firmware Version:"), 1, 0);
formLayout->addWidget(lblDetectorFirmware, 1, 2); formLayout->addWidget(lblDetectorFirmware, 1, 2);
@ -122,28 +136,33 @@ void qTabDebugging::GetInfo() {
treeDet->setHeaderLabel(QString(detName + " Detector")); treeDet->setHeaderLabel(QString(detName + " Detector"));
// gets det names // gets det names
for (int i = 0; i < comboDetector->count(); ++i) for (int i = 0; i < comboDetector->count(); ++i)
items.append(new QTreeWidgetItem((QTreeWidget *)0, QStringList(QString("Module (%1)").arg(comboDetector->itemText(i))))); items.append(new QTreeWidgetItem(
(QTreeWidget *)0,
QStringList(
QString("Module (%1)").arg(comboDetector->itemText(i)))));
treeDet->insertTopLevelItems(0, items); treeDet->insertTopLevelItems(0, items);
break; break;
} }
// show and center widget // show and center widget
int x = ((parentWidget()->width()) - (popup1->frameGeometry().width())) / 2; int x = ((parentWidget()->width()) - (popup1->frameGeometry().width())) / 2;
int y = ((parentWidget()->height()) - (popup1->frameGeometry().height())) / 2; int y =
((parentWidget()->height()) - (popup1->frameGeometry().height())) / 2;
QDesktopWidget *desktop = QApplication::desktop(); QDesktopWidget *desktop = QApplication::desktop();
int screen = desktop->screenNumber(this); int screen = desktop->screenNumber(this);
popup1->setWindowModality(Qt::WindowModal); popup1->setWindowModality(Qt::WindowModal);
popup1->move((desktop->screenGeometry(screen).x()) + x, (desktop->screenGeometry(screen).y()) + y); popup1->move((desktop->screenGeometry(screen).x()) + x,
(desktop->screenGeometry(screen).y()) + y);
popup1->show(); popup1->show();
// put the first parameters // put the first parameters
SetParameters(treeDet->topLevelItem(0)); SetParameters(treeDet->topLevelItem(0));
// connect to slots // connect to slots
connect(treeDet, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(SetParameters(QTreeWidgetItem *))); connect(treeDet, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this,
SLOT(SetParameters(QTreeWidgetItem *)));
} }
void qTabDebugging::SetParameters(QTreeWidgetItem *item) { void qTabDebugging::SetParameters(QTreeWidgetItem *item) {
// eiger: if half module clicked, others: true always // eiger: if half module clicked, others: true always
bool ignoreOrHalfModuleClicked = true; bool ignoreOrHalfModuleClicked = true;
@ -160,11 +179,17 @@ void qTabDebugging::SetParameters(QTreeWidgetItem *item) {
break; break;
} }
try { try {
auto retval = std::string("0x") + std::to_string((unsigned long)det->getFirmwareVersion({comboDetector->currentIndex()})[0]); auto retval = std::string("0x") +
std::to_string((unsigned long)det->getFirmwareVersion(
{comboDetector->currentIndex()})[0]);
lblDetectorFirmware->setText(QString(retval.c_str())); lblDetectorFirmware->setText(QString(retval.c_str()));
retval = std::string("0x") + std::to_string((unsigned long)det->getDetectorServerVersion({comboDetector->currentIndex()})[0]); retval =
std::string("0x") +
std::to_string((unsigned long)det->getDetectorServerVersion(
{comboDetector->currentIndex()})[0]);
lblDetectorSoftware->setText(QString(retval.c_str())); lblDetectorSoftware->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get versions.", "qTabDebugging::SetParameters") }
CATCH_DISPLAY("Could not get versions.", "qTabDebugging::SetParameters")
} }
} }
@ -178,35 +203,42 @@ void qTabDebugging::TestDetector() {
} }
// construct message // construct message
QString message = QString("<nobr>Test Results for %1:</nobr><br><br>").arg(comboDetector->currentText()); QString message = QString("<nobr>Test Results for %1:</nobr><br><br>")
.arg(comboDetector->currentText());
// detector firmware // detector firmware
if (chkDetectorFirmware->isChecked()) { if (chkDetectorFirmware->isChecked()) {
try { try {
det->executeFirmwareTest({comboDetector->currentIndex()}); det->executeFirmwareTest({comboDetector->currentIndex()});
message.append(QString("<nobr>%1 Firmware: PASS</nobr><br>").arg(moduleName)); message.append(QString("<nobr>%1 Firmware: PASS</nobr><br>")
.arg(moduleName));
FILE_LOG(logINFO) << "Detector Firmware Test: Pass"; FILE_LOG(logINFO) << "Detector Firmware Test: Pass";
} CATCH_DISPLAY ("Firmware test failed.", "qTabDebugging::TestDetector") }
CATCH_DISPLAY("Firmware test failed.",
"qTabDebugging::TestDetector")
} }
// detector CPU-FPGA bus // detector CPU-FPGA bus
if (chkDetectorBus->isChecked()) { if (chkDetectorBus->isChecked()) {
try { try {
det->executeBusTest({comboDetector->currentIndex()}); det->executeBusTest({comboDetector->currentIndex()});
message.append(QString("<nobr>%1 Bus: PASS</nobr><br>").arg(moduleName)); message.append(
QString("<nobr>%1 Bus: PASS</nobr><br>").arg(moduleName));
FILE_LOG(logINFO) << "Detector Bus Test: Pass"; FILE_LOG(logINFO) << "Detector Bus Test: Pass";
} CATCH_DISPLAY ("Bus test failed.", "qTabDebugging::TestDetector") }
CATCH_DISPLAY("Bus test failed.", "qTabDebugging::TestDetector")
} }
// display message // display message
qDefs::Message(qDefs::INFORMATION, message.toAscii().constData(), "qTabDebugging::TestDetector"); qDefs::Message(qDefs::INFORMATION, message.toAscii().constData(),
} CATCH_DISPLAY ("Could not execute digital test.", "qTabDebugging::TestDetector") "qTabDebugging::TestDetector");
}
CATCH_DISPLAY("Could not execute digital test.",
"qTabDebugging::TestDetector")
} }
void qTabDebugging::Refresh() { void qTabDebugging::Refresh() {
FILE_LOG(logDEBUG) << "**Updating Debugging Tab"; FILE_LOG(logDEBUG) << "**Updating Debugging Tab";
GetDetectorStatus(); GetDetectorStatus();
FILE_LOG(logDEBUG) << "**Updated Debugging Tab"; FILE_LOG(logDEBUG) << "**Updated Debugging Tab";
} }

358
slsDetectorGui/src/qTabDeveloper.cpp Executable file → Normal file
View File

@ -1,10 +1,11 @@
#include "qTabDeveloper.h" #include "qTabDeveloper.h"
#include "qDefs.h"
#include "qDacWidget.h" #include "qDacWidget.h"
#include "qDefs.h"
#include <iostream> #include <iostream>
qTabDeveloper::qTabDeveloper(QWidget *parent, sls::Detector *detector) : QWidget(parent), det(detector) { qTabDeveloper::qTabDeveloper(QWidget *parent, sls::Detector *detector)
: QWidget(parent), det(detector) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Developer ready"; FILE_LOG(logDEBUG) << "Developer ready";
@ -25,127 +26,260 @@ void qTabDeveloper::SetupWidgetWindow() {
slsDetectorDefs::detectorType detType = det->getDetectorType().squash(); slsDetectorDefs::detectorType detType = det->getDetectorType().squash();
switch (detType) { switch (detType) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
dacWidgets.push_back(new qDacWidget(this, det, true, "v SvP: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "v SvN ", getSLSIndex(detType, tempid++))); this, det, true, "v SvP: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Vrf: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "v Vrs: ", getSLSIndex(detType, tempid++))); this, det, true, "v SvN ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Vtr: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "v Vtgstv: ", getSLSIndex(detType, tempid++))); this, det, true, "v Vrf: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v cal: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "v Vcp ", getSLSIndex(detType, tempid++))); this, det, true, "v Vrs: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Vcn: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "v Vis: ", getSLSIndex(detType, tempid++))); this, det, true, "v Vtr: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v rxb_lb: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "v rxb_rb: ", getSLSIndex(detType, tempid++))); this, det, true, "v Vtgstv: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Vcmp_ll: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "v Vcmp_lr: ", getSLSIndex(detType, tempid++))); this, det, true, "v cal: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Vcmp_rl: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "v Vcmp_rr: ", getSLSIndex(detType, tempid++))); this, det, true, "v Vcp ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v threshold: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature FPGA Ext: ", getSLSIndex(detType, tempid++))); this, det, true, "v Vcn: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature 10GE: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature DCDC: ", getSLSIndex(detType, tempid++))); this, det, true, "v Vis: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature SODL: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature SODR: ", getSLSIndex(detType, tempid++))); this, det, true, "v rxb_lb: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature FPGA: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
this, det, true, "v rxb_rb: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"v Vcmp_ll: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"v Vcmp_lr: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"v Vcmp_rl: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"v Vcmp_rr: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true,
"v threshold: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(
this, det, false,
"Temperature FPGA Ext: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(
this, det, false,
"Temperature 10GE: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(
this, det, false,
"Temperature DCDC: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(
this, det, false,
"Temperature SODL: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(
this, det, false,
"Temperature SODR: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(
this, det, false,
"Temperature FPGA: ", getSLSIndex(detType, tempid++)));
break; break;
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
comboHV->show(); comboHV->show();
lblComboHV->show(); lblComboHV->show();
dacWidgets.push_back(new qDacWidget(this, det, true, "v Reference: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "v Cascode n: ", getSLSIndex(detType, tempid++))); this, det, true,
dacWidgets.push_back(new qDacWidget(this, det, true, "v Cascode p: ", getSLSIndex(detType, tempid++))); "v Reference: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Comp. Output: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "v Cascode out ", getSLSIndex(detType, tempid++))); this, det, true,
dacWidgets.push_back(new qDacWidget(this, det, true, "v Comp. Input: ", getSLSIndex(detType, tempid++))); "v Cascode n: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v Comp. Ref: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "i Base Test: ", getSLSIndex(detType, tempid++))); this, det, true,
adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature ADC: ", getSLSIndex(detType, tempid++))); "v Cascode p: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature FPGA: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
this, det, true,
"v Comp. Output: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true, "v Cascode out ",
getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true,
"v Comp. Input: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true,
"v Comp. Ref: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true,
"i Base Test: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(
this, det, false,
"Temperature ADC: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(
this, det, false,
"Temperature FPGA: ", getSLSIndex(detType, tempid++)));
break; break;
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
lblSpinHV->show(); lblSpinHV->show();
spinHV->show(); spinHV->show();
dacWidgets.push_back(new qDacWidget(this, det, true, "v vb comp: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(
dacWidgets.push_back(new qDacWidget(this, det, true, "v vdd prot: ", getSLSIndex(detType, tempid++))); new qDacWidget(this, det, true,
dacWidgets.push_back(new qDacWidget(this, det, true, "v vin com: ", getSLSIndex(detType, tempid++))); "v vb comp: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v vref prech: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(
dacWidgets.push_back(new qDacWidget(this, det, true, "v vb pixbuf: ", getSLSIndex(detType, tempid++))); new qDacWidget(this, det, true,
dacWidgets.push_back(new qDacWidget(this, det, true, "v vb ds: ", getSLSIndex(detType, tempid++))); "v vdd prot: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "v vref ds: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(
dacWidgets.push_back(new qDacWidget(this, det, true, "i vref comp: ", getSLSIndex(detType, tempid++))); new qDacWidget(this, det, true,
adcWidgets.push_back(new qDacWidget(this, det, false, "Temperature ADC: ", getSLSIndex(detType, tempid++))); "v vin com: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true,
"v vref prech: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true,
"v vb pixbuf: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "v vb ds: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"v vref ds: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true,
"i vref comp: ", getSLSIndex(detType, tempid++)));
adcWidgets.push_back(new qDacWidget(
this, det, false,
"Temperature ADC: ", getSLSIndex(detType, tempid++)));
break; break;
case slsDetectorDefs::MOENCH: case slsDetectorDefs::MOENCH:
lblSpinHV->show(); lblSpinHV->show();
spinHV->show(); spinHV->show();
dacWidgets.push_back(new qDacWidget(this, det, true, "vbp_colbuf: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(
dacWidgets.push_back(new qDacWidget(this, det, true, "vipre: ", getSLSIndex(detType, tempid++))); new qDacWidget(this, det, true,
dacWidgets.push_back(new qDacWidget(this, det, true, "vin_cm: ", getSLSIndex(detType, tempid++))); "vbp_colbuf: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vb_sda: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "vcasc_sfp: ", getSLSIndex(detType, tempid++))); this, det, true, "vipre: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vout_cm: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "vipre_cds: ", getSLSIndex(detType, tempid++))); this, det, true, "vin_cm: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "ibias_sfp: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
this, det, true, "vb_sda: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"vcasc_sfp: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "vout_cm: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"vipre_cds: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"ibias_sfp: ", getSLSIndex(detType, tempid++)));
break; break;
case slsDetectorDefs::MYTHEN3: case slsDetectorDefs::MYTHEN3:
lblSpinHV->show(); lblSpinHV->show();
spinHV->show(); spinHV->show();
hvmin = 0; hvmin = 0;
dacWidgets.push_back(new qDacWidget(this, det, true, "vcassh: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "vth2: ", getSLSIndex(detType, tempid++))); this, det, true, "vcassh: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vshaper: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "vshaperneg: ", getSLSIndex(detType, tempid++))); this, det, true, "vth2: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vipre_out: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "vth3: ", getSLSIndex(detType, tempid++))); this, det, true, "vshaper: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vth1: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(
dacWidgets.push_back(new qDacWidget(this, det, true, "vicin: ", getSLSIndex(detType, tempid++))); new qDacWidget(this, det, true,
dacWidgets.push_back(new qDacWidget(this, det, true, "vcas: ", getSLSIndex(detType, tempid++))); "vshaperneg: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vpreamp: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(
dacWidgets.push_back(new qDacWidget(this, det, true, "vph: ", getSLSIndex(detType, tempid++))); new qDacWidget(this, det, true,
dacWidgets.push_back(new qDacWidget(this, det, true, "vipre: ", getSLSIndex(detType, tempid++))); "vipre_out: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "viinsh: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "vpl: ", getSLSIndex(detType, tempid++))); this, det, true, "vth3: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vtrim: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "vdcsh: ", getSLSIndex(detType, tempid++))); this, det, true, "vth1: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "vicin: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "vcas: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "vpreamp: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "vph: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "vipre: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "viinsh: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "vpl: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "vtrim: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "vdcsh: ", getSLSIndex(detType, tempid++)));
break; break;
case slsDetectorDefs::GOTTHARD2: case slsDetectorDefs::GOTTHARD2:
lblSpinHV->show(); lblSpinHV->show();
spinHV->show(); spinHV->show();
hvmin = 0; hvmin = 0;
dacWidgets.push_back(new qDacWidget(this, det, true, "vref_h_adc: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(
dacWidgets.push_back(new qDacWidget(this, det, true, "vb_comp_fe: ", getSLSIndex(detType, tempid++))); new qDacWidget(this, det, true,
dacWidgets.push_back(new qDacWidget(this, det, true, "vb_comp_adc: ", getSLSIndex(detType, tempid++))); "vref_h_adc: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vcom_cds: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(
dacWidgets.push_back(new qDacWidget(this, det, true, "vref_rstore: ", getSLSIndex(detType, tempid++))); new qDacWidget(this, det, true,
dacWidgets.push_back(new qDacWidget(this, det, true, "vb_opa_1st: ", getSLSIndex(detType, tempid++))); "vb_comp_fe: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vref_comp_fe: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "vcom_adc1: ", getSLSIndex(detType, tempid++))); this, det, true,
dacWidgets.push_back(new qDacWidget(this, det, true, "vref_prech: ", getSLSIndex(detType, tempid++))); "vb_comp_adc: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vref_l_adc: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "vref_cds: ", getSLSIndex(detType, tempid++))); this, det, true, "vcom_cds: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(this, det, true, "vb_cs: ", getSLSIndex(detType, tempid++))); dacWidgets.push_back(new qDacWidget(
dacWidgets.push_back(new qDacWidget(this, det, true, "vb_opa_fd: ", getSLSIndex(detType, tempid++))); this, det, true,
dacWidgets.push_back(new qDacWidget(this, det, true, "vcom_adc2: ", getSLSIndex(detType, tempid++))); "vref_rstore: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"vb_opa_1st: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true,
"vref_comp_fe: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"vcom_adc1: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"vref_prech: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"vref_l_adc: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "vref_cds: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(new qDacWidget(
this, det, true, "vb_cs: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"vb_opa_fd: ", getSLSIndex(detType, tempid++)));
dacWidgets.push_back(
new qDacWidget(this, det, true,
"vcom_adc2: ", getSLSIndex(detType, tempid++)));
break; break;
default: default:
break; break;
} }
} CATCH_DISPLAY (std::string("Could not get dac/ adc index ") + std::to_string(tempid), "qTabDeveloper::SetupWidgetWindow") }
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) { for (size_t i = 0; i < dacWidgets.size(); ++i) {
gridlayoutDac->addWidget(dacWidgets[i], i / 2, i % 2); gridlayoutDac->addWidget(dacWidgets[i], i / 2, i % 2);
} }
gridlayoutDac->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Expanding),dacWidgets.size(), 0); gridlayoutDac->addItem(
new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Expanding),
dacWidgets.size(), 0);
for (size_t i = 0; i < adcWidgets.size(); ++i) { for (size_t i = 0; i < adcWidgets.size(); ++i) {
gridlayoutAdc->addWidget(adcWidgets[i], i / 2, i % 2); gridlayoutAdc->addWidget(adcWidgets[i], i / 2, i % 2);
} }
gridlayoutAdc->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Expanding),adcWidgets.size(), 0); gridlayoutAdc->addItem(
new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Expanding),
adcWidgets.size(), 0);
tabWidget->setCurrentIndex(0); tabWidget->setCurrentIndex(0);
@ -154,10 +288,11 @@ void qTabDeveloper::SetupWidgetWindow() {
Refresh(); Refresh();
} }
void qTabDeveloper::Initialization() { void qTabDeveloper::Initialization() {
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(Refresh())); connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); SLOT(Refresh()));
connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
connect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage())); connect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage()));
} }
@ -181,14 +316,17 @@ void qTabDeveloper::GetHighVoltage() {
return; return;
FILE_LOG(logDEBUG) << "Getting High Voltage"; FILE_LOG(logDEBUG) << "Getting High Voltage";
disconnect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage())); disconnect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage()));
disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); disconnect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
try { try {
// dac units // dac units
auto retval = det->getHighVoltage({comboDetector->currentIndex() - 1}).tsquash("Inconsistent values for high voltage."); auto retval = det->getHighVoltage({comboDetector->currentIndex() - 1})
.tsquash("Inconsistent values for high voltage.");
// spinHV // spinHV
if (spinHV->isVisible()) { if (spinHV->isVisible()) {
if (retval != 0 && retval < hvmin && retval > HV_MAX) { if (retval != 0 && retval < hvmin && retval > HV_MAX) {
throw sls::RuntimeError(std::string("Unknown High Voltage: ") + std::to_string(retval)); throw sls::RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
} }
spinHV->setValue(retval); spinHV->setValue(retval);
} }
@ -217,25 +355,32 @@ void qTabDeveloper::GetHighVoltage() {
comboHV->setCurrentIndex(HV_200); comboHV->setCurrentIndex(HV_200);
break; break;
default: default:
throw sls::RuntimeError(std::string("Unknown High Voltage: ") + std::to_string(retval)); throw sls::RuntimeError(std::string("Unknown High Voltage: ") +
std::to_string(retval));
} }
} }
} CATCH_DISPLAY ("Could not get high voltage.", "qTabDeveloper::GetHighVoltage") }
CATCH_DISPLAY("Could not get high voltage.",
"qTabDeveloper::GetHighVoltage")
connect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage())); connect(spinHV, SIGNAL(editingFinished()), this, SLOT(SetHighVoltage()));
connect(comboHV, SIGNAL(currentIndexChanged(int)), this, SLOT(SetHighVoltage())); connect(comboHV, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetHighVoltage()));
} }
void qTabDeveloper::SetHighVoltage() { void qTabDeveloper::SetHighVoltage() {
int val = (comboHV->isVisible() ? comboHV->currentText().toInt() : spinHV->value()); int val = (comboHV->isVisible() ? comboHV->currentText().toInt()
: spinHV->value());
FILE_LOG(logINFO) << "Setting high voltage:" << val; FILE_LOG(logINFO) << "Setting high voltage:" << val;
try { try {
det->setHighVoltage({comboDetector->currentIndex() - 1}); det->setHighVoltage({comboDetector->currentIndex() - 1});
} CATCH_HANDLE ("Could not set high voltage.", "qTabDeveloper::SetHighVoltage", }
CATCH_HANDLE("Could not set high voltage.", "qTabDeveloper::SetHighVoltage",
this, &qTabDeveloper::GetHighVoltage) this, &qTabDeveloper::GetHighVoltage)
} }
slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) { slsDetectorDefs::dacIndex
qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorType detType, int index) {
switch (detType) { switch (detType) {
case slsDetectorDefs::EIGER: case slsDetectorDefs::EIGER:
@ -287,7 +432,8 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorTy
case 22: case 22:
return slsDetectorDefs::TEMPERATURE_FPGA; return slsDetectorDefs::TEMPERATURE_FPGA;
default: default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index)); throw sls::RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index));
} }
break; break;
case slsDetectorDefs::GOTTHARD: case slsDetectorDefs::GOTTHARD:
@ -313,7 +459,8 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorTy
case 9: case 9:
return slsDetectorDefs::TEMPERATURE_FPGA; return slsDetectorDefs::TEMPERATURE_FPGA;
default: default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index)); throw sls::RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index));
} }
break; break;
@ -338,7 +485,8 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorTy
case 8: case 8:
return slsDetectorDefs::TEMPERATURE_ADC; return slsDetectorDefs::TEMPERATURE_ADC;
default: default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index)); throw sls::RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index));
} }
break; break;
@ -361,7 +509,8 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorTy
case 7: case 7:
return slsDetectorDefs::IBIAS_SFP; return slsDetectorDefs::IBIAS_SFP;
default: default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index)); throw sls::RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index));
} }
break; break;
@ -400,7 +549,8 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorTy
case 15: case 15:
return slsDetectorDefs::VDCSH; return slsDetectorDefs::VDCSH;
default: default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index)); throw sls::RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index));
} }
break; break;
@ -435,7 +585,8 @@ slsDetectorDefs::dacIndex qTabDeveloper::getSLSIndex(slsDetectorDefs::detectorTy
case 13: case 13:
return slsDetectorDefs::VCOM_ADC2; return slsDetectorDefs::VCOM_ADC2;
default: default:
throw sls::RuntimeError(std::string("Unknown dac/adc index") + std::to_string(index)); throw sls::RuntimeError(std::string("Unknown dac/adc index") +
std::to_string(index));
} }
break; break;
@ -455,4 +606,3 @@ void qTabDeveloper::Refresh() {
GetHighVoltage(); GetHighVoltage();
FILE_LOG(logDEBUG) << "**Updated Developer Tab"; FILE_LOG(logDEBUG) << "**Updated Developer Tab";
} }

381
slsDetectorGui/src/qTabMeasurement.cpp Executable file → Normal file
View File

@ -10,25 +10,26 @@
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
qTabMeasurement::qTabMeasurement(QWidget *parent, sls::Detector *detector, qDrawPlot *p) : QWidget(parent), det(detector), plot(p), qTabMeasurement::qTabMeasurement(QWidget *parent, sls::Detector *detector,
progressTimer(nullptr) { qDrawPlot *p)
: QWidget(parent), det(detector), plot(p), progressTimer(nullptr) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Measurement ready"; FILE_LOG(logDEBUG) << "Measurement ready";
} }
qTabMeasurement::~qTabMeasurement() { qTabMeasurement::~qTabMeasurement() { delete progressTimer; }
delete progressTimer;
}
void qTabMeasurement::SetupWidgetWindow() { void qTabMeasurement::SetupWidgetWindow() {
// palette // palette
red = QPalette(); red = QPalette();
red.setColor(QPalette::Active, QPalette::WindowText, Qt::red); red.setColor(QPalette::Active, QPalette::WindowText, Qt::red);
acqPeriodTip = spinPeriod->toolTip(); acqPeriodTip = spinPeriod->toolTip();
errPeriodTip = QString("<nobr>Frame period between exposures.</nobr><br>" errPeriodTip =
QString("<nobr>Frame period between exposures.</nobr><br>"
"<nobr> #period#</nobr><br><br>") + "<nobr> #period#</nobr><br><br>") +
QString("<nobr><font color=\"red\"><b>Acquisition Period</b> should be" QString(
"<nobr><font color=\"red\"><b>Acquisition Period</b> should be"
" greater than or equal to <b>Exposure Time</b>.</font></nobr>"); " greater than or equal to <b>Exposure Time</b>.</font></nobr>");
// timer to update the progress bar // timer to update the progress bar
@ -42,7 +43,8 @@ void qTabMeasurement::SetupWidgetWindow() {
spinDelay->setEnabled(true); spinDelay->setEnabled(true);
comboDelayUnit->setEnabled(true); comboDelayUnit->setEnabled(true);
// default is triggers and delay (not #bursts and burst period for gotthard2 in auto mode) // default is triggers and delay (not #bursts and burst period for gotthard2
// in auto mode)
ShowTriggerDelay(); ShowTriggerDelay();
// enabling according to det type // enabling according to det type
@ -84,38 +86,52 @@ void qTabMeasurement::SetupWidgetWindow() {
} }
void qTabMeasurement::Initialization() { void qTabMeasurement::Initialization() {
connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this,
connect(spinNumMeasurements, SIGNAL(valueChanged(int)), this, SLOT(SetNumMeasurements(int))); SLOT(SetTimingMode(int)));
connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(SetNumFrames(int))); connect(spinNumMeasurements, SIGNAL(valueChanged(int)), this,
connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(SetNumTriggers(int))); SLOT(SetNumMeasurements(int)));
connect(spinNumFrames, SIGNAL(valueChanged(int)), this,
SLOT(SetNumFrames(int)));
connect(spinNumTriggers, SIGNAL(valueChanged(int)), this,
SLOT(SetNumTriggers(int)));
if (spinNumBursts->isEnabled()) { if (spinNumBursts->isEnabled()) {
connect(spinNumBursts, SIGNAL(valueChanged(int)), this, SLOT(SetNumBursts(int))); connect(spinNumBursts, SIGNAL(valueChanged(int)), this,
SLOT(SetNumBursts(int)));
} }
if (spinNumSamples->isEnabled()) { if (spinNumSamples->isEnabled()) {
connect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int))); connect(spinNumSamples, SIGNAL(valueChanged(int)), this,
SLOT(SetNumSamples(int)));
} }
connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); connect(spinExpTime, SIGNAL(valueChanged(double)), this,
connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); SLOT(SetExposureTime()));
connect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetAcquisitionPeriod())); connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this,
connect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetAcquisitionPeriod())); SLOT(SetExposureTime()));
connect(spinPeriod, SIGNAL(valueChanged(double)), this,
SLOT(SetAcquisitionPeriod()));
connect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetAcquisitionPeriod()));
if (spinDelay->isEnabled()) { if (spinDelay->isEnabled()) {
connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay())); connect(spinDelay, SIGNAL(valueChanged(double)), this,
connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDelay())); SLOT(SetDelay()));
connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDelay()));
} }
if (spinBurstPeriod->isEnabled()) { if (spinBurstPeriod->isEnabled()) {
connect(spinBurstPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetBurstPeriod())); connect(spinBurstPeriod, SIGNAL(valueChanged(double)), this,
connect(comboBurstPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetBurstPeriod())); SLOT(SetBurstPeriod()));
connect(comboBurstPeriodUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetBurstPeriod()));
} }
connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool))); connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool)));
connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName())); connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName()));
connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int))); connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int)));
if (startingFnumImplemented) { if (startingFnumImplemented) {
connect(spinStartingFrameNumber, SIGNAL(valueChanged(int)), this, SLOT(SetStartingFrameNumber(int))); connect(spinStartingFrameNumber, SIGNAL(valueChanged(int)), this,
SLOT(SetStartingFrameNumber(int)));
} }
connect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress())); connect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress()));
connect(btnStart, SIGNAL(clicked()), this, SLOT(StartAcquisition())); connect(btnStart, SIGNAL(clicked()), this, SLOT(StartAcquisition()));
connect(btnStop, SIGNAL(clicked()), this, SLOT(StopAcquisition())); connect(btnStop, SIGNAL(clicked()), this, SLOT(StopAcquisition()));
} }
void qTabMeasurement::ShowTriggerDelay() { void qTabMeasurement::ShowTriggerDelay() {
@ -123,12 +139,16 @@ void qTabMeasurement::ShowTriggerDelay() {
if (det->getDetectorType().squash() == slsDetectorDefs::GOTTHARD2) { if (det->getDetectorType().squash() == slsDetectorDefs::GOTTHARD2) {
try { try {
FILE_LOG(logDEBUG) << "Getting burst mode"; FILE_LOG(logDEBUG) << "Getting burst mode";
auto retval = det->getBurstMode().tsquash("Inconsistent burst mode for all detectors."); auto retval = det->getBurstMode().tsquash(
"Inconsistent burst mode for all detectors.");
// burst mode and auto timing mode // burst mode and auto timing mode
if (retval != slsDetectorDefs::BURST_OFF && comboTimingMode->currentIndex() == AUTO) { if (retval != slsDetectorDefs::BURST_OFF &&
comboTimingMode->currentIndex() == AUTO) {
showTrigger = false; showTrigger = false;
} }
} CATCH_DISPLAY ("Could not get burst mode.", "qTabMeasurement::ShowTriggerDelay") }
CATCH_DISPLAY("Could not get burst mode.",
"qTabMeasurement::ShowTriggerDelay")
} }
if (showTrigger) { if (showTrigger) {
@ -146,14 +166,15 @@ void qTabMeasurement::ShowTriggerDelay() {
} }
} }
void qTabMeasurement::SetupTimingMode() { void qTabMeasurement::SetupTimingMode() {
QStandardItemModel* model = qobject_cast<QStandardItemModel *>(comboTimingMode->model()); QStandardItemModel *model =
qobject_cast<QStandardItemModel *>(comboTimingMode->model());
QModelIndex index[NUMTIMINGMODES]; QModelIndex index[NUMTIMINGMODES];
QStandardItem *item[NUMTIMINGMODES]; QStandardItem *item[NUMTIMINGMODES];
if (model) { if (model) {
for (int i = 0; i < NUMTIMINGMODES; i++) { for (int i = 0; i < NUMTIMINGMODES; i++) {
index[i] = model->index(i, comboTimingMode->modelColumn(), comboTimingMode->rootModelIndex()); index[i] = model->index(i, comboTimingMode->modelColumn(),
comboTimingMode->rootModelIndex());
item[i] = model->itemFromIndex(index[i]); item[i] = model->itemFromIndex(index[i]);
} }
@ -251,10 +272,12 @@ void qTabMeasurement::EnableWidgetsforTimingMode() {
void qTabMeasurement::GetTimingMode() { void qTabMeasurement::GetTimingMode() {
FILE_LOG(logDEBUG) << "Getting timing mode"; FILE_LOG(logDEBUG) << "Getting timing mode";
disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); disconnect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetTimingMode(int)));
try { try {
auto oldMode = comboTimingMode->currentIndex(); auto oldMode = comboTimingMode->currentIndex();
auto retval = det->getTimingMode().tsquash("Inconsistent timing mode for all detectors."); auto retval = det->getTimingMode().tsquash(
"Inconsistent timing mode for all detectors.");
switch (retval) { switch (retval) {
case slsDetectorDefs::AUTO_TIMING: case slsDetectorDefs::AUTO_TIMING:
case slsDetectorDefs::TRIGGER_EXPOSURE: case slsDetectorDefs::TRIGGER_EXPOSURE:
@ -267,18 +290,25 @@ void qTabMeasurement::GetTimingMode() {
} }
break; break;
default: default:
throw sls::RuntimeError(std::string("Unknown timing mode: ")+ std::to_string(retval)); throw sls::RuntimeError(std::string("Unknown timing mode: ") +
std::to_string(retval));
} }
} CATCH_DISPLAY("Could not get timing mode.", "qTabMeasurement::GetTimingMode") }
connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int))); CATCH_DISPLAY("Could not get timing mode.",
"qTabMeasurement::GetTimingMode")
connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetTimingMode(int)));
} }
void qTabMeasurement::SetTimingMode(int val) { void qTabMeasurement::SetTimingMode(int val) {
FILE_LOG(logINFO) << "Setting timing mode:" << comboTimingMode->currentText().toAscii().data(); FILE_LOG(logINFO) << "Setting timing mode:"
<< comboTimingMode->currentText().toAscii().data();
try { try {
det->setTimingMode(static_cast<slsDetectorDefs::timingMode>(val)); det->setTimingMode(static_cast<slsDetectorDefs::timingMode>(val));
EnableWidgetsforTimingMode(); EnableWidgetsforTimingMode();
} CATCH_HANDLE("Could not set timing mode.", "qTabMeasurement::SetTimingMode", this, &qTabMeasurement::GetTimingMode) }
CATCH_HANDLE("Could not set timing mode.", "qTabMeasurement::SetTimingMode",
this, &qTabMeasurement::GetTimingMode)
} }
void qTabMeasurement::SetNumMeasurements(int val) { void qTabMeasurement::SetNumMeasurements(int val) {
@ -288,132 +318,190 @@ void qTabMeasurement::SetNumMeasurements(int val) {
void qTabMeasurement::GetNumFrames() { void qTabMeasurement::GetNumFrames() {
FILE_LOG(logDEBUG) << "Getting number of frames"; FILE_LOG(logDEBUG) << "Getting number of frames";
disconnect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(SetNumFrames(int))); disconnect(spinNumFrames, SIGNAL(valueChanged(int)), this,
SLOT(SetNumFrames(int)));
try { try {
auto retval = det->getNumberOfFrames().tsquash("Inconsistent number of frames for all detectors."); auto retval = det->getNumberOfFrames().tsquash(
"Inconsistent number of frames for all detectors.");
spinNumFrames->setValue(retval); spinNumFrames->setValue(retval);
} CATCH_DISPLAY ("Could not get number of frames.", "qTabMeasurement::GetNumFrames") }
connect(spinNumFrames, SIGNAL(valueChanged(int)), this, SLOT(SetNumFrames(int))); CATCH_DISPLAY("Could not get number of frames.",
"qTabMeasurement::GetNumFrames")
connect(spinNumFrames, SIGNAL(valueChanged(int)), this,
SLOT(SetNumFrames(int)));
} }
void qTabMeasurement::SetNumFrames(int val) { void qTabMeasurement::SetNumFrames(int val) {
FILE_LOG(logINFO) << "Setting number of frames to " << val; FILE_LOG(logINFO) << "Setting number of frames to " << val;
try { try {
det->setNumberOfFrames(val); det->setNumberOfFrames(val);
} CATCH_HANDLE("Could not set number of frames.", "qTabMeasurement::SetNumFrames", this, &qTabMeasurement::GetNumFrames) }
CATCH_HANDLE("Could not set number of frames.",
"qTabMeasurement::SetNumFrames", this,
&qTabMeasurement::GetNumFrames)
} }
void qTabMeasurement::GetNumTriggers() { void qTabMeasurement::GetNumTriggers() {
FILE_LOG(logDEBUG) << "Getting number of triggers"; FILE_LOG(logDEBUG) << "Getting number of triggers";
disconnect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(SetNumTriggers(int))); disconnect(spinNumTriggers, SIGNAL(valueChanged(int)), this,
SLOT(SetNumTriggers(int)));
try { try {
auto retval = det->getNumberOfTriggers().tsquash("Inconsistent number of triggers for all detectors."); auto retval = det->getNumberOfTriggers().tsquash(
"Inconsistent number of triggers for all detectors.");
spinNumTriggers->setValue(retval); spinNumTriggers->setValue(retval);
} CATCH_DISPLAY ("Could not get number of frames.", "qTabMeasurement::GetNumTriggers") }
connect(spinNumTriggers, SIGNAL(valueChanged(int)), this, SLOT(SetNumTriggers(int))); CATCH_DISPLAY("Could not get number of frames.",
"qTabMeasurement::GetNumTriggers")
connect(spinNumTriggers, SIGNAL(valueChanged(int)), this,
SLOT(SetNumTriggers(int)));
} }
void qTabMeasurement::SetNumTriggers(int val) { void qTabMeasurement::SetNumTriggers(int val) {
FILE_LOG(logINFO) << "Setting number of triggers to " << val; FILE_LOG(logINFO) << "Setting number of triggers to " << val;
try { try {
det->setNumberOfTriggers(val); det->setNumberOfTriggers(val);
} CATCH_HANDLE("Could not set number of triggers.", "qTabMeasurement::SetNumTriggers", this, &qTabMeasurement::GetNumTriggers) }
CATCH_HANDLE("Could not set number of triggers.",
"qTabMeasurement::SetNumTriggers", this,
&qTabMeasurement::GetNumTriggers)
} }
void qTabMeasurement::GetNumBursts() { void qTabMeasurement::GetNumBursts() {
FILE_LOG(logDEBUG) << "Getting number of bursts"; FILE_LOG(logDEBUG) << "Getting number of bursts";
disconnect(spinNumBursts, SIGNAL(valueChanged(int)), this, SLOT(SetNumBursts(int))); disconnect(spinNumBursts, SIGNAL(valueChanged(int)), this,
SLOT(SetNumBursts(int)));
try { try {
auto retval = det->getNumberOfBursts().tsquash("Inconsistent number of bursts for all detectors."); auto retval = det->getNumberOfBursts().tsquash(
"Inconsistent number of bursts for all detectors.");
spinNumBursts->setValue(retval); spinNumBursts->setValue(retval);
} CATCH_DISPLAY ("Could not get number of frames.", "qTabMeasurement::GetNumBursts") }
connect(spinNumBursts, SIGNAL(valueChanged(int)), this, SLOT(SetNumBursts(int))); CATCH_DISPLAY("Could not get number of frames.",
"qTabMeasurement::GetNumBursts")
connect(spinNumBursts, SIGNAL(valueChanged(int)), this,
SLOT(SetNumBursts(int)));
} }
void qTabMeasurement::SetNumBursts(int val) { void qTabMeasurement::SetNumBursts(int val) {
FILE_LOG(logINFO) << "Setting number of bursts to " << val; FILE_LOG(logINFO) << "Setting number of bursts to " << val;
try { try {
det->setNumberOfBursts(val); det->setNumberOfBursts(val);
} CATCH_HANDLE("Could not set number of bursts.", "qTabMeasurement::SetNumBursts", this, &qTabMeasurement::GetNumBursts) }
CATCH_HANDLE("Could not set number of bursts.",
"qTabMeasurement::SetNumBursts", this,
&qTabMeasurement::GetNumBursts)
} }
void qTabMeasurement::GetNumSamples() { void qTabMeasurement::GetNumSamples() {
FILE_LOG(logDEBUG) << "Getting number of samples"; FILE_LOG(logDEBUG) << "Getting number of samples";
disconnect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int))); disconnect(spinNumSamples, SIGNAL(valueChanged(int)), this,
SLOT(SetNumSamples(int)));
try { try {
auto retval = det->getNumberOfAnalogSamples().tsquash("Inconsistent number of analog samples for all detectors."); auto retval = det->getNumberOfAnalogSamples().tsquash(
"Inconsistent number of analog samples for all detectors.");
spinNumSamples->setValue(retval); spinNumSamples->setValue(retval);
} CATCH_DISPLAY ("Could not get number of samples.", "qTabMeasurement::GetNumSamples") }
connect(spinNumSamples, SIGNAL(valueChanged(int)), this, SLOT(SetNumSamples(int))); CATCH_DISPLAY("Could not get number of samples.",
"qTabMeasurement::GetNumSamples")
connect(spinNumSamples, SIGNAL(valueChanged(int)), this,
SLOT(SetNumSamples(int)));
} }
void qTabMeasurement::SetNumSamples(int val) { void qTabMeasurement::SetNumSamples(int val) {
FILE_LOG(logINFO) << "Setting number of samples to " << val; FILE_LOG(logINFO) << "Setting number of samples to " << val;
try { try {
det->setNumberOfAnalogSamples(val); det->setNumberOfAnalogSamples(val);
} CATCH_HANDLE("Could not set number of samples.", "qTabMeasurement::SetNumSamples", this, &qTabMeasurement::GetNumSamples) }
CATCH_HANDLE("Could not set number of samples.",
"qTabMeasurement::SetNumSamples", this,
&qTabMeasurement::GetNumSamples)
} }
void qTabMeasurement::GetExposureTime() { void qTabMeasurement::GetExposureTime() {
FILE_LOG(logDEBUG) << "Getting exposure time"; FILE_LOG(logDEBUG) << "Getting exposure time";
disconnect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); disconnect(spinExpTime, SIGNAL(valueChanged(double)), this,
disconnect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); SLOT(SetExposureTime()));
disconnect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetExposureTime()));
try { try {
spinExpTime->setValue(-1); spinExpTime->setValue(-1);
auto retval = det->getExptime().tsquash("Inconsistent exposure time for all detectors."); auto retval = det->getExptime().tsquash(
"Inconsistent exposure time for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval); auto time = qDefs::getUserFriendlyTime(retval);
spinExpTime->setValue(time.first); spinExpTime->setValue(time.first);
comboExpUnit->setCurrentIndex(static_cast<int>(time.second)); comboExpUnit->setCurrentIndex(static_cast<int>(time.second));
CheckAcqPeriodGreaterThanExp(); CheckAcqPeriodGreaterThanExp();
} CATCH_DISPLAY ("Could not get exposure time.", "qTabMeasurement::GetExposureTime") }
connect(spinExpTime, SIGNAL(valueChanged(double)), this, SLOT(SetExposureTime())); CATCH_DISPLAY("Could not get exposure time.",
connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetExposureTime())); "qTabMeasurement::GetExposureTime")
connect(spinExpTime, SIGNAL(valueChanged(double)), this,
SLOT(SetExposureTime()));
connect(comboExpUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetExposureTime()));
} }
void qTabMeasurement::SetExposureTime() { void qTabMeasurement::SetExposureTime() {
auto val = spinExpTime->value(); auto val = spinExpTime->value();
auto unit = static_cast<qDefs::timeUnit>(comboExpUnit->currentIndex()); auto unit = static_cast<qDefs::timeUnit>(comboExpUnit->currentIndex());
FILE_LOG(logINFO) << "Setting exposure time to " << val << " " << qDefs::getUnitString(unit); FILE_LOG(logINFO) << "Setting exposure time to " << val << " "
<< qDefs::getUnitString(unit);
try { try {
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit)); auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
det->setExptime(timeNS); det->setExptime(timeNS);
CheckAcqPeriodGreaterThanExp(); CheckAcqPeriodGreaterThanExp();
} CATCH_HANDLE("Could not set exposure time.", "qTabMeasurement::SetExposureTime", this, &qTabMeasurement::GetExposureTime) }
CATCH_HANDLE("Could not set exposure time.",
"qTabMeasurement::SetExposureTime", this,
&qTabMeasurement::GetExposureTime)
} }
void qTabMeasurement::GetAcquisitionPeriod() { void qTabMeasurement::GetAcquisitionPeriod() {
FILE_LOG(logDEBUG) << "Getting acquisition period"; FILE_LOG(logDEBUG) << "Getting acquisition period";
disconnect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetAcquisitionPeriod())); disconnect(spinPeriod, SIGNAL(valueChanged(double)), this,
disconnect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetAcquisitionPeriod())); SLOT(SetAcquisitionPeriod()));
disconnect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetAcquisitionPeriod()));
try { try {
spinPeriod->setValue(-1); spinPeriod->setValue(-1);
auto retval = det->getPeriod().tsquash("Inconsistent acquisition period for all detectors."); auto retval = det->getPeriod().tsquash(
"Inconsistent acquisition period for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval); auto time = qDefs::getUserFriendlyTime(retval);
spinPeriod->setValue(time.first); spinPeriod->setValue(time.first);
comboPeriodUnit->setCurrentIndex(static_cast<int>(time.second)); comboPeriodUnit->setCurrentIndex(static_cast<int>(time.second));
CheckAcqPeriodGreaterThanExp(); CheckAcqPeriodGreaterThanExp();
} CATCH_DISPLAY ("Could not get acquisition period.", "qTabMeasurement::GetAcquisitionPeriod") }
connect(spinPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetAcquisitionPeriod())); CATCH_DISPLAY("Could not get acquisition period.",
connect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetAcquisitionPeriod())); "qTabMeasurement::GetAcquisitionPeriod")
connect(spinPeriod, SIGNAL(valueChanged(double)), this,
SLOT(SetAcquisitionPeriod()));
connect(comboPeriodUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetAcquisitionPeriod()));
} }
void qTabMeasurement::SetAcquisitionPeriod() { void qTabMeasurement::SetAcquisitionPeriod() {
auto val = spinPeriod->value(); auto val = spinPeriod->value();
auto unit = static_cast<qDefs::timeUnit>(comboPeriodUnit->currentIndex()); auto unit = static_cast<qDefs::timeUnit>(comboPeriodUnit->currentIndex());
FILE_LOG(logINFO) << "Setting acquisition period to " << val << " " << qDefs::getUnitString(unit); FILE_LOG(logINFO) << "Setting acquisition period to " << val << " "
<< qDefs::getUnitString(unit);
try { try {
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit)); auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
det->setPeriod(timeNS); det->setPeriod(timeNS);
CheckAcqPeriodGreaterThanExp(); CheckAcqPeriodGreaterThanExp();
} CATCH_HANDLE("Could not set acquisition period.", "qTabMeasurement::SetAcquisitionPeriod", this, &qTabMeasurement::GetAcquisitionPeriod) }
CATCH_HANDLE("Could not set acquisition period.",
"qTabMeasurement::SetAcquisitionPeriod", this,
&qTabMeasurement::GetAcquisitionPeriod)
} }
void qTabMeasurement::CheckAcqPeriodGreaterThanExp() { void qTabMeasurement::CheckAcqPeriodGreaterThanExp() {
FILE_LOG(logDEBUG) << "Checking period >= exptime"; FILE_LOG(logDEBUG) << "Checking period >= exptime";
bool error = false; bool error = false;
if (lblPeriod->isEnabled()) { if (lblPeriod->isEnabled()) {
auto exptimeNS = qDefs::getNSTime(std::make_pair(spinExpTime->value(), static_cast<qDefs::timeUnit>(comboExpUnit->currentIndex()))); auto exptimeNS = qDefs::getNSTime(std::make_pair(
auto acqtimeNS = qDefs::getNSTime(std::make_pair(spinPeriod->value(), static_cast<qDefs::timeUnit>(comboPeriodUnit->currentIndex()))); spinExpTime->value(),
static_cast<qDefs::timeUnit>(comboExpUnit->currentIndex())));
auto acqtimeNS = qDefs::getNSTime(std::make_pair(
spinPeriod->value(),
static_cast<qDefs::timeUnit>(comboPeriodUnit->currentIndex())));
if (exptimeNS > acqtimeNS) { if (exptimeNS > acqtimeNS) {
error = true; error = true;
spinPeriod->setToolTip(errPeriodTip); spinPeriod->setToolTip(errPeriodTip);
@ -434,53 +522,71 @@ void qTabMeasurement::CheckAcqPeriodGreaterThanExp() {
void qTabMeasurement::GetDelay() { void qTabMeasurement::GetDelay() {
FILE_LOG(logDEBUG) << "Getting delay"; FILE_LOG(logDEBUG) << "Getting delay";
disconnect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay())); disconnect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay()));
disconnect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDelay())); disconnect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDelay()));
try { try {
spinDelay->setValue(-1); spinDelay->setValue(-1);
auto retval = det->getDelayAfterTrigger().tsquash("Inconsistent delay for all detectors."); auto retval = det->getDelayAfterTrigger().tsquash(
"Inconsistent delay for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval); auto time = qDefs::getUserFriendlyTime(retval);
spinDelay->setValue(time.first); spinDelay->setValue(time.first);
comboDelayUnit->setCurrentIndex(static_cast<int>(time.second)); comboDelayUnit->setCurrentIndex(static_cast<int>(time.second));
} CATCH_DISPLAY ("Could not get delay.", "qTabMeasurement::GetDelay") }
CATCH_DISPLAY("Could not get delay.", "qTabMeasurement::GetDelay")
connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay())); connect(spinDelay, SIGNAL(valueChanged(double)), this, SLOT(SetDelay()));
connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetDelay())); connect(comboDelayUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDelay()));
} }
void qTabMeasurement::SetDelay() { void qTabMeasurement::SetDelay() {
auto val = spinDelay->value(); auto val = spinDelay->value();
auto unit = static_cast<qDefs::timeUnit>(comboDelayUnit->currentIndex()); auto unit = static_cast<qDefs::timeUnit>(comboDelayUnit->currentIndex());
FILE_LOG(logINFO) << "Setting delay to " << val << " " << qDefs::getUnitString(unit); FILE_LOG(logINFO) << "Setting delay to " << val << " "
<< qDefs::getUnitString(unit);
try { try {
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit)); auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
det->setDelayAfterTrigger(timeNS); det->setDelayAfterTrigger(timeNS);
} CATCH_HANDLE("Could not set delay.", "qTabMeasurement::SetDelay", this, &qTabMeasurement::GetDelay) }
CATCH_HANDLE("Could not set delay.", "qTabMeasurement::SetDelay", this,
&qTabMeasurement::GetDelay)
} }
void qTabMeasurement::GetBurstPeriod() { void qTabMeasurement::GetBurstPeriod() {
FILE_LOG(logDEBUG) << "Getting Burst Period"; FILE_LOG(logDEBUG) << "Getting Burst Period";
disconnect(spinBurstPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetBurstPeriod())); disconnect(spinBurstPeriod, SIGNAL(valueChanged(double)), this,
disconnect(comboBurstPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetBurstPeriod())); SLOT(SetBurstPeriod()));
disconnect(comboBurstPeriodUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetBurstPeriod()));
try { try {
spinBurstPeriod->setValue(-1); spinBurstPeriod->setValue(-1);
auto retval = det->getBurstPeriod().tsquash("Inconsistent burst period for all detectors."); auto retval = det->getBurstPeriod().tsquash(
"Inconsistent burst period for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval); auto time = qDefs::getUserFriendlyTime(retval);
spinBurstPeriod->setValue(time.first); spinBurstPeriod->setValue(time.first);
comboBurstPeriodUnit->setCurrentIndex(static_cast<int>(time.second)); comboBurstPeriodUnit->setCurrentIndex(static_cast<int>(time.second));
} CATCH_DISPLAY ("Could not get burst period.", "qTabMeasurement::GetBurstPeriod") }
connect(spinBurstPeriod, SIGNAL(valueChanged(double)), this, SLOT(SetBurstPeriod())); CATCH_DISPLAY("Could not get burst period.",
connect(comboBurstPeriodUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetBurstPeriod())); "qTabMeasurement::GetBurstPeriod")
connect(spinBurstPeriod, SIGNAL(valueChanged(double)), this,
SLOT(SetBurstPeriod()));
connect(comboBurstPeriodUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetBurstPeriod()));
} }
void qTabMeasurement::SetBurstPeriod() { void qTabMeasurement::SetBurstPeriod() {
auto val = spinBurstPeriod->value(); auto val = spinBurstPeriod->value();
auto unit = static_cast<qDefs::timeUnit>(comboBurstPeriodUnit->currentIndex()); auto unit =
FILE_LOG(logINFO) << "Setting burst period to " << val << " " << qDefs::getUnitString(unit); static_cast<qDefs::timeUnit>(comboBurstPeriodUnit->currentIndex());
FILE_LOG(logINFO) << "Setting burst period to " << val << " "
<< qDefs::getUnitString(unit);
try { try {
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit)); auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
det->setBurstPeriod(timeNS); det->setBurstPeriod(timeNS);
} CATCH_HANDLE("Could not set burst period.", "qTabMeasurement::SetBurstPeriod", this, &qTabMeasurement::GetBurstPeriod)
} }
CATCH_HANDLE("Could not set burst period.",
"qTabMeasurement::SetBurstPeriod", this,
&qTabMeasurement::GetBurstPeriod)
}
void qTabMeasurement::GetFileWrite() { void qTabMeasurement::GetFileWrite() {
FILE_LOG(logDEBUG) << "Getting File Write Enable"; FILE_LOG(logDEBUG) << "Getting File Write Enable";
@ -489,12 +595,15 @@ void qTabMeasurement::GetFileWrite() {
dispFileName->setEnabled(true); // default, even when exception dispFileName->setEnabled(true); // default, even when exception
lblIndex->setEnabled(true); lblIndex->setEnabled(true);
spinIndex->setEnabled(true); spinIndex->setEnabled(true);
auto retval = det->getFileWrite().tsquash("Inconsistent file write for all detectors."); auto retval = det->getFileWrite().tsquash(
"Inconsistent file write for all detectors.");
chkFile->setChecked(retval); chkFile->setChecked(retval);
dispFileName->setEnabled(retval); dispFileName->setEnabled(retval);
lblIndex->setEnabled(retval); lblIndex->setEnabled(retval);
spinIndex->setEnabled(retval); spinIndex->setEnabled(retval);
} CATCH_DISPLAY ("Could not get file over write enable.", "qTabMeasurement::GetFileWrite") }
CATCH_DISPLAY("Could not get file over write enable.",
"qTabMeasurement::GetFileWrite")
connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool))); connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool)));
} }
@ -505,16 +614,23 @@ void qTabMeasurement::SetFileWrite(bool val) {
dispFileName->setEnabled(val); dispFileName->setEnabled(val);
lblIndex->setEnabled(val); lblIndex->setEnabled(val);
spinIndex->setEnabled(val); spinIndex->setEnabled(val);
} CATCH_HANDLE("Could not set file write enable.", "qTabMeasurement::SetFileWrite", this, &qTabMeasurement::GetFileWrite) }
CATCH_HANDLE("Could not set file write enable.",
"qTabMeasurement::SetFileWrite", this,
&qTabMeasurement::GetFileWrite)
} }
void qTabMeasurement::GetFileName() { void qTabMeasurement::GetFileName() {
FILE_LOG(logDEBUG) << "Getting file name prefix"; FILE_LOG(logDEBUG) << "Getting file name prefix";
disconnect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName())); disconnect(dispFileName, SIGNAL(editingFinished()), this,
SLOT(SetFileName()));
try { try {
auto retval = det->getFileNamePrefix().tsquash("Inconsistent file name prefix for all detectors."); auto retval = det->getFileNamePrefix().tsquash(
"Inconsistent file name prefix for all detectors.");
dispFileName->setText(QString(retval.c_str())); dispFileName->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get file name prefix.", "qTabMeasurement::GetFileName") }
CATCH_DISPLAY("Could not get file name prefix.",
"qTabMeasurement::GetFileName")
connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName())); connect(dispFileName, SIGNAL(editingFinished()), this, SLOT(SetFileName()));
} }
@ -523,18 +639,25 @@ void qTabMeasurement::SetFileName() {
FILE_LOG(logINFO) << "Setting File Name Prefix:" << val; FILE_LOG(logINFO) << "Setting File Name Prefix:" << val;
try { try {
det->setFileNamePrefix(val); det->setFileNamePrefix(val);
} CATCH_HANDLE("Could not set file name prefix.", "qTabMeasurement::SetFileName", this, &qTabMeasurement::GetFileName) }
CATCH_HANDLE("Could not set file name prefix.",
"qTabMeasurement::SetFileName", this,
&qTabMeasurement::GetFileName)
emit FileNameChangedSignal(dispFileName->text()); emit FileNameChangedSignal(dispFileName->text());
} }
void qTabMeasurement::GetRunIndex() { void qTabMeasurement::GetRunIndex() {
FILE_LOG(logDEBUG) << "Getting Acquisition File index"; FILE_LOG(logDEBUG) << "Getting Acquisition File index";
disconnect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int))); disconnect(spinIndex, SIGNAL(valueChanged(int)), this,
SLOT(SetRunIndex(int)));
try { try {
auto retval = det->getAcquisitionIndex().tsquash("Inconsistent file index for all detectors."); auto retval = det->getAcquisitionIndex().tsquash(
"Inconsistent file index for all detectors.");
spinIndex->setValue(retval); spinIndex->setValue(retval);
} CATCH_DISPLAY ("Could not get acquisition file index.", "qTabMeasurement::GetRunIndex") }
CATCH_DISPLAY("Could not get acquisition file index.",
"qTabMeasurement::GetRunIndex")
connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int))); connect(spinIndex, SIGNAL(valueChanged(int)), this, SLOT(SetRunIndex(int)));
} }
@ -542,24 +665,35 @@ void qTabMeasurement::SetRunIndex(int val) {
FILE_LOG(logINFO) << "Setting Acquisition File Index to " << val; FILE_LOG(logINFO) << "Setting Acquisition File Index to " << val;
try { try {
det->setAcquisitionIndex(val); det->setAcquisitionIndex(val);
} CATCH_HANDLE("Could not set acquisition file index.", "qTabMeasurement::SetRunIndex", this, &qTabMeasurement::GetRunIndex) }
CATCH_HANDLE("Could not set acquisition file index.",
"qTabMeasurement::SetRunIndex", this,
&qTabMeasurement::GetRunIndex)
} }
void qTabMeasurement::GetStartingFrameNumber() { void qTabMeasurement::GetStartingFrameNumber() {
FILE_LOG(logDEBUG) << "Getting Starting Frame Number"; FILE_LOG(logDEBUG) << "Getting Starting Frame Number";
disconnect(spinStartingFrameNumber, SIGNAL(valueChanged(int)), this, SLOT(SetStartingFrameNumber(int))); disconnect(spinStartingFrameNumber, SIGNAL(valueChanged(int)), this,
SLOT(SetStartingFrameNumber(int)));
try { try {
auto retval = det->getStartingFrameNumber().tsquash("Inconsistent starting frame number for all detectors."); auto retval = det->getStartingFrameNumber().tsquash(
"Inconsistent starting frame number for all detectors.");
spinStartingFrameNumber->setValue(retval); spinStartingFrameNumber->setValue(retval);
} CATCH_DISPLAY ("Could not get starting frame number.", "qTabMeasurement::GetStartingFrameNumber") }
connect(spinStartingFrameNumber, SIGNAL(valueChanged(int)), this, SLOT(SetStartingFrameNumber(int))); CATCH_DISPLAY("Could not get starting frame number.",
"qTabMeasurement::GetStartingFrameNumber")
connect(spinStartingFrameNumber, SIGNAL(valueChanged(int)), this,
SLOT(SetStartingFrameNumber(int)));
} }
void qTabMeasurement::SetStartingFrameNumber(int val) { void qTabMeasurement::SetStartingFrameNumber(int val) {
FILE_LOG(logINFO) << "Setting Starting frame number to " << val; FILE_LOG(logINFO) << "Setting Starting frame number to " << val;
try { try {
det->setStartingFrameNumber(val); det->setStartingFrameNumber(val);
} CATCH_HANDLE("Could not set starting frame number.", "qTabMeasurement::SetStartingFrameNumber", this, &qTabMeasurement::GetStartingFrameNumber) }
CATCH_HANDLE("Could not set starting frame number.",
"qTabMeasurement::SetStartingFrameNumber", this,
&qTabMeasurement::GetStartingFrameNumber)
} }
void qTabMeasurement::ResetProgress() { void qTabMeasurement::ResetProgress() {
@ -583,25 +717,32 @@ int qTabMeasurement::VerifyOutputDirectoryError() {
det->setFilePath(it); det->setFilePath(it);
} }
return slsDetectorDefs::OK; return slsDetectorDefs::OK;
} CATCH_DISPLAY ("Could not set path.", "qTabMeasurement::VerifyOutputDirectoryError") }
CATCH_DISPLAY("Could not set path.",
"qTabMeasurement::VerifyOutputDirectoryError")
return slsDetectorDefs::FAIL; // for exception return slsDetectorDefs::FAIL; // for exception
} }
void qTabMeasurement::StartAcquisition() { void qTabMeasurement::StartAcquisition() {
btnStart->setEnabled(false); btnStart->setEnabled(false);
// if file write enabled and output dir doesnt exist // if file write enabled and output dir doesnt exist
if ((chkFile->isChecked()) && (VerifyOutputDirectoryError() == slsDetectorDefs::FAIL)) { if ((chkFile->isChecked()) &&
if (qDefs::Message(qDefs::QUESTION, (VerifyOutputDirectoryError() == slsDetectorDefs::FAIL)) {
"<nobr>Your data will not be saved.</nobr><br><nobr>Disable File write and Proceed with acquisition anyway?</nobr>", if (qDefs::Message(
qDefs::QUESTION,
"<nobr>Your data will not be saved.</nobr><br><nobr>Disable "
"File write and Proceed with acquisition anyway?</nobr>",
"qTabMeasurement::StartAcquisition") == slsDetectorDefs::FAIL) { "qTabMeasurement::StartAcquisition") == slsDetectorDefs::FAIL) {
btnStart->setEnabled(true); btnStart->setEnabled(true);
return; return;
} else { } else {
disconnect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool))); disconnect(chkFile, SIGNAL(toggled(bool)), this,
SLOT(SetFileWrite(bool)));
chkFile->setChecked(false); chkFile->setChecked(false);
// cannot wait for signals from chkFile // cannot wait for signals from chkFile
SetFileWrite(false); SetFileWrite(false);
connect(chkFile, SIGNAL(toggled(bool)), this, SLOT(SetFileWrite(bool))); connect(chkFile, SIGNAL(toggled(bool)), this,
SLOT(SetFileWrite(bool)));
} }
} }
@ -616,13 +757,14 @@ void qTabMeasurement::StartAcquisition() {
emit EnableTabsSignal(false); emit EnableTabsSignal(false);
} }
void qTabMeasurement::StopAcquisition() { void qTabMeasurement::StopAcquisition() {
FILE_LOG(logINFORED) << "Stopping Acquisition"; FILE_LOG(logINFORED) << "Stopping Acquisition";
try { try {
isAcquisitionStopped = true; isAcquisitionStopped = true;
det->stopDetector(); det->stopDetector();
} CATCH_DISPLAY("Could not stop acquisition.", "qTabMeasurement::StopAcquisition") }
CATCH_DISPLAY("Could not stop acquisition.",
"qTabMeasurement::StopAcquisition")
} }
void qTabMeasurement::AcquireFinished() { void qTabMeasurement::AcquireFinished() {
@ -634,9 +776,11 @@ void qTabMeasurement::AcquireFinished() {
if (startingFnumImplemented) { if (startingFnumImplemented) {
GetStartingFrameNumber(); GetStartingFrameNumber();
} }
FILE_LOG(logDEBUG) << "Measurement " << currentMeasurement << " finished"; FILE_LOG(logDEBUG) << "Measurement " << currentMeasurement
<< " finished";
// next measurement if acq is not stopped // next measurement if acq is not stopped
if (!isAcquisitionStopped && ((currentMeasurement + 1) < numMeasurements)) { if (!isAcquisitionStopped &&
((currentMeasurement + 1) < numMeasurements)) {
++currentMeasurement; ++currentMeasurement;
plot->StartAcquisition(); plot->StartAcquisition();
} }
@ -662,7 +806,8 @@ void qTabMeasurement::Enable(bool enable) {
frameNotTimeResolved->setEnabled(enable); frameNotTimeResolved->setEnabled(enable);
// shortcut each time, else it doesnt work a second time // shortcut each time, else it doesnt work a second time
btnStart->setShortcut(QApplication::translate("TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8)); btnStart->setShortcut(QApplication::translate(
"TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8));
} }
void qTabMeasurement::Refresh() { void qTabMeasurement::Refresh() {

54
slsDetectorGui/src/qTabMessages.cpp Executable file → Normal file
View File

@ -1,12 +1,12 @@
#include "qTabMessages.h" #include "qTabMessages.h"
#include "qDefs.h" #include "qDefs.h"
#include <QDir>
#include <QFile> #include <QFile>
#include <QFileDialog> #include <QFileDialog>
#include <QTextStream>
#include <QDir>
#include <QProcess>
#include <QKeyEvent> #include <QKeyEvent>
#include <QProcess>
#include <QTextStream>
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -41,28 +41,28 @@ void qTabMessages::keyPressEvent(QKeyEvent* event) {
// cout<<"inside KeyPressEvent()\n"; // cout<<"inside KeyPressEvent()\n";
if (event->key() == Qt::Key_Up) { if (event->key() == Qt::Key_Up) {
GetLastCommand(); GetLastCommand();
} } else if (event->key() == Qt::Key_Down) {
else if (event->key() == Qt::Key_Down) {
ClearCommand(); ClearCommand();
} }
/* else if((event->key() == Qt::Key_Return) ||(event->key() == Qt::Key_Enter)) { /* else if((event->key() == Qt::Key_Return) ||(event->key() ==
ExecuteCommand(); Qt::Key_Enter)) { ExecuteCommand();
}*/ else { }*/
else {
event->ignore(); event->ignore();
} }
} }
void qTabMessages::PrintNextLine() { void qTabMessages::PrintNextLine() {
dispLog->append(QString("<font color = \"DarkGrey\">") + QDir::current().dirName() + QString("$ ") + QString("</font>")); dispLog->append(QString("<font color = \"DarkGrey\">") +
QDir::current().dirName() + QString("$ ") +
QString("</font>"));
} }
void qTabMessages::GetLastCommand() { void qTabMessages::GetLastCommand() {
dispCommand->setText(lastCommand.join(" ")); dispCommand->setText(lastCommand.join(" "));
} }
void qTabMessages::ClearCommand() { void qTabMessages::ClearCommand() { dispCommand->setText(""); }
dispCommand->setText("");
}
void qTabMessages::ExecuteCommand() { void qTabMessages::ExecuteCommand() {
QStringList param = dispCommand->text().split(" "); QStringList param = dispCommand->text().split(" ");
@ -71,11 +71,14 @@ void qTabMessages::ExecuteCommand() {
dispCommand->clear(); dispCommand->clear();
// appending command to log without newline // appending command to log without newline
dispLog->moveCursor(QTextCursor::End); dispLog->moveCursor(QTextCursor::End);
dispLog->insertHtml(QString("<font color = \"DarkBlue\">") + param.join(" ") + QString("</font>")); dispLog->insertHtml(QString("<font color = \"DarkBlue\">") +
param.join(" ") + QString("</font>"));
QString command = param.at(0); QString command = param.at(0);
param.removeFirst(); param.removeFirst();
FILE_LOG(logINFO) << "Executing Command:[" << command.toAscii().constData() << "] with Arguments:[" << param.join(" ").toAscii().constData() << "]"; FILE_LOG(logINFO) << "Executing Command:[" << command.toAscii().constData()
<< "] with Arguments:["
<< param.join(" ").toAscii().constData() << "]";
process->setProcessChannelMode(QProcess::MergedChannels); process->setProcessChannelMode(QProcess::MergedChannels);
process->start(command, param); process->start(command, param);
@ -89,34 +92,40 @@ void qTabMessages::ExecuteCommand() {
void qTabMessages::AppendOutput() { void qTabMessages::AppendOutput() {
QByteArray result = process->readAll(); QByteArray result = process->readAll();
result.replace("\n", "<br>"); result.replace("\n", "<br>");
dispLog->append(QString("<font color = \"DarkBlue\">") + result + QString("</font>")); dispLog->append(QString("<font color = \"DarkBlue\">") + result +
QString("</font>"));
FILE_LOG(logDEBUG) << "Command executed successfully"; FILE_LOG(logDEBUG) << "Command executed successfully";
PrintNextLine(); PrintNextLine();
} }
void qTabMessages::AppendError() { void qTabMessages::AppendError() {
dispLog->append(QString("<font color = \"Red\">") + process->errorString() + QString("</font>")); dispLog->append(QString("<font color = \"Red\">") + process->errorString() +
QString("</font>"));
FILE_LOG(logERROR) << "Error executing command"; FILE_LOG(logERROR) << "Error executing command";
PrintNextLine(); PrintNextLine();
} }
void qTabMessages::SaveLog() { void qTabMessages::SaveLog() {
QString fName = QDir::cleanPath(QDir::currentPath()) + "/LogFile.txt"; QString fName = QDir::cleanPath(QDir::currentPath()) + "/LogFile.txt";
fName = QFileDialog::getSaveFileName(this, tr("Save Snapshot "), fName =
fName, tr("Text files (*.txt);;All Files(*)")); QFileDialog::getSaveFileName(this, tr("Save Snapshot "), fName,
tr("Text files (*.txt);;All Files(*)"));
if (!fName.isEmpty()) { if (!fName.isEmpty()) {
QFile outfile; QFile outfile;
outfile.setFileName(fName); outfile.setFileName(fName);
if (outfile.open(QIODevice::WriteOnly | QIODevice::Text)) { if (outfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream out(&outfile); QTextStream out(&outfile);
out << dispLog->toPlainText() << endl; out << dispLog->toPlainText() << endl;
std::string mess = std::string("The Log has been successfully saved to ") + fName.toAscii().constData(); std::string mess =
std::string("The Log has been successfully saved to ") +
fName.toAscii().constData();
qDefs::Message(qDefs::INFORMATION, mess, "TabMessages::SaveLog"); qDefs::Message(qDefs::INFORMATION, mess, "TabMessages::SaveLog");
FILE_LOG(logINFO) << mess; FILE_LOG(logINFO) << mess;
} else { } else {
FILE_LOG(logWARNING) << "Attempt to save log file failed: " << fName.toAscii().constData(); FILE_LOG(logWARNING) << "Attempt to save log file failed: "
qDefs::Message(qDefs::WARNING, "Attempt to save log file failed.", "qTabMessages::SaveLog"); << fName.toAscii().constData();
qDefs::Message(qDefs::WARNING, "Attempt to save log file failed.",
"qTabMessages::SaveLog");
} }
} }
dispCommand->setFocus(); dispCommand->setFocus();
@ -133,4 +142,3 @@ void qTabMessages::Refresh() {
dispCommand->clear(); dispCommand->clear();
dispCommand->setFocus(); dispCommand->setFocus();
} }

268
slsDetectorGui/src/qTabPlot.cpp Executable file → Normal file
View File

@ -2,10 +2,10 @@
#include "qDefs.h" #include "qDefs.h"
#include "qDrawPlot.h" #include "qDrawPlot.h"
#include <QStandardItemModel>
#include <QStackedLayout>
#include <QButtonGroup>
#include <QAbstractButton> #include <QAbstractButton>
#include <QButtonGroup>
#include <QStackedLayout>
#include <QStandardItemModel>
#include <iostream> #include <iostream>
#include <math.h> #include <math.h>
@ -18,17 +18,14 @@ QString qTabPlot::defaultImageXAxisTitle("Pixel");
QString qTabPlot::defaultImageYAxisTitle("Pixel"); QString qTabPlot::defaultImageYAxisTitle("Pixel");
QString qTabPlot::defaultImageZAxisTitle("Intensity"); QString qTabPlot::defaultImageZAxisTitle("Intensity");
qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p)
qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p) : : QWidget(parent), det(detector), plot(p), is1d(false) {
QWidget(parent), det(detector), plot(p), is1d(false) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Plot ready"; FILE_LOG(logDEBUG) << "Plot ready";
} }
qTabPlot::~qTabPlot() { qTabPlot::~qTabPlot() { delete btnGroupPlotType; }
delete btnGroupPlotType;
}
void qTabPlot::SetupWidgetWindow() { void qTabPlot::SetupWidgetWindow() {
// button group for plot type // button group for plot type
@ -86,13 +83,18 @@ void qTabPlot::SetupWidgetWindow() {
void qTabPlot::Initialization() { void qTabPlot::Initialization() {
// Plot arguments box // Plot arguments box
connect(btnGroupPlotType, SIGNAL(buttonClicked(int)), this, SLOT(SetPlot())); connect(btnGroupPlotType, SIGNAL(buttonClicked(int)), this,
SLOT(SetPlot()));
// Plotting frequency box // Plotting frequency box
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency())); connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this,
connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency())); SLOT(SetStreamingFrequency()));
connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency())); connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this,
connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency())); SLOT(SetStreamingFrequency()));
connect(spinTimeGap, SIGNAL(editingFinished()), this,
SLOT(SetStreamingFrequency()));
connect(spinNthFrame, SIGNAL(editingFinished()), this,
SLOT(SetStreamingFrequency()));
// navigation buttons for options // navigation buttons for options
connect(btnRight1D, SIGNAL(clicked()), this, SLOT(Set1DPlotOptionsRight())); connect(btnRight1D, SIGNAL(clicked()), this, SLOT(Set1DPlotOptionsRight()));
@ -101,28 +103,40 @@ void qTabPlot::Initialization() {
connect(btnLeft2D, SIGNAL(clicked()), this, SLOT(Set2DPlotOptionsLeft())); connect(btnLeft2D, SIGNAL(clicked()), this, SLOT(Set2DPlotOptionsLeft()));
// 1D options // 1D options
connect(chkSuperimpose, SIGNAL(toggled(bool)), this, SLOT(EnablePersistency(bool))); connect(chkSuperimpose, SIGNAL(toggled(bool)), this,
connect(spinPersistency, SIGNAL(valueChanged(int)), plot, SLOT(SetPersistency(int))); SLOT(EnablePersistency(bool)));
connect(spinPersistency, SIGNAL(valueChanged(int)), plot,
SLOT(SetPersistency(int)));
connect(chkPoints, SIGNAL(toggled(bool)), plot, SLOT(SetMarkers(bool))); connect(chkPoints, SIGNAL(toggled(bool)), plot, SLOT(SetMarkers(bool)));
connect(chkLines, SIGNAL(toggled(bool)), plot, SLOT(SetLines(bool))); connect(chkLines, SIGNAL(toggled(bool)), plot, SLOT(SetLines(bool)));
connect(chk1DLog, SIGNAL(toggled(bool)), plot, SLOT(Set1dLogY(bool))); connect(chk1DLog, SIGNAL(toggled(bool)), plot, SLOT(Set1dLogY(bool)));
connect(chkStatistics, SIGNAL(toggled(bool)), plot, SLOT(DisplayStatistics(bool))); connect(chkStatistics, SIGNAL(toggled(bool)), plot,
SLOT(DisplayStatistics(bool)));
// 2D Plot box // 2D Plot box
connect(chkInterpolate, SIGNAL(toggled(bool)), plot, SLOT(SetInterpolate(bool))); connect(chkInterpolate, SIGNAL(toggled(bool)), plot,
SLOT(SetInterpolate(bool)));
connect(chkContour, SIGNAL(toggled(bool)), plot, SLOT(SetContour(bool))); connect(chkContour, SIGNAL(toggled(bool)), plot, SLOT(SetContour(bool)));
connect(chkLogz, SIGNAL(toggled(bool)), plot, SLOT(SetLogz(bool))); connect(chkLogz, SIGNAL(toggled(bool)), plot, SLOT(SetLogz(bool)));
connect(chkStatistics_2, SIGNAL(toggled(bool)), plot, SLOT(DisplayStatistics(bool))); connect(chkStatistics_2, SIGNAL(toggled(bool)), plot,
SLOT(DisplayStatistics(bool)));
// pedstal // pedstal
connect(chkPedestal, SIGNAL(toggled(bool)), plot, SLOT(SetPedestal(bool))); connect(chkPedestal, SIGNAL(toggled(bool)), plot, SLOT(SetPedestal(bool)));
connect(btnRecalPedestal, SIGNAL(clicked()), plot, SLOT(RecalculatePedestal())); connect(btnRecalPedestal, SIGNAL(clicked()), plot,
connect(chkPedestal_2, SIGNAL(toggled(bool)), plot, SLOT(SetPedestal(bool))); SLOT(RecalculatePedestal()));
connect(btnRecalPedestal_2, SIGNAL(clicked()), plot, SLOT(RecalculatePedestal())); connect(chkPedestal_2, SIGNAL(toggled(bool)), plot,
SLOT(SetPedestal(bool)));
connect(btnRecalPedestal_2, SIGNAL(clicked()), plot,
SLOT(RecalculatePedestal()));
// accumulate // accumulate
connect(chkAccumulate, SIGNAL(toggled(bool)), plot, SLOT(SetAccumulate(bool))); connect(chkAccumulate, SIGNAL(toggled(bool)), plot,
connect(btnResetAccumulate, SIGNAL(clicked()), plot, SLOT(ResetAccumulate())); SLOT(SetAccumulate(bool)));
connect(chkAccumulate_2, SIGNAL(toggled(bool)), plot, SLOT(SetAccumulate(bool))); connect(btnResetAccumulate, SIGNAL(clicked()), plot,
connect(btnResetAccumulate_2, SIGNAL(clicked()), plot, SLOT(ResetAccumulate())); SLOT(ResetAccumulate()));
connect(chkAccumulate_2, SIGNAL(toggled(bool)), plot,
SLOT(SetAccumulate(bool)));
connect(btnResetAccumulate_2, SIGNAL(clicked()), plot,
SLOT(ResetAccumulate()));
// binary // binary
connect(chkBinary, SIGNAL(toggled(bool)), this, SLOT(SetBinary())); connect(chkBinary, SIGNAL(toggled(bool)), this, SLOT(SetBinary()));
connect(chkBinary_2, SIGNAL(toggled(bool)), this, SLOT(SetBinary())); connect(chkBinary_2, SIGNAL(toggled(bool)), this, SLOT(SetBinary()));
@ -132,12 +146,15 @@ void qTabPlot::Initialization() {
connect(spinTo_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary())); connect(spinTo_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary()));
// gainplot // gainplot
if (chkGainPlot->isEnabled()) if (chkGainPlot->isEnabled())
connect(chkGainPlot, SIGNAL(toggled(bool)), plot, SLOT(EnableGainPlot(bool))); connect(chkGainPlot, SIGNAL(toggled(bool)), plot,
SLOT(EnableGainPlot(bool)));
if (chkGainPlot1D->isEnabled()) if (chkGainPlot1D->isEnabled())
connect(chkGainPlot1D, SIGNAL(toggled(bool)), plot, SLOT(EnableGainPlot(bool))); connect(chkGainPlot1D, SIGNAL(toggled(bool)), plot,
SLOT(EnableGainPlot(bool)));
// gap pixels // gap pixels
if (chkGapPixels->isEnabled()) if (chkGapPixels->isEnabled())
connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); connect(chkGapPixels, SIGNAL(toggled(bool)), this,
SLOT(SetGapPixels(bool)));
// Save, clone // Save, clone
connect(btnSave, SIGNAL(clicked()), plot, SLOT(SavePlot())); connect(btnSave, SIGNAL(clicked()), plot, SLOT(SavePlot()));
@ -148,10 +165,14 @@ void qTabPlot::Initialization() {
connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
connect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); connect(dispTitle, SIGNAL(textChanged(const QString &)), this,
connect(dispXAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); SLOT(SetTitles()));
connect(dispYAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); connect(dispXAxis, SIGNAL(textChanged(const QString &)), this,
connect(dispZAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); SLOT(SetTitles()));
connect(dispYAxis, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
connect(dispZAxis, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
connect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(SetXRange())); connect(chkXMin, SIGNAL(toggled(bool)), this, SLOT(SetXRange()));
connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(SetXRange())); connect(chkXMax, SIGNAL(toggled(bool)), this, SLOT(SetXRange()));
@ -161,7 +182,8 @@ void qTabPlot::Initialization() {
connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXRange())); connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXRange()));
connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange())); connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange())); connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
connect(chkAspectRatio, SIGNAL(toggled(bool)), this, SLOT(CheckAspectRatio())); connect(chkAspectRatio, SIGNAL(toggled(bool)), this,
SLOT(CheckAspectRatio()));
connect(chkZMin, SIGNAL(toggled(bool)), this, SLOT(SetZRange())); connect(chkZMin, SIGNAL(toggled(bool)), this, SLOT(SetZRange()));
connect(chkZMax, SIGNAL(toggled(bool)), this, SLOT(SetZRange())); connect(chkZMax, SIGNAL(toggled(bool)), this, SLOT(SetZRange()));
@ -220,7 +242,8 @@ void qTabPlot::Set1DPlotOptionsRight() {
stackedWidget1D->setCurrentIndex(0); stackedWidget1D->setCurrentIndex(0);
else else
stackedWidget1D->setCurrentIndex(i + 1); stackedWidget1D->setCurrentIndex(i + 1);
box1D->setTitle(QString("1D Plot Options %1").arg(stackedWidget1D->currentIndex() + 1)); box1D->setTitle(
QString("1D Plot Options %1").arg(stackedWidget1D->currentIndex() + 1));
} }
void qTabPlot::Set1DPlotOptionsLeft() { void qTabPlot::Set1DPlotOptionsLeft() {
@ -230,7 +253,8 @@ void qTabPlot::Set1DPlotOptionsLeft() {
stackedWidget1D->setCurrentIndex(stackedWidget1D->count() - 1); stackedWidget1D->setCurrentIndex(stackedWidget1D->count() - 1);
else else
stackedWidget1D->setCurrentIndex(i - 1); stackedWidget1D->setCurrentIndex(i - 1);
box1D->setTitle(QString("1D Plot Options %1").arg(stackedWidget1D->currentIndex() + 1)); box1D->setTitle(
QString("1D Plot Options %1").arg(stackedWidget1D->currentIndex() + 1));
} }
void qTabPlot::Set2DPlotOptionsRight() { void qTabPlot::Set2DPlotOptionsRight() {
@ -240,7 +264,8 @@ void qTabPlot::Set2DPlotOptionsRight() {
stackedWidget2D->setCurrentIndex(0); stackedWidget2D->setCurrentIndex(0);
else else
stackedWidget2D->setCurrentIndex(i + 1); stackedWidget2D->setCurrentIndex(i + 1);
box2D->setTitle(QString("2D Plot Options %1").arg(stackedWidget2D->currentIndex() + 1)); box2D->setTitle(
QString("2D Plot Options %1").arg(stackedWidget2D->currentIndex() + 1));
} }
void qTabPlot::Set2DPlotOptionsLeft() { void qTabPlot::Set2DPlotOptionsLeft() {
@ -250,7 +275,8 @@ void qTabPlot::Set2DPlotOptionsLeft() {
stackedWidget2D->setCurrentIndex(stackedWidget2D->count() - 1); stackedWidget2D->setCurrentIndex(stackedWidget2D->count() - 1);
else else
stackedWidget2D->setCurrentIndex(i - 1); stackedWidget2D->setCurrentIndex(i - 1);
box2D->setTitle(QString("2D Plot Options %1").arg(stackedWidget2D->currentIndex() + 1)); box2D->setTitle(
QString("2D Plot Options %1").arg(stackedWidget2D->currentIndex() + 1));
} }
void qTabPlot::EnablePersistency(bool enable) { void qTabPlot::EnablePersistency(bool enable) {
@ -267,14 +293,16 @@ void qTabPlot::SetBinary() {
bool binary1D = chkBinary->isChecked(); bool binary1D = chkBinary->isChecked();
bool binary2D = chkBinary_2->isChecked(); bool binary2D = chkBinary_2->isChecked();
if (is1d) { if (is1d) {
FILE_LOG(logINFO) << "Binary Plot " << (binary1D ? "enabled" : "disabled"); FILE_LOG(logINFO) << "Binary Plot "
<< (binary1D ? "enabled" : "disabled");
lblFrom->setEnabled(binary1D); lblFrom->setEnabled(binary1D);
lblTo->setEnabled(binary1D); lblTo->setEnabled(binary1D);
spinFrom->setEnabled(binary1D); spinFrom->setEnabled(binary1D);
spinTo->setEnabled(binary1D); spinTo->setEnabled(binary1D);
plot->SetBinary(binary1D, spinFrom->value(), spinTo->value()); plot->SetBinary(binary1D, spinFrom->value(), spinTo->value());
} else { } else {
FILE_LOG(logINFO) << "Binary Plot " << (binary2D ? "enabled" : "disabled"); FILE_LOG(logINFO) << "Binary Plot "
<< (binary2D ? "enabled" : "disabled");
lblFrom_2->setEnabled(binary2D); lblFrom_2->setEnabled(binary2D);
lblTo_2->setEnabled(binary2D); lblTo_2->setEnabled(binary2D);
spinFrom_2->setEnabled(binary2D); spinFrom_2->setEnabled(binary2D);
@ -285,19 +313,25 @@ void qTabPlot::SetBinary() {
void qTabPlot::GetGapPixels() { void qTabPlot::GetGapPixels() {
FILE_LOG(logDEBUG) << "Getting gap pixels"; FILE_LOG(logDEBUG) << "Getting gap pixels";
disconnect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); disconnect(chkGapPixels, SIGNAL(toggled(bool)), this,
SLOT(SetGapPixels(bool)));
try { try {
auto retval = det->getRxAddGapPixels().tsquash("Inconsistent gap pixels enabled for all detectors."); auto retval = det->getRxAddGapPixels().tsquash(
"Inconsistent gap pixels enabled for all detectors.");
chkGapPixels->setChecked(retval); chkGapPixels->setChecked(retval);
} CATCH_DISPLAY ("Could not get gap pixels enable.", "qTabPlot::GetGapPixels") }
connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool))); CATCH_DISPLAY("Could not get gap pixels enable.", "qTabPlot::GetGapPixels")
connect(chkGapPixels, SIGNAL(toggled(bool)), this,
SLOT(SetGapPixels(bool)));
} }
void qTabPlot::SetGapPixels(bool enable) { void qTabPlot::SetGapPixels(bool enable) {
FILE_LOG(logINFO) << "Setting Gap Pixels Enable to " << enable; FILE_LOG(logINFO) << "Setting Gap Pixels Enable to " << enable;
try { try {
det->setRxAddGapPixels(enable); det->setRxAddGapPixels(enable);
} CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels", this, &qTabPlot::GetGapPixels) }
CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels",
this, &qTabPlot::GetGapPixels)
} }
void qTabPlot::SetTitles() { void qTabPlot::SetTitles() {
@ -306,10 +340,14 @@ void qTabPlot::SetTitles() {
disconnect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); disconnect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
disconnect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); disconnect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
disconnect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); disconnect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
disconnect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); disconnect(dispTitle, SIGNAL(textChanged(const QString &)), this,
disconnect(dispXAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); SLOT(SetTitles()));
disconnect(dispYAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); disconnect(dispXAxis, SIGNAL(textChanged(const QString &)), this,
disconnect(dispZAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); SLOT(SetTitles()));
disconnect(dispYAxis, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
disconnect(dispZAxis, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
// title // title
if (!chkTitle->isChecked() || dispTitle->text().isEmpty()) { if (!chkTitle->isChecked() || dispTitle->text().isEmpty()) {
@ -320,15 +358,19 @@ void qTabPlot::SetTitles() {
} }
// x // x
if (!chkXAxis->isChecked() || dispXAxis->text().isEmpty()) { if (!chkXAxis->isChecked() || dispXAxis->text().isEmpty()) {
dispXAxis->setText(is1d ? defaultHistXAxisTitle : defaultImageXAxisTitle); dispXAxis->setText(is1d ? defaultHistXAxisTitle
plot->SetXAxisTitle(is1d ? defaultHistXAxisTitle : defaultImageXAxisTitle); : defaultImageXAxisTitle);
plot->SetXAxisTitle(is1d ? defaultHistXAxisTitle
: defaultImageXAxisTitle);
} else { } else {
plot->SetXAxisTitle(dispXAxis->text()); plot->SetXAxisTitle(dispXAxis->text());
} }
// y // y
if (!chkYAxis->isChecked() || dispYAxis->text().isEmpty()) { if (!chkYAxis->isChecked() || dispYAxis->text().isEmpty()) {
dispYAxis->setText(is1d ? defaultHistYAxisTitle : defaultImageYAxisTitle); dispYAxis->setText(is1d ? defaultHistYAxisTitle
plot->SetYAxisTitle(is1d ? defaultHistYAxisTitle : defaultImageYAxisTitle); : defaultImageYAxisTitle);
plot->SetYAxisTitle(is1d ? defaultHistYAxisTitle
: defaultImageYAxisTitle);
} else { } else {
plot->SetYAxisTitle(dispYAxis->text()); plot->SetYAxisTitle(dispYAxis->text());
} }
@ -344,10 +386,14 @@ void qTabPlot::SetTitles() {
connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles())); connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
connect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); connect(dispTitle, SIGNAL(textChanged(const QString &)), this,
connect(dispXAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); SLOT(SetTitles()));
connect(dispYAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); connect(dispXAxis, SIGNAL(textChanged(const QString &)), this,
connect(dispZAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles())); SLOT(SetTitles()));
connect(dispYAxis, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
connect(dispZAxis, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
} }
void qTabPlot::SetXRange() { void qTabPlot::SetXRange() {
@ -384,13 +430,18 @@ void qTabPlot::SetXYRange() {
bool isRange[4]{false, false, false, false}; bool isRange[4]{false, false, false, false};
double xyRange[4]{0, 0, 0, 0}; double xyRange[4]{0, 0, 0, 0};
QString dispVal[4] {dispXMin->text(), dispXMax->text(), dispYMin->text(), dispYMax->text()}; QString dispVal[4]{dispXMin->text(), dispXMax->text(), dispYMin->text(),
bool chkVal[4] {chkXMin->isChecked(), chkXMax->isChecked(), chkYMin->isChecked(), chkYMax->isChecked()}; dispYMax->text()};
bool chkVal[4]{chkXMin->isChecked(), chkXMax->isChecked(),
chkYMin->isChecked(), chkYMax->isChecked()};
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
if (chkVal[i] && !dispVal[i].isEmpty()) { if (chkVal[i] && !dispVal[i].isEmpty()) {
double val = dispVal[i].toDouble(); double val = dispVal[i].toDouble();
FILE_LOG(logDEBUG) << "Setting " << qDefs::getRangeAsString(static_cast<qDefs::range>(i)) << " to " << val; FILE_LOG(logDEBUG)
<< "Setting "
<< qDefs::getRangeAsString(static_cast<qDefs::range>(i))
<< " to " << val;
xyRange[i] = val; xyRange[i] = val;
isRange[i] = true; isRange[i] = true;
disablezoom = true; disablezoom = true;
@ -433,35 +484,50 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
ranges[qDefs::XMAX] = plot->GetXMaximum(); ranges[qDefs::XMAX] = plot->GetXMaximum();
ranges[qDefs::YMIN] = plot->GetYMinimum(); ranges[qDefs::YMIN] = plot->GetYMinimum();
ranges[qDefs::YMAX] = plot->GetYMaximum(); ranges[qDefs::YMAX] = plot->GetYMaximum();
double idealAspectratio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]); double idealAspectratio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
FILE_LOG(logDEBUG) << "Ideal Aspect ratio: " << idealAspectratio << " for x(" << ranges[qDefs::XMIN] << " - " << ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN] << " - " << ranges[qDefs::YMAX] << ")"; (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]);
FILE_LOG(logDEBUG) << "Ideal Aspect ratio: " << idealAspectratio
<< " for x(" << ranges[qDefs::XMIN] << " - "
<< ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN]
<< " - " << ranges[qDefs::YMAX] << ")";
// calculate current aspect ratio // calculate current aspect ratio
ranges[qDefs::XMIN] = dispXMin->text().toDouble(); ranges[qDefs::XMIN] = dispXMin->text().toDouble();
ranges[qDefs::XMAX] = dispXMax->text().toDouble(); ranges[qDefs::XMAX] = dispXMax->text().toDouble();
ranges[qDefs::YMIN] = dispYMin->text().toDouble(); ranges[qDefs::YMIN] = dispYMin->text().toDouble();
ranges[qDefs::YMAX] = dispYMax->text().toDouble(); ranges[qDefs::YMAX] = dispYMax->text().toDouble();
double currentAspectRatio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]); double currentAspectRatio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
FILE_LOG(logDEBUG) << "Current Aspect ratio: " << currentAspectRatio << " for x(" << ranges[qDefs::XMIN] << " - " << ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN] << " - " << ranges[qDefs::YMAX] << ")"; (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]);
FILE_LOG(logDEBUG) << "Current Aspect ratio: " << currentAspectRatio
<< " for x(" << ranges[qDefs::XMIN] << " - "
<< ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN]
<< " - " << ranges[qDefs::YMAX] << ")";
if (currentAspectRatio != idealAspectratio) { if (currentAspectRatio != idealAspectratio) {
// dimension: 1(x changed: y adjusted), 0(y changed: x adjusted), -1(aspect ratio clicked: larger one adjusted) // dimension: 1(x changed: y adjusted), 0(y changed: x adjusted),
// -1(aspect ratio clicked: larger one adjusted)
if (dimension == -1) { if (dimension == -1) {
dimension = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) > (ranges[qDefs::YMAX] - ranges[qDefs::YMIN])) dimension = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) >
? static_cast<int>(slsDetectorDefs::X) : static_cast<int>(slsDetectorDefs::Y); (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]))
? static_cast<int>(slsDetectorDefs::X)
: static_cast<int>(slsDetectorDefs::Y);
} }
// calculate new value to maintain aspect ratio // calculate new value to maintain aspect ratio
// adjust x // adjust x
double newval = 0; double newval = 0;
if (dimension == static_cast<int>(slsDetectorDefs::X)) { if (dimension == static_cast<int>(slsDetectorDefs::X)) {
newval = idealAspectratio * (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]) + ranges[qDefs::XMIN]; newval =
idealAspectratio * (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]) +
ranges[qDefs::XMIN];
if (newval <= plot->GetXMaximum()) { if (newval <= plot->GetXMaximum()) {
ranges[qDefs::XMAX] = newval; ranges[qDefs::XMAX] = newval;
dispXMax->setText(QString::number(newval)); dispXMax->setText(QString::number(newval));
FILE_LOG(logDEBUG) << "New XMax: " << newval; FILE_LOG(logDEBUG) << "New XMax: " << newval;
} else { } else {
newval = ranges[qDefs::XMAX] - (idealAspectratio * (ranges[qDefs::YMAX] - ranges[qDefs::YMIN])); newval = ranges[qDefs::XMAX] -
(idealAspectratio *
(ranges[qDefs::YMAX] - ranges[qDefs::YMIN]));
ranges[qDefs::XMIN] = newval; ranges[qDefs::XMIN] = newval;
dispXMin->setText(QString::number(newval)); dispXMin->setText(QString::number(newval));
FILE_LOG(logDEBUG) << "New XMin: " << newval; FILE_LOG(logDEBUG) << "New XMin: " << newval;
@ -469,13 +535,17 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
} }
// adjust y // adjust y
else { else {
newval = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / idealAspectratio) + ranges[qDefs::YMIN]; newval = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
idealAspectratio) +
ranges[qDefs::YMIN];
if (newval <= plot->GetYMaximum()) { if (newval <= plot->GetYMaximum()) {
ranges[qDefs::YMAX] = newval; ranges[qDefs::YMAX] = newval;
dispYMax->setText(QString::number(newval)); dispYMax->setText(QString::number(newval));
FILE_LOG(logDEBUG) << "New YMax: " << newval; FILE_LOG(logDEBUG) << "New YMax: " << newval;
} else { } else {
newval = ranges[qDefs::YMAX] - ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / idealAspectratio); newval = ranges[qDefs::YMAX] -
((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
idealAspectratio);
ranges[qDefs::YMIN] = newval; ranges[qDefs::YMIN] = newval;
dispYMin->setText(QString::number(newval)); dispYMin->setText(QString::number(newval));
FILE_LOG(logDEBUG) << "New YMax: " << newval; FILE_LOG(logDEBUG) << "New YMax: " << newval;
@ -516,23 +586,34 @@ void qTabPlot::SetZRange() {
void qTabPlot::GetStreamingFrequency() { void qTabPlot::GetStreamingFrequency() {
FILE_LOG(logDEBUG) << "Getting Streaming Frequency"; FILE_LOG(logDEBUG) << "Getting Streaming Frequency";
disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency())); disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this,
disconnect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency())); SLOT(SetStreamingFrequency()));
disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency())); disconnect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this,
disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency())); SLOT(SetStreamingFrequency()));
disconnect(spinTimeGap, SIGNAL(editingFinished()), this,
SLOT(SetStreamingFrequency()));
disconnect(spinNthFrame, SIGNAL(editingFinished()), this,
SLOT(SetStreamingFrequency()));
try { try {
int freq = det->getRxZmqFrequency().tsquash("Inconsistent receiver zmq streaming frequency for all detectors."); int freq = det->getRxZmqFrequency().tsquash(
"Inconsistent receiver zmq streaming frequency for all detectors.");
// time interval // time interval
if (freq == 0) { if (freq == 0) {
comboFrequency->setCurrentIndex(0); comboFrequency->setCurrentIndex(0);
stackedTimeInterval->setCurrentIndex(0); stackedTimeInterval->setCurrentIndex(0);
try { try {
int timeMs = det->getRxZmqTimer().tsquash("Inconsistent receiver zmq streaming timer for all detectors."); int timeMs = det->getRxZmqTimer().tsquash(
auto timeNS = qDefs::getNSTime(std::make_pair(static_cast<double>(timeMs), qDefs::MILLISECONDS)); "Inconsistent receiver zmq streaming timer for all "
"detectors.");
auto timeNS = qDefs::getNSTime(std::make_pair(
static_cast<double>(timeMs), qDefs::MILLISECONDS));
auto time = qDefs::getUserFriendlyTime(timeNS); auto time = qDefs::getUserFriendlyTime(timeNS);
spinTimeGap->setValue(time.first); spinTimeGap->setValue(time.first);
comboTimeGapUnit->setCurrentIndex(static_cast<int>(time.second)); comboTimeGapUnit->setCurrentIndex(
} CATCH_DISPLAY ("Could not get streaming timer.", "qTabPlot::GetStreamingFrequency") static_cast<int>(time.second));
}
CATCH_DISPLAY("Could not get streaming timer.",
"qTabPlot::GetStreamingFrequency")
} }
// every nth frame // every nth frame
else { else {
@ -540,29 +621,40 @@ void qTabPlot::GetStreamingFrequency() {
stackedTimeInterval->setCurrentIndex(1); stackedTimeInterval->setCurrentIndex(1);
spinNthFrame->setValue(freq); spinNthFrame->setValue(freq);
} }
} CATCH_DISPLAY ("Could not get streaming frequency.", "qTabPlot::GetStreamingFrequency") }
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency())); CATCH_DISPLAY("Could not get streaming frequency.",
connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency())); "qTabPlot::GetStreamingFrequency")
connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency())); connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this,
connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency())); SLOT(SetStreamingFrequency()));
connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetStreamingFrequency()));
connect(spinTimeGap, SIGNAL(editingFinished()), this,
SLOT(SetStreamingFrequency()));
connect(spinNthFrame, SIGNAL(editingFinished()), this,
SLOT(SetStreamingFrequency()));
} }
void qTabPlot::SetStreamingFrequency() { void qTabPlot::SetStreamingFrequency() {
bool frequency = (comboFrequency->currentIndex() == 0) ? 0 : 1; bool frequency = (comboFrequency->currentIndex() == 0) ? 0 : 1;
auto freqVal = spinNthFrame->value(); auto freqVal = spinNthFrame->value();
auto timeVal = spinTimeGap->value(); auto timeVal = spinTimeGap->value();
auto timeUnit = static_cast<qDefs::timeUnit>(comboTimeGapUnit->currentIndex()); auto timeUnit =
static_cast<qDefs::timeUnit>(comboTimeGapUnit->currentIndex());
stackedTimeInterval->setCurrentIndex(comboFrequency->currentIndex()); stackedTimeInterval->setCurrentIndex(comboFrequency->currentIndex());
try { try {
if (frequency) { if (frequency) {
FILE_LOG(logINFO) << "Setting Streaming Frequency to " << freqVal; FILE_LOG(logINFO) << "Setting Streaming Frequency to " << freqVal;
det->setRxZmqFrequency(freqVal); det->setRxZmqFrequency(freqVal);
} else { } else {
FILE_LOG(logINFO) << "Setting Streaming Timer to " << timeVal << " " << qDefs::getUnitString(timeUnit); FILE_LOG(logINFO) << "Setting Streaming Timer to " << timeVal << " "
<< qDefs::getUnitString(timeUnit);
auto timeMS = qDefs::getMSTime(std::make_pair(timeVal, timeUnit)); auto timeMS = qDefs::getMSTime(std::make_pair(timeVal, timeUnit));
det->setRxZmqTimer(timeMS.count()); det->setRxZmqTimer(timeMS.count());
} }
} CATCH_HANDLE("Could not set streaming frequency/ timer.", "qTabPlot::SetStreamingFrequency", this, &qTabPlot::GetStreamingFrequency) }
CATCH_HANDLE("Could not set streaming frequency/ timer.",
"qTabPlot::SetStreamingFrequency", this,
&qTabPlot::GetStreamingFrequency)
} }
void qTabPlot::Refresh() { void qTabPlot::Refresh() {

84
slsDetectorGui/src/qTabSettings.cpp Executable file → Normal file
View File

@ -8,7 +8,8 @@
#include <cmath> #include <cmath>
#include <iostream> #include <iostream>
qTabSettings::qTabSettings(QWidget *parent, sls::Detector *detector): QWidget(parent), det(detector) { qTabSettings::qTabSettings(QWidget *parent, sls::Detector *detector)
: QWidget(parent), det(detector) {
setupUi(this); setupUi(this);
SetupWidgetWindow(); SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Settings ready"; FILE_LOG(logDEBUG) << "Settings ready";
@ -47,12 +48,14 @@ void qTabSettings::SetupWidgetWindow() {
} }
void qTabSettings::SetupDetectorSettings() { void qTabSettings::SetupDetectorSettings() {
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(comboSettings->model()); QStandardItemModel *model =
qobject_cast<QStandardItemModel *>(comboSettings->model());
if (model) { if (model) {
QModelIndex index[NUMSETTINGS]; QModelIndex index[NUMSETTINGS];
QStandardItem *item[NUMSETTINGS]; QStandardItem *item[NUMSETTINGS];
for (int i = 0; i < NUMSETTINGS; ++i) { for (int i = 0; i < NUMSETTINGS; ++i) {
index[i] = model->index(i, comboSettings->modelColumn(), comboSettings->rootModelIndex()); index[i] = model->index(i, comboSettings->modelColumn(),
comboSettings->rootModelIndex());
item[i] = model->itemFromIndex(index[i]); item[i] = model->itemFromIndex(index[i]);
item[i]->setEnabled(false); item[i]->setEnabled(false);
} }
@ -97,7 +100,8 @@ void qTabSettings::SetupDetectorSettings() {
default: default:
FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI."; FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI.";
qDefs::Message(qDefs::CRITICAL, qDefs::Message(qDefs::CRITICAL,
"Unknown detector type. Exiting GUI.", "qTabSettings::SetupDetectorSettings"); "Unknown detector type. Exiting GUI.",
"qTabSettings::SetupDetectorSettings");
exit(-1); exit(-1);
} }
} }
@ -106,22 +110,27 @@ void qTabSettings::SetupDetectorSettings() {
void qTabSettings::Initialization() { void qTabSettings::Initialization() {
// Settings // Settings
if (comboSettings->isEnabled()) if (comboSettings->isEnabled())
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int))); connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSettings(int)));
// Dynamic Range // Dynamic Range
if (comboDynamicRange->isEnabled()) if (comboDynamicRange->isEnabled())
connect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int))); connect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
// Threshold // Threshold
if (spinThreshold->isEnabled()) if (spinThreshold->isEnabled())
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int))); connect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetThresholdEnergy(int)));
} }
void qTabSettings::GetSettings() { void qTabSettings::GetSettings() {
FILE_LOG(logDEBUG) << "Getting settings"; FILE_LOG(logDEBUG) << "Getting settings";
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int))); disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSettings(int)));
try { try {
auto retval = det->getSettings().tsquash("Inconsistent settings for all detectors."); auto retval = det->getSettings().tsquash(
"Inconsistent settings for all detectors.");
switch (retval) { switch (retval) {
case slsDetectorDefs::UNDEFINED: case slsDetectorDefs::UNDEFINED:
comboSettings->setCurrentIndex(UNDEFINED); comboSettings->setCurrentIndex(UNDEFINED);
@ -131,13 +140,16 @@ void qTabSettings::GetSettings() {
break; break;
default: default:
if ((int)retval < -1 || (int)retval >= NUMSETTINGS) { if ((int)retval < -1 || (int)retval >= NUMSETTINGS) {
throw sls::RuntimeError(std::string("Unknown settings: ") + std::to_string(retval)); throw sls::RuntimeError(std::string("Unknown settings: ") +
std::to_string(retval));
} }
comboSettings->setCurrentIndex(retval); comboSettings->setCurrentIndex(retval);
break; break;
} }
} CATCH_DISPLAY ("Could not get settings.", "qTabSettings::GetSettings") }
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int))); CATCH_DISPLAY("Could not get settings.", "qTabSettings::GetSettings")
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSettings(int)));
} }
void qTabSettings::SetSettings(int index) { void qTabSettings::SetSettings(int index) {
@ -146,7 +158,9 @@ void qTabSettings::SetSettings(int index) {
try { try {
FILE_LOG(logINFO) << "Setting Settings to " << sls::ToString(val); FILE_LOG(logINFO) << "Setting Settings to " << sls::ToString(val);
det->setSettings(val); det->setSettings(val);
} CATCH_HANDLE ("Could not set settings.", "qTabSettings::SetSettings", this, &qTabSettings::GetSettings) }
CATCH_HANDLE("Could not set settings.", "qTabSettings::SetSettings", this,
&qTabSettings::GetSettings)
// threshold // threshold
if (spinThreshold->isEnabled()) { if (spinThreshold->isEnabled()) {
SetThresholdEnergy(spinThreshold->value()); SetThresholdEnergy(spinThreshold->value());
@ -155,9 +169,11 @@ void qTabSettings::SetSettings(int index) {
void qTabSettings::GetDynamicRange() { void qTabSettings::GetDynamicRange() {
FILE_LOG(logDEBUG) << "Getting dynamic range"; FILE_LOG(logDEBUG) << "Getting dynamic range";
disconnect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int))); disconnect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
try { try {
auto retval = det->getDynamicRange().tsquash("Inconsistent dynamic range for all detectors."); auto retval = det->getDynamicRange().tsquash(
"Inconsistent dynamic range for all detectors.");
// set the final value on gui // set the final value on gui
switch (retval) { switch (retval) {
case 32: case 32:
@ -173,14 +189,19 @@ void qTabSettings::GetDynamicRange() {
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4); comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4);
break; break;
default: default:
throw sls::RuntimeError(std::string("Unknown dynamic range: ") + std::to_string(retval)); throw sls::RuntimeError(std::string("Unknown dynamic range: ") +
std::to_string(retval));
} }
} CATCH_DISPLAY ("Could not get dynamic range.", "qTabSettings::GetDynamicRange") }
connect(comboDynamicRange, SIGNAL(activated(int)), this,SLOT(SetDynamicRange(int))); CATCH_DISPLAY("Could not get dynamic range.",
"qTabSettings::GetDynamicRange")
connect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
} }
void qTabSettings::SetDynamicRange(int index) { void qTabSettings::SetDynamicRange(int index) {
FILE_LOG(logINFO) << "Setting dynamic range to " << comboDynamicRange->currentText().toAscii().data(); FILE_LOG(logINFO) << "Setting dynamic range to "
<< comboDynamicRange->currentText().toAscii().data();
try { try {
switch (index) { switch (index) {
case DYNAMICRANGE_32: case DYNAMICRANGE_32:
@ -196,26 +217,37 @@ void qTabSettings::SetDynamicRange(int index) {
det->setDynamicRange(4); det->setDynamicRange(4);
break; break;
default: default:
throw sls::RuntimeError(std::string("Unknown dynamic range: ") + std::to_string(index)); throw sls::RuntimeError(std::string("Unknown dynamic range: ") +
std::to_string(index));
} }
} CATCH_HANDLE ("Could not set dynamic range.", "qTabSettings::SetDynamicRange", this, &qTabSettings::GetDynamicRange) }
CATCH_HANDLE("Could not set dynamic range.",
"qTabSettings::SetDynamicRange", this,
&qTabSettings::GetDynamicRange)
} }
void qTabSettings::GetThresholdEnergy() { void qTabSettings::GetThresholdEnergy() {
FILE_LOG(logDEBUG) << "Getting theshold energy"; FILE_LOG(logDEBUG) << "Getting theshold energy";
disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int))); disconnect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetThresholdEnergy(int)));
try { try {
auto retval = det->getThresholdEnergy().tsquash("Inconsistent threhsold energy for all detectors."); auto retval = det->getThresholdEnergy().tsquash(
"Inconsistent threhsold energy for all detectors.");
spinThreshold->setValue(retval); spinThreshold->setValue(retval);
} CATCH_DISPLAY ("Could not get threshold energy.", "qTabDataOutput::GetThresholdEnergy") }
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int))); CATCH_DISPLAY("Could not get threshold energy.",
"qTabDataOutput::GetThresholdEnergy")
connect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetThresholdEnergy(int)));
} }
void qTabSettings::SetThresholdEnergy(int index) { void qTabSettings::SetThresholdEnergy(int index) {
FILE_LOG(logINFO) << "Setting Threshold Energy to " << index << " eV"; FILE_LOG(logINFO) << "Setting Threshold Energy to " << index << " eV";
try { try {
det->setThresholdEnergy(index); det->setThresholdEnergy(index);
} CATCH_DISPLAY ("Could not get threshold energy.", "qTabSettings::SetThresholdEnergy") }
CATCH_DISPLAY("Could not get threshold energy.",
"qTabSettings::SetThresholdEnergy")
// set the right value anyway (due to tolerance) // set the right value anyway (due to tolerance)
GetThresholdEnergy(); GetThresholdEnergy();
} }