mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-26 05:38:39 -05:00
Merge pull request #396 from cjcliffe/session_save_viewstate
Save session view-state and delay loaded active modem to after frequency/view load
This commit is contained in:
commit
3bf17d0f40
@ -1589,6 +1589,13 @@ void AppFrame::saveSession(std::string fileName) {
|
|||||||
*header->newChild("center_freq") = wxGetApp().getFrequency();
|
*header->newChild("center_freq") = wxGetApp().getFrequency();
|
||||||
*header->newChild("sample_rate") = wxGetApp().getSampleRate();
|
*header->newChild("sample_rate") = wxGetApp().getSampleRate();
|
||||||
|
|
||||||
|
if (waterfallCanvas->getViewState()) {
|
||||||
|
DataNode *viewState = header->newChild("view_state");
|
||||||
|
|
||||||
|
*viewState->newChild("center_freq") = waterfallCanvas->getCenterFrequency();
|
||||||
|
*viewState->newChild("bandwidth") = waterfallCanvas->getBandwidth();
|
||||||
|
}
|
||||||
|
|
||||||
DataNode *demods = s.rootNode()->newChild("demodulators");
|
DataNode *demods = s.rootNode()->newChild("demodulators");
|
||||||
|
|
||||||
std::vector<DemodulatorInstance *> &instances = wxGetApp().getDemodMgr().getDemodulators();
|
std::vector<DemodulatorInstance *> &instances = wxGetApp().getDemodMgr().getDemodulators();
|
||||||
@ -1651,13 +1658,6 @@ bool AppFrame::loadSession(std::string fileName) {
|
|||||||
// std::cout << "Loading " << version << " session file" << std::endl;
|
// std::cout << "Loading " << version << " session file" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (header->hasAnother("center_freq")) {
|
|
||||||
long long center_freq = *header->getNext("center_freq");
|
|
||||||
// std::cout << "\tCenter Frequency: " << center_freq << std::endl;
|
|
||||||
|
|
||||||
wxGetApp().setFrequency(center_freq);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (header->hasAnother("sample_rate")) {
|
if (header->hasAnother("sample_rate")) {
|
||||||
int sample_rate = *header->getNext("sample_rate");
|
int sample_rate = *header->getNext("sample_rate");
|
||||||
|
|
||||||
@ -1673,12 +1673,14 @@ bool AppFrame::loadSession(std::string fileName) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DemodulatorInstance *loadedActiveDemod = nullptr;
|
||||||
|
DemodulatorInstance *newDemod = nullptr;
|
||||||
|
|
||||||
if (l.rootNode()->hasAnother("demodulators")) {
|
if (l.rootNode()->hasAnother("demodulators")) {
|
||||||
|
|
||||||
DataNode *demodulators = l.rootNode()->getNext("demodulators");
|
DataNode *demodulators = l.rootNode()->getNext("demodulators");
|
||||||
|
|
||||||
int numDemodulators = 0;
|
int numDemodulators = 0;
|
||||||
DemodulatorInstance *loadedDemod = NULL;
|
|
||||||
DemodulatorInstance *newDemod = NULL;
|
|
||||||
std::vector<DemodulatorInstance *> demodsLoaded;
|
std::vector<DemodulatorInstance *> demodsLoaded;
|
||||||
|
|
||||||
while (demodulators->hasAnother("demodulator")) {
|
while (demodulators->hasAnother("demodulator")) {
|
||||||
@ -1760,7 +1762,7 @@ bool AppFrame::loadSession(std::string fileName) {
|
|||||||
newDemod = wxGetApp().getDemodMgr().newThread();
|
newDemod = wxGetApp().getDemodMgr().newThread();
|
||||||
|
|
||||||
if (demod->hasAnother("active")) {
|
if (demod->hasAnother("active")) {
|
||||||
loadedDemod = newDemod;
|
loadedActiveDemod = newDemod;
|
||||||
}
|
}
|
||||||
|
|
||||||
numDemodulators++;
|
numDemodulators++;
|
||||||
@ -1806,12 +1808,36 @@ bool AppFrame::loadSession(std::string fileName) {
|
|||||||
// std::cout << "\t\tOutput Device: " << output_device << std::endl;
|
// std::cout << "\t\tOutput Device: " << output_device << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
DemodulatorInstance *focusDemod = loadedDemod?loadedDemod:newDemod;
|
if (demodsLoaded.size()) {
|
||||||
|
|
||||||
if (focusDemod) {
|
|
||||||
wxGetApp().bindDemodulators(&demodsLoaded);
|
wxGetApp().bindDemodulators(&demodsLoaded);
|
||||||
wxGetApp().getDemodMgr().setActiveDemodulator(focusDemod, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // if l.rootNode()->hasAnother("demodulators")
|
||||||
|
|
||||||
|
if (header->hasAnother("center_freq")) {
|
||||||
|
long long center_freq = *header->getNext("center_freq");
|
||||||
|
wxGetApp().setFrequency(center_freq);
|
||||||
|
// std::cout << "\tCenter Frequency: " << center_freq << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (header->hasAnother("view_state")) {
|
||||||
|
DataNode *viewState = header->getNext("view_state");
|
||||||
|
|
||||||
|
if (viewState->hasAnother("center_freq") && viewState->hasAnother("bandwidth")) {
|
||||||
|
long long center_freq = *viewState->getNext("center_freq");
|
||||||
|
int bandwidth = *viewState->getNext("bandwidth");
|
||||||
|
spectrumCanvas->setView(center_freq, bandwidth);
|
||||||
|
waterfallCanvas->setView(center_freq, bandwidth);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
spectrumCanvas->disableView();
|
||||||
|
waterfallCanvas->disableView();
|
||||||
|
spectrumCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||||
|
waterfallCanvas->setCenterFrequency(wxGetApp().getFrequency());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (loadedActiveDemod || newDemod) {
|
||||||
|
wxGetApp().getDemodMgr().setActiveDemodulator(loadedActiveDemod?loadedActiveDemod:newDemod, false);
|
||||||
}
|
}
|
||||||
} catch (DataTypeMismatchException &e) {
|
} catch (DataTypeMismatchException &e) {
|
||||||
std::cout << e.what() << std::endl;
|
std::cout << e.what() << std::endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user