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: c2af97cbea90
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: 68285a681808
Choose a head ref
  • 2 commits
  • 8 files changed
  • 1 contributor

Commits on Sep 18, 2020

  1. Copy the full SHA
    bf10f11 View commit details

Commits on Sep 19, 2020

  1. Copy the full SHA
    68285a6 View commit details
2 changes: 1 addition & 1 deletion doc
Submodule doc updated from 6ea05a to a87078
2 changes: 1 addition & 1 deletion lib
Submodule lib updated from ea840b to b504dd
4 changes: 4 additions & 0 deletions src/glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -1965,6 +1965,7 @@ void OscilloscopeWindow::ClearPersistence(WaveformGroup* group, bool geometry_di
//Mark each area as dirty and map the buffers needed for update
for(auto w : areas)
{
w->CalculateOverlayPositions();
w->ClearPersistence(false);

if(geometry_dirty)
@@ -2195,7 +2196,10 @@ void OscilloscopeWindow::OnAllWaveformsUpdated()

//Map all of the buffers we need to update in each area
for(auto w : m_waveformAreas)
{
w->CalculateOverlayPositions();
w->MapAllBuffers(true);
}

float alpha = GetTraceAlpha();

4 changes: 2 additions & 2 deletions src/glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -200,6 +200,7 @@ class WaveformArea : public Gtk::GLArea
static void PrepareGeometry(WaveformRenderData* wdata, bool update_waveform, float alpha);
void MapAllBuffers(bool update_y);
void UnmapAllBuffers(bool update_y);
void CalculateOverlayPositions();

void CenterTimestamp(int64_t time);

@@ -386,15 +387,14 @@ class WaveformArea : public Gtk::GLArea
void RenderChannelLabel(Cairo::RefPtr< Cairo::Context > cr);
void RenderEyeMask(Cairo::RefPtr< Cairo::Context > cr);
void RenderDecodeOverlays(Cairo::RefPtr< Cairo::Context > cr);
void RenderFFTPeaks(Cairo::RefPtr< Cairo::Context > cr);
void InitializeCairoPass();
Texture m_cairoTexture;
Texture m_cairoTextureOver;
VertexArray m_cairoVAO;
VertexBuffer m_cairoVBO;
Program m_cairoProgram;

void CalculateOverlayPositions();

//Helpers for rendering and such
void RenderChannelInfoBox(
StreamDescriptor chan,
65 changes: 65 additions & 0 deletions src/glscopeclient/WaveformArea_cairo.cpp
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@
#include <random>
#include <map>
#include "../scopeprotocols/EyePattern.h"
#include "../scopeprotocols/FFTFilter.h"
#include "../../lib/scopehal/TwoLevelTrigger.h"

using namespace std;
@@ -289,6 +290,7 @@ void WaveformArea::DoRenderCairoOverlays(Cairo::RefPtr< Cairo::Context > cr)

RenderDecodeOverlays(cr);
RenderCursors(cr);
RenderFFTPeaks(cr);
RenderInsertionBar(cr);
RenderChannelLabel(cr);
}
@@ -1080,3 +1082,66 @@ void WaveformArea::RenderComplexSignal(
MakePathSignalBody(cr, xstart, xoff, xend, ybot, ymid, ytop);
cr->stroke();
}

void WaveformArea::RenderFFTPeaks(Cairo::RefPtr< Cairo::Context > cr)
{
auto filter = dynamic_cast<FFTFilter*>(m_channel.m_channel);
if(!filter)
return;

const vector<FFTPeak>& peaks = filter->GetPeaks();

Glib::RefPtr<Pango::Layout> tlayout = Pango::Layout::create (cr);
tlayout->set_font_description(m_cursorLabelFont);
int twidth;
int theight;
int margin = 2;

Unit hz(Unit::UNIT_HZ);
Unit dbm(Unit::UNIT_DBM);

for(size_t i=0; i<peaks.size(); i++)
{
//Format the text
string text = hz.PrettyPrint(peaks[i].m_freq) + "\n" + dbm.PrettyPrint(peaks[i].m_mag);

//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 radius = 4;

float left = x + radius + margin;
float right = left + twidth + margin;
float top = y - (theight/2 + margin);
float bottom = y + (theight/2 + margin);

//Crop
if( (left < 0) || (right > m_plotRight) )
continue;

//Draw the background
cr->set_source_rgba(0, 0, 0, 0.5);
cr->move_to(left, top);
cr->line_to(right, top);
cr->line_to(right, bottom);
cr->line_to(left, bottom);
cr->fill();

//Draw the text
cr->set_source_rgba(1, 1, 1, 1);
cr->save();
cr->move_to(left + margin, y - theight/2);
tlayout->update_from_cairo_context(cr);
tlayout->show_in_cairo_context(cr);
cr->restore();

//Draw the actual peak marker
cr->begin_new_path();
cr->arc(x, y, radius, 0, 2*M_PI);
cr->stroke();
}
}
13 changes: 8 additions & 5 deletions src/glscopeclient/WaveformArea_rendering.cpp
Original file line number Diff line number Diff line change
@@ -61,8 +61,12 @@ void WaveformRenderData::MapBuffers(size_t width, bool update_waveform)
else
{
auto pdat = m_channel.GetData();
if( (pdat == NULL) || ((m_count = pdat->m_offsets.size()) == 0) )
m_count = 1;
m_count = 1;
if(pdat != NULL)
{
m_count = pdat->m_offsets.size();
m_count = max((size_t)1, m_count);
}
}

if(update_waveform)
@@ -112,7 +116,7 @@ void WaveformArea::PrepareGeometry(WaveformRenderData* wdata, bool update_wavefo
return;
}
auto pdat = wdata->m_channel.GetData();
if( (pdat == NULL) || pdat->m_offsets.empty() )
if( (pdat == NULL) || pdat->m_offsets.empty() || (wdata->m_count == 0) )
{
wdata->m_geometryOK = false;
return;
@@ -189,7 +193,6 @@ void WaveformArea::PrepareGeometry(WaveformRenderData* wdata, bool update_wavefo
float alpha_scaled = alpha * 2 / samplesPerPixel;

//Config stuff
//TODO: we should be able to only update this stuff if we pan/zoom, without redoing the waveform data itself
wdata->m_mappedConfigBuffer64[0] = -group->m_xAxisOffset / pdat->m_timescale; //innerXoff
wdata->m_mappedConfigBuffer[2] = height; //windowHeight
wdata->m_mappedConfigBuffer[3] = wdata->m_area->m_plotRight; //windowWidth
@@ -219,7 +222,7 @@ size_t WaveformArea::BinarySearchForGequal(T* buf, size_t len, T value)
if(buf[0] >= value)
return 0;
if(buf[last_hi] < value)
return len;
return len-1;

while(true)
{
2 changes: 1 addition & 1 deletion src/glscopeclient/shaders/waveform-compute-analog.glsl
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ void main()
uint istart = xind[gl_GlobalInvocationID.x];
vec2 left = vec2(float(xpos[istart] + innerXoff) * xscale + xoff, (voltage[istart] + yoff)*yscale + ybase);
vec2 right;
for(uint i=istart; i<(memDepth-1); i++)
for(uint i=istart; i<(memDepth-2); i++)
{
//Fetch coordinates of the current and upcoming sample
right = vec2(float(xpos[i+1] + innerXoff)*xscale + xoff, (voltage[i+1] + yoff)*yscale + ybase);
2 changes: 1 addition & 1 deletion src/glscopeclient/shaders/waveform-compute-digital.glsl
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ void main()
uint istart = xind[gl_GlobalInvocationID.x];
vec2 left = vec2(float(xpos[istart] + innerXoff) * xscale + xoff, GetBoolean(istart)*yscale + ybase);
vec2 right;
for(uint i=istart; i<(memDepth-1); i++)
for(uint i=istart; i<(memDepth-2); i++)
{
//Fetch coordinates of the current and upcoming sample
right = vec2(float(xpos[i+1] + innerXoff)*xscale + xoff, GetBoolean(i+1)*yscale + ybase);