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: bf7739ccae2e
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: 65dd172a337c
Choose a head ref
  • 1 commit
  • 8 files changed
  • 1 contributor

Commits on Feb 17, 2020

  1. Refactoring: changed a bunch of function/variable names to make it mo…

    …re obvious that X axis units may not be time
    azonenberg committed Feb 17, 2020
    Copy the full SHA
    65dd172 View commit details
8 changes: 4 additions & 4 deletions glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -394,7 +394,7 @@ void OscilloscopeWindow::OnMoveNew(WaveformArea* w, bool horizontal)
{
//Make a new group
auto group = new WaveformGroup(this);
group->m_pixelsPerPicosecond = w->m_group->m_pixelsPerPicosecond;
group->m_pixelsPerXUnit = w->m_group->m_pixelsPerXUnit;
m_waveformGroups.emplace(group);

//Split the existing group and add the new group to it
@@ -408,7 +408,7 @@ void OscilloscopeWindow::OnCopyNew(WaveformArea* w, bool horizontal)
{
//Make a new group
auto group = new WaveformGroup(this);
group->m_pixelsPerPicosecond = w->m_group->m_pixelsPerPicosecond;
group->m_pixelsPerXUnit = w->m_group->m_pixelsPerXUnit;
m_waveformGroups.emplace(group);

//Split the existing group and add the new group to it
@@ -527,13 +527,13 @@ void OscilloscopeWindow::OnAutofitHorizontal()

void OscilloscopeWindow::OnZoomInHorizontal(WaveformGroup* group)
{
group->m_pixelsPerPicosecond *= 1.5;
group->m_pixelsPerXUnit *= 1.5;
ClearPersistence(group);
}

void OscilloscopeWindow::OnZoomOutHorizontal(WaveformGroup* group)
{
group->m_pixelsPerPicosecond /= 1.5;
group->m_pixelsPerXUnit /= 1.5;
ClearPersistence(group);
}

2 changes: 1 addition & 1 deletion glscopeclient/ProtocolAnalyzerWindow.cpp
Original file line number Diff line number Diff line change
@@ -215,7 +215,7 @@ void ProtocolAnalyzerWindow::OnSelectionChanged()
m_parent->JumpToHistory(row[m_columns.m_capturekey]);

//Set the offset of the decoder's group
m_area->m_group->m_timeOffset = row[m_columns.m_offset];
m_area->m_group->m_xAxisOffset = row[m_columns.m_offset];
m_area->m_group->m_frame.queue_draw();
}

26 changes: 13 additions & 13 deletions glscopeclient/Timeline.cpp
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ bool Timeline::on_button_press_event(GdkEventButton* event)
{
m_dragState = DRAG_TIMELINE;
m_dragStartX = event->x;
m_originalTimeOffset = m_group->m_timeOffset;
m_originalTimeOffset = m_group->m_xAxisOffset;
}

return true;
@@ -92,12 +92,12 @@ bool Timeline::on_motion_notify_event(GdkEventMotion* event)
case DRAG_TIMELINE:
{
double dx = event->x - m_dragStartX;
double ps = dx / m_group->m_pixelsPerPicosecond;
double ps = dx / m_group->m_pixelsPerXUnit;

//Update offset, but don't allow scrolling before the start of the capture
m_group->m_timeOffset = m_originalTimeOffset - ps;
if(m_group->m_timeOffset < 0)
m_group->m_timeOffset = 0;
m_group->m_xAxisOffset = m_originalTimeOffset - ps;
if(m_group->m_xAxisOffset < 0)
m_group->m_xAxisOffset = 0;

//Clear persistence and redraw the group (fixes #46)
m_group->GetParent()->ClearPersistence(m_group, false);
@@ -189,7 +189,7 @@ void Timeline::Render(const Cairo::RefPtr<Cairo::Context>& cr, Unit xAxisUnit)
double ymid = (h-10) / 2;

//Figure out rounding granularity, based on our time scales
int64_t width_ps = w / m_group->m_pixelsPerPicosecond;
int64_t width_ps = w / m_group->m_pixelsPerXUnit;
int64_t round_divisor = 1;
if(width_ps < 1E4)
{
@@ -223,7 +223,7 @@ void Timeline::Render(const Cairo::RefPtr<Cairo::Context>& cr, Unit xAxisUnit)

//Figure out about how much time per graduation to use
const double min_label_grad_width = 100; //Minimum distance between text labels, in pixels
double grad_ps_nominal = min_label_grad_width / m_group->m_pixelsPerPicosecond;
double grad_ps_nominal = min_label_grad_width / m_group->m_pixelsPerXUnit;

//Round so the division sizes are sane
double units_per_grad = grad_ps_nominal * 1.0 / round_divisor;
@@ -238,7 +238,7 @@ void Timeline::Render(const Cairo::RefPtr<Cairo::Context>& cr, Unit xAxisUnit)
double subtick = grad_ps_rounded / nsubticks;

//Find the start time (rounded down as needed)
double tstart = floor(m_group->m_timeOffset / grad_ps_rounded) * grad_ps_rounded;
double tstart = floor(m_group->m_xAxisOffset / grad_ps_rounded) * grad_ps_rounded;

//Print tick marks and labels
Glib::RefPtr<Pango::Layout> tlayout = Pango::Layout::create (cr);
@@ -249,12 +249,12 @@ void Timeline::Render(const Cairo::RefPtr<Cairo::Context>& cr, Unit xAxisUnit)
int sheight;
for(double t = tstart; t < (tstart + width_ps + grad_ps_rounded); t += grad_ps_rounded)
{
double x = (t - m_group->m_timeOffset) * m_group->m_pixelsPerPicosecond;
double x = (t - m_group->m_xAxisOffset) * m_group->m_pixelsPerXUnit;

//Draw fine ticks first (even if the labeled graduation doesn't fit)
for(int tick=1; tick < nsubticks; tick++)
{
double subx = (t - m_group->m_timeOffset + tick*subtick) * m_group->m_pixelsPerPicosecond;
double subx = (t - m_group->m_xAxisOffset + tick*subtick) * m_group->m_pixelsPerXUnit;

if(subx < 0)
continue;
@@ -296,8 +296,8 @@ void Timeline::Render(const Cairo::RefPtr<Cairo::Context>& cr, Unit xAxisUnit)
if(m_group->m_cursorConfig == WaveformGroup::CURSOR_X_DUAL)
{
//Draw filled area between them
double x = (m_group->m_xCursorPos[0] - m_group->m_timeOffset) * m_group->m_pixelsPerPicosecond;
double x2 = (m_group->m_xCursorPos[1] - m_group->m_timeOffset) * m_group->m_pixelsPerPicosecond;
double x = (m_group->m_xCursorPos[0] - m_group->m_xAxisOffset) * m_group->m_pixelsPerXUnit;
double x2 = (m_group->m_xCursorPos[1] - m_group->m_xAxisOffset) * m_group->m_pixelsPerXUnit;
cr->set_source_rgba(yellow.get_red_p(), yellow.get_green_p(), yellow.get_blue_p(), 0.2);
cr->move_to(x, 0);
cr->line_to(x2, 0);
@@ -384,7 +384,7 @@ void Timeline::DrawCursor(
tlayout->get_pixel_size(swidth, sheight);

//Decide which side of the line to draw on
double x = (ps - m_group->m_timeOffset) * m_group->m_pixelsPerPicosecond;
double x = (ps - m_group->m_xAxisOffset) * m_group->m_pixelsPerXUnit;
double right = x-5;
double left = right - swidth - 5;
if(!draw_left)
8 changes: 4 additions & 4 deletions glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -301,10 +301,10 @@ class WaveformArea : public Gtk::GLArea
float VoltsToYPosition(float volt);
float YPositionToVolts(float y);
float DbToYPosition(float db);
int64_t PixelsToPicoseconds(float pix);
float PicosecondsToPixels(int64_t t);
float PicosecondsToXPosition(int64_t t);
int64_t XPositionToPicoseconds(float pix);
int64_t XPositionToXAxisUnits(float pix);
int64_t PixelsToXAxisUnits(float pix);
float XAxisUnitsToPixels(int64_t t);
float XAxisUnitsToXPosition(int64_t t);

void OnRemoveOverlay(ProtocolDecoder* decode);

12 changes: 6 additions & 6 deletions glscopeclient/WaveformArea_events.cpp
Original file line number Diff line number Diff line change
@@ -223,7 +223,7 @@ bool WaveformArea::on_button_press_event(GdkEventButton* event)
}

//Look up the time of our click (if in the plot area)
int64_t timestamp = XPositionToPicoseconds(event->x);
int64_t timestamp = XPositionToXAxisUnits(event->x);

if(event->type == GDK_BUTTON_PRESS)
OnSingleClick(event, timestamp);
@@ -362,7 +362,7 @@ void WaveformArea::OnDoubleClick(GdkEventButton* /*event*/, int64_t /*timestamp*

bool WaveformArea::on_button_release_event(GdkEventButton* event)
{
int64_t timestamp = XPositionToPicoseconds(event->x);
int64_t timestamp = XPositionToXAxisUnits(event->x);

switch(m_dragState)
{
@@ -400,7 +400,7 @@ bool WaveformArea::on_motion_notify_event(GdkEventMotion* event)
m_cursorX = event->x;
m_cursorY = event->y;

int64_t timestamp = XPositionToPicoseconds(event->x);
int64_t timestamp = XPositionToXAxisUnits(event->x);

switch(m_dragState)
{
@@ -539,7 +539,7 @@ void WaveformArea::OnProtocolDecode(string name)
{
fall->SetWidth(m_width);
fall->SetHeight(m_height);
fall->SetTimeScale(m_group->m_pixelsPerPicosecond);
fall->SetTimeScale(m_group->m_pixelsPerXUnit);
}

//Run the decoder for the first time, so we get valid output even if there's not a trigger pending.
@@ -609,8 +609,8 @@ void WaveformArea::OnWaveformDataReady()
{
//eye is two UIs wide
int64_t eye_width_ps = 2 * eye->GetUIWidth();
m_group->m_pixelsPerPicosecond = m_width * 1.0f / eye_width_ps;
m_group->m_timeOffset = -eye->GetUIWidth();
m_group->m_pixelsPerXUnit = m_width * 1.0f / eye_width_ps;
m_group->m_xAxisOffset = -eye->GetUIWidth();
}

//Update our measurements and redraw the waveform
36 changes: 18 additions & 18 deletions glscopeclient/WaveformArea_rendering.cpp
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ bool WaveformArea::PrepareGeometry()
if(!pdat)
return false;
AnalogCapture& data = *pdat;
m_xoff = (pdat->m_triggerPhase - m_group->m_timeOffset) * m_group->m_pixelsPerPicosecond;
m_xoff = (pdat->m_triggerPhase - m_group->m_xAxisOffset) * m_group->m_pixelsPerXUnit;
size_t count = data.size();
if(count == 0)
return false;
@@ -75,7 +75,7 @@ bool WaveformArea::PrepareGeometry()

//Create the geometry
double offset = m_channel->GetOffset();
double xscale = pdat->m_timescale * m_group->m_pixelsPerPicosecond;
double xscale = pdat->m_timescale * m_group->m_pixelsPerXUnit;
bool fft = IsFFT();

size_t waveform_size = count * 12; //3 points * 2 triangles * 2 coordinates
@@ -307,8 +307,8 @@ void WaveformArea::RenderWaterfall()
return;

//Make sure timebase is correct
pfall->SetTimeScale(m_group->m_pixelsPerPicosecond);
pfall->SetTimeOffset(m_group->m_timeOffset);
pfall->SetTimeScale(m_group->m_pixelsPerXUnit);
pfall->SetTimeOffset(m_group->m_xAxisOffset);

//Just copy it directly into the waveform texture.
m_eyeTexture.Bind();
@@ -482,24 +482,24 @@ void WaveformArea::RenderBackgroundGradient(Cairo::RefPtr< Cairo::Context > cr)
cr->fill();
}

int64_t WaveformArea::XPositionToPicoseconds(float pix)
int64_t WaveformArea::XPositionToXAxisUnits(float pix)
{
return m_group->m_timeOffset + PixelsToPicoseconds(pix);
return m_group->m_xAxisOffset + PixelsToXAxisUnits(pix);
}

int64_t WaveformArea::PixelsToPicoseconds(float pix)
int64_t WaveformArea::PixelsToXAxisUnits(float pix)
{
return pix / m_group->m_pixelsPerPicosecond;
return pix / m_group->m_pixelsPerXUnit;
}

float WaveformArea::PicosecondsToPixels(int64_t t)
float WaveformArea::XAxisUnitsToPixels(int64_t t)
{
return t * m_group->m_pixelsPerPicosecond;
return t * m_group->m_pixelsPerXUnit;
}

float WaveformArea::PicosecondsToXPosition(int64_t t)
float WaveformArea::XAxisUnitsToXPosition(int64_t t)
{
return PicosecondsToPixels(t - m_group->m_timeOffset);
return XAxisUnitsToPixels(t - m_group->m_xAxisOffset);
}

float WaveformArea::PixelsToVolts(float pix)
@@ -826,8 +826,8 @@ void WaveformArea::RenderDecodeOverlays(Cairo::RefPtr< Cairo::Context > cr)
double start = (data->GetSampleStart(i) * data->m_timescale) + data->m_triggerPhase;
double end = start + (data->GetSampleLen(i) * data->m_timescale);

double xs = PicosecondsToXPosition(start);
double xe = PicosecondsToXPosition(end);
double xs = XAxisUnitsToXPosition(start);
double xe = XAxisUnitsToXPosition(end);

if( (xe < textright) || (xs > m_plotRight) )
continue;
@@ -859,8 +859,8 @@ void WaveformArea::RenderDecodeOverlays(Cairo::RefPtr< Cairo::Context > cr)
double start = (data->GetSampleStart(i) * data->m_timescale) + data->m_triggerPhase;
double end = start + (data->GetSampleLen(i) * data->m_timescale);

double xs = PicosecondsToXPosition(start);
double xe = PicosecondsToXPosition(end);
double xs = XAxisUnitsToXPosition(start);
double xe = XAxisUnitsToXPosition(end);

if( (xe < textright) || (xs > m_plotRight) )
continue;
@@ -1009,7 +1009,7 @@ void WaveformArea::RenderCursors(Cairo::RefPtr< Cairo::Context > cr)
(m_group->m_cursorConfig == WaveformGroup::CURSOR_X_SINGLE) )
{
//Draw first vertical cursor
double x = PicosecondsToXPosition(m_group->m_xCursorPos[0]);
double x = XAxisUnitsToXPosition(m_group->m_xCursorPos[0]);
cr->move_to(x, ytop);
cr->line_to(x, ybot);
cr->set_source_rgb(yellow.get_red_p(), yellow.get_green_p(), yellow.get_blue_p());
@@ -1019,7 +1019,7 @@ void WaveformArea::RenderCursors(Cairo::RefPtr< Cairo::Context > cr)
if(m_group->m_cursorConfig == WaveformGroup::CURSOR_X_DUAL)
{
//Draw second vertical cursor
double x2 = PicosecondsToXPosition(m_group->m_xCursorPos[1]);
double x2 = XAxisUnitsToXPosition(m_group->m_xCursorPos[1]);
cr->move_to(x2, ytop);
cr->line_to(x2, ybot);
cr->set_source_rgb(orange.get_red_p(), orange.get_green_p(), orange.get_blue_p());
4 changes: 2 additions & 2 deletions glscopeclient/WaveformGroup.cpp
Original file line number Diff line number Diff line change
@@ -42,8 +42,8 @@ int WaveformGroup::m_numGroups = 1;

WaveformGroup::WaveformGroup(OscilloscopeWindow* parent)
: m_timeline(parent, this)
, m_pixelsPerPicosecond(0.05)
, m_timeOffset(0)
, m_pixelsPerXUnit(0.05)
, m_xAxisOffset(0)
, m_cursorConfig(CURSOR_NONE)
, m_parent(parent)
{
4 changes: 2 additions & 2 deletions glscopeclient/WaveformGroup.h
Original file line number Diff line number Diff line change
@@ -75,8 +75,8 @@ class WaveformGroup
Gtk::Menu m_contextMenu;
Gtk::MenuItem m_removeMeasurementItem;

float m_pixelsPerPicosecond;
int64_t m_timeOffset;
float m_pixelsPerXUnit;
int64_t m_xAxisOffset;

enum CursorConfig
{