Main Page · Class Overview · Hierarchy · All Classes · Special Pages
Public Functions | Protected Functions
QCPPlottableLegendItem Class Reference

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

Inheritance diagram for QCPPlottableLegendItem:
Inheritance graph

Public Functions

 QCPPlottableLegendItem (QCPLegend *parent, QCPAbstractPlottable *plottable)
 
QCPAbstractPlottableplottable ()
 
- Public Functions inherited from QCPAbstractLegendItem
 QCPAbstractLegendItem (QCPLegend *parent)
 
QCPLegendparentLegend () const
 
QFont font () const
 
QColor textColor () const
 
QFont selectedFont () const
 
QColor selectedTextColor () const
 
bool selectable () const
 
bool selected () const
 
void setFont (const QFont &font)
 
void setTextColor (const QColor &color)
 
void setSelectedFont (const QFont &font)
 
void setSelectedTextColor (const QColor &color)
 
Q_SLOT void setSelectable (bool selectable)
 
Q_SLOT void setSelected (bool selected)
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=nullptr) const
 
- Public Functions inherited from QCPLayoutElement
 QCPLayoutElement (QCustomPlot *parentPlot=nullptr)
 
QCPLayoutlayout () const
 
QRect rect () const
 
QRect outerRect () const
 
QMargins margins () const
 
QMargins minimumMargins () const
 
QCP::MarginSides autoMargins () const
 
QSize minimumSize () const
 
QSize maximumSize () const
 
SizeConstraintRect sizeConstraintRect () const
 
QCPMarginGroupmarginGroup (QCP::MarginSide side) const
 
QHash< QCP::MarginSide, QCPMarginGroup * > marginGroups () const
 
void setOuterRect (const QRect &rect)
 
void setMargins (const QMargins &margins)
 
void setMinimumMargins (const QMargins &margins)
 
void setAutoMargins (QCP::MarginSides sides)
 
void setMinimumSize (const QSize &size)
 
void setMinimumSize (int width, int height)
 
void setMaximumSize (const QSize &size)
 
void setMaximumSize (int width, int height)
 
void setSizeConstraintRect (SizeConstraintRect constraintRect)
 
void setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group)
 
virtual void update (UpdatePhase phase)
 
virtual QSize maximumOuterSizeHint () const
 
virtual QList< QCPLayoutElement * > elements (bool recursive) const
 
- Public Functions inherited from QCPLayerable
 QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=nullptr)
 
bool visible () const
 
QCustomPlotparentPlot () const
 
QCPLayerableparentLayerable () const
 
QCPLayerlayer () const
 
bool antialiased () const
 
void setVisible (bool on)
 
Q_SLOT bool setLayer (QCPLayer *layer)
 
bool setLayer (const QString &layerName)
 
void setAntialiased (bool enabled)
 
bool realVisibility () const
 

Protected Functions

virtual void draw (QCPPainter *painter)
 
virtual QSize minimumOuterSizeHint () const
 
QPen getIconBorderPen () const
 
QColor getTextColor () const
 
QFont getFont () const
 
- Protected Functions inherited from QCPAbstractLegendItem
virtual QCP::Interaction selectionCategory () const
 
virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
 
virtual QRect clipRect () const
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
 
virtual void deselectEvent (bool *selectionStateChanged)
 
- Protected Functions inherited from QCPLayoutElement
virtual int calculateAutoMargin (QCP::MarginSide side)
 
virtual void layoutChanged ()
 
virtual void parentPlotInitialized (QCustomPlot *parentPlot)
 
- Protected Functions inherited from QCPLayerable
virtual void mousePressEvent (QMouseEvent *event, const QVariant &details)
 
virtual void mouseMoveEvent (QMouseEvent *event, const QPointF &startPos)
 
virtual void mouseReleaseEvent (QMouseEvent *event, const QPointF &startPos)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event, const QVariant &details)
 
virtual void wheelEvent (QWheelEvent *event)
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 

Additional Inherited Members

- Public Types inherited from QCPLayoutElement
enum  UpdatePhase
 
enum  SizeConstraintRect
 
- Signals inherited from QCPAbstractLegendItem
void selectionChanged (bool selected)
 
void selectableChanged (bool selectable)
 
- Signals inherited from QCPLayerable
void layerChanged (QCPLayer *newLayer)
 

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 and/or a single scatter point in the middle.

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

Since QCPLegend is based on QCPLayoutGrid, a legend item itself is just a subclass of QCPLayoutElement. While it could be added to a legend (or any other layout) via the normal layout interface, QCPLegend has specialized functions for handling legend items conveniently, see the documentation of QCPLegend.

Constructor & Destructor Documentation

§ QCPPlottableLegendItem()

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.

Member Function Documentation

§ draw()

void QCPPlottableLegendItem::draw ( QCPPainter painter)
protectedvirtual

Draws the item with painter. The size and position of the drawn legend item is defined by the parent layout (typically a QCPLegend) and the minimumOuterSizeHint and maximumOuterSizeHint of this legend item.

Implements QCPAbstractLegendItem.

§ minimumOuterSizeHint()

QSize QCPPlottableLegendItem::minimumOuterSizeHint ( ) const
protectedvirtual

Calculates and returns the size of this item. This includes the icon, the text and the padding in between.

For general information about this virtual method, see the base class implementation.

Reimplemented from QCPLayoutElement.

§ getIconBorderPen()

QPen QCPPlottableLegendItem::getIconBorderPen ( ) const
protected

Returns the pen that shall be used to draw the icon border, taking into account the selection state of this item.

§ getTextColor()

QColor QCPPlottableLegendItem::getTextColor ( ) const
protected

Returns the text color that shall be used to draw text, taking into account the selection state of this item.

§ getFont()

QFont QCPPlottableLegendItem::getFont ( ) const
protected

Returns the font that shall be used to draw text, taking into account the selection state of this item.


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