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){d_peaks_color = colorIndex;};
00050 
00051         static QString generateFormula(int order, PeakProfile profile);
00052         static QStringList generateParameterList(int order);
00053         static QStringList generateExplanationList(int order);
00054 
00056         void guessInitialValues();
00057 
00058         virtual double eval(double *par, double x);
00059         double evalPeak(double *par, double x, int peak);
00060 
00061         PeakProfile profile(){return d_profile;};
00062 
00063     private:
00064         void init(int);
00065 
00066         QString logFitInfo(int iterations, int status);
00067         void generateFitCurve();
00068         static QString peakFormula(int peakIndex, PeakProfile profile);
00070         void insertPeakFunctionCurve(int peak);
00071         void customizeFitResults();
00072 
00074         int d_peaks;
00075 
00077         bool generate_peak_curves;
00078 
00080         int d_peaks_color;
00081 
00083         PeakProfile d_profile;
00084 };
00085 
00086 class LorentzFit : public MultiPeakFit
00087 {
00088     Q_OBJECT
00089 
00090     public:
00091         LorentzFit(ApplicationWindow *parent, QwtPlotCurve *);
00092         LorentzFit(ApplicationWindow *parent, QwtPlotCurve *, double, double);
00093         LorentzFit(ApplicationWindow *parent, Graph *g);
00094         LorentzFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
00095         LorentzFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
00096         LorentzFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
00097 
00098     private:
00099         void init();
00100 };
00101 
00102 class GaussFit : public MultiPeakFit
00103 {
00104     Q_OBJECT
00105 
00106     public:
00107         GaussFit(ApplicationWindow *parent, QwtPlotCurve *);
00108         GaussFit(ApplicationWindow *parent, QwtPlotCurve *, double, double);
00109         GaussFit(ApplicationWindow *parent, Graph *g);
00110         GaussFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
00111         GaussFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
00112         GaussFit( ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
00113 
00114     private:
00115         void init();
00116 };
00117 
00118 class GaussAmpFit : public Fit
00119 {
00120     Q_OBJECT
00121 
00122     public:
00123         GaussAmpFit(ApplicationWindow *parent, QwtPlotCurve *);
00124         GaussAmpFit(ApplicationWindow *parent, QwtPlotCurve *, double, double);
00125         GaussAmpFit(ApplicationWindow *parent, Graph *g);
00126         GaussAmpFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
00127         GaussAmpFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
00128         GaussAmpFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
00129 
00130         void guessInitialValues();
00131         double eval(double *par, double x);
00132 
00133     private:
00134         void init();
00135         void calculateFitCurveData(double *X, double *Y);
00136 };
00137 #endif

Generated by  doxygen 1.6.2