Qwt User's Guide  6.1.2
 All Classes Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | Protected Member Functions | List of all members
QwtPlotMarker Class Reference

A class for drawing markers. More...

#include <qwt_plot_marker.h>

Inheritance diagram for QwtPlotMarker:
Inheritance graph
[legend]

Public Types

enum  LineStyle { NoLine, HLine, VLine, Cross }
 
- 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_PlotSVG, Rtti_PlotTradingCurve,
  Rtti_PlotBarChart, Rtti_PlotMultiBarChart, Rtti_PlotShape, Rtti_PlotTextLabel,
  Rtti_PlotZone, 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...
 
typedef QFlags< ItemAttributeItemAttributes
 Plot Item Attributes.
 
typedef QFlags< ItemInterestItemInterests
 Plot Item Interests.
 
typedef QFlags< RenderHintRenderHints
 Render hints.
 

Public Member Functions

 QwtPlotMarker (const QString &title=QString::null)
 Sets alignment to Qt::AlignCenter, and style to QwtPlotMarker::NoLine.
 
 QwtPlotMarker (const QwtText &title)
 Sets alignment to Qt::AlignCenter, and style to QwtPlotMarker::NoLine.
 
virtual ~QwtPlotMarker ()
 Destructor.
 
virtual int rtti () const
 
double xValue () const
 Return x Value.
 
double yValue () const
 Return y Value.
 
QPointF value () const
 Return Value.
 
void setXValue (double)
 Set X Value.
 
void setYValue (double)
 Set Y Value.
 
void setValue (double, double)
 Set Value.
 
void setValue (const QPointF &)
 Set Value.
 
void setLineStyle (LineStyle st)
 Set the line style. More...
 
LineStyle lineStyle () const
 
void setLinePen (const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
 
void setLinePen (const QPen &p)
 
const QPen & linePen () const
 
void setSymbol (const QwtSymbol *)
 Assign a symbol. More...
 
const QwtSymbolsymbol () const
 
void setLabel (const QwtText &)
 Set the label. More...
 
QwtText label () const
 
void setLabelAlignment (Qt::Alignment)
 Set the alignment of the label. More...
 
Qt::Alignment labelAlignment () const
 
void setLabelOrientation (Qt::Orientation)
 Set the orientation of the label. More...
 
Qt::Orientation labelOrientation () const
 
void setSpacing (int)
 Set the spacing. More...
 
int spacing () const
 
virtual void draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &) const
 
virtual QRectF boundingRect () const
 
virtual QwtGraphic legendIcon (int index, const QSizeF &) const
 
- Public Member Functions inherited from QwtPlotItem
 QwtPlotItem (const QwtText &title=QwtText())
 
virtual ~QwtPlotItem ()
 Destroy the QwtPlotItem.
 
void attach (QwtPlot *plot)
 Attach the item to a plot. More...
 
void detach ()
 This method detaches a QwtPlotItem from any QwtPlot it has been associated with. More...
 
QwtPlotplot () const
 Return attached plot.
 
void setTitle (const QString &title)
 
void setTitle (const QwtText &title)
 
const QwtTexttitle () const
 
void setItemAttribute (ItemAttribute, bool on=true)
 
bool testItemAttribute (ItemAttribute) const
 
void setItemInterest (ItemInterest, bool on=true)
 
bool testItemInterest (ItemInterest) const
 
void setRenderHint (RenderHint, bool on=true)
 
bool testRenderHint (RenderHint) const
 
void setRenderThreadCount (uint numThreads)
 
uint renderThreadCount () const
 
void setLegendIconSize (const QSize &)
 
QSize legendIconSize () const
 
double z () const
 
void setZ (double z)
 Set the z value. More...
 
void show ()
 Show the item.
 
void hide ()
 Hide the item.
 
virtual void setVisible (bool)
 
bool isVisible () const
 
void setAxes (int xAxis, int yAxis)
 
void setXAxis (int axis)
 
int xAxis () const
 Return xAxis.
 
void setYAxis (int axis)
 
int yAxis () const
 Return yAxis.
 
virtual void itemChanged ()
 
virtual void legendChanged ()
 
virtual void getCanvasMarginHint (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasSize, double &left, double &top, double &right, double &bottom) const
 Calculate a hint for the canvas margin. More...
 
virtual void updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &)
 Update the item to changes of the axes scale division. More...
 
virtual void updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &)
 Update the item to changes of the legend info. More...
 
QRectF scaleRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the bounding scale rectangle of 2 maps. More...
 
QRectF paintRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the bounding paint rectangle of 2 maps. More...
 
virtual QList< QwtLegendDatalegendData () const
 Return all information, that is needed to represent the item on the legend. More...
 

Protected Member Functions

virtual void drawLines (QPainter *, const QRectF &, const QPointF &) const
 
virtual void drawLabel (QPainter *, const QRectF &, const QPointF &) const
 
- Protected Member Functions inherited from QwtPlotItem
QwtGraphic defaultIcon (const QBrush &, const QSizeF &) const
 Return a default icon from a brush. More...
 

Detailed Description

A class for drawing markers.

A marker can be a horizontal line, a vertical line, a symbol, a label or any combination of them, which can be drawn around a center point inside a bounding rectangle.

The setSymbol() member assigns a symbol to the marker. The symbol is drawn at the specified point.

With setLabel(), a label can be assigned to the marker. The setLabelAlignment() member specifies where the label is drawn. All the Align*-constants in Qt::AlignmentFlags (see Qt documentation) are valid. The interpretation of the alignment depends on the marker's line style. The alignment refers to the center point of the marker, which means, for example, that the label would be printed left above the center point if the alignment was set to Qt::AlignLeft | Qt::AlignTop.

Note
QwtPlotTextLabel is intended to align a text label according to the geometry of canvas ( unrelated to plot coordinates )

Member Enumeration Documentation

Line styles.

See Also
setLineStyle(), lineStyle()
Enumerator
NoLine 

No line.

HLine 

A horizontal line.

VLine 

A vertical line.

Cross 

A crosshair.

Member Function Documentation

QRectF QwtPlotMarker::boundingRect ( ) const
virtual
Returns
An invalid bounding rect: QRectF(1.0, 1.0, -2.0, -2.0)
Note
A width or height < 0.0 is ignored by the autoscaler

Reimplemented from QwtPlotItem.

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

Draw the marker

Parameters
painterPainter
xMapx Scale Map
yMapy Scale Map
canvasRectContents rectangle of the canvas in painter coordinates

Implements QwtPlotItem.

void QwtPlotMarker::drawLabel ( QPainter *  painter,
const QRectF &  canvasRect,
const QPointF &  pos 
) const
protectedvirtual

Align and draw the text label of the marker

Parameters
painterPainter
canvasRectContents rectangle of the canvas in painter coordinates
posPosition of the marker, translated into widget coordinates
See Also
drawLabel(), QwtSymbol::drawSymbol()
void QwtPlotMarker::drawLines ( QPainter *  painter,
const QRectF &  canvasRect,
const QPointF &  pos 
) const
protectedvirtual

Draw the lines marker

Parameters
painterPainter
canvasRectContents rectangle of the canvas in painter coordinates
posPosition of the marker, translated into widget coordinates
See Also
drawLabel(), QwtSymbol::drawSymbol()
QwtText QwtPlotMarker::label ( ) const
Returns
the label
See Also
setLabel()
Qt::Alignment QwtPlotMarker::labelAlignment ( ) const
Returns
the label alignment
See Also
setLabelAlignment(), setLabelOrientation()
Qt::Orientation QwtPlotMarker::labelOrientation ( ) const
Returns
the label orientation
See Also
setLabelOrientation(), labelAlignment()
QwtGraphic QwtPlotMarker::legendIcon ( int  index,
const QSizeF &  size 
) const
virtual
Returns
Icon representing the marker on the legend
Parameters
indexIndex of the legend entry ( usually there is only one )
sizeIcon size
See Also
setLegendIconSize(), legendData()

Reimplemented from QwtPlotItem.

const QPen & QwtPlotMarker::linePen ( ) const
Returns
the line pen
See Also
setLinePen()
QwtPlotMarker::LineStyle QwtPlotMarker::lineStyle ( ) const
Returns
the line style
See Also
setLineStyle()
int QwtPlotMarker::rtti ( ) const
virtual
Returns
QwtPlotItem::Rtti_PlotMarker

Reimplemented from QwtPlotItem.

void QwtPlotMarker::setLabel ( const QwtText label)

Set the label.

Parameters
labelLabel text
See Also
label()
void QwtPlotMarker::setLabelAlignment ( Qt::Alignment  align)

Set the alignment of the label.

In case of QwtPlotMarker::HLine the alignment is relative to the y position of the marker, but the horizontal flags correspond to the canvas rectangle. In case of QwtPlotMarker::VLine the alignment is relative to the x position of the marker, but the vertical flags correspond to the canvas rectangle.

In all other styles the alignment is relative to the marker's position.

Parameters
alignAlignment.
See Also
labelAlignment(), labelOrientation()
void QwtPlotMarker::setLabelOrientation ( Qt::Orientation  orientation)

Set the orientation of the label.

When orientation is Qt::Vertical the label is rotated by 90.0 degrees ( from bottom to top ).

Parameters
orientationOrientation of the label
See Also
labelOrientation(), setLabelAlignment()
void QwtPlotMarker::setLinePen ( const QColor &  color,
qreal  width = 0.0,
Qt::PenStyle  style = Qt::SolidLine 
)

Build and assign a line pen

In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it non cosmetic ( see QPen::isCosmetic() ). This method has been introduced to hide this incompatibility.

Parameters
colorPen color
widthPen width
stylePen style
See Also
pen(), brush()
void QwtPlotMarker::setLinePen ( const QPen &  pen)

Specify a pen for the line.

Parameters
penNew pen
See Also
linePen()
void QwtPlotMarker::setLineStyle ( LineStyle  style)

Set the line style.

Parameters
styleLine style.
See Also
lineStyle()
void QwtPlotMarker::setSpacing ( int  spacing)

Set the spacing.

When the label is not centered on the marker position, the spacing is the distance between the position and the label.

Parameters
spacingSpacing
See Also
spacing(), setLabelAlignment()
void QwtPlotMarker::setSymbol ( const QwtSymbol symbol)

Assign a symbol.

Parameters
symbolNew symbol
See Also
symbol()
int QwtPlotMarker::spacing ( ) const
Returns
the spacing
See Also
setSpacing()
const QwtSymbol * QwtPlotMarker::symbol ( ) const
Returns
the symbol
See Also
setSymbol(), QwtSymbol