svcore  1.9
LogRangeMapper Class Reference

#include <RangeMapper.h>

Inheritance diagram for LogRangeMapper:
Collaboration diagram for LogRangeMapper:

Public Member Functions

 LogRangeMapper (int minpos, int maxpos, float minval, float 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...
 
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. More...
 
virtual int getPositionForValueUnclamped (float value) const
 Return the position that maps to the given value, rounding to the nearest position, without clamping. More...
 
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. More...
 
virtual float getValueForPositionUnclamped (int position) const
 Return the value mapped from the given positionq, without clamping. More...
 
virtual QString getUnit () const
 Get the unit of the mapper's value range. More...
 

Static Public Member Functions

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

Protected Attributes

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

Detailed Description

Definition at line 98 of file RangeMapper.h.

Constructor & Destructor Documentation

◆ LogRangeMapper()

LogRangeMapper::LogRangeMapper ( int  minpos,
int  maxpos,
float  minval,
float  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 76 of file RangeMapper.cpp.

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

Member Function Documentation

◆ convertRatioMinLog()

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

Definition at line 110 of file RangeMapper.cpp.

◆ convertMinMax()

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

Definition at line 99 of file RangeMapper.cpp.

Referenced by LogRangeMapper().

◆ getPositionForValue()

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

References getPositionForValueUnclamped(), m_maxpos, and m_minpos.

Referenced by AutoRangeMapper::chooseMappingTypeFor().

◆ getPositionForValueUnclamped()

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

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

Referenced by getPositionForValue().

◆ getValueForPosition()

float LogRangeMapper::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 138 of file RangeMapper.cpp.

References getValueForPositionUnclamped(), m_maxpos, and m_minpos.

◆ getValueForPositionUnclamped()

float LogRangeMapper::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 147 of file RangeMapper.cpp.

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

Referenced by getValueForPosition().

◆ getUnit()

virtual QString LogRangeMapper::getUnit ( ) const
inlinevirtual

Get the unit of the mapper's value range.

Reimplemented from RangeMapper.

Definition at line 127 of file RangeMapper.h.

References m_unit.

Member Data Documentation

◆ m_minpos

int LogRangeMapper::m_minpos
protected

◆ m_maxpos

int LogRangeMapper::m_maxpos
protected

◆ m_ratio

float LogRangeMapper::m_ratio
protected

◆ m_minlog

float LogRangeMapper::m_minlog
protected

◆ m_maxlog

float LogRangeMapper::m_maxlog
protected

Definition at line 134 of file RangeMapper.h.

Referenced by LogRangeMapper().

◆ m_unit

QString LogRangeMapper::m_unit
protected

Definition at line 135 of file RangeMapper.h.

Referenced by getUnit().

◆ m_inverted

bool LogRangeMapper::m_inverted
protected

Definition at line 136 of file RangeMapper.h.

Referenced by getPositionForValueUnclamped(), and getValueForPositionUnclamped().


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