diff --git a/pub/src/coord.cpp b/pub/src/coord.cpp index 451ba5710e35184f17fae2249f6cd2384af96c7d..3e17f555535cc7eafaaec0ac94aa5387e9072c57 100644 --- a/pub/src/coord.cpp +++ b/pub/src/coord.cpp @@ -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 + ")") : ""); } diff --git a/pub/src/curve.cpp b/pub/src/curve.cpp index 160fc5f4d1b1d26c17427a9a66afb967db752773..6298d3ff9050f84bc465f847288ebaa3f6819109 100644 --- a/pub/src/curve.cpp +++ b/pub/src/curve.cpp @@ -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), "");