comparison layer/TimeValueLayer.cpp @ 960:6f97f5149cb3

Display note name derived from value, when hovering over time-value feature if the scale unit is Hz
author Chris Cannam
date Tue, 12 May 2015 14:25:00 +0100
parents 251dd0abc7b7
children fa96108d552d
comparison
equal deleted inserted replaced
959:2633a1d73e39 960:6f97f5149cb3
18 #include "data/model/Model.h" 18 #include "data/model/Model.h"
19 #include "base/RealTime.h" 19 #include "base/RealTime.h"
20 #include "base/Profiler.h" 20 #include "base/Profiler.h"
21 #include "base/LogRange.h" 21 #include "base/LogRange.h"
22 #include "base/RangeMapper.h" 22 #include "base/RangeMapper.h"
23 #include "base/Pitch.h"
23 #include "ColourDatabase.h" 24 #include "ColourDatabase.h"
24 #include "view/View.h" 25 #include "view/View.h"
25 26
26 #include "data/model/SparseTimeValueModel.h" 27 #include "data/model/SparseTimeValueModel.h"
27 #include "data/model/Labeller.h" 28 #include "data/model/Labeller.h"
604 605
605 sv_frame_t useFrame = points.begin()->frame; 606 sv_frame_t useFrame = points.begin()->frame;
606 607
607 RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate()); 608 RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate());
608 609
610 QString valueText;
611 float value = points.begin()->value;
612 QString unit = getScaleUnits();
613
614 if (unit == "Hz") {
615 valueText = tr("%1 Hz (%2, %3)")
616 .arg(value)
617 .arg(Pitch::getPitchLabelForFrequency(value))
618 .arg(Pitch::getPitchForFrequency(value));
619 } else if (unit != "") {
620 valueText = tr("%1 %2").arg(value).arg(unit);
621 } else {
622 valueText = tr("%1").arg(value);
623 }
624
609 QString text; 625 QString text;
610 QString unit = getScaleUnits();
611 if (unit != "") unit = " " + unit;
612 626
613 if (points.begin()->label == "") { 627 if (points.begin()->label == "") {
614 text = QString(tr("Time:\t%1\nValue:\t%2%3\nNo label")) 628 text = QString(tr("Time:\t%1\nValue:\t%2\nNo label"))
615 .arg(rt.toText(true).c_str()) 629 .arg(rt.toText(true).c_str())
616 .arg(points.begin()->value) 630 .arg(valueText);
617 .arg(unit);
618 } else { 631 } else {
619 text = QString(tr("Time:\t%1\nValue:\t%2%3\nLabel:\t%4")) 632 text = QString(tr("Time:\t%1\nValue:\t%2\nLabel:\t%4"))
620 .arg(rt.toText(true).c_str()) 633 .arg(rt.toText(true).c_str())
621 .arg(points.begin()->value) 634 .arg(valueText)
622 .arg(unit)
623 .arg(points.begin()->label); 635 .arg(points.begin()->label);
624 } 636 }
625 637
626 pos = QPoint(v->getXForFrame(useFrame), 638 pos = QPoint(v->getXForFrame(useFrame),
627 getYForValue(v, points.begin()->value)); 639 getYForValue(v, points.begin()->value));