mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-22 19:58:39 -05:00
Can now press alt to drag demod range
This commit is contained in:
parent
5db4dcdbac
commit
dcb1f33a85
@ -423,9 +423,9 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
|
|||||||
mTracker.setVertDragLock(false);
|
mTracker.setVertDragLock(false);
|
||||||
mTracker.setHorizDragLock(false);
|
mTracker.setHorizDragLock(false);
|
||||||
|
|
||||||
if (mTracker.getOriginDeltaMouseX() == 0 && mTracker.getOriginDeltaMouseY() == 0) {
|
|
||||||
DemodulatorInstance *demod;
|
DemodulatorInstance *demod;
|
||||||
|
|
||||||
|
if (mTracker.getOriginDeltaMouseX() == 0 && mTracker.getOriginDeltaMouseY() == 0) {
|
||||||
float pos = mTracker.getMouseX();
|
float pos = mTracker.getMouseX();
|
||||||
int center_freq = wxGetApp().getFrequency();
|
int center_freq = wxGetApp().getFrequency();
|
||||||
int freq = center_freq - (int) (0.5 * (float) SRATE) + (int) ((float) pos * (float) SRATE);
|
int freq = center_freq - (int) (0.5 * (float) SRATE) + (int) ((float) pos * (float) SRATE);
|
||||||
@ -444,11 +444,11 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
|
|||||||
demod->run();
|
demod->run();
|
||||||
|
|
||||||
wxGetApp().bindDemodulator(demod);
|
wxGetApp().bindDemodulator(demod);
|
||||||
|
|
||||||
wxGetApp().getDemodMgr().setActiveDemodulator(demod);
|
wxGetApp().getDemodMgr().setActiveDemodulator(demod);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demod == NULL) {
|
if (demod == NULL) {
|
||||||
|
dragState = WF_DRAG_NONE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,10 +457,8 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
|
|||||||
DemodulatorThreadCommand command;
|
DemodulatorThreadCommand command;
|
||||||
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY;
|
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY;
|
||||||
command.int_value = freq;
|
command.int_value = freq;
|
||||||
demod->getCommandQueue()->push(command); // doesn't always work on first push?
|
|
||||||
demod->getCommandQueue()->push(command);
|
demod->getCommandQueue()->push(command);
|
||||||
|
|
||||||
|
|
||||||
((wxFrame*) parent)->GetStatusBar()->SetStatusText(
|
((wxFrame*) parent)->GetStatusBar()->SetStatusText(
|
||||||
wxString::Format(wxT("Set demodulator frequency: %s"),
|
wxString::Format(wxT("Set demodulator frequency: %s"),
|
||||||
wxNumberFormatter::ToString((long) freq, wxNumberFormatter::Style_WithThousandsSep)));
|
wxNumberFormatter::ToString((long) freq, wxNumberFormatter::Style_WithThousandsSep)));
|
||||||
@ -471,9 +469,62 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
|
|||||||
mTracker.setVertDragLock(true);
|
mTracker.setVertDragLock(true);
|
||||||
mTracker.setHorizDragLock(false);
|
mTracker.setHorizDragLock(false);
|
||||||
} else {
|
} else {
|
||||||
|
float pos = mTracker.getMouseX();
|
||||||
|
int center_freq = wxGetApp().getFrequency();
|
||||||
|
int freq = center_freq - (int) (0.5 * (float) SRATE) + (int) ((float) pos * (float) SRATE);
|
||||||
|
|
||||||
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getActiveDemodulator(), false);
|
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getActiveDemodulator(), false);
|
||||||
nextDragState = WF_DRAG_NONE;
|
nextDragState = WF_DRAG_NONE;
|
||||||
}
|
}
|
||||||
|
} else if (dragState == WF_DRAG_RANGE) {
|
||||||
|
float width = mTracker.getOriginDeltaMouseX();
|
||||||
|
float pos = mTracker.getOriginMouseX() + width / 2.0;
|
||||||
|
|
||||||
|
int center_freq = wxGetApp().getFrequency();
|
||||||
|
int freq = center_freq - (int) (0.5 * (float) SRATE) + (int) ((float) pos * (float) SRATE);
|
||||||
|
int bandwidth = (int)(fabs(width) * (float)SRATE);
|
||||||
|
|
||||||
|
if (bandwidth < 1000) {
|
||||||
|
bandwidth = 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bandwidth) {
|
||||||
|
dragState = WF_DRAG_NONE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!shiftDown && wxGetApp().getDemodMgr().getDemodulators().size()) {
|
||||||
|
demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||||
|
} else {
|
||||||
|
demod = wxGetApp().getDemodMgr().newThread();
|
||||||
|
demod->getParams().frequency = freq;
|
||||||
|
demod->getParams().bandwidth = bandwidth;
|
||||||
|
|
||||||
|
demod->run();
|
||||||
|
|
||||||
|
wxGetApp().bindDemodulator(demod);
|
||||||
|
wxGetApp().getDemodMgr().setActiveDemodulator(demod);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (demod == NULL) {
|
||||||
|
dragState = WF_DRAG_NONE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
((wxFrame*) parent)->GetStatusBar()->SetStatusText(
|
||||||
|
wxString::Format(wxT("Set demodulator frequency: %s"),
|
||||||
|
wxNumberFormatter::ToString((long) freq, wxNumberFormatter::Style_WithThousandsSep)));
|
||||||
|
|
||||||
|
wxGetApp().getDemodMgr().setActiveDemodulator(wxGetApp().getDemodMgr().getLastActiveDemodulator(), false);
|
||||||
|
demod->updateLabel(freq);
|
||||||
|
|
||||||
|
DemodulatorThreadCommand command;
|
||||||
|
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY;
|
||||||
|
command.int_value = freq;
|
||||||
|
demod->getCommandQueue()->push(command);
|
||||||
|
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_BANDWIDTH;
|
||||||
|
command.int_value = bandwidth;
|
||||||
|
demod->getCommandQueue()->push(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
dragState = WF_DRAG_NONE;
|
dragState = WF_DRAG_NONE;
|
||||||
|
Loading…
Reference in New Issue
Block a user