FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxString & title, DemodulatorInstance *demod, const wxPoint & position, const wxSize & size, long style, FrequencyDialogTarget targetMode) : wxDialog(parent, id, title, position, size, style) { wxString freqStr; activeDemod = demod; this->targetMode = targetMode; if (targetMode == FDIALOG_TARGET_DEFAULT) { if (activeDemod) { freqStr = frequencyToStr(activeDemod->getFrequency()); } else { freqStr = frequencyToStr(wxGetApp().getFrequency()); } } if (targetMode == FDIALOG_TARGET_BANDWIDTH) { std::string lastDemodType = activeDemod?activeDemod->getDemodulatorType():wxGetApp().getDemodMgr().getLastDemodulatorType(); if (lastDemodType == "USB" || lastDemodType == "LSB") { freqStr = frequencyToStr(wxGetApp().getDemodMgr().getLastBandwidth()/2); } else { freqStr = frequencyToStr(wxGetApp().getDemodMgr().getLastBandwidth()); } } dialogText = new wxTextCtrl(this, wxID_FREQ_INPUT, freqStr, wxPoint(6, 1), wxSize(size.GetWidth() - 20, size.GetHeight() - 70), wxTE_PROCESS_ENTER); dialogText->SetFont(wxFont(20, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD)); Centre(); dialogText->SetSelection(-1, -1); }
void BookmarkView::rangeSelection(BookmarkRangeEntryPtr re) { clearButtons(); hideProps(); m_labelText->SetValue(re->label); m_labelText->Show(); m_labelLabel->Show(); m_frequencyVal->Show(); m_frequencyLabel->Show(); std::string strFreq = frequencyToStr(re->startFreq) + "-" + frequencyToStr(re->endFreq); m_frequencyVal->SetLabelText(wxString(strFreq)); showProps(); addButton(m_buttonPanel, "Go to Range", wxCommandEventHandler( BookmarkView::onActivateRange )); addButton(m_buttonPanel, "Update Range", wxCommandEventHandler( BookmarkView::onUpdateRange ))->SetToolTip("Update range by setting it to the active range."); addButton(m_buttonPanel, "Remove Range", wxCommandEventHandler( BookmarkView::onRemoveRange )); showButtons(); refreshLayout(); }
void BookmarkView::recentSelection(BookmarkEntryPtr bmSel) { m_frequencyVal->SetLabelText(frequencyToStr(bmSel->frequency)); m_bandwidthVal->SetLabelText(frequencyToStr(bmSel->bandwidth)); m_modulationVal->SetLabelText(bmSel->type); m_labelText->SetValue(bmSel->label); hideProps(); m_frequencyVal->Show(); m_frequencyLabel->Show(); m_bandwidthVal->Show(); m_bandwidthLabel->Show(); m_modulationVal->Show(); m_modulationLabel->Show(); m_labelText->Show(); m_labelLabel->Show(); clearButtons(); addBookmarkChoice(m_buttonPanel); addButton(m_buttonPanel, "Activate Recent", wxCommandEventHandler( BookmarkView::onActivateRecent )); addButton(m_buttonPanel, "Remove Recent", wxCommandEventHandler( BookmarkView::onRemoveRecent )); showProps(); showButtons(); refreshLayout(); }
ActionDialogUpdateRange( BookmarkRangeEntryPtr rangeEnt ) : ActionDialog(wxGetApp().getAppFrame(), wxID_ANY, wxT("Update Range?")) { subject = rangeEnt; std::wstring name = rangeEnt->label; if (name.length() == 0) { std::string wstr = frequencyToStr(rangeEnt->startFreq) + " - " + frequencyToStr(rangeEnt->endFreq); name = wxString(wstr).ToStdWstring(); } m_questionText->SetLabelText(L"Are you sure you want to update the range\n '" + name + L"' to the active range?"); }
void BookmarkView::activeSelection(DemodulatorInstancePtr dsel) { if (dsel == nullptr) { hideProps(); clearButtons(); showProps(); showButtons(); refreshLayout(); return; } m_frequencyVal->SetLabelText(frequencyToStr(dsel->getFrequency())); m_bandwidthVal->SetLabelText(frequencyToStr(dsel->getBandwidth())); m_modulationVal->SetLabelText(dsel->getDemodulatorType()); m_labelText->SetValue(dsel->getDemodulatorUserLabel()); hideProps(); m_frequencyVal->Show(); m_frequencyLabel->Show(); m_bandwidthVal->Show(); m_bandwidthLabel->Show(); m_modulationVal->Show(); m_modulationLabel->Show(); m_labelText->Show(); m_labelLabel->Show(); clearButtons(); addBookmarkChoice(m_buttonPanel); if (!(dsel->isRecording())) { addButton(m_buttonPanel, "Start Recording", wxCommandEventHandler(BookmarkView::onStartRecording)); } else { addButton(m_buttonPanel, "Stop Recording", wxCommandEventHandler(BookmarkView::onStopRecording)); } addButton(m_buttonPanel, "Remove Active", wxCommandEventHandler( BookmarkView::onRemoveActive )); showProps(); showButtons(); refreshLayout(); }
void DemodulatorInstance::setFrequency(long long freq) { if ((freq - getBandwidth() / 2) <= 0) { freq = getBandwidth() / 2; } demodulatorPreThread->setFrequency(freq); #if ENABLE_DIGITAL_LAB if (activeOutput) { if (isModemInitialized() && getModemType() == "digital") { ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *)getOutput(); outp->setTitle(getDemodulatorType() + ": " + frequencyToStr(getFrequency())); } } #endif #if USE_HAMLIB if (wxGetApp().rigIsActive() && wxGetApp().getRigThread()->getFollowModem() && wxGetApp().getDemodMgr().getLastActiveDemodulator() == this) { wxGetApp().getRigThread()->setFrequency(freq,true); } #endif }
void DemodulatorInstance::setDemodulatorType(std::string demod_type_in) { setGain(getGain()); if (demodulatorPreThread) { std::string currentDemodType = demodulatorPreThread->getDemodType(); if ((currentDemodType != "") && (currentDemodType != demod_type_in)) { lastModemSettings[currentDemodType] = demodulatorPreThread->readModemSettings(); lastModemBandwidth[currentDemodType] = demodulatorPreThread->getBandwidth(); } #if ENABLE_DIGITAL_LAB if (activeOutput) { activeOutput->Hide(); } #endif demodulatorPreThread->setDemodType(demod_type_in); int lastbw = 0; if (currentDemodType != "" && lastModemBandwidth.find(demod_type_in) != lastModemBandwidth.end()) { lastbw = lastModemBandwidth[demod_type_in]; } if (!lastbw) { lastbw = Modem::getModemDefaultSampleRate(demod_type_in); } if (lastbw) { setBandwidth(lastbw); } #if ENABLE_DIGITAL_LAB if (isModemInitialized() && getModemType() == "digital") { ModemDigitalOutputConsole *outp = (ModemDigitalOutputConsole *)getOutput(); outp->setTitle(getDemodulatorType() + ": " + frequencyToStr(getFrequency())); } #endif } wxGetApp().getBookmarkMgr().updateActiveList(); }
void SDRDevicesDialog::refreshDeviceProperties() { SDRDeviceInfo *selDev = getSelectedDevice(devTree->GetSelection()); if (selDev && selDev->isAvailable()) { dev = selDev; selId = devTree->GetSelection(); DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getName()); m_propertyGrid->Clear(); SoapySDR::Device *soapyDev = dev->getSoapyDevice(); SoapySDR::ArgInfoList args = soapyDev->getSettingInfo(); //A) General settings: name, offset, sample rate, agc, antennas (if > 1) m_propertyGrid->Append(new wxPropertyCategory("General Settings")); devSettings.clear(); //A-1) Name devSettings["name"] = m_propertyGrid->Append( new wxStringProperty("Name", wxPG_LABEL, devConfig->getDeviceName()) ); //A-2) Offset devSettings["offset"] = m_propertyGrid->Append( new wxIntProperty("Offset (KHz)", wxPG_LABEL, devConfig->getOffset() / 1000) ); //A-3) Antennas, is there are more than 1 RX antenna, else do not expose the setting. //get the saved setting const std::string& currentSetAntenna = devConfig->getAntennaName(); //compare to the list of existing antennas SoapySDR::ArgInfo antennasArg; std::vector<std::string> antennaOpts = selDev->getAntennaNames(SOAPY_SDR_RX, 0); //only do something if there is more than 1 antenna if (antennaOpts.size() > 1) { //by default, choose the first of the list. std::string antennaToSelect = antennaOpts.front(); auto found_i = std::find(antennaOpts.begin(), antennaOpts.end(), currentSetAntenna); if (found_i != antennaOpts.end()) { antennaToSelect = currentSetAntenna; } else { //erroneous antenna name, re-write device config with the first choice of teh list. devConfig->setAntennaName(antennaToSelect); } //build device settings for (std::string antenna : antennaOpts) { antennasArg.options.push_back(antenna); antennasArg.optionNames.push_back(antenna); } antennasArg.type = SoapySDR::ArgInfo::STRING; antennasArg.units = ""; antennasArg.name = "Antenna"; antennasArg.key = "antenna"; antennasArg.value = antennaToSelect; devSettings["antenna"] = addArgInfoProperty(m_propertyGrid, antennasArg); deviceArgs["antenna"] = antennasArg; } //end if more than 1 antenna else { devConfig->setAntennaName(""); } //A-4) Sample_rate: long currentSampleRate = wxGetApp().getSampleRate(); long deviceSampleRate = devConfig->getSampleRate(); if (!deviceSampleRate) { deviceSampleRate = selDev->getSampleRateNear(SOAPY_SDR_RX, 0, currentSampleRate); } SoapySDR::ArgInfo sampleRateArg; std::vector<long> rateOpts = selDev->getSampleRates(SOAPY_SDR_RX, 0); for (long rate : rateOpts) { sampleRateArg.options.push_back(std::to_string(rate)); sampleRateArg.optionNames.push_back(frequencyToStr(rate)); } sampleRateArg.type = SoapySDR::ArgInfo::STRING; sampleRateArg.units = "Hz"; sampleRateArg.name = "Sample Rate"; sampleRateArg.key = "sample_rate"; sampleRateArg.value = std::to_string(deviceSampleRate); devSettings["sample_rate"] = addArgInfoProperty(m_propertyGrid, sampleRateArg); deviceArgs["sample_rate"] = sampleRateArg; //B) Runtime Settings: runtimeArgs.clear(); runtimeProps.clear(); streamProps.clear(); if (args.size()) { m_propertyGrid->Append(new wxPropertyCategory("Run-time Settings")); for (SoapySDR::ArgInfoList::const_iterator args_i = args.begin(); args_i != args.end(); args_i++) { SoapySDR::ArgInfo arg = (*args_i); //We-reread the Device configuration, else we use the user settings. if (dev) { //Apply saved settings DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); arg.value = devConfig->getSetting(arg.key, soapyDev->readSetting(arg.key)); //use SoapyDevice data as fallback. } else { //re-read the SoapyDevice arg.value = soapyDev->readSetting(arg.key); } runtimeProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg); runtimeArgs[arg.key] = arg; } } if (dev) { args = dev->getSoapyDevice()->getStreamArgsInfo(SOAPY_SDR_RX, 0); DeviceConfig *devConfig = wxGetApp().getConfig()->getDevice(dev->getDeviceId()); ConfigSettings devStreamOpts = devConfig->getStreamOpts(); if (devStreamOpts.size()) { for (int j = 0, jMax = args.size(); j < jMax; j++) { if (devStreamOpts.find(args[j].key) != devStreamOpts.end()) { args[j].value = devStreamOpts[args[j].key]; } } } if (args.size()) { m_propertyGrid->Append(new wxPropertyCategory("Stream Settings")); for (SoapySDR::ArgInfo arg : args) { streamProps[arg.key] = addArgInfoProperty(m_propertyGrid, arg); } } } if (selDev->isManual()) { m_addRemoteButton->SetLabel("Remove"); removeId = selId; } else { m_addRemoteButton->SetLabel("Add"); removeId = nullptr; } } else if (selDev && !selDev->isAvailable() && selDev->isManual()) { m_propertyGrid->Clear(); devSettings.clear(); runtimeArgs.clear(); runtimeProps.clear(); streamProps.clear(); removeId = devTree->GetSelection(); dev = nullptr; selId = nullptr; editId = nullptr; m_addRemoteButton->SetLabel("Remove"); } else if (!selDev) { m_addRemoteButton->SetLabel("Add"); removeId = nullptr; } }
void BookmarkView::doUpdateActiveList() { auto demods = wxGetApp().getDemodMgr().getDemodulators(); auto lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator(); //capture the previously selected item info BY COPY (because the original will be destroyed together with the destroyed tree items) to restore it again after //having rebuilding the whole tree. TreeViewItem* prevSel = itemToTVI(m_treeView->GetSelection()); TreeViewItem* prevSelCopy = nullptr; if (prevSel != NULL) { prevSelCopy = new TreeViewItem(*prevSel); } // Actives m_treeView->DeleteChildren(activeBranch); bool activeExpandState = expandState["active"]; bool searchState = (searchKeywords.size() != 0); wxTreeItemId selItem = nullptr; for (auto demod_i : demods) { wxString activeLabel = BookmarkMgr::getActiveDisplayName(demod_i); if (searchState) { std::string freqStr = frequencyToStr(demod_i->getFrequency()); std::string bwStr = frequencyToStr(demod_i->getBandwidth()); std::string mtype = demod_i->getDemodulatorType(); std::wstring fullText = activeLabel.ToStdWstring() + L" " + demod_i->getDemodulatorUserLabel() + L" " + std::to_wstring(demod_i->getFrequency()) + L" " + wxString(freqStr).ToStdWstring() + L" " + wxString(bwStr).ToStdWstring() + L" " + wxString(mtype).ToStdWstring(); if (!isKeywordMatch(fullText, searchKeywords)) { continue; } } TreeViewItem* tvi = new TreeViewItem(); tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE; tvi->demod = demod_i; wxTreeItemId itm = m_treeView->AppendItem(activeBranch,activeLabel); SetTreeItemData(itm, tvi); if (nextDemod != nullptr && nextDemod == demod_i) { selItem = itm; wxGetApp().getDemodMgr().setActiveDemodulator(nextDemod, false); nextDemod = nullptr; } else if (!selItem && activeExpandState && lastActiveDemodulator && lastActiveDemodulator == demod_i) { selItem = itm; } } bool rangeExpandState = searchState?false:expandState["range"]; //Ranges BookmarkRangeList bmRanges = wxGetApp().getBookmarkMgr().getRanges(); m_treeView->DeleteChildren(rangeBranch); for (auto &re_i: bmRanges) { TreeViewItem* tvi = new TreeViewItem(); tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE; tvi->rangeEnt = re_i; std::wstring labelVal = re_i->label; if (labelVal == L"") { std::string wstr = frequencyToStr(re_i->startFreq) + " - " + frequencyToStr(re_i->endFreq); labelVal = wxString(wstr).ToStdWstring(); } wxTreeItemId itm = m_treeView->AppendItem(rangeBranch, labelVal); SetTreeItemData(itm, tvi); if (nextRange == re_i) { selItem = itm; nextRange = nullptr; } else if (!selItem && rangeExpandState && prevSelCopy && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE && prevSelCopy->rangeEnt == re_i) { selItem = itm; } } bool recentExpandState = searchState || expandState["recent"]; // Recents BookmarkList bmRecents = wxGetApp().getBookmarkMgr().getRecents(); m_treeView->DeleteChildren(recentBranch); for (auto &bmr_i: bmRecents) { TreeViewItem* tvi = new TreeViewItem(); tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT; tvi->bookmarkEnt = bmr_i; std::wstring labelVal; bmr_i->node->child("user_label")->element()->get(labelVal); if (labelVal == L"") { std::string str = frequencyToStr(bmr_i->frequency) + " " + bmr_i->type; labelVal = wxString(str).ToStdWstring(); } if (searchKeywords.size()) { std::string freqStr = frequencyToStr(bmr_i->frequency); std::string bwStr = frequencyToStr(bmr_i->bandwidth); std::wstring fullText = labelVal + L" " + std::to_wstring(bmr_i->frequency) + L" " + wxString(freqStr).ToStdWstring() + L" " + wxString(bwStr).ToStdWstring() + L" " + wxString(bmr_i->type).ToStdWstring(); if (!isKeywordMatch(fullText, searchKeywords)) { continue; } } wxTreeItemId itm = m_treeView->AppendItem(recentBranch, labelVal); SetTreeItemData(itm, tvi); if (nextEnt == bmr_i) { selItem = itm; nextEnt = nullptr; } else if (!selItem && recentExpandState && prevSelCopy && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT && prevSelCopy->bookmarkEnt == bmr_i) { selItem = itm; } } if (activeExpandState) { m_treeView->Expand(activeBranch); } else { m_treeView->Collapse(activeBranch); } if (recentExpandState) { m_treeView->Expand(recentBranch); } else { m_treeView->Collapse(recentBranch); } if (rangeExpandState) { m_treeView->Expand(rangeBranch); } else { m_treeView->Collapse(rangeBranch); } //select the item having the same meaning as the previously selected item if (selItem != nullptr) { m_treeView->SelectItem(selItem); } // Add an extra refresh, that rebuilds the buttons from sratch. activeSelection(lastActiveDemodulator); delete prevSelCopy; }
wxTreeItemId BookmarkView::refreshBookmarks() { //capture the previously selected item info BY COPY (because the original will be destroyed together with the destroyed tree items) to restore it again after //having rebuilding the whole tree. TreeViewItem* prevSel = itemToTVI(m_treeView->GetSelection()); TreeViewItem* prevSelCopy = nullptr; if (prevSel != NULL) { prevSelCopy = new TreeViewItem(*prevSel); } BookmarkNames groupNames; wxGetApp().getBookmarkMgr().getGroups(groupNames); doUpdateBookmarkGroup.clear(); wxTreeItemId bmSelFound = nullptr; std::map<std::string, bool> groupExpandState; bool searchState = (searchKeywords.size() != 0); groups.clear(); m_treeView->DeleteChildren(bookmarkBranch); bool bmExpandState = expandState["bookmark"]; for (auto gn_i : groupNames) { TreeViewItem* tvi = new TreeViewItem(); tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP; tvi->groupName = gn_i; wxTreeItemId group_itm = m_treeView->AppendItem(bookmarkBranch, gn_i); SetTreeItemData(group_itm, tvi); groups[gn_i] = group_itm; if (prevSelCopy != nullptr && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP && gn_i == prevSelCopy->groupName) { bmSelFound = group_itm; } else if (nextGroup != "" && gn_i == nextGroup) { bmSelFound = group_itm; nextGroup = ""; } } if (searchState || bmExpandState) { m_treeView->Expand(bookmarkBranch); } else { m_treeView->Collapse(bookmarkBranch); } for (auto gn_i : groupNames) { wxTreeItemId groupItem = groups[gn_i]; bool groupExpanded = searchState || wxGetApp().getBookmarkMgr().getExpandState(gn_i); BookmarkList bmList = wxGetApp().getBookmarkMgr().getBookmarks(gn_i); for (auto &bmEnt : bmList) { std::wstring labelVal = BookmarkMgr::getBookmarkEntryDisplayName(bmEnt); if (searchState) { std::string freqStr = frequencyToStr(bmEnt->frequency); std::string bwStr = frequencyToStr(bmEnt->bandwidth); std::wstring fullText = labelVal + L" " + bmEnt->label + L" " + std::to_wstring(bmEnt->frequency) + L" " + wxString(freqStr).ToStdWstring() + L" " + wxString(bwStr).ToStdWstring() + L" " + wxString(bmEnt->type).ToStdWstring(); if (!isKeywordMatch(fullText, searchKeywords)) { continue; } } TreeViewItem* tvi = new TreeViewItem(); tvi->type = TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK; tvi->bookmarkEnt = bmEnt; tvi->groupName = gn_i; wxTreeItemId itm = m_treeView->AppendItem(groupItem, labelVal); SetTreeItemData(itm, tvi); if (prevSelCopy != nullptr && prevSelCopy->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK && prevSelCopy->bookmarkEnt == bmEnt && groupExpanded) { bmSelFound = itm; } if (nextEnt == bmEnt) { bmSelFound = itm; nextEnt = nullptr; } } if (groupExpanded) { m_treeView->Expand(groupItem); } } delete prevSelCopy; return bmSelFound; }