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, 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