SciDAVis  1.D4
PlotCurve.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : PlotCurve.h
3  Project : SciDAVis
4  --------------------------------------------------------------------
5  Copyright : (C) 2007 by Ion Vasilief
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : AbstractPlotCurve and DataCurve classes
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 PLOTCURVE_H
30 #define PLOTCURVE_H
31 
32 #include <qwt_plot_curve.h>
33 #include "Table.h"
34 
36 class PlotCurve: public QwtPlotCurve
37 {
38 
39 public:
40  PlotCurve(const QString &name = QString::null): QwtPlotCurve(name), d_type(0){};
41 
42  int type() const {return d_type;};
43  void setType(int t){d_type = t;};
44 
45  QwtDoubleRect boundingRect() const;
46 
47 protected:
48  int d_type;
49 };
50 
51 class DataCurve: public PlotCurve
52 {
53 
54 public:
55  DataCurve(Table *t, const QString& xColName, const QString &name, int startRow = 0, int endRow = -1);
56 
57  QString xColumnName(){return d_x_column;};
58  void setXColumnName(const QString& name){d_x_column = name;};
59 
60  QString yColumnName() { return title().text(); }
61  void setYColumnName(const QString& name) { setTitle(name); }
62 
63  Table* table(){return d_table;};
64 
65  int startRow(){return d_start_row;};
66  int endRow(){return d_end_row;};
67  void setRowRange(int startRow, int endRow);
68 
69  bool isFullRange();
70  void setFullRange();
71 
72  virtual bool updateData(Table *t, const QString& colName);
73  virtual bool loadData();
74  QList< QVector<double> > convertData(const QList<Column*> &cols, const QList<int> &axes) const;
75 
77  int tableRow(int point);
78 
79  void remove();
80 
93  virtual QString plotAssociation();
94  virtual void updateColumnNames(const QString& oldName, const QString& newName, bool updateTableName);
95 
97  QList<DataCurve *> errorBarsList(){return d_error_bars;};
99  void addErrorBars(DataCurve *c){if (c) d_error_bars << c;};
101  void removeErrorBars(DataCurve *c);
103  void clearErrorBars();
104 
105  void setVisible(bool on);
106 
107  bool hasSelectedLabels();
108  void setLabelsSelected(bool on = true);
109 
110 protected:
114  QList <DataCurve *> d_error_bars;
116  /*
117  *The column name used for Y values is stored in title().text().
118  */
119  QString d_x_column;
124 
125 private:
126 
137  mutable QVector<int> d_index_to_row;
138  bool validCurveType();
139 };
140 #endif