mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-04 08:21:16 -05:00
Modem property grid settings now applying/working
- Still some races with initializing the grid on new demodulators
This commit is contained in:
parent
abdb5d32d9
commit
6e74662518
@ -1,4 +1,5 @@
|
||||
#include "ModemProperties.h"
|
||||
#include "CubicSDR.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) {
|
||||
@ -12,6 +13,8 @@ ModemProperties::ModemProperties(wxWindow *parent, wxWindowID winid,
|
||||
bSizer->Add(m_propertyGrid, 1, wxEXPAND | wxALL, 5);
|
||||
|
||||
this->SetSizer(bSizer);
|
||||
|
||||
m_propertyGrid->Connect( wxEVT_PG_CHANGED, wxPropertyGridEventHandler( ModemProperties::OnChange ), NULL, this );
|
||||
}
|
||||
|
||||
ModemProperties::~ModemProperties() {
|
||||
@ -21,8 +24,6 @@ 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"));
|
||||
|
||||
@ -30,7 +31,7 @@ void ModemProperties::initProperties(ModemArgInfoList newArgs) {
|
||||
|
||||
for (args_i = args.begin(); args_i != args.end(); args_i++) {
|
||||
ModemArgInfo arg = (*args_i);
|
||||
props.push_back(addArgInfoProperty(m_propertyGrid, arg));
|
||||
props[arg.key] = addArgInfoProperty(m_propertyGrid, arg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,3 +107,39 @@ wxPGProperty *ModemProperties::addArgInfoProperty(wxPropertyGrid *pg, ModemArgIn
|
||||
return prop;
|
||||
}
|
||||
|
||||
std::string ModemProperties::readProperty(std::string key) {
|
||||
int i = 0;
|
||||
ModemArgInfoList::const_iterator args_i;
|
||||
|
||||
for (args_i = args.begin(); args_i != args.end(); args_i++) {
|
||||
ModemArgInfo arg = (*args_i);
|
||||
if (arg.key == key) {
|
||||
wxPGProperty *prop = props[key];
|
||||
|
||||
std::string result = "";
|
||||
if (arg.type == ModemArgInfo::STRING && arg.options.size()) {
|
||||
return arg.options[prop->GetChoiceSelection()];
|
||||
} else if (arg.type == ModemArgInfo::BOOL) {
|
||||
return (prop->GetValueAsString()=="True")?"true":"false";
|
||||
} else {
|
||||
return prop->GetValueAsString().ToStdString();
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
void ModemProperties::OnChange(wxPropertyGridEvent &event) {
|
||||
DemodulatorInstance *inst = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||
|
||||
std::map<std::string, wxPGProperty *>::const_iterator prop_i;
|
||||
for (prop_i = props.begin(); prop_i != props.end(); prop_i++) {
|
||||
if (prop_i->second == event.m_property) {
|
||||
std::string key = prop_i->first;
|
||||
std::string value = readProperty(prop_i->first);
|
||||
inst->writeModemSetting(key, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,13 @@ public:
|
||||
~ModemProperties();
|
||||
|
||||
void initProperties(ModemArgInfoList newArgs);
|
||||
|
||||
|
||||
private:
|
||||
wxPGProperty *addArgInfoProperty(wxPropertyGrid *pg, ModemArgInfo arg);
|
||||
std::string readProperty(std::string);
|
||||
void OnChange(wxPropertyGridEvent &event);
|
||||
|
||||
wxPropertyGrid* m_propertyGrid;
|
||||
ModemArgInfoList args;
|
||||
std::vector<wxPGProperty *> props;
|
||||
std::map<std::string, wxPGProperty *> props;
|
||||
};
|
@ -68,37 +68,28 @@ std::string ModemAPSK::readSetting(std::string setting) {
|
||||
}
|
||||
|
||||
void ModemAPSK::updateDemodulatorCons(int cons) {
|
||||
this->cons = cons;
|
||||
switch (cons) {
|
||||
case 4:
|
||||
demodAPSK = demodAPSK4;
|
||||
updateDemodulatorCons(4);
|
||||
break;
|
||||
case 8:
|
||||
demodAPSK = demodAPSK8;
|
||||
updateDemodulatorCons(8);
|
||||
break;
|
||||
case 16:
|
||||
demodAPSK = demodAPSK16;
|
||||
updateDemodulatorCons(16);
|
||||
break;
|
||||
case 32:
|
||||
demodAPSK = demodAPSK32;
|
||||
updateDemodulatorCons(32);
|
||||
break;
|
||||
case 64:
|
||||
demodAPSK = demodAPSK64;
|
||||
updateDemodulatorCons(64);
|
||||
break;
|
||||
case 128:
|
||||
demodAPSK = demodAPSK128;
|
||||
updateDemodulatorCons(128);
|
||||
break;
|
||||
case 256:
|
||||
demodAPSK = demodAPSK256;
|
||||
updateDemodulatorCons(256);
|
||||
break;
|
||||
default:
|
||||
demodAPSK = demodAPSK4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user