Layout, interaction improvements

This commit is contained in:
Charles J. Cliffe 2014-12-28 20:55:05 -05:00
parent b9ead19981
commit 0eb8ef60b2
3 changed files with 45 additions and 21 deletions

View File

@ -31,8 +31,9 @@ AppFrame::AppFrame() :
wxFrame(NULL, wxID_ANY, wxT("CubicSDR")) {
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *demodOpts = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *demodVisuals = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL);
demodTray->AddSpacer(5);
demodOpts->AddSpacer(5);
@ -64,15 +65,20 @@ wxFrame(NULL, wxID_ANY, wxT("CubicSDR")) {
demodTray->Add(demodOpts, 1, wxEXPAND | wxALL, 0);
demodWaterfallCanvas = new WaterfallCanvas(this, NULL);
demodWaterfallCanvas->Setup(1024,128);
demodWaterfallCanvas->SetView(DEFAULT_FREQ,300000);
demodTray->Add(demodWaterfallCanvas, 7, wxEXPAND | wxALL, 0);
demodVisuals->Add(demodWaterfallCanvas, 3, wxEXPAND | wxALL, 0);
demodTray->Add(demodVisuals, 7, wxEXPAND | wxALL, 0);
demodTray->AddSpacer(2);
scopeCanvas = new ScopeCanvas(this, NULL);
demodTray->Add(scopeCanvas, 7, wxEXPAND | wxALL, 0);
vbox->Add(demodTray, 1, wxEXPAND | wxALL, 0);
vbox->Add(demodTray, 2, wxEXPAND | wxALL, 0);
vbox->AddSpacer(2);
spectrumCanvas = new SpectrumCanvas(this, NULL);
spectrumCanvas->Setup(2048);
@ -140,12 +146,17 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
if (demod) {
if (demod->getParams().frequency != demodWaterfallCanvas->GetCenterFrequency()) {
demodWaterfallCanvas->SetCenterFrequency(demod->getParams().frequency);
}
unsigned int demodBw = (unsigned int) ceil((float) demod->getParams().bandwidth * 1.5);
if (demodBw != demodWaterfallCanvas->GetBandwidth()) {
demodWaterfallCanvas->SetBandwidth(demodBw);
if (demodWaterfallCanvas->getDragState() == WaterfallCanvas::WF_DRAG_NONE) {
if (demod->getParams().frequency != demodWaterfallCanvas->GetCenterFrequency()) {
demodWaterfallCanvas->SetCenterFrequency(demod->getParams().frequency);
}
unsigned int demodBw = (unsigned int) ceil((float) demod->getParams().bandwidth * 2.5);
if (demodBw > SRATE/2) {
demodBw = SRATE/2;
}
if (demodBw != demodWaterfallCanvas->GetBandwidth()) {
demodWaterfallCanvas->SetBandwidth(demodBw);
}
}
}

View File

@ -29,9 +29,11 @@ EVT_ENTER_WINDOW(WaterfallCanvas::mouseEnterWindow)
wxEND_EVENT_TABLE()
WaterfallCanvas::WaterfallCanvas(wxWindow *parent, int *attribList) :
wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE), parent(parent), frameTimer(0), activeDemodulatorBandwidth(0), activeDemodulatorFrequency(0), dragState(
WF_DRAG_NONE), nextDragState(WF_DRAG_NONE), shiftDown(false), altDown(false), ctrlDown(false), fft_size(0), waterfall_lines(0), plan(NULL), in(NULL), out(NULL), center_freq(0), bandwidth(0), isView(false), resampler(NULL), resample_ratio(0), last_bandwidth(0), last_input_bandwidth(0) {
WF_DRAG_NONE), nextDragState(WF_DRAG_NONE), shiftDown(false), altDown(false), ctrlDown(false), fft_size(0), waterfall_lines(0), plan(
NULL), in(NULL), out(NULL), center_freq(0), bandwidth(0), isView(false), resampler(NULL), resample_ratio(0), last_bandwidth(0), last_input_bandwidth(
0) {
glContext = new WaterfallContext(this, &wxGetApp().GetContext(this));
@ -100,7 +102,7 @@ unsigned int WaterfallCanvas::GetCenterFrequency() {
if (isView) {
return center_freq;
} else {
return (unsigned int)wxGetApp().getFrequency();
return (unsigned int) wxGetApp().getFrequency();
}
}
@ -116,6 +118,14 @@ unsigned int WaterfallCanvas::GetBandwidth() {
}
}
WaterfallCanvas::DragState WaterfallCanvas::getDragState() {
return dragState;
}
WaterfallCanvas::DragState WaterfallCanvas::getNextDragState() {
return nextDragState;
}
void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
wxPaintDC dc(this);
const wxSize ClientSize = GetClientSize();
@ -303,9 +313,9 @@ void WaterfallCanvas::setData(DemodulatorThreadIQData *input) {
}
if (center_freq != input->frequency) {
if (((int)center_freq - (int)input->frequency) != shift_freq || last_input_bandwidth != input->bandwidth) {
if ((int)input->frequency - abs((int)center_freq) < (int) ((float) ((float) SRATE / 2.0))) {
shift_freq = (int)center_freq - (int)input->frequency;
if (((int) center_freq - (int) input->frequency) != shift_freq || last_input_bandwidth != input->bandwidth) {
if ((int) input->frequency - abs((int) center_freq) < (int) ((float) ((float) SRATE / 2.0))) {
shift_freq = (int) center_freq - (int) input->frequency;
nco_crcf_reset(nco_shift);
nco_crcf_set_frequency(nco_shift, (2.0 * M_PI) * (((float) abs(shift_freq)) / ((float) input->bandwidth)));
}
@ -531,7 +541,7 @@ void WaterfallCanvas::mouseMoved(wxMouseEvent& event) {
int freqDiff = ((int) activeDemodulator->getParams().frequency - freqPos);
if (abs(freqDiff) > (activeDemodulator->getParams().bandwidth / 3)) {
SetCursor (wxCURSOR_SIZEWE);
SetCursor(wxCURSOR_SIZEWE);
if (freqDiff > 0) {
nextDragState = WF_DRAG_BANDWIDTH_LEFT;
@ -542,14 +552,14 @@ void WaterfallCanvas::mouseMoved(wxMouseEvent& event) {
mTracker.setVertDragLock(true);
mTracker.setHorizDragLock(false);
} else {
SetCursor (wxCURSOR_SIZING);
SetCursor(wxCURSOR_SIZING);
nextDragState = WF_DRAG_FREQUENCY;
mTracker.setVertDragLock(true);
mTracker.setHorizDragLock(false);
}
} else {
SetCursor (wxCURSOR_CROSS);
SetCursor(wxCURSOR_CROSS);
nextDragState = WF_DRAG_NONE;
}
@ -631,7 +641,7 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
wxNumberFormatter::ToString((long) freq, wxNumberFormatter::Style_WithThousandsSep)));
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getLastActiveDemodulator(), false);
SetCursor (wxCURSOR_SIZING);
SetCursor(wxCURSOR_SIZING);
nextDragState = WF_DRAG_FREQUENCY;
mTracker.setVertDragLock(true);
mTracker.setHorizDragLock(false);
@ -699,12 +709,12 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
void WaterfallCanvas::mouseLeftWindow(wxMouseEvent& event) {
mTracker.OnMouseLeftWindow(event);
SetCursor (wxCURSOR_CROSS);
SetCursor(wxCURSOR_CROSS);
wxGetApp().getDemodMgr().setActiveDemodulator(NULL);
}
void WaterfallCanvas::mouseEnterWindow(wxMouseEvent& event) {
mTracker.OnMouseEnterWindow(event);
SetCursor (wxCURSOR_CROSS);
SetCursor(wxCURSOR_CROSS);
}

View File

@ -34,6 +34,9 @@ public:
void SetBandwidth(unsigned int bandwidth_in);
unsigned int GetBandwidth();
DragState getDragState();
DragState getNextDragState();
private:
void OnPaint(wxPaintEvent& event);
void OnKeyDown(wxKeyEvent& event);