QWT API (English) 7.3.0
Qt Widget Library for Technical Applications - English API Documentation
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
QwtPlotArrowMarker Class Reference

A class for drawing arrow markers on plots. More...

#include <qwt_plot_arrowmarker.h>

Inheritance diagram for QwtPlotArrowMarker:
QwtPlotItem

Classes

class  PrivateData
 

Public Types

enum  EndpointStyle {
  NoEndpoint = 0 , ArrowHead , Circle , Square ,
  Diamond , Triangle , CustomPath
}
 Arrow endpoint style types. More...
 
enum  PositionMode { ExplicitPoints , StartLengthAngle }
 Arrow positioning mode. More...
 
- Public Types inherited from QwtPlotItem
enum  RttiValues {
  Rtti_PlotItem = 0 , Rtti_PlotGrid , Rtti_PlotScale , Rtti_PlotLegend ,
  Rtti_PlotMarker , Rtti_PlotCurve , Rtti_PlotSpectroCurve , Rtti_PlotIntervalCurve ,
  Rtti_PlotHistogram , Rtti_PlotSpectrogram , Rtti_PlotGraphic , Rtti_PlotTradingCurve ,
  Rtti_PlotBarChart , Rtti_PlotMultiBarChart , Rtti_PlotShape , Rtti_PlotTextLabel ,
  Rtti_PlotZone , Rtti_PlotVectorField , Rtti_PlotArrowMarker , Rtti_PlotBoxChart ,
  Rtti_PlotUserItem = 1000
}
 Runtime type information. More...
 
enum  ItemAttribute { Legend = 0x01 , AutoScale = 0x02 , Margins = 0x04 }
 Plot Item Attributes. More...
 
enum  ItemInterest { ScaleInterest = 0x01 , LegendInterest = 0x02 }
 Plot Item Interests. More...
 
enum  RenderHint { RenderAntialiased = 0x1 }
 Render hints. More...
 

Public Member Functions

 QwtPlotArrowMarker ()
 Default constructor.
 
 QwtPlotArrowMarker (const QString &title)
 
 QwtPlotArrowMarker (const QwtText &title)
 
virtual int rtti () const override
 Get the runtime type information.
 
QPointF startPoint () const
 Get the start point of the arrow.
 
QPointF endPoint () const
 Get the end point of the arrow.
 
void setStartPoint (const QPointF &point)
 Set the start point in plot coordinates.
 
void setEndPoint (const QPointF &point)
 Set the end point in plot coordinates.
 
void setPoints (const QPointF &start, const QPointF &end)
 Set both start and end points in plot coordinates.
 
double length () const
 Get the arrow length in pixels.
 
void setLength (double length)
 Set the arrow length in pixels.
 
double angle () const
 Get the rotation angle in degrees.
 
void setAngle (double angle)
 Set the rotation angle in degrees.
 
PositionMode positionMode () const
 Get the positioning mode.
 
void setPositionMode (PositionMode mode)
 Set the positioning mode.
 
const QPen & linePen () const
 Get the arrow line pen.
 
void setLinePen (const QPen &pen)
 Set the arrow line pen.
 
void setLinePen (const QColor &color, qreal width=1.0, Qt::PenStyle style=Qt::SolidLine)
 Convenience method to set line color and width.
 
EndpointStyle headStyle () const
 Get the head style.
 
void setHeadStyle (EndpointStyle style)
 Set the head style.
 
EndpointStyle tailStyle () const
 Get the tail style.
 
void setTailStyle (EndpointStyle style)
 Set the tail style.
 
QSizeF headSize () const
 Get the head size in pixels.
 
void setHeadSize (const QSizeF &size)
 Set the head size in pixels.
 
void setHeadSize (qreal size)
 Convenience method to set head size with equal width and height.
 
QSizeF tailSize () const
 Get the tail size in pixels.
 
void setTailSize (const QSizeF &size)
 Set the tail size in pixels.
 
void setTailSize (qreal size)
 Convenience method to set tail size with equal width and height.
 
const QBrush & headBrush () const
 Get the head brush.
 
void setHeadBrush (const QBrush &brush)
 Set the head brush.
 
const QBrush & tailBrush () const
 Get the tail brush.
 
void setTailBrush (const QBrush &brush)
 Set the tail brush.
 
const QPen & headPen () const
 Get the head pen.
 
void setHeadPen (const QPen &pen)
 Set the head pen.
 
const QPen & tailPen () const
 Get the tail pen.
 
void setTailPen (const QPen &pen)
 Set the tail pen.
 
void setHeadCustomPath (const QPainterPath &path)
 Set a custom path for head endpoint.
 
QPainterPath headCustomPath () const
 Get the custom head path.
 
void setTailCustomPath (const QPainterPath &path)
 Set a custom path for tail endpoint.
 
QPainterPath tailCustomPath () const
 Get the custom tail path.
 
virtual void draw (QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const override
 Draw the arrow marker on the plot.
 
virtual QRectF boundingRect () const override
 Get the bounding rectangle.
 
virtual QwtGraphic legendIcon (int index, const QSizeF &size) const override
 Get the legend icon.
 
- Public Member Functions inherited from QwtPlotItem
 QwtPlotItem ()
 Default constructor.
 
 QwtPlotItem (const QString &title)
 Constructor with title as QString.
 
 QwtPlotItem (const QwtText &title)
 Constructor with title as QwtText.
 
virtual ~QwtPlotItem ()
 Destructor.
 
virtual void attach (QwtPlot *plot)
 Attach the item to a plot.
 
void detach ()
 Detach the item from the plot.
 
QwtPlotplot () const
 Get the plot the item is attached to.
 
void setTitle (const QString &title)
 Set the title using a QString.
 
void setTitle (const QwtText &title)
 Set the title using a QwtText.
 
const QwtTexttitle () const
 Get the title.
 
void setItemAttribute (ItemAttribute, bool on=true)
 Set an item attribute.
 
bool testItemAttribute (ItemAttribute) const
 Test an item attribute.
 
void setItemInterest (ItemInterest, bool on=true)
 Set an item interest.
 
bool testItemInterest (ItemInterest) const
 Test an item interest.
 
void setRenderHint (RenderHint, bool on=true)
 Set a render hint.
 
bool testRenderHint (RenderHint) const
 Test a render hint.
 
void setRenderThreadCount (uint numThreads)
 Set the number of render threads.
 
uint renderThreadCount () const
 Get the number of render threads.
 
void setLegendIconSize (const QSize &)
 Set the legend icon size.
 
QSize legendIconSize () const
 Get the legend icon size.
 
double z () const
 Get the z-value.
 
void setZ (double z)
 Set the z-value.
 
void show ()
 Show the item.
 
void hide ()
 Hide the item.
 
virtual void setVisible (bool)
 Set the visibility.
 
bool isVisible () const
 Check if the item is visible.
 
void setAxes (QwtAxisId xAxis, QwtAxisId yAxis)
 Set both axes.
 
void setXAxis (QwtAxisId)
 Set the x-axis.
 
QwtAxisId xAxis () const
 Get the x-axis.
 
void setYAxis (QwtAxisId)
 Set the y-axis.
 
QwtAxisId yAxis () const
 Get the y-axis.
 
virtual void itemChanged ()
 Notify the plot that the item has changed.
 
virtual void legendChanged ()
 Notify the item that the legend has changed.
 
virtual void getCanvasMarginHint (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const
 Get margin hints for the canvas.
 
virtual void updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &)
 Update the item with new scale divisions.
 
virtual void updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &)
 Update the item with changes of the legend.
 
QRectF scaleRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the scale rectangle.
 
QRectF paintRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the paint rectangle.
 
virtual QList< QwtLegendDatalegendData () const
 Return legend data.
 

Protected Member Functions

virtual void drawArrowLine (QPainter *painter, const QPointF &canvasStart, const QPointF &canvasEnd) const
 Draw the arrow line.
 
virtual void drawCachedEndpoint (QPainter *painter, const QPointF &position, const QPainterPath &cachedPath, const QSizeF &size, const QPen &pen, const QBrush &brush, double rotation=0.0) const
 Draw a cached endpoint path.
 
virtual QPointF toCanvasPoint (const QPointF &plotPoint, const QwtScaleMap &xMap, const QwtScaleMap &yMap) const
 Convert plot coordinates to canvas coordinates.
 
virtual QPointF calculateEndPoint () const
 Calculate end point based on start point, length, and angle.
 
- Protected Member Functions inherited from QwtPlotItem
QwtGraphic defaultIcon (const QBrush &, const QSizeF &) const
 Create a default icon.
 

Detailed Description

A class for drawing arrow markers on plots.

QwtPlotArrowMarker is a specialized plot item for drawing arrows with customizable start and end points, arrow styles, lengths, and colors. The arrow is drawn in canvas pixel coordinates, maintaining its size during zoom operations while following canvas panning.

Key features:

Member Enumeration Documentation

◆ EndpointStyle

Arrow endpoint style types.

See also
setHeadStyle(), setTailStyle(), headStyle(), tailStyle()
Enumerator
NoEndpoint 

No endpoint (invisible)

ArrowHead 

Arrow head style.

Circle 

Circle endpoint.

Square 

Square endpoint.

Diamond 

Diamond endpoint.

Triangle 

Triangle endpoint.

CustomPath 

Custom QPainterPath endpoint.

◆ PositionMode

Arrow positioning mode.

See also
setPositionMode(), positionMode()
Enumerator
ExplicitPoints 

Use explicit start and end points.

In this mode, the arrow's start and end points are specified in plot coordinates. The arrow's size will change proportionally to the plot's zoom level.

StartLengthAngle 

start point, length, and angle

in this mode, the arrow length will be fixed regardless of the zoom level

Constructor & Destructor Documentation

◆ QwtPlotArrowMarker()

QwtPlotArrowMarker::QwtPlotArrowMarker ( )
explicit

Default constructor.

Creates a new QwtPlotArrowMarker with default settings. The arrow has a length of 50 pixels, angle of 45 degrees, arrow head style, and default colors.

Constructor with title

Parameters
[in]titleTitle of the marker

Constructor with QwtText title

Parameters
[in]titleTitle of the marker

Destructor

Member Function Documentation

◆ angle()

double QwtPlotArrowMarker::angle ( ) const

Get the rotation angle in degrees.

Returns
Rotation angle in degrees

◆ boundingRect()

QRectF QwtPlotArrowMarker::boundingRect ( ) const
overridevirtual

Get the bounding rectangle.

Returns
Bounding rectangle

Reimplemented from QwtPlotItem.

◆ draw()

void QwtPlotArrowMarker::draw ( QPainter *  painter,
const QwtScaleMap xMap,
const QwtScaleMap yMap,
const QRectF &  canvasRect 
) const
overridevirtual

Draw the arrow marker on the plot.

Parameters
[in]painterThe painter to use for drawing
[in]xMapX-axis scale map for coordinate transformation
[in]yMapY-axis scale map for coordinate transformation
[in]canvasRectThe canvas rectangle in painter coordinates

This method draws the arrow marker including the line, head, and tail endpoints. It handles both positioning modes (ExplicitPoints and StartLengthAngle) and applies proper rotation to endpoints based on arrow direction.

Implements QwtPlotItem.

◆ drawCachedEndpoint()

void QwtPlotArrowMarker::drawCachedEndpoint ( QPainter *  painter,
const QPointF &  position,
const QPainterPath &  cachedPath,
const QSizeF &  size,
const QPen &  pen,
const QBrush &  brush,
double  rotation = 0.0 
) const
protectedvirtual

Draw a cached endpoint path.

Parameters
[in]painterThe painter to use for drawing
[in]positionThe position to draw the endpoint at (canvas coordinates)
[in]cachedPathThe pre-cached QPainterPath for the endpoint
[in]sizeThe size of the endpoint in pixels
[in]penThe pen to use for drawing the endpoint outline
[in]brushThe brush to use for filling the endpoint
[in]rotationThe rotation angle in degrees (0 = positive X direction)

This method draws a cached endpoint path with proper scaling, positioning, and rotation. It is optimized for performance by reusing pre-computed QPainterPath objects.

◆ endPoint()

QPointF QwtPlotArrowMarker::endPoint ( ) const

Get the end point of the arrow.

Returns
End point in plot coordinates

◆ headBrush()

const QBrush & QwtPlotArrowMarker::headBrush ( ) const

Get the head brush.

Returns
Head brush

◆ headCustomPath()

QPainterPath QwtPlotArrowMarker::headCustomPath ( ) const

Get the custom head path.

Returns
Custom head path

◆ headPen()

const QPen & QwtPlotArrowMarker::headPen ( ) const

Get the head pen.

Returns
Head pen

◆ headSize()

QSizeF QwtPlotArrowMarker::headSize ( ) const

Get the head size in pixels.

Returns
Head size in pixels

◆ headStyle()

QwtPlotArrowMarker::EndpointStyle QwtPlotArrowMarker::headStyle ( ) const

Get the head style.

Returns
Head style

◆ legendIcon()

QwtGraphic QwtPlotArrowMarker::legendIcon ( int  index,
const QSizeF &  size 
) const
overridevirtual

Get the legend icon.

Parameters
[in]indexIndex of the legend entry
[in]sizeSize of the icon
Returns
Legend icon graphic

Reimplemented from QwtPlotItem.

◆ length()

double QwtPlotArrowMarker::length ( ) const

Get the arrow length in pixels.

Returns
Arrow length in pixels

◆ linePen()

const QPen & QwtPlotArrowMarker::linePen ( ) const

Get the arrow line pen.

Returns
Arrow line pen

◆ positionMode()

QwtPlotArrowMarker::PositionMode QwtPlotArrowMarker::positionMode ( ) const

Get the positioning mode.

Returns
Positioning mode

◆ rtti()

int QwtPlotArrowMarker::rtti ( ) const
overridevirtual

Get the runtime type information.

Returns
The RTTI value for QwtPlotArrowMarker (QwtPlotItem::Rtti_PlotArrowMarker)

Reimplemented from QwtPlotItem.

◆ setAngle()

void QwtPlotArrowMarker::setAngle ( double  angle)

Set the rotation angle in degrees.

Parameters
[in]angleRotation angle in degrees

◆ setEndPoint()

void QwtPlotArrowMarker::setEndPoint ( const QPointF &  point)

Set the end point in plot coordinates.

Parameters
[in]pointEnd point in plot coordinates

◆ setHeadBrush()

void QwtPlotArrowMarker::setHeadBrush ( const QBrush &  brush)

Set the head brush.

Parameters
[in]brushHead brush

◆ setHeadCustomPath()

void QwtPlotArrowMarker::setHeadCustomPath ( const QPainterPath &  path)

Set a custom path for head endpoint.

Parameters
[in]pathCustom QPainterPath for head

◆ setHeadPen()

void QwtPlotArrowMarker::setHeadPen ( const QPen &  pen)

Set the head pen.

Parameters
[in]penHead pen

◆ setHeadSize() [1/2]

void QwtPlotArrowMarker::setHeadSize ( const QSizeF &  size)

Set the head size in pixels.

Parameters
[in]sizeHead size in pixels

◆ setHeadSize() [2/2]

void QwtPlotArrowMarker::setHeadSize ( qreal  size)

Convenience method to set head size with equal width and height.

Parameters
[in]sizeHead size (both width and height)

◆ setHeadStyle()

void QwtPlotArrowMarker::setHeadStyle ( EndpointStyle  style)

Set the head style.

Parameters
[in]styleHead style

◆ setLength()

void QwtPlotArrowMarker::setLength ( double  length)

Set the arrow length in pixels.

Parameters
[in]lengthThe arrow length in pixels (must be non-negative)

The arrow length is used when position mode is StartLengthAngle. Invalid values (NaN, Infinity) are rejected with a warning.

◆ setLinePen() [1/2]

void QwtPlotArrowMarker::setLinePen ( const QColor &  color,
qreal  width = 1.0,
Qt::PenStyle  style = Qt::SolidLine 
)

Convenience method to set line color and width.

Parameters
[in]colorLine color
[in]widthLine width
[in]styleLine style

◆ setLinePen() [2/2]

void QwtPlotArrowMarker::setLinePen ( const QPen &  pen)

Set the arrow line pen.

Parameters
[in]penArrow line pen

◆ setPoints()

void QwtPlotArrowMarker::setPoints ( const QPointF &  start,
const QPointF &  end 
)

Set both start and end points in plot coordinates.

Parameters
[in]startStart point in plot coordinates
[in]endEnd point in plot coordinates

◆ setPositionMode()

void QwtPlotArrowMarker::setPositionMode ( PositionMode  mode)

Set the positioning mode.

Parameters
[in]modePositioning mode

◆ setStartPoint()

void QwtPlotArrowMarker::setStartPoint ( const QPointF &  point)

Set the start point in plot coordinates.

Parameters
[in]pointStart point in plot coordinates

◆ setTailBrush()

void QwtPlotArrowMarker::setTailBrush ( const QBrush &  brush)

Set the tail brush.

Parameters
[in]brushTail brush

◆ setTailCustomPath()

void QwtPlotArrowMarker::setTailCustomPath ( const QPainterPath &  path)

Set a custom path for tail endpoint.

Parameters
[in]pathCustom QPainterPath for tail

◆ setTailPen()

void QwtPlotArrowMarker::setTailPen ( const QPen &  pen)

Set the tail pen.

Parameters
[in]penTail pen

◆ setTailSize() [1/2]

void QwtPlotArrowMarker::setTailSize ( const QSizeF &  size)

Set the tail size in pixels.

Parameters
[in]sizeTail size in pixels

◆ setTailSize() [2/2]

void QwtPlotArrowMarker::setTailSize ( qreal  size)

Convenience method to set tail size with equal width and height.

Parameters
[in]sizeTail size (both width and height)

◆ setTailStyle()

void QwtPlotArrowMarker::setTailStyle ( EndpointStyle  style)

Set the tail style.

Parameters
[in]styleTail style

◆ startPoint()

QPointF QwtPlotArrowMarker::startPoint ( ) const

Get the start point of the arrow.

Returns
The start point in plot coordinates

◆ tailBrush()

const QBrush & QwtPlotArrowMarker::tailBrush ( ) const

Get the tail brush.

Returns
Tail brush

◆ tailCustomPath()

QPainterPath QwtPlotArrowMarker::tailCustomPath ( ) const

Get the custom tail path.

Returns
Custom tail path

◆ tailPen()

const QPen & QwtPlotArrowMarker::tailPen ( ) const

Get the tail pen.

Returns
Tail pen

◆ tailSize()

QSizeF QwtPlotArrowMarker::tailSize ( ) const

Get the tail size in pixels.

Returns
Tail size in pixels

◆ tailStyle()

QwtPlotArrowMarker::EndpointStyle QwtPlotArrowMarker::tailStyle ( ) const

Get the tail style.

Returns
Tail style

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