A class which draws a legend inside the plot canvas. More...
#include <qwt_plot_legenditem.h>
Classes | |
class | PrivateData |
Public Types | |
enum | BackgroundMode { LegendBackground, ItemBackground } |
Background mode. More... | |
Public Types inherited from QwtPlotItem | |
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... | |
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... | |
Public Member Functions | |
Qt::Alignment | alignmentInCanvas () const |
QBrush | backgroundBrush () const |
BackgroundMode | backgroundMode () const |
QPen | borderPen () const |
double | borderRadius () const |
void | clearLegend () |
Remove all items from the legend. More... | |
virtual void | draw (QPainter *, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &canvasRect) const QWT_OVERRIDE |
QFont | font () const |
virtual QRect | geometry (const QRectF &canvasRect) const |
virtual int | heightForWidth (const QwtLegendData &, int width) const |
int | itemMargin () const |
int | itemSpacing () const |
QList< QRect > | legendGeometries (const QwtPlotItem *) const |
int | margin () const |
uint | maxColumns () const |
virtual QSize | minimumSize (const QwtLegendData &) const |
int | offsetInCanvas (Qt::Orientation) const |
QList< const QwtPlotItem * > | plotItems () const |
QwtPlotLegendItem () | |
Constructor. More... | |
virtual int | rtti () const QWT_OVERRIDE |
void | setAlignmentInCanvas (Qt::Alignment) |
Set the alignmnet. More... | |
void | setBackgroundBrush (const QBrush &) |
Set the background brush. More... | |
void | setBackgroundMode (BackgroundMode) |
Set the background mode. More... | |
void | setBorderPen (const QPen &) |
void | setBorderRadius (double) |
void | setFont (const QFont &) |
void | setItemMargin (int) |
void | setItemSpacing (int) |
void | setMargin (int) |
Set the margin around legend items. More... | |
void | setMaxColumns (uint) |
Limit the number of columns. More... | |
void | setOffsetInCanvas (Qt::Orientations, int numPixels) |
Set the distance between the legend and the canvas border. More... | |
void | setSpacing (int) |
Set the spacing between the legend items. More... | |
void | setTextPen (const QPen &) |
Set the pen for drawing text labels. More... | |
int | spacing () const |
QPen | textPen () const |
virtual void | updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &) QWT_OVERRIDE |
virtual | ~QwtPlotLegendItem () |
Destructor. More... | |
Public Member Functions inherited from QwtPlotItem | |
void | attach (QwtPlot *plot) |
Attach the item to a plot. More... | |
virtual QRectF | boundingRect () const |
void | detach () |
This method detaches a QwtPlotItem from any QwtPlot it has been associated with. More... | |
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. More... | |
void | hide () |
Hide the item. More... | |
bool | isVisible () const |
virtual void | itemChanged () |
virtual void | legendChanged () |
virtual QList< QwtLegendData > | legendData () const |
Return all information, that is needed to represent the item on the legend. More... | |
virtual QwtGraphic | legendIcon (int index, const QSizeF &) const |
QSize | legendIconSize () const |
QRectF | paintRect (const QwtScaleMap &, const QwtScaleMap &) const |
Calculate the bounding paint rectangle of 2 maps. More... | |
QwtPlot * | plot () const |
Return attached plot. More... | |
QwtPlotItem () | |
QwtPlotItem (const QString &title) | |
QwtPlotItem (const QwtText &title) | |
uint | renderThreadCount () const |
QRectF | scaleRect (const QwtScaleMap &, const QwtScaleMap &) const |
Calculate the bounding scale rectangle of 2 maps. More... | |
void | setAxes (QwtAxisId xAxis, QwtAxisId yAxis) |
void | setItemAttribute (ItemAttribute, bool on=true) |
void | setItemInterest (ItemInterest, bool on=true) |
void | setLegendIconSize (const QSize &) |
void | setRenderHint (RenderHint, bool on=true) |
void | setRenderThreadCount (uint numThreads) |
void | setTitle (const QString &title) |
void | setTitle (const QwtText &title) |
virtual void | setVisible (bool) |
void | setXAxis (QwtAxisId) |
void | setYAxis (QwtAxisId) |
void | setZ (double z) |
Set the z value. More... | |
void | show () |
Show the item. More... | |
bool | testItemAttribute (ItemAttribute) const |
bool | testItemInterest (ItemInterest) const |
bool | testRenderHint (RenderHint) const |
const QwtText & | title () const |
virtual void | updateScaleDiv (const QwtScaleDiv &, const QwtScaleDiv &) |
Update the item to changes of the axes scale division. More... | |
QwtAxisId | xAxis () const |
Return xAxis. More... | |
QwtAxisId | yAxis () const |
Return yAxis. More... | |
double | z () const |
virtual | ~QwtPlotItem () |
Destroy the QwtPlotItem. More... | |
Protected Member Functions | |
virtual void | drawBackground (QPainter *, const QRectF &rect) const |
virtual void | drawLegendData (QPainter *, const QwtPlotItem *, const QwtLegendData &, const QRectF &) const |
Protected Member Functions inherited from QwtPlotItem | |
QwtGraphic | defaultIcon (const QBrush &, const QSizeF &) const |
Return a default icon from a brush. More... | |
Private Attributes | |
PrivateData * | m_data |
A class which draws a legend inside the plot canvas.
QwtPlotLegendItem can be used to draw a inside the plot canvas. It can be used together with a QwtLegend or instead of it to have more space for the plot canvas.
In opposite to QwtLegend the legend item is not interactive. To identify mouse clicks on a legend item an event filter needs to be installed catching mouse events ob the plot canvas. The geometries of the legend items are available using legendGeometries().
The legend item is aligned to plot canvas according to its alignment() flags. It might have a background for the complete legend ( usually semi transparent ) or for each legend item.
Definition at line 41 of file qwt_plot_legenditem.h.
Background mode.
Depending on the mode the complete legend or each item might have an background.
The default setting is LegendBackground.
Enumerator | |
---|---|
LegendBackground | The legend has a background. |
ItemBackground | Each item has a background. |
Definition at line 54 of file qwt_plot_legenditem.h.
|
explicit |
Constructor.
Definition at line 175 of file qwt_plot_legenditem.cpp.
|
virtual |
Destructor.
Definition at line 185 of file qwt_plot_legenditem.cpp.
Qt::Alignment QwtPlotLegendItem::alignmentInCanvas | ( | ) | const |
Definition at line 223 of file qwt_plot_legenditem.cpp.
QBrush QwtPlotLegendItem::backgroundBrush | ( | ) | const |
Definition at line 522 of file qwt_plot_legenditem.cpp.
QwtPlotLegendItem::BackgroundMode QwtPlotLegendItem::backgroundMode | ( | ) | const |
Definition at line 550 of file qwt_plot_legenditem.cpp.
QPen QwtPlotLegendItem::borderPen | ( | ) | const |
Definition at line 496 of file qwt_plot_legenditem.cpp.
double QwtPlotLegendItem::borderRadius | ( | ) | const |
Definition at line 472 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::clearLegend | ( | ) |
Remove all items from the legend.
Definition at line 759 of file qwt_plot_legenditem.cpp.
|
virtual |
Draw the legend
painter | Painter |
xMap | x Scale Map |
yMap | y Scale Map |
canvasRect | Contents rectangle of the canvas in painter coordinates |
Implements QwtPlotItem.
Reimplemented in PlotLegend.
Definition at line 587 of file qwt_plot_legenditem.cpp.
|
protectedvirtual |
Draw a rounded rect
painter | Painter |
rect | Bounding rectangle |
Reimplemented in PlotLegend.
Definition at line 630 of file qwt_plot_legenditem.cpp.
|
protectedvirtual |
Draw an entry on the legend
painter | Qt Painter |
plotItem | Plot item, represented by the entry |
data | Attributes of the legend entry |
rect | Bounding rectangle for the entry |
Reimplemented in PlotLegend.
Definition at line 780 of file qwt_plot_legenditem.cpp.
QFont QwtPlotLegendItem::font | ( | ) | const |
Definition at line 389 of file qwt_plot_legenditem.cpp.
|
virtual |
Calculate the geometry of the legend on the canvas
canvasRect | Geometry of the canvas |
Definition at line 650 of file qwt_plot_legenditem.cpp.
|
virtual |
data | Attributes of the legend entry |
width | Width |
Definition at line 862 of file qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::itemMargin | ( | ) | const |
Definition at line 335 of file qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::itemSpacing | ( | ) | const |
Definition at line 363 of file qwt_plot_legenditem.cpp.
QList< QRect > QwtPlotLegendItem::legendGeometries | ( | const QwtPlotItem * | plotItem | ) | const |
Definition at line 895 of file qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::margin | ( | ) | const |
Definition at line 280 of file qwt_plot_legenditem.cpp.
uint QwtPlotLegendItem::maxColumns | ( | ) | const |
Definition at line 251 of file qwt_plot_legenditem.cpp.
|
virtual |
Minimum size hint needed to display an entry
data | Attributes of the legend entry |
Definition at line 823 of file qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::offsetInCanvas | ( | Qt::Orientation | orientation | ) | const |
orientation | Qt::Horizontal is for the left/right, Qt::Vertical for the top/bottom padding. |
Definition at line 444 of file qwt_plot_legenditem.cpp.
QList< const QwtPlotItem * > QwtPlotLegendItem::plotItems | ( | ) | const |
Definition at line 886 of file qwt_plot_legenditem.cpp.
|
virtual |
Reimplemented from QwtPlotItem.
Definition at line 192 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setAlignmentInCanvas | ( | Qt::Alignment | alignment | ) |
Set the alignmnet.
Alignment means the position of the legend relative to the geometry of the plot canvas.
alignment | Alignment flags |
Definition at line 210 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setBackgroundBrush | ( | const QBrush & | brush | ) |
Set the background brush.
The brush is used to fill the background
brush | Brush |
Definition at line 509 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setBackgroundMode | ( | BackgroundMode | mode | ) |
Set the background mode.
Depending on the mode the complete legend or each item might have an background.
The default setting is LegendBackground.
Definition at line 537 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setBorderPen | ( | const QPen & | pen | ) |
Set the pen for drawing the border
pen | Border pen |
Definition at line 483 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setBorderRadius | ( | double | radius | ) |
Set the radius for the border
radius | A value <= 0 defines a rectangular border |
Definition at line 457 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setFont | ( | const QFont & | font | ) |
Change the font used for drawing the text label
font | Legend font |
Definition at line 374 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setItemMargin | ( | int | margin | ) |
Set the margin around each item
margin | Margin |
Definition at line 319 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setItemSpacing | ( | int | spacing | ) |
Set the spacing inside of each item
spacing | Spacing |
Definition at line 346 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setMargin | ( | int | margin | ) |
Set the margin around legend items.
The default setting for the margin is 0.
margin | Margin in pixels |
Definition at line 264 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setMaxColumns | ( | uint | maxColumns | ) |
Limit the number of columns.
When aligning the legend horizontally ( Qt::AlignLeft, Qt::AlignRight ) the number of columns needs to be limited to avoid, that the width of the legend grows with an increasing number of entries.
maxColumns | Maximum number of columns. 0 means unlimited. |
Definition at line 238 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setOffsetInCanvas | ( | Qt::Orientations | orientations, |
int | numPixels | ||
) |
Set the distance between the legend and the canvas border.
The default setting is 10 pixels.
orientations | Qt::Horizontal is for the left/right, Qt::Vertical for the top/bottom offset. |
numPixels | Distance in pixels |
Definition at line 405 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setSpacing | ( | int | spacing | ) |
Set the spacing between the legend items.
spacing | Spacing in pixels |
Definition at line 294 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setTextPen | ( | const QPen & | pen | ) |
Set the pen for drawing text labels.
pen | Text pen |
Definition at line 561 of file qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::spacing | ( | ) | const |
Definition at line 308 of file qwt_plot_legenditem.cpp.
QPen QwtPlotLegendItem::textPen | ( | ) | const |
Definition at line 574 of file qwt_plot_legenditem.cpp.
|
virtual |
Update the legend items according to modifications of a plot item
plotItem | Plot item |
data | Attributes of the legend entries |
Reimplemented from QwtPlotItem.
Definition at line 697 of file qwt_plot_legenditem.cpp.
|
private |
Definition at line 131 of file qwt_plot_legenditem.h.