QtiPlot  0.9.8.2
MultiPeakFit.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : MultiPeakFit.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2006 by Ion Vasilief
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : MultiPeakFit module with Lorentz and Gauss peak shapes
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef MULTIPEAKFIT_H
30 #define MULTIPEAKFIT_H
31 
32 #include "Fit.h"
33 
34 class MultiPeakFit : public Fit
35 {
36  Q_OBJECT
37 
38  public:
40  MultiPeakFit(ApplicationWindow *parent, QwtPlotCurve *c, PeakProfile profile = Gauss, int peaks = 1);
41  MultiPeakFit(ApplicationWindow *parent, Graph *g = 0, PeakProfile profile = Gauss, int peaks = 1);
42  MultiPeakFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol,
43  int startRow = 0, int endRow = -1, PeakProfile profile = Gauss, int peaks = 1);
44 
45  int peaks(){return d_peaks;};
46  void setNumPeaks(int n);
47 
48  void enablePeakCurves(bool on){generate_peak_curves = on;};
49  void setPeakCurvesColor(int colorIndex);
50  void setPeakCurvesColor(const QColor& color){d_peaks_color = color;};
51 
52  static QString generateFormula(int order, PeakProfile profile);
53  static QStringList generateParameterList(int order);
54  static QStringList generateExplanationList(int order);
55 
57  void guessInitialValues();
58 
59  virtual double eval(double *par, double x);
60  double evalPeak(double *par, double x, int peak);
61 
63 
64  private:
65  void init(int);
66 
67  QString logFitInfo(int iterations, int status);
68  void generateFitCurve();
69  static QString peakFormula(int peakIndex, PeakProfile profile);
71  void insertPeakFunctionCurve(int peak);
72  void customizeFitResults();
73 
75  int d_peaks;
76 
79 
81  QColor d_peaks_color;
82 
85 };
86 
87 class LorentzFit : public MultiPeakFit
88 {
89  Q_OBJECT
90 
91  public:
92  LorentzFit(ApplicationWindow *parent, QwtPlotCurve *);
93  LorentzFit(ApplicationWindow *parent, QwtPlotCurve *, double, double);
94  LorentzFit(ApplicationWindow *parent, Graph *g);
95  LorentzFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
96  LorentzFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
97  LorentzFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
98 
99  private:
100  void init();
101 };
102 
103 class GaussFit : public MultiPeakFit
104 {
105  Q_OBJECT
106 
107  public:
108  GaussFit(ApplicationWindow *parent, QwtPlotCurve *);
109  GaussFit(ApplicationWindow *parent, QwtPlotCurve *, double, double);
110  GaussFit(ApplicationWindow *parent, Graph *g);
111  GaussFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
112  GaussFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
113  GaussFit( ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
114 
115  private:
116  void init();
117 };
118 
119 class GaussAmpFit : public Fit
120 {
121  Q_OBJECT
122 
123  public:
124  GaussAmpFit(ApplicationWindow *parent, QwtPlotCurve *);
125  GaussAmpFit(ApplicationWindow *parent, QwtPlotCurve *, double, double);
126  GaussAmpFit(ApplicationWindow *parent, Graph *g);
127  GaussAmpFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
128  GaussAmpFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
129  GaussAmpFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
130 
131  void guessInitialValues();
132  double eval(double *par, double x);
133 
134  private:
135  void init();
136  void calculateFitCurveData(double *X, double *Y);
137 };
138 #endif
PeakProfile d_profile
The peak profile.
Definition: MultiPeakFit.h:84
GaussAmpFit(ApplicationWindow *parent, QwtPlotCurve *)
Definition: MultiPeakFit.cpp:560
void customizeFitResults()
Customs and stores the fit results according to the derived class specifications. Used by exponential...
Definition: MultiPeakFit.cpp:212
void insertPeakFunctionCurve(int peak)
Inserts a peak function curve into the plot.
Definition: MultiPeakFit.cpp:220
Definition: MultiPeakFit.h:103
double evalPeak(double *par, double x, int peak)
Definition: MultiPeakFit.cpp:403
void setNumPeaks(int n)
Definition: MultiPeakFit.cpp:86
MultiPeakFit(ApplicationWindow *parent, QwtPlotCurve *c, PeakProfile profile=Gauss, int peaks=1)
Definition: MultiPeakFit.cpp:47
static QStringList generateParameterList(int order)
Definition: MultiPeakFit.cpp:105
PeakProfile profile()
Definition: MultiPeakFit.h:62
A 2D-plotting widget.
Definition: Graph.h:123
void guessInitialValues()
Used by the GaussFit and LorentzFit derived classes to calculate initial values for the parameters...
Definition: MultiPeakFit.cpp:177
Definition: MultiPeakFit.h:39
PeakProfile
Definition: MultiPeakFit.h:39
void generateFitCurve()
Adds the result curve to the plot.
Definition: MultiPeakFit.cpp:249
static QString peakFormula(int peakIndex, PeakProfile profile)
Definition: MultiPeakFit.cpp:160
void init()
Definition: MultiPeakFit.cpp:493
void enablePeakCurves(bool on)
Definition: MultiPeakFit.h:48
double eval(double *par, double x)
Calculates the data for the output fit curve.
Definition: MultiPeakFit.cpp:641
GaussFit(ApplicationWindow *parent, QwtPlotCurve *)
Definition: MultiPeakFit.cpp:506
Definition: MultiPeakFit.h:34
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
Definition: MultiPeakFit.h:39
void setPeakCurvesColor(const QColor &color)
Definition: MultiPeakFit.h:50
Fit base class.
Definition: Fit.h:44
int d_peaks
Number of peaks.
Definition: MultiPeakFit.h:75
void setPeakCurvesColor(int colorIndex)
Definition: MultiPeakFit.cpp:441
QtiPlot's main window.
Definition: ApplicationWindow.h:133
bool generate_peak_curves
Tells weather the peak curves should be displayed together with the best line fit.
Definition: MultiPeakFit.h:78
QColor d_peaks_color
Color for the peak curves.
Definition: MultiPeakFit.h:81
Definition: MultiPeakFit.h:119
void init()
Definition: MultiPeakFit.cpp:547
virtual double eval(double *par, double x)
Calculates the data for the output fit curve.
Definition: MultiPeakFit.cpp:394
static QStringList generateExplanationList(int order)
Definition: MultiPeakFit.cpp:121
int peaks()
Definition: MultiPeakFit.h:45
void init()
Definition: Fit.cpp:67
QString logFitInfo(int iterations, int status)
Output string added to the result log.
Definition: MultiPeakFit.cpp:414
void init()
Definition: MultiPeakFit.cpp:601
double * x()
Returns the x values of the input data set.
Definition: Filter.h:98
MDI window providing a spreadsheet table with column logic.
Definition: Table.h:57
static QString generateFormula(int order, PeakProfile profile)
Definition: MultiPeakFit.cpp:137
LorentzFit(ApplicationWindow *parent, QwtPlotCurve *)
Definition: MultiPeakFit.cpp:452
Definition: MultiPeakFit.h:87
void guessInitialValues()
Definition: MultiPeakFit.cpp:647