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

Commits on Mar 11, 2020

  1. Copy the full SHA
    1ed3bb1 View commit details
Showing with 62 additions and 17 deletions.
  1. +1 −0 glscopeclient/CMakeLists.txt
  2. +57 −16 glscopeclient/OscilloscopeWindow.cpp
  3. +3 −0 glscopeclient/OscilloscopeWindow.h
  4. +1 −1 glscopeclient/WaveformGroup.cpp
1 change: 1 addition & 0 deletions glscopeclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ target_link_libraries(glscopeclient
${GTKMM_LIBRARIES}
${SIGCXX_LIBRARIES}
GL
yaml-cpp
)

###############################################################################
73 changes: 57 additions & 16 deletions glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -160,11 +160,9 @@ void OscilloscopeWindow::CreateWidgets()
m_fileMenu.append(*item);
item = Gtk::manage(new Gtk::SeparatorMenuItem);
m_fileMenu.append(*item);
item = Gtk::manage(new Gtk::MenuItem("Load Layout Only...", false));
m_fileMenu.append(*item);
item = Gtk::manage(new Gtk::MenuItem("Load Waveforms Only...", false));
m_fileMenu.append(*item);
item = Gtk::manage(new Gtk::MenuItem("Load Layout and Waveforms...", false));
item = Gtk::manage(new Gtk::MenuItem("Open...", false));
item->signal_activate().connect(
sigc::mem_fun(*this, &OscilloscopeWindow::OnFileOpen));
m_fileMenu.append(*item);
item = Gtk::manage(new Gtk::SeparatorMenuItem);
m_fileMenu.append(*item);
@@ -361,6 +359,49 @@ void OscilloscopeWindow::CreateWidgets()
////////////////////////////////////////////////////////////////////////////////////////////////////
// Message handlers

/**
@brief Open a saved configuration
*/
void OscilloscopeWindow::OnFileOpen()
{
static const char* extension = ".scopesession";

//Remove the CSS provider so the dialog isn't themed
//TODO: how can we un-theme just this one dialog?
get_style_context()->remove_provider_for_screen(
Gdk::Screen::get_default(), m_css);

Gtk::FileChooserDialog dlg(*this, "Open", Gtk::FILE_CHOOSER_ACTION_SAVE);

dlg.add_choice("layout", "Load UI Configuration");
dlg.add_choice("waveform", "Load Waveform Data");
dlg.add_choice("reconnect", "Reconnect to Instrument (reconfigure using saved settings)");

dlg.set_choice("layout", "true");
dlg.set_choice("waveform", "true");
dlg.set_choice("reconnect", "true");

auto filter = Gtk::FileFilter::create();
filter->add_pattern("*.scopesession");
filter->set_name("glscopeclient sessions (*.scopesession)");
dlg.add_filter(filter);
dlg.add_button("Open", Gtk::RESPONSE_OK);
dlg.add_button("Cancel", Gtk::RESPONSE_CANCEL);
auto response = dlg.run();

//Re-add the CSS provider
get_style_context()->add_provider_for_screen(
Gdk::Screen::get_default(), m_css, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

if(response != Gtk::RESPONSE_OK)
return;

m_currentFileName = dlg.get_filename();

//Open the top level
auto docs = YAML::LoadAllFromFile(/*m_currentFileName*/"/dev/null");
}

/**
@brief Common handler for save/save as commands
*/
@@ -534,7 +575,7 @@ string OscilloscopeWindow::SerializeConfiguration(bool saveLayout)
*/
string OscilloscopeWindow::SerializeInstrumentConfiguration(std::map<void*, int>& idmap, int& nextID)
{
string config = "instruments: @\n";
string config = "instruments:\n";

for(auto scope : m_scopes)
config += scope->SerializeConfiguration(idmap, nextID);
@@ -547,7 +588,7 @@ string OscilloscopeWindow::SerializeInstrumentConfiguration(std::map<void*, int>
*/
string OscilloscopeWindow::SerializeDecodeConfiguration(std::map<void*, int>& idmap, int& nextID)
{
string config = "decodes: %\n";
string config = "decodes:\n";

for(auto d : m_decoders)
config += d->SerializeConfiguration(idmap, nextID);
@@ -558,22 +599,22 @@ string OscilloscopeWindow::SerializeDecodeConfiguration(std::map<void*, int>& id
string OscilloscopeWindow::SerializeUIConfiguration(std::map<void*, int>& idmap, int& nextID)
{
char tmp[1024];
string config = "ui_config: %\n";
string config = "ui_config:\n";

config += " window: %\n";
config += " window:\n";
snprintf(tmp, sizeof(tmp), " width: %d\n", get_width());
config += tmp;
snprintf(tmp, sizeof(tmp), " height: %d\n", get_height());
config += tmp;

//Waveform areas
config += " areas: @\n";
config += " areas:\n";
for(auto area : m_waveformAreas)
idmap[area] = nextID++;
for(auto area : m_waveformAreas)
{
int id = idmap[area];
snprintf(tmp, sizeof(tmp), " : %%\n");
snprintf(tmp, sizeof(tmp), " : \n");
config += tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", id);
config += tmp;
@@ -589,12 +630,12 @@ string OscilloscopeWindow::SerializeUIConfiguration(std::map<void*, int>& idmap,
//Overlays
if(area->GetOverlayCount() != 0)
{
snprintf(tmp, sizeof(tmp), " overlays: @\n");
snprintf(tmp, sizeof(tmp), " overlays:\n");
config += tmp;

for(size_t i=0; i<area->GetOverlayCount(); i++)
{
snprintf(tmp, sizeof(tmp), " : %%\n");
snprintf(tmp, sizeof(tmp), " :\n");
config += tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", idmap[area->GetOverlay(i)]);
config += tmp;
@@ -603,21 +644,21 @@ string OscilloscopeWindow::SerializeUIConfiguration(std::map<void*, int>& idmap,
}

//Waveform groups
config += " groups: @\n";
config += " groups: \n";
for(auto group : m_waveformGroups)
idmap[group] = nextID++;
for(auto group : m_waveformGroups)
config += group->SerializeConfiguration(idmap, nextID);

//Splitters
config += " splitters: @\n";
config += " splitters: \n";
for(auto split : m_splitters)
idmap[split] = nextID++;
for(auto split : m_splitters)
{
//Splitter config
int id = idmap[split];
snprintf(tmp, sizeof(tmp), " : %%\n");
snprintf(tmp, sizeof(tmp), " : \n");
config += tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", id);
config += tmp;
3 changes: 3 additions & 0 deletions glscopeclient/OscilloscopeWindow.h
Original file line number Diff line number Diff line change
@@ -42,6 +42,8 @@
#include "ProtocolAnalyzerWindow.h"
#include "HistoryWindow.h"

#include <yaml-cpp/yaml.h>

/**
@brief Main application window class for an oscilloscope
*/
@@ -186,6 +188,7 @@ class OscilloscopeWindow : public Gtk::Window

//Menu event handlers
void OnFileSave(bool saveToCurrentFile, bool saveLayout, bool saveWaveforms);
void OnFileOpen();
void OnEyeColorChanged(EyeColor color, Gtk::RadioMenuItem* item);
void OnTriggerProperties(Oscilloscope* scope);

2 changes: 1 addition & 1 deletion glscopeclient/WaveformGroup.cpp
Original file line number Diff line number Diff line change
@@ -196,7 +196,7 @@ string WaveformGroup::SerializeConfiguration(std::map<void*, int>& idmap, int& n
char tmp[1024];

int id = idmap[this];
snprintf(tmp, sizeof(tmp), " : %%\n");
snprintf(tmp, sizeof(tmp), " : \n");
string config = tmp;
snprintf(tmp, sizeof(tmp), " id: %d\n", id);
config += tmp;