svcore  1.9
LinearRangeMapper Class Reference

#include <RangeMapper.h>

Inheritance diagram for LinearRangeMapper:
Collaboration diagram for LinearRangeMapper:

Public Member Functions

 LinearRangeMapper (int minpos, int maxpos, float minval, float maxval, QString unit="", bool inverted=false)
 Map values in range minval->maxval linearly into integer range minpos->maxpos. 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...
 

Protected Attributes

int m_minpos
 
int m_maxpos
 
float m_minval
 
float m_maxval
 
QString m_unit
 
bool m_inverted
 

Detailed Description

Definition at line 68 of file RangeMapper.h.

Constructor & Destructor Documentation

◆ LinearRangeMapper()

LinearRangeMapper::LinearRangeMapper ( int  minpos,
int  maxpos,
float  minval,
float  maxval,
QString  unit = "",
bool  inverted = false 
)

Map values in range minval->maxval linearly into integer range minpos->maxpos.

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

References m_maxpos, m_maxval, m_minpos, and m_minval.

Member Function Documentation

◆ getPositionForValue()

int LinearRangeMapper::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 39 of file RangeMapper.cpp.

References getPositionForValueUnclamped(), m_maxpos, and m_minpos.

Referenced by AutoRangeMapper::chooseMappingTypeFor().

◆ getPositionForValueUnclamped()

int LinearRangeMapper::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 48 of file RangeMapper.cpp.

References m_inverted, m_maxpos, m_maxval, m_minpos, and m_minval.

Referenced by getPositionForValue().

◆ getValueForPosition()

float LinearRangeMapper::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 58 of file RangeMapper.cpp.

References getValueForPositionUnclamped(), m_maxpos, and m_minpos.

◆ getValueForPositionUnclamped()

float LinearRangeMapper::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 67 of file RangeMapper.cpp.

References m_inverted, m_maxpos, m_maxval, m_minpos, and m_minval.

Referenced by getValueForPosition().

◆ getUnit()

virtual QString LinearRangeMapper::getUnit ( ) const
inlinevirtual

Get the unit of the mapper's value range.

Reimplemented from RangeMapper.

Definition at line 87 of file RangeMapper.h.

References m_unit.

Member Data Documentation

◆ m_minpos

int LinearRangeMapper::m_minpos
protected

◆ m_maxpos

int LinearRangeMapper::m_maxpos
protected

◆ m_minval

float LinearRangeMapper::m_minval
protected

◆ m_maxval

float LinearRangeMapper::m_maxval
protected

◆ m_unit

QString LinearRangeMapper::m_unit
protected

Definition at line 94 of file RangeMapper.h.

Referenced by getUnit().

◆ m_inverted

bool LinearRangeMapper::m_inverted
protected

Definition at line 95 of file RangeMapper.h.

Referenced by getPositionForValueUnclamped(), and getValueForPositionUnclamped().


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