interval between plots work

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@18 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2012-07-11 17:06:12 +00:00
parent 6fb45c6c4b
commit d2b9b6ae1d
15 changed files with 1487 additions and 841 deletions

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>734</width> <width>775</width>
<height>339</height> <height>339</height>
</rect> </rect>
</property> </property>
@ -36,7 +36,7 @@
<rect> <rect>
<x>20</x> <x>20</x>
<y>75</y> <y>75</y>
<width>691</width> <width>731</width>
<height>206</height> <height>206</height>
</rect> </rect>
</property> </property>
@ -48,7 +48,7 @@
<rect> <rect>
<x>10</x> <x>10</x>
<y>20</y> <y>20</y>
<width>671</width> <width>711</width>
<height>181</height> <height>181</height>
</rect> </rect>
</property> </property>
@ -174,7 +174,7 @@
<rect> <rect>
<x>19</x> <x>19</x>
<y>20</y> <y>20</y>
<width>701</width> <width>746</width>
<height>41</height> <height>41</height>
</rect> </rect>
</property> </property>
@ -189,7 +189,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>6</y> <y>6</y>
<width>691</width> <width>731</width>
<height>28</height> <height>28</height>
</rect> </rect>
</property> </property>

View File

@ -137,9 +137,9 @@
<colorrole role="Shadow"> <colorrole role="Shadow">
<brush brushstyle="SolidPattern"> <brush brushstyle="SolidPattern">
<color alpha="255"> <color alpha="255">
<red>189</red> <red>0</red>
<green>189</green> <green>0</green>
<blue>189</blue> <blue>0</blue>
</color> </color>
</brush> </brush>
</colorrole> </colorrole>
@ -153,9 +153,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>30</x> <x>30</x>
<y>179</y> <y>153</y>
<width>319</width> <width>319</width>
<height>90</height> <height>116</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -174,7 +174,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>50</y> <y>75</y>
<width>300</width> <width>300</width>
<height>23</height> <height>23</height>
</rect> </rect>
@ -187,7 +187,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>30</y> <y>25</y>
<width>91</width> <width>91</width>
<height>16</height> <height>16</height>
</rect> </rect>
@ -200,7 +200,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>100</x> <x>100</x>
<y>31</y> <y>25</y>
<width>101</width> <width>101</width>
<height>16</height> <height>16</height>
</rect> </rect>
@ -209,6 +209,47 @@
<string>0</string> <string>0</string>
</property> </property>
</widget> </widget>
<widget class="QLabel" name="lblCurrentMeasurement">
<property name="geometry">
<rect>
<x>150</x>
<y>45</y>
<width>76</width>
<height>16</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>45</y>
<width>136</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Current Measurement:</string>
</property>
</widget>
</widget> </widget>
<widget class="QPushButton" name="btnStartStop"> <widget class="QPushButton" name="btnStartStop">
<property name="geometry"> <property name="geometry">
@ -291,6 +332,9 @@
<property name="whatsThis"> <property name="whatsThis">
<string/> <string/>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="suffix"> <property name="suffix">
<string/> <string/>
</property> </property>
@ -330,6 +374,9 @@
<string>Frame period between exposures. <string>Frame period between exposures.
#period#</string> #period#</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="decimals"> <property name="decimals">
<number>9</number> <number>9</number>
</property> </property>
@ -352,6 +399,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>2</number>
</property> </property>
@ -424,6 +474,9 @@
<property name="whatsThis"> <property name="whatsThis">
<string/> <string/>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="suffix"> <property name="suffix">
<string/> <string/>
</property> </property>
@ -475,6 +528,9 @@
<property name="whatsThis"> <property name="whatsThis">
<string/> <string/>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="suffix"> <property name="suffix">
<string/> <string/>
</property> </property>
@ -581,6 +637,9 @@
<property name="whatsThis"> <property name="whatsThis">
<string/> <string/>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="suffix"> <property name="suffix">
<string/> <string/>
</property> </property>
@ -620,8 +679,11 @@
<string>Exposure time of each frame. <string>Exposure time of each frame.
#exptime#</string> #exptime#</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="decimals"> <property name="decimals">
<number>9</number> <number>5</number>
</property> </property>
<property name="minimum"> <property name="minimum">
<double>0.000000000000000</double> <double>0.000000000000000</double>
@ -645,6 +707,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>2</number>
</property> </property>
@ -705,8 +770,11 @@
<string>Frame period between exposures. <string>Frame period between exposures.
#period#</string> #period#</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="decimals"> <property name="decimals">
<number>9</number> <number>5</number>
</property> </property>
<property name="maximum"> <property name="maximum">
<double>2000000000.000000000000000</double> <double>2000000000.000000000000000</double>
@ -727,6 +795,9 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>2</number>
</property> </property>
@ -816,7 +887,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1" colspan="2">
<widget class="QSpinBox" name="spinNumMeasurements"> <widget class="QSpinBox" name="spinNumMeasurements">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -835,7 +906,7 @@
<string/> <string/>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property> </property>
<property name="suffix"> <property name="suffix">
<string/> <string/>
@ -878,7 +949,7 @@
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_8">
<property name="text"> <property name="text">
<string>Run Index:</string> <string>Start Run Index:</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -900,6 +971,9 @@
<property name="whatsThis"> <property name="whatsThis">
<string/> <string/>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="suffix"> <property name="suffix">
<string/> <string/>
</property> </property>
@ -914,65 +988,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2">
<widget class="QLabel" name="lblCurrentMeasurement">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>193</red>
<green>193</green>
<blue>193</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>

File diff suppressed because it is too large Load Diff

View File

@ -57,8 +57,8 @@ public:
* @param value time * @param value time
* returns time value in ns * returns time value in ns
*/ */
static float getNSTime(timeUnit unit, float value){ static double getNSTime(timeUnit unit, double value){
float valueNS=value; double valueNS=value;
switch(unit){ switch(unit){
case HOURS: valueNS*=60; case HOURS: valueNS*=60;
case MINUTES: valueNS*=60; case MINUTES: valueNS*=60;
@ -78,12 +78,12 @@ public:
* @param value time in seconds * @param value time in seconds
* returns the corresponding time value * returns the corresponding time value
*/ */
static float getCorrectTime(timeUnit& unit, float value){ static double getCorrectTime(timeUnit& unit, double value){
int intUnit = (int)SECONDS; int intUnit = (int)SECONDS;
/** hr, min, sec */ /** hr, min, sec */
if(value>=1){ if(value>=1){
float newVal = value; double newVal = value;
while((newVal>=1)&&(intUnit>=(int)HOURS)){ while((newVal>=1)&&(intUnit>=(int)HOURS)){
/** value retains the old value */ /** value retains the old value */
value = newVal; 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 /**displays an error message
* @param errorMessage the message to be displayed * @param errorMessage the message to be displayed
* @param source is the tab or the source of the error * @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; 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(); errorBox->exec();
} }
@ -124,13 +139,25 @@ public:
* @param infoMessage the message to be displayed * @param infoMessage the message to be displayed
* @param source is the tab or the source of the information * @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; 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(); msgBox->exec();
} }
//-------------------------------------------------------------------------------------------------------------------------------------------------
/** range of x and y axes
*/
enum range{
XMINIMUM,
XMAXIMUM,
YMINIMUM,
YMAXIMUM
};
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
}; };

View File

@ -14,17 +14,19 @@ class slsDetectorUtils;
/** Qt Project Class Headers */ /** Qt Project Class Headers */
#include "SlsQt1DPlot.h" #include "SlsQt1DPlot.h"
#include "SlsQt2DPlotLayout.h" #include "SlsQt2DPlotLayout.h"
#include "qDefs.h"
class SlsQt1DPlot; class SlsQt1DPlot;
class SlsQt2DPlotLayout; class SlsQt2DPlotLayout;
class qCloneWidget; class qCloneWidget;
/** Qt Include Headers */ /** Qt Include Headers */
#include <QWidget> #include <QWidget>
#include <QGridLayout> #include <QGridLayout>
#include <QGroupBox> #include <QGroupBox>
#include <QTimer> #include <QTimer>
#include <QString> #include <QString>
/** C++ Include Headers */
#define MAX_1DPLOTS 10 #define MAX_1DPLOTS 10
@ -40,12 +42,12 @@ public:
/** Destructor */ /** Destructor */
~qDrawPlot(); ~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;}; bool isRunning(){return running;};
/** Number of x axis pixels */ /** gets the progress of acquisition to the measurement tab*/
int GetPixelsX(){return nPixelsX;}; int GetProgress(){return progress;};
/** Number of y axis pixels */
int GetPixelsY(){return nPixelsY;};
/** sets plot Title */ /** sets plot Title */
void SetPlotTitle(QString title) {boxPlot->setTitle(title);} void SetPlotTitle(QString title) {boxPlot->setTitle(title);}
/** sets 1D X Axis Title */ /** sets 1D X Axis Title */
@ -58,32 +60,39 @@ public:
void SetImageYAxisTitle(QString title) {imageYAxisTitle = title;} void SetImageYAxisTitle(QString title) {imageYAxisTitle = title;}
/** sets 2D Z Axis Title */ /** sets 2D Z Axis Title */
void SetImageZAxisTitle(QString title) {imageZAxisTitle = 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 */ /** Disables zoom if any of the axes range are checked and fixed with a value */
void DisableZoom(bool disable); void DisableZoom(bool disable);
/** gets the progress of acquisition to the measurement tab*/
int GetProgress(){return progress;};
/** Enables plot from the plot tab*/ /** Enables plot from the plot tab*/
void EnablePlot(bool enable); 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 /** Starts or stop acquisition
* Calls startDaq() function * Calls startDaq() function
* @param stop_if_running is 0 to stop acquisition and 1 to start acquisition * @param stop_if_running is 0 to stop acquisition and 1 to start acquisition
*/ */
void StartStopDaqToggle(bool stop_if_running=0); void StartStopDaqToggle(bool stop_if_running=0);
/** Set number of measurements
* @param num number of measurements to be set */
void setNumMeasurements(int num);
private: private:
/** The sls detector object */ /** The sls detector object */
@ -171,14 +180,40 @@ private:
double* yvalues[MAX_1DPLOTS]; double* yvalues[MAX_1DPLOTS];
/** temporary Image Values in 2D */ /** temporary Image Values in 2D */
double* image_data; double* image_data;
//bool gui_acquisition_thread_running;
/**persistency to be reached*/
int persistency; int persistency;
/** persistency takes time to reach as it increases per frame
* this is the current one */
int currentPersistency; int currentPersistency;
/** to update the progress for each getData() so that
* measurement tab can request on a timer basis*/
int progress; int progress;
/**If plot is enabled from plot tab*/
bool plotEnable; 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; 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 */ /** Initializes all its members and the thread */
void Initialization(); void Initialization();
/** Sets up the widget */ /** Sets up the widget */
@ -214,9 +249,6 @@ private:
public slots: public slots:
/** Set number of measurements
* @param num number of measurements to be set */
void setNumMeasurements(int num);
/** To select 1D or 2D plot /** To select 1D or 2D plot
@param i is 1 for 1D, else 2D plot */ @param i is 1 for 1D, else 2D plot */
void SelectPlot(int i=2); void SelectPlot(int i=2);
@ -250,6 +282,7 @@ void StartDaq(bool start);
void CloneCloseEvent(int id); void CloneCloseEvent(int id);
signals: signals:
void UpdatingPlotFinished(); void UpdatingPlotFinished();
void InterpolateSignal(bool); void InterpolateSignal(bool);
@ -258,7 +291,6 @@ void LogzSignal(bool);
void SetZRangeSignal(double,double); void SetZRangeSignal(double,double);
void EnableZRangeSignal(bool); void EnableZRangeSignal(bool);
void SetCurrentMeasurementSignal(int); void SetCurrentMeasurementSignal(int);
}; };

View File

@ -52,6 +52,10 @@ private:
QTimer *progressTimer; QTimer *progressTimer;
int numMeasurement;
int currentMeasurement;
/** methods */ /** methods */
/** Sets up the widget /** Sets up the widget
*/ */
@ -91,6 +95,10 @@ void UpdateFinished();
void SetCurrentMeasurement(int val); void SetCurrentMeasurement(int val);
private slots: private slots:
/** Set number of measurements
* @param num number of measurements to be set */
void setNumMeasurements(int num);
/** Set file name /** Set file name
* @param fName name of file * @param fName name of file
*/ */
@ -150,6 +158,7 @@ signals:
void StartSignal(); void StartSignal();
void StopSignal(); void StopSignal();
void CheckPlotIntervalSignal();
}; };

View File

@ -70,6 +70,8 @@ void SaveLog();
/** Clear Log to File*/ /** Clear Log to File*/
void ClearLog(); void ClearLog();
}; };

View File

@ -14,6 +14,8 @@
class slsDetectorUtils; class slsDetectorUtils;
/** Qt Project Class Headers */ /** Qt Project Class Headers */
class qDrawPlot; class qDrawPlot;
/** Qt Include Headers */
#include <QStackedLayout>
/** /**
*@short sets up the Plot parameters *@short sets up the Plot parameters
@ -33,6 +35,9 @@ public:
*/ */
~qTabPlot(); ~qTabPlot();
/** To refresh and update widgets
*/
void Refresh();
private: private:
@ -45,6 +50,11 @@ private:
/** 1d/2d plot */ /** 1d/2d plot */
bool isOneD; bool isOneD;
QStackedLayout* stackedLayout;
QSpinBox *spinNthFrame;
QDoubleSpinBox *spinTimeGap;
QComboBox *comboTimeGapUnit;
/** some Default Values */ /** some Default Values */
static QString defaultPlotTitle; static QString defaultPlotTitle;
static QString defaultHistXAxisTitle; static QString defaultHistXAxisTitle;
@ -66,7 +76,10 @@ private:
public slots: 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(); void EnableZRange();
/** Set Plot to none, data graph, histogram*/ /** Set Plot to none, data graph, histogram*/
void SetPlot(); void SetPlot();
/** Enable Histogram */
void EnableHistogram(bool enable);
signals: signals:
void DisableZoomSignal(bool); void DisableZoomSignal(bool);

View File

@ -183,12 +183,13 @@ void qCloneWidget::SavePlot(){
QPainter painter(&img); QPainter painter(&img);
cloneBox->render(&painter); 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 (!fName.isEmpty())
if((img.save(fName))) if((img.save(fName)))
qDefs::InfoMessage("The SnapShot has been successfully saved","Snapshot: Information"); qDefs::InfoMessage("The SnapShot has been successfully saved","Snapshot");
else 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");
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -171,8 +171,7 @@ void qDetectorMain::SetUpDetector(){
#endif #endif
char cIndex[10]; char cIndex[10];
sprintf(cIndex,"%d",detID); sprintf(cIndex,"%d",detID);
qDefs::ErrorMessage(string("ERROR: No Detector Connected at " qDefs::ErrorMessage(string("No Detector Connected at id : ")+string(cIndex),"Main");
"id : ")+string(cIndex),"Main: ERROR");
exit(-1); exit(-1);
} }
else{ else{
@ -184,9 +183,9 @@ void qDetectorMain::SetUpDetector(){
default: default:
string detName = myDet->slsDetectorBase::getDetectorType(myDet->getDetectorsType()); string detName = myDet->slsDetectorBase::getDetectorType(myDet->getDetectorsType());
string hostname = myDet->getHostname(detID); string hostname = myDet->getHostname(detID);
string errorMess = string("ERROR: ")+hostname+string(" has " string errorMess = hostname+string(" has unknown detector type \"")+
"unknown detector type \"")+detName+string("\". Exiting GUI."); detName+string("\". Exiting GUI.");
qDefs::ErrorMessage(errorMess,"Main: ERROR"); qDefs::ErrorMessage(errorMess,"Main");
exit(-1); exit(-1);
} }
setWindowTitle("SLS Detector GUI : "+ setWindowTitle("SLS Detector GUI : "+
@ -212,6 +211,7 @@ void qDetectorMain::Initialization(){
/** Measurement tab*/ /** Measurement tab*/
connect(tab_measurement, SIGNAL(StartSignal()), this,SLOT(EnableTabs())); connect(tab_measurement, SIGNAL(StartSignal()), this,SLOT(EnableTabs()));
connect(tab_measurement, SIGNAL(StopSignal()), 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))); connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool)));
/** Plotting */ /** Plotting */
@ -293,7 +293,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
/** Gets called when cancelled as well*/ /** Gets called when cancelled as well*/
if (!fName.isEmpty()){ if (!fName.isEmpty()){
myDet->retrieveDetectorSetup(string(fName.toAscii().constData())); 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){ else if(action==actionSaveSetup){
@ -307,7 +307,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
/** Gets called when cancelled as well*/ /** Gets called when cancelled as well*/
if (!fName.isEmpty()){ if (!fName.isEmpty()){
myDet->dumpDetectorSetup(string(fName.toAscii().constData())); 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){ else if(action==actionMeasurementWizard){
@ -326,7 +326,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
/** Gets called when cancelled as well*/ /** Gets called when cancelled as well*/
if (!fName.isEmpty()){ if (!fName.isEmpty()){
myDet->readConfigurationFile(string(fName.toAscii().constData())); 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){ else if(action==actionSaveConfiguration){
@ -340,7 +340,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action){
/** Gets called when cancelled as well*/ /** Gets called when cancelled as well*/
if (!fName.isEmpty()){ if (!fName.isEmpty()){
myDet->writeConfigurationFile(string(fName.toAscii().constData())); 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){ else if(action==actionEnergyCalibration){
@ -386,7 +386,7 @@ void qDetectorMain::Refresh(int index){
case Measurement: if(!myPlot->isRunning()) tab_measurement->Refresh(); break; case Measurement: if(!myPlot->isRunning()) tab_measurement->Refresh(); break;
case Settings: tab_settings->Refresh(); break; case Settings: tab_settings->Refresh(); break;
case DataOutput: tab_dataoutput->Refresh(); break; case DataOutput: tab_dataoutput->Refresh(); break;
case Plot: break; case Plot: tab_plot->Refresh(); break;
case Actions: tab_actions->Refresh(); break; case Actions: tab_actions->Refresh(); break;
case Advanced: tab_advanced->Refresh(); break; case Advanced: tab_advanced->Refresh(); break;
case Debugging: tab_debugging->Refresh(); break; case Debugging: tab_debugging->Refresh(); break;

View File

@ -7,7 +7,6 @@
/** Qt Project Class Headers */ /** Qt Project Class Headers */
#include "qDrawPlot.h" #include "qDrawPlot.h"
#include "qCloneWidget.h" #include "qCloneWidget.h"
#include "qDefs.h"
#include "slsDetector.h" #include "slsDetector.h"
/** Project Class Headers */ /** Project Class Headers */
#include "slsDetector.h" #include "slsDetector.h"
@ -25,6 +24,7 @@
using namespace std; using namespace std;
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
qDrawPlot::qDrawPlot(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){ qDrawPlot::qDrawPlot(QWidget *parent,slsDetectorUtils*& detector):QWidget(parent),myDet(detector){
@ -75,7 +75,10 @@ void qDrawPlot::SetupWidgetWindow(){
currentPersistency = 0; currentPersistency = 0;
progress = 0; progress = 0;
plotEnable=true; plotEnable=true;
plotExists=false; XYRangeChanged = false;
timerValue = PLOT_TIMER_MS;
frameFactor=0;
plotLock = false;
/** This is so that it initially stop and plots */ /** This is so that it initially stop and plots */
running = 1; running = 1;
for(int i=0;i<MAX_1DPLOTS;i++) {histYAxis[i]=0;yvalues[i]=0; } for(int i=0;i<MAX_1DPLOTS;i++) {histYAxis[i]=0;yvalues[i]=0; }
@ -144,6 +147,8 @@ void qDrawPlot::Initialization(){
connect(this, SIGNAL(SetZRangeSignal(double,double)), plot2D, SLOT(SetZRange(double,double))); connect(this, SIGNAL(SetZRangeSignal(double,double)), plot2D, SLOT(SetZRange(double,double)));
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
@ -292,7 +297,8 @@ int qDrawPlot::GetData(detectorData *data){
for(int i=currentPersistency;i>0;i--) for(int i=currentPersistency;i>0;i--)
memcpy(yvalues[i],yvalues[i-1],nPixelsX*sizeof(double)); memcpy(yvalues[i],yvalues[i-1],nPixelsX*sizeof(double));
nHists = currentPersistency+1; 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*/ /**2d*/
else{ else{
@ -306,6 +312,7 @@ int qDrawPlot::GetData(detectorData *data){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"Reading in image: "<<currentFrame+1<<endl; cout<<"Reading in image: "<<currentFrame+1<<endl;
#endif #endif
if(!plotLock){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
char temp_title[2000]; char temp_title[2000];
/** only if you got the lock, do u need to remember lastimagenumber to plot*/ /** only if you got the lock, do u need to remember lastimagenumber to plot*/
@ -328,9 +335,14 @@ int qDrawPlot::GetData(detectorData *data){
} }
pthread_mutex_unlock(&(last_image_complete_mutex)); pthread_mutex_unlock(&(last_image_complete_mutex));
} }
}
currentFrame++; currentFrame++;
} }
/** To make sure plotting locks parameters until it has plotted */
if(frameFactor){
if(currentFrame==number_of_exposures) plotLock = true;
else if(!((currentFrame-1)%frameFactor)) plotLock = true;
}
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"Exiting GetData function"<<endl; cout<<"Exiting GetData function"<<endl;
#endif #endif
@ -341,9 +353,6 @@ int qDrawPlot::GetData(detectorData *data){
void qDrawPlot::setNumMeasurements(int num){ void qDrawPlot::setNumMeasurements(int num){
number_of_measurements = num; number_of_measurements = num;
#ifdef VERBOSE
cout<<"Setting Number of Measurements to " <<num<<endl;
#endif
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
@ -376,12 +385,22 @@ void qDrawPlot::Clear1DPlot(){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::UpdatePlot(){ void qDrawPlot::UpdatePlot(){
//static int last_plot_number = 0; #ifdef VERYVERBOSE
cout<<"Entering UpdatePlot function"<<endl;
#endif
bool canPlot = true;
if(frameFactor) canPlot = plotLock;
plot_update_timer->stop(); plot_update_timer->stop();
/** only if no plot isnt enabled */
if(plotEnable){ if(plotEnable){
/** It doesnt go in here only if nth frame plotting in on and its not the nth frame*/
if(canPlot){
LockLastImageArray(); LockLastImageArray();
//1-d plot stuff /**1-d plot stuff */
if(lastImageNumber){ if(lastImageNumber){
if(histNBins){ if(histNBins){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
@ -403,25 +422,54 @@ void qDrawPlot::UpdatePlot(){
h->Attach(plot1D); h->Attach(plot1D);
} }
/**plot exists is false in the beginning, right after cloning and when no plot is checked*/ /** update range if required */
plotExists=true; 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();
//2-d plot stuff plot1D->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]);
plot1D->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
XYRangeChanged = false;
}
plotLock = false;
}
}
/**2-d plot stuff */
if(lastImageArray){ if(lastImageArray){
if(lastImageNumber&&last_plot_number!=(int)lastImageNumber && //there is a new plot if(lastImageNumber&&last_plot_number!=(int)lastImageNumber && //there is a new plot
nPixelsX>0&&nPixelsY>0){ nPixelsX>0&&nPixelsY>0){
plot2D->GetPlot()->SetData(nPixelsX,-0.5,nPixelsX-0.5,nPixelsY,-0.5,nPixelsY-0.5,lastImageArray); 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->setTitle(GetImageTitle());
plot2D->SetXTitle(imageXAxisTitle); plot2D->SetXTitle(imageXAxisTitle);
plot2D->SetYTitle(imageYAxisTitle); plot2D->SetYTitle(imageYAxisTitle);
plot2D->SetZTitle(imageZAxisTitle); plot2D->SetZTitle(imageZAxisTitle);
plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update(); plot2D->UpdateNKeepSetRangeIfSet(); //this will keep a "set" z range, and call Plot()->Update();
} }
/**plot exists is false in the beginning, right after cloning and when no plot is checked*/ /** update range if required */
plotExists=true; 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();
plot2D->GetPlot()->SetXMinMax(XYRangeValues[qDefs::XMINIMUM],XYRangeValues[qDefs::XMAXIMUM]);
plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
XYRangeChanged = false;
}
plotLock = false;
}
} }
} }
last_plot_number=lastImageNumber; last_plot_number=lastImageNumber;
@ -429,18 +477,24 @@ void qDrawPlot::UpdatePlot(){
if(plotEnable) UnlockLastImageArray(); if(plotEnable) UnlockLastImageArray();
/** Measurement not over, continue*/ /** Measurement not over, continue*/
if(number_of_exposures!=currentFrame){//las plot number? 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 */ /** if a measurement is over */
else{ else{
emit SetCurrentMeasurementSignal(currentMeasurement);
currentMeasurement++; currentMeasurement++;
/** if all the measurements are over */ /** if all the measurements are over */
if(currentMeasurement==number_of_measurements){ if(currentMeasurement==number_of_measurements){
plotLock = false;
StartStopDaqToggle(true); StartStopDaqToggle(true);
emit UpdatingPlotFinished(); emit UpdatingPlotFinished();
}/** To start the next measurement*/ }/** To start the next measurement*/
else{ else{
plotLock = false;
emit SetCurrentMeasurementSignal(currentMeasurement);
StopDaqForGui(); StopDaqForGui();
StartDaq(true); StartDaq(true);
} }
@ -472,8 +526,6 @@ void qDrawPlot::ClonePlot(){
int preheight = height(); int preheight = height();
/** create clone */ /** 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()); winClone[i] = new qCloneWidget(this,i,boxPlot->title(),(int)plot_in_scope,plot1D,plot2D,myDet->getFilePath());
if(plot_in_scope==1){ if(plot_in_scope==1){
plot1D = new SlsQt1DPlot(boxPlot); plot1D = new SlsQt1DPlot(boxPlot);
@ -528,23 +580,25 @@ void qDrawPlot::CloneCloseEvent(int id){
void qDrawPlot::SavePlot(){ void qDrawPlot::SavePlot(){
/** render image */ /** render image */
QImage img(size().width(),size().height(),QImage::Format_RGB32); QImage savedImage(size().width(),size().height(),QImage::Format_RGB32);
QPainter painter(&img); QPainter painter(&savedImage);
render(&painter); render(&painter);
/** save image*/ /** save image*/
QString fName = QString(myDet->getFilePath().c_str())+"/Image.png"; QString fName = QString(myDet->getFilePath().c_str())+"/Image.png";
fName = QFileDialog::getSaveFileName(this,tr("Save Image"),fName,tr("Images (*.png *.xpm *.jpg)")); 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(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");
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){ void qDrawPlot::SetPersistency(int val){
for(int i=0;i<=val;i++){ for(int i=0;i<=val;i++){
if(!yvalues[i]) yvalues[i] = new double [nPixelsX]; if(!yvalues[i]) yvalues[i] = new double [nPixelsX];
@ -562,7 +616,6 @@ void qDrawPlot::EnablePlot(bool enable){
plotEnable = enable; plotEnable = enable;
/**if no plot, cant do setting range. /**if no plot, cant do setting range.
* not true vice versa where plot was false and now set it to true*/ * not true vice versa where plot was false and now set it to true*/
if(!enable) plotExists=false;
Clear1DPlot(); Clear1DPlot();
} }

View File

@ -47,12 +47,15 @@ qTabMeasurement::~qTabMeasurement(){
void qTabMeasurement::SetupWidgetWindow(){ void qTabMeasurement::SetupWidgetWindow(){
/** Number of measurements */
numMeasurement=1;
/** Timer to update the progress bar **/ /** Timer to update the progress bar **/
progressTimer = new QTimer(this); progressTimer = new QTimer(this);
//btnStartStop->setStyleSheet("color:green"); //btnStartStop->setStyleSheet("color:green");
/** Exp Time **/ /** Exp Time **/
qDefs::timeUnit unit; 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); spinExpTime->setValue(time);
comboExpUnit->setCurrentIndex((int)unit); comboExpUnit->setCurrentIndex((int)unit);
/** Hide the error message **/ /** Hide the error message **/
@ -65,6 +68,7 @@ void qTabMeasurement::SetupWidgetWindow(){
lblProgressIndex->setText(QString::number(myDet->getFileIndex())); lblProgressIndex->setText(QString::number(myDet->getFileIndex()));
/** only initially **/ /** only initially **/
progressBar->setValue(0); progressBar->setValue(0);
currentMeasurement = 0;
/** timing mode*/ /** timing mode*/
SetupTimingMode(); SetupTimingMode();
@ -114,7 +118,7 @@ void qTabMeasurement::SetupTimingMode(){
item[(int)Trigger_Window]->setEnabled(false); item[(int)Trigger_Window]->setEnabled(false);
break; break;
default: default:
qDefs::ErrorMessage("ERROR: Unknown detector type.","Measurement: ERROR"); qDefs::ErrorMessage("Unknown detector type.","Measurement");
exit(-1); exit(-1);
break; break;
} }
@ -144,11 +148,9 @@ void qTabMeasurement::SetupTimingMode(){
* This should not happen -only if the server and gui has a mismatch * This should not happen -only if the server and gui has a mismatch
* on which all modes are allowed in detectors */ * on which all modes are allowed in detectors */
else{ 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" "\n\nSetting the following defaults:\nTiming Mode \t: None\n"
"Number of Frames \t: 1\nNumber of Triggers \t: 1","Measurement: WARNING"); "Number of Frames \t: 1\nNumber of Triggers \t: 1","Measurement");
setNumFrames(1);
setNumTriggers(1);
comboTimingMode->setCurrentIndex((int)None); comboTimingMode->setCurrentIndex((int)None);
setTimingMode((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*/ /** These signals are connected only at start up. The others are reinitialized when changing timing mode*/
if(!timingChange){ if(!timingChange){
/** Number of Measurements**/ /** Number of Measurements**/
connect(spinNumMeasurements,SIGNAL(valueChanged(int)), myPlot, SLOT(setNumMeasurements(int))); connect(spinNumMeasurements,SIGNAL(valueChanged(int)), this, SLOT(setNumMeasurements(int)));
/** File Name**/ /** File Name**/
connect(dispFileName,SIGNAL(textChanged(const QString&)), this, SLOT(setFileName(const QString&))); connect(dispFileName,SIGNAL(textChanged(const QString&)), this, SLOT(setFileName(const QString&)));
/** File Index**/ /** File Index**/
@ -233,6 +235,16 @@ void qTabMeasurement::Enable(bool enable){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMeasurement::setNumMeasurements(int val){
#ifdef VERBOSE
cout<<"Setting Number of Measurements to " <<val<<endl;
#endif
numMeasurement = val;
myPlot->setNumMeasurements(val);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMeasurement::setFileName(const QString& fName){ void qTabMeasurement::setFileName(const QString& fName){
myDet->setFileName(fName.toAscii().data()); myDet->setFileName(fName.toAscii().data());
#ifdef VERBOSE #ifdef VERBOSE
@ -263,6 +275,8 @@ void qTabMeasurement::startStopAcquisition(){
btnStartStop->setText("Stop"); btnStartStop->setText("Stop");
Enable(0); Enable(0);
progressBar->setValue(0); progressBar->setValue(0);
/** the progress which keeps adding up for all the measurements*/
currentMeasurement = 0;
progressTimer->start(100); progressTimer->start(100);
emit StartSignal(); emit StartSignal();
@ -300,8 +314,10 @@ void qTabMeasurement::UpdateFinished(){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void SetCurrentMeasurement(int val){ void qTabMeasurement::SetCurrentMeasurement(int val){
lblCurrentMeasurement->setText("0u");//lblCurrentMeasurement->setText(QString::number(val)); currentMeasurement = val;
lblCurrentMeasurement->setText(QString::number(val+1));
} }
@ -309,8 +325,7 @@ void SetCurrentMeasurement(int val){
void qTabMeasurement::UpdateProgress(){ void qTabMeasurement::UpdateProgress(){
progressBar->setValue((int)(((currentMeasurement*100)+(myPlot->GetProgress()))/numMeasurement));
progressBar->setValue(myPlot->GetProgress());
lblProgressIndex->setText(QString::number(myDet->getFileIndex())); lblProgressIndex->setText(QString::number(myDet->getFileIndex()));
} }
@ -331,17 +346,17 @@ void qTabMeasurement::setNumFrames(int val){
void qTabMeasurement::setExposureTime(){ void qTabMeasurement::setExposureTime(){
int64_t exptimeNS; double exptimeNS;
/** Get the value of timer in ns **/ /** 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 #ifdef VERBOSE
cout<<"Setting acquisition time to " << exptimeNS << " clocks" << "/"<<spinExpTime->value()<<qDefs::getUnitString((qDefs::timeUnit)comboExpUnit->currentIndex())<<endl; cout<<"Setting acquisition time to " << exptimeNS << " clocks" << "/"<<spinExpTime->value()<<qDefs::getUnitString((qDefs::timeUnit)comboExpUnit->currentIndex())<<endl;
#endif #endif
myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,exptimeNS); myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,(int64_t)exptimeNS);
if(lblPeriod->isEnabled()){ if(lblPeriod->isEnabled()){
int64_t acqtimeNS; double acqtimeNS;
acqtimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value());
if(exptimeNS>acqtimeNS) { if(exptimeNS>acqtimeNS) {
lblNote->show(); lblNote->show();
lblPeriod->setPalette(lblNote->palette()); lblPeriod->setPalette(lblNote->palette());
@ -360,16 +375,16 @@ void qTabMeasurement::setExposureTime(){
void qTabMeasurement::setAcquisitionPeriod(){ void qTabMeasurement::setAcquisitionPeriod(){
int64_t acqtimeNS; double acqtimeNS;
/** Get the value of timer in ns **/ /** 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 #ifdef VERBOSE
cout<<"Setting frame period between exposures to " << acqtimeNS << " clocks"<< "/"<<spinPeriod->value()<<qDefs::getUnitString((qDefs::timeUnit)comboPeriodUnit->currentIndex())<<endl; cout<<"Setting frame period between exposures to " << acqtimeNS << " clocks"<< "/"<<spinPeriod->value()<<qDefs::getUnitString((qDefs::timeUnit)comboPeriodUnit->currentIndex())<<endl;
#endif #endif
myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,acqtimeNS); myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,(int64_t)acqtimeNS);
int64_t exptimeNS; double exptimeNS;
exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value());
if(exptimeNS>acqtimeNS){ if(exptimeNS>acqtimeNS){
lblNote->show(); lblNote->show();
lblPeriod->setPalette(lblNote->palette()); lblPeriod->setPalette(lblNote->palette());
@ -380,6 +395,9 @@ void qTabMeasurement::setAcquisitionPeriod(){
lblPeriod->setPalette(lblNumFrames->palette()); lblPeriod->setPalette(lblNumFrames->palette());
lblPeriod->setText("Acquisition Period:"); 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(){ void qTabMeasurement::setDelay(){
int64_t exptimeNS; double exptimeNS;
/** Get the value of timer in ns **/ /** 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 #ifdef VERBOSE
cout<<"Setting delay after trigger to " << exptimeNS << " clocks"<< "/"<<spinDelay->value()<<qDefs::getUnitString((qDefs::timeUnit)comboDelayUnit->currentIndex())<<endl; cout<<"Setting delay after trigger to " << exptimeNS << " clocks"<< "/"<<spinDelay->value()<<qDefs::getUnitString((qDefs::timeUnit)comboDelayUnit->currentIndex())<<endl;
#endif #endif
myDet->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; success = true;
break; break;
default: 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); exit(-1);
} }
if(!success){ if(!success){
qDefs::ErrorMessage("ERROR: The detector timing mode could not be set.\n" qDefs::WarningMessage("The detector timing mode could not be set.\n"
"Please check the external flags","Measurement: ERROR"); "Please check the external flags."
exit(-1); "\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 */ if(mode!=None){/** Number of Probes */
@ -525,7 +547,7 @@ void qTabMeasurement::setTimingMode(int mode){
DeInitialization(); DeInitialization();
float time; double time;
int val; int val;
qDefs::timeUnit unit; qDefs::timeUnit unit;
/**Number of Frames */ /**Number of Frames */
@ -539,7 +561,7 @@ void qTabMeasurement::setTimingMode(int mode){
/**Exposure Time */ /**Exposure Time */
if(lblExpTime->isEnabled()){ 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 #ifdef VERBOSE
cout<<"Getting acquisition time : " << time << qDefs::getUnitString(unit) << endl; cout<<"Getting acquisition time : " << time << qDefs::getUnitString(unit) << endl;
#endif #endif
@ -549,16 +571,16 @@ void qTabMeasurement::setTimingMode(int mode){
/**Frame Period between exposures */ /**Frame Period between exposures */
if(lblPeriod->isEnabled()){ 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 #ifdef VERBOSE
cout<<"Getting frame period between exposures : " << time << qDefs::getUnitString(unit) << endl; cout<<"Getting frame period between exposures : " << time << qDefs::getUnitString(unit) << endl;
#endif #endif
spinPeriod->setValue(time); spinPeriod->setValue(time);
comboPeriodUnit->setCurrentIndex((int)unit); comboPeriodUnit->setCurrentIndex((int)unit);
int64_t exptimeNS,acqtimeNS; double exptimeNS,acqtimeNS;
exptimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value()); exptimeNS = qDefs::getNSTime((qDefs::timeUnit)comboExpUnit->currentIndex(),spinExpTime->value());
acqtimeNS = (int64_t)qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value()); acqtimeNS = qDefs::getNSTime((qDefs::timeUnit)comboPeriodUnit->currentIndex(),spinPeriod->value());
if(exptimeNS>acqtimeNS) { if(exptimeNS>acqtimeNS) {
lblNote->show(); lblNote->show();
lblPeriod->setPalette(lblNote->palette()); lblPeriod->setPalette(lblNote->palette());
@ -586,7 +608,7 @@ void qTabMeasurement::setTimingMode(int mode){
/**Delay After Trigger */ /**Delay After Trigger */
if(lblDelay->isEnabled()){ 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 #ifdef VERBOSE
cout<<"Getting delay after trigger : " << time << qDefs::getUnitString(unit) << endl; cout<<"Getting delay after trigger : " << time << qDefs::getUnitString(unit) << endl;
#endif #endif
@ -615,6 +637,8 @@ void qTabMeasurement::setTimingMode(int mode){
/** To reconnect all the signals after changing their values*/ /** To reconnect all the signals after changing their values*/
Initialization(1); Initialization(1);
return;
} }
@ -628,10 +652,8 @@ void qTabMeasurement::Refresh(){
spinIndex->setValue(myDet->getFileIndex()); spinIndex->setValue(myDet->getFileIndex());
/** progress label index **/ /** progress label index **/
lblProgressIndex->setText(QString::number(myDet->getFileIndex())); lblProgressIndex->setText(QString::number(myDet->getFileIndex()));
/** Progress bar **/
progressBar->setValue((int)myDet->getCurrentProgress());
/** Timing mode**/ /** Timing mode**/
SetupTimingMode();//comboTimingMode->setCurrentIndex((int)myDet->setExternalCommunicationMode()); SetupTimingMode();
} }

View File

@ -45,6 +45,7 @@ void qTabMessages::SetupWidgetWindow(){
dispLog = new QTextEdit(this); dispLog = new QTextEdit(this);
dispLog->setReadOnly(true); dispLog->setReadOnly(true);
dispLog->setFocusPolicy(Qt::NoFocus); dispLog->setFocusPolicy(Qt::NoFocus);
dispLog->setTextColor(Qt::darkBlue);
QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
@ -91,9 +92,9 @@ void qTabMessages::SaveLog() {
QTextStream out(&outfile); QTextStream out(&outfile);
out<<dispLog->toPlainText() << endl; out<<dispLog->toPlainText() << endl;
qDefs::InfoMessage(string("The Log has been successfully saved to " 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");
} }
} }

View File

@ -15,6 +15,7 @@
/** C++ Include Headers */ /** C++ Include Headers */
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <math.h>
using namespace std; using namespace std;
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
@ -79,6 +80,42 @@ void qTabPlot::SetupWidgetWindow(){
dispXMax->setValidator(new QDoubleValidator(dispXMax)); dispXMax->setValidator(new QDoubleValidator(dispXMax));
dispYMax->setValidator(new QDoubleValidator(dispYMax)); dispYMax->setValidator(new QDoubleValidator(dispYMax));
dispZMax->setValidator(new QDoubleValidator(dispZMax)); 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){ void qTabPlot::Select1DPlot(bool b){
isOneD = b; isOneD = b;
if(b){ if(b){
box1D->setEnabled(true); box1D->show();
box2D->setEnabled(false); box2D->hide();
chkZAxis->setEnabled(false); chkZAxis->setEnabled(false);
chkZMin->setEnabled(false); chkZMin->setEnabled(false);
chkZMax->setEnabled(false); chkZMax->setEnabled(false);
@ -99,8 +136,8 @@ void qTabPlot::Select1DPlot(bool b){
dispYAxis->setText(defaultHistYAxisTitle); dispYAxis->setText(defaultHistYAxisTitle);
myPlot->Select1DPlot(); myPlot->Select1DPlot();
}else{ }else{
box1D->setEnabled(false); box1D->hide();
box2D->setEnabled(true); box2D->show();
chkZAxis->setEnabled(true); chkZAxis->setEnabled(true);
chkZMin->setEnabled(true); chkZMin->setEnabled(true);
chkZMax->setEnabled(true); chkZMax->setEnabled(true);
@ -124,7 +161,7 @@ void qTabPlot::Initialization(){
connect(radioHistogram, SIGNAL(clicked()),this, SLOT(SetPlot())); connect(radioHistogram, SIGNAL(clicked()),this, SLOT(SetPlot()));
connect(radioDataGraph, SIGNAL(clicked()),this, SLOT(SetPlot())); connect(radioDataGraph, SIGNAL(clicked()),this, SLOT(SetPlot()));
/** Scan box*/ /** Scan box*/
//connect(radioNoPlot, SIGNAL(toggled(bool)),this, SLOT(EnablePlot(bool))); //connect(scna, SIGNAL(toggled(bool)),this, SLOT(scanstuff(bool)));
/** Snapshot box*/ /** Snapshot box*/
connect(btnClone, SIGNAL(clicked()),myPlot, SLOT(ClonePlot())); connect(btnClone, SIGNAL(clicked()),myPlot, SLOT(ClonePlot()));
connect(btnCloseClones, SIGNAL(clicked()),myPlot, SLOT(CloseClones())); connect(btnCloseClones, SIGNAL(clicked()),myPlot, SLOT(CloseClones()));
@ -135,8 +172,11 @@ void qTabPlot::Initialization(){
connect(chkInterpolate, SIGNAL(toggled(bool)),myPlot, SIGNAL(InterpolateSignal(bool))); connect(chkInterpolate, SIGNAL(toggled(bool)),myPlot, SIGNAL(InterpolateSignal(bool)));
connect(chkContour, SIGNAL(toggled(bool)),myPlot, SIGNAL(ContourSignal(bool))); connect(chkContour, SIGNAL(toggled(bool)),myPlot, SIGNAL(ContourSignal(bool)));
connect(chkLogz, SIGNAL(toggled(bool)),myPlot, SIGNAL(LogzSignal(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 **/ /** Plot Axis **/
connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); connect(chkTitle, SIGNAL(toggled(bool)), this, SLOT(EnableTitles()));
connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); connect(chkXAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles()));
@ -270,31 +310,29 @@ void qTabPlot::EnableRange(){
void qTabPlot::SetAxesRange(){ 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 */ /** x max */
if((dispXMin->isEnabled())&&(!dispXMin->text().isEmpty())) changed = (dispXMax->isEnabled())&&(!dispXMax->text().isEmpty());
xmin = dispXMin->text().toDouble(); if(changed) myPlot->SetXYRangeValues(dispXMax->text().toDouble(),qDefs::XMAXIMUM);
else if(myPlot->DoesPlotExist()) myPlot->IsXYRangeValues(changed,qDefs::XMAXIMUM);
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();
/** Setting the range*/ /** y min */
if(myPlot->DoesPlotExist()){ changed = (dispYMin->isEnabled())&&(!dispYMin->text().isEmpty());
myPlot->SetXMinMax(xmin,xmax); if(changed) myPlot->SetXYRangeValues(dispYMin->text().toDouble(),qDefs::YMINIMUM);
myPlot->SetYMinMax(ymin,ymax); 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()){ if(radioNoPlot->isChecked()){
myPlot->EnablePlot(false); myPlot->EnablePlot(false);
/**if enable is true, disable everything */ /**if enable is true, disable everything */
box1D->setEnabled(false); box1D->hide();
box2D->setEnabled(false); box2D->hide();
boxSnapshot->setEnabled(false); boxSnapshot->setEnabled(false);
boxSave->setEnabled(false); boxSave->setEnabled(false);
boxFrequency->setEnabled(false);
boxPlotAxis->setEnabled(false); boxPlotAxis->setEnabled(false);
boxScan->setEnabled(false); boxScan->setEnabled(false);
}else if(radioHistogram->isChecked()){ }else if(radioHistogram->isChecked()){
myPlot->EnablePlot(true); myPlot->EnablePlot(true);
/**if enable is true, disable everything */ /**if enable is true, disable everything */
box1D->setEnabled(isOneD); if(isOneD) box1D->show(); else box1D->hide();
box2D->setEnabled(!isOneD); if(!isOneD) box2D->show(); else box2D->hide();
boxSnapshot->setEnabled(true); boxSnapshot->setEnabled(true);
boxSave->setEnabled(true); boxSave->setEnabled(true);
boxFrequency->setEnabled(true);
boxPlotAxis->setEnabled(true); boxPlotAxis->setEnabled(true);
boxScan->setEnabled(false); boxScan->setEnabled(false);
}else{ }else{
myPlot->EnablePlot(true); myPlot->EnablePlot(true);
/**if enable is true, disable everything */ /**if enable is true, disable everything */
box1D->setEnabled(isOneD); if(isOneD) box1D->show(); else box1D->hide();
box2D->setEnabled(!isOneD); if(!isOneD) box2D->show(); else box2D->hide();
boxSnapshot->setEnabled(true); boxSnapshot->setEnabled(true);
boxSave->setEnabled(true); boxSave->setEnabled(true);
boxFrequency->setEnabled(true);
boxPlotAxis->setEnabled(true); boxPlotAxis->setEnabled(true);
boxScan->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){ double timeMS,acqPeriodMS;
//boxScan->setEnabled(false); 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(timeMS<minPlotTimer){
ret = 1;
qDefs::WarningMessage("Interval between Plots - The Time Interval between plots "
"must be atleast "+string(cplotms)+".","Plot");
spinTimeGap->setValue(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 - "<<spinTimeGap->value()<<qDefs::getUnitString((qDefs::timeUnit)comboTimeGapUnit->currentIndex())<<endl;
#endif
break;
case 1:
acqPeriodMS = (myDet->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(timeMS<minPlotTimer){
ret = 1;
int minFrame = (ceil)(minPlotTimer/acqPeriodMS);
qDefs::WarningMessage("<b>Plot Tab:</b> Interval between Plots - The nth Image must be larger.<br><br>"
"Condition to be satisfied:\n(Acquisition Period)*(nth Image) >= 500ms."
"<br><br>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 - "<<spinNthFrame->value()<<endl;
#endif
break;
}
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::Refresh(){
SetFrequency();
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -96,7 +96,7 @@ void qTabSettings::SetupDetectorSettings(){
item[(int)VeryHighGain]->setEnabled(true); item[(int)VeryHighGain]->setEnabled(true);
break; break;
default: default:
qDefs::ErrorMessage("ERROR: Unknown detector type.","Settings: ERROR"); qDefs::ErrorMessage("Unknown detector type.","Settings");
exit(-1); exit(-1);
break; break;
} }
@ -104,8 +104,8 @@ void qTabSettings::SetupDetectorSettings(){
* This should not happen -only if the server and gui has a mismatch * This should not happen -only if the server and gui has a mismatch
* on which all modes are allowed in detectors */ * on which all modes are allowed in detectors */
if(!(item[(int)sett]->isEnabled())){ if(!(item[(int)sett]->isEnabled())){
qDefs::ErrorMessage("ERROR: Unknown Detector Settings retrieved from detector. " qDefs::ErrorMessage("Unknown Detector Settings retrieved from detector. "
"Exiting GUI.","Settings: ERROR"); "Exiting GUI.","Settings");
#ifdef VERBOSE #ifdef VERBOSE
cout<<"ERROR: Unknown Detector Settings retrieved from detector."<<endl; cout<<"ERROR: Unknown Detector Settings retrieved from detector."<<endl;
#endif #endif