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

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