Mercurial > hg > svgui
comparison view/View.cpp @ 904:e0f08e108064 cxx11
Move to using double rather than float for floating-point calculations (float only for storage); more build fixes
author | Chris Cannam |
---|---|
date | Mon, 09 Mar 2015 12:02:10 +0000 |
parents | ee36642b9b59 |
children | 4a578a360011 |
comparison
equal
deleted
inserted
replaced
903:1757933ce5a7 | 904:e0f08e108064 |
---|---|
180 if (i == 0) return m_propertyContainer; | 180 if (i == 0) return m_propertyContainer; |
181 return m_fixedOrderLayers[i-1]; | 181 return m_fixedOrderLayers[i-1]; |
182 } | 182 } |
183 | 183 |
184 bool | 184 bool |
185 View::getValueExtents(QString unit, float &min, float &max, bool &log) const | 185 View::getValueExtents(QString unit, double &min, double &max, bool &log) const |
186 { | 186 { |
187 bool have = false; | 187 bool have = false; |
188 | 188 |
189 for (LayerList::const_iterator i = m_layerStack.begin(); | 189 for (LayerList::const_iterator i = m_layerStack.begin(); |
190 i != m_layerStack.end(); ++i) { | 190 i != m_layerStack.end(); ++i) { |
191 | 191 |
192 QString layerUnit; | 192 QString layerUnit; |
193 float layerMin = 0.0, layerMax = 0.0; | 193 double layerMin = 0.0, layerMax = 0.0; |
194 float displayMin = 0.0, displayMax = 0.0; | 194 double displayMin = 0.0, displayMax = 0.0; |
195 bool layerLog = false; | 195 bool layerLog = false; |
196 | 196 |
197 if ((*i)->getValueExtents(layerMin, layerMax, layerLog, layerUnit) && | 197 if ((*i)->getValueExtents(layerMin, layerMax, layerLog, layerUnit) && |
198 layerUnit.toLower() == unit.toLower()) { | 198 layerUnit.toLower() == unit.toLower()) { |
199 | 199 |
371 | 371 |
372 frame = (frame / z) * z; // this is start frame | 372 frame = (frame / z) * z; // this is start frame |
373 return frame + x * z; | 373 return frame + x * z; |
374 } | 374 } |
375 | 375 |
376 float | 376 double |
377 View::getYForFrequency(float frequency, | 377 View::getYForFrequency(double frequency, |
378 float minf, | 378 double minf, |
379 float maxf, | 379 double maxf, |
380 bool logarithmic) const | 380 bool logarithmic) const |
381 { | 381 { |
382 Profiler profiler("View::getYForFrequency"); | 382 Profiler profiler("View::getYForFrequency"); |
383 | 383 |
384 int h = height(); | 384 int h = height(); |
385 | 385 |
386 if (logarithmic) { | 386 if (logarithmic) { |
387 | 387 |
388 static float lastminf = 0.0, lastmaxf = 0.0; | 388 static double lastminf = 0.0, lastmaxf = 0.0; |
389 static float logminf = 0.0, logmaxf = 0.0; | 389 static double logminf = 0.0, logmaxf = 0.0; |
390 | 390 |
391 if (lastminf != minf) { | 391 if (lastminf != minf) { |
392 lastminf = (minf == 0.0 ? 1.0 : minf); | 392 lastminf = (minf == 0.0 ? 1.0 : minf); |
393 logminf = log10f(minf); | 393 logminf = log10f(minf); |
394 } | 394 } |
405 if (minf == maxf) return 0; | 405 if (minf == maxf) return 0; |
406 return h - (h * (frequency - minf)) / (maxf - minf); | 406 return h - (h * (frequency - minf)) / (maxf - minf); |
407 } | 407 } |
408 } | 408 } |
409 | 409 |
410 float | 410 double |
411 View::getFrequencyForY(int y, | 411 View::getFrequencyForY(int y, |
412 float minf, | 412 double minf, |
413 float maxf, | 413 double maxf, |
414 bool logarithmic) const | 414 bool logarithmic) const |
415 { | 415 { |
416 int h = height(); | 416 int h = height(); |
417 | 417 |
418 if (logarithmic) { | 418 if (logarithmic) { |
419 | 419 |
420 static float lastminf = 0.0, lastmaxf = 0.0; | 420 static double lastminf = 0.0, lastmaxf = 0.0; |
421 static float logminf = 0.0, logmaxf = 0.0; | 421 static double logminf = 0.0, logmaxf = 0.0; |
422 | 422 |
423 if (lastminf != minf) { | 423 if (lastminf != minf) { |
424 lastminf = (minf == 0.0 ? 1.0 : minf); | 424 lastminf = (minf == 0.0 ? 1.0 : minf); |
425 logminf = log10f(minf); | 425 logminf = log10f(minf); |
426 } | 426 } |
2143 } | 2143 } |
2144 | 2144 |
2145 int fontHeight = paint.fontMetrics().height(); | 2145 int fontHeight = paint.fontMetrics().height(); |
2146 int fontAscent = paint.fontMetrics().ascent(); | 2146 int fontAscent = paint.fontMetrics().ascent(); |
2147 | 2147 |
2148 float v0, v1; | 2148 double v0, v1; |
2149 QString u0, u1; | 2149 QString u0, u1; |
2150 bool b0 = false, b1 = false; | 2150 bool b0 = false, b1 = false; |
2151 | 2151 |
2152 QString axs, ays, bxs, bys, dxs, dys; | 2152 QString axs, ays, bxs, bys, dxs, dys; |
2153 | 2153 |
2215 bw = std::max(bw, paint.fontMetrics().width(bys)); | 2215 bw = std::max(bw, paint.fontMetrics().width(bys)); |
2216 } | 2216 } |
2217 } | 2217 } |
2218 | 2218 |
2219 bool bd = false; | 2219 bool bd = false; |
2220 float dy = 0.f; | 2220 double dy = 0.f; |
2221 QString du; | 2221 QString du; |
2222 | 2222 |
2223 // dimension, height | 2223 // dimension, height |
2224 | 2224 |
2225 if ((bd = topLayer->getYScaleDifference(this, r.y(), r.y() + r.height(), | 2225 if ((bd = topLayer->getYScaleDifference(this, r.y(), r.y() + r.height(), |
2226 dy, du)) && | 2226 dy, du)) && |
2227 dy != 0) { | 2227 dy != 0) { |
2228 if (du != "") { | 2228 if (du != "") { |
2229 if (du == "Hz") { | 2229 if (du == "Hz") { |
2230 int semis; | 2230 int semis; |
2231 float cents; | 2231 double cents; |
2232 semis = Pitch::getPitchForFrequencyDifference(v0, v1, ¢s); | 2232 semis = Pitch::getPitchForFrequencyDifference(v0, v1, ¢s); |
2233 dys = QString("[%1 %2 (%3)]") | 2233 dys = QString("[%1 %2 (%3)]") |
2234 .arg(dy).arg(du) | 2234 .arg(dy).arg(du) |
2235 .arg(Pitch::getLabelForPitchRange(semis, cents)); | 2235 .arg(Pitch::getLabelForPitchRange(semis, cents)); |
2236 } else { | 2236 } else { |