Brief description of class still missing. More...
#include <HistogramReader.h>
Public Types | |
| enum | Action { Gui, Mean, Median, Mode, Grid } |
| enum | ManualLimit { NoManualLimits = 0x00, MinimumX = 0x01, MaximumX = 0x02, MinimumY = 0x04, MaximumY = 0x08, AllManualLimits = 0x0F } |
Public Member Functions | |
| Action | action () const |
| Histogram2D * | histogram () const |
| HistogramReader () | |
| bool | setDefaultLimits () |
| bool | setOptions (int &argc, char **argv) |
Protected Member Functions | |
| virtual bool | parse (QTextStream &s) |
Brief description of class still missing.
Full description of class still missing
{NoManualLimits=0x00, MinimumX=0x01, MaximumX=0x02, MinimumY=0x04, MaximumY=0x08, AllManualLimits=0x0F};
Description of constructor still missing
References Gui, QGpCoreTools::LinearScale, NoManualLimits, and TRACE.
: ArgumentStdinReader() { TRACE; _action=Gui; _xSamplingType=LinearScale; _xMin=0.0; _xMax=0.0; _xCount=100; _ySamplingType=LinearScale; _yMin=0.0; _yMax=0.0; _yCount=100; _manualLimits=NoManualLimits; }
| Action HistogramReader::action | ( | ) | const [inline] |
Referenced by main().
{return _action;}
| Histogram2D * HistogramReader::histogram | ( | ) | const |
References QGpCoreTools::endl(), Histogram2D::setSamples(), Histogram2D::setXSampling(), Histogram2D::setYSampling(), QGpCoreTools::tr(), and TRACE.
Referenced by main().
{
TRACE;
Histogram2D * h=new Histogram2D(_xCount, _yCount);
App::stream() << tr("X axis from %1 to %2 with %3 bins").arg(_xMin).arg(_xMax).arg(_xCount) << endl;
h->setXSampling(_xMin, _xMax, _xSamplingType);
App::stream() << tr("Y axis from %1 to %2 with %3 bins").arg(_yMin).arg(_yMax).arg(_yCount) << endl;
h->setYSampling(_yMin, _yMax, _ySamplingType);
h->setSamples(_samples);
return h;
}
| bool HistogramReader::parse | ( | QTextStream & | s | ) | [protected, virtual] |
Implements QGpCoreTools::ArgumentStdinReader.
References QGpCoreTools::ConsoleProgress::begin(), QGpCoreTools::ConsoleProgress::end(), Sample::read(), QGpCoreTools::ConsoleProgress::setCaption(), QGpCoreTools::AbstractProgress::setValue(), and TRACE.
{
TRACE;
ConsoleProgress progress;
progress.setCaption("Loading... ");
progress.begin();
Sample sample;
while(true) {
if(sample.read(s)) {
_samples.append(sample);
} else {
break;
}
progress.setValue(_samples.count());
}
progress.end(_samples.count());
return true;
}
| bool HistogramReader::setDefaultLimits | ( | ) |
Computes default limits from samples
References AllManualLimits, QGpCoreTools::endl(), MaximumX, MaximumY, MinimumX, MinimumY, QGpCoreTools::tr(), and TRACE.
Referenced by main().
{
TRACE;
if(_manualLimits==AllManualLimits) return true;
QVector<Sample>::iterator it=_samples.begin();
if(it==_samples.end()) {
App::stream() << tr("No samples available") << endl;
return false;
}
if(!(_manualLimits & MinimumX)) {
_xMin=it->x();
for(it++; it!=_samples.end(); it++) {
if(it->x()<_xMin) _xMin=it->x();
}
}
if(!(_manualLimits & MaximumX)) {
it=_samples.begin();
_xMax=it->x();
for(it++; it!=_samples.end(); it++) {
if(it->x()>_xMax) _xMax=it->x();
}
}
if(!(_manualLimits & MinimumY)) {
it=_samples.begin();
_yMin=it->y();
for(it++; it!=_samples.end(); it++) {
if(it->y()<_yMin) _yMin=it->y();
}
}
if(!(_manualLimits & MaximumY)) {
it=_samples.begin();
_yMax=it->y();
for(it++; it!=_samples.end(); it++) {
if(it->y()>_yMax) _yMax=it->y();
}
}
return true;
}
| bool HistogramReader::setOptions | ( | int & | argc, |
| char ** | argv | ||
| ) |
References QGpCoreTools::endl(), Grid, QGpCoreTools::InversedScale, QGpCoreTools::LinearScale, QGpCoreTools::LogScale, MaximumX, MaximumY, Mean, Median, MinimumX, MinimumY, Mode, QGpCoreTools::tr(), and TRACE.
Referenced by main().
{
TRACE;
// Check arguments
int i, j=1;
for(i=1; i<argc; i++) {
QByteArray arg=argv[i];
if(arg[0]=='-') {
if(arg=="-x-sampling") {
CoreApplication::checkOptionArg(i, argc, argv);
if(strcmp(argv[i],"inversed")==0) {
_xSamplingType=InversedScale;
} else if(strcmp(argv[i],"log")==0) {
_xSamplingType=LogScale;
} else {
_xSamplingType=LinearScale;
}
} else if(arg=="-x-min") {
CoreApplication::checkOptionArg(i, argc, argv);
_xMin=atof(argv[i]);
_manualLimits|=MinimumX;
} else if(arg=="-x-max") {
CoreApplication::checkOptionArg(i, argc, argv);
_xMax=atof(argv[i]);
_manualLimits|=MaximumX;
} else if(arg=="-x-count") {
CoreApplication::checkOptionArg(i, argc, argv);
_xCount=atoi(argv[i]);
if(_xCount<=0) {
App::stream() << tr("gphistogram: negative or null number of X samples (option -x-count)") << endl;
return false;
}
} else if(arg=="-y-sampling") {
CoreApplication::checkOptionArg(i, argc, argv);
if(strcmp(argv[i],"inversed")==0) {
_ySamplingType=InversedScale;
} else if(strcmp(argv[i],"log")==0) {
_ySamplingType=LogScale;
} else {
_ySamplingType=LinearScale;
}
} else if(arg=="-y-min") {
CoreApplication::checkOptionArg(i, argc, argv);
_yMin=atof(argv[i]);
_manualLimits|=MinimumY;
} else if(arg=="-y-max") {
CoreApplication::checkOptionArg(i, argc, argv);
_yMax=atof(argv[i]);
_manualLimits|=MaximumY;
} else if(arg=="-y-count") {
CoreApplication::checkOptionArg(i, argc, argv);
_yCount=atoi(argv[i]);
if(_yCount<=0) {
App::stream() << tr("gphistogram: negative or null number of Y samples (option -y-count)") << endl;
return false;
}
} else if(arg=="-grid") {
_action=Grid;
} else if(arg=="-mean") {
_action=Mean;
} else if(arg=="-median") {
_action=Median;
} else if(arg=="-mode") {
_action=Mode;
} else {
App::stream() << tr("gphistogram: bad option %1, see -help").arg(argv[i]) << endl;
return false;
}
} else {
argv[j++]=argv[i];
}
}
if(j < argc) {
argv[j]=0;
argc=j;
}
switch(_xSamplingType) {
case LogScale:
case InversedScale:
if(_xMin<=0.0 || _xMax<=0.0) {
App::stream() << tr("gphistogram: null or negative values not allowed for log and inversed scales (X axis)") << endl;
return false;
}
break;
default:
break;
}
switch(_ySamplingType) {
case LogScale:
case InversedScale:
if(_yMin<=0.0 || _yMax<=0.0) {
App::stream() << tr("gphistogram: null or negative values not allowed for log and inversed scales (Y axis)") << endl;
return false;
}
break;
default:
break;
}
return true;
}