Filter.h
Go to the documentation of this file.
/***************************************************************************
File : Filter.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2007 by Ion Vasilief
Email (use @ for *) : ion_vasilief*yahoo.fr
Description : Abstract base class for data analysis operations
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef FILTER_H
#define FILTER_H
#include <QObject>
#include <ApplicationWindow.h>
class MultiLayer;
class QwtPlotCurve;
class Graph;
class Table;
class Matrix;
class Filter : public QObject
{
Q_OBJECT
public:
Filter(ApplicationWindow *parent, Table *t = 0, const QString& name = QString());
Filter(ApplicationWindow *parent, Graph *g = 0, const QString& name = QString());
Filter(ApplicationWindow *parent, Matrix *m, const QString& name = QString());
Filter(ApplicationWindow *parent, QwtPlotCurve *c);
~Filter();
virtual bool run();
virtual void setDataCurve(QwtPlotCurve *curve, double start, double end);
bool setDataFromCurve(QwtPlotCurve *c);
bool setDataFromCurve(QwtPlotCurve *c, double from, double to);
bool setDataFromCurve(const QString& curveTitle, Graph *g = 0);
bool setDataFromCurve(const QString& curveTitle, double from, double to, Graph *g = 0);
virtual bool setDataFromTable(Table *, const QString&, const QString&, int = 1, int = -1, bool = false);
void setInterval(double from, double to);
void setTolerance(double eps){d_tolerance = eps;};
void setColor(int colorId);
void setColor(const QColor& color){d_curveColor = color;};
void setColor(const QString& colorName);
void setOutputPoints(int points){d_points = points;};
void setOutputPrecision(int digits){d_prec = digits;};
void setMaximumIterations(int iter){d_max_iterations = iter;};
void setSortData(bool on = true){d_sort_data = on;}
virtual void showLegend();
virtual QString legendInfo(){return QString();};
int dataSize(){return d_n;};
double* x(){return d_x;};
double* y(){return d_y;};
Table *resultTable(){return d_result_table;};
Graph *outputGraph(){return d_output_graph;};
QwtPlotCurve *resultCurve(){return d_result_curve;};
bool error(){return d_init_err;};
void setError(bool on = true){d_init_err = on;};
virtual void enableGraphicsDisplay(bool on = true, Graph *g = 0);
void setUpdateOutputGraph(bool update = true) {d_update_output_graph = update;};
protected:
void init();
void memoryErrorMessage();
virtual void freeMemory();
virtual int curveData(QwtPlotCurve *c, double start, double end, double **x, double **y);
virtual int sortedCurveData(QwtPlotCurve *c, double start, double end, double **x, double **y);
int curveRange(QwtPlotCurve *c, double start, double end, int *iStart, int *iEnd);
QwtPlotCurve* addResultCurve(double *x, double *y);
int curveIndex(const QString& curveTitle, Graph *g);
virtual QString logInfo(){return QString();};
virtual void output();
virtual void calculateOutputData(double *X, double *Y) { Q_UNUSED(X) Q_UNUSED(Y) };
MultiLayer* createOutputGraph();
Graph *d_graph;
Graph *d_output_graph;
Table *d_table;
Table *d_result_table;
int d_n;
double *d_x;
double *d_y;
double d_tolerance;
int d_points;
QColor d_curveColor;
int d_max_iterations;
QwtPlotCurve *d_curve;
QwtPlotCurve *d_result_curve;
int d_prec;
bool d_init_err;
double d_from, d_to;
bool d_sort_data;
int d_min_points;
QString d_explanation;
bool d_graphics_display;
bool d_update_output_graph;
QString d_y_col_name;
Matrix *d_matrix;
};
#endif
Filter::d_x
double * d_x
x data set to be analysed
Definition: Filter.h:162
Filter::setColor
void setColor(const QColor &color)
Sets the color of the output fit curve.
Definition: Filter.h:74
Filter::d_curve
QwtPlotCurve * d_curve
The curve to be analysed.
Definition: Filter.h:180
MultiLayer
An MDI window (MdiSubWindow) managing one or more Graph objects.
Definition: MultiLayer.h:64
Filter::d_init_err
bool d_init_err
Error flag telling if something went wrong during the initialization phase.
Definition: Filter.h:189
Filter::d_prec
int d_prec
Precision (number of significant digits) used for the results output.
Definition: Filter.h:186
Filter::~Filter
~Filter()
Definition: Filter.cpp:628
Filter::d_y
double * d_y
y data set to be analysed
Definition: Filter.h:165
Filter::d_matrix
Matrix * d_matrix
Definition: Filter.h:210
Filter::d_min_points
int d_min_points
Minimum number of data points necessary to perform the operation.
Definition: Filter.h:198
Filter::createOutputGraph
MultiLayer * createOutputGraph()
Definition: Filter.cpp:501
Filter::dataSize
int dataSize()
Returns the size of the input data set.
Definition: Filter.h:96
Filter::d_y_col_name
QString d_y_col_name
Definition: Filter.h:209
Graph
A 2D-plotting widget.
Definition: Graph.h:123
Filter::setColor
void setColor(int colorId)
Obsolete: sets the color of the output fit curve.
Definition: Filter.cpp:227
Filter::Filter
Filter(ApplicationWindow *parent, Table *t=0, const QString &name=QString())
Definition: Filter.cpp:63
Filter::setInterval
void setInterval(double from, double to)
Changes the data range if the source curve was already assigned. Provided for convenience.
Definition: Filter.cpp:103
Filter::curveIndex
int curveIndex(const QString &curveTitle, Graph *g)
Performs checks and returns the index of the source data curve if OK, -1 otherwise.
Definition: Filter.cpp:144
Filter::showLegend
virtual void showLegend()
Adds a new legend to the plot. Calls virtual legendInfo()
Definition: Filter.cpp:251
Filter::calculateOutputData
virtual void calculateOutputData(double *X, double *Y)
Calculates the data for the output curve and store it in the X an Y vectors.
Definition: Filter.h:142
Filter
Abstract base class for data analysis operations.
Definition: Filter.h:43
Filter::logInfo
virtual QString logInfo()
Output string added to the log pannel of the application.
Definition: Filter.h:136
Filter::d_from
double d_from
Data interval.
Definition: Filter.h:192
Filter::d_update_output_graph
bool d_update_output_graph
Specifies if the filter should update the output graph.
Definition: Filter.h:207
Filter::curveRange
int curveRange(QwtPlotCurve *c, double start, double end, int *iStart, int *iEnd)
Definition: Filter.cpp:403
Filter::error
bool error()
Definition: Filter.h:108
Filter::setDataCurve
virtual void setDataCurve(QwtPlotCurve *curve, double start, double end)
Definition: Filter.cpp:113
Filter::d_sort_data
bool d_sort_data
Specifies if the filter needs sorted data as input.
Definition: Filter.h:195
Filter::setOutputPoints
void setOutputPoints(int points)
Sets the number of points in the output curve.
Definition: Filter.h:79
Filter::resultTable
Table * resultTable()
Returns a pointer to the table created to display the results.
Definition: Filter.h:102
Filter::setDataFromTable
virtual bool setDataFromTable(Table *, const QString &, const QString &, int=1, int=-1, bool=false)
Definition: Filter.cpp:514
Filter::d_table
Table * d_table
A table source of data.
Definition: Filter.h:153
Filter::output
virtual void output()
Performs the data analysis and takes care of the output.
Definition: Filter.cpp:295
Filter::d_to
double d_to
Definition: Filter.h:192
Filter::init
void init()
Definition: Filter.cpp:79
Filter::d_n
int d_n
Size of the data arrays.
Definition: Filter.h:159
Filter::freeMemory
virtual void freeMemory()
Frees the memory allocated for the X and Y data sets.
Definition: Filter.cpp:616
Filter::d_points
int d_points
Number of result points to de calculated and displayed in the output curve.
Definition: Filter.h:171
Filter::d_graph
Graph * d_graph
The source graph with the curve to be analyzed.
Definition: Filter.h:147
ApplicationWindow
QtiPlot&#39;s main window.
Definition: ApplicationWindow.h:133
Filter::d_tolerance
double d_tolerance
GSL Tolerance, if ever needed...
Definition: Filter.h:168
Filter::d_result_curve
QwtPlotCurve * d_result_curve
The resulting curve.
Definition: Filter.h:183
Filter::d_max_iterations
int d_max_iterations
Maximum number of iterations per fit.
Definition: Filter.h:177
Filter::setUpdateOutputGraph
void setUpdateOutputGraph(bool update=true)
Definition: Filter.h:113
Matrix
Matrix worksheet class.
Definition: Matrix.h:57
Filter::setSortData
void setSortData(bool on=true)
Definition: Filter.h:87
Filter::memoryErrorMessage
void memoryErrorMessage()
Definition: Filter.cpp:605
Filter::d_graphics_display
bool d_graphics_display
Specifies if the filter should display a result curve.
Definition: Filter.h:204
Filter::setDataFromCurve
bool setDataFromCurve(QwtPlotCurve *c)
Definition: Filter.cpp:166
Filter::d_result_table
Table * d_result_table
The table displaying the results of the filtering operation (not alvays valid!)
Definition: Filter.h:156
Filter::curveData
virtual int curveData(QwtPlotCurve *c, double start, double end, double **x, double **y)
Definition: Filter.cpp:367
Filter::run
virtual bool run()
Actually does the job. Should be reimplemented in derived classes.
Definition: Filter.cpp:270
Filter::enableGraphicsDisplay
virtual void enableGraphicsDisplay(bool on=true, Graph *g=0)
Definition: Filter.cpp:490
Filter::setTolerance
void setTolerance(double eps)
Sets the tolerance used by the GSL routines.
Definition: Filter.h:69
Filter::setOutputPrecision
void setOutputPrecision(int digits)
Sets the precision used for the output.
Definition: Filter.h:82
Filter::addResultCurve
QwtPlotCurve * addResultCurve(double *x, double *y)
Adds the result curve to the target output plot window. Creates a hidden table and frees the input da...
Definition: Filter.cpp:445
Filter::d_output_graph
Graph * d_output_graph
The graph where the result curve should be displayed.
Definition: Filter.h:150
Filter::x
double * x()
Returns the x values of the input data set.
Definition: Filter.h:98
Filter::y
double * y()
Returns the y values of the input data set.
Definition: Filter.h:100
Filter::d_explanation
QString d_explanation
String explaining the operation in the comment of the result table and in the project explorer...
Definition: Filter.h:201
Table
MDI window providing a spreadsheet table with column logic.
Definition: Table.h:57
ApplicationWindow.h
Filter::sortedCurveData
virtual int sortedCurveData(QwtPlotCurve *c, double start, double end, double **x, double **y)
Same as curveData, but sorts the points by their x value.
Definition: Filter.cpp:316
Filter::legendInfo
virtual QString legendInfo()
Output string added to the plot as a new legend.
Definition: Filter.h:93
Filter::setMaximumIterations
void setMaximumIterations(int iter)
Sets the maximum number of iterations to be performed during an iterative session.
Definition: Filter.h:85
Filter::d_curveColor
QColor d_curveColor
Color index of the result curve.
Definition: Filter.h:174
Filter::outputGraph
Graph * outputGraph()
Returns a pointer to the graph where the result curve should be displayed.
Definition: Filter.h:104
Filter::resultCurve
QwtPlotCurve * resultCurve()
Returns a pointer to the plot curve created to display the results.
Definition: Filter.h:106
Filter::setError
void setError(bool on=true)
Definition: Filter.h:109