comparison layer/SpectrumLayer.cpp @ 1276:b4cb11ca8233 horizontal-scale

Branch toward adding horizontal numerical scales to things
author Chris Cannam
date Tue, 01 May 2018 16:14:22 +0100
parents a34a2a25907c
children 82258db96244
comparison
equal deleted inserted replaced
1275:3ca1be2e2c91 1276:b4cb11ca8233
23 #include "base/Pitch.h" 23 #include "base/Pitch.h"
24 #include "base/Strings.h" 24 #include "base/Strings.h"
25 25
26 #include "ColourMapper.h" 26 #include "ColourMapper.h"
27 #include "PaintAssistant.h" 27 #include "PaintAssistant.h"
28 #include "PianoScale.h"
29 #include "LogNumericalScale.h"
28 30
29 #include <QPainter> 31 #include <QPainter>
30 #include <QTextStream> 32 #include <QTextStream>
31 33
32 34
601 int w = v->getPaintWidth() - xorigin - 1; 603 int w = v->getPaintWidth() - xorigin - 1;
602 604
603 int pkh = int(paint.fontMetrics().height() * 0.7 + 0.5); 605 int pkh = int(paint.fontMetrics().height() * 0.7 + 0.5);
604 if (pkh < 10) pkh = 10; 606 if (pkh < 10) pkh = 10;
605 607
608 int scaleh = LogNumericalScale().getWidth(v, paint, true);
609
606 paint.save(); 610 paint.save();
607 611
608 if (fft && m_showPeaks) { 612 if (fft && m_showPeaks) {
609 613
610 // draw peak lines 614 // draw peak lines
654 658
655 double norm = 0.f; 659 double norm = 0.f;
656 (void)getYForValue(v, values[bin], norm); // don't need return value, need norm 660 (void)getYForValue(v, values[bin], norm); // don't need return value, need norm
657 661
658 paint.setPen(mapper.map(norm)); 662 paint.setPen(mapper.map(norm));
659 paint.drawLine(xorigin + x, 0, xorigin + x, v->getPaintHeight() - pkh - 1); 663 paint.drawLine(xorigin + x, 0, xorigin + x,
664 v->getPaintHeight() - scaleh - pkh - 1);
660 } 665 }
661 666
662 paint.restore(); 667 paint.restore();
663 } 668 }
664 669
674 // that's a bigger proposition. 679 // that's a bigger proposition.
675 680
676 int h = v->getPaintHeight(); 681 int h = v->getPaintHeight();
677 682
678 PianoScale().paintPianoHorizontal 683 PianoScale().paintPianoHorizontal
679 (v, this, paint, QRect(xorigin, h - pkh - 1, w + xorigin, pkh)); 684 (v, this, paint,
680 685 QRect(xorigin, h - scaleh - pkh - 1, w + xorigin, pkh));
686
687 LogNumericalScale().paintHorizontal
688 (v, this, paint,
689 QRect(xorigin, h - scaleh, w + xorigin, scaleh));
690
681 paint.restore(); 691 paint.restore();
682 } 692 }
683 693
684 void 694 void
685 SpectrumLayer::getBiasCurve(BiasCurve &curve) const 695 SpectrumLayer::getBiasCurve(BiasCurve &curve) const