QtiPlot
0.9.8.2
|
00001 /*************************************************************************** 00002 File : Filter.h 00003 Project : QtiPlot 00004 -------------------------------------------------------------------- 00005 Copyright : (C) 2007 by Ion Vasilief 00006 Email (use @ for *) : ion_vasilief*yahoo.fr 00007 Description : Abstract base class for data analysis operations 00008 00009 ***************************************************************************/ 00010 00011 /*************************************************************************** 00012 * * 00013 * This program is free software; you can redistribute it and/or modify * 00014 * it under the terms of the GNU General Public License as published by * 00015 * the Free Software Foundation; either version 2 of the License, or * 00016 * (at your option) any later version. * 00017 * * 00018 * This program is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00021 * GNU General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU General Public License * 00024 * along with this program; if not, write to the Free Software * 00025 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 00026 * Boston, MA 02110-1301 USA * 00027 * * 00028 ***************************************************************************/ 00029 #ifndef FILTER_H 00030 #define FILTER_H 00031 00032 #include <QObject> 00033 00034 #include <ApplicationWindow.h> 00035 00036 class MultiLayer; 00037 class QwtPlotCurve; 00038 class Graph; 00039 class Table; 00040 class Matrix; 00041 00043 class Filter : public QObject 00044 { 00045 Q_OBJECT 00046 00047 public: 00048 Filter(ApplicationWindow *parent, Table *t = 0, const QString& name = QString()); 00049 Filter(ApplicationWindow *parent, Graph *g = 0, const QString& name = QString()); 00050 Filter(ApplicationWindow *parent, Matrix *m, const QString& name = QString()); 00051 Filter(ApplicationWindow *parent, QwtPlotCurve *c); 00052 ~Filter(); 00053 00055 virtual bool run(); 00056 00057 virtual void setDataCurve(QwtPlotCurve *curve, double start, double end); 00058 bool setDataFromCurve(QwtPlotCurve *c); 00059 bool setDataFromCurve(QwtPlotCurve *c, double from, double to); 00060 bool setDataFromCurve(const QString& curveTitle, Graph *g = 0); 00061 bool setDataFromCurve(const QString& curveTitle, double from, double to, Graph *g = 0); 00062 00063 virtual bool setDataFromTable(Table *, const QString&, const QString&, int = 1, int = -1, bool = false); 00064 00066 void setInterval(double from, double to); 00067 00069 void setTolerance(double eps){d_tolerance = eps;}; 00070 00072 void setColor(int colorId); 00074 void setColor(const QColor& color){d_curveColor = color;}; 00076 void setColor(const QString& colorName); 00077 00079 void setOutputPoints(int points){d_points = points;}; 00080 00082 void setOutputPrecision(int digits){d_prec = digits;}; 00083 00085 void setMaximumIterations(int iter){d_max_iterations = iter;}; 00086 00087 void setSortData(bool on = true){d_sort_data = on;} 00088 00090 virtual void showLegend(); 00091 00093 virtual QString legendInfo(){return QString();}; 00094 00096 int dataSize(){return d_n;}; 00098 double* x(){return d_x;}; 00100 double* y(){return d_y;}; 00102 Table *resultTable(){return d_result_table;}; 00104 Graph *outputGraph(){return d_output_graph;}; 00105 00106 bool error(){return d_init_err;}; 00107 void setError(bool on = true){d_init_err = on;}; 00108 00109 virtual void enableGraphicsDisplay(bool on = true, Graph *g = 0); 00110 00111 void setUpdateOutputGraph(bool update = true) {d_update_output_graph = update;}; 00112 00113 protected: 00114 void init(); 00115 void memoryErrorMessage(); 00117 virtual void freeMemory(); 00118 00121 virtual int curveData(QwtPlotCurve *c, double start, double end, double **x, double **y); 00123 virtual int sortedCurveData(QwtPlotCurve *c, double start, double end, double **x, double **y); 00124 00125 int curveRange(QwtPlotCurve *c, double start, double end, int *iStart, int *iEnd); 00126 00128 QwtPlotCurve* addResultCurve(double *x, double *y); 00129 00131 int curveIndex(const QString& curveTitle, Graph *g); 00132 00134 virtual QString logInfo(){return QString();}; 00135 00137 virtual void output(); 00138 00140 virtual void calculateOutputData(double *X, double *Y) { Q_UNUSED(X) Q_UNUSED(Y) }; 00141 00142 MultiLayer* createOutputGraph(); 00143 00145 Graph *d_graph; 00146 00148 Graph *d_output_graph; 00149 00151 Table *d_table; 00152 00154 Table *d_result_table; 00155 00157 int d_n; 00158 00160 double *d_x; 00161 00163 double *d_y; 00164 00166 double d_tolerance; 00167 00169 int d_points; 00170 00172 QColor d_curveColor; 00173 00175 int d_max_iterations; 00176 00178 QwtPlotCurve *d_curve; 00179 00181 int d_prec; 00182 00184 bool d_init_err; 00185 00187 double d_from, d_to; 00188 00190 bool d_sort_data; 00191 00193 int d_min_points; 00194 00196 QString d_explanation; 00197 00199 bool d_graphics_display; 00200 00202 bool d_update_output_graph; 00203 00204 QString d_y_col_name; 00205 Matrix *d_matrix; 00206 }; 00207 00208 #endif