Can now spawn infinite(?) demodulators by holding shift

This commit is contained in:
Charles J. Cliffe 2014-12-10 18:52:24 -05:00
parent 380145fdaa
commit f2c59fedd1
3 changed files with 39 additions and 21 deletions

View File

@ -49,6 +49,10 @@ public:
return demodMgr;
}
void bindDemodulator(DemodulatorInstance *newDemod) {
sdrPostThread->bindDemodulator(newDemod);
}
private:
PrimaryGLContext *m_glContext;

View File

@ -189,12 +189,17 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, float r, float g, f
}
void PrimaryGLContext::DrawFreqSelector(float uxPos, float r, float g, float b) {
DemodulatorInstance *demod = wxGetApp().getDemodTest();
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
int bw = 0;
if (!demod) {
return;
bw = 200000;
} else {
bw = demod->getParams().bandwidth;
}
glDisable(GL_DEPTH_TEST);
glDisable(GL_TEXTURE_2D);

View File

@ -117,11 +117,9 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
}
void WaterfallCanvas::OnKeyUp(wxKeyEvent& event) {
switch (event.GetKeyCode()) {
case WXK_SHIFT:
shiftDown = false;
break;
}
// switch (event.GetKeyCode()) {
// }
}
void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
@ -147,9 +145,6 @@ void WaterfallCanvas::OnKeyDown(wxKeyEvent& event) {
break;
case WXK_SPACE:
break;
case WXK_SHIFT:
shiftDown = true;
break;
default:
event.Skip();
return;
@ -238,6 +233,8 @@ void WaterfallCanvas::OnIdle(wxIdleEvent &event) {
void WaterfallCanvas::mouseMoved(wxMouseEvent& event) {
mTracker.OnMouseMoved(event);
shiftDown = event.ShiftDown();
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getActiveDemodulator();
if (mTracker.mouseDown()) {
@ -322,7 +319,7 @@ void WaterfallCanvas::mouseMoved(wxMouseEvent& event) {
return;
}
wxGetApp().getDemodMgr().setActiveDemodulator(activeDemodulator, false);
wxGetApp().getDemodMgr().setActiveDemodulator(activeDemodulator);
int freqDiff = ((int) activeDemodulator->getParams().frequency - freqPos);
@ -373,29 +370,41 @@ void WaterfallCanvas::mouseWheelMoved(wxMouseEvent& event) {
void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
mTracker.OnMouseReleased(event);
SetCursor(wxCURSOR_CROSS);
mTracker.setVertDragLock(true);
mTracker.setHorizDragLock(true);
if (mTracker.getOriginDeltaMouseX() == 0 && mTracker.getOriginDeltaMouseY() == 0) {
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
if (1) {
DemodulatorInstance *demod;
float pos = mTracker.getMouseX();
int center_freq = wxGetApp().getFrequency();
int freq = center_freq - (int) (0.5 * (float) SRATE) + (int) ((float) pos * (float) SRATE);
if (!shiftDown) {
demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
} else {
demod = wxGetApp().getDemodMgr().newThread();
demod->getParams().frequency = freq;
if (DemodulatorInstance *last = wxGetApp().getDemodMgr().getLastActiveDemodulator()) {
demod->getParams().bandwidth = last->getParams().bandwidth;
}
demod->run();
wxGetApp().bindDemodulator(demod);
}
if (dragState == WF_DRAG_NONE) {
if (demod == NULL) {
return;
}
float pos = mTracker.getMouseX();
int center_freq = wxGetApp().getFrequency();
int freq = center_freq - (int) (0.5 * (float) SRATE) + (int) ((float) pos * (float) SRATE);
DemodulatorThreadCommand command;
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY;
command.int_value = freq;
demod->getCommandQueue()->push(command);
((wxFrame*) parent)->GetStatusBar()->SetStatusText(