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: 78ebc48396b6
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: 40835c185585
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on May 24, 2020

  1. Copy the full SHA
    40835c1 View commit details
32 changes: 2 additions & 30 deletions glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -368,7 +368,6 @@ void OscilloscopeWindow::CreateWidgets()
show_all();

//Don't show measurements by default
group->m_measurementFrame.hide();
group->m_measurementView.hide();

//Initialize the style sheets
@@ -965,29 +964,7 @@ void OscilloscopeWindow::LoadUIConfiguration(const YAML::Node& node, IDTable& ta
group->m_yCursorPos[0] = gn["ycursor0"].as<float>();
group->m_yCursorPos[1] = gn["ycursor1"].as<float>();

//Measurements
auto measurements = gn["measurements"];
if(measurements)
{
for(auto jt : measurements)
{
auto mn = jt.second;

auto meas = Measurement::CreateMeasurement(mn["measurement"].as<string>());
table.emplace(mn["id"].as<int>(), meas);

//Configure the inputs
auto inputs = mn["inputs"];
for(auto kt : inputs)
{
meas->SetInput(
kt.first.as<string>(),
static_cast<OscilloscopeChannel*>(table[kt.second.as<int>()]) );
}

group->AddColumn(meas, mn["color"].as<string>(), mn["nick"].as<string>());
}
}
//TODO: statistics

//Waveform areas
areas = gn["areas"];
@@ -1621,14 +1598,9 @@ void OscilloscopeWindow::GarbageCollectGroups()
delete s;
}

//Hide measurement display if there's no measurements in the group
//Hide stat display if there's no stats in the group
for(auto g : m_waveformGroups)
{
if(g->m_measurementColumns.empty())
g->m_measurementFrame.hide();
else
g->m_measurementFrame.show_all();

if(g->m_columnToIndexMap.empty())
g->m_measurementView.hide();
else
43 changes: 1 addition & 42 deletions glscopeclient/WaveformArea.cpp
Original file line number Diff line number Diff line change
@@ -433,48 +433,7 @@ void WaveformArea::CreateWidgets()
//TODO: delete measurements once we get rid of them all
m_contextMenu.append(*Gtk::manage(new Gtk::SeparatorMenuItem));

//Measurements
m_contextMenu.append(m_measureItem);
m_measureItem.set_label("Measure");
m_measureItem.set_submenu(m_measureMenu);

m_measureMenu.append(m_measureHorzItem);
m_measureHorzItem.set_label("Horizontal");
m_measureHorzItem.set_submenu(m_measureHorzMenu);
m_measureMenu.append(m_measureProtoItem);
m_measureProtoItem.set_label("Protocol");
m_measureProtoItem.set_submenu(m_measureProtoMenu);
m_measureMenu.append(m_measureVertItem);
m_measureVertItem.set_label("Vertical");
m_measureVertItem.set_submenu(m_measureVertMenu);

names.clear();
Measurement::EnumMeasurements(names);
for(auto p : names)
{
item = Gtk::manage(new Gtk::MenuItem(p, false));
item->signal_activate().connect(
sigc::bind<string>(sigc::mem_fun(*this, &WaveformArea::OnMeasure), p));

auto m = Measurement::CreateMeasurement(p);
switch(m->GetMeasurementType())
{
case Measurement::MEAS_HORZ:
m_measureHorzMenu.append(*item);
break;

case Measurement::MEAS_PROTO:
m_measureProtoMenu.append(*item);
break;

case Measurement::MEAS_VERT:
m_measureVertMenu.append(*item);
break;
}

delete m;
}

//Statistics
m_contextMenu.append(m_statisticsItem);
m_statisticsItem.set_label("Statistics");
m_statisticsItem.signal_activate().connect(
10 changes: 0 additions & 10 deletions glscopeclient/WaveformArea.h
Original file line number Diff line number Diff line change
@@ -214,14 +214,6 @@ class WaveformArea : public Gtk::GLArea
Gtk::Menu m_decodeSerialMenu;
Gtk::MenuItem m_decodeSignalIntegrityItem;
Gtk::Menu m_decodeSignalIntegrityMenu;
Gtk::MenuItem m_measureItem;
Gtk::Menu m_measureMenu;
Gtk::MenuItem m_measureVertItem;
Gtk::Menu m_measureVertMenu;
Gtk::MenuItem m_measureHorzItem;
Gtk::Menu m_measureHorzMenu;
Gtk::MenuItem m_measureProtoItem;
Gtk::Menu m_measureProtoMenu;
Gtk::CheckMenuItem m_statisticsItem;
Gtk::MenuItem m_triggerItem;
Gtk::Menu m_triggerMenu;
@@ -249,12 +241,10 @@ class WaveformArea : public Gtk::GLArea
Gtk::RadioMenuItem m_bw200Item;
Gtk::RadioMenuItem m_bw20Item;
void UpdateContextMenu();
void UpdateMeasureContextMenu(std::vector<Widget*> children);
bool m_updatingContextMenu;
void OnHide();
void OnTogglePersistence();

void OnMeasure(std::string name);
void OnTriggerMode(Oscilloscope::TriggerType type, Gtk::RadioMenuItem* item);
void OnBandwidthLimit(int mhz, Gtk::RadioMenuItem* item);
void OnMoveNewRight();
25 changes: 0 additions & 25 deletions glscopeclient/WaveformArea_events.cpp
Original file line number Diff line number Diff line change
@@ -826,11 +826,6 @@ void WaveformArea::OnDecodeSetupComplete()
m_pendingDecode = NULL;
}

void WaveformArea::OnMeasure(string name)
{
m_group->AddColumn(name, m_selectedChannel, m_selectedChannel->m_displaycolor);
}

void WaveformArea::OnBandwidthLimit(int mhz, Gtk::RadioMenuItem* item)
{
//ignore spurious events while loading menu config, or from item being deselected
@@ -925,20 +920,6 @@ WaveformArea::ClickLocation WaveformArea::HitTest(double x, double y)
return LOC_PLOT;
}

void WaveformArea::UpdateMeasureContextMenu(std::vector<Widget*> children)
{
for(auto item : children)
{
Gtk::MenuItem* menu = dynamic_cast<Gtk::MenuItem*>(item);
if(menu == NULL)
continue;

auto m = Measurement::CreateMeasurement(menu->get_label());
menu->set_sensitive(m->ValidateChannel(0, m_selectedChannel));
delete m;
}
}

/**
@brief Enable/disable or show/hide context menu items for the current selection
*/
@@ -1015,12 +996,6 @@ void WaveformArea::UpdateContextMenu()
}
}

//Gray out measurements that don't make sense for the type of channel we've selected
auto children = m_measureHorzMenu.get_children();
UpdateMeasureContextMenu(children);
children = m_measureVertMenu.get_children();
UpdateMeasureContextMenu(children);

if(m_selectedChannel->IsPhysicalChannel())
{
m_bwMenu.set_sensitive(true);
126 changes: 1 addition & 125 deletions glscopeclient/WaveformGroup.cpp
Original file line number Diff line number Diff line change
@@ -59,16 +59,6 @@ WaveformGroup::WaveformGroup(OscilloscopeWindow* parent)
m_numGroups ++;
m_frame.set_label(tmp);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Measurements

m_vbox.pack_start(m_measurementFrame, Gtk::PACK_SHRINK, 5);
m_measurementFrame.set_label("Measurements");

m_measurementFrame.add(m_measurementBox);

m_measurementBox.set_spacing(30);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// New measurements

@@ -83,14 +73,8 @@ WaveformGroup::WaveformGroup(OscilloscopeWindow* parent)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Context menu

m_contextMenu.append(m_removeMeasurementItem);
m_removeMeasurementItem.set_label("Remove measurement");
m_removeMeasurementItem.signal_activate().connect(
sigc::mem_fun(*this, &WaveformGroup::OnRemoveMeasurementItem));
m_contextMenu.show_all();

m_selectedColumn = NULL;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Cursors

@@ -116,9 +100,6 @@ WaveformGroup::~WaveformGroup()
Statistic* stat = row[m_treeColumns.m_statColumn];
delete stat;
}

for(auto c : m_measurementColumns)
delete c;
}

void WaveformGroup::ToggleOn(OscilloscopeChannel* chan)
@@ -200,21 +181,6 @@ void WaveformGroup::ClearStatistics()

void WaveformGroup::RefreshMeasurements()
{
//Old stuff
char tmp[256];
for(auto m : m_measurementColumns)
{
//Run the measurement once, then update our text
m->m_measurement->Refresh();
snprintf(
tmp,
sizeof(tmp),
"<span font-weight='bold' underline='single'>%s</span>\n"
"<span rise='-5' font-family='monospace'>%s</span>",
m->m_title.c_str(), m->m_measurement->GetValueAsString().c_str());
m->m_label.set_markup(tmp);
}

//New tree view
auto children = m_treeModel->children();
for(auto row : children)
@@ -249,89 +215,6 @@ void WaveformGroup::RefreshMeasurements()
}
}

void WaveformGroup::AddColumn(string name, OscilloscopeChannel* chan, string color)
{
//Create the measurement itself
auto m = Measurement::CreateMeasurement(name);
if(m->GetInputCount() > 1)
{
MeasurementDialog dialog(m_parent, m, chan);
if(dialog.run() != Gtk::RESPONSE_OK)
{
delete m;
return;
}
dialog.ConfigureMeasurement();
}
else
m->SetInput(0, chan);

//Short name of the channel (truncate if too long)
string shortname = chan->m_displayname;
if(shortname.length() > 12)
{
shortname.resize(9);
shortname += "...";
}

//Name the measurement
char tmp[256];
snprintf(tmp, sizeof(tmp), "%s: %s", shortname.c_str(), name.c_str());

AddColumn(m, color, tmp);
}

void WaveformGroup::AddColumn(Measurement* meas, string color, string label)
{
//Make sure the measurements can actually be seen
m_measurementFrame.show();

//TODO: Don't allow adding the same measurement twice

//Create the column and figure out the title
auto col = new MeasurementColumn;
col->m_title = label;
m_measurementColumns.emplace(col);
col->m_measurement = meas;

//Add to the box and show it
m_measurementBox.pack_start(col->m_label, Gtk::PACK_SHRINK, 5);
col->m_label.override_color(Gdk::RGBA(color));
col->m_label.set_justify(Gtk::JUSTIFY_RIGHT);
col->m_label.add_events(Gdk::BUTTON_PRESS_MASK);
col->m_label.show();
col->m_label.set_selectable();
col->m_label.signal_button_press_event().connect(
sigc::bind<MeasurementColumn*>(sigc::mem_fun(*this, &WaveformGroup::OnMeasurementContextMenu), col),
false);

//Recalculate stuff now that we have more measurements to look at
RefreshMeasurements();
}

bool WaveformGroup::OnMeasurementContextMenu(GdkEventButton* event, MeasurementColumn* col)
{
//SKip anything not right click
if(event->button != 3)
return true;

m_selectedColumn = col;

m_contextMenu.popup(event->button, event->time);
return true;
}

void WaveformGroup::OnRemoveMeasurementItem()
{
m_measurementBox.remove(m_selectedColumn->m_label);
m_measurementColumns.erase(m_selectedColumn);
delete m_selectedColumn;
m_selectedColumn = NULL;

if(m_measurementColumns.empty())
m_measurementFrame.hide();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

string WaveformGroup::SerializeConfiguration(IDTable& table)
@@ -382,14 +265,7 @@ string WaveformGroup::SerializeConfiguration(IDTable& table)
snprintf(tmp, sizeof(tmp), " ycursor1: %f\n", m_yCursorPos[1]);
config += tmp;

//Measurements
if(!m_measurementColumns.empty())
{
config += " measurements: \n";

for(auto col : m_measurementColumns)
config += col->m_measurement->SerializeConfiguration(table, col->m_title);
}
//TODO: statistics

//Waveform areas
config += " areas: \n";
Loading