Public Member Functions | Static Public Member Functions | List of all members
istd::TRange< ValueType > Class Template Reference

Implementation of a abstract range defined by two values - minimum and maximum. More...

#include <TRange.h>

Public Member Functions

 TRange ()
 Constructs an empty range object. More...
 
 TRange (const TRange &range)
 Copy constructor. More...
 
 TRange (ValueType minValue, ValueType maxValue)
 Constructs a range object from two numbers. More...
 
bool IsValid () const
 Return true if the bottom value is smaller or equal then the top value. More...
 
bool IsEmpty () const
 Return true if the bottom value is equal to the top value. More...
 
bool IsValidNonEmpty () const
 Return true if the range is valid and it is not empty. More...
 
ValueType GetMinValue () const
 Get the bottom value. More...
 
ValueType & GetMinValueRef ()
 Get reference to the bottom value. More...
 
void SetMinValue (ValueType minValue)
 Set the bottom value. More...
 
ValueType GetMaxValue () const
 Get the top value. More...
 
ValueType & GetMaxValueRef ()
 Get reference to the top value. More...
 
void SetMaxValue (ValueType maxValue)
 Set the top value. More...
 
void Reset ()
 Set this range to be empty. More...
 
ValueType GetLength () const
 Get length of this range. More...
 
TRange GetValidated () const
 Get validated range, if it was invalid. More...
 
void GetValidated (TRange &result) const
 Get validated range, if it was invalid. More...
 
void Validate ()
 Force this range to be valid. More...
 
bool Contains (ValueType value) const
 Returns true, if value is in range between top and bottom. More...
 
bool Contains (const TRange &range) const
 Returns true, if this range is inside of the range. More...
 
bool IsIntersectedBy (const TRange &range) const
 Check if this range is intersected by other range. More...
 
bool IsOutsideOf (const TRange &range) const
 Check if this range is outside of the given range. More...
 
TRange GetTranslated (ValueType offset) const
 Get translated position range. More...
 
void Translate (ValueType offset)
 Translated position of this range. More...
 
TRange GetIntersection (const TRange &range) const
 Get intersection with the second range. More...
 
void Intersection (const TRange &range)
 Set this range to be intersection of two ranges. More...
 
TRange GetUnion (const TRange &range) const
 Get union with the second range. More...
 
TRange GetUnion (double value) const
 Get union with the second range. More...
 
void Unite (const TRange &range)
 Set this range to be union of two ranges. More...
 
void Unite (double value)
 Set this range to be union of two ranges. More...
 
TRange GetExpanded (const TRange &range) const
 Get expanded range using the second range. More...
 
void Expand (const TRange &range)
 Set this range to be expanded. More...
 
ValueType GetDistance (ValueType value) const
 Get distance from value to range. More...
 
ValueType GetNearestInside (ValueType value) const
 Get nearest value belonging to range. More...
 
ValueType GetClipped (ValueType value) const
 Get value clipped to the range. More...
 
TRange GetClipped (const TRange &range) const
 Get range clipped to the current range. More...
 
ValueType GetValueFromAlpha (double alpha) const
 Get value based on 'alpha' factor. More...
 
double GetAlphaFromValue (ValueType value) const
 Get value based on 'alpha' factor. More...
 
ValueType GetMappedTo (ValueType value, const TRange &range) const
 Returns the value, that corresponds the input value inputValue in the other range range. More...
 
TRange GetApply (const TRange &range) const
 Get a combined range. More...
 
TRange GetInvertApply (const TRange &range) const
 
TRange GetInverted () const
 
void SetInterpolated (const TRange &first, const TRange &second, double alpha)
 Set this range to be linear interpolated using two other ranges and adjast alpha value. More...
 
TRangeoperator= (const TRange &range)
 
bool operator== (const TRange &range) const
 
bool operator!= (const TRange &range) const
 
TRange operator* (double value) const
 
TRange operator/ (double value) const
 
TRangeoperator*= (double value)
 
TRangeoperator/= (double value)
 

Static Public Member Functions

static const TRangeGetNull ()
 Return null range. More...
 
static const TRangeGetInvalid ()
 Return invalid range. More...
 
static TRange GetValid (ValueType value1, ValueType value2)
 Return always valid range. More...
 

Detailed Description

template<typename ValueType>
class istd::TRange< ValueType >

Implementation of a abstract range defined by two values - minimum and maximum.

Definition at line 17 of file TRange.h.

Constructor & Destructor Documentation

template<typename ValueType >
istd::TRange< ValueType >::TRange ( )

Constructs an empty range object.

IsEmpty() will return true for this object.

Definition at line 286 of file TRange.h.

template<typename ValueType >
istd::TRange< ValueType >::TRange ( const TRange< ValueType > &  range)

Copy constructor.

Definition at line 294 of file TRange.h.

template<typename ValueType>
istd::TRange< ValueType >::TRange ( ValueType  minValue,
ValueType  maxValue 
)

Constructs a range object from two numbers.

Definition at line 302 of file TRange.h.

Member Function Documentation

template<typename ValueType>
bool istd::TRange< ValueType >::Contains ( ValueType  value) const
inline

Returns true, if value is in range between top and bottom.

This range must be valid.

Definition at line 412 of file TRange.h.

Referenced by i2d::CRect::IsInside().

template<typename ValueType>
bool istd::TRange< ValueType >::Contains ( const TRange< ValueType > &  range) const
inline

Returns true, if this range is inside of the range.

Definition at line 421 of file TRange.h.

References istd::TRange< ValueType >::IsValid().

template<typename ValueType >
void istd::TRange< ValueType >::Expand ( const TRange< ValueType > &  range)
inline

Set this range to be expanded.

Expanding operation calculate simple sum for each components separately.

Definition at line 562 of file TRange.h.

Referenced by i2d::CRect::Expand().

template<typename ValueType>
double istd::TRange< ValueType >::GetAlphaFromValue ( ValueType  value) const
inline

Get value based on 'alpha' factor.

Parameters
alphaalpha factor. If it is 0, minimum range value will be returned. If it is 1, maximum range value will be returned. Rest values are linear interpolated.

Definition at line 638 of file TRange.h.

template<typename ValueType >
TRange< ValueType > istd::TRange< ValueType >::GetApply ( const TRange< ValueType > &  range) const

Get a combined range.

It calculates combined range. Range [0, 1] is neutral element of this operation.

Definition at line 652 of file TRange.h.

template<typename ValueType>
ValueType istd::TRange< ValueType >::GetClipped ( ValueType  value) const

Get value clipped to the range.

Definition at line 600 of file TRange.h.

template<typename ValueType>
TRange< ValueType > istd::TRange< ValueType >::GetClipped ( const TRange< ValueType > &  range) const
template<typename ValueType>
ValueType istd::TRange< ValueType >::GetDistance ( ValueType  value) const
inline

Get distance from value to range.

Distance is the smallest absolute value difference of given value and the values belonging to range.

Definition at line 570 of file TRange.h.

template<typename ValueType >
TRange< ValueType > istd::TRange< ValueType >::GetExpanded ( const TRange< ValueType > &  range) const
inline

Get expanded range using the second range.

Expanding operation calculate simple sum for each components separately.

Definition at line 555 of file TRange.h.

template<typename ValueType >
TRange< ValueType > istd::TRange< ValueType >::GetIntersection ( const TRange< ValueType > &  range) const
inline

Get intersection with the second range.

Definition at line 460 of file TRange.h.

template<typename ValueType >
const TRange< ValueType > & istd::TRange< ValueType >::GetInvalid ( )
inlinestatic

Return invalid range.

Definition at line 786 of file TRange.h.

template<typename ValueType >
TRange< ValueType > istd::TRange< ValueType >::GetInvertApply ( const TRange< ValueType > &  range) const

Definition at line 663 of file TRange.h.

template<typename ValueType >
TRange< ValueType > istd::TRange< ValueType >::GetInverted ( ) const

Definition at line 676 of file TRange.h.

template<typename ValueType >
ValueType istd::TRange< ValueType >::GetLength ( ) const
inline

Get length of this range.

Length is difference between top and bottom values.

Definition at line 381 of file TRange.h.

Referenced by i2d::CRect::GetCenter(), i2d::CRect::GetHeight(), istd::TRange< ValueType >::GetMappedTo(), i2d::CRect::GetRectangle(), i2d::CRect::GetSize(), and i2d::CRect::GetWidth().

template<typename ValueType>
ValueType istd::TRange< ValueType >::GetMappedTo ( ValueType  value,
const TRange< ValueType > &  range 
) const
inline

Returns the value, that corresponds the input value inputValue in the other range range.

It is the same as range.GetValueFromAlpha(GetAlphaFromValue(value)).

Parameters
valuevalue definde in this range. If it is equal to minimum value in this range, it will be mapped to minimum value of range. If it is equal to maximum value in this range, it will be mapped to maximum value of range. Rest values are linear interpolated.
Note
This value must be in current range.

Definition at line 645 of file TRange.h.

References istd::TRange< ValueType >::GetLength(), and istd::TRange< ValueType >::GetMinValue().

template<typename ValueType >
ValueType istd::TRange< ValueType >::GetMaxValue ( ) const
inline
template<typename ValueType >
ValueType & istd::TRange< ValueType >::GetMaxValueRef ( )
inline

Get reference to the top value.

Definition at line 359 of file TRange.h.

template<typename ValueType >
ValueType istd::TRange< ValueType >::GetMinValue ( ) const
inline
template<typename ValueType >
ValueType & istd::TRange< ValueType >::GetMinValueRef ( )
inline

Get reference to the bottom value.

Definition at line 338 of file TRange.h.

template<typename ValueType>
ValueType istd::TRange< ValueType >::GetNearestInside ( ValueType  value) const
inline

Get nearest value belonging to range.

Definition at line 585 of file TRange.h.

template<typename ValueType >
const TRange< ValueType > & istd::TRange< ValueType >::GetNull ( )
inlinestatic

Return null range.

Definition at line 779 of file TRange.h.

template<typename ValueType>
TRange< ValueType > istd::TRange< ValueType >::GetTranslated ( ValueType  offset) const
inline

Get translated position range.

Translation adds the offset value to minimal and mavimal values.

Definition at line 445 of file TRange.h.

template<typename ValueType >
TRange< ValueType > istd::TRange< ValueType >::GetUnion ( const TRange< ValueType > &  range) const

Get union with the second range.

Definition at line 487 of file TRange.h.

References istd::TRange< ValueType >::IsValid().

template<typename ValueType >
TRange< ValueType > istd::TRange< ValueType >::GetUnion ( double  value) const

Get union with the second range.

Definition at line 504 of file TRange.h.

template<typename ValueType>
TRange< ValueType > istd::TRange< ValueType >::GetValid ( ValueType  value1,
ValueType  value2 
)
inlinestatic

Return always valid range.

Definition at line 770 of file TRange.h.

template<typename ValueType >
TRange< ValueType > istd::TRange< ValueType >::GetValidated ( ) const
inline

Get validated range, if it was invalid.

Range is invalid if set min value is bigger than set max value. It returns range with smaller range value as minimum and bigger one as maximum.

Definition at line 388 of file TRange.h.

template<typename ValueType >
void istd::TRange< ValueType >::GetValidated ( TRange< ValueType > &  result) const
inline

Get validated range, if it was invalid.

Range is invalid if set min value is bigger than set max value. It returns range with smaller range value as minimum and bigger one as maximum.

Definition at line 397 of file TRange.h.

References istd::TRange< ValueType >::SetMaxValue(), and istd::TRange< ValueType >::SetMinValue().

template<typename ValueType >
ValueType istd::TRange< ValueType >::GetValueFromAlpha ( double  alpha) const
inline

Get value based on 'alpha' factor.

Parameters
alphaalpha factor. If it is 0, minimum range value will be returned. If it is 1, maximum range value will be returned. Rest values are linear interpolated.

Definition at line 631 of file TRange.h.

template<typename ValueType >
void istd::TRange< ValueType >::Intersection ( const TRange< ValueType > &  range)

Set this range to be intersection of two ranges.

Definition at line 472 of file TRange.h.

Referenced by i2d::CRect::Intersection().

template<typename ValueType >
bool istd::TRange< ValueType >::IsEmpty ( ) const
inline

Return true if the bottom value is equal to the top value.

Definition at line 317 of file TRange.h.

Referenced by i2d::CRect::IsEmpty(), istd::TRanges< ValueType >::TRanges(), and istd::TRanges< ValueType >::Union().

template<typename ValueType >
bool istd::TRange< ValueType >::IsIntersectedBy ( const TRange< ValueType > &  range) const
inline

Check if this range is intersected by other range.

Some range is intersected by another, if intercestion of this two ranges is not empty.

Definition at line 431 of file TRange.h.

template<typename ValueType >
bool istd::TRange< ValueType >::IsOutsideOf ( const TRange< ValueType > &  range) const
inline

Check if this range is outside of the given range.

Definition at line 438 of file TRange.h.

Referenced by i2d::CRect::IsOutside().

template<typename ValueType >
bool istd::TRange< ValueType >::IsValid ( ) const
inline

Return true if the bottom value is smaller or equal then the top value.

Definition at line 310 of file TRange.h.

Referenced by istd::TRange< ValueType >::Contains(), istd::TRange< ValueType >::GetUnion(), i2d::CRect::Intersection(), i2d::CRect::IsValid(), and istd::TRange< ValueType >::Unite().

template<typename ValueType >
bool istd::TRange< ValueType >::IsValidNonEmpty ( ) const
inline

Return true if the range is valid and it is not empty.

Definition at line 324 of file TRange.h.

Referenced by i2d::CRect::IsValidNonEmpty().

template<typename ValueType >
bool istd::TRange< ValueType >::operator!= ( const TRange< ValueType > &  range) const
inline

Definition at line 706 of file TRange.h.

template<typename ValueType >
TRange< ValueType > istd::TRange< ValueType >::operator* ( double  value) const
inline

Definition at line 724 of file TRange.h.

template<typename ValueType >
TRange< ValueType > & istd::TRange< ValueType >::operator*= ( double  value)
inline

Definition at line 748 of file TRange.h.

template<typename ValueType >
TRange< ValueType > istd::TRange< ValueType >::operator/ ( double  value) const
inline

Definition at line 736 of file TRange.h.

template<typename ValueType >
TRange< ValueType > & istd::TRange< ValueType >::operator/= ( double  value)
inline

Definition at line 758 of file TRange.h.

template<typename ValueType >
TRange< ValueType > & istd::TRange< ValueType >::operator= ( const TRange< ValueType > &  range)
inline

Definition at line 714 of file TRange.h.

template<typename ValueType >
bool istd::TRange< ValueType >::operator== ( const TRange< ValueType > &  range) const
inline

Definition at line 699 of file TRange.h.

template<typename ValueType >
void istd::TRange< ValueType >::Reset ( )

Set this range to be empty.

Definition at line 373 of file TRange.h.

Referenced by i2d::CRect::Reset().

template<typename ValueType >
void istd::TRange< ValueType >::SetInterpolated ( const TRange< ValueType > &  first,
const TRange< ValueType > &  second,
double  alpha 
)

Set this range to be linear interpolated using two other ranges and adjast alpha value.

Definition at line 689 of file TRange.h.

template<typename ValueType>
void istd::TRange< ValueType >::SetMaxValue ( ValueType  maxValue)
inline
template<typename ValueType>
void istd::TRange< ValueType >::SetMinValue ( ValueType  minValue)
inline
template<typename ValueType>
void istd::TRange< ValueType >::Translate ( ValueType  offset)
inline

Translated position of this range.

Translation adds the offset value to minimal and mavimal values.

Definition at line 452 of file TRange.h.

template<typename ValueType >
void istd::TRange< ValueType >::Unite ( const TRange< ValueType > &  range)

Set this range to be union of two ranges.

Definition at line 516 of file TRange.h.

References istd::TRange< ValueType >::IsValid().

Referenced by i2d::CRect::GetUnion(), and i2d::CRect::Union().

template<typename ValueType >
void istd::TRange< ValueType >::Unite ( double  value)

Set this range to be union of two ranges.

Definition at line 536 of file TRange.h.

template<typename ValueType >
void istd::TRange< ValueType >::Validate ( )
inline

Force this range to be valid.

Range is invalid if set min value is bigger than set max value. It set smaller range value as minimum and bigger one as maximum.

Definition at line 405 of file TRange.h.


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

© 2007-2017 Witold Gantzke and Kirill Lepskiy