1
/***************************************************************************
4
--------------------------------------------------------------------
5
Copyright : (C) 2006 by Ion Vasilief, Tilman Benkert
6
Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net
7
Description : MultiPeakFit module with Lorentz and Gauss peak shapes
9
***************************************************************************/
11
/***************************************************************************
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. *
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. *
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 *
28
***************************************************************************/
29
#ifndef MULTIPEAKFIT_H
30
#define MULTIPEAKFIT_H
34
class MultiPeakFit : public Fit
39
enum PeakProfile{Gauss, Lorentz};
40
MultiPeakFit(ApplicationWindow *parent, Graph *g = 0, PeakProfile profile = Gauss, int peaks = 1);
42
int peaks(){return d_peaks;};
43
void setNumPeaks(int n);
45
void enablePeakCurves(bool on){generate_peak_curves = on;};
46
void setPeakCurvesColor(int colorIndex){d_peaks_color = colorIndex;};
48
static QString generateFormula(int order, PeakProfile profile);
49
static QStringList generateParameterList(int order);
50
static QStringList generateExplanationList(int order);
53
QString logFitInfo(double *par, int iterations, int status, const QString& plotName);
54
void generateFitCurve(double *par);
55
static QString peakFormula(int peakIndex, PeakProfile profile);
56
//! Inserts a peak function curve into the plot
57
void insertPeakFunctionCurve(double *x, double *y, int peak);
58
void storeCustomFitResults(double *par);
60
//! Used by the GaussFit and LorentzFit derived classes to calculate initial values for the parameters
61
void guessInitialValues();
66
//! Tells weather the peak curves should be displayed together with the best line fit.
67
bool generate_peak_curves;
69
//! Color index for the peak curves
73
PeakProfile d_profile;
76
class LorentzFit : public MultiPeakFit
81
LorentzFit(ApplicationWindow *parent, Graph *g);
82
LorentzFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
83
LorentzFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
89
class GaussFit : public MultiPeakFit
94
GaussFit(ApplicationWindow *parent, Graph *g);
95
GaussFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
96
GaussFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
102
class GaussAmpFit : public Fit
107
GaussAmpFit(ApplicationWindow *parent, Graph *g);
108
GaussAmpFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
109
GaussAmpFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
113
void calculateFitCurveData(double *par, double *X, double *Y);