ArrowMarker.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : ArrowMarker.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 by Ion Vasilief
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr
00007     Description          : Arrow marker (extension to QwtPlotMarker)
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 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     enum AttachPolicy {Page, Scales};
00048     ArrowMarker();
00049 
00051     QPoint startPoint() const;
00053     void setStartPoint(const QPoint& p);
00054 
00056     QPoint endPoint() const;
00058     void setEndPoint(const QPoint& p);
00059 
00061     QwtDoublePoint startPointCoord();
00063     void setStartPoint(double x, double y);
00064 
00066     QwtDoublePoint endPointCoord();
00068     void setEndPoint(double x, double y);
00069 
00070     void setColor(const QColor& c);
00071     QColor color(){return linePen().color();};
00072 
00074     void setWidth(double w);
00076     double width(){return linePen().widthF();};
00077 
00079     void setStyle(Qt::PenStyle s);
00081     Qt::PenStyle style(){return linePen().style ();};
00082 
00084     void drawStartArrow(bool on = true){d_start_arrow = on;};
00085     bool hasStartArrow(){return d_start_arrow;};
00086 
00088     void drawEndArrow(bool on = true){d_end_arrow = on;};
00089     bool hasEndArrow(){return d_end_arrow;};
00090 
00092     int headLength(){return d_head_length;};
00094     void setHeadLength(int l);
00095 
00097     int headAngle(){return d_head_angle;};
00099     void setHeadAngle(int a);
00100 
00101     bool filledArrowHead(){return d_fill_head;};
00103     void fillArrowHead(bool fill = true);
00104 
00106     double dist(int x, int y);
00107 
00109     double length();
00110 
00112     QRect rect() const {return QRect(startPoint(), endPoint()).normalize();};
00113 
00115     QwtDoubleRect boundingRect() const;
00116     void setBoundingRect(double xs, double ys, double xe, double ye);
00117 
00119     void updateBoundingRect();
00120 
00122     bool editable() const { return d_editable; }
00124     void setEditable(bool yes);
00125 
00127     bool eventFilter(QObject *o, QEvent *e);
00128 
00129     void setAttachPolicy(AttachPolicy attachTo);
00130     AttachPolicy attachPolicy(){return d_attach_policy;};
00131 
00132 private:
00133     void displayInfo(bool clear = false);
00134     void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const;
00135     double theta(int xs, int ys, int xe, int ye) const;
00136 
00138     bool d_start_arrow;
00139 
00141     bool d_end_arrow;
00142 
00144     bool d_fill_head;
00145 
00147     int d_head_angle;
00148 
00150     int d_head_length;
00151 
00153     QPoint d_start;
00154 
00156     QPoint d_end;
00157 
00159     QwtDoubleRect d_rect;
00161     bool d_editable;
00162 
00164     Operation d_op;
00165 
00171     QPoint d_op_startat;
00172 
00173     AttachPolicy d_attach_policy;
00174 };
00175 #endif

Generated by  doxygen 1.6.2