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 "PlotEnrichement.h"
00033 
00043 class ArrowMarker: public QObject, public PlotEnrichement
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(int w);
00075     int width(){return linePen().width();};
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

Generated on Thu Feb 7 13:59:26 2008 for QtiPlot by  doxygen 1.5.4