ArrowMarker.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef ARROWMARKER_H
00030 #define ARROWMARKER_H
00031
00032 #include <qwt_plot_marker.h>
00033
00043 class ArrowMarker: public QObject, public QwtPlotMarker
00044 {
00045 public:
00046 enum Operation { None, MoveStart, MoveEnd, MoveBoth };
00047 ArrowMarker();
00048
00050 QPoint startPoint() const;
00052 void setStartPoint(const QPoint& p);
00053
00055 QPoint endPoint() const;
00057 void setEndPoint(const QPoint& p);
00058
00060 QwtDoublePoint startPointCoord();
00062 void setStartPoint(double x, double y);
00063
00065 QwtDoublePoint endPointCoord();
00067 void setEndPoint(double x, double y);
00068
00069 void setColor(const QColor& c);
00070 QColor color(){return linePen().color();};
00071
00073 void setWidth(double w);
00075 double width(){return linePen().widthF();};
00076
00078 void setStyle(Qt::PenStyle s);
00080 Qt::PenStyle style(){return linePen().style ();};
00081
00083 void drawStartArrow(bool on = true){d_start_arrow = on;};
00084 bool hasStartArrow(){return d_start_arrow;};
00085
00087 void drawEndArrow(bool on = true){d_end_arrow = on;};
00088 bool hasEndArrow(){return d_end_arrow;};
00089
00091 int headLength(){return d_head_length;};
00093 void setHeadLength(int l);
00094
00096 int headAngle(){return d_head_angle;};
00098 void setHeadAngle(int a);
00099
00100 bool filledArrowHead(){return d_fill_head;};
00102 void fillArrowHead(bool fill = true);
00103
00105 double dist(int x, int y);
00106
00108 double length();
00109
00111 QRect rect() const {return QRect(startPoint(), endPoint()).normalize();};
00112
00114 QwtDoubleRect boundingRect() const;
00115 void setBoundingRect(double xs, double ys, double xe, double ye);
00116
00118 void updateBoundingRect();
00119
00121 bool editable() const { return d_editable; }
00123 void setEditable(bool yes);
00124
00126 bool eventFilter(QObject *o, QEvent *e);
00127
00128 private:
00129 void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const;
00130 double theta(int xs, int ys, int xe, int ye) const;
00131
00133 bool d_start_arrow;
00134
00136 bool d_end_arrow;
00137
00139 bool d_fill_head;
00140
00142 int d_head_angle;
00143
00145 int d_head_length;
00146
00148 QPoint d_start;
00149
00151 QPoint d_end;
00152
00154 QwtDoubleRect d_rect;
00156 bool d_editable;
00157
00159 Operation d_op;
00160
00166 QPoint d_op_startat;
00167 };
00168 #endif