ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
QCPLegend Class Reference

Manages a legend inside a QCustomPlot. More...

#include <qcustomplot.h>

Inheritance diagram for QCPLegend:
Collaboration diagram for QCPLegend:

Public Types

enum  SelectablePart {
  spNone = 0x000 , spLegendBox = 0x001 , spItems = 0x002 , spNone = 0x000 ,
  spLegendBox = 0x001 , spItems = 0x002
}
 
enum  SelectablePart {
  spNone = 0x000 , spLegendBox = 0x001 , spItems = 0x002 , spNone = 0x000 ,
  spLegendBox = 0x001 , spItems = 0x002
}
 
- Public Types inherited from QCPLayoutGrid
enum  FillOrder { foRowsFirst , foColumnsFirst }
 
- Public Types inherited from QCPLayoutElement
enum  UpdatePhase {
  upPreparation , upMargins , upLayout , upPreparation ,
  upMargins , upLayout
}
 
enum  SizeConstraintRect { scrInnerRect , scrOuterRect }
 
enum  UpdatePhase {
  upPreparation , upMargins , upLayout , upPreparation ,
  upMargins , upLayout
}
 

Signals

void selectionChanged (QCPLegend::SelectableParts parts)
 
void selectableChanged (QCPLegend::SelectableParts parts)
 
void selectionChanged (QCPLegend::SelectableParts parts)
 
void selectableChanged (QCPLegend::SelectableParts parts)
 
- Signals inherited from QCPLayerable
void layerChanged (QCPLayer *newLayer)
 
void layerChanged (QCPLayer *newLayer)
 

Public Member Functions

 QCPLegend ()
 
virtual ~QCPLegend ()
 
QPen borderPen () const
 
QBrush brush () const
 
QFont font () const
 
QColor textColor () const
 
QSize iconSize () const
 
int iconTextPadding () const
 
QPen iconBorderPen () const
 
SelectableParts selectableParts () const
 
SelectableParts selectedParts () const
 
QPen selectedBorderPen () const
 
QPen selectedIconBorderPen () const
 
QBrush selectedBrush () const
 
QFont selectedFont () const
 
QColor selectedTextColor () const
 
void setBorderPen (const QPen &pen)
 
void setBrush (const QBrush &brush)
 
void setFont (const QFont &font)
 
void setTextColor (const QColor &color)
 
void setIconSize (const QSize &size)
 
void setIconSize (int width, int height)
 
void setIconTextPadding (int padding)
 
void setIconBorderPen (const QPen &pen)
 
Q_SLOT void setSelectableParts (const SelectableParts &selectableParts)
 
Q_SLOT void setSelectedParts (const SelectableParts &selectedParts)
 
void setSelectedBorderPen (const QPen &pen)
 
void setSelectedIconBorderPen (const QPen &pen)
 
void setSelectedBrush (const QBrush &brush)
 
void setSelectedFont (const QFont &font)
 
void setSelectedTextColor (const QColor &color)
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
 
QCPAbstractLegendItemitem (int index) const
 
QCPPlottableLegendItemitemWithPlottable (const QCPAbstractPlottable *plottable) const
 
int itemCount () const
 
bool hasItem (QCPAbstractLegendItem *item) const
 
bool hasItemWithPlottable (const QCPAbstractPlottable *plottable) const
 
bool addItem (QCPAbstractLegendItem *item)
 
bool removeItem (int index)
 
bool removeItem (QCPAbstractLegendItem *item)
 
void clearItems ()
 
QList< QCPAbstractLegendItem * > selectedItems () const
 
 QCPLegend ()
 
virtual ~QCPLegend ()
 
QPen borderPen () const
 
QBrush brush () const
 
QFont font () const
 
QColor textColor () const
 
QSize iconSize () const
 
int iconTextPadding () const
 
QPen iconBorderPen () const
 
SelectableParts selectableParts () const
 
SelectableParts selectedParts () const
 
QPen selectedBorderPen () const
 
QPen selectedIconBorderPen () const
 
QBrush selectedBrush () const
 
QFont selectedFont () const
 
QColor selectedTextColor () const
 
void setBorderPen (const QPen &pen)
 
void setBrush (const QBrush &brush)
 
void setFont (const QFont &font)
 
void setTextColor (const QColor &color)
 
void setIconSize (const QSize &size)
 
void setIconSize (int width, int height)
 
void setIconTextPadding (int padding)
 
void setIconBorderPen (const QPen &pen)
 
Q_SLOT void setSelectableParts (const SelectableParts &selectableParts)
 
Q_SLOT void setSelectedParts (const SelectableParts &selectedParts)
 
void setSelectedBorderPen (const QPen &pen)
 
void setSelectedIconBorderPen (const QPen &pen)
 
void setSelectedBrush (const QBrush &brush)
 
void setSelectedFont (const QFont &font)
 
void setSelectedTextColor (const QColor &color)
 
virtual double selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const
 
QCPAbstractLegendItemitem (int index) const
 
QCPPlottableLegendItemitemWithPlottable (const QCPAbstractPlottable *plottable) const
 
int itemCount () const
 
bool hasItem (QCPAbstractLegendItem *item) const
 
bool hasItemWithPlottable (const QCPAbstractPlottable *plottable) const
 
bool addItem (QCPAbstractLegendItem *item)
 
bool removeItem (int index)
 
bool removeItem (QCPAbstractLegendItem *item)
 
void clearItems ()
 
QList< QCPAbstractLegendItem * > selectedItems () const
 
- Public Member Functions inherited from QCPLayoutGrid
 QCPLayoutGrid ()
 
virtual ~QCPLayoutGrid ()
 
int rowCount () const
 
int columnCount () const
 
QList< double > columnStretchFactors () const
 
QList< double > rowStretchFactors () const
 
int columnSpacing () const
 
int rowSpacing () const
 
int wrap () const
 
FillOrder fillOrder () const
 
void setColumnStretchFactor (int column, double factor)
 
void setColumnStretchFactors (const QList< double > &factors)
 
void setRowStretchFactor (int row, double factor)
 
void setRowStretchFactors (const QList< double > &factors)
 
void setColumnSpacing (int pixels)
 
void setRowSpacing (int pixels)
 
void setWrap (int count)
 
void setFillOrder (FillOrder order, bool rearrange=true)
 
virtual void updateLayout ()
 
virtual int elementCount () const
 
virtual QCPLayoutElementelementAt (int index) const
 
virtual QCPLayoutElementtakeAt (int index)
 
virtual bool take (QCPLayoutElement *element)
 
virtual QList< QCPLayoutElement * > elements (bool recursive) const
 
virtual void simplify ()
 
virtual QSize minimumOuterSizeHint () const
 
virtual QSize maximumOuterSizeHint () const
 
QCPLayoutElementelement (int row, int column) const
 
bool addElement (int row, int column, QCPLayoutElement *element)
 
bool addElement (QCPLayoutElement *element)
 
bool hasElement (int row, int column)
 
void expandTo (int newRowCount, int newColumnCount)
 
void insertRow (int newIndex)
 
void insertColumn (int newIndex)
 
int rowColToIndex (int row, int column) const
 
void indexToRowCol (int index, int &row, int &column) const
 
 QCPLayoutGrid ()
 
virtual ~QCPLayoutGrid ()
 
int rowCount () const
 
int columnCount () const
 
QList< double > columnStretchFactors () const
 
QList< double > rowStretchFactors () const
 
int columnSpacing () const
 
int rowSpacing () const
 
void setColumnStretchFactor (int column, double factor)
 
void setColumnStretchFactors (const QList< double > &factors)
 
void setRowStretchFactor (int row, double factor)
 
void setRowStretchFactors (const QList< double > &factors)
 
void setColumnSpacing (int pixels)
 
void setRowSpacing (int pixels)
 
virtual void updateLayout ()
 
virtual int elementCount () const
 
virtual QCPLayoutElementelementAt (int index) const
 
virtual QCPLayoutElementtakeAt (int index)
 
virtual bool take (QCPLayoutElement *element)
 
virtual QList< QCPLayoutElement * > elements (bool recursive) const
 
virtual void simplify ()
 
virtual QSize minimumSizeHint () const
 
virtual QSize maximumSizeHint () const
 
QCPLayoutElementelement (int row, int column) const
 
bool addElement (int row, int column, QCPLayoutElement *element)
 
bool hasElement (int row, int column)
 
void expandTo (int newRowCount, int newColumnCount)
 
void insertRow (int newIndex)
 
void insertColumn (int newIndex)
 
- Public Member Functions inherited from QCPLayout
 QCPLayout ()
 
virtual void update (UpdatePhase phase)
 
bool removeAt (int index)
 
bool remove (QCPLayoutElement *element)
 
void clear ()
 
 QCPLayout ()
 
virtual void update (UpdatePhase phase)
 
bool removeAt (int index)
 
bool remove (QCPLayoutElement *element)
 
void clear ()
 
- Public Member Functions inherited from QCPLayoutElement
 QCPLayoutElement (QCustomPlot *parentPlot=0)
 
virtual ~QCPLayoutElement ()
 
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)
 
 QCPLayoutElement (QCustomPlot *parentPlot=0)
 
virtual ~QCPLayoutElement ()
 
QCPLayoutlayout () const
 
QRect rect () const
 
QRect outerRect () const
 
QMargins margins () const
 
QMargins minimumMargins () const
 
QCP::MarginSides autoMargins () const
 
QSize minimumSize () const
 
QSize maximumSize () 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 setMarginGroup (QCP::MarginSides sides, QCPMarginGroup *group)
 
- Public Member Functions inherited from QCPLayerable
 QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
 
virtual ~QCPLayerable ()
 
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
 
 QCPLayerable (QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
 
 ~QCPLayerable ()
 
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 Member Functions

virtual void parentPlotInitialized (QCustomPlot *parentPlot)
 
virtual QCP::Interaction selectionCategory () const
 
virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
 
virtual void draw (QCPPainter *painter)
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
 
virtual void deselectEvent (bool *selectionStateChanged)
 
QPen getBorderPen () const
 
QBrush getBrush () const
 
virtual void parentPlotInitialized (QCustomPlot *parentPlot)
 
virtual QCP::Interaction selectionCategory () const
 
virtual void applyDefaultAntialiasingHint (QCPPainter *painter) const
 
virtual void draw (QCPPainter *painter)
 
virtual void selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
 
virtual void deselectEvent (bool *selectionStateChanged)
 
QPen getBorderPen () const
 
QBrush getBrush () const
 
- Protected Member Functions inherited from QCPLayoutGrid
void getMinimumRowColSizes (QVector< int > *minColWidths, QVector< int > *minRowHeights) const
 
void getMaximumRowColSizes (QVector< int > *maxColWidths, QVector< int > *maxRowHeights) const
 
void getMinimumRowColSizes (QVector< int > *minColWidths, QVector< int > *minRowHeights) const
 
void getMaximumRowColSizes (QVector< int > *maxColWidths, QVector< int > *maxRowHeights) const
 
- Protected Member Functions inherited from QCPLayout
void sizeConstraintsChanged () const
 
void adoptElement (QCPLayoutElement *el)
 
void releaseElement (QCPLayoutElement *el)
 
QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
 
void sizeConstraintsChanged () const
 
void adoptElement (QCPLayoutElement *el)
 
void releaseElement (QCPLayoutElement *el)
 
QVector< int > getSectionSizes (QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
 
- Protected Member Functions inherited from QCPLayoutElement
virtual int calculateAutoMargin (QCP::MarginSide side)
 
virtual void layoutChanged ()
 
virtual int calculateAutoMargin (QCP::MarginSide side)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void wheelEvent (QWheelEvent *event)
 
- Protected Member Functions inherited from QCPLayerable
virtual QRect clipRect () const
 
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)
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 
virtual QRect clipRect () const
 
void initializeParentPlot (QCustomPlot *parentPlot)
 
void setParentLayerable (QCPLayerable *parentLayerable)
 
bool moveToLayer (QCPLayer *layer, bool prepend)
 
void applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
 

Protected Attributes

QPen mBorderPen
 
QPen mIconBorderPen
 
QBrush mBrush
 
QFont mFont
 
QColor mTextColor
 
QSize mIconSize
 
int mIconTextPadding
 
SelectableParts mSelectedParts
 
SelectableParts mSelectableParts
 
QPen mSelectedBorderPen
 
QPen mSelectedIconBorderPen
 
QBrush mSelectedBrush
 
QFont mSelectedFont
 
QColor mSelectedTextColor
 
- Protected Attributes inherited from QCPLayoutGrid
QList< QList< QCPLayoutElement * > > mElements
 
QList< double > mColumnStretchFactors
 
QList< double > mRowStretchFactors
 
int mColumnSpacing
 
int mRowSpacing
 
int mWrap
 
FillOrder mFillOrder
 
- Protected Attributes inherited from QCPLayoutElement
QCPLayoutmParentLayout
 
QSize mMinimumSize
 
QSize mMaximumSize
 
SizeConstraintRect mSizeConstraintRect
 
QRect mRect
 
QRect mOuterRect
 
QMargins mMargins
 
QMargins mMinimumMargins
 
QCP::MarginSides mAutoMargins
 
QHash< QCP::MarginSide, QCPMarginGroup * > mMarginGroups
 
- Protected Attributes inherited from QCPLayerable
bool mVisible
 
QCustomPlotmParentPlot
 
QPointer< QCPLayerablemParentLayerable
 
QCPLayermLayer
 
bool mAntialiased
 

Additional Inherited Members

- Static Protected Member Functions inherited from QCPLayout
static QSize getFinalMinimumOuterSize (const QCPLayoutElement *el)
 
static QSize getFinalMaximumOuterSize (const QCPLayoutElement *el)
 

Detailed Description

Manages a legend inside a QCustomPlot.

A legend is a small box somewhere in the plot which lists plottables with their name and icon.

A legend is populated with legend items by calling QCPAbstractPlottable::addToLegend on the plottable, for which a legend item shall be created. In the case of the main legend (QCustomPlot::legend), simply adding plottables to the plot while QCustomPlot::setAutoAddPlottableToLegend is set to true (the default) creates corresponding legend items. The legend item associated with a certain plottable can be removed with QCPAbstractPlottable::removeFromLegend. However, QCPLegend also offers an interface to add and manipulate legend items directly: item, itemWithPlottable, itemCount, addItem, removeItem, etc.

Since QCPLegend derives from QCPLayoutGrid, it can be placed in any position a QCPLayoutElement may be positioned. The legend items are themselves QCPLayoutElements which are placed in the grid layout of the legend. QCPLegend only adds an interface specialized for handling child elements of type QCPAbstractLegendItem, as mentioned above. In principle, any other layout elements may also be added to a legend via the normal QCPLayoutGrid interface. See the special page about The Layout System for examples on how to add other elements to the legend and move it outside the axis rect.

Use the methods setFillOrder and setWrap inherited from QCPLayoutGrid to control in which order (column first or row first) the legend is filled up when calling addItem, and at which column or row wrapping occurs. The default fill order for legends is foRowsFirst.

By default, every QCustomPlot has one legend (QCustomPlot::legend) which is placed in the inset layout of the main axis rect (QCPAxisRect::insetLayout). To move the legend to another position inside the axis rect, use the methods of the QCPLayoutInset. To move the legend outside of the axis rect, place it anywhere else with the QCPLayout/ QCPLayoutElement interface.

A legend is a small box somewhere in the plot which lists plottables with their name and icon.

Normally, the legend is populated by calling QCPAbstractPlottable::addToLegend. The respective legend item can be removed with QCPAbstractPlottable::removeFromLegend. However, QCPLegend also offers an interface to add and manipulate legend items directly: item, itemWithPlottable, itemCount, addItem, removeItem, etc.

The QCPLegend derives from QCPLayoutGrid and as such can be placed in any position a QCPLayoutElement may be positioned. The legend items are themselves QCPLayoutElements which are placed in the grid layout of the legend. QCPLegend only adds an interface specialized for handling child elements of type QCPAbstractLegendItem, as mentioned above. In principle, any other layout elements may also be added to a legend via the normal QCPLayoutGrid interface. However, the QCPAbstractLegendItem-Interface will ignore those elements (e.g. itemCount will only return the number of items with QCPAbstractLegendItems type).

By default, every QCustomPlot has one legend (QCustomPlot::legend) which is placed in the inset layout of the main axis rect (QCPAxisRect::insetLayout). To move the legend to another position inside the axis rect, use the methods of the QCPLayoutInset. To move the legend outside of the axis rect, place it anywhere else with the QCPLayout/QCPLayoutElement interface.

Definition at line 5605 of file qcustomplot.h.

Member Enumeration Documentation

◆ SelectablePart [1/2]

Defines the selectable parts of a legend

See also
setSelectedParts, setSelectableParts
Enumerator
spNone 

0x000 None

spLegendBox 

0x001 The legend box (frame)

spItems 

0x002 Legend items individually (see selectedItems)

spNone 

0x000 None

spLegendBox 

0x001 The legend box (frame)

spItems 

0x002 Legend items individually (see selectedItems)

Definition at line 5635 of file qcustomplot.h.

◆ SelectablePart [2/2]

Defines the selectable parts of a legend

See also
setSelectedParts, setSelectableParts
Enumerator
spNone 

0x000 None

spLegendBox 

0x001 The legend box (frame)

spItems 

0x002 Legend items individually (see selectedItems)

spNone 

0x000 None

spLegendBox 

0x001 The legend box (frame)

spItems 

0x002 Legend items individually (see selectedItems)

Definition at line 2665 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPLegend() [1/2]

QCPLegend::QCPLegend ( )
explicit

◆ ~QCPLegend() [1/2]

QCPLegend::~QCPLegend ( )
virtual

◆ QCPLegend() [2/2]

QCPLegend::QCPLegend ( )
explicit

◆ ~QCPLegend() [2/2]

virtual QCPLegend::~QCPLegend ( )
virtual

Member Function Documentation

◆ addItem() [1/2]

bool QCPLegend::addItem ( QCPAbstractLegendItem item)

Adds item to the legend, if it's not present already. The element is arranged according to the current fill order (setFillOrder) and wrapping (setWrap).

Returns true on sucess, i.e. if the item wasn't in the list already and has been successfuly added.

The legend takes ownership of the item.

See also
removeItem, item, hasItem

Adds item to the legend, if it's not present already.

Returns true on sucess, i.e. if the item wasn't in the list already and has been successfuly added.

The legend takes ownership of the item.

Definition at line 19371 of file qcustomplot.cpp.

References QCPLayoutGrid::addElement(), and item().

Referenced by QCPAbstractPlottable::addToLegend().

◆ addItem() [2/2]

bool QCPLegend::addItem ( QCPAbstractLegendItem item)

◆ applyDefaultAntialiasingHint() [1/2]

void QCPLegend::applyDefaultAntialiasingHint ( QCPPainter painter) const
protectedvirtual

◆ applyDefaultAntialiasingHint() [2/2]

virtual void QCPLegend::applyDefaultAntialiasingHint ( QCPPainter painter) const
protectedvirtual

Reimplemented from QCPLayoutElement.

◆ borderPen() [1/2]

QPen QCPLegend::borderPen ( ) const
inline

Definition at line 5651 of file qcustomplot.h.

◆ borderPen() [2/2]

QPen QCPLegend::borderPen ( ) const
inline

Definition at line 2680 of file qcustomplot.h.

◆ brush() [1/2]

QBrush QCPLegend::brush ( ) const
inline

Definition at line 5652 of file qcustomplot.h.

Referenced by setBrush(), and setSelectedBrush().

◆ brush() [2/2]

QBrush QCPLegend::brush ( ) const
inline

Definition at line 2681 of file qcustomplot.h.

◆ clearItems() [1/2]

void QCPLegend::clearItems ( )

Removes all items from the legend.

Definition at line 19424 of file qcustomplot.cpp.

References itemCount(), and removeItem().

Referenced by ~QCPLegend().

◆ clearItems() [2/2]

void QCPLegend::clearItems ( )

◆ deselectEvent() [1/2]

void QCPLegend::deselectEvent ( bool *  selectionStateChanged)
protectedvirtual

Reimplemented from QCPLayerable.

Definition at line 19534 of file qcustomplot.cpp.

References mSelectableParts, mSelectedParts, selectedParts(), setSelectedParts(), and spLegendBox.

◆ deselectEvent() [2/2]

virtual void QCPLegend::deselectEvent ( bool *  selectionStateChanged)
protectedvirtual

Reimplemented from QCPLayerable.

◆ draw() [1/2]

void QCPLegend::draw ( QCPPainter painter)
protectedvirtual

Reimplemented from QCPLayoutElement.

Definition at line 19488 of file qcustomplot.cpp.

References getBorderPen(), getBrush(), QCPLayoutElement::mOuterRect, and QCPPainter::setPen().

◆ draw() [2/2]

virtual void QCPLegend::draw ( QCPPainter painter)
protectedvirtual

Reimplemented from QCPLayoutElement.

◆ font() [1/2]

QFont QCPLegend::font ( ) const
inline

Definition at line 5653 of file qcustomplot.h.

Referenced by setFont(), and setSelectedFont().

◆ font() [2/2]

QFont QCPLegend::font ( ) const
inline

Definition at line 2682 of file qcustomplot.h.

◆ getBorderPen() [1/2]

QPen QCPLegend::getBorderPen ( ) const
protected

Definition at line 19469 of file qcustomplot.cpp.

References mBorderPen, mSelectedBorderPen, mSelectedParts, and spLegendBox.

Referenced by draw().

◆ getBorderPen() [2/2]

QPen QCPLegend::getBorderPen ( ) const
protected

◆ getBrush() [1/2]

QBrush QCPLegend::getBrush ( ) const
protected

Definition at line 19479 of file qcustomplot.cpp.

References mBrush, mSelectedBrush, mSelectedParts, and spLegendBox.

Referenced by draw().

◆ getBrush() [2/2]

QBrush QCPLegend::getBrush ( ) const
protected

◆ hasItem() [1/2]

bool QCPLegend::hasItem ( QCPAbstractLegendItem item) const

Returns whether the legend contains item.

See also
hasItemWithPlottable

Returns whether the legend contains itm.

Definition at line 19340 of file qcustomplot.cpp.

References item(), and itemCount().

◆ hasItem() [2/2]

bool QCPLegend::hasItem ( QCPAbstractLegendItem item) const

◆ hasItemWithPlottable() [1/2]

bool QCPLegend::hasItemWithPlottable ( const QCPAbstractPlottable plottable) const

Returns whether the legend contains a QCPPlottableLegendItem which is associated with plottable (e.g. a QCPGraph*). If such an item isn't in the legend, returns false.

See also
itemWithPlottable

Definition at line 19354 of file qcustomplot.cpp.

References itemWithPlottable().

Referenced by QCPAbstractPlottable::addToLegend().

◆ hasItemWithPlottable() [2/2]

bool QCPLegend::hasItemWithPlottable ( const QCPAbstractPlottable plottable) const

◆ iconBorderPen() [1/2]

QPen QCPLegend::iconBorderPen ( ) const
inline

Definition at line 5657 of file qcustomplot.h.

Referenced by QCPPlottableLegendItem::getIconBorderPen().

◆ iconBorderPen() [2/2]

QPen QCPLegend::iconBorderPen ( ) const
inline

Definition at line 2686 of file qcustomplot.h.

◆ iconSize() [1/2]

QSize QCPLegend::iconSize ( ) const
inline

◆ iconSize() [2/2]

QSize QCPLegend::iconSize ( ) const
inline

Definition at line 2684 of file qcustomplot.h.

◆ iconTextPadding() [1/2]

int QCPLegend::iconTextPadding ( ) const
inline

◆ iconTextPadding() [2/2]

int QCPLegend::iconTextPadding ( ) const
inline

Definition at line 2685 of file qcustomplot.h.

◆ item() [1/2]

QCPAbstractLegendItem * QCPLegend::item ( int  index) const

Returns the item with index i.

Note that the linear index depends on the current fill order (setFillOrder).

See also
itemCount, addItem, itemWithPlottable

Returns the item with index i.

See also
itemCount

Definition at line 19303 of file qcustomplot.cpp.

References QCPLayoutGrid::elementAt().

Referenced by addItem(), hasItem(), itemWithPlottable(), removeItem(), selectedItems(), selectedParts(), setFont(), setSelectedFont(), setSelectedParts(), setSelectedTextColor(), and setTextColor().

◆ item() [2/2]

QCPAbstractLegendItem* QCPLegend::item ( int  index) const

◆ itemCount() [1/2]

int QCPLegend::itemCount ( ) const

Returns the number of items currently in the legend.

Note that if empty cells are in the legend (e.g. by calling methods of the QCPLayoutGrid base class which allows creating empty cells), they are included in the returned count.

See also
item

Returns the number of items currently in the legend.

See also
item

Definition at line 19333 of file qcustomplot.cpp.

References QCPLayoutGrid::elementCount().

Referenced by clearItems(), hasItem(), itemWithPlottable(), selectedItems(), selectedParts(), setFont(), setSelectedFont(), setSelectedParts(), setSelectedTextColor(), and setTextColor().

◆ itemCount() [2/2]

int QCPLegend::itemCount ( ) const

◆ itemWithPlottable() [1/2]

QCPPlottableLegendItem * QCPLegend::itemWithPlottable ( const QCPAbstractPlottable plottable) const

Returns the QCPPlottableLegendItem which is associated with plottable (e.g. a QCPGraph*). If such an item isn't in the legend, returns 0.

See also
hasItemWithPlottable

Definition at line 19313 of file qcustomplot.cpp.

References item(), and itemCount().

Referenced by hasItemWithPlottable(), and QCPAbstractPlottable::removeFromLegend().

◆ itemWithPlottable() [2/2]

QCPPlottableLegendItem* QCPLegend::itemWithPlottable ( const QCPAbstractPlottable plottable) const

◆ parentPlotInitialized() [1/2]

void QCPLegend::parentPlotInitialized ( QCustomPlot parentPlot)
protectedvirtual

Reimplemented from QCPLayoutElement.

Definition at line 19555 of file qcustomplot.cpp.

References QCustomPlot::legend, and QCPLayerable::parentPlot().

◆ parentPlotInitialized() [2/2]

virtual void QCPLegend::parentPlotInitialized ( QCustomPlot parentPlot)
protectedvirtual

Reimplemented from QCPLayoutElement.

◆ removeItem() [1/4]

bool QCPLegend::removeItem ( int  index)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Removes the item with the specified index from the legend and deletes it.

After successful removal, the legend is reordered according to the current fill order (setFillOrder) and wrapping (setWrap), so no empty cell remains where the removed item was. If you don't want this, rather use the raw element interface of QCPLayoutGrid.

Returns true, if successful. Unlike QCPLayoutGrid::removeAt, this method only removes elements derived from QCPAbstractLegendItem.

See also
itemCount, clearItems

Removes the item with index index from the legend.

Returns true, if successful.

See also
itemCount, clearItems

Definition at line 19389 of file qcustomplot.cpp.

References QCPLayoutGrid::fillOrder(), item(), QCPLayout::remove(), and QCPLayoutGrid::setFillOrder().

Referenced by clearItems(), and QCPAbstractPlottable::removeFromLegend().

◆ removeItem() [2/4]

bool QCPLegend::removeItem ( int  index)

◆ removeItem() [3/4]

bool QCPLegend::removeItem ( QCPAbstractLegendItem item)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Removes item from the legend and deletes it.

After successful removal, the legend is reordered according to the current fill order (setFillOrder) and wrapping (setWrap), so no empty cell remains where the removed item was. If you don't want this, rather use the raw element interface of QCPLayoutGrid.

Returns true, if successful.

See also
clearItems

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Removes item from the legend.

Returns true, if successful.

See also
clearItems

Definition at line 19413 of file qcustomplot.cpp.

References QCPLayoutGrid::fillOrder(), item(), QCPLayout::remove(), and QCPLayoutGrid::setFillOrder().

◆ removeItem() [4/4]

bool QCPLegend::removeItem ( QCPAbstractLegendItem item)

◆ selectableChanged [1/2]

void QCPLegend::selectableChanged ( QCPLegend::SelectableParts  parts)
signal

Referenced by setSelectableParts().

◆ selectableChanged [2/2]

void QCPLegend::selectableChanged ( QCPLegend::SelectableParts  parts)
signal

◆ selectableParts() [1/2]

SelectableParts QCPLegend::selectableParts ( ) const
inline

◆ selectableParts() [2/2]

SelectableParts QCPLegend::selectableParts ( ) const
inline

Definition at line 2687 of file qcustomplot.h.

◆ selectedBorderPen() [1/2]

QPen QCPLegend::selectedBorderPen ( ) const
inline

Definition at line 5660 of file qcustomplot.h.

◆ selectedBorderPen() [2/2]

QPen QCPLegend::selectedBorderPen ( ) const
inline

Definition at line 2689 of file qcustomplot.h.

◆ selectedBrush() [1/2]

QBrush QCPLegend::selectedBrush ( ) const
inline

Definition at line 5662 of file qcustomplot.h.

◆ selectedBrush() [2/2]

QBrush QCPLegend::selectedBrush ( ) const
inline

Definition at line 2691 of file qcustomplot.h.

◆ selectedFont() [1/2]

QFont QCPLegend::selectedFont ( ) const
inline

Definition at line 5663 of file qcustomplot.h.

◆ selectedFont() [2/2]

QFont QCPLegend::selectedFont ( ) const
inline

Definition at line 2692 of file qcustomplot.h.

◆ selectedIconBorderPen() [1/2]

QPen QCPLegend::selectedIconBorderPen ( ) const
inline

Definition at line 5661 of file qcustomplot.h.

Referenced by QCPPlottableLegendItem::getIconBorderPen().

◆ selectedIconBorderPen() [2/2]

QPen QCPLegend::selectedIconBorderPen ( ) const
inline

Definition at line 2690 of file qcustomplot.h.

◆ selectedItems() [1/2]

QList< QCPAbstractLegendItem * > QCPLegend::selectedItems ( ) const

Returns the legend items that are currently selected. If no items are selected, the list is empty.

See also
QCPAbstractLegendItem::setSelected, setSelectable

Definition at line 19434 of file qcustomplot.cpp.

References item(), itemCount(), and result.

◆ selectedItems() [2/2]

QList<QCPAbstractLegendItem *> QCPLegend::selectedItems ( ) const

◆ selectedParts() [1/2]

QCPLegend::SelectableParts QCPLegend::selectedParts ( ) const

◆ selectedParts() [2/2]

SelectableParts QCPLegend::selectedParts ( ) const

◆ selectedTextColor() [1/2]

QColor QCPLegend::selectedTextColor ( ) const
inline

Definition at line 5664 of file qcustomplot.h.

◆ selectedTextColor() [2/2]

QColor QCPLegend::selectedTextColor ( ) const
inline

Definition at line 2693 of file qcustomplot.h.

◆ selectEvent() [1/2]

void QCPLegend::selectEvent ( QMouseEvent *  event,
bool  additive,
const QVariant &  details,
bool *  selectionStateChanged 
)
protectedvirtual

Reimplemented from QCPLayerable.

Definition at line 19510 of file qcustomplot.cpp.

References event, mSelectableParts, mSelectedParts, selectedParts(), setSelectedParts(), and spLegendBox.

◆ selectEvent() [2/2]

virtual void QCPLegend::selectEvent ( QMouseEvent *  event,
bool  additive,
const QVariant &  details,
bool *  selectionStateChanged 
)
protectedvirtual

Reimplemented from QCPLayerable.

◆ selectionCategory() [1/2]

QCP::Interaction QCPLegend::selectionCategory ( ) const
protectedvirtual

Reimplemented from QCPLayerable.

Definition at line 19545 of file qcustomplot.cpp.

References QCP::iSelectLegend.

◆ selectionCategory() [2/2]

virtual QCP::Interaction QCPLegend::selectionCategory ( ) const
protectedvirtual

Reimplemented from QCPLayerable.

◆ selectionChanged [1/2]

void QCPLegend::selectionChanged ( QCPLegend::SelectableParts  selection)
signal

This signal is emitted when the selection state of this legend has changed.

See also
setSelectedParts, setSelectableParts

Referenced by setSelectedParts().

◆ selectionChanged [2/2]

void QCPLegend::selectionChanged ( QCPLegend::SelectableParts  parts)
signal

◆ selectTest() [1/2]

double QCPLegend::selectTest ( const QPointF &  pos,
bool  onlySelectable,
QVariant *  details = 0 
) const
virtual

Layout elements are sensitive to events inside their outer rect. If pos is within the outer rect, this method returns a value corresponding to 0.99 times the parent plot's selection tolerance. However, layout elements are not selectable by default. So if onlySelectable is true, -1.0 is returned.

See QCPLayerable::selectTest for a general explanation of this virtual method.

QCPLayoutElement subclasses may reimplement this method to provide more specific selection test behaviour.

Reimplemented from QCPLayoutElement.

Definition at line 19496 of file qcustomplot.cpp.

References QCPLayoutElement::mOuterRect, QCPLayerable::mParentPlot, mSelectableParts, QCustomPlot::selectionTolerance(), and spLegendBox.

◆ selectTest() [2/2]

virtual double QCPLegend::selectTest ( const QPointF &  pos,
bool  onlySelectable,
QVariant *  details = 0 
) const
virtual

Layout elements are sensitive to events inside their outer rect. If pos is within the outer rect, this method returns a value corresponding to 0.99 times the parent plot's selection tolerance. However, layout elements are not selectable by default. So if onlySelectable is true, -1.0 is returned.

See QCPLayerable::selectTest for a general explanation of this virtual method.

QCPLayoutElement subclasses may reimplement this method to provide more specific selection test behaviour.

Reimplemented from QCPLayoutElement.

◆ setBorderPen() [1/2]

void QCPLegend::setBorderPen ( const QPen &  pen)

Sets the pen, the border of the entire legend is drawn with.

Definition at line 19098 of file qcustomplot.cpp.

References mBorderPen.

Referenced by QCPLegend().

◆ setBorderPen() [2/2]

void QCPLegend::setBorderPen ( const QPen &  pen)

◆ setBrush() [1/2]

void QCPLegend::setBrush ( const QBrush &  brush)

Sets the brush of the legend background.

Definition at line 19103 of file qcustomplot.cpp.

References brush(), and mBrush.

Referenced by QCPLegend().

◆ setBrush() [2/2]

void QCPLegend::setBrush ( const QBrush &  brush)

◆ setFont() [1/2]

void QCPLegend::setFont ( const QFont &  font)

Sets the default font of legend text. Legend items that draw text (e.g. the name of a graph) will use this font by default. However, a different font can be specified on a per-item-basis by accessing the specific legend item.

This function will also set font on all already existing legend items.

See also
QCPAbstractLegendItem::setFont

Definition at line 19114 of file qcustomplot.cpp.

References font(), item(), itemCount(), mFont, and QCPAbstractLegendItem::setFont().

Referenced by cvProbeFilter::createUi().

◆ setFont() [2/2]

void QCPLegend::setFont ( const QFont &  font)

◆ setIconBorderPen() [1/2]

void QCPLegend::setIconBorderPen ( const QPen &  pen)

Sets the pen used to draw a border around each legend icon. Legend items that draw an icon (e.g. a visual representation of the graph) will use this pen by default.

If no border is wanted, set this to Qt::NoPen.

Definition at line 19164 of file qcustomplot.cpp.

References mIconBorderPen.

Referenced by QCPLegend().

◆ setIconBorderPen() [2/2]

void QCPLegend::setIconBorderPen ( const QPen &  pen)

◆ setIconSize() [1/4]

void QCPLegend::setIconSize ( const QSize &  size)

Sets the size of legend icons. Legend items that draw an icon (e.g. a visual representation of the graph) will use this size by default.

Definition at line 19141 of file qcustomplot.cpp.

References mIconSize, and size.

Referenced by QCPLegend().

◆ setIconSize() [2/4]

void QCPLegend::setIconSize ( const QSize &  size)

◆ setIconSize() [3/4]

void QCPLegend::setIconSize ( int  width,
int  height 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 19145 of file qcustomplot.cpp.

References height, mIconSize, and width.

◆ setIconSize() [4/4]

void QCPLegend::setIconSize ( int  width,
int  height 
)

◆ setIconTextPadding() [1/2]

void QCPLegend::setIconTextPadding ( int  padding)

Sets the horizontal space in pixels between the legend icon and the text next to it. Legend items that draw an icon (e.g. a visual representation of the graph) and text (e.g. the name of the graph) will use this space by default.

Definition at line 19155 of file qcustomplot.cpp.

References mIconTextPadding.

Referenced by QCPLegend().

◆ setIconTextPadding() [2/2]

void QCPLegend::setIconTextPadding ( int  padding)

◆ setSelectableParts() [1/2]

void QCPLegend::setSelectableParts ( const SelectableParts &  selectable)

Sets whether the user can (de-)select the parts in selectable by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains QCP::iSelectLegend.)

However, even when selectable is set to a value not allowing the selection of a specific part, it is still possible to set the selection of this part manually, by calling setSelectedParts directly.

See also
SelectablePart, setSelectedParts

Definition at line 19177 of file qcustomplot.cpp.

References mSelectableParts, and selectableChanged().

Referenced by QCPLegend().

◆ setSelectableParts() [2/2]

Q_SLOT void QCPLegend::setSelectableParts ( const SelectableParts &  selectableParts)

◆ setSelectedBorderPen() [1/2]

void QCPLegend::setSelectedBorderPen ( const QPen &  pen)

When the legend box is selected, this pen is used to draw the border instead of the normal pen set via setBorderPen.

See also
setSelectedParts, setSelectableParts, setSelectedBrush

Definition at line 19242 of file qcustomplot.cpp.

References mSelectedBorderPen.

Referenced by QCPLegend().

◆ setSelectedBorderPen() [2/2]

void QCPLegend::setSelectedBorderPen ( const QPen &  pen)

◆ setSelectedBrush() [1/2]

void QCPLegend::setSelectedBrush ( const QBrush &  brush)

When the legend box is selected, this brush is used to draw the legend background instead of the normal brush set via setBrush.

See also
setSelectedParts, setSelectableParts, setSelectedBorderPen

Definition at line 19262 of file qcustomplot.cpp.

References brush(), and mSelectedBrush.

Referenced by QCPLegend().

◆ setSelectedBrush() [2/2]

void QCPLegend::setSelectedBrush ( const QBrush &  brush)

◆ setSelectedFont() [1/2]

void QCPLegend::setSelectedFont ( const QFont &  font)

Sets the default font that is used by legend items when they are selected.

This function will also set font on all already existing legend items.

See also
setFont, QCPAbstractLegendItem::setSelectedFont

Definition at line 19273 of file qcustomplot.cpp.

References font(), item(), itemCount(), mSelectedFont, and QCPAbstractLegendItem::setSelectedFont().

◆ setSelectedFont() [2/2]

void QCPLegend::setSelectedFont ( const QFont &  font)

◆ setSelectedIconBorderPen() [1/2]

void QCPLegend::setSelectedIconBorderPen ( const QPen &  pen)

Sets the pen legend items will use to draw their icon borders, when they are selected.

See also
setSelectedParts, setSelectableParts, setSelectedFont

Definition at line 19252 of file qcustomplot.cpp.

References mSelectedIconBorderPen.

Referenced by QCPLegend().

◆ setSelectedIconBorderPen() [2/2]

void QCPLegend::setSelectedIconBorderPen ( const QPen &  pen)

◆ setSelectedParts() [1/2]

void QCPLegend::setSelectedParts ( const SelectableParts &  selected)

Sets the selected state of the respective legend parts described by SelectablePart. When a part is selected, it uses a different pen/font and brush. If some legend items are selected and selected doesn't contain spItems, those items become deselected.

The entire selection mechanism is handled automatically when QCustomPlot::setInteractions contains iSelectLegend. You only need to call this function when you wish to change the selection state manually.

This function can change the selection state of a part even when setSelectableParts was set to a value that actually excludes the part.

emits the selectionChanged signal when selected is different from the previous selection state.

Note that it doesn't make sense to set the selected state spItems here when it wasn't set before, because there's no way to specify which exact items to newly select. Do this by calling QCPAbstractLegendItem::setSelected directly on the legend item you wish to select.

See also
SelectablePart, setSelectableParts, selectTest, setSelectedBorderPen, setSelectedIconBorderPen, setSelectedBrush, setSelectedFont

Definition at line 19208 of file qcustomplot.cpp.

References item(), itemCount(), mSelectedParts, selectedParts(), selectionChanged(), QCPAbstractLegendItem::setSelected(), and spItems.

Referenced by deselectEvent(), QCPLegend(), and selectEvent().

◆ setSelectedParts() [2/2]

Q_SLOT void QCPLegend::setSelectedParts ( const SelectableParts &  selectedParts)

◆ setSelectedTextColor() [1/2]

void QCPLegend::setSelectedTextColor ( const QColor &  color)

Sets the default text color that is used by legend items when they are selected.

This function will also set color on all already existing legend items.

See also
setTextColor, QCPAbstractLegendItem::setSelectedTextColor

Definition at line 19288 of file qcustomplot.cpp.

References color, item(), itemCount(), mSelectedTextColor, and QCPAbstractLegendItem::setSelectedTextColor().

Referenced by QCPLegend().

◆ setSelectedTextColor() [2/2]

void QCPLegend::setSelectedTextColor ( const QColor &  color)

◆ setTextColor() [1/2]

void QCPLegend::setTextColor ( const QColor &  color)

Sets the default color of legend text. Legend items that draw text (e.g. the name of a graph) will use this color by default. However, a different colors can be specified on a per-item-basis by accessing the specific legend item.

This function will also set color on all already existing legend items.

See also
QCPAbstractLegendItem::setTextColor

Definition at line 19130 of file qcustomplot.cpp.

References color, item(), itemCount(), mTextColor, and QCPAbstractLegendItem::setTextColor().

Referenced by QCPLegend().

◆ setTextColor() [2/2]

void QCPLegend::setTextColor ( const QColor &  color)

◆ textColor() [1/2]

QColor QCPLegend::textColor ( ) const
inline

Definition at line 5654 of file qcustomplot.h.

◆ textColor() [2/2]

QColor QCPLegend::textColor ( ) const
inline

Definition at line 2683 of file qcustomplot.h.

Member Data Documentation

◆ mBorderPen

QPen QCPLegend::mBorderPen
protected

Definition at line 5707 of file qcustomplot.h.

Referenced by getBorderPen(), and setBorderPen().

◆ mBrush

QBrush QCPLegend::mBrush
protected

Definition at line 5708 of file qcustomplot.h.

Referenced by getBrush(), and setBrush().

◆ mFont

QFont QCPLegend::mFont
protected

Definition at line 5709 of file qcustomplot.h.

Referenced by setFont().

◆ mIconBorderPen

QPen QCPLegend::mIconBorderPen
protected

Definition at line 5707 of file qcustomplot.h.

Referenced by setIconBorderPen().

◆ mIconSize

QSize QCPLegend::mIconSize
protected

Definition at line 5711 of file qcustomplot.h.

Referenced by setIconSize().

◆ mIconTextPadding

int QCPLegend::mIconTextPadding
protected

Definition at line 5712 of file qcustomplot.h.

Referenced by setIconTextPadding().

◆ mSelectableParts

SelectableParts QCPLegend::mSelectableParts
protected

Definition at line 5713 of file qcustomplot.h.

Referenced by deselectEvent(), selectEvent(), selectTest(), and setSelectableParts().

◆ mSelectedBorderPen

QPen QCPLegend::mSelectedBorderPen
protected

Definition at line 5714 of file qcustomplot.h.

Referenced by getBorderPen(), and setSelectedBorderPen().

◆ mSelectedBrush

QBrush QCPLegend::mSelectedBrush
protected

Definition at line 5715 of file qcustomplot.h.

Referenced by getBrush(), and setSelectedBrush().

◆ mSelectedFont

QFont QCPLegend::mSelectedFont
protected

Definition at line 5716 of file qcustomplot.h.

Referenced by setSelectedFont().

◆ mSelectedIconBorderPen

QPen QCPLegend::mSelectedIconBorderPen
protected

Definition at line 5714 of file qcustomplot.h.

Referenced by setSelectedIconBorderPen().

◆ mSelectedParts

SelectableParts QCPLegend::mSelectedParts
protected

◆ mSelectedTextColor

QColor QCPLegend::mSelectedTextColor
protected

Definition at line 5717 of file qcustomplot.h.

Referenced by setSelectedTextColor().

◆ mTextColor

QColor QCPLegend::mTextColor
protected

Definition at line 5710 of file qcustomplot.h.

Referenced by setTextColor().


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