Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3519807cecd9
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b5f8f3ff3a9f
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Sep 20, 2020

  1. Copy the full SHA
    b5f8f3f View commit details
Showing with 15 additions and 8 deletions.
  1. +1 −1 lib
  2. +14 −7 src/glscopeclient/WaveformArea_cairo.cpp
2 changes: 1 addition & 1 deletion lib
Submodule lib updated from 1a8cb3 to f41c8a
21 changes: 14 additions & 7 deletions src/glscopeclient/WaveformArea_cairo.cpp
Original file line number Diff line number Diff line change
@@ -1094,11 +1094,16 @@ void WaveformArea::RenderComplexSignal(
*/
void WaveformArea::RenderFFTPeaks(Cairo::RefPtr< Cairo::Context > cr)
{
auto filter = dynamic_cast<FFTFilter*>(m_channel.m_channel);
//Grab input and stop if there's nothing for us to do
auto filter = dynamic_cast<PeakDetectionFilter*>(m_channel.m_channel);
if(!filter)
return;
const vector<Peak>& peaks = filter->GetPeaks();
auto data = filter->GetData(0);
if(peaks.empty() || (data == NULL) )
return;

const vector<FFTPeak>& peaks = filter->GetPeaks();
int64_t timescale = data->m_timescale;

//Settings for the text
Glib::RefPtr<Pango::Layout> tlayout = Pango::Layout::create (cr);
@@ -1107,8 +1112,8 @@ void WaveformArea::RenderFFTPeaks(Cairo::RefPtr< Cairo::Context > cr)
int theight;
int margin = 2;

Unit hz(Unit::UNIT_HZ);
Unit dbm(Unit::UNIT_DBM);
auto xunit = filter->GetXAxisUnits();
auto yunit = filter->GetYAxisUnits();

//First pass: get nominal locations of each peak label and discard offscreen ones
float radius = 4;
@@ -1117,15 +1122,17 @@ void WaveformArea::RenderFFTPeaks(Cairo::RefPtr< Cairo::Context > cr)
vector<Rect> rects;
for(size_t i=0; i<peaks.size(); i++)
{
int64_t nx = peaks[i].m_x * timescale;

//Format the text
string text = hz.PrettyPrint(peaks[i].m_freq) + "\n" + dbm.PrettyPrint(peaks[i].m_mag);
string text = xunit.PrettyPrint(nx) + "\n" + yunit.PrettyPrint(peaks[i].m_y);

//Calculate text size
tlayout->set_text(text);
tlayout->get_pixel_size(twidth, theight);

float x = XAxisUnitsToXPosition(peaks[i].m_freq);
float y = VoltsToYPosition(peaks[i].m_mag);
float x = XAxisUnitsToXPosition(nx);
float y = VoltsToYPosition(peaks[i].m_y);

//Don't show labels for offscreen peaks
if( (x < 0) || (x > m_plotRight) )