From 3b59d03526eaec9f0c7fc4f6d9a11b3df77c402a Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Thu, 19 Jul 2012 14:20:51 +0000 Subject: [PATCH] going to start actions git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@19 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/forms/form_detectormain.ui | 119 ++++++- slsDetectorGui/forms/form_tab_dataoutput.ui | 334 +++++++++++++------ slsDetectorGui/forms/form_tab_debugging.ui | 158 ++++++++- slsDetectorGui/forms/form_tab_measurement.ui | 118 ------- slsDetectorGui/forms/form_tab_plot.ui | 2 +- slsDetectorGui/forms/form_tab_settings.ui | 81 +++-- slsDetectorGui/include/qActionsWidget.h | 22 +- slsDetectorGui/include/qDetectorMain.h | 4 +- slsDetectorGui/include/qDrawPlot.h | 6 +- slsDetectorGui/include/qTabActions.h | 17 +- slsDetectorGui/include/qTabAdvanced.h | 6 +- slsDetectorGui/include/qTabDataOutput.h | 35 +- slsDetectorGui/include/qTabDebugging.h | 13 +- slsDetectorGui/include/qTabDeveloper.h | 6 +- slsDetectorGui/include/qTabMeasurement.h | 6 +- slsDetectorGui/include/qTabMessages.h | 6 +- slsDetectorGui/include/qTabPlot.h | 19 +- slsDetectorGui/include/qTabSettings.h | 33 +- slsDetectorGui/src/qActionsWidget.cpp | 87 +++-- slsDetectorGui/src/qDetectorMain.cpp | 188 ++++++----- slsDetectorGui/src/qDrawPlot.cpp | 2 +- slsDetectorGui/src/qTabActions.cpp | 183 +++------- slsDetectorGui/src/qTabAdvanced.cpp | 2 +- slsDetectorGui/src/qTabDataOutput.cpp | 333 ++++++++++++++++-- slsDetectorGui/src/qTabDebugging.cpp | 20 +- slsDetectorGui/src/qTabDeveloper.cpp | 2 +- slsDetectorGui/src/qTabMeasurement.cpp | 2 +- slsDetectorGui/src/qTabMessages.cpp | 2 +- slsDetectorGui/src/qTabPlot.cpp | 93 ++++-- slsDetectorGui/src/qTabSettings.cpp | 144 +++++++- 30 files changed, 1433 insertions(+), 610 deletions(-) diff --git a/slsDetectorGui/forms/form_detectormain.ui b/slsDetectorGui/forms/form_detectormain.ui index 0f2049a6b..ea4ae989a 100644 --- a/slsDetectorGui/forms/form_detectormain.ui +++ b/slsDetectorGui/forms/form_detectormain.ui @@ -19,6 +19,124 @@ 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 185 + 185 + 185 + + + + + + + 185 + 185 + 185 + + + + + + + 185 + 185 + 185 + + + + + + + 89 + 89 + 89 + + + + + + 9 @@ -130,7 +248,6 @@ &Help - diff --git a/slsDetectorGui/forms/form_tab_dataoutput.ui b/slsDetectorGui/forms/form_tab_dataoutput.ui index f36c57116..5afac7644 100644 --- a/slsDetectorGui/forms/form_tab_dataoutput.ui +++ b/slsDetectorGui/forms/form_tab_dataoutput.ui @@ -7,7 +7,7 @@ 0 0 775 - 339 + 345 @@ -35,7 +35,7 @@ 20 - 75 + 110 731 206 @@ -43,114 +43,24 @@ Correction - + - 10 + 15 20 - 711 - 181 + 701 + 176 - + - + - Flat Field File - - - - - - - Rate Correction - - - - - - - Angular Conversion - - - - - - - - - - Discard Bad Channels + Flat Field File: - - - - 0 - 0 - - - - : - - - - - - - : - - - - - - - - 0 - 0 - - - - Browse - - - - - - - Auto - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - Custom dead time(ns): - - - - - - - Qt::Horizontal @@ -166,6 +76,178 @@ + + + + false + + + + + + + false + + + Rate Correction: + + + + + + + false + + + Auto + + + + + + + false + + + + 0 + 0 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + ns + + + 6 + + + 2000000000.000000000000000 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + false + + + + 0 + 0 + + + + Browse + + + + + + + false + + + Custom dead time: + + + + + + + Angular Conversion + + + + + + + Discard Bad Channels + + + @@ -187,9 +269,9 @@ - 0 + 10 6 - 731 + 706 28 @@ -217,6 +299,56 @@ + + + + 245 + 327 + 256 + 16 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 193 + 193 + 193 + + + + + + + + * Note: Enter valid file to enable Flat Field. + + diff --git a/slsDetectorGui/forms/form_tab_debugging.ui b/slsDetectorGui/forms/form_tab_debugging.ui index 47d4c2a20..aeca75ca8 100644 --- a/slsDetectorGui/forms/form_tab_debugging.ui +++ b/slsDetectorGui/forms/form_tab_debugging.ui @@ -6,8 +6,8 @@ 0 0 - 748 - 350 + 775 + 345 @@ -31,19 +31,163 @@ Form - + - 232 - 141 - 75 + 265 + 30 + 251 + 36 + + + + + + + Module Number: + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + All Modules + + + + + + + + + + 30 + 165 + 321 + 156 + + + + Digital Tests + + + + + 15 + 20 + 141 + 51 + + + + + + + Detector Module + + + + + + + Test xxx + + + + + + + + + 15 + 115 + 291 + 25 + + + + Run + + + + + + + 265 + 95 + 251 25 - PushButton + Get Detector Information + + + + 425 + 165 + 321 + 156 + + + + Analog Tests + + + + + 15 + 20 + 141 + 51 + + + + + + + Detector Module + + + + + + + Test xxx + + + + + + + + + 15 + 115 + 291 + 25 + + + + Run + + + diff --git a/slsDetectorGui/forms/form_tab_measurement.ui b/slsDetectorGui/forms/form_tab_measurement.ui index c1e0dc1da..1452b0986 100644 --- a/slsDetectorGui/forms/form_tab_measurement.ui +++ b/slsDetectorGui/forms/form_tab_measurement.ui @@ -28,124 +28,6 @@ 345 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 193 - 193 - 193 - - - - - - - 188 - 188 - 188 - - - - - - - 192 - 192 - 192 - - - - - - - 0 - 0 - 0 - - - - - - Form diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index 5d3607950..cf76e55b6 100644 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -494,7 +494,7 @@ Scan - Y Axis Values - true + false false diff --git a/slsDetectorGui/forms/form_tab_settings.ui b/slsDetectorGui/forms/form_tab_settings.ui index f7184ebdd..415b80f3a 100644 --- a/slsDetectorGui/forms/form_tab_settings.ui +++ b/slsDetectorGui/forms/form_tab_settings.ui @@ -6,8 +6,8 @@ 0 0 - 748 - 339 + 775 + 345 @@ -34,10 +34,10 @@ - 13 - 16 - 311 - 151 + 30 + 20 + 316 + 171 @@ -48,7 +48,7 @@ - + @@ -107,17 +107,19 @@ - - - - Threshold: - - - - + + + eV + - -1 + -100000 + + + 100000 + + + 100 -1 @@ -138,22 +140,59 @@ - + - 16 + 1.67772e+07 - 32 + 65535 + + + + + 255 + + + + + 7 - - + + + + 1 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Threshold: + + diff --git a/slsDetectorGui/include/qActionsWidget.h b/slsDetectorGui/include/qActionsWidget.h index 501a1a5ff..8dd0ad07a 100644 --- a/slsDetectorGui/include/qActionsWidget.h +++ b/slsDetectorGui/include/qActionsWidget.h @@ -24,13 +24,19 @@ class ActionsWidget : public QFrame{ public: /** \short The constructor * @param parent is the parent tab widget - * @param detector is the detector returned from the detector tab + * @param scanType is if its an energy/threshold scan type + * @param id is the id of the widget. to know which one was emitting it */ - ActionsWidget(QWidget *parent, int scanType); + ActionsWidget(QWidget *parent, int scanType, int id); ~ActionsWidget(); private: + /**if its a scan type*/ + int scanType; + /**id of the action widget*/ + int id; + QGridLayout *layout; QComboBox *comboScript; QLineEdit *dispScript; @@ -56,8 +62,8 @@ private: QPushButton *btnValues; /** Sets up the widget - * @param scanType 1 if it includes Threshold Scan,Energy Scan and Trimbits Scan, else 0*/ - void SetupWidgetWindow(int scanType); + */ + void SetupWidgetWindow(); /** Sets up all the slots and signals */ void Initialization(); @@ -72,6 +78,14 @@ void SetScript(int index); * Options: constant size,specific values,values from file */ void EnableSizeWidgets(); +/** Browse for the script + * */ +void BrowsePath(); + +signals: +void EnableScanBox(bool,int); +void SetScriptSignal(QString&,int); + }; diff --git a/slsDetectorGui/include/qDetectorMain.h b/slsDetectorGui/include/qDetectorMain.h index b1807f2b4..476c33022 100644 --- a/slsDetectorGui/include/qDetectorMain.h +++ b/slsDetectorGui/include/qDetectorMain.h @@ -21,7 +21,7 @@ class qTabDebugging; class qTabDeveloper; class qTabMessages; /** Project Class Headers */ -class slsDetectorUtils; +class multiSlsDetector; #include "sls_detector_defs.h" /** Qt Include Headers */ #include @@ -63,7 +63,7 @@ private: /** The Qt Application */ QApplication *theApp; /** The sls detector object */ - slsDetectorUtils *myDet; + multiSlsDetector *myDet; /** sls detector id */ int detID; /** The Plot widget */ diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index 4504b6d17..e4c86eac6 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -9,7 +9,7 @@ /** Project Class Headers */ -class slsDetectorUtils; +class multiSlsDetector; #include "detectorData.h" /** Qt Project Class Headers */ #include "SlsQt1DPlot.h" @@ -38,7 +38,7 @@ class qDrawPlot:public QWidget{ public: /** \short The constructor */ - qDrawPlot(QWidget *parent,slsDetectorUtils*& detector); + qDrawPlot(QWidget *parent,multiSlsDetector*& detector); /** Destructor */ ~qDrawPlot(); @@ -96,7 +96,7 @@ public: private: /** The sls detector object */ - slsDetectorUtils *myDet; + multiSlsDetector *myDet; /** Widgets needed to plot the clone */ diff --git a/slsDetectorGui/include/qTabActions.h b/slsDetectorGui/include/qTabActions.h index 6c8b14c7e..8fc824fca 100644 --- a/slsDetectorGui/include/qTabActions.h +++ b/slsDetectorGui/include/qTabActions.h @@ -9,7 +9,7 @@ #define QTABACTIONS_H_ /** Project Class Headers */ -class slsDetectorUtils; +class multiSlsDetector; class ActionsWidget; #include @@ -31,7 +31,7 @@ public: * @param parent is the parent tab widget * @param detector is the detector returned from the detector tab */ - qTabActions(QWidget *parent,slsDetectorUtils*& detector); + qTabActions(QWidget *parent,multiSlsDetector*& detector); /** Destructor */ @@ -44,7 +44,7 @@ public: private: /** The sls detector object */ - slsDetectorUtils *myDet; + multiSlsDetector *myDet; static const int NUM_ACTION_WIDGETS = 9; @@ -57,6 +57,9 @@ private: QPushButton *btnExpand[NUM_ACTION_WIDGETS]; QLabel *lblName[NUM_ACTION_WIDGETS]; + enum{Start,Scan0,Scan1,ActionBefore,NumPositions, + HeaderBefore,HeaderAfter,ActionAfter,Stop}; + /** Sets up the widget */ void SetupWidgetWindow(); @@ -68,6 +71,14 @@ private slots: /** To Expand the Action Widget */ void Expand(QAbstractButton *button); +/** To set the script of action widget + * @param fName name of script + * @param index id of action widget*/ +void SetScript(const QString& fName,int index); + +signals: +void EnableScanBox(bool,int); + }; #endif /* QTABACTIONS_H_ */ diff --git a/slsDetectorGui/include/qTabAdvanced.h b/slsDetectorGui/include/qTabAdvanced.h index 101d6cfd3..a0573418f 100644 --- a/slsDetectorGui/include/qTabAdvanced.h +++ b/slsDetectorGui/include/qTabAdvanced.h @@ -11,7 +11,7 @@ /** Form Header */ #include "ui_form_tab_advanced.h" /** Project Class Headers */ -class slsDetectorUtils; +class multiSlsDetector; /** *@short sets up the advanced parameters @@ -24,7 +24,7 @@ public: * @param parent is the parent tab widget * @param detector is the detector returned from the detector tab */ - qTabAdvanced(QWidget *parent,slsDetectorUtils*& detector); + qTabAdvanced(QWidget *parent,multiSlsDetector*& detector); /** Destructor */ @@ -37,7 +37,7 @@ public: private: /** The sls detector object */ - slsDetectorUtils *myDet; + multiSlsDetector *myDet; /** The sls detector object type*/ int myDetType; diff --git a/slsDetectorGui/include/qTabDataOutput.h b/slsDetectorGui/include/qTabDataOutput.h index 37dd81317..5372964cb 100644 --- a/slsDetectorGui/include/qTabDataOutput.h +++ b/slsDetectorGui/include/qTabDataOutput.h @@ -11,7 +11,8 @@ /** Form Header */ #include "ui_form_tab_dataoutput.h" /** Project Class Headers */ -class slsDetectorUtils; +class multiSlsDetector; +#include "sls_detector_defs.h" /** Qt Include Headers */ #include @@ -26,8 +27,9 @@ public: /** \short The constructor * @param parent is the parent tab widget * @param detector is the detector returned from the detector tab + * @param detID is the id of the detector */ - qTabDataOutput(QWidget *parent,slsDetectorUtils*& detector); + qTabDataOutput(QWidget *parent,multiSlsDetector*& detector,int detID); /** Destructor */ @@ -41,7 +43,13 @@ public: private: /** The sls detector object */ - slsDetectorUtils *myDet; + multiSlsDetector *myDet; + + /**detector id */ + int detID; + + /** detector type */ + slsDetectorDefs::detectorType detType; /** methods */ /** Sets up the widget */ @@ -59,6 +67,27 @@ void setOutputDir(const QString& path); /** Open dialog to choose the output directory */ void browseOutputDir(); + +/**set flat field file*/ +void SetFlatField(); + +/** update flat field correction from server */ +void UpdateFlatFieldFromServer(); + +/**browse flat field*/ +void BrowseFlatFieldPath(); + +/**rate correction*/ +void SetRateCorrection(); + +/** update rate correction from server */ +void UpdateRateCorrectionFromServer(); + +/**angular correction*/ +void SetAngularCorrection(); + +/**discard bad channels*/ +void DiscardBadChannels(); }; diff --git a/slsDetectorGui/include/qTabDebugging.h b/slsDetectorGui/include/qTabDebugging.h index 8d399a6d0..f604d2161 100644 --- a/slsDetectorGui/include/qTabDebugging.h +++ b/slsDetectorGui/include/qTabDebugging.h @@ -11,7 +11,11 @@ /** Form Header */ #include "ui_form_tab_debugging.h" /** Project Class Headers */ -class slsDetectorUtils; +class multiSlsDetector; +/** Qt Include Headers */ + +/** C++ Include Headers */ +#include "sls_detector_defs.h" /** *@short sets up the Debugging parameters @@ -24,7 +28,7 @@ public: * @param parent is the parent tab widget * @param detector is the detector returned from the detector tab */ - qTabDebugging(QWidget *parent,slsDetectorUtils*& detector); + qTabDebugging(QWidget *parent,multiSlsDetector*& detector); /** Destructor */ @@ -36,7 +40,10 @@ public: private: /** The sls detector object */ - slsDetectorUtils *myDet; + multiSlsDetector *myDet; + + /** detector type */ + slsDetectorDefs::detectorType detType; /** Sets up the widget */ diff --git a/slsDetectorGui/include/qTabDeveloper.h b/slsDetectorGui/include/qTabDeveloper.h index d5baf5e99..7b83e523e 100644 --- a/slsDetectorGui/include/qTabDeveloper.h +++ b/slsDetectorGui/include/qTabDeveloper.h @@ -11,7 +11,7 @@ /** Form Header */ #include "ui_form_tab_developer.h" /** Project Class Headers */ -class slsDetectorUtils; +class multiSlsDetector; /** *@short sets up the Developer parameters @@ -24,7 +24,7 @@ public: * @param parent is the parent tab widget * @param detector is the detector returned from the detector tab */ - qTabDeveloper(QWidget *parent,slsDetectorUtils*& detector); + qTabDeveloper(QWidget *parent,multiSlsDetector*& detector); /** Destructor */ @@ -36,7 +36,7 @@ public: private: /** The sls detector object */ - slsDetectorUtils *myDet; + multiSlsDetector *myDet; /** Sets up the widget */ diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h index c65820f2e..4fa630602 100644 --- a/slsDetectorGui/include/qTabMeasurement.h +++ b/slsDetectorGui/include/qTabMeasurement.h @@ -10,7 +10,7 @@ /** Form Header */ #include "ui_form_tab_measurement.h" /** Project Class Headers */ -class slsDetectorUtils; +class multiSlsDetector; /** Qt Project Class Headers */ class qDrawPlot; @@ -30,7 +30,7 @@ public: * @param detector is the detector returned from the detector tab * @param plot plot object reference */ - qTabMeasurement(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot); + qTabMeasurement(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot); /** Destructor */ @@ -43,7 +43,7 @@ public: private: /** The sls detector object */ - slsDetectorUtils *myDet; + multiSlsDetector *myDet; /** The Plot widget */ qDrawPlot *myPlot; diff --git a/slsDetectorGui/include/qTabMessages.h b/slsDetectorGui/include/qTabMessages.h index bd8be85b6..6821a55f1 100644 --- a/slsDetectorGui/include/qTabMessages.h +++ b/slsDetectorGui/include/qTabMessages.h @@ -11,7 +11,7 @@ /** Project Class Headers */ -class slsDetectorUtils; +class multiSlsDetector; /** Qt Include Headers */ #include #include @@ -30,7 +30,7 @@ public: * @param parent is the parent tab widget * @param detector is the detector returned from the detector tab */ - qTabMessages(QWidget *parent,slsDetectorUtils*& detector); + qTabMessages(QWidget *parent,multiSlsDetector*& detector); /** Destructor */ @@ -39,7 +39,7 @@ public: private: /** The sls detector object */ - slsDetectorUtils *myDet; + multiSlsDetector *myDet; /** Log of executed commands */ QTextEdit *dispLog; diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h index 94d5f1344..4e1701606 100644 --- a/slsDetectorGui/include/qTabPlot.h +++ b/slsDetectorGui/include/qTabPlot.h @@ -11,7 +11,7 @@ /** Form Header */ #include "ui_form_tab_plot.h" /** Project Class Headers */ -class slsDetectorUtils; +class multiSlsDetector; /** Qt Project Class Headers */ class qDrawPlot; /** Qt Include Headers */ @@ -29,7 +29,7 @@ public: * @param detector is the detector returned from the detector tab * @param plot plot object reference */ - qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot); + qTabPlot(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot); /** Destructor */ @@ -42,7 +42,7 @@ public: private: /** The sls detector object */ - slsDetectorUtils *myDet; + multiSlsDetector *myDet; /** The Plot widget */ qDrawPlot *myPlot; @@ -50,6 +50,8 @@ private: /** 1d/2d plot */ bool isOneD; + bool scanLevel[2]; + QStackedLayout* stackedLayout; QSpinBox *spinNthFrame; QDoubleSpinBox *spinTimeGap; @@ -76,10 +78,13 @@ private: public slots: -/** Set frequency between plots - * returns 0 if there were no errors(important - * while editing acquisition period in measurement tab) */ -int SetFrequency(); +/** Set frequency between plots*/ +void SetFrequency(); +/** Enable Scan box + * @param enable to enable the scan group box + * @param id is 0 if its scan level 0 or scan level 1 + */ +void EnableScanBox(bool enable,int id); diff --git a/slsDetectorGui/include/qTabSettings.h b/slsDetectorGui/include/qTabSettings.h index 5729e5c41..4404368a0 100644 --- a/slsDetectorGui/include/qTabSettings.h +++ b/slsDetectorGui/include/qTabSettings.h @@ -11,7 +11,7 @@ /** Form Header */ #include "ui_form_tab_settings.h" /** Project Class Headers */ -class slsDetectorUtils; +class multiSlsDetector; #include "sls_detector_defs.h" /** Qt Include Headers */ #include @@ -28,7 +28,7 @@ public: * @param detector is the detector returned from the detector tab * @param detID is the id of the detector */ - qTabSettings(QWidget *parent,slsDetectorUtils*& detector,int detID); + qTabSettings(QWidget *parent,multiSlsDetector*& detector,int detID); /** Destructor */ @@ -38,15 +38,25 @@ public: */ void Refresh(); + /** enable expert mode + * @param enable true if expert mode is enabled + */ + void EnableExpertMode(bool enable){expertMode=enable;Refresh();}; + + private: /** The sls detector object */ - slsDetectorUtils *myDet; - /**etector id */ + multiSlsDetector *myDet; + + /**detector id */ int detID; + /** detector type */ slsDetectorDefs::detectorType detType; + bool expertMode; + enum{Standard,Fast,HighGain,DynamicGain,LowGain,MediumGain,VeryHighGain,Undefined,Uninitialized,NumSettings}; /** To be able to index items on a combo box */ @@ -68,12 +78,27 @@ private: + + private slots: /** Set settings according to selection * @param index index of selection */ void setSettings(int index); +/** Set number of modules if possible + * @param index number of modules + */ +void SetNumberOfModules(int index); + +/** Set dynamic range if possible + * @param index selection + */ +void SetDynamicRange(int index); + +/** Set threshold energy + */ +void SetEnergy(); }; diff --git a/slsDetectorGui/src/qActionsWidget.cpp b/slsDetectorGui/src/qActionsWidget.cpp index 1004150c8..7eaceaba4 100644 --- a/slsDetectorGui/src/qActionsWidget.cpp +++ b/slsDetectorGui/src/qActionsWidget.cpp @@ -5,9 +5,9 @@ * Author: l_maliakal_d */ -/** Qt Project Class Headers */ +// Qt Project Class Headers #include "qActionsWidget.h" -/** Qt Include Headers */ +// Qt Include Headers #include #include #include @@ -19,20 +19,23 @@ #include #include #include -/** C++ Include Headers */ +#include +// C++ Include Headers #include using namespace std; +//------------------------------------------------------------------------------------------------------------------------------------------------- -ActionsWidget::ActionsWidget(QWidget *parent, int scanType): QFrame(parent){ - SetupWidgetWindow(scanType); +ActionsWidget::ActionsWidget(QWidget *parent, int scanType, int id): + QFrame(parent),scanType(scanType),id(id){ + SetupWidgetWindow(); Initialization(); } - +//------------------------------------------------------------------------------------------------------------------------------------------------- ActionsWidget::~ActionsWidget(){ @@ -40,24 +43,25 @@ ActionsWidget::~ActionsWidget(){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- -void ActionsWidget::SetupWidgetWindow(int scanType){ - /** Widget Settings */ +void ActionsWidget::SetupWidgetWindow(){ + // Widget Settings //setFrameStyle(QFrame::Box); //setFrameShadow(QFrame::Raised); setFixedHeight(25); if(scanType) setFixedHeight(125); - /** Main Layout Settings */ + // Main Layout Settings layout = new QGridLayout(this); setLayout(layout); layout->setContentsMargins(0,0,0,0); if(scanType) layout->setVerticalSpacing(5); - /** Main Widgets*/ + // Main Widgets comboScript = new QComboBox(this); if(!scanType){ comboScript->addItem("None"); @@ -88,7 +92,7 @@ void ActionsWidget::SetupWidgetWindow(int scanType){ - /** Scan Levels Widgets*/ + // Scan Levels Widgets if(scanType){ lblSteps = new QLabel("Number of Steps:"); lblSteps->setEnabled(false); @@ -104,13 +108,13 @@ void ActionsWidget::SetupWidgetWindow(int scanType){ layout->addWidget(spinPrecision,1,6); group = new QGroupBox(this); group->setEnabled(false); - /** Fix the size of the groupbox*/ + // Fix the size of the groupbox group->setFixedSize(513,66); layout->addWidget(group,2,2,1,5); - /** Group Box for step size */ - /** Radio Buttons Layout */ + // Group Box for step size + // Radio Buttons Layout QWidget *h1Widget = new QWidget(group); h1Widget->setGeometry(QRect(10, 5, group->width()-20, 23)); QHBoxLayout *h1 = new QHBoxLayout(h1Widget); @@ -124,7 +128,7 @@ void ActionsWidget::SetupWidgetWindow(int scanType){ radioValue->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); h1->addWidget(radioValue); - /** Constant Size Layout */ + // Constant Size Layout QWidget *h2ConstantWidget = new QWidget(group); h2ConstantWidget->setGeometry(QRect(10, 30, group->width()-20, 31)); QHBoxLayout *h2Constant = new QHBoxLayout(h2ConstantWidget); @@ -149,7 +153,7 @@ void ActionsWidget::SetupWidgetWindow(int scanType){ h2Constant->addWidget(spinSize); h2Constant->addItem(new QSpacerItem(50,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - /** Specific Values Layout */ + // Specific Values Layout QWidget *h2SpecificWidget = new QWidget(group); h2SpecificWidget->setGeometry(QRect(10, 30, group->width()-20, 31)); QHBoxLayout *h2Specific = new QHBoxLayout(h2SpecificWidget); @@ -160,7 +164,7 @@ void ActionsWidget::SetupWidgetWindow(int scanType){ comboSpecific->hide(); h2Specific->addItem(new QSpacerItem(200,20,QSizePolicy::Fixed,QSizePolicy::Fixed)); - /** Values From a File Layout */ + // Values From a File Layout QWidget *h2ValuesWidget = new QWidget(group); h2ValuesWidget->setGeometry(QRect(10, 30, group->width()-20, 31)); QHBoxLayout *h2Values = new QHBoxLayout(h2ValuesWidget); @@ -181,57 +185,67 @@ void ActionsWidget::SetupWidgetWindow(int scanType){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- + void ActionsWidget::Initialization(){ connect(comboScript,SIGNAL(currentIndexChanged(int)),this,SLOT(SetScript(int))); - if(comboScript->count()>2){ + if(scanType){ connect(radioConstant,SIGNAL(toggled(bool)),this,SLOT(EnableSizeWidgets())); connect(radioSpecific,SIGNAL(toggled(bool)),this,SLOT(EnableSizeWidgets())); connect(radioValue,SIGNAL(toggled(bool)),this,SLOT(EnableSizeWidgets())); } + connect(btnBrowse, SIGNAL(clicked()), this, SLOT(BrowsePath())); + + } +//------------------------------------------------------------------------------------------------------------------------------------------------- + void ActionsWidget::SetScript(int index){ - /** defaults */ + // defaults dispScript->setEnabled(false); btnBrowse->setEnabled(false); lblParameter->setEnabled(false); dispParameter->setEnabled(false); - if(comboScript->count()>2){ + if(scanType){ group->setEnabled(false); lblSteps->setEnabled(false); spinSteps->setEnabled(false); lblPrecision->setEnabled(false); spinPrecision->setEnabled(false); } - /** If anything other than None is selected*/ + // If anything other than None is selected if(index){ - /** Custom Script only enables the first layout with addnl parameters etc */ + // Custom Script only enables the first layout with addnl parameters etc if(!comboScript->currentText().compare("Custom Script")){ dispScript->setEnabled(true); btnBrowse->setEnabled(true); lblParameter->setEnabled(true); dispParameter->setEnabled(true); } - /** If this group includes Energy scan , threhold scan etc */ - if(comboScript->count()>2){ + // If this group includes Energy scan , threhold scan etc + if(scanType){ group->setEnabled(true); lblPrecision->setEnabled(true); spinPrecision->setEnabled(true); - /** Steps are enabled only if constant step size is not checked*/ + // Steps are enabled only if constant step size is not checked lblSteps->setEnabled(!radioConstant->isChecked()); spinSteps->setEnabled(!radioConstant->isChecked()); } } + //emit signal to enable scanbox and the radiobuttons + if(scanType) emit EnableScanBox(index,((id==2)?1:0)); } +//------------------------------------------------------------------------------------------------------------------------------------------------- void ActionsWidget::EnableSizeWidgets(){ - /** defaults */ + // defaults lblFrom->hide(); spinFrom->hide(); lblTo->hide(); @@ -243,7 +257,7 @@ void ActionsWidget::EnableSizeWidgets(){ btnValues->hide(); lblSteps->setEnabled(true); spinSteps->setEnabled(true); - /** Constant Step Size */ + // Constant Step Size if(radioConstant->isChecked()){ lblFrom->show(); spinFrom->show(); @@ -253,13 +267,28 @@ void ActionsWidget::EnableSizeWidgets(){ spinSize->show(); lblSteps->setEnabled(false); spinSteps->setEnabled(false); - }/** Specific Values */ + }// Specific Values else if(radioSpecific->isChecked()) comboSpecific->show(); - /** Values from a File */ + // Values from a File else{ dispValues->show(); btnValues->show(); } } + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void ActionsWidget::BrowsePath(){ + QString fName = dispScript->text(); + QString dir = fName.section('/',0,-2,QString::SectionIncludeLeadingSep); + if(dir.isEmpty()) dir = "/home"; + fName = QFileDialog::getOpenFileName(this, + tr("Load Script File"),dir, + tr("Script Files(*.awk);;All Files(*)"));//,0,QFileDialog::ShowDirsOnly); + if (!fName.isEmpty()){ + dispScript->setText(fName); + emit SetScriptSignal(fName,id); + } +} diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index 0730216d4..4b5cda8de 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -1,4 +1,8 @@ -/** Qt Project Class Headers */ +/********************************************************************** + * TO DO + * 1. settcpsocket is done with slsdetector.maybe do for all detectors connected: mythen + * ********************************************************************/ +// Qt Project Class Headers #include "qDetectorMain.h" #include "qDefs.h" #include "qDrawPlot.h" @@ -11,14 +15,14 @@ #include "qTabDebugging.h" #include "qTabDeveloper.h" #include "qTabMessages.h" -/** Project Class Headers */ +// Project Class Headers #include "slsDetector.h" #include "multiSlsDetector.h" #include "sls_detector_defs.h" -/** Qt Include Headers */ +// Qt Include Headers #include #include -/** C++ Include Headers */ +// C++ Include Headers #include #include using namespace std; @@ -44,17 +48,17 @@ int main (int argc, char **argv) { qDetectorMain::qDetectorMain(int argc, char **argv, QApplication *app, QWidget *parent) : QMainWindow(parent), theApp(app),myDet(0),detID(0),myPlot(NULL),tabs(NULL),isDeveloper(0){ - /** Getting all the command line arguments */ + // Getting all the command line arguments for(int iarg=1; iargsetLayout(layoutTabs); -/** plot setup*/ +// plot setup myPlot = new qDrawPlot(dockWidgetPlot,myDet); dockWidgetPlot->setWidget(myPlot); -/**tabs setup*/ +//tabs setup tabs = new MyTabWidget(this); layoutTabs->addWidget(tabs); - /** creating all the tab widgets */ + // creating all the tab widgets tab_messages = new qTabMessages (this, myDet); tab_measurement = new qTabMeasurement (this, myDet,myPlot); - tab_dataoutput = new qTabDataOutput (this, myDet); + tab_dataoutput = new qTabDataOutput (this, myDet, detID); tab_plot = new qTabPlot (this, myDet,myPlot); tab_actions = new qTabActions (this, myDet); tab_settings = new qTabSettings (this, myDet, detID); tab_advanced = new qTabAdvanced (this, myDet); tab_debugging = new qTabDebugging (this, myDet); tab_developer = new qTabDeveloper (this, myDet); - /** creating the scroll area widgets for the tabs */ + // creating the scroll area widgets for the tabs for(int i=0;isetFrameShape(QFrame::NoFrame); } - /** setting the tab widgets to the scrollareas*/ + // setting the tab widgets to the scrollareas scroll[Measurement] ->setWidget(tab_measurement); scroll[DataOutput] ->setWidget(tab_dataoutput); scroll[Plot] ->setWidget(tab_plot); @@ -116,7 +120,7 @@ void qDetectorMain::SetUpWidgetWindow(){ scroll[Advanced] ->setWidget(tab_advanced); scroll[Debugging] ->setWidget(tab_debugging); scroll[Developer] ->setWidget(tab_developer); - /** inserting all the tabs*/ + // inserting all the tabs tabs->insertTab(Measurement, scroll[Measurement], "Measurement"); tabs->insertTab(DataOutput, scroll[DataOutput], "Data Output"); tabs->insertTab(Plot, scroll[Plot], "Plot"); @@ -125,20 +129,20 @@ void qDetectorMain::SetUpWidgetWindow(){ tabs->insertTab(Advanced, scroll[Advanced], "Advanced"); tabs->insertTab(Debugging, scroll[Debugging], "Debugging"); tabs->insertTab(Developer, scroll[Developer], "Developer"); - /** Prefer this to expand and not have scroll buttons*/ + // Prefer this to expand and not have scroll buttons tabs->insertTab(Messages, tab_messages, "Messages"); - /** Default tab color*/ + // Default tab color defaultTabColor = tabs->tabBar()->tabTextColor(DataOutput); - /**Set the current tab(measurement) to blue as it is the current one*/ + //Set the current tab(measurement) to blue as it is the current one tabs->tabBar()->setTabTextColor(0,QColor(0,0,200,255)); - /** increase the width so it uses all the empty space for the tab titles*/ + // increase the width so it uses all the empty space for the tab titles tabs->tabBar()->setFixedWidth(width()+61); -/** mode setup - to set up the tabs initially as disabled, not in form so done here */ +// mode setup - to set up the tabs initially as disabled, not in form so done here #ifdef VERBOSE - cout<<"Setting Debug Mode to 0\nSetting Beamline Mode to 0\n" + cout << "Setting Debug Mode to 0\nSetting Beamline Mode to 0\n" "Setting Expert Mode to 0\nSetting Dockable Mode to false\n" - "Setting Developer Mode to "<setTabEnabled(Debugging,false); //beamline mode to false @@ -147,11 +151,11 @@ void qDetectorMain::SetUpWidgetWindow(){ dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); tabs->setTabEnabled(Developer,isDeveloper); -/** Other setup*/ - /**Height of plot and central widget*/ +// Other setup + //Height of plot and central widget heightPlotWindow = dockWidgetPlot->size().height(); heightCentralWidget = centralwidget->size().height(); - /** Default zoom Tool Tip */ + // Default zoom Tool Tip zoomToolTip = dockWidgetPlot->toolTip(); } @@ -162,38 +166,43 @@ void qDetectorMain::SetUpWidgetWindow(){ void qDetectorMain::SetUpDetector(){ - /**instantiate detector and set window title*/ + //instantiate detector and set window title myDet = new multiSlsDetector(detID); - if(!myDet->getHostname(detID).length()){ + string host = myDet->getHostname(detID); + slsDetector *s = myDet->getSlsDetector(detID); + //if hostname doesnt exist even in shared memory + if(!host.length()){ #ifdef VERBOSE - cout<getHostname(detID)<setTCPSocket()==slsDetectorDefs::FAIL){ + qDefs::ErrorMessage(string("The detector ")+host+string(" is not connected. Exiting GUI."),"Main"); + cout << "The detector " << host << "is not connected. Exiting GUI." << endl; + exit(-1); } else{ - /** Check if type valid. If not, exit*/ - switch(myDet->getDetectorsType()){ + slsDetectorDefs::detectorType detType = myDet->getDetectorsType(); + // Check if type valid. If not, exit + switch(detType){ case slsDetectorDefs::MYTHEN: break; case slsDetectorDefs::EIGER: break; case slsDetectorDefs::GOTTHARD: break; default: - string detName = myDet->slsDetectorBase::getDetectorType(myDet->getDetectorsType()); - string hostname = myDet->getHostname(detID); - string errorMess = hostname+string(" has unknown detector type \"")+ + string detName = myDet->slsDetectorBase::getDetectorType(detType); + string errorMess = host+string(" has unknown detector type \"")+ detName+string("\". Exiting GUI."); qDefs::ErrorMessage(errorMess,"Main"); exit(-1); } setWindowTitle("SLS Detector GUI : "+ - QString(slsDetectorBase::getDetectorType(myDet->getDetectorsType()).c_str())+ - " - "+QString(myDet->getHostname(detID).c_str())); + QString(slsDetectorBase::getDetectorType(detType).c_str())+ " - "+QString(host.c_str())); #ifdef VERBOSE - cout<getDetectorsType())<<"\t\t\tDetector : " - ""<getHostname(detID)<setOnline(slsDetectorDefs::ONLINE_FLAG); } @@ -204,27 +213,30 @@ void qDetectorMain::SetUpDetector(){ void qDetectorMain::Initialization(){ -/** Dockable Plot*/ +// Dockable Plot connect(dockWidgetPlot, SIGNAL(topLevelChanged(bool)), this,SLOT(ResizeMainWindow(bool))); -/** tabs */ +// tabs connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(Refresh(int)));//( QWidget*))); - /** Measurement tab*/ + // Measurement tab connect(tab_measurement, SIGNAL(StartSignal()), this,SLOT(EnableTabs())); connect(tab_measurement, SIGNAL(StopSignal()), this,SLOT(EnableTabs())); connect(tab_measurement, SIGNAL(CheckPlotIntervalSignal()), tab_plot,SLOT(SetFrequency())); - /** Plot tab */ + // Plot tab connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool))); -/** Plotting */ - /** When the acquisition is finished, must update the meas tab */ + // Actions tab + connect(tab_actions, SIGNAL(EnableScanBox(bool,int)), tab_plot,SLOT(EnableScanBox(bool,int))); + +// Plotting + // When the acquisition is finished, must update the meas tab connect(myPlot, SIGNAL(UpdatingPlotFinished()), this, SLOT(EnableTabs())); connect(myPlot, SIGNAL(UpdatingPlotFinished()), tab_measurement, SLOT(UpdateFinished())); connect(myPlot, SIGNAL(SetCurrentMeasurementSignal(int)), tab_measurement, SLOT(SetCurrentMeasurement(int))); -/** menubar */ - /** Modes Menu */ +// menubar + // Modes Menu connect(menuModes, SIGNAL(triggered(QAction*)), this,SLOT(EnableModes(QAction*))); - /** Utilities Menu */ + // Utilities Menu connect(menuUtilities, SIGNAL(triggered(QAction*)), this,SLOT(ExecuteUtilities(QAction*))); - /** Help Menu */ + // Help Menu connect(menuHelp, SIGNAL(triggered(QAction*)), this,SLOT(ExecuteHelp(QAction*))); } @@ -235,33 +247,34 @@ void qDetectorMain::Initialization(){ void qDetectorMain::EnableModes(QAction *action){ bool enable; - /**Set DebugMode */ + //Set DebugMode if(action==actionDebug){ enable = actionDebug->isChecked(); tabs->setTabEnabled(Debugging,enable); #ifdef VERBOSE - cout<<"Setting Debug Mode to "<isChecked(); #ifdef VERBOSE - cout<<"Setting Beamline Mode to "<isChecked(); tabs->setTabEnabled(Advanced,enable); + tab_settings->EnableExpertMode(enable); #ifdef VERBOSE - cout<<"Setting Expert Mode to "<isChecked(); if(enable) @@ -271,7 +284,7 @@ void qDetectorMain::EnableModes(QAction *action){ dockWidgetPlot->setFeatures(QDockWidget::NoDockWidgetFeatures); } #ifdef VERBOSE - cout<<"Setting Dockable Mode to "<getFilePath().c_str()); fName = QFileDialog::getOpenFileName(this, tr("Load Detector Setup"),fName, tr("Detector Setup files (*.det)")); - /** Gets called when cancelled as well*/ + // Gets called when cancelled as well if (!fName.isEmpty()){ myDet->retrieveDetectorSetup(string(fName.toAscii().constData())); qDefs::InfoMessage("The parameters have been successfully setup.","Main"); @@ -298,13 +311,13 @@ void qDetectorMain::ExecuteUtilities(QAction *action){ } else if(action==actionSaveSetup){ #ifdef VERBOSE - cout<<"Saving Setup"<getFilePath().c_str()); fName = QFileDialog::getSaveFileName(this, tr("Save Current Detector Setup"),fName, tr("Detector Setup files (*.det) ")); - /** Gets called when cancelled as well*/ + // Gets called when cancelled as well if (!fName.isEmpty()){ myDet->dumpDetectorSetup(string(fName.toAscii().constData())); qDefs::InfoMessage("The setup parameters have been successfully saved.","Main"); @@ -312,18 +325,18 @@ void qDetectorMain::ExecuteUtilities(QAction *action){ } else if(action==actionMeasurementWizard){ #ifdef VERBOSE - cout<<"Measurement Wizard"<getFilePath().c_str()); fName = QFileDialog::getOpenFileName(this, tr("Load Detector Configuration"),fName, tr("Configuration files (*.config)")); - /** Gets called when cancelled as well*/ + // Gets called when cancelled as well if (!fName.isEmpty()){ myDet->readConfigurationFile(string(fName.toAscii().constData())); qDefs::InfoMessage("The parameters have been successfully configured.","Main"); @@ -331,13 +344,13 @@ void qDetectorMain::ExecuteUtilities(QAction *action){ } else if(action==actionSaveConfiguration){ #ifdef VERBOSE - cout<<"Saving Configuration"<getFilePath().c_str()); fName = QFileDialog::getSaveFileName(this, tr("Save Current Detector Configuration"),fName, tr("Configuration files (*.config) ")); - /** Gets called when cancelled as well*/ + // Gets called when cancelled as well if (!fName.isEmpty()){ myDet->writeConfigurationFile(string(fName.toAscii().constData())); qDefs::InfoMessage("The configuration parameters have been successfully saved.","Main"); @@ -345,12 +358,12 @@ void qDetectorMain::ExecuteUtilities(QAction *action){ } else if(action==actionEnergyCalibration){ #ifdef VERBOSE - cout<<"Executing Energy Calibration"<A heading + qDefs::InfoMessage("

SLS Detector GUI version: 1.0

" + "Common GUI to control the SLS Detectors: " + "Mythen, Eiger, Gotthard and Agipd.

" + "It can be operated in parallel with the command line interface:
" + "sls_detector_put,
sls_detector_get,
sls_detector_acquire and
sls_detector_help.

" + "The software is still in progress. " + "Please report bugs to dhanya.maliakal@psi.ch.<\\p>","About SLS Detector GUI"); } } @@ -405,18 +421,18 @@ void qDetectorMain::Refresh(int index){ void qDetectorMain::ResizeMainWindow(bool b){ #ifdef VERBOSE - cout<<"Resizing Main Window: height:"<setMinimumHeight(0); - cout<<"undocking it from main window"<isTabEnabled(DataOutput)); // or use the Enable/Disable button - /** normal tabs*/ + // normal tabs tabs->setTabEnabled(DataOutput,enable); tabs->setTabEnabled(Actions,enable); tabs->setTabEnabled(Settings,enable); tabs->setTabEnabled(Messages,enable); - /** special tabs */ + // special tabs if(enable==false){ tabs->setTabEnabled(Debugging,enable); tabs->setTabEnabled(Advanced,enable); tabs->setTabEnabled(Developer,enable); } else{ - /** enable these tabs only if they were enabled earlier */ + // enable these tabs only if they were enabled earlier if(actionDebug->isChecked()) tabs->setTabEnabled(Debugging,enable); if(actionExpert->isChecked()) diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 5efbad5d5..a2f6d5e81 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -27,7 +27,7 @@ using namespace std; //------------------------------------------------------------------------------------------------------------------------------------------------- -qDrawPlot::qDrawPlot(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ +qDrawPlot::qDrawPlot(QWidget *parent,multiSlsDetector*& detector):QWidget(parent),myDet(detector){ SetupWidgetWindow(); Initialization(); StartStopDaqToggle(); //as default diff --git a/slsDetectorGui/src/qTabActions.cpp b/slsDetectorGui/src/qTabActions.cpp index 65422ee0f..ec6818dff 100644 --- a/slsDetectorGui/src/qTabActions.cpp +++ b/slsDetectorGui/src/qTabActions.cpp @@ -4,23 +4,24 @@ * Created on: May 10, 2012 * Author: l_maliakal_d */ -/** Qt Project Class Headers */ +// Qt Project Class Headers #include "qTabActions.h" #include "qDefs.h" #include "qActionsWidget.h" -/** Project Class Headers */ +// Project Class Headers #include "slsDetector.h" #include "multiSlsDetector.h" -/** Qt Include Headers */ +// Qt Include Headers #include -/** C++ Include Headers */ +// C++ Include Headers #include using namespace std; -qTabActions::qTabActions(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ +qTabActions::qTabActions(QWidget *parent,multiSlsDetector*& detector): + QWidget(parent),myDet(detector){ SetupWidgetWindow(); Initialization(); } @@ -36,32 +37,32 @@ qTabActions::~qTabActions(){ void qTabActions::SetupWidgetWindow(){ - /** Window Settings*/ + // Window Settings setFixedSize(705,350); setContentsMargins(0,0,0,0); - /** Scroll Area Settings*/ + // Scroll Area Settings QScrollArea *scroll = new QScrollArea; scroll->setWidget(this); scroll->setWidgetResizable(true); - /** Layout Settings*/ + // Layout Settings gridLayout = new QGridLayout(scroll); setLayout(gridLayout); gridLayout->setContentsMargins(10,5,0,0); gridLayout->setVerticalSpacing(2); - /** Buttongroup to know which +/- button was clicked*/ + // Buttongroup to know which +/- button was clicked group = new QButtonGroup(this); palette = new QPalette(); - /** For each level of Actions */ + // For each level of Actions for(int i=0;isetFixedSize(20,20); @@ -70,168 +71,80 @@ void qTabActions::SetupWidgetWindow(){ gridLayout->addWidget(btnExpand[i],(i*2),0); gridLayout->addWidget(lblName[i],(i*2),1); gridLayout->addWidget(actionWidget[i],(i*2)+1,1,1,2); +/* gridLayout->addWidget(btnExpand[i],(i*2),i); + gridLayout->addWidget(lblName[i],(i*2),i+1); + gridLayout->addWidget(actionWidget[i],(i*2)+1,i+1,1,2);*/ } - /** Label Values */ - lblName[0]->setText("Action at Start"); - lblName[1]->setText("Scan Level 0"); - lblName[2]->setText("Scan Level 1"); - lblName[3]->setText("Action before each Frame"); - lblName[4]->setText("Number of Positions"); - lblName[5]->setText("Header before Frame"); - lblName[6]->setText("Header after Frame"); - lblName[7]->setText("Action after each Frame"); - lblName[8]->setText("Action at Stop"); + // Label Values + lblName[Start]->setText("Action at Start"); + lblName[Scan0]->setText("Scan Level 0"); + lblName[Scan1]->setText("Scan Level 1"); + lblName[ActionBefore]->setText("Action before each Frame"); + lblName[NumPositions]->setText("Number of Positions"); + lblName[HeaderBefore]->setText("Header before Frame"); + lblName[HeaderAfter]->setText("Header after Frame"); + lblName[ActionAfter]->setText("Action after each Frame"); + lblName[Stop]->setText("Action at Stop"); - /** initially hide all the widgets*/ - for(int i=0;ihide(); + // initially hide all the widgets + for(int i=0;ihide(); } void qTabActions::Initialization(){ - connect(group,SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(Expand(QAbstractButton*))); + connect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*))); + connect(actionWidget[Scan0],SIGNAL(EnableScanBox(bool,int)), this,SIGNAL(EnableScanBox(bool,int))); + connect(actionWidget[Scan1],SIGNAL(EnableScanBox(bool,int)), this,SIGNAL(EnableScanBox(bool,int))); + + for(int i=0;iid(button); - /** Collapse */ + // Collapse if(!QString::compare(button->text(), "-")){ palette->setColor(QPalette::WindowText,Qt::black); lblName[index]->setPalette(*palette); actionWidget[index]->hide(); button->setText("+"); - if((index==1)||(index==2)) + if((index==Scan0)||(index==Scan1)) setFixedHeight(height()-130); else setFixedHeight(height()-30); }else{ - /** Expand */ + // Expand palette->setColor(QPalette::WindowText,QColor(0,0,200,255)); lblName[index]->setPalette(*palette); actionWidget[index]->show(); button->setText("-"); - if((index==1)||(index==2)) + if((index==Scan0)||(index==Scan1)) setFixedHeight(height()+130); else setFixedHeight(height()+30); } } +//------------------------------------------------------------------------------------------------------------------------------------------------- - - - - - - - - - - - - - - - - - - - - - - - -/* -void qTabActions::Initialization(){ - connect(radio0Constant, SIGNAL(toggled(bool)),this,SLOT(ChangeStepSize(bool))); - connect(radio0Specific, SIGNAL(toggled(bool)),this,SLOT(ChangeStepSize(bool))); - connect(radio0Value, SIGNAL(toggled(bool)),this,SLOT(ChangeStepSize(bool))); - connect(radio1Constant, SIGNAL(toggled(bool)),this,SLOT(ChangeStepSize(bool))); - connect(radio1Specific, SIGNAL(toggled(bool)),this,SLOT(ChangeStepSize(bool))); - connect(radio1Value, SIGNAL(toggled(bool)),this,SLOT(ChangeStepSize(bool))); - - connect(btntry, SIGNAL(clicked()),this,SLOT(Trial())); +void qTabActions::SetScript(const QString& fName,int index){ +#ifdef VERBOSE + cout << "Setting script file of action widget:" << index << " to " << fName.toAscii().constData() << endl; +#endif } - -void qTabActions::Enable(bool enable){ - - -} - - -void qTabActions::ChangeStepSize(bool b){ - * defaults - lbl0From->hide(); - lbl0Size->hide(); - lbl0To->hide(); - spin0From->hide(); - spin0Size->hide(); - spin0To->hide(); - combo0Specific->hide(); - btn0Browse->hide(); - disp0File->hide(); - lbl1From->hide(); - lbl1Size->hide(); - lbl1To->hide(); - spin1From->hide(); - spin1Size->hide(); - spin1To->hide(); - combo1Specific->hide(); - btn1Browse->hide(); - disp1File->hide(); - *Scan 0 - * constant step size - if(radio0Constant->isChecked()){ - lbl0From->show(); - lbl0Size->show(); - lbl0To->show(); - spin0From->show(); - spin0Size->show(); - spin0To->show(); - } - * specific values - else if(radio0Specific->isChecked()) - combo0Specific->show(); - * values from a file - else{ - btn0Browse->show(); - disp0File->show(); - } - *Scan 1 - * constant step size - if(radio1Constant->isChecked()){ - lbl1From->show(); - lbl1Size->show(); - lbl1To->show(); - spin1From->show(); - spin1Size->show(); - spin1To->show(); - } - * specific values - else if(radio1Specific->isChecked()) - combo1Specific->show(); - * values from a file - else{ - btn1Browse->show(); - disp1File->show(); - } - - - //groupBox->hide(); -} - - - //if(!QString::compare(btntry->text(),"+")){ -*/ //------------------------------------------------------------------------------------------------------------------------------------------------- void qTabActions::Refresh(){ diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp index f01985140..0dd12a472 100644 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -16,7 +16,7 @@ using namespace std; -qTabAdvanced::qTabAdvanced(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ +qTabAdvanced::qTabAdvanced(QWidget *parent,multiSlsDetector*& detector):QWidget(parent),myDet(detector){ setupUi(this); myDetType = (int)myDet->getDetectorsType(); SetupWidgetWindow(); diff --git a/slsDetectorGui/src/qTabDataOutput.cpp b/slsDetectorGui/src/qTabDataOutput.cpp index f860b8541..05faa7c85 100644 --- a/slsDetectorGui/src/qTabDataOutput.cpp +++ b/slsDetectorGui/src/qTabDataOutput.cpp @@ -4,14 +4,19 @@ * Created on: May 10, 2012 * Author: l_maliakal_d */ +/********************************************************************** + * TO DO + * 1. Rate correction auto: for eiger depends on settings, tdeadtime{vv,vv,vv} in postprocessing.h + * ********************************************************************/ + #include "qTabDataOutput.h" #include "qDefs.h" -/** Project Class Headers */ +// Project Class Headers #include "slsDetector.h" #include "multiSlsDetector.h" -/** Qt Include Headers */ +// Qt Include Headers #include -/** C++ Include Headers */ +// C++ Include Headers #include #include using namespace std; @@ -20,11 +25,12 @@ using namespace std; //------------------------------------------------------------------------------------------------------------------------------------------------- -qTabDataOutput::qTabDataOutput(QWidget *parent,slsDetectorUtils*& detector): - QWidget(parent),myDet(detector){ +qTabDataOutput::qTabDataOutput(QWidget *parent,multiSlsDetector*& detector,int detID): + QWidget(parent),myDet(detector),detID(detID){ setupUi(this); SetupWidgetWindow(); Initialization(); + Refresh(); } @@ -40,7 +46,12 @@ qTabDataOutput::~qTabDataOutput(){ void qTabDataOutput::SetupWidgetWindow(){ - dispOutputDir->setText(QString(myDet->getFilePath().c_str())); + // Detector Type + detType=myDet->getDetectorsType(); + + //rate correction - not for charge integrating detectors + if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::EIGER)) + chkRate->setEnabled(true); } @@ -48,18 +59,30 @@ void qTabDataOutput::SetupWidgetWindow(){ void qTabDataOutput::Initialization(){ + //output dir connect(dispOutputDir, SIGNAL(textChanged(const QString&)), this, SLOT(setOutputDir(const QString&))); connect(btnOutputBrowse, SIGNAL(clicked()), this, SLOT(browseOutputDir())); + //flat field correction + connect(chkFlatField, SIGNAL(toggled(bool)), this, SLOT(SetFlatField())); + connect(btnFlatField, SIGNAL(clicked()), this, SLOT(BrowseFlatFieldPath())); + //rate correction + connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + connect(radioAuto, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + connect(radioDeadTime, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + connect(spinDeadTime, SIGNAL(valueChanged(double)), this, SLOT(SetRateCorrection())); + //angular correction + connect(chkAngular, SIGNAL(toggled(bool)), this, SLOT(SetAngularCorrection())); + //discard bad channels + connect(chkDiscardBad, SIGNAL(toggled(bool)), this, SLOT(DiscardBadChannels())); + } - - //------------------------------------------------------------------------------------------------------------------------------------------------- void qTabDataOutput::setOutputDir(const QString& path){ myDet->setFilePath(string(path.toAscii().constData())); #ifdef VERBOSE - cout<<"Output Directory changed to :"<getFilePath()<getFilePath() << endl; #endif } @@ -67,20 +90,288 @@ void qTabDataOutput::setOutputDir(const QString& path){ //------------------------------------------------------------------------------------------------------------------------------------------------- -void qTabDataOutput::Refresh(){ - /** output dir*/ - dispOutputDir->setText(QString(myDet->getFilePath().c_str())); -} - - -//------------------------------------------------------------------------------------------------------------------------------------------------- - - void qTabDataOutput::browseOutputDir() { - QString directory = QFileDialog::getExistingDirectory(this,tr("Choose Output Directory "),dispOutputDir->text()); - if (!directory.isEmpty()) - dispOutputDir->setText(directory); + QString directory = QFileDialog::getExistingDirectory(this,tr("Choose Output Directory "),dispOutputDir->text()); + if (!directory.isEmpty()) + dispOutputDir->setText(directory); +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabDataOutput::SetFlatField(){ +#ifdef VERYVERBOSE + cout << "Entering Set Flat Field Correction Function" << endl; +#endif + // so that it doesnt call it twice + disconnect(dispFlatField, SIGNAL(editingFinished()), this, SLOT(SetFlatField())); + + //enable/disable + dispFlatField->setEnabled(chkFlatField->isChecked()); + btnFlatField->setEnabled(chkFlatField->isChecked()); + + if(chkFlatField->isChecked()){ + if(dispFlatField->text().isEmpty()){ + lblNote->show(); + chkFlatField->setPalette(lblNote->palette()); + chkFlatField->setText("Flat Field File:*"); +#ifdef VERBOSE + cout << "Flat Field File is not set." << endl; +#endif + }else{ + QString fName = dispFlatField->text(); + QString file = fName.section('/',-1); + QString dir = fName.section('/',0,-2,QString::SectionIncludeLeadingSep); + + lblNote->hide(); + chkFlatField->setPalette(chkRate->palette()); + chkFlatField->setText("Flat Field File:"); + //set ff dir + myDet->setFlatFieldCorrectionDir(dir.toAscii().constData()); + //set ff file and catch error if -1 + if(myDet->setFlatFieldCorrectionFile(file.toAscii().constData())<0){ + string sDir = dir.toAscii().constData(),sFile = file.toAscii().constData(); + if(sDir.length()<1) sDir = "/home"; + qDefs::WarningMessage("Invalid Flat Field file - "+sDir+sFile+ + ".\nUnsetting Flat Field.","Data Output"); + + //Unsetting flat field + myDet->setFlatFieldCorrectionFile(""); + dispFlatField->setText(""); + lblNote->show(); + chkFlatField->setPalette(lblNote->palette()); + chkFlatField->setText("Flat Field File:*"); +#ifdef VERBOSE + cout << "Invalid Flat Field File - "<< sDir << sFile << ". Unsetting Flat Field." << endl; +#endif + } + else{ +#ifdef VERBOSE + cout << "Setting flat field file to "<< dispFlatField->text().toAscii().constData() << endl; +#endif + } + } + }else{ + lblNote->hide(); + chkFlatField->setPalette(chkRate->palette()); + chkFlatField->setText("Flat Field File:"); + //Unsetting flat field + myDet->setFlatFieldCorrectionFile(""); + dispFlatField->setText(""); +#ifdef VERBOSE + cout << "Unsetting flat field correction file" << endl; +#endif + } + + connect(dispFlatField,SIGNAL(editingFinished()),this,SLOT(SetFlatField())); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qTabDataOutput::UpdateFlatFieldFromServer(){ + disconnect(dispFlatField, SIGNAL(editingFinished()), this, SLOT(SetFlatField())); + + dispFlatField->setText(QString(myDet->getFlatFieldCorrectionDir().c_str())+"/"+QString(myDet->getFlatFieldCorrectionFile().c_str())); +#ifdef VERBOSE + cout << "Getting flat field correction file" << dispFlatField->text().toAscii().constData() << endl; +#endif + //calls setflatfield to ensure the file still exists or disable it + if(!QString(myDet->getFlatFieldCorrectionFile().c_str()).compare("none")){ + dispFlatField->setText(""); + chkFlatField->setChecked(false); +#ifdef VERBOSE + cout << "Flat Field is not set." << endl; +#endif + } + else + chkFlatField->setChecked(true); + + lblNote->hide(); + connect(dispFlatField, SIGNAL(editingFinished()), this, SLOT(SetFlatField())); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qTabDataOutput::BrowseFlatFieldPath() +{ + QString fName = dispFlatField->text(); + QString dir = fName.section('/',0,-2,QString::SectionIncludeLeadingSep); + if(dir.isEmpty()) dir = "/home"; + fName = QFileDialog::getOpenFileName(this, + tr("Load Flat Field Correction File"),dir, + tr("Flat Field Correction Files(*.dat)"));//,0,QFileDialog::ShowDirsOnly); + if (!fName.isEmpty()){ + dispFlatField->setText(fName); + SetFlatField(); + } +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabDataOutput::SetRateCorrection(){ + disconnect(radioAuto, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + disconnect(radioDeadTime, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + disconnect(spinDeadTime, SIGNAL(valueChanged(double)), this, SLOT(SetRateCorrection())); + +#ifdef VERBOSE + cout << "Entering Set Rate Correction function" << endl; +#endif + slsDetector *s = myDet->getSlsDetector(detID); + if(chkRate->isChecked()){ + radioAuto->setEnabled(true); + radioDeadTime->setEnabled(true); + //set auto as default if nothing selected + if(!radioAuto->isChecked()&&!radioDeadTime->isChecked()) + radioAuto->setChecked(true); + //auto + if(radioAuto->isChecked()){ + spinDeadTime->setEnabled(false); + s->setRateCorrection(-1); +#ifdef VERBOSE + cout << "Setting rate corrections with default dead time" << endl; +#endif + }//custom dead time + else{ + spinDeadTime->setEnabled(true); + s->setRateCorrection((float)spinDeadTime->value()); +#ifdef VERBOSE + cout << "Setting rate corrections with dead time "<< spinDeadTime->value() << endl; +#endif + } + }//unsetting + else{ + radioAuto->setEnabled(false); + radioDeadTime->setEnabled(false); + spinDeadTime->setEnabled(false); + //Unsetting rate correction + + s->setRateCorrection(0); +#ifdef VERBOSE + cout << "Unsetting rate correction" << endl; +#endif + } + connect(radioAuto, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + connect(radioDeadTime, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + connect(spinDeadTime, SIGNAL(valueChanged(double)), this, SLOT(SetRateCorrection())); +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabDataOutput::UpdateRateCorrectionFromServer(){ + disconnect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + disconnect(radioAuto, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + disconnect(radioDeadTime, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + disconnect(spinDeadTime, SIGNAL(valueChanged(double)), this, SLOT(SetRateCorrection())); + + double rate; + slsDetector *s = myDet->getSlsDetector(detID); + rate = (double)s->getRateCorrectionTau(); +#ifdef VERBOSE + cout << "Getting rate correction from server:" << rate << " : "; +#endif + if(rate==0){ +#ifdef VERBOSE + cout << "None" << endl; +#endif + radioAuto->setEnabled(false); + radioDeadTime->setEnabled(false); + spinDeadTime->setEnabled(false); + + chkRate->setChecked(false); + }else if(rate<0){ +#ifdef VERBOSE + cout << "Auto" << endl; +#endif + radioAuto->setEnabled(true); + radioDeadTime->setEnabled(true); + spinDeadTime->setEnabled(false); + + chkRate->setChecked(true); + radioAuto->setChecked(true); + }else{ +#ifdef VERBOSE + cout << "Custom" << endl; +#endif + radioAuto->setEnabled(true); + radioDeadTime->setEnabled(true); + spinDeadTime->setEnabled(true); + + chkRate->setChecked(true); + radioDeadTime->setChecked(true); + spinDeadTime->setValue((double)rate); + } + + connect(chkRate, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + connect(radioAuto, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + connect(radioDeadTime, SIGNAL(toggled(bool)), this, SLOT(SetRateCorrection())); + connect(spinDeadTime, SIGNAL(valueChanged(double)), this, SLOT(SetRateCorrection())); +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabDataOutput::SetAngularCorrection(){ +#ifdef VERYVERBOSE + cout << "Entering Set Angular Correction function" << endl; +#endif + if(chkAngular->isChecked()){ + myDet->setAngularConversionFile("default"); +#ifdef VERBOSE + cout << "Setting angular conversion to default" << endl; +#endif + }else{ + myDet->setAngularConversionFile(""); +#ifdef VERBOSE + cout << "Unsetting angular correction" << endl; +#endif + } +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabDataOutput::DiscardBadChannels(){ +#ifdef VERYVERBOSE + cout << "Entering Discard bad channels function" << endl; +#endif + if(chkDiscardBad->isChecked()){ + myDet->setBadChannelCorrection("default"); +#ifdef VERBOSE + cout << "Setting bad channel correction to default" << endl; +#endif + }else{ + myDet->setBadChannelCorrection(""); +#ifdef VERBOSE + cout << "Unsetting bad channel correction" << endl; +#endif + } +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabDataOutput::Refresh(){ + // output dir + dispOutputDir->setText(QString(myDet->getFilePath().c_str())); + //flat field correction from server + UpdateFlatFieldFromServer(); + //rate correction - not for charge integrating detectors + if((detType == slsDetectorDefs::MYTHEN)||(detType == slsDetectorDefs::EIGER)) + UpdateRateCorrectionFromServer(); + //update angular conversion from server + int ang; + if(myDet->getAngularConversion(ang)) chkAngular->setChecked(true); + //discard bad channels from server + if(myDet->getBadChannelCorrection()) chkDiscardBad->setChecked(true); } diff --git a/slsDetectorGui/src/qTabDebugging.cpp b/slsDetectorGui/src/qTabDebugging.cpp index 2fa080cc2..451201ca0 100644 --- a/slsDetectorGui/src/qTabDebugging.cpp +++ b/slsDetectorGui/src/qTabDebugging.cpp @@ -6,17 +6,17 @@ */ #include "qTabDebugging.h" #include "qDefs.h" -/** Project Class Headers */ +// Project Class Headers #include "slsDetector.h" #include "multiSlsDetector.h" -/** C++ Include Headers */ +// C++ Include Headers #include using namespace std; -qTabDebugging::qTabDebugging(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ +qTabDebugging::qTabDebugging(QWidget *parent,multiSlsDetector*& detector):QWidget(parent),myDet(detector){ setupUi(this); SetupWidgetWindow(); Initialization(); @@ -33,6 +33,20 @@ qTabDebugging::~qTabDebugging(){ void qTabDebugging::SetupWidgetWindow(){ + // Detector Type + detType=myDet->getDetectorsType(); + + if(detType==slsDetectorDefs::EIGER) lblModule->setText("Half Module Number:"); + else lblModule->setText("Module Number:"); + + // loading combo box module numbers + int max = myDet->setNumberOfModules(GET_FLAG,slsDetectorDefs::X)*myDet->setNumberOfModules(GET_FLAG,slsDetectorDefs::Y); + for(int i=0;igetSlsDetector(i); + if(s->setTCPSocket()!=slsDetectorDefs::FAIL){ + comboModule->addItem(QString::number(i)); + } + } } diff --git a/slsDetectorGui/src/qTabDeveloper.cpp b/slsDetectorGui/src/qTabDeveloper.cpp index b0fcd68a9..c11f9c537 100644 --- a/slsDetectorGui/src/qTabDeveloper.cpp +++ b/slsDetectorGui/src/qTabDeveloper.cpp @@ -16,7 +16,7 @@ using namespace std; -qTabDeveloper::qTabDeveloper(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ +qTabDeveloper::qTabDeveloper(QWidget *parent,multiSlsDetector*& detector):QWidget(parent),myDet(detector){ setupUi(this); SetupWidgetWindow(); Initialization(); diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index bd4a78e6d..6120ef36f 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -25,7 +25,7 @@ using namespace std; //------------------------------------------------------------------------------------------------------------------------------------------------- -qTabMeasurement::qTabMeasurement(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot): +qTabMeasurement::qTabMeasurement(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot): QWidget(parent),myDet(detector),myPlot(plot){ setupUi(this); SetupWidgetWindow(); diff --git a/slsDetectorGui/src/qTabMessages.cpp b/slsDetectorGui/src/qTabMessages.cpp index fc7945fc4..94a7c5889 100644 --- a/slsDetectorGui/src/qTabMessages.cpp +++ b/slsDetectorGui/src/qTabMessages.cpp @@ -24,7 +24,7 @@ using namespace std; //------------------------------------------------------------------------------------------------------------------------------------------------- -qTabMessages::qTabMessages(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ +qTabMessages::qTabMessages(QWidget *parent,multiSlsDetector*& detector):QWidget(parent),myDet(detector){ SetupWidgetWindow(); Initialization(); } diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index ef49b62df..43312db8a 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -32,18 +32,9 @@ QString qTabPlot::defaultImageZAxisTitle("Intensity"); //------------------------------------------------------------------------------------------------------------------------------------------------- -qTabPlot::qTabPlot(QWidget *parent,slsDetectorUtils*& detector, qDrawPlot*& plot):QWidget(parent),myDet(detector),myPlot(plot){ +qTabPlot::qTabPlot(QWidget *parent,multiSlsDetector*& detector, qDrawPlot*& plot):QWidget(parent),myDet(detector),myPlot(plot){ setupUi(this); SetupWidgetWindow(); - /** Depending on whether the detector is 1d or 2d*/ - switch(myDet->getDetectorsType()){ - case slsDetectorDefs::MYTHEN: Select1DPlot(true); break; - case slsDetectorDefs::EIGER: Select1DPlot(false);break; - case slsDetectorDefs::GOTTHARD: Select1DPlot(true);break; - default: - cout<<"ERROR: Detector Type is Generic"<SetPlotTitle(defaultPlotTitle); dispTitle->setText(defaultPlotTitle); @@ -109,13 +103,18 @@ void qTabPlot::SetupWidgetWindow(){ stackedLayout->addWidget(w); stackedLayout->addWidget(spinNthFrame); - - - - stackWidget->setLayout(stackedLayout); + /** Depending on whether the detector is 1d or 2d*/ + switch(myDet->getDetectorsType()){ + case slsDetectorDefs::MYTHEN: Select1DPlot(true); break; + case slsDetectorDefs::EIGER: Select1DPlot(false);break; + case slsDetectorDefs::GOTTHARD: Select1DPlot(true);break; + default: + cout<<"ERROR: Detector Type is Generic"<setText(defaultImageZAxisTitle); myPlot->Select2DPlot(); } + + boxScan->setEnabled(false); } @@ -368,7 +369,7 @@ void qTabPlot::SetPlot(){ boxFrequency->setEnabled(false); boxPlotAxis->setEnabled(false); boxScan->setEnabled(false); - }else if(radioHistogram->isChecked()){ + }else { myPlot->EnablePlot(true); /**if enable is true, disable everything */ if(isOneD) box1D->show(); else box1D->hide(); @@ -377,25 +378,20 @@ void qTabPlot::SetPlot(){ boxSave->setEnabled(true); boxFrequency->setEnabled(true); boxPlotAxis->setEnabled(true); - boxScan->setEnabled(false); - }else{ - myPlot->EnablePlot(true); - /**if enable is true, disable everything */ - if(isOneD) box1D->show(); else box1D->hide(); - if(!isOneD) box2D->show(); else box2D->hide(); - boxSnapshot->setEnabled(true); - boxSave->setEnabled(true); - boxFrequency->setEnabled(true); - boxPlotAxis->setEnabled(true); - boxScan->setEnabled(true); + + if(radioHistogram->isChecked()) + boxScan->setEnabled(false); + else + //check first if there is a scan from actions tab + boxScan->setEnabled(false); } } //------------------------------------------------------------------------------------------------------------------------------------------------- -int qTabPlot::SetFrequency(){ - int ret=0; +void qTabPlot::SetFrequency(){ + disconnect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); @@ -411,7 +407,6 @@ int qTabPlot::SetFrequency(){ /* Get the time interval from gui in ms*/ timeMS = (qDefs::getNSTime((qDefs::timeUnit)comboTimeGapUnit->currentIndex(),spinTimeGap->value()))/(1e6); if(timeMSsetValue(minPlotTimer); @@ -431,7 +426,6 @@ int qTabPlot::SetFrequency(){ timeMS = (spinNthFrame->value())*acqPeriodMS; /** To make sure the period between plotting is not less than minimum plot timer in ms*/ if(timeMSPlot Tab: Interval between Plots - The nth Image must be larger.

" "Condition to be satisfied:\n(Acquisition Period)*(nth Image) >= 500ms." @@ -450,14 +444,49 @@ int qTabPlot::SetFrequency(){ connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); - - return ret; } //------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabPlot::EnableScanBox(bool enable,int id){ + cout<<"enable:"<setEnabled(false); + }//both are enabled + else if((scanLevel[0])&&(scanLevel[1])){ + //disable none and check the other + if(id) {radioLevel1->setEnabled(true);radioLevel1->setChecked(true);} + else {radioLevel0->setEnabled(true);radioLevel0->setChecked(true);} + }//either 1 is enabled/disabled + else{ + if(!boxScan->isEnabled()) { + boxScan->setEnabled(true); + radioFileIndex->setEnabled(false); + } + //disable one and check the other + if(id) { + radioLevel0->setEnabled(!enable); + radioLevel0->setChecked(!enable); + radioLevel1->setEnabled(enable); + radioLevel1->setChecked(enable); + }else{ + radioLevel0->setEnabled(enable); + radioLevel0->setChecked(enable); + radioLevel1->setEnabled(!enable); + radioLevel1->setChecked(!enable); + } + } +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + void qTabPlot::Refresh(){ SetFrequency(); } diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index deba6aea2..1f61f8ce5 100644 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -16,8 +16,8 @@ using namespace std; //------------------------------------------------------------------------------------------------------------------------------------------------- -qTabSettings::qTabSettings(QWidget *parent,slsDetectorUtils*& detector,int detID): - QWidget(parent),myDet(detector),detID(detID){ +qTabSettings::qTabSettings(QWidget *parent,multiSlsDetector*& detector,int detID): + QWidget(parent),myDet(detector),detID(detID), expertMode(false){ setupUi(this); SetupWidgetWindow(); @@ -41,6 +41,22 @@ void qTabSettings::SetupWidgetWindow(){ SetupDetectorSettings(); comboSettings->setCurrentIndex(myDet->getSettings(detID)); + /**expert mode is not enabled initially*/ + lblThreshold->setEnabled(false); + spinThreshold->setEnabled(false); + + /** Number of Modules */ + spinNumModules->setMaximum(myDet->getMaxNumberOfModules()); + spinNumModules->setValue(myDet->setNumberOfModules()); + + /** Dynamic Range */ + switch(myDet->setDynamicRange(-1)){ + case 32: comboDynamicRange->setCurrentIndex(0); break; + case 16: comboDynamicRange->setCurrentIndex(1); break; + case 8: comboDynamicRange->setCurrentIndex(2); break; + case 4: comboDynamicRange->setCurrentIndex(3); break; + default: comboDynamicRange->setCurrentIndex(0); break; + } } @@ -107,15 +123,12 @@ void qTabSettings::SetupDetectorSettings(){ qDefs::ErrorMessage("Unknown Detector Settings retrieved from detector. " "Exiting GUI.","Settings"); #ifdef VERBOSE - cout<<"ERROR: Unknown Detector Settings retrieved from detector."<setCurrentIndex((int)sett); - - } + else comboSettings->setCurrentIndex((int)sett); } } @@ -123,7 +136,13 @@ void qTabSettings::SetupDetectorSettings(){ void qTabSettings::Initialization(){ /** Settings */ - connect(comboSettings,SIGNAL(currentIndexChanged(int)),this,SLOT(setSettings(int))); + connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); + /** Number of Modules */ + connect(spinNumModules, SIGNAL(valueChanged(int)), this, SLOT(SetNumberOfModules(int))); + /** Dynamic Range */ + connect(comboDynamicRange, SIGNAL(activated(int)), this, SLOT(SetDynamicRange(int))); + /** Threshold */ + connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); } //------------------------------------------------------------------------------------------------------------------------------------------------- @@ -142,11 +161,91 @@ void qTabSettings::setSettings(int index){ } slsDetectorDefs::detectorSettings sett = myDet->setSettings((slsDetectorDefs::detectorSettings)index,detID); #ifdef VERBOSE - cout<<"Settings have been set to "<slsDetectorBase::getDetectorSettings(sett)<slsDetectorBase::getDetectorSettings(sett) << endl; #endif + if((detType==slsDetectorDefs::GOTTHARD)||(detType==slsDetectorDefs::AGIPD)){ + lblThreshold->setEnabled(false); + spinThreshold->setEnabled(false); + }else{ + if((index==Undefined)||(index==Uninitialized)){ + + lblThreshold->setEnabled(false); + spinThreshold->setEnabled(false); + }else{ + lblThreshold->setEnabled(expertMode); + spinThreshold->setEnabled(expertMode); + if(expertMode) SetEnergy(); + } + } +} + +//------------------------------------------------------------------------------------------------------------------------------------------------- + +void qTabSettings::SetNumberOfModules(int index){ +#ifdef VERBOSE + cout << "Setting number of modules to "<< index << endl; +#endif + int i = myDet->setNumberOfModules(index); + if(index!=i) + qDefs::WarningMessage("Number of modules cannot be set for this value.","Settings"); +#ifdef VERBOSE + cout << "ERROR: Setting number of modules to "<< i << endl; +#endif + spinNumModules->setValue(i); +} + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabSettings::SetDynamicRange(int index){ + int ret,dr; + switch (index) { + case 0: dr=32; break; + case 1: dr=16; break; + case 2: dr=8; break; + case 3: dr=4; break; + default: dr=32; break; + } +#ifdef VERBOSE + cout << "Setting dynamic range to "<< dr << endl; +#endif + ret=myDet->setDynamicRange(dr); + if(ret!=dr){ + qDefs::WarningMessage("Dynamic Range cannot be set for this value.","Settings"); +#ifdef VERBOSE + cout << "ERROR: Setting dynamic range to "<< ret << endl; +#endif + switch(ret){ + case 32: comboDynamicRange->setCurrentIndex(0); break; + case 16: comboDynamicRange->setCurrentIndex(1); break; + case 8: comboDynamicRange->setCurrentIndex(2); break; + case 4: comboDynamicRange->setCurrentIndex(3); break; + default: comboDynamicRange->setCurrentIndex(0); break; + } + } +}; + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qTabSettings::SetEnergy(){ +#ifdef VERBOSE + cout << "Settings threshold energy to "<< index << endl; +#endif + int index = spinThreshold->value(); + myDet->setThresholdEnergy(index); + int ret = (int)myDet->getThresholdEnergy(); + if(ret!=index){ + qDefs::WarningMessage("Threshold energy could not be set.","Settings"); + disconnect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); + spinThreshold->setValue(ret); + connect(spinThreshold, SIGNAL(valueChanged(int)), this, SLOT(SetEnergy())); + } } + //------------------------------------------------------------------------------------------------------------------------------------------------- @@ -154,6 +253,33 @@ void qTabSettings::Refresh(){ /** Settings */ SetupDetectorSettings(); comboSettings->setCurrentIndex(myDet->getSettings(detID)); + /** Number of Modules */ + spinNumModules->setValue(myDet->setNumberOfModules()); + + /** Dynamic Range */ + switch(myDet->setDynamicRange(-1)){ + case 32: comboDynamicRange->setCurrentIndex(0); break; + case 16: comboDynamicRange->setCurrentIndex(1); break; + case 8: comboDynamicRange->setCurrentIndex(2); break; + case 4: comboDynamicRange->setCurrentIndex(3); break; + default: comboDynamicRange->setCurrentIndex(0); break; + } + + if((detType==slsDetectorDefs::GOTTHARD)||(detType==slsDetectorDefs::AGIPD)){ + lblThreshold->setEnabled(false); + spinThreshold->setEnabled(false); + }else{ + if((comboSettings->currentIndex()==Undefined)||(comboSettings->currentIndex()==Uninitialized)){ + lblThreshold->setEnabled(false); + spinThreshold->setEnabled(false); + }else{ + lblThreshold->setEnabled(expertMode); + spinThreshold->setEnabled(expertMode); + if(expertMode) SetEnergy(); + } + } + + }