ArrowMarker Class Reference

Draws lines and arrows on a QwtPlot. More...

`#include <ArrowMarker.h>`

Inheritance diagram for ArrowMarker:

## Public Types

enum | AttachPolicy { Page, Scales }
enum | Operation { None, MoveStart, MoveEnd, MoveBoth }

## Public Member Functions

| ArrowMarker ()
double | arrowWidth ()
| Returns half of the arrow width;. More...
AttachPolicy | attachPolicy ()
QwtDoubleRect | boundingRect () const
| Returns the bounding rectangle in plot coordinates. More...
QColor | color ()
double | dist (int x, int y)
| Returns the shortest distance to the arrow line or to one of the arrow heads. More...
void | drawEndArrow (bool on=true)
| Specifies weather the end arrow should be drawn. More...
void | drawStartArrow (bool on=true)
| Specifies weather the start arrow should be drawn. More...
bool | editable () const
| Returns the state of d_editable. More...
QPoint | endPoint () const
| Pixel coordinates of the end point. More...
QwtDoublePoint | endPointCoord ()
| Axes values coordinates of the end point. More...
bool | eventFilter (QObject *o, QEvent *e)
| Filters events for the canvas while d_editable is true. More...
void | fillArrowHead (bool fill=true)
| Specifies weather the arrow head should be filled with a brush. More...
bool | filledArrowHead ()
bool | hasEndArrow ()
bool | hasStartArrow ()
int | headAngle ()
| The angle of the arrow head. More...
int | headLength ()
| Length of the arrow head. More...
double | length ()
| Returns the length of the arrow line. More...
QRect | rect () const
| Returns the bounding rectangle in paint coordinates. More...
void | setAttachPolicy (AttachPolicy attachTo)
void | setBoundingRect (double xs, double ys, double xe, double ye)
void | setColor (const QColor &c)
void | setEditable (bool yes)
| Starts/ends editing of end points by the user. More...
void | setEndPoint (const QPoint &p)
| Sets the end point in pixel coordinates. More...
void | setEndPoint (double x, double y)
| Sets the end point in axes values coordinates. More...
void | setHeadAngle (int a)
| Sets the angle of the arrow head. More...
void | setHeadLength (int l)
| Sets the length of the arrow head. More...
void | setStartPoint (const QPoint &p)
| Sets the start point in pixel coordinates. More...
void | setStartPoint (double x, double y)
| Sets the start point in axes values coordinates. More...
void | setStyle (Qt::PenStyle s)
| Sets the pen style for the arrow line. More...
void | setWidth (double w)
| Sets the width of the arrow line. More...
QPoint | startPoint () const
| Pixel coordinates of the start point. More...
QwtDoublePoint | startPointCoord ()
| Axes values coordinates of the start point. More...
Qt::PenStyle | style ()
| The pen style of the arrow line. More...
void | updateBoundingRect ()
| Recalculates the bounding rectangle in values coordinates using the pixel coordinats when the scales change. More...
double | width ()
| The width of the arrow line. More...

## Private Member Functions

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

## Private Attributes

AttachPolicy | d_attach_policy
bool | d_editable
| Whether start and end point can be moved by the user. More...
QPoint | d_end
| Pixel coordinates of the end point. More...
bool | d_end_arrow
| Flag specifying if the end arrow is visible. More...
bool | d_fill_head
| Flag specifying if the arrow head is filled with a brush. More...
int | d_head_angle
| Angle of the arrow head. More...
int | d_head_length
| Length of the arrow head. More...
Operation | d_op
| What editing operation is in progress. More...
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. More...
QwtDoubleRect | d_rect
| Bounding rectangle of the arrow in axes values coordinates. More...
QPoint | d_start
| Pixel coordinates of the start point. More...
bool | d_start_arrow
| Flag specifying if the start arrow is visible. More...

## Detailed Description

Draws lines and arrows on a QwtPlot.

# Design Ideas

Move all the code for editing the end points from CanvasPicker here, so that we have it all in one place. This approach will make adding new editable markers (e.g. polygons) much easier, and it will allow this to be done in plug-ins.

See also
  ImageMarker, Legend

## Member Enumeration Documentation

## AttachPolicy

enum ArrowMarker::AttachPolicy

Enumerator
Page |
Scales |

## Operation

enum ArrowMarker::Operation

Enumerator
None |
MoveStart |
MoveEnd |
MoveBoth |

## Constructor & Destructor Documentation

## ArrowMarker()

ArrowMarker::ArrowMarker | ( |  | ) |

## Member Function Documentation

## arrowWidth()

double ArrowMarker::arrowWidth | ( |  | ) |

Returns half of the arrow width;.

References d_head_angle, d_head_length, M_PI, and width().

Referenced by eventFilter(), and width().

## attachPolicy()

AttachPolicy ArrowMarker::attachPolicy | ( |  | ) |

inline

References d_attach_policy, displayInfo(), draw(), and theta().

Referenced by Graph::addArrow(), LineDialog::initGeometryTab(), and Graph::saveMarkers().

## boundingRect()

QwtDoubleRect ArrowMarker::boundingRect | ( |  | ) | const

Returns the bounding rectangle in plot coordinates.

References d_rect.

Referenced by rect().

## color()

QColor ArrowMarker::color | ( |  | ) |

inline

References setWidth().

Referenced by Graph::addArrow(), LineDialog::LineDialog(), Graph::saveMarkers(), and setColor().

## displayInfo()

void ArrowMarker::displayInfo | ( | bool | clear = `false` | ) |

private

References MdiSubWindow::applicationWindow(), ApplicationWindow::d_decimal_digits, d_rect, ApplicationWindow::displayInfo(), and Graph::multiLayer().

Referenced by attachPolicy(), eventFilter(), and setEditable().

## dist()

double ArrowMarker::dist | ( | int | x,
|  | int | y
| ) |  |

Returns the shortest distance to the arrow line or to one of the arrow heads.

References d_rect.

Referenced by eventFilter(), filledArrowHead(), and CanvasPicker::selectMarker().

## draw()

void ArrowMarker::draw | ( | QPainter * | p,
|  | const QwtScaleMap & | xMap,
|  | const QwtScaleMap & | yMap,
|  | const QRect & | r
| ) |  | const

private

References d_editable, d_end_arrow, d_fill_head, d_head_angle, d_head_length, d_rect, d_start_arrow, endPoint(), headLength(), M_PI, startPoint(), and theta().

Referenced by attachPolicy().

## drawEndArrow()

void ArrowMarker::drawEndArrow | ( | bool | on = `true` | ) |

inline

Specifies weather the end arrow should be drawn.

References d_end_arrow.

Referenced by Graph::addArrow(), LineDialog::apply(), CanvasPicker::drawLineMarker(), and CanvasPicker::eventFilter().

## drawStartArrow()

void ArrowMarker::drawStartArrow | ( | bool | on = `true` | ) |

inline

Specifies weather the start arrow should be drawn.

References d_start_arrow.

Referenced by Graph::addArrow(), LineDialog::apply(), CanvasPicker::drawLineMarker(), and CanvasPicker::eventFilter().

## editable()

bool ArrowMarker::editable | ( |  | ) | const

inline

Returns the state of d_editable.

References d_editable, eventFilter(), setAttachPolicy(), and setEditable().

Referenced by Graph::setSelectedArrow().

## endPoint()

QPoint ArrowMarker::endPoint | ( |  | ) | const

Pixel coordinates of the end point.

References d_rect.

Referenced by LineDialog::displayCoordinates(), draw(), eventFilter(), SelectionMoveResizer::operateOnTargets(), ApplicationWindow::pasteSelection(), and rect().

## endPointCoord()

QwtDoublePoint ArrowMarker::endPointCoord | ( |  | ) |

Axes values coordinates of the end point.

References d_rect.

Referenced by Graph::addArrow(), LineDialog::displayCoordinates(), ApplicationWindow::pasteSelection(), and Graph::saveMarkers().

## eventFilter()

bool ArrowMarker::eventFilter | ( | QObject * | o,
|  | QEvent * | e
| ) |  |

Filters events for the canvas while d_editable is true.

References arrowWidth(), d_op, d_op_startat, displayInfo(), dist(), endPoint(), MoveBoth, MoveEnd, MoveStart, None, setEndPoint(), setStartPoint(), and startPoint().

Referenced by editable(), and CanvasPicker::eventFilter().

## fillArrowHead()

void ArrowMarker::fillArrowHead | ( | bool | fill = `true` | ) |

Specifies weather the arrow head should be filled with a brush.

References d_fill_head.

Referenced by Graph::addArrow(), LineDialog::apply(), CanvasPicker::eventFilter(), and filledArrowHead().

## filledArrowHead()

bool ArrowMarker::filledArrowHead | ( |  | ) |

inline

References d_fill_head, dist(), fillArrowHead(), and length().

Referenced by Graph::addArrow(), LineDialog::apply(), LineDialog::LineDialog(), and Graph::saveMarkers().

## hasEndArrow()

bool ArrowMarker::hasEndArrow | ( |  | ) |

inline

References d_end_arrow.

Referenced by Graph::addArrow(), LineDialog::LineDialog(), and Graph::saveMarkers().

## hasStartArrow()

bool ArrowMarker::hasStartArrow | ( |  | ) |

inline

References d_start_arrow.

Referenced by Graph::addArrow(), LineDialog::LineDialog(), and Graph::saveMarkers().

## headAngle()

int ArrowMarker::headAngle | ( |  | ) |

inline

The angle of the arrow head.

References d_head_angle, and setHeadAngle().

Referenced by Graph::addArrow(), LineDialog::apply(), LineDialog::LineDialog(), and Graph::saveMarkers().

## headLength()

int ArrowMarker::headLength | ( |  | ) |

inline

Length of the arrow head.

References d_head_length, and setHeadLength().

Referenced by Graph::addArrow(), LineDialog::apply(), draw(), LineDialog::LineDialog(), and Graph::saveMarkers().

## length()

double ArrowMarker::length | ( |  | ) |

Returns the length of the arrow line.

References d_rect.

Referenced by filledArrowHead().

## rect()

QRect ArrowMarker::rect | ( |  | ) | const

inline

Returns the bounding rectangle in paint coordinates.

References boundingRect(), endPoint(), setBoundingRect(), startPoint(), and updateBoundingRect().

Referenced by SelectionMoveResizer::operateOnTargets().

## setAttachPolicy()

void ArrowMarker::setAttachPolicy | ( | AttachPolicy | attachTo | ) |

References d_attach_policy.

Referenced by Graph::addArrow(), LineDialog::apply(), editable(), and CanvasPicker::eventFilter().

## setBoundingRect()

void ArrowMarker::setBoundingRect | ( | double | xs,
|  | double | ys,
|  | double | xe,
|  | double | ye
| ) |  |

References d_end, d_rect, and d_start.

Referenced by Graph::addArrow(), and rect().

## setColor()

void ArrowMarker::setColor | ( | const QColor & | c | ) |

References color().

Referenced by Graph::addArrow(), LineDialog::apply(), CanvasPicker::drawLineMarker(), and CanvasPicker::eventFilter().

## setEditable()

void ArrowMarker::setEditable | ( | bool | yes | ) |

Starts/ends editing of end points by the user.

References d_editable, and displayInfo().

Referenced by Graph::deselectMarker(), CanvasPicker::disableEditing(), editable(), and CanvasPicker::selectMarker().

## setEndPoint() [1/2]

void ArrowMarker::setEndPoint | ( | const QPoint & | p | ) |

Sets the end point in pixel coordinates.

References d_end, and d_rect.

Referenced by Graph::addArrow(), CanvasPicker::drawLineMarker(), CanvasPicker::eventFilter(), eventFilter(), SelectionMoveResizer::operateOnTargets(), ApplicationWindow::pasteSelection(), and LineDialog::setCoordinates().

## setEndPoint() [2/2]

void ArrowMarker::setEndPoint | ( | double | x,
|  | double | y
| ) |  |

Sets the end point in axes values coordinates.

References d_end, and d_rect.

## setHeadAngle()

void ArrowMarker::setHeadAngle | ( | int | a | ) |

Sets the angle of the arrow head.

References d_head_angle.

Referenced by Graph::addArrow(), LineDialog::apply(), CanvasPicker::eventFilter(), and headAngle().

## setHeadLength()

void ArrowMarker::setHeadLength | ( | int | l | ) |

Sets the length of the arrow head.

References d_head_length.

Referenced by Graph::addArrow(), LineDialog::apply(), CanvasPicker::eventFilter(), and headLength().

## setStartPoint() [1/2]

void ArrowMarker::setStartPoint | ( | const QPoint & | p | ) |

Sets the start point in pixel coordinates.

References d_rect, and d_start.

Referenced by Graph::addArrow(), CanvasPicker::drawLineMarker(), CanvasPicker::eventFilter(), eventFilter(), SelectionMoveResizer::operateOnTargets(), ApplicationWindow::pasteSelection(), and LineDialog::setCoordinates().

## setStartPoint() [2/2]

void ArrowMarker::setStartPoint | ( | double | x,
|  | double | y
| ) |  |

Sets the start point in axes values coordinates.

References d_rect, and d_start.

## setStyle()

void ArrowMarker::setStyle | ( | Qt::PenStyle | s | ) |

Sets the pen style for the arrow line.

References style().

Referenced by Graph::addArrow(), LineDialog::apply(), CanvasPicker::drawLineMarker(), CanvasPicker::eventFilter(), and width().

## setWidth()

void ArrowMarker::setWidth | ( | double | w | ) |

Sets the width of the arrow line.

References width().

Referenced by Graph::addArrow(), LineDialog::apply(), color(), CanvasPicker::drawLineMarker(), and CanvasPicker::eventFilter().

## startPoint()

QPoint ArrowMarker::startPoint | ( |  | ) | const

Pixel coordinates of the start point.

References d_rect.

Referenced by LineDialog::displayCoordinates(), draw(), eventFilter(), SelectionMoveResizer::operateOnTargets(), ApplicationWindow::pasteSelection(), and rect().

## startPointCoord()

QwtDoublePoint ArrowMarker::startPointCoord | ( |  | ) |

Axes values coordinates of the start point.

References d_rect.

Referenced by Graph::addArrow(), LineDialog::displayCoordinates(), ApplicationWindow::pasteSelection(), and Graph::saveMarkers().

## style()

Qt::PenStyle ArrowMarker::style | ( |  | ) |

inline

The pen style of the arrow line.

Referenced by Graph::addArrow(), LineDialog::LineDialog(), Graph::saveMarkers(), and setStyle().

## theta()

double ArrowMarker::theta | ( | int | xs,
|  | int | ys,
|  | int | xe,
|  | int | ye
| ) |  | const

private

Referenced by attachPolicy(), and draw().

## updateBoundingRect()

void ArrowMarker::updateBoundingRect | ( |  | ) |

Recalculates the bounding rectangle in values coordinates using the pixel coordinats when the scales change.

References d_attach_policy, d_end, d_rect, d_start, and Scales.

Referenced by rect().

## width()

double ArrowMarker::width | ( |  | ) |

inline

The width of the arrow line.

References arrowWidth(), and setStyle().

Referenced by Graph::addArrow(), arrowWidth(), LineDialog::LineDialog(), Graph::saveMarkers(), and setWidth().

## Member Data Documentation

## d_attach_policy

AttachPolicy ArrowMarker::d_attach_policy

private

Referenced by attachPolicy(), setAttachPolicy(), and updateBoundingRect().

## d_editable

bool ArrowMarker::d_editable

private

Whether start and end point can be moved by the user.

Referenced by draw(), editable(), and setEditable().

## d_end

QPoint ArrowMarker::d_end

private

Pixel coordinates of the end point.

Referenced by setBoundingRect(), setEndPoint(), and updateBoundingRect().

## d_end_arrow

bool ArrowMarker::d_end_arrow

private

Flag specifying if the end arrow is visible.

Referenced by draw(), drawEndArrow(), and hasEndArrow().

## d_fill_head

bool ArrowMarker::d_fill_head

private

Flag specifying if the arrow head is filled with a brush.

Referenced by draw(), fillArrowHead(), and filledArrowHead().

## d_head_angle

int ArrowMarker::d_head_angle

private

Angle of the arrow head.

Referenced by arrowWidth(), draw(), headAngle(), and setHeadAngle().

## d_head_length

int ArrowMarker::d_head_length

private

Length of the arrow head.

Referenced by arrowWidth(), draw(), headLength(), and setHeadLength().

## d_op

Operation ArrowMarker::d_op

private

What editing operation is in progress.

Referenced by eventFilter().

## d_op_startat

QPoint ArrowMarker::d_op_startat

private

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.

Referenced by eventFilter().

## d_rect

QwtDoubleRect ArrowMarker::d_rect

private

Bounding rectangle of the arrow in axes values coordinates.

Referenced by boundingRect(), displayInfo(), dist(), draw(), endPoint(), endPointCoord(), length(), setBoundingRect(), setEndPoint(), setStartPoint(), startPoint(), startPointCoord(), and updateBoundingRect().

## d_start

QPoint ArrowMarker::d_start

private

Pixel coordinates of the start point.

Referenced by setBoundingRect(), setStartPoint(), and updateBoundingRect().

## d_start_arrow

bool ArrowMarker::d_start_arrow

private

Flag specifying if the start arrow is visible.

Referenced by draw(), drawStartArrow(), and hasStartArrow().

The documentation for this class was generated from the following files:

- qtiplot/src/plot2D/ArrowMarker.h
- qtiplot/src/plot2D/ArrowMarker.cpp