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: c8541f2d2748
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: 943bb9ebe2f8
Choose a head ref
  • 1 commit
  • 4 files changed
  • 1 contributor

Commits on Oct 31, 2020

  1. Copy the full SHA
    943bb9e View commit details
8 changes: 4 additions & 4 deletions src/glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -389,10 +389,10 @@ class WaveformArea : public Gtk::GLArea
void ResetTextureFiltering();

//Math helpers
float PixelsToVolts(float pix);
float VoltsToPixels(float volt);
float VoltsToYPosition(float volt);
float YPositionToVolts(float y);
float PixelToYAxisUnits(float pix);
float YAxisUnitsToPixels(float volt);
float YAxisUnitsToYPosition(float volt);
float YPositionToYAxisUnits(float y);
int64_t XPositionToXAxisUnits(float pix);
int64_t PixelsToXAxisUnits(float pix);
float XAxisUnitsToPixels(int64_t t);
18 changes: 9 additions & 9 deletions src/glscopeclient/WaveformArea_cairo.cpp
Original file line number Diff line number Diff line change
@@ -116,7 +116,7 @@ void WaveformArea::RenderGrid(Cairo::RefPtr< Cairo::Context > cr)
std::map<float, float> gridmap;

//Volts from the center line of our graph to the top. May not be the max value in the signal.
float volts_per_half_span = PixelsToVolts(halfheight);
float volts_per_half_span = PixelToYAxisUnits(halfheight);

//Decide what voltage step to use. Pick from a list (in volts)
float selected_step = PickStepSize(volts_per_half_span);
@@ -129,16 +129,16 @@ void WaveformArea::RenderGrid(Cairo::RefPtr< Cairo::Context > cr)
float top_edge = (ytop - theight/2);

//Calculate grid positions
float vbot = YPositionToVolts(ybot);
float vtop = YPositionToVolts(ytop);
float vbot = YPositionToYAxisUnits(ybot);
float vtop = YPositionToYAxisUnits(ytop);
float vmid = (vbot + vtop)/2;
for(float dv=0; ; dv += selected_step)
{
float vp = vmid + dv;
float vn = vmid - dv;

float yt = VoltsToYPosition(vp);
float yb = VoltsToYPosition(vn);
float yt = YAxisUnitsToYPosition(vp);
float yb = YAxisUnitsToYPosition(vn);

if(dv != 0)
{
@@ -161,8 +161,8 @@ void WaveformArea::RenderGrid(Cairo::RefPtr< Cairo::Context > cr)

//Center line is solid
cr->set_source_rgba(0.7, 0.7, 0.7, 1.0);
cr->move_to(0, VoltsToYPosition(0));
cr->line_to(m_plotRight, VoltsToYPosition(0));
cr->move_to(0, YAxisUnitsToYPosition(0));
cr->line_to(m_plotRight, YAxisUnitsToYPosition(0));
cr->stroke();

//Dimmed lines above and below
@@ -227,7 +227,7 @@ void WaveformArea::RenderTriggerArrow(
bool dragging,
Gdk::Color color)
{
float y = VoltsToYPosition(voltage);
float y = YAxisUnitsToYPosition(voltage);

float trisize = 5 * GetDPIScale() * get_window()->get_scale_factor();

@@ -1130,7 +1130,7 @@ void WaveformArea::RenderFFTPeaks(Cairo::RefPtr< Cairo::Context > cr)
tlayout->get_pixel_size(twidth, theight);

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

//Don't show labels for offscreen peaks
if( (x < 0) || (x > m_plotRight) )
16 changes: 8 additions & 8 deletions src/glscopeclient/WaveformArea_events.cpp
Original file line number Diff line number Diff line change
@@ -311,7 +311,7 @@ void WaveformArea::OnSingleClick(GdkEventButton* event, int64_t timestamp)
//Left
case 1:
m_dragState = DRAG_OFFSET;
m_dragStartVoltage = YPositionToVolts(event->y);
m_dragStartVoltage = YPositionToYAxisUnits(event->y);
get_window()->set_cursor(Gdk::Cursor::create(get_display(), "grabbing"));
break;

@@ -459,7 +459,7 @@ bool WaveformArea::on_button_release_event(GdkEventButton* event)
{
auto scope = m_channel.m_channel->GetScope();
auto trig = scope->GetTrigger();
trig->SetLevel(YPositionToVolts(event->y));
trig->SetLevel(YPositionToYAxisUnits(event->y));
scope->PushTrigger();
m_parent->ClearAllPersistence();
queue_draw();
@@ -473,7 +473,7 @@ bool WaveformArea::on_button_release_event(GdkEventButton* event)
auto trig = dynamic_cast<TwoLevelTrigger*>(scope->GetTrigger());
if(trig)
{
trig->SetLowerBound(YPositionToVolts(event->y));
trig->SetLowerBound(YPositionToYAxisUnits(event->y));
scope->PushTrigger();
}
m_parent->ClearAllPersistence();
@@ -614,7 +614,7 @@ bool WaveformArea::on_motion_notify_event(GdkEventMotion* event)
{
auto scope = m_channel.m_channel->GetScope();
auto trig = scope->GetTrigger();
trig->SetLevel(YPositionToVolts(event->y));
trig->SetLevel(YPositionToYAxisUnits(event->y));
scope->PushTrigger();
queue_draw();
}
@@ -626,7 +626,7 @@ bool WaveformArea::on_motion_notify_event(GdkEventMotion* event)
auto trig = dynamic_cast<TwoLevelTrigger*>(scope->GetTrigger());
if(trig)
{
trig->SetLowerBound(YPositionToVolts(event->y));
trig->SetLowerBound(YPositionToYAxisUnits(event->y));
scope->PushTrigger();
}
queue_draw();
@@ -674,7 +674,7 @@ bool WaveformArea::on_motion_notify_event(GdkEventMotion* event)
//Offset drag - update level and refresh
case DRAG_OFFSET:
{
double dv = YPositionToVolts(event->y) - m_dragStartVoltage;
double dv = YPositionToYAxisUnits(event->y) - m_dragStartVoltage;
double old_offset = m_channel.m_channel->GetOffset();
m_channel.m_channel->SetOffset(old_offset + dv);
SetGeometryDirty();
@@ -1155,7 +1155,7 @@ WaveformArea::ClickLocation WaveformArea::HitTest(double x, double y)
auto trig = scope->GetTrigger();
if( (trig != NULL) && (m_channel == trig->GetInput(0)) )
{
float vy = VoltsToYPosition(trig->GetLevel());
float vy = YAxisUnitsToYPosition(trig->GetLevel());
float radius = 20;
if(x < (m_plotRight + radius) )
{
@@ -1174,7 +1174,7 @@ WaveformArea::ClickLocation WaveformArea::HitTest(double x, double y)
auto wt = dynamic_cast<TwoLevelTrigger*>(trig);
if(wt)
{
vy = VoltsToYPosition(wt->GetLowerBound());
vy = YAxisUnitsToYPosition(wt->GetLowerBound());
if(x < (m_plotRight + radius) )
{
//If on top of the trigger, obviously we're a hit
12 changes: 6 additions & 6 deletions src/glscopeclient/WaveformArea_rendering.cpp
Original file line number Diff line number Diff line change
@@ -720,24 +720,24 @@ float WaveformArea::XAxisUnitsToXPosition(int64_t t)
return XAxisUnitsToPixels(t - m_group->m_xAxisOffset);
}

float WaveformArea::PixelsToVolts(float pix)
float WaveformArea::PixelToYAxisUnits(float pix)
{
return pix / m_pixelsPerVolt;
}

float WaveformArea::VoltsToPixels(float volt)
float WaveformArea::YAxisUnitsToPixels(float volt)
{
return volt * m_pixelsPerVolt;
}

float WaveformArea::VoltsToYPosition(float volt)
float WaveformArea::YAxisUnitsToYPosition(float volt)
{
return m_height/2 - VoltsToPixels(volt + m_channel.m_channel->GetOffset());
return m_height/2 - YAxisUnitsToPixels(volt + m_channel.m_channel->GetOffset());
}

float WaveformArea::YPositionToVolts(float y)
float WaveformArea::YPositionToYAxisUnits(float y)
{
return PixelsToVolts(-1 * (y - m_height/2) ) - m_channel.m_channel->GetOffset();
return PixelToYAxisUnits(-1 * (y - m_height/2) ) - m_channel.m_channel->GetOffset();
}

float WaveformArea::PickStepSize(float volts_per_half_span, int min_steps, int max_steps)