mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-11 18:28:57 -04:00
+66
-21
@@ -31,7 +31,7 @@
|
||||
|
||||
wxBEGIN_EVENT_TABLE(AppFrame, wxFrame)
|
||||
//EVT_MENU(wxID_NEW, AppFrame::OnNewWindow)
|
||||
EVT_MENU(wxID_CLOSE, AppFrame::OnClose)
|
||||
EVT_CLOSE(AppFrame::OnClose)
|
||||
EVT_MENU(wxID_ANY, AppFrame::OnMenu)
|
||||
EVT_COMMAND(wxID_ANY, wxEVT_THREAD, AppFrame::OnThread)
|
||||
EVT_IDLE(AppFrame::OnIdle)
|
||||
@@ -152,9 +152,9 @@ AppFrame::AppFrame() :
|
||||
|
||||
wxMenu *dsMenu = new wxMenu;
|
||||
|
||||
dsMenu->AppendRadioItem(wxID_SET_DS_OFF, "Off");
|
||||
dsMenu->AppendRadioItem(wxID_SET_DS_I, "I-ADC");
|
||||
dsMenu->AppendRadioItem(wxID_SET_DS_Q, "Q-ADC");
|
||||
directSamplingMenuItems[0] = dsMenu->AppendRadioItem(wxID_SET_DS_OFF, "Off");
|
||||
directSamplingMenuItems[1] = dsMenu->AppendRadioItem(wxID_SET_DS_I, "I-ADC");
|
||||
directSamplingMenuItems[2] = dsMenu->AppendRadioItem(wxID_SET_DS_Q, "Q-ADC");
|
||||
|
||||
menu->AppendSubMenu(dsMenu, "Direct Sampling");
|
||||
|
||||
@@ -191,13 +191,15 @@ AppFrame::AppFrame() :
|
||||
|
||||
menu = new wxMenu;
|
||||
|
||||
menu->AppendRadioItem(wxID_THEME_DEFAULT, "Default")->Check(true);
|
||||
menu->AppendRadioItem(wxID_THEME_RADAR, "RADAR");
|
||||
menu->AppendRadioItem(wxID_THEME_BW, "Black & White");
|
||||
menu->AppendRadioItem(wxID_THEME_SHARP, "Sharp");
|
||||
menu->AppendRadioItem(wxID_THEME_RAD, "Rad");
|
||||
menu->AppendRadioItem(wxID_THEME_TOUCH, "Touch");
|
||||
menu->AppendRadioItem(wxID_THEME_HD, "HD");
|
||||
int themeId = wxGetApp().getConfig()->getTheme();
|
||||
|
||||
menu->AppendRadioItem(wxID_THEME_DEFAULT, "Default")->Check(themeId==COLOR_THEME_DEFAULT);
|
||||
menu->AppendRadioItem(wxID_THEME_RADAR, "RADAR")->Check(themeId==COLOR_THEME_RADAR);
|
||||
menu->AppendRadioItem(wxID_THEME_BW, "Black & White")->Check(themeId==COLOR_THEME_BW);
|
||||
menu->AppendRadioItem(wxID_THEME_SHARP, "Sharp")->Check(themeId==COLOR_THEME_SHARP);
|
||||
menu->AppendRadioItem(wxID_THEME_RAD, "Rad")->Check(themeId==COLOR_THEME_RAD);
|
||||
menu->AppendRadioItem(wxID_THEME_TOUCH, "Touch")->Check(themeId==COLOR_THEME_TOUCH);
|
||||
menu->AppendRadioItem(wxID_THEME_HD, "HD")->Check(themeId==COLOR_THEME_HD);
|
||||
|
||||
menuBar->Append(menu, wxT("&Color Scheme"));
|
||||
|
||||
@@ -303,8 +305,23 @@ AppFrame::AppFrame() :
|
||||
SetMenuBar(menuBar);
|
||||
|
||||
CreateStatusBar();
|
||||
SetClientSize(1280, 600);
|
||||
Centre();
|
||||
|
||||
wxRect *win = wxGetApp().getConfig()->getWindow();
|
||||
if (win) {
|
||||
this->SetPosition(win->GetPosition());
|
||||
this->SetClientSize(win->GetSize());
|
||||
} else {
|
||||
SetClientSize(1280, 600);
|
||||
Centre();
|
||||
}
|
||||
bool max = wxGetApp().getConfig()->getWindowMaximized();
|
||||
|
||||
if (max) {
|
||||
this->Maximize();
|
||||
}
|
||||
|
||||
ThemeMgr::mgr.setTheme(wxGetApp().getConfig()->getTheme());
|
||||
|
||||
Show();
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -329,6 +346,22 @@ AppFrame::~AppFrame() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AppFrame::initDeviceParams(std::string deviceId) {
|
||||
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(deviceId);
|
||||
|
||||
int dsMode = devConfig->getDirectSampling();
|
||||
|
||||
if (dsMode > 0 && dsMode <= 2) {
|
||||
directSamplingMenuItems[devConfig->getDirectSampling()]->Check();
|
||||
}
|
||||
|
||||
if (devConfig->getIQSwap()) {
|
||||
iqSwapMenuItem->Check();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AppFrame::OnMenu(wxCommandEvent& event) {
|
||||
if (event.GetId() >= wxID_RT_AUDIO_DEVICE && event.GetId() < wxID_RT_AUDIO_DEVICE + devices.size()) {
|
||||
if (activeDemodulator) {
|
||||
@@ -449,7 +482,19 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
||||
|
||||
std::vector<SDRDeviceInfo *> *devs = wxGetApp().getDevices();
|
||||
if (event.GetId() >= wxID_DEVICE_ID && event.GetId() <= wxID_DEVICE_ID + devs->size()) {
|
||||
wxGetApp().setDevice(event.GetId() - wxID_DEVICE_ID);
|
||||
int devId = event.GetId() - wxID_DEVICE_ID;
|
||||
wxGetApp().setDevice(devId);
|
||||
|
||||
SDRDeviceInfo *dev = (*wxGetApp().getDevices())[devId];
|
||||
DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId());
|
||||
|
||||
int dsMode = devConfig->getDirectSampling();
|
||||
|
||||
if (dsMode >= 0 && dsMode <= 2) {
|
||||
directSamplingMenuItems[devConfig->getDirectSampling()]->Check();
|
||||
}
|
||||
|
||||
iqSwapMenuItem->Check(devConfig->getIQSwap());
|
||||
}
|
||||
|
||||
if (event.GetId() >= wxID_AUDIO_BANDWIDTH_BASE) {
|
||||
@@ -479,8 +524,12 @@ void AppFrame::OnMenu(wxCommandEvent& event) {
|
||||
|
||||
}
|
||||
|
||||
void AppFrame::OnClose(wxCommandEvent& WXUNUSED(event)) {
|
||||
Close(false);
|
||||
void AppFrame::OnClose(wxCloseEvent& event) {
|
||||
wxGetApp().getConfig()->setWindow(this->GetPosition(), this->GetClientSize());
|
||||
wxGetApp().getConfig()->setWindowMaximized(this->IsMaximized());
|
||||
wxGetApp().getConfig()->setTheme(ThemeMgr::mgr.getTheme());
|
||||
wxGetApp().getConfig()->save();
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void AppFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event)) {
|
||||
@@ -618,7 +667,6 @@ void AppFrame::saveSession(std::string fileName) {
|
||||
DataNode *header = s.rootNode()->newChild("header");
|
||||
*header->newChild("version") = std::string(CUBICSDR_VERSION);
|
||||
*header->newChild("center_freq") = wxGetApp().getFrequency();
|
||||
*header->newChild("offset") = wxGetApp().getOffset();
|
||||
|
||||
DataNode *demods = s.rootNode()->newChild("demodulators");
|
||||
|
||||
@@ -657,14 +705,11 @@ bool AppFrame::loadSession(std::string fileName) {
|
||||
|
||||
std::string version(*header->getNext("version"));
|
||||
long long center_freq = *header->getNext("center_freq");
|
||||
long long offset = *header->getNext("offset");
|
||||
|
||||
std::cout << "Loading " << version << " session file" << std::endl;
|
||||
std::cout << "\tCenter Frequency: " << center_freq << std::endl;
|
||||
std::cout << "\tOffset: " << offset << std::endl;
|
||||
|
||||
wxGetApp().setFrequency(center_freq);
|
||||
wxGetApp().setOffset(offset);
|
||||
|
||||
DataNode *demodulators = l.rootNode()->getNext("demodulators");
|
||||
|
||||
@@ -712,7 +757,7 @@ bool AppFrame::loadSession(std::string fileName) {
|
||||
}
|
||||
|
||||
newDemod->run();
|
||||
|
||||
newDemod->setActive(false);
|
||||
wxGetApp().bindDemodulator(newDemod);
|
||||
|
||||
std::cout << "\tAdded demodulator at frequency " << freq << " type " << type << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user