SciDAVis
1.D4
|
Draws lines and arrows on a QwtPlot. More...
#include <ArrowMarker.h>
Public Types | |
enum | Operation { None, MoveStart, MoveEnd, MoveBoth } |
Public Member Functions | |
ArrowMarker () | |
QwtDoubleRect | boundingRect () const |
Returns the bounding rectangle in plot coordinates. | |
QColor | color () |
double | dist (int x, int y) |
Returns the shortest distance to the arrow line or to one of the arrow heads. | |
void | drawEndArrow (bool on=true) |
Specifies weather the end arrow should be drawn. | |
void | drawStartArrow (bool on=true) |
Specifies weather the start arrow should be drawn. | |
bool | editable () const |
Returns the state of d_editable. | |
QPoint | endPoint () const |
Pixel coordinates of the end point. | |
QwtDoublePoint | endPointCoord () |
Axes values coordinates of the end point. | |
bool | eventFilter (QObject *o, QEvent *e) |
Filters events for the canvas while d_editable is true. | |
void | fillArrowHead (bool fill=true) |
Specifies weather the arrow head should be filled with a brush. | |
bool | filledArrowHead () |
bool | hasEndArrow () |
bool | hasStartArrow () |
int | headAngle () |
The angle of the arrow head. | |
int | headLength () |
Length of the arrow head. | |
double | length () |
Returns the length of the arrow line. | |
QRect | rect () const |
Returns the bounding rectangle in paint coordinates. | |
void | setBoundingRect (double xs, double ys, double xe, double ye) |
Set position (xValue() and yValue()), right and bottom values giving everything in plot coordinates. | |
void | setColor (const QColor &c) |
void | setEditable (bool yes) |
Starts/ends editing of end points by the user. | |
void | setEndPoint (const QPoint &p) |
Sets the end point in pixel coordinates. | |
void | setEndPoint (double x, double y) |
Sets the end point in axes values coordinates. | |
void | setHeadAngle (int a) |
Sets the angle of the arrow head. | |
void | setHeadLength (int l) |
Sets the length of the arrow head. | |
void | setStartPoint (const QPoint &p) |
Sets the start point in pixel coordinates. | |
void | setStartPoint (double x, double y) |
Sets the start point in axes values coordinates. | |
void | setStyle (Qt::PenStyle s) |
Sets the pen style for the arrow line. | |
void | setWidth (int w) |
Sets the width of the arrow line. | |
QPoint | startPoint () const |
Pixel coordinates of the start point. | |
QwtDoublePoint | startPointCoord () |
Axes values coordinates of the start point. | |
Qt::PenStyle | style () |
The pen style of the arrow line. | |
void | updateBoundingRect () |
Recalculates the bounding rectangle in values coordinates using the pixel coordinats when the scales change. | |
int | width () |
The width of the arrow line. | |
Public Member Functions inherited from PlotEnrichement | |
double | bottom () |
QPoint | origin () const |
Return position in paint coordinates. | |
PlotEnrichement () | |
double | right () |
void | setOrigin (const QPoint &p) |
Set QwtPlotMarker::value() in paint coordinates. | |
virtual void | setRect (int x, int y, int w, int h) |
Set value (position) and d_size, giving everything in paint coordinates. | |
void | setSize (const QSize &size) |
Set d_size. | |
QSize | size () |
Return d_size. |
Private Member Functions | |
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 | |
bool | d_editable |
Whether start and end point can be moved by the user. | |
QPoint | d_end |
Pixel coordinates of the end point. | |
bool | d_end_arrow |
Flag specifying if the end arrow is visible. | |
bool | d_fill_head |
Flag specifying if the arrow head is filled with a brush. | |
int | d_head_angle |
Angle of the arrow head. | |
int | d_head_length |
Length of the arrow head. | |
Operation | d_op |
What editing operation is in progress. | |
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. | |
QwtDoubleRect | d_rect |
Bounding rectangle of the arrow in axes values coordinates. | |
QPoint | d_start |
Pixel coordinates of the start point. | |
bool | d_start_arrow |
Flag specifying if the start arrow is visible. |
Draws lines and arrows on a QwtPlot.
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.
ArrowMarker::ArrowMarker | ( | ) |
|
virtual |
Returns the bounding rectangle in plot coordinates.
Reimplemented from PlotEnrichement.
References d_rect.
|
inline |
Referenced by Graph::addArrow(), ApplicationWindow::copyMarker(), LineDialog::LineDialog(), Graph::saveMarkers(), and setColor().
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(), and CanvasPicker::selectMarker().
|
private |
References d_editable, d_end_arrow, d_fill_head, d_head_angle, d_head_length, d_rect, d_start_arrow, endPoint(), M_PI, startPoint(), and theta().
|
inline |
Specifies weather the end arrow should be drawn.
References d_end_arrow.
Referenced by Graph::addArrow(), LineProfileTool::addLineMarker(), LineDialog::apply(), CanvasPicker::drawLineMarker(), CanvasPicker::eventFilter(), and Graph::pasteMarker().
|
inline |
Specifies weather the start arrow should be drawn.
References d_start_arrow.
Referenced by Graph::addArrow(), LineProfileTool::addLineMarker(), LineDialog::apply(), CanvasPicker::drawLineMarker(), CanvasPicker::eventFilter(), and Graph::pasteMarker().
|
inline |
Returns the state of d_editable.
References d_editable.
QPoint ArrowMarker::endPoint | ( | ) | const |
Pixel coordinates of the end point.
References d_rect.
Referenced by Graph::copyMarker(), LineDialog::displayCoordinates(), draw(), eventFilter(), SelectionMoveResizer::operateOnTargets(), and rect().
QwtDoublePoint ArrowMarker::endPointCoord | ( | ) |
Axes values coordinates of the end point.
References d_rect.
Referenced by Graph::addArrow(), LineDialog::displayCoordinates(), and Graph::saveMarkers().
bool ArrowMarker::eventFilter | ( | QObject * | o, |
QEvent * | e | ||
) |
Filters events for the canvas while d_editable is true.
References d_op, d_op_startat, dist(), endPoint(), headAngle(), headLength(), M_PI, MoveBoth, MoveEnd, MoveStart, None, setEndPoint(), setStartPoint(), startPoint(), and width().
Referenced by CanvasPicker::eventFilter().
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 Graph::pasteMarker().
|
inline |
References d_fill_head.
Referenced by Graph::addArrow(), LineDialog::apply(), ApplicationWindow::copyMarker(), LineDialog::LineDialog(), and Graph::saveMarkers().
|
inline |
References d_end_arrow.
Referenced by Graph::addArrow(), ApplicationWindow::copyMarker(), LineDialog::LineDialog(), and Graph::saveMarkers().
|
inline |
References d_start_arrow.
Referenced by Graph::addArrow(), ApplicationWindow::copyMarker(), LineDialog::LineDialog(), and Graph::saveMarkers().
|
inline |
The angle of the arrow head.
References d_head_angle.
Referenced by Graph::addArrow(), LineDialog::apply(), ApplicationWindow::copyMarker(), eventFilter(), LineDialog::LineDialog(), Graph::saveMarkers(), and CanvasPicker::selectMarker().
|
inline |
Length of the arrow head.
References d_head_length.
Referenced by Graph::addArrow(), LineDialog::apply(), ApplicationWindow::copyMarker(), eventFilter(), LineDialog::LineDialog(), Graph::saveMarkers(), and CanvasPicker::selectMarker().
double ArrowMarker::length | ( | ) |
Returns the length of the arrow line.
References d_rect.
|
inlinevirtual |
Returns the bounding rectangle in paint coordinates.
Reimplemented from PlotEnrichement.
References endPoint(), and startPoint().
Referenced by SelectionMoveResizer::operateOnTargets().
|
virtual |
Set position (xValue() and yValue()), right and bottom values giving everything in plot coordinates.
Reimplemented from PlotEnrichement.
References d_end, d_rect, and d_start.
Referenced by Graph::addArrow().
void ArrowMarker::setColor | ( | const QColor & | c | ) |
References color().
Referenced by Graph::addArrow(), LineProfileTool::addLineMarker(), LineDialog::apply(), CanvasPicker::drawLineMarker(), CanvasPicker::eventFilter(), and Graph::pasteMarker().
void ArrowMarker::setEditable | ( | bool | yes | ) |
Starts/ends editing of end points by the user.
References d_editable.
Referenced by CanvasPicker::disableEditing(), CanvasPicker::eventFilter(), and CanvasPicker::selectMarker().
void ArrowMarker::setEndPoint | ( | const QPoint & | p | ) |
Sets the end point in pixel coordinates.
Referenced by Graph::addArrow(), LineProfileTool::addLineMarker(), CanvasPicker::drawLineMarker(), CanvasPicker::eventFilter(), eventFilter(), SelectionMoveResizer::operateOnTargets(), Graph::pasteMarker(), and LineDialog::setCoordinates().
void ArrowMarker::setEndPoint | ( | double | x, |
double | y | ||
) |
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 Graph::pasteMarker().
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 Graph::pasteMarker().
void ArrowMarker::setStartPoint | ( | const QPoint & | p | ) |
Sets the start point in pixel coordinates.
References d_rect, and d_start.
Referenced by Graph::addArrow(), LineProfileTool::addLineMarker(), CanvasPicker::drawLineMarker(), CanvasPicker::eventFilter(), eventFilter(), SelectionMoveResizer::operateOnTargets(), Graph::pasteMarker(), and LineDialog::setCoordinates().
void ArrowMarker::setStartPoint | ( | double | x, |
double | y | ||
) |
void ArrowMarker::setStyle | ( | Qt::PenStyle | s | ) |
Sets the pen style for the arrow line.
References style().
Referenced by Graph::addArrow(), LineProfileTool::addLineMarker(), LineDialog::apply(), CanvasPicker::drawLineMarker(), CanvasPicker::eventFilter(), and Graph::pasteMarker().
void ArrowMarker::setWidth | ( | int | w | ) |
Sets the width of the arrow line.
References width().
Referenced by Graph::addArrow(), LineProfileTool::addLineMarker(), LineDialog::apply(), CanvasPicker::drawLineMarker(), CanvasPicker::eventFilter(), and Graph::pasteMarker().
QPoint ArrowMarker::startPoint | ( | ) | const |
Pixel coordinates of the start point.
References d_rect.
Referenced by Graph::copyMarker(), LineDialog::displayCoordinates(), draw(), eventFilter(), SelectionMoveResizer::operateOnTargets(), and rect().
QwtDoublePoint ArrowMarker::startPointCoord | ( | ) |
Axes values coordinates of the start point.
References d_rect.
Referenced by Graph::addArrow(), LineDialog::displayCoordinates(), and Graph::saveMarkers().
|
inline |
The pen style of the arrow line.
Referenced by Graph::addArrow(), ApplicationWindow::copyMarker(), LineDialog::LineDialog(), Graph::saveMarkers(), and setStyle().
|
private |
Referenced by draw().
|
virtual |
Recalculates the bounding rectangle in values coordinates using the pixel coordinats when the scales change.
Reimplemented from PlotEnrichement.
References d_end, d_rect, and d_start.
Referenced by Graph::updateMarkersBoundingRect().
|
inline |
The width of the arrow line.
Referenced by Graph::addArrow(), ApplicationWindow::copyMarker(), eventFilter(), LineDialog::LineDialog(), Graph::saveMarkers(), CanvasPicker::selectMarker(), and setWidth().
|
private |
Whether start and end point can be moved by the user.
Referenced by draw(), editable(), and setEditable().
|
private |
Pixel coordinates of the end point.
Referenced by setBoundingRect(), setEndPoint(), and updateBoundingRect().
|
private |
Flag specifying if the end arrow is visible.
Referenced by draw(), drawEndArrow(), and hasEndArrow().
|
private |
Flag specifying if the arrow head is filled with a brush.
Referenced by draw(), fillArrowHead(), and filledArrowHead().
|
private |
Angle of the arrow head.
Referenced by draw(), headAngle(), and setHeadAngle().
|
private |
Length of the arrow head.
Referenced by draw(), headLength(), and setHeadLength().
|
private |
What editing operation is in progress.
Referenced by eventFilter().
|
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().
|
private |
Bounding rectangle of the arrow in axes values coordinates.
Referenced by boundingRect(), dist(), draw(), endPoint(), endPointCoord(), length(), setBoundingRect(), setEndPoint(), setStartPoint(), startPoint(), startPointCoord(), and updateBoundingRect().
|
private |
Pixel coordinates of the start point.
Referenced by setBoundingRect(), setStartPoint(), and updateBoundingRect().
|
private |
Flag specifying if the start arrow is visible.
Referenced by draw(), drawStartArrow(), and hasStartArrow().