QtiPlot  0.9.8.2
Filter.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : Filter.h
3  Project : QtiPlot
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
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
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. *
17  * *
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. *
22  * *
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 *
27  * *
28  ***************************************************************************/
29 #ifndef FILTER_H
30 #define FILTER_H
31 
32 #include <QObject>
33 
34 #include <ApplicationWindow.h>
35 
36 class MultiLayer;
37 class QwtPlotCurve;
38 class Graph;
39 class Table;
40 class Matrix;
41 
43 class Filter : public QObject
44 {
45  Q_OBJECT
46 
47  public:
48  Filter(ApplicationWindow *parent, Table *t = 0, const QString& name = QString());
49  Filter(ApplicationWindow *parent, Graph *g = 0, const QString& name = QString());
50  Filter(ApplicationWindow *parent, Matrix *m, const QString& name = QString());
51  Filter(ApplicationWindow *parent, QwtPlotCurve *c);
52  ~Filter();
53 
55  virtual bool run();
56 
57  virtual void setDataCurve(QwtPlotCurve *curve, double start, double end);
58  bool setDataFromCurve(QwtPlotCurve *c);
59  bool setDataFromCurve(QwtPlotCurve *c, double from, double to);
60  bool setDataFromCurve(const QString& curveTitle, Graph *g = 0);
61  bool setDataFromCurve(const QString& curveTitle, double from, double to, Graph *g = 0);
62 
63  virtual bool setDataFromTable(Table *, const QString&, const QString&, int = 1, int = -1, bool = false);
64 
66  void setInterval(double from, double to);
67 
69  void setTolerance(double eps){d_tolerance = eps;};
70 
72  void setColor(int colorId);
74  void setColor(const QColor& color){d_curveColor = color;};
76  void setColor(const QString& colorName);
77 
79  void setOutputPoints(int points){d_points = points;};
80 
82  void setOutputPrecision(int digits){d_prec = digits;};
83 
85  void setMaximumIterations(int iter){d_max_iterations = iter;};
86 
87  void setSortData(bool on = true){d_sort_data = on;}
88 
90  virtual void showLegend();
91 
93  virtual QString legendInfo(){return QString();};
94 
96  int dataSize(){return d_n;};
98  double* x(){return d_x;};
100  double* y(){return d_y;};
106  QwtPlotCurve *resultCurve(){return d_result_curve;};
107 
108  bool error(){return d_init_err;};
109  void setError(bool on = true){d_init_err = on;};
110 
111  virtual void enableGraphicsDisplay(bool on = true, Graph *g = 0);
112 
113  void setUpdateOutputGraph(bool update = true) {d_update_output_graph = update;};
114 
115  protected:
116  void init();
117  void memoryErrorMessage();
119  virtual void freeMemory();
120 
123  virtual int curveData(QwtPlotCurve *c, double start, double end, double **x, double **y);
125  virtual int sortedCurveData(QwtPlotCurve *c, double start, double end, double **x, double **y);
126 
127  int curveRange(QwtPlotCurve *c, double start, double end, int *iStart, int *iEnd);
128 
130  QwtPlotCurve* addResultCurve(double *x, double *y);
131 
133  int curveIndex(const QString& curveTitle, Graph *g);
134 
136  virtual QString logInfo(){return QString();};
137 
139  virtual void output();
140 
142  virtual void calculateOutputData(double *X, double *Y) { Q_UNUSED(X) Q_UNUSED(Y) };
143 
145 
148 
151 
154 
157 
159  int d_n;
160 
162  double *d_x;
163 
165  double *d_y;
166 
168  double d_tolerance;
169 
171  int d_points;
172 
174  QColor d_curveColor;
175 
178 
180  QwtPlotCurve *d_curve;
181 
183  QwtPlotCurve *d_result_curve;
184 
186  int d_prec;
187 
190 
192  double d_from, d_to;
193 
196 
199 
201  QString d_explanation;
202 
205 
208 
209  QString d_y_col_name;
211 };
212 
213 #endif