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: e28a7493bd00
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: e83413e2d12b
Choose a head ref
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Aug 20, 2020

  1. Bugfixes to PickStepSize()

    azonenberg committed Aug 20, 2020

    Unverified

    This user has not yet uploaded their public signing key.
    Copy the full SHA
    4d68932 View commit details
  2. Copy the full SHA
    e83413e View commit details
28 changes: 24 additions & 4 deletions src/glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -1773,15 +1773,35 @@ void OscilloscopeWindow::OnAutofitHorizontal()
//
}

void OscilloscopeWindow::OnZoomInHorizontal(WaveformGroup* group)
/**
@brief Zoom in, keeping timestamp "target" at the same position within the group
*/
void OscilloscopeWindow::OnZoomInHorizontal(WaveformGroup* group, int64_t target)
{
group->m_pixelsPerXUnit *= 1.5;
//Calculate the *current* position of the target within the window
float delta = target - group->m_xAxisOffset;

//Change the zoom
float step = 1.5;
group->m_pixelsPerXUnit *= step;
group->m_xAxisOffset = target - (delta/step);

ClearPersistence(group);
}

void OscilloscopeWindow::OnZoomOutHorizontal(WaveformGroup* group)
/**
@brief Zoom out, keeping timestamp "target" at the same position within the group
*/
void OscilloscopeWindow::OnZoomOutHorizontal(WaveformGroup* group, int64_t target)
{
group->m_pixelsPerXUnit /= 1.5;
//Calculate the *current* position of the target within the window
float delta = target - group->m_xAxisOffset;

//Change the zoom
float step = 1.5;
group->m_pixelsPerXUnit /= step;
group->m_xAxisOffset = target - (delta*step);

ClearPersistence(group);
}

4 changes: 2 additions & 2 deletions src/glscopeclient/OscilloscopeWindow.h
Original file line number Diff line number Diff line change
@@ -54,8 +54,8 @@ class OscilloscopeWindow : public Gtk::Window
~OscilloscopeWindow();

void OnAutofitHorizontal();
void OnZoomInHorizontal(WaveformGroup* group);
void OnZoomOutHorizontal(WaveformGroup* group);
void OnZoomInHorizontal(WaveformGroup* group, int64_t target);
void OnZoomOutHorizontal(WaveformGroup* group, int64_t target);
void ClearPersistence(WaveformGroup* group, bool dirty = true);
void ClearAllPersistence();

10 changes: 6 additions & 4 deletions src/glscopeclient/Timeline.cpp
Original file line number Diff line number Diff line change
@@ -124,20 +124,22 @@ bool Timeline::on_motion_notify_event(GdkEventMotion* event)

bool Timeline::on_scroll_event (GdkEventScroll* ev)
{
int64_t timestamp = (ev->x / m_group->m_pixelsPerXUnit) + m_group->m_xAxisOffset;

switch(ev->direction)
{
case GDK_SCROLL_LEFT:
m_parent->OnZoomInHorizontal(m_group);
m_parent->OnZoomInHorizontal(m_group, timestamp);
break;
case GDK_SCROLL_RIGHT:
m_parent->OnZoomOutHorizontal(m_group);
m_parent->OnZoomOutHorizontal(m_group, timestamp);
break;

case GDK_SCROLL_SMOOTH:
if(ev->delta_y < 0)
m_parent->OnZoomInHorizontal(m_group);
m_parent->OnZoomInHorizontal(m_group, timestamp);
else
m_parent->OnZoomOutHorizontal(m_group);
m_parent->OnZoomOutHorizontal(m_group, timestamp);
break;

default:
6 changes: 3 additions & 3 deletions src/glscopeclient/WaveformArea_cairo.cpp
Original file line number Diff line number Diff line change
@@ -152,6 +152,9 @@ void WaveformArea::RenderGrid(Cairo::RefPtr< Cairo::Context > cr)
else
gridmap[vp] = yt;

if(gridmap.size() > 50)
break;

//Stop if we're off the edge
if( (yb > ytop) && (yt < ybot) )
break;
@@ -163,9 +166,6 @@ void WaveformArea::RenderGrid(Cairo::RefPtr< Cairo::Context > cr)
cr->line_to(m_plotRight, VoltsToYPosition(0));
cr->stroke();

if(gridmap.size() > 50)
LogFatal("gridmap way too big (%zu)\n", gridmap.size());

//Dimmed lines above and below
cr->set_source_rgba(0.7, 0.7, 0.7, 0.25);
for(auto it : gridmap)
8 changes: 2 additions & 6 deletions src/glscopeclient/WaveformArea_events.cpp
Original file line number Diff line number Diff line change
@@ -120,16 +120,12 @@ bool WaveformArea::on_scroll_event (GdkEventScroll* ev)
switch(ev->direction)
{
case GDK_SCROLL_UP:
{
//TODO: zoom to center
}

if(!IsEyeOrBathtub())
m_parent->OnZoomInHorizontal(m_group);
m_parent->OnZoomInHorizontal(m_group, XPositionToXAxisUnits(ev->x));
break;
case GDK_SCROLL_DOWN:
if(!IsEyeOrBathtub())
m_parent->OnZoomOutHorizontal(m_group);
m_parent->OnZoomOutHorizontal(m_group, XPositionToXAxisUnits(ev->x));
break;
case GDK_SCROLL_LEFT:
LogDebug("scroll left\n");
74 changes: 14 additions & 60 deletions src/glscopeclient/WaveformArea_rendering.cpp
Original file line number Diff line number Diff line change
@@ -767,69 +767,23 @@ float WaveformArea::YPositionToVolts(float y)

float WaveformArea::PickStepSize(float volts_per_half_span, int min_steps, int max_steps)
{
static const float step_sizes[]=
{
//mV per div
0.001,
0.0025,
0.005,

0.01,
0.025,
0.05,

0.1,
0.25,
0.5,

1,
2.5,
5,

10,
25,
50,

100,
250,
500,

1000,
2500,
5000,

1.0e4,
2.5e4,
5.0e4,
static const float steps[3] = {1, 2, 5};

1.0e5,
2.5e5,
5.0e5,

1.0e6,
2.5e6,
5.0e6,

1.0e7,
2.5e7,
5.0e7,

1.0e8,
2.5e8,
5.0e8
};

for(size_t i=0; i<sizeof(step_sizes)/sizeof(step_sizes[0]); i++)
for(int exp = -4; exp < 12; exp ++)
{
float step = step_sizes[i];
float steps_per_half_span = volts_per_half_span / step;
if(steps_per_half_span > max_steps)
continue;
if(steps_per_half_span < min_steps)
continue;
return step;
for(int i=0; i<3; i++)
{
float step = pow(10, exp) * steps[i];

float steps_per_half_span = volts_per_half_span / step;
if(steps_per_half_span > max_steps)
continue;
if(steps_per_half_span < min_steps)
continue;
return step;
}
}

//if no hits
return 1;
return FLT_MAX;
}