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: db403620b537
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: b9e8bf5fb9b6
Choose a head ref
  • 1 commit
  • 5 files changed
  • 1 contributor

Commits on Mar 15, 2020

  1. Continued work on file loading. Can now load all UI config, but when …

    …waveform area is realized, it hangs during startup. Not yet sure why.
    azonenberg committed Mar 15, 2020
    Copy the full SHA
    b9e8bf5 View commit details
Showing with 89 additions and 16 deletions.
  1. +68 −3 glscopeclient/OscilloscopeWindow.cpp
  2. +6 −10 glscopeclient/ScopeApp.cpp
  3. +2 −2 glscopeclient/ScopeApp.h
  4. +2 −0 glscopeclient/WaveformArea.cpp
  5. +11 −1 glscopeclient/WaveformGroup.cpp
71 changes: 68 additions & 3 deletions glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -471,6 +471,14 @@ void OscilloscopeWindow::DoFileOpen(string filename, bool loadLayout, bool loadW

//Re-title the window for the new scope
SetTitle();

//TODO: load waveform data

//TODO: refresh measurements and protocol decodes

//Start threads to poll scopes etc
g_app->StartScopeThreads();
show_all();
}

/**
@@ -533,6 +541,8 @@ void OscilloscopeWindow::LoadInstruments(const YAML::Node& node, bool reconnect,
m_scopes.push_back(scope);
table.emplace(inst["id"].as<int>(), scope);

//TODO: start ScopeThread's

//Configure the scope
scope->LoadConfiguration(inst, table);
}
@@ -602,7 +612,7 @@ void OscilloscopeWindow::LoadUIConfiguration(const YAML::Node& node, IDTable& ta
//Create the group
auto gn = it.second;
WaveformGroup* group = new WaveformGroup(this);
table.emplace(gn["id"].as<int>(), group);
table.emplace(gn["id"].as<int>(), &group->m_frame);
group->m_measurementFrame.set_label(gn["name"].as<string>());
group->m_pixelsPerXUnit = gn["pixelsPerXUnit"].as<float>();
group->m_xAxisOffset = gn["xAxisOffset"].as<long>();
@@ -648,7 +658,52 @@ void OscilloscopeWindow::LoadUIConfiguration(const YAML::Node& node, IDTable& ta
group->AddColumn(meas, mn["color"].as<string>(), mn["nick"].as<string>());
}
}

//Waveform areas
areas = gn["areas"];
for(auto at : areas)
{
auto area = static_cast<WaveformArea*>(table[at.second["id"].as<int>()]);
area->m_group = group;
if(area->GetChannel()->GetType() == OscilloscopeChannel::CHANNEL_TYPE_DIGITAL)
group->m_waveformBox.pack_start(*area, Gtk::PACK_SHRINK);
else
group->m_waveformBox.pack_start(*area);
}
}

//Splitters
auto splitters = node["splitters"];
for(auto it : splitters)
{
//Create the splitter
auto sn = it.second;
Gtk::Paned* split = NULL;
if(sn["dir"].as<string>() == "h")
split = new Gtk::HPaned;
else
split = new Gtk::VPaned;
m_splitters.emplace(split);
table.emplace(sn["id"].as<int>(), split);
}
for(auto it : splitters)
{
auto sn = it.second;
Gtk::Paned* split = static_cast<Gtk::Paned*>(table[sn["id"].as<int>()]);

auto a = static_cast<Gtk::Widget*>(table[sn["child0"].as<int>()]);
auto b = static_cast<Gtk::Widget*>(table[sn["child1"].as<int>()]);
if(a)
split->pack1(*a);
if(b)
split->pack1(*b);
split->set_position(sn["split"].as<int>());
}

//Add the top level splitter right before the status bar
m_vbox.remove(m_statusbar);
m_vbox.pack_start(*static_cast<Gtk::Paned*>(table[node["top"].as<int>()]), Gtk::PACK_EXPAND_WIDGET);
m_vbox.pack_start(m_statusbar, Gtk::PACK_SHRINK);
}

/**
@@ -891,7 +946,7 @@ string OscilloscopeWindow::SerializeUIConfiguration(IDTable& table)
//Waveform groups
config += " groups: \n";
for(auto group : m_waveformGroups)
table.emplace(group);
table.emplace(&group->m_frame);
for(auto group : m_waveformGroups)
config += group->SerializeConfiguration(table);

@@ -907,7 +962,7 @@ string OscilloscopeWindow::SerializeUIConfiguration(IDTable& table)
snprintf(tmp, sizeof(tmp), " id: %d\n", table[split]);
config += tmp;

if(dynamic_cast<Gtk::HPaned*>(split) != NULL)
if(split->get_orientation() == Gtk::ORIENTATION_HORIZONTAL)
config += " dir: h\n";
else
config += " dir: v\n";
@@ -923,6 +978,16 @@ string OscilloscopeWindow::SerializeUIConfiguration(IDTable& table)
config += tmp;
}

//Top level splitter
for(auto split : m_splitters)
{
if(split->get_parent() == &m_vbox)
{
snprintf(tmp, sizeof(tmp), " top: %d\n", table[split]);
config += tmp;
}
}

return config;
}

16 changes: 6 additions & 10 deletions glscopeclient/ScopeApp.cpp
Original file line number Diff line number Diff line change
@@ -45,11 +45,15 @@ ScopeApp::~ScopeApp()
void ScopeApp::run(string fileToLoad)
{
register_application();
on_activate();

m_window = new OscilloscopeWindow(m_scopes);
add_window(*m_window);

if(!fileToLoad.empty())
m_window->DoFileOpen(fileToLoad);

m_window->present();

while(true)
{
//Poll the scope to see if we have any new data
@@ -95,17 +99,9 @@ void ScopeApp::ShutDownSession()
m_terminating = false;
}

/**
@brief Create windows for each instrument
*/
void ScopeApp::on_activate()
void ScopeApp::StartScopeThreads()
{
//Start the scope threads
for(auto scope : m_scopes)
m_threads.push_back(new thread(ScopeThread, scope));

//Launch the application
m_window = new OscilloscopeWindow(m_scopes);
add_window(*m_window);
m_window->present();
}
4 changes: 2 additions & 2 deletions glscopeclient/ScopeApp.h
Original file line number Diff line number Diff line change
@@ -58,13 +58,13 @@ class ScopeApp : public Gtk::Application
bool IsTerminating()
{ return m_terminating; }

void StartScopeThreads();

protected:
bool m_terminating;

OscilloscopeWindow* m_window;

virtual void on_activate();

std::vector<std::thread*> m_threads;
};

2 changes: 2 additions & 0 deletions glscopeclient/WaveformArea.cpp
Original file line number Diff line number Diff line change
@@ -442,6 +442,8 @@ void WaveformArea::CreateWidgets()

void WaveformArea::on_realize()
{
LogDebug("realize waveform area\n");

//Let the base class create the GL context, then select it
Gtk::GLArea::on_realize();
make_current();
12 changes: 11 additions & 1 deletion glscopeclient/WaveformGroup.cpp
Original file line number Diff line number Diff line change
@@ -204,7 +204,7 @@ string WaveformGroup::SerializeConfiguration(IDTable& table)

snprintf(tmp, sizeof(tmp), " : \n");
string config = tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", table.emplace(this));
snprintf(tmp, sizeof(tmp), " id: %d\n", table.emplace(&m_frame));
config += tmp;

config += " name: \"" + m_frame.get_label() + "\"\n";
@@ -255,5 +255,15 @@ string WaveformGroup::SerializeConfiguration(IDTable& table)
config += col->m_measurement->SerializeConfiguration(table, col->m_title);
}

//Waveform areas
config += " areas: \n";
auto children = m_waveformBox.get_children();
for(size_t i=0; i<children.size(); i++)
{
config += " : \n";
snprintf(tmp, sizeof(tmp), " id: %d\n", table[children[i]]);
config += tmp;
}

return config;
}