Tweaks, cleanup, helptips

This commit is contained in:
Charles J. Cliffe 2015-01-02 22:44:09 -05:00
parent 8f8dd01341
commit 63a4913558
5 changed files with 37 additions and 49 deletions

View File

@ -37,37 +37,6 @@ AppFrame::AppFrame() :
wxBoxSizer *demodVisuals = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *demodTray = new wxBoxSizer(wxHORIZONTAL);
/*
demodTray->AddSpacer(5);
demodOpts->AddSpacer(5);
wxStaticText *audioDeviceLabel = new wxStaticText(this, wxID_ANY, wxString("Audio Device:"));
demodOpts->Add(audioDeviceLabel, 1, wxFIXED_MINSIZE | wxALL, 0);
wxArrayString str;
str.Add("Primary Device");
wxChoice *wxCh = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, str);
demodOpts->Add(wxCh, 1, wxFIXED_MINSIZE | wxALL, 0);
demodOpts->AddSpacer(2);
wxStaticText *demodTypeLabel = new wxStaticText(this, wxID_ANY, wxString("Demodulation:"));
demodOpts->Add(demodTypeLabel, 1, wxFIXED_MINSIZE | wxALL, 0);
str.Clear();
str.Add("FM");
str.Add("FM Stereo");
str.Add("AM");
str.Add("LSB");
str.Add("USB");
wxChoice *wxDemodChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, str);
demodOpts->Add(wxDemodChoice, 1, wxFIXED_MINSIZE | wxALL, 0);
demodOpts->AddSpacer(5);
demodTray->AddSpacer(5);
demodTray->Add(demodOpts, 1, wxEXPAND | wxALL, 0); */
demodSpectrumCanvas = new SpectrumCanvas(this, NULL);
demodSpectrumCanvas->Setup(1024);
demodSpectrumCanvas->SetView(DEFAULT_FREQ, 300000);
@ -152,7 +121,7 @@ AppFrame::AppFrame() :
}
wxMenuBar *menuBar = new wxMenuBar;
menuBar->Append(menu, wxT("Output &Device"));
menuBar->Append(menu, wxT("Active Demodulator &Output"));
wxMenu *demodMenu = new wxMenu;
demod_menuitems[DEMOD_TYPE_FM] = demodMenu->AppendRadioItem(wxID_DEMOD_TYPE_FM, wxT("FM"), wxT("Description?"));
@ -160,7 +129,7 @@ AppFrame::AppFrame() :
demod_menuitems[DEMOD_TYPE_LSB] = demodMenu->AppendRadioItem(wxID_DEMOD_TYPE_LSB, wxT("LSB"), wxT("Description?"));
demod_menuitems[DEMOD_TYPE_USB] = demodMenu->AppendRadioItem(wxID_DEMOD_TYPE_USB, wxT("USB"), wxT("Description?"));
menuBar->Append(demodMenu, wxT("Demodulaton &Type"));
menuBar->Append(demodMenu, wxT("Active Demodulator &Type"));
SetMenuBar(menuBar);

View File

@ -20,7 +20,7 @@
InteractiveCanvas::InteractiveCanvas(wxWindow *parent, int *attribList) :
wxGLCanvas(parent, wxID_ANY, attribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE), parent(parent), shiftDown(false), altDown(false), ctrlDown(false), center_freq(0), bandwidth(0), last_bandwidth(0), isView(
false) {
false) {
mTracker.setTarget(this);
}
@ -123,3 +123,11 @@ void InteractiveCanvas::mouseEnterWindow(wxMouseEvent& event) {
mTracker.OnMouseEnterWindow(event);
}
void InteractiveCanvas::setStatusText(std::string statusText) {
((wxFrame*) parent)->GetStatusBar()->SetStatusText(statusText);
}
void InteractiveCanvas::setStatusText(std::string statusText, int value) {
((wxFrame*) parent)->GetStatusBar()->SetStatusText(
wxString::Format(statusText.c_str(), wxNumberFormatter::ToString((long) value, wxNumberFormatter::Style_WithThousandsSep)));
}

View File

@ -4,6 +4,7 @@
#include "wx/timer.h"
#include "MouseTracker.h"
#include <string>
class InteractiveCanvas: public wxGLCanvas {
public:
@ -32,6 +33,9 @@ protected:
void mouseEnterWindow(wxMouseEvent& event);
void mouseLeftWindow(wxMouseEvent& event);
void setStatusText(std::string statusText);
void setStatusText(std::string statusText, int value);
wxWindow *parent;
MouseTracker mTracker;

View File

@ -201,12 +201,12 @@ void SpectrumCanvas::mouseMoved(wxMouseEvent& event) {
if (freqChange) {
freq -= freqChange;
wxGetApp().setFrequency(freq);
((wxFrame*) parent)->GetStatusBar()->SetStatusText(
wxString::Format(wxT("Set center frequency: %s"),
wxNumberFormatter::ToString((long) freq, wxNumberFormatter::Style_WithThousandsSep)));
setStatusText("Set center frequency: %s", freq);
}
}
} else {
setStatusText("Click and drag to adjust center frequency.");
}
}

View File

@ -221,7 +221,7 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
}
}
wxGetApp().setFrequency(freq);
((wxFrame*) parent)->GetStatusBar()->SetStatusText(wxString::Format(wxT("Set center frequency: %i"), freq));
setStatusText("Set center frequency: %s", freq);
break;
case WXK_LEFT:
freq = wxGetApp().getFrequency();
@ -243,7 +243,7 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
}
}
wxGetApp().setFrequency(freq);
((wxFrame*) parent)->GetStatusBar()->SetStatusText(wxString::Format(wxT("Set center frequenfcy: %i"), freq));
setStatusText("Set center frequency: %s", freq);
break;
case 'D':
case WXK_DELETE:
@ -546,6 +546,7 @@ void WaterfallCanvas::mouseMoved(wxMouseEvent& event) {
command.int_value = activeDemodulatorBandwidth;
demod->getCommandQueue()->push(command);
setStatusText("Set demodulator bandwidth: %s", activeDemodulatorBandwidth);
}
if (dragState == WF_DRAG_FREQUENCY) {
@ -563,6 +564,8 @@ void WaterfallCanvas::mouseMoved(wxMouseEvent& event) {
demod->getCommandQueue()->push(command);
demod->updateLabel(activeDemodulatorFrequency);
setStatusText("Set demodulator frequency: %s", activeDemodulatorFrequency);
}
} else {
int freqPos = GetFrequencyAt(mTracker.getMouseX());
@ -575,6 +578,11 @@ void WaterfallCanvas::mouseMoved(wxMouseEvent& event) {
nextDragState = WF_DRAG_RANGE;
mTracker.setVertDragLock(true);
mTracker.setHorizDragLock(false);
if (shiftDown) {
setStatusText("Click and drag to create a new demodulator by range.");
} else {
setStatusText("Click and drag to set the current demodulator range.");
}
} else if (demodsHover->size()) {
int hovered = -1;
int near_dist = GetBandwidth();
@ -621,16 +629,23 @@ void WaterfallCanvas::mouseMoved(wxMouseEvent& event) {
mTracker.setVertDragLock(true);
mTracker.setHorizDragLock(false);
setStatusText("Click and drag to change demodulator bandwidth. D to delete, SPACE for stereo.");
} else {
SetCursor(wxCURSOR_SIZING);
nextDragState = WF_DRAG_FREQUENCY;
mTracker.setVertDragLock(true);
mTracker.setHorizDragLock(false);
setStatusText("Click and drag to change demodulator frequency. D to delete, SPACE for stereo.");
}
} else {
SetCursor(wxCURSOR_CROSS);
nextDragState = WF_DRAG_NONE;
if (shiftDown) {
setStatusText("Click to create a new demodulator or hold ALT to drag range.");
} else {
setStatusText("Click to move active demodulator frequency or hold ALT to drag range; hold SHIFT to create new. A / Z to Zoom. Arrow keys (+SHIFT) to move center frequency.");
}
}
delete demodsHover;
@ -703,9 +718,7 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
command.int_value = freq;
demod->getCommandQueue()->push(command);
((wxFrame*) parent)->GetStatusBar()->SetStatusText(
wxString::Format(wxT("Set demodulator frequency: %s"),
wxNumberFormatter::ToString((long) freq, wxNumberFormatter::Style_WithThousandsSep)));
setStatusText("New demodulator at frequency: %s", freq);
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getLastActiveDemodulator(), false);
SetCursor(wxCURSOR_SIZING);
@ -713,10 +726,6 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
mTracker.setVertDragLock(true);
mTracker.setHorizDragLock(false);
} else {
float pos = mTracker.getMouseX();
int input_center_freq = GetCenterFrequency();
int freq = input_center_freq - (int) (0.5 * (float) GetBandwidth()) + (int) ((float) pos * (float) GetBandwidth());
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getActiveDemodulator(), false);
nextDragState = WF_DRAG_FREQUENCY;
}
@ -760,9 +769,7 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
return;
}
((wxFrame*) parent)->GetStatusBar()->SetStatusText(
wxString::Format(wxT("Set demodulator frequency: %s"),
wxNumberFormatter::ToString((long) freq, wxNumberFormatter::Style_WithThousandsSep)));
setStatusText("New demodulator at frequency: %s", freq);
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getLastActiveDemodulator(), false);
demod->updateLabel(freq);