#include <RangeMapper.h>

Inheritance diagram for LogRangeMapper:
Inheritance graph
Collaboration diagram for LogRangeMapper:
Collaboration graph

Public Member Functions

 LogRangeMapper (int minpos, int maxpos, double minval, double maxval, QString m_unit="", bool inverted=false)
 Map values in range minval->maxval into integer range minpos->maxpos such that logs of the values are mapped linearly. 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...
 

Static Public Member Functions

static void convertRatioMinLog (double ratio, double minlog, int minpos, int maxpos, double &minval, double &maxval)
 
static void convertMinMax (int minpos, int maxpos, double minval, double maxval, double &minlog, double &ratio)
 

Protected Attributes

int m_minpos
 
int m_maxpos
 
double m_ratio
 
double m_minlog
 
double m_maxlog
 
QString m_unit
 
bool m_inverted
 

Detailed Description

Definition at line 111 of file RangeMapper.h.

Constructor & Destructor Documentation

LogRangeMapper::LogRangeMapper ( int  minpos,
int  maxpos,
double  minval,
double  maxval,
QString  m_unit = "",
bool  inverted = false 
)

Map values in range minval->maxval into integer range minpos->maxpos such that logs of the values are mapped linearly.

minval must be greater than zero, and minval and minpos must be less than maxval and maxpos respectively. If inverted is true, the range will be mapped "backwards" (minval to maxpos and maxval to minpos).

Definition at line 94 of file RangeMapper.cpp.

References convertMinMax(), m_maxlog, m_maxpos, m_minlog, m_minpos, and m_ratio.

Member Function Documentation

void LogRangeMapper::convertRatioMinLog ( double  ratio,
double  minlog,
int  minpos,
int  maxpos,
double &  minval,
double &  maxval 
)
static

Definition at line 130 of file RangeMapper.cpp.

void LogRangeMapper::convertMinMax ( int  minpos,
int  maxpos,
double  minval,
double  maxval,
double &  minlog,
double &  ratio 
)
static

Definition at line 119 of file RangeMapper.cpp.

Referenced by LogRangeMapper().

int LogRangeMapper::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 139 of file RangeMapper.cpp.

References getPositionForValueUnclamped(), m_maxpos, and m_minpos.

Referenced by AutoRangeMapper::chooseMappingTypeFor().

int LogRangeMapper::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 148 of file RangeMapper.cpp.

References m_inverted, m_maxpos, m_minlog, m_minpos, and m_ratio.

Referenced by getPositionForValue().

double LogRangeMapper::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 158 of file RangeMapper.cpp.

References getValueForPositionUnclamped(), m_maxpos, and m_minpos.

double LogRangeMapper::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 167 of file RangeMapper.cpp.

References m_inverted, m_maxpos, m_minlog, m_minpos, and m_ratio.

Referenced by getValueForPosition().

QString LogRangeMapper::getUnit ( ) const
inlineoverridevirtual

Get the unit of the mapper's value range.

Reimplemented from RangeMapper.

Definition at line 140 of file RangeMapper.h.

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

int LogRangeMapper::m_minpos
protected
int LogRangeMapper::m_maxpos
protected
double LogRangeMapper::m_ratio
protected
double LogRangeMapper::m_minlog
protected
double LogRangeMapper::m_maxlog
protected

Definition at line 147 of file RangeMapper.h.

Referenced by LogRangeMapper().

QString LogRangeMapper::m_unit
protected

Definition at line 148 of file RangeMapper.h.

bool LogRangeMapper::m_inverted
protected

Definition at line 149 of file RangeMapper.h.

Referenced by getPositionForValueUnclamped(), and getValueForPositionUnclamped().


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