QWT 7.0.1
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | List of all members
QwtPlotTextLabel Class Reference

A plot item, which displays a text label. More...

#include <qwt_plot_textlabel.h>

Inheritance diagram for QwtPlotTextLabel:
QwtPlotItem

Classes

class  PrivateData
 

Public Member Functions

 QwtPlotTextLabel ()
 Constructor.
 
virtual ~QwtPlotTextLabel ()
 Destructor.
 
virtual int rtti () const QWT_OVERRIDE
 
void setText (const QwtText &)
 Set the text.
 
QwtText text () const
 
void setMargin (int margin)
 Set the margin.
 
int margin () const
 
virtual QRectF textRect (const QRectF &, const QSizeF &) const
 Align the text label.
 
- Public Member Functions inherited from QwtPlotItem
 QwtPlotItem ()
 Constructor.
 
 QwtPlotItem (const QString &title)
 Constructor.
 
 QwtPlotItem (const QwtText &title)
 Constructor.
 
virtual ~QwtPlotItem ()
 Destroy the QwtPlotItem.
 
void attach (QwtPlot *plot)
 Attach the item to a plot.
 
void detach ()
 This method detaches a QwtPlotItem from any QwtPlot it has been associated with.
 
QwtPlotplot () const
 Return attached plot.
 
void setTitle (const QString &title)
 Set a new title.
 
void setTitle (const QwtText &title)
 Set a new title.
 
const QwtTexttitle () const
 
void setItemAttribute (ItemAttribute, bool on=true)
 Toggle an item attribute.
 
bool testItemAttribute (ItemAttribute) const
 Test an item attribute.
 
void setItemInterest (ItemInterest, bool on=true)
 Toggle an item interest.
 
bool testItemInterest (ItemInterest) const
 Test an item interest.
 
void setRenderHint (RenderHint, bool on=true)
 Toggle an render hint.
 
bool testRenderHint (RenderHint) const
 Test a render hint.
 
void setRenderThreadCount (uint numThreads)
 On multi core systems rendering of certain plot item ( f.e QwtPlotRasterItem ) can be done in parallel in several threads.
 
uint renderThreadCount () const
 
void setLegendIconSize (const QSize &)
 Set the size of the legend icon.
 
QSize legendIconSize () const
 
double z () const
 Plot items are painted in increasing z-order.
 
void setZ (double z)
 Set the z value.
 
void show ()
 Show the item.
 
void hide ()
 Hide the item.
 
virtual void setVisible (bool)
 Show/Hide the item.
 
bool isVisible () const
 
void setAxes (QwtAxisId xAxis, QwtAxisId yAxis)
 Set X and Y axis.
 
void setXAxis (QwtAxisId)
 Set the X axis.
 
QwtAxisId xAxis () const
 Return xAxis.
 
void setYAxis (QwtAxisId)
 Set the Y axis.
 
QwtAxisId yAxis () const
 Return yAxis.
 
virtual void itemChanged ()
 Update the legend and call QwtPlot::autoRefresh() for the parent plot.
 
virtual void legendChanged ()
 Update the legend of the parent plot.
 
virtual QRectF boundingRect () const
 
virtual void getCanvasMarginHint (const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect, double &left, double &top, double &right, double &bottom) const
 Calculate a hint for the canvas margin.
 
virtual void updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &)
 Update the item to changes of the axes scale division.
 
virtual void updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &)
 Update the item to changes of the legend info.
 
QRectF scaleRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the bounding scale rectangle of 2 maps.
 
QRectF paintRect (const QwtScaleMap &, const QwtScaleMap &) const
 Calculate the bounding paint rectangle of 2 maps.
 
virtual QList< QwtLegendDatalegendData () const
 Return all information, that is needed to represent the item on the legend.
 
virtual QwtGraphic legendIcon (int index, const QSizeF &) const
 

Protected Member Functions

virtual void draw (QPainter *, const QwtScaleMap &, const QwtScaleMap &, const QRectF &) const QWT_OVERRIDE
 Draw the text label.
 
void invalidateCache ()
 Invalidate all internal cache.
 
- Protected Member Functions inherited from QwtPlotItem
QwtGraphic defaultIcon (const QBrush &, const QSizeF &) const
 Return a default icon from a brush.
 

Additional Inherited Members

- 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_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...
 

Detailed Description

A plot item, which displays a text label.

QwtPlotTextLabel displays a text label aligned to the plot canvas.

In opposite to QwtPlotMarker the position of the label is unrelated to plot coordinates.

As drawing a text is an expensive operation the label is cached in a pixmap to speed up replots.

Example
The following code shows how to add a title.
QwtText title( "Plot Title" );
title.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop );
QFont font;
font.setBold( true );
title.setFont( font );
titleItem->setText( title );
titleItem->attach( plot );
const QwtText & title() const
Definition qwt_plot_item.cpp:232
QwtPlot * plot() const
Return attached plot.
Definition qwt_plot_item.cpp:159
void attach(QwtPlot *plot)
Attach the item to a plot.
Definition qwt_plot_item.cpp:115
A plot item, which displays a text label.
Definition qwt_plot_textlabel.h:65
QwtPlotTextLabel()
Constructor.
Definition qwt_plot_textlabel.cpp:99
void setText(const QwtText &)
Set the text.
Definition qwt_plot_textlabel.cpp:132
A class representing a text.
Definition qwt_text.h:69
void setFont(const QFont &)
Set the font.
Definition qwt_text.cpp:327
void setRenderFlags(int)
Change the render flags.
Definition qwt_text.cpp:303
See also
QwtPlotMarker

Constructor & Destructor Documentation

◆ QwtPlotTextLabel()

QwtPlotTextLabel::QwtPlotTextLabel ( )

Constructor.

Initializes an text label with an empty text

Sets the following item attributes:

The z value is initialized by 150

See also
QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ()

Member Function Documentation

◆ draw()

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

Draw the text label.

Parameters
painterPainter
xMapx Scale Map
yMapy Scale Map
canvasRectContents rectangle of the canvas in painter coordinates
See also
textRect()

Implements QwtPlotItem.

◆ margin()

int QwtPlotTextLabel::margin ( ) const
Returns
Margin added to the contentsMargins() of the canvas
See also
setMargin()

◆ rtti()

int QwtPlotTextLabel::rtti ( ) const
virtual
Returns
QwtPlotItem::Rtti_PlotTextLabel

Reimplemented from QwtPlotItem.

◆ setMargin()

void QwtPlotTextLabel::setMargin ( int  margin)

Set the margin.

The margin is the distance between the contentsRect() of the plot canvas and the rectangle where the label can be displayed.

Parameters
marginMargin
See also
margin(), textRect()

◆ setText()

void QwtPlotTextLabel::setText ( const QwtText text)

Set the text.

The label will be aligned to the plot canvas according to the alignment flags of text.

Parameters
textText to be displayed
See also
text(), QwtText::renderFlags()

◆ text()

QwtText QwtPlotTextLabel::text ( ) const
Returns
Text to be displayed
See also
setText()

◆ textRect()

QRectF QwtPlotTextLabel::textRect ( const QRectF &  rect,
const QSizeF &  textSize 
) const
virtual

Align the text label.

Parameters
rectCanvas rectangle with margins subtracted
textSizeSize required to draw the text
Returns
A rectangle aligned according the the alignment flags of the text.
See also
setMargin(), QwtText::renderFlags(), QwtText::textSize()

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