mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-03 21:57:51 -04:00
Can now drag tuner values
This commit is contained in:
parent
9f945026b8
commit
482ff41382
@ -25,7 +25,7 @@ EVT_ENTER_WINDOW(TuningCanvas::OnMouseEnterWindow)
|
|||||||
wxEND_EVENT_TABLE()
|
wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) :
|
TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) :
|
||||||
InteractiveCanvas(parent, attribList) {
|
InteractiveCanvas(parent, attribList), dragAccum(0) {
|
||||||
|
|
||||||
glContext = new TuningContext(this, &wxGetApp().GetContext(this));
|
glContext = new TuningContext(this, &wxGetApp().GetContext(this));
|
||||||
}
|
}
|
||||||
@ -46,7 +46,9 @@ void TuningCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
|
|||||||
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||||
|
|
||||||
if (activeDemod != NULL) {
|
if (activeDemod != NULL) {
|
||||||
glContext->DrawDemodFreqBw(activeDemod->getFrequency(),activeDemod->getBandwidth(),wxGetApp().getFrequency());
|
glContext->DrawDemodFreqBw(activeDemod->getFrequency(), activeDemod->getBandwidth(), wxGetApp().getFrequency());
|
||||||
|
} else {
|
||||||
|
glContext->DrawDemodFreqBw(0, 0, wxGetApp().getFrequency());
|
||||||
}
|
}
|
||||||
|
|
||||||
glContext->DrawEnd();
|
glContext->DrawEnd();
|
||||||
@ -61,11 +63,37 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) {
|
|||||||
void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
|
void TuningCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||||
InteractiveCanvas::OnMouseMoved(event);
|
InteractiveCanvas::OnMouseMoved(event);
|
||||||
|
|
||||||
|
if (mouseTracker.mouseDown()) {
|
||||||
|
DemodulatorInstance *activeDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
|
||||||
|
|
||||||
|
float uxPos = 2.0 * (mouseTracker.getMouseX() - 0.5);
|
||||||
|
|
||||||
|
dragAccum += mouseTracker.getDeltaMouseX();
|
||||||
|
|
||||||
|
if (uxPos < -0.275 && activeDemod != NULL) {
|
||||||
|
if (abs(dragAccum * 100.0) >= 1) {
|
||||||
|
activeDemod->setFrequency(activeDemod->getFrequency() + (int) (dragAccum * 100.0));
|
||||||
|
dragAccum = 0;
|
||||||
|
}
|
||||||
|
} else if (uxPos > 0.275) {
|
||||||
|
wxGetApp().setFrequency(wxGetApp().getFrequency() + (int) (mouseTracker.getDeltaMouseX() * SRATE * 100.0));
|
||||||
|
dragAccum = 0;
|
||||||
|
} else if (activeDemod != NULL) {
|
||||||
|
if (abs(dragAccum * 100.0) >= 1) {
|
||||||
|
activeDemod->setBandwidth(activeDemod->getBandwidth() + (int) (dragAccum * 100.0));
|
||||||
|
dragAccum = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TuningCanvas::OnMouseDown(wxMouseEvent& event) {
|
void TuningCanvas::OnMouseDown(wxMouseEvent& event) {
|
||||||
InteractiveCanvas::OnMouseDown(event);
|
InteractiveCanvas::OnMouseDown(event);
|
||||||
mouseTracker.setHorizDragLock(true);
|
mouseTracker.setHorizDragLock(true);
|
||||||
|
mouseTracker.setVertDragLock(true);
|
||||||
|
|
||||||
|
dragAccum = 0;
|
||||||
|
SetCursor(wxCURSOR_IBEAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TuningCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
|
void TuningCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
|
||||||
@ -74,6 +102,9 @@ void TuningCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
|
|||||||
|
|
||||||
void TuningCanvas::OnMouseReleased(wxMouseEvent& event) {
|
void TuningCanvas::OnMouseReleased(wxMouseEvent& event) {
|
||||||
InteractiveCanvas::OnMouseReleased(event);
|
InteractiveCanvas::OnMouseReleased(event);
|
||||||
|
mouseTracker.setHorizDragLock(false);
|
||||||
|
mouseTracker.setVertDragLock(false);
|
||||||
|
SetCursor(wxCURSOR_SIZEWE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TuningCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
|
void TuningCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
|
||||||
@ -83,7 +114,7 @@ void TuningCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
|
|||||||
|
|
||||||
void TuningCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
|
void TuningCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
|
||||||
InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event);
|
InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event);
|
||||||
SetCursor(wxCURSOR_CROSS);
|
SetCursor(wxCURSOR_SIZEWE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TuningCanvas::setHelpTip(std::string tip) {
|
void TuningCanvas::setHelpTip(std::string tip) {
|
||||||
|
@ -34,6 +34,7 @@ private:
|
|||||||
TuningContext *glContext;
|
TuningContext *glContext;
|
||||||
|
|
||||||
std::string helpTip;
|
std::string helpTip;
|
||||||
|
float dragAccum;
|
||||||
//
|
//
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
@ -70,18 +70,42 @@ void TuningContext::DrawDemodFreqBw(long long freq, unsigned int bw, long long c
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFont(fontSize).drawString("Freq: ", -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
getFont(fontSize).drawString("Freq: ", -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
freqStr.str("");
|
if (bw) {
|
||||||
freqStr << std::fixed << freq << "Hz";
|
freqStr.str("");
|
||||||
|
freqStr << std::fixed << freq << "Hz";
|
||||||
|
} else {
|
||||||
|
freqStr.str("---");
|
||||||
|
}
|
||||||
getFont(fontSize).drawString(freqStr.str(), -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
getFont(fontSize).drawString(freqStr.str(), -0.75, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
|
|
||||||
|
glColor3f(0.65, 0.65, 0.65);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex2f(-0.275, -1.0);
|
||||||
|
glVertex2f(-0.275, 1.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
getFont(fontSize).drawString("BW: ", -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
getFont(fontSize).drawString("BW: ", -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
freqStr.str("");
|
if (bw) {
|
||||||
freqStr << std::fixed << bw << "Hz";
|
freqStr.str("");
|
||||||
|
freqStr << std::fixed << bw << "Hz";
|
||||||
|
} else {
|
||||||
|
freqStr.str("---");
|
||||||
|
}
|
||||||
getFont(fontSize).drawString(freqStr.str(), -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
getFont(fontSize).drawString(freqStr.str(), -0.10, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
|
|
||||||
|
glColor3f(0.65, 0.65, 0.65);
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex2f(0.275, -1.0);
|
||||||
|
glVertex2f(0.275, 1.0);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
getFont(fontSize).drawString("CTR: ", 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
getFont(fontSize).drawString("CTR: ", 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
freqStr.str("");
|
if (center) {
|
||||||
freqStr << std::fixed << center << "Hz";
|
freqStr.str("");
|
||||||
|
freqStr << std::fixed << center << "Hz";
|
||||||
|
} else {
|
||||||
|
freqStr.str("---");
|
||||||
|
}
|
||||||
getFont(fontSize).drawString(freqStr.str(), 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
getFont(fontSize).drawString(freqStr.str(), 0.50, 0, fontHeight, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user