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: 525c19d433d1
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: b9266a035fd4
Choose a head ref
  • 1 commit
  • 4 files changed
  • 1 contributor

Commits on May 23, 2020

  1. Copy the full SHA
    b9266a0 View commit details
Showing with 156 additions and 54 deletions.
  1. +2 −0 glscopeclient/WaveformArea.cpp
  2. +8 −1 glscopeclient/WaveformArea.h
  3. +67 −52 glscopeclient/WaveformArea_cairo.cpp
  4. +79 −1 glscopeclient/WaveformArea_events.cpp
2 changes: 2 additions & 0 deletions glscopeclient/WaveformArea.cpp
Original file line number Diff line number Diff line change
@@ -88,9 +88,11 @@ void WaveformArea::SharedCtorInit()
m_insertionBarLocation = INSERT_NONE;
m_dropTarget = NULL;
m_padding = 2;
m_overlaySpacing = 30;
m_persistenceClear = true;
m_firstFrame = false;
m_waveformRenderData = NULL;
m_dragOverlayPosition = 0;

m_decodeDialog = NULL;
m_pendingDecode = NULL;
9 changes: 8 additions & 1 deletion glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -402,6 +402,7 @@ class WaveformArea : public Gtk::GLArea
float m_pixelsPerVolt;
float m_padding;
float m_plotRight;
int m_overlaySpacing;

//Positions of various UI elements used by hit testing
Rect m_infoBoxRect;
@@ -423,7 +424,8 @@ class WaveformArea : public Gtk::GLArea
DRAG_TRIGGER,
DRAG_CURSOR,
DRAG_OFFSET,
DRAG_WAVEFORM_AREA
DRAG_WAVEFORM_AREA,
DRAG_OVERLAY
} m_dragState;

//Start voltage of a drag (only used in DRAG_OFFSET mode)
@@ -437,8 +439,13 @@ class WaveformArea : public Gtk::GLArea
INSERT_TOP,
INSERT_RIGHT_SPLIT
} m_insertionBarLocation;

//Destination of a drag (only used in DRAG_WAVEFORM_AREA mode)
WaveformArea* m_dropTarget;

//Destination of a drag (only used in DRAG_OVERLAY mode)
int m_dragOverlayPosition;

bool m_firstFrame;
};

119 changes: 67 additions & 52 deletions glscopeclient/WaveformArea_cairo.cpp
Original file line number Diff line number Diff line change
@@ -258,8 +258,7 @@ void WaveformArea::RenderDecodeOverlays(Cairo::RefPtr< Cairo::Context > cr)
{
//TODO: adjust height/spacing depending on font sizes etc
int height = 20;
int spacing = 30;
int midline = spacing / 2;
int midline = m_overlaySpacing / 2;

//Render digital bus waveforms in the main channel here (TODO: GL stuff)
auto bus = dynamic_cast<DigitalBusWaveform*>(m_channel->GetData());
@@ -342,7 +341,7 @@ void WaveformArea::RenderDecodeOverlays(Cairo::RefPtr< Cairo::Context > cr)
continue;

int pos = m_overlayPositions[o];
int index = (pos - midline) / spacing;
int index = (pos - midline) / m_overlaySpacing;
if( (pos >= 0) && (index < max_overlays) )
overlayPositionsUsed[index] = true;
}
@@ -357,7 +356,7 @@ void WaveformArea::RenderDecodeOverlays(Cairo::RefPtr< Cairo::Context > cr)
if(!overlayPositionsUsed[i])
{
overlayPositionsUsed[i] = true;
m_overlayPositions[o] = midline + spacing*i;
m_overlayPositions[o] = midline + m_overlaySpacing*i;
break;
}
}
@@ -540,6 +539,7 @@ void WaveformArea::RenderCursors(Cairo::RefPtr< Cairo::Context > cr)

Gdk::Color yellow("yellow");
Gdk::Color orange("orange");
Gdk::Color red("red");

if( (m_group->m_cursorConfig == WaveformGroup::CURSOR_X_DUAL) ||
(m_group->m_cursorConfig == WaveformGroup::CURSOR_X_SINGLE) )
@@ -571,57 +571,72 @@ void WaveformArea::RenderCursors(Cairo::RefPtr< Cairo::Context > cr)
}
}

//Render the insertion bar, if needed
if(m_insertionBarLocation != INSERT_NONE)
int barsize = 5;
switch(m_dragState)
{
Gdk::Color red("red");
int barpos = 0;
float alpha = 0.75;
int barsize = 5;
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_width - barsize;
break;
//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;
}

//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();
}
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();

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();
default:
break;
}
}

80 changes: 79 additions & 1 deletion glscopeclient/WaveformArea_events.cpp
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@
#include "ChannelPropertiesDialog.h"
#include "../../lib/scopeprotocols/EyeDecoder2.h"
#include "../../lib/scopeprotocols/WaterfallDecoder.h"
#include <map>

using namespace std;
using namespace glm;
@@ -302,7 +303,9 @@ void WaveformArea::OnSingleClick(GdkEventButton* event, int64_t timestamp)
m_dragState = DRAG_WAVEFORM_AREA;
else
{
// LogDebug("Start dragging overlay (not yet implemented)\n");
m_dragState = DRAG_OVERLAY;
m_dragOverlayPosition =
m_overlayPositions[static_cast<ProtocolDecoder*>(m_selectedChannel)] - 10;
}
break;

@@ -427,6 +430,48 @@ bool WaveformArea::on_button_release_event(GdkEventButton* event)
}
break;

//Move overlay to a new location
case DRAG_OVERLAY:
{
//Sort overlays by position
std::map<int, ProtocolDecoder*> revmap;
vector<int> positions;
for(auto it : m_overlayPositions)
{
revmap[it.second] = it.first;
positions.push_back(it.second);
}
std::sort(positions.begin(), positions.end(), less<int>());

//Make a new, sorted list of decode positions
vector<ProtocolDecoder*> sorted;
bool inserted = false;
for(size_t i=0; i<positions.size(); i++)
{
int pos = positions[i];
if( (pos > m_dragOverlayPosition) && !inserted)
{
sorted.push_back(static_cast<ProtocolDecoder*>(m_selectedChannel));
inserted = true;
}

if(revmap[pos] != m_selectedChannel)
sorted.push_back(revmap[pos]);
}
if(!inserted)
sorted.push_back(static_cast<ProtocolDecoder*>(m_selectedChannel));

//Reposition everything
int pos = m_overlaySpacing / 2;
for(auto d : sorted)
{
m_overlayPositions[d] = pos;
pos += m_overlaySpacing;
}
queue_draw();
}
break;

default:
break;
}
@@ -476,6 +521,39 @@ bool WaveformArea::on_motion_notify_event(GdkEventMotion* event)
}
break;

//Reorder the selected overlay.
//TODO: allow overlays to be moved between waveform areas?
case DRAG_OVERLAY:
{
//See what decoder we're above/below
int maxpos = 0;
ProtocolDecoder* maxover = NULL;
for(auto it : m_overlayPositions)
{
if(event->y > it.second)
{
if(it.second > maxpos)
{
maxpos = it.second;
maxover = it.first;
}
}
}

if(maxover)
{
m_dragOverlayPosition = maxpos + 10;
queue_draw();
}
else
{
m_dragOverlayPosition = 0;
queue_draw();
}

}
break;

//Move this waveform area to a new place
case DRAG_WAVEFORM_AREA:
{