From 0d66e62d107978ec858aa27880682d52e36dfe18 Mon Sep 17 00:00:00 2001 From: Maliakal Dhanya Date: Tue, 9 Sep 2014 15:46:36 +0200 Subject: [PATCH] fixed histogram for trimbits and threshold --- slsDetectorGui/include/qDrawPlot.h | 4 +-- slsDetectorGui/src/qDrawPlot.cpp | 49 +++++++++++++++++++----------- slsDetectorGui/src/qTabPlot.cpp | 27 ++++++++++------ 3 files changed, 52 insertions(+), 28 deletions(-) diff --git a/slsDetectorGui/include/qDrawPlot.h b/slsDetectorGui/include/qDrawPlot.h index f8266e517..2b09e840e 100644 --- a/slsDetectorGui/include/qDrawPlot.h +++ b/slsDetectorGui/include/qDrawPlot.h @@ -143,7 +143,7 @@ public: void SetBinary(bool enable, int from=0, int to=0); /** Enable/Disable Histogram */ - void SetHistogram(bool enable,int histArg, int min=0, int max=0, int size=0){histogram = enable;histogramArgument = histArg; histFrom=min;histTo=max;histSize=size;}; + void SetHistogram(bool enable,int histArg, int min=0, int max=0, double size=0){histogram = enable;histogramArgument = histArg; histFrom=min;histTo=max;histSize=size;}; public slots: /** To select 1D or 2D plot @@ -563,7 +563,7 @@ bool displayStatistics; bool histogram; int histFrom; int histTo; -int histSize; +double histSize; QwtPlotGrid *grid; QwtPlotHistogram *plotHistogram; QVector histogramSamples; diff --git a/slsDetectorGui/src/qDrawPlot.cpp b/slsDetectorGui/src/qDrawPlot.cpp index 076e24c7b..308be8e78 100644 --- a/slsDetectorGui/src/qDrawPlot.cpp +++ b/slsDetectorGui/src/qDrawPlot.cpp @@ -210,7 +210,7 @@ void qDrawPlot::SetupWidgetWindow(){ grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine)); */ plotHistogram = new QwtPlotHistogram(); - plotHistogram->setStyle(QwtPlotHistogram::Columns); + plotHistogram->setStyle(QwtPlotHistogram::Columns);//Options:Outline,Columns, Lines firstPlot = false; @@ -542,7 +542,6 @@ void qDrawPlot::SetScanArgument(int scanArg){ minPixelsY = 0; nPixelsX = myDet->getTotalNumberOfChannels(slsDetectorDefs::X); nPixelsY = myDet->getTotalNumberOfChannels(slsDetectorDefs::Y); - //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 @@ -595,25 +594,23 @@ void qDrawPlot::SetScanArgument(int scanArg){ //histogram if(histogram){ - histogramSamples.resize(0); int iloop = 0; - int min = iloop*histSize + histFrom; - int max = (iloop+1)*histSize + histFrom; - while(min < histTo){ - histogramSamples.resize(iloop+1); - histogramSamples[iloop].interval.setInterval(min,max-1); + int numSteps = ((histTo-histFrom)/(histSize)) + 1; + histogramSamples.resize(numSteps); + startPixel = histFrom -(histSize/2); + endPixel = histTo + (histSize/2); + while(startPixel < endPixel){ + histogramSamples[iloop].interval.setInterval(startPixel,startPixel+histSize,QwtInterval::ExcludeMaximum); histogramSamples[iloop].value = 0; + startPixel += histSize; iloop++; - min = max; - max = (iloop+1)*histSize + histFrom; - if(max>histTo) - max = histTo; } + //print values cout << "Histogram Intervals:" << endl; for(int j=0;jvalues[i] <= histFrom) || (data->values[i] >= histTo)) + if ((data->values[i] < histFrom) || (data->values[i] >= histTo)) continue; //check for intervals, increment if validates for(int j=0;j= histTo) || (scanval == -1)) + if ((scanval < histFrom) || (scanval > histTo) || (scanval == -1)) scanval = -1; //check for intervals, increment if validates for(int j=0;j l2){ + cout << "***** s curve inflectionfound at " << histogramSamples[j].interval.maxValue() << "" + "or j at " << j << " with l1 " << l1 << " and l2 " << l2 << endl; + } + } + } + return 0; } @@ -1321,9 +1336,9 @@ void qDrawPlot::UpdatePlot(){ histFrameIndexTitle->setText(GetHistTitle(0)); plotHistogram->attach(plot1D); //refixing all the zooming - plot1D->SetXMinMax(histFrom,histTo); + plot1D->SetXMinMax(startPixel,endPixel); plot1D->SetYMinMax(0,plotHistogram->boundingRect().height()); - plot1D->SetZoomBase(0,0,nPixelsX,plotHistogram->boundingRect().height()); + plot1D->SetZoomBase(startPixel,0,endPixel-startPixel,plotHistogram->boundingRect().height()); } //not histogram else{ diff --git a/slsDetectorGui/src/qTabPlot.cpp b/slsDetectorGui/src/qTabPlot.cpp index 3e16651f7..6fa2c46f9 100644 --- a/slsDetectorGui/src/qTabPlot.cpp +++ b/slsDetectorGui/src/qTabPlot.cpp @@ -572,11 +572,13 @@ void qTabPlot::SetPlot(){ cout << " - Histogram" << endl; - if(radioHistIntensity->isChecked()) + if(radioHistIntensity->isChecked()){ pageHistogram->setEnabled(true); - else + pageHistogram_2->setEnabled(true); + }else{ pageHistogram->setEnabled(false); - + pageHistogram_2->setEnabled(false); + } boxScan->hide(); boxHistogram->show(); myPlot->EnablePlot(true); @@ -587,8 +589,9 @@ void qTabPlot::SetPlot(){ boxPlotAxis->setEnabled(true); if(!myPlot->isRunning()) EnableScanBox(); - qDefs::Message(qDefs::INFORMATION,"Please check the Plot Histogram Options below " - "before Starting Acquitision","qTabPlot::SetPlot"); + + //qDefs::Message(qDefs::INFORMATION,"Please check the Plot Histogram Options below " + // "before Starting Acquitision","qTabPlot::SetPlot"); } } @@ -865,10 +868,13 @@ void qTabPlot::EnableScanBox(){ //histogram if(radioHistogram->isChecked()){ - if(radioHistIntensity->isChecked()) + if(radioHistIntensity->isChecked()){ pageHistogram->setEnabled(true); - else + pageHistogram_2->setEnabled(true); + }else{ pageHistogram->setEnabled(false); + pageHistogram_2->setEnabled(false); + } stackedWidget->setCurrentIndex(stackedWidget->count()-1); stackedWidget_2->setCurrentIndex(stackedWidget_2->count()-1); box1D->setTitle(QString("1D Plot Options %1 - Histogram").arg(stackedWidget->currentIndex()+1)); @@ -900,7 +906,7 @@ void qTabPlot::EnableScanBox(){ }else{ pageHistogram->setEnabled(false); - /*pageHistogram_2->setEnabled(false);*/ + pageHistogram_2->setEnabled(false); } connect(btnGroupPlotType,SIGNAL(buttonClicked(int)),this, SLOT(SetPlot())); @@ -939,7 +945,7 @@ void qTabPlot::SetScanArgument(){ //histogram default - set before setscanargument int min = spinHistFrom->value(); int max = spinHistTo->value(); - int size = spinHistSize->value(); + double size = spinHistSize->value(); int histArg = qDefs::Intensity; if(radioHistogram->isChecked()){ if(!radioHistIntensity->isChecked()){ @@ -1089,8 +1095,10 @@ void qTabPlot::SetBinary(){ void qTabPlot::SetHistogramOptions(){ if(radioHistIntensity->isChecked()){ pageHistogram->setEnabled(true); + pageHistogram_2->setEnabled(true); }else { pageHistogram->setEnabled(false); + pageHistogram_2->setEnabled(false); } } @@ -1115,6 +1123,7 @@ void qTabPlot::Refresh(){ disconnect(boxScan, SIGNAL(toggled(bool)), this, SLOT(EnableScanBox())); boxScan->setEnabled(false); pageHistogram->setEnabled(false); + pageHistogram_2->setEnabled(false); if(radioHistogram->isChecked()) radioDataGraph->setEnabled(false); else