Mercurial > hg > svgui
comparison layer/SliceLayer.cpp @ 220:8dc50f57d480
* Make the vertical scale a bit less thtoopid for many linear scale spectra
* Don't forget to reload slice layer properties when loading a session, as well
as spectrum layer (i.e. subclass) properties
author | Chris Cannam |
---|---|
date | Mon, 05 Mar 2007 13:04:52 +0000 |
parents | 34bbbcb3c01f |
children | 28c8e8e3c537 |
comparison
equal
deleted
inserted
replaced
219:1fff998ae4a9 | 220:8dc50f57d480 |
---|---|
434 | 434 |
435 int | 435 int |
436 SliceLayer::getVerticalScaleWidth(View *v, QPainter &paint) const | 436 SliceLayer::getVerticalScaleWidth(View *v, QPainter &paint) const |
437 { | 437 { |
438 if (m_energyScale == LinearScale) { | 438 if (m_energyScale == LinearScale) { |
439 return paint.fontMetrics().width("0.0") + 13; | 439 return std::max(paint.fontMetrics().width("0.0") + 13, |
440 paint.fontMetrics().width("x10-10")); | |
440 } else { | 441 } else { |
441 return std::max(paint.fontMetrics().width(tr("0dB")), | 442 return std::max(paint.fontMetrics().width(tr("0dB")), |
442 paint.fontMetrics().width(tr("-Inf"))) + 13; | 443 paint.fontMetrics().width(tr("-Inf"))) + 13; |
443 } | 444 } |
444 } | 445 } |
458 int h = yorigin - paint.fontMetrics().height() - 8; | 459 int h = yorigin - paint.fontMetrics().height() - 8; |
459 if (h < 0) return; | 460 if (h < 0) return; |
460 | 461 |
461 QRect actual(rect.x(), rect.y() + yorigin - h, rect.width(), h); | 462 QRect actual(rect.x(), rect.y() + yorigin - h, rect.width(), h); |
462 | 463 |
464 int mult = 1; | |
465 | |
463 PaintAssistant::paintVerticalLevelScale | 466 PaintAssistant::paintVerticalLevelScale |
464 (paint, actual, thresh, 1.0 / m_gain, | 467 (paint, actual, thresh, 1.0 / m_gain, |
465 PaintAssistant::Scale(m_energyScale), | 468 PaintAssistant::Scale(m_energyScale), |
469 mult, | |
466 const_cast<std::vector<int> *>(&m_scalePoints)); | 470 const_cast<std::vector<int> *>(&m_scalePoints)); |
471 | |
472 if (mult != 1 && mult != 0) { | |
473 int log = lrintf(log10f(mult)); | |
474 QString a = tr("x10"); | |
475 QString b = QString("%1").arg(-log); | |
476 paint.drawText(3, 8 + paint.fontMetrics().ascent(), a); | |
477 paint.drawText(3 + paint.fontMetrics().width(a), | |
478 3 + paint.fontMetrics().ascent(), b); | |
479 } | |
467 } | 480 } |
468 | 481 |
469 Layer::PropertyList | 482 Layer::PropertyList |
470 SliceLayer::getProperties() const | 483 SliceLayer::getProperties() const |
471 { | 484 { |
838 setNormalize(normalize); | 851 setNormalize(normalize); |
839 } | 852 } |
840 | 853 |
841 bool | 854 bool |
842 SliceLayer::getValueExtents(float &min, float &max, bool &logarithmic, | 855 SliceLayer::getValueExtents(float &min, float &max, bool &logarithmic, |
843 QString &units) const | 856 QString &units) const |
844 { | 857 { |
845 return false; | 858 return false; |
846 } | 859 } |
847 | 860 |