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

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

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

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

@ -7,27 +7,27 @@
#include <string>
class qDacWidget:public QWidget, private Ui::WidgetDacObject {
Q_OBJECT
class qDacWidget : public QWidget, private Ui::WidgetDacObject {
Q_OBJECT
public:
qDacWidget(QWidget *parent, sls::Detector* detector, bool d, std::string n, slsDetectorDefs::dacIndex i);
~qDacWidget();
void SetDetectorIndex(int id);
public:
qDacWidget(QWidget *parent, sls::Detector *detector, bool d, std::string n,
slsDetectorDefs::dacIndex i);
~qDacWidget();
void SetDetectorIndex(int id);
private slots:
void SetDac();
private slots:
void SetDac();
private:
void SetupWidgetWindow(std::string name);
void Initialization();
void GetDac();
void GetAdc();
void Refresh();
private:
void SetupWidgetWindow(std::string name);
void Initialization();
void GetDac();
void GetAdc();
void Refresh();
sls::Detector *det;
bool isDac{true};
slsDetectorDefs::dacIndex index;
int detectorIndex{-1};
sls::Detector *det;
bool isDac{true};
slsDetectorDefs::dacIndex index;
int detectorIndex{-1};
};

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

@ -5,22 +5,28 @@
#include <QAbstractButton>
#include <QMessageBox>
#include <chrono>
#include <iostream>
#include <ostream>
#include <stdint.h>
#include <string>
#include <chrono>
using std::chrono::duration;
using std::chrono::duration_cast;
using std::chrono::nanoseconds;
using std::chrono::hours;
using std::chrono::microseconds;
using std::chrono::milliseconds;
using std::chrono::seconds;
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_HANDLE(...) catch(...) { qDefs::HandleExceptions(__VA_ARGS__); }
#define CATCH_DISPLAY(m, s) \
catch (...) { \
qDefs::DisplayExceptions(m, s); \
}
#define CATCH_HANDLE(...) \
catch (...) { \
qDefs::HandleExceptions(__VA_ARGS__); \
}
class qDefs : public QWidget {
public:
@ -29,9 +35,9 @@ class qDefs : public QWidget {
*/
qDefs(){};
static const int Q_FONT_SIZE=9;
static const int DATA_GAIN_PLOT_RATIO=5;
static const int MIN_HEIGHT_GAIN_PLOT_1D=75;
static const int Q_FONT_SIZE = 9;
static const int DATA_GAIN_PLOT_RATIO = 5;
static const int MIN_HEIGHT_GAIN_PLOT_1D = 75;
static void DisplayExceptions(std::string emsg, std::string src) {
try {
@ -47,8 +53,8 @@ class qDefs : public QWidget {
template <class CT> struct NonDeduced { using type = CT; };
template <class S, typename RT, typename... CT>
static void HandleExceptions(const std::string emsg, const std::string src, S* s,
RT (S::*somefunc)(CT...),
static void HandleExceptions(const std::string emsg, const std::string src,
S *s, RT (S::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) {
try {
throw;
@ -72,15 +78,22 @@ class qDefs : public QWidget {
QF_NUM_FUNCTIONS
};
static const char* getQFunctionNameFromEnum(enum qFuncNames func) {
static const char *getQFunctionNameFromEnum(enum qFuncNames func) {
switch (func) {
case QF_GET_DETECTOR_STATUS: return "QF_GET_DETECTOR_STATUS";
case QF_START_ACQUISITION: return "QF_START_ACQUISITION";
case QF_STOP_ACQUISITION: return "QF_STOP_ACQUISITION";
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";
case QF_GET_DETECTOR_STATUS:
return "QF_GET_DETECTOR_STATUS";
case QF_START_ACQUISITION:
return "QF_START_ACQUISITION";
case QF_STOP_ACQUISITION:
return "QF_STOP_ACQUISITION";
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) {
switch (r) {
case XMIN: return "XMIN";
case XMAX: return "XMAX";
case YMIN: return "YMIN";
case YMAX: return "YMAX";
default: return "Unknown";
case XMIN:
return "XMIN";
case XMAX:
return "XMAX";
case YMIN:
return "YMIN";
case YMAX:
return "YMAX";
default:
return "Unknown";
}
};
@ -190,7 +208,8 @@ class qDefs : public QWidget {
MINUTES);
}
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 */
@ -296,10 +315,12 @@ class qDefs : public QWidget {
/**
* Wrap exception message
*/
static int ExceptionMessage(std::string message,
std::string exceptionMessage,
std::string source) {
return Message(qDefs::WARNING, message + std::string("\nCaught exception:\n") + exceptionMessage, source);
}
static int ExceptionMessage(std::string message,
std::string exceptionMessage,
std::string 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 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 {
public:
MyTabWidget(QWidget *parent = 0) { setParent(parent); }

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

@ -19,7 +19,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
Q_OBJECT
public:
qDrawPlot(QWidget *parent, sls::Detector *detector);
qDrawPlot(QWidget *parent, sls::Detector *detector);
~qDrawPlot();
bool GetIsRunning();
void SetRunning(bool enable);
@ -30,8 +30,8 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void SetXAxisTitle(QString title);
void SetYAxisTitle(QString title);
void SetZAxisTitle(QString title);
void SetXYRangeChanged(bool disable, double* xy, bool* isXY);
void SetZRange(double* z, bool* isZ);
void SetXYRangeChanged(bool disable, double *xy, bool *isXY);
void SetZRange(double *z, bool *isZ);
double GetXMinimum();
double GetXMaximum();
double GetYMinimum();
@ -56,7 +56,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void SetNumDiscardBits(int value);
void EnableGainPlot(bool enable);
void ClonePlot();
void SavePlot();
void SavePlot();
protected:
void resizeEvent(QResizeEvent *event);
@ -65,7 +65,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void SetSaveFileName(QString val);
void AcquireThread();
void UpdatePlot();
signals:
void StartAcquireSignal();
void AcquireFinishedSignal();
@ -75,40 +75,45 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
private:
void SetupWidgetWindow();
void Initialization();
void SetupPlots();
void SetupPlots();
void GetStatistics(double &min, double &max, double &sum);
void DetachHists();
static void GetAcquisitionFinishedCallBack(double currentProgress, int detectorStatus, void *this_pointer);
static void GetDataCallBack(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex, void *this_pointer);
static void GetAcquisitionFinishedCallBack(double currentProgress,
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 GetData(detectorData *data, uint64_t frameIndex, uint32_t subFrameIndex);
void toDoublePixelData(double *dest, char *source, int size, int databytes, int dr, double *gaindest = NULL);
void Get1dData(double* rawData);
void Get2dData(double* rawData);
void GetData(detectorData *data, uint64_t frameIndex,
uint32_t subFrameIndex);
void toDoublePixelData(double *dest, char *source, int size, int databytes,
int dr, double *gaindest = NULL);
void Get1dData(double *rawData);
void Get2dData(double *rawData);
void Update1dPlot();
void Update2dPlot();
void Update1dXYRange();
void Update2dXYRange();
static const int NUM_PEDESTAL_FRAMES = 20;
static const int NUM_PEDESTAL_FRAMES = 20;
sls::Detector *det;
slsDetectorDefs::detectorType detType;
SlsQt1DPlot *plot1d{nullptr};
QVector<SlsQtH1D *> hists1d;
QVector<SlsQtH1D *> hists1d;
SlsQt1DPlot *gainplot1d{nullptr};
SlsQtH1D * gainhist1d{nullptr};
SlsQtH1D *gainhist1d{nullptr};
SlsQt2DPlot *plot2d{nullptr};
SlsQt2DPlot *gainplot2d{nullptr};
bool is1d{true};
bool isRunning{false};
// titles
// titles
QString plotTitlePrefix{""};
QString xTitle1d{"Channel Number"};
QString yTitle1d{"Counts"};
QString xTitle2d{"Pixel"};
QString xTitle2d{"Pixel"};
QString yTitle2d{"Pixel"};
QString zTitle2d{"Intensity"};
QString plotTitle{""};
@ -119,7 +124,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
double zRange[2]{0, 1};
bool isZRange[2]{false, false};
// data
// data
int nHists{1};
double *datax1d{nullptr};
std::vector<double *> datay1d;
@ -127,9 +132,9 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
double *data2d{nullptr};
double *gainData{nullptr};
//options
// options
bool isPlot{true};
bool isBinary{false};
bool isBinary{false};
int binaryFrom{0};
int binaryTo{0};
int persistency{0};

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

@ -6,64 +6,62 @@ class qDrawPlot;
#include "Detector.h"
class qTabAdvanced:public QWidget, private Ui::TabAdvancedObject{
Q_OBJECT
class qTabAdvanced : public QWidget, private Ui::TabAdvancedObject {
Q_OBJECT
public:
qTabAdvanced(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
~qTabAdvanced();
public:
qTabAdvanced(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
~qTabAdvanced();
public slots:
void Refresh();
public slots:
void Refresh();
private slots:
void SetDetector();
void SetControlPort(int port);
void SetStopPort(int port);
void SetDetectorUDPIP();
void SetDetectorUDPMAC();
void SetCltZMQPort(int port);
void SetCltZMQIP();
void SetRxrHostname();
void SetRxrTCPPort(int port);
void SetRxrUDPPort(int port);
void SetRxrUDPIP();
void SetRxrUDPMAC();
void SetRxrZMQPort(int port);
void SetRxrZMQIP();
void GetROI();
void ClearROI();
void SetROI();
void SetAllTrimbits();
void SetNumStoragecells(int value);
void SetSubExposureTime();
void SetSubDeadTime();
private slots:
void SetDetector();
void SetControlPort(int port);
void SetStopPort(int port);
void SetDetectorUDPIP();
void SetDetectorUDPMAC();
void SetCltZMQPort(int port);
void SetCltZMQIP();
void SetRxrHostname();
void SetRxrTCPPort(int port);
void SetRxrUDPPort(int port);
void SetRxrUDPIP();
void SetRxrUDPMAC();
void SetRxrZMQPort(int port);
void SetRxrZMQIP();
void GetROI();
void ClearROI();
void SetROI();
void SetAllTrimbits();
void SetNumStoragecells(int value);
void SetSubExposureTime();
void SetSubDeadTime();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
void GetControlPort();
void GetStopPort();
void GetDetectorUDPIP();
void GetDetectorUDPMAC();
void GetCltZMQPort();
void GetCltZMQIP();
void GetRxrHostname();
void GetRxrTCPPort();
void GetRxrUDPPort();
void GetRxrUDPIP();
void GetRxrUDPMAC();
void GetRxrZMQPort();
void GetRxrZMQIP();
void GetAllTrimbits();
void GetNumStoragecells();
void GetSubExposureTime();
void GetSubDeadTime();
void GetControlPort();
void GetStopPort();
void GetDetectorUDPIP();
void GetDetectorUDPMAC();
void GetCltZMQPort();
void GetCltZMQIP();
void GetRxrHostname();
void GetRxrTCPPort();
void GetRxrUDPPort();
void GetRxrUDPIP();
void GetRxrUDPMAC();
void GetRxrZMQPort();
void GetRxrZMQIP();
void GetAllTrimbits();
void GetNumStoragecells();
void GetSubExposureTime();
void GetSubDeadTime();
sls::Detector *det;
qDrawPlot *plot;
sls::Detector *det;
qDrawPlot *plot;
};

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

@ -4,47 +4,43 @@
#include "Detector.h"
class qTabDataOutput:public QWidget, private Ui::TabDataOutputObject{
Q_OBJECT
class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
Q_OBJECT
public:
qTabDataOutput(QWidget *parent, sls::Detector* detector);
~qTabDataOutput();
void Refresh();
public:
qTabDataOutput(QWidget *parent, sls::Detector *detector);
~qTabDataOutput();
void Refresh();
private slots:
void GetOutputDir();
void BrowseOutputDir();
void SetOutputDir();
void SetFileFormat(int format);
void SetOverwriteEnable(bool enable);
void SetTenGigaEnable(bool enable);
void EnableRateCorrection();
void SetRateCorrection();
void SetSpeed(int speed);
void SetFlags();
private slots:
void GetOutputDir();
void BrowseOutputDir();
void SetOutputDir();
void SetFileFormat(int format);
void SetOverwriteEnable(bool enable);
void SetTenGigaEnable(bool enable);
void EnableRateCorrection();
void SetRateCorrection();
void SetSpeed(int speed);
void SetFlags();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
void EnableBrowse();
void GetFileWrite();
void GetFileName();
void GetFileFormat();
void GetFileOverwrite();
void GetTenGigaEnable();
void GetRateCorrection();
void GetSpeed();
void GetFlags();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
void EnableBrowse();
void GetFileWrite();
void GetFileName();
void GetFileFormat();
void GetFileOverwrite();
void GetTenGigaEnable();
void GetRateCorrection();
void GetSpeed();
void GetFlags();
sls::Detector *det;
// Button group for radiobuttons for rate
QButtonGroup *btnGroupRate;
// enum for the Eiger Parallel flag
enum {
PARALLEL,
NONPARALLEL
};
sls::Detector *det;
// Button group for radiobuttons for rate
QButtonGroup *btnGroupRate;
// enum for the Eiger Parallel flag
enum { PARALLEL, NONPARALLEL };
};

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

@ -7,30 +7,29 @@
class QTreeWidget;
class QTreeWidgetItem;
class qTabDebugging:public QWidget, private Ui::TabDebuggingObject{
Q_OBJECT
class qTabDebugging : public QWidget, private Ui::TabDebuggingObject {
Q_OBJECT
public:
qTabDebugging(QWidget *parent, sls::Detector* detector);
~qTabDebugging();
void Refresh();
public:
qTabDebugging(QWidget *parent, sls::Detector *detector);
~qTabDebugging();
void Refresh();
private slots:
void GetDetectorStatus();
void GetInfo();
void SetParameters(QTreeWidgetItem *item);
void TestDetector();
private slots:
void GetDetectorStatus();
void GetInfo();
void SetParameters(QTreeWidgetItem *item);
void TestDetector();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
sls::Detector *det;
/** Tree Widget displaying the detectors, modules */
QTreeWidget *treeDet;
QLabel *lblDetectorHostname;
QLabel *lblDetectorFirmware;
QLabel *lblDetectorSoftware;
sls::Detector *det;
/** Tree Widget displaying the detectors, modules */
QTreeWidget *treeDet;
QLabel *lblDetectorHostname;
QLabel *lblDetectorFirmware;
QLabel *lblDetectorSoftware;
};

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

@ -9,41 +9,33 @@ class qDacWidget;
#include <string>
#include <vector>
class qTabDeveloper:public QWidget, private Ui::TabDeveloperObject {
Q_OBJECT
class qTabDeveloper : public QWidget, private Ui::TabDeveloperObject {
Q_OBJECT
public:
qTabDeveloper(QWidget *parent, sls::Detector* detector);
~qTabDeveloper();
public:
qTabDeveloper(QWidget *parent, sls::Detector *detector);
~qTabDeveloper();
public slots:
void Refresh();
public slots:
void Refresh();
private slots:
void SetHighVoltage();
private slots:
void SetHighVoltage();
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
void GetHighVoltage();
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType, int index);
private:
void SetupWidgetWindow();
void Initialization();
void PopulateDetectors();
void GetHighVoltage();
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType,
int index);
sls::Detector *det;
std::vector<qDacWidget*> dacWidgets;
std::vector<qDacWidget*> adcWidgets;
enum hvVals {
HV_0,
HV_90,
HV_110,
HV_120,
HV_150,
HV_180,
HV_200
};
int hvmin;
static const int HV_MIN = 60;
static const int HV_MAX = 200;
sls::Detector *det;
std::vector<qDacWidget *> dacWidgets;
std::vector<qDacWidget *> adcWidgets;
enum hvVals { HV_0, HV_90, HV_110, HV_120, HV_150, HV_180, HV_200 };
int hvmin;
static const int HV_MIN = 60;
static const int HV_MAX = 200;
};

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

@ -8,92 +8,87 @@ class qDrawPlot;
class QStandardItemModel;
class qTabMeasurement:public QWidget, private Ui::TabMeasurementObject{
Q_OBJECT
class qTabMeasurement : public QWidget, private Ui::TabMeasurementObject {
Q_OBJECT
public:
qTabMeasurement(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
~qTabMeasurement();
public:
qTabMeasurement(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
~qTabMeasurement();
void Refresh();
void Refresh();
public slots:
void AcquireFinished();
void AbortAcquire();
public slots:
void AcquireFinished();
void AbortAcquire();
private slots:
void SetTimingMode(int val);
void SetNumMeasurements(int val);
void SetNumFrames(int val);
void SetNumTriggers(int val);
void SetNumBursts(int val);
void SetNumSamples(int val);
void SetExposureTime();
void SetAcquisitionPeriod();
void SetDelay();
void SetBurstPeriod();
void SetFileWrite(bool val);
void SetFileName();
void SetRunIndex(int val);
void SetStartingFrameNumber(int val);
void UpdateProgress();
void StartAcquisition();
void StopAcquisition();
private slots:
void SetTimingMode(int val);
void SetNumMeasurements(int val);
void SetNumFrames(int val);
void SetNumTriggers(int val);
void SetNumBursts(int val);
void SetNumSamples(int val);
void SetExposureTime();
void SetAcquisitionPeriod();
void SetDelay();
void SetBurstPeriod();
void SetFileWrite(bool val);
void SetFileName();
void SetRunIndex(int val);
void SetStartingFrameNumber(int val);
void UpdateProgress();
void StartAcquisition();
void StopAcquisition();
private:
void SetupWidgetWindow();
void Initialization();
/** default, show trigger and delay,
* otherwise for gotthard2 in auto timing mode and burst mode,
* show bursts and burst period
*/
void ShowTriggerDelay();
void SetupTimingMode();
void EnableWidgetsforTimingMode();
private:
void SetupWidgetWindow();
void Initialization();
/** default, show trigger and delay,
* otherwise for gotthard2 in auto timing mode and burst mode,
* show bursts and burst period
*/
void ShowTriggerDelay();
void SetupTimingMode();
void EnableWidgetsforTimingMode();
void GetTimingMode();
void GetNumFrames();
void GetNumTriggers();
void GetNumBursts();
void GetNumSamples();
void GetExposureTime();
void GetAcquisitionPeriod();
void CheckAcqPeriodGreaterThanExp();
void GetDelay();
void GetBurstPeriod();
void GetFileWrite();
void GetFileName();
void GetRunIndex();
void GetStartingFrameNumber();
void GetTimingMode();
void GetNumFrames();
void GetNumTriggers();
void GetNumBursts();
void GetNumSamples();
void GetExposureTime();
void GetAcquisitionPeriod();
void CheckAcqPeriodGreaterThanExp();
void GetDelay();
void GetBurstPeriod();
void GetFileWrite();
void GetFileName();
void GetRunIndex();
void GetStartingFrameNumber();
void ResetProgress();
void ResetProgress();
void Enable(bool enable);
int VerifyOutputDirectoryError();
void Enable(bool enable);
int VerifyOutputDirectoryError();
signals:
void EnableTabsSignal(bool);
void FileNameChangedSignal(QString);
private:
sls::Detector *det;
qDrawPlot *plot;
// enum for the timing mode
enum{
AUTO,
TRIGGER,
GATED,
BURST_TRIGGER,
NUMTIMINGMODES
};
QTimer *progressTimer;
//tool tip variables
QString acqPeriodTip;
QString errPeriodTip;
QPalette red;
bool delayImplemented;
bool sampleImplemented;
bool startingFnumImplemented;
bool isAcquisitionStopped{false};
int numMeasurements{1};
int currentMeasurement{0};
signals:
void EnableTabsSignal(bool);
void FileNameChangedSignal(QString);
private:
sls::Detector *det;
qDrawPlot *plot;
// enum for the timing mode
enum { AUTO, TRIGGER, GATED, BURST_TRIGGER, NUMTIMINGMODES };
QTimer *progressTimer;
// tool tip variables
QString acqPeriodTip;
QString errPeriodTip;
QPalette red;
bool delayImplemented;
bool sampleImplemented;
bool startingFnumImplemented;
bool isAcquisitionStopped{false};
int numMeasurements{1};
int currentMeasurement{0};
};

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

@ -5,32 +5,31 @@
class QProcess;
class QKeyEvent;
class qTabMessages:public QWidget, private Ui::TabMessagesObject {
Q_OBJECT
class qTabMessages : public QWidget, private Ui::TabMessagesObject {
Q_OBJECT
public:
qTabMessages(QWidget* parent);
~qTabMessages();
void Refresh();
public:
qTabMessages(QWidget *parent);
~qTabMessages();
void Refresh();
protected:
void keyPressEvent(QKeyEvent* event);
protected:
void keyPressEvent(QKeyEvent *event);
private slots:
void ExecuteCommand();
void SaveLog();
void ClearLog();
private slots:
void ExecuteCommand();
void SaveLog();
void ClearLog();
private:
void SetupWidgetWindow();
void Initialization();
void PrintNextLine();
void GetLastCommand();
void ClearCommand();
void AppendOutput();
void AppendError();
private:
void SetupWidgetWindow();
void Initialization();
void PrintNextLine();
void GetLastCommand();
void ClearCommand();
void AppendOutput();
void AppendError();
QProcess* process;
QStringList lastCommand;
QProcess *process;
QStringList lastCommand;
};

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

@ -8,56 +8,54 @@ class qDrawPlot;
class QButtonGroup;
class qTabPlot:public QWidget, private Ui::TabPlotObject{
Q_OBJECT
class qTabPlot : public QWidget, private Ui::TabPlotObject {
Q_OBJECT
public:
qTabPlot(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
~qTabPlot();
void SetScanArgument();
void Refresh();
public:
qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p);
~qTabPlot();
void SetScanArgument();
void Refresh();
private slots:
void SetPlot();
void Set1DPlotOptionsRight();
void Set1DPlotOptionsLeft();
void Set2DPlotOptionsRight();
void Set2DPlotOptionsLeft();
void EnablePersistency(bool enable);
void SetBinary();
void SetGapPixels(bool enable);
void SetTitles();
void SetXRange();
void SetYRange();
void CheckAspectRatio();
void SetZRange();
void SetStreamingFrequency();
private slots:
void SetPlot();
void Set1DPlotOptionsRight();
void Set1DPlotOptionsLeft();
void Set2DPlotOptionsRight();
void Set2DPlotOptionsLeft();
void EnablePersistency(bool enable);
void SetBinary();
void SetGapPixels(bool enable);
void SetTitles();
void SetXRange();
void SetYRange();
void CheckAspectRatio();
void SetZRange();
void SetStreamingFrequency();
signals:
void DisableZoomSignal(bool);
signals:
void DisableZoomSignal(bool);
private:
void SetupWidgetWindow();
void Initialization();
void Select1DPlot(bool enable);
void GetGapPixels();
void GetStreamingFrequency();
void SetXYRange();
void MaintainAspectRatio(int dimension);
private:
void SetupWidgetWindow();
void Initialization();
void Select1DPlot(bool enable);
void GetGapPixels();
void GetStreamingFrequency();
void SetXYRange();
void MaintainAspectRatio(int dimension);
sls::Detector *det;
qDrawPlot *plot;
bool is1d;
sls::Detector *det;
qDrawPlot *plot;
bool is1d;
QButtonGroup *btnGroupPlotType{nullptr};
QButtonGroup *btnGroupPlotType{nullptr};
/** default plot and axis titles */
static QString defaultPlotTitle;
static QString defaultHistXAxisTitle;
static QString defaultHistYAxisTitle;
static QString defaultImageXAxisTitle;
static QString defaultImageYAxisTitle;
static QString defaultImageZAxisTitle;
/** default plot and axis titles */
static QString defaultPlotTitle;
static QString defaultHistXAxisTitle;
static QString defaultHistYAxisTitle;
static QString defaultImageXAxisTitle;
static QString defaultImageYAxisTitle;
static QString defaultImageZAxisTitle;
};

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

@ -4,43 +4,43 @@
#include "Detector.h"
class qTabSettings: public QWidget, private Ui::TabSettingsObject{
Q_OBJECT
class qTabSettings : public QWidget, private Ui::TabSettingsObject {
Q_OBJECT
public:
qTabSettings(QWidget *parent, sls::Detector* detector);
~qTabSettings();
void Refresh();
public:
qTabSettings(QWidget *parent, sls::Detector *detector);
~qTabSettings();
void Refresh();
private slots:
void SetSettings(int index);
void SetDynamicRange(int index);
void SetThresholdEnergy(int index);
private slots:
void SetSettings(int index);
void SetDynamicRange(int index);
void SetThresholdEnergy(int index);
private:
void SetupWidgetWindow();
void SetupDetectorSettings();
void Initialization();
private:
void SetupWidgetWindow();
void SetupDetectorSettings();
void Initialization();
void GetSettings();
void GetDynamicRange();
void GetThresholdEnergy();
void GetSettings();
void GetDynamicRange();
void GetThresholdEnergy();
sls::Detector *det;
enum {
STANDARD,
FAST,
HIGHGAIN,
DYNAMICGAIN,
LOWGAIN,
MEDIUMGAIN,
VERYHIGHGAIN,
DYNAMICHG0,
FIXGAIN1,
FIXGAIN2,
FORCESWITCHG1,
FORCESWITCHG2,
VERLOWGAIN,
sls::Detector *det;
enum {
STANDARD,
FAST,
HIGHGAIN,
DYNAMICGAIN,
LOWGAIN,
MEDIUMGAIN,
VERYHIGHGAIN,
DYNAMICHG0,
FIXGAIN1,
FIXGAIN2,
FORCESWITCHG1,
FORCESWITCHG2,
VERLOWGAIN,
G1_HIGHGAIN,
G1_LOWGAIN,
G2_HIGHCAP_HIGHGAIN,
@ -48,15 +48,10 @@ private:
G2_LOWCAP_HIGHGAIN,
G2_LOWCAP_LOWGAIN,
G4_HIGHGAIN,
G4_LOWGAIN,
UNDEFINED,
UNINITIALIZED,
NUMSETTINGS
};
enum {
DYNAMICRANGE_32,
DYNAMICRANGE_16,
DYNAMICRANGE_8,
DYNAMICRANGE_4
};
G4_LOWGAIN,
UNDEFINED,
UNINITIALIZED,
NUMSETTINGS
};
enum { DYNAMICRANGE_32, DYNAMICRANGE_16, DYNAMICRANGE_8, DYNAMICRANGE_4 };
};

258
slsDetectorGui/slsDetectorPlotting/include/SlsQt1DPlot.h Executable file → Normal file
View File

@ -3,181 +3,179 @@
* @author Ian Johnson
* @version 1.0
* Modifications:
* 19.06.2012: {Some functions have been added by Dhanya to enable zooming in and out
* without using mouse control:
* DisableZoom,
* SetXMinMax,SetYMinMax,
* 19.06.2012: {Some functions have been added by Dhanya to enable zooming in
* and out without using mouse control: DisableZoom, SetXMinMax,SetYMinMax,
* GetXMinimum,GetXMaximum,GetYMinimum,GetYMaximum}
* */
#ifndef SLSQT1DPLOT_H
#define SLSQT1DPLOT_H
typedef double double32_t;
typedef float float32_t;
typedef int int32_t;
typedef double double32_t;
typedef float float32_t;
typedef int int32_t;
#include "ansi.h"
#include "SlsQt1DZoomer.h"
#include <iostream>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_marker.h>
#include <qwt_scale_div.h>
#include "SlsQt1DZoomer.h"
#include <iostream>
class QPen;
class SlsQt1DPlot;
class QwtSymbol;
class SlsQtH1D:public QwtPlotCurve{
class SlsQtH1D : public QwtPlotCurve {
public:
SlsQtH1D(QString title, int n, double xmin, double xmax, double* data=0);
SlsQtH1D(QString title, int n, double* data_x, double* data_y);
~SlsQtH1D();
public:
SlsQtH1D(QString title, int n, double xmin, double xmax, double *data = 0);
SlsQtH1D(QString title, int n, double *data_x, double *data_y);
~SlsQtH1D();
void Attach(SlsQt1DPlot* p);
void Detach(SlsQt1DPlot* p);
void Attach(SlsQt1DPlot *p);
void Detach(SlsQt1DPlot *p);
int SetLineColor(int c=-1);
int SetLineWidth(int w=1);
void SetLineStyle(int s=0);
void setStyleLinesorDots(bool isLines);
void setSymbolMarkers(bool isMarker);
int SetLineColor(int c = -1);
int SetLineWidth(int w = 1);
void SetLineStyle(int s = 0);
void setStyleLinesorDots(bool isLines);
void setSymbolMarkers(bool isMarker);
void SetData(int n, double xmin, double xmax, double* d=0);
void SetData(int n, double* dx, double* dy);
void SetData(int n, double xmin, double xmax, double *d = 0);
void SetData(int n, double *dx, double *dy);
double* GetX() {return x;}
double* GetY() {return y;}
int GetNBinsX() {return ndata;}
double *GetX() { return x; }
double *GetY() { return y; }
int GetNBinsX() { return ndata; }
double FillBin(int bx, double v=1);
double Fill(double x, double v=1);
double SetBinContent(int bx,double v);
double SetContent(double x,double v);
int FindBinIndex(double px);
double FillBin(int bx, double v = 1);
double Fill(double x, double v = 1);
double SetBinContent(int bx, double v);
double SetContent(double x, double v);
int FindBinIndex(double px);
double GetXMin() {return x[0];}
double GetFirstXgtZero() {return firstXgt0;}
double GetXMax() {return x[ndata-1];}
double GetYMin() {return ymin;}
double GetFirstYgtZero() {return firstYgt0;}
double GetYMax() {return ymax;}
double GetXMin() { return x[0]; }
double GetFirstXgtZero() { return firstXgt0; }
double GetXMax() { return x[ndata - 1]; }
double GetYMin() { return ymin; }
double GetFirstYgtZero() { return firstYgt0; }
double GetYMax() { return ymax; }
SlsQtH1D* Add(double v);
SlsQtH1D *Add(double v);
private:
int ndata;
int n_array;
double dx;
double *x{nullptr}, *y{nullptr};
double ymin, ymax;
double firstXgt0, firstYgt0;
void Initailize();
int SetUpArrays(int n);
int CheckIndex(int bx);
private:
int ndata;
int n_array;
double dx;
double *x{nullptr},*y{nullptr};
double ymin,ymax;
double firstXgt0,firstYgt0;
void Initailize();
int SetUpArrays(int n);
int CheckIndex(int bx);
QPen* pen_ptr{nullptr};
QPen *pen_ptr{nullptr};
};
class SlsQtH1DList {
public:
SlsQtH1DList(SlsQtH1D *hist = 0);
~SlsQtH1DList();
class SlsQtH1DList{
public:
SlsQtH1DList(SlsQtH1D* hist=0);
~SlsQtH1DList();
SlsQtH1D *Add(SlsQtH1D *h);
void Remove(SlsQtH1D *h);
void Print();
SlsQtH1D* Add(SlsQtH1D* h);
void Remove(SlsQtH1D* h);
void Print();
SlsQtH1D *Hist() { return the_hist; } // if no hist returns 0
SlsQtH1DList *Next() { return the_next; }
SlsQtH1D* Hist() {return the_hist;} //if no hist returns 0
SlsQtH1DList* Next() {return the_next;}
private:
SlsQtH1DList* the_next;
SlsQtH1D* the_hist;
private:
SlsQtH1DList *the_next;
SlsQtH1D *the_hist;
};
class SlsQt1DPlot:public QwtPlot{
Q_OBJECT
class SlsQt1DPlot : public QwtPlot {
Q_OBJECT
public:
SlsQt1DPlot(QWidget* = NULL);
~SlsQt1DPlot();
void SetTitle(QString title);
void SetXTitle(QString title);
void SetYTitle(QString title);
void SetTitleFont(const QFont& f);
void SetXFont(const QFont& f);
void SetYFont(const QFont& f);
void InsertHLine(double y);
void RemoveHLine();
void InsertVLine(double v);
void RemoveVLine();
public:
SlsQt1DPlot(QWidget * = NULL);
~SlsQt1DPlot();
void SetTitle(QString title);
void SetXTitle(QString title);
void SetYTitle(QString title);
void SetTitleFont(const QFont &f);
void SetXFont(const QFont &f);
void SetYFont(const QFont &f);
/** This group of functions have been added by Dhanya on 19.06.2012 to be able to
use zooming functionality without mouse control*/
void DisableZoom(bool disable);
void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);Update();};
void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);Update();};
void SetYStep (int step) {ystep = step;};
void SetXMinMax(double min,double 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 GetXMaximum(){return hist_list->Hist()->GetXMax();};
double GetYMinimum(){return hist_list->Hist()->GetYMin();};
double GetYMaximum(){return hist_list->Hist()->GetYMax();};
/**---*/
void InsertHLine(double y);
void RemoveHLine();
void InsertVLine(double v);
void RemoveVLine();
/** This group of functions have been added by Dhanya on 19.06.2012 to be
able to use zooming functionality without mouse control*/
void DisableZoom(bool disable);
void EnableXAutoScaling() {
setAxisAutoScale(QwtPlot::xBottom, true);
Update();
};
void EnableYAutoScaling() {
setAxisAutoScale(QwtPlot::yLeft, true);
Update();
};
void SetYStep(int step) { ystep = step; };
void SetXMinMax(double min, double 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 GetXMaximum() { return hist_list->Hist()->GetXMax(); };
double GetYMinimum() { return hist_list->Hist()->GetYMin(); };
double GetYMaximum() { return hist_list->Hist()->GetYMax(); };
/**---*/
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 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 alignScales();
void alignScales();
void SetLogX(bool yes=1);
void SetLogY(bool yes=1);
private:
SlsQtH1DList* hist_list{nullptr};
SlsQt1DZoomer* zoomer{nullptr};
QwtPlotPanner* panner{nullptr};
void SetLogX(bool yes = 1);
void SetLogY(bool yes = 1);
QwtPlotMarker *hline{nullptr};
QwtPlotMarker *vline{nullptr};
bool disableZoom{false};
int ystep{0};
void SetupZoom();
void UnknownStuff();
//void alignScales();
void CalculateNResetZoomBase();
void NewHistogramAttached(SlsQtH1D* h);
void HistogramDetached(SlsQtH1D* h);
private:
SlsQtH1DList *hist_list{nullptr};
SlsQt1DZoomer *zoomer{nullptr};
QwtPlotPanner *panner{nullptr};
void SetLog(int axisId, bool yes);
friend void SlsQtH1D::Attach(SlsQt1DPlot* p);
friend void SlsQtH1D::Detach(SlsQt1DPlot* p);
public slots:
void UnZoom();
void Update();
QwtPlotMarker *hline{nullptr};
QwtPlotMarker *vline{nullptr};
bool disableZoom{false};
int ystep{0};
void SetupZoom();
void UnknownStuff();
// void alignScales();
void CalculateNResetZoomBase();
void NewHistogramAttached(SlsQtH1D *h);
void HistogramDetached(SlsQtH1D *h);
void SetLog(int axisId, bool yes);
friend void SlsQtH1D::Attach(SlsQt1DPlot *p);
friend void SlsQtH1D::Detach(SlsQt1DPlot *p);
public slots:
void UnZoom();
void Update();
};
#endif

View File

@ -7,54 +7,51 @@
#ifndef SLSQT1DZOOMER_H
#define SLSQT1DZOOMER_H
#include <qwt_plot_zoomer.h>
#include <qwt_plot_panner.h>
#include <qwt_global.h>
#include <qwt_plot_panner.h>
#include <qwt_plot_zoomer.h>
class SlsQtH1D;
class SlsQt1DZoomer:public QwtPlotZoomer{
private:
double x0,x1,y0,y1;
double firstXgt0,firstYgt0;
bool xIsLog,yIsLog;
class SlsQt1DZoomer : public QwtPlotZoomer {
private:
double x0, x1, y0, y1;
double firstXgt0, firstYgt0;
bool xIsLog, yIsLog;
public:
SlsQt1DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
setTrackerMode(AlwaysOn);
xIsLog=yIsLog=0;
}
public:
SlsQt1DZoomer(QWidget *canvas) : QwtPlotZoomer(canvas) {
setTrackerMode(AlwaysOn);
xIsLog = yIsLog = 0;
}
double x() {return x0;}
double x_firstGreaterThan0() {return firstXgt0;}
double w() {return x1-x0;}
double x() { return x0; }
double x_firstGreaterThan0() { return firstXgt0; }
double w() { return x1 - x0; }
double y() {return y0;}
double y_firstGreaterThan0() {return firstYgt0;}
double h() {return y1-y0;}
double y() { return y0; }
double y_firstGreaterThan0() { return firstYgt0; }
double h() { return y1 - y0; }
void SetZoomBase(double xmin,double ymin,double x_width, double y_width);
void SetZoomBase(SlsQtH1D* h);
void ExtendZoomBase(SlsQtH1D* h);
void ResetZoomBase();
void SetZoomBase(double xmin, double ymin, double x_width, double y_width);
void SetZoomBase(SlsQtH1D *h);
void ExtendZoomBase(SlsQtH1D *h);
void ResetZoomBase();
bool IsLogX(){ return xIsLog;}
bool IsLogY(){ return yIsLog;}
bool SetLogX(bool yes) { return xIsLog=yes;}
bool SetLogY(bool yes) { return yIsLog=yes;}
bool IsLogX() { return xIsLog; }
bool IsLogY() { return yIsLog; }
bool SetLogX(bool yes) { return xIsLog = yes; }
bool SetLogY(bool yes) { return yIsLog = yes; }
using QwtPlotPicker::trackerText;
virtual QwtText trackerText(const QPoint &pos) const{
QColor bg(Qt::white);
bg.setAlpha(200);
QwtText text = QwtPlotPicker::trackerText(pos);
text.setBackgroundBrush( QBrush( bg ));
return text;
}
using QwtPlotPicker::trackerText;
virtual QwtText trackerText(const QPoint &pos) const {
QColor bg(Qt::white);
bg.setAlpha(200);
QwtText text = QwtPlotPicker::trackerText(pos);
text.setBackgroundBrush(QBrush(bg));
return text;
}
};
#endif

191
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DHist.h Executable file → Normal file
View File

@ -4,132 +4,131 @@
* @version 1.0
*/
#ifndef SLSQT2DHIST_H
#define SLSQT2DHIST_H
#if QT_VERSION >= 0x040000
#include <qprintdialog.h>
#endif
#include <qwt_color_map.h>
#include <qwt_plot_spectrogram.h>
#include <qwt_scale_widget.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_width, y_width;
double x_min,x_max,y_min,y_max;
double x_width,y_width;
int nx, ny, nb;
double *data{nullptr};
double z_min, z_mean, z_max;
bool z_mean_has_been_calculated;
int nx,ny,nb;
double *data{nullptr};
double z_min,z_mean,z_max;
bool z_mean_has_been_calculated;
int nx_array,ny_array;
int nx_array, ny_array;
bool interp;
bool interp;
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;
}
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);
virtual ~SlsQt2DHist();
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;
}
double GetXMin() {return x_min;}
double GetXMax() {return x_max;}
double GetXBinWidth() {return x_width;}
double GetYMin() {return y_min;}
double GetYMax() {return y_max;}
double GetYBinWidth() {return y_width;}
double GetMinimum() {return z_min;}
double GetMaximum() {return z_max;}
double GetMean();
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);
virtual ~SlsQt2DHist();
int GetNBinsX(){return nx;}
int GetNBinsY(){return ny;}
double GetBinValue(int bx,int by);
int GetBinIndex(int bx,int by);
double* GetDataPtr(){return data;}
double GetXMin() { return x_min; }
double GetXMax() { return x_max; }
double GetXBinWidth() { return x_width; }
double GetYMin() { return y_min; }
double GetYMax() { return y_max; }
double GetYBinWidth() { return y_width; }
double GetMinimum() { return z_min; }
double GetMaximum() { return z_max; }
double GetMean();
void Interpolate(bool on=1) {interp=on;}
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);
double SetMinimumToFirstGreaterThanZero();
void SetMinimum(double zmin) {z_min=zmin;}
void SetMaximum(double zmax) {z_max=zmax;}
void SetMinMax(double zmin=0,double zmax=-1);
int GetNBinsX() { return nx; }
int GetNBinsY() { return ny; }
double GetBinValue(int bx, int by);
int GetBinIndex(int bx, int by);
double *GetDataPtr() { return data; }
int FindBinIndex(double x, double y);
void Interpolate(bool on = 1) { interp = on; }
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);
double SetMinimumToFirstGreaterThanZero();
void SetMinimum(double zmin) { z_min = zmin; }
void SetMaximum(double zmax) { z_max = zmax; }
void SetMinMax(double zmin = 0, double zmax = -1);
int FindBinIndex(double x, double y);
virtual QwtRasterData *copy() const{
//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
return (QwtRasterData*) this;
}
virtual QwtRasterData *copy() const {
// 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
return (QwtRasterData *)this;
}
virtual QwtInterval range() const{ return QwtInterval(z_min,z_max);}
virtual QwtInterval interval(Qt::Axis axis) const {
switch (axis){
case Qt::ZAxis:
return QwtInterval(z_min,z_max);
case Qt::XAxis:
return QwtInterval(x_min,x_max);
case Qt::YAxis:
return QwtInterval(y_min,y_max);
default:
return QwtInterval(z_min,z_max);
virtual QwtInterval range() const { return QwtInterval(z_min, z_max); }
virtual QwtInterval interval(Qt::Axis axis) const {
switch (axis) {
case Qt::ZAxis:
return QwtInterval(z_min, z_max);
case Qt::XAxis:
return QwtInterval(x_min, x_max);
case Qt::YAxis:
return QwtInterval(y_min, y_max);
default:
return QwtInterval(z_min, z_max);
};
};
};
virtual double value(double x, double y) const {
// if(!interp){ //default is box like plot
int index =
int((x - x_min) / x_width) + int((y - y_min) / y_width) * nx;
if (index < 0 || index > nb)
index = nb;
if (!interp)
return data[index];
//}
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;
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;
int b00 = x_int * ny + y_int;
int b01 = x_int * ny + y_int + 1;
int b10 = (x_int + 1) * ny + y_int;
int b11 = (x_int + 1) * ny + y_int + 1;
virtual double value(double x, double y) const{
//if(!interp){ //default is box like plot
int index = int((x-x_min)/x_width) + int((y-y_min)/y_width)*nx;
if(index<0||index>nb) index = nb;
if(!interp) return data[index];
//}
// vertical extrap
double y0 = y_min + (y_int + 0.5) * y_width;
double y1 = y_min + (y_int + 1.5) * y_width;
double left_v = value_between_points(y0, data[b00], y1, data[b01], y);
double right_v = value_between_points(y0, data[b10], y1, data[b11], y);
// horazontal extrap
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;
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;
return 0.5;
int b00 = x_int*ny + y_int;
int b01 = x_int*ny + y_int+1;
int b10 = (x_int+1)*ny + y_int;
int b11 = (x_int+1)*ny + y_int+1;
//vertical extrap
double y0 = y_min+(y_int+0.5)*y_width;
double y1 = y_min+(y_int+1.5)*y_width;
double left_v = value_between_points(y0,data[b00],y1,data[b01],y);
double right_v = value_between_points(y0,data[b10],y1,data[b11],y);
//horazontal extrap
return 0.5;
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);
}
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);
}
};
#endif

105
slsDetectorGui/slsDetectorPlotting/include/SlsQt2DPlot.h Executable file → Normal file
View File

@ -1,93 +1,92 @@
#pragma once
#include <qwt_plot.h>
#include <qlist.h>
#include <qwt_plot.h>
#include <qwt_plot_spectrogram.h>
#include "SlsQt2DZoomer.h"
#include "SlsQt2DHist.h"
#include "SlsQt2DHist.h"
#include "SlsQt2DZoomer.h"
class QwtPlotPanner;
class QwtScaleWidget;
class QwtLinearColorMap;
class QwtPlotPanner;
class QwtScaleWidget;
class QwtLinearColorMap;
class SlsQt2DPlot: public QwtPlot{
class SlsQt2DPlot : public QwtPlot {
Q_OBJECT
public:
public:
SlsQt2DPlot(QWidget * = NULL);
~SlsQt2DPlot();
void SetTitle(QString title);
void SetXTitle(QString title);
void SetYTitle(QString title);
void SetZTitle(QString title);
void SetTitleFont(const QFont& f);
void SetXFont(const QFont& f);
void SetYFont(const QFont& f);
void SetZFont(const QFont& f);
void SetTitleFont(const QFont &f);
void SetXFont(const QFont &f);
void SetYFont(const QFont &f);
void SetZFont(const QFont &f);
void UnZoom(bool replot=true);
void SetZoom(double xmin,double ymin,double x_width,double y_width);
void UnZoom(bool replot = true);
void SetZoom(double xmin, double ymin, double x_width, double y_width);
void DisableZoom(bool disable);
void EnableXAutoScaling() {setAxisAutoScale(QwtPlot::xBottom, true);};
void EnableYAutoScaling() {setAxisAutoScale(QwtPlot::yLeft, true);};
void SetXMinMax(double min,double max){setAxisScale(QwtPlot::xBottom,min,max);};
void SetYMinMax(double min,double max){setAxisScale(QwtPlot::yLeft,min,max);};
double GetXMinimum(){return hist->GetXMin();};
double GetXMaximum(){return hist->GetXMax();};
double GetYMinimum(){return hist->GetYMin();};
double GetYMaximum(){return hist->GetYMax();};
double GetZMinimum(){ return hist->GetMinimum();}
double GetZMaximum(){ return hist->GetMaximum();}
void SetZMinMax(double zmin=0,double zmax=-1);
void SetZMinimumToFirstGreaterThanZero(){hist->SetMinimumToFirstGreaterThanZero();}
double GetZMean() { return hist->GetMean();}
void EnableXAutoScaling() { setAxisAutoScale(QwtPlot::xBottom, true); };
void EnableYAutoScaling() { setAxisAutoScale(QwtPlot::yLeft, true); };
void SetXMinMax(double min, double max) {
setAxisScale(QwtPlot::xBottom, min, max);
};
void SetYMinMax(double min, double max) {
setAxisScale(QwtPlot::yLeft, min, max);
};
double GetXMinimum() { return hist->GetXMin(); };
double GetXMaximum() { return hist->GetXMax(); };
double GetYMinimum() { return hist->GetYMin(); };
double GetYMaximum() { return hist->GetYMax(); };
double GetZMinimum() { return hist->GetMinimum(); }
double GetZMaximum() { return hist->GetMaximum(); }
void SetZMinMax(double zmin = 0, double zmax = -1);
void SetZMinimumToFirstGreaterThanZero() {
hist->SetMinimumToFirstGreaterThanZero();
}
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){
hist->SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d,zmin,zmax);
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);
}
double* GetDataPtr() {return hist->GetDataPtr();}
int GetBinIndex(int bx,int by) {return hist->GetBinIndex(bx,by);}
int FindBinIndex(double x,double y) {return hist->FindBinIndex(x,y);}
void SetBinValue(int bx,int by,double v) { hist->SetBinValue(bx,by,v);}
double GetBinValue(int bx,int by) {return hist->GetBinValue(bx,by);}
void FillTestPlot(int i=0);
double *GetDataPtr() { return hist->GetDataPtr(); }
int GetBinIndex(int bx, int by) { return hist->GetBinIndex(bx, by); }
int FindBinIndex(double x, double y) { return hist->FindBinIndex(x, y); }
void SetBinValue(int bx, int by, double v) { hist->SetBinValue(bx, by, v); }
double GetBinValue(int bx, int by) { return hist->GetBinValue(bx, by); }
void FillTestPlot(int i = 0);
void Update();
void SetInterpolate(bool enable);
void SetContour(bool enable);
void SetLogz(bool enable, 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);
private:
private:
void SetupZoom();
void SetupColorMap();
QwtLinearColorMap* myColourMap(QVector<double> colourStops);
QwtLinearColorMap* myColourMap(int log=0);
QwtLinearColorMap *myColourMap(QVector<double> colourStops);
QwtLinearColorMap *myColourMap(int log = 0);
QwtPlotSpectrogram *d_spectrogram{nullptr};
SlsQt2DHist* hist{nullptr};
SlsQt2DZoomer* zoomer{nullptr};
QwtPlotPanner* panner{nullptr};
SlsQt2DHist *hist{nullptr};
SlsQt2DZoomer *zoomer{nullptr};
QwtPlotPanner *panner{nullptr};
QwtScaleWidget *rightAxis{nullptr};
QwtLinearColorMap* colorMapLinearScale{nullptr};
QwtLinearColorMap* colorMapLogScale{nullptr};
QwtLinearColorMap *colorMapLinearScale{nullptr};
QwtLinearColorMap *colorMapLogScale{nullptr};
QList<double> contourLevelsLinear;
QList<double> contourLevelsLog;
bool disableZoom{false};
int isLog;
};

View File

@ -5,60 +5,50 @@
* Dhanya-05.12.2012- included an additional header
*/
#ifndef 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>
/**end of Change by Dhanya*/
#include <qwt_plot_zoomer.h>
#include <qwt_plot_panner.h>
#include <qwt_plot_zoomer.h>
#include "SlsQt2DHist.h"
class SlsQt2DZoomer:public QwtPlotZoomer{
private:
SlsQt2DHist* hist;
public:
SlsQt2DZoomer(QWidget *canvas):QwtPlotZoomer(canvas){
setTrackerMode(AlwaysOn);
}
void SetHist(SlsQt2DHist* h){
hist=h;
}
virtual QwtText trackerTextF(const QPointF &pos) const{
QColor bg(Qt::white);
bg.setAlpha(200);
//QwtText text = QwtPlotZoomer::trackerText(pos);
static QwtText text;
if(hist){
static char t[200];
sprintf(t,"%3.2f, %3.2f, %3.2f",pos.x(),pos.y(),hist->value(pos.x(),pos.y()));
text.setText(t);
}else {
QPoint p=pos.toPoint();
QwtText text = QwtPlotZoomer::trackerText(p);
class SlsQt2DZoomer : public QwtPlotZoomer {
private:
SlsQt2DHist *hist;
public:
SlsQt2DZoomer(QWidget *canvas) : QwtPlotZoomer(canvas) {
setTrackerMode(AlwaysOn);
}
void SetHist(SlsQt2DHist *h) { hist = h; }
virtual QwtText trackerTextF(const QPointF &pos) const {
QColor bg(Qt::white);
bg.setAlpha(200);
// QwtText text = QwtPlotZoomer::trackerText(pos);
static QwtText text;
if (hist) {
static char t[200];
sprintf(t, "%3.2f, %3.2f, %3.2f", pos.x(), pos.y(),
hist->value(pos.x(), pos.y()));
text.setText(t);
} else {
QPoint p = pos.toPoint();
QwtText text = QwtPlotZoomer::trackerText(p);
}
text.setBackgroundBrush(QBrush(bg));
return text;
}
text.setBackgroundBrush( QBrush( bg ));
return text;
}
};
#endif

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

@ -5,6 +5,7 @@
*/
#include "SlsQt1DPlot.h"
#include "qwt_symbol.h"
#include <iostream>
#include <qwt_legend.h>
#include <qwt_math.h>
@ -14,19 +15,18 @@
#include <qwt_scale_draw.h>
#include <qwt_scale_engine.h>
#include <qwt_scale_widget.h>
#include "qwt_symbol.h"
#include <stdlib.h>
#define QwtLog10ScaleEngine QwtLogScaleEngine // hmm
#define QwtLog10ScaleEngine QwtLogScaleEngine //hmm
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data) : QwtPlotCurve(title), x(nullptr), y(nullptr), pen_ptr(nullptr) {
SlsQtH1D::SlsQtH1D(QString title, int n, double min, double max, double *data)
: QwtPlotCurve(title), x(nullptr), y(nullptr), pen_ptr(nullptr) {
Initailize();
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();
SetData(n, data_x, data_y);
}
@ -39,12 +39,12 @@ void SlsQtH1D::Initailize() {
}
SlsQtH1D::~SlsQtH1D() {
delete [] x;
delete [] y;
delete pen_ptr;
delete[] x;
delete[] y;
delete pen_ptr;
}
void SlsQtH1D::Attach(SlsQt1DPlot *p) {
@ -128,18 +128,17 @@ void SlsQtH1D::SetLineStyle(int s) {
setPen(*pen_ptr);
}
void SlsQtH1D::setStyleLinesorDots(bool isLines) {
void SlsQtH1D::setStyleLinesorDots(bool isLines) {
setStyle(isLines ? QwtPlotCurve::Lines : QwtPlotCurve::Dots);
}
void SlsQtH1D::setSymbolMarkers(bool isMarker) {
QwtSymbol* marker = new QwtSymbol();
void SlsQtH1D::setSymbolMarkers(bool isMarker) {
QwtSymbol *marker = new QwtSymbol();
if (isMarker) {
marker->setStyle(QwtSymbol::Cross);
marker->setSize(5, 5);
}
setSymbol(marker);
}
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];
}
setRawSamples(x, y, ndata);
}
void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
@ -181,7 +178,7 @@ void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
n = SetUpArrays(n);
ndata = n;
dx = -1; //signifies not regular intervals
dx = -1; // signifies not regular intervals
ymin = ymax = data_y ? data_y[0] : 0;
@ -202,18 +199,17 @@ void SlsQtH1D::SetData(int n, double *data_x, double *data_y) {
firstYgt0 = y[b];
}
setRawSamples(x, y, ndata);
}
int SlsQtH1D::SetUpArrays(int n) {
n = n < 1 ? 1 : n; //overflow bin
n = n < 1 ? 1 : n; // overflow bin
if (n + 1 > n_array) {
n_array = n + 1;
delete x;
delete y;
delete x;
delete y;
x = new double[n_array];
y = new double[n_array];
}
@ -225,7 +221,9 @@ double SlsQtH1D::FillBin(int bx, double v) {
bx = CheckIndex(bx);
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) {
bx = CheckIndex(bx);
@ -241,13 +239,15 @@ double SlsQtH1D::SetBinContent(int bx, double v) {
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) {
if (dx > 0)
CheckIndex(int((px - x[0]) / dx));
//find closest bin
// find closest bin
int b = 0;
for (; b < ndata; b++)
if (x[b] > px)
@ -261,7 +261,9 @@ int SlsQtH1D::FindBinIndex(double px) {
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) {
for (int bx = 0; bx < ndata; bx++)
@ -269,23 +271,20 @@ SlsQtH1D *SlsQtH1D::Add(double v) {
return this;
}
//1d hist list stuff
// 1d hist list stuff
SlsQtH1DList::SlsQtH1DList(SlsQtH1D *hist) {
the_hist = hist;
the_next = 0;
}
SlsQtH1DList::~SlsQtH1DList() {
delete the_next;
}
SlsQtH1DList::~SlsQtH1DList() { delete the_next; }
SlsQtH1D *SlsQtH1DList::Add(SlsQtH1D *hist) {
SlsQtH1DList *hl = this;
while (hl) {
if (hist == hl->the_hist)
return hist; //already added
return hist; // already added
if (!hl->the_next)
break;
hl = hl->the_next;
@ -304,7 +303,8 @@ void SlsQtH1DList::Print() {
SlsQtH1DList *hl = this;
int i = 0;
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;
if (i > 10)
break;
@ -313,10 +313,10 @@ void SlsQtH1DList::Print() {
void SlsQtH1DList::Remove(SlsQtH1D *hist) {
SlsQtH1DList *hl = this;
while (hl) { //every match will be removed
while (hl) { // every match will be removed
if (hl->the_hist != hist)
hl = hl->the_next;
else { //match
else { // match
if (!hl->the_next)
hl->the_hist = 0; // first the_hist is zero when there's no next
else {
@ -330,7 +330,7 @@ void SlsQtH1DList::Remove(SlsQtH1D *hist) {
}
}
//1d plot stuff
// 1d plot stuff
SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
// n_histograms_attached=0;
hline = vline = 0;
@ -352,16 +352,16 @@ SlsQt1DPlot::SlsQt1DPlot(QWidget *parent) : QwtPlot(parent) {
}
SlsQt1DPlot::~SlsQt1DPlot() {
delete hist_list;
delete hline;
delete vline;
delete zoomer;
delete panner;
delete hist_list;
delete hline;
delete vline;
delete zoomer;
delete panner;
}
void SlsQt1DPlot::CalculateNResetZoomBase() {
@ -378,8 +378,8 @@ void SlsQt1DPlot::CalculateNResetZoomBase() {
void SlsQt1DPlot::NewHistogramAttached(SlsQtH1D *h) {
hist_list->Add(h);
CalculateNResetZoomBase();
//commented out by dhanya to take off zooming every hist in 1d plots
//if(!hist_list->Next()) UnZoom();
// commented out by dhanya to take off zooming every hist in 1d plots
// if(!hist_list->Next()) UnZoom();
Update();
}
@ -389,13 +389,9 @@ void SlsQt1DPlot::HistogramDetached(SlsQtH1D *h) {
Update();
}
void SlsQt1DPlot::Update() {
replot();
}
void SlsQt1DPlot::Update() { replot(); }
void SlsQt1DPlot::SetTitle(QString title) {
setTitle(title);
}
void SlsQt1DPlot::SetTitle(QString title) { setTitle(title); }
void SlsQt1DPlot::SetXTitle(QString title) {
setAxisTitle(QwtPlot::xBottom, title);
@ -405,20 +401,20 @@ void SlsQt1DPlot::SetYTitle(QString title) {
setAxisTitle(QwtPlot::yLeft, title);
}
void SlsQt1DPlot::SetTitleFont(const QFont& f) {
void SlsQt1DPlot::SetTitleFont(const QFont &f) {
QwtText t("");
t.setFont(f);
t.setRenderFlags( Qt::AlignLeft | Qt::AlignVCenter);
t.setRenderFlags(Qt::AlignLeft | Qt::AlignVCenter);
setTitle(t);
}
void SlsQt1DPlot::SetXFont(const QFont& f) {
void SlsQt1DPlot::SetXFont(const QFont &f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::xBottom, t);
}
void SlsQt1DPlot::SetYFont(const QFont& f) {
void SlsQt1DPlot::SetYFont(const QFont &f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::yLeft, t);
@ -432,9 +428,10 @@ void SlsQt1DPlot::SetLog(int axisId, bool yes) {
if (axisId == QwtPlot::yLeft)
zoomer->SetLogY(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)
setAxisScaleEngine(axisId, new QwtLog10ScaleEngine());
else
@ -450,11 +447,13 @@ void SlsQt1DPlot::UnZoom() {
setAxisScale(QwtPlot::xBottom, zoomer->x(), zoomer->x() + zoomer->w());
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();
}
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::yLeft, ymin, ymin + y_width);
Update();
@ -503,9 +502,11 @@ void SlsQt1DPlot::SetupZoom() {
zoomer = new SlsQt1DZoomer(canvas());
#if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
Qt::ControlButton);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
@ -546,32 +547,39 @@ void SlsQt1DPlot::alignScales() {
void SlsQt1DPlot::UnknownStuff() {
// We don't need the cache here
((QwtPlotCanvas *)canvas())->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
((QwtPlotCanvas *)canvas())
->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
#ifdef Q_WS_X11
// Qt::WA_PaintOnScreen is only supported for X11, but leads
// to substantial bugs with Qt 4.2.x/Windows
canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
#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) {
if (disableZoom != disable) {
disableZoom = disable;
if (disable) {
if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
Qt::NoButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::NoButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::NoButton);
}
if (panner)
panner->setMouseButton(Qt::NoButton);
} else {
if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
Qt::LeftButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
}
if (panner)
panner->setMouseButton(Qt::MidButton);

136
slsDetectorGui/slsDetectorPlotting/src/SlsQt1DZoomer.cxx Executable file → Normal file
View File

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

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

@ -4,125 +4,145 @@
* @version 1.0
*/
#include "ansi.h"
#include <iostream>
#include <cmath>
#include "SlsQt2DHist.h"
#include "ansi.h"
#include <cmath>
#include <iostream>
using std::cout;
using std::endl;
SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy, 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;
nx_array=ny_array=0;data=0;
SetData(nbinsx,xmin,xmax,nbinsy,ymin,ymax,d,zmin,zmax);
SlsQt2DHist::SlsQt2DHist(int nbinsx, double xmin, double xmax, int nbinsy,
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;
nx_array = ny_array = 0;
data = 0;
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 b = bx*ny+by;
if(b<0 || b>=nb){
cout<<"GetBinIndex:: Incorrect indicies bx and by returning overflow bin;"<<endl;
return nb;
}
return b;
}
int SlsQt2DHist::FindBinIndex(double x, double y){
return GetBinIndex(int((x-x_min)/x_width),int((y-y_min)/y_width));
}
double SlsQt2DHist::GetBinValue(int bx,int by){
return data[GetBinIndex(bx,by)];
}
void SlsQt2DHist::SetBinValue(int bx,int by,double v){
z_mean_has_been_calculated = 0;
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){
z_mean_has_been_calculated = 0;
if(xmax<xmin||ymax<ymin) cout<<"Warning input range invalid."<<endl;
x_width = (xmax - xmin)/nbinsx;
y_width = (ymax - ymin)/nbinsy;
if(x_min!=xmin||x_max!=xmax||y_min!=ymin||y_max!=ymax){
x_min=xmin;x_max=xmax;
y_min=ymin;y_max=ymax;
setInterval( Qt::XAxis,QwtInterval(xmin,xmax));
setInterval( Qt::YAxis,QwtInterval(ymin,ymax));
}
if(nbinsx*nbinsy<1){
cout<<"Exitting: SlsQt2DHist::SetData() number of bins must be greater than zero."<<endl;
exit(1);
}
if(nbinsx*nbinsy>nx_array*ny_array){
delete [] data;
data = new double [nbinsx*nbinsy+1]; //one for under/overflow bin
nx_array = nbinsx;
ny_array = nbinsy;
}
nx=nbinsx;
ny=nbinsy;
nb=nx*ny;
data[nb]=0;//set over flow to zero
if(d){
memcpy(data,d,nb*sizeof(double));
SetMinMax(zmin,zmax);
}
}
void SlsQt2DHist::SetMinMax(double zmin,double zmax){
/* if(zmin<zmax){ edited out to test*/
if(zmax != -1){
z_min=zmin;
z_max=zmax;
}else{
z_mean_has_been_calculated = 1;
z_min=data[0];
z_mean=0;
z_max=data[0];
for(int i=0;i<nb;i++){
if(data[i]<z_min) z_min=data[i];
if(data[i]>z_max) z_max=data[i];
z_mean+=data[i];
int SlsQt2DHist::GetBinIndex(int bx, int by) {
int b = bx * ny + by;
if (b < 0 || b >= nb) {
cout << "GetBinIndex:: Incorrect indicies bx and by returning overflow "
"bin;"
<< endl;
return nb;
}
z_mean/=nb;
if(z_min>0) 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));
return b;
}
double SlsQt2DHist::GetMean(){
if(!z_mean_has_been_calculated){
z_mean_has_been_calculated = 1;
z_mean=0;
for(int i=0;i<nb;i++) z_mean+=data[i];
z_mean/=nb;
}
return z_mean;
int SlsQt2DHist::FindBinIndex(double x, double y) {
return GetBinIndex(int((x - x_min) / x_width), int((y - y_min) / y_width));
}
double SlsQt2DHist::SetMinimumToFirstGreaterThanZero(){
z_min=fabs(z_max)+1;
for(int i=0;i<nb;i++){
if(data[i]>0 && data[i]<z_min) z_min=data[i];
}
setInterval( Qt::ZAxis,QwtInterval(z_min,z_max));
return z_min;
double SlsQt2DHist::GetBinValue(int bx, int by) {
return data[GetBinIndex(bx, by)];
}
void SlsQt2DHist::SetBinValue(int bx, int by, double v) {
z_mean_has_been_calculated = 0;
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) {
z_mean_has_been_calculated = 0;
if (xmax < xmin || ymax < ymin)
cout << "Warning input range invalid." << endl;
x_width = (xmax - xmin) / nbinsx;
y_width = (ymax - ymin) / nbinsy;
if (x_min != xmin || x_max != xmax || y_min != ymin || y_max != ymax) {
x_min = xmin;
x_max = xmax;
y_min = ymin;
y_max = ymax;
setInterval(Qt::XAxis, QwtInterval(xmin, xmax));
setInterval(Qt::YAxis, QwtInterval(ymin, ymax));
}
if (nbinsx * nbinsy < 1) {
cout << "Exitting: SlsQt2DHist::SetData() number of bins must be "
"greater than zero."
<< endl;
exit(1);
}
if (nbinsx * nbinsy > nx_array * ny_array) {
delete[] data;
data = new double[nbinsx * nbinsy + 1]; // one for under/overflow bin
nx_array = nbinsx;
ny_array = nbinsy;
}
nx = nbinsx;
ny = nbinsy;
nb = nx * ny;
data[nb] = 0; // set over flow to zero
if (d) {
memcpy(data, d, nb * sizeof(double));
SetMinMax(zmin, zmax);
}
}
void SlsQt2DHist::SetMinMax(double zmin, double zmax) {
/* if(zmin<zmax){ edited out to test*/
if (zmax != -1) {
z_min = zmin;
z_max = zmax;
} else {
z_mean_has_been_calculated = 1;
z_min = data[0];
z_mean = 0;
z_max = data[0];
for (int i = 0; i < nb; i++) {
if (data[i] < z_min)
z_min = data[i];
if (data[i] > z_max)
z_max = data[i];
z_mean += data[i];
}
z_mean /= nb;
if (z_min > 0)
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));
}
double SlsQt2DHist::GetMean() {
if (!z_mean_has_been_calculated) {
z_mean_has_been_calculated = 1;
z_mean = 0;
for (int i = 0; i < nb; i++)
z_mean += data[i];
z_mean /= nb;
}
return z_mean;
}
double SlsQt2DHist::SetMinimumToFirstGreaterThanZero() {
z_min = fabs(z_max) + 1;
for (int i = 0; i < nb; i++) {
if (data[i] > 0 && data[i] < z_min)
z_min = data[i];
}
setInterval(Qt::ZAxis, QwtInterval(z_min, z_max));
return z_min;
}

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

@ -19,11 +19,7 @@
#include <qwt_scale_engine.h>
#include <qwt_scale_widget.h>
#define QwtLog10ScaleEngine QwtLogScaleEngine //hmm remove?
#define QwtLog10ScaleEngine QwtLogScaleEngine // hmm remove?
SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
isLog = 0;
@ -40,55 +36,52 @@ SlsQt2DPlot::SlsQt2DPlot(QWidget *parent) : QwtPlot(parent) {
Update();
}
SlsQt2DPlot::~SlsQt2DPlot() {
if (d_spectrogram) {
d_spectrogram->detach();
//delete d_spectrogram;
// delete d_spectrogram;
}
delete hist;
delete colorMapLinearScale;
delete colorMapLogScale;
delete zoomer;
delete panner;
delete hist;
delete colorMapLinearScale;
delete colorMapLogScale;
delete zoomer;
delete panner;
}
void SlsQt2DPlot::SetTitle(QString title) {
setTitle(title);
}
void SlsQt2DPlot::SetTitle(QString title) { setTitle(title); }
void SlsQt2DPlot::SetXTitle(QString title) {
setAxisTitle(QwtPlot::xBottom, title);
setAxisTitle(QwtPlot::xBottom, title);
}
void SlsQt2DPlot::SetYTitle(QString title) {
setAxisTitle(QwtPlot::yLeft, title);
setAxisTitle(QwtPlot::yLeft, title);
}
void SlsQt2DPlot::SetZTitle(QString title) {
setAxisTitle(QwtPlot::yRight, title);
setAxisTitle(QwtPlot::yRight, title);
}
void SlsQt2DPlot::SetTitleFont(const QFont& f) {
void SlsQt2DPlot::SetTitleFont(const QFont &f) {
QwtText t("");
t.setFont(f);
t.setRenderFlags( Qt::AlignLeft | Qt::AlignVCenter);
t.setRenderFlags(Qt::AlignLeft | Qt::AlignVCenter);
setTitle(t);
}
void SlsQt2DPlot::SetXFont(const QFont& f) {
void SlsQt2DPlot::SetXFont(const QFont &f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::xBottom, t);
}
void SlsQt2DPlot::SetYFont(const QFont& f) {
void SlsQt2DPlot::SetYFont(const QFont &f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::yLeft, t);
}
void SlsQt2DPlot::SetZFont(const QFont& f) {
void SlsQt2DPlot::SetZFont(const QFont &f) {
QwtText t("");
t.setFont(f);
setAxisTitle(QwtPlot::yRight, t);
@ -105,7 +98,6 @@ void SlsQt2DPlot::SetupColorMap() {
for (double level = 0.5; level < 10.0; level += 1.0)
(contourLevelsLog) += (pow(10, 2 * level / 10.0) - 1) / 99.0 * 10;
// A color bar on the right axis
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));
for (int i = 0; i < nx; i++) {
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)
the_data[i + j * nx] = 10 * d / dmax;
@ -146,9 +139,11 @@ void SlsQt2DPlot::SetupZoom() {
zoomer->SetHist(hist);
#if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
Qt::ControlButton);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
@ -169,27 +164,31 @@ void SlsQt2DPlot::SetupZoom() {
}
/*void SlsQt2DPlot::CompletelyUnZoom(){
setAxisScale(QwtPlot::xBottom,hist->GetXMin(),hist->GetXMin()+(hist->GetXMax()-hist->GetXMin()));
setAxisScale(QwtPlot::yLeft,hist->GetYMin(),hist->GetYMin()+(hist->GetYMax()-hist->GetYMin()));
zoomer->setZoomBase();
//replot();
setAxisScale(QwtPlot::xBottom,hist->GetXMin(),hist->GetXMin()+(hist->GetXMax()-hist->GetXMin()));
setAxisScale(QwtPlot::yLeft,hist->GetYMin(),hist->GetYMin()+(hist->GetYMax()-hist->GetYMin()));
zoomer->setZoomBase();
//replot();
}*/
void SlsQt2DPlot::UnZoom(bool replot) {
zoomer->setZoomBase(QRectF(hist->GetXMin(), hist->GetYMin(), 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->setZoomBase(QRectF(hist->GetXMin(), hist->GetYMin(),
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);
}
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));
}
void SlsQt2DPlot::DisableZoom(bool disable) {
if (disableZoom != disable) {
disableZoom = disable;
#ifdef VERBOSE
if (disable)
std::cout << "Disabling zoom\n";
@ -198,25 +197,33 @@ void SlsQt2DPlot::DisableZoom(bool disable) {
#endif
if (disable) {
if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::NoButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
Qt::NoButton);
#if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::NoButton, Qt::ControlButton);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::NoButton, Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::NoButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::NoButton);
}
if (panner)
panner->setMouseButton(Qt::NoButton);
} else {
if (zoomer) {
zoomer->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect1,
Qt::LeftButton);
#if QT_VERSION < 0x040000
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlButton);
#else
zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier);
zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier);
#endif
zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
}
if (panner)
panner->setMouseButton(Qt::MidButton);
@ -224,7 +231,6 @@ void SlsQt2DPlot::DisableZoom(bool disable) {
}
}
void SlsQt2DPlot::SetZMinMax(double zmin, double zmax) {
hist->SetMinMax(zmin, zmax);
}
@ -294,24 +300,25 @@ void SlsQt2DPlot::SetContour(bool enable) {
Update();
}
void SlsQt2DPlot::SetLogz(bool enable, bool isMin, bool isMax, double min, double max) {
LogZ(enable);
SetZRange(isMin, isMax, min, max);
void SlsQt2DPlot::SetLogz(bool enable, bool isMin, bool isMax, double min,
double max) {
LogZ(enable);
SetZRange(isMin, isMax, min, max);
}
void SlsQt2DPlot::SetZRange(bool isMin, bool isMax, double min, double max){
if(isLog) {
SetZMinimumToFirstGreaterThanZero();
}
void SlsQt2DPlot::SetZRange(bool isMin, bool isMax, double min, double max) {
if (isLog) {
SetZMinimumToFirstGreaterThanZero();
}
// set zmin and zmax
if (isMin || isMax) {
double zmin = (isMin ? min : GetZMinimum());
double zmax = (isMax ? max : GetZMaximum());
SetZMinMax(zmin, zmax);
}
// set zmin and zmax
if (isMin || isMax) {
double zmin = (isMin ? min : GetZMinimum());
double zmax = (isMax ? max : GetZMaximum());
SetZMinMax(zmin, zmax);
}
Update();
Update();
}
void SlsQt2DPlot::LogZ(bool on) {

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

@ -1,7 +1,7 @@
#include "qCloneWidget.h"
#include "qDefs.h"
#include "SlsQt1DPlot.h"
#include "SlsQt2DPlot.h"
#include "qDefs.h"
#include <QCloseEvent>
#include <QFileDialog>
@ -11,35 +11,39 @@
int qCloneWidget::NumClones{0};
qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot* p1, SlsQt2DPlot* p2, SlsQt1DPlot *gp1, SlsQt2DPlot* gp,
QString title, QString fPath, QString fName, int64_t aIndex,
bool displayStats, QString min, QString max, QString sum):
QMainWindow(parent), plot1d(p1), plot2d(p2), gainplot1d(gp1), gainplot2d(gp), filePath(fPath), fileName(fName), acqIndex(aIndex) {
setupUi(this);
id = qCloneWidget::NumClones++;
qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2,
SlsQt1DPlot *gp1, SlsQt2DPlot *gp, QString title,
QString fPath, QString fName, int64_t aIndex,
bool displayStats, QString min, QString max,
QString sum)
: QMainWindow(parent), plot1d(p1), plot2d(p2), gainplot1d(gp1),
gainplot2d(gp), filePath(fPath), fileName(fName), acqIndex(aIndex) {
setupUi(this);
id = qCloneWidget::NumClones++;
SetupWidgetWindow(title);
DisplayStats(displayStats, min, max, sum);
}
qCloneWidget::~qCloneWidget() {
delete plot1d;
delete plot2d;
delete gainplot1d;
delete gainplot2d;
delete plot1d;
delete plot2d;
delete gainplot1d;
delete gainplot2d;
}
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()));
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
boxPlot->setTitle(title);
// 1d
if (plot1d != nullptr) {
if (gainplot1d == nullptr) {
@ -49,7 +53,7 @@ void qCloneWidget::SetupWidgetWindow(QString title) {
plotLayout->addWidget(plot1d, 0, 0, ratio, ratio);
plotLayout->addWidget(gainplot1d, ratio, 0, 1, ratio, Qt::AlignTop);
}
}
}
// 2d
else {
if (gainplot2d == nullptr) {
@ -57,7 +61,8 @@ void qCloneWidget::SetupWidgetWindow(QString title) {
} else {
int ratio = qDefs::DATA_GAIN_PLOT_RATIO - 1;
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()));
@ -65,15 +70,19 @@ void qCloneWidget::SetupWidgetWindow(QString title) {
if (gainplot1d != nullptr) {
gainplot1d->setMinimumHeight(qDefs::MIN_HEIGHT_GAIN_PLOT_1D);
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) {
gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedWidth(plot2d->width() /
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) {
lblMinDisp->setText(QString("%1").arg(min));
lblMaxDisp->setText(QString("%1").arg(max));
@ -87,21 +96,32 @@ void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString s
void qCloneWidget::SavePlot() {
char cID[10];
sprintf(cID, "%d", id);
//title
QString fName = filePath + QString('/') + fileName + QString("_clone") + QString("%1").arg(id) + QString("_acq") + QString("%1").arg(acqIndex) + QString(".png");
// title
QString fName = filePath + QString('/') + fileName + QString("_clone") +
QString("%1").arg(id) + QString("_acq") +
QString("%1").arg(acqIndex) + QString(".png");
FILE_LOG(logINFO) << "Saving Clone:" << fName.toAscii().constData();
//save
QImage img(centralwidget->size().width(), centralwidget->size().height(), QImage::Format_RGB32);
// save
QImage img(centralwidget->size().width(), centralwidget->size().height(),
QImage::Format_RGB32);
QPainter painter(&img);
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 ((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";
} 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";
}
}
@ -110,11 +130,14 @@ void qCloneWidget::SavePlot() {
void qCloneWidget::resizeEvent(QResizeEvent *event) {
if (gainplot1d != nullptr) {
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) {
gainplot2d->setFixedWidth(plot2d->width() / qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedHeight(plot2d->height() / qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedWidth(plot2d->width() /
qDefs::DATA_GAIN_PLOT_RATIO);
gainplot2d->setFixedHeight(plot2d->height() /
qDefs::DATA_GAIN_PLOT_RATIO);
}
event->accept();
}

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

@ -3,88 +3,92 @@
#include <iostream>
qDacWidget::qDacWidget(QWidget *parent, sls::Detector *detector, bool d, std::string n, slsDetectorDefs::dacIndex i) :
QWidget(parent), det(detector), isDac(d), index(i){
setupUi(this);
SetupWidgetWindow(n);
qDacWidget::qDacWidget(QWidget *parent, sls::Detector *detector, bool d,
std::string n, slsDetectorDefs::dacIndex i)
: QWidget(parent), det(detector), isDac(d), index(i) {
setupUi(this);
SetupWidgetWindow(n);
}
qDacWidget::~qDacWidget() {}
void qDacWidget::SetupWidgetWindow(std::string name) {
lblDac->setText(name.c_str());
if (isDac) {
spinDac->setDecimals(0);
} else {
spinDac->setSuffix(0x00b0 + QString("C"));
spinDac->setReadOnly(true);
lblDacmV->setMinimumWidth(0);
lblDacmV->setMaximumWidth(0);
}
Initialization();
Refresh();
lblDac->setText(name.c_str());
if (isDac) {
spinDac->setDecimals(0);
} else {
spinDac->setSuffix(0x00b0 + QString("C"));
spinDac->setReadOnly(true);
lblDacmV->setMinimumWidth(0);
lblDacmV->setMaximumWidth(0);
}
Initialization();
Refresh();
}
void qDacWidget::Initialization() {
if (isDac) {
connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
}
if (isDac) {
connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
}
}
void qDacWidget::SetDetectorIndex(int id) {
detectorIndex = id;
Refresh();
detectorIndex = id;
Refresh();
}
void qDacWidget::GetDac() {
FILE_LOG(logDEBUG) << "Getting Dac " << index;
FILE_LOG(logDEBUG) << "Getting Dac " << index;
disconnect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
try {
// dac units
auto retval = det->getDAC(index, 0, {detectorIndex}).squash(-1);
spinDac->setValue(retval);
// mv
retval = det->getDAC(index, 1, {detectorIndex}).squash(-1);
lblDacmV->setText(QString("%1mV").arg(retval -10));
} CATCH_DISPLAY(std::string("Could not get dac ") + std::to_string(index), "qDacWidget::GetDac")
disconnect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
try {
// dac units
auto retval = det->getDAC(index, 0, {detectorIndex}).squash(-1);
spinDac->setValue(retval);
// mv
retval = det->getDAC(index, 1, {detectorIndex}).squash(-1);
lblDacmV->setText(QString("%1mV").arg(retval - 10));
}
CATCH_DISPLAY(std::string("Could not get dac ") + std::to_string(index),
"qDacWidget::GetDac")
connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
connect(spinDac, SIGNAL(editingFinished()), this, SLOT(SetDac()));
}
void qDacWidget::SetDac() {
int val = (int)spinDac->value();
FILE_LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data() << " : " << val;
int val = (int)spinDac->value();
FILE_LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data()
<< " : " << val;
try {
det->setDAC(index, val, 0, {detectorIndex});
} CATCH_DISPLAY (std::string("Could not set dac ") + std::to_string(index), "qDacWidget::SetDac")
// update mV anyway
try {
det->setDAC(index, val, 0, {detectorIndex});
}
CATCH_DISPLAY(std::string("Could not set dac ") + std::to_string(index),
"qDacWidget::SetDac")
// update mV anyway
GetDac();
}
void qDacWidget::GetAdc() {
FILE_LOG(logDEBUG) << "Getting ADC " << index;
try {
auto retval = det->getTemperature(index, {detectorIndex}).squash(-1);
if (retval == -1 && detectorIndex == -1) {
spinDac->setValue(-1);
} else {
spinDac->setValue(retval);
}
} CATCH_DISPLAY (std::string("Could not get adc ") + std::to_string(index), "qDacWidget::GetAdc")
FILE_LOG(logDEBUG) << "Getting ADC " << index;
try {
auto retval = det->getTemperature(index, {detectorIndex}).squash(-1);
if (retval == -1 && detectorIndex == -1) {
spinDac->setValue(-1);
} else {
spinDac->setValue(retval);
}
}
CATCH_DISPLAY(std::string("Could not get adc ") + std::to_string(index),
"qDacWidget::GetAdc")
}
void qDacWidget::Refresh() {
if (isDac) {
GetDac();
} else {
GetAdc();
}
if (isDac) {
GetDac();
} else {
GetAdc();
}
}

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

@ -1,25 +1,24 @@
#include "qDetectorMain.h"
#include "qDefs.h"
#include "qDrawPlot.h"
#include "qTabMeasurement.h"
#include "qTabDataOutput.h"
#include "qTabPlot.h"
#include "qTabAdvanced.h"
#include "qTabSettings.h"
#include "qTabDataOutput.h"
#include "qTabDebugging.h"
#include "qTabDeveloper.h"
#include "qTabMeasurement.h"
#include "qTabMessages.h"
#include "qTabPlot.h"
#include "qTabSettings.h"
#include "versionAPI.h"
#include "ToString.h"
#include "versionAPI.h"
#include <QResizeEvent>
#include <QScrollArea>
#include <QFileDialog>
#include <QPlastiqueStyle>
#include <QResizeEvent>
#include <QScrollArea>
#include <QSizePolicy>
#include <iostream>
#include <getopt.h>
#include <iostream>
#include <string>
@ -94,10 +93,9 @@ int main(int argc, char **argv) {
}
}
QApplication app(argc, argv);
app.setStyle(new QPlastiqueStyle);
//app.setWindowIcon(QIcon(":/icons/images/mountain.png"));
// app.setWindowIcon(QIcon(":/icons/images/mountain.png"));
try {
qDetectorMain det(multiId, fname, isDeveloper);
det.show();
@ -133,7 +131,8 @@ void qDetectorMain::SetUpWidgetWindow() {
layoutTabs->addWidget(tabs.get());
// 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());
tabPlot = sls::make_unique<qTabPlot>(this, det.get(), plot.get());
tabSettings = sls::make_unique<qTabSettings>(this, det.get());
@ -219,7 +218,8 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
LoadConfigFile(fName);
// 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);
switch (detType) {
case slsDetectorDefs::EIGER:
@ -230,18 +230,20 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
case slsDetectorDefs::MOENCH:
case slsDetectorDefs::MYTHEN3:
case slsDetectorDefs::GOTTHARD2:
break;
break;
default:
std::ostringstream os;
os << det->getHostname() << " has " <<
sls::ToString(det->getDetectorType().squash()) << " detector type (" <<
std::to_string(detType) << "). Exiting GUI.";
os << det->getHostname() << " has "
<< sls::ToString(det->getDetectorType().squash())
<< " detector type (" << std::to_string(detType)
<< "). Exiting GUI.";
std::string errorMess = os.str();
throw sls::RuntimeError(errorMess.c_str());
}
std::ostringstream os;
os << "SLS Detector GUI : " << sls::ToString(det->getDetectorType().squash())
<< " - " << det->getHostname();
os << "SLS Detector GUI : "
<< sls::ToString(det->getDetectorType().squash()) << " - "
<< det->getHostname();
std::string title = os.str();
FILE_LOG(logINFO) << title;
setWindowTitle(QString(title.c_str()));
@ -249,27 +251,36 @@ void qDetectorMain::SetUpDetector(const std::string fName, int multiID) {
void qDetectorMain::Initialization() {
// Dockable Plot
connect(dockWidgetPlot, SIGNAL(topLevelChanged(bool)), this, SLOT(ResizeMainWindow(bool)));
connect(dockWidgetPlot, SIGNAL(topLevelChanged(bool)), this,
SLOT(ResizeMainWindow(bool)));
// 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
connect(tabMeasurement.get(), SIGNAL(EnableTabsSignal(bool)), this, SLOT(EnableTabs(bool)));
connect(tabMeasurement.get(), SIGNAL(FileNameChangedSignal(QString)), plot.get(), SLOT(SetSaveFileName(QString)));
connect(tabMeasurement.get(), SIGNAL(EnableTabsSignal(bool)), this,
SLOT(EnableTabs(bool)));
connect(tabMeasurement.get(), SIGNAL(FileNameChangedSignal(QString)),
plot.get(), SLOT(SetSaveFileName(QString)));
// Plot tab
connect(tabPlot.get(), SIGNAL(DisableZoomSignal(bool)), this, SLOT(SetZoomToolTip(bool)));
connect(tabPlot.get(), SIGNAL(DisableZoomSignal(bool)), this,
SLOT(SetZoomToolTip(bool)));
// Plotting
connect(plot.get(), SIGNAL(AcquireFinishedSignal()), tabMeasurement.get(), SLOT(AcquireFinished()));
connect(plot.get(), SIGNAL(AbortSignal()), tabMeasurement.get(), SLOT(AbortAcquire()));
connect(plot.get(), SIGNAL(AcquireFinishedSignal()), tabMeasurement.get(),
SLOT(AcquireFinished()));
connect(plot.get(), SIGNAL(AbortSignal()), tabMeasurement.get(),
SLOT(AbortAcquire()));
// menubar
// Modes Menu
connect(menuModes, SIGNAL(triggered(QAction *)), this, SLOT(EnableModes(QAction *)));
connect(menuModes, SIGNAL(triggered(QAction *)), this,
SLOT(EnableModes(QAction *)));
// Utilities Menu
connect(menuUtilities, SIGNAL(triggered(QAction *)), this, SLOT(ExecuteUtilities(QAction *)));
connect(menuUtilities, SIGNAL(triggered(QAction *)), this,
SLOT(ExecuteUtilities(QAction *)));
// 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) {
@ -302,7 +313,9 @@ void qDetectorMain::LoadConfigFile(const std::string fName) {
} else {
try {
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) {
enable = actionDebug->isChecked();
tabs->setTabEnabled(DEBUGGING, enable);
FILE_LOG(logINFO) << "Debug Mode: "
<< qDefs::stringEnable(enable);
FILE_LOG(logINFO) << "Debug Mode: " << qDefs::stringEnable(enable);
}
@ -323,9 +335,9 @@ void qDetectorMain::EnableModes(QAction *action) {
enable = actionExpert->isChecked();
tabs->setTabEnabled(ADVANCED, enable);
actionLoadTrimbits->setVisible(enable && detType == slsDetectorDefs::EIGER);
FILE_LOG(logINFO) << "Expert Mode: "
<< qDefs::stringEnable(enable);
actionLoadTrimbits->setVisible(enable &&
detType == slsDetectorDefs::EIGER);
FILE_LOG(logINFO) << "Expert Mode: " << qDefs::stringEnable(enable);
}
// Set DockableMode
@ -337,8 +349,7 @@ void qDetectorMain::EnableModes(QAction *action) {
dockWidgetPlot->setFloating(false);
dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures);
}
FILE_LOG(logINFO) << "Dockable Mode: "
<< qDefs::stringEnable(enable);
FILE_LOG(logINFO) << "Dockable Mode: " << qDefs::stringEnable(enable);
}
}
@ -355,8 +366,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
// Gets called when cancelled as well
if (!fName.isEmpty()) {
refreshTabs = true;
det->loadConfig(
std::string(fName.toAscii().constData()));
det->loadConfig(std::string(fName.toAscii().constData()));
qDefs::Message(qDefs::INFORMATION,
"The Configuration Parameters have been "
"configured successfully.",
@ -375,19 +385,18 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
// Gets called when cancelled as well
if (!fName.isEmpty()) {
refreshTabs = true;
det->loadParameters(
std::string(fName.toAscii().constData()));
det->loadParameters(std::string(fName.toAscii().constData()));
qDefs::Message(qDefs::INFORMATION,
"The Detector Parameters have been "
"configured successfully.",
"qDetectorMain::ExecuteUtilities");
FILE_LOG(logINFO)
<< "Parameters loaded successfully";
FILE_LOG(logINFO) << "Parameters loaded successfully";
}
}
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";
// so that even nonexisting files can be selected
QFileDialog *fileDialog = new QFileDialog(
@ -399,18 +408,16 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
// Gets called when cancelled as well
if (!fName.isEmpty()) {
det->loadTrimbits(
std::string(fName.toAscii().constData()));
qDefs::Message(
qDefs::INFORMATION,
"The Trimbits have been loaded successfully.",
"qDetectorMain::ExecuteUtilities");
det->loadTrimbits(std::string(fName.toAscii().constData()));
qDefs::Message(qDefs::INFORMATION,
"The Trimbits have been loaded successfully.",
"qDetectorMain::ExecuteUtilities");
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());
if (refreshTabs) {
@ -429,13 +436,16 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
void qDetectorMain::ExecuteHelp(QAction *action) {
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 clientVersion = "unknown";
try {
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,
"<p style=\"font-family:verdana;\">"
@ -446,7 +456,8 @@ void qDetectorMain::ExecuteHelp(QAction *action) {
clientVersion +
"<br><br>"
"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 "
"line interface:<br>"
"sls_detector_put,<br>sls_detector_get,<br>sls_"
@ -553,7 +564,8 @@ void qDetectorMain::EnableTabs(bool enable) {
// expert
bool expertTab = enable && (actionExpert->isChecked());
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
// threads

587
slsDetectorGui/src/qDrawPlot.cpp Executable file → Normal file

File diff suppressed because it is too large Load Diff

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

@ -1,11 +1,12 @@
#include "qTabAdvanced.h"
#include "network_utils.h"
#include "qDefs.h"
#include "qDrawPlot.h"
#include "network_utils.h"
#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) {
setupUi(this);
SetupWidgetWindow();
@ -88,7 +89,8 @@ void qTabAdvanced::Initialization() {
// roi
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(btnClearRoi, SIGNAL(clicked()), this, SLOT(ClearROI()));
}
@ -114,7 +116,7 @@ void qTabAdvanced::Initialization() {
// throw bits
if (lblDiscardBits->isEnabled()) {
connect(spinDiscardBits, SIGNAL(valueChanged(int)), plot,
SLOT(SetNumDiscardBits(int)));
SLOT(SetNumDiscardBits(int)));
}
}
@ -122,7 +124,8 @@ void qTabAdvanced::PopulateDetectors() {
FILE_LOG(logDEBUG) << "Populating detectors";
disconnect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDetector()));
disconnect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI()));
disconnect(comboReadout, SIGNAL(currentIndexChanged(int)), this,
SLOT(GetROI()));
comboDetector->clear();
comboReadout->clear();
@ -132,11 +135,12 @@ void qTabAdvanced::PopulateDetectors() {
comboReadout->addItem(QString(it.c_str()));
}
comboDetector->setCurrentIndex(0);
comboReadout->setCurrentIndex(0);
comboReadout->setCurrentIndex(0);
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetDetector()));
connect(comboReadout, SIGNAL(currentIndexChanged(int)), this, SLOT(GetROI()));
connect(comboReadout, SIGNAL(currentIndexChanged(int)), this,
SLOT(GetROI()));
}
void qTabAdvanced::GetControlPort() {
@ -147,7 +151,9 @@ void qTabAdvanced::GetControlPort() {
try {
int retval = det->getControlPort({comboDetector->currentIndex()})[0];
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,
SLOT(SetControlPort(int)));
@ -161,7 +167,9 @@ void qTabAdvanced::GetStopPort() {
try {
int retval = det->getStopPort({comboDetector->currentIndex()})[0];
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,
SLOT(SetStopPort(int)));
@ -173,9 +181,12 @@ void qTabAdvanced::GetDetectorUDPIP() {
SLOT(SetDetectorUDPIP()));
try {
auto retval = det->getSourceUDPIP({comboDetector->currentIndex()})[0].str();
auto retval =
det->getSourceUDPIP({comboDetector->currentIndex()})[0].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,
SLOT(SetDetectorUDPIP()));
@ -187,9 +198,12 @@ void qTabAdvanced::GetDetectorUDPMAC() {
SLOT(SetDetectorUDPMAC()));
try {
auto retval = det->getSourceUDPMAC({comboDetector->currentIndex()})[0].str();
auto retval =
det->getSourceUDPMAC({comboDetector->currentIndex()})[0].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,
SLOT(SetDetectorUDPMAC()));
@ -201,10 +215,11 @@ void qTabAdvanced::GetCltZMQPort() {
SLOT(SetCltZMQPort(int)));
try {
int retval =
det->getClientZmqPort({comboDetector->currentIndex()})[0];
int retval = det->getClientZmqPort({comboDetector->currentIndex()})[0];
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,
SLOT(SetCltZMQPort(int)));
@ -218,7 +233,8 @@ void qTabAdvanced::GetCltZMQIP() {
auto retval =
det->getClientZmqIp({comboDetector->currentIndex()})[0].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()));
}
@ -231,7 +247,9 @@ void qTabAdvanced::GetRxrHostname() {
try {
auto retval = det->getRxHostname({comboDetector->currentIndex()})[0];
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,
SLOT(SetRxrHostname()));
@ -245,7 +263,9 @@ void qTabAdvanced::GetRxrTCPPort() {
try {
int retval = det->getRxPort({comboDetector->currentIndex()})[0];
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,
SLOT(SetRxrTCPPort(int)));
@ -257,9 +277,12 @@ void qTabAdvanced::GetRxrUDPPort() {
SLOT(SetRxrUDPPort(int)));
try {
int retval = det->getDestinationUDPPort({comboDetector->currentIndex()})[0];
int retval =
det->getDestinationUDPPort({comboDetector->currentIndex()})[0];
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,
SLOT(SetRxrUDPPort(int)));
@ -271,9 +294,11 @@ void qTabAdvanced::GetRxrUDPIP() {
SLOT(SetRxrUDPIP()));
try {
auto retval = det->getDestinationUDPIP({comboDetector->currentIndex()})[0].str();
auto retval =
det->getDestinationUDPIP({comboDetector->currentIndex()})[0].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()));
}
@ -284,9 +309,12 @@ void qTabAdvanced::GetRxrUDPMAC() {
SLOT(SetRxrUDPMAC()));
try {
auto retval = det->getDestinationUDPMAC({comboDetector->currentIndex()})[0].str();
auto retval =
det->getDestinationUDPMAC({comboDetector->currentIndex()})[0].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,
SLOT(SetRxrUDPMAC()));
@ -298,10 +326,11 @@ void qTabAdvanced::GetRxrZMQPort() {
SLOT(SetRxrZMQPort(int)));
try {
int retval =
det->getRxZmqPort({comboDetector->currentIndex()})[0];
int retval = det->getRxZmqPort({comboDetector->currentIndex()})[0];
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,
SLOT(SetRxrZMQPort(int)));
@ -313,10 +342,10 @@ void qTabAdvanced::GetRxrZMQIP() {
SLOT(SetRxrZMQIP()));
try {
auto retval =
det->getRxZmqIP({comboDetector->currentIndex()})[0].str();
auto retval = det->getRxZmqIP({comboDetector->currentIndex()})[0].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()));
}
@ -346,7 +375,8 @@ void qTabAdvanced::SetControlPort(int port) {
FILE_LOG(logINFO) << "Setting Control Port:" << port;
try {
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)
}
@ -354,8 +384,9 @@ void qTabAdvanced::SetStopPort(int port) {
FILE_LOG(logINFO) << "Setting Stop Port:" << port;
try {
det->setStopPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set stop port.", "qTabAdvanced::SetStopPort", this,
&qTabAdvanced::GetStopPort)
}
CATCH_HANDLE("Could not set stop port.", "qTabAdvanced::SetStopPort", this,
&qTabAdvanced::GetStopPort)
}
void qTabAdvanced::SetDetectorUDPIP() {
@ -363,9 +394,10 @@ void qTabAdvanced::SetDetectorUDPIP() {
FILE_LOG(logINFO) << "Setting Detector UDP IP:" << s;
try {
det->setSourceUDPIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Detector UDP IP.",
"qTabAdvanced::SetDetectorUDPIP", this,
&qTabAdvanced::GetDetectorUDPIP)
}
CATCH_HANDLE("Could not set Detector UDP IP.",
"qTabAdvanced::SetDetectorUDPIP", this,
&qTabAdvanced::GetDetectorUDPIP)
}
void qTabAdvanced::SetDetectorUDPMAC() {
@ -373,18 +405,20 @@ void qTabAdvanced::SetDetectorUDPMAC() {
FILE_LOG(logINFO) << "Setting Detector UDP MAC:" << s;
try {
det->setSourceUDPMAC(sls::MacAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Detector UDP MAC.",
"qTabAdvanced::SetDetectorUDPMAC", this,
&qTabAdvanced::GetDetectorUDPMAC)
}
CATCH_HANDLE("Could not set Detector UDP MAC.",
"qTabAdvanced::SetDetectorUDPMAC", this,
&qTabAdvanced::GetDetectorUDPMAC)
}
void qTabAdvanced::SetCltZMQPort(int port) {
FILE_LOG(logINFO) << "Setting Client ZMQ Port:" << port;
try {
det->setClientZmqPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ port.",
"qTabAdvanced::SetCltZMQPort", this,
&qTabAdvanced::GetCltZMQPort)
}
CATCH_HANDLE("Could not set Client ZMQ port.",
"qTabAdvanced::SetCltZMQPort", this,
&qTabAdvanced::GetCltZMQPort)
}
void qTabAdvanced::SetCltZMQIP() {
@ -392,9 +426,9 @@ void qTabAdvanced::SetCltZMQIP() {
FILE_LOG(logINFO) << "Setting Client ZMQ IP:" << s;
try {
det->setClientZmqIp(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ IP.",
"qTabAdvanced::SetCltZMQIP", this,
&qTabAdvanced::GetCltZMQIP)
}
CATCH_HANDLE("Could not set Client ZMQ IP.", "qTabAdvanced::SetCltZMQIP",
this, &qTabAdvanced::GetCltZMQIP)
}
void qTabAdvanced::SetRxrHostname() {
@ -402,9 +436,9 @@ void qTabAdvanced::SetRxrHostname() {
FILE_LOG(logINFO) << "Setting Receiver Hostname:" << s;
try {
det->setRxHostname(s, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Client ZMQ IP.",
"qTabAdvanced::SetRxrHostname", this,
&qTabAdvanced::GetRxrHostname)
}
CATCH_HANDLE("Could not set Client ZMQ IP.", "qTabAdvanced::SetRxrHostname",
this, &qTabAdvanced::GetRxrHostname)
// update all network widgets (receiver mainly)
SetDetector();
@ -414,47 +448,53 @@ void qTabAdvanced::SetRxrTCPPort(int port) {
FILE_LOG(logINFO) << "Setting Receiver TCP Port:" << port;
try {
det->setRxPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver TCP port.",
"qTabAdvanced::SetRxrTCPPort", this,
&qTabAdvanced::GetRxrTCPPort)
}
CATCH_HANDLE("Could not set Receiver TCP port.",
"qTabAdvanced::SetRxrTCPPort", this,
&qTabAdvanced::GetRxrTCPPort)
}
void qTabAdvanced::SetRxrUDPPort(int port) {
FILE_LOG(logINFO) << "Setting Receiver UDP Port:" << port;
try {
det->setRxPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP port.",
"qTabAdvanced::SetRxrUDPPort", this,
&qTabAdvanced::GetRxrUDPPort)
}
CATCH_HANDLE("Could not set Receiver UDP port.",
"qTabAdvanced::SetRxrUDPPort", this,
&qTabAdvanced::GetRxrUDPPort)
}
void qTabAdvanced::SetRxrUDPIP() {
std::string s = dispRxrUDPIP->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver UDP IP:" << s;
try {
det->setDestinationUDPIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP IP.",
"qTabAdvanced::SetRxrUDPIP", this,
&qTabAdvanced::GetRxrUDPIP)
det->setDestinationUDPIP(sls::IpAddr{s},
{comboDetector->currentIndex()});
}
CATCH_HANDLE("Could not set Receiver UDP IP.", "qTabAdvanced::SetRxrUDPIP",
this, &qTabAdvanced::GetRxrUDPIP)
}
void qTabAdvanced::SetRxrUDPMAC() {
std::string s = dispRxrUDPMAC->text().toAscii().constData();
FILE_LOG(logINFO) << "Setting Receiver UDP MAC:" << s;
try {
det->setDestinationUDPMAC(sls::MacAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver UDP MAC.",
"qTabAdvanced::SetRxrUDPMAC", this,
&qTabAdvanced::GetRxrUDPMAC)
det->setDestinationUDPMAC(sls::MacAddr{s},
{comboDetector->currentIndex()});
}
CATCH_HANDLE("Could not set Receiver UDP MAC.",
"qTabAdvanced::SetRxrUDPMAC", this,
&qTabAdvanced::GetRxrUDPMAC)
}
void qTabAdvanced::SetRxrZMQPort(int port) {
FILE_LOG(logINFO) << "Setting Receiver ZMQ Port:" << port;
try {
det->setRxZmqPort(port, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver ZMQ port.",
"qTabAdvanced::SetRxrZMQPort", this,
&qTabAdvanced::GetRxrZMQPort)
}
CATCH_HANDLE("Could not set Receiver ZMQ port.",
"qTabAdvanced::SetRxrZMQPort", this,
&qTabAdvanced::GetRxrZMQPort)
}
void qTabAdvanced::SetRxrZMQIP() {
@ -462,24 +502,26 @@ void qTabAdvanced::SetRxrZMQIP() {
FILE_LOG(logINFO) << "Setting Receiver ZMQ IP:" << s;
try {
det->setRxZmqIP(sls::IpAddr{s}, {comboDetector->currentIndex()});
} CATCH_HANDLE ("Could not set Receiver ZMQ IP.",
"qTabAdvanced::SetRxrZMQIP", this,
&qTabAdvanced::GetRxrZMQIP)
}
CATCH_HANDLE("Could not set Receiver ZMQ IP.", "qTabAdvanced::SetRxrZMQIP",
this, &qTabAdvanced::GetRxrZMQIP)
}
void qTabAdvanced::GetROI() {
FILE_LOG(logDEBUG) << "Getting ROI";
try {
slsDetectorDefs::ROI roi = det->getROI({comboReadout->currentIndex()})[0];
slsDetectorDefs::ROI roi =
det->getROI({comboReadout->currentIndex()})[0];
spinXmin->setValue(roi.xmin);
spinXmax->setValue(roi.xmax);
} CATCH_DISPLAY ("Could not get ROI.", "qTabAdvanced::GetROI")
spinXmax->setValue(roi.xmax);
}
CATCH_DISPLAY("Could not get ROI.", "qTabAdvanced::GetROI")
}
void qTabAdvanced::ClearROI() {
FILE_LOG(logINFO) << "Clearing ROI";
spinXmin->setValue(-1);
spinXmax->setValue(-1);
spinXmax->setValue(-1);
SetROI();
FILE_LOG(logDEBUG) << "ROIs cleared";
}
@ -491,11 +533,12 @@ void qTabAdvanced::SetROI() {
roi.xmax = spinXmax->value();
// set roi
FILE_LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax << "]";
FILE_LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax
<< "]";
try {
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
GetROI();
@ -509,7 +552,8 @@ void qTabAdvanced::GetAllTrimbits() {
try {
int retval = det->getAllTrimbits().squash(-1);
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,
SLOT(SetAllTrimbits()));
@ -521,7 +565,8 @@ void qTabAdvanced::SetAllTrimbits() {
try {
det->setAllTrimbits(value);
} CATCH_HANDLE("Could not set all trimbits.", "qTabAdvanced::SetAllTrimbits",
}
CATCH_HANDLE("Could not set all trimbits.", "qTabAdvanced::SetAllTrimbits",
this, &qTabAdvanced::GetAllTrimbits)
}
@ -531,11 +576,12 @@ void qTabAdvanced::GetNumStoragecells() {
SLOT(SetNumStoragecells(int)));
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);
} CATCH_DISPLAY (
"Could not get number of additional storage cells.",
"qTabAdvanced::GetNumStoragecells")
}
CATCH_DISPLAY("Could not get number of additional storage cells.",
"qTabAdvanced::GetNumStoragecells")
connect(spinNumStoragecells, SIGNAL(valueChanged(int)), this,
SLOT(SetNumStoragecells(int)));
@ -546,10 +592,10 @@ void qTabAdvanced::SetNumStoragecells(int value) {
<< value;
try {
det->setNumberOfAdditionalStorageCells(value);
} CATCH_HANDLE (
"Could not set number of additional storage cells.",
"qTabAdvanced::SetNumStoragecells", this,
&qTabAdvanced::GetNumStoragecells)
}
CATCH_HANDLE("Could not set number of additional storage cells.",
"qTabAdvanced::SetNumStoragecells", this,
&qTabAdvanced::GetNumStoragecells)
}
void qTabAdvanced::GetSubExposureTime() {
@ -559,13 +605,14 @@ void qTabAdvanced::GetSubExposureTime() {
disconnect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSubExposureTime()));
try {
auto retval =
det->getSubExptime().tsquash("Subexptime is inconsistent for all detectors.");
auto retval = det->getSubExptime().tsquash(
"Subexptime is inconsistent for all detectors.");
auto time = qDefs::getUserFriendlyTime(retval);
spinSubExpTime->setValue(time.first);
comboSubExpTimeUnit->setCurrentIndex(static_cast<int>(time.second));
} CATCH_DISPLAY ("Could not get sub exposure time.",
"qTabSettings::GetSubExposureTime")
}
CATCH_DISPLAY("Could not get sub exposure time.",
"qTabSettings::GetSubExposureTime")
connect(spinSubExpTime, SIGNAL(valueChanged(double)), this,
SLOT(SetSubExposureTime()));
connect(comboSubExpTimeUnit, SIGNAL(currentIndexChanged(int)), this,
@ -573,7 +620,9 @@ void qTabAdvanced::GetSubExposureTime() {
}
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)
<< "Setting sub frame acquisition time to " << timeNS.count() << " ns"
<< "/" << spinSubExpTime->value()
@ -581,8 +630,9 @@ void qTabAdvanced::SetSubExposureTime() {
(qDefs::timeUnit)comboSubExpTimeUnit->currentIndex());
try {
det->setSubExptime(timeNS);
} CATCH_DISPLAY ("Could not set sub exposure time.",
"qTabAdvanced::SetSubExposureTime")
}
CATCH_DISPLAY("Could not set sub exposure time.",
"qTabAdvanced::SetSubExposureTime")
GetSubExposureTime();
}
@ -594,13 +644,14 @@ void qTabAdvanced::GetSubDeadTime() {
disconnect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSubDeadTime()));
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);
spinSubDeadTime->setValue(time.first);
comboSubDeadTimeUnit->setCurrentIndex(
static_cast<int>(time.second));
} CATCH_DISPLAY ("Could not get sub dead time.",
"qTabSettings::GetSubDeadTime")
comboSubDeadTimeUnit->setCurrentIndex(static_cast<int>(time.second));
}
CATCH_DISPLAY("Could not get sub dead time.",
"qTabSettings::GetSubDeadTime")
connect(spinSubDeadTime, SIGNAL(valueChanged(double)), this,
SLOT(SetSubDeadTime()));
connect(comboSubDeadTimeUnit, SIGNAL(currentIndexChanged(int)), this,
@ -608,7 +659,9 @@ void qTabAdvanced::GetSubDeadTime() {
}
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)
<< "Setting sub frame dead time to " << timeNS.count() << " ns"
@ -617,8 +670,9 @@ void qTabAdvanced::SetSubDeadTime() {
(qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex());
try {
det->setSubDeadTime(timeNS);
} CATCH_DISPLAY ("Could not set sub dead time.",
"qTabAdvanced::SetSubDeadTime")
}
CATCH_DISPLAY("Could not set sub dead time.",
"qTabAdvanced::SetSubDeadTime")
GetSubDeadTime();
}

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

@ -1,342 +1,431 @@
#include "qTabDataOutput.h"
#include "qDefs.h"
#include <QButtonGroup>
#include <QFileDialog>
#include <QStandardItemModel>
#include <QButtonGroup>
#include <QString>
#include <iostream>
#include <string>
qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector) : QWidget(parent), det(detector), btnGroupRate(nullptr) {
setupUi(this);
SetupWidgetWindow();
FILE_LOG(logDEBUG) << "DataOutput ready";
qTabDataOutput::qTabDataOutput(QWidget *parent, sls::Detector *detector)
: QWidget(parent), det(detector), btnGroupRate(nullptr) {
setupUi(this);
SetupWidgetWindow();
FILE_LOG(logDEBUG) << "DataOutput ready";
}
qTabDataOutput::~qTabDataOutput() {
delete btnGroupRate;
}
qTabDataOutput::~qTabDataOutput() { delete btnGroupRate; }
void qTabDataOutput::SetupWidgetWindow() {
// button group for rate
btnGroupRate = new QButtonGroup(this);
btnGroupRate->addButton(radioDefaultDeadtime, 0);
btnGroupRate->addButton(radioCustomDeadtime, 1);
// button group for rate
btnGroupRate = new QButtonGroup(this);
btnGroupRate->addButton(radioDefaultDeadtime, 0);
btnGroupRate->addButton(radioCustomDeadtime, 1);
// enabling according to det type
switch(det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER:
chkTenGiga->setEnabled(true);
chkRate->setEnabled(true);
radioDefaultDeadtime->setEnabled(true);
radioCustomDeadtime->setEnabled(true);
// flags and speed
widgetEiger->setVisible(true);
widgetEiger->setEnabled(true);
break;
case slsDetectorDefs::MOENCH:
chkTenGiga->setEnabled(true);
break;
default:
break;
}
PopulateDetectors();
// enabling according to det type
switch (det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER:
chkTenGiga->setEnabled(true);
chkRate->setEnabled(true);
radioDefaultDeadtime->setEnabled(true);
radioCustomDeadtime->setEnabled(true);
// flags and speed
widgetEiger->setVisible(true);
widgetEiger->setEnabled(true);
break;
case slsDetectorDefs::MOENCH:
chkTenGiga->setEnabled(true);
break;
default:
break;
}
PopulateDetectors();
Initialization();
Initialization();
Refresh();
Refresh();
}
void qTabDataOutput::Initialization() {
// ourdir, fileformat, overwrite enable
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this, SLOT(GetOutputDir()));
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(BrowseOutputDir()));
connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int)));
connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool)));
if (chkTenGiga->isEnabled()) {
connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool)));
}
// rate
if (chkRate->isEnabled()) {
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection()));
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
}
// flags, speed
if (widgetEiger->isEnabled()) {
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int)));
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
}
// ourdir, fileformat, overwrite enable
connect(comboDetector, SIGNAL(currentIndexChanged(int)), this,
SLOT(GetOutputDir()));
connect(dispOutputDir, SIGNAL(editingFinished()), this,
SLOT(SetOutputDir()));
connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(BrowseOutputDir()));
connect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFileFormat(int)));
connect(chkOverwriteEnable, SIGNAL(toggled(bool)), this,
SLOT(SetOverwriteEnable(bool)));
if (chkTenGiga->isEnabled()) {
connect(chkTenGiga, SIGNAL(toggled(bool)), this,
SLOT(SetTenGigaEnable(bool)));
}
// rate
if (chkRate->isEnabled()) {
connect(chkRate, SIGNAL(toggled(bool)), this,
SLOT(EnableRateCorrection()));
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this,
SLOT(SetRateCorrection()));
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this,
SLOT(SetRateCorrection()));
}
// flags, speed
if (widgetEiger->isEnabled()) {
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSpeed(int)));
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFlags()));
}
}
void qTabDataOutput::PopulateDetectors() {
FILE_LOG(logDEBUG) << "Populating detectors";
FILE_LOG(logDEBUG) << "Populating detectors";
comboDetector->clear();
comboDetector->addItem("All");
if (det->size() > 1) {
auto res = det->getHostname();
for (auto &it : res) {
comboDetector->addItem(QString(it.c_str()));
}
}
comboDetector->clear();
comboDetector->addItem("All");
if (det->size() > 1) {
auto res = det->getHostname();
for (auto &it : res) {
comboDetector->addItem(QString(it.c_str()));
}
}
}
void qTabDataOutput::EnableBrowse() {
FILE_LOG(logDEBUG) << "Getting browse enable";
try {
btnOutputBrowse->setEnabled(false); // exception default
std::string rxHostname = det->getRxHostname({comboDetector->currentIndex() - 1}).squash("none");
if (rxHostname == "none") {
btnOutputBrowse->setEnabled(false);
} else if (rxHostname == "localhost") {
btnOutputBrowse->setEnabled(true);
} else {
std::string hostname;
const size_t len = 15;
char host[len]{};
if (gethostname(host, len) == 0) {
hostname.assign(host);
}
// client pc (hostname) same as reciever hostname
if (hostname == rxHostname) {
btnOutputBrowse->setEnabled(true);
} else {
btnOutputBrowse->setEnabled(false);
}
}
} CATCH_DISPLAY ("Could not get receiver hostname.", "qTabDataOutput::EnableBrowse")
FILE_LOG(logDEBUG) << "Getting browse enable";
try {
btnOutputBrowse->setEnabled(false); // exception default
std::string rxHostname =
det->getRxHostname({comboDetector->currentIndex() - 1})
.squash("none");
if (rxHostname == "none") {
btnOutputBrowse->setEnabled(false);
} else if (rxHostname == "localhost") {
btnOutputBrowse->setEnabled(true);
} else {
std::string hostname;
const size_t len = 15;
char host[len]{};
if (gethostname(host, len) == 0) {
hostname.assign(host);
}
// client pc (hostname) same as reciever hostname
if (hostname == rxHostname) {
btnOutputBrowse->setEnabled(true);
} else {
btnOutputBrowse->setEnabled(false);
}
}
}
CATCH_DISPLAY("Could not get receiver hostname.",
"qTabDataOutput::EnableBrowse")
}
void qTabDataOutput::GetFileWrite() {
FILE_LOG(logDEBUG) << "Getting file write enable";
try {
boxFileWriteEnabled->setEnabled(true); // exception default
auto retval = det->getFileWrite().tsquash("File write is inconsistent for all detectors.");
boxFileWriteEnabled->setEnabled(retval);
} CATCH_DISPLAY("Could not get file enable.", "qTabDataOutput::GetFileWrite")
FILE_LOG(logDEBUG) << "Getting file write enable";
try {
boxFileWriteEnabled->setEnabled(true); // exception default
auto retval = det->getFileWrite().tsquash(
"File write is inconsistent for all detectors.");
boxFileWriteEnabled->setEnabled(retval);
}
CATCH_DISPLAY("Could not get file enable.", "qTabDataOutput::GetFileWrite")
}
void qTabDataOutput::GetFileName() {
FILE_LOG(logDEBUG) << "Getting file name";
try {
auto retval = det->getFileNamePrefix().tsquash("File name is inconsistent for all detectors.");
dispFileName->setText(QString(retval.c_str()));
} CATCH_DISPLAY ("Could not get file name prefix.", "qTabDataOutput::GetFileName")
FILE_LOG(logDEBUG) << "Getting file name";
try {
auto retval = det->getFileNamePrefix().tsquash(
"File name is inconsistent for all detectors.");
dispFileName->setText(QString(retval.c_str()));
}
CATCH_DISPLAY("Could not get file name prefix.",
"qTabDataOutput::GetFileName")
}
void qTabDataOutput::GetOutputDir() {
FILE_LOG(logDEBUG) << "Getting file path";
disconnect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
try {
std::string path = det->getFilePath({comboDetector->currentIndex() - 1}).tsquash("File path is different for all detectors.");
dispOutputDir->setText(QString(path.c_str()));
} CATCH_DISPLAY ("Could not get file path.", "qTabDataOutput::GetOutputDir")
connect(dispOutputDir, SIGNAL(editingFinished()), this, SLOT(SetOutputDir()));
FILE_LOG(logDEBUG) << "Getting file path";
disconnect(dispOutputDir, SIGNAL(editingFinished()), this,
SLOT(SetOutputDir()));
try {
std::string path =
det->getFilePath({comboDetector->currentIndex() - 1})
.tsquash("File path is different for all detectors.");
dispOutputDir->setText(QString(path.c_str()));
}
CATCH_DISPLAY("Could not get file path.", "qTabDataOutput::GetOutputDir")
connect(dispOutputDir, SIGNAL(editingFinished()), this,
SLOT(SetOutputDir()));
}
void qTabDataOutput::BrowseOutputDir() {
FILE_LOG(logDEBUG) << "Browsing output directory";
QString directory = QFileDialog::getExistingDirectory(this, tr("Choose Output Directory "), dispOutputDir->text());
if (!directory.isEmpty())
dispOutputDir->setText(directory);
FILE_LOG(logDEBUG) << "Browsing output directory";
QString directory = QFileDialog::getExistingDirectory(
this, tr("Choose Output Directory "), dispOutputDir->text());
if (!directory.isEmpty())
dispOutputDir->setText(directory);
}
void qTabDataOutput::SetOutputDir() {
QString path = dispOutputDir->text();
FILE_LOG(logDEBUG) << "Setting output directory to " << path.toAscii().constData();
QString path = dispOutputDir->text();
FILE_LOG(logDEBUG) << "Setting output directory to "
<< path.toAscii().constData();
// empty
if (path.isEmpty()) {
qDefs::Message(qDefs::WARNING, "Invalid Output Path. Must not be empty.", "qTabDataOutput::SetOutputDir");
FILE_LOG(logWARNING) << "Invalid Output Path. Must not be empty.";
GetOutputDir();
} else {
// chop off trailing '/'
if (path.endsWith('/')) {
while (path.endsWith('/')) {
path.chop(1);
}
}
std::string spath = std::string(path.toAscii().constData());
try {
det->setFilePath(spath, {comboDetector->currentIndex() - 1});
} CATCH_HANDLE ("Could not set output file path.", "qTabDataOutput::SetOutputDir", this, &qTabDataOutput::GetOutputDir)
}
// empty
if (path.isEmpty()) {
qDefs::Message(qDefs::WARNING,
"Invalid Output Path. Must not be empty.",
"qTabDataOutput::SetOutputDir");
FILE_LOG(logWARNING) << "Invalid Output Path. Must not be empty.";
GetOutputDir();
} else {
// chop off trailing '/'
if (path.endsWith('/')) {
while (path.endsWith('/')) {
path.chop(1);
}
}
std::string spath = std::string(path.toAscii().constData());
try {
det->setFilePath(spath, {comboDetector->currentIndex() - 1});
}
CATCH_HANDLE("Could not set output file path.",
"qTabDataOutput::SetOutputDir", this,
&qTabDataOutput::GetOutputDir)
}
}
void qTabDataOutput::GetFileFormat() {
FILE_LOG(logDEBUG) << "Getting File Format";
disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFileFormat(int)));
try {
auto retval = det->getFileFormat().tsquash("File format is inconsistent for all detectors.");
switch(retval) {
case slsDetectorDefs::BINARY:
case slsDetectorDefs::HDF5:
comboFileFormat->setCurrentIndex(static_cast<int>(retval));
break;
default:
throw sls::RuntimeError(std::string("Unknown file format: ") + std::to_string(static_cast<int>(retval)));
FILE_LOG(logDEBUG) << "Getting File Format";
disconnect(comboFileFormat, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFileFormat(int)));
try {
auto retval = det->getFileFormat().tsquash(
"File format is inconsistent for all detectors.");
switch (retval) {
case slsDetectorDefs::BINARY:
case slsDetectorDefs::HDF5:
comboFileFormat->setCurrentIndex(static_cast<int>(retval));
break;
default:
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) {
FILE_LOG(logINFO) << "Setting File Format to " << comboFileFormat->currentText().toAscii().data();
try {
det->setFileFormat(static_cast<slsDetectorDefs::fileFormat>(comboFileFormat->currentIndex()));
} CATCH_HANDLE ("Could not set file format.", "qTabDataOutput::SetFileFormat", this, &qTabDataOutput::GetFileFormat)
FILE_LOG(logINFO) << "Setting File Format to "
<< comboFileFormat->currentText().toAscii().data();
try {
det->setFileFormat(static_cast<slsDetectorDefs::fileFormat>(
comboFileFormat->currentIndex()));
}
CATCH_HANDLE("Could not set file format.", "qTabDataOutput::SetFileFormat",
this, &qTabDataOutput::GetFileFormat)
}
void qTabDataOutput::GetFileOverwrite() {
FILE_LOG(logDEBUG) << "Getting File Over Write Enable";
disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this, SLOT(SetOverwriteEnable(bool)));
try {
auto retval = det->getFileOverWrite().tsquash("File over write is inconsistent for all detectors.");
chkOverwriteEnable->setChecked(retval);
} CATCH_DISPLAY ("Could not get file over write enable.", "qTabDataOutput::GetFileOverwrite")
FILE_LOG(logDEBUG) << "Getting File Over Write Enable";
disconnect(chkOverwriteEnable, SIGNAL(toggled(bool)), this,
SLOT(SetOverwriteEnable(bool)));
try {
auto retval = det->getFileOverWrite().tsquash(
"File over write is inconsistent for all detectors.");
chkOverwriteEnable->setChecked(retval);
}
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) {
FILE_LOG(logINFO) << "Setting File Over Write Enable to " << enable;
try {
FILE_LOG(logINFO) << "Setting File Over Write Enable to " << enable;
try {
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() {
FILE_LOG(logDEBUG) << "Getting 10GbE enable";
disconnect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool)));
try {
auto retval = det->getTenGiga().tsquash("10GbE enable is inconsistent for all detectors.");
chkTenGiga->setChecked(retval);
} CATCH_DISPLAY ("Could not get 10GbE enable.", "qTabDataOutput::GetTenGigaEnable")
connect(chkTenGiga, SIGNAL(toggled(bool)), this, SLOT(SetTenGigaEnable(bool)));
FILE_LOG(logDEBUG) << "Getting 10GbE enable";
disconnect(chkTenGiga, SIGNAL(toggled(bool)), this,
SLOT(SetTenGigaEnable(bool)));
try {
auto retval = det->getTenGiga().tsquash(
"10GbE enable is inconsistent for all detectors.");
chkTenGiga->setChecked(retval);
}
CATCH_DISPLAY("Could not get 10GbE enable.",
"qTabDataOutput::GetTenGigaEnable")
connect(chkTenGiga, SIGNAL(toggled(bool)), this,
SLOT(SetTenGigaEnable(bool)));
}
void qTabDataOutput::SetTenGigaEnable(bool enable) {
FILE_LOG(logINFO) << "Setting 10GbE to " << enable;
try {
FILE_LOG(logINFO) << "Setting 10GbE to " << enable;
try {
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() {
FILE_LOG(logDEBUG) << "Getting Rate Correction";
disconnect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
disconnect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection()));
disconnect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
try {
spinCustomDeadTime->setValue(-1);
int64_t retval = det->getRateCorrection().tsquash("Rate correction (enable/tau) is inconsistent for all detectors.").count();
chkRate->setChecked(retval == 0 ? false : true);
if (retval != 0)
spinCustomDeadTime->setValue(retval);
} CATCH_DISPLAY("Could not get rate correction.", "qTabDataOutput::GetRateCorrection")
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this, SLOT(SetRateCorrection()));
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this, SLOT(SetRateCorrection()));
FILE_LOG(logDEBUG) << "Getting Rate Correction";
disconnect(chkRate, SIGNAL(toggled(bool)), this,
SLOT(EnableRateCorrection()));
disconnect(btnGroupRate, SIGNAL(buttonClicked(int)), this,
SLOT(SetRateCorrection()));
disconnect(spinCustomDeadTime, SIGNAL(editingFinished()), this,
SLOT(SetRateCorrection()));
try {
spinCustomDeadTime->setValue(-1);
int64_t retval = det->getRateCorrection()
.tsquash("Rate correction (enable/tau) is "
"inconsistent for all detectors.")
.count();
chkRate->setChecked(retval == 0 ? false : true);
if (retval != 0)
spinCustomDeadTime->setValue(retval);
}
CATCH_DISPLAY("Could not get rate correction.",
"qTabDataOutput::GetRateCorrection")
connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(EnableRateCorrection()));
connect(btnGroupRate, SIGNAL(buttonClicked(int)), this,
SLOT(SetRateCorrection()));
connect(spinCustomDeadTime, SIGNAL(editingFinished()), this,
SLOT(SetRateCorrection()));
}
void qTabDataOutput::EnableRateCorrection() {
// enable
if (chkRate->isChecked()) {
SetRateCorrection();
return;
}
FILE_LOG(logINFO) << "Disabling Rate correction";
// disable
try {
det->setRateCorrection(sls::ns(0));
} CATCH_HANDLE ("Could not switch off rate correction.", "qTabDataOutput::EnableRateCorrection", this, &qTabDataOutput::GetRateCorrection)
// enable
if (chkRate->isChecked()) {
SetRateCorrection();
return;
}
FILE_LOG(logINFO) << "Disabling Rate correction";
// disable
try {
det->setRateCorrection(sls::ns(0));
}
CATCH_HANDLE("Could not switch off rate correction.",
"qTabDataOutput::EnableRateCorrection", this,
&qTabDataOutput::GetRateCorrection)
}
void qTabDataOutput::SetRateCorrection() {
// do nothing if rate correction is disabled
if (!chkRate->isChecked()) {
return;
}
try {
// custom dead time
if (radioCustomDeadtime->isChecked()) {
int64_t deadtime = spinCustomDeadTime->value();
FILE_LOG(logINFO) << "Setting Rate Correction with custom dead time: " << deadtime;
det->setRateCorrection(sls::ns(deadtime));
}
// default dead time
else {
FILE_LOG(logINFO) << "Setting Rate Correction with default dead time";
det->setDefaultRateCorrection();
}
} CATCH_HANDLE ("Could not set rate correction.", "qTabDataOutput::SetRateCorrection", this, &qTabDataOutput::GetRateCorrection)
// do nothing if rate correction is disabled
if (!chkRate->isChecked()) {
return;
}
try {
// custom dead time
if (radioCustomDeadtime->isChecked()) {
int64_t deadtime = spinCustomDeadTime->value();
FILE_LOG(logINFO)
<< "Setting Rate Correction with custom dead time: "
<< deadtime;
det->setRateCorrection(sls::ns(deadtime));
}
// default dead time
else {
FILE_LOG(logINFO)
<< "Setting Rate Correction with default dead time";
det->setDefaultRateCorrection();
}
}
CATCH_HANDLE("Could not set rate correction.",
"qTabDataOutput::SetRateCorrection", this,
&qTabDataOutput::GetRateCorrection)
}
void qTabDataOutput::GetSpeed() {
FILE_LOG(logDEBUG) << "Getting Speed";
disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int)));
try {
auto retval = det->getSpeed().tsquash("Speed is inconsistent for all detectors.");
comboEigerClkDivider->setCurrentIndex(static_cast<int>(retval));
} CATCH_DISPLAY ("Could not get speed.", "qTabDataOutput::GetSpeed")
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSpeed(int)));
FILE_LOG(logDEBUG) << "Getting Speed";
disconnect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSpeed(int)));
try {
auto retval =
det->getSpeed().tsquash("Speed is inconsistent for all detectors.");
comboEigerClkDivider->setCurrentIndex(static_cast<int>(retval));
}
CATCH_DISPLAY("Could not get speed.", "qTabDataOutput::GetSpeed")
connect(comboEigerClkDivider, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSpeed(int)));
}
void qTabDataOutput::SetSpeed(int speed) {
FILE_LOG(logINFO) << "Setting Speed to " << comboEigerClkDivider->currentText().toAscii().data();;
try {
FILE_LOG(logINFO) << "Setting Speed to "
<< comboEigerClkDivider->currentText().toAscii().data();
;
try {
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() {
FILE_LOG(logDEBUG) << "Getting readout flags";
disconnect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
try {
auto retval = det->getParallelMode().tsquash("Parallel Flag is inconsistent for all detectors.");
// parallel or non parallel
if (retval)
comboEigerParallelFlag->setCurrentIndex(PARALLEL);
else
comboEigerParallelFlag->setCurrentIndex(NONPARALLEL);
} CATCH_DISPLAY ("Could not get flags.", "qTabDataOutput::GetFlags")
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFlags()));
FILE_LOG(logDEBUG) << "Getting readout flags";
disconnect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFlags()));
try {
auto retval = det->getParallelMode().tsquash(
"Parallel Flag is inconsistent for all detectors.");
// parallel or non parallel
if (retval)
comboEigerParallelFlag->setCurrentIndex(PARALLEL);
else
comboEigerParallelFlag->setCurrentIndex(NONPARALLEL);
}
CATCH_DISPLAY("Could not get flags.", "qTabDataOutput::GetFlags")
connect(comboEigerParallelFlag, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetFlags()));
}
void qTabDataOutput::SetFlags() {
auto mode = comboEigerParallelFlag->currentIndex() == PARALLEL ? true : false;
try {
FILE_LOG(logINFO) << "Setting Readout Flags to " << comboEigerParallelFlag->currentText().toAscii().data();
det->setParallelMode(mode);
} CATCH_HANDLE ("Could not set readout flags.", "qTabDataOutput::SetFlags", this, &qTabDataOutput::GetFlags)
auto mode =
comboEigerParallelFlag->currentIndex() == PARALLEL ? true : false;
try {
FILE_LOG(logINFO)
<< "Setting Readout Flags to "
<< comboEigerParallelFlag->currentText().toAscii().data();
det->setParallelMode(mode);
}
CATCH_HANDLE("Could not set readout flags.", "qTabDataOutput::SetFlags",
this, &qTabDataOutput::GetFlags)
}
void qTabDataOutput::Refresh() {
FILE_LOG(logDEBUG) << "**Updating DataOutput Tab";
FILE_LOG(logDEBUG) << "**Updating DataOutput Tab";
EnableBrowse();
GetFileWrite();
GetFileName();
GetOutputDir();
GetFileOverwrite();
GetFileFormat();
if (chkRate->isEnabled()) {
GetRateCorrection();
}
if (chkTenGiga->isEnabled()) {
GetTenGigaEnable();
}
if (widgetEiger->isEnabled()) {
GetSpeed();
GetFlags();
}
EnableBrowse();
GetFileWrite();
GetFileName();
GetOutputDir();
GetFileOverwrite();
GetFileFormat();
if (chkRate->isEnabled()) {
GetRateCorrection();
}
if (chkTenGiga->isEnabled()) {
GetTenGigaEnable();
}
if (widgetEiger->isEnabled()) {
GetSpeed();
GetFlags();
}
FILE_LOG(logDEBUG) << "**Updated DataOutput Tab";
FILE_LOG(logDEBUG) << "**Updated DataOutput Tab";
}

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

@ -9,23 +9,24 @@
#include <iostream>
qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector) :
QWidget(parent), det(detector), treeDet(nullptr), lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr), lblDetectorSoftware(nullptr) {
qTabDebugging::qTabDebugging(QWidget *parent, sls::Detector *detector)
: QWidget(parent), det(detector), treeDet(nullptr),
lblDetectorHostname(nullptr), lblDetectorFirmware(nullptr),
lblDetectorSoftware(nullptr) {
setupUi(this);
SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Debugging ready";
}
qTabDebugging::~qTabDebugging() {
delete treeDet;
delete lblDetectorHostname;
delete lblDetectorFirmware;
delete lblDetectorSoftware;
delete treeDet;
delete lblDetectorHostname;
delete lblDetectorFirmware;
delete lblDetectorSoftware;
}
void qTabDebugging::SetupWidgetWindow() {
// enabling according to det type
// enabling according to det type
if (det->getDetectorType().squash() == slsDetectorDefs::EIGER) {
lblDetector->setText("Half Module:");
chkDetectorFirmware->setEnabled(false);
@ -40,19 +41,19 @@ void qTabDebugging::SetupWidgetWindow() {
Refresh();
}
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()));
if (btnTest ->isEnabled()) {
connect(btnTest, SIGNAL(clicked()), this, SLOT(TestDetector()));
if (btnTest->isEnabled()) {
connect(btnTest, SIGNAL(clicked()), this, SLOT(TestDetector()));
}
}
void qTabDebugging::PopulateDetectors() {
FILE_LOG(logDEBUG) << "Populating detectors";
FILE_LOG(logDEBUG) << "Populating detectors";
comboDetector->clear();
comboDetector->clear();
auto res = det->getHostname();
for (auto &it : res) {
comboDetector->addItem(QString(it.c_str()));
@ -62,13 +63,15 @@ void qTabDebugging::PopulateDetectors() {
void qTabDebugging::GetDetectorStatus() {
FILE_LOG(logDEBUG) << "Getting Status";
try {
std::string status = sls::ToString(det->getDetectorStatus({comboDetector->currentIndex()})[0]);
try {
std::string status = sls::ToString(
det->getDetectorStatus({comboDetector->currentIndex()})[0]);
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() {
FILE_LOG(logDEBUG) << "Getting Readout Info";
@ -83,67 +86,83 @@ void qTabDebugging::GetInfo() {
lblDetectorHostname = new QLabel("");
lblDetectorFirmware = new QLabel("");
lblDetectorSoftware = new QLabel("");
//to make sure the size is constant
// to make sure the size is constant
lblDetectorFirmware->setFixedWidth(100);
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()) {
case slsDetectorDefs::EIGER:
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(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(new QLabel("Half Module Software Version:"), 2, 0);
formLayout->addWidget(new QLabel("Half Module Software Version:"), 2,
0);
formLayout->addWidget(lblDetectorSoftware, 2, 2);
treeDet->setHeaderLabel("Eiger Detector");
//get num modules
// get num modules
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);
//gets det names
// gets det names
for (int i = 0; i < comboDetector->count(); ++i) {
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);
}
break;
default:
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(new QLabel("Module Firmware Version:"), 1, 0);
formLayout->addWidget(lblDetectorFirmware, 1, 2);
formLayout->addWidget(new QLabel("Module Software Version:"), 2, 0);
formLayout->addWidget(lblDetectorSoftware, 2, 2);
treeDet->setHeaderLabel(QString(detName + " Detector"));
//gets det names
// gets det names
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);
break;
}
//show and center widget
// show and center widget
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();
int screen = desktop->screenNumber(this);
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();
//put the first parameters
// put the first parameters
SetParameters(treeDet->topLevelItem(0));
// 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) {
// eiger: if half module clicked, others: true always
bool ignoreOrHalfModuleClicked = true;
@ -160,11 +179,17 @@ void qTabDebugging::SetParameters(QTreeWidgetItem *item) {
break;
}
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()));
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()));
} 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
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()) {
try {
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";
} 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()) {
try {
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";
} CATCH_DISPLAY ("Bus test failed.", "qTabDebugging::TestDetector")
}
CATCH_DISPLAY("Bus test failed.", "qTabDebugging::TestDetector")
}
//display message
qDefs::Message(qDefs::INFORMATION, message.toAscii().constData(), "qTabDebugging::TestDetector");
} CATCH_DISPLAY ("Could not execute digital test.", "qTabDebugging::TestDetector")
// display message
qDefs::Message(qDefs::INFORMATION, message.toAscii().constData(),
"qTabDebugging::TestDetector");
}
CATCH_DISPLAY("Could not execute digital test.",
"qTabDebugging::TestDetector")
}
void qTabDebugging::Refresh() {
FILE_LOG(logDEBUG) << "**Updating Debugging Tab";
GetDetectorStatus();
FILE_LOG(logDEBUG) << "**Updated Debugging Tab";
}

976
slsDetectorGui/src/qTabDeveloper.cpp Executable file → Normal file

File diff suppressed because it is too large Load Diff

1209
slsDetectorGui/src/qTabMeasurement.cpp Executable file → Normal file

File diff suppressed because it is too large Load Diff

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

@ -1,12 +1,12 @@
#include "qTabMessages.h"
#include "qDefs.h"
#include <QDir>
#include <QFile>
#include <QFileDialog>
#include <QTextStream>
#include <QDir>
#include <QProcess>
#include <QKeyEvent>
#include <QProcess>
#include <QTextStream>
#include <iostream>
#include <string>
@ -37,32 +37,32 @@ void qTabMessages::Initialization() {
connect(dispCommand, SIGNAL(returnPressed()), this, SLOT(ExecuteCommand()));
}
void qTabMessages::keyPressEvent(QKeyEvent* event) {
//cout<<"inside KeyPressEvent()\n";
if (event->key() == Qt::Key_Up) {
void qTabMessages::keyPressEvent(QKeyEvent *event) {
// cout<<"inside KeyPressEvent()\n";
if (event->key() == Qt::Key_Up) {
GetLastCommand();
}
else if (event->key() == Qt::Key_Down) {
} else if (event->key() == Qt::Key_Down) {
ClearCommand();
}
/* else if((event->key() == Qt::Key_Return) ||(event->key() == Qt::Key_Enter)) {
ExecuteCommand();
}*/ else {
event->ignore();
}
/* else if((event->key() == Qt::Key_Return) ||(event->key() ==
Qt::Key_Enter)) { ExecuteCommand();
}*/
else {
event->ignore();
}
}
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() {
dispCommand->setText(lastCommand.join(" "));
dispCommand->setText(lastCommand.join(" "));
}
void qTabMessages::ClearCommand() {
dispCommand->setText("");
}
void qTabMessages::ClearCommand() { dispCommand->setText(""); }
void qTabMessages::ExecuteCommand() {
QStringList param = dispCommand->text().split(" ");
@ -70,16 +70,19 @@ void qTabMessages::ExecuteCommand() {
lastCommand += param;
dispCommand->clear();
// appending command to log without newline
dispLog->moveCursor (QTextCursor::End);
dispLog->insertHtml(QString("<font color = \"DarkBlue\">") + param.join(" ") + QString("</font>"));
dispLog->moveCursor(QTextCursor::End);
dispLog->insertHtml(QString("<font color = \"DarkBlue\">") +
param.join(" ") + QString("</font>"));
QString command = param.at(0);
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->start(command, param);
if(!process->waitForFinished()) {
if (!process->waitForFinished()) {
AppendError();
} else {
AppendOutput();
@ -89,34 +92,40 @@ void qTabMessages::ExecuteCommand() {
void qTabMessages::AppendOutput() {
QByteArray result = process->readAll();
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";
PrintNextLine();
}
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";
PrintNextLine();
}
void qTabMessages::SaveLog() {
QString fName = QDir::cleanPath(QDir::currentPath()) + "/LogFile.txt";
fName = QFileDialog::getSaveFileName(this, tr("Save Snapshot "),
fName, tr("Text files (*.txt);;All Files(*)"));
fName =
QFileDialog::getSaveFileName(this, tr("Save Snapshot "), fName,
tr("Text files (*.txt);;All Files(*)"));
if (!fName.isEmpty()) {
QFile outfile;
outfile.setFileName(fName);
if (outfile.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream out(&outfile);
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");
FILE_LOG(logINFO) << mess;
} else {
FILE_LOG(logWARNING) << "Attempt to save log file failed: " << fName.toAscii().constData();
qDefs::Message(qDefs::WARNING, "Attempt to save log file failed.", "qTabMessages::SaveLog");
FILE_LOG(logWARNING) << "Attempt to save log file failed: "
<< fName.toAscii().constData();
qDefs::Message(qDefs::WARNING, "Attempt to save log file failed.",
"qTabMessages::SaveLog");
}
}
dispCommand->setFocus();
@ -133,4 +142,3 @@ void qTabMessages::Refresh() {
dispCommand->clear();
dispCommand->setFocus();
}

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

@ -2,10 +2,10 @@
#include "qDefs.h"
#include "qDrawPlot.h"
#include <QStandardItemModel>
#include <QStackedLayout>
#include <QButtonGroup>
#include <QAbstractButton>
#include <QButtonGroup>
#include <QStackedLayout>
#include <QStandardItemModel>
#include <iostream>
#include <math.h>
@ -18,17 +18,14 @@ QString qTabPlot::defaultImageXAxisTitle("Pixel");
QString qTabPlot::defaultImageYAxisTitle("Pixel");
QString qTabPlot::defaultImageZAxisTitle("Intensity");
qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p) :
QWidget(parent), det(detector), plot(p), is1d(false) {
qTabPlot::qTabPlot(QWidget *parent, sls::Detector *detector, qDrawPlot *p)
: QWidget(parent), det(detector), plot(p), is1d(false) {
setupUi(this);
SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Plot ready";
}
qTabPlot::~qTabPlot() {
delete btnGroupPlotType;
}
qTabPlot::~qTabPlot() { delete btnGroupPlotType; }
void qTabPlot::SetupWidgetWindow() {
// button group for plot type
@ -56,27 +53,27 @@ void qTabPlot::SetupWidgetWindow() {
// enabling according to det type
is1d = false;
switch(det->getDetectorType().squash()) {
case slsDetectorDefs::GOTTHARD:
case slsDetectorDefs::MYTHEN3:
is1d = true;
break;
case slsDetectorDefs::GOTTHARD2:
is1d = true;
chkGainPlot1D->setEnabled(true);
chkGainPlot1D->setChecked(true);
plot->EnableGainPlot(true);
break;
case slsDetectorDefs::EIGER:
chkGapPixels->setEnabled(true);
break;
case slsDetectorDefs::JUNGFRAU:
chkGainPlot->setEnabled(true);
chkGainPlot->setChecked(true);
plot->EnableGainPlot(true);
break;
default:
break;
switch (det->getDetectorType().squash()) {
case slsDetectorDefs::GOTTHARD:
case slsDetectorDefs::MYTHEN3:
is1d = true;
break;
case slsDetectorDefs::GOTTHARD2:
is1d = true;
chkGainPlot1D->setEnabled(true);
chkGainPlot1D->setChecked(true);
plot->EnableGainPlot(true);
break;
case slsDetectorDefs::EIGER:
chkGapPixels->setEnabled(true);
break;
case slsDetectorDefs::JUNGFRAU:
chkGainPlot->setEnabled(true);
chkGainPlot->setChecked(true);
plot->EnableGainPlot(true);
break;
default:
break;
}
Select1DPlot(is1d);
@ -86,58 +83,78 @@ void qTabPlot::SetupWidgetWindow() {
void qTabPlot::Initialization() {
// Plot arguments box
connect(btnGroupPlotType, SIGNAL(buttonClicked(int)), this, SLOT(SetPlot()));
connect(btnGroupPlotType, SIGNAL(buttonClicked(int)), this,
SLOT(SetPlot()));
// Plotting frequency box
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetStreamingFrequency()));
connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetStreamingFrequency()));
connect(spinTimeGap, SIGNAL(editingFinished()), this,
SLOT(SetStreamingFrequency()));
connect(spinNthFrame, SIGNAL(editingFinished()), this,
SLOT(SetStreamingFrequency()));
// navigation buttons for options
connect(btnRight1D, SIGNAL(clicked()), this, SLOT(Set1DPlotOptionsRight()));
connect(btnLeft1D, SIGNAL(clicked()), this, SLOT(Set1DPlotOptionsLeft()));
connect(btnRight2D, SIGNAL(clicked()), this, SLOT(Set2DPlotOptionsRight()));
connect(btnLeft2D, SIGNAL(clicked()), this, SLOT(Set2DPlotOptionsLeft()));
// 1D options
connect(chkSuperimpose, SIGNAL(toggled(bool)), this, SLOT(EnablePersistency(bool)));
connect(spinPersistency, SIGNAL(valueChanged(int)), plot, SLOT(SetPersistency(int)));
connect(chkSuperimpose, SIGNAL(toggled(bool)), this,
SLOT(EnablePersistency(bool)));
connect(spinPersistency, SIGNAL(valueChanged(int)), plot,
SLOT(SetPersistency(int)));
connect(chkPoints, SIGNAL(toggled(bool)), plot, SLOT(SetMarkers(bool)));
connect(chkLines, SIGNAL(toggled(bool)), plot, SLOT(SetLines(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
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(chkLogz, SIGNAL(toggled(bool)), plot, SLOT(SetLogz(bool)));
connect(chkStatistics_2, SIGNAL(toggled(bool)), plot, SLOT(DisplayStatistics(bool)));
//pedstal
connect(chkStatistics_2, SIGNAL(toggled(bool)), plot,
SLOT(DisplayStatistics(bool)));
// pedstal
connect(chkPedestal, SIGNAL(toggled(bool)), plot, SLOT(SetPedestal(bool)));
connect(btnRecalPedestal, SIGNAL(clicked()), plot, SLOT(RecalculatePedestal()));
connect(chkPedestal_2, SIGNAL(toggled(bool)), plot, SLOT(SetPedestal(bool)));
connect(btnRecalPedestal_2, SIGNAL(clicked()), plot, SLOT(RecalculatePedestal()));
//accumulate
connect(chkAccumulate, SIGNAL(toggled(bool)), plot, SLOT(SetAccumulate(bool)));
connect(btnResetAccumulate, SIGNAL(clicked()), plot, SLOT(ResetAccumulate()));
connect(chkAccumulate_2, SIGNAL(toggled(bool)), plot, SLOT(SetAccumulate(bool)));
connect(btnResetAccumulate_2, SIGNAL(clicked()), plot, SLOT(ResetAccumulate()));
//binary
connect(btnRecalPedestal, SIGNAL(clicked()), plot,
SLOT(RecalculatePedestal()));
connect(chkPedestal_2, SIGNAL(toggled(bool)), plot,
SLOT(SetPedestal(bool)));
connect(btnRecalPedestal_2, SIGNAL(clicked()), plot,
SLOT(RecalculatePedestal()));
// accumulate
connect(chkAccumulate, SIGNAL(toggled(bool)), plot,
SLOT(SetAccumulate(bool)));
connect(btnResetAccumulate, SIGNAL(clicked()), plot,
SLOT(ResetAccumulate()));
connect(chkAccumulate_2, SIGNAL(toggled(bool)), plot,
SLOT(SetAccumulate(bool)));
connect(btnResetAccumulate_2, SIGNAL(clicked()), plot,
SLOT(ResetAccumulate()));
// binary
connect(chkBinary, SIGNAL(toggled(bool)), this, SLOT(SetBinary()));
connect(chkBinary_2, SIGNAL(toggled(bool)), this, SLOT(SetBinary()));
connect(spinFrom, SIGNAL(valueChanged(int)), this, SLOT(SetBinary()));
connect(spinFrom_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary()));
connect(spinTo, SIGNAL(valueChanged(int)), this, SLOT(SetBinary()));
connect(spinTo_2, SIGNAL(valueChanged(int)), this, SLOT(SetBinary()));
//gainplot
// gainplot
if (chkGainPlot->isEnabled())
connect(chkGainPlot, SIGNAL(toggled(bool)), plot, SLOT(EnableGainPlot(bool)));
connect(chkGainPlot, SIGNAL(toggled(bool)), plot,
SLOT(EnableGainPlot(bool)));
if (chkGainPlot1D->isEnabled())
connect(chkGainPlot1D, SIGNAL(toggled(bool)), plot, SLOT(EnableGainPlot(bool)));
connect(chkGainPlot1D, SIGNAL(toggled(bool)), plot,
SLOT(EnableGainPlot(bool)));
// gap pixels
if (chkGapPixels->isEnabled())
connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool)));
connect(chkGapPixels, SIGNAL(toggled(bool)), this,
SLOT(SetGapPixels(bool)));
// Save, clone
connect(btnSave, SIGNAL(clicked()), plot, SLOT(SavePlot()));
@ -148,10 +165,14 @@ void qTabPlot::Initialization() {
connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
connect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
connect(dispXAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
connect(dispYAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
connect(dispZAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
connect(dispTitle, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
connect(dispXAxis, SIGNAL(textChanged(const QString &)), this,
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(chkXMax, SIGNAL(toggled(bool)), this, SLOT(SetXRange()));
@ -161,7 +182,8 @@ void qTabPlot::Initialization() {
connect(dispXMax, SIGNAL(editingFinished()), this, SLOT(SetXRange()));
connect(dispYMin, 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(chkZMax, SIGNAL(toggled(bool)), this, SLOT(SetZRange()));
@ -209,7 +231,7 @@ void qTabPlot::SetPlot() {
SetZRange();
}
}
plot->SetDataCallBack(plotEnable);
}
@ -220,7 +242,8 @@ void qTabPlot::Set1DPlotOptionsRight() {
stackedWidget1D->setCurrentIndex(0);
else
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() {
@ -230,7 +253,8 @@ void qTabPlot::Set1DPlotOptionsLeft() {
stackedWidget1D->setCurrentIndex(stackedWidget1D->count() - 1);
else
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() {
@ -240,7 +264,8 @@ void qTabPlot::Set2DPlotOptionsRight() {
stackedWidget2D->setCurrentIndex(0);
else
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() {
@ -250,7 +275,8 @@ void qTabPlot::Set2DPlotOptionsLeft() {
stackedWidget2D->setCurrentIndex(stackedWidget2D->count() - 1);
else
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) {
@ -265,16 +291,18 @@ void qTabPlot::EnablePersistency(bool enable) {
void qTabPlot::SetBinary() {
bool binary1D = chkBinary->isChecked();
bool binary2D = chkBinary_2->isChecked();
bool binary2D = chkBinary_2->isChecked();
if (is1d) {
FILE_LOG(logINFO) << "Binary Plot " << (binary1D ? "enabled" : "disabled");
FILE_LOG(logINFO) << "Binary Plot "
<< (binary1D ? "enabled" : "disabled");
lblFrom->setEnabled(binary1D);
lblTo->setEnabled(binary1D);
spinFrom->setEnabled(binary1D);
spinTo->setEnabled(binary1D);
plot->SetBinary(binary1D, spinFrom->value(), spinTo->value());
} else {
FILE_LOG(logINFO) << "Binary Plot " << (binary2D ? "enabled" : "disabled");
FILE_LOG(logINFO) << "Binary Plot "
<< (binary2D ? "enabled" : "disabled");
lblFrom_2->setEnabled(binary2D);
lblTo_2->setEnabled(binary2D);
spinFrom_2->setEnabled(binary2D);
@ -285,19 +313,25 @@ void qTabPlot::SetBinary() {
void qTabPlot::GetGapPixels() {
FILE_LOG(logDEBUG) << "Getting gap pixels";
disconnect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool)));
try {
auto retval = det->getRxAddGapPixels().tsquash("Inconsistent gap pixels enabled for all detectors.");
chkGapPixels->setChecked(retval);
} CATCH_DISPLAY ("Could not get gap pixels enable.", "qTabPlot::GetGapPixels")
connect(chkGapPixels, SIGNAL(toggled(bool)), this, SLOT(SetGapPixels(bool)));
disconnect(chkGapPixels, SIGNAL(toggled(bool)), this,
SLOT(SetGapPixels(bool)));
try {
auto retval = det->getRxAddGapPixels().tsquash(
"Inconsistent gap pixels enabled for all detectors.");
chkGapPixels->setChecked(retval);
}
CATCH_DISPLAY("Could not get gap pixels enable.", "qTabPlot::GetGapPixels")
connect(chkGapPixels, SIGNAL(toggled(bool)), this,
SLOT(SetGapPixels(bool)));
}
void qTabPlot::SetGapPixels(bool enable) {
FILE_LOG(logINFO) << "Setting Gap Pixels Enable to " << enable;
try {
FILE_LOG(logINFO) << "Setting Gap Pixels Enable to " << enable;
try {
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() {
@ -306,32 +340,40 @@ void qTabPlot::SetTitles() {
disconnect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
disconnect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
disconnect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
disconnect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
disconnect(dispXAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
disconnect(dispYAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
disconnect(dispZAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
disconnect(dispTitle, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
disconnect(dispXAxis, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
disconnect(dispYAxis, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
disconnect(dispZAxis, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
// title
if (!chkTitle->isChecked() || dispTitle->text().isEmpty()) {
plot->SetPlotTitlePrefix("");
dispTitle->setText("");
dispTitle->setText("");
} else {
plot->SetPlotTitlePrefix(dispTitle->text());
}
// x
if (!chkXAxis->isChecked() || dispXAxis->text().isEmpty()) {
dispXAxis->setText(is1d ? defaultHistXAxisTitle : defaultImageXAxisTitle);
plot->SetXAxisTitle(is1d ? defaultHistXAxisTitle : defaultImageXAxisTitle);
dispXAxis->setText(is1d ? defaultHistXAxisTitle
: defaultImageXAxisTitle);
plot->SetXAxisTitle(is1d ? defaultHistXAxisTitle
: defaultImageXAxisTitle);
} else {
plot->SetXAxisTitle(dispXAxis->text());
}
}
// y
if (!chkYAxis->isChecked() || dispYAxis->text().isEmpty()) {
dispYAxis->setText(is1d ? defaultHistYAxisTitle : defaultImageYAxisTitle);
plot->SetYAxisTitle(is1d ? defaultHistYAxisTitle : defaultImageYAxisTitle);
dispYAxis->setText(is1d ? defaultHistYAxisTitle
: defaultImageYAxisTitle);
plot->SetYAxisTitle(is1d ? defaultHistYAxisTitle
: defaultImageYAxisTitle);
} else {
plot->SetYAxisTitle(dispYAxis->text());
}
}
// z
if (!chkZAxis->isChecked() || dispZAxis->text().isEmpty()) {
plot->SetZAxisTitle(defaultImageZAxisTitle);
@ -344,10 +386,14 @@ void qTabPlot::SetTitles() {
connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
connect(chkZAxis, SIGNAL(toggled(bool)), this, SLOT(SetTitles()));
connect(dispTitle, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
connect(dispXAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
connect(dispYAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
connect(dispZAxis, SIGNAL(textChanged(const QString &)), this, SLOT(SetTitles()));
connect(dispTitle, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
connect(dispXAxis, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
connect(dispYAxis, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
connect(dispZAxis, SIGNAL(textChanged(const QString &)), this,
SLOT(SetTitles()));
}
void qTabPlot::SetXRange() {
@ -384,13 +430,18 @@ void qTabPlot::SetXYRange() {
bool isRange[4]{false, false, false, false};
double xyRange[4]{0, 0, 0, 0};
QString dispVal[4] {dispXMin->text(), dispXMax->text(), dispYMin->text(), dispYMax->text()};
bool chkVal[4] {chkXMin->isChecked(), chkXMax->isChecked(), chkYMin->isChecked(), chkYMax->isChecked()};
QString dispVal[4]{dispXMin->text(), dispXMax->text(), dispYMin->text(),
dispYMax->text()};
bool chkVal[4]{chkXMin->isChecked(), chkXMax->isChecked(),
chkYMin->isChecked(), chkYMax->isChecked()};
for (int i = 0; i < 4; ++i) {
if (chkVal[i] && !dispVal[i].isEmpty()) {
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;
isRange[i] = true;
disablezoom = true;
@ -418,13 +469,13 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
chkXMax->setChecked(true);
chkYMin->setChecked(true);
chkYMax->setChecked(true);
if (dispXMin->text().isEmpty())
if (dispXMin->text().isEmpty())
dispXMin->setText(QString::number(plot->GetXMinimum()));
if (dispXMax->text().isEmpty())
if (dispXMax->text().isEmpty())
dispXMax->setText(QString::number(plot->GetXMaximum()));
if (dispYMin->text().isEmpty())
if (dispYMin->text().isEmpty())
dispYMin->setText(QString::number(plot->GetYMinimum()));
if (dispYMax->text().isEmpty())
if (dispYMax->text().isEmpty())
dispYMax->setText(QString::number(plot->GetYMaximum()));
// calculate ideal aspect ratio with previous limits
@ -433,49 +484,68 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
ranges[qDefs::XMAX] = plot->GetXMaximum();
ranges[qDefs::YMIN] = plot->GetYMinimum();
ranges[qDefs::YMAX] = plot->GetYMaximum();
double idealAspectratio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / (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] << ")";
double idealAspectratio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
(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
ranges[qDefs::XMIN] = dispXMin->text().toDouble();
ranges[qDefs::XMAX] = dispXMax->text().toDouble();
ranges[qDefs::YMIN] = dispYMin->text().toDouble();
ranges[qDefs::YMAX] = dispYMax->text().toDouble();
double currentAspectRatio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / (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] << ")";
double currentAspectRatio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
(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) {
// 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) {
dimension = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) > (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]))
? static_cast<int>(slsDetectorDefs::X) : static_cast<int>(slsDetectorDefs::Y);
dimension = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) >
(ranges[qDefs::YMAX] - ranges[qDefs::YMIN]))
? static_cast<int>(slsDetectorDefs::X)
: static_cast<int>(slsDetectorDefs::Y);
}
// calculate new value to maintain aspect ratio
// adjust x
double newval = 0;
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()) {
ranges[qDefs::XMAX] = newval;
dispXMax->setText(QString::number(newval));
FILE_LOG(logDEBUG) << "New XMax: " << newval;
} 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;
dispXMin->setText(QString::number(newval));
FILE_LOG(logDEBUG) << "New XMin: " << newval;
}
}
// adjust y
else {
newval = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / idealAspectratio) + ranges[qDefs::YMIN];
else {
newval = ((ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
idealAspectratio) +
ranges[qDefs::YMIN];
if (newval <= plot->GetYMaximum()) {
ranges[qDefs::YMAX] = newval;
dispYMax->setText(QString::number(newval));
FILE_LOG(logDEBUG) << "New YMax: " << newval;
} 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;
dispYMin->setText(QString::number(newval));
FILE_LOG(logDEBUG) << "New YMax: " << newval;
@ -492,14 +562,14 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
connect(dispYMin, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
connect(dispYMax, SIGNAL(editingFinished()), this, SLOT(SetYRange()));
bool isRange[4] {true, true, true, true};
bool isRange[4]{true, true, true, true};
plot->SetXYRangeChanged(true, ranges, isRange);
emit DisableZoomSignal(true);
}
void qTabPlot::SetZRange() {
bool isZRange[2] {chkZMin->isChecked(), chkZMax->isChecked()};
double zRange[2] {0 , 0};
bool isZRange[2]{chkZMin->isChecked(), chkZMax->isChecked()};
double zRange[2]{0, 0};
if (isZRange[0] && !dispZMin->text().isEmpty()) {
double val = dispZMin->text().toDouble();
@ -515,24 +585,35 @@ void qTabPlot::SetZRange() {
}
void qTabPlot::GetStreamingFrequency() {
FILE_LOG(logDEBUG) << "Getting Streaming Frequency";
disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
disconnect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
try {
int freq = det->getRxZmqFrequency().tsquash("Inconsistent receiver zmq streaming frequency for all detectors.");
FILE_LOG(logDEBUG) << "Getting Streaming Frequency";
disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetStreamingFrequency()));
disconnect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetStreamingFrequency()));
disconnect(spinTimeGap, SIGNAL(editingFinished()), this,
SLOT(SetStreamingFrequency()));
disconnect(spinNthFrame, SIGNAL(editingFinished()), this,
SLOT(SetStreamingFrequency()));
try {
int freq = det->getRxZmqFrequency().tsquash(
"Inconsistent receiver zmq streaming frequency for all detectors.");
// time interval
if (freq == 0) {
comboFrequency->setCurrentIndex(0);
stackedTimeInterval->setCurrentIndex(0);
try {
int timeMs = det->getRxZmqTimer().tsquash("Inconsistent receiver zmq streaming timer for all detectors.");
auto timeNS = qDefs::getNSTime(std::make_pair(static_cast<double>(timeMs), qDefs::MILLISECONDS));
int timeMs = det->getRxZmqTimer().tsquash(
"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);
spinTimeGap->setValue(time.first);
comboTimeGapUnit->setCurrentIndex(static_cast<int>(time.second));
} CATCH_DISPLAY ("Could not get streaming timer.", "qTabPlot::GetStreamingFrequency")
comboTimeGapUnit->setCurrentIndex(
static_cast<int>(time.second));
}
CATCH_DISPLAY("Could not get streaming timer.",
"qTabPlot::GetStreamingFrequency")
}
// every nth frame
else {
@ -540,29 +621,40 @@ void qTabPlot::GetStreamingFrequency() {
stackedTimeInterval->setCurrentIndex(1);
spinNthFrame->setValue(freq);
}
} CATCH_DISPLAY ("Could not get streaming frequency.", "qTabPlot::GetStreamingFrequency")
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
connect(comboTimeGapUnit, SIGNAL(currentIndexChanged(int)), this, SLOT(SetStreamingFrequency()));
connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetStreamingFrequency()));
}
CATCH_DISPLAY("Could not get streaming frequency.",
"qTabPlot::GetStreamingFrequency")
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this,
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() {
bool frequency = (comboFrequency->currentIndex() == 0) ? 0 : 1;
auto freqVal = spinNthFrame->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());
try {
try {
if (frequency) {
FILE_LOG(logINFO) << "Setting Streaming Frequency to " << freqVal;
det->setRxZmqFrequency(freqVal);
} 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));
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() {
@ -577,19 +669,19 @@ void qTabPlot::Refresh() {
}
GetStreamingFrequency();
// gain plot, gap pixels enable
switch(det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER:
chkGapPixels->setEnabled(true);
GetGapPixels();
break;
case slsDetectorDefs::JUNGFRAU:
chkGainPlot->setEnabled(true);
break;
case slsDetectorDefs::GOTTHARD2:
chkGainPlot1D->setEnabled(true);
break;
default:
break;
switch (det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER:
chkGapPixels->setEnabled(true);
GetGapPixels();
break;
case slsDetectorDefs::JUNGFRAU:
chkGainPlot->setEnabled(true);
break;
case slsDetectorDefs::GOTTHARD2:
chkGainPlot1D->setEnabled(true);
break;
default:
break;
}
} else {
boxPlotType->setEnabled(false);

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

@ -8,7 +8,8 @@
#include <cmath>
#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);
SetupWidgetWindow();
FILE_LOG(logDEBUG) << "Settings ready";
@ -18,20 +19,20 @@ qTabSettings::~qTabSettings() {}
void qTabSettings::SetupWidgetWindow() {
// enabling according to det type
switch(det->getDetectorType().squash()) {
case slsDetectorDefs::MYTHEN3:
lblSettings->setEnabled(false);
comboSettings->setEnabled(false);
break;
case slsDetectorDefs::EIGER:
lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true);
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
break;
default:
break;
// enabling according to det type
switch (det->getDetectorType().squash()) {
case slsDetectorDefs::MYTHEN3:
lblSettings->setEnabled(false);
comboSettings->setEnabled(false);
break;
case slsDetectorDefs::EIGER:
lblDynamicRange->setEnabled(true);
comboDynamicRange->setEnabled(true);
lblThreshold->setEnabled(true);
spinThreshold->setEnabled(true);
break;
default:
break;
}
// default settings for the disabled
@ -47,14 +48,16 @@ void qTabSettings::SetupWidgetWindow() {
}
void qTabSettings::SetupDetectorSettings() {
QStandardItemModel *model = qobject_cast<QStandardItemModel *>(comboSettings->model());
QStandardItemModel *model =
qobject_cast<QStandardItemModel *>(comboSettings->model());
if (model) {
QModelIndex index[NUMSETTINGS];
QStandardItem *item[NUMSETTINGS];
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]->setEnabled(false);
item[i]->setEnabled(false);
}
switch (det->getDetectorType().squash()) {
case slsDetectorDefs::EIGER:
@ -83,7 +86,7 @@ void qTabSettings::SetupDetectorSettings() {
item[(int)DYNAMICGAIN]->setEnabled(true);
item[(int)FIXGAIN1]->setEnabled(true);
item[(int)FIXGAIN2]->setEnabled(true);
break;
break;
case slsDetectorDefs::MOENCH:
item[(int)G1_HIGHGAIN]->setEnabled(true);
item[(int)G1_LOWGAIN]->setEnabled(true);
@ -93,11 +96,12 @@ void qTabSettings::SetupDetectorSettings() {
item[(int)G2_LOWCAP_LOWGAIN]->setEnabled(true);
item[(int)G4_HIGHGAIN]->setEnabled(true);
item[(int)G4_LOWGAIN]->setEnabled(true);
break;
break;
default:
FILE_LOG(logDEBUG) << "Unknown detector type. Exiting GUI.";
qDefs::Message(qDefs::CRITICAL,
"Unknown detector type. Exiting GUI.", "qTabSettings::SetupDetectorSettings");
"Unknown detector type. Exiting GUI.",
"qTabSettings::SetupDetectorSettings");
exit(-1);
}
}
@ -106,38 +110,46 @@ void qTabSettings::SetupDetectorSettings() {
void qTabSettings::Initialization() {
// Settings
if (comboSettings->isEnabled())
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
connect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSettings(int)));
// Dynamic Range
if (comboDynamicRange->isEnabled())
connect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int)));
connect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
// Threshold
if (spinThreshold->isEnabled())
connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetThresholdEnergy(int)));
connect(spinThreshold, SIGNAL(valueChanged(int)), this,
SLOT(SetThresholdEnergy(int)));
}
void qTabSettings::GetSettings() {
FILE_LOG(logDEBUG) << "Getting settings";
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(SetSettings(int)));
try{
auto retval = det->getSettings().tsquash("Inconsistent settings for all detectors.");
disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this,
SLOT(SetSettings(int)));
try {
auto retval = det->getSettings().tsquash(
"Inconsistent settings for all detectors.");
switch (retval) {
case slsDetectorDefs::UNDEFINED:
comboSettings->setCurrentIndex(UNDEFINED);
break;
case slsDetectorDefs::UNINITIALIZED:
comboSettings->setCurrentIndex(UNINITIALIZED);
break;
default:
if ((int)retval < -1 || (int)retval >= NUMSETTINGS) {
throw sls::RuntimeError(std::string("Unknown settings: ") + std::to_string(retval));
}
comboSettings->setCurrentIndex(retval);
break;
case slsDetectorDefs::UNDEFINED:
comboSettings->setCurrentIndex(UNDEFINED);
break;
case slsDetectorDefs::UNINITIALIZED:
comboSettings->setCurrentIndex(UNINITIALIZED);
break;
default:
if ((int)retval < -1 || (int)retval >= NUMSETTINGS) {
throw sls::RuntimeError(std::string("Unknown settings: ") +
std::to_string(retval));
}
comboSettings->setCurrentIndex(retval);
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) {
@ -146,7 +158,9 @@ void qTabSettings::SetSettings(int index) {
try {
FILE_LOG(logINFO) << "Setting Settings to " << sls::ToString(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
if (spinThreshold->isEnabled()) {
SetThresholdEnergy(spinThreshold->value());
@ -155,9 +169,11 @@ void qTabSettings::SetSettings(int index) {
void qTabSettings::GetDynamicRange() {
FILE_LOG(logDEBUG) << "Getting dynamic range";
disconnect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int)));
try {
auto retval = det->getDynamicRange().tsquash("Inconsistent dynamic range for all detectors.");
disconnect(comboDynamicRange, SIGNAL(activated(int)), this,
SLOT(SetDynamicRange(int)));
try {
auto retval = det->getDynamicRange().tsquash(
"Inconsistent dynamic range for all detectors.");
// set the final value on gui
switch (retval) {
case 32:
@ -173,14 +189,19 @@ void qTabSettings::GetDynamicRange() {
comboDynamicRange->setCurrentIndex(DYNAMICRANGE_4);
break;
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) {
FILE_LOG(logINFO) << "Setting dynamic range to " << comboDynamicRange->currentText().toAscii().data();
FILE_LOG(logINFO) << "Setting dynamic range to "
<< comboDynamicRange->currentText().toAscii().data();
try {
switch (index) {
case DYNAMICRANGE_32:
@ -196,28 +217,39 @@ void qTabSettings::SetDynamicRange(int index) {
det->setDynamicRange(4);
break;
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() {
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 {
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);
} 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) {
FILE_LOG(logINFO) << "Setting Threshold Energy to " << index << " eV";
try {
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)
GetThresholdEnergy();
GetThresholdEnergy();
}
void qTabSettings::Refresh() {
@ -230,7 +262,7 @@ void qTabSettings::Refresh() {
if (comboDynamicRange->isEnabled()) {
GetDynamicRange();
}
if (spinThreshold->isEnabled())
GetThresholdEnergy();