Add bookmark panel to appframe layout, implement some methods

This commit is contained in:
Charles J. Cliffe 2016-09-14 22:10:27 -04:00
parent ba7a0d8cd3
commit 488e8ed9e7
10 changed files with 109 additions and 28 deletions

View File

@ -232,10 +232,13 @@ AppFrame::AppFrame() :
// vbox->Add(demodTray, 12, wxEXPAND | wxALL, 0);
// vbox->AddSpacer(1);
mainVisSplitter = new wxSplitterWindow( mainSplitter, wxID_VIS_SPLITTER, wxDefaultPosition, wxDefaultSize, wxSP_3DSASH | wxSP_LIVE_UPDATE );
mainVisSplitter->SetSashGravity(6.0/25.0);
bookmarkSplitter = new wxSplitterWindow( mainSplitter, wxID_VIS_SPLITTER, wxDefaultPosition, wxDefaultSize, wxSP_3DSASH | wxSP_LIVE_UPDATE );
bookmarkSplitter->SetMinimumPaneSize(1);
bookmarkSplitter->SetSashGravity(1.0/20.0);
mainVisSplitter = new wxSplitterWindow( bookmarkSplitter, wxID_VIS_SPLITTER, wxDefaultPosition, wxDefaultSize, wxSP_3DSASH | wxSP_LIVE_UPDATE );
mainVisSplitter->SetMinimumPaneSize(1);
mainVisSplitter->SetSashGravity(6.0/25.0);
// mainVisSplitter->Connect( wxEVT_IDLE, wxIdleEventHandler( AppFrame::mainVisSplitterIdle ), NULL, this );
@ -309,7 +312,11 @@ AppFrame::AppFrame() :
// vbox->Add(wfSizer, 20, wxEXPAND | wxALL, 0);
mainVisSplitter->SplitHorizontally( spectrumPanel, waterfallPanel, 0 );
mainSplitter->SplitHorizontally( demodPanel, mainVisSplitter );
bookmarkPanel = new BookmarkPanel(bookmarkSplitter, wxID_ANY, wxDefaultPosition, wxSize(120,-1));
bookmarkSplitter->SplitVertically( bookmarkPanel, mainVisSplitter );
mainSplitter->SplitHorizontally( demodPanel, bookmarkSplitter );
vbox->Add(mainSplitter, 1, wxEXPAND | wxALL, 0);

View File

@ -19,7 +19,6 @@
#include "ModemProperties.h"
//#include "UITestCanvas.h"
#include "FrequencyDialog.h"
#include "BookmarkMgr.h"
#include "BookmarkView.h"
#include <map>
@ -135,8 +134,9 @@ private:
ModeSelectorCanvas *demodMuteButton, *peakHoldButton, *soloModeButton, *deltaLockButton;
GainCanvas *gainCanvas;
wxSizerItem *gainSizerItem, *gainSpacerItem;
wxSplitterWindow *mainVisSplitter, *mainSplitter;
wxSplitterWindow *mainVisSplitter, *mainSplitter, *bookmarkSplitter;
wxBoxSizer *demodTray;
BookmarkPanel *bookmarkPanel;
DemodulatorInstance *activeDemodulator;

View File

@ -1,4 +1,6 @@
#include "BookmarkMgr.h"
#include "CubicSDR.h"
#include "DataTree.h"
void BookmarkMgr::saveToFile(std::string bookmarkFn) {
@ -12,17 +14,47 @@ void BookmarkMgr::loadFromFile(std::string bookmarkFn) {
}
void BookmarkMgr::addBookmark(std::string group, DemodulatorInstance *demod) {
void BookmarkMgr::addBookmark(std::string group, DemodulatorInstance *demod, std::string folder) {
std::lock_guard < std::mutex > lock(busy_lock);
BookmarkEntry *be = new BookmarkEntry;
be->bandwidth = demod->getBandwidth();
be->type = demod->getDemodulatorType();
be->label = demod->getLabel();
be->frequency = demod->getFrequency();
be->folder = folder;
wxGetApp().getDemodMgr().saveInstance(be->node, demod);
bmData[group].insert(be);
}
void BookmarkMgr::removeBookmark(std::string group, BookmarkEntry *be) {
std::lock_guard < std::mutex > lockData(busy_lock);
std::lock_guard < std::mutex > lockEnt(be->busy_lock);
bmData[group].erase(be);
}
BookmarkList BookmarkMgr::getBookmarks(std::string group, std::string folder) {
std::lock_guard < std::mutex > lock(busy_lock);
BookmarkList results;
if (folder != "") {
for (auto be_i : bmData[group]) {
results.push_back(be_i);
}
} else {
for (auto be_i : bmData[group]) {
if (be_i->folder != folder) {
continue;
}
results.push_back(be_i);
}
}
return results;
}

View File

@ -1,11 +1,12 @@
#pragma once
#include <vector>
#include <map>
#include <set>
#include "DataTree.h"
#include "DemodulatorInstance.h"
class DataNode;
class BookmarkEntry {
public:
std::mutex busy_lock;
@ -20,15 +21,25 @@ public:
DataNode *node;
};
struct BookmarkEntryCompare : public std::binary_function<BookmarkEntry *,BookmarkEntry *,bool>
{
bool operator()(const BookmarkEntry *a, BookmarkEntry *b) const
{
return a->frequency < b->frequency;
}
};
typedef std::vector<BookmarkEntry *> BookmarkList;
typedef std::map<std::string, std::map<long long, BookmarkEntry *> > BookmarkMap;
typedef std::map<std::string, std::set<BookmarkEntry *, BookmarkEntryCompare> > BookmarkMap;
class BookmarkMgr {
public:
void saveToFile(std::string bookmarkFn);
void loadFromFile(std::string bookmarkFn);
void addBookmark(std::string group, DemodulatorInstance *demod);
void addBookmark(std::string group, DemodulatorInstance *demod, std::string folder = "");
void removeBookmark(std::string group, BookmarkEntry *be);
BookmarkList getBookmarks(std::string group, std::string folder = "");
protected:

View File

@ -671,6 +671,10 @@ DemodulatorMgr &CubicSDR::getDemodMgr() {
return demodMgr;
}
BookmarkMgr &CubicSDR::getBookmarkMgr() {
return bookmarkMgr;
}
SDRPostThread *CubicSDR::getSDRPostThread() {
return sdrPostThread;
}

View File

@ -23,6 +23,7 @@
#include "AppFrame.h"
#include "FrequencyDialog.h"
#include "DemodLabelDialog.h"
#include "BookmarkMgr.h"
#include "ScopeVisualProcessor.h"
#include "SpectrumVisualProcessor.h"
@ -111,6 +112,7 @@ public:
DemodulatorThreadInputQueue* getWaterfallVisualQueue();
DemodulatorThreadInputQueue* getActiveDemodVisualQueue();
DemodulatorMgr &getDemodMgr();
BookmarkMgr &getBookmarkMgr();
SDRPostThread *getSDRPostThread();
SDRThread *getSDRThread();
@ -179,6 +181,7 @@ private:
std::vector<SDRDeviceInfo *> *devs = nullptr;
DemodulatorMgr demodMgr;
BookmarkMgr bookmarkMgr;
std::atomic_llong frequency;
std::atomic_llong offset;

View File

@ -26,14 +26,14 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po
m_staticText1 = new wxStaticText( m_propPanel, wxID_ANY, wxT("Label"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
fgPropSizer->Add( m_staticText1, 0, wxALIGN_RIGHT|wxALL, 5 );
fgPropSizer->Add( m_staticText1, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_labelText = new wxTextCtrl( m_propPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgPropSizer->Add( m_labelText, 0, wxALL|wxEXPAND|wxLEFT|wxTOP, 5 );
fgPropSizer->Add( m_labelText, 0, wxALL|wxEXPAND, 5 );
m_frequencyLabel = new wxStaticText( m_propPanel, wxID_ANY, wxT("Freq"), wxDefaultPosition, wxDefaultSize, 0 );
m_frequencyLabel->Wrap( -1 );
fgPropSizer->Add( m_frequencyLabel, 0, wxALIGN_RIGHT|wxALL, 5 );
fgPropSizer->Add( m_frequencyLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_frequencyVal = new wxStaticText( m_propPanel, wxID_ANY, wxT("FrequencyVal"), wxDefaultPosition, wxDefaultSize, 0 );
m_frequencyVal->Wrap( -1 );
@ -41,7 +41,7 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po
m_bandwidthLabel = new wxStaticText( m_propPanel, wxID_ANY, wxT("BW"), wxDefaultPosition, wxDefaultSize, 0 );
m_bandwidthLabel->Wrap( -1 );
fgPropSizer->Add( m_bandwidthLabel, 0, wxALIGN_RIGHT|wxALL, 5 );
fgPropSizer->Add( m_bandwidthLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_bandwidthVal = new wxStaticText( m_propPanel, wxID_ANY, wxT("BandwidthVal"), wxDefaultPosition, wxDefaultSize, 0 );
m_bandwidthVal->Wrap( -1 );
@ -49,7 +49,7 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po
m_modulationLabel = new wxStaticText( m_propPanel, wxID_ANY, wxT("Type"), wxDefaultPosition, wxDefaultSize, 0 );
m_modulationLabel->Wrap( -1 );
fgPropSizer->Add( m_modulationLabel, 0, wxALIGN_RIGHT|wxALL, 5 );
fgPropSizer->Add( m_modulationLabel, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT, 5 );
m_typeVal = new wxStaticText( m_propPanel, wxID_ANY, wxT("TypeVal"), wxDefaultPosition, wxDefaultSize, 0 );
m_typeVal->Wrap( -1 );
@ -62,10 +62,10 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po
bSizer1->Add( m_propPanel, 1, wxBOTTOM|wxEXPAND|wxTOP, 5 );
m_bookmarkButton = new wxButton( this, wxID_ANY, wxT("Bookmark"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer1->Add( m_bookmarkButton, 0, wxALIGN_RIGHT|wxALL|wxEXPAND, 5 );
bSizer1->Add( m_bookmarkButton, 0, wxALL|wxEXPAND, 5 );
m_activateButton = new wxButton( this, wxID_ANY, wxT("Activate"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer1->Add( m_activateButton, 0, wxALIGN_RIGHT|wxALL|wxEXPAND, 5 );
bSizer1->Add( m_activateButton, 0, wxALL|wxEXPAND, 5 );
m_removeButton = new wxButton( this, wxID_ANY, wxT("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer1->Add( m_removeButton, 0, wxALL|wxEXPAND, 5 );

View File

@ -277,7 +277,7 @@
<property name="vgap">0</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_RIGHT|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
@ -360,7 +360,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND|wxLEFT|wxTOP</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
@ -451,7 +451,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_RIGHT|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -617,7 +617,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_RIGHT|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -783,7 +783,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_RIGHT|wxALL</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -952,7 +952,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_RIGHT|wxALL|wxEXPAND</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
@ -1040,7 +1040,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_RIGHT|wxALL|wxEXPAND</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>

View File

@ -1,7 +1,29 @@
#include "BookmarkView.h"
#include "CubicSDR.h"
BookmarkView::BookmarkView( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) : BookmarkPanel(parent, id, pos, size, style) {
doUpdateActive = false;
}
void BookmarkView::updateActiveList() {
std::vector<DemodulatorInstance *> &demods = wxGetApp().getDemodMgr().getDemodulators();
DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator();
DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator();
m_treeView->Disable();
m_treeView->DeleteAllItems();
activeItems.erase(activeItems.begin(),activeItems.end());
activeBranch = m_treeView->AddRoot("Active");
for (auto demod_i : demods) {
wxTreeItemId itm = m_treeView->AppendItem(activeBranch,demod_i->getLabel());
activeItems[itm] = demod_i;
}
m_treeView->Enable();
m_treeView->ExpandAll();
}
void BookmarkView::onTreeBeginLabelEdit( wxTreeEvent& event ) {

View File

@ -23,5 +23,7 @@ protected:
void onActivate( wxCommandEvent& event );
void onRemove( wxCommandEvent& event );
bool doUpdateActive;
wxTreeItemId activeBranch;
std::map<wxTreeItemId, DemodulatorInstance *> activeItems;
};