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 Member Functions | |
Qt::Alignment | alignment () const |
QBrush | backgroundBrush () const |
BackgroundMode | backgroundMode () const |
int | borderDistance () const |
QPen | borderPen () const |
double | borderRadius () const |
void | clearLegend () |
Remove all items from the legend. | |
virtual void | draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRectF &rect) const |
QFont | font () const |
virtual QRect | geometry (const QRectF &canvasRect) const |
virtual int | heightForWidth (const QwtLegendData &, int w) 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 |
QList< const QwtPlotItem * > | plotItems () const |
QwtPlotLegendItem () | |
Constructor. | |
virtual int | rtti () const |
void | setAlignment (Qt::Alignment) |
Set the alignmnet. | |
void | setBackgroundBrush (const QBrush &) |
Set the background brush. | |
void | setBackgroundMode (BackgroundMode) |
Set the background mode. | |
void | setBorderDistance (int numPixels) |
Set the margin between the legend and the canvas border. | |
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. | |
void | setMaxColumns (uint) |
Limit the number of columns. | |
void | setSpacing (int) |
Set the spacing between the legend items. | |
void | setTextPen (const QPen &) |
Set the pen for drawing text labels. | |
int | spacing () const |
QPen | textPen () const |
virtual void | updateLegend (const QwtPlotItem *, const QList< QwtLegendData > &) |
virtual | ~QwtPlotLegendItem () |
Destructor. | |
Protected Member Functions | |
virtual void | drawBackground (QPainter *, const QRectF &rect) const |
virtual void | drawLegendData (QPainter *painter, const QwtPlotItem *, const QwtLegendData &, const QRectF &) const |
Private Attributes | |
PrivateData * | d_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 42 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.
LegendBackground |
The legend has a background. |
ItemBackground |
Each item has a background. |
Definition at line 55 of file qwt_plot_legenditem.h.
QwtPlotLegendItem::QwtPlotLegendItem | ( | ) | [explicit] |
Constructor.
Definition at line 170 of file qwt_plot_legenditem.cpp.
QwtPlotLegendItem::~QwtPlotLegendItem | ( | ) | [virtual] |
Destructor.
Definition at line 180 of file qwt_plot_legenditem.cpp.
Qt::Alignment QwtPlotLegendItem::alignment | ( | ) | const |
Definition at line 218 of file qwt_plot_legenditem.cpp.
QBrush QwtPlotLegendItem::backgroundBrush | ( | ) | const |
Definition at line 489 of file qwt_plot_legenditem.cpp.
Definition at line 517 of file qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::borderDistance | ( | ) | const |
Definition at line 413 of file qwt_plot_legenditem.cpp.
QPen QwtPlotLegendItem::borderPen | ( | ) | const |
Definition at line 463 of file qwt_plot_legenditem.cpp.
double QwtPlotLegendItem::borderRadius | ( | ) | const |
Definition at line 439 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::clearLegend | ( | ) |
Remove all items from the legend.
Definition at line 721 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::draw | ( | QPainter * | painter, |
const QwtScaleMap & | xMap, | ||
const QwtScaleMap & | yMap, | ||
const QRectF & | canvasRect | ||
) | const [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.
Definition at line 554 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::drawBackground | ( | QPainter * | painter, |
const QRectF & | rect | ||
) | const [protected, virtual] |
Draw a rounded rect
painter | Painter |
rect | Bounding rectangle |
Definition at line 597 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::drawLegendData | ( | QPainter * | painter, |
const QwtPlotItem * | plotItem, | ||
const QwtLegendData & | data, | ||
const QRectF & | rect | ||
) | const [protected, virtual] |
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 |
Definition at line 742 of file qwt_plot_legenditem.cpp.
QFont QwtPlotLegendItem::font | ( | ) | const |
Definition at line 384 of file qwt_plot_legenditem.cpp.
QRect QwtPlotLegendItem::geometry | ( | const QRectF & | canvasRect | ) | const [virtual] |
Calculate the geometry of the legend on the canvas
canvasRect | Geometry of the canvas |
Definition at line 617 of file qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::heightForWidth | ( | const QwtLegendData & | data, |
int | width | ||
) | const [virtual] |
data | Attributes of the legend entry |
width | Width |
Definition at line 824 of file qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::itemMargin | ( | ) | const |
Definition at line 330 of file qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::itemSpacing | ( | ) | const |
Definition at line 358 of file qwt_plot_legenditem.cpp.
QList< QRect > QwtPlotLegendItem::legendGeometries | ( | const QwtPlotItem * | plotItem | ) | const |
Definition at line 857 of file qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::margin | ( | ) | const |
Definition at line 275 of file qwt_plot_legenditem.cpp.
uint QwtPlotLegendItem::maxColumns | ( | ) | const |
Definition at line 246 of file qwt_plot_legenditem.cpp.
QSize QwtPlotLegendItem::minimumSize | ( | const QwtLegendData & | data | ) | const [virtual] |
Minimum size hint needed to display an entry
data | Attributes of the legend entry |
Definition at line 785 of file qwt_plot_legenditem.cpp.
QList< const QwtPlotItem * > QwtPlotLegendItem::plotItems | ( | ) | const |
Definition at line 848 of file qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::rtti | ( | ) | const [virtual] |
Reimplemented from QwtPlotItem.
Definition at line 187 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setAlignment | ( | 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 205 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 476 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 504 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setBorderDistance | ( | int | distance | ) |
Set the margin between the legend and the canvas border.
The default setting for the margin is 10 pixels.
distance | Margin in pixels |
Definition at line 397 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 450 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 424 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 369 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setItemMargin | ( | int | margin | ) |
Set the margin around each item
margin | Margin |
Definition at line 314 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::setItemSpacing | ( | int | spacing | ) |
Set the spacing inside of each item
spacing | Spacing |
Definition at line 341 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 259 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 233 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 289 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 528 of file qwt_plot_legenditem.cpp.
int QwtPlotLegendItem::spacing | ( | ) | const |
Definition at line 303 of file qwt_plot_legenditem.cpp.
QPen QwtPlotLegendItem::textPen | ( | ) | const |
Definition at line 541 of file qwt_plot_legenditem.cpp.
void QwtPlotLegendItem::updateLegend | ( | const QwtPlotItem * | plotItem, |
const QList< QwtLegendData > & | data | ||
) | [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 661 of file qwt_plot_legenditem.cpp.
PrivateData* QwtPlotLegendItem::d_data [private] |
Reimplemented from QwtPlotItem.
Definition at line 132 of file qwt_plot_legenditem.h.