qcustomplot/ 0000755 0001750 0001750 00000000000 12236016576 013330 5 ustar dermanu dermanu qcustomplot/documentation/ 0000755 0001750 0001750 00000000000 12236016576 016201 5 ustar dermanu dermanu qcustomplot/documentation/html/ 0000755 0001750 0001750 00000000000 12236016576 017145 5 ustar dermanu dermanu qcustomplot/documentation/html/functions_func_0x66.html 0000644 0001750 0001750 00000002572 12236016575 023646 0 ustar dermanu dermanu
Manages a single axis inside a QCustomPlot. More...
Public Types | |
enum | AxisType |
enum | LabelType |
enum | ScaleType |
enum | SelectablePart |
Public Functions | |
QCPAxis (QCPAxisRect *parent, AxisType type) | |
AxisType | axisType () const |
QCPAxisRect * | axisRect () const |
ScaleType | scaleType () const |
double | scaleLogBase () const |
const QCPRange | range () const |
bool | rangeReversed () const |
bool | autoTicks () const |
int | autoTickCount () const |
bool | autoTickLabels () const |
bool | autoTickStep () const |
bool | autoSubTicks () const |
bool | ticks () const |
bool | tickLabels () const |
int | tickLabelPadding () const |
LabelType | tickLabelType () const |
QFont | tickLabelFont () const |
QColor | tickLabelColor () const |
double | tickLabelRotation () const |
QString | dateTimeFormat () const |
Qt::TimeSpec | dateTimeSpec () const |
QString | numberFormat () const |
int | numberPrecision () const |
double | tickStep () const |
QVector< double > | tickVector () const |
QVector< QString > | tickVectorLabels () const |
int | tickLengthIn () const |
int | tickLengthOut () const |
int | subTickCount () const |
int | subTickLengthIn () const |
int | subTickLengthOut () const |
QPen | basePen () const |
QPen | tickPen () const |
QPen | subTickPen () const |
QFont | labelFont () const |
QColor | labelColor () const |
QString | label () const |
int | labelPadding () const |
int | padding () const |
int | offset () const |
SelectableParts | selectedParts () const |
SelectableParts | selectableParts () const |
QFont | selectedTickLabelFont () const |
QFont | selectedLabelFont () const |
QColor | selectedTickLabelColor () const |
QColor | selectedLabelColor () const |
QPen | selectedBasePen () const |
QPen | selectedTickPen () const |
QPen | selectedSubTickPen () const |
QCPLineEnding | lowerEnding () const |
QCPLineEnding | upperEnding () const |
QCPGrid * | grid () const |
void | setScaleType (ScaleType type) |
void | setScaleLogBase (double base) |
Q_SLOT void | setRange (const QCPRange &range) |
void | setRange (double lower, double upper) |
void | setRange (double position, double size, Qt::AlignmentFlag alignment) |
void | setRangeLower (double lower) |
void | setRangeUpper (double upper) |
void | setRangeReversed (bool reversed) |
void | setAutoTicks (bool on) |
void | setAutoTickCount (int approximateCount) |
void | setAutoTickLabels (bool on) |
void | setAutoTickStep (bool on) |
void | setAutoSubTicks (bool on) |
void | setTicks (bool show) |
void | setTickLabels (bool show) |
void | setTickLabelPadding (int padding) |
void | setTickLabelType (LabelType type) |
void | setTickLabelFont (const QFont &font) |
void | setTickLabelColor (const QColor &color) |
void | setTickLabelRotation (double degrees) |
void | setDateTimeFormat (const QString &format) |
void | setDateTimeSpec (const Qt::TimeSpec &timeSpec) |
void | setNumberFormat (const QString &formatCode) |
void | setNumberPrecision (int precision) |
void | setTickStep (double step) |
void | setTickVector (const QVector< double > &vec) |
void | setTickVectorLabels (const QVector< QString > &vec) |
void | setTickLength (int inside, int outside=0) |
void | setTickLengthIn (int inside) |
void | setTickLengthOut (int outside) |
void | setSubTickCount (int count) |
void | setSubTickLength (int inside, int outside=0) |
void | setSubTickLengthIn (int inside) |
void | setSubTickLengthOut (int outside) |
void | setBasePen (const QPen &pen) |
void | setTickPen (const QPen &pen) |
void | setSubTickPen (const QPen &pen) |
void | setLabelFont (const QFont &font) |
void | setLabelColor (const QColor &color) |
void | setLabel (const QString &str) |
void | setLabelPadding (int padding) |
void | setPadding (int padding) |
void | setOffset (int offset) |
void | setSelectedTickLabelFont (const QFont &font) |
void | setSelectedLabelFont (const QFont &font) |
void | setSelectedTickLabelColor (const QColor &color) |
void | setSelectedLabelColor (const QColor &color) |
void | setSelectedBasePen (const QPen &pen) |
void | setSelectedTickPen (const QPen &pen) |
void | setSelectedSubTickPen (const QPen &pen) |
Q_SLOT void | setSelectableParts (const QCPAxis::SelectableParts &selectableParts) |
Q_SLOT void | setSelectedParts (const QCPAxis::SelectableParts &selectedParts) |
void | setLowerEnding (const QCPLineEnding &ending) |
void | setUpperEnding (const QCPLineEnding &ending) |
virtual double | selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const |
Qt::Orientation | orientation () const |
void | moveRange (double diff) |
void | scaleRange (double factor, double center) |
void | setScaleRatio (const QCPAxis *otherAxis, double ratio=1.0) |
void | rescale (bool onlyVisiblePlottables=false) |
double | pixelToCoord (double value) const |
double | coordToPixel (double value) const |
SelectablePart | getPartAt (const QPointF &pos) const |
QList< QCPAbstractPlottable * > | plottables () const |
QList< QCPGraph * > | graphs () const |
QList< QCPAbstractItem * > | items () const |
bool | visible () const |
QCustomPlot * | parentPlot () const |
QCPLayerable * | parentLayerable () const |
QCPLayer * | layer () const |
bool | antialiased () const |
void | setVisible (bool on) |
bool | setLayer (QCPLayer *layer) |
bool | setLayer (const QString &layerName) |
void | setAntialiased (bool enabled) |
bool | realVisibility () const |
Signals | |
void | ticksRequest () |
void | rangeChanged (const QCPRange &newRange) |
void | rangeChanged (const QCPRange &newRange, const QCPRange &oldRange) |
void | selectionChanged (const QCPAxis::SelectableParts &parts) |
Static Public Functions | |
static AxisType | marginSideToAxisType (QCP::MarginSide side) |
Protected Functions | |
virtual void | setupTickVectors () |
virtual void | generateAutoTicks () |
virtual int | calculateAutoSubTickCount (double tickStep) const |
virtual int | calculateMargin () |
virtual void | placeTickLabel (QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize) |
virtual void | drawTickLabel (QCPPainter *painter, double x, double y, const TickLabelData &labelData) const |
virtual TickLabelData | getTickLabelData (const QFont &font, const QString &text) const |
virtual QPointF | getTickLabelDrawOffset (const TickLabelData &labelData) const |
virtual void | getMaxTickLabelSize (const QFont &font, const QString &text, QSize *tickLabelsSize) const |
virtual void | applyDefaultAntialiasingHint (QCPPainter *painter) const |
virtual void | draw (QCPPainter *painter) |
virtual QCP::Interaction | selectionCategory () const |
virtual void | selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) |
virtual void | deselectEvent (bool *selectionStateChanged) |
void | visibleTickBounds (int &lowIndex, int &highIndex) const |
double | baseLog (double value) const |
double | basePow (double value) const |
QPen | getBasePen () const |
QPen | getTickPen () const |
QPen | getSubTickPen () const |
QFont | getTickLabelFont () const |
QFont | getLabelFont () const |
QColor | getTickLabelColor () const |
QColor | getLabelColor () const |
virtual void | parentPlotInitialized (QCustomPlot *parentPlot) |
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 |
Manages a single axis inside a QCustomPlot.
Usually doesn't need to be instantiated externally. Access QCustomPlot's default four axes via QCustomPlot::xAxis (bottom), QCustomPlot::yAxis (left), QCustomPlot::xAxis2 (top) and QCustomPlot::yAxis2 (right).
Axes are always part of an axis rect, see QCPAxisRect.
enum QCPAxis::AxisType |
Defines at which side of the axis rect the axis will appear. This also affects how the tick marks are drawn, on which side the labels are placed etc.
enum QCPAxis::LabelType |
When automatic tick label generation is enabled (setAutoTickLabels), defines how the coordinate of the tick is interpreted, i.e. translated into a string.
ltNumber |
Tick coordinate is regarded as normal number and will be displayed as such. (see setNumberFormat) |
ltDateTime |
Tick coordinate is regarded as a date/time (seconds since 1970-01-01T00:00:00 UTC) and will be displayed and formatted as such. (for details, see setDateTimeFormat) |
enum QCPAxis::ScaleType |
Defines the scale of an axis.
stLinear |
Linear scaling. |
stLogarithmic |
Logarithmic scaling with correspondingly transformed plots and (major) tick marks at every base power (see setScaleLogBase). |
Defines the selectable parts of an axis.
|
explicit |
Constructs an Axis instance of Type type for the axis rect parent. You shouldn't instantiate axes directly, rather use QCPAxisRect::addAxis.
|
inline |
Returns the QCPGrid instance belonging to this axis. Access it to set details about the way the grid is displayed.
void QCPAxis::setScaleType | ( | ScaleType | type | ) |
Sets whether the axis uses a linear scale or a logarithmic scale. If type is set to stLogarithmic, the logarithm base can be set with setScaleLogBase. In logarithmic axis scaling, major tick marks appear at all powers of the logarithm base. Properties like tick step (setTickStep) don't apply in logarithmic scaling. If you wish a decimal base but less major ticks, consider choosing a logarithm base of 100, 1000 or even higher.
If type is stLogarithmic and the number format (setNumberFormat) uses the 'b' option (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10 [superscript] n", which looks unnatural for logarithmic scaling (the "1 [multiplication sign]" part). To only display the decimal power, set the number precision to zero with setNumberPrecision.
void QCPAxis::setScaleLogBase | ( | double | base | ) |
If setScaleType is set to stLogarithmic, base will be the logarithm base of the scaling. In logarithmic axis scaling, major tick marks appear at all powers of base.
Properties like tick step (setTickStep) don't apply in logarithmic scaling. If you wish a decimal base but less major ticks, consider choosing base 100, 1000 or even higher.
void QCPAxis::setRange | ( | const QCPRange & | range | ) |
Sets the range of the axis.
This slot may be connected with the rangeChanged signal of another axis so this axis is always synchronized with the other axis range, when it changes.
To invert the direction of an axis, use setRangeReversed.
void QCPAxis::setRange | ( | double | lower, |
double | upper | ||
) |
This is an overloaded function.
Sets the lower and upper bound of the axis range.
To invert the direction of an axis, use setRangeReversed.
There is also a slot to set a range, see setRange(const QCPRange &range).
void QCPAxis::setRange | ( | double | position, |
double | size, | ||
Qt::AlignmentFlag | alignment | ||
) |
This is an overloaded function.
Sets the range of the axis.
The position coordinate indicates together with the alignment parameter, where the new range will be positioned. size defines the size of the new axis range. alignment may be Qt::AlignLeft, Qt::AlignRight or Qt::AlignCenter. This will cause the left border, right border, or center of the range to be aligned with position. Any other values of alignment will default to Qt::AlignCenter.
void QCPAxis::setRangeLower | ( | double | lower | ) |
Sets the lower bound of the axis range. The upper bound is not changed.
void QCPAxis::setRangeUpper | ( | double | upper | ) |
Sets the upper bound of the axis range. The lower bound is not changed.
void QCPAxis::setRangeReversed | ( | bool | reversed | ) |
Sets whether the axis range (direction) is displayed reversed. Normally, the values on horizontal axes increase left to right, on vertical axes bottom to top. When reversed is set to true, the direction of increasing values is inverted.
Note that the range and data interface stays the same for reversed axes, e.g. the lower part of the setRange interface will still reference the mathematically smaller number than the upper part.
void QCPAxis::setAutoTicks | ( | bool | on | ) |
Sets whether the tick positions should be calculated automatically (either from an automatically generated tick step or a tick step provided manually via setTickStep, see setAutoTickStep).
If on is set to false, you must provide the tick positions manually via setTickVector. For these manual ticks you may let QCPAxis generate the appropriate labels automatically by leaving setAutoTickLabels set to true. If you also wish to control the displayed labels manually, set setAutoTickLabels to false and provide the label strings with setTickVectorLabels.
If you need dynamically calculated tick vectors (and possibly tick label vectors), set the vectors in a slot connected to the ticksRequest signal.
void QCPAxis::setAutoTickCount | ( | int | approximateCount | ) |
When setAutoTickStep is true, approximateCount determines how many ticks should be generated in the visible range, approximately.
It's not guaranteed that this number of ticks is met exactly, but approximately within a tolerance of about two.
Only values greater than zero are accepted as approximateCount.
void QCPAxis::setAutoTickLabels | ( | bool | on | ) |
Sets whether the tick labels are generated automatically. Depending on the tick label type (ltNumber or ltDateTime), the labels will either show the coordinate as floating point number (setNumberFormat), or a date/time formatted according to setDateTimeFormat.
If on is set to false, you should provide the tick labels via setTickVectorLabels. This is usually used in a combination with setAutoTicks set to false for complete control over tick positions and labels, e.g. when the ticks should be at multiples of pi and show "2pi", "3pi" etc. as tick labels.
If you need dynamically calculated tick vectors (and possibly tick label vectors), set the vectors in a slot connected to the ticksRequest signal.
void QCPAxis::setAutoTickStep | ( | bool | on | ) |
Sets whether the tick step, i.e. the interval between two (major) ticks, is calculated automatically. If on is set to true, the axis finds a tick step that is reasonable for human readable plots.
The number of ticks the algorithm aims for within the visible range can be set with setAutoTickCount.
If on is set to false, you may set the tick step manually with setTickStep.
void QCPAxis::setAutoSubTicks | ( | bool | on | ) |
Sets whether the number of sub ticks in one tick interval is determined automatically. This works, as long as the tick step mantissa is a multiple of 0.5. When setAutoTickStep is enabled, this is always the case.
When on is set to false, you may set the sub tick count with setSubTickCount manually.
void QCPAxis::setTicks | ( | bool | show | ) |
Sets whether tick marks are displayed.
Note that setting show to false does not imply that tick labels are invisible, too. To achieve that, see setTickLabels.
void QCPAxis::setTickLabels | ( | bool | show | ) |
Sets whether tick labels are displayed. Tick labels are the numbers drawn next to tick marks.
void QCPAxis::setTickLabelPadding | ( | int | padding | ) |
Sets the distance between the axis base line (including any outward ticks) and the tick labels.
void QCPAxis::setTickLabelType | ( | LabelType | type | ) |
Sets whether the tick labels display numbers or dates/times.
If type is set to ltNumber, the format specifications of setNumberFormat apply.
If type is set to ltDateTime, the format specifications of setDateTimeFormat apply.
In QCustomPlot, date/time coordinates are double
numbers representing the seconds since 1970-01-01T00:00:00 UTC. This format can be retrieved from QDateTime objects with the QDateTime::toTime_t() function. Since this only gives a resolution of one second, there is also the QDateTime::toMSecsSinceEpoch() function which returns the timespan described above in milliseconds. Divide its return value by 1000.0 to get a value with the format needed for date/time plotting, with a resolution of one millisecond.
Using the toMSecsSinceEpoch function allows dates that go back to 2nd January 4713 B.C. (represented by a negative number), unlike the toTime_t function, which works with unsigned integers and thus only goes back to 1st January 1970. So both for range and accuracy, use of toMSecsSinceEpoch()/1000.0 should be preferred as key coordinate for date/time axes.
void QCPAxis::setTickLabelFont | ( | const QFont & | font | ) |
Sets the font of the tick labels.
void QCPAxis::setTickLabelColor | ( | const QColor & | color | ) |
Sets the color of the tick labels.
void QCPAxis::setTickLabelRotation | ( | double | degrees | ) |
Sets the rotation of the tick labels. If degrees is zero, the labels are drawn normally. Else, the tick labels are drawn rotated by degrees clockwise. The specified angle is bound to values from -90 to 90 degrees.
If degrees is exactly -90, 0 or 90, the tick labels are centered on the tick coordinate. For other angles, the label is drawn with an offset such that it seems to point toward or away from the tick mark.
void QCPAxis::setDateTimeFormat | ( | const QString & | format | ) |
Sets the format in which dates and times are displayed as tick labels, if setTickLabelType is ltDateTime. for details about the format string, see the documentation of QDateTime::toString().
Newlines can be inserted with "\n".
void QCPAxis::setDateTimeSpec | ( | const Qt::TimeSpec & | timeSpec | ) |
Sets the time spec that is used for the date time values when setTickLabelType is ltDateTime.
The default value of QDateTime objects (and also QCustomPlot) is Qt::LocalTime
. However, if the date time values passed to QCustomPlot are given in the UTC spec, set timeSpec to Qt::UTC
to get the correct axis labels.
void QCPAxis::setNumberFormat | ( | const QString & | formatCode | ) |
Sets the number format for the numbers drawn as tick labels (if tick label type is ltNumber). This formatCode is an extended version of the format code used e.g. by QString::number() and QLocale::toString(). For reference about that, see the "Argument Formats" section in the detailed description of the QString class. formatCode is a string of one, two or three characters. The first character is identical to the normal format code used by Qt. In short, this means: 'e'/'E' scientific format, 'f' fixed format, 'g'/'G' scientific or fixed, whichever is shorter.
The second and third characters are optional and specific to QCustomPlot:
If the first char was 'e' or 'g', numbers are/might be displayed in the scientific format, e.g. "5.5e9", which is ugly in a plot. So when the second char of formatCode is set to 'b' (for "beautiful"), those exponential numbers are formatted in a more natural way, i.e. "5.5
[multiplication sign] 10 [superscript] 9". By default, the multiplication sign is a centered dot. If instead a cross should be shown (as is usual in the USA), the third char of formatCode can be set to 'c'. The inserted multiplication signs are the UTF-8 characters 215 (0xD7) for the cross and 183 (0xB7) for the dot.
If the scale type (setScaleType) is stLogarithmic and the formatCode uses the 'b' option (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10 [superscript] n", which looks unnatural for logarithmic scaling (the "1 [multiplication sign]" part). To only display the decimal power, set the number precision to zero with setNumberPrecision.
Examples for formatCode:
g
normal format code behaviour. If number is small, fixed format is used, if number is large, normal scientific format is used gb
If number is small, fixed format is used, if number is large, scientific format is used with beautifully typeset decimal powers and a dot as multiplication sign ebc
All numbers are in scientific format with beautifully typeset decimal power and a cross as multiplication sign fb
illegal format code, since fixed format doesn't support (or need) beautifully typeset decimal powers. Format code will be reduced to 'f'. hello
illegal format code, since first char is not 'e', 'E', 'f', 'g' or 'G'. Current format code will not be changed. void QCPAxis::setNumberPrecision | ( | int | precision | ) |
Sets the precision of the tick label numbers. See QLocale::toString(double i, char f, int prec) for details. The effect of precisions are most notably for number Formats starting with 'e', see setNumberFormat
If the scale type (setScaleType) is stLogarithmic and the number format (setNumberFormat) uses the 'b' format code (beautifully typeset decimal powers), the display usually is "1 [multiplication sign] 10 [superscript] n", which looks unnatural for logarithmic scaling (the redundant "1 [multiplication sign]" part). To only display the decimal power "10 [superscript] n", set precision to zero.
void QCPAxis::setTickStep | ( | double | step | ) |
If setAutoTickStep is set to false, use this function to set the tick step manually. The tick step is the interval between (major) ticks, in plot coordinates.
void QCPAxis::setTickVector | ( | const QVector< double > & | vec | ) |
If you want full control over what ticks (and possibly labels) the axes show, this function is used to set the coordinates at which ticks will appear.setAutoTicks must be disabled, else the provided tick vector will be overwritten with automatically generated tick coordinates upon replot. The labels of the ticks can be generated automatically when setAutoTickLabels is left enabled. If it is disabled, you can set the labels manually with setTickVectorLabels.
vec is a vector containing the positions of the ticks, in plot coordinates.
void QCPAxis::setTickVectorLabels | ( | const QVector< QString > & | vec | ) |
If you want full control over what ticks and labels the axes show, this function is used to set a number of QStrings that will be displayed at the tick positions which you need to provide with setTickVector. These two vectors should have the same size. (Note that you need to disable setAutoTicks and setAutoTickLabels first.)
vec is a vector containing the labels of the ticks. The entries correspond to the respective indices in the tick vector, passed via setTickVector.
void QCPAxis::setTickLength | ( | int | inside, |
int | outside = 0 |
||
) |
Sets the length of the ticks in pixels. inside is the length the ticks will reach inside the plot and outside is the length they will reach outside the plot. If outside is greater than zero, the tick labels and axis label will increase their distance to the axis accordingly, so they won't collide with the ticks.
void QCPAxis::setTickLengthIn | ( | int | inside | ) |
Sets the length of the inward ticks in pixels. inside is the length the ticks will reach inside the plot.
void QCPAxis::setTickLengthOut | ( | int | outside | ) |
Sets the length of the outward ticks in pixels. outside is the length the ticks will reach outside the plot. If outside is greater than zero, the tick labels and axis label will increase their distance to the axis accordingly, so they won't collide with the ticks.
void QCPAxis::setSubTickCount | ( | int | count | ) |
Sets the number of sub ticks in one (major) tick step. A sub tick count of three for example, divides the tick intervals in four sub intervals.
By default, the number of sub ticks is chosen automatically in a reasonable manner as long as the mantissa of the tick step is a multiple of 0.5. When setAutoTickStep is enabled, this is always the case.
If you want to disable automatic sub tick count and use this function to set the count manually, see setAutoSubTicks.
void QCPAxis::setSubTickLength | ( | int | inside, |
int | outside = 0 |
||
) |
Sets the length of the subticks in pixels. inside is the length the subticks will reach inside the plot and outside is the length they will reach outside the plot. If outside is greater than zero, the tick labels and axis label will increase their distance to the axis accordingly, so they won't collide with the ticks.
void QCPAxis::setSubTickLengthIn | ( | int | inside | ) |
Sets the length of the inward subticks in pixels. inside is the length the subticks will reach inside the plot.
void QCPAxis::setSubTickLengthOut | ( | int | outside | ) |
Sets the length of the outward subticks in pixels. outside is the length the subticks will reach outside the plot. If outside is greater than zero, the tick labels will increase their distance to the axis accordingly, so they won't collide with the ticks.
void QCPAxis::setBasePen | ( | const QPen & | pen | ) |
Sets the pen, the axis base line is drawn with.
void QCPAxis::setTickPen | ( | const QPen & | pen | ) |
Sets the pen, tick marks will be drawn with.
void QCPAxis::setSubTickPen | ( | const QPen & | pen | ) |
Sets the pen, subtick marks will be drawn with.
void QCPAxis::setLabelFont | ( | const QFont & | font | ) |
Sets the font of the axis label.
void QCPAxis::setLabelColor | ( | const QColor & | color | ) |
Sets the color of the axis label.
void QCPAxis::setLabel | ( | const QString & | str | ) |
Sets the text of the axis label that will be shown below/above or next to the axis, depending on its orientation. To disable axis labels, pass an empty string as str.
void QCPAxis::setLabelPadding | ( | int | padding | ) |
Sets the distance between the tick labels and the axis label.
void QCPAxis::setPadding | ( | int | padding | ) |
Sets the padding of the axis.
When QCPAxisRect::setAutoMargins is enabled, the padding is the additional outer most space, that is left blank.
The axis padding has no meaning if QCPAxisRect::setAutoMargins is disabled.
void QCPAxis::setOffset | ( | int | offset | ) |
Sets the offset the axis has to its axis rect side.
If an axis rect side has multiple axes, only the offset of the inner most axis has meaning. The offset of the other axes is controlled automatically, to place the axes at appropriate positions to prevent them from overlapping.
void QCPAxis::setSelectedTickLabelFont | ( | const QFont & | font | ) |
Sets the font that is used for tick labels when they are selected.
void QCPAxis::setSelectedLabelFont | ( | const QFont & | font | ) |
Sets the font that is used for the axis label when it is selected.
void QCPAxis::setSelectedTickLabelColor | ( | const QColor & | color | ) |
Sets the color that is used for tick labels when they are selected.
void QCPAxis::setSelectedLabelColor | ( | const QColor & | color | ) |
Sets the color that is used for the axis label when it is selected.
void QCPAxis::setSelectedBasePen | ( | const QPen & | pen | ) |
Sets the pen that is used to draw the axis base line when selected.
void QCPAxis::setSelectedTickPen | ( | const QPen & | pen | ) |
Sets the pen that is used to draw the (major) ticks when selected.
void QCPAxis::setSelectedSubTickPen | ( | const QPen & | pen | ) |
Sets the pen that is used to draw the subticks when selected.
void QCPAxis::setSelectableParts | ( | const QCPAxis::SelectableParts & | selectableParts | ) |
Sets whether the user can (de-)select the parts in selectable by clicking on the QCustomPlot surface. (When QCustomPlot::setInteractions contains iSelectAxes.)
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.
void QCPAxis::setSelectedParts | ( | const QCPAxis::SelectableParts & | selectedParts | ) |
Sets the selected state of the respective axis parts described by SelectablePart. When a part is selected, it uses a different pen/font.
The entire selection mechanism for axes is handled automatically when QCustomPlot::setInteractions contains iSelectAxes. 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, independent of the setSelectableParts setting.
emits the selectionChanged signal when selected is different from the previous selection state.
void QCPAxis::setLowerEnding | ( | const QCPLineEnding & | ending | ) |
Sets the style for the lower axis ending. See the documentation of QCPLineEnding for available styles.
For horizontal axes, this method refers to the left ending, for vertical axes the bottom ending. Note that this meaning does not change when the axis range is reversed with setRangeReversed.
void QCPAxis::setUpperEnding | ( | const QCPLineEnding & | ending | ) |
Sets the style for the upper axis ending. See the documentation of QCPLineEnding for available styles.
For horizontal axes, this method refers to the right ending, for vertical axes the top ending. Note that this meaning does not change when the axis range is reversed with setRangeReversed.
|
virtual |
This function is used to decide whether a click hits a layerable object or not.
pos is a point in pixel coordinates on the QCustomPlot surface. This function returns the shortest pixel distance of this point to the object. If the object is either invisible or the distance couldn't be determined, -1.0 is returned. Further, if onlySelectable is true and the object is not selectable, -1.0 is returned, too.
If the item is represented not by single lines but by an area like QCPItemRect or QCPItemText, a click inside the area returns a constant value greater zero (typically the selectionTolerance of the parent QCustomPlot multiplied by 0.99). If the click lies outside the area, this function returns -1.0.
Providing a constant value for area objects allows selecting line objects even when they are obscured by such area objects, by clicking close to the lines (i.e. closer than 0.99*selectionTolerance).
The actual setting of the selection state is not done by this function. This is handled by the parent QCustomPlot when the mouseReleaseEvent occurs, and the finally selected object is notified via the selectEvent/deselectEvent methods.
details is an optional output parameter. Every layerable subclass may place any information in details. This information will be passed to selectEvent when the parent QCustomPlot decides on the basis of this selectTest call, that the object was successfully selected. The subsequent call to selectEvent will carry the details. This is useful for multi-part objects (like QCPAxis). This way, a possibly complex calculation to decide which part was clicked is only done once in selectTest. The result (i.e. the actually clicked part) can then be placed in details. So in the subsequent selectEvent, the decision which part was selected doesn't have to be done a second time for a single selection operation.
You may pass 0 as details to indicate that you are not interested in those selection details.
Reimplemented from QCPLayerable.
|
inline |
Returns the orientation of the axis. The axis orientation (horizontal or vertical) is deduced from the axis type (left, top, right or bottom).
void QCPAxis::moveRange | ( | double | diff | ) |
If the scale type (setScaleType) is stLinear, diff is added to the lower and upper bounds of the range. The range is simply moved by diff.
If the scale type is stLogarithmic, the range bounds are multiplied by diff. This corresponds to an apparent "linear" move in logarithmic scaling by a distance of log(diff).
void QCPAxis::scaleRange | ( | double | factor, |
double | center | ||
) |
Scales the range of this axis by factor around the coordinate center. For example, if factor is 2.0, center is 1.0, then the axis range will double its size, and the point at coordinate 1.0 won't have changed its position in the QCustomPlot widget (i.e. coordinates around 1.0 will have moved symmetrically closer to 1.0).
void QCPAxis::setScaleRatio | ( | const QCPAxis * | otherAxis, |
double | ratio = 1.0 |
||
) |
Scales the range of this axis to have a certain scale ratio to otherAxis. The scaling will be done around the center of the current axis range.
For example, if ratio is 1, this axis is the yAxis and otherAxis is xAxis, graphs plotted with those axes will appear in a 1:1 aspect ratio, independent of the aspect ratio the axis rect has.
This is an operation that changes the range of this axis once, it doesn't fix the scale ratio indefinitely. Note that calling this function in the constructor of the QCustomPlot's parent won't have the desired effect, since the widget dimensions aren't defined yet, and a resizeEvent will follow.
void QCPAxis::rescale | ( | bool | onlyVisiblePlottables = false | ) |
Changes the axis range such that all plottables associated with this axis are fully visible in that dimension.
double QCPAxis::pixelToCoord | ( | double | value | ) | const |
Transforms value, in pixel coordinates of the QCustomPlot widget, to axis coordinates.
double QCPAxis::coordToPixel | ( | double | value | ) | const |
Transforms value, in coordinates of the axis, to pixel coordinates of the QCustomPlot widget.
QCPAxis::SelectablePart QCPAxis::getPartAt | ( | const QPointF & | pos | ) | const |
Returns the part of the axis that is hit by pos (in pixels). The return value of this function is independent of the user-selectable parts defined with setSelectableParts. Further, this function does not change the current selection state of the axis.
If the axis is not visible (setVisible), this function always returns spNone.
QList< QCPAbstractPlottable * > QCPAxis::plottables | ( | ) | const |
QList< QCPGraph * > QCPAxis::graphs | ( | ) | const |
Returns a list of all the graphs that have this axis as key or value axis.
QList< QCPAbstractItem * > QCPAxis::items | ( | ) | const |
Returns a list of all the items that are associated with this axis. An item is considered associated with an axis if at least one of its positions uses the axis as key or value axis.
|
static |
Transforms a margin side to the logically corresponding axis type. (QCP::msLeft to QCPAxis::atLeft, QCP::msRight to QCPAxis::atRight, etc.)
|
signal |
This signal is emitted when setAutoTicks is false and the axis is about to generate tick labels for a replot.
Modifying the tick positions can be done with setTickVector. If you also want to control the tick labels, set setAutoTickLabels to false and also provide the labels with setTickVectorLabels.
If you only want static ticks you probably don't need this signal, since you can just set the tick vector (and possibly tick label vector) once. However, if you want to provide ticks (and maybe labels) dynamically, e.g. depending on the current axis range, connect a slot to this signal and set the vector/vectors there.
|
signal |
This signal is emitted when the range of this axis has changed. You can connect it to the setRange slot of another axis to communicate the new range to the other axis, in order for it to be synchronized.
This is an overloaded function.
Additionally to the new range, this signal also provides the previous range held by the axis as oldRange.
|
signal |
This signal is emitted when the selection state of this axis has changed, either by user interaction or by a direct call to setSelectedParts.
|
protectedvirtual |
This function is called to prepare the tick vector, sub tick vector and tick label vector. If setAutoTicks is set to true, appropriate tick values are determined automatically via generateAutoTicks. If it's set to false, the signal ticksRequest is emitted, which can be used to provide external tick positions. Then the sub tick vectors and tick label vectors are created.
|
protectedvirtual |
If setAutoTicks is set to true, this function is called by setupTickVectors to generate reasonable tick positions (and subtick count). The algorithm tries to create approximately mAutoTickCount
ticks (set via setAutoTickCount).
If the scale is logarithmic, setAutoTickCount is ignored, and one tick is generated at every power of the current logarithm base, set via setScaleLogBase.
|
protectedvirtual |
Called by generateAutoTicks when setAutoSubTicks is set to true. Depending on the tickStep between two major ticks on the axis, a different number of sub ticks is appropriate. For Example taking 4 sub ticks for a tickStep of 1 makes more sense than taking 5 sub ticks, because this corresponds to a sub tick step of 0.2, instead of the less intuitive 0.16667. Note that a subtick count of 4 means dividing the major tick step into 5 sections.
This is implemented by a hand made lookup for integer tick steps as well as fractional tick steps with a fractional part of (approximately) 0.5. If a tick step is different (i.e. has no fractional part close to 0.5), the currently set sub tick count (setSubTickCount) is returned.
|
protectedvirtual |
Returns the appropriate outward margin for this axis. It is needed if QCPAxisRect::setAutoMargins is set to true on the parent axis rect. An axis with axis type atLeft will return an appropriate left margin, atBottom will return an appropriate bottom margin and so forth. For the calculation, this function goes through similar steps as draw, so changing one function likely requires the modification of the other one as well.
The margin consists of the outward tick length, tick label padding, tick label size, label padding, label size, and padding.
The margin is cached internally, so repeated calls while leaving the axis range, fonts, etc. unchanged are very fast.
|
protectedvirtual |
Draws a single tick label with the provided painter, utilizing the internal label cache to significantly speed up drawing of labels that were drawn in previous calls. The tick label is always bound to an axis, the distance to the axis is controllable via distanceToAxis in pixels. The pixel position in the axis direction is passed in the position parameter. Hence for the bottom axis, position would indicate the horizontal pixel position (not coordinate), at which the label should be drawn.
In order to later draw the axis label in a place that doesn't overlap with the tick labels, the largest tick label size is needed. This is acquired by passing a tickLabelsSize to the drawTickLabel calls during the process of drawing all tick labels of one axis. In every call, tickLabelsSize is expanded, if the drawn label exceeds the value tickLabelsSize currently holds.
The label is drawn with the font and pen that are currently set on the painter. To draw superscripted powers, the font is temporarily made smaller by a fixed factor (see getTickLabelData).
|
protectedvirtual |
This is a placeTickLabel helper function.
Draws the tick label specified in labelData with painter at the pixel positions x and y. This function is used by placeTickLabel to create new tick labels for the cache, or to directly draw the labels on the QCustomPlot surface when label caching is disabled, i.e. when QCP::phCacheLabels plotting hint is not set.
|
protectedvirtual |
This is a placeTickLabel helper function.
Transforms the passed text and font to a tickLabelData structure that can then be further processed by getTickLabelDrawOffset and drawTickLabel. It splits the text into base and exponent if necessary (see setNumberFormat) and calculates appropriate bounding boxes.
|
protectedvirtual |
This is a placeTickLabel helper function.
Calculates the offset at which the top left corner of the specified tick label shall be drawn. The offset is relative to a point right next to the tick the label belongs to.
This function is thus responsible for e.g. centering tick labels under ticks and positioning them appropriately when they are rotated.
|
protectedvirtual |
Simulates the steps done by placeTickLabel by calculating bounding boxes of the text label to be drawn, depending on number format etc. Since only the largest tick label is wanted for the margin calculation, the passed tickLabelsSize is only expanded, if it's currently set to a smaller width/height.
|
protectedvirtual |
A convenience function to easily set the QPainter::Antialiased hint on the provided painter before drawing axis lines.
This is the antialiasing state the painter passed to the draw method is in by default.
This function takes into account the local setting of the antialiasing flag as well as the overrides set with QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.
Implements QCPLayerable.
|
protectedvirtual |
Draws the axis with the specified painter.
The selection boxes (mAxisSelectionBox, mTickLabelsSelectionBox, mLabelSelectionBox) are set here, too.
Implements QCPLayerable.
|
protectedvirtual |
Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.
Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.
Reimplemented from QCPLayerable.
|
protectedvirtual |
This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.
event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).
Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.
selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.
Reimplemented from QCPLayerable.
|
protectedvirtual |
This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.
just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.
Reimplemented from QCPLayerable.
|
protected |
Returns via lowIndex and highIndex, which ticks in the current tick vector are visible in the current range. The return values are indices of the tick vector, not the positions of the ticks themselves.
The actual use of this function is when an external tick vector is provided, since it might exceed far beyond the currently displayed range, and would cause unnecessary calculations e.g. of subticks.
If all ticks are outside the axis range, an inverted range is returned, i.e. highIndex will be smaller than lowIndex. There is one case, where this function returns indices that are not really visible in the current axis range: When the tick spacing is larger than the axis range size and one tick is below the axis range and the next tick is already above the axis range. Because in such cases it is usually desirable to know the tick pair, to draw proper subticks.
|
protected |
A log function with the base mScaleLogBase, used mostly for coordinate transforms in logarithmic scales with arbitrary log base. Uses the buffered mScaleLogBaseLogInv for faster calculation. This is set to 1.0/qLn(mScaleLogBase)
in setScaleLogBase.
|
protected |
A power function with the base mScaleLogBase, used mostly for coordinate transforms in logarithmic scales with arbitrary log base.
|
protected |
Returns the pen that is used to draw the axis base line. Depending on the selection state, this is either mSelectedBasePen or mBasePen.
|
protected |
Returns the pen that is used to draw the (major) ticks. Depending on the selection state, this is either mSelectedTickPen or mTickPen.
|
protected |
Returns the pen that is used to draw the subticks. Depending on the selection state, this is either mSelectedSubTickPen or mSubTickPen.
|
protected |
Returns the font that is used to draw the tick labels. Depending on the selection state, this is either mSelectedTickLabelFont or mTickLabelFont.
|
protected |
Returns the font that is used to draw the axis label. Depending on the selection state, this is either mSelectedLabelFont or mLabelFont.
|
protected |
Returns the color that is used to draw the tick labels. Depending on the selection state, this is either mSelectedTickLabelColor or mTickLabelColor.
|
protected |
Returns the color that is used to draw the axis label. Depending on the selection state, this is either mSelectedLabelColor or mLabelColor.
|
inlineinherited |
Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.
Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.
A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.
|
inherited |
Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.
|
inherited |
Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.
Returns true on success, i.e. if layer is a valid layer.
|
inherited |
This is an overloaded function.
Sets the layer of this layerable object by name
Returns true on success, i.e. if layerName is a valid layer name.
|
inherited |
Sets whether this object will be drawn antialiased or not.
Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.
|
inherited |
Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.
If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.
If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.
|
protectedvirtualinherited |
This function is called by initializeParentPlot, to allow subclasses to react on the setting of a parent plot. This is the case when 0 was passed as parent plot in the constructor, and the parent plot is set at a later time.
For example, QCPLayoutElement/QCPLayout hierarchies may be created independently of any QCustomPlot at first. When they are then added to a layout inside the QCustomPlot, the top level element of the hierarchy gets its parent plot initialized with initializeParentPlot. To propagate the parent plot to all the children of the hierarchy, the top level element then uses this function to pass the parent plot on to its child elements.
The default implementation does nothing.
Reimplemented in QCPLegend, and QCPLayoutElement.
|
protectedvirtualinherited |
Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.
The returned clipping rect is set on the painter before the draw function of the respective object is called.
Reimplemented in QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.
|
protectedinherited |
Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.
Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.
Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.
The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).
|
protectedinherited |
Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.
The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.
|
protectedinherited |
Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.
Returns true on success, i.e. if layer is a valid layer.
|
protectedinherited |
Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.
The abstract base class for layouts. More...
Public Functions | |
QCPLayout () | |
virtual void | update () |
virtual QList< QCPLayoutElement * > | elements (bool recursive) const |
virtual int | elementCount () const =0 |
virtual QCPLayoutElement * | elementAt (int index) const =0 |
virtual QCPLayoutElement * | takeAt (int index)=0 |
virtual bool | take (QCPLayoutElement *element)=0 |
virtual void | simplify () |
bool | removeAt (int index) |
bool | remove (QCPLayoutElement *element) |
void | clear () |
QCPLayout * | layout () const |
QRect | rect () const |
QRect | outerRect () const |
QMargins | margins () const |
QMargins | minimumMargins () const |
QCP::MarginSides | autoMargins () const |
QSize | minimumSize () const |
QSize | maximumSize () const |
QCPMarginGroup * | marginGroup (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) |
virtual QSize | minimumSizeHint () const |
virtual QSize | maximumSizeHint () const |
virtual double | selectTest (const QPointF &pos, bool onlySelectable, QVariant *details=0) const |
bool | visible () const |
QCustomPlot * | parentPlot () const |
QCPLayerable * | parentLayerable () const |
QCPLayer * | layer () const |
bool | antialiased () const |
void | setVisible (bool on) |
bool | setLayer (QCPLayer *layer) |
bool | setLayer (const QString &layerName) |
void | setAntialiased (bool enabled) |
bool | realVisibility () const |
Protected Functions | |
virtual void | updateLayout () |
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 |
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) |
virtual void | applyDefaultAntialiasingHint (QCPPainter *painter) const |
virtual void | draw (QCPPainter *painter) |
virtual void | parentPlotInitialized (QCustomPlot *parentPlot) |
virtual QCP::Interaction | selectionCategory () const |
virtual QRect | clipRect () const |
virtual void | selectEvent (QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) |
virtual void | deselectEvent (bool *selectionStateChanged) |
void | initializeParentPlot (QCustomPlot *parentPlot) |
void | setParentLayerable (QCPLayerable *parentLayerable) |
bool | moveToLayer (QCPLayer *layer, bool prepend) |
void | applyAntialiasingHint (QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const |
The abstract base class for layouts.
This is an abstract base class for layout elements whose main purpose is to define the position and size of other child layout elements. In most cases, layouts don't draw anything themselves (but there are exceptions to this, e.g. QCPLegend).
QCPLayout derives from QCPLayoutElement, and thus can itself be nested in other layouts.
QCPLayout introduces a common interface for accessing and manipulating the child elements. Those functions are most notably elementCount, elementAt, takeAt, take, simplify, removeAt, remove and clear. Individual subclasses may add more functions to this interface which are more specialized to the form of the layout. For example, QCPLayoutGrid adds functions that take row and column indices to access cells of the layout grid more conveniently.
Since this is an abstract base class, you can't instantiate it directly. Rather use one of its subclasses like QCPLayoutGrid or QCPLayoutInset.
For a general introduction to the layout system, see the dedicated documentation page The Layout System.
|
explicit |
Creates an instance of QCPLayoutElement and sets default values. Note that since QCPLayoutElement is an abstract base class, it can't be instantiated directly.
|
virtual |
First calls the QCPLayoutElement::update base class implementation to update the margins on this layout.
Then calls updateLayout which subclasses reimplement to reposition and resize their cells.
Finally, update is called on all child elements.
Reimplemented from QCPLayoutElement.
|
virtual |
Returns a list of all child elements in this layout element. If recursive is true, all sub-child elements are included in the list, too.
Note that there may be entries with value 0 in the returned list. (For example, QCPLayoutGrid may have empty cells which yield 0 at the respective index.)
Reimplemented from QCPLayoutElement.
Reimplemented in QCPLayoutGrid.
|
pure virtual |
Returns the number of elements/cells in the layout.
Implemented in QCPLayoutInset, and QCPLayoutGrid.
|
pure virtual |
Returns the element in the cell with the given index. If index is invalid, returns 0.
Note that even if index is valid, the respective cell may be empty in some layouts (e.g. QCPLayoutGrid), so this function may return 0 in those cases. You may use this function to check whether a cell is empty or not.
Implemented in QCPLayoutInset, and QCPLayoutGrid.
|
pure virtual |
Removes the element with the given index from the layout and returns it.
If the index is invalid or the cell with that index is empty, returns 0.
Note that some layouts don't remove the respective cell right away but leave an empty cell after successful removal of the layout element. To collapse empty cells, use simplify.
Implemented in QCPLayoutInset, and QCPLayoutGrid.
|
pure virtual |
Removes the specified element from the layout and returns true on success.
If the element isn't in this layout, returns false.
Note that some layouts don't remove the respective cell right away but leave an empty cell after successful removal of the layout element. To collapse empty cells, use simplify.
Implemented in QCPLayoutInset, and QCPLayoutGrid.
|
virtual |
Simplifies the layout by collapsing empty cells. The exact behavior depends on subclasses, the default implementation does nothing.
Not all layouts need simplification. For example, QCPLayoutInset doesn't use explicit simplification while QCPLayoutGrid does.
Reimplemented in QCPLayoutInset, and QCPLayoutGrid.
bool QCPLayout::removeAt | ( | int | index | ) |
bool QCPLayout::remove | ( | QCPLayoutElement * | element | ) |
void QCPLayout::clear | ( | ) |
|
protectedvirtual |
Subclasses reimplement this method to update the position and sizes of the child elements/cells via calling their QCPLayoutElement::setOuterRect. The default implementation does nothing.
The geometry used as a reference is the inner rect of this layout. Child elements should stay within that rect.
getSectionSizes may help with the reimplementation of this function.
Reimplemented in QCPLayoutInset, and QCPLayoutGrid.
|
protected |
Subclasses call this method to report changed (minimum/maximum) size constraints.
If the parent of this layout is again a QCPLayout, forwards the call to the parent's sizeConstraintsChanged. If the parent is a QWidget (i.e. is the QCustomPlot::plotLayout of QCustomPlot), calls QWidget::updateGeometry, so if the QCustomPlot widget is inside a Qt QLayout, it may update itself and resize cells accordingly.
|
protected |
Associates el with this layout. This is done by setting the QCPLayoutElement::layout, the QCPLayerable::parentLayerable and the QObject parent to this layout.
Further, if el didn't previously have a parent plot, calls QCPLayerable::initializeParentPlot on el to set the paret plot.
This method is used by subclass specific methods that add elements to the layout. Note that this method only changes properties in el. The removal from the old layout and the insertion into the new layout must be done additionally.
|
protected |
Disassociates el from this layout. This is done by setting the QCPLayoutElement::layout and the QCPLayerable::parentLayerable to zero. The QObject parent is set to the parent QCustomPlot.
This method is used by subclass specific methods that remove elements from the layout (e.g. take or takeAt). Note that this method only changes properties in el. The removal from the old layout must be done additionally.
|
protected |
This is a helper function for the implementation of updateLayout in subclasses.
It calculates the sizes of one-dimensional sections with provided constraints on maximum section sizes, minimum section sizes, relative stretch factors and the final total size of all sections.
The QVector entries refer to the sections. Thus all QVectors must have the same size.
maxSizes gives the maximum allowed size of each section. If there shall be no maximum size imposed, set all vector values to Qt's QWIDGETSIZE_MAX.
minSizes gives the minimum allowed size of each section. If there shall be no minimum size imposed, set all vector values to zero. If the minSizes entries add up to a value greater than totalSize, sections will be scaled smaller than the proposed minimum sizes. (In other words, not exceeding the allowed total size is taken to be more important than not going below minimum section sizes.)
stretchFactors give the relative proportions of the sections to each other. If all sections shall be scaled equally, set all values equal. If the first section shall be double the size of each individual other section, set the first number of stretchFactors to double the value of the other individual values (e.g. {2, 1, 1, 1}).
totalSize is the value that the final section sizes will add up to. Due to rounding, the actual sum may differ slightly. If you want the section sizes to sum up to exactly that value, you could distribute the remaining difference on the sections.
The return value is a QVector containing the section sizes.
|
inlineinherited |
Returns the parent layout of this layout element.
|
inlineinherited |
Returns the inner rect of this layout element. The inner rect is the outer rect (setOuterRect) shrinked by the margins (setMargins, setAutoMargins).
In some cases, the area between outer and inner rect is left blank. In other cases the margin area is used to display peripheral graphics while the main content is in the inner rect. This is where automatic margin calculation becomes interesting because it allows the layout element to adapt the margins to the peripheral graphics it wants to draw. For example, QCPAxisRect draws the axis labels and tick labels in the margin area, thus needs to adjust the margins (if setAutoMargins is enabled) according to the space required by the labels of the axes.
|
inherited |
Sets the outer rect of this layout element. If the layout element is inside a layout, the layout sets the position and size of this layout element using this function.
Calling this function externally has no effect, since the layout will overwrite any changes to the outer rect upon the next replot.
The layout element will adapt its inner rect by applying the margins inward to the outer rect.
|
inherited |
Sets the margins of this layout element. If setAutoMargins is disabled for some or all sides, this function is used to manually set the margin on those sides. Sides that are still set to be handled automatically are ignored and may have any value in margins.
The margin is the distance between the outer rect (controlled by the parent layout via setOuterRect) and the inner rect (which usually contains the main content of this layout element).
|
inherited |
If setAutoMargins is enabled on some or all margins, this function is used to provide minimum values for those margins.
The minimum values are not enforced on margin sides that were set to be under manual control via setAutoMargins.
|
inherited |
Sets on which sides the margin shall be calculated automatically. If a side is calculated automatically, a minimum margin value may be provided with setMinimumMargins. If a side is set to be controlled manually, the value may be specified with setMargins.
Margin sides that are under automatic control may participate in a QCPMarginGroup (see setMarginGroup), to synchronize (align) it with other layout elements in the plot.
|
inherited |
Sets the minimum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.
If the parent layout size is not sufficient to satisfy all minimum size constraints of its child layout elements, the layout may set a size that is actually smaller than size. QCustomPlot propagates the layout's size constraints to the outside by setting its own minimum QWidget size accordingly, so violations of size should be exceptions.
|
inherited |
This is an overloaded function.
Sets the minimum size for the inner rect of this layout element.
|
inherited |
Sets the maximum size for the inner rect of this layout element. A parent layout tries to respect the size here by changing row/column sizes in the layout accordingly.
|
inherited |
This is an overloaded function.
Sets the maximum size for the inner rect of this layout element.
|
inherited |
Sets the margin group of the specified margin sides.
Margin groups allow synchronizing specified margins across layout elements, see the documentation of QCPMarginGroup.
To unset the margin group of sides, set group to 0.
Note that margin groups only work for margin sides that are set to automatic (setAutoMargins).
|
virtualinherited |
Returns the minimum size this layout element (the inner rect) may be compressed to.
if a minimum size (setMinimumSize) was not set manually, parent layouts consult this function to determine the minimum allowed size of this layout element. (A manual minimum size is considered set if it is non-zero.)
Reimplemented in QCPLayoutGrid, QCPPlottableLegendItem, and QCPPlotTitle.
|
virtualinherited |
Returns the maximum size this layout element (the inner rect) may be expanded to.
if a maximum size (setMaximumSize) was not set manually, parent layouts consult this function to determine the maximum allowed size of this layout element. (A manual maximum size is considered set if it is smaller than Qt's QWIDGETSIZE_MAX.)
Reimplemented in QCPLayoutGrid, and QCPPlotTitle.
|
virtualinherited |
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 QCPLayerable.
Reimplemented in QCPLayoutInset, QCPLegend, QCPAbstractLegendItem, and QCPPlotTitle.
|
protectedvirtualinherited |
Returns the margin size for this side. It is used if automatic margins is enabled for this side (see setAutoMargins). If a minimum margin was set with setMinimumMargins, the returned value will not be smaller than the specified minimum margin.
The default implementation just returns the respective manual margin (setMargins) or the minimum margin, whichever is larger.
Reimplemented in QCPAxisRect.
|
inlineprotectedvirtualinherited |
This event is called, if the mouse was pressed while being inside the outer rect of this layout element.
Reimplemented in QCPAxisRect.
|
inlineprotectedvirtualinherited |
This event is called, if the mouse is moved inside the outer rect of this layout element.
Reimplemented in QCPAxisRect.
|
inlineprotectedvirtualinherited |
This event is called, if the mouse was previously pressed inside the outer rect of this layout element and is now released.
Reimplemented in QCPAxisRect.
|
inlineprotectedvirtualinherited |
This event is called, if the mouse is double-clicked inside the outer rect of this layout element.
|
inlineprotectedvirtualinherited |
This event is called, if the mouse wheel is scrolled while the cursor is inside the rect of this layout element.
Reimplemented in QCPAxisRect.
|
inlineprotectedvirtualinherited |
This function applies the default antialiasing setting to the specified painter, using the function applyAntialiasingHint. It is the antialiasing state the painter is put in, when draw is called on the layerable. If the layerable has multiple entities whose antialiasing setting may be specified individually, this function should set the antialiasing state of the most prominent entity. In this case however, the draw function usually calls the specialized versions of this function before drawing each entity, effectively overriding the setting of the default antialiasing hint.
First example: QCPGraph has multiple entities that have an antialiasing setting: The graph line, fills, scatters and error bars. Those can be configured via QCPGraph::setAntialiased, QCPGraph::setAntialiasedFill, QCPGraph::setAntialiasedScatters etc. Consequently, there isn't only the QCPGraph::applyDefaultAntialiasingHint function (which corresponds to the graph line's antialiasing), but specialized ones like QCPGraph::applyFillAntialiasingHint and QCPGraph::applyScattersAntialiasingHint. So before drawing one of those entities, QCPGraph::draw calls the respective specialized applyAntialiasingHint function.
Second example: QCPItemLine consists only of a line so there is only one antialiasing setting which can be controlled with QCPItemLine::setAntialiased. (This function is inherited by all layerables. The specialized functions, as seen on QCPGraph, must be added explicitly to the respective layerable subclass.) Consequently it only has the normal QCPItemLine::applyDefaultAntialiasingHint. The QCPItemLine::draw function doesn't need to care about setting any antialiasing states, because the default antialiasing hint is already set on the painter when the draw function is called, and that's the state it wants to draw the line with.
Implements QCPLayerable.
Reimplemented in QCPLegend, QCPAxisRect, QCPAbstractLegendItem, and QCPPlotTitle.
|
inlineprotectedvirtualinherited |
This function draws the layerable with the specified painter. It is only called by QCustomPlot, if the layerable is visible (setVisible).
Before this function is called, the painter's antialiasing state is set via applyDefaultAntialiasingHint, see the documentation there. Further, the clipping rectangle was set to clipRect.
Implements QCPLayerable.
Reimplemented in QCPLegend, QCPAxisRect, QCPPlottableLegendItem, QCPAbstractLegendItem, and QCPPlotTitle.
|
protectedvirtualinherited |
propagates the parent plot initialization to all child elements, by calling QCPLayerable::initializeParentPlot on them.
Reimplemented from QCPLayerable.
Reimplemented in QCPLegend.
|
inlineinherited |
Returns the parent layerable of this layerable. The parent layerable is used to provide visibility hierarchies in conjunction with the method realVisibility. This way, layerables only get drawn if their parent layerables are visible, too.
Note that a parent layerable is not necessarily also the QObject parent for memory management. Further, a layerable doesn't always have a parent layerable, so this function may return 0.
A parent layerable is set implicitly with when placed inside layout elements and doesn't need to be set manually by the user.
|
inherited |
Sets the visibility of this layerable object. If an object is not visible, it will not be drawn on the QCustomPlot surface, and user interaction with it (e.g. click and selection) is not possible.
|
inherited |
Sets the layer of this layerable object. The object will be placed on top of the other objects already on layer.
Returns true on success, i.e. if layer is a valid layer.
|
inherited |
This is an overloaded function.
Sets the layer of this layerable object by name
Returns true on success, i.e. if layerName is a valid layer name.
|
inherited |
Sets whether this object will be drawn antialiased or not.
Note that antialiasing settings may be overridden by QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements.
|
inherited |
Returns whether this layerable is visible, taking possible direct layerable parent visibility into account. This is the method that is consulted to decide whether a layerable shall be drawn or not.
If this layerable has a direct layerable parent (usually set via hierarchies implemented in subclasses, like in the case of QCPLayoutElement), this function returns true only if this layerable has its visibility set to true and the parent layerable's realVisibility returns true.
If this layerable doesn't have a direct layerable parent, returns the state of this layerable's visibility.
|
protectedvirtualinherited |
Returns the selection category this layerable shall belong to. The selection category is used in conjunction with QCustomPlot::setInteractions to control which objects are selectable and which aren't.
Subclasses that don't fit any of the normal QCP::Interaction values can use QCP::iSelectOther. This is what the default implementation returns.
Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.
|
protectedvirtualinherited |
Returns the clipping rectangle of this layerable object. By default, this is the viewport of the parent QCustomPlot. Specific subclasses may reimplement this function to provide different clipping rects.
The returned clipping rect is set on the painter before the draw function of the respective object is called.
Reimplemented in QCPAbstractItem, QCPAbstractPlottable, and QCPAbstractLegendItem.
|
protectedvirtualinherited |
This event is called when the layerable shall be selected, as a consequence of a click by the user. Subclasses should react to it by setting their selection state appropriately. The default implementation does nothing.
event is the mouse event that caused the selection. additive indicates, whether the user was holding the multi-select-modifier while performing the selection (see QCustomPlot::setMultiSelectModifier). if additive is true, the selection state must be toggled (i.e. become selected when unselected and unselected when selected).
Every selectEvent is preceded by a call to selectTest, which has returned positively (i.e. returned a value greater than 0 and less than the selection tolerance of the parent QCustomPlot). The details data you output from selectTest is feeded back via details here. You may use it to transport any kind of information from the selectTest to the possibly subsequent selectEvent. Usually details is used to transfer which part was clicked, if it is a layerable that has multiple individually selectable parts (like QCPAxis). This way selectEvent doesn't need to do the calculation again to find out which part was actually clicked.
selectionStateChanged is an output parameter. If the pointer is non-null, this function must set the value either to true or false, depending on whether the selection state of this layerable was actually changed. For layerables that only are selectable as a whole and not in parts, this is simple: if additive is true, selectionStateChanged must also be set to true, because the selection toggles. If additive is false, selectionStateChanged is only set to true, if the layerable was previously unselected and now is switched to the selected state.
Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.
|
protectedvirtualinherited |
This event is called when the layerable shall be deselected, either as consequence of a user interaction or a call to QCustomPlot::deselectAll. Subclasses should react to it by unsetting their selection appropriately.
just as in selectEvent, the output parameter selectionStateChanged (if non-null), must return true or false when the selection state of this layerable has changed or not changed, respectively.
Reimplemented in QCPAxis, QCPLegend, QCPAbstractItem, QCPAbstractPlottable, QCPPlotTitle, and QCPAbstractLegendItem.
|
protectedinherited |
Sets the parent plot of this layerable. Use this function once to set the parent plot if you have passed 0 in the constructor. It can not be used to move a layerable from one QCustomPlot to another one.
Note that, unlike when passing a non-null parent plot in the constructor, this function does not make parentPlot the QObject-parent of this layerable. If you want this, call QObject::setParent(parentPlot) in addition to this function.
Further, you will probably want to set a layer (setLayer) after calling this function, to make the layerable appear on the QCustomPlot.
The parent plot change will be propagated to subclasses via a call to parentPlotInitialized so they can react accordingly (e.g. also initialize the parent plot of child layerables, like QCPLayout does).
|
protectedinherited |
Sets the parent layerable of this layerable to parentLayerable. Note that parentLayerable does not become the QObject-parent (for memory management) of this layerable.
The parent layerable has influence on the return value of the realVisibility method. Only layerables with a fully visible parent tree will return true for realVisibility, and thus be drawn.
|
protectedinherited |
Moves this layerable object to layer. If prepend is true, this object will be prepended to the new layer's list, i.e. it will be drawn below the objects already on the layer. If it is false, the object will be appended.
Returns true on success, i.e. if layer is a valid layer.
|
protectedinherited |
Sets the QCPainter::setAntialiasing state on the provided painter, depending on the localAntialiased value as well as the overrides QCustomPlot::setAntialiasedElements and QCustomPlot::setNotAntialiasedElements. Which override enum this function takes into account is controlled via overrideElement.