QtiPlot
0.9.8.2
|
00001 /*************************************************************************** 00002 File : VectorCurve.h 00003 Project : QtiPlot 00004 -------------------------------------------------------------------- 00005 Copyright : (C) 2006 - 2010 by Ion Vasilief 00006 Email (use @ for *) : ion_vasilief*yahoo.fr 00007 Description : Vector curve class 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 VECTORCURVE_H 00030 #define VECTORCURVE_H 00031 00032 #include "PlotCurve.h" 00033 #include <qwt_plot.h> 00034 00035 class QwtPlot; 00036 00038 class VectorCurve: public DataCurve 00039 { 00040 public: 00041 enum VectorStyle{XYXY, XYAM}; 00042 00043 VectorCurve(VectorStyle style, Table *t, const QString& xColName, const char *name, 00044 const QString& endCol1, const QString& endCol2, int startRow, int endRow); 00045 ~VectorCurve(); 00046 00047 enum Position{Tail, Middle, Head}; 00048 00049 void copy(const VectorCurve *vc); 00050 00051 QwtDoubleRect boundingRect() const; 00052 00053 QString vectorEndXAColName(){return d_end_x_a;}; 00054 QString vectorEndYMColName(){return d_end_y_m;}; 00055 void setVectorEnd(const QString& xColName, const QString& yColName); 00056 00057 double width(); 00058 void setWidth(double w); 00059 00060 QColor color(); 00061 void setColor(const QColor& c); 00062 00063 int headLength(){return d_headLength;}; 00064 void setHeadLength(int l); 00065 00066 int headAngle(){return d_headAngle;}; 00067 void setHeadAngle(int a); 00068 00069 bool filledArrowHead(){return filledArrow;}; 00070 void fillArrowHead(bool fill); 00071 00072 int position(){return d_position;}; 00073 void setPosition(int pos){d_position = pos;}; 00074 00075 int vectorStyle(){return d_style;}; 00076 void setVectorStyle(int style){d_style = style;}; 00077 00078 bool updateData(Table *t, const QString& colName); 00079 void loadData(); 00080 00081 QStringList plotAssociation(); 00082 void updateColumnNames(const QString& oldName, const QString& newName, bool updateTableName); 00083 00084 QPen vectorPen(){return d_pen;}; 00085 void setVectorPen(const QPen& pen){d_pen = pen;}; 00086 00087 private: 00088 void setVectorEnd(const QwtArray<double>&x, const QwtArray<double>&y); 00089 00090 void draw(QPainter *painter,const QwtScaleMap &xMap, 00091 const QwtScaleMap &yMap, int from, int to) const; 00092 00093 void drawVector(QPainter *painter, const QwtScaleMap &xMap, 00094 const QwtScaleMap &yMap, int from, int to) const; 00095 00096 void drawArrowHead(QPainter *p, int xs, int ys, int xe, int ye) const; 00097 double theta(int x0, int y0, int x1, int y1) const; 00098 00099 protected: 00100 QPen d_pen; 00101 bool filledArrow; 00102 int d_style, d_headLength, d_headAngle, d_position; 00103 QString d_end_x_a; 00104 QString d_end_y_m; 00105 QwtArrayData *vectorEnd; 00106 }; 00107 00108 #endif