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, Tilman Hoener zu Siederdissen
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net
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, Graph *g = 0, PeakProfile profile = Gauss, int peaks = 1);
00041         MultiPeakFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol,
00042                      int startRow = 0, int endRow = -1, PeakProfile profile = Gauss, int peaks = 1);
00043 
00044         int peaks(){return d_peaks;};
00045         void setNumPeaks(int n);
00046 
00047         void enablePeakCurves(bool on){generate_peak_curves = on;};
00048         void setPeakCurvesColor(int colorIndex){d_peaks_color = colorIndex;};
00049 
00050         static QString generateFormula(int order, PeakProfile profile);
00051         static QStringList generateParameterList(int order);
00052         static QStringList generateExplanationList(int order);
00053 
00055         void guessInitialValues();
00056 
00057         virtual double eval(double *par, double x);
00058         double evalPeak(double *par, double x, int peak);
00059 
00060     private:
00061         void init(int);
00062 
00063         QString logFitInfo(int iterations, int status);
00064         void generateFitCurve();
00065         static QString peakFormula(int peakIndex, PeakProfile profile);
00067         void insertPeakFunctionCurve(double *x, double *y, int peak);
00068         void customizeFitResults();
00069 
00071         int d_peaks;
00072 
00074         bool generate_peak_curves;
00075 
00077         int d_peaks_color;
00078 
00080         PeakProfile d_profile;
00081 };
00082 
00083 class LorentzFit : public MultiPeakFit
00084 {
00085     Q_OBJECT
00086 
00087     public:
00088         LorentzFit(ApplicationWindow *parent, Graph *g);
00089         LorentzFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
00090         LorentzFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
00091         LorentzFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
00092 
00093     private:
00094         void init();
00095 };
00096 
00097 class GaussFit : public MultiPeakFit
00098 {
00099     Q_OBJECT
00100 
00101     public:
00102         GaussFit(ApplicationWindow *parent, Graph *g);
00103         GaussFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
00104         GaussFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
00105         GaussFit( ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
00106 
00107     private:
00108         void init();
00109 };
00110 
00111 class GaussAmpFit : public Fit
00112 {
00113     Q_OBJECT
00114 
00115     public:
00116         GaussAmpFit(ApplicationWindow *parent, Graph *g);
00117         GaussAmpFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle);
00118         GaussAmpFit(ApplicationWindow *parent, Graph *g, const QString& curveTitle, double start, double end);
00119         GaussAmpFit(ApplicationWindow *parent, Table *t, const QString& xCol, const QString& yCol, int startRow = 0, int endRow = -1);
00120 
00121         void guessInitialValues();
00122         double eval(double *par, double x);
00123 
00124     private:
00125         void init();
00126         void calculateFitCurveData(double *X, double *Y);
00127 };
00128 #endif

Generated on Tue Jun 17 08:36:11 2008 for QtiPlot by  doxygen 1.5.5