Skip to content
Snippets Groups Projects
Commit 669f4c46 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

mittendrin: vereinheitliche askFunction

parent 6f219646
No related branches found
No related tags found
No related merge requests found
......@@ -110,7 +110,7 @@ string CCoord::str( int maxlen ) const
return name.substr(0,maxlen);
}
string CCoord::ps_str() const // just two blanks instead of one
string CCoord::ps_str() const // two blanks instead of one, and no unit ""
{
return name + ( unit!="" ? (" (" + unit + ")") : "");
}
......
......@@ -52,8 +52,9 @@ bool allow_slow_conv = true;
//! Parse expression, and set auxiliary parameters.
// Used here (Create) and when reading from disk (NFileIn::Load).
void NCurveFile::setFunction( POlc f, const string& expr )
void NCurveFile::askFunction( POlc f, const string& quest )
{
string expr = sask( quest+" ?" );
// parse expression
PTree T;
user_xaxparse( expr.c_str(), &T );
......@@ -75,19 +76,18 @@ void NCurveFile::setFunction( POlc f, const string& expr )
void NCurveFile::CreateFitcurve()
{
string expr = sask( "Fit function ?" );
if( expr=="" ) return;
POlc fc;
askFunction( fc, "Fit function" );
NOlm::IterateD fiter;
POld fd;
while( (fd=fiter()) ) {
POlc fout( new COlc );
setFunction( fout, expr );
POlc fout( new_olc(fc) );
vector<double> P( fout->nPar(), 1.0 );
fout->name = string("fit_") + fd->name;
fout->kd = fiter.k();
fout->xco = CCoord( "ip", "" );
fout->yco = CCoord( "p[ip]", "" );
fout->xco = fd->xco;
fout->yco = fd->yco;
fout->ZCo = fd->ZCo;
fout->RPar = fd->RPar;
fout->lDoc.push_back( "cc " + expr + " # z from " + fd->name );
......@@ -109,11 +109,9 @@ void NCurveFile::CreateFreecurve()
{
static int default_no=0;
string expr = sask( "Function ?" );
if( expr=="" ) return;
POlc fout( new COlc );
setFunction( fout, expr );
askFunction( fout, "Fit function" );
fout->name = string("curve") + strg(default_no++);
fout->xco = CCoord( "x", "" );
fout->yco = CCoord( "y", "" );
......@@ -131,16 +129,17 @@ void NCurveFile::CreateFreecurve()
void NCurveFile::ChangeExpr()
{
string expr = sask( "Replace function by ?" );
if( expr=="" ) return;
POlc ftmp( new COlc );
askFunction( ftmp, "Replace function by" );
NOlm::IterateC fiter;
POlc fc;
while( (fc=fiter()) ) {
uint nParOld = fc->nPar();
setFunction( fc, expr );
fc->expr = ftmp->expr;
fc->T = ftmp->tmp;
fc->lDoc.push_back( "ccm " + expr );
uint nParNew = fc->T->npar();
uint nParNew = fc->npar();
fc->PCo.resize(nParNew);
for( uint ip=nParOld; ip<nParNew; ip++ ){
fc->PCo[ip] = CCoord("p" + strg(ip), "");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment