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: d1e1a9e7f102
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: 7f9d628d0987
Choose a head ref
  • 16 commits
  • 12 files changed
  • 4 contributors

Commits on Sep 22, 2020

  1. Migrate the gui-dev changes to a gui-new branch.

    This was needed as master couldn't be merged into gui-dev cleanly due to the
    submodule refactoring.
    tarunik committed Sep 22, 2020
    Copy the full SHA
    47c74d3 View commit details

Commits on Sep 23, 2020

  1. Merge pull request #182 from tarunik/gui-dev-new

    Migrate the gui-dev changes to a gui-dev-new branch.
    azonenberg authored Sep 23, 2020
    Copy the full SHA
    e45482d View commit details

Commits on Oct 8, 2020

  1. Node base for preference tree

    nshcat committed Oct 8, 2020
    Copy the full SHA
    0fd9c93 View commit details
  2. Copy the full SHA
    0986def View commit details
  3. Copy the full SHA
    5496e4e View commit details
  4. Copy the full SHA
    2fc3b45 View commit details
  5. PreferenceManager adjustments

    nshcat committed Oct 8, 2020
    Copy the full SHA
    50f7a51 View commit details

Commits on Oct 9, 2020

  1. Copy the full SHA
    31cbedd View commit details
  2. Copy the full SHA
    4b71121 View commit details

Commits on Oct 25, 2020

  1. Finished preference dialog

    nshcat committed Oct 25, 2020
    Copy the full SHA
    72f902f View commit details

Commits on Oct 26, 2020

  1. Copy the full SHA
    f1bbee7 View commit details
  2. Fixed windows build errors

    nshcat committed Oct 26, 2020
    Copy the full SHA
    23db3a7 View commit details
  3. Copy the full SHA
    984f1b3 View commit details

Commits on Oct 27, 2020

  1. Copy the full SHA
    2d8cd77 View commit details
  2. More windows fixes

    nshcat committed Oct 27, 2020
    Copy the full SHA
    b742674 View commit details
  3. Merge pull request #252 from azonenberg/gui-dev-new

    Implemented Preferences System
    azonenberg authored Oct 27, 2020
    Copy the full SHA
    7f9d628 View commit details
4 changes: 4 additions & 0 deletions src/glscopeclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -49,6 +49,10 @@ add_executable(glscopeclient
MultimeterDialog.cpp
OscilloscopeWindow.cpp
Program.cpp
Preference.cpp
PreferenceTree.cpp
PreferenceManager.cpp
PreferenceDialog.cpp
ProtocolAnalyzerWindow.cpp
ScopeApp.cpp
ScopeSyncWizard.cpp
38 changes: 38 additions & 0 deletions src/glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@
#include "../scopehal/Instrument.h"
#include "../scopehal/MockOscilloscope.h"
#include "OscilloscopeWindow.h"
#include "PreferenceDialog.h"
#include "TriggerPropertiesDialog.h"
#include "TimebasePropertiesDialog.h"
#include "FileProgressDialog.h"
@@ -191,6 +192,10 @@ void OscilloscopeWindow::CreateWidgets(bool nodigital, bool nospectrum)
m_setupHaltMenuItem.set_label("Halt Conditions...");
m_setupHaltMenuItem.signal_activate().connect(
sigc::mem_fun(*this, &OscilloscopeWindow::OnHaltConditions));
m_setupMenu.append(m_preferencesMenuItem);
m_preferencesMenuItem.set_label("Preferences");
m_preferencesMenuItem.signal_activate().connect(
sigc::mem_fun(*this, &OscilloscopeWindow::OnPreferences));
m_menu.append(m_viewMenuItem);
m_viewMenuItem.set_label("View");
m_viewMenuItem.set_submenu(m_viewMenu);
@@ -454,6 +459,28 @@ bool OscilloscopeWindow::OnTimer(int /*timer*/)
return true;
}

void OscilloscopeWindow::OnPreferences()
{
if(m_preferenceDialog)
delete m_preferenceDialog;

m_preferenceDialog = new PreferenceDialog{ this, m_preferences };
m_preferenceDialog->show();
m_preferenceDialog->signal_response().connect(sigc::mem_fun(*this, &OscilloscopeWindow::OnPreferenceDialogResponse));
}

void OscilloscopeWindow::OnPreferenceDialogResponse(int response)
{
if(response == Gtk::RESPONSE_OK)
{
m_preferenceDialog->SaveChanges();
}

//Clean up the dialog
delete m_preferenceDialog;
m_preferenceDialog = NULL;
}

/**
@brief Clean up when we're closed
*/
@@ -470,6 +497,17 @@ bool OscilloscopeWindow::on_delete_event(GdkEventAny* /*any_event*/)
*/
void OscilloscopeWindow::CloseSession()
{
//Close preferences dialog, if it exists
if(m_preferenceDialog)
{
m_preferenceDialog->hide();
delete m_preferenceDialog;
m_preferenceDialog = nullptr;
}

//Save preferences
m_preferences.SavePreferences();

//Need to clear the analyzers before we delete waveform areas.
//Otherwise waveform areas will try to delete them too
for(auto a : m_analyzers)
11 changes: 11 additions & 0 deletions src/glscopeclient/OscilloscopeWindow.h
Original file line number Diff line number Diff line change
@@ -39,11 +39,15 @@
#include "../scopehal/Oscilloscope.h"
#include "WaveformArea.h"
#include "WaveformGroup.h"
#include "PreferenceDialog.h"
#include "ProtocolAnalyzerWindow.h"
#include "HistoryWindow.h"
#include "ScopeSyncWizard.h"
#include "HaltConditionsDialog.h"
#include "FileProgressDialog.h"
#include "PreferenceManager.h"

class PreferenceDialog;

class MultimeterDialog;

@@ -158,6 +162,7 @@ class OscilloscopeWindow : public Gtk::Window
Gtk::MenuItem m_setupTriggerMenuItem;
Gtk::Menu m_setupTriggerMenu;
Gtk::MenuItem m_setupHaltMenuItem;
Gtk::MenuItem m_preferencesMenuItem;
Gtk::MenuItem m_channelsMenuItem;
Gtk::Menu m_channelsMenu;
Gtk::MenuItem m_viewMenuItem;
@@ -203,6 +208,9 @@ class OscilloscopeWindow : public Gtk::Window

//shared by all scopes/channels
std::map<Oscilloscope*, HistoryWindow*> m_historyWindows;

//Preferences state
PreferenceManager m_preferences;

public:
//All of the waveform groups and areas, regardless of where they live
@@ -255,6 +263,8 @@ class OscilloscopeWindow : public Gtk::Window
void OnShowAnalyzer(ProtocolAnalyzerWindow* window);
void OnShowMultimeter(Multimeter* meter);

void OnPreferences();
void OnPreferenceDialogResponse(int response);
//Reconfigure menus
void RefreshChannelsMenu();
void RefreshAnalyzerMenu();
@@ -298,6 +308,7 @@ class OscilloscopeWindow : public Gtk::Window

//WFM/s performance info
std::vector<double> m_lastWaveformTimes;
PreferenceDialog* m_preferenceDialog{nullptr};

//Fullscreen state
bool m_fullscreen;
152 changes: 152 additions & 0 deletions src/glscopeclient/Preference.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* 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 Katharina B.
@brief Implementation of Preference
*/

#include <stdexcept>

#include "Preference.h"

using namespace std;

const string& Preference::GetIdentifier() const
{
return m_identifier;
}

const string& Preference::GetDescription() const
{
return m_description;
}

PreferenceType Preference::GetType() const
{
return m_type;
}

bool Preference::GetBool() const
{
if(m_type != PreferenceType::Boolean)
throw runtime_error("Preference type mismatch");

return GetValueRaw<bool>();
}

double Preference::GetReal() const
{
if(m_type != PreferenceType::Real)
throw runtime_error("Preference type mismatch");

return GetValueRaw<double>();
}

const std::string& Preference::GetString() const
{
if(m_type != PreferenceType::String)
throw runtime_error("Preference type mismatch");

return GetValueRaw<std::string>();
}

void Preference::CleanUp()
{
if(m_type == PreferenceType::String)
(reinterpret_cast<string*>(&m_value))->~basic_string();
}

string Preference::ToString() const
{
switch(m_type)
{
case PreferenceType::String:
return GetString();
case PreferenceType::Boolean:
return GetBool() ? "true" : "false";
case PreferenceType::Real:
return to_string(GetReal());
default:
throw runtime_error("tried to retrieve value from preference in moved-from state");
}
}

void Preference::MoveFrom(Preference& other)
{
m_type = other.m_type;
m_identifier = move(other.m_identifier);
m_description = move(other.m_description);
m_label = move(other.m_label);

switch(other.m_type)
{
case PreferenceType::Boolean:
Construct<bool>(other.GetBool());
break;

case PreferenceType::Real:
Construct<double>(other.GetReal());
break;

case PreferenceType::String:
Construct<string>(move(other.GetValueRaw<string>()));
break;

default:
break;
}

other.m_type = PreferenceType::None;
}


const std::string& Preference::GetLabel() const
{
return m_label;
}

void Preference::SetBool(bool value)
{
CleanUp();
Construct<bool>(value);
}

void Preference::SetReal(double value)
{
CleanUp();
Construct<double>(value);
}

void Preference::SetString(string value)
{
CleanUp();
Construct<string>(move(value));
}
Loading