~valavanisalex/ubuntu/maverick/scidavis/fix-604811

« back to all changes in this revision

Viewing changes to scidavis/src/PlotCurve.h

  • Committer: Bazaar Package Importer
  • Author(s): Ruben Molina
  • Date: 2009-09-06 11:34:04 UTC
  • Revision ID: james.westby@ubuntu.com-20090906113404-4awaey82l3686w4q
Tags: upstream-0.2.3
ImportĀ upstreamĀ versionĀ 0.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
35
//! Abstract 2D plot curve class
 
36
class PlotCurve: public QwtPlotCurve
 
37
{
 
38
 
 
39
public:
 
40
        PlotCurve(const char *name = 0): 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 char *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 void loadData();
 
74
 
 
75
        //! Returns the row index in the data source table corresponding to the data point index.
 
76
        int tableRow(int point);
 
77
 
 
78
        void remove();
 
79
 
 
80
        /**
 
81
                 * \brief A list of data sources for this curve.
 
82
                 *
 
83
                 * Elements must be in either of the following forms:
 
84
                 *  - &lt;id of X column> "(X)," &lt;id of Y column> "(Y)" [ "," &lt;id of error column> ("(xErr)" | "(yErr)") ]
 
85
                 *  - &lt;id of Xstart column> "(X)," &lt;id of Ystart column>"(Y)," &lt;id of Xend column> "(X)," &lt;id of Yend column> "(Y)"\n
 
86
                 *    (denoting start and end coordinates for the #VectXYXY style)
 
87
                 *  - &lt;id of Xstart column> "(X)," &lt;id of Ystart column> "(Y)," &lt;id of angle column> "(A)," &lt;id of magnitude column> "(M)"\n
 
88
                 *    (denoting start coordinates, angle in radians and length for the #VectXYAM style)
 
89
                 *
 
90
                 * Column ids are of the form '&lt;name of table> "_" &lt;name of column>'.
 
91
                 */
 
92
    virtual QString plotAssociation();
 
93
        virtual void updateColumnNames(const QString& oldName, const QString& newName, bool updateTableName);
 
94
 
 
95
        //! The list of attached error bars.
 
96
        QList<DataCurve *> errorBarsList(){return d_error_bars;};
 
97
        //! Adds a single error bars curve to the list of attached error bars.
 
98
        void addErrorBars(DataCurve *c){if (c) d_error_bars << c;};
 
99
        //! Remove a single error bars curve from the list of attached error bars.
 
100
        void removeErrorBars(DataCurve *c);
 
101
        //! Clears the list of attached error bars.
 
102
        void clearErrorBars();
 
103
 
 
104
        void setVisible(bool on);
 
105
 
 
106
        bool hasSelectedLabels();
 
107
        void setLabelsSelected(bool on = true);
 
108
 
 
109
protected:
 
110
        //! List of the error bar curves associated to this curve.
 
111
        QList <DataCurve *> d_error_bars;
 
112
        //! The data source table.
 
113
        Table *d_table;
 
114
        //!\brief The name of the column used for abscissae values.
 
115
        /*
 
116
         *The column name used for Y values is stored in title().text().
 
117
         */
 
118
        QString d_x_column;
 
119
 
 
120
        int d_start_row;
 
121
        int d_end_row;
 
122
        bool validCurveType();
 
123
};
 
124
#endif