SciDAVis  1.D4
ArrowMarker.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : ArrowMarker.h
3  Project : SciDAVis
4  --------------------------------------------------------------------
5  Copyright : (C) 2006 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 "PlotEnrichement.h"
33 
43 class ArrowMarker: public QObject, public PlotEnrichement
44 {
45 public:
47  ArrowMarker();
48 
50  QPoint startPoint() const;
52  void setStartPoint(const QPoint& p);
53 
55  QPoint endPoint() const;
57  void setEndPoint(const QPoint& p);
58 
60  QwtDoublePoint startPointCoord();
62  void setStartPoint(double x, double y);
63 
65  QwtDoublePoint endPointCoord();
67  void setEndPoint(double x, double y);
68 
69  void setColor(const QColor& c);
70  QColor color(){return linePen().color();};
71 
73  void setWidth(int w);
75  int width(){return linePen().width();};
76 
78  void setStyle(Qt::PenStyle s);
80  Qt::PenStyle style(){return linePen().style ();};
81 
83  void drawStartArrow(bool on = true){d_start_arrow = on;};
84  bool hasStartArrow(){return d_start_arrow;};
85 
87  void drawEndArrow(bool on = true){d_end_arrow = on;};
88  bool hasEndArrow(){return d_end_arrow;};
89 
91  int headLength(){return d_head_length;};
93  void setHeadLength(int l);
94 
96  int headAngle(){return d_head_angle;};
98  void setHeadAngle(int a);
99 
100  bool filledArrowHead(){return d_fill_head;};
102  void fillArrowHead(bool fill = true);
103 
105  double dist(int x, int y);
106 
108  double length();
109 
111  QRect rect() const {return QRect(startPoint(), endPoint()).normalized();};
112 
114  QwtDoubleRect boundingRect() const;
115  void setBoundingRect(double xs, double ys, double xe, double ye);
116 
118  void updateBoundingRect();
119 
121  bool editable() const { return d_editable; }
123  void setEditable(bool yes);
124 
126  bool eventFilter(QObject *o, QEvent *e);
127 
128 private:
129  void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const;
130  double theta(int xs, int ys, int xe, int ye) const;
131 
134 
137 
140 
143 
146 
148  QPoint d_start;
149 
151  QPoint d_end;
152 
154  QwtDoubleRect d_rect;
157 
160 
166  QPoint d_op_startat;
167 };
168 #endif