#include <RangeMapper.h>

Inheritance diagram for AutoRangeMapper:
Inheritance graph
Collaboration diagram for AutoRangeMapper:
Collaboration graph

Public Types

enum  MappingType { Interpolating, StraightLine, Logarithmic }
 
typedef std::map< double, 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. More...
 
 ~AutoRangeMapper ()
 
MappingType getType () const
 Return the mapping type in use. More...
 
int getPositionForValue (double value) const override
 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. More...
 
int getPositionForValueUnclamped (double value) const override
 Return the position that maps to the given value, rounding to the nearest position, without clamping. More...
 
double getValueForPosition (int position) const override
 Return the value mapped from the given position, clamping to the minimum and maximum extents of the mapper's value range. More...
 
double getValueForPositionUnclamped (int position) const override
 Return the value mapped from the given position, without clamping. More...
 
QString getUnit () const override
 Get the unit of the mapper's value range. More...
 
virtual QString getLabel (int) const
 The mapper may optionally provide special labels for one or more individual positions (such as the minimum position, the default, or indeed all positions). More...
 

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 195 of file RangeMapper.h.

Member Typedef Documentation

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

Definition at line 204 of file RangeMapper.h.

Member Enumeration Documentation

Enumerator
Interpolating 
StraightLine 
Logarithmic 

Definition at line 198 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 248 of file RangeMapper.cpp.

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

AutoRangeMapper::~AutoRangeMapper ( )

Definition at line 276 of file RangeMapper.cpp.

References m_mapper.

Member Function Documentation

MappingType AutoRangeMapper::getType ( ) const
inline
int AutoRangeMapper::getPositionForValue ( double  value) const
overridevirtual

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 340 of file RangeMapper.cpp.

References RangeMapper::getPositionForValue(), and m_mapper.

int AutoRangeMapper::getPositionForValueUnclamped ( double  value) const
overridevirtual

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 352 of file RangeMapper.cpp.

References RangeMapper::getPositionForValueUnclamped(), and m_mapper.

double AutoRangeMapper::getValueForPosition ( int  position) const
overridevirtual

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 346 of file RangeMapper.cpp.

References RangeMapper::getValueForPosition(), and m_mapper.

double AutoRangeMapper::getValueForPositionUnclamped ( int  position) const
overridevirtual

Return the value mapped from the given 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 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 358 of file RangeMapper.cpp.

References RangeMapper::getValueForPositionUnclamped(), and m_mapper.

QString AutoRangeMapper::getUnit ( ) const
inlineoverridevirtual

Get the unit of the mapper's value range.

Reimplemented from RangeMapper.

Definition at line 257 of file RangeMapper.h.

AutoRangeMapper::MappingType AutoRangeMapper::chooseMappingTypeFor ( const CoordMap mappings)
protected
virtual QString RangeMapper::getLabel ( int  ) const
inlinevirtualinherited

The mapper may optionally provide special labels for one or more individual positions (such as the minimum position, the default, or indeed all positions).

These should be used in any display context in preference to just showing the numerical value for the position. If a position has such a label, return it here.

Reimplemented in LinearRangeMapper.

Definition at line 74 of file RangeMapper.h.

Referenced by LinearRangeMapper::getUnit().

Member Data Documentation

MappingType AutoRangeMapper::m_type
protected

Definition at line 260 of file RangeMapper.h.

Referenced by AutoRangeMapper().

CoordMap AutoRangeMapper::m_mappings
protected

Definition at line 261 of file RangeMapper.h.

Referenced by AutoRangeMapper().

QString AutoRangeMapper::m_unit
protected

Definition at line 262 of file RangeMapper.h.


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