QtiPlot  0.9.8.2
VectorCurve.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : VectorCurve.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2006 - 2010 by Ion Vasilief
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : Vector curve class
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 VECTORCURVE_H
30 #define VECTORCURVE_H
31 
32 #include "PlotCurve.h"
33 #include <qwt_plot.h>
34 
35 class QwtPlot;
36 
38 class VectorCurve: public DataCurve
39 {
40 public:
42 
43  VectorCurve(VectorStyle style, Table *t, const QString& xColName, const char *name,
44  const QString& endCol1, const QString& endCol2, int startRow, int endRow);
45  ~VectorCurve();
46 
48 
49  void copy(const VectorCurve *vc);
50 
51  QwtDoubleRect boundingRect() const;
52 
53  QString vectorEndXAColName(){return d_end_x_a;};
54  QString vectorEndYMColName(){return d_end_y_m;};
55  void setVectorEnd(const QString& xColName, const QString& yColName);
56 
57  double width();
58  void setWidth(double w);
59 
60  QColor color();
61  void setColor(const QColor& c);
62 
63  int headLength(){return d_headLength;};
64  void setHeadLength(int l);
65 
66  int headAngle(){return d_headAngle;};
67  void setHeadAngle(int a);
68 
69  bool filledArrowHead(){return filledArrow;};
70  void fillArrowHead(bool fill);
71 
72  int position(){return d_position;};
73  void setPosition(int pos){d_position = pos;};
74 
75  int vectorStyle(){return d_style;};
76  void setVectorStyle(int style){d_style = style;};
77 
78  bool updateData(Table *t, const QString& colName);
79  void loadData();
80 
81  QStringList plotAssociation();
82  void updateColumnNames(const QString& oldName, const QString& newName, bool updateTableName);
83 
84  QPen vectorPen(){return d_pen;};
85  void setVectorPen(const QPen& pen){d_pen = pen;};
86 
87 private:
88  void setVectorEnd(const QwtArray<double>&x, const QwtArray<double>&y);
89 
90  void draw(QPainter *painter,const QwtScaleMap &xMap,
91  const QwtScaleMap &yMap, int from, int to) const;
92 
93  void drawVector(QPainter *painter, const QwtScaleMap &xMap,
94  const QwtScaleMap &yMap, int from, int to) const;
95 
96  void drawArrowHead(QPainter *p, int xs, int ys, int xe, int ye) const;
97  double theta(int x0, int y0, int x1, int y1) const;
98 
99 protected:
100  QPen d_pen;
103  QString d_end_x_a;
104  QString d_end_y_m;
105  QwtArrayData *vectorEnd;
106 };
107 
108 #endif