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: 3273292096a6
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: 01ef2ea256be
Choose a head ref
  • 1 commit
  • 5 files changed
  • 1 contributor

Commits on Mar 14, 2020

  1. Implemented window and waveform area loading. Still can't SEE anythin…

    …g as we have no groups or splitters. See #3.
    azonenberg committed Mar 14, 2020
    Copy the full SHA
    01ef2ea View commit details
Showing with 36 additions and 28 deletions.
  1. +16 −13 glscopeclient/OscilloscopeWindow.cpp
  2. +0 −3 glscopeclient/WaveformArea.cpp
  3. +10 −2 glscopeclient/WaveformArea.h
  4. +2 −2 glscopeclient/WaveformArea_cairo.cpp
  5. +8 −8 glscopeclient/WaveformArea_events.cpp
29 changes: 16 additions & 13 deletions glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -319,10 +319,7 @@ void OscilloscopeWindow::CreateWidgets()
if( (type == OscilloscopeChannel::CHANNEL_TYPE_ANALOG) ||
(type == OscilloscopeChannel::CHANNEL_TYPE_DIGITAL) )
{
auto w = new WaveformArea(
scope,
chan,
this);
auto w = new WaveformArea(chan, this);
w->m_group = group;
m_waveformAreas.emplace(w);
if(type == OscilloscopeChannel::CHANNEL_TYPE_DIGITAL)
@@ -582,10 +579,20 @@ void OscilloscopeWindow::LoadUIConfiguration(const YAML::Node& node, IDTable& ta
resize(wnode["width"].as<int>(), wnode["height"].as<int>());

//Waveform areas
auto anode = node["areas"];
for(auto it : anode)
auto areas = node["areas"];
for(auto it : areas)
{

//Load the area itself
auto an = it.second;
WaveformArea* area = new WaveformArea(static_cast<OscilloscopeChannel*>(table[an["channel"].as<int>()]), this);
table.emplace(an["id"].as<int>(), area);
area->SetPersistenceEnabled(an["persistence"].as<int>() ? true : false);
m_waveformAreas.emplace(area);

//Add any overlays
auto overlays = an["overlays"];
for(auto jt : overlays)
area->AddOverlay(static_cast<ProtocolDecoder*>(table[jt.second["id"].as<int>()]));
}
}

@@ -797,10 +804,9 @@ string OscilloscopeWindow::SerializeUIConfiguration(IDTable& table)
table.emplace(area);
for(auto area : m_waveformAreas)
{
int id = table[area];
snprintf(tmp, sizeof(tmp), " : \n");
config += tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", id);
snprintf(tmp, sizeof(tmp), " id: %d\n", table[area]);
config += tmp;
snprintf(tmp, sizeof(tmp), " persistence: %d\n", area->GetPersistenceEnabled());
config += tmp;
@@ -1178,10 +1184,7 @@ WaveformArea* OscilloscopeWindow::DoAddChannel(OscilloscopeChannel* chan, Wavefo
AddDecoder(decode);

//Create the viewer
auto w = new WaveformArea(
chan->GetScope(),
chan,
this);
auto w = new WaveformArea(chan, this);
w->m_group = ngroup;
m_waveformAreas.emplace(w);

3 changes: 0 additions & 3 deletions glscopeclient/WaveformArea.cpp
Original file line number Diff line number Diff line change
@@ -43,12 +43,10 @@ using namespace std;
using namespace glm;

WaveformArea::WaveformArea(
Oscilloscope* scope,
OscilloscopeChannel* channel,
OscilloscopeWindow* parent
)
: m_persistence(false)
, m_scope(scope)
, m_channel(channel)
, m_parent(parent)
, m_pixelsPerVolt(1)
@@ -63,7 +61,6 @@ WaveformArea::WaveformArea(
*/
WaveformArea::WaveformArea(const WaveformArea* clone)
: m_persistence(clone->m_persistence)
, m_scope(clone->m_scope)
, m_channel(clone->m_channel)
, m_parent(clone->m_parent)
, m_pixelsPerVolt(clone->m_pixelsPerVolt)
12 changes: 10 additions & 2 deletions glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ class OscilloscopeWindow;
class WaveformArea : public Gtk::GLArea
{
public:
WaveformArea(Oscilloscope* scope, OscilloscopeChannel* channel, OscilloscopeWindow* parent);
WaveformArea(OscilloscopeChannel* channel, OscilloscopeWindow* parent);
WaveformArea(const WaveformArea* clone);
virtual ~WaveformArea();

@@ -146,6 +146,15 @@ class WaveformArea : public Gtk::GLArea
bool GetPersistenceEnabled()
{ return m_persistence; }

void SetPersistenceEnabled(bool enabled)
{ m_persistence = enabled; }

void AddOverlay(ProtocolDecoder* decode)
{
decode->AddRef();
m_overlays.push_back(decode);
}

protected:
void SharedCtorInit();

@@ -342,7 +351,6 @@ class WaveformArea : public Gtk::GLArea

void OnRemoveOverlay(ProtocolDecoder* decode);

Oscilloscope* m_scope;
OscilloscopeChannel* m_channel; //The main waveform for this view
OscilloscopeChannel* m_selectedChannel; //The selected channel (either m_channel or an overlay)
OscilloscopeWindow* m_parent;
4 changes: 2 additions & 2 deletions glscopeclient/WaveformArea_cairo.cpp
Original file line number Diff line number Diff line change
@@ -206,9 +206,9 @@ void WaveformArea::RenderGrid(Cairo::RefPtr< Cairo::Context > cr)
cr->begin_new_path();

//See if we're the active trigger
if( (m_scope != NULL) && (m_channel->GetIndex() == m_scope->GetTriggerChannelIndex()) )
if(m_channel->GetIndex() == m_channel->GetScope()->GetTriggerChannelIndex())
{
float v = m_scope->GetTriggerVoltage();
float v = m_channel->GetScope()->GetTriggerVoltage();
float y = VoltsToYPosition(v);

float trisize = 5;
16 changes: 8 additions & 8 deletions glscopeclient/WaveformArea_events.cpp
Original file line number Diff line number Diff line change
@@ -340,7 +340,7 @@ bool WaveformArea::on_button_release_event(GdkEventButton* event)
case DRAG_TRIGGER:
if(event->button == 1)
{
m_scope->SetTriggerVoltage(YPositionToVolts(event->y));
m_channel->GetScope()->SetTriggerVoltage(YPositionToVolts(event->y));
m_parent->ClearAllPersistence();
queue_draw();
}
@@ -376,7 +376,7 @@ bool WaveformArea::on_motion_notify_event(GdkEventMotion* event)
{
//Trigger drag - update level and refresh
case DRAG_TRIGGER:
m_scope->SetTriggerVoltage(YPositionToVolts(event->y));
m_channel->GetScope()->SetTriggerVoltage(YPositionToVolts(event->y));
m_parent->ClearAllPersistence();
queue_draw();
break;
@@ -569,8 +569,8 @@ void WaveformArea::OnTriggerMode(Oscilloscope::TriggerType type, Gtk::RadioMenuI
if(m_updatingContextMenu || !item->get_active())
return;

m_scope->SetTriggerChannelIndex(m_channel->GetIndex());
m_scope->SetTriggerType(type);
m_channel->GetScope()->SetTriggerChannelIndex(m_channel->GetIndex());
m_channel->GetScope()->SetTriggerType(type);
m_parent->ClearAllPersistence();
}

@@ -625,9 +625,9 @@ WaveformArea::ClickLocation WaveformArea::HitTest(double x, double y)
if(x > m_plotRight)
{
//On the trigger button?
if((m_scope != NULL) && (m_channel->GetIndex() == m_scope->GetTriggerChannelIndex()) )
if((m_channel->GetScope() != NULL) && (m_channel->GetIndex() == m_channel->GetScope()->GetTriggerChannelIndex()) )
{
float vy = VoltsToYPosition(m_scope->GetTriggerVoltage());
float vy = VoltsToYPosition(m_channel->GetScope()->GetTriggerVoltage());
float radius = 20;
if( (fabs(y - vy) < radius) &&
(x < (m_plotRight + radius) ) )
@@ -804,7 +804,7 @@ void WaveformArea::UpdateContextMenu()
break;
}

if(m_scope->GetTriggerChannelIndex() != m_channel->GetIndex())
if(m_channel->GetScope()->GetTriggerChannelIndex() != m_channel->GetIndex())
{
m_risingTriggerItem.set_inconsistent(true);
m_fallingTriggerItem.set_inconsistent(true);
@@ -824,7 +824,7 @@ void WaveformArea::UpdateContextMenu()
m_fallingTriggerItem.set_draw_as_radio(true);
m_bothTriggerItem.set_draw_as_radio(true);

switch(m_scope->GetTriggerType())
switch(m_channel->GetScope()->GetTriggerType())
{
case Oscilloscope::TRIGGER_TYPE_RISING:
m_risingTriggerItem.set_active();