From a79c5c61838f71ca58818f9c914b8ac008a3ba35 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Tue, 25 Sep 2012 07:22:04 +0000 Subject: [PATCH] fixed advanced tab, optimize settings, threshold and exposure time enabling, histogram plotting crashing git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@68 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/forms/form_tab_advanced.ui | 10 +-- slsDetectorGui/include/qDefs.h | 2 +- slsDetectorGui/include/qDrawPlot.h | 4 + slsDetectorGui/src/qDrawPlot.cpp | 90 ++++++++++++----------- slsDetectorGui/src/qTabAdvanced.cpp | 24 +++--- slsDetectorGui/src/qTabSettings.cpp | 4 +- 6 files changed, 70 insertions(+), 64 deletions(-) diff --git a/slsDetectorGui/forms/form_tab_advanced.ui b/slsDetectorGui/forms/form_tab_advanced.ui index 374ac2249..26b6b7045 100644 --- a/slsDetectorGui/forms/form_tab_advanced.ui +++ b/slsDetectorGui/forms/form_tab_advanced.ui @@ -60,7 +60,7 @@ true - false + true @@ -120,7 +120,7 @@ - false + true @@ -167,7 +167,7 @@ - false + true @@ -339,7 +339,7 @@ An extension given by the modules serial number will be attached. - false + true @@ -402,7 +402,7 @@ An extension given by the modules serial number will be attached. - false + true diff --git a/slsDetectorGui/include/qDefs.h b/slsDetectorGui/include/qDefs.h index a117438ac..b87f47158 100644 --- a/slsDetectorGui/include/qDefs.h +++ b/slsDetectorGui/include/qDefs.h @@ -21,7 +21,7 @@ public: qDefs(){}; //------------------------------------------------------------------------------------------------------------------------------------------------- -#define GUI_VERSION 0.1 +#define GUI_VERSION 0.11 //------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index 6b9ba3a72..6ea6d18d8 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -369,6 +369,10 @@ double* histYAxis[MAX_1DPLOTS]; double* histXAngleAxis; /** Y Axis for angles in 1D (no persistency) */ double* histYAngleAxis; +/** X Axis for trimbits in 1D */ +double* histTrimbits; + + /** Current Image Values in 2D */ double* lastImageArray; diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 3e93a902a..4332132b0 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -82,7 +82,7 @@ void qDrawPlot::SetupWidgetWindow(){ histNBins = 0; histXAxis = 0; histXAngleAxis = 0; - histYAngleAxis = 0; + histYAngleAxis = 0;histTrimbits=0; persistency = 0; currentPersistency = 0; @@ -1190,90 +1190,98 @@ void qDrawPlot::DisableZoom(bool disable){ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){ int ret,i,actualPixelsX; - double *temp; + //double *temp=0,*trimXAxis=0,*trimYAxis=0; #ifdef VERBOSE - if(fromDetector) cout << "Geting Trimbits from Detector: "; - else cout << "Getting Trimbits from Shared Memory: "; - if(Histogram) cout << "Histogram" << endl; - else cout << "Data Graph" << endl; + if(fromDetector) cout << "Geting Trimbits from Detector" << endl; + else cout << "Getting Trimbits from Shared Memory" << endl; #endif + slsDetectorDefs::detectorType detType = myDet->getDetectorsType(); + if(detType == slsDetectorDefs::MYTHEN){ - switch(myDet->getDetectorsType()){ - - - case slsDetectorDefs::MYTHEN: //get trimbits actualPixelsX = myDet->getTotalNumberOfChannels(); - temp = new double[actualPixelsX]; - ret = myDet->getChanRegs(temp,fromDetector); + if(histTrimbits) delete [] histTrimbits; histTrimbits = new double[actualPixelsX]; + ret = myDet->getChanRegs(histTrimbits,fromDetector); if(!ret){ qDefs::Message(qDefs::WARNING,"No Trimbit data found in shared memory.","Dock"); return qDefs::FAIL; } - +#ifdef VERBOSE + cout << "Got Trimbits" << endl; +#endif //defining axes - if(Histogram) nPixelsX = TRIM_HISTOGRAM_XMAX; + if(Histogram) nPixelsX = TRIM_HISTOGRAM_XMAX+1; else nPixelsX = actualPixelsX; - if(histXAxis) delete [] histXAxis; histXAxis = new double [nPixelsX]; - if(histYAxis[0]) delete [] histYAxis[0];histYAxis[0] = new double [nPixelsX]; + + if(histXAxis) delete [] histXAxis; histXAxis = new double [nPixelsX]; + if(histYAxis[0]) delete [] histYAxis[0]; histYAxis[0]= new double [nPixelsX]; //initializing - for(unsigned int px=0;pxsetTitle("Trimbits Plot - Data Graph"); plot1D->SetXTitle("Channel Number"); plot1D->SetYTitle("Trimbits"); //set plot parameters SlsQtH1D* h; - plot1D_hists.append(h=new SlsQtH1D("1d plot",nPixelsX,histXAxis,GetHistYAxis(0))); + plot1D_hists.append(h=new SlsQtH1D("1d plot",nPixelsX,histXAxis,histYAxis[0])); h->SetLineColor(1); h->setTitle(GetHistTitle(0)); //attach plot h->Attach(plot1D); - }else{ - //data - for(i=0;i=0)){ + value = (int) histTrimbits[i]; + histYAxis[0][value]++; + } + else cout<<"OUT OF BOUNDS:"<0)) cout<<"HIsty["<setTitle("Trimbits Plot - Histogram"); plot1D->SetXTitle("Trimbits"); plot1D->SetYTitle("Frequency"); //set plot parameters SlsQtH1D* h; - plot1D_hists.append(h=new SlsQtH1D("1d plot",nPixelsX,histXAxis,GetHistYAxis(0))); + plot1D_hists.append(h=new SlsQtH1D("1d plot",nPixelsX,histXAxis,histYAxis[0])); h->SetLineColor(1); h->setTitle(GetHistTitle(0)); //attach plot h->Attach(plot1D); - } + + + #ifdef VERBOSE cout << "Trimbits Plot updated" << endl; #endif - break; + } + else if(detType == slsDetectorDefs::EIGER){ - //2d - case slsDetectorDefs::EIGER: //defining axes nPixelsX = 100;/**??*/ nPixelsY = 100; @@ -1299,16 +1307,10 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){ #ifdef VERBOSE cout << "Trimbits Plot updated" << endl; #endif - break; - - - - - - //shouldnt be here - default: - break; } + + + return qDefs::OK; } diff --git a/slsDetectorGui/src/qTabAdvanced.cpp b/slsDetectorGui/src/qTabAdvanced.cpp index defb1032b..05da30fe2 100644 --- a/slsDetectorGui/src/qTabAdvanced.cpp +++ b/slsDetectorGui/src/qTabAdvanced.cpp @@ -353,17 +353,17 @@ void qTabAdvanced::StartTrimming(){ //execute int ret = myDet->executeTrimming(trimmingMode,parameter1,parameter2,-1); + if((ret!=slsDetectorDefs::FAIL)&&(ret!=-1)); + else + qDefs::Message(qDefs::WARNING,"Atleast 1 channel could not be trimmed.","Advanced"); + //save trim file + ret = myDet->saveSettingsFile(string(dispFile->text().toAscii().constData()),-1); if((ret!=slsDetectorDefs::FAIL)&&(ret!=-1)){ - //save trim file - ret = myDet->saveSettingsFile(string(dispFile->text().toAscii().constData()),-1); - if((ret!=slsDetectorDefs::FAIL)&&(ret!=-1)) - qDefs::Message(qDefs::INFORMATION,"The Trimbits have been saved successfully.","Advanced"); - else qDefs::Message(qDefs::WARNING,string("Could not Save the Trimbits to file:\n")+dispFile->text().toAscii().constData(),"Advanced"); + qDefs::Message(qDefs::INFORMATION,"The Trimbits have been saved successfully.","Advanced"); //updates plots myPlot->UpdateTrimbitPlot(false,radioHistogram->isChecked()); } - else - qDefs::Message(qDefs::WARNING,"Atleast 1 channel could not be trimmed.","Advanced"); + else qDefs::Message(qDefs::WARNING,string("Could not Save the Trimbits to file:\n")+dispFile->text().toAscii().constData(),"Advanced"); } @@ -371,10 +371,12 @@ void qTabAdvanced::StartTrimming(){ void qTabAdvanced::UpdateTrimbitPlot(int id){ - //refresh - if(!id) myPlot->UpdateTrimbitPlot(false,radioHistogram->isChecked()); - //from detector - else myPlot->UpdateTrimbitPlot(true,radioHistogram->isChecked()); + if(boxPlot->isChecked()){ + //refresh + if(!id) myPlot->UpdateTrimbitPlot(false,radioHistogram->isChecked()); + //from detector + else myPlot->UpdateTrimbitPlot(true,radioHistogram->isChecked()); + } } diff --git a/slsDetectorGui/src/qTabSettings.cpp b/slsDetectorGui/src/qTabSettings.cpp index 068811924..b68652894 100644 --- a/slsDetectorGui/src/qTabSettings.cpp +++ b/slsDetectorGui/src/qTabSettings.cpp @@ -70,7 +70,6 @@ void qTabSettings::SetupWidgetWindow(){ void qTabSettings::SetupDetectorSettings(){ // Get detector settings from detector slsDetectorDefs::detectorSettings sett = myDet->getSettings(); - // To be able to index items on a combo box model = qobject_cast(comboSettings->model()); if (model) { @@ -268,10 +267,9 @@ void qTabSettings::Refresh(){ #ifdef VERBOSE cout << "Getting settings" << endl; #endif - SetupDetectorSettings(); //changin the combo settings also plots the trimbits for mythen and eiger, so disconnect disconnect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int))); - comboSettings->setCurrentIndex(myDet->getSettings()); + SetupDetectorSettings();//comboSettings->setCurrentIndex(myDet->getSettings()); connect(comboSettings, SIGNAL(currentIndexChanged(int)), this, SLOT(setSettings(int)));