Search for usage in LXR

Public Types

enum  EndingStyle {
  esNone , esFlatArrow , esSpikeArrow , esLineArrow ,
  esDisc , esSquare , esDiamond , esBar ,
  esHalfBar , esSkewedBar

Public Member Functions

 QCPLineEnding ()
 QCPLineEnding (EndingStyle style, double width=8, double length=10, bool inverted=false)
double boundingDistance () const
void draw (QCPPainter *painter, const QCPVector2D &pos, const QCPVector2D &dir) const
void draw (QCPPainter *painter, const QCPVector2D &pos, double angle) const
bool inverted () const
double length () const
double realLength () const
void setInverted (bool inverted)
void setLength (double length)
void setStyle (EndingStyle style)
void setWidth (double width)
EndingStyle style () const
double width () const

Protected Attributes

bool mInverted
double mLength
EndingStyle mStyle
double mWidth

Detailed Description

Handles the different ending decorations for line-like items.

The various ending styles currently supported

For every ending a line-like item has, an instance of this class exists. For example, QCPItemLine has two endings which can be set with QCPItemLine::setHead and QCPItemLine::setTail.

The styles themselves are defined via the enum QCPLineEnding::EndingStyle. Most decorations can be modified regarding width and length, see setWidth and setLength. The direction of the ending decoration (e.g. direction an arrow is pointing) is controlled by the line-like item. For example, when both endings of a QCPItemLine are set to be arrows, they will point to opposite directions, e.g. "outward". This can be changed by setInverted, which would make the respective arrow point inward.

Note that due to the overloaded QCPLineEnding constructor, you may directly specify a QCPLineEnding::EndingStyle where actually a QCPLineEnding is expected, e.g.

Definition at line 1471 of file qcustomplot.h.

Member Enumeration Documentation

◆ EndingStyle

Defines the type of ending decoration for line-like items, e.g. an arrow.

The width and length of these decorations can be controlled with the functions setWidth and setLength. Some decorations like esDisc, esSquare, esDiamond and esBar only support a width, the length property is ignored.

See also
QCPItemLine::setHead, QCPItemLine::setTail, QCPItemCurve::setHead, QCPItemCurve::setTail, QCPAxis::setLowerEnding, QCPAxis::setUpperEnding

No ending decoration.


A filled arrow head with a straight/flat back (a triangle)


A filled arrow head with an indented back.


A non-filled arrow head with open back.


A filled circle.


A filled square.


A filled diamond (45 degrees rotated square)


A bar perpendicular to the line.


A bar perpendicular to the line, pointing out to only one side (to which side can be changed with setInverted)


A bar that is skewed (skew controllable via setLength)

Definition at line 1486 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPLineEnding() [1/2]

QCPLineEnding::QCPLineEnding ( )

Creates a QCPLineEnding instance with default values (style esNone).

Definition at line 5175 of file qcustomplot.cpp.

◆ QCPLineEnding() [2/2]

QCPLineEnding::QCPLineEnding ( QCPLineEnding::EndingStyle style,
double width = 8,
double length = 10,
bool inverted = false )

Creates a QCPLineEnding instance with the specified values.

Definition at line 5186 of file qcustomplot.cpp.

Member Function Documentation

◆ boundingDistance()

double QCPLineEnding::boundingDistance ( ) const

Returns the maximum pixel radius the ending decoration might cover, starting from the position the decoration is drawn at (typically a line ending/QCPItemPosition of an item).

This is relevant for clipping. Only omit painting of the decoration when the position where the decoration is supposed to be drawn is farther away from the clipping rect than the returned distance.

Definition at line 5246 of file qcustomplot.cpp.

◆ draw() [1/2]

void QCPLineEnding::draw ( QCPPainter * painter,
const QCPVector2D & pos,
const QCPVector2D & dir ) const

Draws the line ending with the specified painter at the position pos. The direction of the line ending is controlled with dir.

Definition at line 5311 of file qcustomplot.cpp.

◆ draw() [2/2]

void QCPLineEnding::draw ( QCPPainter * painter,
const QCPVector2D & pos,
double angle ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Draws the line ending. The direction is controlled with the angle parameter in radians.

Definition at line 5432 of file qcustomplot.cpp.

◆ inverted()

bool QCPLineEnding::inverted ( ) const

Definition at line 1506 of file qcustomplot.h.

◆ length()

double QCPLineEnding::length ( ) const

Definition at line 1505 of file qcustomplot.h.

◆ realLength()

double QCPLineEnding::realLength ( ) const

Starting from the origin of this line ending (which is style specific), returns the length covered by the line ending symbol, in backward direction.

For example, the esSpikeArrow has a shorter real length than a esFlatArrow, even if both have the same setLength value, because the spike arrow has an inward curved back, which reduces the length along its center axis (the drawing origin for arrows is at the tip).

This function is used for precise, style specific placement of line endings, for example in QCPAxes.

Definition at line 5281 of file qcustomplot.cpp.

◆ setInverted()

void QCPLineEnding::setInverted ( bool inverted)

Sets whether the ending decoration shall be inverted. For example, an arrow decoration will point inward when inverted is set to true.

Note that also the width direction is inverted. For symmetrical ending styles like arrows or discs, this doesn't make a difference. However, asymmetric styles like esHalfBar are affected by it, which can be used to control to which side the half bar points to.

Definition at line 5232 of file qcustomplot.cpp.

◆ setLength()

void QCPLineEnding::setLength ( double length)

Sets the length of the ending decoration, if the style supports it. On arrows, for example, the length defines the size in pointing direction.

See also

Definition at line 5219 of file qcustomplot.cpp.

◆ setStyle()

void QCPLineEnding::setStyle ( QCPLineEnding::EndingStyle style)

Sets the style of the ending decoration.

Definition at line 5197 of file qcustomplot.cpp.

◆ setWidth()

void QCPLineEnding::setWidth ( double width)

Sets the width of the ending decoration, if the style supports it. On arrows, for example, the width defines the size perpendicular to the arrow's pointing direction.

See also

Definition at line 5208 of file qcustomplot.cpp.

◆ style()

EndingStyle QCPLineEnding::style ( ) const

Definition at line 1503 of file qcustomplot.h.

◆ width()

double QCPLineEnding::width ( ) const

Definition at line 1504 of file qcustomplot.h.

Member Data Documentation

◆ mInverted

bool QCPLineEnding::mInverted

Definition at line 1524 of file qcustomplot.h.

◆ mLength

double QCPLineEnding::mLength

Definition at line 1523 of file qcustomplot.h.

◆ mStyle

EndingStyle QCPLineEnding::mStyle

Definition at line 1522 of file qcustomplot.h.

◆ mWidth

double QCPLineEnding::mWidth

Definition at line 1523 of file qcustomplot.h.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:28 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.