Aquila  2.0 prealpha
Cognitive Robotics Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QCPPlottableLegendItem Class Reference

A legend item representing a plottable with an icon and the plottable name. More...

#include <plot2d.h>

Inheritance diagram for QCPPlottableLegendItem:

Public Member Functions

 QCPPlottableLegendItem (QCPLegend *parent, QCPAbstractPlottable *plottable)
virtual ~QCPPlottableLegendItem ()
QCPAbstractPlottableplottable ()
bool textWrap () const
void setTextWrap (bool wrap)
- Public Member Functions inherited from QCPAbstractLegendItem
 QCPAbstractLegendItem (QCPLegend *parent)
virtual ~QCPAbstractLegendItem ()
bool antialiased () const
QFont font () const
QColor textColor () const
QFont selectedFont () const
QColor selectedTextColor () const
bool selectable () const
bool selected () const
void setAntialiased (bool enabled)
void setFont (const QFont &font)
void setTextColor (const QColor &color)
void setSelectedFont (const QFont &font)
void setSelectedTextColor (const QColor &color)
void setSelectable (bool selectable)
void setSelected (bool selected)

Protected Member Functions

QPen getIconBorderPen () const
QColor getTextColor () const
QFont getFont () const
virtual void draw (QCPPainter *painter, const QRect &rect) const
virtual QSize size (const QSize &targetSize) const
- Protected Member Functions inherited from QCPAbstractLegendItem
void applyAntialiasingHint (QCPPainter *painter) const

Protected Attributes

bool mTextWrap
- Protected Attributes inherited from QCPAbstractLegendItem
bool mAntialiased
QFont mFont
QColor mTextColor
QFont mSelectedFont
QColor mSelectedTextColor
bool mSelectable
bool mSelected

Additional Inherited Members

- Signals inherited from QCPAbstractLegendItem
void selectionChanged (bool selected)

Detailed Description

A legend item representing a plottable with an icon and the plottable name.

This is the standard legend item for plottables. It displays an icon of the plottable next to the plottable name. The icon is drawn by the respective plottable itself (QCPAbstractPlottable::drawLegendIcon), and tries to give an intuitive symbol for the plottable. For example, the QCPGraph draws a centered horizontal line with a single scatter point in the middle and filling (if enabled) below.

Legend items of this type are always associated with one plottable (retrievable via the plottable() function and settable with the constructor). You may change the font of the plottable name with setFont. If setTextWrap is set to true, the plottable name will wrap at the right legend boundary (see QCPLegend::setMinimumSize). Icon padding and border pen is taken from the parent QCPLegend, see QCPLegend::setIconBorderPen and QCPLegend::setIconTextPadding.

The function QCPAbstractPlottable::addToLegend/QCPAbstractPlottable::removeFromLegend creates/removes legend items of this type in the default implementation. However, these functions may be reimplemented such that a different kind of legend item (e.g a direct subclass of QCPAbstractLegendItem) is used for that plottable.

Constructor & Destructor Documentation

QCPPlottableLegendItem::QCPPlottableLegendItem ( QCPLegend parent,
QCPAbstractPlottable plottable 

Creates a new legend item associated with plottable.

Once it's created, it can be added to the legend via QCPLegend::addItem.

A more convenient way of adding/removing a plottable to/from the legend is via the functions QCPAbstractPlottable::addToLegend and QCPAbstractPlottable::removeFromLegend.

virtual QCPPlottableLegendItem::~QCPPlottableLegendItem ( )

Member Function Documentation

void QCPPlottableLegendItem::draw ( QCPPainter painter,
const QRect &  rect 
) const

Draws this legend item with painter inside the specified rect. The rect typically has the size which was returned from a preceding size call.

Implements QCPAbstractLegendItem.

QFont QCPPlottableLegendItem::getFont ( ) const
QPen QCPPlottableLegendItem::getIconBorderPen ( ) const
QColor QCPPlottableLegendItem::getTextColor ( ) const
QCPAbstractPlottable* QCPPlottableLegendItem::plottable ( )
void QCPPlottableLegendItem::setTextWrap ( bool  wrap)

Sets whether the text of the legend item is wrapped at word boundaries to fit the with of the legend.

To prevent the legend autoSize feature (QCPLegend::setAutoSize) from compressing the text too strong by wrapping it very often, set an appropriate minimum width with QCPLegend::setMinimumSize.

QSize QCPPlottableLegendItem::size ( const QSize &  targetSize) const

Returns the size this item occupies in the legend. The legend will adapt its layout with the help of this function. If this legend item can have a variable width (e.g. auto-wrapping text), this function tries to find a size with a width close to the width of targetSize. The height of targetSize only may have meaning in specific sublasses. Typically, it's ignored.

Implements QCPAbstractLegendItem.

bool QCPPlottableLegendItem::textWrap ( ) const

Member Data Documentation

QCPAbstractPlottable* QCPPlottableLegendItem::mPlottable
bool QCPPlottableLegendItem::mTextWrap

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