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: 52724cb0730c
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: f07ac59801a7
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on Dec 16, 2019

  1. Copy the full SHA
    f07ac59 View commit details
1 change: 1 addition & 0 deletions glscopeclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ link_directories(${GTKMM_LIBRARY_DIRS} ${SIGCXX_LIBRARY_DIRS})
add_executable(glscopeclient
Framebuffer.cpp
HistoryWindow.cpp
MeasurementDialog.cpp
OscilloscopeWindow.cpp
Program.cpp
ProtocolAnalyzerWindow.cpp
145 changes: 145 additions & 0 deletions glscopeclient/MeasurementDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of MeasurementDialog
*/
#include "glscopeclient.h"
#include "OscilloscopeWindow.h"
#include "MeasurementDialog.h"

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction

MeasurementDialog::MeasurementDialog(
OscilloscopeWindow* parent,
Measurement* measurement,
OscilloscopeChannel* chan)
: Gtk::Dialog("Configure Measurement", *parent, Gtk::DIALOG_MODAL)
, m_measurement(measurement)
{
add_button("OK", Gtk::RESPONSE_OK);
add_button("Cancel", Gtk::RESPONSE_CANCEL);

for(size_t i=0; i<measurement->GetInputCount(); i++)
{
//Add the row
auto row = new ChannelSelectorRow;
get_vbox()->pack_start(row->m_box, Gtk::PACK_SHRINK);
m_rows.push_back(row);

//Label is just the channel name
row->m_label.set_label(measurement->GetInputName(i));

//always allow not connecting an input
row->m_chans.append("NULL");
row->m_chanptrs["NULL"] = NULL;

//Fill the channel list with all channels that are legal to use here
for(size_t j=0; j<parent->GetScopeCount(); j++)
{
Oscilloscope* scope = parent->GetScope(j);
for(size_t k=0; k<scope->GetChannelCount(); k++)
{
auto c = scope->GetChannel(k);
if(measurement->ValidateChannel(i, c))
{
row->m_chans.append(c->m_displayname);
row->m_chanptrs[c->m_displayname] = c;
if(c == chan)
row->m_chans.set_active_text(c->m_displayname);
}
}
}

//Add protocol decoders
for(auto d : parent->m_decoders)
{
if(measurement->ValidateChannel(i, d))
{
row->m_chans.append(d->m_displayname);
row->m_chanptrs[d->m_displayname] = d;
if(d == chan)
row->m_chans.set_active_text(d->m_displayname);
}
}
}

//Add parameters
/*
for(auto it = measurement->GetParamBegin(); it != measurement->GetParamEnd(); it ++)
{
auto row = new ParameterRow;
get_vbox()->pack_start(row->m_box, Gtk::PACK_SHRINK);
m_prows.push_back(row);
row->m_label.set_label(it->first);
//Set initial value
row->m_entry.set_text(it->second.ToString());
}
*/

show_all();
}

MeasurementDialog::~MeasurementDialog()
{
for(auto r : m_rows)
delete r;
/*
for(auto r : m_prows)
delete r;
*/
m_rows.clear();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Output

void MeasurementDialog::ConfigureMeasurement()
{
for(size_t i=0; i<m_rows.size(); i++)
{
auto chname = m_rows[i]->m_chans.get_active_text();
m_measurement->SetInput(i, m_rows[i]->m_chanptrs[chname]);
}
/*
for(size_t i=0; i<m_prows.size(); i++)
{
m_measurement->GetParameter(m_prows[i]->m_label.get_label()).ParseString(
m_prows[i]->m_entry.get_text());
}
*/
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Event handlers
59 changes: 59 additions & 0 deletions glscopeclient/MeasurementDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Dialog for configuring protocol decoders
*/

#ifndef MeasurementDialog_h
#define MeasurementDialog_h

#include "ProtocolDecoderDialog.h"

/**
@brief Main application window class for an oscilloscope
*/
class MeasurementDialog : public Gtk::Dialog
{
public:
MeasurementDialog(OscilloscopeWindow* parent, Measurement* measurement, OscilloscopeChannel* chan);
virtual ~MeasurementDialog();

void ConfigureMeasurement();

protected:
Measurement* m_measurement;

std::vector<ChannelSelectorRow*> m_rows;
//std::vector<ParameterRow*> m_prows;
};

#endif
8 changes: 3 additions & 5 deletions glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -36,8 +36,6 @@
#include "glscopeclient.h"
#include "../scopehal/Instrument.h"
#include "OscilloscopeWindow.h"
//#include "../scopehal/AnalogRenderer.h"
//#include "ProtocolDecoderDialog.h"

using namespace std;

@@ -232,7 +230,7 @@ void OscilloscopeWindow::CreateWidgets()
auto split = new Gtk::HPaned;
m_vbox.pack_start(*split);
m_splitters.emplace(split);
auto group = new WaveformGroup;
auto group = new WaveformGroup(this);
m_waveformGroups.emplace(group);
split->pack1(group->m_frame);

@@ -395,7 +393,7 @@ void OscilloscopeWindow::SplitGroup(Gtk::Widget* frame, WaveformGroup* group, bo
void OscilloscopeWindow::OnMoveNew(WaveformArea* w, bool horizontal)
{
//Make a new group
auto group = new WaveformGroup;
auto group = new WaveformGroup(this);
group->m_pixelsPerPicosecond = w->m_group->m_pixelsPerPicosecond;
m_waveformGroups.emplace(group);

@@ -409,7 +407,7 @@ void OscilloscopeWindow::OnMoveNew(WaveformArea* w, bool horizontal)
void OscilloscopeWindow::OnCopyNew(WaveformArea* w, bool horizontal)
{
//Make a new group
auto group = new WaveformGroup;
auto group = new WaveformGroup(this);
group->m_pixelsPerPicosecond = w->m_group->m_pixelsPerPicosecond;
m_waveformGroups.emplace(group);

23 changes: 18 additions & 5 deletions glscopeclient/WaveformGroup.cpp
Original file line number Diff line number Diff line change
@@ -34,15 +34,17 @@
*/
#include "glscopeclient.h"
#include "WaveformGroup.h"
#include "MeasurementDialog.h"

using namespace std;

int WaveformGroup::m_numGroups = 1;

WaveformGroup::WaveformGroup()
WaveformGroup::WaveformGroup(OscilloscopeWindow* parent)
: m_pixelsPerPicosecond(0.05)
, m_timeOffset(0)
, m_cursorConfig(CURSOR_NONE)
, m_parent(parent)
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Initial GUI hierarchy, title, etc
@@ -113,6 +115,21 @@ 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);

//Make sure the measurements can actually be seen
m_measurementFrame.show();

@@ -132,11 +149,7 @@ void WaveformGroup::AddColumn(string name, OscilloscopeChannel* chan, string col
snprintf(tmp, sizeof(tmp), "%s: %s", shortname.c_str(), name.c_str());
col->m_title = tmp;
m_measurementColumns.emplace(col);

//Create the measurement itself
auto m = Measurement::CreateMeasurement(name);
col->m_measurement = m;
m->SetInput(0, chan); //TODO: allow multiple inputs, pop up dialog or something

//Add to the box and show it
m_measurementBox.pack_start(col->m_label, Gtk::PACK_SHRINK, 5);
6 changes: 5 additions & 1 deletion glscopeclient/WaveformGroup.h
Original file line number Diff line number Diff line change
@@ -38,6 +38,8 @@

#include "Timeline.h"

class OscilloscopeWindow;

class MeasurementColumn
{
public:
@@ -55,7 +57,7 @@ class MeasurementColumn
class WaveformGroup
{
public:
WaveformGroup();
WaveformGroup(OscilloscopeWindow* parent);
virtual ~WaveformGroup();

void RefreshMeasurements();
@@ -94,6 +96,8 @@ class WaveformGroup
void OnRemoveMeasurementItem();

static int m_numGroups;

OscilloscopeWindow* m_parent;
};

#endif