mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-12 23:26:10 -05:00
AppFrame Cleanup: Move config, menubar inits
This commit is contained in:
parent
8d09d9c329
commit
5f3de57bd8
167
src/AppFrame.cpp
167
src/AppFrame.cpp
@ -69,21 +69,23 @@ public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* split a string by 'seperator' into a vector of string */
|
||||
std::vector<std::string> str_explode(const std::string &seperator, const std::string &in_str);
|
||||
|
||||
#define APPFRAME_MODEMPROPS_MINSIZE 20
|
||||
#define APPFRAME_MODEMPROPS_MAXSIZE 240
|
||||
|
||||
AppFrame::AppFrame() :
|
||||
wxFrame(NULL, wxID_ANY, CUBICSDR_TITLE), activeDemodulator(nullptr) {
|
||||
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
SetIcon(wxICON(cubicsdr));
|
||||
#endif
|
||||
initIcon();
|
||||
|
||||
devInfo = NULL;
|
||||
|
||||
deviceChanged.store(false);
|
||||
modemPropertiesUpdated.store(false);
|
||||
|
||||
saveDisabled = false;
|
||||
aboutDlg = nullptr;
|
||||
|
||||
|
||||
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
|
||||
demodTray = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer *demodScopeTray = new wxBoxSizer(wxVERTICAL);
|
||||
wxBoxSizer *demodTunerTray = new wxBoxSizer(wxHORIZONTAL);
|
||||
@ -136,8 +138,6 @@ AppFrame::AppFrame() :
|
||||
demodTray->Add(demodModeSelectorAdv, 3, wxEXPAND | wxALL, 0);
|
||||
#endif
|
||||
|
||||
modemPropertiesUpdated.store(false);
|
||||
|
||||
// Modem properties panel
|
||||
modemProps = makeModemProperties(demodPanel);
|
||||
|
||||
@ -171,7 +171,6 @@ AppFrame::AppFrame() :
|
||||
demodVisuals->SetMinSize(wxSize(128,-1));
|
||||
|
||||
demodTray->Add(demodVisuals, 30, wxEXPAND | wxALL, 0);
|
||||
|
||||
demodTray->AddSpacer(1);
|
||||
#else
|
||||
demodSpectrumCanvas = nullptr;
|
||||
@ -181,13 +180,11 @@ AppFrame::AppFrame() :
|
||||
// Demod Signal/Squelch Meter
|
||||
demodSignalMeter = makeSignalMeter(demodPanel, attribList);
|
||||
demodTray->Add(demodSignalMeter, 1, wxEXPAND | wxALL, 0);
|
||||
|
||||
demodTray->AddSpacer(1);
|
||||
|
||||
#if CUBICSDR_ENABLE_VIEW_SCOPE
|
||||
// Scope
|
||||
scopeCanvas = makeScopeCanvas(demodPanel, attribList);
|
||||
|
||||
demodScopeTray->Add(scopeCanvas, 8, wxEXPAND | wxALL, 0);
|
||||
|
||||
wxGetApp().getScopeProcessor()->setup(DEFAULT_SCOPE_FFT_SIZE);
|
||||
@ -206,13 +203,10 @@ AppFrame::AppFrame() :
|
||||
|
||||
// Modem Tuner
|
||||
demodTuner = makeModemTuner(demodPanel, attribList);
|
||||
|
||||
demodTunerTray->Add(demodTuner, 1, wxEXPAND | wxALL, 0);
|
||||
|
||||
demodScopeTray->Add(demodTunerTray, 1, wxEXPAND | wxALL, 0);
|
||||
|
||||
demodTray->Add(demodScopeTray, 30, wxEXPAND | wxALL, 0);
|
||||
|
||||
demodTray->AddSpacer(1);
|
||||
|
||||
wxBoxSizer *demodGainTray = new wxBoxSizer(wxVERTICAL);
|
||||
@ -220,13 +214,11 @@ AppFrame::AppFrame() :
|
||||
// Demod Gain Meter
|
||||
demodGainMeter = makeModemGainMeter(demodPanel, attribList);
|
||||
demodGainTray->Add(demodGainMeter, 8, wxEXPAND | wxALL, 0);
|
||||
|
||||
demodGainTray->AddSpacer(1);
|
||||
|
||||
// Solo Button
|
||||
soloModeButton = makeSoloModeButton(demodPanel, attribList);
|
||||
demodGainTray->Add(soloModeButton, 1, wxEXPAND | wxALL, 0);
|
||||
|
||||
demodGainTray->AddSpacer(1);
|
||||
|
||||
// Mute Button
|
||||
@ -261,38 +253,36 @@ AppFrame::AppFrame() :
|
||||
|
||||
// Peak Hold
|
||||
peakHoldButton = makePeakHoldButton(spectrumPanel, attribList);
|
||||
|
||||
spectrumCtlTray->Add(peakHoldButton, 1, wxEXPAND | wxALL, 0);
|
||||
spectrumCtlTray->AddSpacer(1);
|
||||
|
||||
// Spectrum Average Meter
|
||||
spectrumAvgMeter = makeSpectrumAvgMeter(spectrumPanel, attribList);
|
||||
|
||||
spectrumCtlTray->Add(spectrumAvgMeter, 8, wxEXPAND | wxALL, 0);
|
||||
spectrumSizer->Add(spectrumCtlTray, 1, wxEXPAND | wxALL, 0);
|
||||
spectrumPanel->SetSizer(spectrumSizer);
|
||||
|
||||
wxPanel *waterfallPanel = new wxPanel(mainVisSplitter, wxID_ANY);
|
||||
wxBoxSizer *wfSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
wxBoxSizer *waterfallSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
// Waterfall
|
||||
waterfallCanvas = makeWaterfall(waterfallPanel, attribList);
|
||||
|
||||
// Create and connect the FFT visual data thread
|
||||
waterfallDataThread = new FFTVisualDataThread();
|
||||
|
||||
waterfallDataThread->setInputQueue("IQDataInput", wxGetApp().getWaterfallVisualQueue());
|
||||
waterfallDataThread->setOutputQueue("FFTDataOutput", waterfallCanvas->getVisualDataQueue());
|
||||
waterfallDataThread->getProcessor()->setHideDC(true);
|
||||
|
||||
t_FFTData = new std::thread(&FFTVisualDataThread::threadMain, waterfallDataThread);
|
||||
|
||||
|
||||
// Waterfall speed meter
|
||||
waterfallSpeedMeter = makeWaterfallSpeedMeter(waterfallPanel, attribList);
|
||||
|
||||
wfSizer->Add(waterfallCanvas, 63, wxEXPAND | wxALL, 0);
|
||||
wfSizer->AddSpacer(1);
|
||||
wfSizer->Add(waterfallSpeedMeter, 1, wxEXPAND | wxALL, 0);
|
||||
waterfallPanel->SetSizer(wfSizer);
|
||||
waterfallSizer->Add(waterfallCanvas, 63, wxEXPAND | wxALL, 0);
|
||||
waterfallSizer->AddSpacer(1);
|
||||
waterfallSizer->Add(waterfallSpeedMeter, 1, wxEXPAND | wxALL, 0);
|
||||
waterfallPanel->SetSizer(waterfallSizer);
|
||||
|
||||
mainVisSplitter->SplitHorizontally( spectrumPanel, waterfallPanel, 0 );
|
||||
|
||||
@ -300,18 +290,16 @@ AppFrame::AppFrame() :
|
||||
bookmarkView = new BookmarkView(bookmarkSplitter, wxID_ANY, wxDefaultPosition, wxSize(120,-1));
|
||||
bookmarkSplitter->SplitVertically( bookmarkView, mainVisSplitter );
|
||||
mainSplitter->SplitHorizontally( demodPanel, bookmarkSplitter );
|
||||
|
||||
if (!wxGetApp().getConfig()->getBookmarksVisible()) {
|
||||
bookmarkSplitter->Unsplit(bookmarkView);
|
||||
bookmarkSplitter->Layout();
|
||||
}
|
||||
|
||||
vbox->Add(mainSplitter, 1, wxEXPAND | wxALL, 0);
|
||||
|
||||
|
||||
// TODO: refactor these..
|
||||
waterfallCanvas->attachSpectrumCanvas(spectrumCanvas);
|
||||
spectrumCanvas->attachWaterfallCanvas(waterfallCanvas);
|
||||
|
||||
// Primary sizer for the window
|
||||
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
|
||||
vbox->Add(mainSplitter, 1, wxEXPAND | wxALL, 0);
|
||||
|
||||
/* * /
|
||||
vbox->AddSpacer(1);
|
||||
testCanvas = new UITestCanvas(this, attribList);
|
||||
@ -320,7 +308,36 @@ AppFrame::AppFrame() :
|
||||
|
||||
this->SetSizer(vbox);
|
||||
|
||||
// File Menu
|
||||
// Load and apply configuration
|
||||
initConfigurationSettings();
|
||||
|
||||
// Initialize menu
|
||||
initMenuBar();
|
||||
|
||||
// Create status bar
|
||||
CreateStatusBar();
|
||||
|
||||
// Show the window
|
||||
Show();
|
||||
|
||||
// Force refresh of all
|
||||
Refresh();
|
||||
|
||||
// Pop up the device selector
|
||||
wxGetApp().deviceSelector();
|
||||
}
|
||||
|
||||
void AppFrame::initIcon() {
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
SetIcon(wxICON(cubicsdr));
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
SetIcon(wxICON(frame_icon));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void AppFrame::initMenuBar() {// File Menu
|
||||
menuBar = new wxMenuBar;
|
||||
fileMenu = makeFileMenu();
|
||||
menuBar->Append(fileMenu, wxT("&File"));
|
||||
@ -336,16 +353,12 @@ AppFrame::AppFrame() :
|
||||
// Audio Sample Rate Menu
|
||||
menuBar->Append(makeAudioSampleRateMenu(), wxT("Audio &Sample Rate"));
|
||||
|
||||
//Add a Recording menu
|
||||
//Add a Recording menu
|
||||
recordingMenu = makeRecordingMenu();
|
||||
menuBar->Append(recordingMenu, wxT("Recordin&g"));
|
||||
updateRecordingMenu();
|
||||
menuBar->Append(recordingMenu, wxT("Recordin&g"));
|
||||
updateRecordingMenu();
|
||||
|
||||
#ifdef USE_HAMLIB
|
||||
rigModel = wxGetApp().getConfig()->getRigModel();
|
||||
rigSerialRate = wxGetApp().getConfig()->getRigRate();
|
||||
rigPort = wxGetApp().getConfig()->getRigPort();
|
||||
|
||||
rigPortDialog = nullptr;
|
||||
|
||||
// Rig Menu
|
||||
@ -359,7 +372,20 @@ AppFrame::AppFrame() :
|
||||
|
||||
SetMenuBar(menuBar);
|
||||
|
||||
CreateStatusBar();
|
||||
wxAcceleratorEntry entries[3];
|
||||
entries[0].Set(wxACCEL_CTRL, (int) 'O', wxID_OPEN);
|
||||
entries[1].Set(wxACCEL_CTRL, (int) 'S', wxID_SAVE);
|
||||
entries[2].Set(wxACCEL_CTRL, (int) 'A', wxID_SAVEAS);
|
||||
|
||||
wxAcceleratorTable accel(3, entries);
|
||||
SetAcceleratorTable(accel);
|
||||
}
|
||||
|
||||
void AppFrame::initConfigurationSettings() {
|
||||
|
||||
// Init Theme
|
||||
ThemeMgr::mgr.setTheme(wxGetApp().getConfig()->getTheme());
|
||||
bookmarkView->updateTheme();
|
||||
|
||||
// Init Font Scale
|
||||
int fontScale = wxGetApp().getConfig()->getFontScale();
|
||||
@ -368,73 +394,66 @@ AppFrame::AppFrame() :
|
||||
// Init window position from configuration
|
||||
wxRect *win = wxGetApp().getConfig()->getWindow();
|
||||
if (win) {
|
||||
this->SetPosition(win->GetPosition());
|
||||
this->SetClientSize(win->GetSize());
|
||||
SetPosition(win->GetPosition());
|
||||
SetClientSize(win->GetSize());
|
||||
} else {
|
||||
SetClientSize(1280, 600);
|
||||
Centre();
|
||||
}
|
||||
|
||||
// Maximized last time?
|
||||
// Init maximize state
|
||||
if (wxGetApp().getConfig()->getWindowMaximized()) {
|
||||
this->Maximize();
|
||||
Maximize();
|
||||
}
|
||||
|
||||
// Init frequency snap
|
||||
wxGetApp().setFrequencySnap(wxGetApp().getConfig()->getSnap());
|
||||
|
||||
// Init spectrum average speed
|
||||
float spectrumAvg = wxGetApp().getConfig()->getSpectrumAvgSpeed();
|
||||
spectrumAvgMeter->setLevel(spectrumAvg);
|
||||
wxGetApp().getSpectrumProcessor()->setFFTAverageRate(spectrumAvg);
|
||||
|
||||
|
||||
// Init waterfall speed
|
||||
int wflps =wxGetApp().getConfig()->getWaterfallLinesPerSec();
|
||||
|
||||
waterfallSpeedMeter->setLevel(sqrt(wflps));
|
||||
waterfallSpeedMeter->setLevel(sqrtf(wflps));
|
||||
waterfallDataThread->setLinesPerSecond(wflps);
|
||||
waterfallCanvas->setLinesPerSecond(wflps);
|
||||
|
||||
ThemeMgr::mgr.setTheme(wxGetApp().getConfig()->getTheme());
|
||||
bookmarkView->updateTheme();
|
||||
|
||||
// Init modem property collapsed state
|
||||
int mpc =wxGetApp().getConfig()->getModemPropsCollapsed();
|
||||
|
||||
if (mpc) {
|
||||
modemProps->setCollapsed(true);
|
||||
}
|
||||
|
||||
// Init main splitter position (separates top/bottom area horizontally)
|
||||
int msPos = wxGetApp().getConfig()->getMainSplit();
|
||||
if (msPos != -1) {
|
||||
mainSplitter->SetSashPosition(msPos);
|
||||
}
|
||||
|
||||
// Init bookmark splitter position (separates bookmark/main vis vertically)
|
||||
int bsPos = wxGetApp().getConfig()->getBookmarkSplit();
|
||||
if (bsPos != -1) {
|
||||
bookmarkSplitter->SetSashPosition(bsPos);
|
||||
}
|
||||
|
||||
// Init vis splitter position (separates spectrum/waterfall horizontally)
|
||||
int vsPos = wxGetApp().getConfig()->getVisSplit();
|
||||
if (vsPos != -1) {
|
||||
mainVisSplitter->SetSashPosition(vsPos);
|
||||
}
|
||||
|
||||
Show();
|
||||
|
||||
#ifdef _WIN32
|
||||
SetIcon(wxICON(frame_icon));
|
||||
if (!wxGetApp().getConfig()->getBookmarksVisible()) {
|
||||
bookmarkSplitter->Unsplit(bookmarkView);
|
||||
bookmarkSplitter->Layout();
|
||||
}
|
||||
|
||||
#ifdef USE_HAMLIB
|
||||
rigModel = wxGetApp().getConfig()->getRigModel();
|
||||
rigSerialRate = wxGetApp().getConfig()->getRigRate();
|
||||
rigPort = wxGetApp().getConfig()->getRigPort();
|
||||
#endif
|
||||
|
||||
wxAcceleratorEntry entries[3];
|
||||
entries[0].Set(wxACCEL_CTRL, (int) 'O', wxID_OPEN);
|
||||
entries[1].Set(wxACCEL_CTRL, (int) 'S', wxID_SAVE);
|
||||
entries[2].Set(wxACCEL_CTRL, (int) 'A', wxID_SAVEAS);
|
||||
|
||||
wxAcceleratorTable accel(3, entries);
|
||||
SetAcceleratorTable(accel);
|
||||
deviceChanged.store(false);
|
||||
devInfo = NULL;
|
||||
wxGetApp().deviceSelector();
|
||||
saveDisabled = false;
|
||||
aboutDlg = nullptr;
|
||||
|
||||
//Force refresh of all
|
||||
Refresh();
|
||||
}
|
||||
|
||||
ModemProperties *AppFrame::makeModemProperties(wxPanel *parent) {
|
||||
|
@ -228,12 +228,8 @@ private:
|
||||
//depending on context, maps the item id to wxMenuItem*,
|
||||
//OR the submenu item id to its parent wxMenuItem*.
|
||||
std::map<int, wxMenuItem *> settingsMenuItems;
|
||||
|
||||
std::map<int, wxMenuItem *> performanceMenuItems;
|
||||
|
||||
std::map<int, wxMenuItem *> audioSampleRateMenuItems;
|
||||
|
||||
//
|
||||
std::map<int, wxMenuItem *> recordingMenuItems;
|
||||
|
||||
wxMenuBar *menuBar;
|
||||
@ -273,34 +269,8 @@ private:
|
||||
bool saveDisabled;
|
||||
|
||||
AboutDialog *aboutDlg;
|
||||
|
||||
std::string lastToolTip;
|
||||
|
||||
#ifdef USE_HAMLIB
|
||||
void enableRig();
|
||||
void disableRig();
|
||||
|
||||
wxMenu *rigMenu;
|
||||
wxMenuItem *rigEnableMenuItem;
|
||||
wxMenuItem *rigPortMenuItem;
|
||||
wxMenuItem *rigControlMenuItem;
|
||||
wxMenuItem *rigFollowMenuItem;
|
||||
wxMenuItem *rigCenterLockMenuItem;
|
||||
wxMenuItem *rigFollowModemMenuItem;
|
||||
|
||||
std::map<int, wxMenuItem *> rigSerialMenuItems;
|
||||
std::map<int, wxMenuItem *> rigModelMenuItems;
|
||||
int rigModel;
|
||||
int rigSerialRate;
|
||||
long long rigSDRIF;
|
||||
std::vector<int> rigSerialRates;
|
||||
std::string rigPort;
|
||||
int numRigs;
|
||||
PortSelectorDialog *rigPortDialog;
|
||||
#endif
|
||||
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
|
||||
ModeSelectorCanvas *makeModemSelectorPanel(wxWindow *parent, const wxGLAttributes &attribList);
|
||||
WaterfallCanvas *makeWaterfallCanvas(wxWindow *parent, const wxGLAttributes &attribList);
|
||||
SpectrumCanvas *makeDemodSpectrumCanvas(wxWindow *parent, const wxGLAttributes &attribList);
|
||||
@ -319,11 +289,12 @@ private:
|
||||
ModeSelectorCanvas *makeModemAdvSelectorPanel(wxPanel *parent, const wxGLAttributes &attribList);
|
||||
ModemProperties *makeModemProperties(wxPanel *parent);
|
||||
|
||||
void initConfigurationSettings();
|
||||
void initMenuBar();
|
||||
void initIcon();
|
||||
|
||||
wxMenu *makeAudioSampleRateMenu();
|
||||
wxMenu *makeDisplayMenu();
|
||||
#ifdef USE_HAMLIB
|
||||
wxMenu *makeRigMenu();
|
||||
#endif
|
||||
|
||||
void handleTXAntennaChange();
|
||||
void handleCurrentModem();
|
||||
@ -337,7 +308,33 @@ private:
|
||||
void handleModemProperties();
|
||||
void handlePeakHold();
|
||||
|
||||
#if USE_HAMLIB
|
||||
|
||||
#ifdef USE_HAMLIB
|
||||
void enableRig();
|
||||
void disableRig();
|
||||
|
||||
wxMenu *rigMenu;
|
||||
wxMenuItem *rigEnableMenuItem;
|
||||
wxMenuItem *rigPortMenuItem;
|
||||
wxMenuItem *rigControlMenuItem;
|
||||
wxMenuItem *rigFollowMenuItem;
|
||||
wxMenuItem *rigCenterLockMenuItem;
|
||||
wxMenuItem *rigFollowModemMenuItem;
|
||||
|
||||
std::map<int, wxMenuItem *> rigSerialMenuItems;
|
||||
std::map<int, wxMenuItem *> rigModelMenuItems;
|
||||
int rigModel;
|
||||
int rigSerialRate;
|
||||
long long rigSDRIF;
|
||||
std::vector<int> rigSerialRates;
|
||||
std::string rigPort;
|
||||
int numRigs;
|
||||
PortSelectorDialog *rigPortDialog;
|
||||
|
||||
wxMenu *makeRigMenu();
|
||||
void handleRigMenu();
|
||||
#endif
|
||||
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user