QCPBarsGroup
Public Types | |
enum | SpacingType { stAbsolute , stAxisRectRatio , stPlotCoords } |
Protected Member Functions | |
double | getPixelSpacing (const QCPBars *bars, double keyCoord) |
double | keyPixelOffset (const QCPBars *bars, double keyCoord) |
void | registerBars (QCPBars *bars) |
void | unregisterBars (QCPBars *bars) |
Protected Member Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Attributes | |
QList< QCPBars * > | mBars |
QCustomPlot * | mParentPlot |
double | mSpacing |
SpacingType | mSpacingType |
Detailed Description
Groups multiple QCPBars together so they appear side by side.
When showing multiple QCPBars in one plot which have bars at identical keys, it may be desirable to have them appearing next to each other at each key. This is what adding the respective QCPBars plottables to a QCPBarsGroup achieves. (An alternative approach is to stack them on top of each other, see QCPBars::moveAbove.)
Usage
To add a QCPBars plottable to the group, create a new group and then add the respective bars intances:
Alternatively to appending to the group like shown above, you can also set the group on the QCPBars plottable via QCPBars::setBarsGroup.
The spacing between the bars can be configured via setSpacingType and setSpacing. The bars in this group appear in the plot in the order they were appended. To insert a bars plottable at a certain index position, or to reposition a bars plottable which is already in the group, use insert.
To remove specific bars from the group, use either remove or call QCPBars::setBarsGroup(0) on the respective bars plottable.
To clear the entire group, call clear, or simply delete the group.
Example
The image above is generated with the following code:
Definition at line 5659 of file qcustomplot.h.
Member Enumeration Documentation
◆ SpacingType
Defines the ways the spacing between bars in the group can be specified. Thus it defines what the number passed to setSpacing actually means.
- See also
- setSpacingType, setSpacing
Definition at line 5673 of file qcustomplot.h.
Constructor & Destructor Documentation
◆ QCPBarsGroup()
|
explicit |
Constructs a new bars group for the specified QCustomPlot instance.
Definition at line 24008 of file qcustomplot.cpp.
◆ ~QCPBarsGroup()
|
virtual |
Definition at line 24016 of file qcustomplot.cpp.
Member Function Documentation
◆ append()
void QCPBarsGroup::append | ( | QCPBars * | bars | ) |
Adds the specified bars plottable to this group. Alternatively, you can also use QCPBars::setBarsGroup on the bars instance.
Definition at line 24080 of file qcustomplot.cpp.
◆ bars() [1/2]
Returns all bars currently in this group.
- See also
- bars(int index)
Definition at line 5691 of file qcustomplot.h.
◆ bars() [2/2]
QCPBars * QCPBarsGroup::bars | ( | int | index | ) | const |
◆ clear()
void QCPBarsGroup::clear | ( | ) |
Removes all QCPBars plottables from this group.
- See also
- isEmpty
Definition at line 24067 of file qcustomplot.cpp.
◆ contains()
|
inline |
Returns whether the specified bars plottable is part of this group.
Definition at line 5696 of file qcustomplot.h.
◆ getPixelSpacing()
Returns the spacing in pixels which is between this bars and the following one, both at the key coordinate keyCoord.
- Note
- Typically the returned value doesn't depend on bars or keyCoord. bars is only needed to get access to the key axis transformation and axis rect for the modes stAxisRectRatio and stPlotCoords. The keyCoord is only relevant for spacings given in stPlotCoords on a logarithmic axis.
Definition at line 24234 of file qcustomplot.cpp.
◆ insert()
void QCPBarsGroup::insert | ( | int | i, |
QCPBars * | bars ) |
Inserts the specified bars plottable into this group at the specified index position i. This gives you full control over the ordering of the bars.
bars may already be part of this group. In that case, bars is just moved to the new index position.
Definition at line 24103 of file qcustomplot.cpp.
◆ isEmpty()
|
inline |
Returns whether this bars group is empty.
- See also
- size
Definition at line 5694 of file qcustomplot.h.
◆ keyPixelOffset()
Returns the pixel offset in the key dimension the specified bars plottable should have at the given key coordinate keyCoord. The offset is relative to the pixel position of the key coordinate keyCoord.
Definition at line 24168 of file qcustomplot.cpp.
◆ registerBars()
|
protected |
Adds the specified bars to the internal mBars list of bars. This method does not change the barsGroup property on bars.
- See also
- unregisterBars
Definition at line 24144 of file qcustomplot.cpp.
◆ remove()
void QCPBarsGroup::remove | ( | QCPBars * | bars | ) |
Removes the specified bars plottable from this group.
Definition at line 24123 of file qcustomplot.cpp.
◆ setSpacing()
void QCPBarsGroup::setSpacing | ( | double | spacing | ) |
Sets the spacing between adjacent bars. What the number passed as spacing actually means, is defined by the current SpacingType, which can be set with setSpacingType.
- See also
- setSpacingType
Definition at line 24039 of file qcustomplot.cpp.
◆ setSpacingType()
void QCPBarsGroup::setSpacingType | ( | SpacingType | spacingType | ) |
Sets how the spacing between adjacent bars is interpreted. See SpacingType.
The actual spacing can then be specified with setSpacing.
- See also
- setSpacing
Definition at line 24028 of file qcustomplot.cpp.
◆ size()
|
inline |
Returns the number of QCPBars plottables that are part of this group.
Definition at line 5693 of file qcustomplot.h.
◆ spacing()
|
inline |
Definition at line 5684 of file qcustomplot.h.
◆ spacingType()
|
inline |
Definition at line 5683 of file qcustomplot.h.
◆ unregisterBars()
|
protected |
Removes the specified bars from the internal mBars list of bars. This method does not change the barsGroup property on bars.
- See also
- registerBars
Definition at line 24157 of file qcustomplot.cpp.
Member Data Documentation
◆ mBars
Definition at line 5706 of file qcustomplot.h.
◆ mParentPlot
|
protected |
Definition at line 5703 of file qcustomplot.h.
◆ mSpacing
|
protected |
Definition at line 5705 of file qcustomplot.h.
◆ mSpacingType
|
protected |
Definition at line 5704 of file qcustomplot.h.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:05 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.