From 4f1dfe8b87ec34874b12a76e3b8280541b3ce155 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Tue, 28 May 2013 06:45:56 +0000 Subject: [PATCH] 2d pedestal implemented git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@192 af1100a4-978c-4157-bff7-07162d2ba061 --- slsDetectorGui/forms/form_tab_plot.ui | 404 ++++++++++++++++++++------ slsDetectorGui/include/qTabPlot.h | 3 + slsDetectorGui/src/qDrawPlot.cpp | 50 +++- slsDetectorGui/src/qTabPlot.cpp | 30 +- 4 files changed, 400 insertions(+), 87 deletions(-) diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index f12d41bbb..dc515bac4 100644 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -81,7 +81,7 @@ - 2D Plot Options + 2D Plot Options 1 Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -89,88 +89,325 @@ false - + - 8 - 20 - 358 - 26 + 5 + 15 + 361 + 31 - - - - - - 0 - 0 - - - - Interpolate - - - - - - - - 0 - 0 - - - - Contour - - - - - - - - 0 - 0 - - - - Log Scale (Z) - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 33 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 33 - 20 - - - - - + + 0 + + + + + + 345 + 0 + 16 + 16 + + + + + 0 + 0 + + + + Qt::NoFocus + + + + + + + :/icons/images/rightArrow.png:/icons/images/rightArrow.png + + + + 16 + 16 + + + + true + + + + + + 5 + 5 + 341 + 26 + + + + + + + + 0 + 0 + + + + Interpolate + + + + + + + + 0 + 0 + + + + Contour + + + + + + + + 0 + 0 + + + + Log Scale (Z) + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 29 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 29 + 20 + + + + + + + + + + + + 345 + 0 + 16 + 16 + + + + + 0 + 0 + + + + Qt::NoFocus + + + + + + + :/icons/images/rightArrow.png:/icons/images/rightArrow.png + + + + 16 + 16 + + + + true + + + + + + 5 + 4 + 141 + 25 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + Qt::NoFocus + + + Reset Pedestal + + + + :/icons/images/erase.png:/icons/images/erase.png + + + + 16 + 16 + + + + + + + 200 + 4 + 141 + 25 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + Qt::NoFocus + + + Calculate Pedestal + + + + :/icons/images/calculate.png:/icons/images/calculate.png + + + + 16 + 16 + + + + @@ -201,7 +438,7 @@ - 2 + 0 @@ -756,6 +993,9 @@ + horizontalLayoutWidget + btnSave + gridLayoutWidget_5 @@ -1386,7 +1626,7 @@ 15 - 137 + 135 371 49 @@ -1804,6 +2044,8 @@ Interval between plots has 2 modes. A condition to be satisfied, in order to avo + gridLayoutWidget_4 + gridLayoutWidget_5 diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h index 6d822cf15..4ebfed61b 100644 --- a/slsDetectorGui/include/qTabPlot.h +++ b/slsDetectorGui/include/qTabPlot.h @@ -147,6 +147,9 @@ private slots: /** Change pages in 1D box*/ void Set1DPage(); + /** Change pages in 2D box*/ + void Set2DPage(); + signals: void DisableZoomSignal(bool); diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 91853366d..cba1bf8a8 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -892,7 +892,51 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){ lastImageArray[py*nPixelsX+px] = sqrt(pow(currentFrame+1,2)*pow(double(px)-nPixelsX/2,2)/pow(nPixelsX/2,2)/pow(number_of_exposures+1,2) + pow(double(py)-nPixelsY/2,2)/pow(nPixelsY/2,2))/sqrt(2); */ // copy data - memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double)); + /*memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double));*/ + + + + //normal data + if(resetPedestal){ + memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double)); + }else{ + //start adding frames to get to the pedestal value + if(pedestalCountvalues[px]; + memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double)); + } + //calculate the pedestal value + else if(pedestalCount==NUM_PEDESTAL_FRAMES){ + cout << "Pedestal Calculated" << endl; + for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++) + pedestalVals[px] = pedestalVals[px]/(double)NUM_PEDESTAL_FRAMES; + memcpy(lastImageArray,data->values,nPixelsX*nPixelsY*sizeof(double)); + } + //use this pedestal value henceforth + else{ + for(unsigned int px=0;px<(nPixelsX*nPixelsY);px++) + lastImageArray[px] = data->values[px] - (pedestalVals[px]); + } + pedestalCount++; + + } + + + + + + + + + + + + + + + + } pthread_mutex_unlock(&(last_image_complete_mutex)); } @@ -1578,9 +1622,9 @@ void qDrawPlot::CalculatePedestal(){ while(1){ if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ //create array - if(pedestalVals) delete [] pedestalVals; pedestalVals = new double[nPixelsX]; + if(pedestalVals) delete [] pedestalVals; pedestalVals = new double[nPixelsX*nPixelsY]; //reset all values - for(unsigned int px=0;pxsetCurrentIndex(0); - + stackedWidget_2->setCurrentIndex(0); if(myDet->getDetectorsType()!=slsDetectorDefs::GOTTHARD){ btnCalPedestal->setEnabled(false); btnResetPedestal->setEnabled(false); } + if(myDet->getDetectorsType()!=slsDetectorDefs::MOENCH){ + btnCalPedestal_2->setEnabled(false); + btnResetPedestal_2->setEnabled(false); + } qDefs::checkErrorMessage(myDet); } @@ -172,8 +176,24 @@ void qTabPlot::SetupWidgetWindow(){ //------------------------------------------------------------------------------------------------------------------------------------------------- +void qTabPlot::Set2DPage(){ + //QPushButton *clickedButton = qobject_cast(sender()); + if(stackedWidget_2->currentIndex()==0){ + stackedWidget_2->setCurrentIndex(1); + box2D->setTitle("2D Plot Options 2"); + } + else{ + stackedWidget_2->setCurrentIndex(0); + box2D->setTitle("2D Plot Options 1"); + } +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + void qTabPlot::Set1DPage(){ - QPushButton *clickedButton = qobject_cast(sender()); + //QPushButton *clickedButton = qobject_cast(sender()); if(stackedWidget->currentIndex()==0){ //if(clickedButton->icon().pixmap(QSize(16,16)).toImage()==btnLeft->icon().pixmap(QSize(16,16)).toImage()) stackedWidget->setCurrentIndex(1); @@ -240,6 +260,9 @@ 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))); + //to change pages + connect(btn2DRight, SIGNAL(clicked()), this, SLOT(Set2DPage())); + connect(btn2DRight2, SIGNAL(clicked()), this, SLOT(Set2DPage())); // Plotting frequency box connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency())); @@ -278,7 +301,8 @@ void qTabPlot::Initialization(){ //pedstal connect(btnResetPedestal, SIGNAL(clicked()),myPlot, SLOT(ResetPedestal())); connect(btnCalPedestal, SIGNAL(clicked()),myPlot, SLOT(CalculatePedestal())); - + connect(btnResetPedestal_2, SIGNAL(clicked()),myPlot, SLOT(ResetPedestal())); + connect(btnCalPedestal_2, SIGNAL(clicked()),myPlot, SLOT(CalculatePedestal())); }