diff --git a/slsDetectorGui/forms/form_tab_dataoutput.ui b/slsDetectorGui/forms/form_tab_dataoutput.ui index 82f060c07..f36c57116 100644 --- a/slsDetectorGui/forms/form_tab_dataoutput.ui +++ b/slsDetectorGui/forms/form_tab_dataoutput.ui @@ -6,7 +6,7 @@ 0 0 - 734 + 775 339 @@ -36,7 +36,7 @@ 20 75 - 691 + 731 206 @@ -48,7 +48,7 @@ 10 20 - 671 + 711 181 @@ -174,7 +174,7 @@ 19 20 - 701 + 746 41 @@ -189,7 +189,7 @@ 0 6 - 691 + 731 28 diff --git a/slsDetectorGui/forms/form_tab_measurement.ui b/slsDetectorGui/forms/form_tab_measurement.ui index b3a67bf20..c1e0dc1da 100644 --- a/slsDetectorGui/forms/form_tab_measurement.ui +++ b/slsDetectorGui/forms/form_tab_measurement.ui @@ -137,9 +137,9 @@ - 189 - 189 - 189 + 0 + 0 + 0 @@ -153,9 +153,9 @@ 30 - 179 + 153 319 - 90 + 116 @@ -174,7 +174,7 @@ 10 - 50 + 75 300 23 @@ -187,7 +187,7 @@ 10 - 30 + 25 91 16 @@ -200,7 +200,7 @@ 100 - 31 + 25 101 16 @@ -209,6 +209,47 @@ 0 + + + + 150 + 45 + 76 + 16 + + + + + 0 + 0 + + + + + 60 + 0 + + + + 0 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + 10 + 45 + 136 + 16 + + + + Current Measurement: + + @@ -291,6 +332,9 @@ + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + @@ -330,6 +374,9 @@ Frame period between exposures. #period# + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + 9 @@ -352,6 +399,9 @@ 0 + + Qt::LeftToRight + 2 @@ -424,6 +474,9 @@ + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + @@ -475,6 +528,9 @@ + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + @@ -581,6 +637,9 @@ + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + @@ -620,8 +679,11 @@ Exposure time of each frame. #exptime# + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + - 9 + 5 0.000000000000000 @@ -645,6 +707,9 @@ 0 + + Qt::LeftToRight + 2 @@ -705,8 +770,11 @@ Frame period between exposures. #period# + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + - 9 + 5 2000000000.000000000000000 @@ -727,6 +795,9 @@ 0 + + Qt::LeftToRight + 2 @@ -816,7 +887,7 @@ - + @@ -835,7 +906,7 @@ - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -878,7 +949,7 @@ - Run Index: + Start Run Index: @@ -900,6 +971,9 @@ + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + @@ -914,65 +988,6 @@ - - - - - 0 - 0 - - - - - 60 - 0 - - - - - - - - - 0 - 0 - 127 - - - - - - - - - 0 - 0 - 127 - - - - - - - - - 193 - 193 - 193 - - - - - - - - 0 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index fdd0b5018..5d3607950 100644 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -28,15 +28,602 @@ 1000 + + + + + + + 0 + 0 + 30 + + + + + + + + + 0 + 0 + 30 + + + + + + + + + 0 + 0 + 30 + + + + + + Form + + + true + + + + 15 + 70 + 371 + 51 + + + + 2D Plot Options + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + + + 10 + 20 + 361 + 26 + + + + + + + + 0 + 0 + + + + Interpolate + + + + + + + + 0 + 0 + + + + Contour + + + + + + + + 0 + 0 + + + + Log Scale (Z) + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 33 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 33 + 20 + + + + + + + + + + + 15 + 70 + 371 + 51 + + + + 1D Plot Options + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + + + 10 + 20 + 356 + 26 + + + + + + + + 0 + 0 + + + + Superimpose + + + false + + + + + + + + 0 + 0 + + + + Line + + + + + + + + 0 + 0 + + + + Points + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 150 + 10 + + + + + + + + + + 118 + 20 + 126 + 23 + + + + + 1 + + + + + false + + + + 0 + 0 + + + + Persistency: + + + + + + + false + + + + 0 + 0 + + + + + 40 + 16777215 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 1 + + + 10 + + + 1 + + + + + + + + + + 410 + 70 + 351 + 51 + + + + Save Image + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + + + 80 + 20 + 271 + 26 + + + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + + + + + + 0 + 0 + + + + Automatic File Name + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 18 + 20 + + + + + + + + + 0 + 0 + + + + Save All + + + + + + + + + 11 + 19 + 70 + 25 + + + + + 0 + 0 + + + + + 70 + 16777215 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + Qt::NoFocus + + + Save + + + + + + + 410 + 5 + 351 + 51 + + + + Scan - Y Axis Values + + + true + + + false + + + + + 10 + 20 + 337 + 26 + + + + + 0 + + + + + + 0 + 0 + + + + Level 0 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 11 + 10 + + + + + + + + + 0 + 0 + + + + Level 1 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 11 + 10 + + + + + + + + + 0 + 0 + + + + File Index + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 11 + 10 + + + + + + + + + 0 + 0 + + + + All Frames + + + true + + + + + + - 10 + 15 200 - 751 + 746 141 @@ -54,7 +641,7 @@ 10 15 - 731 + 726 121 @@ -405,495 +992,15 @@ - - - true - - - - 430 - 70 - 331 - 51 - - - - 2D Plot Options - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - 10 - 20 - 321 - 22 - - - - - - - - 0 - 0 - - - - Interpolate - - - - - - - - 0 - 0 - - - - Contour - - - - - - - - 0 - 0 - - - - Log Scale (Z) - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - 10 - 70 - 391 - 51 - - - - 1D Plot Options - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - 10 - 20 - 376 - 21 - - - - - - - - 0 - 0 - - - - Superimpose - - - false - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 10 - - - - - - - - - 0 - 0 - - - - Line - - - - - - - - 0 - 0 - - - - Points - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - 1 - - - - - false - - - - 0 - 0 - - - - Persistency: - - - - - - - false - - - - 0 - 0 - - - - - 40 - 16777215 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 1 - - - 10 - - - 1 - - - - - - - - - - - - 10 - 135 - 391 - 51 - - - - Save Image - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - 10 - 15 - 382 - 31 - - - - - - - - 0 - 0 - - - - Qt::NoFocus - - - Save - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 40 - 20 - - - - - - - - Automatic File Name - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Save All - - - - - - - - - true - - - - 430 - 135 - 331 - 51 - - - - Snapshot - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - - 10 - 15 - 311 - 31 - - - - - - - - 0 - 0 - - - - Qt::NoFocus - - - Create - - - false - - - - - - - - 0 - 0 - - - - Qt::NoFocus - - - Close All - - - false - - - - - - - - 0 - 0 - - - - Qt::NoFocus - - - Save All - - - false - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 30 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 30 - 20 - - - - - - - true - 10 - 10 - 391 + 15 + 5 + 371 51 @@ -911,8 +1018,8 @@ 10 20 - 381 - 23 + 361 + 26 @@ -968,7 +1075,7 @@ - 50 + 45 10 @@ -984,7 +1091,7 @@ - 50 + 45 10 @@ -993,52 +1100,316 @@ - + - 430 - 10 - 331 - 51 + 15 + 137 + 371 + 49 - Scan - Y Axis Values + Interval between Plots - - true + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - + false - + - 11 - 20 - 316 - 23 + 10 + 16 + 351 + 26 - + 0 - + - + 0 0 - - Level 0 + + + 150 + 0 + + + + 16777215 + 16777215 + + + + + + + + + 11 + 11 + 11 + + + + + + + 20 + 20 + 20 + + + + + + + + + 11 + 11 + 11 + + + + + + + 20 + 20 + 20 + + + + + + + + + 119 + 119 + 119 + + + + + + + 20 + 20 + 20 + + + + + + + + 0 + + + + Time Interval + + + + + Every nth Image + + - + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 80 + 20 + + + + + + + + + 0 + 0 + + + + + 140 + 21 + + + + + + + + + + true + + + + 410 + 135 + 351 + 51 + + + + Snapshot + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + + + 10 + 15 + 336 + 31 + + + + + + + + 0 + 0 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + Qt::NoFocus + + + Create + + + false + + + + + + + + 0 + 0 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + Qt::NoFocus + + + Close All + + + false + + + + + Qt::Horizontal @@ -1047,27 +1418,14 @@ - 5 - 10 + 40 + 20 - - - - - 0 - 0 - - - - Level 1 - - - - - + + Qt::Horizontal @@ -1076,54 +1434,65 @@ - 5 - 10 + 40 + 20 - - + + - + 0 0 - - File Index + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 10 - - - - - - - - - 0 - 0 - + + Qt::NoFocus - All Frames + Save All - - true + + false diff --git a/slsDetectorGui/include/qDefs.h b/slsDetectorGui/include/qDefs.h index 5167465a4..e094b4edc 100644 --- a/slsDetectorGui/include/qDefs.h +++ b/slsDetectorGui/include/qDefs.h @@ -57,8 +57,8 @@ public: * @param value time * returns time value in ns */ - static float getNSTime(timeUnit unit, float value){ - float valueNS=value; + static double getNSTime(timeUnit unit, double value){ + double valueNS=value; switch(unit){ case HOURS: valueNS*=60; case MINUTES: valueNS*=60; @@ -78,12 +78,12 @@ public: * @param value time in seconds * returns the corresponding time value */ - static float getCorrectTime(timeUnit& unit, float value){ + static double getCorrectTime(timeUnit& unit, double value){ int intUnit = (int)SECONDS; /** hr, min, sec */ if(value>=1){ - float newVal = value; + double newVal = value; while((newVal>=1)&&(intUnit>=(int)HOURS)){ /** value retains the old value */ value = newVal; @@ -105,16 +105,31 @@ public: } }; +//------------------------------------------------------------------------------------------------------------------------------------------------- + + /**displays an warning message + * @param warningMessage the message to be displayed + * @param source is the tab or the source of the warning + * */ + static void WarningMessage(string warningMessage,string source) + { + static QMessageBox* warningBox; + source.append(": WARNING"); + warningBox= new QMessageBox(QMessageBox::Warning,source.c_str(),tr(warningMessage.c_str()),QMessageBox::Ok, warningBox); + warningBox->exec(); + } + //------------------------------------------------------------------------------------------------------------------------------------------------- /**displays an error message * @param errorMessage the message to be displayed * @param source is the tab or the source of the error * */ - static void ErrorMessage(string errorMessage,char source[]) + static void ErrorMessage(string errorMessage,string source) { static QMessageBox* errorBox; - errorBox= new QMessageBox(QMessageBox::Warning,source,tr(errorMessage.c_str()),QMessageBox::Ok, errorBox); + source.append(": ERROR"); + errorBox= new QMessageBox(QMessageBox::Critical,source.c_str(),tr(errorMessage.c_str()),QMessageBox::Ok, errorBox); errorBox->exec(); } @@ -124,13 +139,25 @@ public: * @param infoMessage the message to be displayed * @param source is the tab or the source of the information * */ - static void InfoMessage(string infoMessage,char source[]) + static void InfoMessage(string infoMessage,string source) { static QMessageBox* msgBox; - msgBox= new QMessageBox(QMessageBox::Information,source,tr(infoMessage.c_str()),QMessageBox::Ok, msgBox); + source.append(": INFORMATION"); + msgBox= new QMessageBox(QMessageBox::Information,source.c_str(),tr(infoMessage.c_str()),QMessageBox::Ok, msgBox); msgBox->exec(); } +//------------------------------------------------------------------------------------------------------------------------------------------------- + + /** range of x and y axes + */ + enum range{ + XMINIMUM, + XMAXIMUM, + YMINIMUM, + YMAXIMUM + }; + //------------------------------------------------------------------------------------------------------------------------------------------------- }; diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index 5138cf023..4504b6d17 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -14,17 +14,19 @@ class slsDetectorUtils; /** Qt Project Class Headers */ #include "SlsQt1DPlot.h" #include "SlsQt2DPlotLayout.h" +#include "qDefs.h" class SlsQt1DPlot; class SlsQt2DPlotLayout; class qCloneWidget; /** Qt Include Headers */ - #include #include #include #include #include +/** C++ Include Headers */ + #define MAX_1DPLOTS 10 @@ -40,50 +42,57 @@ public: /** Destructor */ ~qDrawPlot(); - /**is an acquisition running */ + /**is an acquisition running , need it to prevent measurement tab + * from being refreshed when switching tabs during acquisition */ bool isRunning(){return running;}; - /** Number of x axis pixels */ - int GetPixelsX(){return nPixelsX;}; - /** Number of y axis pixels */ - int GetPixelsY(){return nPixelsY;}; - /** sets plot Title */ - void SetPlotTitle(QString title) {boxPlot->setTitle(title);} - /** sets 1D X Axis Title */ - void SetHistXAxisTitle(QString title) {histXAxisTitle = title;} - /** sets 1D Y Axis Title */ - void SetHistYAxisTitle(QString title) {histYAxisTitle = title;} - /** sets 2D X Axis Title */ - void SetImageXAxisTitle(QString title) {imageXAxisTitle = title;} - /** sets 2D Y Axis Title */ - void SetImageYAxisTitle(QString title) {imageYAxisTitle = title;} - /** sets 2D Z Axis Title */ - void SetImageZAxisTitle(QString title) {imageZAxisTitle = title;} - /** Sets X min and max */ - void SetXMinMax(double min,double max) {if(plot_in_scope==1)plot1D->SetXMinMax(min,max); else plot2D->GetPlot()->SetXMinMax(min,max);}; - /** Sets Y min and max */ - void SetYMinMax(double min,double max) {if(plot_in_scope==1)plot1D->SetYMinMax(min,max); else plot2D->GetPlot()->SetYMinMax(min,max);}; - /** Gets X min */ - double GetXMinimum(){if(plot_in_scope==1)return plot1D->GetXMinimum(); else return plot2D->GetPlot()->GetXMinimum();}; - /** Gets X max */ - double GetXMaximum(){if(plot_in_scope==1)return plot1D->GetXMaximum(); else return plot2D->GetPlot()->GetXMaximum();}; - /** Gets Y min */ - double GetYMinimum(){if(plot_in_scope==1)return plot1D->GetYMinimum(); else return plot2D->GetPlot()->GetYMinimum();}; - /** Gets Y max */ - double GetYMaximum(){if(plot_in_scope==1)return plot1D->GetYMaximum(); else return plot2D->GetPlot()->GetYMaximum();}; - /** Disables zoom if any of the axes range are checked and fixed with a value */ - void DisableZoom(bool disable); /** gets the progress of acquisition to the measurement tab*/ int GetProgress(){return progress;}; + + /** sets plot Title */ + void SetPlotTitle(QString title) {boxPlot->setTitle(title);} + /** sets 1D X Axis Title */ + void SetHistXAxisTitle(QString title) {histXAxisTitle = title;} + /** sets 1D Y Axis Title */ + void SetHistYAxisTitle(QString title) {histYAxisTitle = title;} + /** sets 2D X Axis Title */ + void SetImageXAxisTitle(QString title) {imageXAxisTitle = title;} + /** sets 2D Y Axis Title */ + void SetImageYAxisTitle(QString title) {imageYAxisTitle = title;} + /** sets 2D Z Axis Title */ + void SetImageZAxisTitle(QString title) {imageZAxisTitle = title;} + /** Disables zoom if any of the axes range are checked and fixed with a value */ + void DisableZoom(bool disable); /** Enables plot from the plot tab*/ void EnablePlot(bool enable); - /** To know whether 1d started*/ - bool DoesPlotExist(){return plotExists;}; + + /** Its a reminder to update plot to set the xy range + * This is done only when there is a plot to update */ + void SetXYRange(bool changed){XYRangeChanged = changed;}; + /**Sets the min/max for x/y + * @param val is the value to be set + * @param xy is xmin,xmax,ymin or ymax */ + void SetXYRangeValues(double val,qDefs::range xy){XYRangeValues[xy]=val;}; + /**Sets if min/max for x/y is enabled + * @param changed is if this has been changed + * @param xy is xmin,xmax,ymin or ymax */ + void IsXYRangeValues(bool changed,qDefs::range xy){IsXYRange[xy]=changed;}; + + /** Get minimum Plot timer - between plots */ + double GetMinimumPlotTimer(){return PLOT_TIMER_MS;}; + /** Set Plot timer - between plots in ms*/ + void SetPlotTimer(double time){timerValue = time;}; + /** Set Plot frame factor - between plots */ + void SetFrameFactor(int frame){frameFactor = frame;}; /** Starts or stop acquisition * Calls startDaq() function * @param stop_if_running is 0 to stop acquisition and 1 to start acquisition */ void StartStopDaqToggle(bool stop_if_running=0); + /** Set number of measurements + * @param num number of measurements to be set */ + void setNumMeasurements(int num); + private: /** The sls detector object */ @@ -171,14 +180,40 @@ private: double* yvalues[MAX_1DPLOTS]; /** temporary Image Values in 2D */ double* image_data; - //bool gui_acquisition_thread_running; + + /**persistency to be reached*/ int persistency; + /** persistency takes time to reach as it increases per frame + * this is the current one */ int currentPersistency; + /** to update the progress for each getData() so that + * measurement tab can request on a timer basis*/ int progress; + /**If plot is enabled from plot tab*/ bool plotEnable; - bool plotExists; + + + /**if an acquisition is running, so as not to refresh tab + * and also to update plot only if running (while creating clones)*/ bool running; + /** if the min/max of x and y has been changed, + * to notify while plotting */ + bool XYRangeChanged; + /**the specific min/max of x/y*/ + double XYRangeValues[4]; + /**if the specific min/max of x/y is enabled */ + bool IsXYRange[4]; + + /** Default timer between plots*/ + static const double PLOT_TIMER_MS = 500; + /** Specific timer value between plots */ + double timerValue; + /** every nth frame when to plot */ + int frameFactor; + bool plotLock; + + /** Initializes all its members and the thread */ void Initialization(); /** Sets up the widget */ @@ -214,9 +249,6 @@ private: public slots: -/** Set number of measurements - * @param num number of measurements to be set */ -void setNumMeasurements(int num); /** To select 1D or 2D plot @param i is 1 for 1D, else 2D plot */ void SelectPlot(int i=2); @@ -250,6 +282,7 @@ void StartDaq(bool start); void CloneCloseEvent(int id); + signals: void UpdatingPlotFinished(); void InterpolateSignal(bool); @@ -258,7 +291,6 @@ void LogzSignal(bool); void SetZRangeSignal(double,double); void EnableZRangeSignal(bool); void SetCurrentMeasurementSignal(int); - }; diff --git a/slsDetectorGui/include/qTabMeasurement.h b/slsDetectorGui/include/qTabMeasurement.h index 447c4ff02..c65820f2e 100644 --- a/slsDetectorGui/include/qTabMeasurement.h +++ b/slsDetectorGui/include/qTabMeasurement.h @@ -52,6 +52,10 @@ private: QTimer *progressTimer; + int numMeasurement; + + int currentMeasurement; + /** methods */ /** Sets up the widget */ @@ -91,6 +95,10 @@ void UpdateFinished(); void SetCurrentMeasurement(int val); private slots: +/** Set number of measurements + * @param num number of measurements to be set */ +void setNumMeasurements(int num); + /** Set file name * @param fName name of file */ @@ -150,6 +158,7 @@ signals: void StartSignal(); void StopSignal(); +void CheckPlotIntervalSignal(); }; diff --git a/slsDetectorGui/include/qTabMessages.h b/slsDetectorGui/include/qTabMessages.h index 972160300..bd8be85b6 100644 --- a/slsDetectorGui/include/qTabMessages.h +++ b/slsDetectorGui/include/qTabMessages.h @@ -70,6 +70,8 @@ void SaveLog(); /** Clear Log to File*/ void ClearLog(); + + }; diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h index 957347e30..94d5f1344 100644 --- a/slsDetectorGui/include/qTabPlot.h +++ b/slsDetectorGui/include/qTabPlot.h @@ -14,6 +14,8 @@ class slsDetectorUtils; /** Qt Project Class Headers */ class qDrawPlot; +/** Qt Include Headers */ +#include /** *@short sets up the Plot parameters @@ -33,6 +35,9 @@ public: */ ~qTabPlot(); + /** To refresh and update widgets + */ + void Refresh(); private: @@ -45,6 +50,11 @@ private: /** 1d/2d plot */ bool isOneD; + QStackedLayout* stackedLayout; + QSpinBox *spinNthFrame; + QDoubleSpinBox *spinTimeGap; + QComboBox *comboTimeGapUnit; + /** some Default Values */ static QString defaultPlotTitle; static QString defaultHistXAxisTitle; @@ -66,7 +76,10 @@ private: public slots: - +/** Set frequency between plots + * returns 0 if there were no errors(important + * while editing acquisition period in measurement tab) */ +int SetFrequency(); @@ -94,8 +107,7 @@ void SetZRange(); void EnableZRange(); /** Set Plot to none, data graph, histogram*/ void SetPlot(); -/** Enable Histogram */ -void EnableHistogram(bool enable); + signals: void DisableZoomSignal(bool); diff --git a/slsDetectorGui/src/qCloneWidget.cpp b/slsDetectorGui/src/qCloneWidget.cpp index 52bb930f2..c0345813b 100644 --- a/slsDetectorGui/src/qCloneWidget.cpp +++ b/slsDetectorGui/src/qCloneWidget.cpp @@ -183,12 +183,13 @@ void qCloneWidget::SavePlot(){ QPainter painter(&img); cloneBox->render(&painter); - fName = QFileDialog::getSaveFileName(this,tr("Save Snapshot "),fName,tr("Images (*.png *.xpm *.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::InfoMessage("The SnapShot has been successfully saved","Snapshot: Information"); + qDefs::InfoMessage("The SnapShot has been successfully saved","Snapshot"); else - qDefs::ErrorMessage("ERROR: Attempt to save snapshot failed. Wrong Format","Snapshot: WARNING"); + qDefs::WarningMessage("Attempt to save snapshot failed.\n" + "Formats: .png, .jpg, .xpm.","Snapshot"); } //------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index aa8a1bffb..0730216d4 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -171,8 +171,7 @@ void qDetectorMain::SetUpDetector(){ #endif char cIndex[10]; sprintf(cIndex,"%d",detID); - qDefs::ErrorMessage(string("ERROR: No Detector Connected at " - "id : ")+string(cIndex),"Main: ERROR"); + qDefs::ErrorMessage(string("No Detector Connected at id : ")+string(cIndex),"Main"); exit(-1); } else{ @@ -184,9 +183,9 @@ void qDetectorMain::SetUpDetector(){ default: string detName = myDet->slsDetectorBase::getDetectorType(myDet->getDetectorsType()); string hostname = myDet->getHostname(detID); - string errorMess = string("ERROR: ")+hostname+string(" has " - "unknown detector type \"")+detName+string("\". Exiting GUI."); - qDefs::ErrorMessage(errorMess,"Main: ERROR"); + string errorMess = hostname+string(" has unknown detector type \"")+ + detName+string("\". Exiting GUI."); + qDefs::ErrorMessage(errorMess,"Main"); exit(-1); } setWindowTitle("SLS Detector GUI : "+ @@ -212,6 +211,7 @@ void qDetectorMain::Initialization(){ /** 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 */ connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool))); /** Plotting */ @@ -293,7 +293,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){ /** Gets called when cancelled as well*/ if (!fName.isEmpty()){ myDet->retrieveDetectorSetup(string(fName.toAscii().constData())); - qDefs::InfoMessage("The parameters have been successfully setup.","Main: Information"); + qDefs::InfoMessage("The parameters have been successfully setup.","Main"); } } else if(action==actionSaveSetup){ @@ -307,7 +307,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){ /** 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: Information"); + qDefs::InfoMessage("The setup parameters have been successfully saved.","Main"); } } else if(action==actionMeasurementWizard){ @@ -326,7 +326,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){ /** Gets called when cancelled as well*/ if (!fName.isEmpty()){ myDet->readConfigurationFile(string(fName.toAscii().constData())); - qDefs::InfoMessage("The parameters have been successfully configured.","Main: Information"); + qDefs::InfoMessage("The parameters have been successfully configured.","Main"); } } else if(action==actionSaveConfiguration){ @@ -340,7 +340,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){ /** 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: Information"); + qDefs::InfoMessage("The configuration parameters have been successfully saved.","Main"); } } else if(action==actionEnergyCalibration){ @@ -386,7 +386,7 @@ void qDetectorMain::Refresh(int index){ case Measurement: if(!myPlot->isRunning()) tab_measurement->Refresh(); break; case Settings: tab_settings->Refresh(); break; case DataOutput: tab_dataoutput->Refresh(); break; - case Plot: break; + case Plot: tab_plot->Refresh(); break; case Actions: tab_actions->Refresh(); break; case Advanced: tab_advanced->Refresh(); break; case Debugging: tab_debugging->Refresh(); break; diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 71808c29a..5efbad5d5 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -7,7 +7,6 @@ /** Qt Project Class Headers */ #include "qDrawPlot.h" #include "qCloneWidget.h" -#include "qDefs.h" #include "slsDetector.h" /** Project Class Headers */ #include "slsDetector.h" @@ -25,6 +24,7 @@ using namespace std; + //------------------------------------------------------------------------------------------------------------------------------------------------- qDrawPlot::qDrawPlot(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ @@ -75,7 +75,10 @@ void qDrawPlot::SetupWidgetWindow(){ currentPersistency = 0; progress = 0; plotEnable=true; - plotExists=false; + XYRangeChanged = false; + timerValue = PLOT_TIMER_MS; + frameFactor=0; + plotLock = false; /** This is so that it initially stop and plots */ running = 1; for(int i=0;i0;i--) memcpy(yvalues[i],yvalues[i-1],nPixelsX*sizeof(double)); nHists = currentPersistency+1; - memcpy(yvalues[0],data->values,nPixelsX*sizeof(double)); + //memcpy(yvalues[0],data->values,nPixelsX*sizeof(double)); + for(int i=0;i<(int)nPixelsX;i++) *(yvalues[0]+i) = (double)*(data->values+i); } /**2d*/ else{ @@ -306,6 +312,7 @@ int qDrawPlot::GetData(detectorData *data){ #ifdef VERYVERBOSE cout<<"Reading in image: "<stop(); - if(plotEnable){ - LockLastImageArray(); - //1-d plot stuff - if(lastImageNumber){ - if(histNBins){ #ifdef VERYVERBOSE - cout<<"Last Image Number: "<SetXTitle(histXAxisTitle.toAscii().constData()); - plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); - for(int hist_num=0;hist_num<(int)nHists;hist_num++){ - SlsQtH1D* h; - if(hist_num+1>plot1D_hists.size()){ - plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num))); - h->SetLineColor(hist_num+1); - }else{ - h=plot1D_hists.at(hist_num); - h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num)); + bool canPlot = true; + if(frameFactor) canPlot = plotLock; + + plot_update_timer->stop(); + + /** only if no plot isnt enabled */ + if(plotEnable){ + /** It doesnt go in here only if nth frame plotting in on and its not the nth frame*/ + if(canPlot){ + LockLastImageArray(); + /**1-d plot stuff */ + if(lastImageNumber){ + if(histNBins){ +#ifdef VERYVERBOSE + cout<<"Last Image Number: "<SetXTitle(histXAxisTitle.toAscii().constData()); + plot1D->SetYTitle(histYAxisTitle.toAscii().constData()); + for(int hist_num=0;hist_num<(int)nHists;hist_num++){ + SlsQtH1D* h; + if(hist_num+1>plot1D_hists.size()){ + plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num))); + h->SetLineColor(hist_num+1); + }else{ + h=plot1D_hists.at(hist_num); + h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num)); + } + h->setTitle(GetHistTitle(hist_num)); + h->Attach(plot1D); + } - h->setTitle(GetHistTitle(hist_num)); - h->Attach(plot1D); + /** update range if required */ + if(XYRangeChanged){ + if(!IsXYRange[qDefs::XMINIMUM]) + XYRangeValues[qDefs::XMINIMUM]= plot1D->GetXMinimum(); + if(!IsXYRange[qDefs::XMAXIMUM]) + XYRangeValues[qDefs::XMAXIMUM]= plot1D->GetXMaximum(); + if(!IsXYRange[qDefs::YMINIMUM]) + XYRangeValues[qDefs::YMINIMUM]= plot1D->GetYMinimum(); + if(!IsXYRange[qDefs::YMAXIMUM]) + XYRangeValues[qDefs::YMAXIMUM]= plot1D->GetYMaximum(); + plot1D->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); + plot1D->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); + + XYRangeChanged = false; + } + plotLock = false; } - /**plot exists is false in the beginning, right after cloning and when no plot is checked*/ - plotExists=true; } - } + /**2-d plot stuff */ + if(lastImageArray){ + if(lastImageNumber&&last_plot_number!=(int)lastImageNumber && //there is a new plot + nPixelsX>0&&nPixelsY>0){ + plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray); + plot2D->setTitle(GetImageTitle()); + plot2D->SetXTitle(imageXAxisTitle); + plot2D->SetYTitle(imageYAxisTitle); + plot2D->SetZTitle(imageZAxisTitle); + plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update(); + } + /** update range if required */ + if(XYRangeChanged){ + if(!IsXYRange[qDefs::XMINIMUM]) + XYRangeValues[qDefs::XMINIMUM]= plot2D->GetPlot()->GetXMinimum(); + if(!IsXYRange[qDefs::XMAXIMUM]) + XYRangeValues[qDefs::XMAXIMUM]= plot2D->GetPlot()->GetXMaximum(); + if(!IsXYRange[qDefs::YMINIMUM]) + XYRangeValues[qDefs::YMINIMUM]= plot2D->GetPlot()->GetYMinimum(); + if(!IsXYRange[qDefs::YMAXIMUM]) + XYRangeValues[qDefs::YMAXIMUM]= plot2D->GetPlot()->GetYMaximum(); - //2-d plot stuff - if(lastImageArray){ - if(lastImageNumber&&last_plot_number!=(int)lastImageNumber && //there is a new plot - nPixelsX>0&&nPixelsY>0){ - plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray); - //as it inherits a widget - plot2D->setTitle(GetImageTitle()); - plot2D->SetXTitle(imageXAxisTitle); - plot2D->SetYTitle(imageYAxisTitle); - plot2D->SetZTitle(imageZAxisTitle); - plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update(); + plot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]); + plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]); + + XYRangeChanged = false; + } + plotLock = false; } - /**plot exists is false in the beginning, right after cloning and when no plot is checked*/ - plotExists=true; } } last_plot_number=lastImageNumber; @@ -429,18 +477,24 @@ void qDrawPlot::UpdatePlot(){ if(plotEnable) UnlockLastImageArray(); /** Measurement not over, continue*/ if(number_of_exposures!=currentFrame){//las plot number? - plot_update_timer->start(500); + /**if the interval is a timer and not nth frame **/ + if(!frameFactor) + plot_update_timer->start((int)timerValue); + else + plot_update_timer->start((int)PLOT_TIMER_MS); } /** if a measurement is over */ else{ - emit SetCurrentMeasurementSignal(currentMeasurement); currentMeasurement++; /** if all the measurements are over */ if(currentMeasurement==number_of_measurements){ + plotLock = false; StartStopDaqToggle(true); emit UpdatingPlotFinished(); }/** To start the next measurement*/ else{ + plotLock = false; + emit SetCurrentMeasurementSignal(currentMeasurement); StopDaqForGui(); StartDaq(true); } @@ -472,8 +526,6 @@ void qDrawPlot::ClonePlot(){ int preheight = height(); /** create clone */ - /** plotexists is true after calling updateplot*/ - plotExists=false; winClone[i] = new qCloneWidget(this,i,boxPlot->title(),(int)plot_in_scope,plot1D,plot2D,myDet->getFilePath()); if(plot_in_scope==1){ plot1D = new SlsQt1DPlot(boxPlot); @@ -528,23 +580,25 @@ void qDrawPlot::CloneCloseEvent(int id){ void qDrawPlot::SavePlot(){ /** render image */ - QImage img(size().width(),size().height(),QImage::Format_RGB32); - QPainter painter(&img); + QImage savedImage(size().width(),size().height(),QImage::Format_RGB32); + QPainter painter(&savedImage); render(&painter); /** save image*/ QString fName = QString(myDet->getFilePath().c_str())+"/Image.png"; - fName = QFileDialog::getSaveFileName(this,tr("Save Image"),fName,tr("Images (*.png *.xpm *.jpg)")); - if (!fName.isEmpty()) - if(img.save(fName)) - qDefs::InfoMessage("The Image has been successfully saved","Dock: Information"); - else - qDefs::ErrorMessage("ERROR: Attempt to save image failed. Wrong Format","Dock: WARNING"); + fName = QFileDialog::getSaveFileName(0,tr("Save Image"),fName,tr("PNG Files (*.png);;XPM Files(*.xpm);;JPEG Files(*.jpg)"),0,QFileDialog::ShowDirsOnly); + if (!fName.isEmpty()) + if(savedImage.save(fName)) + qDefs::InfoMessage("The Image has been successfully saved","Dock"); + else + qDefs::WarningMessage("Attempt to save image failed.\n" + "Formats: .png, .jpg, .xpm.","Dock"); } //------------------------------------------------------------------------------------------------------------------------------------------------- + void qDrawPlot::SetPersistency(int val){ for(int i=0;i<=val;i++){ if(!yvalues[i]) yvalues[i] = new double [nPixelsX]; @@ -562,7 +616,6 @@ void qDrawPlot::EnablePlot(bool enable){ plotEnable = enable; /**if no plot, cant do setting range. * not true vice versa where plot was false and now set it to true*/ - if(!enable) plotExists=false; Clear1DPlot(); } diff --git a/slsDetectorGui/src/qTabMeasurement.cpp b/slsDetectorGui/src/qTabMeasurement.cpp index 857597bc9..bd4a78e6d 100644 --- a/slsDetectorGui/src/qTabMeasurement.cpp +++ b/slsDetectorGui/src/qTabMeasurement.cpp @@ -47,12 +47,15 @@ qTabMeasurement::~qTabMeasurement(){ void qTabMeasurement::SetupWidgetWindow(){ + /** Number of measurements */ + numMeasurement=1; + /** Timer to update the progress bar **/ progressTimer = new QTimer(this); //btnStartStop->setStyleSheet("color:green"); /** Exp Time **/ qDefs::timeUnit unit; - float time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); + double time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); spinExpTime->setValue(time); comboExpUnit->setCurrentIndex((int)unit); /** Hide the error message **/ @@ -65,6 +68,7 @@ void qTabMeasurement::SetupWidgetWindow(){ lblProgressIndex->setText(QString::number(myDet->getFileIndex())); /** only initially **/ progressBar->setValue(0); + currentMeasurement = 0; /** timing mode*/ SetupTimingMode(); @@ -114,7 +118,7 @@ void qTabMeasurement::SetupTimingMode(){ item[(int)Trigger_Window]->setEnabled(false); break; default: - qDefs::ErrorMessage("ERROR: Unknown detector type.","Measurement: ERROR"); + qDefs::ErrorMessage("Unknown detector type.","Measurement"); exit(-1); break; } @@ -144,11 +148,9 @@ void qTabMeasurement::SetupTimingMode(){ * This should not happen -only if the server and gui has a mismatch * on which all modes are allowed in detectors */ else{ - qDefs::ErrorMessage("ERROR: Unknown Timing Mode detected from detector." + qDefs::WarningMessage("Unknown Timing Mode detected from detector." "\n\nSetting the following defaults:\nTiming Mode \t: None\n" - "Number of Frames \t: 1\nNumber of Triggers \t: 1","Measurement: WARNING"); - setNumFrames(1); - setNumTriggers(1); + "Number of Frames \t: 1\nNumber of Triggers \t: 1","Measurement"); comboTimingMode->setCurrentIndex((int)None); setTimingMode((int)None); } @@ -163,7 +165,7 @@ void qTabMeasurement::Initialization(int timingChange){ /** These signals are connected only at start up. The others are reinitialized when changing timing mode*/ if(!timingChange){ /** Number of Measurements**/ - connect(spinNumMeasurements,SIGNAL(valueChanged(int)), myPlot, SLOT(setNumMeasurements(int))); + connect(spinNumMeasurements,SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int))); /** File Name**/ connect(dispFileName,SIGNAL(textChanged(const QString&)), this, SLOT(setFileName(const QString&))); /** File Index**/ @@ -233,6 +235,16 @@ void qTabMeasurement::Enable(bool enable){ //------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabMeasurement::setNumMeasurements(int val){ +#ifdef VERBOSE + cout<<"Setting Number of Measurements to " <setNumMeasurements(val); +} +//------------------------------------------------------------------------------------------------------------------------------------------------- + + void qTabMeasurement::setFileName(const QString& fName){ myDet->setFileName(fName.toAscii().data()); #ifdef VERBOSE @@ -263,6 +275,8 @@ void qTabMeasurement::startStopAcquisition(){ btnStartStop->setText("Stop"); Enable(0); progressBar->setValue(0); + /** the progress which keeps adding up for all the measurements*/ + currentMeasurement = 0; progressTimer->start(100); emit StartSignal(); @@ -300,8 +314,10 @@ void qTabMeasurement::UpdateFinished(){ //------------------------------------------------------------------------------------------------------------------------------------------------- -void SetCurrentMeasurement(int val){ - lblCurrentMeasurement->setText("0u");//lblCurrentMeasurement->setText(QString::number(val)); +void qTabMeasurement::SetCurrentMeasurement(int val){ + currentMeasurement = val; + lblCurrentMeasurement->setText(QString::number(val+1)); + } @@ -309,8 +325,7 @@ void SetCurrentMeasurement(int val){ void qTabMeasurement::UpdateProgress(){ - - progressBar->setValue(myPlot->GetProgress()); + progressBar->setValue((int)(((currentMeasurement*100)+(myPlot->GetProgress()))/numMeasurement)); lblProgressIndex->setText(QString::number(myDet->getFileIndex())); } @@ -331,17 +346,17 @@ void qTabMeasurement::setNumFrames(int val){ void qTabMeasurement::setExposureTime(){ - int64_t exptimeNS; + double exptimeNS; /** Get the value of timer in ns **/ - exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); + exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); #ifdef VERBOSE cout<<"Setting acquisition time to " << exptimeNS << " clocks" << "/"<value()<currentIndex())<setTimer(slsDetectorDefs::ACQUISITION_TIME,exptimeNS); + myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,(int64_t)exptimeNS); if(lblPeriod->isEnabled()){ - int64_t acqtimeNS; - acqtimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); + double acqtimeNS; + acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); if(exptimeNS>acqtimeNS) { lblNote->show(); lblPeriod->setPalette(lblNote->palette()); @@ -360,16 +375,16 @@ void qTabMeasurement::setExposureTime(){ void qTabMeasurement::setAcquisitionPeriod(){ - int64_t acqtimeNS; + double acqtimeNS; /** Get the value of timer in ns **/ - acqtimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); + acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); #ifdef VERBOSE cout<<"Setting frame period between exposures to " << acqtimeNS << " clocks"<< "/"<value()<currentIndex())<setTimer(slsDetectorDefs::FRAME_PERIOD,acqtimeNS); + myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,(int64_t)acqtimeNS); - int64_t exptimeNS; - exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); + double exptimeNS; + exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); if(exptimeNS>acqtimeNS){ lblNote->show(); lblPeriod->setPalette(lblNote->palette()); @@ -380,6 +395,9 @@ void qTabMeasurement::setAcquisitionPeriod(){ lblPeriod->setPalette(lblNumFrames->palette()); lblPeriod->setText("Acquisition Period:"); } + + /** Check if the interval between plots is ok */ + emit CheckPlotIntervalSignal(); } @@ -398,13 +416,13 @@ void qTabMeasurement::setNumTriggers(int val){ void qTabMeasurement::setDelay(){ - int64_t exptimeNS; + double exptimeNS; /** Get the value of timer in ns **/ - exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboDelayUnit->currentIndex(),spinDelay->value()); + exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboDelayUnit->currentIndex(),spinDelay->value()); #ifdef VERBOSE cout<<"Setting delay after trigger to " << exptimeNS << " clocks"<< "/"<value()<currentIndex())<setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,exptimeNS); + myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,(int64_t)exptimeNS); } @@ -506,13 +524,17 @@ void qTabMeasurement::setTimingMode(int mode){ success = true; break; default: - qDefs::ErrorMessage("ERROR: Timing mode unknown to GUI","Measurement: ERROR"); + /** This should never happen */ + qDefs::ErrorMessage("Timing mode unknown to GUI","Measurement"); exit(-1); } if(!success){ - qDefs::ErrorMessage("ERROR: The detector timing mode could not be set.\n" - "Please check the external flags","Measurement: ERROR"); - exit(-1); + qDefs::WarningMessage("The detector timing mode could not be set.\n" + "Please check the external flags." + "\n\nSetting the following defaults:\nTiming Mode \t: None\n" + "Number of Frames \t: 1\nNumber of Triggers \t: 1","Measurement"); + comboTimingMode->setCurrentIndex((int)None); + return; } if(mode!=None){/** Number of Probes */ @@ -525,7 +547,7 @@ void qTabMeasurement::setTimingMode(int mode){ DeInitialization(); - float time; + double time; int val; qDefs::timeUnit unit; /**Number of Frames */ @@ -539,7 +561,7 @@ void qTabMeasurement::setTimingMode(int mode){ /**Exposure Time */ if(lblExpTime->isEnabled()){ - time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); + time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9)))); #ifdef VERBOSE cout<<"Getting acquisition time : " << time << qDefs::getUnitString(unit) << endl; #endif @@ -549,16 +571,16 @@ void qTabMeasurement::setTimingMode(int mode){ /**Frame Period between exposures */ if(lblPeriod->isEnabled()){ - time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9)))); + time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9)))); #ifdef VERBOSE cout<<"Getting frame period between exposures : " << time << qDefs::getUnitString(unit) << endl; #endif spinPeriod->setValue(time); comboPeriodUnit->setCurrentIndex((int)unit); - int64_t exptimeNS,acqtimeNS; - exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); - acqtimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); + double exptimeNS,acqtimeNS; + exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); + acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); if(exptimeNS>acqtimeNS) { lblNote->show(); lblPeriod->setPalette(lblNote->palette()); @@ -586,7 +608,7 @@ void qTabMeasurement::setTimingMode(int mode){ /**Delay After Trigger */ if(lblDelay->isEnabled()){ - time = qDefs::getCorrectTime(unit,((float)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9)))); + time = qDefs::getCorrectTime(unit,((double)(myDet->setTimer(slsDetectorDefs::DELAY_AFTER_TRIGGER,-1)*(1E-9)))); #ifdef VERBOSE cout<<"Getting delay after trigger : " << time << qDefs::getUnitString(unit) << endl; #endif @@ -615,6 +637,8 @@ void qTabMeasurement::setTimingMode(int mode){ /** To reconnect all the signals after changing their values*/ Initialization(1); + + return; } @@ -628,10 +652,8 @@ void qTabMeasurement::Refresh(){ spinIndex->setValue(myDet->getFileIndex()); /** progress label index **/ lblProgressIndex->setText(QString::number(myDet->getFileIndex())); - /** Progress bar **/ - progressBar->setValue((int)myDet->getCurrentProgress()); /** Timing mode**/ - SetupTimingMode();//comboTimingMode->setCurrentIndex((int)myDet->setExternalCommunicationMode()); + SetupTimingMode(); } diff --git a/slsDetectorGui/src/qTabMessages.cpp b/slsDetectorGui/src/qTabMessages.cpp index 7b1022922..fc7945fc4 100644 --- a/slsDetectorGui/src/qTabMessages.cpp +++ b/slsDetectorGui/src/qTabMessages.cpp @@ -45,6 +45,7 @@ void qTabMessages::SetupWidgetWindow(){ dispLog = new QTextEdit(this); dispLog->setReadOnly(true); dispLog->setFocusPolicy(Qt::NoFocus); + dispLog->setTextColor(Qt::darkBlue); QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); @@ -91,9 +92,9 @@ void qTabMessages::SaveLog() { QTextStream out(&outfile); out<toPlainText() << endl; qDefs::InfoMessage(string("The Log has been successfully saved to " - "")+fName.toAscii().constData(),"Messages: Information"); + "")+fName.toAscii().constData(),"Messages"); } - else qDefs::ErrorMessage("ERROR: Attempt to save log file failed.","Messages: WARNING"); + else qDefs::WarningMessage("Attempt to save log file failed.","Messages"); } } diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index 1ff770e16..ef49b62df 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -15,6 +15,7 @@ /** C++ Include Headers */ #include #include +#include using namespace std; //------------------------------------------------------------------------------------------------------------------------------------------------- @@ -79,6 +80,42 @@ void qTabPlot::SetupWidgetWindow(){ dispXMax->setValidator(new QDoubleValidator(dispXMax)); dispYMax->setValidator(new QDoubleValidator(dispYMax)); dispZMax->setValidator(new QDoubleValidator(dispZMax)); + + /** Plotting Frequency */ + + stackedLayout = new QStackedLayout; + stackedLayout->setSpacing(0); + spinNthFrame = new QSpinBox; + spinNthFrame->setMinimum(1); + spinNthFrame->setMaximum(2000000000); + spinTimeGap = new QDoubleSpinBox; + spinTimeGap->setMinimum(0); + spinTimeGap->setDecimals(3); + spinTimeGap->setMaximum(999999); + spinTimeGap->setValue(500.00); + comboTimeGapUnit = new QComboBox; + comboTimeGapUnit->addItem("hr"); + comboTimeGapUnit->addItem("min"); + comboTimeGapUnit->addItem("s"); + comboTimeGapUnit->addItem("ms"); + comboTimeGapUnit->setCurrentIndex(3); + QWidget *w = new QWidget; + QHBoxLayout *h1 = new QHBoxLayout; + w->setLayout(h1); + h1->setContentsMargins(0,0,0,0); + h1->setSpacing(3); + h1->addWidget(spinTimeGap); + h1->addWidget(comboTimeGapUnit); + + stackedLayout->addWidget(w); + stackedLayout->addWidget(spinNthFrame); + + + + + stackWidget->setLayout(stackedLayout); + + } @@ -88,8 +125,8 @@ void qTabPlot::SetupWidgetWindow(){ void qTabPlot::Select1DPlot(bool b){ isOneD = b; if(b){ - box1D->setEnabled(true); - box2D->setEnabled(false); + box1D->show(); + box2D->hide(); chkZAxis->setEnabled(false); chkZMin->setEnabled(false); chkZMax->setEnabled(false); @@ -99,8 +136,8 @@ void qTabPlot::Select1DPlot(bool b){ dispYAxis->setText(defaultHistYAxisTitle); myPlot->Select1DPlot(); }else{ - box1D->setEnabled(false); - box2D->setEnabled(true); + box1D->hide(); + box2D->show(); chkZAxis->setEnabled(true); chkZMin->setEnabled(true); chkZMax->setEnabled(true); @@ -124,7 +161,7 @@ void qTabPlot::Initialization(){ connect(radioHistogram, SIGNAL(clicked()),this, SLOT(SetPlot())); connect(radioDataGraph, SIGNAL(clicked()),this, SLOT(SetPlot())); /** Scan box*/ - //connect(radioNoPlot, SIGNAL(toggled(bool)),this, SLOT(EnablePlot(bool))); + //connect(scna, SIGNAL(toggled(bool)),this, SLOT(scanstuff(bool))); /** Snapshot box*/ connect(btnClone, SIGNAL(clicked()),myPlot, SLOT(ClonePlot())); connect(btnCloseClones, SIGNAL(clicked()),myPlot, SLOT(CloseClones())); @@ -135,8 +172,11 @@ void qTabPlot::Initialization(){ connect(chkInterpolate, SIGNAL(toggled(bool)),myPlot, SIGNAL(InterpolateSignal(bool))); connect(chkContour, SIGNAL(toggled(bool)),myPlot, SIGNAL(ContourSignal(bool))); connect(chkLogz, SIGNAL(toggled(bool)),myPlot, SIGNAL(LogzSignal(bool))); - - +/** Plotting frequency box */ + connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); /** Plot Axis **/ connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); @@ -270,31 +310,29 @@ void qTabPlot::EnableRange(){ void qTabPlot::SetAxesRange(){ - double xmin=0,xmax=0,ymin=0,ymax=0; + bool changed = false; + /** x min */ + changed = (dispXMin->isEnabled())&&(!dispXMin->text().isEmpty()); + if(changed) myPlot->SetXYRangeValues(dispXMin->text().toDouble(),qDefs::XMINIMUM); + myPlot->IsXYRangeValues(changed,qDefs::XMINIMUM); - /** If disabled, get the min or max range of the plot as default */ - if((dispXMin->isEnabled())&&(!dispXMin->text().isEmpty())) - xmin = dispXMin->text().toDouble(); - else if(myPlot->DoesPlotExist()) - xmin = myPlot->GetXMinimum(); - if((dispXMax->isEnabled())&&(!dispXMax->text().isEmpty())) - xmax = dispXMax->text().toDouble(); - else if(myPlot->DoesPlotExist()) - xmax = myPlot->GetXMaximum(); - if((dispYMin->isEnabled())&&(!dispYMin->text().isEmpty())) - ymin = dispYMin->text().toDouble(); - else if(myPlot->DoesPlotExist()) - ymin = myPlot->GetYMinimum(); - if((dispYMax->isEnabled())&&(!dispYMax->text().isEmpty())) - ymax = dispYMax->text().toDouble(); - else if(myPlot->DoesPlotExist()) - ymax = myPlot->GetYMaximum(); + /** x max */ + changed = (dispXMax->isEnabled())&&(!dispXMax->text().isEmpty()); + if(changed) myPlot->SetXYRangeValues(dispXMax->text().toDouble(),qDefs::XMAXIMUM); + myPlot->IsXYRangeValues(changed,qDefs::XMAXIMUM); - /** Setting the range*/ - if(myPlot->DoesPlotExist()){ - myPlot->SetXMinMax(xmin,xmax); - myPlot->SetYMinMax(ymin,ymax); - } + /** y min */ + changed = (dispYMin->isEnabled())&&(!dispYMin->text().isEmpty()); + if(changed) myPlot->SetXYRangeValues(dispYMin->text().toDouble(),qDefs::YMINIMUM); + myPlot->IsXYRangeValues(changed,qDefs::YMINIMUM); + + /** y max */ + changed = (dispYMax->isEnabled())&&(!dispYMax->text().isEmpty()); + if(changed) myPlot->SetXYRangeValues(dispYMax->text().toDouble(),qDefs::YMAXIMUM); + myPlot->IsXYRangeValues(changed,qDefs::YMAXIMUM); + + /** To remind the updateplot in qdrawplot to set range after updating plot*/ + myPlot->SetXYRange(true); } @@ -323,28 +361,31 @@ void qTabPlot::SetPlot(){ if(radioNoPlot->isChecked()){ myPlot->EnablePlot(false); /**if enable is true, disable everything */ - box1D->setEnabled(false); - box2D->setEnabled(false); + box1D->hide(); + box2D->hide(); boxSnapshot->setEnabled(false); boxSave->setEnabled(false); + boxFrequency->setEnabled(false); boxPlotAxis->setEnabled(false); boxScan->setEnabled(false); }else if(radioHistogram->isChecked()){ myPlot->EnablePlot(true); /**if enable is true, disable everything */ - box1D->setEnabled(isOneD); - box2D->setEnabled(!isOneD); + 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(false); }else{ myPlot->EnablePlot(true); /**if enable is true, disable everything */ - box1D->setEnabled(isOneD); - box2D->setEnabled(!isOneD); + 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); } @@ -353,11 +394,73 @@ void qTabPlot::SetPlot(){ //------------------------------------------------------------------------------------------------------------------------------------------------- +int qTabPlot::SetFrequency(){ + int ret=0; + disconnect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + disconnect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); -void qTabPlot::EnableHistogram(bool enable){ - //boxScan->setEnabled(false); + double timeMS,acqPeriodMS; + double minPlotTimer = myPlot->GetMinimumPlotTimer(); + char cplotms[200]; + sprintf(cplotms,"%f ms",minPlotTimer); + + stackedLayout->setCurrentIndex(comboFrequency->currentIndex()); + switch(comboFrequency->currentIndex()){ + case 0: + /* Get the time interval from gui in ms*/ + timeMS = (qDefs::getNSTime((qDefs::timeUnit)comboTimeGapUnit->currentIndex(),spinTimeGap->value()))/(1e6); + if(timeMSsetValue(minPlotTimer); + comboTimeGapUnit->setCurrentIndex(qDefs::MILLISECONDS); + } + /**This is done so that its known which one was selected */ + myPlot->SetFrameFactor(0); + /** Setting the timer value(ms) between plots */ + myPlot->SetPlotTimer(timeMS); +#ifdef VERBOSE + cout<<"Plotting Frequency: Time Gap - "<value()<currentIndex())<setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-6)); + /** gets the acq period * number of frames*/ + 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." + "

Nth image adjusted to minimum, " + "for the chosen Acquisition Period.","Plot"); + spinNthFrame->setValue(minFrame); + } + /** Setting the timer value (nth frames) between plots */ + myPlot->SetFrameFactor(spinNthFrame->value()); +#ifdef VERBOSE + cout<<"Plotting Frequency: Nth Frame - "<value()<setEnabled(true); break; default: - qDefs::ErrorMessage("ERROR: Unknown detector type.","Settings: ERROR"); + qDefs::ErrorMessage("Unknown detector type.","Settings"); exit(-1); break; } @@ -104,8 +104,8 @@ void qTabSettings::SetupDetectorSettings(){ * This should not happen -only if the server and gui has a mismatch * on which all modes are allowed in detectors */ if(!(item[(int)sett]->isEnabled())){ - qDefs::ErrorMessage("ERROR: Unknown Detector Settings retrieved from detector. " - "Exiting GUI.","Settings: ERROR"); + qDefs::ErrorMessage("Unknown Detector Settings retrieved from detector. " + "Exiting GUI.","Settings"); #ifdef VERBOSE cout<<"ERROR: Unknown Detector Settings retrieved from detector."<