svcore  1.9
AutoRangeMapper Class Reference

#include <RangeMapper.h>

Inheritance diagram for AutoRangeMapper:
Collaboration diagram for AutoRangeMapper:

List of all members.

Public Types

enum  MappingType { Interpolating, StraightLine, Logarithmic }
typedef std::map< float, int > CoordMap

Public Member Functions

 AutoRangeMapper (CoordMap pointMappings, QString unit)
 Given a series of (value, position) coordinate mappings, construct a range mapper that maps arbitrary values, in the range between minimum and maximum of the provided values, onto coordinates.
 ~AutoRangeMapper ()
MappingType getType () const
 Return the mapping type in use.
virtual int getPositionForValue (float value) const
 Return the position that maps to the given value, rounding to the nearest position and clamping to the minimum and maximum extents of the mapper's positional range.
virtual int getPositionForValueUnclamped (float value) const
 Return the position that maps to the given value, rounding to the nearest position, without clamping.
virtual float getValueForPosition (int position) const
 Return the value mapped from the given position, clamping to the minimum and maximum extents of the mapper's value range.
virtual float getValueForPositionUnclamped (int position) const
 Return the value mapped from the given positionq, without clamping.
virtual QString getUnit () const
 Get the unit of the mapper's value range.

Protected Member Functions

MappingType chooseMappingTypeFor (const CoordMap &)

Protected Attributes

MappingType m_type
CoordMap m_mappings
QString m_unit
RangeMapperm_mapper

Detailed Description

Definition at line 182 of file RangeMapper.h.


Member Typedef Documentation

typedef std::map<float, int> AutoRangeMapper::CoordMap

Definition at line 191 of file RangeMapper.h.


Member Enumeration Documentation

Enumerator:
Interpolating 
StraightLine 
Logarithmic 

Definition at line 185 of file RangeMapper.h.


Constructor & Destructor Documentation

AutoRangeMapper::AutoRangeMapper ( CoordMap  pointMappings,
QString  unit 
)

Given a series of (value, position) coordinate mappings, construct a range mapper that maps arbitrary values, in the range between minimum and maximum of the provided values, onto coordinates.

The mapping used may be

Interpolating -- an InterpolatingRangeMapper will be used

StraightLine -- a LinearRangeMapper from the minimum to maximum value coordinates will be used, ignoring all other supplied coordinate mappings

Logarithmic -- a LogRangeMapper from the minimum to maximum value coordinates will be used, ignoring all other supplied coordinate mappings

The mapping will be chosen automatically by looking at the supplied coordinates. If the supplied coordinates fall on a straight line, a StraightLine mapping will be used; if they fall on a log curve, a Logarithmic mapping will be used; otherwise an Interpolating mapping will be used.

!!! todo: inverted flag

The set of provided mappings must contain at least two coordinates, or at least three if the points are not supposed to be in a straight line.

It is expected that the values and positions in the coordinate mappings will both be monotonically increasing (i.e. no inflections in the mapping curve). Behaviour is undefined if this is not the case.

Definition at line 227 of file RangeMapper.cpp.

References chooseMappingTypeFor(), Interpolating, Logarithmic, m_mapper, m_mappings, m_type, and StraightLine.

Definition at line 255 of file RangeMapper.cpp.

References m_mapper.


Member Function Documentation

Return the mapping type in use.

Definition at line 236 of file RangeMapper.h.

References m_type.

int AutoRangeMapper::getPositionForValue ( float  value) const [virtual]

Return the position that maps to the given value, rounding to the nearest position and clamping to the minimum and maximum extents of the mapper's positional range.

Implements RangeMapper.

Definition at line 319 of file RangeMapper.cpp.

References RangeMapper::getPositionForValue(), and m_mapper.

int AutoRangeMapper::getPositionForValueUnclamped ( float  value) const [virtual]

Return the position that maps to the given value, rounding to the nearest position, without clamping.

That is, whatever mapping function is in use will be projected even outside the minimum and maximum extents of the mapper's positional range. (The mapping outside that range is not guaranteed to be exact, except if the mapper is a linear one.)

Implements RangeMapper.

Definition at line 331 of file RangeMapper.cpp.

References RangeMapper::getPositionForValueUnclamped(), and m_mapper.

float AutoRangeMapper::getValueForPosition ( int  position) const [virtual]

Return the value mapped from the given position, clamping to the minimum and maximum extents of the mapper's value range.

Implements RangeMapper.

Definition at line 325 of file RangeMapper.cpp.

References RangeMapper::getValueForPosition(), and m_mapper.

float AutoRangeMapper::getValueForPositionUnclamped ( int  position) const [virtual]

Return the value mapped from the given positionq, without clamping.

That is, whatever mapping function is in use will be projected even outside the minimum and maximum extents of the mapper's value range. (The mapping outside that range is not guaranteed to be exact, except if the mapper is a linear one.)

Implements RangeMapper.

Definition at line 337 of file RangeMapper.cpp.

References RangeMapper::getValueForPositionUnclamped(), and m_mapper.

virtual QString AutoRangeMapper::getUnit ( ) const [inline, virtual]

Get the unit of the mapper's value range.

Reimplemented from RangeMapper.

Definition at line 244 of file RangeMapper.h.

References m_unit.


Member Data Documentation

Definition at line 247 of file RangeMapper.h.

Referenced by AutoRangeMapper(), and getType().

Definition at line 248 of file RangeMapper.h.

Referenced by AutoRangeMapper().

QString AutoRangeMapper::m_unit [protected]

Definition at line 249 of file RangeMapper.h.

Referenced by getUnit().


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