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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -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
};
//-------------------------------------------------------------------------------------------------------------------------------------------------
};

View File

@ -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 <QWidget>
#include <QGridLayout>
#include <QGroupBox>
#include <QTimer>
#include <QString>
/** 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);
};

View File

@ -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();
};

View File

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

View File

@ -14,6 +14,8 @@
class slsDetectorUtils;
/** Qt Project Class Headers */
class qDrawPlot;
/** Qt Include Headers */
#include <QStackedLayout>
/**
*@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);

View File

@ -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");
}
//-------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -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;

View File

@ -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;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)));
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
@ -292,7 +297,8 @@ int qDrawPlot::GetData(detectorData *data){
for(int i=currentPersistency;i>0;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: "<<currentFrame+1<<endl;
#endif
if(!plotLock){
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
char temp_title[2000];
/** 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));
}
}
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
cout<<"Exiting GetData function"<<endl;
#endif
@ -341,9 +353,6 @@ int qDrawPlot::GetData(detectorData *data){
void qDrawPlot::setNumMeasurements(int num){
number_of_measurements = num;
#ifdef VERBOSE
cout<<"Setting Number of Measurements to " <<num<<endl;
#endif
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
@ -376,52 +385,91 @@ void qDrawPlot::Clear1DPlot(){
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::UpdatePlot(){
//static int last_plot_number = 0;
plot_update_timer->stop();
if(plotEnable){
LockLastImageArray();
//1-d plot stuff
if(lastImageNumber){
if(histNBins){
#ifdef VERYVERBOSE
cout<<"Last Image Number: "<<lastImageNumber<<endl;
cout<<"Entering UpdatePlot function"<<endl;
#endif
Clear1DPlot();
plot1D->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: "<<lastImageNumber<<endl;
#endif
Clear1DPlot();
plot1D->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();
}

View File

@ -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 " <<val<<endl;
#endif
numMeasurement = val;
myPlot->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" << "/"<<spinExpTime->value()<<qDefs::getUnitString((qDefs::timeUnit)comboExpUnit->currentIndex())<<endl;
#endif
myDet->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"<< "/"<<spinPeriod->value()<<qDefs::getUnitString((qDefs::timeUnit)comboPeriodUnit->currentIndex())<<endl;
#endif
myDet->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"<< "/"<<spinDelay->value()<<qDefs::getUnitString((qDefs::timeUnit)comboDelayUnit->currentIndex())<<endl;
#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;
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();
}

View File

@ -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<<dispLog->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");
}
}

View File

@ -15,6 +15,7 @@
/** C++ Include Headers */
#include <iostream>
#include <string>
#include <math.h>
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(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);
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."<<endl;
#endif