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

Represents the range an axis is encompassing. More...

#include <qcustomplot.h>

Public Member Functions

 QCPRange ()
 
 QCPRange (double lower, double upper)
 
bool operator== (const QCPRange &other) const
 
bool operator!= (const QCPRange &other) const
 
QCPRangeoperator+= (const double &value)
 
QCPRangeoperator-= (const double &value)
 
QCPRangeoperator*= (const double &value)
 
QCPRangeoperator/= (const double &value)
 
double size () const
 
double center () const
 
void normalize ()
 
void expand (const QCPRange &otherRange)
 
void expand (double includeCoord)
 
QCPRange expanded (const QCPRange &otherRange) const
 
QCPRange expanded (double includeCoord) const
 
QCPRange bounded (double lowerBound, double upperBound) const
 
QCPRange sanitizedForLogScale () const
 
QCPRange sanitizedForLinScale () const
 
bool contains (double value) const
 
 QCPRange ()
 
 QCPRange (double lower, double upper)
 
bool operator== (const QCPRange &other) const
 
bool operator!= (const QCPRange &other) const
 
QCPRangeoperator+= (const double &value)
 
QCPRangeoperator-= (const double &value)
 
QCPRangeoperator*= (const double &value)
 
QCPRangeoperator/= (const double &value)
 
double size () const
 
double center () const
 
void normalize ()
 
void expand (const QCPRange &otherRange)
 
QCPRange expanded (const QCPRange &otherRange) const
 
QCPRange sanitizedForLogScale () const
 
QCPRange sanitizedForLinScale () const
 
bool contains (double value) const
 

Static Public Member Functions

static bool validRange (double lower, double upper)
 
static bool validRange (const QCPRange &range)
 
static bool validRange (double lower, double upper)
 
static bool validRange (const QCPRange &range)
 

Public Attributes

double lower
 
double upper
 

Static Public Attributes

static const double minRange = 1e-280
 
static const double maxRange = 1e250
 

Related Functions

(Note that these are not member functions.)

QDebug operator<< (QDebug d, const QCPRange &range)
 

Detailed Description

Represents the range an axis is encompassing.

contains a lower and upper double value and provides convenience input, output and modification functions.

See also
QCPAxis::setRange

Definition at line 975 of file qcustomplot.h.

Constructor & Destructor Documentation

◆ QCPRange() [1/4]

QCPRange::QCPRange ( )

Constructs a range with lower and upper set to zero.

Definition at line 1875 of file qcustomplot.cpp.

◆ QCPRange() [2/4]

QCPRange::QCPRange ( double  lower,
double  upper 
)

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

Constructs a range with the specified lower and upper values.

The resulting range will be normalized (see normalize), so if lower is not numerically smaller than upper, they will be swapped.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Constructs a range with the specified lower and upper values.

Definition at line 1884 of file qcustomplot.cpp.

References normalize().

◆ QCPRange() [3/4]

QCPRange::QCPRange ( )

◆ QCPRange() [4/4]

QCPRange::QCPRange ( double  lower,
double  upper 
)

Member Function Documentation

◆ bounded()

QCPRange QCPRange::bounded ( double  lowerBound,
double  upperBound 
) const

Returns this range, possibly modified to not exceed the bounds provided as lowerBound and upperBound. If possible, the size of the current range is preserved in the process.

If the range shall only be bounded at the lower side, you can set upperBound to QCPRange::maxRange. If it shall only be bounded at the upper side, set lowerBound to -QCPRange::maxRange.

Definition at line 1966 of file qcustomplot.cpp.

References lower, result, size(), and upper.

◆ center() [1/2]

double QCPRange::center ( ) const
inline

Returns the center of the range, i.e. (upper+lower)*0.5

Definition at line 1015 of file qcustomplot.h.

◆ center() [2/2]

double QCPRange::center ( ) const

◆ contains() [1/2]

bool QCPRange::contains ( double  value) const
inline

Returns true when value lies within or exactly on the borders of the range.

Definition at line 1026 of file qcustomplot.h.

Referenced by QCPFinancial::candlestickSelectTest(), QCPCurve::getScatters(), QCPAbstractPlottable1D< DataType >::selectTest(), QCPColorMap::selectTest(), and QCPAbstractPlottable1D< DataType >::selectTestRect().

◆ contains() [2/2]

bool QCPRange::contains ( double  value) const

◆ expand() [1/3]

void QCPRange::expand ( const QCPRange otherRange)

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

Expands this range such that otherRange is contained in the new range. It is assumed that both this range and otherRange are normalized (see normalize).

If this range contains NaN as lower or upper bound, it will be replaced by the respective bound of otherRange.

If otherRange is already inside the current range, this function does nothing.

See also
expanded

Expands this range such that otherRange is contained in the new range. It is assumed that both this range and otherRange are normalized (see normalize).

If otherRange is already inside the current range, this function does nothing.

See also
expanded

Definition at line 1902 of file qcustomplot.cpp.

References lower, and upper.

Referenced by QCPAxis::rescale(), QCPColorScale::rescaleDataRange(), QCPAbstractPlottable::rescaleKeyAxis(), and QCPAbstractPlottable::rescaleValueAxis().

◆ expand() [2/3]

void QCPRange::expand ( const QCPRange otherRange)

◆ expand() [3/3]

void QCPRange::expand ( double  includeCoord)

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

Expands this range such that includeCoord is contained in the new range. It is assumed that this range is normalized (see normalize).

If this range contains NaN as lower or upper bound, the respective bound will be set to includeCoord.

If includeCoord is already inside the current range, this function does nothing.

See also
expand

Definition at line 1920 of file qcustomplot.cpp.

References lower, and upper.

◆ expanded() [1/3]

QCPRange QCPRange::expanded ( const QCPRange otherRange) const

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

Returns an expanded range that contains this and otherRange. It is assumed that both this range and otherRange are normalized (see normalize).

If this range contains NaN as lower or upper bound, the returned range's bound will be taken from otherRange.

See also
expand

Returns an expanded range that contains this and otherRange. It is assumed that both this range and otherRange are normalized (see normalize).

See also
expand

Definition at line 1935 of file qcustomplot.cpp.

References result.

◆ expanded() [2/3]

QCPRange QCPRange::expanded ( const QCPRange otherRange) const

◆ expanded() [3/3]

QCPRange QCPRange::expanded ( double  includeCoord) const

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

Returns an expanded range that includes the specified includeCoord. It is assumed that this range is normalized (see normalize).

If this range contains NaN as lower or upper bound, the returned range's bound will be set to includeCoord.

See also
expand

Definition at line 1951 of file qcustomplot.cpp.

References result.

◆ normalize() [1/2]

void QCPRange::normalize ( )
inline

Makes sure lower is numerically smaller than upper. If this is not the case, the values are swapped.

Definition at line 1016 of file qcustomplot.h.

Referenced by QCPRange(), sanitizedForLinScale(), and sanitizedForLogScale().

◆ normalize() [2/2]

void QCPRange::normalize ( )

◆ operator!=() [1/2]

bool QCPRange::operator!= ( const QCPRange other) const
inline

Definition at line 985 of file qcustomplot.h.

◆ operator!=() [2/2]

bool QCPRange::operator!= ( const QCPRange other) const
inline

Definition at line 657 of file qcustomplot.h.

◆ operator*=() [1/2]

QCPRange & QCPRange::operator*= ( const double &  value)
inline

Multiplies both boundaries of the range by value.

Definition at line 997 of file qcustomplot.h.

◆ operator*=() [2/2]

QCPRange& QCPRange::operator*= ( const double &  value)
inline

Definition at line 669 of file qcustomplot.h.

◆ operator+=() [1/2]

QCPRange & QCPRange::operator+= ( const double &  value)
inline

Adds value to both boundaries of the range.

Definition at line 987 of file qcustomplot.h.

◆ operator+=() [2/2]

QCPRange& QCPRange::operator+= ( const double &  value)
inline

Definition at line 659 of file qcustomplot.h.

◆ operator-=() [1/2]

QCPRange & QCPRange::operator-= ( const double &  value)
inline

Subtracts value from both boundaries of the range.

Definition at line 992 of file qcustomplot.h.

◆ operator-=() [2/2]

QCPRange& QCPRange::operator-= ( const double &  value)
inline

Definition at line 664 of file qcustomplot.h.

◆ operator/=() [1/2]

QCPRange & QCPRange::operator/= ( const double &  value)
inline

Divides both boundaries of the range by value.

Definition at line 1002 of file qcustomplot.h.

◆ operator/=() [2/2]

QCPRange& QCPRange::operator/= ( const double &  value)
inline

Definition at line 674 of file qcustomplot.h.

◆ operator==() [1/2]

bool QCPRange::operator== ( const QCPRange other) const
inline

Definition at line 982 of file qcustomplot.h.

References lower, and upper.

◆ operator==() [2/2]

bool QCPRange::operator== ( const QCPRange other) const
inline

Definition at line 654 of file qcustomplot.h.

References lower, and upper.

◆ sanitizedForLinScale() [1/2]

QCPRange QCPRange::sanitizedForLinScale ( ) const

Returns a sanitized version of the range. Sanitized means for linear scales, that lower will always be numerically smaller (or equal) to upper.

Definition at line 2048 of file qcustomplot.cpp.

References lower, normalize(), and upper.

Referenced by QCPAxis::scaleRange(), QCPColorMap::setDataRange(), QCPAxis::setRange(), QCPAxis::setRangeLower(), and QCPAxis::setRangeUpper().

◆ sanitizedForLinScale() [2/2]

QCPRange QCPRange::sanitizedForLinScale ( ) const

◆ sanitizedForLogScale() [1/2]

QCPRange QCPRange::sanitizedForLogScale ( ) const

Returns a sanitized version of the range. Sanitized means for logarithmic scales, that the range won't span the positive and negative sign domain, i.e. contain zero. Further lower will always be numerically smaller (or equal) to upper.

If the original range does span positive and negative sign domains or contains zero, the returned range will try to approximate the original range as good as possible. If the positive interval of the original range is wider than the negative interval, the returned range will only contain the positive interval, with lower bound set to rangeFac or rangeFac *upper, whichever is closer to zero. Same procedure is used if the negative interval is wider than the positive interval, this time by changing the upper bound.

Definition at line 2001 of file qcustomplot.cpp.

References e, lower, normalize(), and upper.

Referenced by QCPAxis::scaleRange(), QCPColorMap::setDataRange(), QCPColorScale::setDataScaleType(), QCPColorMap::setDataScaleType(), QCPAxis::setRange(), QCPAxis::setRangeLower(), QCPAxis::setRangeUpper(), and QCPAxis::setScaleType().

◆ sanitizedForLogScale() [2/2]

QCPRange QCPRange::sanitizedForLogScale ( ) const

◆ size() [1/2]

◆ size() [2/2]

double QCPRange::size ( ) const

◆ validRange() [1/4]

bool QCPRange::validRange ( const QCPRange range)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Checks, whether the specified range is within valid bounds, which are defined as QCPRange::maxRange and QCPRange::minRange. A valid range means:

  • range bounds within -maxRange and maxRange
  • range size above minRange
  • range size below maxRange

Definition at line 2078 of file qcustomplot.cpp.

References lower, maxRange, minRange, and upper.

◆ validRange() [2/4]

static bool QCPRange::validRange ( const QCPRange range)
static

◆ validRange() [3/4]

bool QCPRange::validRange ( double  lower,
double  upper 
)
static

Checks, whether the specified range is within valid bounds, which are defined as QCPRange::maxRange and QCPRange::minRange. A valid range means:

  • range bounds within -maxRange and maxRange
  • range size above minRange
  • range size below maxRange

Definition at line 2062 of file qcustomplot.cpp.

References lower, maxRange, minRange, and upper.

Referenced by QCPAxis::rescale(), QCPColorScale::rescaleDataRange(), QCPAbstractPlottable::rescaleKeyAxis(), QCPAbstractPlottable::rescaleValueAxis(), QCPAxis::scaleRange(), QCPColorMap::setDataRange(), and QCPAxis::setRange().

◆ validRange() [4/4]

static bool QCPRange::validRange ( double  lower,
double  upper 
)
static

Friends And Related Function Documentation

◆ operator<<()

QDebug operator<< ( QDebug  d,
const QCPRange range 
)
related

Prints range in a human readable format to the qDebug output.

Definition at line 1041 of file qcustomplot.h.

References lower, and upper.

Member Data Documentation

◆ lower

double QCPRange::lower

Definition at line 977 of file qcustomplot.h.

Referenced by bounded(), QCPColorMapData::cellToCoord(), QCPColorGradient::color(), QCPColorGradient::colorize(), QCPColorMapData::coordToCell(), QCPAxis::coordToPixel(), QCPAxisTicker::createTickVector(), QCPAxisTickerText::createTickVector(), QCPAxisTickerLog::createTickVector(), QCPColorMapData::data(), QCPColorMap::draw(), QCPGrid::drawGridLines(), expand(), QCPAxis::generateAutoTicks(), QCPCurve::getCurveData(), QCPCurve::getCurveLines(), QCPBars::getKeyRange(), QCPStatisticalBox::getKeyRange(), QCPFinancial::getKeyRange(), QCPErrorBars::getKeyRange(), QCPGraph::getKeyRange(), QCPCurve::getKeyRange(), QCPGraph::getOptimizedScatterData(), QCPGraph::getPreparedData(), QCPCurve::getScatters(), QCPBars::getValueRange(), QCPColorMap::getValueRange(), QCPErrorBars::getValueRange(), QCPGraph::getValueRange(), QCPCurve::getValueRange(), QCPFinancial::getValueRange(), QCPErrorBars::getVisibleDataBounds(), QCPGraph::getVisibleDataBounds(), QCPDataContainer< DataType >::keyRange(), QCPAxis::mouseMoveEvent(), QCPAxis::moveRange(), operator<<(), operator==(), QCPAxis::pixelToCoord(), QCPColorMapData::recalculateDataBounds(), QCPAxis::rescale(), QCPColorScale::rescaleDataRange(), QCPGraph::rescaleKeyAxis(), QCPAbstractPlottable::rescaleKeyAxis(), QCPGraph::rescaleValueAxis(), QCPAbstractPlottable::rescaleValueAxis(), sanitizedForLinScale(), sanitizedForLogScale(), QCPAxis::scaleRange(), QCPAbstractPlottable1D< DataType >::selectTestRect(), QCPColorMapData::setCell(), QCPColorMapData::setData(), QCPColorScale::setDataRange(), QCPColorMap::setDataRange(), QCPAxis::setRange(), QCPAxis::setRangeLower(), QCPAxisTicker::trimTicks(), validRange(), QCPDataContainer< DataType >::valueRange(), QCPAxis::visibleTickBounds(), and QCPAxisRect::zoom().

◆ maxRange

static const double QCPRange::maxRange = 1e250
static

Maximum values (negative and positive) the range will accept in range-changing functions. Larger absolute values would cause errors due to the 11-bit exponent of double precision numbers, corresponding to a maximum magnitude of roughly 1e308.

Warning
Do not use this constant to indicate "arbitrarily large" values in plotting logic (as values that will appear in the plot)! It is intended only as a bound to compare against, e.g. to prevent axis ranges from obtaining overflowing ranges.
See also
validRange, minRange

Maximum values (negative and positive) the range will accept in range-changing functions. Larger absolute values would cause errors due to the 11-bit exponent of double precision numbers, corresponding to a maximum magnitude of roughly 1e308. Since the number of planck-volumes in the entire visible universe is only ~1e183, this should be enough.

See also
validRange, minRange

Definition at line 1033 of file qcustomplot.h.

Referenced by validRange().

◆ minRange

static const double QCPRange::minRange = 1e-280
static

Minimum range size (upper - lower) the range changing functions will accept. Smaller intervals would cause errors due to the 11-bit exponent of double precision numbers, corresponding to a minimum magnitude of roughly 1e-308.

Warning
Do not use this constant to indicate "arbitrarily small" values in plotting logic (as values that will appear in the plot)! It is intended only as a bound to compare against, e.g. to prevent axis ranges from obtaining underflowing ranges.
See also
validRange, maxRange

Minimum range size (upper - lower) the range changing functions will accept. Smaller intervals would cause errors due to the 11-bit exponent of double precision numbers, corresponding to a minimum magnitude of roughly 1e-308.

See also
validRange, maxRange

Definition at line 1032 of file qcustomplot.h.

Referenced by validRange().

◆ upper

double QCPRange::upper

Definition at line 977 of file qcustomplot.h.

Referenced by bounded(), QCPColorMapData::cellToCoord(), QCPColorGradient::color(), QCPColorGradient::colorize(), QCPColorMapData::coordToCell(), QCPAxis::coordToPixel(), QCPAxisTicker::createTickVector(), QCPAxisTickerText::createTickVector(), QCPAxisTickerLog::createTickVector(), QCPColorMapData::data(), QCPColorMap::draw(), QCPGrid::drawGridLines(), expand(), QCPAxis::generateAutoTicks(), QCPCurve::getCurveData(), QCPCurve::getCurveLines(), QCPGraph::getFillBasePoint(), QCPBars::getKeyRange(), QCPStatisticalBox::getKeyRange(), QCPFinancial::getKeyRange(), QCPErrorBars::getKeyRange(), QCPGraph::getKeyRange(), QCPCurve::getKeyRange(), QCPGraph::getOptimizedScatterData(), QCPGraph::getPreparedData(), QCPCurve::getScatters(), QCPBars::getValueRange(), QCPColorMap::getValueRange(), QCPErrorBars::getValueRange(), QCPGraph::getValueRange(), QCPCurve::getValueRange(), QCPFinancial::getValueRange(), QCPErrorBars::getVisibleDataBounds(), QCPGraph::getVisibleDataBounds(), QCPDataContainer< DataType >::keyRange(), QCPGraph::lowerFillBasePoint(), QCPAxis::mouseMoveEvent(), QCPAxis::moveRange(), operator<<(), operator==(), QCPAxis::pixelToCoord(), QCPColorMapData::recalculateDataBounds(), QCPAxis::rescale(), QCPColorScale::rescaleDataRange(), QCPGraph::rescaleKeyAxis(), QCPAbstractPlottable::rescaleKeyAxis(), QCPGraph::rescaleValueAxis(), QCPAbstractPlottable::rescaleValueAxis(), sanitizedForLinScale(), sanitizedForLogScale(), QCPAxis::scaleRange(), QCPAbstractPlottable1D< DataType >::selectTestRect(), QCPColorMapData::setCell(), QCPColorMapData::setData(), QCPColorScale::setDataRange(), QCPColorMap::setDataRange(), QCPAxis::setRange(), QCPAxis::setRangeUpper(), QCPAxisTicker::trimTicks(), QCPGraph::upperFillBasePoint(), validRange(), QCPDataContainer< DataType >::valueRange(), QCPAxis::visibleTickBounds(), and QCPAxisRect::zoom().


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