fixed histogram for trimbits and threshold

This commit is contained in:
Maliakal Dhanya 2014-09-09 15:46:36 +02:00
parent 705a25c9e0
commit 0d66e62d10
3 changed files with 52 additions and 28 deletions

View File

@ -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<QwtIntervalSample> histogramSamples;

View File

@ -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;j<histogramSamples.size();j++){
cout<<j<<":\tmin:"<<histogramSamples[j].interval.minValue()<<""
"\tmax:"<<histogramSamples[j].interval.maxValue()<<"\t:"<<histogramSamples[j].value<<endl;
"\t\tmax:"<<histogramSamples[j].interval.maxValue()<<"\t\tvalue:"<<histogramSamples[j].value<<endl;
}
}
@ -700,6 +697,11 @@ void qDrawPlot::SetupMeasurement(){
startPixel = minPixelsY -(pixelWidth/2);
endPixel = maxPixelsY + (pixelWidth/2);
}
if(histogram){
startPixel = histFrom -(histSize/2);
endPixel = histTo + (histSize/2);
}
}
@ -988,7 +990,7 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
//frequency of intensity
if(histogramArgument == qDefs::Intensity){
//ignore outside limits
if ((data->values[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<histogramSamples.size();j++){
@ -1017,7 +1019,7 @@ int qDrawPlot::GetData(detectorData *data,int fIndex){
else scanval = cs1;
//ignore outside limits
if ((scanval <= histFrom) || (scanval >= histTo) || (scanval == -1))
if ((scanval < histFrom) || (scanval > histTo) || (scanval == -1))
scanval = -1;
//check for intervals, increment if validates
for(int j=0;j<histogramSamples.size();j++){
@ -1190,6 +1192,19 @@ int qDrawPlot::AcquisitionFinished(double currentProgress, int detectorStatus){
//this lets the measurement tab know its over, and to enable tabs
emit UpdatingPlotFinished();
//calculate s curve inflection point
int l1=0,l2=0,j;
if((histogram)&&(histogramArgument != qDefs::Intensity)){
for(j=0;j<histogramSamples.size()-2;j++){
l1 = histogramSamples[j+1].value - histogramSamples[j].value;
l2 = histogramSamples[j+2].value - histogramSamples[j+1].value;
if(l1 > 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{

View File

@ -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,"<nobr>Please check the <b>Plot Histogram Options</b> below "
"before <b>Starting Acquitision</b></nobr>","qTabPlot::SetPlot");
//qDefs::Message(qDefs::INFORMATION,"<nobr>Please check the <b>Plot Histogram Options</b> below "
// "before <b>Starting Acquitision</b></nobr>","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