2 * Cueplot: a GUI front-end to gnuplot
3 * Copyright (C) 2007, 2008 Muneyuki Noguchi
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 const double Fit::DEFAULT_FIT_LIMIT = 1e-5;
23 Fit::Fit() : functionName_("f(x)"),
24 fitLimit_(DEFAULT_FIT_LIMIT), fitMaxIter_(DEFAULT_FIT_MAX_ITER)
28 void Fit::setRange(const FitRange &range)
33 const FitRange &Fit::range() const
38 void Fit::setFunctionName(const QString &name)
43 const QString &Fit::functionName() const
48 void Fit::setFunction(const QString &function)
53 const QString &Fit::function() const
58 void Fit::setDataFile(const QString &file)
63 const QString &Fit::dataFile() const
68 void Fit::setDataFileModifier(const FitModifier &mod)
70 dataFileModifier_ = mod;
73 const FitModifier &Fit::dataFileModifier() const
75 return dataFileModifier_;
78 void Fit::setParameterFile(bool isFile)
80 isParameterFile_ = isFile;
83 bool Fit::isParameterFile() const
85 return isParameterFile_;
88 void Fit::setParameterFile(const QString &file)
90 parameterFile_ = file;
93 const QString &Fit::parameterFile() const
95 return parameterFile_;
98 void Fit::setVariable(const QStringList &var)
103 const QStringList &Fit::variable() const
108 void Fit::setFitLimit(double limit)
113 double Fit::fitLimit() const
118 void Fit::setFitMaxIter(int iter)
123 int Fit::fitMaxIter() const
128 QString Fit::command() const
130 QStringList commandList;
131 if (fitLimit_ != DEFAULT_FIT_LIMIT) {
132 commandList << "FIT_LIMIT = " + QString::number(fitLimit_);
134 if (fitMaxIter_ != DEFAULT_FIT_MAX_ITER) {
135 commandList << "FIT_MAXITER = " + QString::number(fitMaxIter_);
137 commandList << functionName_ + '=' + function_;
138 QString str = "fit " + range_.option() + ' ' + functionName_ + " '"
139 + dataFile_ + "' " + dataFileModifier_.option() + " via ";
140 if (isParameterFile_) {
141 str += '\'' + parameterFile_ + '\'';
143 str += variable_.join(",");
146 return commandList.join("\n");