diff --git a/slsDetectorGui/forms/form_tab_measurement.ui b/slsDetectorGui/forms/form_tab_measurement.ui index f7e9c07cf..98a81f770 100644 --- a/slsDetectorGui/forms/form_tab_measurement.ui +++ b/slsDetectorGui/forms/form_tab_measurement.ui @@ -162,7 +162,7 @@ :/icons/images/start.png:/icons/images/start.png - Space + Shift+Space true diff --git a/slsDetectorGui/forms/form_tab_plot.ui b/slsDetectorGui/forms/form_tab_plot.ui index f0d754300..72063f919 100644 --- a/slsDetectorGui/forms/form_tab_plot.ui +++ b/slsDetectorGui/forms/form_tab_plot.ui @@ -183,7 +183,7 @@ - 1D Plot Options + 1D Plot Options 1 Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -201,7 +201,7 @@ - 0 + 2 @@ -407,7 +407,7 @@ - + 345 @@ -430,7 +430,194 @@ - :/icons/images/leftArrow.png:/icons/images/leftArrow.png + :/icons/images/rightArrow.png:/icons/images/rightArrow.png + + + + 16 + 16 + + + + true + + + + + + + + 5 + 5 + 141 + 25 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + Qt::NoFocus + + + Reset Pedestal + + + + :/icons/images/remove.png:/icons/images/remove.png + + + + 16 + 16 + + + + + + + 200 + 5 + 141 + 25 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + + 20 + 20 + 20 + + + + + + + + Qt::NoFocus + + + Calculate Pedestal + + + + :/icons/images/add.png:/icons/images/add.png + + + + 16 + 16 + + + + + + + 345 + 0 + 16 + 16 + + + + + 0 + 0 + + + + Qt::NoFocus + + + + + + + :/icons/images/rightArrow.png:/icons/images/rightArrow.png @@ -593,7 +780,7 @@ 10 20 - 341 + 348 26 diff --git a/slsDetectorGui/include/qCloneWidget.h b/slsDetectorGui/include/qCloneWidget.h index 507f06887..081d5e682 100644 --- a/slsDetectorGui/include/qCloneWidget.h +++ b/slsDetectorGui/include/qCloneWidget.h @@ -126,6 +126,8 @@ private: QCheckBox *chkAutoFName; QCheckBox *chkSaveAll; + QLabel *lblHistTitle; + /** Gets the current time stamp for the window title*/ char* GetCurrentTimeStamp(); diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index 0ab31038d..a6a225cdc 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -149,8 +149,11 @@ void SetScanArgument(int scanArg); /** sets stop_signal to true */ void StopAcquisition(){ stop_signal = true; }; - - +//pedestal +/** reset pedestal */ +void ResetPedestal(); +/** Calculate Pedestal */ +void CalculatePedestal(); @@ -304,6 +307,10 @@ SlsQt2DPlotLayout* plot2D; QVector plot1D_hists; +/**label with frame index for those with many frames per file*/ +QLabel *histFrameIndexTitle; + + /** Current Measurement */ int currentMeasurement; /** currentFrame */ @@ -464,6 +471,17 @@ bool backwardScanPlot; bool fileSaveEnable; +//pedstal +/** Number of pedestal frames*/ +static const int NUM_PEDESTAL_FRAMES = 20; +/**reset pedestal*/ +bool resetPedestal; +/** pedestal values */ +double* pedestalVals; +/** count for 20 frames to calculate the pedestal */ +int pedestalCount; + + signals: void UpdatingPlotFinished(); void InterpolateSignal(bool); diff --git a/slsDetectorGui/include/qTabDebugging.h b/slsDetectorGui/include/qTabDebugging.h index 480833354..875b37e0f 100644 --- a/slsDetectorGui/include/qTabDebugging.h +++ b/slsDetectorGui/include/qTabDebugging.h @@ -13,10 +13,11 @@ /** Project Class Headers */ class multiSlsDetector; class slsDetector; +#include "sls_detector_defs.h" /** Qt Include Headers */ #include -/** C++ Include Headers */ -#include "sls_detector_defs.h" + + /** *@short sets up the Debugging parameters diff --git a/slsDetectorGui/include/qTabPlot.h b/slsDetectorGui/include/qTabPlot.h index a07cdad35..2e18513e6 100644 --- a/slsDetectorGui/include/qTabPlot.h +++ b/slsDetectorGui/include/qTabPlot.h @@ -12,6 +12,7 @@ #include "ui_form_tab_plot.h" /** Project Class Headers */ class multiSlsDetector; +#include "sls_detector_defs.h" /** Qt Project Class Headers */ class qDrawPlot; /** Qt Include Headers */ @@ -54,6 +55,7 @@ private: /** The Plot widget */ qDrawPlot *myPlot; + /** 1d/2d plot */ bool isOneD; bool isOriginallyOneD; diff --git a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx index 8f0f01147..6fbcfefc6 100644 --- a/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx +++ b/slsDetectorGui/slsDetectorPlotting/src/SlsQt1DPlot.cxx @@ -276,7 +276,7 @@ SlsQt1DPlot::SlsQt1DPlot(QWidget *parent):QwtPlot(parent){ SetupZoom(); // Assign a title - insertLegend(new QwtLegend(), QwtPlot::RightLegend); + insertLegend(new QwtLegend(), QwtPlot::RightLegend); axisScaleEngine(QwtPlot::yLeft)->setAttribute(QwtScaleEngine::Floating); axisScaleEngine(QwtPlot::xBottom)->setAttribute(QwtScaleEngine::Floating); diff --git a/slsDetectorGui/src/qCloneWidget.cpp b/slsDetectorGui/src/qCloneWidget.cpp index afe3905a8..bf99a2032 100644 --- a/slsDetectorGui/src/qCloneWidget.cpp +++ b/slsDetectorGui/src/qCloneWidget.cpp @@ -71,6 +71,8 @@ void qCloneWidget::SetupWidgetWindow(QString title,int numDim,SlsQt1DPlot*& plot gridClone->addWidget(cloneplot1D,0,0); cloneBox->setFlat(false); cloneBox->setContentsMargins(0,30,0,0); + lblHistTitle = new QLabel(""); + mainLayout->addWidget(lblHistTitle,0,0); }else{ cloneplot2D = plot2D; @@ -128,7 +130,8 @@ void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,doub #endif } //set title and attach plot - k->setTitle(histTitle[hist_num].c_str()); + lblHistTitle->setText(QString(histTitle[0].c_str())); + //k->setTitle(histTitle[hist_num].c_str()); k->Attach(cloneplot1D); } //cloneplot1D->UnZoom(); @@ -171,7 +174,8 @@ void qCloneWidget::SetCloneHists(int nHists,int histNBins,double* histXAxis,doub #endif } //set title and attach plot - k->setTitle(histTitle[hist_num].c_str()); + lblHistTitle->setText(QString(histTitle[0].c_str())); + //k->setTitle(histTitle[hist_num].c_str()); k->Attach(cloneplot1D); } //cloneplot1D->UnZoom(); diff --git a/slsDetectorGui/src/qDetectorMain.cpp b/slsDetectorGui/src/qDetectorMain.cpp index 7201e97d5..f00b3494c 100644 --- a/slsDetectorGui/src/qDetectorMain.cpp +++ b/slsDetectorGui/src/qDetectorMain.cpp @@ -258,7 +258,7 @@ void qDetectorMain::Initialization(){ connect(tab_plot, SIGNAL(DisableZoomSignal(bool)), this,SLOT(SetZoomToolTip(bool))); // Actions tab (only for scan) connect(tab_actions, SIGNAL(EnableScanBox()), tab_plot,SLOT(EnableScanBox())); - //settings to advanced tab(int=id is always 0 to only refresh) + //settings to advanced tab(int is always 0 to only refresh) connect(tab_settings, SIGNAL(UpdateTrimbitSignal(int)), tab_advanced,SLOT(UpdateTrimbitPlot(int))); // Plotting // When the acquisition is finished, must update the meas tab diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 1cab23125..f16f4d110 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -123,10 +123,14 @@ void qDrawPlot::SetupWidgetWindow(){ setFont(QFont("Sans Serif",9)); layout = new QGridLayout; this->setLayout(layout); + + histFrameIndexTitle= histFrameIndexTitle = new QLabel(""); + boxPlot = new QGroupBox(""); layout->addWidget(boxPlot,1,1); boxPlot->setAlignment(Qt::AlignHCenter); boxPlot->setFont(QFont("Sans Serif",11,QFont::Normal)); + plot_update_timer = new QTimer(this); connect(plot_update_timer, SIGNAL(timeout()), this, SLOT(UpdatePlot())); data_pause_timer = new QTimer(this); @@ -190,6 +194,14 @@ void qDrawPlot::SetupWidgetWindow(){ fileSaveEnable= myDet->enableWriteToFile(); + //pedestal + resetPedestal = true; + pedestalVals = 0; + pedestalCount = -1; + + if(myDet->getDetectorsType()==slsDetectorDefs::GOTTHARD) + pedestalCount = 0; + // Setting the callback function to get data from detector class myDet->registerDataCallback(&(GetDataCallBack),this); @@ -555,8 +567,8 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){ currentFrameIndex=fIndex; sprintf(temp_title,"#%d",fIndex); }else{ - if(fileSaveEnable) strcpy(temp_title,""); - else sprintf(temp_title,"#%d",currentFrame); + if(fileSaveEnable) strcpy(temp_title,"#%d"); + else sprintf(temp_title,"",currentFrame); } @@ -748,10 +760,37 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){ else currentPersistency=persistency; nHists = currentPersistency+1; histNBins = nPixelsX; + // copy data for(int i=currentPersistency;i>0;i--) memcpy(histYAxis[i],histYAxis[i-1],nPixelsX*sizeof(double)); - memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double)); + + //normal data + if(resetPedestal) + memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double)); + else{ + //start adding frames to get to the pedestal value + if(pedestalCountvalues[px]; + memcpy(histYAxis[0],data->values,nPixelsX*sizeof(double)); + } + //calculate the pedestal value + else if(pedestalCount==NUM_PEDESTAL_FRAMES){ + cout << "Pedestal Calculated" << endl; + for(unsigned int px=0;pxvalues,nPixelsX*sizeof(double)); + } + //use this pedestal value henceforth + else{ + for(unsigned int px=0;pxvalues[px] - (pedestalVals[px]); + } + pedestalCount++; + + } + } //2d else{cout<hide(); boxPlot->setFlat(false); plot_in_scope=1; + layout->addWidget(histFrameIndexTitle,0,0); }else{ plot2D->SetXTitle(imageXAxisTitle); plot2D->SetYTitle(imageYAxisTitle); @@ -895,6 +935,9 @@ void qDrawPlot::SelectPlot(int i){ //1 for 1D otherwise 2D plot2D->show(); boxPlot->setFlat(true); plot_in_scope=2; + histFrameIndexTitle->setText(""); + layout->removeWidget(histFrameIndexTitle); + } } @@ -936,9 +979,9 @@ void qDrawPlot::UpdatePlot(){ SlsQtH1D* h; if(hist_num+1>plot1D_hists.size()){ if(anglePlot) - plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAngleAxis,histYAngleAxis)); + plot1D_hists.append(h=new SlsQtH1D("",histNBins,histXAngleAxis,histYAngleAxis)); else - plot1D_hists.append(h=new SlsQtH1D("1d plot",histNBins,histXAxis,GetHistYAxis(hist_num))); + plot1D_hists.append(h=new SlsQtH1D("",histNBins,histXAxis,GetHistYAxis(hist_num))); h->SetLineColor(hist_num+1); }else{ h=plot1D_hists.at(hist_num); @@ -948,7 +991,8 @@ void qDrawPlot::UpdatePlot(){ h->SetData(histNBins,histXAxis,GetHistYAxis(hist_num)); } SetStyle(h); - h->setTitle(GetHistTitle(hist_num)); + histFrameIndexTitle->setText(GetHistTitle(0)); + //h->setTitle(GetHistTitle(hist_num)); h->Attach(plot1D); } // update range if required @@ -1318,7 +1362,7 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){ plot1D->SetYTitle("Trimbits"); //set plot parameters SlsQtH1D* h; - plot1D_hists.append(h=new SlsQtH1D("1d plot",nPixelsX,histXAxis,histYAxis[0])); + plot1D_hists.append(h=new SlsQtH1D("",nPixelsX,histXAxis,histYAxis[0])); h->SetLineColor(1); h->setTitle(GetHistTitle(0)); //attach plot @@ -1347,7 +1391,7 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){ plot1D->SetYTitle("Frequency"); //set plot parameters SlsQtH1D* h; - plot1D_hists.append(h=new SlsQtH1D("1d plot",nPixelsX,histXAxis,histYAxis[0])); + plot1D_hists.append(h=new SlsQtH1D("",nPixelsX,histXAxis,histYAxis[0])); h->SetLineColor(1); h->setTitle(GetHistTitle(0)); //attach plot @@ -1398,4 +1442,47 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){ } +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qDrawPlot::ResetPedestal(){ +#ifdef VERBOSE + cout << "Resetting Pedestal" << endl; +#endif + while(1){ + if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ + pedestalVals = 0; + pedestalCount = 0; + resetPedestal = true; + pthread_mutex_unlock(&(last_image_complete_mutex)); + break; + } + } +} + + +//------------------------------------------------------------------------------------------------------------------------------------------------- + + +void qDrawPlot::CalculatePedestal(){ +#ifdef VERBOSE + cout << "Calculating Pedestal" << endl; +#endif + while(1){ + if(!pthread_mutex_trylock(&(last_image_complete_mutex))){ + //create array + if(pedestalVals) delete [] pedestalVals; pedestalVals = new double[nPixelsX]; + //reset all values + for(unsigned int px=0;pxsetEnabled(enable); //Enable this always if(!enable) btnStartStop->setEnabled(true); - btnStartStop->setShortcut(QApplication::translate("TabMeasurementObject", "Space", 0, QApplication::UnicodeUTF8)); + btnStartStop->setShortcut(QApplication::translate("TabMeasurementObject", "Shift+Space", 0, QApplication::UnicodeUTF8)); } diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index aa110685d..9b60d38a6 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -60,7 +60,6 @@ void qTabPlot::SetupWidgetWindow(){ intervalTip = boxFrequency->toolTip(); - //scan arguments btnGroupScan = new QButtonGroup(this); btnGroupScan->addButton(radioLevel0,0); @@ -148,6 +147,13 @@ void qTabPlot::SetupWidgetWindow(){ //to check if this should be enabled EnableScanBox(); + stackedWidget->setCurrentIndex(0); + + if(myDet->getDetectorsType()!=slsDetectorDefs::GOTTHARD){ + btnCalPedestal->setEnabled(false); + btnResetPedestal->setEnabled(false); + } + } @@ -156,10 +162,19 @@ void qTabPlot::SetupWidgetWindow(){ void qTabPlot::Set1DPage(){ QPushButton *clickedButton = qobject_cast(sender()); - if(clickedButton->icon().pixmap(QSize(16,16)).toImage()==btnLeft->icon().pixmap(QSize(16,16)).toImage()) - stackedWidget->setCurrentIndex(0); - else + if(stackedWidget->currentIndex()==0){ + //if(clickedButton->icon().pixmap(QSize(16,16)).toImage()==btnLeft->icon().pixmap(QSize(16,16)).toImage()) stackedWidget->setCurrentIndex(1); + box1D->setTitle("1D Plot Options 2"); + } + else if(stackedWidget->currentIndex()==1){ + stackedWidget->setCurrentIndex(2); + box1D->setTitle("1D Plot Options 3"); + } + else{ + stackedWidget->setCurrentIndex(0); + box1D->setTitle("1D Plot Options 1"); + } } @@ -206,8 +221,9 @@ void qTabPlot::Initialization(){ connect(chkLines, SIGNAL(toggled(bool)), myPlot, SLOT(SetLines(bool))); connect(chk1DLog, SIGNAL(toggled(bool)), myPlot, SIGNAL(LogySignal(bool))); //to change pages - connect(btnLeft, SIGNAL(clicked()), this, SLOT(Set1DPage())); connect(btnRight, SIGNAL(clicked()), this, SLOT(Set1DPage())); + connect(btnRight2, SIGNAL(clicked()), this, SLOT(Set1DPage())); + connect(btnRight3, SIGNAL(clicked()), this, SLOT(Set1DPage())); // 2D Plot box connect(chkInterpolate, SIGNAL(toggled(bool)),myPlot, SIGNAL(InterpolateSignal(bool))); connect(chkContour, SIGNAL(toggled(bool)),myPlot, SIGNAL(ContourSignal(bool))); @@ -247,6 +263,9 @@ void qTabPlot::Initialization(){ connect(this,SIGNAL(SetZRangeSignal(double,double)),myPlot, SIGNAL(SetZRangeSignal(double,double))); +//pedstal + connect(btnResetPedestal, SIGNAL(clicked()),myPlot, SLOT(ResetPedestal())); + connect(btnCalPedestal, SIGNAL(clicked()),myPlot, SLOT(CalculatePedestal())); } @@ -796,6 +815,7 @@ void qTabPlot::Refresh(){ connect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); EnableScanBox(); SetFrequency(); + }else{ disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); boxScan->setEnabled(false); @@ -803,6 +823,7 @@ void qTabPlot::Refresh(){ if(radioHistogram->isChecked()) radioDataGraph->setEnabled(false); radioHistogram->setEnabled(false); + } #ifdef VERBOSE cout << "**Updated Plot Tab" << endl << endl;