From 3c92f26be7fabd1be8ebd73999118008b12f1a65 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Fri, 16 Aug 2013 12:59:48 +0000 Subject: [PATCH] fixed some probelems wuth scans for receiver and also scans for allframes/frameindex git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@227 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/forms/form_tab_plot.ui | 14 +- slsDetectorGui/include/svnInfoGui.h | 6 +- slsDetectorGui/src/qDrawPlot.cpp | 53 ++++--- slsDetectorGui/src/qTabPlot.cpp | 190 +++++++++++++++++++++----- 4 files changed, 204 insertions(+), 59 deletions(-) diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index a1a2bb915..05e5c1283 100644 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -1319,7 +1319,7 @@ Displays minimum, maximum and sum of values for each plot. true - true + false @@ -1342,6 +1342,9 @@ Displays minimum, maximum and sum of values for each plot. 0 + + <nobr>Enabled only when there is a Scan Level 0</nobr> + Level 0 @@ -1374,6 +1377,9 @@ Displays minimum, maximum and sum of values for each plot. 0 + + <nobr>Enabled only when there is a Scan Level 1</nobr> + Level 1 @@ -1403,6 +1409,9 @@ Displays minimum, maximum and sum of values for each plot. 0 + + <nobr>Enabled only when there is a Scan Level 0 or a Scan Level 1, not both</nobr> + Frame Index @@ -1432,6 +1441,9 @@ Displays minimum, maximum and sum of values for each plot. 0 + + <nobr>Disabled only for Angle Plots, Moench and Eiger Detectors</nobr> + All Frames diff --git a/slsDetectorGui/include/svnInfoGui.h b/slsDetectorGui/include/svnInfoGui.h index ee3ea724c..906073b92 100644 --- a/slsDetectorGui/include/svnInfoGui.h +++ b/slsDetectorGui/include/svnInfoGui.h @@ -2,10 +2,10 @@ #define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui" //#define SVNREPPATH "" #define SVNREPUUID "af1100a4-978c-4157-bff7-07162d2ba061" -//#define SVNREV 0x225 +//#define SVNREV 0x226 //#define SVNKIND "" //#define SVNSCHED "" #define SVNAUTH "l_maliakal_d" -#define SVNREV 0x225 -#define SVNDATE 0x20130812 +#define SVNREV 0x226 +#define SVNDATE 0x20130813 // diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index b2bba5916..38de07cb1 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -339,34 +339,30 @@ void qDrawPlot::Initialization(){ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){ -//#ifdef VERYVERBOSE +#ifdef VERYVERBOSE cout << "Entering StartStopDaqToggle(" << stop_if_running << ")" <setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); int numTriggers = (isTriggerEnabled)*((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); numFrames = ((numFrames==0)?1:numFrames); numTriggers = ((numTriggers==0)?1:numTriggers); - number_of_frames = numFrames * numTriggers; cout << "\tNumber of Frames per Scan/Measurement:" << number_of_frames << endl; - //get #scansets for level 0 and level 1 int numScan0 = myDet->getScanSteps(0); numScan0 = ((numScan0==0)?1:numScan0); int numScan1 = myDet->getScanSteps(1); numScan1 = ((numScan1==0)?1:numScan1); @@ -374,9 +370,8 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){ number_of_exposures = number_of_frames * numScan0 * numScan1; if(anglePlot) number_of_exposures = numScan0 * numScan1;// * numPos; - - cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures << endl; + */ // ExposureTime exposureTime= ((double)(myDet->setTimer(slsDetectorDefs::ACQUISITION_TIME,-1))*1E-9); @@ -384,9 +379,7 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){ // Acquisition Period acquisitionPeriod= ((double)(myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1))*1E-9); cout << "\tAcquisition Period:" << setprecision (10) << acquisitionPeriod << endl; - cout << "\tFile Index:" << myDet->getFileIndex() << endl; - //to take the first data if frameFactor numFactor = 0; @@ -402,8 +395,6 @@ void qDrawPlot::StartStopDaqToggle(bool stop_if_running){ currentFileIndex = myDet->getFileIndex(); currentFrameIndex = 0; - - StartDaq(true); running=!running; @@ -502,15 +493,32 @@ void qDrawPlot::SetScanArgument(int scanArg){ #endif scanArgument = scanArg; + LockLastImageArray(); + if(plot_in_scope==1) Clear1DPlot(); - LockLastImageArray(); - - + maxPixelsY = 0; + minPixelsY = 0; nPixelsX = myDet->getTotalNumberOfChannels(slsDetectorDefs::X); nPixelsY = myDet->getTotalNumberOfChannels(slsDetectorDefs::Y); + // Number of Exposures - must be calculated here to get npixelsy for allframes/frameindex scans + int numFrames = (isFrameEnabled)*((int)myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1)); + int numTriggers = (isTriggerEnabled)*((int)myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1)); + numFrames = ((numFrames==0)?1:numFrames); + numTriggers = ((numTriggers==0)?1:numTriggers); + number_of_frames = numFrames * numTriggers; + cout << "\tNumber of Frames per Scan/Measurement:" << number_of_frames << endl; + //get #scansets for level 0 and level 1 + int numScan0 = myDet->getScanSteps(0); numScan0 = ((numScan0==0)?1:numScan0); + int numScan1 = myDet->getScanSteps(1); numScan1 = ((numScan1==0)?1:numScan1); + int numPos=myDet->getPositions(); + + number_of_exposures = number_of_frames * numScan0 * numScan1; + if(anglePlot) number_of_exposures = numScan0 * numScan1;// * numPos; + cout << "\tNumber of Exposures Per Measurement:" << number_of_exposures << endl; + //cannot do this in between measurements , so update instantly if(scanArgument==qDefs::Level0){ //no need to check if numsteps=0,cuz otherwise this mode wont be set in plot tab @@ -530,7 +538,11 @@ void qDrawPlot::SetScanArgument(int scanArg){ maxPixelsY = values[numSteps-1]; minPixelsY = values[0]; nPixelsY = numSteps; - } + }else if(scanArgument==qDefs::AllFrames) + nPixelsY = number_of_exposures; + else if(scanArgument==qDefs::FileIndex) + nPixelsY = number_of_frames; + if(minPixelsY>maxPixelsY){ double temp = minPixelsY; @@ -609,7 +621,7 @@ void qDrawPlot::SetupMeasurement(){ maxPixelsY = number_of_exposures - 1; minPixelsY = 0; if(!running) nPixelsY = number_of_exposures; - }//file index + }//frame index else if(scanArgument==qDefs::FileIndex){ maxPixelsY = number_of_frames - 1; minPixelsY = 0; @@ -671,6 +683,7 @@ int qDrawPlot::GetDataCallBack(detectorData *data, int fIndex, void *this_pointe int qDrawPlot::GetData(detectorData *data,int fIndex){ #ifdef VERYVERBOSE cout << "******Entering GetDatafunction********" << endl; + cout << "fIndex " << fIndex << endl; cout << "fname " << data->fileName << endl; cout << "npoints " << data->npoints << endl; cout << "npy " << data->npy << endl; @@ -812,6 +825,8 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){ lastImageNumber= currentFrame+1; //title imageTitle = temp_title; + cout<<"lastImageNumber:"<values[px]; pthread_mutex_unlock(&(last_image_complete_mutex)); @@ -1158,7 +1173,7 @@ void qDrawPlot::UpdatePlot(){ if(plot_in_scope==1){ if(lastImageNumber){ #ifdef VERYVERBOSE - cout << "Last Image Number:" << lastImageNumber << endl; + cout << "*Last Image Number:" << lastImageNumber << endl; #endif if(histNBins){ Clear1DPlot(); diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index 2a67b666c..baafa370b 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -174,8 +174,6 @@ void qTabPlot::SetupWidgetWindow(){ } Select1DPlot(isOriginallyOneD); - if(isOriginallyOneD) myPlot->Select1DPlot(); - else myPlot->Select2DPlot(); //to check if this should be enabled EnableScanBox(); @@ -248,12 +246,14 @@ void qTabPlot::Select1DPlot(bool b){ chkZAxis->setEnabled(false); chkZMin->setEnabled(false); chkZMax->setEnabled(false); + myPlot->Select1DPlot(); }else{ box1D->hide(); box2D->show(); chkZAxis->setEnabled(true); chkZMin->setEnabled(true); chkZMax->setEnabled(true); + myPlot->Select2DPlot(); } } @@ -267,7 +267,6 @@ void qTabPlot::Initialization(){ connect(radioHistogram, SIGNAL(toggled(bool)),this, SLOT(SetPlot())); connect(radioDataGraph, SIGNAL(toggled(bool)),this, SLOT(SetPlot())); // Scan box - /*connect(btnGroupScan, SIGNAL(buttonClicked(QAbstractButton *)),this, SLOT(SetScanArgument()));*/ connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); // Snapshot box connect(btnClone, SIGNAL(clicked()),myPlot, SLOT(ClonePlot())); @@ -507,36 +506,27 @@ void qTabPlot::SetPlot(){ if(radioNoPlot->isChecked()){ cout << " - No Plot" << endl; - //Select1DPlot(isOriginallyOneD); - //if(isOriginallyOneD) {box1D->show(); box2D->hide();} - //if(!isOriginallyOneD){box2D->show(); box1D->hide();} myPlot->EnablePlot(false); - //if enable is true, disable everything - boxSnapshot->setEnabled(false); boxSave->setEnabled(false); boxFrequency->setEnabled(false); boxPlotAxis->setEnabled(false); boxScan->setEnabled(false); - }else {//if(radioDataGraph->isChecked()){ - cout << " - DataGraph" << endl; + }else { + if(radioDataGraph->isChecked()) + cout << " - DataGraph" << endl; + else + cout << " - Histogram" << endl; myPlot->EnablePlot(true); - //if enable is true, disable everything - if(isOriginallyOneD) {box1D->show(); box2D->hide();} - if(!isOriginallyOneD) {box2D->show(); box1D->hide();} Select1DPlot(isOriginallyOneD); - if(isOriginallyOneD) myPlot->Select1DPlot(); - else myPlot->Select2DPlot(); boxSnapshot->setEnabled(true); boxSave->setEnabled(true); boxFrequency->setEnabled(true); boxPlotAxis->setEnabled(true); - if(!myPlot->isRunning()) EnableScanBox(); - }/*else{ - cout << " - Histogram" << endl; - //select(2d) will set oneD to false, but originallyoneD will remember - }*/ + if(!myPlot->isRunning()) + EnableScanBox(); + } } @@ -683,10 +673,98 @@ void qTabPlot::SetFrequency(){ //------------------------------------------------------------------------------------------------------------------------------------------------- void qTabPlot::EnableScanBox(){ -#ifdef VERYVERBOSE +#ifdef VERBOSE cout << "Entering Enable Scan Box()" << endl; #endif + disconnect(radioNoPlot, SIGNAL(toggled(bool)),this, SLOT(SetPlot())); + disconnect(radioHistogram, SIGNAL(toggled(bool)),this, SLOT(SetPlot())); + disconnect(radioDataGraph, SIGNAL(toggled(bool)),this, SLOT(SetPlot())); + disconnect(boxScan, SIGNAL(toggled(bool)),this, SLOT(EnableScanBox())); + int mode0 = myDet->getScanMode(0); + int mode1 = myDet->getScanMode(1); + int ang; + bool angConvert = myDet->getAngularConversion(ang); + + //enabling it after it was plotted + radioDataGraph->setEnabled(true); + + + //if angle plot or originally 2d, uncheck and disable scanbox + if ((angConvert) || (!isOriginallyOneD)){ + boxScan->setChecked(false); + boxScan->setEnabled(false); + //disable histogram + radioHistogram->setEnabled(false); + if(radioHistogram->isChecked()) + radioDataGraph->setChecked(true); + //angle only + if((angConvert)&&(chkSuperimpose->isChecked())) + chkSuperimpose->setChecked(false); + chkSuperimpose->setEnabled(!angConvert); + myPlot->EnableAnglePlot(angConvert); + if(angConvert) + boxScan->setToolTip("Only 1D Plots enabled for Angle Plots"); + } + + //originally1d && not angle plot + else{ + boxScan->setToolTip(""); + boxScan->setEnabled(true); + if(mode0 || mode1) + boxScan->setChecked(true); + + //still 1d + if(!boxScan->isChecked()){ + radioHistogram->setEnabled(true); + /*if(radioHistogram->isChecked()) + EnablingNthFrameFunction(false);//just this + else EnablingNthFrameFunction(true); */ + } + + //2d enabled with boxscan + else{ + disconnect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + disconnect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + + comboFrequency->setCurrentIndex(1); + spinNthFrame->setValue(1); + SetFrequency(); + + //disable histogram for 2d + radioHistogram->setEnabled(false); + if(radioHistogram->isChecked()) + radioDataGraph->setChecked(true); + + /*//make sure nth frame frequency plot is disabled + EnablingNthFrameFunction(false); + */ + //enabling options + radioFileIndex->setEnabled(mode0||mode1); + if(mode0 && mode1){ + radioLevel0->setEnabled(false); + radioLevel1->setEnabled(false); + }else{ + radioLevel0->setEnabled(mode0); + radioLevel1->setEnabled(mode1); + } + //default is allframes if checked button is disabled + if(!btnGroupScan->checkedButton()->isEnabled()) + radioAllFrames->setChecked(true); + + connect(spinNthFrame, SIGNAL(editingFinished()), this, SLOT(SetFrequency())); + connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); + + + } + } + + connect(radioNoPlot, SIGNAL(toggled(bool)),this, SLOT(SetPlot())); + connect(radioHistogram, SIGNAL(toggled(bool)),this, SLOT(SetPlot())); + connect(radioDataGraph, SIGNAL(toggled(bool)),this, SLOT(SetPlot())); + connect(boxScan, SIGNAL(toggled(bool)),this, SLOT(EnableScanBox())); + +/* int mode0 = myDet->getScanMode(0); int mode1 = myDet->getScanMode(1); @@ -759,9 +837,7 @@ void qTabPlot::EnableScanBox(){ //boxFrequency->setEnabled(positionsExist); myPlot->EnableAnglePlot(positionsExist); - - //sets the scan argument - /*SetScanArgument();*/ +*/ } @@ -791,41 +867,85 @@ void qTabPlot::EnablingNthFrameFunction(bool enable){ //------------------------------------------------------------------------------------------------------------------------------------------------- void qTabPlot::SetScanArgument(){ - bool histogram = radioHistogram->isChecked(); +#ifdef VERYVERBOSE + cout << "Entering qTabPlot::SetScanArgument()" << endl; +#endif - //as default from histogram and default titles are set here if scanbox is disabled + //1d if(isOriginallyOneD){ dispXAxis->setText(defaultHistXAxisTitle); dispYAxis->setText(defaultHistYAxisTitle); myPlot->SetHistXAxisTitle(defaultHistXAxisTitle); myPlot->SetHistYAxisTitle(defaultHistYAxisTitle); - }else{ + Select1DPlot(true); + } + //2d + else{ dispXAxis->setText(defaultImageXAxisTitle); dispYAxis->setText(defaultImageYAxisTitle); dispZAxis->setText(defaultImageZAxisTitle); myPlot->SetImageXAxisTitle(defaultImageXAxisTitle); myPlot->SetImageYAxisTitle(defaultImageYAxisTitle); myPlot->SetImageZAxisTitle(defaultImageZAxisTitle); + Select1DPlot(false); } - Select1DPlot(isOriginallyOneD); - if(isOriginallyOneD) myPlot->Select1DPlot(); - else myPlot->Select2DPlot(); + + //angles (1D) + int ang; + if(myDet->getAngularConversion(ang)){ + dispXAxis->setText("Angles"); + myPlot->SetHistXAxisTitle("Angles"); + Select1DPlot(true); + } + + /* bool histogram = radioHistogram->isChecked(); + * else if(histogram)*/ + + //1d with scan + if(boxScan->isChecked()){ + + myPlot->SetScanArgument(btnGroupScan->checkedId()+1); + + switch(btnGroupScan->checkedId()){ + case 0://level0 + dispYAxis->setText("Scan Level 0"); + myPlot->SetImageYAxisTitle("Scan Level 0"); + break; + case 1://level1 + dispYAxis->setText("Scan Level 1"); + myPlot->SetImageYAxisTitle("Scan Level 1"); + break; + break; + case 2://file index + dispYAxis->setText("Frame Index"); + myPlot->SetImageYAxisTitle("Frame Index"); + break; + case 3://all frames + dispYAxis->setText("All Frames"); + myPlot->SetImageYAxisTitle("All Frames"); + break; + } + Select1DPlot(false); + }else + myPlot->SetScanArgument(qDefs::None); + + /* + Select1DPlot(isOriginallyOneD); + int ang; //if scans(1D or 2D) if((boxScan->isEnabled())||(histogram)){ //setting the title according to the scans Select1DPlot(isOriginallyOneD); - if(isOriginallyOneD) myPlot->Select1DPlot(); - else myPlot->Select2DPlot(); + }//angles (1D) else if(myDet->getAngularConversion(ang)){ dispXAxis->setText("Angles"); myPlot->SetHistXAxisTitle("Angles"); Select1DPlot(true); - myPlot->Select1DPlot(); } @@ -844,7 +964,6 @@ void qTabPlot::SetScanArgument(){ //set plot to 2d Select1DPlot(false); - myPlot->Select2DPlot(); } //2d else if((boxScan->isEnabled())&&(boxScan->isChecked())){ @@ -881,11 +1000,10 @@ void qTabPlot::SetScanArgument(){ //set plot to 2d Select1DPlot(false); - myPlot->Select2DPlot(); }else //done here so that it isnt set by default each time myPlot->SetScanArgument(qDefs::None); - +*/ qDefs::checkErrorMessage(myDet,"qTabPlot::SetScanArgument"); }