QtiPlot 0.9.7.3

MultiPeakFit.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : MultiPeakFit.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 by Ion Vasilief
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr
00007     Description          : MultiPeakFit module with Lorentz and Gauss peak shapes
00008 
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *  This program is free software; you can redistribute it and/or modify   *
00014  *  it under the terms of the GNU General Public License as published by   *
00015  *  the Free Software Foundation; either version 2 of the License, or      *
00016  *  (at your option) any later version.                                    *
00017  *                                                                         *
00018  *  This program is distributed in the hope that it will be useful,        *
00019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
00020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
00021  *  GNU General Public License for more details.                           *
00022  *                                                                         *
00023  *   You should have received a copy of the GNU General Public License     *
00024  *   along with this program; if not, write to the Free Software           *
00025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
00026  *   Boston, MA  02110-1301  USA                                           *
00027  *                                                                         *
00028  ***************************************************************************/
00029 #ifndef MULTIPEAKFIT_H
00030 #define MULTIPEAKFIT_H
00031 
00032 #include "Fit.h"
00033 
00034 class MultiPeakFit : public Fit
00035 {
00036     Q_OBJECT
00037 
00038     public:
00039         enum PeakProfile{Gauss, Lorentz};
00040         MultiPeakFit(ApplicationWindow *parent, QwtPlotCurve *c, PeakProfile profile = Gauss, int peaks = 1);
00041         MultiPeakFit(ApplicationWindow *parent, Graph *g = 0, PeakProfile profile = Gauss, int peaks = 1);
00042         MultiPeakFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol,
00043                      int startRow = 0, int endRow = -1, PeakProfile profile = Gauss, int peaks = 1);
00044 
00045         int peaks(){return d_peaks;};
00046         void setNumPeaks(int n);
00047 
00048         void enablePeakCurves(bool on){generate_peak_curves = on;};
00049         void setPeakCurvesColor(int colorIndex);
00050         void setPeakCurvesColor(const QColor& color){d_peaks_color = color;};
00051 
00052         static QString generateFormula(int order, PeakProfile profile);
00053         static QStringList generateParameterList(int order);
00054         static QStringList generateExplanationList(int order);
00055 
00057         void guessInitialValues();
00058 
00059         virtual double eval(double *par, double x);
00060         double evalPeak(double *par, double x, int peak);
00061 
00062         PeakProfile profile(){return d_profile;};
00063 
00064     private:
00065         void init(int);
00066 
00067         QString logFitInfo(int iterations, int status);
00068         void generateFitCurve();
00069         static QString peakFormula(int peakIndex, PeakProfile profile);
00071         void insertPeakFunctionCurve(int peak);
00072         void customizeFitResults();
00073 
00075         int d_peaks;
00076 
00078         bool generate_peak_curves;
00079 
00081         QColor d_peaks_color;
00082 
00084         PeakProfile d_profile;
00085 };
00086 
00087 class LorentzFit : public MultiPeakFit
00088 {
00089     Q_OBJECT
00090 
00091     public:
00092         LorentzFit(ApplicationWindow *parent, QwtPlotCurve *);
00093         LorentzFit(ApplicationWindow *parent, QwtPlotCurve *, double, double);
00094         LorentzFit(ApplicationWindow *parent, Graph *g);
00095         LorentzFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
00096         LorentzFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
00097         LorentzFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
00098 
00099     private:
00100         void init();
00101 };
00102 
00103 class GaussFit : public MultiPeakFit
00104 {
00105     Q_OBJECT
00106 
00107     public:
00108         GaussFit(ApplicationWindow *parent, QwtPlotCurve *);
00109         GaussFit(ApplicationWindow *parent, QwtPlotCurve *, double, double);
00110         GaussFit(ApplicationWindow *parent, Graph *g);
00111         GaussFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
00112         GaussFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
00113         GaussFit( ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
00114 
00115     private:
00116         void init();
00117 };
00118 
00119 class GaussAmpFit : public Fit
00120 {
00121     Q_OBJECT
00122 
00123     public:
00124         GaussAmpFit(ApplicationWindow *parent, QwtPlotCurve *);
00125         GaussAmpFit(ApplicationWindow *parent, QwtPlotCurve *, double, double);
00126         GaussAmpFit(ApplicationWindow *parent, Graph *g);
00127         GaussAmpFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
00128         GaussAmpFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
00129         GaussAmpFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
00130 
00131         void guessInitialValues();
00132         double eval(double *par, double x);
00133 
00134     private:
00135         void init();
00136         void calculateFitCurveData(double *X, double *Y);
00137 };
00138 #endif