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: b4a9e948a119
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: 828cc897f92c
Choose a head ref
  • 1 commit
  • 4 files changed
  • 1 contributor

Commits on Mar 4, 2020

  1. Copy the full SHA
    828cc89 View commit details
Showing with 65 additions and 30 deletions.
  1. +13 −3 glscopeclient/OscilloscopeWindow.cpp
  2. +1 −1 glscopeclient/WaveformArea.h
  3. +32 −24 glscopeclient/WaveformArea_cairo.cpp
  4. +19 −2 glscopeclient/WaveformArea_rendering.cpp
16 changes: 13 additions & 3 deletions glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -323,7 +323,10 @@ void OscilloscopeWindow::CreateWidgets()
this);
w->m_group = group;
m_waveformAreas.emplace(w);
group->m_waveformBox.pack_start(*w);
if(type == OscilloscopeChannel::CHANNEL_TYPE_DIGITAL)
group->m_waveformBox.pack_start(*w, Gtk::PACK_SHRINK);
else
group->m_waveformBox.pack_start(*w);
}
}
}
@@ -875,7 +878,11 @@ void OscilloscopeWindow::OnMoveToExistingGroup(WaveformArea* w, WaveformGroup* n
{
w->m_group = ngroup;
w->get_parent()->remove(*w);
ngroup->m_waveformBox.pack_start(*w);

if(w->GetChannel()->GetType() == OscilloscopeChannel::CHANNEL_TYPE_DIGITAL)
ngroup->m_waveformBox.pack_start(*w, Gtk::PACK_SHRINK);
else
ngroup->m_waveformBox.pack_start(*w);

//TODO: move any measurements related to this trace to the new group?

@@ -902,7 +909,10 @@ void OscilloscopeWindow::OnCopyToExistingGroup(WaveformArea* w, WaveformGroup* n

//Then add it like normal
nw->m_group = ngroup;
ngroup->m_waveformBox.pack_start(*nw);
if(nw->GetChannel()->GetType() == OscilloscopeChannel::CHANNEL_TYPE_DIGITAL)
ngroup->m_waveformBox.pack_start(*nw, Gtk::PACK_SHRINK);
else
ngroup->m_waveformBox.pack_start(*nw);
nw->show();
}

2 changes: 1 addition & 1 deletion glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -316,7 +316,7 @@ class WaveformArea : public Gtk::GLArea
int bottom,
std::string text,
Rect& box,
int labelmargin = 6);
int labelmargin = 3);

void ResetTextureFiltering();

56 changes: 32 additions & 24 deletions glscopeclient/WaveformArea_cairo.cpp
Original file line number Diff line number Diff line change
@@ -416,35 +416,43 @@ void WaveformArea::RenderDecodeOverlays(Cairo::RefPtr< Cairo::Context > cr)

void WaveformArea::RenderChannelLabel(Cairo::RefPtr< Cairo::Context > cr)
{
//Add sample rate info to physical channels
//Add sample rate info to physical analog channels
//TODO: do this to some decodes too?
string label = m_channel->m_displayname;
auto data = m_channel->GetData();
if(m_channel->IsPhysicalChannel() && (data != NULL) )
if(m_channel->IsPhysicalChannel() && (data != NULL))
{
label += " : ";

//Format sample depth
char tmp[256];
size_t len = data->GetDepth();
if(len > 1e6)
snprintf(tmp, sizeof(tmp), "%.0f MS", len * 1e-6f);
else if(len > 1e3)
snprintf(tmp, sizeof(tmp), "%.0f kS", len * 1e-3f);
else
snprintf(tmp, sizeof(tmp), "%zu S", len);
label += tmp;
label += "\n";

//Format timebase
double gsps = 1000.0f / data->m_timescale;
if(gsps > 1)
snprintf(tmp, sizeof(tmp), "%.0f GS/s", gsps);
else if(gsps > 0.001)
snprintf(tmp, sizeof(tmp), "%.0f MS/s", gsps * 1000);
//Do not render sample rate on digital signals unless we have overlays, because this ~doubles the height
//of the channel and hurts packing density.
if( (m_channel->GetType() == OscilloscopeChannel::CHANNEL_TYPE_DIGITAL) && m_overlays.empty() )
{}

else
snprintf(tmp, sizeof(tmp), "%.1f kS/s", gsps * 1000 * 1000);
label += tmp;
{
label += " : ";

//Format sample depth
char tmp[256];
size_t len = data->GetDepth();
if(len > 1e6)
snprintf(tmp, sizeof(tmp), "%.0f MS", len * 1e-6f);
else if(len > 1e3)
snprintf(tmp, sizeof(tmp), "%.0f kS", len * 1e-3f);
else
snprintf(tmp, sizeof(tmp), "%zu S", len);
label += tmp;
label += "\n";

//Format timebase
double gsps = 1000.0f / data->m_timescale;
if(gsps > 1)
snprintf(tmp, sizeof(tmp), "%.0f GS/s", gsps);
else if(gsps > 0.001)
snprintf(tmp, sizeof(tmp), "%.0f MS/s", gsps * 1000);
else
snprintf(tmp, sizeof(tmp), "%.1f kS/s", gsps * 1000 * 1000);
label += tmp;
}
}

//Do the actual drawing
21 changes: 19 additions & 2 deletions glscopeclient/WaveformArea_rendering.cpp
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ void WaveformArea::PrepareGeometry(WaveformRenderData* wdata)
{
//Main channel
if(channel == m_channel)
ybase = 5;
ybase = 2;

//Overlay
else
@@ -113,6 +113,8 @@ void WaveformArea::PrepareGeometry(WaveformRenderData* wdata)
size_t realcount = count;
count *= 2;

float digheight = m_height - 5;

traceBuffer.resize(count*2);
indexBuffer.resize(m_width);
#pragma omp parallel for num_threads(8)
@@ -121,7 +123,7 @@ void WaveformArea::PrepareGeometry(WaveformRenderData* wdata)
traceBuffer[j*4] = pdat->GetSampleStart(j) * xscale + xoff;
traceBuffer[j*4 + 2] = pdat->GetSampleEnd(j) * xscale + xoff - 1;

float y = ybase + 5 + ( (*digdat)[j] ? 20: 0 );
float y = ybase + ( (*digdat)[j] ? digheight: 0 );
traceBuffer[j*4 + 1] = y;
traceBuffer[j*4 + 3] = y;
}
@@ -299,6 +301,21 @@ bool WaveformArea::on_render(const Glib::RefPtr<Gdk::GLContext>& /*context*/)
dt = GetTime() - start;
m_renderTime += dt;

//If our channel is digital, set us to minimal size
if(m_channel->GetType() == OscilloscopeChannel::CHANNEL_TYPE_DIGITAL)
{
//Base height
int height = m_infoBoxRect.get_bottom() - m_infoBoxRect.get_top() + 5;

//Add in overlays (TODO: don't hard code overlay pitch)
height += 30*m_overlays.size();

int rw, rh;
get_size_request(rw, rh);
if(height != rh)
set_size_request(30, height);
}

return true;
}