00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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