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;};
105 
106  bool error(){return d_init_err;};
107  void setError(bool on = true){d_init_err = on;};
108 
109  virtual void enableGraphicsDisplay(bool on = true, Graph *g = 0);
110 
111  void setUpdateOutputGraph(bool update = true) {d_update_output_graph = update;};
112 
113  protected:
114  void init();
115  void memoryErrorMessage();
117  virtual void freeMemory();
118 
121  virtual int curveData(QwtPlotCurve *c, double start, double end, double **x, double **y);
123  virtual int sortedCurveData(QwtPlotCurve *c, double start, double end, double **x, double **y);
124 
125  int curveRange(QwtPlotCurve *c, double start, double end, int *iStart, int *iEnd);
126 
128  QwtPlotCurve* addResultCurve(double *x, double *y);
129 
131  int curveIndex(const QString& curveTitle, Graph *g);
132 
134  virtual QString logInfo(){return QString();};
135 
137  virtual void output();
138 
140  virtual void calculateOutputData(double *X, double *Y) { Q_UNUSED(X) Q_UNUSED(Y) };
141 
143 
146 
149 
152 
155 
157  int d_n;
158 
160  double *d_x;
161 
163  double *d_y;
164 
166  double d_tolerance;
167 
169  int d_points;
170 
172  QColor d_curveColor;
173 
176 
178  QwtPlotCurve *d_curve;
179 
181  int d_prec;
182 
185 
187  double d_from, d_to;
188 
191 
194 
196  QString d_explanation;
197 
200 
203 
204  QString d_y_col_name;
206 };
207 
208 #endif