#include <StatGridAnalyser.h>
Public Slots | |
| void | gridChanged () |
| void | on_freqScroll_valueChanged (int) |
| void | on_rejectAllBut_clicked () |
| void | on_rejectBut_clicked () |
| void | on_undoAllBut_clicked () |
| void | on_undoBut_clicked () |
| void | setBand (double min, double max) |
Signals | |
| void | newMean () |
| void | newMedian () |
| void | newMode () |
| void | reject (double frequency, double minVel, double maxVel) |
| void | undo (double frequency) |
Public Member Functions | |
| void | setGrid (IrregularGrid2DPlot *grid, Axis *valueAxis) |
| void | setUnits (const QString &u) |
| StatGridAnalyser (QWidget *parent=0, Qt::WFlags fl=0) | |
| ~StatGridAnalyser () | |
| StatGridAnalyser::StatGridAnalyser | ( | QWidget * | parent = 0, |
| Qt::WFlags | fl = 0 |
||
| ) |
References newMean(), newMedian(), newMode(), QGpCoreTools::tr(), and TRACE.
: QWidget(parent, fl)
{
TRACE;
setupUi(this);
setFocusPolicy(Qt::ClickFocus);
_grid=0;
_lastFreq=0;
// Init the curve menu
QMenu * m=new QMenu(this);
m->setTitle(tr( "Curve"));
m->setTearOffEnabled (true);
curveBut->setMenu(m);
QAction * a;
a=new QAction(tr("&Mean"), this);
curveBut->menu()->addAction(a);
connect(a, SIGNAL(triggered()), this, SIGNAL(newMean()) );
a=new QAction(tr("Medi&an"), this);
curveBut->menu()->addAction(a);
connect(a, SIGNAL(triggered()), this, SIGNAL(newMedian()) );
a=new QAction(tr("Mo&de"), this);
curveBut->menu()->addAction(a);
connect(a, SIGNAL(triggered()), this, SIGNAL(newMode()) );
new QShortcut(Qt::Key_Up, this, SLOT(nextFrequency()) );
new QShortcut(Qt::Key_Up+Qt::SHIFT, this, SLOT(nextFrequencyReject()) );
new QShortcut(Qt::Key_Down, this, SLOT(previousFrequency()) );
new QShortcut(Qt::Key_Down+Qt::SHIFT, this, SLOT(previousFrequencyReject()) );
new QShortcut(Qt::Key_Left, this, SLOT(decreaseLowLimit()) );
new QShortcut(Qt::Key_Left+Qt::SHIFT, this, SLOT(decreaseHighLimit()) );
new QShortcut(Qt::Key_Right, this, SLOT(increaseLowLimit()) );
new QShortcut(Qt::Key_Right+Qt::SHIFT, this, SLOT(increaseHighLimit()) );
_partitionBandLayer=0;
_partitionCurveLayer=0;
_densityBandLayer=0;
_densityCurveLayer=0;
}
| void StatGridAnalyser::gridChanged | ( | ) | [slot] |
References SciFigs::IrregularGrid2DPlot::grid(), QGpCoreTools::IrregularGrid2D::maximumValue(), QGpCoreTools::IrregularGrid2D::nx(), on_freqScroll_valueChanged(), SciFigs::Axis::setRange(), and TRACE.
Referenced by HistogramWidget::fillGrid().
{
TRACE;
const IrregularGrid2D& g=_grid->grid();
if(g.nx()==0) {
freqScroll->setMaximum(0);
} else {
freqScroll->setMaximum(g.nx() - 1);
*probaDensity->xAxis()=*_valueAxis;
static bool initialized=false;
if(!initialized) probaDensity->yAxis()->setRange(0.0, g.maximumValue());
initialized=true;
*probaPartition->xAxis()=*_valueAxis;
on_freqScroll_valueChanged(0);
}
_bands.resize(g.nx());
}
| void StatGridAnalyser::newMean | ( | ) | [signal] |
Referenced by StatGridAnalyser().
| void StatGridAnalyser::newMedian | ( | ) | [signal] |
Referenced by StatGridAnalyser().
| void StatGridAnalyser::newMode | ( | ) | [signal] |
Referenced by StatGridAnalyser().
| void StatGridAnalyser::on_freqScroll_valueChanged | ( | int | ) | [slot] |
References SciFigs::ParallelBands::band(), QGpCoreTools::Curve< pointType >::count(), QGpCoreTools::IrregularGrid2D::crossSection(), SciFigs::PlotLine2D::curve(), SciFigs::IrregularGrid2DPlot::grid(), QGpCoreTools::IrregularGrid2D::height(), SciFigs::LineLayer::line(), SciFigs::GraphContentLayer::lockDelayPainting(), QGpCoreTools::IrregularGrid2D::log10(), SciFigs::ParallelBand::maximum(), QGpCoreTools::IrregularGrid2D::mean(), QGpCoreTools::IrregularGrid2D::median(), SciFigs::ParallelBand::minimum(), QGpCoreTools::IrregularGrid2D::mode(), QGpCoreTools::IrregularGrid2D::nx(), QGpCoreTools::GaussDistribution::part(), QGpCoreTools::GaussDistribution::rho(), SciFigs::Axis::scaleType, setBand(), SciFigs::PlotLine2D::setCurve(), QGpCoreTools::Point2D::setY(), QGpCoreTools::sqrt(), QGpCoreTools::tr(), TRACE, SciFigs::GraphContentLayer::unlock(), QGpCoreTools::IrregularGrid2D::variance(), QGpCoreTools::Point2D::x(), QGpCoreTools::IrregularGrid2D::x(), QGpCoreTools::Point2D::y(), and QGpCoreTools::YAxis.
Referenced by gridChanged().
{
TRACE;
IrregularGrid2D grid=_grid->grid();
if(grid.nx()==0) return ;
bool logScale=_valueAxis->scaleType()==Scale::Log;
int iFreq=freqScroll->value();
freqEdit->setText(QString( "%1 Hz" ).arg(grid.x(iFreq) ));
PlotLine2D * gridDensityLine=static_cast<PlotLine2D *>(_densityCurveLayer->line(0));
PlotLine2D * gaussDensityLine=static_cast<PlotLine2D *>(_densityCurveLayer->line(1));
PlotLine2D * gridPartitionLine=static_cast<PlotLine2D *>(_partitionCurveLayer->line(0));
PlotLine2D * gaussPartitionLine=static_cast<PlotLine2D *>(_partitionCurveLayer->line(1));
_densityCurveLayer->lockDelayPainting();
_partitionCurveLayer->lockDelayPainting();
gridDensityLine->setCurve(grid.crossSection(YAxis, iFreq) );
gaussDensityLine->setCurve(gridDensityLine->curve());
gridPartitionLine->setCurve(gridDensityLine->curve());
gaussPartitionLine->setCurve(gridDensityLine->curve());
if(logScale) {
grid.log10(YAxis);
}
double mean=grid.mean(YAxis, iFreq);
double stddev=sqrt(grid.variance(YAxis, iFreq) );
double med=grid.median(YAxis, iFreq);
double meddev=sqrt(grid.variance(YAxis, iFreq, med) );
double mod=grid.mode(YAxis, iFreq);
double moddev=sqrt(grid.variance(YAxis, iFreq, mod) );
int n=gridDensityLine->curve().count();
double sum=0;
for(int i=0;i < n;i++ ) {
Point2D& p=gridPartitionLine->curve()[i];
sum += p.y();
p.setY(sum * grid.height(i) );
}
GaussDistribution gd(mean, stddev);
for(int i=0;i < n;i++ ) {
Point2D& p=gaussDensityLine->curve()[i];
if(logScale)
p.setY(gd.rho(log10( p.x()) ));
else
p.setY(gd.rho(p.x()) );
}
for(int i=0;i < n;i++ ) {
Point2D& p=gaussPartitionLine->curve()[i];
if(logScale)
p.setY(gd.part(log10( p.x()) ));
else
p.setY(gd.part(p.x()) );
}
if(_lastFreq<_bands.count()) {
const ParallelBand& b=_densityBandLayer->band(0);
_bands[_lastFreq].first=b.minimum();
_bands[_lastFreq].second=b.maximum();
}
if(iFreq<_bands.count()) {
if(_bands[iFreq].first!=0.0 || _bands[iFreq].second!=0.0) {
setBand(_bands[iFreq].first, _bands[iFreq].second);
}
_lastFreq=iFreq;
}
_densityCurveLayer->unlock();
_partitionCurveLayer->unlock();
if(logScale) {
mean=pow(10.0, mean);
stddev=pow(10.0, stddev);
med=pow(10.0, med);
meddev=pow(10.0, meddev);
mod=pow(10.0, mod);
moddev=pow(10.0, moddev);
}
statValuesLabel->setText(tr( "Average %1 %7 - Stddev %2 %7\n"
"Median %3 %7 - Meddev %4 %7\n"
"Mode %5 %7 - Moddev %6 %7" ).
arg(mean, 0, 'g', 3).arg(stddev, 0, 'g', 3).
arg(med, 0, 'g', 3).arg(meddev, 0, 'g', 3).
arg(mod, 0, 'g', 3).arg(moddev, 0, 'g', 3).arg(_units));
probaDensity->graphContent() ->deepUpdate();
probaPartition->graphContent() ->deepUpdate();
}
| void StatGridAnalyser::on_rejectAllBut_clicked | ( | ) | [slot] |
| void StatGridAnalyser::on_rejectBut_clicked | ( | ) | [slot] |
Reject all samples outside the band. If SHIFT key is pressed, the current frequency is incremented. If the band for next frequency does not exist, a new one is created from the current one plus a translation calculated on the median difference before the rejection at the current frequency.
References SciFigs::ParallelBands::band(), SciFigs::IrregularGrid2DPlot::grid(), SciFigs::ParallelBand::maximum(), SciFigs::ParallelBand::minimum(), reject(), TRACE, and QGpCoreTools::IrregularGrid2D::x().
| void StatGridAnalyser::on_undoAllBut_clicked | ( | ) | [slot] |
| void StatGridAnalyser::on_undoBut_clicked | ( | ) | [slot] |
References SciFigs::IrregularGrid2DPlot::grid(), TRACE, undo(), and QGpCoreTools::IrregularGrid2D::x().
| void StatGridAnalyser::reject | ( | double | frequency, |
| double | minVel, | ||
| double | maxVel | ||
| ) | [signal] |
Referenced by on_rejectAllBut_clicked(), and on_rejectBut_clicked().
| void StatGridAnalyser::setBand | ( | double | min, |
| double | max | ||
| ) | [slot] |
References SciFigs::ParallelBands::band(), SciFigs::ParallelBand::setMaximum(), SciFigs::ParallelBand::setMinimum(), and TRACE.
Referenced by on_freqScroll_valueChanged(), and setGrid().
{
TRACE;
ParallelBand& b1=_densityBandLayer->band(0);
b1.setMinimum(min);
b1.setMaximum(max);
ParallelBand& b2=_partitionBandLayer->band(0);
b2.setMinimum(min);
b2.setMaximum(max);
probaDensity->graphContent()->deepUpdate();
probaPartition->graphContent()->deepUpdate();
}
| void StatGridAnalyser::setGrid | ( | IrregularGrid2DPlot * | grid, |
| Axis * | valueAxis | ||
| ) |
References SciFigs::ParallelBands::addBand(), SciFigs::LineLayer::addLine(), SciFigs::GraphContentLayer::addTrackingAction(), setBand(), SciFigs::GraphContentLayer::setOpacity(), SciFigs::LineLayer::setReferenceLine(), SciFigs::LineLayer::setReferencePen(), QGpCoreTools::tr(), and TRACE.
Referenced by HistogramWidget::HistogramWidget().
{
TRACE;
_grid=grid;
_valueAxis=valueAxis;
_densityBandLayer=new ParallelBands(probaDensity);
_densityBandLayer->setObjectName( "FKStatSlowLimits" );
_densityBandLayer->addTrackingAction(tr("Pick bands"), 0, tr("Define the frequency band to rejet."));
_densityBandLayer->setOpacity(0.6);
_densityBandLayer->addBand(0, 0, Brush(QColor( 205, 242, 255) ));
connect(_densityBandLayer, SIGNAL(bandPicked(double, double)), this, SLOT(setBand( double, double) ));
_densityCurveLayer=new LineLayer(probaDensity);
_densityCurveLayer->setObjectName( "FKStatProba" );
_densityCurveLayer->setReferenceLine(new PlotLine2D);
_densityCurveLayer->setReferencePen(Pen( Qt::blue) );
probaDensity->yAxis()->setNumberType(Number::Scientific);
probaDensity->yAxis()->setNumberPrecision(1);
probaDensity->yAxis()->setTitle( "Probability density" );
_densityCurveLayer->addLine(Pen( Qt::blue), Symbol());
_densityCurveLayer->addLine(Pen( Qt::red), Symbol());
_partitionBandLayer=new ParallelBands(probaPartition);
_partitionBandLayer->setObjectName( "FKStatSlowLimits" );
_partitionBandLayer->addTrackingAction(tr("Pick bands"), 0, tr("Define the frequency band to rejet."));
_partitionBandLayer->setOpacity(0.6);
_partitionBandLayer->addBand(0, 0, Brush(QColor( 205, 242, 255) ));
connect(_partitionBandLayer, SIGNAL(bandPicked(double, double)), this, SLOT(setBand( double, double) ));
_partitionCurveLayer=new LineLayer(probaPartition);
_partitionCurveLayer->setObjectName( "FKStatPartF" );
_partitionCurveLayer->setReferenceLine(new PlotLine2D);
_partitionCurveLayer->setReferencePen(Pen( Qt::blue) );
probaPartition->yAxis()->setRange(0.0, 1.0);
probaPartition->yAxis()->setNumberType(Number::Fixed);
probaPartition->yAxis()->setNumberPrecision(1);
probaPartition->yAxis()->setTitle( "Partition Function" );
_partitionCurveLayer->addLine(Pen( Qt::blue), Symbol());
_partitionCurveLayer->addLine(Pen( Qt::red), Symbol());
}
| void StatGridAnalyser::setUnits | ( | const QString & | u | ) | [inline] |
Referenced by HistogramWidget::select().
{_units=u;}
| void StatGridAnalyser::undo | ( | double | frequency | ) | [signal] |
Referenced by on_undoAllBut_clicked(), and on_undoBut_clicked().