mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-01 18:30:05 +02:00
displaying statistics works now
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui@226 af1100a4-978c-4157-bff7-07162d2ba061
This commit is contained in:
parent
eb48b1c492
commit
505328bcaa
@ -30,6 +30,9 @@ class SlsQtH1D;
|
|||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QString>
|
||||||
|
#include <QSpacerItem>
|
||||||
|
#include <QWidget>
|
||||||
/** C++ Include Headers */
|
/** C++ Include Headers */
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -44,7 +47,8 @@ class qCloneWidget:public QMainWindow{
|
|||||||
public:
|
public:
|
||||||
/** \short The constructor
|
/** \short The constructor
|
||||||
*/
|
*/
|
||||||
qCloneWidget(QWidget *parent,int id,QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D,string FilePath);
|
qCloneWidget(QWidget *parent,int id,QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D,string FilePath,
|
||||||
|
bool displayStats, QString min, QString max, QString sum);
|
||||||
|
|
||||||
/** Destructor
|
/** Destructor
|
||||||
*/
|
*/
|
||||||
@ -125,6 +129,9 @@ private:
|
|||||||
/** Gets the current time stamp for the window title*/
|
/** Gets the current time stamp for the window title*/
|
||||||
char* GetCurrentTimeStamp();
|
char* GetCurrentTimeStamp();
|
||||||
|
|
||||||
|
/** Display Statistics */
|
||||||
|
void DisplayStats(bool enable, QString min, QString max, QString sum);
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/** Save Plot */
|
/** Save Plot */
|
||||||
|
@ -172,6 +172,12 @@ void RecalculatePedestal();
|
|||||||
void SetAccumulate(bool enable);
|
void SetAccumulate(bool enable);
|
||||||
/** Reset accumulation */
|
/** Reset accumulation */
|
||||||
void ResetAccumulate();
|
void ResetAccumulate();
|
||||||
|
/** Display Statistics */
|
||||||
|
void DisplayStatistics(bool enable);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -260,6 +266,15 @@ void SetStyle(SlsQtH1D* h){
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** Find Statistics
|
||||||
|
* @param min is the minimum value
|
||||||
|
* @param max is the maximum value
|
||||||
|
* @param sum is the sum of all values
|
||||||
|
* @param array is the array to get statistics from
|
||||||
|
* @param size is the size of the array */
|
||||||
|
void GetStatistics(double &min, double &max, double &sum, double* array, int size);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -521,6 +536,15 @@ int binaryTo;
|
|||||||
bool clientInitiated;
|
bool clientInitiated;
|
||||||
|
|
||||||
|
|
||||||
|
/** display statistics widgets */
|
||||||
|
QWidget *widgetStatistics;
|
||||||
|
QLabel *lblMinDisp;
|
||||||
|
QLabel *lblMaxDisp;
|
||||||
|
QLabel *lblSumDisp;
|
||||||
|
|
||||||
|
bool displayStatistics;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void UpdatingPlotFinished();
|
void UpdatingPlotFinished();
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
#define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui"
|
#define SVNURL "file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorGui"
|
||||||
//#define SVNREPPATH ""
|
//#define SVNREPPATH ""
|
||||||
#define SVNREPUUID "af1100a4-978c-4157-bff7-07162d2ba061"
|
#define SVNREPUUID "af1100a4-978c-4157-bff7-07162d2ba061"
|
||||||
//#define SVNREV 0x218
|
//#define SVNREV 0x225
|
||||||
//#define SVNKIND ""
|
//#define SVNKIND ""
|
||||||
//#define SVNSCHED ""
|
//#define SVNSCHED ""
|
||||||
#define SVNAUTH "l_maliakal_d"
|
#define SVNAUTH "l_maliakal_d"
|
||||||
#define SVNREV 0x218
|
#define SVNREV 0x225
|
||||||
#define SVNDATE 0x20130807
|
#define SVNDATE 0x20130812
|
||||||
//
|
//
|
||||||
|
@ -18,8 +18,10 @@
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
qCloneWidget::qCloneWidget(QWidget *parent,int id,QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D,string FilePath):
|
qCloneWidget::qCloneWidget(QWidget *parent,int id,QString title,int numDim,SlsQt1DPlot*& plot1D,SlsQt2DPlotLayout*& plot2D,string FilePath,
|
||||||
QMainWindow(parent),id(id),cloneplot2D(0),cloneplot1D(0),filePath(FilePath){
|
bool displayStats, QString min, QString max, QString sum):
|
||||||
|
QMainWindow(parent),id(id),cloneplot2D(0),cloneplot1D(0),filePath(FilePath)
|
||||||
|
{
|
||||||
/** Window title*/
|
/** Window title*/
|
||||||
char winTitle[300],currTime[50];
|
char winTitle[300],currTime[50];
|
||||||
strcpy(currTime,GetCurrentTimeStamp());
|
strcpy(currTime,GetCurrentTimeStamp());
|
||||||
@ -28,6 +30,7 @@ qCloneWidget::qCloneWidget(QWidget *parent,int id,QString title,int numDim,SlsQt
|
|||||||
|
|
||||||
/** Set up widget*/
|
/** Set up widget*/
|
||||||
SetupWidgetWindow(title,numDim,plot1D,plot2D);
|
SetupWidgetWindow(title,numDim,plot1D,plot2D);
|
||||||
|
DisplayStats(displayStats,min,max,sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -262,11 +265,60 @@ int qCloneWidget::SavePlotAutomatic(){
|
|||||||
else return -1;
|
else return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
void qCloneWidget::closeEvent(QCloseEvent* event){
|
void qCloneWidget::closeEvent(QCloseEvent* event){
|
||||||
emit CloneClosedSignal(id);
|
emit CloneClosedSignal(id);
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
void qCloneWidget::DisplayStats(bool enable, QString min, QString max, QString sum){
|
||||||
|
if(enable){
|
||||||
|
QWidget *widgetStatistics = new QWidget(this);
|
||||||
|
widgetStatistics->setFixedHeight(15);
|
||||||
|
QHBoxLayout *hl1 = new QHBoxLayout;
|
||||||
|
hl1->setSpacing(0);
|
||||||
|
hl1->setContentsMargins(0, 0, 0, 0);
|
||||||
|
QLabel *lblMin = new QLabel("Min: ");
|
||||||
|
lblMin->setFixedWidth(40);
|
||||||
|
lblMin->setAlignment(Qt::AlignRight);
|
||||||
|
QLabel *lblMax = new QLabel("Max: ");
|
||||||
|
lblMax->setFixedWidth(40);
|
||||||
|
lblMax->setAlignment(Qt::AlignRight);
|
||||||
|
QLabel *lblSum = new QLabel("Sum: ");
|
||||||
|
lblSum->setFixedWidth(40);
|
||||||
|
lblSum->setAlignment(Qt::AlignRight);
|
||||||
|
QLabel *lblMinDisp = new QLabel(min);
|
||||||
|
lblMinDisp->setAlignment(Qt::AlignLeft);
|
||||||
|
QLabel *lblMaxDisp = new QLabel(max);
|
||||||
|
lblMaxDisp->setAlignment(Qt::AlignLeft);
|
||||||
|
QLabel *lblSumDisp = new QLabel(sum);
|
||||||
|
lblSumDisp->setAlignment(Qt::AlignLeft);
|
||||||
|
hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
|
||||||
|
hl1->addWidget(lblMin);
|
||||||
|
hl1->addWidget(lblMinDisp);
|
||||||
|
hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed));
|
||||||
|
hl1->addWidget(lblMax);
|
||||||
|
hl1->addWidget(lblMaxDisp);
|
||||||
|
hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed));
|
||||||
|
hl1->addWidget(lblSum);
|
||||||
|
hl1->addWidget(lblSumDisp);
|
||||||
|
hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
|
||||||
|
widgetStatistics->setLayout(hl1);
|
||||||
|
mainLayout->addWidget(widgetStatistics,2,0);
|
||||||
|
widgetStatistics->show();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,6 +219,44 @@ void qDrawPlot::SetupWidgetWindow(){
|
|||||||
connect(data_pause_timer, SIGNAL(timeout()), this, SLOT(UpdatePause()));
|
connect(data_pause_timer, SIGNAL(timeout()), this, SLOT(UpdatePause()));
|
||||||
|
|
||||||
|
|
||||||
|
//display statistics
|
||||||
|
displayStatistics = false;
|
||||||
|
widgetStatistics = new QWidget(this);
|
||||||
|
widgetStatistics->setFixedHeight(15);
|
||||||
|
QHBoxLayout *hl1 = new QHBoxLayout;
|
||||||
|
hl1->setSpacing(0);
|
||||||
|
hl1->setContentsMargins(0, 0, 0, 0);
|
||||||
|
QLabel *lblMin = new QLabel("Min: ");
|
||||||
|
lblMin->setFixedWidth(40);
|
||||||
|
lblMin->setAlignment(Qt::AlignRight);
|
||||||
|
QLabel *lblMax = new QLabel("Max: ");
|
||||||
|
lblMax->setFixedWidth(40);
|
||||||
|
lblMax->setAlignment(Qt::AlignRight);
|
||||||
|
QLabel *lblSum = new QLabel("Sum: ");
|
||||||
|
lblSum->setFixedWidth(40);
|
||||||
|
lblSum->setAlignment(Qt::AlignRight);
|
||||||
|
lblMinDisp = new QLabel("-");
|
||||||
|
lblMinDisp->setAlignment(Qt::AlignLeft);
|
||||||
|
lblMaxDisp = new QLabel("-");
|
||||||
|
lblMaxDisp->setAlignment(Qt::AlignLeft);
|
||||||
|
lblSumDisp = new QLabel("-");
|
||||||
|
lblSumDisp->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
|
||||||
|
lblSumDisp->setAlignment(Qt::AlignLeft);
|
||||||
|
hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
|
||||||
|
hl1->addWidget(lblMin);
|
||||||
|
hl1->addWidget(lblMinDisp);
|
||||||
|
hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed));
|
||||||
|
hl1->addWidget(lblMax);
|
||||||
|
hl1->addWidget(lblMaxDisp);
|
||||||
|
hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed));
|
||||||
|
hl1->addWidget(lblSum);
|
||||||
|
hl1->addWidget(lblSumDisp);
|
||||||
|
hl1->addItem(new QSpacerItem(20,20,QSizePolicy::Fixed,QSizePolicy::Fixed));
|
||||||
|
widgetStatistics->setLayout(hl1);
|
||||||
|
layout->addWidget(widgetStatistics,2,0);
|
||||||
|
widgetStatistics->hide();
|
||||||
|
|
||||||
|
|
||||||
// setting default plot titles and settings
|
// setting default plot titles and settings
|
||||||
plot1D = new SlsQt1DPlot(boxPlot);
|
plot1D = new SlsQt1DPlot(boxPlot);
|
||||||
|
|
||||||
@ -1156,7 +1194,19 @@ void qDrawPlot::UpdatePlot(){
|
|||||||
plot1D->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
|
plot1D->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
|
||||||
XYRangeChanged = false;
|
XYRangeChanged = false;
|
||||||
}
|
}
|
||||||
|
//Display Statistics
|
||||||
|
if(displayStatistics){
|
||||||
|
double min=0,max=0,sum=0;
|
||||||
|
if(anglePlot)
|
||||||
|
GetStatistics(min,max,sum,histYAngleAxis,histNBins);
|
||||||
|
else
|
||||||
|
GetStatistics(min,max,sum,histYAxis[0],histNBins);
|
||||||
|
lblMinDisp->setText(QString("%1").arg(min));
|
||||||
|
lblMaxDisp->setText(QString("%1").arg(max));
|
||||||
|
lblSumDisp->setText(QString("%1").arg(sum));
|
||||||
|
}
|
||||||
if(saveAll) SavePlotAutomatic();
|
if(saveAll) SavePlotAutomatic();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//2-d plot stuff
|
}//2-d plot stuff
|
||||||
@ -1182,6 +1232,14 @@ void qDrawPlot::UpdatePlot(){
|
|||||||
plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
|
plot2D->GetPlot()->SetYMinMax(XYRangeValues[qDefs::YMINIMUM],XYRangeValues[qDefs::YMAXIMUM]);
|
||||||
XYRangeChanged = false;
|
XYRangeChanged = false;
|
||||||
}
|
}
|
||||||
|
//Display Statistics
|
||||||
|
if(displayStatistics){
|
||||||
|
double min=0,max=0,sum=0;
|
||||||
|
GetStatistics(min,max,sum,lastImageArray,nPixelsX*nPixelsY);
|
||||||
|
lblMinDisp->setText(QString("%1").arg(min));
|
||||||
|
lblMaxDisp->setText(QString("%1").arg(max));
|
||||||
|
lblSumDisp->setText(QString("%1").arg(sum));
|
||||||
|
}
|
||||||
if(saveAll) SavePlotAutomatic();
|
if(saveAll) SavePlotAutomatic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1257,7 +1315,8 @@ void qDrawPlot::ClonePlot(){
|
|||||||
disconnect(this, SIGNAL(SetZRangeSignal(double,double)), plot2D, SLOT(SetZRange(double,double)));
|
disconnect(this, SIGNAL(SetZRangeSignal(double,double)), plot2D, SLOT(SetZRange(double,double)));
|
||||||
|
|
||||||
// create clone
|
// create clone
|
||||||
winClone[i] = new qCloneWidget(this,i,boxPlot->title(),(int)plot_in_scope,plot1D,plot2D,sFilePath);
|
winClone[i] = new qCloneWidget(this,i,boxPlot->title(),(int)plot_in_scope,plot1D,plot2D,sFilePath,
|
||||||
|
displayStatistics,lblMinDisp->text(),lblMaxDisp->text(),lblSumDisp->text());
|
||||||
if(plot_in_scope==1){
|
if(plot_in_scope==1){
|
||||||
plot1D = new SlsQt1DPlot(boxPlot);
|
plot1D = new SlsQt1DPlot(boxPlot);
|
||||||
plot1D->setFont(QFont("Sans Serif",9,QFont::Normal));
|
plot1D->setFont(QFont("Sans Serif",9,QFont::Normal));
|
||||||
@ -1576,7 +1635,14 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){
|
|||||||
//attach plot
|
//attach plot
|
||||||
h->Attach(plot1D);
|
h->Attach(plot1D);
|
||||||
}
|
}
|
||||||
|
//Display Statistics
|
||||||
|
if(displayStatistics){
|
||||||
|
double min=0,max=0,sum=0;
|
||||||
|
GetStatistics(min,max,sum,histYAxis[0],nPixelsX);
|
||||||
|
lblMinDisp->setText(QString("%1").arg(min));
|
||||||
|
lblMaxDisp->setText(QString("%1").arg(max));
|
||||||
|
lblSumDisp->setText(QString("%1").arg(sum));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
@ -1614,7 +1680,14 @@ int qDrawPlot::UpdateTrimbitPlot(bool fromDetector,bool Histogram){
|
|||||||
cout << "Trimbits Plot updated" << endl;
|
cout << "Trimbits Plot updated" << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
//Display Statistics
|
||||||
|
if(displayStatistics){
|
||||||
|
double min=0,max=0,sum=0;
|
||||||
|
GetStatistics(min,max,sum,lastImageArray,nPixelsX*nPixelsY);
|
||||||
|
lblMinDisp->setText(QString("%1").arg(min));
|
||||||
|
lblMaxDisp->setText(QString("%1").arg(max));
|
||||||
|
lblSumDisp->setText(QString("%1").arg(sum));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return qDefs::OK;
|
return qDefs::OK;
|
||||||
@ -1750,3 +1823,42 @@ void qDrawPlot::SetBinary(bool enable, int from, int to){
|
|||||||
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
void qDrawPlot::DisplayStatistics(bool enable){
|
||||||
|
#ifdef VERBOSE
|
||||||
|
if(!enable)
|
||||||
|
cout << "Disabling Statistics Display" << endl;
|
||||||
|
else
|
||||||
|
cout << "Enabling Statistics Display" << endl;
|
||||||
|
#endif
|
||||||
|
if(enable) widgetStatistics->show();
|
||||||
|
else widgetStatistics->hide();
|
||||||
|
|
||||||
|
displayStatistics = enable;
|
||||||
|
lblMinDisp->setText("-");
|
||||||
|
lblMaxDisp->setText("-");
|
||||||
|
lblSumDisp->setText("-");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
void qDrawPlot::GetStatistics(double &min, double &max, double &sum, double* array, int size){
|
||||||
|
#ifdef VERYVERBOSE
|
||||||
|
cout << "Calculating Statistics" << endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for(int i=0; i < size; i++){
|
||||||
|
//calculate min
|
||||||
|
if(array[i] < min)
|
||||||
|
min = array[i];
|
||||||
|
//calculate max
|
||||||
|
if(array[i] > max)
|
||||||
|
max = array[i];
|
||||||
|
//calculate sum
|
||||||
|
sum += array[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -283,11 +283,13 @@ void qTabPlot::Initialization(){
|
|||||||
connect(chkPoints, SIGNAL(toggled(bool)), myPlot, SLOT(SetMarkers(bool)));
|
connect(chkPoints, SIGNAL(toggled(bool)), myPlot, SLOT(SetMarkers(bool)));
|
||||||
connect(chkLines, SIGNAL(toggled(bool)), myPlot, SLOT(SetLines(bool)));
|
connect(chkLines, SIGNAL(toggled(bool)), myPlot, SLOT(SetLines(bool)));
|
||||||
connect(chk1DLog, SIGNAL(toggled(bool)), myPlot, SIGNAL(LogySignal(bool)));
|
connect(chk1DLog, SIGNAL(toggled(bool)), myPlot, SIGNAL(LogySignal(bool)));
|
||||||
|
connect(chkStatistics, SIGNAL(toggled(bool)), myPlot, SLOT(DisplayStatistics(bool)));
|
||||||
|
|
||||||
// 2D Plot box
|
// 2D Plot box
|
||||||
connect(chkInterpolate, SIGNAL(toggled(bool)),myPlot, SIGNAL(InterpolateSignal(bool)));
|
connect(chkInterpolate, SIGNAL(toggled(bool)),myPlot, SIGNAL(InterpolateSignal(bool)));
|
||||||
connect(chkContour, SIGNAL(toggled(bool)),myPlot, SIGNAL(ContourSignal(bool)));
|
connect(chkContour, SIGNAL(toggled(bool)),myPlot, SIGNAL(ContourSignal(bool)));
|
||||||
connect(chkLogz, SIGNAL(toggled(bool)),myPlot, SIGNAL(LogzSignal(bool)));
|
connect(chkLogz, SIGNAL(toggled(bool)),myPlot, SIGNAL(LogzSignal(bool)));
|
||||||
|
connect(chkStatistics_2,SIGNAL(toggled(bool)),myPlot, SLOT(DisplayStatistics(bool)));
|
||||||
// Plotting frequency box
|
// Plotting frequency box
|
||||||
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
|
connect(comboFrequency, SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
|
||||||
connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
|
connect(comboTimeGapUnit,SIGNAL(currentIndexChanged(int)), this, SLOT(SetFrequency()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user