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: 3f181657069d
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: 1ccb336edad7
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on May 23, 2020

  1. Copy the full SHA
    9572431 View commit details
  2. Copy the full SHA
    1ccb336 View commit details
Showing with 79 additions and 83 deletions.
  1. +18 −18 glscopeclient/Timeline.cpp
  2. +4 −3 glscopeclient/Timeline.h
  3. +56 −62 glscopeclient/WaveformArea_cairo.cpp
  4. +1 −0 glscopeclient/WaveformArea_events.cpp
36 changes: 18 additions & 18 deletions glscopeclient/Timeline.cpp
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ using namespace std;
Timeline::Timeline(OscilloscopeWindow* parent, WaveformGroup* group)
: m_group(group)
, m_parent(parent)
, m_xAxisUnit(Unit::UNIT_PS)
{
m_dragState = DRAG_NONE;
m_dragStartX = 0;
@@ -106,10 +107,13 @@ bool Timeline::on_motion_notify_event(GdkEventMotion* event)
double dx = event->x - m_dragStartX;
double ps = dx / m_group->m_pixelsPerXUnit;

//Update offset, but don't allow scrolling before the start of the capture
//Update offset, but don't allow scrolling before time zero for time domain waveforms
m_group->m_xAxisOffset = m_originalTimeOffset - ps;
if(m_group->m_xAxisOffset < 0)
m_group->m_xAxisOffset = 0;
if(m_xAxisUnit == Unit::UNIT_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);
@@ -177,22 +181,21 @@ bool Timeline::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)

//Figure out the units to use for the axis
auto children = m_group->m_waveformBox.get_children();
Unit unit(Unit::UNIT_PS);
if(!children.empty())
{
auto view = dynamic_cast<WaveformArea*>(children[0]);
if(view != NULL)
unit = view->GetChannel()->GetXAxisUnits();
m_xAxisUnit = view->GetChannel()->GetXAxisUnits();
}

//And actually draw the rest
Render(cr, unit);
Render(cr);

cr->restore();
return true;
}

void Timeline::Render(const Cairo::RefPtr<Cairo::Context>& cr, Unit xAxisUnit)
void Timeline::Render(const Cairo::RefPtr<Cairo::Context>& cr)
{
size_t w = get_width();
size_t h = get_height();
@@ -293,7 +296,7 @@ void Timeline::Render(const Cairo::RefPtr<Cairo::Context>& cr, Unit xAxisUnit)
cr->stroke();

//Render it
tlayout->set_text(xAxisUnit.PrettyPrint(t));
tlayout->set_text(m_xAxisUnit.PrettyPrint(t));
tlayout->get_pixel_size(swidth, sheight);
cr->move_to(x+2, ymid + sheight/2);
tlayout->update_from_cairo_context(cr);
@@ -328,8 +331,7 @@ void Timeline::Render(const Cairo::RefPtr<Cairo::Context>& cr, Unit xAxisUnit)
"X2",
orange,
false,
true,
xAxisUnit);
true);
}

//First cursor
@@ -339,8 +341,7 @@ void Timeline::Render(const Cairo::RefPtr<Cairo::Context>& cr, Unit xAxisUnit)
"X1",
yellow,
true,
false,
xAxisUnit);
false);
}
}

@@ -350,8 +351,7 @@ void Timeline::DrawCursor(
const char* name,
Gdk::Color color,
bool draw_left,
bool show_delta,
Unit xAxisUnit)
bool show_delta)
{
int h = get_height();

@@ -373,7 +373,7 @@ void Timeline::DrawCursor(
sizeof(label),
"%s: %s",
name,
xAxisUnit.PrettyPrint(ps).c_str()
m_xAxisUnit.PrettyPrint(ps).c_str()
);
}
else
@@ -382,7 +382,7 @@ void Timeline::DrawCursor(

//Special case for time domain traces
//Also show the frequency dual
if(xAxisUnit.GetType() == Unit::UNIT_PS)
if(m_xAxisUnit.GetType() == Unit::UNIT_PS)
format += " (%.3f MHz)\n";

int64_t dt = m_group->m_xCursorPos[1] - m_group->m_xCursorPos[0];
@@ -392,8 +392,8 @@ void Timeline::DrawCursor(
sizeof(label),
format.c_str(),
name,
xAxisUnit.PrettyPrint(ps).c_str(),
xAxisUnit.PrettyPrint(dt).c_str(),
m_xAxisUnit.PrettyPrint(ps).c_str(),
m_xAxisUnit.PrettyPrint(dt).c_str(),
1.0e6 / dt);
}
tlayout->set_text(label);
7 changes: 4 additions & 3 deletions glscopeclient/Timeline.h
Original file line number Diff line number Diff line change
@@ -56,19 +56,20 @@ class Timeline : public Gtk::Layout
virtual bool on_motion_notify_event(GdkEventMotion* event);
virtual bool on_scroll_event (GdkEventScroll* ev);

void Render(const Cairo::RefPtr<Cairo::Context>& cr, Unit xAxisUnit);
void Render(const Cairo::RefPtr<Cairo::Context>& cr);

virtual void DrawCursor(
const Cairo::RefPtr<Cairo::Context>& cr,
int64_t ps,
const char* name,
Gdk::Color color,
bool draw_left,
bool show_delta,
Unit xAxisUnit);
bool show_delta);

WaveformGroup* m_group;
OscilloscopeWindow* m_parent;

Unit m_xAxisUnit;
};

#endif
118 changes: 56 additions & 62 deletions glscopeclient/WaveformArea_cairo.cpp
Original file line number Diff line number Diff line change
@@ -568,71 +568,65 @@ void WaveformArea::RenderCursors(Cairo::RefPtr< Cairo::Context > cr)
}

int barsize = 5;
switch(m_dragState)

if(m_insertionBarLocation != INSERT_NONE)
{
//Render the insertion bar, if needed
case DRAG_WAVEFORM_AREA:
if(m_insertionBarLocation != INSERT_NONE)
{
int barpos = 0;
float alpha = 0.75;
bool barhorz = true;
switch(m_insertionBarLocation)
{
case INSERT_BOTTOM:
cr->set_source_rgba(yellow.get_red_p(), yellow.get_green_p(), yellow.get_blue_p(), alpha);
barpos = ybot - barsize;
break;

case INSERT_BOTTOM_SPLIT:
cr->set_source_rgba(orange.get_red_p(), orange.get_green_p(), orange.get_blue_p(), alpha);
barpos = ybot - barsize;
break;

case INSERT_TOP:
cr->set_source_rgba(yellow.get_red_p(), yellow.get_green_p(), yellow.get_blue_p(), alpha);
barpos = 0;
break;

case INSERT_RIGHT_SPLIT:
cr->set_source_rgba(orange.get_red_p(), orange.get_green_p(), orange.get_blue_p(), alpha);
barhorz = false;
barpos = m_plotRight - barsize;
break;

//no bar to draw
default:
break;
}
int barpos = 0;
float alpha = 0.75;
bool barhorz = true;
switch(m_insertionBarLocation)
{
case INSERT_BOTTOM:
cr->set_source_rgba(yellow.get_red_p(), yellow.get_green_p(), yellow.get_blue_p(), alpha);
barpos = ybot - barsize;
break;

if(barhorz)
{
cr->move_to(0, barpos);
cr->line_to(m_width, barpos);
cr->line_to(m_width, barpos + barsize);
cr->line_to(0, barpos + barsize);
}
else
{
cr->move_to(barpos, 0);
cr->line_to(barpos + barsize, 0);
cr->line_to(barpos + barsize, m_height);
cr->line_to(barpos, m_height);
}
cr->fill();
}
break;

case DRAG_OVERLAY:
cr->set_source_rgba(yellow.get_red_p(), yellow.get_green_p(), yellow.get_blue_p(), 0.75);
cr->move_to(0, m_dragOverlayPosition);
cr->line_to(m_plotRight, m_dragOverlayPosition);
cr->line_to(m_plotRight, m_dragOverlayPosition + barsize);
cr->line_to(0, m_dragOverlayPosition + barsize);
cr->fill();
case INSERT_BOTTOM_SPLIT:
cr->set_source_rgba(orange.get_red_p(), orange.get_green_p(), orange.get_blue_p(), alpha);
barpos = ybot - barsize;
break;

case INSERT_TOP:
cr->set_source_rgba(yellow.get_red_p(), yellow.get_green_p(), yellow.get_blue_p(), alpha);
barpos = 0;
break;

default:
break;
case INSERT_RIGHT_SPLIT:
cr->set_source_rgba(orange.get_red_p(), orange.get_green_p(), orange.get_blue_p(), alpha);
barhorz = false;
barpos = m_plotRight - barsize;
break;

//no bar to draw
default:
break;
}

if(barhorz)
{
cr->move_to(0, barpos);
cr->line_to(m_width, barpos);
cr->line_to(m_width, barpos + barsize);
cr->line_to(0, barpos + barsize);
}
else
{
cr->move_to(barpos, 0);
cr->line_to(barpos + barsize, 0);
cr->line_to(barpos + barsize, m_height);
cr->line_to(barpos, m_height);
}
cr->fill();
}

else if(m_dragState == DRAG_OVERLAY)
{
cr->set_source_rgba(yellow.get_red_p(), yellow.get_green_p(), yellow.get_blue_p(), 0.75);
cr->move_to(0, m_dragOverlayPosition);
cr->line_to(m_plotRight, m_dragOverlayPosition);
cr->line_to(m_plotRight, m_dragOverlayPosition + barsize);
cr->line_to(0, m_dragOverlayPosition + barsize);
cr->fill();
}
}

1 change: 1 addition & 0 deletions glscopeclient/WaveformArea_events.cpp
Original file line number Diff line number Diff line change
@@ -481,6 +481,7 @@ bool WaveformArea::on_button_release_event(GdkEventButton* event)
{
m_dropTarget = NULL;
m_dragState = DRAG_NONE;
m_insertionBarLocation = INSERT_NONE;
queue_draw();
}