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: 679e6cda23ba
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: 58711f3e6e0c
Choose a head ref
  • 2 commits
  • 8 files changed
  • 1 contributor

Commits on Dec 3, 2020

  1. Copy the full SHA
    3ea598a View commit details
  2. Copy the full SHA
    58711f3 View commit details
2 changes: 1 addition & 1 deletion lib
1 change: 1 addition & 0 deletions src/glscopeclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -71,6 +71,7 @@ add_executable(glscopeclient
WaveformArea_rendering.cpp
WaveformArea_cairo.cpp
WaveformGroup.cpp
WaveformGroupPropertiesDialog.cpp

main.cpp
)
2 changes: 1 addition & 1 deletion src/glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -1376,7 +1376,7 @@ void OscilloscopeWindow::LoadUIConfiguration(const YAML::Node& node, IDTable& ta
auto gn = it.second;
WaveformGroup* group = new WaveformGroup(this);
table.emplace(gn["id"].as<int>(), &group->m_frame);
group->m_frame.set_label(gn["name"].as<string>());
group->m_realframe.set_label(gn["name"].as<string>());

//Scale if needed
bool timestamps_are_ps = true;
4 changes: 2 additions & 2 deletions src/glscopeclient/WaveformArea_events.cpp
Original file line number Diff line number Diff line change
@@ -1264,7 +1264,7 @@ void WaveformArea::UpdateContextMenu()
{
//Move
auto item = new Gtk::MenuItem;
item->set_label(g->m_frame.get_label());
item->set_label(g->m_realframe.get_label());
m_moveMenu.append(*item);
m_moveExistingGroupItems.emplace(item);
if(get_parent() == &g->m_waveformBox)
@@ -1274,7 +1274,7 @@ void WaveformArea::UpdateContextMenu()

//Copy
item = new Gtk::MenuItem;
item->set_label(g->m_frame.get_label());
item->set_label(g->m_realframe.get_label());
m_copyMenu.append(*item);
m_copyExistingGroupItems.emplace(item);
//don't disable if in this group, it's OK to copy to ourself
40 changes: 35 additions & 5 deletions src/glscopeclient/WaveformGroup.cpp
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@
#include "glscopeclient.h"
#include "WaveformGroup.h"
#include "ChannelPropertiesDialog.h"
#include "WaveformGroupPropertiesDialog.h"
#include "FilterDialog.h"

using namespace std;
@@ -47,19 +48,21 @@ WaveformGroup::WaveformGroup(OscilloscopeWindow* parent)
, m_xAxisOffset(0)
, m_cursorConfig(CURSOR_NONE)
, m_parent(parent)
, m_propertiesDialog(NULL)
, m_measurementContextMenuChannel(NULL)
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Initial GUI hierarchy, title, etc

m_frame.add(m_vbox);
m_vbox.pack_start(m_timeline, Gtk::PACK_SHRINK);
m_vbox.pack_start(m_waveformBox, Gtk::PACK_EXPAND_WIDGET);
m_frame.add(m_realframe);
m_realframe.add(m_vbox);
m_vbox.pack_start(m_timeline, Gtk::PACK_SHRINK);
m_vbox.pack_start(m_waveformBox, Gtk::PACK_EXPAND_WIDGET);

char tmp[64];
snprintf(tmp, sizeof(tmp), "Waveform Group %d", m_numGroups);
m_numGroups ++;
m_frame.set_label(tmp);
m_realframe.set_label(tmp);

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Statistics
@@ -76,6 +79,10 @@ WaveformGroup::WaveformGroup(OscilloscopeWindow* parent)
m_measurementView.signal_button_press_event().connect_notify(
sigc::mem_fun(*this, &WaveformGroup::OnMeasurementButtonPressEvent));

m_frame.add_events(Gdk::BUTTON_PRESS_MASK);
m_frame.signal_button_press_event().connect_notify(
sigc::mem_fun(*this, &WaveformGroup::OnTitleButtonPressEvent));

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Context menu

@@ -101,6 +108,9 @@ WaveformGroup::WaveformGroup(OscilloscopeWindow* parent)

WaveformGroup::~WaveformGroup()
{
if(m_propertiesDialog)
delete m_propertiesDialog;

//Free each of our channels
for(size_t i=1; i<32; i++)
{
@@ -248,7 +258,7 @@ string WaveformGroup::SerializeConfiguration(IDTable& table)
snprintf(tmp, sizeof(tmp), " id: %d\n", table.emplace(&m_frame));
config += tmp;

config += " name: \"" + m_frame.get_label() + "\"\n";
config += " name: \"" + m_realframe.get_label() + "\"\n";

snprintf(tmp, sizeof(tmp), " timebaseResolution: fs\n");
config += tmp;
@@ -325,6 +335,26 @@ bool WaveformGroup::IsLastChild(Gtk::Widget* child)
return false;
}

void WaveformGroup::OnTitleButtonPressEvent(GdkEventButton* event)
{
if(event->type == GDK_2BUTTON_PRESS)
{
m_propertiesDialog = new WaveformGroupPropertiesDialog(m_parent, this);
m_propertiesDialog->signal_response().connect(
sigc::mem_fun(*this, &WaveformGroup::OnPropertiesDialogResponse));
m_propertiesDialog->show();
}
}

void WaveformGroup::OnPropertiesDialogResponse(int response)
{
if(response == Gtk::RESPONSE_OK)
m_propertiesDialog->ConfigureGroup();

delete m_propertiesDialog;
m_propertiesDialog = NULL;
}

void WaveformGroup::OnMeasurementButtonPressEvent(GdkEventButton* event)
{
//Right click
16 changes: 11 additions & 5 deletions src/glscopeclient/WaveformGroup.h
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@
#include "Timeline.h"

class OscilloscopeWindow;
class WaveformGroupPropertiesDialog;

class MeasurementColumns : public Gtk::TreeModel::ColumnRecord
{
@@ -90,11 +91,12 @@ class WaveformGroup
std::map<OscilloscopeChannel*, int> m_columnToIndexMap;
std::map<int, OscilloscopeChannel*> m_indexToColumnMap;

Gtk::Frame m_frame;
Gtk::VBox m_vbox;
Timeline m_timeline;
Gtk::VBox m_waveformBox;
Gtk::TreeView m_measurementView;
Gtk::EventBox m_frame;
Gtk::Frame m_realframe;
Gtk::VBox m_vbox;
Timeline m_timeline;
Gtk::VBox m_waveformBox;
Gtk::TreeView m_measurementView;

float m_pixelsPerXUnit;
int64_t m_xAxisOffset;
@@ -118,6 +120,7 @@ class WaveformGroup

protected:
void OnMeasurementButtonPressEvent(GdkEventButton* event);
void OnTitleButtonPressEvent(GdkEventButton* event);

static int m_numGroups;

@@ -130,6 +133,9 @@ class WaveformGroup
void OnStatisticProperties();
void OnHideStatistic();

WaveformGroupPropertiesDialog* m_propertiesDialog;
void OnPropertiesDialogResponse(int response);

OscilloscopeChannel* m_measurementContextMenuChannel;
};

78 changes: 78 additions & 0 deletions src/glscopeclient/WaveformGroupPropertiesDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/***********************************************************************************************************************
* *
* glscopeclient *
* *
* Copyright (c) 2012-2020 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 WaveformGroupPropertiesDialog
*/
#include "glscopeclient.h"
#include "OscilloscopeWindow.h"
#include "WaveformGroupPropertiesDialog.h"

using namespace std;

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

WaveformGroupPropertiesDialog::WaveformGroupPropertiesDialog(
OscilloscopeWindow* parent,
WaveformGroup* group)
: Gtk::Dialog(string("Waveform group properties"), *parent, Gtk::DIALOG_MODAL)
, m_group(group)
{
add_button("OK", Gtk::RESPONSE_OK);
add_button("Cancel", Gtk::RESPONSE_CANCEL);

get_vbox()->pack_start(m_grid, Gtk::PACK_EXPAND_WIDGET);
m_grid.attach(m_groupNameLabel, 0, 0, 1, 1);
m_groupNameLabel.set_text("Name");
m_groupNameLabel.set_halign(Gtk::ALIGN_START);
m_grid.attach_next_to(m_groupNameEntry, m_groupNameLabel, Gtk::POS_RIGHT, 1, 1);
m_groupNameEntry.set_halign(Gtk::ALIGN_START);
m_groupNameEntry.set_text(group->m_realframe.get_label());

show_all();
}

WaveformGroupPropertiesDialog::~WaveformGroupPropertiesDialog()
{

}

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

void WaveformGroupPropertiesDialog::ConfigureGroup()
{
m_group->m_realframe.set_label(m_groupNameEntry.get_text());
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Event handlers
59 changes: 59 additions & 0 deletions src/glscopeclient/WaveformGroupPropertiesDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/***********************************************************************************************************************
* *
* glscopeclient *
* *
* Copyright (c) 2012-2020 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 channel properties
*/

#ifndef WaveformGroupPropertiesDialog_h
#define WaveformGroupPropertiesDialog_h

/**
@brief Dialog for configuring a single scope channel
*/
class WaveformGroupPropertiesDialog : public Gtk::Dialog
{
public:
WaveformGroupPropertiesDialog(OscilloscopeWindow* parent, WaveformGroup* group);
virtual ~WaveformGroupPropertiesDialog();

void ConfigureGroup();

protected:
Gtk::Grid m_grid;

Gtk::Label m_groupNameLabel;
Gtk::Entry m_groupNameEntry;

WaveformGroup* m_group;
};

#endif