QtiPlot  0.9.8.2
ArrowMarker.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : ArrowMarker.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2006 - 2011 by Ion Vasilief
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : Arrow marker (extension to QwtPlotMarker)
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 ARROWMARKER_H
30 #define ARROWMARKER_H
31 
32 #include <qwt_plot_marker.h>
33 
43 class ArrowMarker: public QObject, public QwtPlotMarker
44 {
45 public:
48  ArrowMarker();
49 
51  QPoint startPoint() const;
53  void setStartPoint(const QPoint& p);
54 
56  QPoint endPoint() const;
58  void setEndPoint(const QPoint& p);
59 
61  QwtDoublePoint startPointCoord();
63  void setStartPoint(double x, double y);
64 
66  QwtDoublePoint endPointCoord();
68  void setEndPoint(double x, double y);
69 
70  void setColor(const QColor& c);
71  QColor color(){return linePen().color();};
72 
74  void setWidth(double w);
76  double width(){return linePen().widthF();};
77 
79  double arrowWidth();
80 
82  void setStyle(Qt::PenStyle s);
84  Qt::PenStyle style(){return linePen().style ();};
85 
87  void drawStartArrow(bool on = true){d_start_arrow = on;};
88  bool hasStartArrow(){return d_start_arrow;};
89 
91  void drawEndArrow(bool on = true){d_end_arrow = on;};
92  bool hasEndArrow(){return d_end_arrow;};
93 
95  int headLength(){return d_head_length;};
97  void setHeadLength(int l);
98 
100  int headAngle(){return d_head_angle;};
102  void setHeadAngle(int a);
103 
104  bool filledArrowHead(){return d_fill_head;};
106  void fillArrowHead(bool fill = true);
107 
109  double dist(int x, int y);
110 
112  double length();
113 
115  QRect rect() const {return QRect(startPoint(), endPoint()).normalize();};
116 
118  QwtDoubleRect boundingRect() const;
119  void setBoundingRect(double xs, double ys, double xe, double ye);
120 
122  void updateBoundingRect();
123 
125  bool editable() const { return d_editable; }
127  void setEditable(bool yes);
128 
130  bool eventFilter(QObject *o, QEvent *e);
131 
132  void setAttachPolicy(AttachPolicy attachTo);
134 
135 private:
136  void displayInfo(bool clear = false);
137  void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const;
138  double theta(int xs, int ys, int xe, int ye) const;
139 
142 
145 
148 
151 
154 
156  QPoint d_start;
157 
159  QPoint d_end;
160 
162  QwtDoubleRect d_rect;
165 
168 
174  QPoint d_op_startat;
175 
177 };
178 #endif