updated plot to show index instead of frame number

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@35 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
l_maliakal_d 2012-08-21 11:53:23 +00:00
parent 40af9384b5
commit 1ce04ef785
8 changed files with 185 additions and 108 deletions

View File

@ -519,6 +519,9 @@
<property name="text"> <property name="text">
<string>Level 0</string> <string>Level 0</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -607,7 +610,7 @@
<string>All Frames</string> <string>All Frames</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
@ -1051,7 +1054,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>true</bool> <bool>false</bool>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">

View File

@ -137,6 +137,8 @@ private:
int currentMeasurement; int currentMeasurement;
/** currentFrame */ /** currentFrame */
int currentFrame; int currentFrame;
/** current Index */
int currentIndex;
/** Number of Exposures */ /** Number of Exposures */
int number_of_exposures; int number_of_exposures;
/** Duration between Exposures */ /** Duration between Exposures */

View File

@ -167,6 +167,7 @@ signals:
void StartSignal(); void StartSignal();
void StopSignal(); void StopSignal();
void CheckPlotIntervalSignal(); void CheckPlotIntervalSignal();
void EnableNthFrameSignal(bool);
}; };

View File

@ -16,6 +16,8 @@ class multiSlsDetector;
class qDrawPlot; class qDrawPlot;
/** Qt Include Headers */ /** Qt Include Headers */
#include <QStackedLayout> #include <QStackedLayout>
#include <QButtonGroup>
#include <QAbstractButton>
/** /**
*@short sets up the Plot parameters *@short sets up the Plot parameters
@ -51,12 +53,14 @@ private:
bool isOneD; bool isOneD;
bool isOrginallyOneD; bool isOrginallyOneD;
int scanLevel[2]; /**whether to enable nth frame according to timing mode*/
bool enableNFrame;
QStackedLayout* stackedLayout; QStackedLayout *stackedLayout;
QSpinBox *spinNthFrame; QSpinBox *spinNthFrame;
QDoubleSpinBox *spinTimeGap; QDoubleSpinBox *spinTimeGap;
QComboBox *comboTimeGapUnit; QComboBox *comboTimeGapUnit;
QButtonGroup *btnGroupScan;
/** some Default Values */ /** some Default Values */
static QString defaultPlotTitle; static QString defaultPlotTitle;
@ -75,6 +79,11 @@ private:
*/ */
void Initialization(); void Initialization();
/** This enabled/disables the nth frame from frequency plot
* @param enable enable/disable
*/
void EnablingNthFrameFunction(bool enable);
@ -85,9 +94,18 @@ 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(int mode,int id); void EnableScanBox(int mode=-1,int id=-1);
/** a variable is set when timing mode has been changed.
* This variable is also disabled if exptime>acq period to be on safe side
* Its to check whether to enabled nth frame for frequency plot
* @param enable enable/disable
*/
void EnableNthFrame(bool enable){enableNFrame = enable;};
/** Sets the scan argument of the plot
*/
void SetScanArgument();
private slots: private slots:
@ -119,7 +137,6 @@ 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

@ -222,6 +222,7 @@ void qDetectorMain::Initialization(){
connect(tab_measurement, SIGNAL(StartSignal()), this,SLOT(EnableTabs())); connect(tab_measurement, SIGNAL(StartSignal()), this,SLOT(EnableTabs()));
connect(tab_measurement, SIGNAL(StopSignal()), this,SLOT(EnableTabs())); connect(tab_measurement, SIGNAL(StopSignal()), this,SLOT(EnableTabs()));
connect(tab_measurement, SIGNAL(CheckPlotIntervalSignal()), tab_plot,SLOT(SetFrequency())); connect(tab_measurement, SIGNAL(CheckPlotIntervalSignal()), tab_plot,SLOT(SetFrequency()));
connect(tab_measurement, SIGNAL(EnableNthFrameSignal(bool)), tab_plot,SLOT(EnableNthFrame(bool)));
// Plot tab // Plot tab
connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool))); connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool)));
// Actions tab // Actions tab

View File

@ -51,7 +51,7 @@ qDrawPlot::~qDrawPlot(){
void qDrawPlot::SetupWidgetWindow(){ void qDrawPlot::SetupWidgetWindow(){
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Setting up plot variables"<<endl; cout << "Setting up plot variables" << endl;
#endif #endif
number_of_measurements=1; number_of_measurements=1;
currentMeasurement = 0; currentMeasurement = 0;
@ -184,13 +184,16 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
numTriggers = ((numTriggers==0)?1:numTriggers); numTriggers = ((numTriggers==0)?1:numTriggers);
number_of_exposures= numFrames * numTriggers; number_of_exposures= numFrames * numTriggers;
cout<<"\tNumber of Exposures:"<<number_of_exposures<<endl; cout << "\tNumber of Exposures:" << number_of_exposures << endl;
// ExposureTime // ExposureTime
exposureTime= ((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1))*1E-9); exposureTime= ((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1))*1E-9);
cout<<"\tExposure Time:"<<setprecision (10)<<exposureTime<<endl; cout << "\tExposure Time:" << setprecision (10) << exposureTime << endl;
// Acquisition Period // Acquisition Period
acquisitionPeriod= ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1))*1E-9); acquisitionPeriod= ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1))*1E-9);
cout<<"\tAcquisition Period:"<<setprecision (10)<<acquisitionPeriod<<endl; cout << "\tAcquisition Period:" << setprecision (10) << acquisitionPeriod << endl;
// Current Index
currentIndex = myDet->getFileIndex();
cout << "\tCurrent Index:" << currentIndex << endl;
StartDaq(true); StartDaq(true);
running=!running; running=!running;
@ -202,14 +205,14 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){
void qDrawPlot::StartDaq(bool start){ void qDrawPlot::StartDaq(bool start){
if(start){ if(start){
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Start Daq(true) function"<<endl; cout << "Start Daq(true) function" << endl;
#endif #endif
ResetDaqForGui(); ResetDaqForGui();
StartDaqForGui(); StartDaqForGui();
UpdatePlot(); UpdatePlot();
}else{ }else{
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Start Daq(false) function"<<endl; cout << "Start Daq(false) function" << endl;
#endif #endif
StopDaqForGui(); StopDaqForGui();
StopUpdatePlot(); StopUpdatePlot();
@ -220,7 +223,7 @@ void qDrawPlot::StartDaq(bool start){
int qDrawPlot::ResetDaqForGui(){ int qDrawPlot::ResetDaqForGui(){
if(!StopDaqForGui()) return 0; if(!StopDaqForGui()) return 0;
cout<<"Resetting image number"<<endl; cout << "Resetting image number" << endl;
lastImageNumber = 0; lastImageNumber = 0;
return 1; return 1;
} }
@ -236,7 +239,7 @@ bool qDrawPlot::StartOrStopThread(bool start){
pthread_mutex_lock(&gui_acquisition_start_stop_mutex); pthread_mutex_lock(&gui_acquisition_start_stop_mutex);
//stop part, before start or restart //stop part, before start or restart
if(gui_acquisition_thread_running){ if(gui_acquisition_thread_running){
cout<<"Stopping current acquisition thread ...."<<endl; cout << "Stopping current acquisition thread ...." << endl;
stop_signal = 1;//sorta useless right now stop_signal = 1;//sorta useless right now
gui_acquisition_thread_running = 0; gui_acquisition_thread_running = 0;
} }
@ -259,7 +262,7 @@ bool qDrawPlot::StartOrStopThread(bool start){
if(plot_in_scope==1) Clear1DPlot(); if(plot_in_scope==1) Clear1DPlot();
cout<<"Starting new acquisition threadddd ...."<<endl; cout << "Starting new acquisition threadddd ...." << endl;
// Setting the callback function to get data from software client // Setting the callback function to get data from software client
myDet->registerDataCallback(&(GetDataCallBack),this); myDet->registerDataCallback(&(GetDataCallBack),this);
// Start acquiring data from server // Start acquiring data from server
@ -270,7 +273,7 @@ bool qDrawPlot::StartOrStopThread(bool start){
// This is manually done instead of keeping track of thread because // This is manually done instead of keeping track of thread because
// this thread returns immediately after executing the acquire command // this thread returns immediately after executing the acquire command
gui_acquisition_thread_running=1; gui_acquisition_thread_running=1;
cout<<"Started acquiring threaddd:"<<endl; cout << "Started acquiring threaddd:" << endl;
} }
pthread_mutex_unlock(&gui_acquisition_start_stop_mutex); pthread_mutex_unlock(&gui_acquisition_start_stop_mutex);
return gui_acquisition_thread_running; return gui_acquisition_thread_running;
@ -279,9 +282,9 @@ bool qDrawPlot::StartOrStopThread(bool start){
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void* qDrawPlot::DataStartAcquireThread(void *this_pointer){ void* qDrawPlot::DataStartAcquireThread(void *this_pointer){
cout<<"before acquire ...."<<endl; cout << "before acquire ...." << endl;
((qDrawPlot*)this_pointer)->myDet->acquire(1); ((qDrawPlot*)this_pointer)->myDet->acquire(1);
cout<<"after acquire ...."<<endl; cout << "after acquire ...." << endl;
return this_pointer; return this_pointer;
} }
@ -296,7 +299,7 @@ int qDrawPlot::GetDataCallBack(detectorData *data, void *this_pointer){
int qDrawPlot::GetData(detectorData *data){ int qDrawPlot::GetData(detectorData *data){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"Entering GetDatafunction"<<endl; cout << "Entering GetDatafunction" << endl;
#endif #endif
if(!stop_signal){ if(!stop_signal){
//not frame factor //not frame factor
@ -305,6 +308,7 @@ int qDrawPlot::GetData(detectorData *data){
if(!data_pause_over){ if(!data_pause_over){
//lastImageNumber= currentFrame+1; //lastImageNumber= currentFrame+1;
currentFrame++; currentFrame++;
currentIndex++;
return 0; return 0;
} }
data_pause_over=false; data_pause_over=false;
@ -317,11 +321,12 @@ int qDrawPlot::GetData(detectorData *data){
else{ else{
//lastImageNumber= currentFrame+1; //lastImageNumber= currentFrame+1;
currentFrame++; currentFrame++;
currentIndex++;
progress=(int)data->progressIndex; progress=(int)data->progressIndex;
//if theres an old copy, try to get lock again //if theres an old copy, try to get lock again
if(oldCopy){ if(oldCopy){
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Copying old data: "<<oldFrameNumber<<endl; cout << "Copying old data: " << oldFrameNumber << endl;
#endif #endif
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
char temp_title[2000]; char temp_title[2000];
@ -330,7 +335,7 @@ int qDrawPlot::GetData(detectorData *data){
//1d //1d
if(plot_in_scope==1){ if(plot_in_scope==1){
// Titles // Titles
sprintf(temp_title,"Frame %d",oldFrameNumber); histTitle[0] = temp_title; sprintf(temp_title,"Frame Index%d",oldFrameNumber); histTitle[0] = temp_title;
// copy data//memcpy(histXAxis, xvalues,nPixelsX*sizeof(double)); // copy data//memcpy(histXAxis, xvalues,nPixelsX*sizeof(double));
for(int i=currentPersistency;i>0;i--) for(int i=currentPersistency;i>0;i--)
memcpy(histYAxis[i],yvalues[i-1],nPixelsX*sizeof(double)); memcpy(histYAxis[i],yvalues[i-1],nPixelsX*sizeof(double));
@ -338,7 +343,7 @@ int qDrawPlot::GetData(detectorData *data){
}//2d }//2d
else{ else{
// Titles // Titles
sprintf(temp_title,"Image Number %d",oldFrameNumber); sprintf(temp_title,"Image Index %d",oldFrameNumber);
imageTitle = temp_title; imageTitle = temp_title;
// copy data // copy data
//memcpy(lastImageArray,image_data,nPixelsX*nPixelsY*sizeof(double)); //memcpy(lastImageArray,image_data,nPixelsX*nPixelsY*sizeof(double));
@ -354,6 +359,7 @@ int qDrawPlot::GetData(detectorData *data){
progress=(int)data->progressIndex; progress=(int)data->progressIndex;
//lastImageNumber= currentFrame+1; //lastImageNumber= currentFrame+1;
currentFrame++; currentFrame++;
currentIndex++;
return 0; return 0;
} }
//what comes here has plot enabled AND (frame factor OR data pause over ) //what comes here has plot enabled AND (frame factor OR data pause over )
@ -361,7 +367,7 @@ int qDrawPlot::GetData(detectorData *data){
if((currentFrame)<(number_of_exposures)){ if((currentFrame)<(number_of_exposures)){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"Reading in image: "<<currentFrame<<endl; cout << "Reading in image: " << currentIndex << endl;
#endif #endif
if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){
char temp_title[2000]; char temp_title[2000];
@ -371,7 +377,7 @@ int qDrawPlot::GetData(detectorData *data){
//1d //1d
if(plot_in_scope==1){ if(plot_in_scope==1){
// Titles // Titles
sprintf(temp_title,"Frame %d",currentFrame); histTitle[0] = temp_title; sprintf(temp_title,"Frame Index %d",currentIndex); histTitle[0] = temp_title;
// Persistency // Persistency
if(currentPersistency < persistency)currentPersistency++; if(currentPersistency < persistency)currentPersistency++;
else currentPersistency=persistency; else currentPersistency=persistency;
@ -386,7 +392,7 @@ int qDrawPlot::GetData(detectorData *data){
//2d //2d
else{ else{
// Titles // Titles
sprintf(temp_title,"Image Number %d",currentFrame); sprintf(temp_title,"Image Index %d",currentIndex);
imageTitle = temp_title; imageTitle = temp_title;
// manufacture data for now // manufacture data for now
for(unsigned int px=0;px<nPixelsX;px++) for(unsigned int px=0;px<nPixelsX;px++)
@ -400,7 +406,7 @@ int qDrawPlot::GetData(detectorData *data){
}//copies old data only if its frame factor }//copies old data only if its frame factor
else if(frameFactor){ else if(frameFactor){
oldCopy = true; oldCopy = true;
oldFrameNumber = currentFrame; oldFrameNumber = currentIndex;
//1D //1D
if(plot_in_scope==1){ if(plot_in_scope==1){
// Persistency // Persistency
@ -419,10 +425,11 @@ int qDrawPlot::GetData(detectorData *data){
} }
} }
currentFrame++; currentFrame++;
currentIndex++;
} }
} }
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"Exiting GetData function"<<endl; cout << "Exiting GetData function" << endl;
#endif #endif
return 0; return 0;
} }
@ -442,7 +449,7 @@ int qDrawPlot::GetScanDataCallBack(detectorData *data, void *this_pointer){
int qDrawPlot::GetScanData(detectorData *data){/* int qDrawPlot::GetScanData(detectorData *data){/*
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"Entering GetScanDatafunction"<<endl; cout << "Entering GetScanDatafunction"<<endl;
#endif #endif
if(!stop_signal){ if(!stop_signal){
//if plot disabled, RETURN //if plot disabled, RETURN
@ -516,7 +523,7 @@ void qDrawPlot::Clear1DPlot(){
void qDrawPlot::UpdatePlot(){ void qDrawPlot::UpdatePlot(){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"Entering UpdatePlot function"<<endl; cout << "Entering UpdatePlot function" << endl;
#endif #endif
plot_update_timer->stop(); plot_update_timer->stop();
@ -528,7 +535,7 @@ void qDrawPlot::UpdatePlot(){
if(lastImageNumber){ if(lastImageNumber){
if(histNBins){ if(histNBins){
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"Last Image Number: "<<lastImageNumber<<endl; cout << "Last Image Number: " << lastImageNumber << endl;
#endif #endif
Clear1DPlot(); Clear1DPlot();
plot1D->SetXTitle(histXAxisTitle.toAscii().constData()); plot1D->SetXTitle(histXAxisTitle.toAscii().constData());
@ -602,6 +609,7 @@ void qDrawPlot::UpdatePlot(){
}// To start the next measurement }// To start the next measurement
else{ else{
emit SetCurrentMeasurementSignal(currentMeasurement); emit SetCurrentMeasurementSignal(currentMeasurement);
currentIndex++;
StopDaqForGui(); StopDaqForGui();
StartDaq(true); StartDaq(true);
} }
@ -626,7 +634,7 @@ void qDrawPlot::ClonePlot(){
} }
// no space for more clone widget references // no space for more clone widget references
if(!found){ if(!found){
cout<<"Too many clones"<<endl; cout << "Too many clones" << endl;
exit(-1); exit(-1);
} }
// save height to keep maintain same height of plot // save height to keep maintain same height of plot
@ -679,7 +687,7 @@ void qDrawPlot::CloseClones(){
void qDrawPlot::CloneCloseEvent(int id){ void qDrawPlot::CloneCloseEvent(int id){
winClone[id]=0; winClone[id]=0;
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Closing Clone Window id:"<<id<<endl; cout << "Closing Clone Window id:" << id << endl;
#endif #endif
} }
@ -718,7 +726,7 @@ void qDrawPlot::SetPersistency(int val){
void qDrawPlot::EnablePlot(bool enable){ void qDrawPlot::EnablePlot(bool enable){
#ifdef VERBOSE #ifdef VERBOSE
cout<<"Plotting set to:"<<enable<<endl; cout << "Plotting set to:" << enable << endl;
#endif #endif
plotEnable = enable; plotEnable = enable;
//if no plot, cant do setting range. //if no plot, cant do setting range.

View File

@ -404,14 +404,17 @@ void qTabMeasurement::setAcquisitionPeriod(){
lblPeriod->setToolTip(errPeriodTip); lblPeriod->setToolTip(errPeriodTip);
lblPeriod->setPalette(red); lblPeriod->setPalette(red);
lblPeriod->setText("Acquisition Period:*"); lblPeriod->setText("Acquisition Period:*");
emit EnableNthFrameSignal(false);
} }
else { else {
spinPeriod->setToolTip(acqPeriodTip); spinPeriod->setToolTip(acqPeriodTip);
lblPeriod->setToolTip(acqPeriodTip); lblPeriod->setToolTip(acqPeriodTip);
lblPeriod->setPalette(lblTimingMode->palette()); lblPeriod->setPalette(lblTimingMode->palette());
lblPeriod->setText("Acquisition Period:"); lblPeriod->setText("Acquisition Period:");
emit EnableNthFrameSignal(true);
} }
//Check if the interval between plots is ok //Check if the interval between plots is ok
emit CheckPlotIntervalSignal(); emit CheckPlotIntervalSignal();
} }
@ -558,6 +561,7 @@ void qTabMeasurement::SetTimingMode(int mode){
return; return;
} }
if(mode!=None){//Number of Probes if(mode!=None){//Number of Probes
if(myDet->getDetectorsType()==slsDetectorDefs::MYTHEN){ if(myDet->getDetectorsType()==slsDetectorDefs::MYTHEN){
lblNumProbes->setEnabled(true); spinNumProbes->setEnabled(true); lblNumProbes->setEnabled(true); spinNumProbes->setEnabled(true);
@ -668,9 +672,19 @@ void qTabMeasurement::SetTimingMode(int mode){
myPlot->setFrameEnabled(lblNumFrames->isEnabled()); myPlot->setFrameEnabled(lblNumFrames->isEnabled());
myPlot->setTriggerEnabled(lblNumTriggers->isEnabled()); myPlot->setTriggerEnabled(lblNumTriggers->isEnabled());
//check if period is enabled and alright, only then the nth frame frequency is enabled
if((lblPeriod->isEnabled())&&(lblPeriod->text()=="Acquisition Period:"))
emit EnableNthFrameSignal(true);
else emit EnableNthFrameSignal(false);
return; return;
} }
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabMeasurement::EnableFileWrite(bool enable){ void qTabMeasurement::EnableFileWrite(bool enable){
#ifdef VERBOSE #ifdef VERBOSE
cout << "Enable File Write:" << enable << endl; cout << "Enable File Write:" << enable << endl;

View File

@ -12,6 +12,7 @@
#include "slsDetector.h" #include "slsDetector.h"
#include "multiSlsDetector.h" #include "multiSlsDetector.h"
// Qt Include Headers // Qt Include Headers
#include <QStandardItemModel>
// C++ Include Headers // C++ Include Headers
#include <iostream> #include <iostream>
#include <string> #include <string>
@ -52,8 +53,27 @@ qTabPlot::~qTabPlot(){
void qTabPlot::SetupWidgetWindow(){ void qTabPlot::SetupWidgetWindow(){
scanLevel[0]=false; //check if nth frame should be enabled
scanLevel[1]=false; enableNFrame = true;
//according to timing mode
slsDetectorDefs::externalCommunicationMode mode = myDet->setExternalCommunicationMode();
if( (mode==slsDetectorDefs::GATE_FIX_NUMBER)||
(mode==slsDetectorDefs::TRIGGER_FRAME) ||
(mode==slsDetectorDefs::TRIGGER_WINDOW) ||
((mode==slsDetectorDefs::AUTO_TIMING)&&((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)==1)&&((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)==1)) )
enableNFrame = false;
//according to if exptime > acq period
if((myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1)*(1E-9))>(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1)*(1E-9)))
enableNFrame = false;
//scan arguments
btnGroupScan = new QButtonGroup(this);
btnGroupScan->addButton(radioLevel0,0);
btnGroupScan->addButton(radioLevel1,1);
btnGroupScan->addButton(radioFileIndex,2);
btnGroupScan->addButton(radioAllFrames,3);
// Plot Axis // Plot Axis
myPlot->SetPlotTitle(defaultPlotTitle); myPlot->SetPlotTitle(defaultPlotTitle);
@ -129,10 +149,10 @@ void qTabPlot::Select1DPlot(bool b){
chkZAxis->setEnabled(false); chkZAxis->setEnabled(false);
chkZMin->setEnabled(false); chkZMin->setEnabled(false);
chkZMax->setEnabled(false); chkZMax->setEnabled(false);
myPlot->SetHistXAxisTitle(defaultHistXAxisTitle);
dispXAxis->setText(defaultHistXAxisTitle); dispXAxis->setText(defaultHistXAxisTitle);
myPlot->SetHistYAxisTitle(defaultHistYAxisTitle);
dispYAxis->setText(defaultHistYAxisTitle); dispYAxis->setText(defaultHistYAxisTitle);
myPlot->SetHistXAxisTitle(defaultHistXAxisTitle);
myPlot->SetHistYAxisTitle(defaultHistYAxisTitle);
myPlot->Select1DPlot(); myPlot->Select1DPlot();
}else{ }else{
box1D->hide(); box1D->hide();
@ -140,22 +160,12 @@ void qTabPlot::Select1DPlot(bool b){
chkZAxis->setEnabled(true); chkZAxis->setEnabled(true);
chkZMin->setEnabled(true); chkZMin->setEnabled(true);
chkZMax->setEnabled(true); chkZMax->setEnabled(true);
dispXAxis->setText(defaultImageXAxisTitle);
//threshold scan dispYAxis->setText(defaultImageYAxisTitle);
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);
dispXAxis->setText(defaultImageXAxisTitle);
dispYAxis->setText(defaultImageYAxisTitle);
myPlot->SetImageYAxisTitle(defaultImageYAxisTitle);
}
myPlot->SetImageZAxisTitle(defaultImageZAxisTitle);
dispZAxis->setText(defaultImageZAxisTitle); dispZAxis->setText(defaultImageZAxisTitle);
myPlot->SetImageXAxisTitle(defaultImageXAxisTitle);
myPlot->SetImageYAxisTitle(defaultImageYAxisTitle);
myPlot->SetImageZAxisTitle(defaultImageZAxisTitle);
myPlot->Select2DPlot(); myPlot->Select2DPlot();
} }
@ -172,7 +182,7 @@ void qTabPlot::Initialization(){
connect(radioHistogram, SIGNAL(toggled(bool)),this, SLOT(SetPlot())); connect(radioHistogram, SIGNAL(toggled(bool)),this, SLOT(SetPlot()));
connect(radioDataGraph, SIGNAL(toggled(bool)),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(btnGroupScan, SIGNAL(buttonClicked(QAbstractButton *)),this, SLOT(SetScanArgument()));
// 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()));
@ -213,7 +223,8 @@ void qTabPlot::Initialization(){
connect(dispYMax, SIGNAL(returnPressed()), this, SLOT(SetAxesRange())); connect(dispYMax, SIGNAL(returnPressed()), this, SLOT(SetAxesRange()));
connect(dispZMin, SIGNAL(returnPressed()), this, SLOT(SetZRange())); connect(dispZMin, SIGNAL(returnPressed()), this, SLOT(SetZRange()));
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
@ -390,26 +401,16 @@ void qTabPlot::SetPlot(){
myPlot->EnablePlot(true); myPlot->EnablePlot(true);
//if enable is true, disable everything //if enable is true, disable everything
if(isOrginallyOneD) {box1D->show();box1D->setEnabled(true);} else box1D->hide(); if(isOrginallyOneD) {box1D->show();box1D->setEnabled(true);} else box1D->hide();
if(!isOrginallyOneD){box2D->show();box2D->setEnabled(true);} else box2D->hide(); if(!isOrginallyOneD){box2D->show();box2D->setEnabled(true);} else box2D->hide();
Select1DPlot(isOrginallyOneD); 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);
EnableScanBox();
}else{ }else{
cout << " - Histogram" << endl; cout << " - Histogram" << endl;
myPlot->EnablePlot(true); //select(2d) will set oneD to false, but originallyoneD will remember
Select1DPlot(false);
box1D->hide();
box2D->show();
box2D->setEnabled(true);
boxSnapshot->setEnabled(true);
boxSave->setEnabled(true);
boxFrequency->setEnabled(false);
boxPlotAxis->setEnabled(true);
boxScan->setEnabled(false);
myPlot->SetPlotTimer(250);
emit ThresholdScanSignal(0);
} }
} }
@ -452,7 +453,7 @@ void qTabPlot::SetFrequency(){
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 = (int)(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>"
"Condition to be satisfied:\n(Acquisition Period)*(nth Image) >= 250ms." "Condition to be satisfied:\n(Acquisition Period)*(nth Image) >= 250ms."
"<br><br>Nth image adjusted to minimum, " "<br><br>Nth image adjusted to minimum, "
@ -477,57 +478,87 @@ void qTabPlot::SetFrequency(){
void qTabPlot::EnableScanBox(int mode,int id){ void qTabPlot::EnableScanBox(int mode,int id){
#ifdef VERBOSE #ifdef VERYVERBOSE
cout << "Entering Enable Scan Box()" << endl; cout << "Entering Enable Scan Box() \t mode:" << mode << " \t id:" << id << endl;
#endif #endif
int mode0 = myDet->getScanMode(0);
int mode1 = myDet->getScanMode(1);
scanLevel[id]=mode; boxScan->setEnabled(mode0||mode1);
//both are disabled
if((!scanLevel[0])&&(!scanLevel[1])){ if(boxScan->isEnabled()){
boxScan->setEnabled(false); //make sure nth frame frequency plot is disabled
}//both are enabled EnablingNthFrameFunction(false);
else if((scanLevel[0])&&(scanLevel[1])){
//disable none and check the other //if level0 or 1, check argument to find which scan enabled last from actions tab
if(id) {radioLevel1->setEnabled(true);radioLevel1->setChecked(true);} if((btnGroupScan->checkedId()!=2)&&(btnGroupScan->checkedId()!=3)){
else {radioLevel0->setEnabled(true);radioLevel0->setChecked(true);} cout<<"mode:"<<mode<<" id:"<<id<<endl;
}//either 1 is enabled/disabled //if mode is not none(doesnt check them if called form refresh)
else{ if(mode>0){
if(!boxScan->isEnabled()) { if(!id) radioLevel0->setChecked(true);
boxScan->setEnabled(true); else radioLevel1->setChecked(true);
radioFileIndex->setEnabled(false);/**???*/ }
} }
//disable one and check the other
if(id) { radioLevel0->setEnabled(mode0);
radioLevel0->setEnabled(!mode); radioLevel1->setEnabled(mode1);
radioLevel0->setChecked(!mode); }else EnablingNthFrameFunction(enableNFrame);
radioLevel1->setEnabled(mode); }
radioLevel1->setChecked(mode);
}else{
radioLevel0->setEnabled(mode); //-------------------------------------------------------------------------------------------------------------------------------------------------
radioLevel0->setChecked(mode);
radioLevel1->setEnabled(!mode); void qTabPlot::EnablingNthFrameFunction(bool enable){
radioLevel1->setChecked(!mode); #ifdef VERYVERBOSE
cout << "Enabling Nth Frame : " << enable << endl;
#endif
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(comboFrequency->model());
QStandardItem* item = model->itemFromIndex(model->index(1, comboFrequency->modelColumn(), comboFrequency->rootModelIndex()));
//enabling/disabling is easy if it wasnt selected anyway
if(comboFrequency->currentIndex()!=1)
item->setEnabled(enable);
else{
//only when it was enabled before and now to disable is a problem
if(!enable){
spinTimeGap->setValue(myPlot->GetMinimumPlotTimer());
comboFrequency->setCurrentIndex(0);
item->setEnabled(false);
} }
} }
//check for threshold
if((scanLevel[0]==2)||(scanLevel[1]==2))
radioHistogram->setChecked(true);
else
radioDataGraph->setChecked(true);
/*
if(boxScan->isEnabled()){
myDet->setPlotType(i);
}*/
} }
//-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabPlot::SetScanArgument(){
switch(btnGroupScan->checkedId()){
//level0
case 0:
break;
//level1
case 1:
break;
//file index
case 2:
break;
//all frames
case 3:
break;
}
}
//------------------------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------------------------
void qTabPlot::Refresh(){ void qTabPlot::Refresh(){
SetFrequency(); SetFrequency();
EnableScanBox();
} }