comparison base/RangeMapper.cpp @ 687:06f13a3b9e9e debug-output

Convert many cerrs to DEBUGs
author Chris Cannam
date Mon, 16 May 2011 17:19:09 +0100
parents b4a8d8221eaf
children 1424aa29ae95
comparison
equal deleted inserted replaced
686:b4a8d8221eaf 687:06f13a3b9e9e
41 int position = m_minpos + 41 int position = m_minpos +
42 lrintf(((value - m_minval) / (m_maxval - m_minval)) 42 lrintf(((value - m_minval) / (m_maxval - m_minval))
43 * (m_maxpos - m_minpos)); 43 * (m_maxpos - m_minpos));
44 if (position < m_minpos) position = m_minpos; 44 if (position < m_minpos) position = m_minpos;
45 if (position > m_maxpos) position = m_maxpos; 45 if (position > m_maxpos) position = m_maxpos;
46 // std::cerr << "LinearRangeMapper::getPositionForValue: " << value << " -> " 46 // DEBUG << "LinearRangeMapper::getPositionForValue: " << value << " -> "
47 // << position << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", minval " << m_minval << ", maxval " << m_maxval << ")" << std::endl; 47 // << position << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", minval " << m_minval << ", maxval " << m_maxval << ")" << endl;
48 if (m_inverted) return m_maxpos - position; 48 if (m_inverted) return m_maxpos - position;
49 else return position; 49 else return position;
50 } 50 }
51 51
52 float 52 float
56 float value = m_minval + 56 float value = m_minval +
57 ((float(position - m_minpos) / float(m_maxpos - m_minpos)) 57 ((float(position - m_minpos) / float(m_maxpos - m_minpos))
58 * (m_maxval - m_minval)); 58 * (m_maxval - m_minval));
59 if (value < m_minval) value = m_minval; 59 if (value < m_minval) value = m_minval;
60 if (value > m_maxval) value = m_maxval; 60 if (value > m_maxval) value = m_maxval;
61 // std::cerr << "LinearRangeMapper::getValueForPosition: " << position << " -> " 61 // DEBUG << "LinearRangeMapper::getValueForPosition: " << position << " -> "
62 // << value << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", minval " << m_minval << ", maxval " << m_maxval << ")" << std::endl; 62 // << value << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", minval " << m_minval << ", maxval " << m_maxval << ")" << endl;
63 return value; 63 return value;
64 } 64 }
65 65
66 LogRangeMapper::LogRangeMapper(int minpos, int maxpos, 66 LogRangeMapper::LogRangeMapper(int minpos, int maxpos,
67 float minval, float maxval, 67 float minval, float maxval,
107 LogRangeMapper::getPositionForValue(float value) const 107 LogRangeMapper::getPositionForValue(float value) const
108 { 108 {
109 int position = (log10(value) - m_minlog) * m_ratio + m_minpos; 109 int position = (log10(value) - m_minlog) * m_ratio + m_minpos;
110 if (position < m_minpos) position = m_minpos; 110 if (position < m_minpos) position = m_minpos;
111 if (position > m_maxpos) position = m_maxpos; 111 if (position > m_maxpos) position = m_maxpos;
112 // std::cerr << "LogRangeMapper::getPositionForValue: " << value << " -> " 112 // DEBUG << "LogRangeMapper::getPositionForValue: " << value << " -> "
113 // << position << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", ratio " << m_ratio << ", minlog " << m_minlog << ")" << std::endl; 113 // << position << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", ratio " << m_ratio << ", minlog " << m_minlog << ")" << endl;
114 if (m_inverted) return m_maxpos - position; 114 if (m_inverted) return m_maxpos - position;
115 else return position; 115 else return position;
116 } 116 }
117 117
118 float 118 float
119 LogRangeMapper::getValueForPosition(int position) const 119 LogRangeMapper::getValueForPosition(int position) const
120 { 120 {
121 if (m_inverted) position = m_maxpos - position; 121 if (m_inverted) position = m_maxpos - position;
122 float value = powf(10, (position - m_minpos) / m_ratio + m_minlog); 122 float value = powf(10, (position - m_minpos) / m_ratio + m_minlog);
123 // std::cerr << "LogRangeMapper::getValueForPosition: " << position << " -> " 123 // DEBUG << "LogRangeMapper::getValueForPosition: " << position << " -> "
124 // << value << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", ratio " << m_ratio << ", minlog " << m_minlog << ")" << std::endl; 124 // << value << " (minpos " << m_minpos << ", maxpos " << m_maxpos << ", ratio " << m_ratio << ", minlog " << m_minlog << ")" << endl;
125 return value; 125 return value;
126 } 126 }
127 127