MultiPeakFit.h
Go to the documentation of this file.
/***************************************************************************
File : MultiPeakFit.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2006 by Ion Vasilief
Email (use @ for *) : ion_vasilief*yahoo.fr
Description : MultiPeakFit module with Lorentz and Gauss peak shapes
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef MULTIPEAKFIT_H
#define MULTIPEAKFIT_H
#include "Fit.h"
class MultiPeakFit : public Fit
{
Q_OBJECT
public:
enum PeakProfile{Gauss, Lorentz};
MultiPeakFit(ApplicationWindow *parent, QwtPlotCurve *c, PeakProfile profile = Gauss, int peaks = 1);
MultiPeakFit(ApplicationWindow *parent, Graph *g = 0, PeakProfile profile = Gauss, int peaks = 1);
MultiPeakFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol,
int startRow = 0, int endRow = -1, PeakProfile profile = Gauss, int peaks = 1);
int peaks(){return d_peaks;};
void setNumPeaks(int n);
void enablePeakCurves(bool on){generate_peak_curves = on;};
void setPeakCurvesColor(int colorIndex);
void setPeakCurvesColor(const QColor& color){d_peaks_color = color;};
static QString generateFormula(int order, PeakProfile profile);
static QStringList generateParameterList(int order);
static QStringList generateExplanationList(int order);
void guessInitialValues();
virtual double eval(double *par, double x);
double evalPeak(double *par, double x, int peak);
PeakProfile profile(){return d_profile;};
private:
void init(int);
QString logFitInfo(int iterations, int status);
void generateFitCurve();
static QString peakFormula(int peakIndex, PeakProfile profile);
void insertPeakFunctionCurve(int peak);
void customizeFitResults();
int d_peaks;
bool generate_peak_curves;
QColor d_peaks_color;
PeakProfile d_profile;
};
class LorentzFit : public MultiPeakFit
{
Q_OBJECT
public:
LorentzFit(ApplicationWindow *parent, QwtPlotCurve *);
LorentzFit(ApplicationWindow *parent, QwtPlotCurve *, double, double);
LorentzFit(ApplicationWindow *parent, Graph *g);
LorentzFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
LorentzFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
LorentzFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
private:
void init();
};
class GaussFit : public MultiPeakFit
{
Q_OBJECT
public:
GaussFit(ApplicationWindow *parent, QwtPlotCurve *);
GaussFit(ApplicationWindow *parent, QwtPlotCurve *, double, double);
GaussFit(ApplicationWindow *parent, Graph *g);
GaussFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
GaussFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
GaussFit( ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
private:
void init();
};
class GaussAmpFit : public Fit
{
Q_OBJECT
public:
GaussAmpFit(ApplicationWindow *parent, QwtPlotCurve *);
GaussAmpFit(ApplicationWindow *parent, QwtPlotCurve *, double, double);
GaussAmpFit(ApplicationWindow *parent, Graph *g);
GaussAmpFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
GaussAmpFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
GaussAmpFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
void guessInitialValues();
double eval(double *par, double x);
private:
void init();
void calculateFitCurveData(double *X, double *Y);
};
#endif
MultiPeakFit::d_profile
PeakProfile d_profile
The peak profile.
Definition: MultiPeakFit.h:84
GaussAmpFit::GaussAmpFit
GaussAmpFit(ApplicationWindow *parent, QwtPlotCurve *)
Definition: MultiPeakFit.cpp:560
MultiPeakFit::customizeFitResults
void customizeFitResults()
Customs and stores the fit results according to the derived class specifications. Used by exponential...
Definition: MultiPeakFit.cpp:212
MultiPeakFit::insertPeakFunctionCurve
void insertPeakFunctionCurve(int peak)
Inserts a peak function curve into the plot.
Definition: MultiPeakFit.cpp:220
GaussFit
Definition: MultiPeakFit.h:103
MultiPeakFit::evalPeak
double evalPeak(double *par, double x, int peak)
Definition: MultiPeakFit.cpp:403
MultiPeakFit::setNumPeaks
void setNumPeaks(int n)
Definition: MultiPeakFit.cpp:86
Fit.h
MultiPeakFit::MultiPeakFit
MultiPeakFit(ApplicationWindow *parent, QwtPlotCurve *c, PeakProfile profile=Gauss, int peaks=1)
Definition: MultiPeakFit.cpp:47
MultiPeakFit::generateParameterList
static QStringList generateParameterList(int order)
Definition: MultiPeakFit.cpp:105
MultiPeakFit::profile
PeakProfile profile()
Definition: MultiPeakFit.h:62
Graph
A 2D-plotting widget.
Definition: Graph.h:123
MultiPeakFit::guessInitialValues
void guessInitialValues()
Used by the GaussFit and LorentzFit derived classes to calculate initial values for the parameters...
Definition: MultiPeakFit.cpp:177
MultiPeakFit::Lorentz
Definition: MultiPeakFit.h:39
MultiPeakFit::PeakProfile
PeakProfile
Definition: MultiPeakFit.h:39
MultiPeakFit::generateFitCurve
void generateFitCurve()
Adds the result curve to the plot.
Definition: MultiPeakFit.cpp:249
MultiPeakFit::peakFormula
static QString peakFormula(int peakIndex, PeakProfile profile)
Definition: MultiPeakFit.cpp:160
LorentzFit::init
void init()
Definition: MultiPeakFit.cpp:493
MultiPeakFit::enablePeakCurves
void enablePeakCurves(bool on)
Definition: MultiPeakFit.h:48
GaussAmpFit::eval
double eval(double *par, double x)
Calculates the data for the output fit curve.
Definition: MultiPeakFit.cpp:641
GaussFit::GaussFit
GaussFit(ApplicationWindow *parent, QwtPlotCurve *)
Definition: MultiPeakFit.cpp:506
MultiPeakFit
Definition: MultiPeakFit.h:34
GaussAmpFit::calculateFitCurveData
void calculateFitCurveData(double *X, double *Y)
Calculates the data for the output fit curve and store itin the X an Y vectors.
Definition: MultiPeakFit.cpp:616
MultiPeakFit::Gauss
Definition: MultiPeakFit.h:39
MultiPeakFit::setPeakCurvesColor
void setPeakCurvesColor(const QColor &color)
Definition: MultiPeakFit.h:50
Fit
Fit base class.
Definition: Fit.h:44
MultiPeakFit::d_peaks
int d_peaks
Number of peaks.
Definition: MultiPeakFit.h:75
MultiPeakFit::setPeakCurvesColor
void setPeakCurvesColor(int colorIndex)
Definition: MultiPeakFit.cpp:441
ApplicationWindow
QtiPlot's main window.
Definition: ApplicationWindow.h:133
MultiPeakFit::generate_peak_curves
bool generate_peak_curves
Tells weather the peak curves should be displayed together with the best line fit.
Definition: MultiPeakFit.h:78
MultiPeakFit::d_peaks_color
QColor d_peaks_color
Color for the peak curves.
Definition: MultiPeakFit.h:81
GaussAmpFit
Definition: MultiPeakFit.h:119
GaussFit::init
void init()
Definition: MultiPeakFit.cpp:547
MultiPeakFit::eval
virtual double eval(double *par, double x)
Calculates the data for the output fit curve.
Definition: MultiPeakFit.cpp:394
MultiPeakFit::generateExplanationList
static QStringList generateExplanationList(int order)
Definition: MultiPeakFit.cpp:121
MultiPeakFit::peaks
int peaks()
Definition: MultiPeakFit.h:45
Fit::init
void init()
Definition: Fit.cpp:67
MultiPeakFit::logFitInfo
QString logFitInfo(int iterations, int status)
Output string added to the result log.
Definition: MultiPeakFit.cpp:414
GaussAmpFit::init
void init()
Definition: MultiPeakFit.cpp:601
Filter::x
double * x()
Returns the x values of the input data set.
Definition: Filter.h:98
Table
MDI window providing a spreadsheet table with column logic.
Definition: Table.h:57
MultiPeakFit::generateFormula
static QString generateFormula(int order, PeakProfile profile)
Definition: MultiPeakFit.cpp:137
LorentzFit::LorentzFit
LorentzFit(ApplicationWindow *parent, QwtPlotCurve *)
Definition: MultiPeakFit.cpp:452
LorentzFit
Definition: MultiPeakFit.h:87
GaussAmpFit::guessInitialValues
void guessInitialValues()
Definition: MultiPeakFit.cpp:647