ArrowMarker.h
Go to the documentation of this file.
/***************************************************************************
File : ArrowMarker.h
Project : QtiPlot
--------------------------------------------------------------------
Copyright : (C) 2006 - 2011 by Ion Vasilief
Email (use @ for *) : ion_vasilief*yahoo.fr
Description : Arrow marker (extension to QwtPlotMarker)
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
* Boston, MA 02110-1301 USA *
* *
***************************************************************************/
#ifndef ARROWMARKER_H
#define ARROWMARKER_H
#include <qwt_plot_marker.h>
class ArrowMarker: public QObject, public QwtPlotMarker
{
public:
enum Operation { None, MoveStart, MoveEnd, MoveBoth };
enum AttachPolicy {Page, Scales};
ArrowMarker();
QPoint startPoint() const;
void setStartPoint(const QPoint& p);
QPoint endPoint() const;
void setEndPoint(const QPoint& p);
QwtDoublePoint startPointCoord();
void setStartPoint(double x, double y);
QwtDoublePoint endPointCoord();
void setEndPoint(double x, double y);
void setColor(const QColor& c);
QColor color(){return linePen().color();};
void setWidth(double w);
double width(){return linePen().widthF();};
double arrowWidth();
void setStyle(Qt::PenStyle s);
Qt::PenStyle style(){return linePen().style ();};
void drawStartArrow(bool on = true){d_start_arrow = on;};
bool hasStartArrow(){return d_start_arrow;};
void drawEndArrow(bool on = true){d_end_arrow = on;};
bool hasEndArrow(){return d_end_arrow;};
int headLength(){return d_head_length;};
void setHeadLength(int l);
int headAngle(){return d_head_angle;};
void setHeadAngle(int a);
bool filledArrowHead(){return d_fill_head;};
void fillArrowHead(bool fill = true);
double dist(int x, int y);
double length();
QRect rect() const {return QRect(startPoint(), endPoint()).normalize();};
QwtDoubleRect boundingRect() const;
void setBoundingRect(double xs, double ys, double xe, double ye);
void updateBoundingRect();
bool editable() const { return d_editable; }
void setEditable(bool yes);
bool eventFilter(QObject *o, QEvent *e);
void setAttachPolicy(AttachPolicy attachTo);
AttachPolicy attachPolicy(){return d_attach_policy;};
private:
void displayInfo(bool clear = false);
void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const;
double theta(int xs, int ys, int xe, int ye) const;
bool d_start_arrow;
bool d_end_arrow;
bool d_fill_head;
int d_head_angle;
int d_head_length;
QPoint d_start;
QPoint d_end;
QwtDoubleRect d_rect;
bool d_editable;
Operation d_op;
QPoint d_op_startat;
AttachPolicy d_attach_policy;
};
#endif
ArrowMarker::headAngle
int headAngle()
The angle of the arrow head.
Definition: ArrowMarker.h:100
ArrowMarker::style
Qt::PenStyle style()
The pen style of the arrow line.
Definition: ArrowMarker.h:84
ArrowMarker::filledArrowHead
bool filledArrowHead()
Definition: ArrowMarker.h:104
ArrowMarker::d_end
QPoint d_end
Pixel coordinates of the end point.
Definition: ArrowMarker.h:159
ArrowMarker::setEditable
void setEditable(bool yes)
Starts/ends editing of end points by the user.
Definition: ArrowMarker.cpp:411
ArrowMarker::hasStartArrow
bool hasStartArrow()
Definition: ArrowMarker.h:88
ArrowMarker::d_head_angle
int d_head_angle
Angle of the arrow head.
Definition: ArrowMarker.h:150
ArrowMarker::width
double width()
The width of the arrow line.
Definition: ArrowMarker.h:76
ArrowMarker::setAttachPolicy
void setAttachPolicy(AttachPolicy attachTo)
Definition: ArrowMarker.cpp:587
ArrowMarker::MoveStart
Definition: ArrowMarker.h:46
ArrowMarker::length
double length()
Returns the length of the arrow line.
Definition: ArrowMarker.cpp:161
ArrowMarker::Page
Definition: ArrowMarker.h:47
ArrowMarker::d_start
QPoint d_start
Pixel coordinates of the start point.
Definition: ArrowMarker.h:156
ArrowMarker::attachPolicy
AttachPolicy attachPolicy()
Definition: ArrowMarker.h:133
ArrowMarker::headLength
int headLength()
Length of the arrow head.
Definition: ArrowMarker.h:95
ArrowMarker::d_attach_policy
AttachPolicy d_attach_policy
Definition: ArrowMarker.h:176
ArrowMarker::ArrowMarker
ArrowMarker()
Definition: ArrowMarker.cpp:47
ArrowMarker::d_end_arrow
bool d_end_arrow
Flag specifying if the end arrow is visible.
Definition: ArrowMarker.h:144
ArrowMarker
Draws lines and arrows on a QwtPlot.
Definition: ArrowMarker.h:43
ArrowMarker::updateBoundingRect
void updateBoundingRect()
Recalculates the bounding rectangle in values coordinates using the pixel coordinats when the scales ...
Definition: ArrowMarker.cpp:397
ArrowMarker::draw
void draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &r) const
Definition: ArrowMarker.cpp:59
ArrowMarker::color
QColor color()
Definition: ArrowMarker.h:71
ArrowMarker::None
Definition: ArrowMarker.h:46
ArrowMarker::d_op_startat
QPoint d_op_startat
Difference between mouse position where a MoveBoth operation started and startPoint(). When only one point is being moved, we can simply setStartPoint() or setEndPoint() to the current mouse position, but when the editing starts in the middle of the line, we need to remember this bit.
Definition: ArrowMarker.h:174
ArrowMarker::setStyle
void setStyle(Qt::PenStyle s)
Sets the pen style for the arrow line.
Definition: ArrowMarker.cpp:241
ArrowMarker::Operation
Operation
Definition: ArrowMarker.h:46
ArrowMarker::MoveEnd
Definition: ArrowMarker.h:46
ArrowMarker::AttachPolicy
AttachPolicy
Definition: ArrowMarker.h:47
ArrowMarker::d_editable
bool d_editable
Whether start and end point can be moved by the user.
Definition: ArrowMarker.h:164
ArrowMarker::eventFilter
bool eventFilter(QObject *o, QEvent *e)
Filters events for the canvas while d_editable is true.
Definition: ArrowMarker.cpp:429
ArrowMarker::setHeadLength
void setHeadLength(int l)
Sets the length of the arrow head.
Definition: ArrowMarker.cpp:251
ArrowMarker::setColor
void setColor(const QColor &c)
Definition: ArrowMarker.cpp:221
ArrowMarker::dist
double dist(int x, int y)
Returns the shortest distance to the arrow line or to one of the arrow heads.
Definition: ArrowMarker.cpp:178
ArrowMarker::arrowWidth
double arrowWidth()
Returns half of the arrow width;.
Definition: ArrowMarker.cpp:213
ArrowMarker::MoveBoth
Definition: ArrowMarker.h:46
ArrowMarker::editable
bool editable() const
Returns the state of d_editable.
Definition: ArrowMarker.h:125
ArrowMarker::theta
double theta(int xs, int ys, int xe, int ye) const
Definition: ArrowMarker.cpp:145
ArrowMarker::fillArrowHead
void fillArrowHead(bool fill=true)
Specifies weather the arrow head should be filled with a brush.
Definition: ArrowMarker.cpp:267
ArrowMarker::drawEndArrow
void drawEndArrow(bool on=true)
Specifies weather the end arrow should be drawn.
Definition: ArrowMarker.h:91
ArrowMarker::setStartPoint
void setStartPoint(const QPoint &p)
Sets the start point in pixel coordinates.
Definition: ArrowMarker.cpp:275
ArrowMarker::d_head_length
int d_head_length
Length of the arrow head.
Definition: ArrowMarker.h:153
ArrowMarker::d_rect
QwtDoubleRect d_rect
Bounding rectangle of the arrow in axes values coordinates.
Definition: ArrowMarker.h:162
ArrowMarker::boundingRect
QwtDoubleRect boundingRect() const
Returns the bounding rectangle in plot coordinates.
Definition: ArrowMarker.cpp:380
ArrowMarker::d_start_arrow
bool d_start_arrow
Flag specifying if the start arrow is visible.
Definition: ArrowMarker.h:141
ArrowMarker::setHeadAngle
void setHeadAngle(int a)
Sets the angle of the arrow head.
Definition: ArrowMarker.cpp:259
ArrowMarker::setWidth
void setWidth(double w)
Sets the width of the arrow line.
Definition: ArrowMarker.cpp:231
ArrowMarker::displayInfo
void displayInfo(bool clear=false)
Definition: ArrowMarker.cpp:538
ArrowMarker::startPoint
QPoint startPoint() const
Pixel coordinates of the start point.
Definition: ArrowMarker.cpp:303
ArrowMarker::startPointCoord
QwtDoublePoint startPointCoord()
Axes values coordinates of the start point.
Definition: ArrowMarker.cpp:312
ArrowMarker::d_fill_head
bool d_fill_head
Flag specifying if the arrow head is filled with a brush.
Definition: ArrowMarker.h:147
ArrowMarker::endPoint
QPoint endPoint() const
Pixel coordinates of the end point.
Definition: ArrowMarker.cpp:332
ArrowMarker::drawStartArrow
void drawStartArrow(bool on=true)
Specifies weather the start arrow should be drawn.
Definition: ArrowMarker.h:87
ArrowMarker::endPointCoord
QwtDoublePoint endPointCoord()
Axes values coordinates of the end point.
Definition: ArrowMarker.cpp:356
ArrowMarker::Scales
Definition: ArrowMarker.h:47
ArrowMarker::rect
QRect rect() const
Returns the bounding rectangle in paint coordinates.
Definition: ArrowMarker.h:115
ArrowMarker::hasEndArrow
bool hasEndArrow()
Definition: ArrowMarker.h:92
ArrowMarker::setBoundingRect
void setBoundingRect(double xs, double ys, double xe, double ye)
Definition: ArrowMarker.cpp:361
ArrowMarker::d_op
Operation d_op
What editing operation is in progress.
Definition: ArrowMarker.h:167
ArrowMarker::setEndPoint
void setEndPoint(const QPoint &p)
Sets the end point in pixel coordinates.
Definition: ArrowMarker.cpp:289