fixed the dac problem

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@28 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2012-08-15 17:21:05 +00:00
parent 63bfdb9cb9
commit 30c11d7589
14 changed files with 214 additions and 108 deletions

View File

@ -1051,7 +1051,7 @@
<item row="0" column="2"> <item row="0" column="2">
<widget class="QRadioButton" name="radioHistogram"> <widget class="QRadioButton" name="radioHistogram">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">

View File

@ -264,7 +264,10 @@ private:
static int GetDataCallBack(detectorData *data, void *this_pointer); static int GetDataCallBack(detectorData *data, void *this_pointer);
/** This is called by the GetDataCallBack function to copy the data */ /** This is called by the GetDataCallBack function to copy the data */
int GetData(detectorData *data); int GetData(detectorData *data);
/** This is called by the detector class to copy the scan data it jus acquired */
static int GetScanDataCallBack(detectorData *data, void *this_pointer);
/** This is called by the GetDataCallBack function to copy the scan data */
int GetScanData(detectorData *data);
public slots: public slots:
/** To select 1D or 2D plot /** To select 1D or 2D plot

View File

@ -145,7 +145,7 @@ void BrowseFileStepsPath();
signals: signals:
void EnableScanBox(bool,int); void EnableScanBox(int,int);
}; };

View File

@ -111,7 +111,7 @@ void SetPosition();
void DeletePosition(); void DeletePosition();
signals: signals:
void EnableScanBox(bool,int); void EnableScanBox(int,int);
}; };

View File

@ -98,6 +98,12 @@ void UpdateFinished();
*/ */
void SetCurrentMeasurement(int val); void SetCurrentMeasurement(int val);
/** Sets the timing mode
* @ param mode cane be None, Auto, Gated, Trigger Exposure Series,
* Trigger Frame, Trigger Readout, External Trigger Window
*/
void SetTimingMode(int mode);
private slots: private slots:
/** Set number of measurements /** Set number of measurements
* @param num number of measurements to be set */ * @param num number of measurements to be set */
@ -117,12 +123,6 @@ void setRunIndex(int index);
*/ */
void startStopAcquisition(); void startStopAcquisition();
/** Sets the timing mode
* @ param mode cane be None, Auto, Gated, Trigger Exposure Series,
* Trigger Frame, Trigger Readout, External Trigger Window
*/
void setTimingMode(int mode);
/** Set number of frames /** Set number of frames
* @param val number of frames to be set * @param val number of frames to be set
*/ */

View File

@ -49,8 +49,9 @@ private:
/** 1d/2d plot */ /** 1d/2d plot */
bool isOneD; bool isOneD;
bool isOrginallyOneD;
bool scanLevel[2]; int scanLevel[2];
QStackedLayout* stackedLayout; QStackedLayout* stackedLayout;
QSpinBox *spinNthFrame; QSpinBox *spinNthFrame;
@ -84,7 +85,7 @@ void SetFrequency();
* @param enable to enable the scan group box * @param enable to enable the scan group box
* @param id is 0 if its scan level 0 or scan level 1 * @param id is 0 if its scan level 0 or scan level 1
*/ */
void EnableScanBox(bool enable,int id); void EnableScanBox(int mode,int id);
@ -118,6 +119,7 @@ signals:
void DisableZoomSignal(bool); void DisableZoomSignal(bool);
void SetZRangeSignal(double,double); void SetZRangeSignal(double,double);
void EnableZRangeSignal(bool); void EnableZRangeSignal(bool);
void ThresholdScanSignal(int);
}; };

View File

@ -6,7 +6,7 @@ UI_HEADERS_DIR = forms/include
RESOURCES += icons.qrc RESOURCES += icons.qrc
DEFINES += VERBOSE DEFINES += VERBOSE DACS_INT
target.path += $(DESTDIR) target.path += $(DESTDIR)

View File

@ -138,7 +138,7 @@ void qDetectorMain::SetUpWidgetWindow(){
// increase the width so it uses all the empty space for the tab titles // increase the width so it uses all the empty space for the tab titles
tabs->tabBar()->setFixedWidth(width()+61); tabs->tabBar()->setFixedWidth(width()+61);
// mode setup - to set up the tabs initially as disabled, not in form so done here // mode setup - to set up the tabs initially as disabled, not in form so done here
#ifdef VERBOSE #ifdef VERBOSE
cout << "Setting Debug Mode to 0\nSetting Beamline Mode to 0\n" cout << "Setting Debug Mode to 0\nSetting Beamline Mode to 0\n"
"Setting Expert Mode to 0\nSetting Dockable Mode to false\n" "Setting Expert Mode to 0\nSetting Dockable Mode to false\n"
@ -224,9 +224,9 @@ void qDetectorMain::Initialization(){
connect(tab_measurement, SIGNAL(CheckPlotIntervalSignal()), tab_plot,SLOT(SetFrequency())); 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)));
connect(tab_plot, SIGNAL(ThresholdScanSignal(int)), tab_measurement,SLOT(SetTimingMode(int)));
// Actions tab // Actions tab
connect(tab_actions, SIGNAL(EnableScanBox(bool,int)), tab_plot,SLOT(EnableScanBox(bool,int))); connect(tab_actions, SIGNAL(EnableScanBox(int,int)), tab_plot,SLOT(EnableScanBox(int,int)));
// Plotting // Plotting
// When the acquisition is finished, must update the meas tab // When the acquisition is finished, must update the meas tab
connect(myPlot, SIGNAL(UpdatingPlotFinished()), this, SLOT(EnableTabs())); connect(myPlot, SIGNAL(UpdatingPlotFinished()), this, SLOT(EnableTabs()));
@ -453,6 +453,14 @@ void qDetectorMain::resizeEvent(QResizeEvent* event){
centralwidget->setMaximumHeight(heightCentralWidget); centralwidget->setMaximumHeight(heightCentralWidget);
} }
} }
//adjusting tab width
if(width()>=800){ tabs->tabBar()->setFixedWidth(width()+61);}
else { tabs->tabBar()->setMinimumWidth(0);
tabs->tabBar()->setExpanding(true);
tabs->tabBar()->setUsesScrollButtons(true);
}
event->accept(); event->accept();
} }

View File

@ -64,7 +64,8 @@ void qDrawPlot::SetupWidgetWindow(){
lastImageNumber = 0; lastImageNumber = 0;
last_plot_number = 0; last_plot_number = 0;
nPixelsX = 1280; nPixelsY = 100; nPixelsX = myDet->getTotalNumberOfChannels();
nPixelsY = 100;
lastImageArray = 0; lastImageArray = 0;
image_data = 0; image_data = 0;
@ -426,8 +427,64 @@ int qDrawPlot::GetData(detectorData *data){
return 0; return 0;
} }
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
int qDrawPlot::GetScanDataCallBack(detectorData *data, void *this_pointer){
((qDrawPlot*)this_pointer)->GetScanData(data);
return 0;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
int qDrawPlot::GetScanData(detectorData *data){/*
#ifdef VERYVERBOSE
cout<<"Entering GetScanDatafunction"<<endl;
#endif
if(!stop_signal){
//if plot disabled, RETURN
if(!plotEnable) {
progress=(int)data->progressIndex;
//lastImageNumber= currentFrame+1;
currentThrehold++;
return 0;
}
//what comes here has plot enabled AND (frame factor OR data pause over )
progress=(int)data->progressIndex;
#ifdef VERYVERBOSE
cout<<"Reading in image: "<<currentThrehold<<endl;
#endif
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
lastImageNumber= currentThrehold+1;
nPixelsY = currentThrehold+1;
// Titles
sprintf(temp_title,"Adding Threshold %f",threhold[currentThrehold]);
imageTitle = temp_title;
// copy data
memcpy(lastImageArray[i],data->values,nPixelsX*sizeof(double));
pthread_mutex_unlock(&(last_image_complete_mutex));
}
currentThrehold++;
}
#ifdef VERYVERBOSE
cout<<"Exiting GetScanData function"<<endl;
#endif*/
return 0;
}
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D
if(i==1){ if(i==1){
plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); plot1D->SetXTitle(histXAxisTitle.toAscii().constData());

View File

@ -323,9 +323,6 @@ void qScanWidget::SetMode(int mode){
//set the group box widgets //set the group box widgets
EnableSizeWidgets(); EnableSizeWidgets();
//emit signal to enable scanbox in plot tab
emit EnableScanBox(mode,id);
//set the mode //set the mode
SetScan(mode); SetScan(mode);
} }
@ -366,16 +363,20 @@ int qScanWidget::SetScan(int mode){
break; break;
} }
//custom script
int actualMode = myDet->getScanMode(id);
if((mode==CustomScript)&&((script=="")||(script=="none"))){ if((mode==CustomScript)&&((script=="")||(script=="none"))){
return qDefs::OK; return qDefs::OK;
}else{ }else{//mode NOT set
if((mode!=myDet->getScanMode(id))&&(actualNumSteps)){ if((mode!=actualMode)&&(actualNumSteps)){
qDefs::WarningMessage("The mode could not be changed for an unknown reason.","ScanWidget"); qDefs::WarningMessage("The mode could not be changed for an unknown reason.","ScanWidget");
comboScript->setCurrentIndex(myDet->getScanMode(id)); comboScript->setCurrentIndex(actualMode);
return qDefs::FAIL; return qDefs::FAIL;
} }
} }
emit EnableScanBox(actualMode,id);
return qDefs::OK; return qDefs::OK;
} }

View File

@ -181,7 +181,7 @@ void qTabActions::Initialization(){
connect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*))); connect(group, SIGNAL(buttonClicked(QAbstractButton*)), this,SLOT(Expand(QAbstractButton*)));
//enable scan box in plot tab //enable scan box in plot tab
for(int i=0;i<qScanWidget::NUM_SCAN_WIDGETS;i++) for(int i=0;i<qScanWidget::NUM_SCAN_WIDGETS;i++)
connect(scanWidget[i], SIGNAL(EnableScanBox(bool,int)), this,SIGNAL(EnableScanBox(bool,int))); connect(scanWidget[i], SIGNAL(EnableScanBox(int,int)), this,SIGNAL(EnableScanBox(int,int)));
//positions //positions
connect(comboPos, SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition())); connect(comboPos, SIGNAL(currentIndexChanged(int)), this, SLOT(SetPosition()));
connect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition())); connect(spinNumPos, SIGNAL(valueChanged(int)), this, SLOT(SetPosition()));

View File

@ -182,11 +182,11 @@ void qTabDeveloper::CreateADCWidgets(){
void qTabDeveloper::SetDacValues(int id){ void qTabDeveloper::SetDacValues(int id){
#ifdef VERYVERBOSE #ifdef VERBOSE
cout << "Setting dac:" <<dacNames[id] << " : " << spinDacs[id]->value() << endl; cout << "Setting dac:" <<dacNames[id] << " : " << spinDacs[id]->value() << endl;
#endif #endif
spinDacs[id]->setValue(myDet->setDAC(spinDacs[id]->value(),getSLSIndex(id))); spinDacs[id]->setValue((double)myDet->setDAC(spinDacs[id]->value(),getSLSIndex(id)));
} }
@ -246,7 +246,7 @@ void qTabDeveloper::RefreshAdcs(){
#endif #endif
adcTimer->stop(); adcTimer->stop();
for(int i=0;i<NUM_ADC_WIDGETS;i++) for(int i=0;i<NUM_ADC_WIDGETS;i++)
spinAdcs[i]->setValue(myDet->getADC(getSLSIndex(i+NUM_DAC_WIDGETS))); spinAdcs[i]->setValue((double)myDet->getADC(getSLSIndex(i+NUM_DAC_WIDGETS)));
adcTimer->start(ADC_TIMEOUT); adcTimer->start(ADC_TIMEOUT);
} }
@ -260,8 +260,7 @@ void qTabDeveloper::Refresh(){
#endif #endif
//dacs //dacs
for(int i=0;i<NUM_DAC_WIDGETS;i++) for(int i=0;i<NUM_DAC_WIDGETS;i++)
spinDacs[i]->setValue(myDet->setDAC(-1,getSLSIndex(i))); spinDacs[i]->setValue((double)myDet->setDAC(-1,getSLSIndex(i)));
//adcs //adcs
RefreshAdcs(); RefreshAdcs();
} }

View File

@ -143,15 +143,15 @@ void qTabMeasurement::SetupTimingMode(){
int triggers = (int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1); int triggers = (int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1);
if((frames==1)&&(triggers==1)){ if((frames==1)&&(triggers==1)){
comboTimingMode->setCurrentIndex((int)None); comboTimingMode->setCurrentIndex((int)None);
setTimingMode((int)None); SetTimingMode((int)None);
}else{ }else{
comboTimingMode->setCurrentIndex((int)Auto); comboTimingMode->setCurrentIndex((int)Auto);
setTimingMode((int)Auto); SetTimingMode((int)Auto);
} }
}else{ }else{
//mode +1 since the detector class has no timingmode as "None" //mode +1 since the detector class has no timingmode as "None"
comboTimingMode->setCurrentIndex((int)mode+1); comboTimingMode->setCurrentIndex((int)mode+1);
setTimingMode((int)mode+1); SetTimingMode((int)mode+1);
} }
} }
// Mode NOT ENABLED. // Mode NOT ENABLED.
@ -162,7 +162,7 @@ void qTabMeasurement::SetupTimingMode(){
"\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"); "Number of Frames \t: 1\nNumber of Triggers \t: 1","Measurement");
comboTimingMode->setCurrentIndex((int)None); comboTimingMode->setCurrentIndex((int)None);
setTimingMode((int)None); SetTimingMode((int)None);
} }
} }
} }
@ -183,7 +183,7 @@ void qTabMeasurement::Initialization(int timingChange){
//Start/Stop Acquisition //Start/Stop Acquisition
connect(btnStartStop, SIGNAL(clicked()), this, SLOT(startStopAcquisition())); connect(btnStartStop, SIGNAL(clicked()), this, SLOT(startStopAcquisition()));
//Timing Mode //Timing Mode
connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(setTimingMode(int)));// connect(comboTimingMode, SIGNAL(currentIndexChanged(int)), this, SLOT(SetTimingMode(int)));//
//progress bar //progress bar
connect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress())); connect(progressTimer, SIGNAL(timeout()), this, SLOT(UpdateProgress()));
//enable write to file //enable write to file
@ -467,7 +467,7 @@ void qTabMeasurement::setNumProbes(int val){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMeasurement::setTimingMode(int mode){ void qTabMeasurement::SetTimingMode(int mode){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Setting Timing mode to " << comboTimingMode->currentText().toAscii().data() << endl; cout << "Setting Timing mode to " << comboTimingMode->currentText().toAscii().data() << endl;
#endif #endif

View File

@ -8,11 +8,11 @@
#include "qTabPlot.h" #include "qTabPlot.h"
#include "qDefs.h" #include "qDefs.h"
#include "qDrawPlot.h" #include "qDrawPlot.h"
/** Project Class Headers */ // Project Class Headers
#include "slsDetector.h" #include "slsDetector.h"
#include "multiSlsDetector.h" #include "multiSlsDetector.h"
/** Qt Include Headers */ // Qt Include Headers
/** C++ Include Headers */ // C++ Include Headers
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <math.h> #include <math.h>
@ -55,7 +55,7 @@ void qTabPlot::SetupWidgetWindow(){
scanLevel[0]=false; scanLevel[0]=false;
scanLevel[1]=false; scanLevel[1]=false;
/** Plot Axis*/ // Plot Axis
myPlot->SetPlotTitle(defaultPlotTitle); myPlot->SetPlotTitle(defaultPlotTitle);
dispTitle->setText(defaultPlotTitle); dispTitle->setText(defaultPlotTitle);
dispTitle->setEnabled(false); dispTitle->setEnabled(false);
@ -75,7 +75,7 @@ void qTabPlot::SetupWidgetWindow(){
dispYMax->setValidator(new QDoubleValidator(dispYMax)); dispYMax->setValidator(new QDoubleValidator(dispYMax));
dispZMax->setValidator(new QDoubleValidator(dispZMax)); dispZMax->setValidator(new QDoubleValidator(dispZMax));
/** Plotting Frequency */ // Plotting Frequency
stackedLayout = new QStackedLayout; stackedLayout = new QStackedLayout;
stackedLayout->setSpacing(0); stackedLayout->setSpacing(0);
@ -106,13 +106,13 @@ void qTabPlot::SetupWidgetWindow(){
stackWidget->setLayout(stackedLayout); stackWidget->setLayout(stackedLayout);
/** Depending on whether the detector is 1d or 2d*/ // Depending on whether the detector is 1d or 2d
switch(myDet->getDetectorsType()){ switch(myDet->getDetectorsType()){
case slsDetectorDefs::MYTHEN: Select1DPlot(true); break; case slsDetectorDefs::MYTHEN: isOrginallyOneD = true; Select1DPlot(true); break;
case slsDetectorDefs::EIGER: Select1DPlot(false);break; case slsDetectorDefs::EIGER: isOrginallyOneD = false; Select1DPlot(false);break;
case slsDetectorDefs::GOTTHARD: Select1DPlot(true);break; case slsDetectorDefs::GOTTHARD: isOrginallyOneD = true; Select1DPlot(true);break;
default: default:
cout<<"ERROR: Detector Type is Generic"<<endl; cout << "ERROR: Detector Type is Generic" << endl;
exit(-1); exit(-1);
} }
} }
@ -140,10 +140,20 @@ void qTabPlot::Select1DPlot(bool b){
chkZAxis->setEnabled(true); chkZAxis->setEnabled(true);
chkZMin->setEnabled(true); chkZMin->setEnabled(true);
chkZMax->setEnabled(true); chkZMax->setEnabled(true);
//threshold scan
if((scanLevel[0]==2)||(scanLevel[1]==2)){
myPlot->SetImageXAxisTitle("Channel Number");
dispXAxis->setText("Channel Number");
dispYAxis->setText("Threshold");
myPlot->SetImageYAxisTitle("Threshold");
}
else{
myPlot->SetImageXAxisTitle(defaultImageXAxisTitle); myPlot->SetImageXAxisTitle(defaultImageXAxisTitle);
dispXAxis->setText(defaultImageXAxisTitle); dispXAxis->setText(defaultImageXAxisTitle);
myPlot->SetImageYAxisTitle(defaultImageYAxisTitle);
dispYAxis->setText(defaultImageYAxisTitle); dispYAxis->setText(defaultImageYAxisTitle);
myPlot->SetImageYAxisTitle(defaultImageYAxisTitle);
}
myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); myPlot->SetImageZAxisTitle(defaultImageZAxisTitle);
dispZAxis->setText(defaultImageZAxisTitle); dispZAxis->setText(defaultImageZAxisTitle);
myPlot->Select2DPlot(); myPlot->Select2DPlot();
@ -157,29 +167,29 @@ void qTabPlot::Select1DPlot(bool b){
void qTabPlot::Initialization(){ void qTabPlot::Initialization(){
/** Plot arguments box*/ // Plot arguments box
connect(radioNoPlot, SIGNAL(clicked()),this, SLOT(SetPlot())); connect(radioNoPlot, SIGNAL(toggled(bool)),this, SLOT(SetPlot()));
connect(radioHistogram, SIGNAL(clicked()),this, SLOT(SetPlot())); connect(radioHistogram, SIGNAL(toggled(bool)),this, SLOT(SetPlot()));
connect(radioDataGraph, SIGNAL(clicked()),this, SLOT(SetPlot())); connect(radioDataGraph, SIGNAL(toggled(bool)),this, SLOT(SetPlot()));
/** Scan box*/ // Scan box
//connect(scna, SIGNAL(toggled(bool)),this, SLOT(scanstuff(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()));
/** 1D Plot box*/ // 1D Plot box
connect(chkSuperimpose, SIGNAL(toggled(bool)), this, SLOT(EnablePersistency(bool))); connect(chkSuperimpose, SIGNAL(toggled(bool)), this, SLOT(EnablePersistency(bool)));
connect(spinPersistency,SIGNAL(valueChanged(int)), myPlot,SLOT(SetPersistency(int))); connect(spinPersistency,SIGNAL(valueChanged(int)), myPlot,SLOT(SetPersistency(int)));
connect(chkPoints, SIGNAL(toggled(bool)), myPlot, SLOT(SetDottedPlot(bool))); connect(chkPoints, SIGNAL(toggled(bool)), myPlot, SLOT(SetDottedPlot(bool)));
/** 2D Plot box*/ // 2D Plot box
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 */ // Plotting frequency box
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); connect(spinTimeGap, SIGNAL(editingFinished()), this, SLOT(SetFrequency()));
connect(spinNthFrame, 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()));
connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles())); connect(chkYAxis, SIGNAL(toggled(bool)), this, SLOT(EnableTitles()));
@ -205,8 +215,8 @@ void qTabPlot::Initialization(){
connect(dispZMax, SIGNAL(returnPressed()), this, SLOT(SetZRange())); connect(dispZMax, SIGNAL(returnPressed()), this, SLOT(SetZRange()));
connect(this, SIGNAL(SetZRangeSignal(double,double)),myPlot, SIGNAL(SetZRangeSignal(double,double))); connect(this, SIGNAL(SetZRangeSignal(double,double)),myPlot, SIGNAL(SetZRangeSignal(double,double)));
/** Common Buttons*/ // Common Buttons
/** Save */ // Save
connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot())); connect(btnSave, SIGNAL(clicked()), myPlot, SLOT(SavePlot()));
} }
@ -227,20 +237,20 @@ void qTabPlot::EnablePersistency(bool enable){
void qTabPlot::SetTitles(){ void qTabPlot::SetTitles(){
/** Plot Title*/ // Plot Title
if(dispTitle->isEnabled()) if(dispTitle->isEnabled())
myPlot->SetPlotTitle(dispTitle->text()); myPlot->SetPlotTitle(dispTitle->text());
/** X Axis */ // X Axis
if(dispXAxis->isEnabled()){ if(dispXAxis->isEnabled()){
if(isOneD) myPlot->SetHistXAxisTitle(dispXAxis->text()); if(isOneD) myPlot->SetHistXAxisTitle(dispXAxis->text());
else myPlot->SetImageXAxisTitle(dispXAxis->text()); else myPlot->SetImageXAxisTitle(dispXAxis->text());
} }
/** Y Axis */ // Y Axis
if(dispYAxis->isEnabled()){ if(dispYAxis->isEnabled()){
if(isOneD) myPlot->SetHistYAxisTitle(dispYAxis->text()); if(isOneD) myPlot->SetHistYAxisTitle(dispYAxis->text());
else myPlot->SetImageYAxisTitle(dispYAxis->text()); else myPlot->SetImageYAxisTitle(dispYAxis->text());
} }
/** Z Axis */ // Z Axis
if(dispZAxis->isEnabled()) if(dispZAxis->isEnabled())
myPlot->SetImageZAxisTitle(dispZAxis->text()); myPlot->SetImageZAxisTitle(dispZAxis->text());
} }
@ -250,13 +260,13 @@ void qTabPlot::SetTitles(){
void qTabPlot::EnableTitles(){ void qTabPlot::EnableTitles(){
/** Plot Title*/ // Plot Title
dispTitle->setEnabled(chkTitle->isChecked()); dispTitle->setEnabled(chkTitle->isChecked());
if(!chkTitle->isChecked()){ if(!chkTitle->isChecked()){
myPlot->SetPlotTitle(defaultPlotTitle); myPlot->SetPlotTitle(defaultPlotTitle);
dispTitle->setText(defaultPlotTitle); dispTitle->setText(defaultPlotTitle);
} }
/** X Axis */ // X Axis
dispXAxis->setEnabled(chkXAxis->isChecked()); dispXAxis->setEnabled(chkXAxis->isChecked());
if(!chkXAxis->isChecked()){ if(!chkXAxis->isChecked()){
if(isOneD){ if(isOneD){
@ -268,7 +278,7 @@ void qTabPlot::EnableTitles(){
dispXAxis->setText(defaultImageXAxisTitle); dispXAxis->setText(defaultImageXAxisTitle);
} }
} }
/** Y Axis */ // Y Axis
dispYAxis->setEnabled(chkYAxis->isChecked()); dispYAxis->setEnabled(chkYAxis->isChecked());
if(!chkYAxis->isChecked()){ if(!chkYAxis->isChecked()){
if(isOneD){ if(isOneD){
@ -279,7 +289,7 @@ void qTabPlot::EnableTitles(){
dispYAxis->setText(defaultImageYAxisTitle); dispYAxis->setText(defaultImageYAxisTitle);
} }
} }
/** Z Axis */ // Z Axis
dispZAxis->setEnabled(chkZAxis->isChecked()); dispZAxis->setEnabled(chkZAxis->isChecked());
if(!chkZAxis->isChecked()){ if(!chkZAxis->isChecked()){
myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); myPlot->SetImageZAxisTitle(defaultImageZAxisTitle);
@ -313,27 +323,27 @@ void qTabPlot::EnableRange(){
void qTabPlot::SetAxesRange(){ void qTabPlot::SetAxesRange(){
bool changed = false; bool changed = false;
/** x min */ // x min
changed = (dispXMin->isEnabled())&&(!dispXMin->text().isEmpty()); changed = (dispXMin->isEnabled())&&(!dispXMin->text().isEmpty());
if(changed) myPlot->SetXYRangeValues(dispXMin->text().toDouble(),qDefs::XMINIMUM); if(changed) myPlot->SetXYRangeValues(dispXMin->text().toDouble(),qDefs::XMINIMUM);
myPlot->IsXYRangeValues(changed,qDefs::XMINIMUM); myPlot->IsXYRangeValues(changed,qDefs::XMINIMUM);
/** x max */ // x max
changed = (dispXMax->isEnabled())&&(!dispXMax->text().isEmpty()); changed = (dispXMax->isEnabled())&&(!dispXMax->text().isEmpty());
if(changed) myPlot->SetXYRangeValues(dispXMax->text().toDouble(),qDefs::XMAXIMUM); if(changed) myPlot->SetXYRangeValues(dispXMax->text().toDouble(),qDefs::XMAXIMUM);
myPlot->IsXYRangeValues(changed,qDefs::XMAXIMUM); myPlot->IsXYRangeValues(changed,qDefs::XMAXIMUM);
/** y min */ // y min
changed = (dispYMin->isEnabled())&&(!dispYMin->text().isEmpty()); changed = (dispYMin->isEnabled())&&(!dispYMin->text().isEmpty());
if(changed) myPlot->SetXYRangeValues(dispYMin->text().toDouble(),qDefs::YMINIMUM); if(changed) myPlot->SetXYRangeValues(dispYMin->text().toDouble(),qDefs::YMINIMUM);
myPlot->IsXYRangeValues(changed,qDefs::YMINIMUM); myPlot->IsXYRangeValues(changed,qDefs::YMINIMUM);
/** y max */ // y max
changed = (dispYMax->isEnabled())&&(!dispYMax->text().isEmpty()); changed = (dispYMax->isEnabled())&&(!dispYMax->text().isEmpty());
if(changed) myPlot->SetXYRangeValues(dispYMax->text().toDouble(),qDefs::YMAXIMUM); if(changed) myPlot->SetXYRangeValues(dispYMax->text().toDouble(),qDefs::YMAXIMUM);
myPlot->IsXYRangeValues(changed,qDefs::YMAXIMUM); myPlot->IsXYRangeValues(changed,qDefs::YMAXIMUM);
/** To remind the updateplot in qdrawplot to set range after updating plot*/ // To remind the updateplot in qdrawplot to set range after updating plot
myPlot->SetXYRange(true); myPlot->SetXYRange(true);
} }
@ -360,31 +370,46 @@ void qTabPlot::EnableZRange(){
void qTabPlot::SetPlot(){ void qTabPlot::SetPlot(){
#ifdef VERBOSE
cout << "Entering Set Plot()" ;
#endif
if(radioNoPlot->isChecked()){ if(radioNoPlot->isChecked()){
cout << " - No Plot" << endl;
Select1DPlot(isOrginallyOneD);
myPlot->EnablePlot(false); myPlot->EnablePlot(false);
/**if enable is true, disable everything */ //if enable is true, disable everything
if(isOneD) {box1D->show(); box1D->setEnabled(false); box2D->hide();} if(isOrginallyOneD) {box1D->show(); box1D->setEnabled(false); box2D->hide();}
if(!isOneD){box2D->show(); box2D->setEnabled(false); box1D->hide();} if(!isOrginallyOneD){box2D->show(); box2D->setEnabled(false); box1D->hide();}
boxSnapshot->setEnabled(false); boxSnapshot->setEnabled(false);
boxSave->setEnabled(false); boxSave->setEnabled(false);
boxFrequency->setEnabled(false); boxFrequency->setEnabled(false);
boxPlotAxis->setEnabled(false); boxPlotAxis->setEnabled(false);
boxScan->setEnabled(false); boxScan->setEnabled(false);
}else { }else if(radioDataGraph->isChecked()){
cout << " - DataGraph" << endl;
myPlot->EnablePlot(true); myPlot->EnablePlot(true);
/**if enable is true, disable everything */ //if enable is true, disable everything
if(isOneD) {box1D->show();box1D->setEnabled(true);} else box1D->hide(); if(isOrginallyOneD) {box1D->show();box1D->setEnabled(true);} else box1D->hide();
if(!isOneD){box2D->show();box2D->setEnabled(true);} else box2D->hide(); if(!isOrginallyOneD){box2D->show();box2D->setEnabled(true);} else box2D->hide();
Select1DPlot(isOrginallyOneD);
boxSnapshot->setEnabled(true); boxSnapshot->setEnabled(true);
boxSave->setEnabled(true); boxSave->setEnabled(true);
boxFrequency->setEnabled(true); boxFrequency->setEnabled(true);
boxPlotAxis->setEnabled(true); boxPlotAxis->setEnabled(true);
}else{
if(radioHistogram->isChecked()) cout << " - Histogram" << endl;
boxScan->setEnabled(false); myPlot->EnablePlot(true);
else Select1DPlot(false);
//check first if there is a scan from actions tab box1D->hide();
box2D->show();
box2D->setEnabled(true);
boxSnapshot->setEnabled(true);
boxSave->setEnabled(true);
boxFrequency->setEnabled(false);
boxPlotAxis->setEnabled(true);
boxScan->setEnabled(false); boxScan->setEnabled(false);
myPlot->SetPlotTimer(250);
emit ThresholdScanSignal(0);
} }
} }
@ -405,7 +430,7 @@ void qTabPlot::SetFrequency(){
stackedLayout->setCurrentIndex(comboFrequency->currentIndex()); stackedLayout->setCurrentIndex(comboFrequency->currentIndex());
switch(comboFrequency->currentIndex()){ switch(comboFrequency->currentIndex()){
case 0: case 0:
/* Get the time interval from gui in ms*/ // Get the time interval from gui in ms
timeMS = (qDefs::getNSTime((qDefs::timeUnit)comboTimeGapUnit->currentIndex(),spinTimeGap->value()))/(1e6); timeMS = (qDefs::getNSTime((qDefs::timeUnit)comboTimeGapUnit->currentIndex(),spinTimeGap->value()))/(1e6);
if(timeMS<minPlotTimer){ if(timeMS<minPlotTimer){
qDefs::WarningMessage("Interval between Plots - The Time Interval between plots " qDefs::WarningMessage("Interval between Plots - The Time Interval between plots "
@ -413,19 +438,19 @@ void qTabPlot::SetFrequency(){
spinTimeGap->setValue(minPlotTimer); spinTimeGap->setValue(minPlotTimer);
comboTimeGapUnit->setCurrentIndex(qDefs::MILLISECONDS); comboTimeGapUnit->setCurrentIndex(qDefs::MILLISECONDS);
} }
/**This is done so that its known which one was selected */ //This is done so that its known which one was selected
myPlot->SetFrameFactor(0); myPlot->SetFrameFactor(0);
/** Setting the timer value(ms) between plots */ // Setting the timer value(ms) between plots
myPlot->SetPlotTimer(timeMS); myPlot->SetPlotTimer(timeMS);
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Plotting Frequency: Time Gap - "<<spinTimeGap->value()<<qDefs::getUnitString((qDefs::timeUnit)comboTimeGapUnit->currentIndex())<<endl; cout << "Plotting Frequency: Time Gap - " << spinTimeGap->value() << qDefs::getUnitString((qDefs::timeUnit)comboTimeGapUnit->currentIndex()) << endl;
#endif #endif
break; break;
case 1: case 1:
acqPeriodMS = (myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-6)); acqPeriodMS = (myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-6));
/** gets the acq period * number of nth frames*/ // gets the acq period * number of nth frames
timeMS = (spinNthFrame->value())*acqPeriodMS; timeMS = (spinNthFrame->value())*acqPeriodMS;
/** To make sure the period between plotting is not less than minimum plot timer in ms*/ // To make sure the period between plotting is not less than minimum plot timer in ms
if(timeMS<minPlotTimer){ if(timeMS<minPlotTimer){
int minFrame = (ceil)(minPlotTimer/acqPeriodMS); int minFrame = (ceil)(minPlotTimer/acqPeriodMS);
qDefs::WarningMessage("<b>Plot Tab:</b> Interval between Plots - The nth Image must be larger.<br><br>" qDefs::WarningMessage("<b>Plot Tab:</b> Interval between Plots - The nth Image must be larger.<br><br>"
@ -434,10 +459,10 @@ void qTabPlot::SetFrequency(){
"for the chosen Acquisition Period.","Plot"); "for the chosen Acquisition Period.","Plot");
spinNthFrame->setValue(minFrame); spinNthFrame->setValue(minFrame);
} }
/** Setting the timer value (nth frames) between plots */ // Setting the timer value (nth frames) between plots
myPlot->SetFrameFactor(spinNthFrame->value()); myPlot->SetFrameFactor(spinNthFrame->value());
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Plotting Frequency: Nth Frame - "<<spinNthFrame->value()<<endl; cout << "Plotting Frequency: Nth Frame - " << spinNthFrame->value() << endl;
#endif #endif
break; break;
} }
@ -451,10 +476,13 @@ void qTabPlot::SetFrequency(){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabPlot::EnableScanBox(bool enable,int id){ void qTabPlot::EnableScanBox(int mode,int id){
/**find out when this is enabled*/ #ifdef VERBOSE
cout << "Entering Enable Scan Box()" << endl;
#endif
scanLevel[id]=enable;
scanLevel[id]=mode;
//both are disabled //both are disabled
if((!scanLevel[0])&&(!scanLevel[1])){ if((!scanLevel[0])&&(!scanLevel[1])){
boxScan->setEnabled(false); boxScan->setEnabled(false);
@ -467,22 +495,30 @@ void qTabPlot::EnableScanBox(bool enable,int id){
else{ else{
if(!boxScan->isEnabled()) { if(!boxScan->isEnabled()) {
boxScan->setEnabled(true); boxScan->setEnabled(true);
radioFileIndex->setEnabled(false); radioFileIndex->setEnabled(false);/**???*/
} }
//disable one and check the other //disable one and check the other
if(id) { if(id) {
radioLevel0->setEnabled(!enable); radioLevel0->setEnabled(!mode);
radioLevel0->setChecked(!enable); radioLevel0->setChecked(!mode);
radioLevel1->setEnabled(enable); radioLevel1->setEnabled(mode);
radioLevel1->setChecked(enable); radioLevel1->setChecked(mode);
}else{ }else{
radioLevel0->setEnabled(enable); radioLevel0->setEnabled(mode);
radioLevel0->setChecked(enable); radioLevel0->setChecked(mode);
radioLevel1->setEnabled(!enable); radioLevel1->setEnabled(!mode);
radioLevel1->setChecked(!enable); radioLevel1->setChecked(!mode);
} }
} }
/**if(boxScan->isEnabled()){
//check for threshold
if((scanLevel[0]==2)||(scanLevel[1]==2))
radioHistogram->setChecked(true);
else
radioDataGraph->setChecked(true);
/*
if(boxScan->isEnabled()){
myDet->setPlotType(i); myDet->setPlotType(i);
}*/ }*/
} }