Brief description of class still missing. More...
#include <CurveReader.h>
Public Member Functions | |
CurveReader () | |
void | generateFunction () const |
bool | isFunctionMode () const |
bool | setOptions (int &argc, char **argv) |
bool | terminate () |
Protected Member Functions | |
virtual bool | parse (QTextStream &s) |
Brief description of class still missing.
Full description of class still missing
Description of constructor still missing
References QGpCoreTools::L2_Normalized, QGpCoreTools::LinearScale, and TRACE.
: ArgumentStdinReader() { TRACE; _mode=None; _nResample=100; _minX=-1e99; _maxX=1e99; _dx=1; _xValue=0.0; _columnIndex=1; _samplingType=LinearScale; _misfitType=L2_Normalized; _misfitMin=0.0; _misfitDof=1; _logBase=10.0; _multiplyFactor=1.0; }
void CurveReader::generateFunction | ( | ) | const |
References QGpCoreTools::endl(), QGpCoreTools::flush(), sOut(), and TRACE.
Referenced by main().
{ TRACE; QTextStream sOut(stdout); QScriptEngine engine; QScriptValue global=engine.globalObject(); engine.evaluate("function f(x) {return "+_functionText+";}"); if(engine.hasUncaughtException()) { App::stream() << engine.uncaughtException().toString() << endl; App::stream() << engine.uncaughtExceptionBacktrace().join("\n") << endl; return; } QScriptValue f=global.property("f"); for(double x=_minX;x<=_maxX;x+=_dx) { QScriptValueList args; args << x; sOut << QString("%1 %2\n").arg(x, 0, 'g', 16).arg(f.call(QScriptValue(), args).toNumber(), 0, 'g', 16); } sOut << flush; }
bool CurveReader::isFunctionMode | ( | ) | const [inline] |
Referenced by main().
{return _mode==ParseFunction;}
bool CurveReader::parse | ( | QTextStream & | s | ) | [protected, virtual] |
Implements QGpCoreTools::ArgumentStdinReader.
References QGpCoreTools::Curve< pointType >::append(), QGpCoreTools::Curve< pointType >::clear(), QGpCoreTools::endl(), QGpCoreTools::PointND::fromString(), sOut(), and TRACE.
{ TRACE; QTextStream sOut(stdout); Curve<PointND> curve; PointND p; QString buf; while(!s.atEnd()) { buf=s.readLine(); if(buf.isEmpty() || buf[0]=='\n' || buf[0]=='#') { if(!exec(curve)) { return false; } curve.clear(); if(buf[0]=='#') sOut << buf << endl; } else { p.fromString(buf); curve.append(p); } } return exec(curve); }
bool CurveReader::setOptions | ( | int & | argc, |
char ** | argv | ||
) |
References QGpCoreTools::endl(), QGpCoreTools::InversedScale, QGpCoreTools::LinearScale, QGpCoreTools::LogScale, QGpCoreTools::tr(), and TRACE.
Referenced by main().
{ TRACE; int i, j=1; for(i=1; i<argc; i++) { QByteArray arg=argv[i]; if(arg[0]=='-') { if(arg=="-resample") { CoreApplication::checkOptionArg(i, argc, argv); _mode=Resample; _nResample=atoi(argv[i]); } else if(arg=="-resample-ext") { CoreApplication::checkOptionArg(i, argc, argv); _mode=ResampleExtrapole; _nResample=atoi(argv[i]); } else if(arg=="-cut") { _mode=Cut; } else if(arg=="-cut-int") { _mode=CutInterpole; } else if(arg=="-column") { CoreApplication::checkOptionArg(i, argc, argv); _columnIndex=atoi(argv[i]); } else if(arg=="-swap") { _mode=Swap; } else if(arg=="-max-index") { _mode=MaxIndex; } else if(arg=="-max-value") { _mode=MaxValue; } else if(arg=="-value") { CoreApplication::checkOptionArg(i, argc, argv); _mode=FunctionValue; _xValue=atof(argv[i]); } else if(arg=="-merge-replace") { CoreApplication::checkOptionArg(i, argc, argv); _mode=MergeReplace; _referenceFile=argv[i]; } else if(arg=="-merge-interpolate") { CoreApplication::checkOptionArg(i, argc, argv); _mode=MergeInterpolate; _referenceFile=argv[i]; } else if(arg=="-minmax") { _mode=MinMax; } else if(arg=="-misfit") { CoreApplication::checkOptionArg(i, argc, argv); _mode=Misfit; _referenceFile=argv[i]; } else if(arg=="-regression") { _mode=Regression; } else if(arg=="-derivative") { _mode=Derivative; } else if(arg=="-pow") { CoreApplication::checkOptionArg(i, argc, argv); _mode=Power; _logBase=atof(argv[i]); } else if(arg=="-log") { CoreApplication::checkOptionArg(i, argc, argv); _mode=Log; _logBase=atof(argv[i]); } else if(arg=="-multiply") { CoreApplication::checkOptionArg(i, argc, argv); _mode=Multiply; _multiplyFactor=atof(argv[i]); } else if(arg=="-function") { CoreApplication::checkOptionArg(i, argc, argv); _mode=ParseFunction; _functionText=argv[i]; } else if(arg=="-misfit-type") { CoreApplication::checkOptionArg(i, argc, argv); _misfitType=RealStatisticalValue::misfitType(argv[i] ); } else if(arg=="-misfit-min") { CoreApplication::checkOptionArg(i, argc, argv); _misfitMin=atof(argv[i] ); } else if(arg=="-misfit-dof") { CoreApplication::checkOptionArg(i, argc, argv); _misfitDof=atoi(argv[i] ); } else if(arg=="-min") { CoreApplication::checkOptionArg(i, argc, argv); _minX=atof(argv[i]); } else if(arg=="-max") { CoreApplication::checkOptionArg(i, argc, argv); _maxX=atof(argv[i]); } else if(arg=="-dx") { CoreApplication::checkOptionArg(i, argc, argv); _dx=atof(argv[i]); } else if(arg=="-sampling") { CoreApplication::checkOptionArg(i, argc, argv); if(strcmp(argv[i],"inversed")==0) { _samplingType=InversedScale; } else if(strcmp(argv[i],"linear")==0) { _samplingType=LinearScale; } else { _samplingType=LogScale; } } else { App::stream() << tr("gpcurve: bad option %1, see -help").arg(argv[i]) << endl; return false; } } else { argv[j++]=argv[i]; } } if(j < argc) { argv[j]=0; argc=j; } return true; }
bool CurveReader::terminate | ( | ) |