1
/***************************************************************************
4
--------------------------------------------------------------------
5
Copyright : (C) 2007 by Ion Vasilief
6
Email (use @ for *) : ion_vasilief*yahoo.fr
7
Description : Abstract base class for data analysis operations
9
***************************************************************************/
11
/***************************************************************************
13
* This program is free software; you can redistribute it and/or modify *
14
* it under the terms of the GNU General Public License as published by *
15
* the Free Software Foundation; either version 2 of the License, or *
16
* (at your option) any later version. *
18
* This program is distributed in the hope that it will be useful, *
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21
* GNU General Public License for more details. *
23
* You should have received a copy of the GNU General Public License *
24
* along with this program; if not, write to the Free Software *
25
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26
* Boston, MA 02110-1301 USA *
28
***************************************************************************/
34
#include "ApplicationWindow.h"
40
//! Abstract base class for data analysis operations
41
class Filter : public QObject
46
Filter(ApplicationWindow *parent, Table *t = 0, const char * name = 0);
47
Filter(ApplicationWindow *parent, Graph *g = 0, const char * name = 0);
50
//! Actually does the job. Should be reimplemented in derived classes.
53
virtual void setDataCurve(int curve, double start, double end);
54
bool setDataFromCurve(const QString& curveTitle, Graph *g = 0);
55
bool setDataFromCurve(const QString& curveTitle, double from, double to, Graph *g = 0);
57
//! Changes the data range if the source curve was already assigned. Provided for convenience.
58
void setInterval(double from, double to);
60
//! Sets the tolerance used by the GSL routines
61
void setTolerance(double eps){d_tolerance = eps;};
63
//! Sets the color of the output fit curve.
64
void setColor(int colorId){d_curveColorIndex = colorId;};
66
//! Sets the color of the output fit curve. Provided for convenience. To be used in scripts only!
67
void setColor(const QString& colorName);
69
//! Sets the number of points in the output curve
70
void setOutputPoints(int points){d_points = points;};
72
//! Sets the precision used for the output
73
void setOutputPrecision(int digits){d_prec = digits;};
75
//! Sets the maximum number of iterations to be performed during an iterative session
76
void setMaximumIterations(int iter){d_max_iterations = iter;};
78
//! Adds a new legend to the plot. Calls virtual legendInfo()
79
virtual void showLegend();
81
//! Output string added to the plot as a new legend
82
virtual QString legendInfo(){return QString();};
84
//! Returns the size of the fitted data set
85
int dataSize(){return d_n;};
87
bool error(){return d_init_err;};
92
//! Sets x and y to the curve points between start and end. Memory will be allocated with new double[].
93
//! Returns the number of points within range == size of x and y arrays.
94
virtual int curveData(QwtPlotCurve *c, double start, double end, double **x, double **y);
95
//! Same as curveData, but sorts the points by their x value.
96
virtual int sortedCurveData(QwtPlotCurve *c, double start, double end, double **x, double **y);
98
//! Adds the result curve to the target output plot window. Creates a hidden table and frees the input data from memory.
99
QwtPlotCurve* addResultCurve(double *x, double *y);
101
//! Performs checks and returns the index of the source data curve if OK, -1 otherwise
102
int curveIndex(const QString& curveTitle, Graph *g);
104
//! Output string added to the log pannel of the application
105
virtual QString logInfo(){return QString();};
107
//! Performs the data analysis and takes care of the output
108
virtual void output();
110
//! Calculates the data for the output curve and store it in the X an Y vectors
111
virtual void calculateOutputData(double *X, double *Y) { Q_UNUSED(X) Q_UNUSED(Y) };
113
//! The graph where the result curve should be displayed
116
//! A table source of data
119
//! Size of the data arrays
122
//! x data set to be analysed
125
//! y data set to be analysed
128
//! GSL Tolerance, if ever needed...
131
//! Number of result points to de calculated and displayed in the output curve
134
//! Color index of the result curve
135
int d_curveColorIndex;
137
//! Maximum number of iterations per fit
138
int d_max_iterations;
140
//! The curve to be analysed
141
QwtPlotCurve *d_curve;
143
//! Precision (number of significant digits) used for the results output
146
//! Error flag telling if something went wrong during the initialization phase.
152
//! Specifies if the filter needs sorted data as input
155
//! Minimum number of data points necessary to perform the operation
158
//! String explaining the operation in the comment of the result table and in the project explorer
159
QString d_explanation;