ModemProperties panel property grid init
This commit is contained in:
parent
4af943791b
commit
5303f329df
|
@ -14,7 +14,7 @@ SET(CPACK_PACKAGE_VERSION_PATCH ${CUBICSDR_VERSION_PATCH})
|
||||||
SET (VERSION_SUFFIX "" CACHE STRING "Add custom version suffix to CubicSDR application title.")
|
SET (VERSION_SUFFIX "" CACHE STRING "Add custom version suffix to CubicSDR application title.")
|
||||||
|
|
||||||
ADD_DEFINITIONS(
|
ADD_DEFINITIONS(
|
||||||
-DCUBICSDR_VERSION="${CUBICSDR_VERSION}-${VERSION_SUFFIX}"
|
-DCUBICSDR_VERSION="${CUBICSDR_VERSION}${VERSION_SUFFIX}"
|
||||||
)
|
)
|
||||||
|
|
||||||
SET (ENABLE_DIGITAL_LAB OFF CACHE BOOL "Enable 'Digital Lab' testing features.")
|
SET (ENABLE_DIGITAL_LAB OFF CACHE BOOL "Enable 'Digital Lab' testing features.")
|
||||||
|
@ -225,6 +225,7 @@ SET (cubicsdr_sources
|
||||||
src/AppConfig.cpp
|
src/AppConfig.cpp
|
||||||
src/FrequencyDialog.cpp
|
src/FrequencyDialog.cpp
|
||||||
src/IOThread.cpp
|
src/IOThread.cpp
|
||||||
|
src/ModemProperties.cpp
|
||||||
src/sdr/SDRDeviceInfo.cpp
|
src/sdr/SDRDeviceInfo.cpp
|
||||||
src/sdr/SDRPostThread.cpp
|
src/sdr/SDRPostThread.cpp
|
||||||
src/sdr/SDREnumerator.cpp
|
src/sdr/SDREnumerator.cpp
|
||||||
|
@ -310,6 +311,7 @@ SET (cubicsdr_headers
|
||||||
src/AppConfig.h
|
src/AppConfig.h
|
||||||
src/FrequencyDialog.h
|
src/FrequencyDialog.h
|
||||||
src/IOThread.h
|
src/IOThread.h
|
||||||
|
src/ModemProperties.h
|
||||||
src/sdr/SDRDeviceInfo.h
|
src/sdr/SDRDeviceInfo.h
|
||||||
src/sdr/SDRPostThread.h
|
src/sdr/SDRPostThread.h
|
||||||
src/sdr/SDREnumerator.h
|
src/sdr/SDREnumerator.h
|
||||||
|
|
|
@ -79,7 +79,7 @@ AppFrame::AppFrame() :
|
||||||
demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0);
|
demodTray->Add(demodModeSelector, 2, wxEXPAND | wxALL, 0);
|
||||||
|
|
||||||
#ifdef ENABLE_DIGITAL_LAB
|
#ifdef ENABLE_DIGITAL_LAB
|
||||||
demodModeSelectorAdv = new ModeSelectorCanvas(this, attribList);
|
demodModeSelectorAdv = new ModeSelectorCanvas(demodPanel, attribList);
|
||||||
demodModeSelectorAdv->addChoice(0, "ASK");
|
demodModeSelectorAdv->addChoice(0, "ASK");
|
||||||
demodModeSelectorAdv->addChoice(1, "APSK");
|
demodModeSelectorAdv->addChoice(1, "APSK");
|
||||||
demodModeSelectorAdv->addChoice(2, "BPSK");
|
demodModeSelectorAdv->addChoice(2, "BPSK");
|
||||||
|
@ -93,6 +93,9 @@ AppFrame::AppFrame() :
|
||||||
demodModeSelectorAdv->addChoice(10, "QPSK");
|
demodModeSelectorAdv->addChoice(10, "QPSK");
|
||||||
demodModeSelectorAdv->setHelpTip("Choose advanced modulation types.");
|
demodModeSelectorAdv->setHelpTip("Choose advanced modulation types.");
|
||||||
demodTray->Add(demodModeSelectorAdv, 3, wxEXPAND | wxALL, 0);
|
demodTray->Add(demodModeSelectorAdv, 3, wxEXPAND | wxALL, 0);
|
||||||
|
|
||||||
|
modemProps = new ModemProperties(demodPanel, wxID_ANY);
|
||||||
|
demodTray->Add(modemProps, 10, wxEXPAND | wxALL, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxGetApp().getDemodSpectrumProcessor()->setup(1024);
|
wxGetApp().getDemodSpectrumProcessor()->setup(1024);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "GainCanvas.h"
|
#include "GainCanvas.h"
|
||||||
#include "FFTVisualDataThread.h"
|
#include "FFTVisualDataThread.h"
|
||||||
#include "SDRDeviceInfo.h"
|
#include "SDRDeviceInfo.h"
|
||||||
|
#include "ModemProperties.h"
|
||||||
//#include "UITestCanvas.h"
|
//#include "UITestCanvas.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -120,6 +121,8 @@ private:
|
||||||
std::thread *t_FFTData;
|
std::thread *t_FFTData;
|
||||||
SDRDeviceInfo *devInfo;
|
SDRDeviceInfo *devInfo;
|
||||||
std::atomic_bool deviceChanged;
|
std::atomic_bool deviceChanged;
|
||||||
|
|
||||||
|
ModemProperties *modemProps;
|
||||||
|
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
#include "ModemProperties.h"
|
||||||
|
|
||||||
|
ModemProperties::ModemProperties(wxWindow *parent, wxWindowID winid,
|
||||||
|
const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxPanel(parent, winid, pos, size, style, name) {
|
||||||
|
|
||||||
|
m_propertyGrid = new wxPropertyGrid(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxPG_DEFAULT_STYLE);
|
||||||
|
|
||||||
|
wxBoxSizer* bSizer;
|
||||||
|
|
||||||
|
bSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
bSizer->Add(m_propertyGrid, wxEXPAND );
|
||||||
|
|
||||||
|
this->SetSizer(bSizer);
|
||||||
|
}
|
||||||
|
|
||||||
|
ModemProperties::~ModemProperties() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModemProperties::initProperties(ModemArgInfoList newArgs) {
|
||||||
|
args = newArgs;
|
||||||
|
|
||||||
|
// props.erase(props.begin(), props.end());
|
||||||
|
|
||||||
|
m_propertyGrid->Clear();
|
||||||
|
m_propertyGrid->Append(new wxPropertyCategory("Modem Settings"));
|
||||||
|
|
||||||
|
ModemArgInfoList::const_iterator args_i;
|
||||||
|
|
||||||
|
for (args_i = args.begin(); args_i != args.end(); args_i++) {
|
||||||
|
ModemArgInfo arg = (*args_i);
|
||||||
|
props.push_back(addArgInfoProperty(m_propertyGrid, arg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPGProperty *ModemProperties::addArgInfoProperty(wxPropertyGrid *pg, ModemArgInfo arg) {
|
||||||
|
wxPGProperty *prop = nullptr;
|
||||||
|
|
||||||
|
int intVal;
|
||||||
|
double floatVal;
|
||||||
|
std::vector<std::string>::iterator stringIter;
|
||||||
|
|
||||||
|
switch (arg.type) {
|
||||||
|
case ModemArgInfo::INT:
|
||||||
|
try {
|
||||||
|
intVal = std::stoi(arg.value);
|
||||||
|
} catch (std::invalid_argument e) {
|
||||||
|
intVal = 0;
|
||||||
|
}
|
||||||
|
prop = pg->Append( new wxIntProperty(arg.name, wxPG_LABEL, intVal) );
|
||||||
|
if (arg.range.minimum() != arg.range.maximum()) {
|
||||||
|
pg->SetPropertyAttribute( prop, wxPG_ATTR_MIN, arg.range.minimum());
|
||||||
|
pg->SetPropertyAttribute( prop, wxPG_ATTR_MAX, arg.range.maximum());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ModemArgInfo::FLOAT:
|
||||||
|
try {
|
||||||
|
floatVal = std::stod(arg.value);
|
||||||
|
} catch (std::invalid_argument e) {
|
||||||
|
floatVal = 0;
|
||||||
|
}
|
||||||
|
prop = pg->Append( new wxFloatProperty(arg.name, wxPG_LABEL, floatVal) );
|
||||||
|
if (arg.range.minimum() != arg.range.maximum()) {
|
||||||
|
pg->SetPropertyAttribute( prop, wxPG_ATTR_MIN, arg.range.minimum());
|
||||||
|
pg->SetPropertyAttribute( prop, wxPG_ATTR_MAX, arg.range.maximum());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ModemArgInfo::BOOL:
|
||||||
|
prop = pg->Append( new wxBoolProperty(arg.name, wxPG_LABEL, (arg.value=="true")) );
|
||||||
|
break;
|
||||||
|
case ModemArgInfo::STRING:
|
||||||
|
if (arg.options.size()) {
|
||||||
|
intVal = 0;
|
||||||
|
prop = pg->Append( new wxEnumProperty(arg.name, wxPG_LABEL) );
|
||||||
|
for (stringIter = arg.options.begin(); stringIter != arg.options.end(); stringIter++) {
|
||||||
|
std::string optName = (*stringIter);
|
||||||
|
std::string displayName = optName;
|
||||||
|
if (arg.optionNames.size()) {
|
||||||
|
displayName = arg.optionNames[intVal];
|
||||||
|
}
|
||||||
|
|
||||||
|
prop->AddChoice(displayName);
|
||||||
|
if ((*stringIter)==arg.value) {
|
||||||
|
prop->SetChoiceSelection(intVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
intVal++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prop = pg->Append( new wxStringProperty(arg.name, wxPG_LABEL, arg.value) );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ModemArgInfo::PATH_DIR:
|
||||||
|
break;
|
||||||
|
case ModemArgInfo::PATH_FILE:
|
||||||
|
break;
|
||||||
|
case ModemArgInfo::COLOR:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prop != NULL) {
|
||||||
|
prop->SetHelpString(arg.key + ": " + arg.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
return prop;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/panel.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/propgrid/propgrid.h>
|
||||||
|
#include <wx/propgrid/advprops.h>
|
||||||
|
|
||||||
|
#include "Modem.h"
|
||||||
|
|
||||||
|
class ModemProperties : public wxPanel {
|
||||||
|
public:
|
||||||
|
ModemProperties(
|
||||||
|
wxWindow *parent,
|
||||||
|
wxWindowID winid = wxID_ANY,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
|
||||||
|
const wxString& name = wxPanelNameStr
|
||||||
|
);
|
||||||
|
~ModemProperties();
|
||||||
|
|
||||||
|
void initProperties(ModemArgInfoList newArgs);
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxPGProperty *addArgInfoProperty(wxPropertyGrid *pg, ModemArgInfo arg);
|
||||||
|
|
||||||
|
wxPropertyGrid* m_propertyGrid;
|
||||||
|
ModemArgInfoList args;
|
||||||
|
std::vector<wxPGProperty *> props;
|
||||||
|
};
|
|
@ -14,6 +14,16 @@ ModemRange::ModemRange(const double minimum, const double maximum) {
|
||||||
_max = maximum;
|
_max = maximum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Get the range minimum
|
||||||
|
double ModemRange::minimum(void) const {
|
||||||
|
return _min;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Get the range maximum
|
||||||
|
double ModemRange::maximum(void) const {
|
||||||
|
return _max;
|
||||||
|
}
|
||||||
|
|
||||||
ModemArgInfo::ModemArgInfo(void) {
|
ModemArgInfo::ModemArgInfo(void) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue